[gtk+] file chooser: Improve search focus handling
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+] file chooser: Improve search focus handling
- Date: Fri, 2 Oct 2015 03:34:36 +0000 (UTC)
commit 7d4ed3692ed84986dcb02847b083c361454b5267
Author: Matthias Clasen <mclasen redhat com>
Date: Thu Oct 1 23:32:30 2015 -0400
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
entry.
https://bugzilla.gnome.org/show_bug.cgi?id=755926
gtk/gtkfilechooserwidget.c | 18 +++++++++++++++++-
1 files changed, 17 insertions(+), 1 deletions(-)
---
diff --git a/gtk/gtkfilechooserwidget.c b/gtk/gtkfilechooserwidget.c
index 1ea94b2..1c9e642 100644
--- a/gtk/gtkfilechooserwidget.c
+++ b/gtk/gtkfilechooserwidget.c
@@ -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.
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]