[gnome-disk-utility/wip/mdraid] Show progress bar for certain RAID sync operations
- From: David Zeuthen <davidz src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-disk-utility/wip/mdraid] Show progress bar for certain RAID sync operations
- Date: Thu, 13 Sep 2012 19:30:01 +0000 (UTC)
commit f04a35a98382c55fca4ff2024c6b9bb866aa2650
Author: David Zeuthen <zeuthen gmail com>
Date: Thu Sep 13 15:29:43 2012 -0400
Show progress bar for certain RAID sync operations
http://people.freedesktop.org/~david/gnome-disks-mdraid-20120913-2.png
Signed-off-by: David Zeuthen <zeuthen gmail com>
data/ui/disks.ui | 81 ++++++++++++++++++++++++++++++++++++-------------
src/disks/gduwindow.c | 58 +++++++++++++++++++++++++++++------
2 files changed, 108 insertions(+), 31 deletions(-)
---
diff --git a/data/ui/disks.ui b/data/ui/disks.ui
index 7e8373e..076c813 100644
--- a/data/ui/disks.ui
+++ b/data/ui/disks.ui
@@ -512,9 +512,9 @@
</child>
<child>
<object class="GtkButtonBox" id="devtab-drive-buttonbox">
- <style><class name="linked"/></style>
<property name="visible">True</property>
<property name="can_focus">False</property>
+ <style><class name="linked"/></style>
<child>
<object class="GtkButton" id="devtab-drive-eject-button">
<property name="use_action_appearance">False</property>
@@ -847,6 +847,7 @@
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="xalign">1</property>
+ <property name="yalign">0</property>
<property name="label" translatable="yes">State</property>
<style><class name="dim-label"/></style>
</object>
@@ -854,26 +855,7 @@
<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-state-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 name="y_options">GTK_FILL</property>
<property name="y_padding">4</property>
</packing>
</child>
@@ -912,6 +894,63 @@
<property name="y_padding">4</property>
</packing>
</child>
+ <child>
+ <object class="GtkGrid" id="devtab-drive-raid-state-grid">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="row_spacing">6</property>
+ <property name="column_spacing">6</property>
+ <child>
+ <object class="GtkProgressBar" id="devtab-drive-raid-state-progressbar">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="hexpand">True</property>
+ </object>
+ <packing>
+ <property name="left_attach">0</property>
+ <property name="top_attach">0</property>
+ <property name="width">1</property>
+ <property name="height">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="devtab-drive-raid-state-progress-label">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="xalign">0</property>
+ </object>
+ <packing>
+ <property name="left_attach">0</property>
+ <property name="top_attach">1</property>
+ <property name="width">1</property>
+ <property name="height">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="devtab-drive-raid-state-no-progress-label">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="xalign">0</property>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="top_attach">0</property>
+ <property name="width">1</property>
+ <property name="height">1</property>
+ </packing>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
+ </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="y_options"/>
+ </packing>
+ </child>
</object>
<packing>
<property name="expand">False</property>
diff --git a/src/disks/gduwindow.c b/src/disks/gduwindow.c
index ba48a77..a4d5aa6 100644
--- a/src/disks/gduwindow.c
+++ b/src/disks/gduwindow.c
@@ -125,6 +125,12 @@ struct _GduWindow
GtkWidget *devtab_loop_autoclear_switch;
+ GtkWidget *devtab_drive_raid_state_label;
+ GtkWidget *devtab_drive_raid_state_grid;
+ GtkWidget *devtab_drive_raid_state_progressbar;
+ GtkWidget *devtab_drive_raid_state_progress_label;
+ GtkWidget *devtab_drive_raid_state_no_progress_label;
+
GtkWidget *devtab_drive_job_label;
GtkWidget *devtab_drive_job_grid;
GtkWidget *devtab_drive_job_progressbar;
@@ -207,6 +213,12 @@ static const struct {
{G_STRUCT_OFFSET (GduWindow, generic_menu_item_restore_volume_image), "generic-menu-item-restore-volume-image"},
{G_STRUCT_OFFSET (GduWindow, generic_menu_item_benchmark), "generic-menu-item-benchmark"},
+ {G_STRUCT_OFFSET (GduWindow, devtab_drive_raid_state_label), "devtab-drive-raid-state-label"},
+ {G_STRUCT_OFFSET (GduWindow, devtab_drive_raid_state_grid), "devtab-drive-raid-state-grid"},
+ {G_STRUCT_OFFSET (GduWindow, devtab_drive_raid_state_progressbar), "devtab-drive-raid-state-progressbar"},
+ {G_STRUCT_OFFSET (GduWindow, devtab_drive_raid_state_progress_label), "devtab-drive-raid-state-progress-label"},
+ {G_STRUCT_OFFSET (GduWindow, devtab_drive_raid_state_no_progress_label), "devtab-drive-raid-state-no-progress-label"},
+
{G_STRUCT_OFFSET (GduWindow, devtab_drive_job_label), "devtab-drive-job-label"},
{G_STRUCT_OFFSET (GduWindow, devtab_drive_job_grid), "devtab-drive-job-grid"},
{G_STRUCT_OFFSET (GduWindow, devtab_drive_job_progressbar), "devtab-drive-job-progressbar"},
@@ -1877,6 +1889,8 @@ update_device_page_for_mdraid (GduWindow *window,
GList *members = NULL;
guint degraded;
const gchar *sync_action;
+ gdouble sync_completed;
+ gboolean sync_show_completed = FALSE;
gdu_volume_grid_set_no_media_string (GDU_VOLUME_GRID (window->volume_grid),
_("RAID Array is not running"));
@@ -1888,6 +1902,7 @@ update_device_page_for_mdraid (GduWindow *window,
num_members = g_list_length (members);
degraded = udisks_mdraid_get_degraded (mdraid);
sync_action = udisks_mdraid_get_sync_action (mdraid);
+ sync_completed = udisks_mdraid_get_sync_completed (mdraid);
icon = g_themed_icon_new ("gdu-enclosure");
@@ -2042,27 +2057,26 @@ update_device_page_for_mdraid (GduWindow *window,
}
else if (g_strcmp0 (sync_action, "check") == 0)
{
- /* TODO: include percentage + time remaining */
s = g_strdup (C_("mdraid-state", "Redundancy check underway"));
+ sync_show_completed = TRUE;
}
else if (g_strcmp0 (sync_action, "repair") == 0)
{
- /* TODO: include percentage + time remaining */
s = g_strdup (C_("mdraid-state", "Redundancy check and repair underway"));
+ sync_show_completed = TRUE;
}
else if (g_strcmp0 (sync_action, "resync") == 0)
{
- /* TODO: include percentage + time remaining */
s = g_strdup (C_("mdraid-state", "Resyncing"));
+ sync_show_completed = TRUE;
}
else if (g_strcmp0 (sync_action, "recover") == 0)
{
- /* TODO: include percentage + time remaining */
s = g_strdup (C_("mdraid-state", "Recovering"));
+ sync_show_completed = TRUE;
}
else if (g_strcmp0 (sync_action, "frozen") == 0)
{
- /* TODO: include percentage + time remaining */
s = g_strdup (C_("mdraid-state", "Frozen"));
}
else
@@ -2070,11 +2084,35 @@ update_device_page_for_mdraid (GduWindow *window,
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);
+
+ gtk_widget_show (window->devtab_drive_raid_state_label);
+ gtk_widget_show (window->devtab_drive_raid_state_grid);
+ if (sync_show_completed)
+ {
+ gtk_widget_show (window->devtab_drive_raid_state_progressbar);
+ gtk_widget_show (window->devtab_drive_raid_state_progress_label);
+ gtk_widget_hide (window->devtab_drive_raid_state_no_progress_label);
+
+ s2 = g_strdup_printf ("<small>%s</small>", s);
+ gtk_label_set_markup (GTK_LABEL (window->devtab_drive_raid_state_progress_label), s2);
+ g_free (s2);
+ g_free (s);
+
+ gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR (window->devtab_drive_raid_state_progressbar), sync_completed);
+
+ s = g_strdup_printf ("%2.1f%%", 100.0 * sync_completed);
+ gtk_progress_bar_set_show_text (GTK_PROGRESS_BAR (window->devtab_drive_raid_state_progressbar), TRUE);
+ gtk_progress_bar_set_text (GTK_PROGRESS_BAR (window->devtab_drive_raid_state_progressbar), s);
+ g_free (s);
+ }
+ else
+ {
+ gtk_widget_hide (window->devtab_drive_raid_state_progressbar);
+ gtk_widget_hide (window->devtab_drive_raid_state_progress_label);
+ gtk_widget_show (window->devtab_drive_raid_state_no_progress_label);
+ gtk_label_set_text (GTK_LABEL (window->devtab_drive_raid_state_no_progress_label), s);
+ g_free (s);
+ }
/* -------------------------------------------------- */
/* 'Degraded' field - only shown if actually degraded */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]