gnucash master: Multiple changes pushed

John Ralls jralls at code.gnucash.org
Thu May 7 15:06:01 EDT 2020


Updated	 via  https://github.com/Gnucash/gnucash/commit/6141592d (commit)
	 via  https://github.com/Gnucash/gnucash/commit/534bcd6c (commit)
	from  https://github.com/Gnucash/gnucash/commit/650f7901 (commit)



commit 6141592d404bdb38db9bcfbd0a45bc989b53944a
Author: John Ralls <jralls at ceridwen.us>
Date:   Thu May 7 11:22:42 2020 -0700

    Don't mutate the cached global account list store.
    
    That defeats the purpose of caching it and causes problems when using it
    from two registers at once. Instead use the PopBox tmp_store for listing
    the type-ahead match results if any.
    
    Since a no-match causes an empty ItemList and an empty ItemList with
    grab loses key events because there's no cell to handle them--very
    confusing to the user--prevent that by checking that there are entries
    before grabbing.

diff --git a/gnucash/gnome-utils/account-quickfill.c b/gnucash/gnome-utils/account-quickfill.c
index 7fb639bb4..f28e91725 100644
--- a/gnucash/gnome-utils/account-quickfill.c
+++ b/gnucash/gnome-utils/account-quickfill.c
@@ -56,9 +56,6 @@ 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. */
-    GtkListStore* list_store_full;
     QofBook* book;
     Account* root;
     gint  listener;
@@ -80,7 +77,6 @@ shared_quickfill_destroy (QofBook* book, gpointer key, gpointer user_data)
                                  qfb);
     gnc_quickfill_destroy (qfb->qf);
     g_object_unref (qfb->list_store);
-    g_object_unref (qfb->list_store_full);
     qof_event_unregister_handler (qfb->listener);
     g_free (qfb);
 }
@@ -144,11 +140,6 @@ load_shared_qf_cb (Account* account, gpointer data)
                             ACCOUNT_NAME, name,
                             ACCOUNT_POINTER, account,
                             -1);
-        gtk_list_store_append (qfb->list_store_full, &iter);
-        gtk_list_store_set (qfb->list_store_full, &iter,
-                            ACCOUNT_NAME, name,
-                            ACCOUNT_POINTER, account,
-                            -1);
     }
     g_free (name);
 }
@@ -162,7 +153,6 @@ shared_quickfill_pref_changed (gpointer prefs, gchar* pref, gpointer user_data)
     /* Reload the quickfill */
     gnc_quickfill_purge (qfb->qf);
     gtk_list_store_clear (qfb->list_store);
-    gtk_list_store_clear (qfb->list_store_full);
     qfb->load_list_store = TRUE;
     gnc_account_foreach_descendant (qfb->root, load_shared_qf_cb, qfb);
     qfb->load_list_store = FALSE;
