Commit 7d4ed369 authored by Matthias Clasen's avatar Matthias Clasen

file chooser: Improve search focus handling

Move focus to list when search results appear to make it
possible to select the first search result by just hitting
Enter. To keep this from interfering with keynav, we need
to make sure that we still handle Escape to search. And when
search comes up empty, we need to move the focus back to the
parent 134c2ea7
......@@ -1353,6 +1353,13 @@ browse_files_key_press_event_cb (GtkWidget *widget,
if (event->keyval == GDK_KEY_Escape &&
priv->operation_mode == OPERATION_MODE_SEARCH)
gtk_search_entry_handle_event (GTK_SEARCH_ENTRY (priv->search_entry), (GdkEvent *)event);
return TRUE;
return FALSE;
......@@ -7074,6 +7081,10 @@ search_engine_hits_added_cb (GtkSearchEngine *engine,
GList *l, *files, *files_with_info, *infos;
GFile *file;
gboolean select = FALSE;
if (gtk_tree_model_iter_n_children (GTK_TREE_MODEL (impl->priv->search_model), NULL) == 0)
select = TRUE;
files = NULL;
files_with_info = NULL;
......@@ -7101,6 +7112,8 @@ search_engine_hits_added_cb (GtkSearchEngine *engine,
g_list_free_full (infos, g_object_unref);
gtk_stack_set_visible_child_name (GTK_STACK (impl->priv->browse_files_stack), "list");
if (select)
gtk_widget_grab_focus (impl->priv->browse_files_tree_view);
/* Callback used from GtkSearchEngine when the query is done running */
......@@ -7121,7 +7134,10 @@ search_engine_finished_cb (GtkSearchEngine *engine,
if (gtk_tree_model_iter_n_children (GTK_TREE_MODEL (priv->search_model), NULL) == 0)
gtk_stack_set_visible_child_name (GTK_STACK (priv->browse_files_stack), "empty");
gtk_stack_set_visible_child_name (GTK_STACK (priv->browse_files_stack), "empty");
gtk_entry_grab_focus_without_selecting (GTK_ENTRY (priv->search_entry));
/* Displays a generic error when we cannot create a GtkSearchEngine.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment