[gnome-disk-utility] Rework how to ignore drives in DiskSelectionWidget



commit 3734f3aa470bb841dcb490582a9bb8fd74060e83
Author: David Zeuthen <davidz redhat com>
Date:   Thu Feb 4 18:08:20 2010 -0500

    Rework how to ignore drives in DiskSelectionWidget

 src/gdu-gtk/gdu-add-component-linux-md-dialog.c |   33 ++++-
 src/gdu-gtk/gdu-add-pv-linux-lvm2-dialog.c      |   66 +++++++-
 src/gdu-gtk/gdu-create-linux-md-dialog.c        |    3 +-
 src/gdu-gtk/gdu-disk-selection-widget.c         |  224 ++++++++++-------------
 src/gdu-gtk/gdu-disk-selection-widget.h         |    5 +-
 src/gdu-gtk/gdu-gtk-enums.h                     |    7 +-
 src/gdu/gdu-marshal.list                        |    1 +
 7 files changed, 195 insertions(+), 144 deletions(-)
---
diff --git a/src/gdu-gtk/gdu-add-component-linux-md-dialog.c b/src/gdu-gtk/gdu-add-component-linux-md-dialog.c
index fbfe0c2..5988c7f 100644
--- a/src/gdu-gtk/gdu-add-component-linux-md-dialog.c
+++ b/src/gdu-gtk/gdu-add-component-linux-md-dialog.c
@@ -113,6 +113,34 @@ on_disk_selection_widget_changed (GduDiskSelectionWidget *widget,
 
 /* ---------------------------------------------------------------------------------------------------- */
 
+static gchar *
+on_is_drive_ignored (GduDiskSelectionWidget *widget,
+                     GduDrive               *drive,
+                     gpointer                user_data)
+{
+        GduAddComponentLinuxMdDialog *dialog = GDU_ADD_COMPONENT_LINUX_MD_DIALOG (user_data);
+        gchar *ignored_reason;
+        GduLinuxMdDrive *md_drive;
+
+        ignored_reason = NULL;
+
+        md_drive = GDU_LINUX_MD_DRIVE (gdu_dialog_get_presentable (GDU_DIALOG (dialog)));
+
+        if (GDU_PRESENTABLE (drive) == GDU_PRESENTABLE (md_drive)) {
+                ignored_reason = g_strdup (_("The RAID Array to add a component to."));
+                goto out;
+        }
+
+        /* TODO: check if drive has one or more components for our array - if so, return something
+         * like "Device is already part of the array".
+         */
+
+ out:
+        return ignored_reason;
+}
+
+/* ---------------------------------------------------------------------------------------------------- */
+
 static void
 gdu_add_component_linux_md_dialog_constructed (GObject *object)
 {
@@ -196,8 +224,11 @@ gdu_add_component_linux_md_dialog_constructed (GObject *object)
         /* --- */
 
         disk_selection_widget = gdu_disk_selection_widget_new (pool,
-                                                               NULL, /* TODO: ignored_drives */
                                                                GDU_DISK_SELECTION_WIDGET_FLAGS_NONE);
+        g_signal_connect (disk_selection_widget,
+                          "is-drive-ignored",
+                          G_CALLBACK (on_is_drive_ignored),
+                          dialog);
         gdu_disk_selection_widget_set_component_size (GDU_DISK_SELECTION_WIDGET (disk_selection_widget),
                                                       component_size);
         dialog->priv->disk_selection_widget = disk_selection_widget;
diff --git a/src/gdu-gtk/gdu-add-pv-linux-lvm2-dialog.c b/src/gdu-gtk/gdu-add-pv-linux-lvm2-dialog.c
index 3f942a9..16450b4 100644
--- a/src/gdu-gtk/gdu-add-pv-linux-lvm2-dialog.c
+++ b/src/gdu-gtk/gdu-add-pv-linux-lvm2-dialog.c
@@ -36,6 +36,8 @@ struct GduAddPvLinuxLvm2DialogPrivate
 {
         GtkWidget *size_widget;
         GtkWidget *disk_selection_widget;
+
+        gchar *currently_selected_id;
 };
 
 enum {
@@ -49,7 +51,9 @@ G_DEFINE_TYPE (GduAddPvLinuxLvm2Dialog, gdu_add_pv_linux_lvm2_dialog, GDU_TYPE_D
 static void
 gdu_add_pv_linux_lvm2_dialog_finalize (GObject *object)
 {
-        /*GduAddPvLinuxLvm2Dialog *dialog = GDU_ADD_PV_LINUX_LVM2_DIALOG (object);*/
+        GduAddPvLinuxLvm2Dialog *dialog = GDU_ADD_PV_LINUX_LVM2_DIALOG (object);
+
+        g_free (dialog->priv->currently_selected_id);
 
         if (G_OBJECT_CLASS (gdu_add_pv_linux_lvm2_dialog_parent_class)->finalize != NULL)
                 G_OBJECT_CLASS (gdu_add_pv_linux_lvm2_dialog_parent_class)->finalize (object);
@@ -99,6 +103,9 @@ static void
 update (GduAddPvLinuxLvm2Dialog *dialog)
 {
         guint64 largest_segment;
+        gchar *old_selected_id;
+        gboolean selection_changed;
+        GPtrArray *currently_selected_drives;
 
         largest_segment = gdu_disk_selection_widget_get_largest_segment_for_selected (GDU_DISK_SELECTION_WIDGET (dialog->priv->disk_selection_widget));
 
@@ -108,6 +115,26 @@ update (GduAddPvLinuxLvm2Dialog *dialog)
         gdu_size_widget_set_max_size (GDU_SIZE_WIDGET (dialog->priv->size_widget), largest_segment);
 
         update_add_sensitivity (dialog);
+
+        /* has the selection changed? */
+        selection_changed = FALSE;
+        old_selected_id = dialog->priv->currently_selected_id;
+        currently_selected_drives = gdu_disk_selection_widget_get_selected_drives (GDU_DISK_SELECTION_WIDGET (dialog->priv->disk_selection_widget));
+        if (currently_selected_drives->len > 0)
+                dialog->priv->currently_selected_id = g_strdup (gdu_presentable_get_id (GDU_PRESENTABLE (currently_selected_drives->pdata[0])));
+        else
+                dialog->priv->currently_selected_id = NULL;
+        g_ptr_array_unref (currently_selected_drives);
+        if (g_strcmp0 (old_selected_id, dialog->priv->currently_selected_id) != 0) {
+                selection_changed = TRUE;
+        }
+        g_free (old_selected_id);
+
+        /* if so, select maximum size */
+        if (selection_changed) {
+                gdu_size_widget_set_size (GDU_SIZE_WIDGET (dialog->priv->size_widget),
+                                          gdu_size_widget_get_max_size (GDU_SIZE_WIDGET (dialog->priv->size_widget)));
+        }
 }
 
 
@@ -140,6 +167,34 @@ on_size_widget_changed (GduSizeWidget *size_widget,
 
 /* ---------------------------------------------------------------------------------------------------- */
 
+static gchar *
+on_is_drive_ignored (GduDiskSelectionWidget *widget,
+                     GduDrive               *drive,
+                     gpointer                user_data)
+{
+        GduAddPvLinuxLvm2Dialog *dialog = GDU_ADD_PV_LINUX_LVM2_DIALOG (user_data);
+        gchar *ignored_reason;
+        GduLinuxLvm2VolumeGroup *vg;
+
+        ignored_reason = NULL;
+
+        vg = GDU_LINUX_LVM2_VOLUME_GROUP (gdu_dialog_get_presentable (GDU_DIALOG (dialog)));
+
+        if (GDU_PRESENTABLE (drive) == GDU_PRESENTABLE (vg)) {
+                ignored_reason = g_strdup (_("The VG to add a PV to."));
+                goto out;
+        }
+
+        /* TODO: check if drive has one or more PVs for our VG - if so, return something like
+         * "Device is already part of the VG".
+         */
+
+ out:
+        return ignored_reason;
+}
+
+/* ---------------------------------------------------------------------------------------------------- */
+
 static void
 gdu_add_pv_linux_lvm2_dialog_constructed (GObject *object)
 {
@@ -205,7 +260,7 @@ gdu_add_pv_linux_lvm2_dialog_constructed (GObject *object)
         gtk_table_set_row_spacings (GTK_TABLE (table), 6);
         gtk_box_pack_start (GTK_BOX (vbox), table, FALSE, FALSE, 0);
 
-        /*  Array size  */
+        /*  PV size  */
         label = gtk_label_new (NULL);
         gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
         gtk_label_set_markup_with_mnemonic (GTK_LABEL (label), _("_Size:"));
@@ -231,8 +286,11 @@ gdu_add_pv_linux_lvm2_dialog_constructed (GObject *object)
         /* --- */
 
         disk_selection_widget = gdu_disk_selection_widget_new (pool,
-                                                               NULL, /* TODO: ignored_drives */
-                                                               GDU_DISK_SELECTION_WIDGET_FLAGS_SHOW_DISKS_WITH_INSUFFICIENT_SPACE);
+                                                               GDU_DISK_SELECTION_WIDGET_FLAGS_ALLOW_DISKS_WITH_INSUFFICIENT_SPACE);
+        g_signal_connect (disk_selection_widget,
+                          "is-drive-ignored",
+                          G_CALLBACK (on_is_drive_ignored),
+                          dialog);
         dialog->priv->disk_selection_widget = disk_selection_widget;
         gtk_box_pack_start (GTK_BOX (vbox), disk_selection_widget, TRUE, TRUE, 0);
 
diff --git a/src/gdu-gtk/gdu-create-linux-md-dialog.c b/src/gdu-gtk/gdu-create-linux-md-dialog.c
index 54da53a..ea4216c 100644
--- a/src/gdu-gtk/gdu-create-linux-md-dialog.c
+++ b/src/gdu-gtk/gdu-create-linux-md-dialog.c
@@ -678,9 +678,8 @@ gdu_create_linux_md_dialog_constructed (GObject *object)
         /* -------------------------------------------------------------------------------- */
 
         disk_selection_widget = gdu_disk_selection_widget_new (dialog->priv->pool,
-                                                               NULL,
                                                                GDU_DISK_SELECTION_WIDGET_FLAGS_ALLOW_MULTIPLE |
-                                                               GDU_DISK_SELECTION_WIDGET_FLAGS_SHOW_DISKS_WITH_INSUFFICIENT_SPACE);
+                                                               GDU_DISK_SELECTION_WIDGET_FLAGS_ALLOW_DISKS_WITH_INSUFFICIENT_SPACE);
         dialog->priv->disk_selection_widget = disk_selection_widget;
 
         label = gtk_label_new (NULL);
diff --git a/src/gdu-gtk/gdu-disk-selection-widget.c b/src/gdu-gtk/gdu-disk-selection-widget.c
index 287e300..5b850ec 100644
--- a/src/gdu-gtk/gdu-disk-selection-widget.c
+++ b/src/gdu-gtk/gdu-disk-selection-widget.c
@@ -27,6 +27,8 @@
 
 #include <math.h>
 
+#include <gdu/gdu-marshal.h>
+
 #include "gdu-disk-selection-widget.h"
 #include "gdu-size-widget.h"
 
@@ -47,9 +49,6 @@ struct GduDiskSelectionWidgetPrivate
 
         /* A list of GduDrive objects that are selected */
         GList *selected_drives;
-
-        /* A list of GduDrive objects that are ignored */
-        GPtrArray *ignored_drives;
 };
 
 enum
@@ -58,7 +57,6 @@ enum
         PROP_POOL,
         PROP_FLAGS,
         PROP_SELECTED_DRIVES,
-        PROP_IGNORED_DRIVES,
         PROP_COMPONENT_SIZE,
         PROP_NUM_AVAILABLE_DISKS,
         PROP_LARGEST_SEGMENT_FOR_SELECTED,
@@ -68,6 +66,7 @@ enum
 enum
 {
         CHANGED_SIGNAL,
+        IS_DRIVE_IGNORED_SIGNAL,
         LAST_SIGNAL
 };
 
@@ -75,7 +74,7 @@ static guint signals[LAST_SIGNAL] = { 0 };
 
 static void gdu_disk_selection_widget_constructed (GObject *object);
 
-static void update (GduDiskSelectionWidget *widget);
+static void emit_changed (GduDiskSelectionWidget *widget);
 
 static void on_presentable_added   (GduPool          *pool,
                                     GduPresentable   *presentable,
@@ -121,9 +120,6 @@ gdu_disk_selection_widget_finalize (GObject *object)
         g_list_foreach (widget->priv->selected_drives, (GFunc) g_object_unref, NULL);
         g_list_free (widget->priv->selected_drives);
 
-        if (widget->priv->ignored_drives != NULL)
-                g_ptr_array_unref (widget->priv->ignored_drives);
-
         if (G_OBJECT_CLASS (gdu_disk_selection_widget_parent_class)->finalize != NULL)
                 G_OBJECT_CLASS (gdu_disk_selection_widget_parent_class)->finalize (object);
 }
@@ -152,12 +148,6 @@ gdu_disk_selection_widget_get_property (GObject    *object,
                 g_ptr_array_unref (p);
                 break;
 
-        case PROP_IGNORED_DRIVES:
-                p = gdu_disk_selection_widget_get_ignored_drives (widget);
-                g_value_set_boxed (value, p);
-                g_ptr_array_unref (p);
-                break;
-
         case PROP_COMPONENT_SIZE:
                 g_value_set_uint64 (value, gdu_disk_selection_widget_get_component_size (widget));
                 break;
@@ -197,10 +187,6 @@ gdu_disk_selection_widget_set_property (GObject      *object,
                 widget->priv->flags = g_value_get_flags (value);
                 break;
 
-        case PROP_IGNORED_DRIVES:
-                widget->priv->ignored_drives = g_value_dup_boxed (value);
-                break;
-
         case PROP_COMPONENT_SIZE:
                 gdu_disk_selection_widget_set_component_size (widget, g_value_get_uint64 (value));
                 break;
@@ -276,19 +262,6 @@ gdu_disk_selection_widget_class_init (GduDiskSelectionWidgetClass *klass)
                                                              G_PARAM_STATIC_BLURB));
 
         g_object_class_install_property (gobject_class,
-                                         PROP_IGNORED_DRIVES,
-                                         g_param_spec_boxed ("ignored-drives",
-                                                             _("Ignored Drives"),
-                                                             _("Array of drives to ignore"),
-                                                             G_TYPE_PTR_ARRAY,
-                                                             G_PARAM_READABLE |
-                                                             G_PARAM_WRITABLE |
-                                                             G_PARAM_CONSTRUCT_ONLY |
-                                                             G_PARAM_STATIC_NAME |
-                                                             G_PARAM_STATIC_NICK |
-                                                             G_PARAM_STATIC_BLURB));
-
-        g_object_class_install_property (gobject_class,
                                          PROP_NUM_AVAILABLE_DISKS,
                                          g_param_spec_uint ("num-available-disks",
                                                             _("Number of available disks"),
@@ -351,6 +324,29 @@ gdu_disk_selection_widget_class_init (GduDiskSelectionWidgetClass *klass)
                                                 G_TYPE_NONE,
                                                 0);
 
+        /**
+         * GduDiskSelectionWidget::is-drive-ignored:
+         * @widget: A #GduDiskSelectionWidget.
+         * @drive: A #GduDrive.
+         *
+         * Emitted when @widget needs to determine whether @drive is
+         * ignored or not.
+         *
+         * Returns: %NULL if @drive is not ignored, otherwise an allocated localized string
+         * containing the reason why @drive is ignored.  The recipient of the signal will free
+         * the string.
+         */
+        signals[IS_DRIVE_IGNORED_SIGNAL] = g_signal_new ("is-drive-ignored",
+                                                         G_TYPE_FROM_CLASS (klass),
+                                                         G_SIGNAL_RUN_LAST,
+                                                         G_STRUCT_OFFSET (GduDiskSelectionWidgetClass, is_drive_ignored),
+                                                         NULL, /* accumulator function */
+                                                         NULL, /* user_data for accumulator function */
+                                                         gdu_marshal_STRING__OBJECT,
+                                                         G_TYPE_STRING,
+                                                         1,
+                                                         GDU_TYPE_DRIVE);
+
 }
 
 static void
@@ -362,13 +358,11 @@ gdu_disk_selection_widget_init (GduDiskSelectionWidget *widget)
 }
 
 GtkWidget *
-gdu_disk_selection_widget_new (GduPool                    *pool,
-                               GPtrArray                  *drives_to_ignore,
-                               GduDiskSelectionWidgetFlags flags)
+gdu_disk_selection_widget_new (GduPool                     *pool,
+                               GduDiskSelectionWidgetFlags  flags)
 {
         return GTK_WIDGET (g_object_new (GDU_TYPE_DISK_SELECTION_WIDGET,
                                          "pool", pool,
-                                         "ignored-drives", drives_to_ignore,
                                          "flags", flags,
                                          NULL));
 }
@@ -391,38 +385,36 @@ gdu_disk_selection_widget_get_selected_drives (GduDiskSelectionWidget  *widget)
         return p;
 }
 
-GPtrArray *
-gdu_disk_selection_widget_get_ignored_drives (GduDiskSelectionWidget  *widget)
-{
-        return widget->priv->ignored_drives != NULL ? g_ptr_array_ref (widget->priv->ignored_drives) : NULL;
-}
-
 /* ---------------------------------------------------------------------------------------------------- */
 
-typedef enum {
-        REASON_INSUFFICIENT_SPACE,
-        REASON_MULTIPATH_COMPONENT,
-} Reason;
 
 static gboolean
 is_drive_selectable (GduDiskSelectionWidget *widget,
                      GduDrive               *drive,
-                     Reason                 *out_reason)
+                     gchar                 **out_reason)
 {
         gboolean ret;
         guint64 largest_segment;
         gboolean whole_disk_is_uninitialized;
-        Reason reason;
         GduDevice *d;
+        gchar *reason;
 
         ret = FALSE;
         d = NULL;
-        reason = REASON_INSUFFICIENT_SPACE;
+        reason = NULL;
+
+        g_signal_emit (widget,
+                       signals[IS_DRIVE_IGNORED_SIGNAL],
+                       0, /* detail */
+                       drive,
+                       &reason);
+        if (reason != NULL) {
+                goto out;
+        }
 
         d = gdu_presentable_get_device (GDU_PRESENTABLE (drive));
         if (d != NULL && gdu_device_is_linux_dmmp_component (d)) {
-                ret = FALSE;
-                reason = REASON_MULTIPATH_COMPONENT;
+                reason = g_strdup (_("Cannot select multipath component"));
                 goto out;
         }
 
@@ -431,26 +423,54 @@ is_drive_selectable (GduDiskSelectionWidget *widget,
                                          &largest_segment,
                                          NULL, /* total_free */
                                          NULL)) {
-                if (largest_segment >= widget->priv->component_size) {
+                if (widget->priv->flags & GDU_DISK_SELECTION_WIDGET_FLAGS_ALLOW_DISKS_WITH_INSUFFICIENT_SPACE) {
+                        /* size is not enforced */
                         ret = TRUE;
+                } else {
+                        /* do enforce size */
+                        if (largest_segment >= widget->priv->component_size) {
+                                ret = TRUE;
+                        } else {
+                                if (largest_segment < SIZE_EPSILON) {
+                                        reason = g_strdup (_("No free space."));
+                                } else {
+                                       gchar *s1;
+                                       gchar *s2;
+                                       s1 = gdu_util_get_size_for_display (widget->priv->component_size, FALSE, FALSE);
+                                       s2 = gdu_util_get_size_for_display (largest_segment, FALSE, FALSE);
+                                       /* Translators: Shown when device is unselectable because not enough space is available.
+                                        * First %s (e.g. '10 GB') is how much space is needed.
+                                        * Second %s (e.g. '5 GB') is how much space is available.
+                                        */
+                                       reason = g_strdup_printf (_("Insufficient space: %s is needed but largest contiguous free block is %s."),
+                                                                 s1,
+                                                                 s2);
+                                       g_free (s1);
+                                       g_free (s2);
+                                }
+                                goto out;
+                        }
                 }
+        } else {
+                reason = g_strdup (_("No free space."));
         }
 
  out:
-#if 0
-        g_debug ("is_drive_selectable (%s): %d %" G_GUINT64_FORMAT " (%d %d) ...",
-                 d != NULL ? gdu_device_get_device_file (d) : "(not set)",
-                 whole_disk_is_uninitialized,
-                 largest_segment,
-                 reason,
-                 ret);
-#endif
 
         if (d != NULL)
                 g_object_unref (d);
 
-        if (out_reason != NULL)
+        if (ret)
+                g_assert (reason == NULL);
+        else
+                g_assert (reason != NULL);
+
+        if (out_reason != NULL) {
                 *out_reason = reason;
+        } else {
+                g_free (reason);
+        }
+
         return ret;
 }
 
@@ -584,7 +604,7 @@ on_disk_toggled (GtkCellRendererToggle *renderer,
         }
 
         g_object_unref (p);
-        update (widget);
+        emit_changed (widget);
 
  out:
         ;
@@ -855,13 +875,14 @@ notes_data_func (GtkCellLayout   *cell_layout,
         guint64 total_free;
         guint64 remaining_size;
         gboolean is_selectable;
-        Reason reason;
+        gchar *reason;
         gchar *strsize;
         gchar *rem_strsize;
 
         d = NULL;
         markup = NULL;
         sensitive = TRUE;
+        reason = NULL;
 
         gtk_tree_model_get (tree_model,
                             iter,
@@ -899,32 +920,8 @@ notes_data_func (GtkCellLayout   *cell_layout,
 
         /* handle when the drive is not selectable */
         if (!is_selectable) {
-                switch (reason) {
-                case REASON_INSUFFICIENT_SPACE:
-                        if (largest_segment < SIZE_EPSILON) {
-                                /* Translators: Shown when the device is not selectable because
-                                 * there is no free space.
-                                 */
-                                markup = g_strdup_printf (_("No free space."));
-                        } else {
-                                strsize = gdu_util_get_size_for_display (widget->priv->component_size, FALSE, FALSE);
-                                rem_strsize = gdu_util_get_size_for_display (largest_segment, FALSE, FALSE);
-                                /* Translators: Shown when device is unselectable because not enough space is available.
-                                 * First %s (e.g. '10 GB') is how much space is needed.
-                                 * Second %s (e.g. '5 GB') is how much space is available.
-                                 */
-                                markup = g_strdup_printf (_("Insufficient space: %s is needed but largest contiguous free block is %s."),
-                                                          strsize,
-                                                          rem_strsize);
-                                g_free (strsize);
-                                g_free (rem_strsize);
-                        }
-                        break;
-                case REASON_MULTIPATH_COMPONENT:
-                        /* Translators: Shown when the device is unselectable because it is a multipath component. */
-                        markup = g_strdup_printf (_("Cannot select multipath component"));
-                        break;
-                }
+                markup = reason; /* steal string */
+                reason = NULL;
                 goto out;
         }
 
@@ -1071,6 +1068,7 @@ notes_data_func (GtkCellLayout   *cell_layout,
 
         g_free (markup);
         g_object_unref (p);
+        g_free (reason);
 
         if (d != NULL)
                 g_object_unref (d);
@@ -1078,42 +1076,6 @@ notes_data_func (GtkCellLayout   *cell_layout,
 
 /* ---------------------------------------------------------------------------------------------------- */
 
-#if 0
-static gboolean
-model_visible_func (GtkTreeModel  *model,
-                    GtkTreeIter   *iter,
-                    gpointer       user_data)
-{
-        GduDiskSelectionWidget *widget = GDU_DISK_SELECTION_WIDGET (user_data);
-        GduPresentable *p;
-        gboolean ret;
-
-        ret = FALSE;
-
-        /* Only show a drive if it has enough free space */
-        if (widget->priv->flags & GDU_DISK_SELECTION_WIDGET_FLAGS_SHOW_DISKS_WITH_INSUFFICIENT_SPACE) {
-                ret = TRUE;
-        } else {
-                gtk_tree_model_get (model,
-                                    iter,
-                                    GDU_POOL_TREE_MODEL_COLUMN_PRESENTABLE, &p,
-                                    -1);
-                if (p != NULL) {
-                        if (GDU_IS_DRIVE (p)) {
-                                ret = is_drive_selectable (widget, GDU_DRIVE (p));
-                        } else {
-                                ret = TRUE;
-                        }
-                        g_object_unref (p);
-                }
-        }
-
-        return ret;
-}
-#endif
-
-/* ---------------------------------------------------------------------------------------------------- */
-
 static void
 gdu_disk_selection_widget_constructed (GObject *object)
 {
@@ -1262,7 +1224,7 @@ on_presentable_added (GduPool          *pool,
                       gpointer          user_data)
 {
         GduDiskSelectionWidget *widget = GDU_DISK_SELECTION_WIDGET (user_data);
-        update (widget);
+        emit_changed (widget);
 }
 
 static void
@@ -1275,7 +1237,7 @@ on_presentable_removed (GduPool          *pool,
         if (drive_is_selected (widget, presentable))
                 drive_remove (widget, presentable);
 
-        update (widget);
+        emit_changed (widget);
 }
 
 static void
@@ -1284,7 +1246,7 @@ on_presentable_changed (GduPool          *pool,
                         gpointer          user_data)
 {
         GduDiskSelectionWidget *widget = GDU_DISK_SELECTION_WIDGET (user_data);
-        update (widget);
+        emit_changed (widget);
 }
 
 static void
@@ -1294,7 +1256,7 @@ on_row_changed (GtkTreeModel *tree_model,
                 gpointer      user_data)
 {
         GduDiskSelectionWidget *widget = GDU_DISK_SELECTION_WIDGET (user_data);
-        update (widget);
+        emit_changed (widget);
 }
 
 static void
@@ -1303,7 +1265,7 @@ on_row_deleted (GtkTreeModel *tree_model,
                 gpointer      user_data)
 {
         GduDiskSelectionWidget *widget = GDU_DISK_SELECTION_WIDGET (user_data);
-        update (widget);
+        emit_changed (widget);
 }
 
 static void
@@ -1313,7 +1275,7 @@ on_row_inserted (GtkTreeModel *tree_model,
                  gpointer      user_data)
 {
         GduDiskSelectionWidget *widget = GDU_DISK_SELECTION_WIDGET (user_data);
-        update (widget);
+        emit_changed (widget);
 }
 
 /* ---------------------------------------------------------------------------------------------------- */
@@ -1385,7 +1347,7 @@ gdu_disk_selection_widget_get_largest_segment_for_all (GduDiskSelectionWidget *w
 /* ---------------------------------------------------------------------------------------------------- */
 
 static void
-update (GduDiskSelectionWidget *widget)
+emit_changed (GduDiskSelectionWidget *widget)
 {
         g_signal_emit (widget, signals[CHANGED_SIGNAL], 0);
 }
diff --git a/src/gdu-gtk/gdu-disk-selection-widget.h b/src/gdu-gtk/gdu-disk-selection-widget.h
index 15aa7e8..2ecf7eb 100644
--- a/src/gdu-gtk/gdu-disk-selection-widget.h
+++ b/src/gdu-gtk/gdu-disk-selection-widget.h
@@ -50,13 +50,14 @@ struct GduDiskSelectionWidgetClass
         GtkVBoxClass parent_class;
 
         void (*changed) (GduDiskSelectionWidget *widget);
+
+        gchar *(*is_drive_ignored) (GduDiskSelectionWidget *widget,
+                                    GduDrive               *drive);
 };
 
 GType       gdu_disk_selection_widget_get_type                         (void) G_GNUC_CONST;
 GtkWidget  *gdu_disk_selection_widget_new                              (GduPool                     *pool,
-                                                                        GPtrArray                   *drives_to_ignore,
                                                                         GduDiskSelectionWidgetFlags  flags);
-GPtrArray  *gdu_disk_selection_widget_get_ignored_drives               (GduDiskSelectionWidget      *widget);
 GPtrArray  *gdu_disk_selection_widget_get_selected_drives              (GduDiskSelectionWidget      *widget);
 guint64     gdu_disk_selection_widget_get_component_size               (GduDiskSelectionWidget      *widget);
 void        gdu_disk_selection_widget_set_component_size               (GduDiskSelectionWidget      *widget,
diff --git a/src/gdu-gtk/gdu-gtk-enums.h b/src/gdu-gtk/gdu-gtk-enums.h
index c394c6a..4232571 100644
--- a/src/gdu-gtk/gdu-gtk-enums.h
+++ b/src/gdu-gtk/gdu-gtk-enums.h
@@ -94,16 +94,15 @@ typedef enum {
  * GduDiskSelectionWidgetFlags:
  * @GDU_DISK_SELECTION_WIDGET_FLAGS_NONE: No flags set.
  * @GDU_DISK_SELECTION_WIDGET_FLAGS_ALLOW_MULTIPLE: Allow multiple disks to be selected.
- * @GDU_DISK_SELECTION_WIDGET_FLAGS_SHOW_DISKS_WITH_INSUFFICIENT_SPACE: If set, disks with less
- * space than #GduDiskSelectionWidget:component-size will be shown and eligible for selection.
- * Otherwise they are hidden.
+ * @GDU_DISK_SELECTION_WIDGET_FLAGS_ALLOW_DISKS_WITH_INSUFFICIENT_SPACE: If set, disks with less
+ * space than #GduDiskSelectionWidget:component-size will be eligible for selection.
  *
  * Flags used when creating a #GduDiskSelectionWidget.
  */
 typedef enum {
         GDU_DISK_SELECTION_WIDGET_FLAGS_NONE = 0,
         GDU_DISK_SELECTION_WIDGET_FLAGS_ALLOW_MULTIPLE = (1<<0),
-        GDU_DISK_SELECTION_WIDGET_FLAGS_SHOW_DISKS_WITH_INSUFFICIENT_SPACE = (1<<1)
+        GDU_DISK_SELECTION_WIDGET_FLAGS_ALLOW_DISKS_WITH_INSUFFICIENT_SPACE = (1<<1)
 } GduDiskSelectionWidgetFlags;
 
 #endif /* GDU_GTK_ENUMS_H */
diff --git a/src/gdu/gdu-marshal.list b/src/gdu/gdu-marshal.list
index 8767880..57563c8 100644
--- a/src/gdu/gdu-marshal.list
+++ b/src/gdu/gdu-marshal.list
@@ -1,2 +1,3 @@
 VOID:BOOLEAN,STRING,UINT,BOOLEAN,DOUBLE
 VOID:STRING,BOOLEAN,STRING,UINT,BOOLEAN,DOUBLE
+STRING:OBJECT



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