[gnome-disk-utility] Show a cluebar when selecting a multipath component
- From: David Zeuthen <davidz src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [gnome-disk-utility] Show a cluebar when selecting a multipath component
- Date: Wed, 27 Jan 2010 16:33:15 +0000 (UTC)
commit 6856cb382171e6dc30b1f6a1465d3c63205ce613
Author: David Zeuthen <davidz redhat com>
Date: Wed Jan 27 11:14:44 2010 -0500
Show a cluebar when selecting a multipath component
http://people.freedesktop.org/~david/gdu-multipath-component-selected-1.png
src/palimpsest/gdu-section-drive.c | 112 +++++++++++++++++++++++++++++++----
1 files changed, 99 insertions(+), 13 deletions(-)
---
diff --git a/src/palimpsest/gdu-section-drive.c b/src/palimpsest/gdu-section-drive.c
index af7033e..0149c6a 100644
--- a/src/palimpsest/gdu-section-drive.c
+++ b/src/palimpsest/gdu-section-drive.c
@@ -33,7 +33,8 @@
struct _GduSectionDrivePrivate
{
- GtkWidget *multipath_warning_info_bar;
+ GtkWidget *multipath_component_warning_info_bar;
+ GtkWidget *multipath_component_info_bar;
GtkWidget *drive_label;
@@ -119,7 +120,8 @@ gdu_section_drive_update (GduSection *_section)
gboolean show_benchmark_button;
const gchar *device_file;
gchar **similar_devices;
- gboolean show_multipath_warning_info_bar;
+ gboolean show_multipath_component_warning_info_bar;
+ gboolean show_multipath_component_info_bar;
show_cddvd_button = FALSE;
show_format_button = FALSE;
@@ -127,7 +129,8 @@ gdu_section_drive_update (GduSection *_section)
show_detach_button = FALSE;
show_smart_button = FALSE;
show_benchmark_button = FALSE;
- show_multipath_warning_info_bar = FALSE;
+ show_multipath_component_warning_info_bar = FALSE;
+ show_multipath_component_info_bar = FALSE;
d = NULL;
port = NULL;
@@ -363,12 +366,18 @@ gdu_section_drive_update (GduSection *_section)
show_format_button = TRUE;
}
- /* Show a warning if multipath isn't configured */
+ /* Show a warning cluebar if multipath isn't configured */
similar_devices = gdu_device_drive_get_similar_devices (d);
if (similar_devices != NULL && g_strv_length (similar_devices) > 0) {
- if (!gdu_device_is_linux_dmmp (d) && !gdu_device_is_linux_dmmp_component (d))
- show_multipath_warning_info_bar = TRUE;
+ if (!gdu_device_is_linux_dmmp (d) && !gdu_device_is_linux_dmmp_component (d)) {
+ show_multipath_component_warning_info_bar = TRUE;
+ }
+ }
+
+ /* Show an informational cluebar if multipath is configured and the selected object is just a single path */
+ if (gdu_device_is_linux_dmmp_component (d)) {
+ show_multipath_component_info_bar = TRUE;
}
out:
@@ -379,10 +388,15 @@ gdu_section_drive_update (GduSection *_section)
gdu_button_element_set_visible (section->priv->smart_button, show_smart_button);
gdu_button_element_set_visible (section->priv->benchmark_button, show_benchmark_button);
- if (show_multipath_warning_info_bar)
- gtk_widget_show_all (section->priv->multipath_warning_info_bar);
+ if (show_multipath_component_warning_info_bar)
+ gtk_widget_show_all (section->priv->multipath_component_warning_info_bar);
else
- gtk_widget_hide_all (section->priv->multipath_warning_info_bar);
+ gtk_widget_hide_all (section->priv->multipath_component_warning_info_bar);
+
+ if (show_multipath_component_info_bar)
+ gtk_widget_show_all (section->priv->multipath_component_info_bar);
+ else
+ gtk_widget_hide_all (section->priv->multipath_component_info_bar);
if (d != NULL)
g_object_unref (d);
@@ -727,6 +741,56 @@ on_multipath_warning_info_bar_next_path (GtkInfoBar *info_bar,
/* ---------------------------------------------------------------------------------------------------- */
static void
+on_multipath_component_info_bar_go_to_multipath_device (GtkInfoBar *info_bar,
+ gint response_id,
+ gpointer user_data)
+{
+ GduSectionDrive *section = GDU_SECTION_DRIVE (user_data);
+ GduDevice *d;
+ const gchar *multipath_object_path;
+ GduPool *pool;
+ GduDevice *device_for_multipath;
+ GduPresentable *drive_for_multipath;
+
+ pool = NULL;
+ device_for_multipath = NULL;
+ drive_for_multipath = NULL;
+
+ d = gdu_presentable_get_device (gdu_section_get_presentable (GDU_SECTION (section)));
+ if (d == NULL) {
+ goto out;
+ }
+
+ multipath_object_path = gdu_device_linux_dmmp_component_get_holder (d);
+
+ pool = gdu_device_get_pool (d);
+ device_for_multipath = gdu_pool_get_by_object_path (pool, multipath_object_path);
+ if (device_for_multipath == NULL) {
+ g_warning ("No device for object path %s", multipath_object_path);
+ goto out;
+ }
+
+ drive_for_multipath = gdu_pool_get_drive_by_device (pool, device_for_multipath);
+ if (drive_for_multipath == NULL) {
+ g_warning ("No drive for object path %s", multipath_object_path);
+ goto out;
+ }
+
+ gdu_shell_select_presentable (gdu_section_get_shell (GDU_SECTION (section)),
+ drive_for_multipath);
+
+ out:
+ if (device_for_multipath != NULL)
+ g_object_unref (device_for_multipath);
+ if (drive_for_multipath != NULL)
+ g_object_unref (drive_for_multipath);
+ if (pool != NULL)
+ g_object_unref (pool);
+}
+
+/* ---------------------------------------------------------------------------------------------------- */
+
+static void
gdu_section_drive_constructed (GObject *object)
{
GduSectionDrive *section = GDU_SECTION_DRIVE (object);
@@ -752,12 +816,9 @@ gdu_section_drive_constructed (GObject *object)
info_bar = gtk_info_bar_new ();
gtk_info_bar_set_message_type (GTK_INFO_BAR (info_bar), GTK_MESSAGE_WARNING);
-
hbox = gtk_hbox_new (FALSE, 6);
-
image = gtk_image_new_from_stock (GTK_STOCK_DIALOG_WARNING, GTK_ICON_SIZE_DIALOG);
gtk_box_pack_start (GTK_BOX (hbox), image, FALSE, FALSE, 0);
-
label = gtk_label_new (NULL);
gtk_label_set_markup (GTK_LABEL (label),
_("<b>WARNING:</b> Several paths to this drive has been detected but no "
@@ -766,10 +827,35 @@ gdu_section_drive_constructed (GObject *object)
gtk_label_set_line_wrap (GTK_LABEL (label), TRUE);
gtk_label_set_width_chars (GTK_LABEL (label), 70);
gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
+ gtk_container_add (GTK_CONTAINER (gtk_info_bar_get_content_area (GTK_INFO_BAR (info_bar))), hbox);
+ gtk_box_pack_start (GTK_BOX (section), info_bar, FALSE, FALSE, 0);
+ section->priv->multipath_component_warning_info_bar = info_bar;
+
+ /*------------------------------------- */
+ info_bar = gtk_info_bar_new ();
+ gtk_info_bar_set_message_type (GTK_INFO_BAR (info_bar), GTK_MESSAGE_INFO);
+ gtk_info_bar_add_button (GTK_INFO_BAR (info_bar),
+ _("Go to Multipath Device"),
+ GTK_RESPONSE_OK);
+ g_signal_connect (info_bar,
+ "response",
+ G_CALLBACK (on_multipath_component_info_bar_go_to_multipath_device),
+ section);
+ hbox = gtk_hbox_new (FALSE, 6);
+ image = gtk_image_new_from_stock (GTK_STOCK_DIALOG_INFO, GTK_ICON_SIZE_DIALOG);
+ gtk_box_pack_start (GTK_BOX (hbox), image, FALSE, FALSE, 0);
+ label = gtk_label_new (NULL);
+ gtk_label_set_markup (GTK_LABEL (label),
+ _("<b>NOTE:</b> This object represents one of several paths to the drive. "
+ "To perform operations on the drive, use the corresponding multipath object."));
+ gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
+ gtk_label_set_line_wrap (GTK_LABEL (label), TRUE);
+ gtk_label_set_width_chars (GTK_LABEL (label), 70);
+ gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
gtk_container_add (GTK_CONTAINER (gtk_info_bar_get_content_area (GTK_INFO_BAR (info_bar))), hbox);
gtk_box_pack_start (GTK_BOX (section), info_bar, FALSE, FALSE, 0);
- section->priv->multipath_warning_info_bar = info_bar;
+ section->priv->multipath_component_info_bar = info_bar;
/*------------------------------------- */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]