@@ -188,8 +178,6 @@ build_shared_quickfill (QofBook* book, Account* root, const char* key,
     qfb->load_list_store = TRUE;
     qfb->list_store      = gtk_list_store_new (NUM_ACCOUNT_COLUMNS,
                                                G_TYPE_STRING, G_TYPE_POINTER);
-    qfb->list_store_full = gtk_list_store_new (NUM_ACCOUNT_COLUMNS,
-                                               G_TYPE_STRING, G_TYPE_POINTER);
 
     gnc_prefs_register_cb (GNC_PREFS_GROUP_GENERAL,
                            GNC_PREF_ACCOUNT_SEPARATOR,
@@ -245,23 +233,6 @@ gnc_get_shared_account_name_list_store (Account* root, const char* key,
     return qfb->list_store;
 }
 
-GtkListStore*
-gnc_get_shared_account_name_list_store_full (Account* root, const char* key,
-                                             AccountBoolCB cb, gpointer cb_data)
-{
-    QFB* qfb;
-    QofBook* book;
-
-    book = gnc_account_get_book (root);
-    qfb = qof_book_get_data (book, key);
-
-    if (qfb)
-        return qfb->list_store_full;
-
-    qfb = build_shared_quickfill (book, root, key, cb, cb_data);
-    return qfb->list_store_full;
-}
-
 /* Since we are maintaining a 'global' quickfill list, we need to
  * update it whenever the user creates a new account.  So listen
  * for account modification events, and add new accounts.
@@ -314,7 +285,7 @@ listen_for_account_events (QofInstance* entity, QofEventId event_type,
          * full name of all these accounts has changed. */
         data.accounts = gnc_account_get_descendants (account);
         data.accounts = g_list_prepend (data.accounts, account);
-        gtk_tree_model_foreach (GTK_TREE_MODEL (qfb->list_store_full),
+        gtk_tree_model_foreach (GTK_TREE_MODEL (qfb->list_store),
                                 shared_quickfill_find_accounts, &data);
 
         /* Update the existing items in the list store.  Its possible
@@ -326,14 +297,14 @@ listen_for_account_events (QofInstance* entity, QofEventId event_type,
             gchar* old_name, *new_name;
             path = gtk_tree_row_reference_get_path (tmp->data);
             gtk_tree_row_reference_free (tmp->data);
-            if (!gtk_tree_model_get_iter (GTK_TREE_MODEL (qfb->list_store_full),
+            if (!gtk_tree_model_get_iter (GTK_TREE_MODEL (qfb->list_store),
                                           &iter, path))
             {
                 gtk_tree_path_free (path);
                 continue;
             }
             gtk_tree_path_free (path);
-            gtk_tree_model_get (GTK_TREE_MODEL (qfb->list_store_full), &iter,
+            gtk_tree_model_get (GTK_TREE_MODEL (qfb->list_store), &iter,
                                 ACCOUNT_POINTER, &account,
                                 ACCOUNT_NAME, &old_name,
                                 -1);
@@ -349,12 +320,12 @@ listen_for_account_events (QofInstance* entity, QofEventId event_type,
                 qfb->dont_add_cb (account, qfb->dont_add_data))
             {
                 gnc_quickfill_remove (qf, new_name, QUICKFILL_ALPHA);
-                gtk_list_store_remove (qfb->list_store_full, &iter);
+                gtk_list_store_remove (qfb->list_store, &iter);
             }
             else
             {
                 gnc_quickfill_insert (qf, new_name, QUICKFILL_ALPHA);
-                gtk_list_store_set (qfb->list_store_full, &iter,
+                gtk_list_store_set (qfb->list_store, &iter,
                                     ACCOUNT_NAME, new_name,
                                     -1);
             }
@@ -376,8 +347,8 @@ listen_for_account_events (QofInstance* entity, QofEventId event_type,
                 }
             }
             gnc_quickfill_insert (qf, name, QUICKFILL_ALPHA);
-            gtk_list_store_append (qfb->list_store_full, &iter);
-            gtk_list_store_set (qfb->list_store_full, &iter,
+            gtk_list_store_append (qfb->list_store, &iter);
+            gtk_list_store_set (qfb->list_store, &iter,
                                 ACCOUNT_NAME, name,
                                 ACCOUNT_POINTER, account,
                                 -1);
@@ -392,7 +363,7 @@ listen_for_account_events (QofInstance* entity, QofEventId event_type,
 
         /* Does the account exist in the model? */
         data.accounts = g_list_append (NULL, account);
-        gtk_tree_model_foreach (GTK_TREE_MODEL (qfb->list_store_full),
+        gtk_tree_model_foreach (GTK_TREE_MODEL (qfb->list_store),
                                 shared_quickfill_find_accounts, &data);
 
         /* Remove from list store */
@@ -400,10 +371,10 @@ listen_for_account_events (QofInstance* entity, QofEventId event_type,
         {
             path = gtk_tree_row_reference_get_path (tmp->data);
             gtk_tree_row_reference_free (tmp->data);
-            if (gtk_tree_model_get_iter (GTK_TREE_MODEL (qfb->list_store_full),
+            if (gtk_tree_model_get_iter (GTK_TREE_MODEL (qfb->list_store),
                                          &iter, path))
             {
-                gtk_list_store_remove (qfb->list_store_full, &iter);
+                gtk_list_store_remove (qfb->list_store, &iter);
             }
             gtk_tree_path_free (path);
         }
@@ -429,8 +400,8 @@ listen_for_account_events (QofInstance* entity, QofEventId event_type,
 
         PINFO ("insert new account %s into qf=%p", name, qf);
         gnc_quickfill_insert (qf, name, QUICKFILL_ALPHA);
-        gtk_list_store_append (qfb->list_store_full, &iter);
-        gtk_list_store_set (qfb->list_store_full, &iter,
+        gtk_list_store_append (qfb->list_store, &iter);
+        gtk_list_store_set (qfb->list_store, &iter,
                             ACCOUNT_NAME, name,
                             ACCOUNT_POINTER, account,
                             -1);
@@ -440,25 +411,6 @@ listen_for_account_events (QofInstance* entity, QofEventId event_type,
         DEBUG ("other %s", name);
         break;
     }
-    /* Now that qfb->list_store_full has been updated, qfb->list_store also needs to be updated in
-    case we're using the regular search. */
-    gtk_list_store_clear (qfb->list_store);
-
-    g_debug ("Replicate shared_store_full\n");
-    valid = gtk_tree_model_get_iter_first (GTK_TREE_MODEL (qfb->list_store_full),
-                                           &iter);
-    while (valid)
-    {
-        gchar* str_data = NULL;
-        GtkTreeIter iter2;
-        gtk_tree_model_get (GTK_TREE_MODEL (qfb->list_store_full), &iter, 0, &str_data,
-                            -1);
-        gtk_list_store_append (qfb->list_store, &iter2);
-        gtk_list_store_set (qfb->list_store, &iter2, 0, str_data, -1);
-        valid = gtk_tree_model_iter_next (GTK_TREE_MODEL (qfb->list_store_full),
-                                          &iter);
-        g_free (str_data);
-    }
 
     if (data.accounts)
         g_list_free (data.accounts);
diff --git a/gnucash/gnome-utils/account-quickfill.h b/gnucash/gnome-utils/account-quickfill.h
index aeac65cb0..97ea2a0b4 100644
--- a/gnucash/gnome-utils/account-quickfill.h
+++ b/gnucash/gnome-utils/account-quickfill.h
@@ -74,9 +74,6 @@ gnc_get_shared_account_name_quickfill (Account* root, const char* key,
 GtkListStore*
 gnc_get_shared_account_name_list_store (Account* root, const char* key,
                                         AccountBoolCB cb, gpointer cb_data);
-GtkListStore*
-gnc_get_shared_account_name_list_store_full (Account* root, const char* key,
-                                             AccountBoolCB cb, gpointer cb_data);
 
 #endif
 
diff --git a/gnucash/register/ledger-core/gncEntryLedgerLoad.c b/gnucash/register/ledger-core/gncEntryLedgerLoad.c
index f62bfaacf..b8972b724 100644
--- a/gnucash/register/ledger-core/gncEntryLedgerLoad.c
+++ b/gnucash/register/ledger-core/gncEntryLedgerLoad.c
@@ -195,7 +195,6 @@ load_xfer_type_cells (GncEntryLedger* ledger)
     ComboCell* cell;
     QuickFill* qf = NULL;
     GtkListStore* store = NULL;
-    GtkListStore* store_full = NULL;
 
     root = gnc_book_get_root_account (ledger->book);
     if (root == NULL) return;
@@ -216,8 +215,6 @@ load_xfer_type_cells (GncEntryLedger* ledger)
                                                     skip_expense_acct_cb, NULL);
         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);
         break;
 
     case GNCENTRY_BILL_ENTRY:
@@ -232,9 +229,8 @@ load_xfer_type_cells (GncEntryLedger* ledger)
         qf = gnc_get_shared_account_name_quickfill (root, EKEY,
                                                     skip_income_acct_cb, NULL);
         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");
@@ -244,12 +240,12 @@ load_xfer_type_cells (GncEntryLedger* ledger)
     cell = (ComboCell*)
            gnc_table_layout_get_cell (ledger->table->layout, ENTRY_IACCT_CELL);
     gnc_combo_cell_use_quickfill_cache (cell, qf);
-    gnc_combo_cell_use_list_store_cache (cell, store, store_full);
+    gnc_combo_cell_use_list_store_cache (cell, store);
 
     cell = (ComboCell*)
            gnc_table_layout_get_cell (ledger->table->layout, ENTRY_BACCT_CELL);
     gnc_combo_cell_use_quickfill_cache (cell, qf);
-    gnc_combo_cell_use_list_store_cache (cell, store, store_full);
+    gnc_combo_cell_use_list_store_cache (cell, store);
 }
 
 /* ===================================================================== */
diff --git a/gnucash/register/ledger-core/split-register-load.c b/gnucash/register/ledger-core/split-register-load.c
index d49fc75c5..10385c24d 100644
--- a/gnucash/register/ledger-core/split-register-load.c
+++ b/gnucash/register/ledger-core/split-register-load.c
@@ -813,7 +813,6 @@ gnc_split_register_load_xfer_cells (SplitRegister* reg, Account* base_account)
     QuickFill* qf;
     ComboCell* cell;
     GtkListStore* store;
-    GtkListStore* store_full;
 
     if (base_account)
         root = gnc_account_get_root (base_account);
@@ -824,18 +823,16 @@ gnc_split_register_load_xfer_cells (SplitRegister* reg, Account* base_account)
 
     qf = gnc_get_shared_account_name_quickfill (root, QKEY, skip_cb, NULL);
     store = gnc_get_shared_account_name_list_store (root, QKEY, skip_cb, NULL);
-    store_full = gnc_get_shared_account_name_list_store_full (root, QKEY, skip_cb,
-                                                              NULL);
 
     cell = (ComboCell*)
            gnc_table_layout_get_cell (reg->table->layout, XFRM_CELL);
     gnc_combo_cell_use_quickfill_cache (cell, qf);
-    gnc_combo_cell_use_list_store_cache (cell, store, store_full);
+    gnc_combo_cell_use_list_store_cache (cell, store);
 
     cell = (ComboCell*)
            gnc_table_layout_get_cell (reg->table->layout, MXFRM_CELL);
     gnc_combo_cell_use_quickfill_cache (cell, qf);
-    gnc_combo_cell_use_list_store_cache (cell, store, store_full);
+    gnc_combo_cell_use_list_store_cache (cell, store);
 }
 
 /* ====================== END OF FILE ================================== */
diff --git a/gnucash/register/register-core/combocell.h b/gnucash/register/register-core/combocell.h
index f333aebd3..ceeb7b7dd 100644
--- a/gnucash/register/register-core/combocell.h
+++ b/gnucash/register/register-core/combocell.h
@@ -49,7 +49,6 @@ typedef struct
 {
     BasicCell cell;
     gpointer shared_store;
-    gpointer shared_store_full;
 } ComboCell;
 
 
@@ -103,8 +102,7 @@ void         gnc_combo_cell_set_autosize (ComboCell* cell, gboolean autosize);
  */
 void gnc_combo_cell_use_quickfill_cache (ComboCell* cell,
                                          QuickFill* shared_qf);
-void gnc_combo_cell_use_list_store_cache (ComboCell* cell, gpointer data,
-                                          gpointer data2);
+void gnc_combo_cell_use_list_store_cache (ComboCell* cell, gpointer data);
 
 /** @} */
 #endif
diff --git a/gnucash/register/register-gnome/combocell-gnome.c b/gnucash/register/register-gnome/combocell-gnome.c
index 5c0fea753..9d798302d 100644
--- a/gnucash/register/register-gnome/combocell-gnome.c
+++ b/gnucash/register/register-gnome/combocell-gnome.c
@@ -151,7 +151,6 @@ gnc_combo_cell_init (ComboCell* cell)
     box->list_popped = FALSE;
     box->autosize = FALSE;
 
-    cell->shared_store_full = NULL;
     cell->cell.gui_private = box;
 
     box->qf = gnc_quickfill_new();
@@ -386,7 +385,8 @@ gnc_combo_cell_clear_menu (ComboCell* cell)
         block_list_signals (cell);
 
         gnc_item_list_clear (box->item_list);
-
+        gnc_item_edit_hide_popup (box->item_edit);
+        box->list_popped = FALSE;
         unblock_list_signals (cell);
     }
     else
@@ -412,13 +412,11 @@ gnc_combo_cell_use_quickfill_cache (ComboCell* cell, QuickFill* shared_qf)
 }
 
 void
-gnc_combo_cell_use_list_store_cache (ComboCell* cell, gpointer data,
-                                     gpointer data_full)
+gnc_combo_cell_use_list_store_cache (ComboCell* cell, gpointer data)
 {
     if (cell == NULL) return;
 
     cell->shared_store = data;
-    cell->shared_store_full = data_full;
 }
 
 void
@@ -508,65 +506,87 @@ gnc_combo_cell_set_value (ComboCell* cell, const char* str)
     gnc_basic_cell_set_value (&cell->cell, str);
 }
 
-/* This function looks through full_store for a partial match with newval and returns the first
- match (which must be subsequently freed). It fills out box->item_list with found matches */
+static inline void
+list_store_append (GtkListStore *store, char* string)
+{
+    GtkTreeIter iter;
+
+    g_return_if_fail (store != NULL);
+    g_return_if_fail (string != NULL);
+    gtk_list_store_append (store, &iter);
+    gtk_list_store_set (store, &iter, 0, string, -1);
+}
+
+/* This function looks through full_store for a partial match with newval and
+ * returns the first match (which must be subsequently freed). It fills out
+ * box->item_list with found matches.
+ */
 static gchar*
 gnc_combo_cell_type_ahead_search (const gchar* newval,
                                   GtkListStore* full_store, PopBox* box)
 {
     GtkTreeIter iter;
-    gboolean valid;
     int num_found = 0;
-    gchar* first_found = NULL;
     gchar* match_str = NULL;
-    GError* gerror = NULL;
-    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.
-    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);
-
-    valid = gtk_tree_model_get_iter_first (GTK_TREE_MODEL (full_store), &iter);
-    // Clear result list.
-    gnc_item_list_clear (box->item_list);
-    while (valid)
+    const char* sep = gnc_get_account_separator_string ();
+    gchar* newval_rep = g_strdup_printf (".*%s.*", sep);
+    GRegex* regex0 = g_regex_new (sep, 0, 0, NULL);
+    char* rep_str = g_regex_replace_literal (regex0, newval, -1, 0,
+                                             newval_rep, 0, NULL);
+    GRegex *regex = g_regex_new (rep_str, G_REGEX_CASELESS, 0, NULL);
+
+    gboolean valid = gtk_tree_model_get_iter_first (GTK_TREE_MODEL (full_store),
+                                                    &iter);
+
+    /* Limit the number found to keep the combo box from getting unreasonably
+     * large.
+     */
+    static const gint MAX_NUM_MATCHES = 30;
+
+    g_free (rep_str);
+    g_free (newval_rep);
+    g_regex_unref (regex0);
+
+    gtk_list_store_clear (box->tmp_store);
+
+    while (valid && num_found < MAX_NUM_MATCHES)
     {
-        static const gint MAX_NUM_MATCHES = 30;
         gchar* str_data = NULL;
         gchar* normalized_str_data = NULL;
-        gtk_tree_model_get (GTK_TREE_MODEL (full_store), &iter, 0, &str_data, -1);
+        gtk_tree_model_get (GTK_TREE_MODEL (full_store), &iter, 0,
+                            &str_data, -1);
         normalized_str_data = g_utf8_normalize (str_data, -1, G_NORMALIZE_ALL);
 
         if (g_regex_match (regex, normalized_str_data, 0, NULL))
         {
-            if (!num_found) first_found = g_strdup (str_data);
+            if (!num_found)
+                match_str = g_strdup (str_data);
             ++num_found;
-            /* The pop box can be very slow to display if it has too many items and it's not very useful
-             to have many. So limit that to a reasonable number. */
-            if (num_found < MAX_NUM_MATCHES)
-                gnc_item_list_append (box->item_list, str_data);
+            list_store_append (box->tmp_store, str_data);
         }
         g_free (str_data);
         g_free (normalized_str_data);
         valid = gtk_tree_model_iter_next (GTK_TREE_MODEL (full_store), &iter);
     }
+
     if (num_found)
-        match_str = first_found;
+    {
+        gnc_item_list_set_temp_store (box->item_list, box->tmp_store);
+        gnc_item_edit_show_popup (box->item_edit);
+        box->list_popped = TRUE;
+    }
     g_regex_unref (regex);
-    g_regex_unref (regex0);
-    g_free (rep_str);
-    g_free (newval_rep);
     return match_str;
 }
 
+static char*
+quickfill_match (QuickFill *qf, const char *string)
+{
+    QuickFill *match = gnc_quickfill_get_string_match (qf, string);
+    return g_strdup (gnc_quickfill_string (match));
+}
+
+
 static void
 gnc_combo_cell_modify_verify (BasicCell* _cell,
                               const char* change,
@@ -582,9 +602,7 @@ gnc_combo_cell_modify_verify (BasicCell* _cell,
     gchar* match_str = NULL;
     glong newval_chars;
     glong change_chars;
-    GtkListStore* full_store;
     const gchar* box_str = NULL;
-    QuickFill* match = NULL;
 
     newval_chars = g_utf8_strlen (newval, newval_len);
     change_chars = g_utf8_strlen (change, change_len);
@@ -598,12 +616,16 @@ gnc_combo_cell_modify_verify (BasicCell* _cell,
         return;
     }
 
-    // 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));
+    /* If item_list is using temp then we're already partly matched by
+     * type-ahead and a quickfill_match won't work.
+     */
+    if (!gnc_item_list_using_temp (box->item_list))
+        match_str = quickfill_match (box->qf, newval);
     if (match_str != NULL)
     {
-        // We have a match, but if we were deleting or inserting in the middle, just accept.
+        /* We have a match, but if we were deleting or inserting in the middle,
+         * just accept.
+         */
         if (change == NULL || *cursor_position < _cell->value_chars)
         {
             gnc_basic_cell_set_value_internal (_cell, newval);
@@ -616,9 +638,9 @@ gnc_combo_cell_modify_verify (BasicCell* _cell,
     }
     else
     {
-        // No start-of-name match, try type-ahead search, we match any substring of the account name.
-        full_store = cell->shared_store_full;
-        match_str = gnc_combo_cell_type_ahead_search (newval, full_store, box);
+        // No start-of-name match, try type-ahead search, we match any substring of the full account name.
+        GtkListStore *store = cell->shared_store;
+        match_str = gnc_combo_cell_type_ahead_search (newval, store, box);
         *start_selection = newval_chars;
         *end_selection = -1;
         *cursor_position = newval_chars;
@@ -628,7 +650,11 @@ gnc_combo_cell_modify_verify (BasicCell* _cell,
 
     if (match_str == NULL)
     {
-        // No match. Remove any selection in popup, don't change the type-in box
+        if (gnc_item_list_using_temp (box->item_list))
+        {
+            gnc_item_list_set_temp_store (box->item_list, NULL);
+            gtk_list_store_clear (box->tmp_store);
+        }
         gnc_basic_cell_set_value_internal (_cell, newval);
         block_list_signals (cell);
         gnc_item_list_select (box->item_list, NULL);
@@ -720,7 +746,6 @@ gnc_combo_cell_direct_update (BasicCell* bcell,
         *cursor_position += prefix_len;
         *start_selection = *cursor_position;
         *end_selection = -1;
-
         return TRUE;
     }
 
@@ -881,7 +906,11 @@ static void
 popup_set_focus (GtkWidget* widget,
                  G_GNUC_UNUSED gpointer user_data)
 {
-    gtk_widget_grab_focus (GTK_WIDGET (GNC_ITEM_LIST (widget)->tree_view));
+    /* An empty GtkTreeView grabbing focus causes the key_press events to be
+     * lost because there's no entry cell to handle them.
+     */
+    if (gnc_item_list_num_entries (GNC_ITEM_LIST (widget)))
+        gtk_widget_grab_focus (GTK_WIDGET (GNC_ITEM_LIST (widget)->tree_view));
 }
 
 static void
diff --git a/gnucash/register/register-gnome/gnucash-item-list.c b/gnucash/register/register-gnome/gnucash-item-list.c
index 734b0ace7..85de133a8 100644
--- a/gnucash/register/register-gnome/gnucash-item-list.c
+++ b/gnucash/register/register-gnome/gnucash-item-list.c
@@ -233,12 +233,33 @@ gnc_item_list_autosize (GncItemList* item_list)
     return 100;
 }
 
+void
+gnc_item_list_set_temp_store (GncItemList *item_list, GtkListStore *store)
+{
+
+    g_return_if_fail (item_list != 0);
+
+    item_list->temp_store = store;
+    if (store)
+        gtk_tree_view_set_model (item_list->tree_view,
+                                 GTK_TREE_MODEL (item_list->temp_store));
+    else
+        gtk_tree_view_set_model (item_list->tree_view,
+                                 GTK_TREE_MODEL (item_list->list_store));
+}
+
+gboolean
+gnc_item_list_using_temp (GncItemList *item_list)
+{
+    return item_list && item_list->temp_store;
+}
 
 static void
 gnc_item_list_init (GncItemList* item_list)
 {
     item_list->tree_view = NULL;
     item_list->list_store = NULL;
+    item_list->temp_store = NULL;
 }
 
 
diff --git a/gnucash/register/register-gnome/gnucash-item-list.h b/gnucash/register/register-gnome/gnucash-item-list.h
index 1f8a1a3cc..2be05f28e 100644
--- a/gnucash/register/register-gnome/gnucash-item-list.h
+++ b/gnucash/register/register-gnome/gnucash-item-list.h
@@ -43,6 +43,7 @@ typedef struct
 
     GtkTreeView *tree_view;
     GtkListStore *list_store; /* Contains the list items */
+    GtkListStore *temp_store; /* Temporary store for typeahead select */
 } GncItemList;
 
 typedef struct
@@ -81,6 +82,9 @@ void gnc_item_list_show_selected (GncItemList *item_list);
 
 int gnc_item_list_autosize (GncItemList *item_list);
 
+void gnc_item_list_set_temp_store (GncItemList *item_list, GtkListStore *store);
+
+gboolean gnc_item_list_using_temp (GncItemList *item_list);
 
 /** @} */
 #endif /* GNUCASH_ITEM_LIST_H */

commit 534bcd6c1b9d8a6ef6130300c8efd46af2d3cc29
Author: John Ralls <jralls at ceridwen.us>
Date:   Thu May 7 11:19:49 2020 -0700

    Clean up some leftover noise from the ime-fix branch.

diff --git a/gnucash/register/register-gnome/gnucash-sheet.c b/gnucash/register/register-gnome/gnucash-sheet.c
index 774feae0d..48a0e367f 100644
--- a/gnucash/register/register-gnome/gnucash-sheet.c
+++ b/gnucash/register/register-gnome/gnucash-sheet.c
@@ -30,7 +30,6 @@
 
 #include <config.h>
 #include <glib.h>
-#include <glib/gprintf.h>
 #include <gdk/gdkkeysyms.h>
 
 #include "gnucash-sheet.h"
diff --git a/gnucash/register/register-gnome/gnucash-sheetP.h b/gnucash/register/register-gnome/gnucash-sheetP.h
index 7f148d5c0..fa3370abb 100644
--- a/gnucash/register/register-gnome/gnucash-sheetP.h
+++ b/gnucash/register/register-gnome/gnucash-sheetP.h
@@ -88,7 +88,6 @@ struct _GnucashSheet
 
     guint insert_signal;
     guint delete_signal;
-    guint changed_signal;
 
     GtkAdjustment *hadj, *vadj;
     GtkWidget *hscrollbar, *vscrollbar;



Summary of changes:
 gnucash/gnome-utils/account-quickfill.c            |  72 ++---------
 gnucash/gnome-utils/account-quickfill.h            |   3 -
 gnucash/register/ledger-core/gncEntryLedgerLoad.c  |  12 +-
 gnucash/register/ledger-core/split-register-load.c |   7 +-
 gnucash/register/register-core/combocell.h         |   4 +-
 gnucash/register/register-gnome/combocell-gnome.c  | 131 +++++++++++++--------
 .../register/register-gnome/gnucash-item-list.c    |  21 ++++
 .../register/register-gnome/gnucash-item-list.h    |   4 +
 gnucash/register/register-gnome/gnucash-sheet.c    |   1 -
 gnucash/register/register-gnome/gnucash-sheetP.h   |   1 -
 10 files changed, 124 insertions(+), 132 deletions(-)



More information about the gnucash-changes mailing list