[nautilus/wip/coreyberla/app-chooser-fixes: 6/9] app-chooser: Connect application-activated signal




commit 4e7d17fbb091877b7baf34175b8887aef063fac2
Author: Corey Berla <corey berla me>
Date:   Sun Aug 7 21:17:43 2022 -0700

    app-chooser: Connect application-activated signal
    
    The app chooser doesn't work correctly when user the <Enter> key.
    Connect to the application-activated signal to properly handle this
    and other situations where it's activated.
    
    Related: https://gitlab.gnome.org/GNOME/nautilus/-/issues/2390

 src/nautilus-app-chooser.c               | 13 ++++++++++---
 src/resources/ui/nautilus-app-chooser.ui |  2 +-
 2 files changed, 11 insertions(+), 4 deletions(-)
---
diff --git a/src/nautilus-app-chooser.c b/src/nautilus-app-chooser.c
index 00af912a7..3c9367f78 100644
--- a/src/nautilus-app-chooser.c
+++ b/src/nautilus-app-chooser.c
@@ -41,8 +41,7 @@ enum
 };
 
 static void
-open_button_clicked_cb (GtkButton          *button,
-                        NautilusAppChooser *self)
+open_cb (NautilusAppChooser *self)
 {
     gboolean set_new_default = FALSE;
     g_autoptr (GAppInfo) info = NULL;
@@ -81,7 +80,13 @@ open_button_clicked_cb (GtkButton          *button,
         adw_message_dialog_add_response (ADW_MESSAGE_DIALOG (message_dialog), "close", _("OK"));
         gtk_window_present (GTK_WINDOW (message_dialog));
     }
+}
 
+static void
+on_application_activated (NautilusAppChooser *self)
+{
+    open_cb (self);
+    gtk_dialog_response (GTK_DIALOG (self), GTK_RESPONSE_OK);
 }
 
 static void
@@ -182,6 +187,8 @@ nautilus_app_chooser_constructed (GObject *object)
 
     g_signal_connect_object (self->app_chooser_widget, "application-selected",
                              G_CALLBACK (on_application_selected), self, 0);
+    g_signal_connect_object (self->app_chooser_widget, "application-activated",
+                             G_CALLBACK (on_application_activated), self, G_CONNECT_SWAPPED);
 
     if (self->file_name != NULL)
     {
@@ -246,7 +253,7 @@ nautilus_app_chooser_class_init (NautilusAppChooserClass *klass)
     gtk_widget_class_bind_template_child (widget_class, NautilusAppChooser, label_content_type_description);
     gtk_widget_class_bind_template_child (widget_class, NautilusAppChooser, set_default_box);
 
-    gtk_widget_class_bind_template_callback (widget_class, open_button_clicked_cb);
+    gtk_widget_class_bind_template_callback (widget_class, open_cb);
 
     g_object_class_install_property (object_class,
                                      PROP_CONTENT_TYPE,
diff --git a/src/resources/ui/nautilus-app-chooser.ui b/src/resources/ui/nautilus-app-chooser.ui
index 721006920..5d1b838e5 100644
--- a/src/resources/ui/nautilus-app-chooser.ui
+++ b/src/resources/ui/nautilus-app-chooser.ui
@@ -129,7 +129,7 @@
         <property name="label" translatable="yes">_Open</property>
         <property name="use-underline">True</property>
         <property name="sensitive">False</property>
-        <signal name="clicked" object="NautilusAppChooser" handler="open_button_clicked_cb" swapped="no"/>
+        <signal name="clicked" object="NautilusAppChooser" handler="open_cb" swapped="yes"/>
       </object>
     </child>
     <action-widgets>


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