[gnome-disk-utility/wip/mdraid] Convey array state



commit 75f0c82a2f8c1e2da1d3107a403c16cc7ca4c58f
Author: David Zeuthen <zeuthen gmail com>
Date:   Thu Sep 13 12:56:05 2012 -0400

    Convey array state
    
    We still need to convey the progress / time-remaining of sync actions
    like e.g. "repair" or "recover". Coming soon!
    
    Signed-off-by: David Zeuthen <zeuthen gmail com>

 data/ui/disks.ui               |  105 ++++++++++++++++++++----------
 src/disks/gdudevicetreemodel.c |   32 +++++++--
 src/disks/gduwindow.c          |  136 ++++++++++++++++++++++++++++++++--------
 3 files changed, 205 insertions(+), 68 deletions(-)
---
diff --git a/data/ui/disks.ui b/data/ui/disks.ui
index e35828a..7e8373e 100644
--- a/data/ui/disks.ui
+++ b/data/ui/disks.ui
@@ -237,7 +237,7 @@
                   <object class="GtkTable" id="devtab-drive-table">
                     <property name="visible">True</property>
                     <property name="can_focus">False</property>
-                    <property name="n_rows">12</property>
+                    <property name="n_rows">13</property>
                     <property name="n_columns">2</property>
                     <property name="column_spacing">10</property>
                     <child>
@@ -284,8 +284,8 @@
                         <style><class name="dim-label"/></style>
                       </object>
                       <packing>
-                        <property name="top_attach">7</property>
-                        <property name="bottom_attach">8</property>
+                        <property name="top_attach">8</property>
+                        <property name="bottom_attach">9</property>
                         <property name="x_options">GTK_FILL</property>
                         <property name="y_options"/>
                         <property name="y_padding">4</property>
@@ -303,8 +303,8 @@
                       <packing>
                         <property name="left_attach">1</property>
                         <property name="right_attach">2</property>
-                        <property name="top_attach">7</property>
-                        <property name="bottom_attach">8</property>
+                        <property name="top_attach">8</property>
+                        <property name="bottom_attach">9</property>
                         <property name="x_options">GTK_FILL</property>
                         <property name="y_options"/>
                         <property name="y_padding">4</property>
@@ -319,8 +319,8 @@
                         <style><class name="dim-label"/></style>
                       </object>
                       <packing>
-                        <property name="top_attach">8</property>
-                        <property name="bottom_attach">9</property>
+                        <property name="top_attach">9</property>
+                        <property name="bottom_attach">10</property>
                         <property name="x_options">GTK_FILL</property>
                         <property name="y_options"/>
                         <property name="y_padding">4</property>
@@ -338,8 +338,8 @@
                       <packing>
                         <property name="left_attach">1</property>
                         <property name="right_attach">2</property>
-                        <property name="top_attach">8</property>
-                        <property name="bottom_attach">9</property>
+                        <property name="top_attach">9</property>
+                        <property name="bottom_attach">10</property>
                         <property name="x_options">GTK_FILL</property>
                         <property name="y_options"/>
                         <property name="y_padding">4</property>
@@ -354,8 +354,8 @@
                         <style><class name="dim-label"/></style>
                       </object>
                       <packing>
-                        <property name="top_attach">9</property>
-                        <property name="bottom_attach">10</property>
+                        <property name="top_attach">10</property>
+                        <property name="bottom_attach">11</property>
                         <property name="x_options">GTK_FILL</property>
                         <property name="y_options"/>
                         <property name="y_padding">4</property>
@@ -373,8 +373,8 @@
                       <packing>
                         <property name="left_attach">1</property>
                         <property name="right_attach">2</property>
-                        <property name="top_attach">9</property>
-                        <property name="bottom_attach">10</property>
+                        <property name="top_attach">10</property>
+                        <property name="bottom_attach">11</property>
                         <property name="x_options">GTK_FILL</property>
                         <property name="y_options"/>
                         <property name="y_padding">4</property>
@@ -437,8 +437,8 @@
                         <style><class name="dim-label"/></style>
                       </object>
                       <packing>
-                        <property name="top_attach">10</property>
-                        <property name="bottom_attach">11</property>
+                        <property name="top_attach">11</property>
+                        <property name="bottom_attach">12</property>
                         <property name="x_options">GTK_FILL</property>
                         <property name="y_options"/>
                         <property name="y_padding">4</property>
@@ -456,8 +456,8 @@
                       <packing>
                         <property name="left_attach">1</property>
                         <property name="right_attach">2</property>
