From 5986b2db2f09f4aacc55e538a45bcc7b054601d2 Mon Sep 17 00:00:00 2001 From: Jeremy Bicha Date: Sat, 14 May 2022 09:03:44 -0400 Subject: [PATCH] Cherry-pick patch to fix pasting into the filechooser name field LP: #1971532 --- ...Propagate-keys-from-external-entry-t.patch | 112 ++++++++++++++++++ debian/patches/series | 1 + 2 files changed, 113 insertions(+) create mode 100644 debian/patches/GtkFileChooserWidget-Propagate-keys-from-external-entry-t.patch diff --git a/debian/patches/GtkFileChooserWidget-Propagate-keys-from-external-entry-t.patch b/debian/patches/GtkFileChooserWidget-Propagate-keys-from-external-entry-t.patch new file mode 100644 index 0000000000..428caf44df --- /dev/null +++ b/debian/patches/GtkFileChooserWidget-Propagate-keys-from-external-entry-t.patch @@ -0,0 +1,112 @@ +From: Luca Bacci +Date: Fri, 13 May 2022 12:28:25 +0200 +Subject: GtkFileChooserWidget: Propagate keys from external entry to fcwidget + at the BUBBLE phase + +Now that we use event controllers we can forward keybindings from the +external entry to the filechooserwidget at the bubble phase. + +Fixes #4905 + +References: + * commit 1fb075dbca911d4a61e7ebbf9fc040cd697f4d83 + * commit 686116ba615f989610a6b78e84870555dbf5106b +(cherry picked from commit 40709245adc965e3501c6324d7a51536181349d2) +--- + gtk/gtkfilechooserwidget.c | 38 ++++++++++++++++++++++++++++---------- + 1 file changed, 28 insertions(+), 10 deletions(-) + +diff --git a/gtk/gtkfilechooserwidget.c b/gtk/gtkfilechooserwidget.c +index 34e3473..16a4f2c 100644 +--- a/gtk/gtkfilechooserwidget.c ++++ b/gtk/gtkfilechooserwidget.c +@@ -236,6 +236,7 @@ struct _GtkFileChooserWidget + LocationMode location_mode; + + GtkWidget *external_entry; ++ GtkEventController *external_entry_controller; + + GtkWidget *choice_box; + GHashTable *choices; +@@ -2302,6 +2303,28 @@ forward_key (GtkEventControllerKey *key, + return gtk_event_controller_key_forward (key, GTK_WIDGET (impl)); + } + ++static void ++external_entry_setup (GtkFileChooserWidget *impl) ++{ ++ /* Make keybindings (for example, Ctrl+H to toggle showing hidden files) ++ * work even when the focus is on the external entry (which is outside ++ * the hierarchy of GtkFileChooserWidget) */ ++ ++ impl->external_entry_controller = gtk_event_controller_key_new (); ++ gtk_event_controller_set_propagation_phase (impl->external_entry_controller, ++ GTK_PHASE_BUBBLE); ++ g_signal_connect (impl->external_entry_controller, "key-pressed", ++ G_CALLBACK (forward_key), impl); ++ gtk_widget_add_controller (impl->external_entry, impl->external_entry_controller); ++} ++ ++static void ++external_entry_disconnect (GtkFileChooserWidget *impl) ++{ ++ gtk_widget_remove_controller (impl->external_entry, impl->external_entry_controller); ++ impl->external_entry_controller = NULL; ++} ++ + /* Creates the widgets specific to Save mode */ + static void + save_widgets_create (GtkFileChooserWidget *impl) +@@ -2323,10 +2346,7 @@ save_widgets_create (GtkFileChooserWidget *impl) + impl->location_entry = impl->external_entry; + g_object_add_weak_pointer (G_OBJECT (impl->external_entry), (gpointer *)&impl->location_entry); + location_entry_setup (impl); +- +- g_signal_connect_after (gtk_entry_get_key_controller (GTK_ENTRY (impl->external_entry)), +- "key-pressed", +- G_CALLBACK (forward_key), impl); ++ external_entry_setup (impl); + return; + } + +@@ -2363,9 +2383,7 @@ save_widgets_destroy (GtkFileChooserWidget *impl) + { + if (impl->external_entry && impl->external_entry == impl->location_entry) + { +- g_signal_handlers_disconnect_by_func (gtk_entry_get_key_controller (GTK_ENTRY (impl->external_entry)), +- forward_key, impl); +- ++ external_entry_disconnect (impl); + location_entry_disconnect (impl); + impl->location_entry = NULL; + } +@@ -3104,7 +3122,6 @@ gtk_file_chooser_widget_dispose (GObject *object) + GtkFileChooserWidget *impl = (GtkFileChooserWidget *) object; + + cancel_all_operations (impl); +- + g_clear_pointer (&impl->rename_file_popover, gtk_widget_unparent); + g_clear_pointer (&impl->browse_files_popover, gtk_widget_unparent); + g_clear_object (&impl->extra_widget); +@@ -3112,6 +3129,7 @@ gtk_file_chooser_widget_dispose (GObject *object) + + if (impl->external_entry && impl->location_entry == impl->external_entry) + { ++ external_entry_disconnect (impl); + location_entry_disconnect (impl); + impl->external_entry = NULL; + } +@@ -7854,11 +7872,11 @@ gtk_file_chooser_widget_set_save_entry (GtkFileChooserWidget *impl, + g_return_if_fail (GTK_IS_FILE_CHOOSER_WIDGET (impl)); + g_return_if_fail (entry == NULL || GTK_IS_FILE_CHOOSER_ENTRY (entry)); + +- impl->external_entry = entry; +- + if (impl->action == GTK_FILE_CHOOSER_ACTION_SAVE) + { + save_widgets_destroy (impl); ++ ++ impl->external_entry = entry; + save_widgets_create (impl); + } + } diff --git a/debian/patches/series b/debian/patches/series index 351b2fdb5f..e723896ea4 100644 --- a/debian/patches/series +++ b/debian/patches/series @@ -3,3 +3,4 @@ reftest_compare_surfaces-Report-how-much-the-images-diffe.patch reftests-Allow-minor-differences-to-be-tolerated.patch debian/Skip-some-known-failing-tests-on-mips-family-architecture.patch debian/Disable-clipboard-test.patch +GtkFileChooserWidget-Propagate-keys-from-external-entry-t.patch -- 2.30.2