[gtk+] file chooser: Trigger location entry not just from file list



commit 1c3ccb39c7aded5bc14d6fb7ab566411f90fe7d1
Author: Matthias Clasen <mclasen redhat com>
Date:   Sat Jun 27 15:23:24 2015 -0400

    file chooser: Trigger location entry not just from file list
    
    Use the same code that brings up the location entry on '/',
    '~' or '.' also when the focus is not on the file list. This
    prevents those key presses on the sidebar from ending up in
    the search entry.

 gtk/gtkfilechooserwidget.c |   35 ++++++++++++++++++++++++++---------
 1 files changed, 26 insertions(+), 9 deletions(-)
---
diff --git a/gtk/gtkfilechooserwidget.c b/gtk/gtkfilechooserwidget.c
index 8ed65d5..3ef560e 100644
--- a/gtk/gtkfilechooserwidget.c
+++ b/gtk/gtkfilechooserwidget.c
@@ -1199,17 +1199,10 @@ key_is_left_or_right (GdkEventKey *event)
          && (event->state & modifiers) == 0);
 }
 
-/* Handles key press events on the file list, so that we can trap Enter to
- * activate the default button on our own.  Also, checks to see if “/” has been
- * pressed.
- */
 static gboolean
-browse_files_key_press_event_cb (GtkWidget   *widget,
-                                GdkEventKey *event,
-                                gpointer     data)
+should_trigger_location_entry (GtkWidget   *widget,
+                               GdkEventKey *event)
 {
-  GtkFileChooserWidget *impl = (GtkFileChooserWidget *) data;
-  GtkFileChooserWidgetPrivate *priv = impl->priv;
   GdkModifierType no_text_input_mask;
 
   no_text_input_mask =
@@ -1222,6 +1215,24 @@ browse_files_key_press_event_cb (GtkWidget   *widget,
        || event->keyval == GDK_KEY_asciitilde
 #endif
        ) && !(event->state & no_text_input_mask))
+    return TRUE;
+
+  return FALSE;
+}
+
+/* Handles key press events on the file list, so that we can trap Enter to
+ * activate the default button on our own.  Also, checks to see if “/” has been
+ * pressed.
+ */
+static gboolean
+browse_files_key_press_event_cb (GtkWidget   *widget,
+                                GdkEventKey *event,
+                                gpointer     data)
+{
+  GtkFileChooserWidget *impl = (GtkFileChooserWidget *) data;
+  GtkFileChooserWidgetPrivate *priv = impl->priv;
+
+  if (should_trigger_location_entry (widget, event))
     {
       location_popup_handler (impl, event->string);
       return TRUE;
@@ -1272,6 +1283,12 @@ gtk_file_chooser_widget_key_press_event (GtkWidget   *widget,
   GtkFileChooserWidget *impl = (GtkFileChooserWidget *) widget;
   GtkFileChooserWidgetPrivate *priv = impl->priv;
 
+  if (should_trigger_location_entry (widget, event))
+    {
+      location_popup_handler (impl, event->string);
+      return TRUE;
+    }
+
   if (gtk_search_entry_handle_event (GTK_SEARCH_ENTRY (priv->search_entry), (GdkEvent *)event))
     {
       if (priv->operation_mode != OPERATION_MODE_SEARCH)


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