Bug #129099: Add option to toggle between full account path and leaf name in registers.

* Introduce new property show_full_account_names to the schema
  general/register to toggle between full account path and leaf name
* Configuration in Preferences dialog  ("Register Defaults")
* Convenience functions gnc_get_account_name_for_register() and
  gnc_account_lookup_for_register() return the proper values depending on the
  configurations.
* Ledgers and registers use the new functions for displaying account names
  (applies also to business-ledger)
* account-quickfill uses gnc_get_account_name_for_register() and listens to
  gconf property

Patch from Christoph Ernst.


git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@17324 57a11ea4-9604-0410-9ed3-97b8803252fd
2.4
Andreas Köhler 18 years ago
parent 7cc810cfef
commit 1a25b2bc39

@ -137,6 +137,7 @@ Tyson Dowd <tyson@tyse.net> for config/make patches & debian maint
Koen D'Hondt <ripley@xs4all.nl> for Solaris patches to XmHTML
Bob Drzyzgula <bob@mostly.com> for budgeting design notes
Volker Englisch <Volker@englisch.us> QA and testing
Christoph Ernst <C.Ernst72@googlemail.com> Small bugfixes and minor enhancements
Jonathan Ernst <jonathan@ernstfamily.ch> Translations
Stephen Evanchik <evanchsa@clarkson.edu> Logging improvements; gtk2 conversions
Joshua Facemyer / Impressus Art <faceman@impressusart.com>: New artwork.

