[gnome-disk-utility/udisks2-port] Avoid usage of words like /etc/fstab and /etc/crypttab as much as possible



commit 50d1c0e7c324b28b3a01bf015bf0a67de1b48ea4
Author: David Zeuthen <davidz redhat com>
Date:   Thu Aug 11 16:47:49 2011 -0400

    Avoid usage of words like /etc/fstab and /etc/crypttab as much as possible
    
    Also show a small star in the grid if a device is configured!
    
    Signed-off-by: David Zeuthen <davidz redhat com>

 data/ui/palimpsest.ui          |    4 +-
 src/palimpsest/gduvolumegrid.c |   11 +++-
 src/palimpsest/gduwindow.c     |  162 +++++++++++++++++++++++++--------------
 3 files changed, 116 insertions(+), 61 deletions(-)
---
diff --git a/data/ui/palimpsest.ui b/data/ui/palimpsest.ui
index efe2ad6..03aabf1 100644
--- a/data/ui/palimpsest.ui
+++ b/data/ui/palimpsest.ui
@@ -957,7 +957,7 @@
         <property name="visible">True</property>
         <property name="can_focus">False</property>
         <property name="use_action_appearance">False</property>
-        <property name="label" translatable="yes">Edit /etc/fstab entry...</property>
+        <property name="label" translatable="yes">Configure mount options...</property>
         <property name="use_underline">True</property>
       </object>
     </child>
@@ -966,7 +966,7 @@
         <property name="visible">True</property>
         <property name="can_focus">False</property>
         <property name="use_action_appearance">False</property>
-        <property name="label" translatable="yes">Edit /etc/crypttab entry...</property>
+        <property name="label" translatable="yes">Configure encryption...</property>
         <property name="use_underline">True</property>
       </object>
     </child>
diff --git a/src/palimpsest/gduvolumegrid.c b/src/palimpsest/gduvolumegrid.c
index 20c5cf7..89dfde7 100644
--- a/src/palimpsest/gduvolumegrid.c
+++ b/src/palimpsest/gduvolumegrid.c
@@ -75,6 +75,7 @@ struct GridElement
   gboolean show_padlock_open;
   gboolean show_padlock_closed;
   gboolean show_mounted;
+  gboolean show_configured;
 
   /* used for the job spinner */
   guint spinner_current;
