[gnome-commander] Add all unix devices with a UUID, but only if it was not manually add by the user already
- From: Uwe Scholz <uwescholz src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-commander] Add all unix devices with a UUID, but only if it was not manually add by the user already
- Date: Sun, 28 Nov 2021 11:32:36 +0000 (UTC)
commit d99c980bae70b7741b65765887b5d371763086fa
Author: Uwe Scholz <u scholz83 gmx de>
Date: Sun Nov 28 12:30:47 2021 +0100
Add all unix devices with a UUID, but only if it was not manually add by the user already
src/gnome-cmd-con-device.cc | 2 +-
src/gnome-cmd-data.cc | 41 ++++++++++++++++++++++-------------------
2 files changed, 23 insertions(+), 20 deletions(-)
---
diff --git a/src/gnome-cmd-con-device.cc b/src/gnome-cmd-con-device.cc
index c87fbfed..2e40386a 100644
--- a/src/gnome-cmd-con-device.cc
+++ b/src/gnome-cmd-con-device.cc
@@ -39,7 +39,7 @@ using namespace std;
struct GnomeCmdConDevicePrivate
{
gchar *alias {nullptr};
- gchar *device_fn {nullptr};
+ gchar *device_fn {nullptr}; // The device identifier (either a linux device string or a uuid)
gchar *mountp {nullptr};
gchar *icon_path {nullptr};
gboolean autovolume;
diff --git a/src/gnome-cmd-data.cc b/src/gnome-cmd-data.cc
index 4ba3ed9b..e8bf1c40 100644
--- a/src/gnome-cmd-data.cc
+++ b/src/gnome-cmd-data.cc
@@ -2142,10 +2142,14 @@ static void add_gvolume (GVolume *gVolume)
{
g_return_if_fail (gVolume != nullptr);
- char *uuid = g_volume_get_uuid (gVolume);
- auto *gIcon = g_volume_get_icon (gVolume);
- char *name = g_volume_get_name (gVolume);
- auto identifier = g_volume_get_identifier(gVolume, G_VOLUME_IDENTIFIER_KIND_UNIX_DEVICE);
+ auto uuid = g_volume_get_identifier(gVolume, G_VOLUME_IDENTIFIER_KIND_UUID);
+ auto unixDeviceString = g_volume_get_identifier(gVolume, G_VOLUME_IDENTIFIER_KIND_UNIX_DEVICE);
+ auto *gIcon = g_volume_get_icon (gVolume);
+ char *name = g_volume_get_name (gVolume);
+
+ DEBUG('m',"volume name = %s\n", name);
+ DEBUG('m',"volume uuid = %s\n", uuid);
+ DEBUG('m',"volume unix device = %s\n", unixDeviceString);
// Try to load the icon, using current theme
const gchar *iconpath = nullptr;
@@ -2158,32 +2162,31 @@ static void add_gvolume (GVolume *gVolume)
iconpath = gtk_icon_info_get_filename (iconinfo);
}
- DEBUG('m',"name = %s\n", name);
- DEBUG('m',"device path = %s\n", identifier);
- DEBUG('m',"uuid = %s\n", uuid);
- DEBUG('m',"icon path = %s\n", iconpath);
+ DEBUG('m',"volume icon path = %s\n", iconpath);
- // Don't create a new device connect if one already exists. This can happen if the user manually added
the same device in "Options|Devices" menu
- if (identifier && (!device_mount_point_exists (gnome_cmd_data.priv->con_list, identifier)))
+ // Only create a new device connection if it does not already exist.
+ // This can happen if the user manually added the same device in "Options|Devices" menu
+ // We have to compare each connection in con_list with the unixDeviceString for this.
+ if (unixDeviceString && (device_mount_point_exists (gnome_cmd_data.priv->con_list, unixDeviceString)))
{
- GnomeCmdConDevice *ConDev = gnome_cmd_con_device_new (name, identifier, nullptr, iconpath);
+ DEBUG('m', "Device for mountpoint(%s) already exists. AutoVolume not added\n", unixDeviceString);
+ }
+ // If it does not exist already and a UUID is available, create the new device connection
+ else if (uuid)
+ {
+ GnomeCmdConDevice *ConDev = gnome_cmd_con_device_new (name, uuid, nullptr, iconpath);
gnome_cmd_con_device_set_autovol (ConDev, TRUE);
gnome_cmd_con_device_set_gvolume (ConDev, gVolume);
gnome_cmd_data.priv->con_list->add(ConDev);
}
- else if (identifier)
- {
- DEBUG('m', "Device for mountpoint(%s) already exists. AutoVolume not added\n", identifier);
- }
else
{
- DEBUG('m', "Device does not look like unix device. Skipping\n");
+ DEBUG('m', "Device does not have a UUID. Skipping\n");
}
- g_free (uuid);
g_free (name);
- g_free (identifier);
-
+ g_free (uuid);
+ g_free (unixDeviceString);
g_object_unref (gIcon);
g_object_unref (gVolume);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]