[gnome-disk-utility/udisks2-port] Make setting fstab/crypttab options a bit friendlier
- From: David Zeuthen <davidz src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-disk-utility/udisks2-port] Make setting fstab/crypttab options a bit friendlier
- Date: Mon, 12 Dec 2011 21:09:37 +0000 (UTC)
commit 182bc46b1311ac8f9568bd76e9b9667b5b6b4e21
Author: David Zeuthen <davidz redhat com>
Date: Mon Dec 12 16:07:50 2011 -0500
Make setting fstab/crypttab options a bit friendlier
In particular, map well-known options
- noauto
- users
- comment=gvfs.name=<VALUE>
- comment=gvfs.icon_name=<VALUE>
to check-buttons and entries.
http://people.freedesktop.org/~david/gdu2-fstab-mount-options.png
http://people.freedesktop.org/~david/gdu2-crypttab-options.png
Signed-off-by: David Zeuthen <davidz redhat com>
data/ui/edit-crypttab-dialog.ui | 65 +++++++----
data/ui/edit-fstab-dialog.ui | 220 ++++++++++++++++++++++++------------
src/palimpsest/gducrypttabdialog.c | 29 +++--
src/palimpsest/gdufstabdialog.c | 108 +++++++++--------
src/palimpsest/gduutils.c | 152 +++++++++++++++++++++++++
src/palimpsest/gduutils.h | 10 ++
6 files changed, 424 insertions(+), 160 deletions(-)
---
diff --git a/data/ui/edit-crypttab-dialog.ui b/data/ui/edit-crypttab-dialog.ui
index 17f567b..210169e 100644
--- a/data/ui/edit-crypttab-dialog.ui
+++ b/data/ui/edit-crypttab-dialog.ui
@@ -77,7 +77,7 @@
</child>
<child>
<object class="GtkCheckButton" id="crypttab-configure-checkbutton">
- <property name="label" translatable="yes">Config_ure passphrase and options</property>
+ <property name="label" translatable="yes">Con_figure passphrase and options</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
@@ -182,38 +182,34 @@
</packing>
</child>
<child>
- <object class="GtkLabel" id="crypttab-passphrase-label">
+ <object class="GtkLabel" id="crypttab-passphrase-path-label">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="xalign">1</property>
- <property name="label" translatable="yes">_Passphrase</property>
+ <property name="label" translatable="yes">Passphrase File</property>
<property name="use_underline">True</property>
- <property name="mnemonic_widget">crypttab-passphrase-entry</property>
<attributes>
<attribute name="foreground" value="#555555555555"/>
</attributes>
</object>
<packing>
<property name="left_attach">0</property>
- <property name="top_attach">2</property>
+ <property name="top_attach">5</property>
<property name="width">1</property>
<property name="height">1</property>
</packing>
</child>
<child>
- <object class="GtkEntry" id="crypttab-passphrase-entry">
+ <object class="GtkLabel" id="crypttab-passphrase-path-value-label">
<property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="has_tooltip">True</property>
- <property name="tooltip_markup" translatable="yes">Passphrase of the device or empty to request from user when setting up the device</property>
- <property name="tooltip_text" translatable="yes">Passphrase of the device or empty to request from user when setting up the device</property>
- <property name="hexpand">True</property>
- <property name="invisible_char">â</property>
- <property name="invisible_char_set">True</property>
+ <property name="can_focus">False</property>
+ <property name="xalign">0</property>
+ <property name="selectable">True</property>
+ <property name="ellipsize">middle</property>
</object>
<packing>
<property name="left_attach">1</property>
- <property name="top_attach">2</property>
+ <property name="top_attach">5</property>
<property name="width">1</property>
<property name="height">1</property>
</packing>
@@ -231,17 +227,35 @@
</object>
<packing>
<property name="left_attach">1</property>
+ <property name="top_attach">4</property>
+ <property name="width">1</property>
+ <property name="height">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkEntry" id="crypttab-passphrase-entry">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="has_tooltip">True</property>
+ <property name="tooltip_markup" translatable="yes">Passphrase of the device or empty to request from user when setting up the device</property>
+ <property name="tooltip_text" translatable="yes">Passphrase of the device or empty to request from user when setting up the device</property>
+ <property name="hexpand">True</property>
+ <property name="invisible_char">â</property>
+ <property name="invisible_char_set">True</property>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
<property name="top_attach">3</property>
<property name="width">1</property>
<property name="height">1</property>
</packing>
</child>
<child>
- <object class="GtkLabel" id="crypttab-passphrase-path-label">
+ <object class="GtkLabel" id="crypttab-passphrase-label">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="xalign">1</property>
- <property name="label" translatable="yes">Passphrase File</property>
+ <property name="label" translatable="yes">_Passphrase</property>
<property name="use_underline">True</property>
<attributes>
<attribute name="foreground" value="#555555555555"/>
@@ -249,22 +263,26 @@
</object>
<packing>
<property name="left_attach">0</property>
- <property name="top_attach">4</property>
+ <property name="top_attach">3</property>
<property name="width">1</property>
<property name="height">1</property>
</packing>
</child>
<child>
- <object class="GtkLabel" id="crypttab-passphrase-path-value-label">
+ <object class="GtkCheckButton" id="crypttab-noauto-checkbutton">
+ <property name="label" translatable="yes">Don't unlock at _startup</property>
<property name="visible">True</property>
- <property name="can_focus">False</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">False</property>
+ <property name="tooltip_text" translatable="yes">If checked, the device will not be unlocked at startup [noauto]</property>
+ <property name="use_action_appearance">False</property>
+ <property name="use_underline">True</property>
<property name="xalign">0</property>
- <property name="selectable">True</property>
- <property name="ellipsize">middle</property>
+ <property name="draw_indicator">True</property>
</object>
<packing>
<property name="left_attach">1</property>
- <property name="top_attach">4</property>
+ <property name="top_attach">2</property>
<property name="width">1</property>
<property name="height">1</property>
</packing>
@@ -275,9 +293,6 @@
<child>
<placeholder/>
</child>
- <child>
- <placeholder/>
- </child>
</object>
<packing>
<property name="expand">False</property>
diff --git a/data/ui/edit-fstab-dialog.ui b/data/ui/edit-fstab-dialog.ui
index 368ed50..177ceec 100644
--- a/data/ui/edit-fstab-dialog.ui
+++ b/data/ui/edit-fstab-dialog.ui
@@ -76,7 +76,7 @@
<property name="spacing">12</property>
<child>
<object class="GtkCheckButton" id="fstab-configure-checkbutton">
- <property name="label" translatable="yes">Config_ure mount point and options</property>
+ <property name="label" translatable="yes">Con_figure mount point and options</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
@@ -194,63 +194,6 @@
</packing>
</child>
<child>
- <object class="GtkLabel" id="fstab-options-label">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="xalign">1</property>
- <property name="label" translatable="yes">_Options</property>
- <property name="use_underline">True</property>
- <property name="mnemonic_widget">fstab-options-entry</property>
- <attributes>
- <attribute name="foreground" value="#555555555555"/>
- </attributes>
- </object>
- <packing>
- <property name="left_attach">0</property>
- <property name="top_attach">4</property>
- <property name="width">1</property>
- <property name="height">1</property>
- </packing>
- </child>
- <child>
- <object class="GtkLabel" id="fstab-freq-label">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="xalign">1</property>
- <property name="label" translatable="yes">_Frequency</property>
- <property name="use_underline">True</property>
- <property name="mnemonic_widget">fstab-freq-spinbutton</property>
- <attributes>
- <attribute name="foreground" value="#555555555555"/>
- </attributes>
- </object>
- <packing>
- <property name="left_attach">0</property>
- <property name="top_attach">5</property>
- <property name="width">1</property>
- <property name="height">1</property>
- </packing>
- </child>
- <child>
- <object class="GtkLabel" id="fstab-passno-label">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="xalign">1</property>
- <property name="label" translatable="yes">Pass _Number</property>
- <property name="use_underline">True</property>
- <property name="mnemonic_widget">fstab-passno-spinbutton</property>
- <attributes>
- <attribute name="foreground" value="#555555555555"/>
- </attributes>
- </object>
- <packing>
- <property name="left_attach">0</property>
- <property name="top_attach">6</property>
- <property name="width">1</property>
- <property name="height">1</property>
- </packing>
- </child>
- <child>
<object class="GtkEntry" id="fstab-directory-entry">
<property name="visible">True</property>
<property name="can_focus">True</property>
@@ -302,16 +245,35 @@
</packing>
</child>
<child>
- <object class="GtkSpinButton" id="fstab-freq-spinbutton">
+ <object class="GtkLabel" id="fstab-options-label">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="xalign">1</property>
+ <property name="label" translatable="yes">_Options</property>
+ <property name="use_underline">True</property>
+ <property name="mnemonic_widget">fstab-options-entry</property>
+ <attributes>
+ <attribute name="foreground" value="#555555555555"/>
+ </attributes>
+ </object>
+ <packing>
+ <property name="left_attach">0</property>
+ <property name="top_attach">4</property>
+ <property name="width">1</property>
+ <property name="height">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkCheckButton" id="fstab-noauto-checkbutton">
+ <property name="label" translatable="yes">Don't mount at startu_p</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
- <property name="has_tooltip">True</property>
- <property name="tooltip_markup" translatable="yes">This field is used for these filesystems by the <b>dump(8)</b> command to determine which filesystems need to be dumped.</property>
- <property name="tooltip_text" translatable="yes">This field is used for these filesystems by the dump(8) command to determine which filesystems need to be dumped.</property>
- <property name="invisible_char">â</property>
- <property name="invisible_char_set">True</property>
- <property name="adjustment">fstab-freq-adjustment</property>
- <property name="numeric">True</property>
+ <property name="receives_default">False</property>
+ <property name="tooltip_text" translatable="yes">If checked, the device will not be mounted at startup [noauto]</property>
+ <property name="use_action_appearance">False</property>
+ <property name="use_underline">True</property>
+ <property name="xalign">0</property>
+ <property name="draw_indicator">True</property>
</object>
<packing>
<property name="left_attach">1</property>
@@ -321,16 +283,16 @@
</packing>
</child>
<child>
- <object class="GtkSpinButton" id="fstab-passno-spinbutton">
+ <object class="GtkCheckButton" id="fstab-users-checkbutton">
+ <property name="label" translatable="yes">Allow any _user to mount and unmount</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
- <property name="has_tooltip">True</property>
- <property name="tooltip_markup" translatable="yes">This field is used by the <b>fsck(8)</b> program to determine the order in which filesystem checks are done at reboot time.</property>
- <property name="tooltip_text" translatable="yes">This field is used by the fsck(8) program to determine the order in which filesystem checks are done at reboot time.</property>
- <property name="invisible_char">â</property>
- <property name="invisible_char_set">True</property>
- <property name="adjustment">fstab-passno-adjustment</property>
- <property name="numeric">True</property>
+ <property name="receives_default">False</property>
+ <property name="tooltip_text" translatable="yes">If checked, any user may mount and unmount the device [users]</property>
+ <property name="use_action_appearance">False</property>
+ <property name="use_underline">True</property>
+ <property name="xalign">0</property>
+ <property name="draw_indicator">True</property>
</object>
<packing>
<property name="left_attach">1</property>
@@ -340,6 +302,116 @@
</packing>
</child>
<child>
+ <object class="GtkGrid" id="grid1">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="row_spacing">10</property>
+ <property name="column_spacing">6</property>
+ <child>
+ <object class="GtkLabel" id="label1">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="xalign">1</property>
+ <property name="label" translatable="yes">Display _Name</property>
+ <property name="use_underline">True</property>
+ <property name="mnemonic_widget">fstab-name-entry</property>
+ <attributes>
+ <attribute name="foreground" value="#555555555555"/>
+ </attributes>
+ </object>
+ <packing>
+ <property name="left_attach">0</property>
+ <property name="top_attach">0</property>
+ <property name="width">1</property>
+ <property name="height">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkEntry" id="fstab-name-entry">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="has_tooltip">True</property>
+ <property name="tooltip_text" translatable="yes">If set, the name to use for the device in the user interface [comment=gvfs.name]</property>
+ <property name="hexpand">True</property>
+ <property name="invisible_char">â</property>
+ <property name="invisible_char_set">True</property>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="top_attach">0</property>
+ <property name="width">1</property>
+ <property name="height">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="label2">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="xalign">1</property>
+ <property name="label" translatable="yes">Icon Na_me</property>
+ <property name="use_underline">True</property>
+ <property name="mnemonic_widget">fstab-icon-entry</property>
+ <attributes>
+ <attribute name="foreground" value="#555555555555"/>
+ </attributes>
+ </object>
+ <packing>
+ <property name="left_attach">0</property>
+ <property name="top_attach">1</property>
+ <property name="width">1</property>
+ <property name="height">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkEntry" id="fstab-icon-entry">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="has_tooltip">True</property>
+ <property name="tooltip_text" translatable="yes">If set, the name of the icon to use in the device in the user interface [comment=gvfs.icon_name]</property>
+ <property name="hexpand">True</property>
+ <property name="invisible_char">â</property>
+ <property name="invisible_char_set">True</property>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="top_attach">1</property>
+ <property name="width">1</property>
+ <property name="height">1</property>
+ </packing>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="top_attach">7</property>
+ <property name="width">1</property>
+ <property name="height">1</property>
+ </packing>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
<placeholder/>
</child>
</object>
diff --git a/src/palimpsest/gducrypttabdialog.c b/src/palimpsest/gducrypttabdialog.c
index c3e0d61..60a8602 100644
--- a/src/palimpsest/gducrypttabdialog.c
+++ b/src/palimpsest/gducrypttabdialog.c
@@ -50,6 +50,7 @@ typedef struct
GtkWidget *name_entry;
GtkWidget *options_entry;
+ GtkWidget *noauto_checkbutton;
GtkWidget *passphrase_label;
GtkWidget *passphrase_entry;
GtkWidget *show_passphrase_checkbutton;
@@ -76,7 +77,8 @@ crypttab_dialog_free (CrypttabDialogData *data)
}
static void
-crypttab_dialog_update (CrypttabDialogData *data)
+update (CrypttabDialogData *data,
+ GtkWidget *widget)
{
gboolean ui_configured;
const gchar *ui_name;
@@ -151,6 +153,10 @@ crypttab_dialog_update (CrypttabDialogData *data)
gtk_label_set_markup (GTK_LABEL (data->passphrase_path_value_label), s);
g_free (s);
+ g_object_freeze_notify (G_OBJECT (data->options_entry));
+ gdu_options_update_check_option (data->options_entry, "noauto", widget, data->noauto_checkbutton);
+ g_object_thaw_notify (G_OBJECT (data->options_entry));
+
can_apply = FALSE;
if (configured != ui_configured)
{
@@ -172,12 +178,12 @@ crypttab_dialog_update (CrypttabDialogData *data)
}
static void
-crypttab_dialog_property_changed (GObject *object,
- GParamSpec *pspec,
- gpointer user_data)
+on_property_changed (GObject *object,
+ GParamSpec *pspec,
+ gpointer user_data)
{
CrypttabDialogData *data = user_data;
- crypttab_dialog_update (data);
+ update (data, GTK_WIDGET (object));
}
@@ -226,17 +232,19 @@ crypttab_dialog_present (CrypttabDialogData *data)
G_BINDING_SYNC_CREATE);
g_signal_connect (data->configure_checkbutton,
- "notify::active", G_CALLBACK (crypttab_dialog_property_changed), data);
+ "notify::active", G_CALLBACK (on_property_changed), data);
g_signal_connect (data->name_entry,
- "notify::text", G_CALLBACK (crypttab_dialog_property_changed), data);
+ "notify::text", G_CALLBACK (on_property_changed), data);
g_signal_connect (data->options_entry,
- "notify::text", G_CALLBACK (crypttab_dialog_property_changed), data);
+ "notify::text", G_CALLBACK (on_property_changed), data);
+ g_signal_connect (data->noauto_checkbutton,
+ "notify::active", G_CALLBACK (on_property_changed), data);
g_signal_connect (data->passphrase_entry,
- "notify::text", G_CALLBACK (crypttab_dialog_property_changed), data);
+ "notify::text", G_CALLBACK (on_property_changed), data);
gtk_widget_show_all (data->dialog);
- crypttab_dialog_update (data);
+ update (data, NULL);
response = gtk_dialog_run (GTK_DIALOG (data->dialog));
@@ -471,6 +479,7 @@ gdu_crypttab_dialog_show (GduWindow *window,
data->grid = GTK_WIDGET (gtk_builder_get_object (data->builder, "crypttab-grid"));
data->name_entry = GTK_WIDGET (gtk_builder_get_object (data->builder, "crypttab-name-entry"));
data->options_entry = GTK_WIDGET (gtk_builder_get_object (data->builder, "crypttab-options-entry"));
+ data->noauto_checkbutton = GTK_WIDGET (gtk_builder_get_object (data->builder, "crypttab-noauto-checkbutton"));
data->passphrase_label = GTK_WIDGET (gtk_builder_get_object (data->builder, "crypttab-passphrase-label"));
data->passphrase_entry = GTK_WIDGET (gtk_builder_get_object (data->builder, "crypttab-passphrase-entry"));
data->show_passphrase_checkbutton = GTK_WIDGET (gtk_builder_get_object (data->builder, "crypttab-show-passphrase-checkbutton"));
diff --git a/src/palimpsest/gdufstabdialog.c b/src/palimpsest/gdufstabdialog.c
index cd329e8..1a8cdda 100644
--- a/src/palimpsest/gdufstabdialog.c
+++ b/src/palimpsest/gdufstabdialog.c
@@ -43,30 +43,30 @@ typedef struct
GtkWidget *device_explanation_label;
GtkWidget *directory_entry;
GtkWidget *type_entry;
+
GtkWidget *options_entry;
- GtkWidget *freq_spinbutton;
- GtkWidget *passno_spinbutton;
+ GtkWidget *noauto_checkbutton;
+ GtkWidget *users_checkbutton;
+ GtkWidget *name_entry;
+ GtkWidget *icon_entry;
GVariant *orig_fstab_entry;
} FstabDialogData;
static void
-fstab_dialog_update (FstabDialogData *data)
+update (FstabDialogData *data,
+ GtkWidget *widget)
{
gboolean ui_configured;
gchar *ui_fsname;
const gchar *ui_dir;
const gchar *ui_type;
const gchar *ui_opts;
- gint ui_freq;
- gint ui_passno;
gboolean configured;
const gchar *fsname;
const gchar *dir;
const gchar *type;
const gchar *opts;
- gint freq;
- gint passno;
gboolean can_apply;
if (data->orig_fstab_entry != NULL)
@@ -76,8 +76,6 @@ fstab_dialog_update (FstabDialogData *data)
g_variant_lookup (data->orig_fstab_entry, "dir", "^&ay", &dir);
g_variant_lookup (data->orig_fstab_entry, "type", "^&ay", &type);
g_variant_lookup (data->orig_fstab_entry, "opts", "^&ay", &opts);
- g_variant_lookup (data->orig_fstab_entry, "freq", "i", &freq);
- g_variant_lookup (data->orig_fstab_entry, "passno", "i", &passno);
}
else
{
@@ -86,8 +84,6 @@ fstab_dialog_update (FstabDialogData *data)
dir = "";
type = "";
opts = "";
- freq = 0;
- passno = 0;
}
ui_configured = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (data->configure_checkbutton));
@@ -95,8 +91,13 @@ fstab_dialog_update (FstabDialogData *data)
ui_dir = gtk_entry_get_text (GTK_ENTRY (data->directory_entry));
ui_type = gtk_entry_get_text (GTK_ENTRY (data->type_entry));
ui_opts = gtk_entry_get_text (GTK_ENTRY (data->options_entry));
- ui_freq = gtk_spin_button_get_value (GTK_SPIN_BUTTON (data->freq_spinbutton));
- ui_passno = gtk_spin_button_get_value (GTK_SPIN_BUTTON (data->passno_spinbutton));
+
+ g_object_freeze_notify (G_OBJECT (data->options_entry));
+ gdu_options_update_check_option (data->options_entry, "noauto", widget, data->noauto_checkbutton);
+ gdu_options_update_check_option (data->options_entry, "users", widget, data->users_checkbutton);
+ gdu_options_update_entry_option (data->options_entry, "comment=gvfs.name=", widget, data->name_entry);
+ gdu_options_update_entry_option (data->options_entry, "comment=gvfs.icon_name=", widget, data->icon_entry);
+ g_object_thaw_notify (G_OBJECT (data->options_entry));
can_apply = FALSE;
if (configured != ui_configured)
@@ -108,9 +109,7 @@ fstab_dialog_update (FstabDialogData *data)
if (g_strcmp0 (ui_fsname, fsname) != 0 ||
g_strcmp0 (ui_dir, dir) != 0 ||
g_strcmp0 (ui_type, type) != 0 ||
- g_strcmp0 (ui_opts, opts) != 0 ||
- freq != ui_freq ||
- passno != ui_passno)
+ g_strcmp0 (ui_opts, opts) != 0)
{
can_apply = TRUE;
}
@@ -126,16 +125,16 @@ fstab_dialog_update (FstabDialogData *data)
}
static void
-fstab_dialog_property_changed (GObject *object,
- GParamSpec *pspec,
- gpointer user_data)
+on_property_changed (GObject *object,
+ GParamSpec *pspec,
+ gpointer user_data)
{
FstabDialogData *data = user_data;
- fstab_dialog_update (data);
+ update (data, GTK_WIDGET (object));
}
static void
-fstab_update_device_explanation (FstabDialogData *data)
+update_device_explanation (FstabDialogData *data)
{
const gchar *s;
gchar *fsname;
@@ -207,7 +206,7 @@ fstab_on_device_combobox_changed (GtkComboBox *combobox,
g_free (proposed_mount_point);
g_free (fsname);
- fstab_update_device_explanation (data);
+ update_device_explanation (data);
}
static void
@@ -400,8 +399,10 @@ gdu_fstab_dialog_show (GduWindow *window,
data.directory_entry = GTK_WIDGET (gtk_builder_get_object (builder, "fstab-directory-entry"));
data.type_entry = GTK_WIDGET (gtk_builder_get_object (builder, "fstab-type-entry"));
data.options_entry = GTK_WIDGET (gtk_builder_get_object (builder, "fstab-options-entry"));
- data.freq_spinbutton = GTK_WIDGET (gtk_builder_get_object (builder, "fstab-freq-spinbutton"));
- data.passno_spinbutton = GTK_WIDGET (gtk_builder_get_object (builder, "fstab-passno-spinbutton"));
+ data.noauto_checkbutton = GTK_WIDGET (gtk_builder_get_object (builder, "fstab-noauto-checkbutton"));
+ data.users_checkbutton = GTK_WIDGET (gtk_builder_get_object (builder, "fstab-users-checkbutton"));
+ data.name_entry = GTK_WIDGET (gtk_builder_get_object (builder, "fstab-name-entry"));
+ data.icon_entry = GTK_WIDGET (gtk_builder_get_object (builder, "fstab-icon-entry"));
/* there could be multiple fstab entries - we only consider the first one */
g_variant_iter_init (&iter, udisks_block_get_configuration (block));
@@ -450,28 +451,9 @@ gdu_fstab_dialog_show (GduWindow *window,
gtk_entry_set_text (GTK_ENTRY (data.directory_entry), dir);
gtk_entry_set_text (GTK_ENTRY (data.type_entry), type);
gtk_entry_set_text (GTK_ENTRY (data.options_entry), opts);
- gtk_spin_button_set_value (GTK_SPIN_BUTTON (data.freq_spinbutton), freq);
- gtk_spin_button_set_value (GTK_SPIN_BUTTON (data.passno_spinbutton), passno);
if (!configured)
fstab_on_device_combobox_changed (GTK_COMBO_BOX (data.device_combobox), &data);
- g_signal_connect (data.configure_checkbutton,
- "notify::active", G_CALLBACK (fstab_dialog_property_changed), &data);
- g_signal_connect (data.device_combobox,
- "notify::active", G_CALLBACK (fstab_dialog_property_changed), &data);
- g_signal_connect (data.directory_entry,
- "notify::text", G_CALLBACK (fstab_dialog_property_changed), &data);
- g_signal_connect (data.type_entry,
- "notify::text", G_CALLBACK (fstab_dialog_property_changed), &data);
- g_signal_connect (data.options_entry,
- "notify::text", G_CALLBACK (fstab_dialog_property_changed), &data);
- g_signal_connect (data.freq_spinbutton,
- "notify::value", G_CALLBACK (fstab_dialog_property_changed), &data);
- g_signal_connect (data.passno_spinbutton,
- "notify::value", G_CALLBACK (fstab_dialog_property_changed), &data);
- g_signal_connect (data.device_combobox,
- "changed", G_CALLBACK (fstab_on_device_combobox_changed), &data);
-
/* Show a cluebar if the entry is considered a system mount */
if (is_system_mount)
{
@@ -484,8 +466,29 @@ gdu_fstab_dialog_show (GduWindow *window,
gtk_widget_show_all (dialog);
- fstab_update_device_explanation (&data);
- fstab_dialog_update (&data);
+ update_device_explanation (&data);
+ update (&data, NULL);
+
+ g_signal_connect (data.configure_checkbutton,
+ "notify::active", G_CALLBACK (on_property_changed), &data);
+ g_signal_connect (data.device_combobox,
+ "notify::active", G_CALLBACK (on_property_changed), &data);
+ g_signal_connect (data.directory_entry,
+ "notify::text", G_CALLBACK (on_property_changed), &data);
+ g_signal_connect (data.type_entry,
+ "notify::text", G_CALLBACK (on_property_changed), &data);
+ g_signal_connect (data.options_entry,
+ "notify::text", G_CALLBACK (on_property_changed), &data);
+ g_signal_connect (data.device_combobox,
+ "changed", G_CALLBACK (fstab_on_device_combobox_changed), &data);
+ g_signal_connect (data.noauto_checkbutton,
+ "notify::active", G_CALLBACK (on_property_changed), &data);
+ g_signal_connect (data.users_checkbutton,
+ "notify::active", G_CALLBACK (on_property_changed), &data);
+ g_signal_connect (data.name_entry,
+ "notify::text", G_CALLBACK (on_property_changed), &data);
+ g_signal_connect (data.icon_entry,
+ "notify::text", G_CALLBACK (on_property_changed), &data);
response = gtk_dialog_run (GTK_DIALOG (dialog));
if (response == GTK_RESPONSE_APPLY)
@@ -495,8 +498,8 @@ gdu_fstab_dialog_show (GduWindow *window,
const gchar *ui_dir;
const gchar *ui_type;
const gchar *ui_opts;
- gint ui_freq;
- gint ui_passno;
+ gint freq = 0;
+ gint passno = 0;
GError *error;
GVariant *old_item;
GVariant *new_item;
@@ -506,8 +509,11 @@ gdu_fstab_dialog_show (GduWindow *window,
ui_dir = gtk_entry_get_text (GTK_ENTRY (data.directory_entry));
ui_type = gtk_entry_get_text (GTK_ENTRY (data.type_entry));
ui_opts = gtk_entry_get_text (GTK_ENTRY (data.options_entry));
- ui_freq = gtk_spin_button_get_value (GTK_SPIN_BUTTON (data.freq_spinbutton));
- ui_passno = gtk_spin_button_get_value (GTK_SPIN_BUTTON (data.passno_spinbutton));
+ if (data.orig_fstab_entry != NULL)
+ {
+ g_variant_lookup (data.orig_fstab_entry, "freq", "i", &freq);
+ g_variant_lookup (data.orig_fstab_entry, "passno", "i", &passno);
+ }
gtk_widget_hide (dialog);
@@ -527,8 +533,8 @@ gdu_fstab_dialog_show (GduWindow *window,
g_variant_builder_add (&builder, "{sv}", "dir", g_variant_new_bytestring (ui_dir));
g_variant_builder_add (&builder, "{sv}", "type", g_variant_new_bytestring (ui_type));
g_variant_builder_add (&builder, "{sv}", "opts", g_variant_new_bytestring (ui_opts));
- g_variant_builder_add (&builder, "{sv}", "freq", g_variant_new_int32 (ui_freq));
- g_variant_builder_add (&builder, "{sv}", "passno", g_variant_new_int32 (ui_passno));
+ g_variant_builder_add (&builder, "{sv}", "freq", g_variant_new_int32 (freq));
+ g_variant_builder_add (&builder, "{sv}", "passno", g_variant_new_int32 (passno));
new_item = g_variant_new ("(sa{sv})", "fstab", &builder);
}
diff --git a/src/palimpsest/gduutils.c b/src/palimpsest/gduutils.c
index 605502d..e3a08a0 100644
--- a/src/palimpsest/gduutils.c
+++ b/src/palimpsest/gduutils.c
@@ -216,3 +216,155 @@ gdu_utils_unfuse_path (const gchar *path)
return ret;
}
+
+/* ---------------------------------------------------------------------------------------------------- */
+
+static gboolean
+has_option (GtkWidget *options_entry,
+ const gchar *option,
+ gboolean check_prefix,
+ gchar **out_value)
+{
+ guint n;
+ gboolean ret = FALSE;
+ gchar **options;
+
+ options = g_strsplit (gtk_entry_get_text (GTK_ENTRY (options_entry)), ",", 0);
+ for (n = 0; options != NULL && options[n] != NULL; n++)
+ {
+ if (check_prefix)
+ {
+ if (g_str_has_prefix (options[n], option))
+ {
+ if (out_value != NULL)
+ *out_value = g_strdup (options[n] + strlen (option));
+ ret = TRUE;
+ goto out;
+ }
+ }
+ else
+ {
+ if (g_strcmp0 (options[n], option) == 0)
+ {
+ ret = TRUE;
+ goto out;
+ }
+ }
+ }
+ out:
+ g_strfreev (options);
+ return ret;
+}
+
+static void
+add_option (GtkWidget *options_entry,
+ const gchar *prefix,
+ const gchar *option)
+{
+ gchar *s;
+ const gchar *text;
+ text = gtk_entry_get_text (GTK_ENTRY (options_entry));
+ s = g_strdup_printf ("%s%s%s%s",
+ text,
+ strlen (text) > 0 ? "," : "",
+ prefix,
+ option);
+ gtk_entry_set_text (GTK_ENTRY (options_entry), s);
+ g_free (s);
+}
+
+static void
+remove_option (GtkWidget *options_entry,
+ const gchar *option,
+ gboolean check_prefix)
+{
+ GString *str;
+ guint n;
+ gchar **options;
+
+ str = g_string_new (NULL);
+ options = g_strsplit (gtk_entry_get_text (GTK_ENTRY (options_entry)), ",", 0);
+ for (n = 0; options != NULL && options[n] != NULL; n++)
+ {
+ if (check_prefix)
+ {
+ if (g_str_has_prefix (options[n], option))
+ continue;
+ }
+ else
+ {
+ if (g_strcmp0 (options[n], option) == 0)
+ continue;
+ }
+ if (str->len > 0)
+ g_string_append_c (str, ',');
+ g_string_append (str, options[n]);
+ }
+ gtk_entry_set_text (GTK_ENTRY (options_entry), str->str);
+ g_string_free (str, TRUE);
+}
+
+void
+gdu_options_update_check_option (GtkWidget *options_entry,
+ const gchar *option,
+ GtkWidget *widget,
+ GtkWidget *check_button)
+{
+ gboolean opts, ui;
+ opts = !! has_option (options_entry, option, FALSE, NULL);
+ ui = !! gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (check_button));
+ if (opts != ui)
+ {
+ if (widget == check_button)
+ {
+ if (ui)
+ add_option (options_entry, "", option);
+ else
+ remove_option (options_entry, option, FALSE);
+ }
+ else
+ {
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (check_button), opts);
+ }
+ }
+}
+
+void
+gdu_options_update_entry_option (GtkWidget *options_entry,
+ const gchar *option,
+ GtkWidget *widget,
+ GtkWidget *entry)
+{
+ gchar *opts = NULL;
+ const gchar *ui;
+ gchar *ui_escaped;
+ has_option (options_entry, option, TRUE, &opts);
+ if (opts == NULL)
+ opts = g_strdup ("");
+ ui = gtk_entry_get_text (GTK_ENTRY (entry));
+ ui_escaped = g_uri_escape_string (ui, NULL, TRUE);
+ // g_print ("opts=`%s', ui=`%s', widget=%p, entry=%p\n", opts, ui, widget, entry);
+ if (g_strcmp0 (opts, ui_escaped) != 0)
+ {
+ if (widget == entry)
+ {
+ if (strlen (ui_escaped) > 0)
+ {
+ remove_option (options_entry, option, TRUE);
+ add_option (options_entry, option, ui_escaped);
+ }
+ else
+ {
+ remove_option (options_entry, option, TRUE);
+ }
+ }
+ else
+ {
+ gchar *opts_unescaped = g_uri_unescape_string (opts, NULL);
+ gtk_entry_set_text (GTK_ENTRY (entry), opts_unescaped);
+ g_free (opts_unescaped);
+ }
+ }
+ g_free (ui_escaped);
+ g_free (opts);
+}
diff --git a/src/palimpsest/gduutils.h b/src/palimpsest/gduutils.h
index 7b3f6de..e9659a4 100644
--- a/src/palimpsest/gduutils.h
+++ b/src/palimpsest/gduutils.h
@@ -43,6 +43,16 @@ GtkWidget *gdu_utils_create_info_bar (GtkMessageType message_type,
gchar *gdu_utils_unfuse_path (const gchar *path);
+void gdu_options_update_check_option (GtkWidget *options_entry,
+ const gchar *option,
+ GtkWidget *widget,
+ GtkWidget *check_button);
+
+void gdu_options_update_entry_option (GtkWidget *options_entry,
+ const gchar *option,
+ GtkWidget *widget,
+ GtkWidget *entry);
+
G_END_DECLS
#endif /* __GDU_UTILS_H__ */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]