[gnome-disk-utility] Add a way to change the name of a Logical Volume
- From: David Zeuthen <davidz src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [gnome-disk-utility] Add a way to change the name of a Logical Volume
- Date: Tue, 12 Jan 2010 12:44:30 +0000 (UTC)
commit 072541d6c4cab32b1ff301a84590055bca8b4d6f
Author: David Zeuthen <davidz redhat com>
Date: Tue Jan 12 07:43:06 2010 -0500
Add a way to change the name of a Logical Volume
src/gdu/gdu-callbacks.h | 4 ++
src/gdu/gdu-pool.c | 45 ++++++++++++++++-
src/gdu/gdu-pool.h | 7 +++
src/palimpsest/gdu-section-volumes.c | 95 ++++++++++++++++++++++++++++++++-
4 files changed, 147 insertions(+), 4 deletions(-)
---
diff --git a/src/gdu/gdu-callbacks.h b/src/gdu/gdu-callbacks.h
index f47d060..c757f97 100644
--- a/src/gdu/gdu-callbacks.h
+++ b/src/gdu/gdu-callbacks.h
@@ -180,6 +180,10 @@ typedef void (*GduPoolLinuxLvm2VGSetNameCompletedFunc) (GduPool *pool,
GError *error,
gpointer user_data);
+typedef void (*GduPoolLinuxLvm2LVSetNameCompletedFunc) (GduPool *pool,
+ GError *error,
+ gpointer user_data);
+
/* ---------------------------------------------------------------------------------------------------- */
/* GduDrive */
diff --git a/src/gdu/gdu-pool.c b/src/gdu/gdu-pool.c
index 6ab4d45..eaf7073 100644
--- a/src/gdu/gdu-pool.c
+++ b/src/gdu/gdu-pool.c
@@ -2883,7 +2883,7 @@ gdu_pool_op_linux_lvm2_lv_start (GduPool *pool,
typedef struct {
GduPool *pool;
- GduPoolLinuxLvm2VGStopCompletedFunc callback;
+ GduPoolLinuxLvm2VGSetNameCompletedFunc callback;
gpointer user_data;
} LinuxLvm2VGSetNameData;
@@ -2921,6 +2921,49 @@ gdu_pool_op_linux_lvm2_vg_set_name (GduPool *pool,
/* ---------------------------------------------------------------------------------------------------- */
+
+typedef struct {
+ GduPool *pool;
+ GduPoolLinuxLvm2LVSetNameCompletedFunc callback;
+ gpointer user_data;
+} LinuxLvm2LVSetNameData;
+
+static void
+op_linux_lvm2_lv_set_name_cb (DBusGProxy *proxy, GError *error, gpointer user_data)
+{
+ LinuxLvm2LVSetNameData *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_set_name (GduPool *pool,
+ const gchar *group_uuid,
+ const gchar *uuid,
+ const gchar *new_name,
+ GduPoolLinuxLvm2LVSetNameCompletedFunc callback,
+ gpointer user_data)
+{
+ LinuxLvm2LVSetNameData *data;
+
+ 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_set_name_async (pool->priv->proxy,
+ group_uuid,
+ uuid,
+ new_name,
+ op_linux_lvm2_lv_set_name_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 1aecad3..8dabf35 100644
--- a/src/gdu/gdu-pool.h
+++ b/src/gdu/gdu-pool.h
@@ -155,6 +155,13 @@ void gdu_pool_op_linux_lvm2_vg_set_name (GduPool *pool,
GduPoolLinuxLvm2VGSetNameCompletedFunc callback,
gpointer user_data);
+void gdu_pool_op_linux_lvm2_lv_set_name (GduPool *pool,
+ const gchar *group_uuid,
+ const gchar *uuid,
+ const gchar *new_name,
+ GduPoolLinuxLvm2LVSetNameCompletedFunc 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 3768dab..33b0baf 100644
--- a/src/palimpsest/gdu-section-volumes.c
+++ b/src/palimpsest/gdu-section-volumes.c
@@ -71,6 +71,7 @@ struct _GduSectionVolumesPrivate
GduButtonElement *lvm2_create_lv_button;
GduButtonElement *lvm2_lv_start_button;
GduButtonElement *lvm2_lv_stop_button;
+ GduButtonElement *lvm2_lv_edit_name_button;
};
G_DEFINE_TYPE (GduSectionVolumes, gdu_section_volumes, GDU_TYPE_SECTION)
@@ -1509,6 +1510,80 @@ on_lvm2_lv_start_button_clicked (GduButtonElement *button_element,
/* ---------------------------------------------------------------------------------------------------- */
+
+static void
+lvm2_lv_set_name_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 setting name for 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_edit_name_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;
+ gchar *lv_name;
+ 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);
+
+ lv_name = gdu_presentable_get_name (GDU_PRESENTABLE (volume));
+
+ toplevel = GTK_WINDOW (gdu_shell_get_toplevel (gdu_section_get_shell (GDU_SECTION (section))));
+ dialog = gdu_edit_name_dialog_new (toplevel,
+ GDU_PRESENTABLE (volume),
+ lv_name,
+ 256,
+ _("Choose a new name for the Logical Volume."),
+ _("_Name:"));
+ gtk_widget_show_all (dialog);
+ response = gtk_dialog_run (GTK_DIALOG (dialog));
+ if (response == GTK_RESPONSE_APPLY) {
+ gchar *new_name;
+ new_name = gdu_edit_name_dialog_get_name (GDU_EDIT_NAME_DIALOG (dialog));
+ gdu_pool_op_linux_lvm2_lv_set_name (pool,
+ group_uuid,
+ uuid,
+ new_name,
+ lvm2_lv_set_name_op_callback,
+ g_object_ref (gdu_section_get_shell (GDU_SECTION (section))));
+ g_free (new_name);
+ }
+ gtk_widget_destroy (dialog);
+
+ g_object_unref (pool);
+ g_free (lv_name);
+}
+
+/* ---------------------------------------------------------------------------------------------------- */
+
static void
gdu_section_volumes_update (GduSection *_section)
{
@@ -1534,6 +1609,7 @@ gdu_section_volumes_update (GduSection *_section)
gboolean show_lvm2_create_lv_button;
gboolean show_lvm2_lv_start_button;
gboolean show_lvm2_lv_stop_button;
+ gboolean show_lvm2_lv_edit_name_button;
GduKnownFilesystem *kfs;
GPtrArray *elements;
@@ -1557,6 +1633,7 @@ gdu_section_volumes_update (GduSection *_section)
show_lvm2_create_lv_button = FALSE;
show_lvm2_lv_start_button = FALSE;
show_lvm2_lv_stop_button = FALSE;
+ show_lvm2_lv_edit_name_button = FALSE;
v = gdu_volume_grid_get_selected (GDU_VOLUME_GRID (section->priv->grid));
@@ -1665,6 +1742,7 @@ gdu_section_volumes_update (GduSection *_section)
show_lvm2_lv_stop_button = TRUE;
else
show_lvm2_lv_start_button = TRUE;
+ show_lvm2_lv_edit_name_button = TRUE;
}
if (section->priv->usage_element != NULL) {
@@ -1923,7 +2001,7 @@ gdu_section_volumes_update (GduSection *_section)
gdu_button_element_set_visible (section->priv->lvm2_create_lv_button, show_lvm2_create_lv_button);
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);
if (d != NULL)
g_object_unref (d);
@@ -2053,8 +2131,8 @@ gdu_section_volumes_constructed (GObject *object)
/* TODO: better icon */
button_element = gdu_button_element_new (GTK_STOCK_BOLD,
- _("Edit _Label"),
- _("Change the label of the volume"));
+ _("Edit Filesystem _Label"),
+ _("Change the label of the filesystem"));
g_signal_connect (button_element,
"clicked",
G_CALLBACK (on_fs_change_label_button_clicked),
@@ -2153,6 +2231,17 @@ gdu_section_volumes_constructed (GObject *object)
section->priv->lvm2_lv_start_button = button_element;
g_ptr_array_add (button_elements, button_element);
+ /* TODO: better icon */
+ button_element = gdu_button_element_new (GTK_STOCK_BOLD,
+ _("Edit Vol_ume Name"),
+ _("Change the name of the volume"));
+ g_signal_connect (button_element,
+ "clicked",
+ G_CALLBACK (on_lvm2_lv_edit_name_button_clicked),
+ section);
+ g_ptr_array_add (button_elements, button_element);
+ section->priv->lvm2_lv_edit_name_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]