[gnome-disk-utility/udisks2-port] Don't abstract 'defaults' away, it's too confusing



commit dd1d146760125d981ca0e68e8701379fa5ecf2f6
Author: David Zeuthen <davidz redhat com>
Date:   Thu Jan 19 13:56:41 2012 -0500

    Don't abstract 'defaults' away, it's too confusing
    
    Signed-off-by: David Zeuthen <davidz redhat com>

 data/ui/edit-fstab-dialog.ui    |   29 ++++++++++++++++++++++++-----
 src/palimpsest/gdufstabdialog.c |   25 ++++++++++++++++---------
 2 files changed, 40 insertions(+), 14 deletions(-)
---
diff --git a/data/ui/edit-fstab-dialog.ui b/data/ui/edit-fstab-dialog.ui
index 2e32385..c64aed5 100644
--- a/data/ui/edit-fstab-dialog.ui
+++ b/data/ui/edit-fstab-dialog.ui
@@ -264,6 +264,25 @@
                       </packing>
                     </child>
                     <child>
+                      <object class="GtkCheckButton" id="fstab-defaults-checkbutton">
+                        <property name="label" translatable="yes">Defaults</property>
+                        <property name="visible">True</property>
+                        <property name="can_focus">True</property>
+                        <property name="receives_default">False</property>
+                        <property name="tooltip_text" translatable="yes">If checked, the default options will be used (rw, suid, dev, exec, auto, nouser, async) [defaults]</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>
+                        <property name="top_attach">5</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>
@@ -277,7 +296,7 @@
                       </object>
                       <packing>
                         <property name="left_attach">1</property>
-                        <property name="top_attach">5</property>
+                        <property name="top_attach">6</property>
                         <property name="width">1</property>
                         <property name="height">1</property>
                       </packing>
@@ -296,7 +315,7 @@
                       </object>
                       <packing>
                         <property name="left_attach">1</property>
-                        <property name="top_attach">6</property>
+                        <property name="top_attach">7</property>
                         <property name="width">1</property>
                         <property name="height">1</property>
                       </packing>
@@ -315,7 +334,7 @@
                       </object>
                       <packing>
                         <property name="left_attach">1</property>
-                        <property name="top_attach">7</property>
+                        <property name="top_attach">8</property>
                         <property name="width">1</property>
                         <property name="height">1</property>
                       </packing>
@@ -334,7 +353,7 @@
                       </object>
                       <packing>
                         <property name="left_attach">1</property>
-                        <property name="top_attach">8</property>
+                        <property name="top_attach">9</property>
                         <property name="width">1</property>
                         <property name="height">1</property>
                       </packing>
@@ -435,7 +454,7 @@
                       </object>
                       <packing>
                         <property name="left_attach">1</property>
-                        <property name="top_attach">9</property>
+                        <property name="top_attach">10</property>
                         <property name="width">1</property>
                         <property name="height">1</property>
                       </packing>
diff --git a/src/palimpsest/gdufstabdialog.c b/src/palimpsest/gdufstabdialog.c
index 266144a..6d06d1c 100644
--- a/src/palimpsest/gdufstabdialog.c
+++ b/src/palimpsest/gdufstabdialog.c
@@ -45,6 +45,7 @@ typedef struct
   GtkWidget *type_entry;
 
   GtkWidget *options_entry;
+  GtkWidget *defaults_checkbutton;
   GtkWidget *noauto_checkbutton;
   GtkWidget *auth_checkbutton;
   GtkWidget *show_checkbutton;
@@ -95,6 +96,7 @@ update (FstabDialogData *data,
   ui_opts = gtk_entry_get_text (GTK_ENTRY (data->options_entry));
 
   g_object_freeze_notify (G_OBJECT (data->options_entry));
+  gdu_options_update_check_option (data->options_entry, "defaults", widget, data->defaults_checkbutton);
   gdu_options_update_check_option (data->options_entry, "noauto", widget, data->noauto_checkbutton);
   gdu_options_update_check_option (data->options_entry, "comment=udisks-auth", widget, data->auth_checkbutton);
   gdu_options_update_check_option (data->options_entry, "comment=gvfs-show", widget, data->show_checkbutton);
@@ -115,7 +117,14 @@ update (FstabDialogData *data,
           g_strcmp0 (ui_type, type) != 0 ||
           g_strcmp0 (ui_opts, opts) != 0)
         {
-          can_apply = TRUE;
+          /* sanity-check */
+          if (strlen (ui_fsname) > 0 &&
+              strlen (ui_dir) > 0 &&
+              strlen (ui_type) > 0 &&
+              strlen (ui_opts) > 0)
+            {
+              can_apply = TRUE;
+            }
         }
     }
 
@@ -403,6 +412,7 @@ 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.defaults_checkbutton = GTK_WIDGET (gtk_builder_get_object (builder, "fstab-defaults-checkbutton"));
   data.noauto_checkbutton = GTK_WIDGET (gtk_builder_get_object (builder, "fstab-noauto-checkbutton"));
   data.auth_checkbutton = GTK_WIDGET (gtk_builder_get_object (builder, "fstab-auth-checkbutton"));
   data.show_checkbutton = GTK_WIDGET (gtk_builder_get_object (builder, "fstab-show-checkbutton"));
@@ -431,8 +441,6 @@ gdu_fstab_dialog_show (GduWindow    *window,
       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);
-      if (g_strcmp0 (opts, "defaults") == 0)
-        opts = "";
       g_variant_lookup (data.orig_fstab_entry, "freq", "i", &freq);
       g_variant_lookup (data.orig_fstab_entry, "passno", "i", &passno);
     }
@@ -442,10 +450,10 @@ gdu_fstab_dialog_show (GduWindow    *window,
       fsname = NULL;
       dir = "";
       type = "auto";
-      opts = "";
+      opts = "defaults";
       /* propose noauto if the media is removable - otherwise e.g. systemd will time out at boot */
       if (drive != NULL && udisks_drive_get_removable (drive))
-        opts = "noauto";
+        opts = "defaults,noauto";
       freq = 0;
       passno = 0;
     }
@@ -489,6 +497,8 @@ gdu_fstab_dialog_show (GduWindow    *window,
                     "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.defaults_checkbutton,
+                    "notify::active", G_CALLBACK (on_property_changed), &data);
   g_signal_connect (data.noauto_checkbutton,
                     "notify::active", G_CALLBACK (on_property_changed), &data);
   g_signal_connect (data.auth_checkbutton,
@@ -544,10 +554,7 @@ gdu_fstab_dialog_show (GduWindow    *window,
           g_variant_builder_add (&builder, "{sv}", "fsname", g_variant_new_bytestring (ui_fsname));
           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));
-          if (strlen (ui_opts) > 0)
-            g_variant_builder_add (&builder, "{sv}", "opts", g_variant_new_bytestring (ui_opts));
-          else
-            g_variant_builder_add (&builder, "{sv}", "opts", g_variant_new_bytestring ("defaults"));
+          g_variant_builder_add (&builder, "{sv}", "opts", g_variant_new_bytestring (ui_opts));
           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);



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]