[gnome-disk-utility] Combine "Contents" and "In Use" fields



commit fb155287720a1ac2dec05f9ec19e3610a2d85cd3
Author: David Zeuthen <zeuthen gmail com>
Date:   Sat Oct 6 15:21:11 2012 -0400

    Combine "Contents" and "In Use" fields
    
    Much cleaner this way, see
    
     http://people.freedesktop.org/~david/gnome-disks-nuke-in-use-field.png
    
    Signed-off-by: David Zeuthen <zeuthen gmail com>

 data/ui/disks.ui      |   47 ++-------------
 src/disks/gduwindow.c |  153 ++++++++++++++++++++++++-------------------------
 2 files changed, 79 insertions(+), 121 deletions(-)
---
diff --git a/data/ui/disks.ui b/data/ui/disks.ui
index 99b4128..a4a68b2 100644
--- a/data/ui/disks.ui
+++ b/data/ui/disks.ui
@@ -1265,7 +1265,7 @@
                           <object class="GtkTable" id="devtab-table">
                             <property name="visible">True</property>
                             <property name="can_focus">False</property>
-                            <property name="n_rows">6</property>
+                            <property name="n_rows">5</property>
                             <property name="n_columns">2</property>
                             <property name="column_spacing">10</property>
                             <child>
@@ -1376,43 +1376,6 @@
                               </packing>
                             </child>
                             <child>
-                              <object class="GtkLabel" id="devtab-volume-in-use-label">
-                                <property name="visible">True</property>
-                                <property name="can_focus">False</property>
-                                <property name="xalign">1</property>
-                                <property name="label" translatable="yes">In Use</property>
-                                <style>
-                                  <class name="dim-label"/>
-                                </style>
-                              </object>
-                              <packing>
-                                <property name="top_attach">4</property>
-                                <property name="bottom_attach">5</property>
-                                <property name="x_options">GTK_FILL</property>
-                                <property name="y_options"/>
-                                <property name="y_padding">4</property>
-                              </packing>
-                            </child>
-                            <child>
-                              <object class="GtkLabel" id="devtab-volume-in-use-value-label">
-                                <property name="visible">True</property>
-                                <property name="can_focus">False</property>
-                                <property name="hexpand">True</property>
-                                <property name="xalign">0</property>
-                                <property name="selectable">True</property>
-                                <property name="ellipsize">end</property>
-                              </object>
-                              <packing>
-                                <property name="left_attach">1</property>
-                                <property name="right_attach">2</property>
-                                <property name="top_attach">4</property>
-                                <property name="bottom_attach">5</property>
-                                <property name="x_options">GTK_FILL</property>
-                                <property name="y_options"/>
-                                <property name="y_padding">4</property>
-                              </packing>
-                            </child>
-                            <child>
                               <object class="GtkLabel" id="devtab-partition-label">
                                 <property name="visible">True</property>
                                 <property name="can_focus">False</property>
@@ -1461,8 +1424,8 @@
                                 </style>
                               </object>
                               <packing>
-                                <property name="top_attach">5</property>
-                                <property name="bottom_attach">6</property>
+                                <property name="top_attach">4</property>
+                                <property name="bottom_attach">5</property>
                                 <property name="x_options">GTK_FILL</property>
                                 <property name="y_padding">4</property>
                               </packing>
@@ -1542,8 +1505,8 @@
                               <packing>
                                 <property name="left_attach">1</property>
                                 <property name="right_attach">2</property>
-                                <property name="top_attach">5</property>
-                                <property name="bottom_attach">6</property>
+                                <property name="top_attach">4</property>
+                                <property name="bottom_attach">5</property>
                                 <property name="y_options">GTK_FILL</property>
                               </packing>
                             </child>
