[gnome-disk-utility] Make Drive + Volume sections insensitive when selecting a multipath component



commit c050bdf64fd80451827a964988adec079d91773c
Author: David Zeuthen <davidz redhat com>
Date:   Wed Jan 27 11:31:31 2010 -0500

    Make Drive + Volume sections insensitive when selecting a multipath component
    
    http://people.freedesktop.org/~david/gdu-multipath-component-selected-2.png

 src/palimpsest/gdu-section-drive.c   |   22 +++++++++++++++++-----
 src/palimpsest/gdu-section-volumes.c |   28 ++++++++++++++++++++++------
 2 files changed, 39 insertions(+), 11 deletions(-)
---
diff --git a/src/palimpsest/gdu-section-drive.c b/src/palimpsest/gdu-section-drive.c
index 0149c6a..2735dfe 100644
--- a/src/palimpsest/gdu-section-drive.c
+++ b/src/palimpsest/gdu-section-drive.c
@@ -37,6 +37,7 @@ struct _GduSectionDrivePrivate
         GtkWidget *multipath_component_info_bar;
 
         GtkWidget *drive_label;
+        GtkWidget *main_vbox;
 
         GduDetailsElement *model_element;
         GduDetailsElement *firmware_element;
@@ -122,6 +123,7 @@ gdu_section_drive_update (GduSection *_section)
         gchar **similar_devices;
         gboolean show_multipath_component_warning_info_bar;
         gboolean show_multipath_component_info_bar;
+        gboolean make_insensitive;
 
         show_cddvd_button = FALSE;
         show_format_button = FALSE;
@@ -131,6 +133,7 @@ gdu_section_drive_update (GduSection *_section)
         show_benchmark_button = FALSE;
         show_multipath_component_warning_info_bar = FALSE;
         show_multipath_component_info_bar = FALSE;
+        make_insensitive = FALSE;
 
         d = NULL;
         port = NULL;
@@ -375,9 +378,12 @@ gdu_section_drive_update (GduSection *_section)
                 }
         }
 
-        /* Show an informational cluebar if multipath is configured and the selected object is just a single path */
+        /* Show an informational cluebar if multipath is configured and the selected object
+         * is just a single path. Also make the whole section insensitive.
+         */
         if (gdu_device_is_linux_dmmp_component (d)) {
                 show_multipath_component_info_bar = TRUE;
+                make_insensitive = TRUE;
         }
 
  out:
@@ -388,15 +394,20 @@ 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_component_warning_info_bar)
+        if (show_multipath_component_warning_info_bar) {
                 gtk_widget_show_all (section->priv->multipath_component_warning_info_bar);
-        else
+        } else {
                 gtk_widget_hide_all (section->priv->multipath_component_warning_info_bar);
+        }
 
-        if (show_multipath_component_info_bar)
+        if (show_multipath_component_info_bar) {
                 gtk_widget_show_all (section->priv->multipath_component_info_bar);
-        else
+        } else {
                 gtk_widget_hide_all (section->priv->multipath_component_info_bar);
+        }
+
+        gtk_widget_set_sensitive (section->priv->drive_label, !make_insensitive);
+        gtk_widget_set_sensitive (section->priv->main_vbox, !make_insensitive);
 
         if (d != NULL)
                 g_object_unref (d);
@@ -870,6 +881,7 @@ gdu_section_drive_constructed (GObject *object)
 
         vbox = gtk_vbox_new (FALSE, 6);
         gtk_container_add (GTK_CONTAINER (align), vbox);
+        section->priv->main_vbox = vbox;
 
         /* -------------------------------------------------------------------------------- */
 
