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.
pull/626/head
Geert Janssens 6 years ago
parent 77ddaf91ab
commit 1dc595589e

@ -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);

@ -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;

@ -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));

Loading…
Cancel
Save