-                        <property name="top_attach">10</property>
-                        <property name="bottom_attach">11</property>
+                        <property name="top_attach">11</property>
+                        <property name="bottom_attach">12</property>
                         <property name="x_options">GTK_FILL</property>
                         <property name="y_options"/>
                         <property name="y_padding">4</property>
@@ -648,8 +648,8 @@
                         <style><class name="dim-label"/></style>
                       </object>
                       <packing>
-                        <property name="top_attach">11</property>
-                        <property name="bottom_attach">12</property>
+                        <property name="top_attach">12</property>
+                        <property name="bottom_attach">13</property>
                         <property name="x_options">GTK_FILL</property>
                         <property name="y_options">GTK_FILL</property>
                         <property name="y_padding">4</property>
@@ -732,8 +732,8 @@
                       <packing>
                         <property name="left_attach">1</property>
                         <property name="right_attach">2</property>
-                        <property name="top_attach">11</property>
-                        <property name="bottom_attach">12</property>
+                        <property name="top_attach">12</property>
+                        <property name="bottom_attach">13</property>
                         <property name="y_options"/>
                       </packing>
                     </child>
@@ -808,23 +808,23 @@
                       </packing>
                     </child>
                     <child>
-                      <object class="GtkLabel" id="devtab-drive-numdevices-label">
+                      <object class="GtkLabel" id="devtab-drive-size-label">
                         <property name="visible">True</property>
                         <property name="can_focus">False</property>
                         <property name="xalign">1</property>
-                        <property name="label" translatable="yes">Members</property>
+                        <property name="label" translatable="yes">Size</property>
                         <style><class name="dim-label"/></style>
                       </object>
                       <packing>
-                        <property name="top_attach">6</property>
-                        <property name="bottom_attach">7</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-drive-numdevices-value-label">
+                      <object class="GtkLabel" id="devtab-drive-size-value-label">
                         <property name="visible">True</property>
                         <property name="can_focus">False</property>
                         <property name="hexpand">True</property>
@@ -835,31 +835,31 @@
                       <packing>
                         <property name="left_attach">1</property>
                         <property name="right_attach">2</property>
-                        <property name="top_attach">6</property>
-                        <property name="bottom_attach">7</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-drive-size-label">
+                      <object class="GtkLabel" id="devtab-drive-raid-state-label">
                         <property name="visible">True</property>
                         <property name="can_focus">False</property>
                         <property name="xalign">1</property>
-                        <property name="label" translatable="yes">Size</property>
+                        <property name="label" translatable="yes">State</property>
                         <style><class name="dim-label"/></style>
                       </object>
                       <packing>
-                        <property name="top_attach">4</property>
-                        <property name="bottom_attach">5</property>
+                        <property name="top_attach">7</property>
+                        <property name="bottom_attach">8</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-drive-size-value-label">
+                      <object class="GtkLabel" id="devtab-drive-raid-state-value-label">
                         <property name="visible">True</property>
                         <property name="can_focus">False</property>
                         <property name="hexpand">True</property>
@@ -870,8 +870,43 @@
                       <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="top_attach">7</property>
+                        <property name="bottom_attach">8</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-drive-raid-degraded-label">
+                        <property name="visible">True</property>
+                        <property name="can_focus">False</property>
+                        <property name="xalign">1</property>
+                        <property name="label" translatable="yes">Degraded</property>
+                        <style><class name="dim-label"/></style>
+                      </object>
+                      <packing>
+                        <property name="top_attach">6</property>
+                        <property name="bottom_attach">7</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-drive-raid-degraded-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">6</property>
+                        <property name="bottom_attach">7</property>
                         <property name="x_options">GTK_FILL</property>
                         <property name="y_options"/>
                         <property name="y_padding">4</property>
