[gnome-disk-utility/udisks2-port] Make SMART one-liner convey self-test status without having to go the dialog
- From: David Zeuthen <davidz src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-disk-utility/udisks2-port] Make SMART one-liner convey self-test status without having to go the dialog
- Date: Fri, 9 Dec 2011 16:12:51 +0000 (UTC)
commit ae941048875988bd3673472735a1a98e59413811
Author: David Zeuthen <davidz redhat com>
Date: Fri Dec 9 11:10:52 2011 -0500
Make SMART one-liner convey self-test status without having to go the dialog
http://people.freedesktop.org/~david/gdu2-ata-smart-one-liner.png
Signed-off-by: David Zeuthen <davidz redhat com>
src/palimpsest/gduatasmartdialog.c | 56 +++++++++++++++++++++++++++---------
src/palimpsest/gduatasmartdialog.h | 5 +--
src/palimpsest/gduwindow.c | 2 +-
3 files changed, 45 insertions(+), 18 deletions(-)
---
diff --git a/src/palimpsest/gduatasmartdialog.c b/src/palimpsest/gduatasmartdialog.c
index b099db0..60f43ac 100644
--- a/src/palimpsest/gduatasmartdialog.c
+++ b/src/palimpsest/gduatasmartdialog.c
@@ -965,7 +965,7 @@ calculate_self_test (DialogData *data,
ret = g_strdup (C_("smart-self-test-result", "Last self-test failed (handling)"));
else if (g_strcmp0 (s, "inprogress") == 0)
{
- ret = g_strdup_printf (C_("smart-self-test-result", "A self-test is in progress (%d%% remaining)"),
+ ret = g_strdup_printf (C_("smart-self-test-result", "Self-test in progress â %d%% remaining"),
udisks_drive_ata_get_smart_selftest_percent_remaining (data->ata));
selftest_running = TRUE;
}
@@ -1032,9 +1032,9 @@ format_powered_on (UDisksDriveAta *ata)
return ret;
}
-gchar *
+static gchar *
gdu_ata_smart_get_overall_assessment (UDisksDriveAta *ata,
- gboolean include_temperature,
+ gboolean one_liner,
gboolean *out_smart_is_supported)
{
gchar *ret;
@@ -1042,17 +1042,16 @@ gdu_ata_smart_get_overall_assessment (UDisksDriveAta *ata,
gint num_failed_in_the_past;
gint num_bad_sectors;
gboolean smart_is_supported = FALSE;
+ gchar *selftest = NULL;
if (!udisks_drive_ata_get_smart_supported (ata))
{
- /* Translators: XXX */
ret = g_strdup (_("SMART is not supported"));
goto out_no_smart;
}
if (!udisks_drive_ata_get_smart_enabled (ata))
{
- /* Translators: XXX */
ret = g_strdup (_("SMART is not enabled"));
goto out_no_smart;
}
@@ -1063,19 +1062,43 @@ gdu_ata_smart_get_overall_assessment (UDisksDriveAta *ata,
num_failed_in_the_past = udisks_drive_ata_get_smart_num_attributes_failed_in_the_past (ata);
num_bad_sectors = udisks_drive_ata_get_smart_num_bad_sectors (ata);
- /* If self-assessment indicates failure, just return that */
+ if (g_strcmp0 (udisks_drive_ata_get_smart_selftest_status (ata), "inprogress") == 0)
+ {
+ selftest = g_strdup_printf (_("Self-test in progress â %d%% remaining"),
+ udisks_drive_ata_get_smart_selftest_percent_remaining (ata));
+ }
+
+ /* If self-assessment indicates failure, always return that */
if (udisks_drive_ata_get_smart_failing (ata))
{
- ret = g_strdup_printf ("<span foreground=\"#ff0000\"><b>%s</b></span>",
- /* Translators: XXX */
- _("DISK IS LIKELY TO FAIL SOON"));
+ /* if doing a one-liner also include if a self-test is running */
+ if (one_liner && selftest != NULL)
+ {
+ ret = g_strdup_printf ("<span foreground=\"#ff0000\"><b>%s</b></span> â %s",
+ _("DISK IS LIKELY TO FAIL SOON"),
+ selftest);
+ }
+ else
+ {
+ ret = g_strdup_printf ("<span foreground=\"#ff0000\"><b>%s</b></span>",
+ _("DISK IS LIKELY TO FAIL SOON"));
+ }
+ goto out;
+ }
+
+ /* Ok, self-assessment is good.. so if doing a self-test, prefer that to attrs / bad sectors
+ * on the one-liner
+ */
+ if (one_liner && selftest != NULL)
+ {
+ ret = selftest;
+ selftest = NULL;
goto out;
}
/* Otherwise, if an attribute is failing, return that */
if (num_failing > 0)
{
- /* Translators: XXX */
ret = g_strdup_printf (dngettext (GETTEXT_PACKAGE,
"Disk is OK, one failing attribute is failing",
"Disk is OK, %d attributes are failing",
@@ -1087,7 +1110,6 @@ gdu_ata_smart_get_overall_assessment (UDisksDriveAta *ata,
/* Otherwise, if bad sectors have been detected, return that */
if (num_bad_sectors > 0)
{
- /* Translators: XXX */
ret = g_strdup_printf (dngettext (GETTEXT_PACKAGE,
"Disk is OK, one bad sector",
"Disk is OK, %d bad sectors",
@@ -1099,7 +1121,6 @@ gdu_ata_smart_get_overall_assessment (UDisksDriveAta *ata,
/* Otherwise, if an attribute has failed in the past return that */
if (num_failed_in_the_past > 0)
{
- /* Translators: XXX */
ret = g_strdup_printf (dngettext (GETTEXT_PACKAGE,
"Disk is OK, one attribute failed in the past",
"Disk is OK, %d attributes failed in the past",
@@ -1110,12 +1131,11 @@ gdu_ata_smart_get_overall_assessment (UDisksDriveAta *ata,
/* Otherwise, it's all honky dory */
- /* Translators: XXX */
ret = g_strdup ("Disk is OK");
out:
- if (include_temperature)
+ if (one_liner)
{
gchar *s, *s1;
s = format_temp (ata);
@@ -1132,11 +1152,19 @@ gdu_ata_smart_get_overall_assessment (UDisksDriveAta *ata,
}
out_no_smart:
+ g_free (selftest);
if (out_smart_is_supported != NULL)
*out_smart_is_supported = smart_is_supported;
return ret;
}
+gchar *
+gdu_ata_smart_get_one_liner_assessment (UDisksDriveAta *ata,
+ gboolean *out_smart_is_supported)
+{
+ return gdu_ata_smart_get_overall_assessment (ata, TRUE, out_smart_is_supported);
+}
+
static void
update_dialog (DialogData *data)
{
diff --git a/src/palimpsest/gduatasmartdialog.h b/src/palimpsest/gduatasmartdialog.h
index dce1d67..de3b2b2 100644
--- a/src/palimpsest/gduatasmartdialog.h
+++ b/src/palimpsest/gduatasmartdialog.h
@@ -31,9 +31,8 @@ G_BEGIN_DECLS
void gdu_ata_smart_dialog_show (GduWindow *window,
UDisksObject *object);
-gchar *gdu_ata_smart_get_overall_assessment (UDisksDriveAta *ata,
- gboolean include_temperature,
- gboolean *out_smart_is_supported);
+gchar *gdu_ata_smart_get_one_liner_assessment (UDisksDriveAta *ata,
+ gboolean *out_smart_is_supported);
G_END_DECLS
diff --git a/src/palimpsest/gduwindow.c b/src/palimpsest/gduwindow.c
index db685c0..0fc3a1f 100644
--- a/src/palimpsest/gduwindow.c
+++ b/src/palimpsest/gduwindow.c
@@ -1587,7 +1587,7 @@ update_device_page_for_drive (GduWindow *window,
if (ata != NULL && !udisks_drive_get_media_removable (drive))
{
gboolean smart_is_supported;
- s = gdu_ata_smart_get_overall_assessment (ata, TRUE, &smart_is_supported);
+ s = gdu_ata_smart_get_one_liner_assessment (ata, &smart_is_supported);
set_markup (window,
"devtab-drive-smart-label",
"devtab-drive-smart-value-label",
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]