summaryrefslogtreecommitdiff
path: root/gtk/gtkfilechooserwidget.c
diff options
context:
space:
mode:
authorMatthias Clasen <mclasen@redhat.com>2020-04-27 00:13:46 -0400
committerMatthias Clasen <mclasen@redhat.com>2020-04-27 00:14:38 -0400
commitf18eef7e6faab4730ab16d46f4b12f7004815558 (patch)
treeb13d7ba8a762b7b65c5680dd9f3faa712b2996dc /gtk/gtkfilechooserwidget.c
parentbf1a9b2b0dc1b18a305931c624bda1d2776db0e4 (diff)
downloadgtk+-f18eef7e6faab4730ab16d46f4b12f7004815558.tar.gz
filechooser: Fix type-to-search
We need to capture the keys and forward them to the search entry, for anything to happen.
Diffstat (limited to 'gtk/gtkfilechooserwidget.c')
-rw-r--r--gtk/gtkfilechooserwidget.c26
1 files changed, 26 insertions, 0 deletions
diff --git a/gtk/gtkfilechooserwidget.c b/gtk/gtkfilechooserwidget.c
index 7be77590a4..c625114015 100644
--- a/gtk/gtkfilechooserwidget.c
+++ b/gtk/gtkfilechooserwidget.c
@@ -7658,6 +7658,26 @@ gtk_file_chooser_widget_class_init (GtkFileChooserWidgetClass *class)
gtk_widget_class_set_layout_manager_type (widget_class, GTK_TYPE_BIN_LAYOUT);
}
+static gboolean
+captured_key (GtkEventControllerKey *controller,
+ guint keyval,
+ guint keycode,
+ GdkModifierType state,
+ gpointer data)
+{
+ GtkFileChooserWidget *impl = data;
+ gboolean handled;
+
+ if (impl->operation_mode == OPERATION_MODE_SEARCH)
+ return GDK_EVENT_PROPAGATE;
+
+ handled = gtk_event_controller_key_forward (controller, GTK_WIDGET (impl->search_entry));
+ if (handled == GDK_EVENT_STOP)
+ operation_mode_set (impl, OPERATION_MODE_SEARCH);
+
+ return handled;
+}
+
static void
post_process_ui (GtkFileChooserWidget *impl)
{
@@ -7735,6 +7755,12 @@ post_process_ui (GtkFileChooserWidget *impl)
gtk_search_entry_set_key_capture_widget (GTK_SEARCH_ENTRY (impl->search_entry), impl->search_entry);
+ controller = gtk_event_controller_key_new ();
+ g_signal_connect (controller, "key-pressed", G_CALLBACK (captured_key), impl);
+ g_signal_connect (controller, "key-released", G_CALLBACK (captured_key), impl);
+ gtk_event_controller_set_propagation_phase (controller, GTK_PHASE_CAPTURE);
+ gtk_widget_add_controller (GTK_WIDGET (impl), controller);
+
gtk_widget_set_parent (impl->rename_file_popover, GTK_WIDGET (impl));
gesture = gtk_gesture_click_new ();