Skip to content

Commit

Permalink
Add a keypress callback to only expand the tree when the user starts …
Browse files Browse the repository at this point in the history
…typing
  • Loading branch information
jean committed Apr 7, 2020
1 parent 1dcb26c commit b561dec
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions gnucash/import-export/import-account-matcher.c
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,14 @@ account_tree_row_changed_cb (GtkTreeSelection *selection,
gtk_widget_hide (GTK_WIDGET(picker->pwhbox)); // hide the placeholder warning
}

static gboolean
account_tree_key_press_cb(GtkWidget *widget, GdkEventKey *event, gpointer user_data)
{
// Expand the tree when the user starts typing, this will allow sub-accounts to be found.
gtk_tree_view_expand_all(GTK_TREE_VIEW(user_data));
return FALSE;
}


/*******************************************************
* account_tree_row_activated_cb
Expand Down Expand Up @@ -385,11 +393,13 @@ Account * gnc_import_select_account(GtkWidget *parent,
}
gtk_label_set_text((GtkLabel*)online_id_label, account_description_text);
build_acct_tree(picker);
// Expand the tree so if you start typing, any sub-account will match
gtk_tree_view_expand_all(GTK_TREE_VIEW(picker->account_tree));
gtk_window_set_modal(GTK_WINDOW(picker->dialog), TRUE);
g_signal_connect(picker->account_tree, "row-activated",
G_CALLBACK(account_tree_row_activated_cb), picker);

/* Connect key press event so we can expand the tree when the user starts typing, allowing
* any subaccount to match */
g_signal_connect (picker->account_tree, "key-press-event", G_CALLBACK (account_tree_key_press_cb), picker->account_tree);

selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(picker->account_tree));
g_signal_connect(selection, "changed",
Expand Down

0 comments on commit b561dec

Please sign in to comment.