Use the right device file UDisksObjectInfo.one_liner for a partition of a drive
authorDavid Zeuthen <zeuthen@gmail.com>
Wed, 17 Oct 2012 16:20:08 +0000 (12:20 -0400)
committerDavid Zeuthen <zeuthen@gmail.com>
Wed, 17 Oct 2012 16:20:08 +0000 (12:20 -0400)
E.g. use /dev/sdb1, not /dev/sdb

Signed-off-by: David Zeuthen <zeuthen@gmail.com>
udisks/udisksclient.c

index edb8a30..394c911 100644 (file)
@@ -2744,6 +2744,7 @@ udisks_client_get_object_info_for_drive (UDisksClient     *client,
   UDisksBlock *block = NULL;
   gchar *s;
   const gchar *cs;
+  UDisksBlock *block_for_partition = NULL;
 
   g_return_if_fail (UDISKS_IS_DRIVE (drive));
 
@@ -2999,6 +3000,16 @@ udisks_client_get_object_info_for_drive (UDisksClient     *client,
 
   if (partition != NULL)
     {
+      GDBusObject *object_for_partition;
+      object_for_partition = g_dbus_interface_get_object (G_DBUS_INTERFACE (partition));
+      if (object_for_partition != NULL)
+        block_for_partition = udisks_object_peek_block (UDISKS_OBJECT (object_for_partition));
+    }
+  if (block_for_partition == NULL)
+    block_for_partition = block;
+
+  if (partition != NULL)
+    {
       /* Translators: Used to describe a partition of a drive.
        *              The %d is the partition number.
        *              The %s is the description for the drive (e.g. "2 GB Thumb Drive").
@@ -3025,7 +3036,7 @@ udisks_client_get_object_info_for_drive (UDisksClient     *client,
                                              info->description,
                                              info->name,
                                              drive_revision,
-                                             udisks_block_get_preferred_device (block));
+                                             udisks_block_get_preferred_device (block_for_partition));
         }
       else
         {
@@ -3037,7 +3048,7 @@ udisks_client_get_object_info_for_drive (UDisksClient     *client,
           info->one_liner = g_strdup_printf (C_("one-liner-drive", "%s — %s — %s"),
                                              info->description,
                                              info->name,
-                                             udisks_block_get_preferred_device (block));
+                                             udisks_block_get_preferred_device (block_for_partition));
         }
     }