[nautilus] properties: Use dbus-launcher to open gnome-disks



commit 8d4682b98969cb07879f55b8c8dab00e1c957a55
Author: Corey Berla <corey berla me>
Date:   Mon May 9 12:41:19 2022 -0700

    properties: Use dbus-launcher to open gnome-disks
    
    Use the dbus_launcher to launch gnome disks rather than the
    commandline for stability and flatpak integration.
    
    Related to: https://gitlab.gnome.org/GNOME/nautilus/-/issues/1997

 src/nautilus-properties-window.c | 35 ++++++++++++++++++-----------------
 1 file changed, 18 insertions(+), 17 deletions(-)
---
diff --git a/src/nautilus-properties-window.c b/src/nautilus-properties-window.c
index e6fcc8a24..0335a6d61 100644
--- a/src/nautilus-properties-window.c
+++ b/src/nautilus-properties-window.c
@@ -36,6 +36,7 @@
 #include <libgnome-desktop/gnome-desktop-thumbnail.h>
 
 #include "nautilus-application.h"
+#include "nautilus-dbus-launcher.h"
 #include "nautilus-enums.h"
 #include "nautilus-error-reporting.h"
 #include "nautilus-file-operations.h"
@@ -2604,25 +2605,25 @@ static void
 open_in_disks (GtkButton                *button,
                NautilusPropertiesWindow *self)
 {
-    g_autofree char *message = NULL;
-    g_autoptr (GError) error = NULL;
-    g_autoptr (GAppInfo) app_info = NULL;
+    NautilusDBusLauncher *launcher = nautilus_dbus_launcher_get ();
+    g_autoptr (GMount) mount = NULL;
+    g_autoptr (GVolume) volume = NULL;
+    g_autofree gchar *device_identifier = NULL;
+    GVariant *parameters;
 
-    app_info = g_app_info_create_from_commandline ("gnome-disks",
-                                                   NULL,
-                                                   G_APP_INFO_CREATE_NONE,
-                                                   NULL);
+    mount = nautilus_file_get_mount (get_original_file (self));
+    volume = (mount != NULL) ? g_mount_get_volume (mount) : NULL;
+    device_identifier = g_volume_get_identifier (volume,
+                                                 G_VOLUME_IDENTIFIER_KIND_UNIX_DEVICE);
 
-    g_app_info_launch (app_info, NULL, NULL, &error);
+    parameters = g_variant_new_parsed ("(objectpath '/org/gnome/DiskUtility', "
+                                       "@aay [], {'options': <{'block-device': <%s>}> })",
+                                       device_identifier);
 
-    if (error != NULL)
-    {
-        message = g_strdup_printf (_("Details: %s"), error->message);
-        show_dialog (_("There was an error launching the application."),
-                     message,
-                     GTK_WINDOW (self),
-                     GTK_MESSAGE_ERROR);
-    }
+    nautilus_dbus_launcher_call (launcher,
+                                 NAUTILUS_DBUS_LAUNCHER_DISKS,
+                                 "CommandLine", parameters,
+                                 GTK_WINDOW (self));
 }
 
 static void
@@ -2796,9 +2797,9 @@ setup_basic_page (NautilusPropertiesWindow *self)
     {
         gtk_widget_show (self->volume_widget_box);
         gtk_widget_show (self->open_in_disks_button);
+        g_signal_connect (self->open_in_disks_button, "clicked", G_CALLBACK (open_in_disks), self);
         setup_volume_usage_widget (self);
         /*Translators: Here Disks mean the name of application GNOME Disks.*/
-        g_signal_connect (self->open_in_disks_button, "clicked", G_CALLBACK (open_in_disks), NULL);
     }
 }
 


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