[gtk/filechooser-cancel-search] filechooser: Unbreak location entry



commit 9c89beea9a21becd54fccd43c97cb2caeb796e9b
Author: Matthias Clasen <mclasen redhat com>
Date:   Sun Aug 2 00:05:48 2020 -0400

    filechooser: Unbreak location entry
    
    We don't want to capture key presses for search
    when the location entry or the server entry are
    visible.
    
    Fixes: #2985

 gtk/gtkfilechooserwidget.c | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)
---
diff --git a/gtk/gtkfilechooserwidget.c b/gtk/gtkfilechooserwidget.c
index f79db9de42..39a8aef402 100644
--- a/gtk/gtkfilechooserwidget.c
+++ b/gtk/gtkfilechooserwidget.c
@@ -2419,6 +2419,16 @@ location_switch_to_filename_entry (GtkFileChooserWidget *impl)
   gtk_widget_grab_focus (impl->location_entry);
 }
 
+static LocationMode
+location_mode_get (GtkFileChooserWidget *impl)
+{
+  if (gtk_revealer_get_child_revealed (GTK_REVEALER (impl->browse_header_revealer)) &&
+      strcmp (gtk_stack_get_visible_child_name (GTK_STACK (impl->browse_header_stack)), "location") == 0)
+    return LOCATION_MODE_FILENAME_ENTRY;
+  else
+    return LOCATION_MODE_PATH_BAR;
+}
+
 /* Sets a new location mode.
  */
 static void
@@ -7687,7 +7697,9 @@ captured_key (GtkEventControllerKey *controller,
   GtkFileChooserWidget *impl = data;
   gboolean handled;
 
-  if (impl->operation_mode == OPERATION_MODE_SEARCH)
+  if (impl->operation_mode == OPERATION_MODE_SEARCH ||
+      impl->operation_mode == OPERATION_MODE_OTHER_LOCATIONS ||
+      location_mode_get (impl) == LOCATION_MODE_FILENAME_ENTRY)
     return GDK_EVENT_PROPAGATE;
 
   handled = gtk_event_controller_key_forward (controller, GTK_WIDGET (impl->search_entry));


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