@ -212,6 +212,33 @@ gnc_get_current_commodities (void)
return gnc_book_get_commodity_table (gnc_get_current_book ());
}
gchar *
gnc_get_account_name_for_register(const Account *account)
{
gboolean show_leaf_accounts;
show_leaf_accounts = gnc_gconf_get_bool(GCONF_GENERAL_REGISTER,
KEY_SHOW_LEAF_ACCOUNT_NAMES, NULL);
if (show_leaf_accounts)
return g_strdup (xaccAccountGetName (account));
else
return xaccAccountGetFullName (account);
}
Account *
gnc_account_lookup_for_register(const Account *base_account, const char *name)
{
gboolean show_leaf_accounts;
show_leaf_accounts = gnc_gconf_get_bool(GCONF_GENERAL_REGISTER,
KEY_SHOW_LEAF_ACCOUNT_NAMES, NULL);
if (show_leaf_accounts)
return gnc_account_lookup_by_name (base_account, name);
else
return gnc_account_lookup_by_full_name (base_account, name);
}
/*
* This is a wrapper routine around an xaccGetBalanceInCurrency
* function that handles additional needs of the gui.

@ -57,6 +57,29 @@ QofBook * gnc_get_current_book (void);
Account * gnc_get_current_root_account (void);
gnc_commodity_table * gnc_get_current_commodities (void);
/**
* Get either the full name of the account or the simple name, depending on the
* configuration parameter general/register/show_leaf_account_names.
*
* @param account The account to retrieve the name for.
* @return A newly allocated string.
*/
gchar *gnc_get_account_name_for_register(const Account *account);
/**
* Retrieve the account matching the given name starting from the descandants of
* base_account.
* @a name is either considered to be the name of the leaf in the account tree
* or to be the full account path, depending on the configuration parameter
* general/register/show_leaf_account_names.
*
* @param base_account The account to start the search at.
* @param name The name to search for.
* @return A pointer to the account, or NULL if the account was not found.
*/
Account *gnc_account_lookup_for_register(const Account *base_account, const
gchar *name);
/*
* This is a wrapper routine around an xaccGetBalanceInCurrency
* function that handles additional needs of the gui.

@ -81,12 +81,12 @@ gnc_entry_ledger_get_account_by_name (GncEntryLedger *ledger, BasicCell * bcell,
const char *placeholder = _("The account %s does not allow transactions.");
const char *missing = _("The account %s does not exist. "
"Would you like to create it?");
char *fullname;
char *account_name;
ComboCell *cell = (ComboCell *) bcell;
Account *account;
/* Find the account */
account = gnc_account_lookup_by_full_name (gnc_get_current_root_account (), name);
account = gnc_account_lookup_for_register (gnc_get_current_root_account (), name);
if (!account) {
/* Ask if they want to create a new one. */
@ -103,10 +103,10 @@ gnc_entry_ledger_get_account_by_name (GncEntryLedger *ledger, BasicCell * bcell,
*new = TRUE;
/* Now have a new account. Update the cell with the name as created. */
fullname = xaccAccountGetFullName (account);
gnc_combo_cell_set_value (cell, fullname);
account_name = gnc_get_account_name_for_register (account);
gnc_combo_cell_set_value (cell, account_name);
gnc_basic_cell_set_changed (&cell->cell, TRUE);
g_free (fullname);
g_free (account_name);
}
/* See if the account (either old or new) is a placeholder. */

@ -155,7 +155,7 @@ static const char * get_iacct_entry (VirtualLocation virt_loc,
entry = gnc_entry_ledger_get_entry (ledger, virt_loc.vcell_loc);
g_free (name);
name = xaccAccountGetFullName (gncEntryGetInvAccount (entry));
name = gnc_get_account_name_for_register (gncEntryGetInvAccount (entry));
return name;
}
@ -172,7 +172,7 @@ static const char * get_bacct_entry (VirtualLocation virt_loc,
entry = gnc_entry_ledger_get_entry (ledger, virt_loc.vcell_loc);
g_free (name);
name = xaccAccountGetFullName (gncEntryGetBillAccount (entry));
name = gnc_get_account_name_for_register (gncEntryGetBillAccount (entry));
return name;
}

@ -67,6 +67,7 @@
#define KEY_NUMBER_OF_ROWS "number_of_rows"
#define KEY_ENABLE_EURO "enable_euro"
#define KEY_DATE_FORMAT "date_format"
#define KEY_SHOW_LEAF_ACCOUNT_NAMES "show_leaf_account_names"
typedef void (*GncGconfGeneralCb) (GConfEntry *entry, gpointer user_data);
typedef void (*GncGconfGeneralAnyCb) (gpointer user_data);

@ -40,7 +40,7 @@ static void listen_for_account_events (QofInstance *entity, QofEventId event_t
#define NUM_ACCOUNT_COLUMNS 2
/* ===================================================================== */
/* In order to speed up register starts for registers htat have a huge
/* In order to speed up register starts for registers that have a huge
* number of accounts in them (where 'huge' is >500) we build a quickfill
* cache of account names. This cache is needed because some users on
* some machines experience register open times in the tens of seconds
@ -67,6 +67,9 @@ shared_quickfill_destroy (QofBook *book, gpointer key, gpointer user_data)
gnc_gconf_general_remove_cb(KEY_ACCOUNT_SEPARATOR,
shared_quickfill_gconf_changed,
qfb);
gnc_gconf_general_remove_cb(KEY_SHOW_LEAF_ACCOUNT_NAMES,
shared_quickfill_gconf_changed,
qfb);
gnc_quickfill_destroy (qfb->qf);
g_object_unref(qfb->list_store);
qof_event_unregister_handler (qfb->listener);
@ -118,7 +121,7 @@ load_shared_qf_cb (Account *account, gpointer data)
if (skip) return;
}
name = xaccAccountGetFullName (account);
name = gnc_get_account_name_for_register (account);
if (NULL == name) return;
gnc_quickfill_insert (qfb->qf, name, QUICKFILL_ALPHA);
if (qfb->load_list_store) {
@ -169,6 +172,10 @@ build_shared_quickfill (QofBook *book, Account *root, const char * key,
shared_quickfill_gconf_changed,
qfb);
gnc_gconf_general_register_cb(KEY_SHOW_LEAF_ACCOUNT_NAMES,
shared_quickfill_gconf_changed,
qfb);
gnc_account_foreach_descendant(root, load_shared_qf_cb, qfb);
qfb->load_list_store = FALSE;
@ -248,7 +255,7 @@ listen_for_account_events (QofInstance *entity, QofEventId event_type,
return;
}
name = xaccAccountGetFullName (account);
name = gnc_get_account_name_for_register(account);
if (NULL == name) {
LEAVE("account has no name");
return;
@ -285,9 +292,11 @@ listen_for_account_events (QofInstance *entity, QofEventId event_type,
qfb->dont_add_cb(account, qfb->dont_add_data)) {
gtk_list_store_remove(qfb->list_store, &iter);
} else {
gchar *aname = gnc_get_account_name_for_register(account);
gtk_list_store_set(qfb->list_store, &iter,
ACCOUNT_NAME, xaccAccountGetFullName(account),
ACCOUNT_NAME, aname,
-1);
g_free(aname);
}
}

@ -3116,8 +3116,8 @@
<packing>
<property name="left_attach">0</property>
<property name="right_attach">1</property>
<property name="top_attach">9</property>
<property name="bottom_attach">10</property>
<property name="top_attach">10</property>
<property name="bottom_attach">11</property>
<property name="x_padding">12</property>
<property name="x_options">fill</property>
<property name="y_options"></property>
@ -3146,8 +3146,8 @@
<packing>
<property name="left_attach">0</property>
<property name="right_attach">1</property>
<property name="top_attach">8</property>
<property name="bottom_attach">9</property>
<property name="top_attach">9</property>
<property name="bottom_attach">10</property>
<property name="x_padding">12</property>
<property name="x_options">fill</property>
<property name="y_options"></property>
@ -3170,8 +3170,8 @@
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">8</property>
<property name="bottom_attach">9</property>
<property name="top_attach">9</property>
<property name="bottom_attach">10</property>
<property name="x_options"></property>
<property name="y_options"></property>
</packing>
@ -3225,6 +3225,30 @@
</packing>
</child>
<child>
<widget class="GtkCheckButton" id="gconf/general/register/show_leaf_account_names">
<property name="visible">True</property>
<property name="tooltip" translatable="yes">If checked, only the names of the leaf accounts are displayed in the register and in the account selection popup. The default behaviour is to display the full name, including the path in the account tree. Cecking this option implies that you use unique leaf names.</property>
<property name="can_focus">True</property>
<property name="label" translatable="yes">_Only display leaf account names</property>
<property name="use_underline">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property>
<property name="focus_on_click">True</property>
<property name="active">False</property>
<property name="inconsistent">False</property>
<property name="draw_indicator">True</property>
</widget>
<packing>
<property name="left_attach">0</property>
<property name="right_attach">4</property>
<property name="top_attach">8</property>
<property name="bottom_attach">9</property>
<property name="x_padding">12</property>
<property name="x_options">fill</property>
<property name="y_options"></property>
</packing>
</child>
<child>
<widget class="GtkSpinButton" id="gconf/general/register/number_of_rows">
<property name="visible">True</property>
@ -3241,8 +3265,8 @@
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">9</property>
<property name="bottom_attach">10</property>
<property name="top_attach">10</property>
<property name="bottom_attach">11</property>
<property name="x_options">fill</property>
<property name="y_options"></property>
</packing>

@ -451,6 +451,23 @@
</locale>
</schema>
<schema>
<key>/schemas/apps/gnucash/general/register/show_leaf_account_names</key>
<applyto>/apps/gnucash/general/register/show_leaf_account_names</applyto>
<owner>gnucash</owner>
<type>bool</type>
<default>FALSE</default>
<locale name="C">
<short>Only display leaf account names.</short>
<long>
Show only the names of the leaf accounts in the register and in the
account selection popup. The default behaviour is to display the full
name, including the path in the account tree. Activating this option
implies that you use unique leaf names.
</long>
</locale>
</schema>
<schema>
<key>/schemas/apps/gnucash/general/register/number_of_rows</key>
<applyto>/apps/gnucash/general/register/number_of_rows</applyto>

@ -750,7 +750,7 @@ gnc_split_register_auto_completion (SplitRegister *reg,
case CURSOR_CLASS_SPLIT:
{
char *fullname;
char *account_name;
const char *memo;
gboolean unit_price;
Split *auto_split;
@ -820,9 +820,9 @@ gnc_split_register_auto_completion (SplitRegister *reg,
/* auto-complete the account name */
cell = gnc_table_layout_get_cell (reg->table->layout, XFRM_CELL);
fullname = xaccAccountGetFullName (xaccSplitGetAccount (auto_split));
gnc_combo_cell_set_value ((ComboCell *) cell, fullname);
g_free(fullname);
account_name = gnc_get_account_name_for_register (xaccSplitGetAccount (auto_split));
gnc_combo_cell_set_value ((ComboCell *) cell, account_name);
g_free(account_name);
gnc_basic_cell_set_changed (cell, TRUE);

@ -82,7 +82,7 @@ gnc_split_register_use_security_cells (SplitRegister *reg,
const char *name;
name = gnc_table_layout_get_cell_value (reg->table->layout, XFRM_CELL);
account = gnc_account_lookup_by_full_name (gnc_get_current_root_account (), name);
account = gnc_account_lookup_for_register (gnc_get_current_root_account (), name);
}
if (!account)
@ -1205,7 +1205,7 @@ gnc_split_register_get_xfrm_entry (VirtualLocation virt_loc,
g_free (name);
name = xaccAccountGetFullName (xaccSplitGetAccount (split));
name = gnc_get_account_name_for_register (xaccSplitGetAccount (split));
return name;
}
@ -1246,7 +1246,7 @@ gnc_split_register_get_mxfrm_entry (VirtualLocation virt_loc,
g_free (name);
if (s)
name = xaccAccountGetFullName (xaccSplitGetAccount (s));
name = gnc_get_account_name_for_register (xaccSplitGetAccount (s));
else
{
/* For multi-split transactions and stock splits,
@ -1737,7 +1737,7 @@ gnc_template_register_get_xfrm_entry (VirtualLocation virt_loc,
account = xaccAccountLookup (guid, gnc_get_current_book ());
name = account ? xaccAccountGetFullName(account) : NULL;
name = account ? gnc_get_account_name_for_register (account) : NULL;
}
else
name = NULL;

@ -1498,7 +1498,7 @@ gnc_split_register_get_account_by_name (SplitRegister *reg, BasicCell * bcell,
const char *placeholder = _("The account %s does not allow transactions.");
const char *missing = _("The account %s does not exist. "
"Would you like to create it?");
char *fullname;
char *account_name;
ComboCell *cell = (ComboCell *) bcell;
Account *account;
@ -1506,7 +1506,7 @@ gnc_split_register_get_account_by_name (SplitRegister *reg, BasicCell * bcell,
return NULL;
/* Find the account */
account = gnc_account_lookup_by_full_name (gnc_get_current_root_account (), name);
account = gnc_account_lookup_for_register (gnc_get_current_root_account (), name);
if (!account)
account = gnc_account_lookup_by_code (gnc_get_current_root_account (), name);
@ -1525,10 +1525,10 @@ gnc_split_register_get_account_by_name (SplitRegister *reg, BasicCell * bcell,
/* Now have the account. Update the cell with the name as created. */
*refresh = TRUE;
fullname = xaccAccountGetFullName (account);
gnc_combo_cell_set_value (cell, fullname);
account_name = gnc_get_account_name_for_register (account);
gnc_combo_cell_set_value (cell, account_name);
gnc_basic_cell_set_changed (&cell->cell, TRUE);
g_free (fullname);
g_free (account_name);
/* See if the account (either old or new) is a placeholder. */
if (xaccAccountGetPlaceholder (account)) {

Loading…
Cancel
Save