From b3553b13d34cd8ddb435d5b2433a570acd4780fa Mon Sep 17 00:00:00 2001 From: Christopher Lam Date: Mon, 27 Mar 2023 11:52:11 +0800 Subject: [PATCH] [dialog-search.c] if result, select first one. also grab focus. Addendum to bug 355498 to select the result. This allows faster keyboard navigation -- Find Customer, input search string, press ENTER, use up/down to select desired object, press ENTER to open object. --- gnucash/gnome-search/dialog-search.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/gnucash/gnome-search/dialog-search.c b/gnucash/gnome-search/dialog-search.c index 9d07ca63e1..3c67c85626 100644 --- a/gnucash/gnome-search/dialog-search.c +++ b/gnucash/gnome-search/dialog-search.c @@ -368,13 +368,14 @@ gnc_search_dialog_display_results (GNCSearchWindow *sw) if (gnc_query_view_get_num_entries(GNC_QUERY_VIEW(sw->result_view)) < max_count) gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON (sw->new_rb), TRUE); - /* If there is only one item then select it */ - if (gnc_query_view_get_num_entries (GNC_QUERY_VIEW(sw->result_view)) == 1) + /* If there are results then select the first, and grab focus */ + if (gnc_query_view_get_num_entries (GNC_QUERY_VIEW(sw->result_view)) > 0) { GtkTreeSelection *selection = gtk_tree_view_get_selection (GTK_TREE_VIEW(sw->result_view)); GtkTreePath *path = gtk_tree_path_new_first (); gtk_tree_selection_select_path (selection, path); gtk_tree_path_free (path); + gtk_widget_grab_focus (sw->result_view); } }