[gtk/wip/baedert/filechooser: 4/9] filechooserwidget: Focus the search entry when keynav fails...



commit 6ee3d881f6cbc2ef88e4e0e06798013fe1c17657
Author: Timm Bäder <mail baedert org>
Date:   Tue Jan 15 06:11:52 2019 +0100

    filechooserwidget: Focus the search entry when keynav fails...
    
    ... when going UP in the treeview while searching. If the treeview is
    manually focused and the cursor gets moved up in the direction of the
    searchentry, focus the entry.

 gtk/gtkfilechooserwidget.c     | 18 ++++++++++++++++++
 gtk/ui/gtkfilechooserwidget.ui |  1 +
 2 files changed, 19 insertions(+)
---
diff --git a/gtk/gtkfilechooserwidget.c b/gtk/gtkfilechooserwidget.c
index 4767015d4d..4a898ee7ef 100644
--- a/gtk/gtkfilechooserwidget.c
+++ b/gtk/gtkfilechooserwidget.c
@@ -7674,6 +7674,23 @@ list_cursor_changed (GtkTreeView          *list,
   check_preview_change (impl);
 }
 
+static gboolean
+browse_files_tree_view_keynav_failed_cb (GtkWidget        *widget,
+                                         GtkDirectionType  direction,
+                                         gpointer          user_data)
+{
+ GtkFileChooserWidget *self = user_data;
+ GtkFileChooserWidgetPrivate *priv = gtk_file_chooser_widget_get_instance_private (self);
+
+ if (direction == GTK_DIR_UP && priv->operation_mode == OPERATION_MODE_SEARCH)
+   {
+     gtk_entry_grab_focus_without_selecting (GTK_ENTRY (priv->search_entry));
+     return TRUE;
+   }
+
+  return FALSE;
+}
+
 /* Callback used when a row in the file list is activated */
 static void
 list_row_activated (GtkTreeView          *tree_view,
@@ -8400,6 +8417,7 @@ gtk_file_chooser_widget_class_init (GtkFileChooserWidgetClass *class)
   gtk_widget_class_bind_template_callback (widget_class, file_list_drag_end_cb);
   gtk_widget_class_bind_template_callback (widget_class, list_selection_changed);
   gtk_widget_class_bind_template_callback (widget_class, list_cursor_changed);
+  gtk_widget_class_bind_template_callback (widget_class, browse_files_tree_view_keynav_failed_cb);
   gtk_widget_class_bind_template_callback (widget_class, filter_combo_changed);
   gtk_widget_class_bind_template_callback (widget_class, path_bar_clicked);
   gtk_widget_class_bind_template_callback (widget_class, places_sidebar_open_location_cb);
diff --git a/gtk/ui/gtkfilechooserwidget.ui b/gtk/ui/gtkfilechooserwidget.ui
index fbb53bd76e..1a51df0178 100644
--- a/gtk/ui/gtkfilechooserwidget.ui
+++ b/gtk/ui/gtkfilechooserwidget.ui
@@ -169,6 +169,7 @@
                                         <signal name="query-tooltip" handler="file_list_query_tooltip_cb" 
swapped="no"/>
                                         <signal name="row-activated" handler="list_row_activated" 
swapped="no"/>
                                         <signal name="cursor-changed" handler="list_cursor_changed" 
swapped="no"/>
+                                        <signal name="keynav-failed" 
handler="browse_files_tree_view_keynav_failed_cb" />
                                         <child internal-child="selection">
                                           <object class="GtkTreeSelection" id="treeview-selection2">
                                             <signal name="changed" handler="list_selection_changed" 
swapped="no"/>


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]