diff options
author | Corey Berla <corey@berla.me> | 2022-08-23 09:52:52 -0700 |
---|---|---|
committer | Corey Berla <corey@berla.me> | 2022-08-31 23:58:07 +0000 |
commit | d761df22f62c25a01e99823aad568b1ef75395c1 (patch) | |
tree | 09fc1e1b14a7be1e7363947b6995eda970db90b1 | |
parent | 65cff25aa0abeb25aecf9b01bc33b650f2227843 (diff) | |
download | nautilus-d761df22f62c25a01e99823aad568b1ef75395c1.tar.gz |
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").
So, use unix-specific API to handle that case (antoniof's ammendment).
As a 2nd fallback, just open Disks without selecting anything (but if
this ever happens, it's a bug: we probably shouldn't show the Disks
section in Properties in that directory).
Fixes: https://gitlab.gnome.org/GNOME/nautilus/-/issues/2447
-rw-r--r-- | src/nautilus-properties-window.c | 36 |
1 files changed, 31 insertions, 5 deletions
diff --git a/src/nautilus-properties-window.c b/src/nautilus-properties-window.c index 67f88ea08..3343fa4eb 100644 --- a/src/nautilus-properties-window.c +++ b/src/nautilus-properties-window.c @@ -28,6 +28,7 @@ #include <gtk/gtk.h> #include <gdk/gdkkeysyms.h> #include <glib/gi18n.h> +#include <gio/gunixmounts.h> #include <nautilus-extension.h> #include <string.h> #include <sys/stat.h> @@ -2613,12 +2614,37 @@ 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); + } + else + { + g_autoptr (GFile) location = NULL; + g_autofree gchar *path = NULL; + g_autoptr (GUnixMountEntry) mount_entry = NULL; + + location = nautilus_file_get_location (get_original_file (self)); + path = g_file_get_path (location); + mount_entry = (path != NULL) ? g_unix_mount_at (path, NULL) : NULL; + if (mount_entry != NULL) + { + device_identifier = g_strdup (g_unix_mount_get_device_path (mount_entry)); + } + } + + if (device_identifier != NULL) + { + 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, |