gnucash stable: Bug799051 - Shortcut Ctrl + Tab not working in 5.3

Robert Fewell bobit at code.gnucash.org
Wed Aug 9 04:48:10 EDT 2023


Updated	 via  https://github.com/Gnucash/gnucash/commit/7a1f01d3 (commit)
	from  https://github.com/Gnucash/gnucash/commit/79e36e6c (commit)



commit 7a1f01d3ca9934b7324c94b42ddb613ddec967e9
Author: Robert Fewell <14uBobIT at gmail.com>
Date:   Sun Aug 6 11:59:51 2023 +0100

    Bug799051 - Shortcut Ctrl + Tab not working in 5.3
    
    In a register description cell pressing Ctrl+Tab would populate the
    description cell if the list had only one entry, i.e. all the register
    transaction descriptions were the same. This was removed by mistake so
    this commit adds it back.

diff --git a/gnucash/register/register-gnome/completioncell-gnome.c b/gnucash/register/register-gnome/completioncell-gnome.c
index 697d662b52..b1eb0a420a 100644
--- a/gnucash/register/register-gnome/completioncell-gnome.c
+++ b/gnucash/register/register-gnome/completioncell-gnome.c
@@ -752,6 +752,24 @@ gnc_completion_cell_modify_verify (BasicCell* bcell,
     gnc_basic_cell_set_value_internal (bcell, newval);
 }
 
+static char*
+get_entry_from_hash_if_size_is_one (CompletionCell* cell)
+{
+    if (!cell)
+        return NULL;
+
+    PopBox* box = cell->cell.gui_private;
+
+    if (box->item_hash && (g_hash_table_size (box->item_hash) == 1))
+    {
+        GList *keys = g_hash_table_get_keys (box->item_hash);
+        char *ret = g_strdup (keys->data);
+        g_list_free (keys);
+        return ret;
+    }
+    return NULL;
+}
+
 static gboolean
 gnc_completion_cell_direct_update (BasicCell* bcell,
                                    int* cursor_position,
@@ -771,6 +789,19 @@ gnc_completion_cell_direct_update (BasicCell* bcell,
     case GDK_KEY_Tab:
     case GDK_KEY_ISO_Left_Tab:
         {
+            if (event->state & GDK_CONTROL_MASK)
+            {
+                char* hash_string = get_entry_from_hash_if_size_is_one (cell);
+
+                if (hash_string)
+                {
+                    gnc_basic_cell_set_value_internal (bcell, hash_string);
+                    *cursor_position = strlen (hash_string);
+                }
+                g_free (hash_string);
+                return TRUE;
+            }
+
             char* string = gnc_item_list_get_selection (box->item_list);
 
             if (!string)



Summary of changes:
 .../register/register-gnome/completioncell-gnome.c | 31 ++++++++++++++++++++++
 1 file changed, 31 insertions(+)



More information about the gnucash-changes mailing list