From 1dc595589e1a6bd1a78132e9ee5eecac2b014468 Mon Sep 17 00:00:00 2001 From: Geert Janssens Date: Fri, 27 Dec 2019 17:59:00 +0100 Subject: [PATCH] Bug 796530 - [txn csv importer] usability suggestions Fix account selection by typing in the base account combo box text field The typing triggered the combobox' changed event. That triggered a repopulation of the csv data treeview (due to possibly having to unset an account column). That then in the end retriggered setting the base account. However while typing in the combo box there may not be a valid account selected in the combo box. So break this short circuit by testing for a change in the last-known base account compared to what the combo box believes is the proper account. This last-known account nore the combo box' internal state will change while typing allowing proper user input. --- gnucash/gnome-utils/gnc-account-sel.c | 6 ++++++ gnucash/gnome-utils/gnc-account-sel.h | 1 + .../csv-imp/assistant-csv-trans-import.cpp | 12 ++++++++---- 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/gnucash/gnome-utils/gnc-account-sel.c b/gnucash/gnome-utils/gnc-account-sel.c index f3a2916428..cd69f2c62f 100644 --- a/gnucash/gnome-utils/gnc-account-sel.c +++ b/gnucash/gnome-utils/gnc-account-sel.c @@ -139,6 +139,11 @@ gnc_account_sel_class_init (GNCAccountSelClass *klass) static void combo_changed_cb(GNCAccountSel *gas, gpointer combo) { + gint selected = gtk_combo_box_get_active (GTK_COMBO_BOX (combo)); + if (selected == gas->currentSelection) + return; + + gas->currentSelection = selected; g_signal_emit_by_name(gas, "account_sel_changed"); } @@ -152,6 +157,7 @@ gnc_account_sel_init (GNCAccountSel *gas) gas->initDone = FALSE; gas->acctTypeFilters = FALSE; gas->newAccountButton = NULL; + gas->currentSelection = -1; g_object_set(gas, "spacing", 2, (gchar*)NULL); diff --git a/gnucash/gnome-utils/gnc-account-sel.h b/gnucash/gnome-utils/gnc-account-sel.h index 49d837f57d..7cfe25124c 100644 --- a/gnucash/gnome-utils/gnc-account-sel.h +++ b/gnucash/gnome-utils/gnc-account-sel.h @@ -51,6 +51,7 @@ typedef struct /* The state of this pointer also serves as a flag about what state * the widget is in WRT the new-account-button ability. */ GtkWidget *newAccountButton; + gint currentSelection; #if 0 /* completion not implemented. */ GCompletion *completion; diff --git a/gnucash/import-export/csv-imp/assistant-csv-trans-import.cpp b/gnucash/import-export/csv-imp/assistant-csv-trans-import.cpp index abdc54b94c..373c4633e8 100644 --- a/gnucash/import-export/csv-imp/assistant-csv-trans-import.cpp +++ b/gnucash/import-export/csv-imp/assistant-csv-trans-import.cpp @@ -1596,10 +1596,14 @@ void CsvImpTransAssist::preview_refresh_table () g_object_unref (combostore); /* Also reset the base account combo box as it's value may have changed due to column changes here */ - g_signal_handlers_block_by_func (acct_selector, (gpointer) csv_tximp_preview_acct_sel_cb, this); - gnc_account_sel_set_account(GNC_ACCOUNT_SEL(acct_selector), - tx_imp->base_account() , false); - g_signal_handlers_unblock_by_func (acct_selector, (gpointer) csv_tximp_preview_acct_sel_cb, this); + auto base_acct = gnc_account_sel_get_account(GNC_ACCOUNT_SEL(acct_selector)); + if (tx_imp->base_account() != base_acct) + { + g_signal_handlers_block_by_func (acct_selector, (gpointer) csv_tximp_preview_acct_sel_cb, this); + gnc_account_sel_set_account(GNC_ACCOUNT_SEL(acct_selector), + tx_imp->base_account() , false); + g_signal_handlers_unblock_by_func (acct_selector, (gpointer) csv_tximp_preview_acct_sel_cb, this); + } /* Make the things actually appear. */ gtk_widget_show_all (GTK_WIDGET(treeview));