[gnome-disk-utility] Update for ABI change in udisks' LinuxLvm2VGRemovePV() method



commit ccd72387e2fbacbb874df14c78489571663cd208
Author: David Zeuthen <davidz redhat com>
Date:   Tue Jan 19 13:38:05 2010 -0500

    Update for ABI change in udisks' LinuxLvm2VGRemovePV() method

 src/gdu-gtk/gdu-edit-linux-lvm2-dialog.c           |   40 +++++++++++++++----
 src/gdu-gtk/gdu-edit-linux-lvm2-dialog.h           |    2 +-
 src/gdu/gdu-pool.c                                 |   12 +++---
 src/gdu/gdu-pool.h                                 |    6 +-
 .../gdu-section-linux-lvm2-volume-group.c          |   41 ++++++++++++-------
 5 files changed, 67 insertions(+), 34 deletions(-)
---
diff --git a/src/gdu-gtk/gdu-edit-linux-lvm2-dialog.c b/src/gdu-gtk/gdu-edit-linux-lvm2-dialog.c
index a36acad..9ac5402 100644
--- a/src/gdu-gtk/gdu-edit-linux-lvm2-dialog.c
+++ b/src/gdu-gtk/gdu-edit-linux-lvm2-dialog.c
@@ -71,6 +71,7 @@ static void update_tree (GduEditLinuxLvm2Dialog *dialog);
 static void update_details (GduEditLinuxLvm2Dialog *dialog);
 
 static GduDevice *get_selected_pv (GduEditLinuxLvm2Dialog *dialog);
+static gchar *get_selected_pv_uuid (GduEditLinuxLvm2Dialog *dialog);
 
 G_DEFINE_TYPE (GduEditLinuxLvm2Dialog, gdu_edit_linux_lvm2_dialog, GDU_TYPE_DIALOG)
 
@@ -120,10 +121,10 @@ gdu_edit_linux_lvm2_dialog_class_init (GduEditLinuxLvm2DialogClass *klass)
                               G_STRUCT_OFFSET (GduEditLinuxLvm2DialogClass, remove_button_clicked),
                               NULL,
                               NULL,
-                              g_cclosure_marshal_VOID__OBJECT,
+                              g_cclosure_marshal_VOID__STRING,
                               G_TYPE_NONE,
                               1,
-                              GDU_TYPE_DEVICE);
+                              G_TYPE_STRING);
 }
 
 static void
@@ -157,18 +158,19 @@ on_pv_new_button_clicked (GduButtonElement *button_element,
 
 static void
 on_pv_remove_button_clicked (GduButtonElement *button_element,
-                                    gpointer          user_data)
+                             gpointer          user_data)
 {
         GduEditLinuxLvm2Dialog *dialog = GDU_EDIT_LINUX_LVM2_DIALOG (user_data);
-        GduDevice *slave;
+        gchar *pv_uuid;
 
-        slave = get_selected_pv (dialog);
-        g_signal_emit (dialog, signals[REMOVE_BUTTON_CLICKED_SIGNAL], 0, slave);
-        g_object_unref (slave);
+        pv_uuid = get_selected_pv_uuid (dialog);
+        if (pv_uuid != NULL) {
+                g_signal_emit (dialog, signals[REMOVE_BUTTON_CLICKED_SIGNAL], 0, pv_uuid);
+                g_free (pv_uuid);
+        }
 }
 
 
-
 /* ---------------------------------------------------------------------------------------------------- */
 
 static void
@@ -552,6 +554,26 @@ get_selected_pv (GduEditLinuxLvm2Dialog *dialog)
         return pv;
 }
 
+static gchar *
+get_selected_pv_uuid (GduEditLinuxLvm2Dialog *dialog)
+{
+        gchar *pv_uuid;
+         GtkTreeSelection *tree_selection;
+        GtkTreeIter iter;
+
+        pv_uuid = NULL;
+
+        tree_selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (dialog->priv->pvs_tree_view));
+        if (gtk_tree_selection_get_selected (tree_selection, NULL, &iter)) {
+                gtk_tree_model_get (GTK_TREE_MODEL (dialog->priv->pvs_tree_store), &iter,
+                                    LINUX_LVM2_PV_UUID_COLUMN,
+                                    &pv_uuid,
+                                    -1);
+        }
+
+         return pv_uuid;
+}
+
 /* ---------------------------------------------------------------------------------------------------- */
 
 static gint
