mirror of
https://github.com/Gnucash/gnucash.git
synced 2026-09-03 20:53:02 -05:00
Bug 773945 - Select Security Dialog Not User Friendly
Add a new namespace “ALL NON-CURRENCY” to the namespace (type) selector lists on the security picker and price editor which causes the commodity list to include all non-security commodities.
This commit is contained in:
@@ -33,3 +33,5 @@
|
||||
(define GNC_COMMODITY_NS_NASDAQ "NASDAQ")
|
||||
(define GNC_COMMODITY_NS_EUREX "EUREX")
|
||||
(define GNC_COMMODITY_NS_MUTUAL "FUND")
|
||||
(define GNC_COMMODITY_NS_ASX "ASX")
|
||||
(define GNC_COMMODITY_NS_NONCURRENCY (gettext "ALL NON-CURRENCY"))
|
||||
|
||||
@@ -2100,6 +2100,26 @@ gnc_commodity_is_currency(const gnc_commodity *cm)
|
||||
* list commodities in a give namespace
|
||||
********************************************************************/
|
||||
|
||||
static CommodityList*
|
||||
commodity_table_get_all_noncurrency_commodities(const gnc_commodity_table* table)
|
||||
{
|
||||
GList *node = NULL, *nslist = gnc_commodity_table_get_namespaces(table);
|
||||
CommodityList *retval = NULL;
|
||||
for (node = nslist; node; node=g_list_next(node))
|
||||
{
|
||||
gnc_commodity_namespace *ns = NULL;
|
||||
if (g_strcmp0((char*)(node->data), GNC_COMMODITY_NS_CURRENCY) == 0
|
||||
|| g_strcmp0((char*)(node->data), "template") == 0)
|
||||
continue;
|
||||
ns = gnc_commodity_table_find_namespace(table, (char*)(node->data));
|
||||
if (!ns)
|
||||
continue;
|
||||
retval = g_list_concat(g_hash_table_values(ns->cm_table), retval);
|
||||
}
|
||||
g_list_free(nslist);
|
||||
return retval;
|
||||
}
|
||||
|
||||
CommodityList *
|
||||
gnc_commodity_table_get_commodities(const gnc_commodity_table * table,
|
||||
const char * name_space)
|
||||
@@ -2108,7 +2128,8 @@ gnc_commodity_table_get_commodities(const gnc_commodity_table * table,
|
||||
|
||||
if (!table)
|
||||
return NULL;
|
||||
|
||||
if (g_strcmp0(name_space, GNC_COMMODITY_NS_NONCURRENCY) == 0)
|
||||
return commodity_table_get_all_noncurrency_commodities(table);
|
||||
ns = gnc_commodity_table_find_namespace(table, name_space);
|
||||
if (!ns)
|
||||
return NULL;
|
||||
|
||||
@@ -104,6 +104,7 @@ GType gnc_commodity_namespace_get_type(void);
|
||||
#define GNC_COMMODITY_NS_MUTUAL "FUND"
|
||||
#define GNC_COMMODITY_NS_AMEX "AMEX"
|
||||
#define GNC_COMMODITY_NS_ASX "ASX"
|
||||
#define GNC_COMMODITY_NS_NONCURRENCY _("ALL NON-CURRENCY")
|
||||
|
||||
typedef GList CommodityList;
|
||||
|
||||
|
||||
@@ -188,7 +188,7 @@ gnc_account_commodity_from_type (AccountWindow * aw, gboolean update)
|
||||
if (aw->type == ACCT_TYPE_TRADING)
|
||||
new_mode = DIAG_COMM_ALL;
|
||||
else if ((aw->type == ACCT_TYPE_STOCK) || (aw->type == ACCT_TYPE_MUTUAL))
|
||||
new_mode = DIAG_COMM_NON_CURRENCY;
|
||||
new_mode = DIAG_COMM_NON_CURRENCY_SELECT;
|
||||
else
|
||||
new_mode = DIAG_COMM_CURRENCY;
|
||||
|
||||
|
||||
@@ -285,6 +285,7 @@ gnc_ui_select_commodity_create(const gnc_commodity * orig_sel,
|
||||
text = _("_Security/currency:");
|
||||
break;
|
||||
case DIAG_COMM_NON_CURRENCY:
|
||||
case DIAG_COMM_NON_CURRENCY_SELECT:
|
||||
title = _("Select security");
|
||||
text = _("_Security:");
|
||||
break;
|
||||
@@ -664,6 +665,7 @@ gnc_ui_update_namespace_picker (GtkWidget *cbwe,
|
||||
break;
|
||||
|
||||
case DIAG_COMM_NON_CURRENCY:
|
||||
case DIAG_COMM_NON_CURRENCY_SELECT:
|
||||
namespaces =
|
||||
gnc_commodity_table_get_namespaces (gnc_get_current_commodities());
|
||||
node = g_list_find_custom (namespaces, GNC_COMMODITY_NS_CURRENCY, collate);
|
||||
@@ -682,7 +684,13 @@ gnc_ui_update_namespace_picker (GtkWidget *cbwe,
|
||||
namespaces = g_list_prepend (NULL, GNC_COMMODITY_NS_CURRENCY);
|
||||
break;
|
||||
}
|
||||
|
||||
/* First insert "ALL" */
|
||||
if (mode == DIAG_COMM_NON_CURRENCY_SELECT || mode == DIAG_COMM_ALL)
|
||||
{
|
||||
gtk_list_store_append(GTK_LIST_STORE(model), &iter);
|
||||
gtk_list_store_set (GTK_LIST_STORE(model), &iter, 0,
|
||||
GNC_COMMODITY_NS_NONCURRENCY, -1);
|
||||
}
|
||||
/* add them to the combobox */
|
||||
namespaces = g_list_sort(namespaces, collate);
|
||||
for (node = namespaces; node; node = node->next)
|
||||
|
||||
@@ -49,6 +49,10 @@ typedef enum
|
||||
of a currency. */
|
||||
DIAG_COMM_NON_CURRENCY, /**< Dialog box should allow selection of
|
||||
anything but a currency. */
|
||||
DIAG_COMM_NON_CURRENCY_SELECT, /**< Dialog box should allow selection of
|
||||
* anything but a currency and should include
|
||||
* the "ALL" namespace to display all such
|
||||
* commodities in a single list. */
|
||||
DIAG_COMM_ALL, /**< Dialog box should allow selection of
|
||||
anything. */
|
||||
} dialog_commodity_mode;
|
||||
|
||||
Reference in New Issue
Block a user