gnucash master: Multiple changes pushed

John Ralls jralls at code.gnucash.org
Fri Dec 30 15:48:57 EST 2022


Updated	 via  https://github.com/Gnucash/gnucash/commit/72f81f7b (commit)
	 via  https://github.com/Gnucash/gnucash/commit/91486a73 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/46c2e449 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/e3665287 (commit)
	from  https://github.com/Gnucash/gnucash/commit/ab13b01f (commit)



commit 72f81f7b83194950fa8030ea38a92433e3609255
Merge: ab13b01f8 91486a731
Author: John Ralls <jralls at ceridwen.us>
Date:   Fri Dec 30 11:38:58 2022 -0800

    Merge Bob Fewell's 'reg-desc' into master.


commit 91486a7318db0358150fada38ff0159cf8eb9aad
Author: Robert Fewell <14uBobIT at gmail.com>
Date:   Mon Oct 10 11:41:11 2022 +0100

    Add a function to combocell to set the search behaviour
    
    When searching for entered text, the combocell search starts from the
    front till the entered text is not found and then changes to find the
    entered text any where.
    
    This function sets the combocell to use only the second option, type
    ahead search.

diff --git a/gnucash/register/ledger-core/split-register-load.c b/gnucash/register/ledger-core/split-register-load.c
index d87318354..b8a5bd48f 100644
--- a/gnucash/register/ledger-core/split-register-load.c
+++ b/gnucash/register/ledger-core/split-register-load.c
@@ -862,6 +862,8 @@ gnc_split_register_load_desc_cells (SplitRegister* reg)
     cell = (ComboCell*)
            gnc_table_layout_get_cell (reg->table->layout, DESC_CELL);
 
+    gnc_combo_cell_use_type_ahead_only (cell);
+
     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 942d144ee..ebdb0340a 100644
--- a/gnucash/register/register-core/combocell.h
+++ b/gnucash/register/register-core/combocell.h
@@ -108,5 +108,9 @@ void gnc_combo_cell_use_quickfill_cache (ComboCell* cell,
                                          QuickFill* shared_qf);
 void gnc_combo_cell_use_list_store_cache (ComboCell* cell, gpointer data);
 
+/** Set the combocell to use only type ahead search. This will make the
+ *  search to be more like a modified entry completion. */
+void gnc_combo_cell_use_type_ahead_only (ComboCell* cell);
+
 /** @} */
 #endif
diff --git a/gnucash/register/register-gnome/combocell-gnome.c b/gnucash/register/register-gnome/combocell-gnome.c
index 4e2b5b022..bd47f2084 100644
--- a/gnucash/register/register-gnome/combocell-gnome.c
+++ b/gnucash/register/register-gnome/combocell-gnome.c
@@ -75,6 +75,8 @@ typedef struct _PopBox
     GList* ignore_strings;
 
     GHashTable *item_hash;
+
+    gboolean use_type_ahead_only;
 } PopBox;
 
 
@@ -167,6 +169,8 @@ gnc_combo_cell_init (ComboCell* cell)
     box->ignore_strings = NULL;
 
     box->item_hash = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL);
+
+    box->use_type_ahead_only = FALSE;
 }
 
 static void
