[gnome-disk-utility] Make it possible to delete a LVM2 LV
- From: David Zeuthen <davidz src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [gnome-disk-utility] Make it possible to delete a LVM2 LV
- Date: Tue, 12 Jan 2010 15:17:02 +0000 (UTC)
commit ba4e1efebac7ff3c298d5adeb363390f1830fbdd
Author: David Zeuthen <davidz redhat com>
Date: Tue Jan 12 10:16:16 2010 -0500
Make it possible to delete a LVM2 LV
src/gdu/gdu-callbacks.h | 4 ++
src/gdu/gdu-pool.c | 45 +++++++++++++++++++-
src/gdu/gdu-pool.h | 6 +++
src/palimpsest/gdu-section-volumes.c | 78 +++++++++++++++++++++++++++++++++-
4 files changed, 131 insertions(+), 2 deletions(-)
---
diff --git a/src/gdu/gdu-callbacks.h b/src/gdu/gdu-callbacks.h
index c757f97..ffd34b9 100644
--- a/src/gdu/gdu-callbacks.h
+++ b/src/gdu/gdu-callbacks.h
@@ -184,6 +184,10 @@ typedef void (*GduPoolLinuxLvm2LVSetNameCompletedFunc) (GduPool *pool,
GError *error,
gpointer user_data);
+typedef void (*GduPoolLinuxLvm2LVRemoveCompletedFunc) (GduPool *pool,
+ GError *error,
+ gpointer user_data);
+
/* ---------------------------------------------------------------------------------------------------- */
/* GduDrive */
diff --git a/src/gdu/gdu-pool.c b/src/gdu/gdu-pool.c
index eaf7073..217cfed 100644
--- a/src/gdu/gdu-pool.c
+++ b/src/gdu/gdu-pool.c
@@ -2921,7 +2921,6 @@ gdu_pool_op_linux_lvm2_vg_set_name (GduPool *pool,
/* ---------------------------------------------------------------------------------------------------- */
-
typedef struct {
GduPool *pool;
GduPoolLinuxLvm2LVSetNameCompletedFunc callback;
@@ -2964,6 +2963,50 @@ gdu_pool_op_linux_lvm2_lv_set_name (GduPool *pool,
/* ---------------------------------------------------------------------------------------------------- */
+typedef struct {
+ GduPool *pool;
+ GduPoolLinuxLvm2LVRemoveCompletedFunc callback;
+ gpointer user_data;
+} LinuxLvm2LVRemoveData;
+
+static void
+op_linux_lvm2_lv_remove_cb (DBusGProxy *proxy, GError *error, gpointer user_data)
+{
+ LinuxLvm2LVRemoveData *data = user_data;
+ _gdu_error_fixup (error);
+ if (data->callback != NULL)
+ data->callback (data->pool, error, data->user_data);
+ g_object_unref (data->pool);
+ g_free (data);
+}
+
+void
+gdu_pool_op_linux_lvm2_lv_remove (GduPool *pool,
+ const gchar *group_uuid,
+ const gchar *uuid,
+ GduPoolLinuxLvm2LVSetNameCompletedFunc callback,
+ gpointer user_data)
+{
+ LinuxLvm2LVSetNameData *data;
+ char *options[16];
+
+ options[0] = NULL;
+
+ data = g_new0 (LinuxLvm2LVSetNameData, 1);
+ data->pool = g_object_ref (pool);
+ data->callback = callback;
+ data->user_data = user_data;
+
+ org_freedesktop_UDisks_linux_lvm2_lv_remove_async (pool->priv->proxy,
+ group_uuid,
+ uuid,
+ (const char **) options,
+ op_linux_lvm2_lv_remove_cb,
+ data);
+}
+
+/* ---------------------------------------------------------------------------------------------------- */
+
/**
* gdu_pool_get_daemon_version:
* @pool: A #GduPool.
diff --git a/src/gdu/gdu-pool.h b/src/gdu/gdu-pool.h
index 8dabf35..b93c1fb 100644
--- a/src/gdu/gdu-pool.h
+++ b/src/gdu/gdu-pool.h
@@ -162,6 +162,12 @@ void gdu_pool_op_linux_lvm2_lv_set_name (GduPool *pool,
GduPoolLinuxLvm2LVSetNameCompletedFunc callback,
gpointer user_data);
+void gdu_pool_op_linux_lvm2_lv_remove (GduPool *pool,
+ const gchar *group_uuid,
+ const gchar *uuid,
+ GduPoolLinuxLvm2LVRemoveCompletedFunc callback,
+ gpointer user_data);
+
G_END_DECLS
#endif /* __GDU_POOL_H */
diff --git a/src/palimpsest/gdu-section-volumes.c b/src/palimpsest/gdu-section-volumes.c
index 33b0baf..04b170b 100644
--- a/src/palimpsest/gdu-section-volumes.c
+++ b/src/palimpsest/gdu-section-volumes.c
@@ -72,6 +72,7 @@ struct _GduSectionVolumesPrivate
GduButtonElement *lvm2_lv_start_button;
GduButtonElement *lvm2_lv_stop_button;
GduButtonElement *lvm2_lv_edit_name_button;
+ GduButtonElement *lvm2_lv_delete_button;
};
G_DEFINE_TYPE (GduSectionVolumes, gdu_section_volumes, GDU_TYPE_SECTION)
@@ -1510,7 +1511,6 @@ on_lvm2_lv_start_button_clicked (GduButtonElement *button_element,
/* ---------------------------------------------------------------------------------------------------- */
-
static void
lvm2_lv_set_name_op_callback (GduPool *pool,
GError *error,
@@ -1585,6 +1585,68 @@ on_lvm2_lv_edit_name_button_clicked (GduButtonElement *button_element,
/* ---------------------------------------------------------------------------------------------------- */
static void
+lvm2_lv_remove_op_callback (GduPool *pool,
+ GError *error,
+ gpointer user_data)
+{
+ GduShell *shell = GDU_SHELL (user_data);
+
+ if (error != NULL) {
+ GtkWidget *dialog;
+ dialog = gdu_error_dialog_new (GTK_WINDOW (gdu_shell_get_toplevel (shell)),
+ NULL,
+ _("Error deleting Logical Volume"),
+ error);
+ gtk_widget_show_all (dialog);
+ gtk_window_present (GTK_WINDOW (dialog));
+ gtk_dialog_run (GTK_DIALOG (dialog));
+ gtk_widget_destroy (dialog);
+ g_error_free (error);
+ }
+ g_object_unref (shell);
+}
+
+static void
+on_lvm2_lv_delete_button_clicked (GduButtonElement *button_element,
+ gpointer user_data)
+{
+ GduSectionVolumes *section = GDU_SECTION_VOLUMES (user_data);
+ GduLinuxLvm2Volume *volume;
+ GduPool *pool;
+ const gchar *group_uuid;
+ const gchar *uuid;
+ GtkWindow *toplevel;
+ GtkWidget *dialog;
+ gint response;
+
+ volume = GDU_LINUX_LVM2_VOLUME (gdu_volume_grid_get_selected (GDU_VOLUME_GRID (section->priv->grid)));
+ pool = gdu_presentable_get_pool (GDU_PRESENTABLE (volume));
+
+ group_uuid = gdu_linux_lvm2_volume_get_group_uuid (volume);
+ uuid = gdu_linux_lvm2_volume_get_uuid (volume);
+
+ toplevel = GTK_WINDOW (gdu_shell_get_toplevel (gdu_section_get_shell (GDU_SECTION (section))));
+ dialog = gdu_confirmation_dialog_new (toplevel,
+ GDU_PRESENTABLE (volume),
+ _("Are you sure you want to delete the logical volume?"),
+ _("_Delete"));
+ gtk_widget_show_all (dialog);
+ response = gtk_dialog_run (GTK_DIALOG (dialog));
+ if (response == GTK_RESPONSE_OK) {
+ gdu_pool_op_linux_lvm2_lv_remove (pool,
+ group_uuid,
+ uuid,
+ lvm2_lv_remove_op_callback,
+ g_object_ref (gdu_section_get_shell (GDU_SECTION (section))));
+ }
+ gtk_widget_destroy (dialog);
+
+ g_object_unref (pool);
+}
+
+/* ---------------------------------------------------------------------------------------------------- */
+
+static void
gdu_section_volumes_update (GduSection *_section)
{
GduSectionVolumes *section = GDU_SECTION_VOLUMES (_section);
@@ -1610,6 +1672,7 @@ gdu_section_volumes_update (GduSection *_section)
gboolean show_lvm2_lv_start_button;
gboolean show_lvm2_lv_stop_button;
gboolean show_lvm2_lv_edit_name_button;
+ gboolean show_lvm2_lv_delete_button;
GduKnownFilesystem *kfs;
GPtrArray *elements;
@@ -1634,6 +1697,7 @@ gdu_section_volumes_update (GduSection *_section)
show_lvm2_lv_start_button = FALSE;
show_lvm2_lv_stop_button = FALSE;
show_lvm2_lv_edit_name_button = FALSE;
+ show_lvm2_lv_delete_button = FALSE;
v = gdu_volume_grid_get_selected (GDU_VOLUME_GRID (section->priv->grid));
@@ -1743,6 +1807,7 @@ gdu_section_volumes_update (GduSection *_section)
else
show_lvm2_lv_start_button = TRUE;
show_lvm2_lv_edit_name_button = TRUE;
+ show_lvm2_lv_delete_button = TRUE;
}
if (section->priv->usage_element != NULL) {
@@ -2002,6 +2067,7 @@ gdu_section_volumes_update (GduSection *_section)
gdu_button_element_set_visible (section->priv->lvm2_lv_start_button, show_lvm2_lv_start_button);
gdu_button_element_set_visible (section->priv->lvm2_lv_stop_button, show_lvm2_lv_stop_button);
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);
if (d != NULL)
g_object_unref (d);
@@ -2242,6 +2308,16 @@ gdu_section_volumes_constructed (GObject *object)
g_ptr_array_add (button_elements, button_element);
section->priv->lvm2_lv_edit_name_button = button_element;
+ button_element = gdu_button_element_new (GTK_STOCK_DELETE,
+ _("D_elete Volume"),
+ _("Delete the Logical Volume"));
+ g_signal_connect (button_element,
+ "clicked",
+ G_CALLBACK (on_lvm2_lv_delete_button_clicked),
+ section);
+ g_ptr_array_add (button_elements, button_element);
+ section->priv->lvm2_lv_delete_button = button_element;
+
button_element = gdu_button_element_new ("gdu-raid-array-stop",
_("Sto_p Volume"),
_("Deactivate the Logical Volume"));
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]