@@ -882,7 +904,7 @@ update_details (GduEditLinuxLvm2Dialog *dialog)
         //GduLinuxLvm2DriveSlaveFlags slave_flags;
 
         show_pv_new_button = TRUE; /* It's always possible to add a PV */
-        show_pv_remove_button = FALSE;
+        show_pv_remove_button = TRUE; /* .. and it's always possible to remove a PV */
 
         slave_drive_device = NULL;
 
diff --git a/src/gdu-gtk/gdu-edit-linux-lvm2-dialog.h b/src/gdu-gtk/gdu-edit-linux-lvm2-dialog.h
index 4286925..ae9573a 100644
--- a/src/gdu-gtk/gdu-edit-linux-lvm2-dialog.h
+++ b/src/gdu-gtk/gdu-edit-linux-lvm2-dialog.h
@@ -51,7 +51,7 @@ struct GduEditLinuxLvm2DialogClass
 
         void (*new_button_clicked)    (GduEditLinuxLvm2Dialog *dialog);
         void (*remove_button_clicked) (GduEditLinuxLvm2Dialog *dialog,
-                                       GduDevice              *physical_volume);
+                                       const gchar            *pv_uuid);
 };
 
 GType       gdu_edit_linux_lvm2_dialog_get_type           (void) G_GNUC_CONST;