@@ -694,7 +698,7 @@ gnc_combo_cell_modify_verify (BasicCell* _cell,
     /* 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))
+    if (!gnc_item_list_using_temp (box->item_list) && !box->use_type_ahead_only)
     {
         // If we were deleting or inserting in the middle, just accept.
         if (change == NULL || *cursor_position < _cell->value_chars)
@@ -926,6 +930,19 @@ gnc_combo_cell_direct_update (BasicCell* bcell,
     return TRUE;
 }
 
+void
+gnc_combo_cell_use_type_ahead_only (ComboCell* cell)
+{
+    PopBox* box;
+
+    if (cell == NULL) return;
+
+    box = cell->cell.gui_private;
+
+    box->use_type_ahead_only = TRUE;
+
+}
+
 static void
 gnc_combo_cell_gui_realize (BasicCell* bcell, gpointer data)
 {

commit 46c2e44988ea7dd3ecb3207c68cfe51b0221ba4f
Author: Robert Fewell <14uBobIT at gmail.com>
Date:   Mon Oct 10 11:17:02 2022 +0100

    Change the Register description layout cell type.
    
    Currently the description cell type is QUICKFILL_CELL_TYPE and
    commit changes it to COMBO_CELL_TYPE. Doing this allows the user to
    select a transaction description from a list or do a similar search to
    that of the transfer cell.

diff --git a/gnucash/register/ledger-core/split-register-layout.c b/gnucash/register/ledger-core/split-register-layout.c
index 6f7f2bef9..050fb95be 100644
--- a/gnucash/register/ledger-core/split-register-layout.c
+++ b/gnucash/register/ledger-core/split-register-layout.c
@@ -675,7 +675,7 @@ gnc_split_register_layout_add_cells (SplitRegister* reg,
 
     gnc_register_add_cell (layout,
                            DESC_CELL,
-                           QUICKFILL_CELL_TYPE_NAME,
+                           COMBO_CELL_TYPE_NAME,
                            C_ ("sample", "Description of a transaction"),
                            CELL_ALIGN_LEFT,
                            TRUE,
diff --git a/gnucash/register/ledger-core/split-register-load.c b/gnucash/register/ledger-core/split-register-load.c
index a86250be0..d87318354 100644
--- a/gnucash/register/ledger-core/split-register-load.c
+++ b/gnucash/register/ledger-core/split-register-load.c
@@ -50,6 +50,7 @@ static QofLogModule log_module = GNC_MOD_LEDGER;
 static void gnc_split_register_load_xfer_cells (SplitRegister* reg,
                                                 Account* base_account);
 
+static void gnc_split_register_load_desc_cells (SplitRegister* reg);
 static void
 gnc_split_register_load_recn_cells (SplitRegister* reg)
 {
@@ -239,10 +240,6 @@ _find_split_with_parent_txn (gconstpointer a, gconstpointer b)
 static void add_quickfill_completions (TableLayout* layout, Transaction* trans,
                                        Split* split, gboolean has_last_num)
 {
-    gnc_quickfill_cell_add_completion (
-        (QuickFillCell*) gnc_table_layout_get_cell (layout, DESC_CELL),
-        xaccTransGetDescription (trans));
-
     gnc_quickfill_cell_add_completion (
         (QuickFillCell*) gnc_table_layout_get_cell (layout, NOTES_CELL),
         xaccTransGetNotes (trans));
@@ -528,6 +525,7 @@ gnc_split_register_load (SplitRegister* reg, GList* slist,
 
         /* load up account names into the transfer combobox menus */
         gnc_split_register_load_xfer_cells (reg, default_account);
+        gnc_split_register_load_desc_cells (reg);
         gnc_split_register_load_doclink_cells (reg);
         gnc_split_register_load_recn_cells (reg);
         gnc_split_register_load_type_cells (reg);
@@ -662,6 +660,10 @@ gnc_split_register_load (SplitRegister* reg, GList* slist,
         if (info->first_pass)
             add_quickfill_completions (reg->table->layout, trans, split, has_last_num);
 
+        gnc_combo_cell_add_menu_item_unique (
+            (ComboCell*) gnc_table_layout_get_cell (reg->table->layout, DESC_CELL),
+            xaccTransGetDescription (trans));
+
         if (trans == find_trans)
             new_trans_row = vcell_loc.virt_row;
 
@@ -851,4 +853,15 @@ gnc_split_register_load_xfer_cells (SplitRegister* reg, Account* base_account)
     gnc_combo_cell_use_list_store_cache (cell, store);
 }
 
+static void
+gnc_split_register_load_desc_cells (SplitRegister* reg)
+{
+    ComboCell* cell;
+    GtkListStore* store = gtk_list_store_new (1, G_TYPE_STRING);
+
+    cell = (ComboCell*)
+           gnc_table_layout_get_cell (reg->table->layout, DESC_CELL);
+
+    gnc_combo_cell_use_list_store_cache (cell, store);
+}
 /* ====================== END OF FILE ================================== */
diff --git a/gnucash/register/ledger-core/split-register.c b/gnucash/register/ledger-core/split-register.c
index 6c0bfa4a1..7f85246ce 100644
--- a/gnucash/register/ledger-core/split-register.c
+++ b/gnucash/register/ledger-core/split-register.c
@@ -2666,6 +2666,11 @@ gnc_split_register_config_cells (SplitRegister* reg)
         ((ComboCell*)
          gnc_table_layout_get_cell (reg->table->layout, ACTN_CELL), TRUE);
 
+    /* the description cell */
+    gnc_combo_cell_set_autosize
+        ((ComboCell*)
+         gnc_table_layout_get_cell (reg->table->layout, DESC_CELL), TRUE);
+
     /* Use GNC_COMMODITY_MAX_FRACTION for prices and "exchange rates"  */
     gnc_price_cell_set_fraction
         ((PriceCell*)
@@ -2693,6 +2698,11 @@ gnc_split_register_config_cells (SplitRegister* reg)
         ((ComboCell*)
          gnc_table_layout_get_cell (reg->table->layout, ACTN_CELL), FALSE);
 
+    /* The description cell should accept strings not in the list */
+    gnc_combo_cell_set_strict
+        ((ComboCell*)
+         gnc_table_layout_get_cell (reg->table->layout, DESC_CELL), FALSE);
+
     /* number format for share quantities in stock ledgers */
     switch (reg->type)
     {
diff --git a/gnucash/register/register-core/combocell.h b/gnucash/register/register-core/combocell.h
index ceeb7b7dd..942d144ee 100644
--- a/gnucash/register/register-core/combocell.h
+++ b/gnucash/register/register-core/combocell.h
@@ -63,6 +63,10 @@ void         gnc_combo_cell_clear_menu (ComboCell* cell);
 void         gnc_combo_cell_add_menu_item (ComboCell* cell,
                                            const char* menustr);
 
+/** Add a unique menu item to the list. */
+void gnc_combo_cell_add_menu_item_unique (ComboCell* cell,
+                                          const char* menustr);
+
 /** Add a 'account name' menu item to the list. When testing for
  *  equality with the currently selected item, this function will
  *  ignore the characters normally used to separate account names. */
diff --git a/gnucash/register/register-gnome/combocell-gnome.c b/gnucash/register/register-gnome/combocell-gnome.c
index 01abe784d..4e2b5b022 100644
--- a/gnucash/register/register-gnome/combocell-gnome.c
+++ b/gnucash/register/register-gnome/combocell-gnome.c
@@ -73,6 +73,8 @@ typedef struct _PopBox
     gunichar complete_char; /* char to be used for auto-completion */
 
     GList* ignore_strings;
+
+    GHashTable *item_hash;
 } PopBox;
 
 
@@ -163,6 +165,8 @@ gnc_combo_cell_init (ComboCell* cell)
     box->complete_char = '\0';
 
     box->ignore_strings = NULL;
+
+    box->item_hash = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL);
 }
 
 static void
