file chooser: Trigger location entry not just from file list
authorMatthias Clasen <mclasen@redhat.com>
Sat, 27 Jun 2015 19:23:24 +0000 (15:23 -0400)
committerMatthias Clasen <mclasen@redhat.com>
Sat, 4 Jul 2015 04:29:25 +0000 (00:29 -0400)
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

index 8ed65d5bde2564b15b94b2dc687e5e4102a9939f..3ef560e932283286b9d52a506c41e55abeb4b588 100644 (file)
@@ -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)