[nautilus] autorun-software: Stop using blocking dialog functions



commit d87f5be77bb4ee03e363cb560aaefb00cf56b275
Author: Matthew Jakeman <mjakeman26 outlook co nz>
Date:   Tue Dec 14 18:32:57 2021 +1300

    autorun-software: Stop using blocking dialog functions
    
    Replaces gtk_dialog_run() with equivalent non-blocking
    behaviour for the nautilus-autorun-software utility.
    
    Part of #1992

 src/nautilus-autorun-software.c | 32 ++++++++++++++++++++++++--------
 1 file changed, 24 insertions(+), 8 deletions(-)
---
diff --git a/src/nautilus-autorun-software.c b/src/nautilus-autorun-software.c
index e0043ca30..edf0a35fb 100644
--- a/src/nautilus-autorun-software.c
+++ b/src/nautilus-autorun-software.c
@@ -161,8 +161,25 @@ out:
          *  there is no way to get it back. */
         gtk_window_set_keep_above (GTK_WINDOW (dialog), TRUE);
 
-        gtk_dialog_run (GTK_DIALOG (dialog));
-        gtk_widget_destroy (dialog);
+        g_signal_connect (dialog,
+                          "response",
+                          G_CALLBACK (gtk_widget_destroy),
+                          NULL);
+
+        gtk_widget_show_all (dialog);
+    }
+}
+
+static void
+autorun_software_dialog_response (GtkDialog *dialog,
+                                  gint       response_id,
+                                  GMount    *mount)
+{
+    gtk_widget_destroy (GTK_WIDGET (dialog));
+
+    if (response_id == GTK_RESPONSE_OK)
+    {
+        autorun (mount);
     }
 }
 
@@ -223,13 +240,12 @@ present_autorun_for_software_dialog (GMount *mount)
                            _("_Run"),
                            GTK_RESPONSE_OK);
 
-    gtk_widget_show_all (dialog);
+    g_signal_connect (dialog,
+                      "response",
+                      G_CALLBACK (autorun_software_dialog_response),
+                      mount);
 
-    if (gtk_dialog_run (GTK_DIALOG (dialog)) == GTK_RESPONSE_OK)
-    {
-        gtk_widget_destroy (dialog);
-        autorun (mount);
-    }
+    gtk_widget_show_all (dialog);
 }
 
 int


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