@@ -333,6 +337,9 @@ gnc_combo_cell_destroy (BasicCell* bcell)
             box->qf = NULL;
         }
 
+        if (box->item_hash)
+           g_hash_table_destroy (box->item_hash);
+
         g_list_free_full (box->ignore_strings, g_free);
         box->ignore_strings = NULL;
 
@@ -458,6 +465,64 @@ gnc_combo_cell_add_menu_item (ComboCell* cell, const char* menustr)
     }
 }
 
+void
+gnc_combo_cell_add_menu_item_unique (ComboCell* cell, const char* menustr)
+{
+    PopBox* box;
+
+    if (cell == NULL)
+        return;
+    if (menustr == NULL)
+        return;
+
+    box = cell->cell.gui_private;
+
+    if (box->item_list != NULL)
+    {
+        block_list_signals (cell);
+
+        /* check if menustr has already been added. */
+        if (g_hash_table_lookup_extended (box->item_hash, menustr, NULL, NULL))
+            return;
+
+        g_hash_table_insert (box->item_hash, g_strdup (menustr), NULL);
+
+        gnc_item_list_append (box->item_list, menustr);
+        if (cell->cell.value &&
+            (strcmp (menustr, cell->cell.value) == 0))
+            gnc_item_list_select (box->item_list, menustr);
+
+        unblock_list_signals (cell);
+    }
+    else
+    {
+        GtkTreeIter iter;
+
+        // add a blank entry as the first entry in store
+        if (gtk_tree_model_iter_n_children (GTK_TREE_MODEL(cell->shared_store), NULL) == 0)
+        {
+            gtk_list_store_append (cell->shared_store, &iter);
+            gtk_list_store_set (cell->shared_store, &iter, 0, "", -1);
+            g_hash_table_insert (box->item_hash, g_strdup (""), NULL);
+        }
+
+        /* check if menustr has already been added. */
+        if (g_hash_table_lookup_extended (box->item_hash, menustr, NULL, NULL))
+            return;
+
+        g_hash_table_insert (box->item_hash, g_strdup (menustr), NULL);
+        gtk_list_store_append (cell->shared_store, &iter);
+        gtk_list_store_set (cell->shared_store, &iter, 0, menustr, -1);
+    }
+
+    /* If we're going to be using a pre-fab quickfill,
+     * then don't fill it in here */
+    if (FALSE == box->use_quickfill_cache)
+    {
+        gnc_quickfill_insert (box->qf, menustr, QUICKFILL_ALPHA);
+    }
+}
+
 void
 gnc_combo_cell_add_account_menu_item (ComboCell* cell, char* menustr)
 {

commit e366528770c883d0e3d4994f18a82fd404ff25bd
Author: Robert Fewell <14uBobIT at gmail.com>
Date:   Mon Oct 10 11:05:06 2022 +0100

    Change Register popup width
    
    When obtaining the popup width when using autosize, set it to the width
    of the cell unless it is smaller than the default, then use that.

diff --git a/gnucash/register/register-gnome/gnucash-item-edit.c b/gnucash/register/register-gnome/gnucash-item-edit.c
index b06c238ad..659b4d4b3 100644
--- a/gnucash/register/register-gnome/gnucash-item-edit.c
+++ b/gnucash/register/register-gnome/gnucash-item-edit.c
@@ -1089,6 +1089,12 @@ gnc_item_edit_show_popup (GncItemEdit *item_edit)
     // Lets check popup height is the true height
     item_edit->popup_returned_height = popup_h;
 
+    gtk_widget_get_allocation (GTK_WIDGET(item_edit), &alloc);
+
+    // the calendar will be 0
+    if ((popup_w != 0) && (popup_w < alloc.width))
+        popup_w = alloc.width;
+
     if (popup_h == popup_max_height)
         gtk_widget_set_size_request (item_edit->popup_item, popup_w - 1, popup_h);
     else
diff --git a/gnucash/register/register-gnome/gnucash-item-list.c b/gnucash/register/register-gnome/gnucash-item-list.c
index 625b9aa67..f01ab20bb 100644
--- a/gnucash/register/register-gnome/gnucash-item-list.c
+++ b/gnucash/register/register-gnome/gnucash-item-list.c
@@ -247,7 +247,7 @@ gnc_item_list_autosize (GncItemList* item_list)
     g_return_val_if_fail (item_list != NULL, 0);
     g_return_val_if_fail (IS_GNC_ITEM_LIST (item_list), 0);
 
-    return 100;
+    return 150;
 }
 
 void



Summary of changes:
 .../register/ledger-core/split-register-layout.c   |  2 +-
 gnucash/register/ledger-core/split-register-load.c | 23 ++++--
 gnucash/register/ledger-core/split-register.c      | 10 +++
 gnucash/register/register-core/combocell.h         |  8 +++
 gnucash/register/register-gnome/combocell-gnome.c  | 84 +++++++++++++++++++++-
 .../register/register-gnome/gnucash-item-edit.c    |  6 ++
 .../register/register-gnome/gnucash-item-list.c    |  2 +-
 7 files changed, 128 insertions(+), 7 deletions(-)



More information about the gnucash-changes mailing list