diff --git a/src/disks/gduwindow.c b/src/disks/gduwindow.c
index 9ccc3bb..f02b69f 100644
--- a/src/disks/gduwindow.c
+++ b/src/disks/gduwindow.c
@@ -2857,6 +2857,7 @@ update_device_page_for_block (GduWindow          *window,
   UDisksPartitionTable *partition_table = NULL;
   gboolean read_only;
   gchar *s, *s2, *s3;
+  gchar *in_use_markup = NULL;
   UDisksObject *drive_object;
   UDisksDrive *drive = NULL;
   GList *jobs;
@@ -2956,60 +2957,18 @@ update_device_page_for_block (GduWindow          *window,
       g_free (s);
     }
 
+  /* ------------------------------ */
+  /* 'Contents' field */
+
   usage = udisks_block_get_id_usage (block);
   type = udisks_block_get_id_type (block);
   version = udisks_block_get_id_version (block);
 
-  if (size > 0)
-    {
-      if (partition != NULL && udisks_partition_get_is_container (partition))
-        {
-          s = g_strdup (_("Extended Partition"));
-        }
-      else
-        {
-          s = udisks_client_get_id_for_display (window->client, usage, type, version, TRUE);
-          if (g_strcmp0 (udisks_block_get_mdraid_member (block), "/") != 0)
-            {
-              s2 = g_strdup_printf ("<a href=\"x-udisks://%s\">%s</a>",
-                                    udisks_block_get_mdraid_member (block),
-                                    /* Translators: Shown as a hyperlink in the 'Contents' field for a member of an RAID Array */
-                                    C_("raid-member", "Go To Array"));
-              /* Translators: Shown in the 'Contents' field for a member of an RAID array.
-               *              The first %s is the usual contents string (e.g. "Linux RAID Member").
-               *              The second %s is the hyperlink "Go To Array".
-               */
-              s3 = g_strdup_printf (C_("raid-member", "%s â %s"), s, s2);
-              g_free (s); s = s3;
-            }
-        }
-    }
-  else
-    {
-      s = NULL;
-    }
-  set_markup (window,
-              "devtab-volume-type-label",
-              "devtab-volume-type-value-label",
-              s, SET_MARKUP_FLAGS_HYPHEN_IF_EMPTY);
-  g_free (s);
-
-  if (partition != NULL)
-    {
-      if (!read_only)
-        show_flags->volume_menu |= SHOW_FLAGS_VOLUME_MENU_EDIT_PARTITION;
-    }
-  else
-    {
-      if (drive != NULL && udisks_drive_get_ejectable (drive))
-        show_flags->drive_buttons |= SHOW_FLAGS_DRIVE_BUTTONS_EJECT;
-    }
-
+  /* Figure out in use */
+  in_use_markup = NULL;
   if (filesystem != NULL)
     {
       const gchar *const *mount_points;
-      gchar *mount_point;
-
       mount_points = udisks_filesystem_get_mount_points (filesystem);
       if (g_strv_length ((gchar **) mount_points) > 0)
         {
@@ -3018,28 +2977,22 @@ update_device_page_for_block (GduWindow          *window,
             {
               /* Translators: Use for mount point '/' simply because '/' is too small to hit as a hyperlink
                */
-              s = g_strdup_printf ("<a href=\"file:///\">%s</a>", _("Filesystem Root"));
+              s = g_strdup_printf ("<a href=\"file:///\">%s</a>", C_("volume-content-fs", "Filesystem Root"));
             }
           else
             {
               s = g_strdup_printf ("<a href=\"file://%s\">%s</a>",
                                    mount_points[0], mount_points[0]);
             }
-          /* Translators: Shown next to "In Use". The first %s is the mount point, e.g. /media/foobar */
-          mount_point = g_strdup_printf (_("Yes, mounted at %s"), s);
+          /* Translators: Shown as in-use part of 'Contents'. The first %s is the mount point, e.g. /media/foobar */
+          in_use_markup = g_strdup_printf (C_("volume-content-fs", "Mounted at %s"), s);
           g_free (s);
         }
       else
         {
           /* Translators: Shown when the device is not mounted next to the "In Use" label */
-          mount_point = g_strdup (_("No"));
+          in_use_markup = g_strdup (C_("volume-content-fs", "Not Mounted"));
         }
-      set_markup (window,
-                  "devtab-volume-in-use-label",
-                  "devtab-volume-in-use-value-label",
-                  mount_point,
-                  SET_MARKUP_FLAGS_NONE);
-      g_free (mount_point);
 
       if (g_strv_length ((gchar **) mount_points) > 0)
         show_flags->volume_buttons |= SHOW_FLAGS_VOLUME_BUTTONS_UNMOUNT;
@@ -3054,58 +3007,99 @@ update_device_page_for_block (GduWindow          *window,
            g_strcmp0 (udisks_block_get_id_type (block), "swap") == 0)
     {
       UDisksSwapspace *swapspace;
-      const gchar *str;
       swapspace = udisks_object_peek_swapspace (object);
       if (swapspace != NULL)
         {
           if (udisks_swapspace_get_active (swapspace))
             {
               show_flags->volume_buttons |= SHOW_FLAGS_VOLUME_BUTTONS_DEACTIVATE_SWAP;
-              /* Translators: Shown if the swap device is in use next to the "In Use" label */
-              str = _("Yes");
+              /* Translators: Shown as in-use part of 'Contents' if the swap device is in use */
+              in_use_markup = g_strdup (C_("volume-content-swap", "Active"));
             }
           else
             {
               show_flags->volume_buttons |= SHOW_FLAGS_VOLUME_BUTTONS_ACTIVATE_SWAP;
-              /* Translators: Shown if the swap device is not in use next to the "In Use" label */
-              str = _("No");
+              /* Translators: Shown as in-use part of 'Contents' if the swap device is not in use */
+              in_use_markup = g_strdup (C_("volume-content-swap", "Not Active"));
             }
-          set_markup (window,
-                      "devtab-volume-in-use-label",
-                      "devtab-volume-in-use-value-label",
-                      str,
-                      SET_MARKUP_FLAGS_NONE);
         }
     }
   else if (g_strcmp0 (udisks_block_get_id_usage (block), "crypto") == 0)
     {
       UDisksObject *cleartext_device;
-      const gchar *str;
-
       cleartext_device = lookup_cleartext_device_for_crypto_device (window->client,
                                                                     g_dbus_object_get_object_path (G_DBUS_OBJECT (object)));
       if (cleartext_device != NULL)
         {
           show_flags->volume_buttons |= SHOW_FLAGS_VOLUME_BUTTONS_ENCRYPTED_LOCK;
-          /* Translators: Shown if the encrypted device is unlocked next to the "In Use" label */
-          str = _("Yes");
+          /* Translators: Shown as in-use part of 'Contents' if the encrypted device is unlocked */
+          in_use_markup = g_strdup (C_("volume-content-luks", "Unlocked"));
         }
       else
         {
           show_flags->volume_buttons |= SHOW_FLAGS_VOLUME_BUTTONS_ENCRYPTED_UNLOCK;
-          /* Translators: Shown if the encrypted device is not unlocked next to the "In Use" label */
-          str = _("No");
+          /* Translators: Shown as in-use part of 'Contents' if the encrypted device is unlocked */
+          in_use_markup = g_strdup (C_("volume-content-luks", "Locked"));
         }
-      set_markup (window,
-                  "devtab-volume-in-use-label",
-                  "devtab-volume-in-use-value-label",
-                  str,
-                  SET_MARKUP_FLAGS_NONE);
-
       show_flags->volume_menu |= SHOW_FLAGS_VOLUME_MENU_CONFIGURE_CRYPTTAB;
       show_flags->volume_menu |= SHOW_FLAGS_VOLUME_MENU_CHANGE_PASSPHRASE;
     }
 
+  if (size > 0)
+    {
+      if (partition != NULL && udisks_partition_get_is_container (partition))
+        {
+          s = g_strdup (C_("volume-contents-msdos-ext", "Extended Partition"));
+        }
+      else
+        {
+          s = udisks_client_get_id_for_display (window->client, usage, type, version, TRUE);
+          if (g_strcmp0 (udisks_block_get_mdraid_member (block), "/") != 0)
+            {
+              s2 = g_strdup_printf ("<a href=\"x-udisks://%s\">%s</a>",
+                                    udisks_block_get_mdraid_member (block),
+                                    /* Translators: Shown as a hyperlink in the 'Contents' field for a member of an RAID Array */
+                                    C_("volume-contents-raid", "Go To Array"));
+              /* Translators: Shown in the 'Contents' field for a member of an RAID array.
+               *              The first %s is the usual contents string (e.g. "Linux RAID Member").
+               *              The second %s is the hyperlink "Go To Array".
+               */
+              s3 = g_strdup_printf (C_("volume-contents-raid", "%s â %s"), s, s2);
+              g_free (s); s = s3;
+            }
+        }
+    }
+  else
+    {
+      s = NULL;
+    }
+
+  if (in_use_markup != NULL)
+    {
+      /* Translators: Shown in 'Contents' field for a member that can be "mounted" (e.g. filesystem or swap area).
+       *              The first %s is the usual contents string e.g. "Swapspace" or "Ext4 (version 1.0)".
+       *              The second %s is either "Mounted at /path/to/fs", "Not Mounted, "Active", "Not Active", "Unlocked" or "Locked".
+       */
+      s2 = g_strdup_printf (C_("volume-contents-combiner", "%s â %s"), s, in_use_markup);
+      g_free (s); s = s2;
+    }
+  set_markup (window,
+              "devtab-volume-type-label",
+              "devtab-volume-type-value-label",
+              s, SET_MARKUP_FLAGS_HYPHEN_IF_EMPTY);
+  g_free (s);
+
+  if (partition != NULL)
+    {
+      if (!read_only)
+        show_flags->volume_menu |= SHOW_FLAGS_VOLUME_MENU_EDIT_PARTITION;
+    }
+  else
+    {
+      if (drive != NULL && udisks_drive_get_ejectable (drive))
+        show_flags->drive_buttons |= SHOW_FLAGS_DRIVE_BUTTONS_EJECT;
+    }
+
   jobs = udisks_client_get_jobs_for_object (window->client, object);
   if (jobs == NULL)
     {
@@ -3153,6 +3147,7 @@ update_device_page_for_block (GduWindow          *window,
   g_list_foreach (jobs, (GFunc) g_object_unref, NULL);
   g_list_free (jobs);
   g_clear_object (&partition_table);
+  g_free (in_use_markup);
 }
 
 static void



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