[gnome-disk-utility/new-ui] Add a way to change filesystem labels
- From: David Zeuthen <davidz src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [gnome-disk-utility/new-ui] Add a way to change filesystem labels
- Date: Tue, 27 Oct 2009 15:23:50 +0000 (UTC)
commit e61632ca8b2a984939b900cce5a793f18789d5c9
Author: David Zeuthen <davidz redhat com>
Date: Tue Oct 27 11:23:41 2009 -0400
Add a way to change filesystem labels
src/gdu-gtk/Makefile.am | 2 +
src/gdu-gtk/gdu-edit-filesystem-dialog.c | 264 ++++++++++++++++++++++++++++++
src/gdu-gtk/gdu-edit-filesystem-dialog.h | 64 +++++++
src/gdu-gtk/gdu-gtk-types.h | 1 +
src/gdu-gtk/gdu-gtk.h | 1 +
src/palimpsest/gdu-section-volumes.c | 181 +++++++++++++++++----
6 files changed, 484 insertions(+), 29 deletions(-)
---
diff --git a/src/gdu-gtk/Makefile.am b/src/gdu-gtk/Makefile.am
index 2710b75..0cab29f 100644
--- a/src/gdu-gtk/Makefile.am
+++ b/src/gdu-gtk/Makefile.am
@@ -49,6 +49,7 @@ libgdu_gtkinclude_HEADERS = \
gdu-format-dialog.h \
gdu-partition-dialog.h \
gdu-create-partition-dialog.h \
+ gdu-edit-filesystem-dialog.h \
$(NULL)
libgdu_gtk_la_SOURCES = \
@@ -75,6 +76,7 @@ libgdu_gtk_la_SOURCES = \
gdu-format-dialog.h gdu-format-dialog.c \
gdu-partition-dialog.h gdu-partition-dialog.c \
gdu-create-partition-dialog.h gdu-create-partition-dialog.c \
+ gdu-edit-filesystem-dialog.h gdu-edit-filesystem-dialog.c \
$(NULL)
libgdu_gtk_la_CPPFLAGS = \
diff --git a/src/gdu-gtk/gdu-edit-filesystem-dialog.c b/src/gdu-gtk/gdu-edit-filesystem-dialog.c
new file mode 100644
index 0000000..c4e9db7
--- /dev/null
+++ b/src/gdu-gtk/gdu-edit-filesystem-dialog.c
@@ -0,0 +1,264 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- */
+/* gdu-edit-filesystem-dialog.c
+ *
+ * Copyright (C) 2009 David Zeuthen
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public License
+ * as published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+ * 02111-1307, USA.
+ */
+
+#include <config.h>
+#include <glib/gi18n.h>
+#include <atasmart.h>
+#include <glib/gstdio.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <errno.h>
+
+#include "gdu-gtk.h"
+#include "gdu-edit-filesystem-dialog.h"
+
+/* ---------------------------------------------------------------------------------------------------- */
+
+struct GduEditFilesystemDialogPrivate
+{
+ GtkWidget *label_entry;
+};
+
+enum {
+ PROP_0,
+ PROP_LABEL,
+};
+
+G_DEFINE_TYPE (GduEditFilesystemDialog, gdu_edit_filesystem_dialog, GDU_TYPE_DIALOG)
+
+static void
+gdu_edit_filesystem_dialog_finalize (GObject *object)
+{
+ //GduEditFilesystemDialog *dialog = GDU_EDIT_FILESYSTEM_DIALOG (object);
+
+ if (G_OBJECT_CLASS (gdu_edit_filesystem_dialog_parent_class)->finalize != NULL)
+ G_OBJECT_CLASS (gdu_edit_filesystem_dialog_parent_class)->finalize (object);
+}
+
+static void
+gdu_edit_filesystem_dialog_get_property (GObject *object,
+ guint property_id,
+ GValue *value,
+ GParamSpec *pspec)
+{
+ GduEditFilesystemDialog *dialog = GDU_EDIT_FILESYSTEM_DIALOG (object);
+
+ switch (property_id) {
+ case PROP_LABEL:
+ g_value_take_string (value, gdu_edit_filesystem_dialog_get_label (dialog));
+ break;
+
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+ break;
+ }
+}
+
+/* ---------------------------------------------------------------------------------------------------- */
+
+static void
+update_apply_sensitivity (GduEditFilesystemDialog *dialog)
+{
+ gboolean label_differ;
+ GduDevice *device;
+
+ device = gdu_dialog_get_device (GDU_DIALOG (dialog));
+
+ label_differ = FALSE;
+
+ if (g_strcmp0 (gdu_device_id_get_label (device),
+ gtk_entry_get_text (GTK_ENTRY (dialog->priv->label_entry))) != 0) {
+ label_differ = TRUE;
+ }
+
+ if (label_differ) {
+ gtk_dialog_set_response_sensitive (GTK_DIALOG (dialog), GTK_RESPONSE_APPLY, TRUE);
+ } else {
+ gtk_dialog_set_response_sensitive (GTK_DIALOG (dialog), GTK_RESPONSE_APPLY, FALSE);
+ }
+}
+
+static void
+update (GduEditFilesystemDialog *dialog)
+{
+ update_apply_sensitivity (dialog);
+}
+
+
+/* ---------------------------------------------------------------------------------------------------- */
+
+static void
+label_entry_changed (GtkWidget *combo_box,
+ gpointer user_data)
+{
+ GduEditFilesystemDialog *dialog = GDU_EDIT_FILESYSTEM_DIALOG (user_data);
+ update_apply_sensitivity (dialog);
+}
+
+/* ---------------------------------------------------------------------------------------------------- */
+
+static void
+gdu_edit_filesystem_dialog_constructed (GObject *object)
+{
+ GduEditFilesystemDialog *dialog = GDU_EDIT_FILESYSTEM_DIALOG (object);
+ GtkWidget *content_area;
+ GtkWidget *hbox;
+ GtkWidget *vbox;
+ GtkWidget *image;
+ GtkWidget *label;
+ gchar *s;
+ gchar *s2;
+ GIcon *icon;
+ GduPresentable *p;
+ GduDevice *d;
+ GduPool *pool;
+ GtkWidget *table;
+ GtkWidget *entry;
+ gint row;
+ GduKnownFilesystem *kfs;
+
+ gtk_dialog_set_has_separator (GTK_DIALOG (dialog), FALSE);
+ gtk_container_set_border_width (GTK_CONTAINER (dialog), 12);
+
+ gtk_dialog_add_button (GTK_DIALOG (dialog),
+ GTK_STOCK_CANCEL,
+ GTK_RESPONSE_CANCEL);
+
+ gtk_dialog_add_button (GTK_DIALOG (dialog),
+ GTK_STOCK_APPLY,
+ GTK_RESPONSE_APPLY);
+
+ content_area = gtk_dialog_get_content_area (GTK_DIALOG (dialog));
+
+ icon = gdu_presentable_get_icon (gdu_dialog_get_presentable (GDU_DIALOG (dialog)));
+
+ hbox = gtk_hbox_new (FALSE, 12);
+ gtk_box_pack_start (GTK_BOX (content_area), hbox, TRUE, TRUE, 0);
+
+ image = gtk_image_new_from_gicon (icon, GTK_ICON_SIZE_DIALOG);
+ gtk_misc_set_alignment (GTK_MISC (image), 0.5, 0.0);
+ gtk_box_pack_start (GTK_BOX (hbox), image, FALSE, FALSE, 0);
+
+ vbox = gtk_vbox_new (FALSE, 12);
+ gtk_box_pack_start (GTK_BOX (hbox), vbox, FALSE, FALSE, 0);
+
+ p = gdu_dialog_get_presentable (GDU_DIALOG (dialog));
+ d = gdu_presentable_get_device (p);
+ pool = gdu_presentable_get_pool (p);
+ kfs = gdu_pool_get_known_filesystem_by_id (pool, gdu_device_id_get_type (d));
+
+ s2 = gdu_presentable_get_vpd_name (gdu_dialog_get_presentable (GDU_DIALOG (dialog)));
+ s = g_strdup_printf (_("Edit Filesystem on %s"), s2);
+ gtk_window_set_title (GTK_WINDOW (dialog), s);
+ g_free (s);
+ g_free (s2);
+
+ /* --- */
+
+ table = gtk_table_new (2, 2, FALSE);
+ gtk_table_set_col_spacings (GTK_TABLE (table), 12);
+ gtk_box_pack_start (GTK_BOX (vbox), table, FALSE, FALSE, 0);
+
+ row = 0;
+
+ 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), _("Label:"));
+ gtk_table_attach (GTK_TABLE (table), label, 0, 1, row, row + 1,
+ GTK_FILL, GTK_EXPAND | GTK_FILL, 2, 2);
+ entry = gtk_entry_new ();
+ gtk_table_attach (GTK_TABLE (table), entry, 1, 2, row, row + 1,
+ GTK_FILL, GTK_EXPAND | GTK_FILL, 2, 2);
+ gtk_label_set_mnemonic_widget (GTK_LABEL (label), entry);
+ /* init with current label */
+ gtk_entry_set_text (GTK_ENTRY (entry), gdu_device_id_get_label (d));
+ if (kfs != NULL)
+ gtk_entry_set_max_length (GTK_ENTRY (entry),
+ gdu_known_filesystem_get_max_label_len (kfs));
+ dialog->priv->label_entry = entry;
+
+ row++;
+
+ /* --- */
+
+
+ g_signal_connect (dialog->priv->label_entry,
+ "changed",
+ G_CALLBACK (label_entry_changed),
+ dialog);
+
+ g_object_unref (icon);
+ g_object_unref (d);
+ g_object_unref (pool);
+ g_object_unref (kfs);
+
+ update (dialog);
+
+ if (G_OBJECT_CLASS (gdu_edit_filesystem_dialog_parent_class)->constructed != NULL)
+ G_OBJECT_CLASS (gdu_edit_filesystem_dialog_parent_class)->constructed (object);
+}
+
+static void
+gdu_edit_filesystem_dialog_class_init (GduEditFilesystemDialogClass *klass)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+ g_type_class_add_private (klass, sizeof (GduEditFilesystemDialogPrivate));
+
+ object_class->get_property = gdu_edit_filesystem_dialog_get_property;
+ object_class->constructed = gdu_edit_filesystem_dialog_constructed;
+ object_class->finalize = gdu_edit_filesystem_dialog_finalize;
+
+ g_object_class_install_property (object_class,
+ PROP_LABEL,
+ g_param_spec_string ("label",
+ NULL,
+ NULL,
+ NULL,
+ G_PARAM_READABLE));
+}
+
+static void
+gdu_edit_filesystem_dialog_init (GduEditFilesystemDialog *dialog)
+{
+ dialog->priv = G_TYPE_INSTANCE_GET_PRIVATE (dialog,
+ GDU_TYPE_EDIT_FILESYSTEM_DIALOG,
+ GduEditFilesystemDialogPrivate);
+}
+
+GtkWidget *
+gdu_edit_filesystem_dialog_new (GtkWindow *parent,
+ GduPresentable *presentable)
+{
+ g_return_val_if_fail (GDU_IS_PRESENTABLE (presentable), NULL);
+ return GTK_WIDGET (g_object_new (GDU_TYPE_EDIT_FILESYSTEM_DIALOG,
+ "transient-for", parent,
+ "presentable", presentable,
+ NULL));
+}
+
+gchar *
+gdu_edit_filesystem_dialog_get_label (GduEditFilesystemDialog *dialog)
+{
+ g_return_val_if_fail (GDU_IS_EDIT_FILESYSTEM_DIALOG (dialog), NULL);
+ return g_strdup (gtk_entry_get_text (GTK_ENTRY (dialog->priv->label_entry)));
+}
diff --git a/src/gdu-gtk/gdu-edit-filesystem-dialog.h b/src/gdu-gtk/gdu-edit-filesystem-dialog.h
new file mode 100644
index 0000000..06cb671
--- /dev/null
+++ b/src/gdu-gtk/gdu-edit-filesystem-dialog.h
@@ -0,0 +1,64 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- */
+/* gdu-edit-filesystem-dialog.h
+ *
+ * Copyright (C) 2009 David Zeuthen
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public License
+ * as published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+ * 02111-1307, USA.
+ */
+
+#if !defined (__GDU_GTK_INSIDE_GDU_GTK_H) && !defined (GDU_GTK_COMPILATION)
+#error "Only <gdu-gtk/gdu-gtk.h> can be included directly, this file may disappear or change contents."
+#endif
+
+#ifndef __GDU_EDIT_FILESYSTEM_DIALOG_H
+#define __GDU_EDIT_FILESYSTEM_DIALOG_H
+
+#include <gdu-gtk/gdu-gtk-types.h>
+#include <gdu-gtk/gdu-dialog.h>
+
+G_BEGIN_DECLS
+
+#define GDU_TYPE_EDIT_FILESYSTEM_DIALOG gdu_edit_filesystem_dialog_get_type()
+#define GDU_EDIT_FILESYSTEM_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GDU_TYPE_EDIT_FILESYSTEM_DIALOG, GduEditFilesystemDialog))
+#define GDU_EDIT_FILESYSTEM_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GDU_TYPE_EDIT_FILESYSTEM_DIALOG, GduEditFilesystemDialogClass))
+#define GDU_IS_EDIT_FILESYSTEM_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GDU_TYPE_EDIT_FILESYSTEM_DIALOG))
+#define GDU_IS_EDIT_FILESYSTEM_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GDU_TYPE_EDIT_FILESYSTEM_DIALOG))
+#define GDU_EDIT_FILESYSTEM_DIALOG_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GDU_TYPE_EDIT_FILESYSTEM_DIALOG, GduEditFilesystemDialogClass))
+
+typedef struct GduEditFilesystemDialogClass GduEditFilesystemDialogClass;
+typedef struct GduEditFilesystemDialogPrivate GduEditFilesystemDialogPrivate;
+
+struct GduEditFilesystemDialog
+{
+ GduDialog parent;
+
+ /*< private >*/
+ GduEditFilesystemDialogPrivate *priv;
+};
+
+struct GduEditFilesystemDialogClass
+{
+ GduDialogClass parent_class;
+};
+
+GType gdu_edit_filesystem_dialog_get_type (void) G_GNUC_CONST;
+GtkWidget *gdu_edit_filesystem_dialog_new (GtkWindow *parent,
+ GduPresentable *volume);
+gchar *gdu_edit_filesystem_dialog_get_label (GduEditFilesystemDialog *dialog);
+
+G_END_DECLS
+
+#endif /* __GDU_EDIT_FILESYSTEM_DIALOG_H */
diff --git a/src/gdu-gtk/gdu-gtk-types.h b/src/gdu-gtk/gdu-gtk-types.h
index fa183d0..f37e657 100644
--- a/src/gdu-gtk/gdu-gtk-types.h
+++ b/src/gdu-gtk/gdu-gtk-types.h
@@ -56,6 +56,7 @@ typedef struct GduEditPartitionDialog GduEditPartitionDialog;
typedef struct GduFormatDialog GduFormatDialog;
typedef struct GduPartitionDialog GduPartitionDialog;
typedef struct GduCreatePartitionDialog GduCreatePartitionDialog;
+typedef struct GduEditFilesystemDialog GduEditFilesystemDialog;
G_END_DECLS
diff --git a/src/gdu-gtk/gdu-gtk.h b/src/gdu-gtk/gdu-gtk.h
index 5c40c09..91997eb 100644
--- a/src/gdu-gtk/gdu-gtk.h
+++ b/src/gdu-gtk/gdu-gtk.h
@@ -48,6 +48,7 @@
#include <gdu-gtk/gdu-format-dialog.h>
#include <gdu-gtk/gdu-partition-dialog.h>
#include <gdu-gtk/gdu-create-partition-dialog.h>
+#include <gdu-gtk/gdu-edit-filesystem-dialog.h>
#undef __GDU_GTK_INSIDE_GDU_GTK_H
G_BEGIN_DECLS
diff --git a/src/palimpsest/gdu-section-volumes.c b/src/palimpsest/gdu-section-volumes.c
index 597bfb9..4976d5f 100644
--- a/src/palimpsest/gdu-section-volumes.c
+++ b/src/palimpsest/gdu-section-volumes.c
@@ -40,7 +40,9 @@ struct _GduSectionVolumesPrivate
/* shared between all volume types */
GduDetailsElement *usage_element;
GduDetailsElement *capacity_element;
- GduDetailsElement *partition_element;
+ GduDetailsElement *partition_type_element;
+ GduDetailsElement *partition_flags_element;
+ GduDetailsElement *partition_label_element;
GduDetailsElement *device_element;
/* elements for the 'filesystem' usage */
@@ -52,6 +54,7 @@ struct _GduSectionVolumesPrivate
GduButtonElement *fs_mount_button;
GduButtonElement *fs_unmount_button;
GduButtonElement *fs_check_button;
+ GduButtonElement *fs_change_label_button;
GduButtonElement *format_button;
GduButtonElement *partition_edit_button;
GduButtonElement *partition_delete_button;
@@ -940,8 +943,6 @@ partition_create_op_callback (GduDevice *device,
gtk_widget_destroy (dialog);
g_error_free (error);
} else {
- g_debug ("Created %s", created_device_object_path);
-
if (data->encrypt_passphrase != NULL) {
GduDevice *cleartext_device;
GduPool *pool;
@@ -1095,6 +1096,76 @@ on_partition_create_button_clicked (GduButtonElement *button_element,
/* ---------------------------------------------------------------------------------------------------- */
static void
+filesystem_set_label_op_callback (GduDevice *device,
+ GError *error,
+ gpointer user_data)
+{
+ GduShell *shell = GDU_SHELL (user_data);
+
+ if (error != NULL) {
+ GtkWidget *dialog;
+ dialog = gdu_error_dialog_new_for_volume (GTK_WINDOW (gdu_shell_get_toplevel (shell)),
+ device,
+ _("Error changing label"),
+ 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_fs_change_label_button_clicked (GduButtonElement *button_element,
+ gpointer user_data)
+{
+ GduSectionVolumes *section = GDU_SECTION_VOLUMES (user_data);
+ GduPresentable *v;
+ GduDevice *d;
+ GtkWindow *toplevel;
+ GtkWidget *dialog;
+ gint response;
+
+ v = NULL;
+
+ v = gdu_volume_grid_get_selected (GDU_VOLUME_GRID (section->priv->grid));
+ if (v == NULL)
+ goto out;
+
+ d = gdu_presentable_get_device (v);
+ if (d == NULL)
+ goto out;
+
+ toplevel = GTK_WINDOW (gdu_shell_get_toplevel (gdu_section_get_shell (GDU_SECTION (section))));
+ dialog = gdu_edit_filesystem_dialog_new (toplevel, v);
+ gtk_widget_show_all (dialog);
+ response = gtk_dialog_run (GTK_DIALOG (dialog));
+ if (response == GTK_RESPONSE_APPLY) {
+ gchar *label;
+
+ label = gdu_edit_filesystem_dialog_get_label (GDU_EDIT_FILESYSTEM_DIALOG (dialog));
+
+ gdu_device_op_filesystem_set_label (d,
+ label,
+ filesystem_set_label_op_callback,
+ g_object_ref (gdu_section_get_shell (GDU_SECTION (section))));
+
+ g_free (label);
+ }
+ gtk_widget_destroy (dialog);
+
+ out:
+ if (d != NULL)
+ g_object_unref (d);
+ if (v != NULL)
+ g_object_unref (v);
+}
+
+/* ---------------------------------------------------------------------------------------------------- */
+
+static void
gdu_section_volumes_update (GduSection *_section)
{
GduSectionVolumes *section = GDU_SECTION_VOLUMES (_section);
@@ -1102,10 +1173,12 @@ gdu_section_volumes_update (GduSection *_section)
GduDevice *d;
gchar *s;
gchar *s2;
- const gchar *usage;
+ const gchar *id_usage;
+ const gchar *id_type;
gboolean show_fs_mount_button;
gboolean show_fs_unmount_button;
gboolean show_fs_check_button;
+ gboolean show_fs_change_label_button;
gboolean show_format_button;
gboolean show_partition_edit_button;
gboolean show_partition_delete_button;
@@ -1114,13 +1187,17 @@ gdu_section_volumes_update (GduSection *_section)
gboolean show_luks_unlock_button;
gboolean show_luks_forget_passphrase_button;
gboolean show_luks_change_passphrase_button;
+ GduKnownFilesystem *kfs;
v = NULL;
d = NULL;
- usage = "";
+ kfs = NULL;
+ id_usage = "";
+ id_type = "";
show_fs_mount_button = FALSE;
show_fs_unmount_button = FALSE;
show_fs_check_button = FALSE;
+ show_fs_change_label_button = FALSE;
show_format_button = FALSE;
show_partition_edit_button = FALSE;
show_partition_delete_button = FALSE;
@@ -1135,7 +1212,15 @@ gdu_section_volumes_update (GduSection *_section)
if (v != NULL) {
d = gdu_presentable_get_device (v);
if (d != NULL) {
- usage = gdu_device_id_get_usage (d);
+ GduPool *pool;
+
+ pool = gdu_device_get_pool (d);
+
+ id_usage = gdu_device_id_get_usage (d);
+ id_type = gdu_device_id_get_type (d);
+ kfs = gdu_pool_get_known_filesystem_by_id (pool, id_type);
+
+ g_object_unref (pool);
}
}
@@ -1151,7 +1236,9 @@ gdu_section_volumes_update (GduSection *_section)
section->priv->usage_element = NULL;
section->priv->capacity_element = NULL;
- section->priv->partition_element = NULL;
+ section->priv->partition_type_element = NULL;
+ section->priv->partition_flags_element = NULL;
+ section->priv->partition_label_element = NULL;
section->priv->device_element = NULL;
section->priv->fs_type_element = NULL;
section->priv->fs_label_element = NULL;
@@ -1166,13 +1253,19 @@ gdu_section_volumes_update (GduSection *_section)
section->priv->device_element = gdu_details_element_new (_("Device:"), NULL, NULL);
g_ptr_array_add (elements, section->priv->device_element);
- section->priv->partition_element = gdu_details_element_new (_("Partition:"), NULL, NULL);
- g_ptr_array_add (elements, section->priv->partition_element);
+ section->priv->partition_type_element = gdu_details_element_new (_("Partition Type:"), NULL, NULL);
+ g_ptr_array_add (elements, section->priv->partition_type_element);
+
+ section->priv->partition_label_element = gdu_details_element_new (_("Partition Label:"), NULL, NULL);
+ g_ptr_array_add (elements, section->priv->partition_label_element);
+
+ section->priv->partition_flags_element = gdu_details_element_new (_("Partition Flags:"), NULL, NULL);
+ g_ptr_array_add (elements, section->priv->partition_flags_element);
section->priv->capacity_element = gdu_details_element_new (_("Capacity:"), NULL, NULL);
g_ptr_array_add (elements, section->priv->capacity_element);
- if (g_strcmp0 (usage, "filesystem") == 0) {
+ if (g_strcmp0 (id_usage, "filesystem") == 0) {
section->priv->fs_type_element = gdu_details_element_new (_("Type:"), NULL, NULL);
g_ptr_array_add (elements, section->priv->fs_type_element);
@@ -1204,8 +1297,9 @@ gdu_section_volumes_update (GduSection *_section)
gdu_details_element_set_text (section->priv->capacity_element, "â??");
}
}
- if (section->priv->partition_element != NULL) {
+ if (section->priv->partition_type_element != NULL) {
if (d != NULL && gdu_device_is_partition (d)) {
+ const gchar *partition_label;
const gchar * const *partition_flags;
guint n;
GString *str;
@@ -1243,21 +1337,24 @@ gdu_section_volumes_update (GduSection *_section)
s = gdu_util_get_desc_for_part_type (gdu_device_partition_get_scheme (d),
gdu_device_partition_get_type (d));
+ gdu_details_element_set_text (section->priv->partition_type_element, s);
+ g_free (s);
if (str->len > 0) {
- /* Translators: First %s is the partition type, second %s is a comma
- * separated list of partition flags
- */
- s2 = g_strdup_printf (C_("Partition Type", "%s (%s)"), s, str->str);
- gdu_details_element_set_text (section->priv->partition_element, s2);
- g_free (s2);
+ gdu_details_element_set_text (section->priv->partition_flags_element, str->str);
} else {
- gdu_details_element_set_text (section->priv->partition_element, s);
+ gdu_details_element_set_text (section->priv->partition_flags_element, "â??");
}
- g_free (s);
g_string_free (str, TRUE);
show_partition_delete_button = TRUE;
+ partition_label = gdu_device_partition_get_label (d);
+ if (partition_label != NULL && strlen (partition_label) > 0) {
+ gdu_details_element_set_text (section->priv->partition_label_element, partition_label);
+ } else {
+ gdu_details_element_set_text (section->priv->partition_label_element, "â??");
+ }
+
/* Don't show partition edit button for extended partitions */
show_partition_edit_button = TRUE;
if (g_strcmp0 (gdu_device_partition_get_scheme (d), "mbr") == 0) {
@@ -1271,7 +1368,7 @@ gdu_section_volumes_update (GduSection *_section)
}
}
} else {
- gdu_details_element_set_text (section->priv->partition_element, "â??");
+ gdu_details_element_set_text (section->priv->partition_type_element, "â??");
}
}
if (section->priv->device_element != NULL) {
@@ -1298,7 +1395,7 @@ gdu_section_volumes_update (GduSection *_section)
/* populate according to usage */
show_format_button = TRUE;
- if (g_strcmp0 (usage, "filesystem") == 0) {
+ if (g_strcmp0 (id_usage, "filesystem") == 0) {
gdu_details_element_set_text (section->priv->usage_element, _("Filesystem"));
s = gdu_util_get_fstype_for_display (gdu_device_id_get_type (d),
gdu_device_id_get_version (d),
@@ -1338,7 +1435,7 @@ gdu_section_volumes_update (GduSection *_section)
show_fs_check_button = TRUE;
- } else if (g_strcmp0 (usage, "crypto") == 0) {
+ } else if (g_strcmp0 (id_usage, "crypto") == 0) {
if (g_strcmp0 (gdu_device_luks_get_holder (d), "/") == 0) {
show_luks_unlock_button = TRUE;
@@ -1351,7 +1448,7 @@ gdu_section_volumes_update (GduSection *_section)
show_luks_forget_passphrase_button = TRUE;
show_luks_change_passphrase_button = TRUE;
- } else if (g_strcmp0 (usage, "") == 0 &&
+ } else if (g_strcmp0 (id_usage, "") == 0 &&
d != NULL && gdu_device_is_partition (d) &&
g_strcmp0 (gdu_device_partition_get_scheme (d), "mbr") == 0 &&
(g_strcmp0 (gdu_device_partition_get_type (d), "0x05") == 0 ||
@@ -1373,9 +1470,22 @@ gdu_section_volumes_update (GduSection *_section)
show_format_button = FALSE;
}
+ if (kfs != NULL) {
+ if (show_fs_unmount_button) {
+ if (gdu_known_filesystem_get_supports_online_label_rename (kfs)) {
+ show_fs_change_label_button = TRUE;
+ }
+ } else {
+ if (gdu_known_filesystem_get_supports_label_rename (kfs)) {
+ show_fs_change_label_button = TRUE;
+ }
+ }
+ }
+
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);
gdu_button_element_set_visible (section->priv->fs_check_button, show_fs_check_button);
+ gdu_button_element_set_visible (section->priv->fs_change_label_button, show_fs_change_label_button);
gdu_button_element_set_visible (section->priv->format_button, show_format_button);
gdu_button_element_set_visible (section->priv->partition_edit_button, show_partition_edit_button);
gdu_button_element_set_visible (section->priv->partition_delete_button, show_partition_delete_button);
@@ -1390,6 +1500,8 @@ gdu_section_volumes_update (GduSection *_section)
g_object_unref (d);
if (v != NULL)
g_object_unref (v);
+ if (kfs != NULL)
+ g_object_unref (kfs);
}
/* ---------------------------------------------------------------------------------------------------- */
@@ -1483,6 +1595,16 @@ gdu_section_volumes_constructed (GObject *object)
g_ptr_array_add (button_elements, button_element);
section->priv->fs_unmount_button = button_element;
+ button_element = gdu_button_element_new ("nautilus-gdu",
+ _("Fo_rmat Volume"),
+ _("Format the volume"));
+ g_signal_connect (button_element,
+ "clicked",
+ G_CALLBACK (on_format_button_clicked),
+ section);
+ g_ptr_array_add (button_elements, button_element);
+ section->priv->format_button = button_element;
+
button_element = gdu_button_element_new ("gdu-check-disk",
_("_Check Filesystem"),
_("Check the filesystem for errors"));
@@ -1495,19 +1617,20 @@ gdu_section_volumes_constructed (GObject *object)
g_ptr_array_add (button_elements, button_element);
section->priv->fs_check_button = button_element;
- button_element = gdu_button_element_new ("nautilus-gdu",
- _("Fo_rmat Volume"),
- _("Format the volume"));
+ /* TODO: better icon */
+ button_element = gdu_button_element_new (GTK_STOCK_BOLD,
+ _("Edit _Label"),
+ _("Change the label of the volume"));
g_signal_connect (button_element,
"clicked",
- G_CALLBACK (on_format_button_clicked),
+ G_CALLBACK (on_fs_change_label_button_clicked),
section);
g_ptr_array_add (button_elements, button_element);
- section->priv->format_button = button_element;
+ section->priv->fs_change_label_button = button_element;
button_element = gdu_button_element_new (GTK_STOCK_EDIT,
_("Ed_it Partition"),
- _("Change partition type and flags"));
+ _("Change partition type, label and flags"));
g_signal_connect (button_element,
"clicked",
G_CALLBACK (on_partition_edit_button_clicked),
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]