[nautilus/wip/corey/properties: 40/44] properties: Fix opening gnome-disks for root filesystem




commit c8969ca6ad70e6369dba4061cc0c5060a3b9033a
Author: Corey Berla <corey berla me>
Date:   Tue Aug 23 09:52:52 2022 -0700

    properties: Fix opening gnome-disks for root filesystem
    
    With the introduction of nautilus-dbus-launcher, we made it so that
    the current disk is selected in gnome-disks (when opening from the
    properties window) by passing the disk identifier to --block-device.
    This works fine for most mounted volumes, but breaks the ability to
    open gnome-disks for the root filesystem because
    g_file_find_enclosing_mount() doesn't return a mount for the root file
    system (it only returns "user interesting locations").  Rather than
    creating a more complicated setup, use the old behavior for the root
    filesystem where no volume is selected by default.
    
    Fixes: https://gitlab.gnome.org/GNOME/nautilus/-/issues/2447

 src/nautilus-properties-window.c | 18 +++++++++++++-----
 1 file changed, 13 insertions(+), 5 deletions(-)
---
diff --git a/src/nautilus-properties-window.c b/src/nautilus-properties-window.c
index 67f88ea08..f33606cbd 100644
--- a/src/nautilus-properties-window.c
+++ b/src/nautilus-properties-window.c
@@ -2613,12 +2613,20 @@ open_in_disks (NautilusPropertiesWindow *self)
 
     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);
 
-    parameters = g_variant_new_parsed ("(objectpath '/org/gnome/DiskUtility', "
-                                       "@aay [], {'options': <{'block-device': <%s>}> })",
-                                       device_identifier);
+    if (volume != NULL)
+    {
+        device_identifier = g_volume_get_identifier (volume,
+                                                     G_VOLUME_IDENTIFIER_KIND_UNIX_DEVICE);
+
+        parameters = g_variant_new_parsed ("(objectpath '/org/gnome/DiskUtility', "
+                                           "@aay [], {'options': <{'block-device': <%s>}> })",
+                                           device_identifier);
+    }
+    else
+    {
+        parameters = g_variant_new_parsed ("(objectpath '/org/gnome/DiskUtility', @aay [], @a{sv} {})");
+    }
 
     nautilus_dbus_launcher_call (launcher,
                                  NAUTILUS_DBUS_LAUNCHER_DISKS,


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