From a934c41ef45ef7551ea4b88cb74f46f9aef4337b Mon Sep 17 00:00:00 2001 From: jean Date: Sat, 28 Mar 2020 12:02:14 -0700 Subject: [PATCH] Finish removing preference, re-nice the code --- gnucash/gnome-utils/account-quickfill.c | 5 ++--- .../register/ledger-core/gncEntryLedgerLoad.c | 4 ++-- .../register/register-gnome/combocell-gnome.c | 20 +++++++++---------- 3 files changed, 14 insertions(+), 15 deletions(-) diff --git a/gnucash/gnome-utils/account-quickfill.c b/gnucash/gnome-utils/account-quickfill.c index 8af848b93d..f7e18dbba1 100644 --- a/gnucash/gnome-utils/account-quickfill.c +++ b/gnucash/gnome-utils/account-quickfill.c @@ -54,8 +54,8 @@ typedef struct QuickFill *qf; gboolean load_list_store; GtkListStore *list_store; - // For the type-ahead search, we need two lists, list_store contains the accounts that - // match the search. list_store_full contain the original full list of accounts. + /* For the type-ahead search, we need two lists, list_store contains the accounts that + match the search. list_store_full contain the original full list of accounts. */ GtkListStore *list_store_full; QofBook *book; Account *root; @@ -124,7 +124,6 @@ load_shared_qf_cb (Account *account, gpointer data) char *name; GtkTreeIter iter; - // A callback to disable adding the account if (qfb->dont_add_cb) { gboolean skip = (qfb->dont_add_cb) (account, qfb->dont_add_data); diff --git a/gnucash/register/ledger-core/gncEntryLedgerLoad.c b/gnucash/register/ledger-core/gncEntryLedgerLoad.c index cb1dc6f13e..2372008a19 100644 --- a/gnucash/register/ledger-core/gncEntryLedgerLoad.c +++ b/gnucash/register/ledger-core/gncEntryLedgerLoad.c @@ -217,7 +217,7 @@ load_xfer_type_cells (GncEntryLedger *ledger) store = gnc_get_shared_account_name_list_store (root, IKEY, skip_expense_acct_cb, NULL); store_full = gnc_get_shared_account_name_list_store_full (root, IKEY, - skip_expense_acct_cb, NULL); + skip_expense_acct_cb, NULL); break; case GNCENTRY_BILL_ENTRY: @@ -234,7 +234,7 @@ load_xfer_type_cells (GncEntryLedger *ledger) store = gnc_get_shared_account_name_list_store (root, EKEY, skip_income_acct_cb, NULL); store_full = gnc_get_shared_account_name_list_store_full (root, EKEY, - skip_income_acct_cb, NULL); + skip_income_acct_cb, NULL); break; default: PWARN ("Bad GncEntryLedgerType"); diff --git a/gnucash/register/register-gnome/combocell-gnome.c b/gnucash/register/register-gnome/combocell-gnome.c index 2cdfd1fa7b..2a6eedcb93 100644 --- a/gnucash/register/register-gnome/combocell-gnome.c +++ b/gnucash/register/register-gnome/combocell-gnome.c @@ -90,7 +90,6 @@ static GOnce auto_pop_init_once = G_ONCE_INIT; static gboolean auto_pop_combos = FALSE; -// Two Callbacks called when the user changes preferences static void gnc_combo_cell_set_autopop (gpointer prefs, gchar *pref, gpointer user_data) { @@ -104,12 +103,12 @@ gnc_combo_cell_autopop_init (gpointer unused) gulong id; auto_pop_combos = gnc_prefs_get_bool (GNC_PREFS_GROUP_GENERAL_REGISTER, GNC_PREF_AUTO_RAISE_LISTS); - - // Register callbacks for when the user changes preferences. + id = gnc_prefs_register_cb (GNC_PREFS_GROUP_GENERAL_REGISTER, - GNC_PREF_AUTO_RAISE_LISTS, - gnc_combo_cell_set_autopop, - NULL); + GNC_PREF_AUTO_RAISE_LISTS, + gnc_combo_cell_set_autopop, + NULL); + gnc_prefs_set_reg_auto_raise_lists_id (id); return NULL; } @@ -519,10 +518,13 @@ gnc_combo_cell_type_ahead_search(const gchar* newval, GtkListStore* full_store, GMatchInfo *match_info = NULL; GRegex *regex = NULL; gchar *rep_str = NULL; + gchar *newval_rep = NULL; GRegex *regex0 = g_regex_new (gnc_get_account_separator_string(), 0, 0, &gerror); // Replace ":" in newval with ".*:.*" so we can use regexp to match. - rep_str = g_regex_replace (regex0,newval,-1,0,".*:.*",0,&gerror); + newval_rep = g_strconcat (".*", gnc_get_account_separator_string(), ".*", + NULL); + rep_str = g_regex_replace (regex0, newval, -1, 0, newval_rep, 0, &gerror); // Then compile the regular expression based on rep_str. regex = g_regex_new (rep_str, G_REGEX_CASELESS, 0, &gerror); @@ -555,6 +557,7 @@ gnc_combo_cell_type_ahead_search(const gchar* newval, GtkListStore* full_store, g_regex_unref(regex); g_regex_unref(regex0); g_free(rep_str); + g_free(newval_rep); return match_str; } @@ -589,8 +592,6 @@ gnc_combo_cell_modify_verify (BasicCell *_cell, return; } - // JEAN: If change == ":" do an autocompletion: if there's only 1 account that is currently matched - // Try the start-of-name match using the quickfill match = gnc_quickfill_get_string_match (box->qf, newval); match_str = g_strdup(gnc_quickfill_string (match)); @@ -736,7 +737,6 @@ gnc_combo_cell_direct_update (BasicCell *bcell, (*end_selection < bcell->value_chars)) return FALSE; - // JEAN: WHERE : IS MATCHED find_pos = -1; if (*start_selection < bcell->value_chars) {