diff --git a/src/palimpsest/gdu-section-volumes.c b/src/palimpsest/gdu-section-volumes.c
index 26d5ac2..4923921 100644
--- a/src/palimpsest/gdu-section-volumes.c
+++ b/src/palimpsest/gdu-section-volumes.c
@@ -34,6 +34,9 @@ struct _GduSectionVolumesPrivate
 {
         GduPresentable *cur_volume;
 
+        GtkWidget *main_label;
+        GtkWidget *main_vbox;
+
         GtkWidget *grid;
         GtkWidget *details_table;
         GtkWidget *button_table;
@@ -1804,6 +1807,7 @@ gdu_section_volumes_update (GduSection *_section)
         GduSectionVolumes *section = GDU_SECTION_VOLUMES (_section);
         GduPresentable *v;
         GduDevice *d;
+        GduDevice *drive_d;
         gchar *s;
         gchar *s2;
         const gchar *id_usage;
@@ -1827,9 +1831,11 @@ gdu_section_volumes_update (GduSection *_section)
         gboolean show_lvm2_lv_delete_button;
         GduKnownFilesystem *kfs;
         GPtrArray *elements;
+        gboolean make_insensitive;
 
         v = NULL;
         d = NULL;
+        drive_d = NULL;
         kfs = NULL;
         id_usage = "";
         id_type = "";
@@ -1850,6 +1856,7 @@ gdu_section_volumes_update (GduSection *_section)
         show_lvm2_lv_stop_button = FALSE;
         show_lvm2_lv_edit_name_button = FALSE;
         show_lvm2_lv_delete_button = FALSE;
+        make_insensitive = FALSE;
 
         v = gdu_volume_grid_get_selected (GDU_VOLUME_GRID (section->priv->grid));
 
@@ -1868,6 +1875,8 @@ gdu_section_volumes_update (GduSection *_section)
                 }
         }
 
+        drive_d = gdu_presentable_get_device (gdu_section_get_presentable (GDU_SECTION (section)));
+
         /* ---------------------------------------------------------------------------------------------------- */
         /* rebuild table  */
 
@@ -2181,17 +2190,13 @@ gdu_section_volumes_update (GduSection *_section)
                 show_format_button = FALSE;
 
         } else if (GDU_IS_VOLUME_HOLE (v)) {
-                GduDevice *drive_device;
                 const char *device_file;
 
                 gdu_details_element_set_text (section->priv->usage_element, _("Unallocated Space"));
-                drive_device = gdu_presentable_get_device (gdu_section_get_presentable (GDU_SECTION (section)));
-
-                device_file = gdu_device_get_device_file_presentation (drive_device);
+                device_file = gdu_device_get_device_file_presentation (drive_d);
                 if (device_file == NULL || strlen (device_file) == 0)
-                        device_file = gdu_device_get_device_file (drive_device);
+                        device_file = gdu_device_get_device_file (drive_d);
                 gdu_details_element_set_text (section->priv->device_element, device_file);
-                g_object_unref (drive_device);
 
                 if (can_create_partition (section, GDU_VOLUME_HOLE (v), NULL))
                         show_partition_create_button = TRUE;
@@ -2210,6 +2215,10 @@ gdu_section_volumes_update (GduSection *_section)
                 }
         }
 
+        if (drive_d != NULL && gdu_device_is_linux_dmmp_component (drive_d)) {
+                make_insensitive = TRUE;
+        }
+
  out:
         gdu_button_element_set_visible (section->priv->fs_mount_button, show_fs_mount_button);
         gdu_button_element_set_visible (section->priv->fs_unmount_button, show_fs_unmount_button);
@@ -2229,8 +2238,13 @@ gdu_section_volumes_update (GduSection *_section)
         gdu_button_element_set_visible (section->priv->lvm2_lv_edit_name_button, show_lvm2_lv_edit_name_button);
         gdu_button_element_set_visible (section->priv->lvm2_lv_delete_button, show_lvm2_lv_delete_button);
 
+        gtk_widget_set_sensitive (section->priv->main_label, !make_insensitive);
+        gtk_widget_set_sensitive (section->priv->main_vbox, !make_insensitive);
+
         if (d != NULL)
                 g_object_unref (d);
+        if (drive_d != NULL)
+                g_object_unref (drive_d);
         if (v != NULL)
                 g_object_unref (v);
         if (kfs != NULL)
@@ -2281,6 +2295,7 @@ gdu_section_volumes_constructed (GObject *object)
         gtk_label_set_use_underline (GTK_LABEL (label), TRUE);
         g_free (s);
         gtk_box_pack_start (GTK_BOX (section), label, FALSE, FALSE, 0);
+        section->priv->main_label = label;
 
         align = gtk_alignment_new (0.5, 0.5, 1.0, 1.0);
         gtk_alignment_set_padding (GTK_ALIGNMENT (align), 0, 0, 12, 0);
@@ -2288,6 +2303,7 @@ gdu_section_volumes_constructed (GObject *object)
 
         vbox2 = gtk_vbox_new (FALSE, 6);
         gtk_container_add (GTK_CONTAINER (align), vbox2);
+        section->priv->main_vbox = vbox2;
 
         grid = gdu_volume_grid_new (GDU_DRIVE (gdu_section_get_presentable (GDU_SECTION (section))));
         gtk_label_set_mnemonic_widget (GTK_LABEL (label), grid);



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