diff --git a/src/gdu/gdu-pool.c b/src/gdu/gdu-pool.c
index 60cd862..1e516b3 100644
--- a/src/gdu/gdu-pool.c
+++ b/src/gdu/gdu-pool.c
@@ -3158,10 +3158,10 @@ op_linux_lvm2_vg_remove_pv_cb (DBusGProxy *proxy, GError *error, gpointer user_d
 
 void
 gdu_pool_op_linux_lvm2_vg_remove_pv (GduPool *pool,
-                                  const gchar *uuid,
-                                  const gchar *physical_volume_object_path,
-                                  GduPoolLinuxLvm2VGRemovePVCompletedFunc callback,
-                                  gpointer user_data)
+                                     const gchar *vg_uuid,
+                                     const gchar *pv_uuid,
+                                     GduPoolLinuxLvm2VGRemovePVCompletedFunc callback,
+                                     gpointer user_data)
 {
         LinuxLvm2VGRemovePVData *data;
         char *options[16];
@@ -3174,8 +3174,8 @@ gdu_pool_op_linux_lvm2_vg_remove_pv (GduPool *pool,
         data->user_data = user_data;
 
         org_freedesktop_UDisks_linux_lvm2_vg_remove_pv_async (pool->priv->proxy,
-                                                              uuid,
-                                                              physical_volume_object_path,
+                                                              vg_uuid,
+                                                              pv_uuid,
                                                               (const gchar **) options,
                                                               op_linux_lvm2_vg_remove_pv_cb,
                                                               data);
diff --git a/src/gdu/gdu-pool.h b/src/gdu/gdu-pool.h
index d98f027..ae050ec 100644
--- a/src/gdu/gdu-pool.h
+++ b/src/gdu/gdu-pool.h
@@ -191,9 +191,9 @@ void gdu_pool_op_linux_lvm2_vg_add_pv (GduPool *pool,
                                        gpointer user_data);
 
 void gdu_pool_op_linux_lvm2_vg_remove_pv (GduPool *pool,
-                                          const gchar *uuid,
-                                          const gchar *physical_volume_object_path,
-                                          GduPoolLinuxLvm2VGAddPVCompletedFunc callback,
+                                          const gchar *vg_uuid,
+                                          const gchar *pv_uuid,
+                                          GduPoolLinuxLvm2VGRemovePVCompletedFunc callback,
                                           gpointer user_data);
 
 G_END_DECLS
diff --git a/src/palimpsest/gdu-section-linux-lvm2-volume-group.c b/src/palimpsest/gdu-section-linux-lvm2-volume-group.c
index de68828..f2df3e6 100644
--- a/src/palimpsest/gdu-section-linux-lvm2-volume-group.c
+++ b/src/palimpsest/gdu-section-linux-lvm2-volume-group.c
@@ -462,7 +462,8 @@ on_pvs_dialog_new_button_clicked (GduEditLinuxMdDialog *_dialog,
 typedef struct {
         GduShell *shell;
         GduLinuxLvm2VolumeGroup *vg;
-        GduDevice *pv;
+        gchar *pv_uuid;
+        GduDevice *pv; /* may be NULL */
 } RemovePvData;
 
 static void
@@ -470,7 +471,9 @@ remove_pv_data_free (RemovePvData *data)
 {
         g_object_unref (data->shell);
         g_object_unref (data->vg);
-        g_object_unref (data->pv);
+        g_free (data->pv_uuid);
+        if (data->pv != NULL)
+                g_object_unref (data->pv);
         g_free (data);
 }
 
@@ -506,10 +509,10 @@ remove_pv_op_callback (GduPool    *pool,
 
         if (error != NULL) {
                 GtkWidget *dialog;
-                dialog = gdu_error_dialog_new_for_volume (GTK_WINDOW (gdu_shell_get_toplevel (data->shell)),
-                                                          data->pv,
-                                                          _("Error removing Physical Volume from Volume Group"),
-                                                          error);
+                dialog = gdu_error_dialog_new (GTK_WINDOW (gdu_shell_get_toplevel (data->shell)),
+                                               GDU_PRESENTABLE (data->vg),
+                                               _("Error removing Physical Volume from Volume Group"),
+                                               error);
                 gtk_widget_show_all (dialog);
                 gtk_window_present (GTK_WINDOW (dialog));
                 gtk_dialog_run (GTK_DIALOG (dialog));
@@ -519,7 +522,7 @@ remove_pv_op_callback (GduPool    *pool,
                 remove_pv_data_free (data);
         } else {
                 /* if the device is a partition, also remove the partition */
-                if (gdu_device_is_partition (data->pv)) {
+                if (data->pv != NULL && gdu_device_is_partition (data->pv)) {
                         gdu_device_op_partition_delete (data->pv,
                                                         remove_pv_delete_partition_op_callback,
                                                         data);
@@ -532,7 +535,7 @@ remove_pv_op_callback (GduPool    *pool,
 
 static void
 on_pvs_dialog_remove_button_clicked (GduEditLinuxMdDialog   *_dialog,
-                                     GduDevice              *physical_volume,
+                                     const gchar            *pv_uuid,
                                      gpointer                user_data)
 {
         GduSectionLinuxLvm2VolumeGroup *section = GDU_SECTION_LINUX_LVM2_VOLUME_GROUP (user_data);
@@ -542,18 +545,20 @@ on_pvs_dialog_remove_button_clicked (GduEditLinuxMdDialog   *_dialog,
         gint response;
         RemovePvData *data;
         GduPool *pool;
+        GduDevice *pv;
 
         pool = NULL;
+        pv = NULL;
 
         toplevel = GTK_WINDOW (gdu_shell_get_toplevel (gdu_section_get_shell (GDU_SECTION (section))));
 
         vg = GDU_LINUX_LVM2_VOLUME_GROUP (gdu_section_get_presentable (GDU_SECTION (section)));
 
         /* TODO: more details in this dialog - e.g. "The VG may degrade" etc etc */
-        dialog = gdu_confirmation_dialog_new_for_volume (toplevel,
-                                                         physical_volume,
-                                                         _("Are you sure you want the remove the Physical Volume?"),
-                                                         _("_Remove"));
+        dialog = gdu_confirmation_dialog_new (toplevel,
+                                              GDU_PRESENTABLE (vg),
+                                              _("Are you sure you want the remove the Physical Volume?"),
+                                              _("_Remove"));
         gtk_widget_show_all (dialog);
         response = gtk_dialog_run (GTK_DIALOG (dialog));
         gtk_widget_hide (dialog);
@@ -561,21 +566,27 @@ on_pvs_dialog_remove_button_clicked (GduEditLinuxMdDialog   *_dialog,
         if (response != GTK_RESPONSE_OK)
                 goto out;
 
+        /* TODO: find PV */
+
         data = g_new0 (RemovePvData, 1);
         data->shell = g_object_ref (gdu_section_get_shell (GDU_SECTION (section)));
         data->vg = g_object_ref (vg);
-        data->pv = g_object_ref (physical_volume);
+        data->pv_uuid = g_strdup (pv_uuid);
 
-        pool = gdu_device_get_pool (data->pv);
+        data->pv = pv != NULL ? g_object_ref (pv) : NULL;
+
+        pool = gdu_presentable_get_pool (GDU_PRESENTABLE (vg));
         gdu_pool_op_linux_lvm2_vg_remove_pv (pool,
                                              gdu_linux_lvm2_volume_group_get_uuid (data->vg),
-                                             gdu_device_get_object_path (physical_volume),
+                                             pv_uuid,
                                              remove_pv_op_callback,
                                              data);
 
  out:
         if (pool != NULL)
                 g_object_unref (pool);
+        if (pv != NULL)
+                g_object_unref (pv);
 }
 
 /* ---------------------------------------------------------------------------------------------------- */



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