@@ -1234,7 +1235,12 @@ render_element (GduVolumeGrid *grid,
   if (element->show_mounted)
     g_ptr_array_add (pixbufs_to_render,
                      gtk_icon_theme_load_icon (gtk_icon_theme_get_default (),
-                                               "gdu-state-mounted-symbolic",
+                                               "media-playback-start-symbolic",
+                                               12, 0, NULL));
+  if (element->show_configured)
+    g_ptr_array_add (pixbufs_to_render,
+                     gtk_icon_theme_load_icon (gtk_icon_theme_get_default (),
+                                               "user-bookmarks-symbolic",
                                                12, 0, NULL));
   for (n = 0; n < pixbufs_to_render->len; n++)
     {
@@ -1925,6 +1931,9 @@ grid_element_set_details (GduVolumeGrid  *grid,
         version = udisks_block_device_get_id_version (block);
         partition_type = strtol (udisks_block_device_get_part_entry_type (block), NULL, 0);
 
+        if (g_variant_n_children (udisks_block_device_get_configuration (block)) > 0)
+          element->show_configured = TRUE;
+
         if (udisks_block_device_get_part_entry (block) &&
             g_strcmp0 (udisks_block_device_get_part_entry_scheme (block), "mbr") == 0 &&
             (partition_type == 0x05 || partition_type == 0x0f || partition_type == 0x85))
diff --git a/src/palimpsest/gduwindow.c b/src/palimpsest/gduwindow.c
index 6fb8974..3df0422 100644
--- a/src/palimpsest/gduwindow.c
+++ b/src/palimpsest/gduwindow.c
@@ -1499,6 +1499,90 @@ lookup_cleartext_device_for_crypto_device (UDisksClient  *client,
   return ret;
 }
 
+static gchar *
+calculate_configuration_for_display (UDisksBlockDevice *block)
+{
+  GString *str;
+  GVariantIter iter;
+  const gchar *config_type;
+  gboolean mentioned_fstab = FALSE;
+  gboolean mentioned_crypttab = FALSE;
+
+  /* TODO: could include more details such as whether the
+   * device is activated at boot time
+   */
+
+  str = g_string_new (NULL);
+  g_variant_iter_init (&iter, udisks_block_device_get_configuration (block));
+  while (g_variant_iter_next (&iter, "(&s a{sv})", &config_type, NULL))
+    {
+      if (g_strcmp0 (config_type, "fstab") == 0)
+        {
+          if (!mentioned_fstab)
+            {
+              mentioned_fstab = TRUE;
+              if (str->len > 0)
+                g_string_append (str, ", ");
+              /* Translators: Shown when the device is configured in /etc/fstab.
+               * Do not translate "/etc/fstab".
+               */
+              g_string_append (str, _("Yes (via /etc/fstab)"));
+            }
+        }
+      else if (g_strcmp0 (config_type, "crypttab") == 0)
+        {
+          if (!mentioned_crypttab)
+            {
+              mentioned_crypttab = TRUE;
+              if (str->len > 0)
+                g_string_append (str, ", ");
+              /* Translators: Shown when the device is configured in /etc/crypttab.
+               * Do not translate "/etc/crypttab".
+               */
+              g_string_append (str, _("Yes (via /etc/crypttab)"));
+            }
+        }
+      else
+        {
+          if (str->len > 0)
+            g_string_append (str, ", ");
+          g_string_append (str, config_type);
+        }
+    }
+
+  if (str->len == 0)
+    {
+      /* Translators: Shown when the device is not configured */
+      g_string_append (str, _("No"));
+    }
+
+  return g_string_free (str, FALSE);
+}
+
+static gboolean
+has_configuration (UDisksBlockDevice *block,
+                   const gchar       *type)
+{
+  GVariantIter iter;
+  const gchar *config_type;
+  gboolean ret;
+
+  ret = FALSE;
+
+  g_variant_iter_init (&iter, udisks_block_device_get_configuration (block));
+  while (g_variant_iter_next (&iter, "(&s a{sv})", &config_type, NULL))
+    {
+      if (g_strcmp0 (config_type, type) == 0)
+        {
+          ret = TRUE;
+          goto out;
+        }
+    }
+
+ out:
+  return ret;
+}
+
 static void
 update_device_page_for_block (GduWindow          *window,
                               UDisksObject       *object,
@@ -1511,9 +1595,17 @@ update_device_page_for_block (GduWindow          *window,
   const gchar *version;
   gint partition_type;
   gchar *type_for_display;
+  gchar *configuration_for_display;
 
-  /* any device can be referenced in /etc/fstab even if it has no media or the type is unknown */
-  *show_flags |= SHOW_FLAGS_POPUP_MENU_CONFIGURE_FSTAB;
+  /* Since /etc/fstab, /etc/crypttab and so on can reference
+   * any device regardless of its content ... we want to show
+   * the relevant menu option (to get to the configuration dialog)
+   * if the device matches the configuration....
+   */
+  if (has_configuration (block, "fstab"))
+    *show_flags |= SHOW_FLAGS_POPUP_MENU_CONFIGURE_FSTAB;
+  if (has_configuration (block, "crypttab"))
+    *show_flags |= SHOW_FLAGS_POPUP_MENU_CONFIGURE_CRYPTTAB;
 
   //g_debug ("In update_device_page_for_block() - size=%" G_GUINT64_FORMAT " selected=%s",
   //         size,
@@ -1589,6 +1681,7 @@ update_device_page_for_block (GduWindow          *window,
   if (g_strcmp0 (udisks_block_device_get_id_usage (block), "filesystem") == 0)
     {
       UDisksFilesystem *filesystem;
+
       filesystem = udisks_object_peek_filesystem (object);
       if (filesystem != NULL)
         {
@@ -1629,7 +1722,9 @@ update_device_page_for_block (GduWindow          *window,
           else
             *show_flags |= SHOW_FLAGS_MOUNT_BUTTON;
         }
+
       *show_flags |= SHOW_FLAGS_POPUP_MENU_EDIT_LABEL;
+      *show_flags |= SHOW_FLAGS_POPUP_MENU_CONFIGURE_FSTAB;
     }
   else if (g_strcmp0 (udisks_block_device_get_id_usage (block), "other") == 0 &&
            g_strcmp0 (udisks_block_device_get_id_type (block), "swap") == 0)
@@ -1686,62 +1781,13 @@ update_device_page_for_block (GduWindow          *window,
       *show_flags |= SHOW_FLAGS_POPUP_MENU_CONFIGURE_CRYPTTAB;
     }
 
-  /* Configuration */
-  if (TRUE)
-    {
-      GString *str;
-      GVariantIter iter;
-      const gchar *config_type;
-      gboolean mentioned_fstab = FALSE;
-      gboolean mentioned_crypttab = FALSE;
-
-      str = g_string_new (NULL);
-
-      g_variant_iter_init (&iter, udisks_block_device_get_configuration (block));
-      while (g_variant_iter_next (&iter, "(&sa{sv})", &config_type, NULL))
-        {
-          if (g_strcmp0 (config_type, "fstab") == 0)
-            {
-              if (!mentioned_fstab)
-                {
-                  mentioned_fstab = TRUE;
-                  if (str->len > 0)
-                    g_string_append (str, ", ");
-                  /* Translators: Shown when the device is configured in /etc/fstab.
-                   * Do not translate "/etc/fstab".
-                   */
-                  g_string_append (str, _("In /etc/fstab"));
-                }
-            }
-          else if (g_strcmp0 (config_type, "crypttab") == 0)
-            {
-              if (!mentioned_crypttab)
-                {
-                  mentioned_crypttab = TRUE;
-                  if (str->len > 0)
-                    g_string_append (str, ", ");
-                  /* Translators: Shown when the device is configured in /etc/crypttab.
-                   * Do not translate "/etc/crypttab".
-                   */
-                  g_string_append (str, _("In /etc/crypttab"));
-                }
-            }
-          else
-            {
-              if (str->len > 0)
-                g_string_append (str, ", ");
-              g_string_append (str, config_type);
-            }
-        }
-
-      set_markup (window,
-                  "devtab-volume-configured-label",
-                  "devtab-volume-configured-value-label",
-                  str->str,
-                  SET_MARKUP_FLAGS_HYPHEN_IF_EMPTY);
-      g_string_free (str, TRUE);
-    }
-
+  configuration_for_display = calculate_configuration_for_display (block);
+  set_markup (window,
+              "devtab-volume-configured-label",
+              "devtab-volume-configured-value-label",
+              configuration_for_display,
+              SET_MARKUP_FLAGS_HYPHEN_IF_EMPTY);
+  g_free (configuration_for_display);
 }
 
 static void



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