[gnome-disk-utility/udisks2-port] Show SMART status and temperature



commit 9552a6e894491ef5bfa0c37a32701f1266d09722
Author: David Zeuthen <davidz redhat com>
Date:   Fri Aug 12 16:27:06 2011 -0400

    Show SMART status and temperature
    
    Signed-off-by: David Zeuthen <davidz redhat com>

 data/ui/palimpsest.ui      |   76 +++++++++++++++++++++++++++++++++++++++++++-
 src/palimpsest/gduwindow.c |   70 ++++++++++++++++++++++++++++++++++++++++
 2 files changed, 145 insertions(+), 1 deletions(-)
---
diff --git a/data/ui/palimpsest.ui b/data/ui/palimpsest.ui
index 03aabf1..8a90cfc 100644
--- a/data/ui/palimpsest.ui
+++ b/data/ui/palimpsest.ui
@@ -1137,7 +1137,7 @@
                   <object class="GtkTable" id="devtab-drive-table">
                     <property name="visible">True</property>
                     <property name="can_focus">False</property>
-                    <property name="n_rows">7</property>
+                    <property name="n_rows">9</property>
                     <property name="n_columns">2</property>
                     <property name="column_spacing">10</property>
                     <child>
@@ -1392,6 +1392,80 @@
                         <property name="y_padding">4</property>
                       </packing>
                     </child>
+                    <child>
+                      <object class="GtkLabel" id="devtab-drive-smart-label">
+                        <property name="visible">True</property>
+                        <property name="can_focus">False</property>
+                        <property name="xalign">1</property>
+                        <property name="label" translatable="yes">Self-Assessment</property>
+                        <attributes>
+                          <attribute name="foreground" value="#555555555555"/>
+                        </attributes>
+                      </object>
+                      <packing>
+                        <property name="top_attach">7</property>
+                        <property name="bottom_attach">8</property>
+                        <property name="x_options">GTK_FILL</property>
+                        <property name="y_options"></property>
+                        <property name="y_padding">4</property>
+                      </packing>
+                    </child>
+                    <child>
+                      <object class="GtkLabel" id="devtab-drive-smart-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">7</property>
+                        <property name="bottom_attach">8</property>
+                        <property name="x_options">GTK_FILL</property>
+                        <property name="y_options"></property>
+                        <property name="y_padding">4</property>
+                      </packing>
+                    </child>
+                    <child>
+                      <object class="GtkLabel" id="devtab-drive-temperature-label">
+                        <property name="visible">True</property>
+                        <property name="can_focus">False</property>
+                        <property name="xalign">1</property>
+                        <property name="label" translatable="yes">Temperature</property>
+                        <attributes>
+                          <attribute name="foreground" value="#555555555555"/>
+                        </attributes>
+                      </object>
+                      <packing>
+                        <property name="top_attach">8</property>
+                        <property name="bottom_attach">9</property>
+                        <property name="x_options">GTK_FILL</property>
+                        <property name="y_options"></property>
+                        <property name="y_padding">4</property>
+                      </packing>
+                    </child>
+                    <child>
+                      <object class="GtkLabel" id="devtab-drive-temperature-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">8</property>
+                        <property name="bottom_attach">9</property>
+                        <property name="x_options">GTK_FILL</property>
+                        <property name="y_options"></property>
+                        <property name="y_padding">4</property>
+                      </packing>
+                    </child>
                   </object>
                   <packing>
                     <property name="expand">False</property>
diff --git a/src/palimpsest/gduwindow.c b/src/palimpsest/gduwindow.c
index 49c4625..71e7c98 100644
--- a/src/palimpsest/gduwindow.c
+++ b/src/palimpsest/gduwindow.c
@@ -1362,6 +1362,7 @@ update_device_page_for_drive (GduWindow      *window,
   GIcon *drive_icon;
   GIcon *media_icon;
   guint64 size;
+  UDisksDriveAta *ata;
 
   //g_debug ("In update_device_page_for_drive() - selected=%s",
   //         object != NULL ? g_dbus_object_get_object_path (object) : "<nothing>");
@@ -1370,6 +1371,8 @@ update_device_page_for_drive (GduWindow      *window,
   block_devices = get_top_level_block_devices_for_drive (window, g_dbus_object_get_object_path (G_DBUS_OBJECT (object)));
   block_devices = g_list_sort (block_devices, (GCompareFunc) block_device_compare_on_preferred);
 
+  ata = udisks_object_peek_drive_ata (object);
+
   udisks_util_get_drive_info (drive, &name, &description, &drive_icon, &media_description, &media_icon);
 
   drive_vendor = udisks_drive_get_vendor (drive);
@@ -1420,6 +1423,73 @@ update_device_page_for_drive (GduWindow      *window,
               "devtab-wwn-value-label",
               udisks_drive_get_wwn (drive), SET_MARKUP_FLAGS_NONE);
 
+  if (ata != NULL && !udisks_drive_get_media_removable (drive))
+    {
+      gchar *s2 = NULL;
+      if (!udisks_drive_ata_get_smart_supported (ata))
+        {
+          s = g_strdup (_("S.M.A.R.T. not supported"));
+        }
+      else if (!udisks_drive_ata_get_smart_enabled (ata))
+        {
+          s = g_strdup (_("S.M.A.R.T. not enabled"));
+        }
+      else
+        {
+          guint64 updated;
+
+          updated = udisks_drive_ata_get_smart_updated (ata);
+          if (updated == 0)
+            {
+              s = g_strdup (_("S.M.A.R.T. data not collected"));
+            }
+          else
+            {
+              gboolean failing;
+              gdouble temp;
+
+              failing = udisks_drive_ata_get_smart_failing (ata);
+              if (failing)
+                {
+                  s = g_strdup_printf ("<b><span foreground=\"#ff0000\">%s</span></b>",
+                                        _("FAILING NOW"));
+                }
+              else
+                {
+                  s = g_strdup (_("Passed"));
+                }
+              /* TODO: also show if a self-test is in progress */
+
+              temp = udisks_drive_ata_get_smart_temperature (ata);
+              if (temp > 1.0)
+                {
+                  gdouble celcius;
+                  gdouble fahrenheit;
+                  celcius = temp - 273.15;
+                  fahrenheit = 9.0 * celcius / 5.0 + 32.0;
+                  /* Translators: Used to convey the temperature of a drive.
+                   * The first %f is the temperature in degrees Celcius and the second %f
+                   * is the temperature in degrees Fahrenheit
+                   */
+                  s2 = g_strdup_printf (_("%.0f C / %.0f F"), celcius, fahrenheit);
+                }
+            }
+        }
+      set_markup (window,
+                  "devtab-drive-smart-label",
+                  "devtab-drive-smart-value-label",
+                  s, SET_MARKUP_FLAGS_NONE);
+      g_free (s);
+      if (s2 != NULL)
+        {
+          set_markup (window,
+                      "devtab-drive-temperature-label",
+                      "devtab-drive-temperature-value-label",
+                      s2, SET_MARKUP_FLAGS_NONE);
+          g_free (s2);
+        }
+    }
+
   size = udisks_drive_get_size (drive);
   if (size > 0)
     {



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