[gnome-disk-utility] Add a switch for turning MD-RAID bitmap on/off
- From: David Zeuthen <davidz src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-disk-utility] Add a switch for turning MD-RAID bitmap on/off
- Date: Fri, 30 Nov 2012 16:58:41 +0000 (UTC)
commit 02ed6fd20e8ef045a674b67dad5dd5c140a151f4
Author: David Zeuthen <zeuthen gmail com>
Date: Fri Nov 30 11:55:55 2012 -0500
Add a switch for turning MD-RAID bitmap on/off
Signed-off-by: David Zeuthen <zeuthen gmail com>
data/ui/disks.ui | 93 +++++++++++++++++++++++++++++++++------------
src/disks/gduwindow.c | 101 ++++++++++++++++++++++++++++++++++++++++++++-----
2 files changed, 159 insertions(+), 35 deletions(-)
---
diff --git a/data/ui/disks.ui b/data/ui/disks.ui
index 9dbab48..f0f559e 100644
--- a/data/ui/disks.ui
+++ b/data/ui/disks.ui
@@ -353,7 +353,7 @@
<object class="GtkTable" id="devtab-drive-table">
<property name="visible">True</property>
<property name="can_focus">False</property>
- <property name="n_rows">15</property>
+ <property name="n_rows">16</property>
<property name="n_columns">2</property>
<property name="column_spacing">10</property>
<child>
@@ -404,8 +404,8 @@
</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>
@@ -423,8 +423,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>
@@ -441,8 +441,8 @@
</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"/>
<property name="y_padding">4</property>
@@ -460,8 +460,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="x_options">GTK_FILL</property>
<property name="y_options"/>
<property name="y_padding">4</property>
@@ -478,8 +478,8 @@
</style>
</object>
<packing>
- <property name="top_attach">12</property>
- <property name="bottom_attach">13</property>
+ <property name="top_attach">13</property>
+ <property name="bottom_attach">14</property>
<property name="x_options">GTK_FILL</property>
<property name="y_options"/>
<property name="y_padding">4</property>
@@ -497,8 +497,8 @@
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
- <property name="top_attach">12</property>
- <property name="bottom_attach">13</property>
+ <property name="top_attach">13</property>
+ <property name="bottom_attach">14</property>
<property name="x_options">GTK_FILL</property>
<property name="y_options"/>
<property name="y_padding">4</property>
@@ -565,8 +565,8 @@
</style>
</object>
<packing>
- <property name="top_attach">13</property>
- <property name="bottom_attach">14</property>
+ <property name="top_attach">14</property>
+ <property name="bottom_attach">15</property>
<property name="x_options">GTK_FILL</property>
<property name="y_options"/>
<property name="y_padding">4</property>
@@ -584,8 +584,8 @@
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
- <property name="top_attach">13</property>
- <property name="bottom_attach">14</property>
+ <property name="top_attach">14</property>
+ <property name="bottom_attach">15</property>
<property name="x_options">GTK_FILL</property>
<property name="y_options"/>
<property name="y_padding">4</property>
@@ -810,8 +810,8 @@
</style>
</object>
<packing>
- <property name="top_attach">14</property>
- <property name="bottom_attach">15</property>
+ <property name="top_attach">15</property>
+ <property name="bottom_attach">16</property>
<property name="x_options">GTK_FILL</property>
<property name="y_options">GTK_FILL</property>
<property name="y_padding">4</property>
@@ -892,8 +892,8 @@
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
- <property name="top_attach">14</property>
- <property name="bottom_attach">15</property>
+ <property name="top_attach">15</property>
+ <property name="bottom_attach">16</property>
<property name="y_options"/>
</packing>
</child>
@@ -1020,8 +1020,8 @@
</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">GTK_FILL</property>
<property name="y_padding">4</property>
@@ -1076,8 +1076,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="y_options"/>
</packing>
</child>
@@ -1198,6 +1198,49 @@
<property name="y_padding">4</property>
</packing>
</child>
+ <child>
+ <object class="GtkLabel" id="devtab-drive-raid-bitmap-label">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="xalign">1</property>
+ <property name="label" translatable="yes">Bitmap</property>
+ <style>
+ <class name="dim-label"/>
+ </style>
+ </object>
+ <packing>
+ <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>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkBox" id="devtab-drive-raid-bitmap-switch-box">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <child>
+ <object class="GtkSwitch" id="devtab-drive-raid-bitmap-switch">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ </object>
+ <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="x_options">GTK_FILL</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 607186f..cac04bb 100644
--- a/src/disks/gduwindow.c
+++ b/src/disks/gduwindow.c
@@ -139,6 +139,7 @@ struct _GduWindow
GtkWidget *generic_menu_item_benchmark;
GtkWidget *devtab_loop_autoclear_switch;
+ GtkWidget *devtab_drive_raid_bitmap_switch;
GtkWidget *devtab_drive_raid_state_label;
GtkWidget *devtab_drive_raid_state_grid;
@@ -218,6 +219,7 @@ static const struct {
{G_STRUCT_OFFSET (GduWindow, devtab_drive_action_generic), "devtab-drive-action-generic"},
{G_STRUCT_OFFSET (GduWindow, devtab_loop_autoclear_switch), "devtab-loop-autoclear-switch"},
+ {G_STRUCT_OFFSET (GduWindow, devtab_drive_raid_bitmap_switch), "devtab-drive-raid-bitmap-switch"},
{G_STRUCT_OFFSET (GduWindow, generic_drive_menu), "generic-drive-menu"},
{G_STRUCT_OFFSET (GduWindow, generic_drive_menu_item_format_disk), "generic-drive-menu-item-format-disk"},
@@ -412,6 +414,10 @@ static void on_devtab_loop_autoclear_switch_notify_active (GObject *object,
GParamSpec *pspec,
gpointer user_data);
+static void on_devtab_drive_raid_bitmap_switch_notify_active (GObject *object,
+ GParamSpec *pspec,
+ gpointer user_data);
+
static void on_drive_job_cancel_button_clicked (GtkButton *button,
gpointer user_data);
@@ -1560,6 +1566,12 @@ gdu_window_constructed (GObject *object)
G_CALLBACK (on_devtab_loop_autoclear_switch_notify_active),
window);
+ /* MDRAID's bitmap switch */
+ g_signal_connect (window->devtab_drive_raid_bitmap_switch,
+ "notify::active",
+ G_CALLBACK (on_devtab_drive_raid_bitmap_switch_notify_active),
+ window);
+
/* cancel-button for drive job */
g_signal_connect (window->devtab_drive_job_cancel_button,
"clicked",
@@ -2293,6 +2305,22 @@ update_device_page_for_mdraid (GduWindow *window,
}
/* -------------------------------------------------- */
+ /* 'Bitmap' field */
+
+ if (strlen (bitmap_location) > 0)
+ {
+ gboolean has_bitmap = FALSE;
+ if (bitmap_location != NULL && strlen (bitmap_location) > 0 && g_strcmp0 (bitmap_location, "none") != 0)
+ has_bitmap = TRUE;
+
+ set_switch (window,
+ "devtab-drive-raid-bitmap-label",
+ "devtab-drive-raid-bitmap-switch-box",
+ "devtab-drive-raid-bitmap-switch",
+ has_bitmap);
+ }
+
+ /* -------------------------------------------------- */
/* 'Raid Level' field */
level_desc = gdu_utils_format_mdraid_level (udisks_mdraid_get_level (mdraid), FALSE, FALSE);
@@ -2318,16 +2346,6 @@ update_device_page_for_mdraid (GduWindow *window,
g_free (s3);
}
- if (bitmap_location != NULL && strlen (bitmap_location) > 0 && g_strcmp0 (bitmap_location, "none") != 0)
- {
- /* Translators: Used to convey that bitmap is enabled for the disk.
- * The first %s is the number of disks e.g. "3 disks, 512 KiB".
- */
- s = s2;
- s2 = g_strdup_printf (C_("mdraid-disks-and-chunk-size-and-bitmap", "%s, Bitmap"), s2);
- g_free (s);
- }
-
/* 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 optionally with the chunk size e.g. "8 disks" or "8 disks, 512 KiB Chunk".
@@ -4509,6 +4527,69 @@ on_devtab_action_deactivate_swap_activated (GtkAction *action, gpointer user_dat
/* ---------------------------------------------------------------------------------------------------- */
static void
+mdraid_set_bitmap_location_cb (UDisksMDRaid *mdraid,
+ GAsyncResult *res,
+ gpointer user_data)
+{
+ GduWindow *window = GDU_WINDOW (user_data);
+ GError *error;
+
+ error = NULL;
+ if (!udisks_mdraid_call_set_bitmap_location_finish (mdraid,
+ res,
+ &error))
+ {
+ gdu_utils_show_error (GTK_WINDOW (window),
+ _("Error setting bitmap for the RAID array"),
+ error);
+ g_error_free (error);
+ /* in case of error, make sure the GtkSwitch:active reverts */
+ update_all (window);
+ }
+ g_object_unref (window);
+}
+
+static void
+on_devtab_drive_raid_bitmap_switch_notify_active (GObject *gobject,
+ GParamSpec *pspec,
+ gpointer user_data)
+{
+ GduWindow *window = GDU_WINDOW (user_data);
+ UDisksMDRaid *mdraid;
+ gboolean sw_value = FALSE;
+ const gchar *bitmap_location;
+ gboolean has_bitmap = FALSE;
+
+ mdraid = udisks_object_peek_mdraid (window->current_object);
+
+ bitmap_location = udisks_mdraid_get_bitmap_location (mdraid);
+ if (bitmap_location != NULL && strlen (bitmap_location) > 0 && g_strcmp0 (bitmap_location, "none") != 0)
+ has_bitmap = TRUE;
+
+ sw_value = !! gtk_switch_get_active (GTK_SWITCH (gobject));
+ if (sw_value != (!!has_bitmap))
+ {
+ const gchar *bitmap_location_new_value;
+ GVariantBuilder options_builder;
+
+ if (sw_value)
+ bitmap_location_new_value = "internal";
+ else
+ bitmap_location_new_value = "none";
+
+ g_variant_builder_init (&options_builder, G_VARIANT_TYPE_VARDICT);
+ udisks_mdraid_call_set_bitmap_location (mdraid,
+ bitmap_location_new_value,
+ g_variant_builder_end (&options_builder),
+ NULL, /* cancellable */
+ (GAsyncReadyCallback) mdraid_set_bitmap_location_cb,
+ g_object_ref (window));
+ }
+}
+
+/* ---------------------------------------------------------------------------------------------------- */
+
+static void
loop_set_autoclear_cb (UDisksLoop *loop,
GAsyncResult *res,
gpointer user_data)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]