[gnome-disk-utility/udisks2-port] Implement UI parts of "Change Filesystem Label" dialog
- From: David Zeuthen <davidz src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-disk-utility/udisks2-port] Implement UI parts of "Change Filesystem Label" dialog
- Date: Sun, 13 Mar 2011 18:03:56 +0000 (UTC)
commit 3a0886b30b1063e0c22c4b751331948b431d4940
Author: David Zeuthen <davidz redhat com>
Date: Sun Mar 13 14:03:33 2011 -0400
Implement UI parts of "Change Filesystem Label" dialog
Signed-off-by: David Zeuthen <davidz redhat com>
data/ui/palimpsest.ui | 106 ++++++++++++++++++++++++++++++++++++++++++++
src/palimpsest/gduwindow.c | 76 ++++++++++++++++++++++++++++++-
2 files changed, 179 insertions(+), 3 deletions(-)
---
diff --git a/data/ui/palimpsest.ui b/data/ui/palimpsest.ui
index 97702ea..a8985dc 100644
--- a/data/ui/palimpsest.ui
+++ b/data/ui/palimpsest.ui
@@ -1,6 +1,112 @@
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<!-- interface-requires gtk+ 3.0 -->
+ <object class="GtkDialog" id="change-filesystem-label-dialog">
+ <property name="can_focus">False</property>
+ <property name="border_width">12</property>
+ <property name="resizable">False</property>
+ <property name="modal">True</property>
+ <property name="type_hint">dialog</property>
+ <child internal-child="vbox">
+ <object class="GtkBox" id="dialog-vbox4">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="orientation">vertical</property>
+ <property name="spacing">12</property>
+ <child>
+ <object class="GtkLabel" id="label6">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="xalign">0</property>
+ <property name="label" translatable="yes"><big>Change Filesystem Label</big></property>
+ <property name="use_markup">True</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child internal-child="action_area">
+ <object class="GtkButtonBox" id="dialog-action_area4">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="layout_style">end</property>
+ <child>
+ <object class="GtkButton" id="button3">
+ <property name="label">gtk-cancel</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ <property name="use_action_appearance">False</property>
+ <property name="use_stock">True</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkButton" id="button4">
+ <property name="label" translatable="yes">C_hange</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ <property name="use_action_appearance">False</property>
+ <property name="use_underline">True</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </object>
+ </child>
+ <child>
+ <object class="GtkTable" id="table2">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="n_columns">2</property>
+ <property name="column_spacing">12</property>
+ <child>
+ <object class="GtkLabel" id="label7">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="xalign">1</property>
+ <property name="label" translatable="yes">Label:</property>
+ </object>
+ <packing>
+ <property name="x_options">GTK_FILL</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkEntry" id="change-filesystem-label-entry">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="invisible_char">â?¢</property>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="right_attach">2</property>
+ <property name="y_options"></property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">2</property>
+ </packing>
+ </child>
+ </object>
+ </child>
+ <action-widgets>
+ <action-widget response="-6">button3</action-widget>
+ <action-widget response="-5">button4</action-widget>
+ </action-widgets>
+ </object>
<object class="GtkDialog" id="change-partition-type-dialog">
<property name="can_focus">False</property>
<property name="border_width">12</property>
diff --git a/src/palimpsest/gduwindow.c b/src/palimpsest/gduwindow.c
index c2b172e..09828a7 100644
--- a/src/palimpsest/gduwindow.c
+++ b/src/palimpsest/gduwindow.c
@@ -1086,10 +1086,80 @@ on_volume_grid_changed (GduVolumeGrid *grid,
update_devtab (window);
}
+/* ---------------------------------------------------------------------------------------------------- */
+
+typedef struct
+{
+ GtkWidget *dialog;
+ gchar *orig_label;
+} ChangeFilesystemLabelData;
+
static void
-on_change_label (GduWindow *window)
+on_change_filesystem_label_entry_changed (GtkEditable *editable,
+ gpointer user_data)
{
- g_debug ("TODO: %s", G_STRFUNC);
+ ChangeFilesystemLabelData *data = user_data;
+ gboolean sensitive;
+
+ sensitive = FALSE;
+ if (g_strcmp0 (gtk_entry_get_text (GTK_ENTRY (editable)), data->orig_label) != 0)
+ {
+ sensitive = TRUE;
+ }
+
+ gtk_dialog_set_response_sensitive (GTK_DIALOG (data->dialog),
+ GTK_RESPONSE_OK,
+ sensitive);
+}
+
+static void
+on_change_filesystem_label (GduWindow *window)
+{
+ gint response;
+ GtkWidget *dialog;
+ GtkWidget *entry;
+ GDBusObjectProxy *object_proxy;
+ UDisksBlockDevice *block;
+ const gchar *label;
+ ChangeFilesystemLabelData data;
+ const gchar *label_to_set;
+
+ object_proxy = gdu_volume_grid_get_selected_device (GDU_VOLUME_GRID (window->volume_grid));
+ g_assert (object_proxy != NULL);
+ block = UDISKS_PEEK_BLOCK_DEVICE (object_proxy);
+ g_assert (block != NULL);
+
+ dialog = gdu_window_get_widget (window, "change-filesystem-label-dialog");
+ entry = gdu_window_get_widget (window, "change-filesystem-label-entry");
+ gtk_window_set_transient_for (GTK_WINDOW (dialog), GTK_WINDOW (window));
+ //gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_OK);
+
+ label = udisks_block_device_get_id_label (block);
+ g_signal_connect (entry,
+ "changed",
+ G_CALLBACK (on_change_filesystem_label_entry_changed),
+ &data);
+ memset (&data, '\0', sizeof (ChangeFilesystemLabelData));
+ data.dialog = dialog;
+ data.orig_label = g_strdup (label);
+
+ gtk_entry_set_text (GTK_ENTRY (entry), label);
+
+ gtk_widget_show_all (dialog);
+ response = gtk_dialog_run (GTK_DIALOG (dialog));
+ if (response != GTK_RESPONSE_OK)
+ goto out;
+
+ label_to_set = gtk_entry_get_text (GTK_ENTRY (entry));
+
+ g_debug ("TODO: set filesystem label to %s", label_to_set);
+
+ out:
+ g_signal_handlers_disconnect_by_func (entry,
+ G_CALLBACK (on_change_filesystem_label_entry_changed),
+ &data);
+ gtk_widget_hide (dialog);
+ g_free (data.orig_label);
}
/* ---------------------------------------------------------------------------------------------------- */
@@ -1220,7 +1290,7 @@ on_activate_link (GtkLabel *label,
handled = TRUE;
if (g_strcmp0 (uri, "palimpsest://change/devtab-volume-label-value-label") == 0)
- on_change_label (window);
+ on_change_filesystem_label (window);
else if (g_strcmp0 (uri, "palimpsest://change/devtab-volume-partition-type-value-label") == 0)
on_change_partition_type (window);
else if (g_strcmp0 (uri, "palimpsest://change/devtab-volume-partition-label-value-label") == 0)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]