diff --git a/src/disks/gdudevicetreemodel.c b/src/disks/gdudevicetreemodel.c
index 6af2a66..4118533 100644
--- a/src/disks/gdudevicetreemodel.c
+++ b/src/disks/gdudevicetreemodel.c
@@ -1123,13 +1123,29 @@ update_mdraid (GduDeviceTreeModel *model,
 
   icon = g_themed_icon_new ("gdu-enclosure");
 
-  /* TODO: once https://bugzilla.gnome.org/show_bug.cgi?id=657194 is resolved, use that instead
-   * of hard-coding the color
-   */
-  s = g_strdup_printf ("%s\n"
-                       "<small><span foreground=\"#555555\">%s</span></small>",
-                       desc,
-                       desc2);
+  if (udisks_mdraid_get_degraded (mdraid) > 0)
+    warning = TRUE;
+
+  if (warning)
+    {
+      /* TODO: once https://bugzilla.gnome.org/show_bug.cgi?id=657194 is resolved, use that instead
+       * of hard-coding the color
+       */
+      s = g_strdup_printf ("<span foreground=\"#ff0000\">%s</span>\n"
+                           "<small><span foreground=\"#ff0000\">%s</span></small>",
+                           desc,
+                           desc2);
+    }
+  else
+    {
+      /* TODO: once https://bugzilla.gnome.org/show_bug.cgi?id=657194 is resolved, use that instead
+       * of hard-coding the color
+       */
+      s = g_strdup_printf ("%s\n"
+                           "<small><span foreground=\"#555555\">%s</span></small>",
+                           desc,
+                           desc2);
+    }
 
   jobs_running = mdraid_has_jobs (model->client, mdraid);
 
@@ -1140,6 +1156,8 @@ update_mdraid (GduDeviceTreeModel *model,
   if (from_timer)
     pulse += 1;
 
+
+
   gtk_tree_store_set (GTK_TREE_STORE (model),
                       &iter,
                       GDU_DEVICE_TREE_MODEL_COLUMN_ICON, icon,
diff --git a/src/disks/gduwindow.c b/src/disks/gduwindow.c
index ec3ec5e..ba48a77 100644
--- a/src/disks/gduwindow.c
+++ b/src/disks/gduwindow.c
@@ -1875,6 +1875,8 @@ update_device_page_for_mdraid (GduWindow      *window,
   char hostname[512];
   GList *jobs = NULL;
   GList *members = NULL;
+  guint degraded;
+  const gchar *sync_action;
 
   gdu_volume_grid_set_no_media_string (GDU_VOLUME_GRID (window->volume_grid),
                                        _("RAID Array is not running"));
@@ -1884,6 +1886,8 @@ update_device_page_for_mdraid (GduWindow      *window,
   block = udisks_client_get_block_for_mdraid (window->client, mdraid);
   members = udisks_client_get_members_for_mdraid (window->client, mdraid);
   num_members = g_list_length (members);
+  degraded = udisks_mdraid_get_degraded (mdraid);
+  sync_action = udisks_mdraid_get_sync_action (mdraid);
 
   icon = g_themed_icon_new ("gdu-enclosure");
 
@@ -1933,11 +1937,16 @@ update_device_page_for_mdraid (GduWindow      *window,
   gtk_widget_show (window->devtab_drive_buttonbox);
   gtk_widget_show (window->devtab_drive_generic_button);
 
+  /* -------------------------------------------------- */
+  /* 'Size' field */
+
   set_size (window,
             "devtab-drive-size-label",
             "devtab-drive-size-value-label",
             size, SET_MARKUP_FLAGS_HYPHEN_IF_EMPTY);
 
+  /* -------------------------------------------------- */
+  /* 'Name' field */
 
   /* figure out hostname of this box */
   hostname[sizeof hostname - 1] = '\0';
@@ -1983,48 +1992,123 @@ update_device_page_for_mdraid (GduWindow      *window,
                   name, SET_MARKUP_FLAGS_HYPHEN_IF_EMPTY);
     }
 
+  /* -------------------------------------------------- */
+  /* 'Raid Level' field */
+
+  /* Translators: Used to convey the number of required disks for a RAID array
+   *              The %d is the number of required disks.
+   */
+  s2 = g_strdup_printf (dngettext (GETTEXT_PACKAGE,
+                                   "%d disk",
+                                   "%d disks",
+                                   (gint) num_devices),
+                        (gint) num_devices);
+  /* Translators: Shown in the "RAID Level" field.
+   *              The first %s is the long description of the RAID level e.g. "RAID 6 (Dual Distributed Parity)".
+   *              The second %s is the number of RAID disks e.g. "8 disks".
+   */
+  s = g_strdup_printf (C_("mdraid", "%s â %s"),
+                       level_desc,
+                       s2);
+  g_free (s2);
   set_markup (window,
               "devtab-drive-raidlevel-label",
               "devtab-drive-raidlevel-value-label",
-              level_desc, SET_MARKUP_FLAGS_NONE);
+              s, SET_MARKUP_FLAGS_NONE);
+  g_free (s);
 
-  if (num_members < num_devices)
+  /* -------------------------------------------------- */
+  /* 'State' field */
+
+  if (sync_action == NULL || strlen (sync_action) == 0)
     {
-      /* Translators: Used to convey the number of required members for a RAID array.
-       *              The %d is the number of required members (always greater than 1).
+      /* TODO: show "Not Running â Not enough disks available to start" if
+       *       we don't have enough members
        */
-      s2 = g_strdup_printf (dngettext (GETTEXT_PACKAGE,
-                                       "%d required",
-                                       "%d required",
-                                       (gint) num_devices),
-                            (gint) num_devices);
-      /* Translators: Used to convey the number of available members for a RAID array.
-       *              The %d is the number of available members.
+      if (num_members < num_devices)
+        {
+          /* Translators: Shown in the 'State' field for MD-RAID when not running and can only be started degraded */
+          s = g_strdup (C_("mdraid-state", "Not Running â Can only start degraded"));
+        }
+      else
+        {
+          /* Translators: Shown in the 'State' field for MD-RAID when not running */
+          s = g_strdup (C_("mdraid-state", "Not Running"));
+        }
+    }
+  else if (g_strcmp0 (sync_action, "idle") == 0)
+    {
+      s = g_strdup (C_("mdraid-state", "Running"));
+    }
+  else if (g_strcmp0 (sync_action, "check") == 0)
+    {
+      /* TODO: include percentage + time remaining */
+      s = g_strdup (C_("mdraid-state", "Redundancy check underway"));
+    }
+  else if (g_strcmp0 (sync_action, "repair") == 0)
+    {
+      /* TODO: include percentage + time remaining */
+      s = g_strdup (C_("mdraid-state", "Redundancy check and repair underway"));
+    }
+  else if (g_strcmp0 (sync_action, "resync") == 0)
+    {
+      /* TODO: include percentage + time remaining */
+      s = g_strdup (C_("mdraid-state", "Resyncing"));
+    }
+  else if (g_strcmp0 (sync_action, "recover") == 0)
+    {
+      /* TODO: include percentage + time remaining */
+      s = g_strdup (C_("mdraid-state", "Recovering"));
+    }
+  else if (g_strcmp0 (sync_action, "frozen") == 0)
+    {
+      /* TODO: include percentage + time remaining */
+      s = g_strdup (C_("mdraid-state", "Frozen"));
+    }
+  else
+    {
+      g_warning ("unhandled sync action `%s'", sync_action);
+      s = g_strdup (sync_action);
+    }
+  set_markup (window,
+              "devtab-drive-raid-state-label",
+              "devtab-drive-raid-state-value-label",
+              s, SET_MARKUP_FLAGS_NONE);
+  g_free (s);
+
+  /* -------------------------------------------------- */
+  /* 'Degraded' field - only shown if actually degraded */
+
+  s = NULL;
+  if (degraded > 0)
+    {
+      /* Translators: Shown in the 'Degraded' field for a degraded RAID array.
+       *              The %d is the number of missing disks (always > 0).
        */
-      s3 = g_strdup_printf (dngettext (GETTEXT_PACKAGE,
-                                       "%d detected",
-                                       "%d detected",
-                                       (gint) num_members),
-                            (gint) num_members);
-      /* Translators: Shown in the 'Members' field when not all RAID members are there.
-       *              The first %s conveys the number of required members (e.g. '8 required').
-       *              The second %s conveys the number of available members (e.g. '6 detected').
+      s2 = g_strdup_printf (dngettext (GETTEXT_PACKAGE,
+                                       "%d disk is missing",
+                                       "%d disks are missing",
+                                       (gint) degraded),
+                            (gint) degraded);
+      /* Translators: string shown when the RAID array is degraded. All-caps is used for emphasis */
+      s3 = g_strdup_printf ("<span foreground=\"#ff0000\"><b>%s</b></span>",
+                            C_("mdraid", "ARRAY IS DEGRADED"));
+      /* Translators: The first %s is the sentence 'ARRAY IS DEGRADED'.
+       *              The second %s conveys the number of devices missing e.g. "1 disk is missing".
        */
-      s = g_strdup_printf (C_("mdraid-members", "%s (%s)"), s2, s3);
+      s = g_strdup_printf (C_("mdraid-degraded", "%s â %s"),
+                           s3, s2);
       g_free (s2);
       g_free (s3);
     }
-  else
-    {
-      s = g_strdup_printf ("%d", num_devices);
-    }
   set_markup (window,
-              "devtab-drive-numdevices-label",
-              "devtab-drive-numdevices-value-label",
+              "devtab-drive-raid-degraded-label",
+              "devtab-drive-raid-degraded-value-label",
               s, SET_MARKUP_FLAGS_NONE);
   g_free (s);
 
   /* -------------------------------------------------- */
+  /* 'Job' field - only shown if a job is running */
 
   jobs = udisks_client_get_jobs_for_object (window->client, object);
   /* if there are no jobs on the RAID Array, look at the block object if it's partitioned



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