[gnome-disk-utility] Also clean up crypttab dialog



commit c8b205eb383900fc16cbfd206871c1f452f14315
Author: David Zeuthen <davidz redhat com>
Date:   Tue Feb 21 14:13:58 2012 -0500

    Also clean up crypttab dialog
    
    Signed-off-by: David Zeuthen <davidz redhat com>

 data/ui/edit-crypttab-dialog.ui    |  474 ++++++++++++++++++------------------
 data/ui/palimpsest.ui              |    2 +-
 src/palimpsest/gducrypttabdialog.c |  153 +++++-------
 3 files changed, 295 insertions(+), 334 deletions(-)
---
diff --git a/data/ui/edit-crypttab-dialog.ui b/data/ui/edit-crypttab-dialog.ui
index eca4adf..93314c2 100644
--- a/data/ui/edit-crypttab-dialog.ui
+++ b/data/ui/edit-crypttab-dialog.ui
@@ -18,8 +18,9 @@
             <property name="can_focus">False</property>
             <property name="layout_style">end</property>
             <child>
-              <object class="GtkButton" id="button10">
+              <object class="GtkButton" id="crypttab-cancel-button">
                 <property name="label">gtk-cancel</property>
+                <property name="use_action_appearance">False</property>
                 <property name="visible">True</property>
                 <property name="can_focus">True</property>
                 <property name="receives_default">True</property>
@@ -33,8 +34,9 @@
               </packing>
             </child>
             <child>
-              <object class="GtkButton" id="button9">
+              <object class="GtkButton" id="crypttab-apply-button">
                 <property name="label">gtk-apply</property>
+                <property name="use_action_appearance">False</property>
                 <property name="visible">True</property>
                 <property name="can_focus">True</property>
                 <property name="receives_default">True</property>
@@ -47,6 +49,22 @@
                 <property name="position">1</property>
               </packing>
             </child>
+            <child>
+              <object class="GtkButton" id="crypttab-reset-button">
+                <property name="label" translatable="yes">Reset</property>
+                <property name="use_action_appearance">False</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>
+              </object>
+              <packing>
+                <property name="expand">False</property>
+                <property name="fill">True</property>
+                <property name="position">2</property>
+                <property name="secondary">True</property>
+              </packing>
+            </child>
           </object>
           <packing>
             <property name="expand">False</property>
@@ -77,232 +95,197 @@
               </packing>
             </child>
             <child>
-              <object class="GtkCheckButton" id="crypttab-configure-checkbutton">
-                <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>
-                <property name="has_tooltip">True</property>
-                <property name="tooltip_markup" translatable="yes">Checked if an entry in the /etc/crypttab file exists for the device</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="expand">False</property>
-                <property name="fill">True</property>
-                <property name="position">1</property>
-              </packing>
-            </child>
-            <child>
-              <object class="GtkBox" id="box4">
+              <object class="GtkGrid" id="crypttab-grid">
                 <property name="visible">True</property>
                 <property name="can_focus">False</property>
-                <property name="margin_left">24</property>
-                <property name="orientation">vertical</property>
-                <property name="spacing">12</property>
+                <property name="row_spacing">6</property>
+                <property name="column_spacing">10</property>
                 <child>
-                  <object class="GtkGrid" id="crypttab-grid">
+                  <object class="GtkLabel" id="crypttab-name-label">
                     <property name="visible">True</property>
                     <property name="can_focus">False</property>
-                    <property name="row_spacing">6</property>
-                    <property name="column_spacing">10</property>
-                    <child>
-                      <object class="GtkLabel" id="crypttab-name-label">
-                        <property name="visible">True</property>
-                        <property name="can_focus">False</property>
-                        <property name="xalign">1</property>
-                        <property name="label" translatable="yes">_Name</property>
-                        <property name="use_underline">True</property>
-                        <property name="mnemonic_widget">crypttab-name-entry</property>
-                        <style>
-                          <class name="dim-label"/>
-                        </style>
-                      </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="GtkLabel" id="crypttab-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">crypttab-options-entry</property>
-                        <style>
-                          <class name="dim-label"/>
-                        </style>
-                      </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="crypttab-name-entry">
-                        <property name="visible">True</property>
-                        <property name="can_focus">True</property>
-                        <property name="has_tooltip">True</property>
-                        <property name="tooltip_markup" translatable="yes">The name to use for the unlocked device - the device is set up as the name prefixed with &lt;b&gt;/dev/mapper/&lt;/b&gt;</property>
-                        <property name="tooltip_text" translatable="yes">The name to use for the unlocked device - the device is set up as the name prefixed with /dev/mapper/</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="GtkEntry" id="crypttab-options-entry">
-                        <property name="visible">True</property>
-                        <property name="can_focus">True</property>
-                        <property name="has_tooltip">True</property>
-                        <property name="tooltip_markup" translatable="yes">Options to use when unlocking the device</property>
-                        <property name="tooltip_text" translatable="yes">Options to use when unlocking 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">1</property>
-                        <property name="width">1</property>
-                        <property name="height">1</property>
-                      </packing>
-                    </child>
-                    <child>
-                      <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 File</property>
-                        <property name="use_underline">True</property>
-                        <style>
-                          <class name="dim-label"/>
-                        </style>
-                      </object>
-                      <packing>
-                        <property name="left_attach">0</property>
-                        <property name="top_attach">7</property>
-                        <property name="width">1</property>
-                        <property name="height">1</property>
-                      </packing>
-                    </child>
-                    <child>
-                      <object class="GtkLabel" id="crypttab-passphrase-path-value-label">
-                        <property name="visible">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">7</property>
-                        <property name="width">1</property>
-                        <property name="height">1</property>
-                      </packing>
-                    </child>
-                    <child>
-                      <object class="GtkCheckButton" id="crypttab-show-passphrase-checkbutton">
-                        <property name="label" translatable="yes">Sho_w passphrase</property>
-                        <property name="visible">True</property>
-                        <property name="can_focus">True</property>
-                        <property name="receives_default">False</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">6</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">5</property>
-                        <property name="width">1</property>
-                        <property name="height">1</property>
-                      </packing>
-                    </child>
-                    <child>
-                      <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</property>
-                        <property name="use_underline">True</property>
-                        <style>
-                          <class name="dim-label"/>
-                        </style>
-                      </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>
+                    <property name="xalign">1</property>
+                    <property name="label" translatable="yes">_Name</property>
+                    <property name="use_underline">True</property>
+                    <property name="mnemonic_widget">crypttab-name-entry</property>
+                    <style>
+                      <class name="dim-label"/>
+                    </style>
+                  </object>
+                  <packing>
+                    <property name="left_attach">0</property>
+                    <property name="top_attach">2</property>
+                    <property name="width">1</property>
+                    <property name="height">1</property>
+                  </packing>
+                </child>
+                <child>
+                  <object class="GtkLabel" id="crypttab-options-label">
+                    <property name="visible">True</property>
+                    <property name="can_focus">False</property>
+                    <property name="xalign">1</property>
+                    <property name="yalign">0</property>
+                    <property name="label" translatable="yes">_Options</property>
+                    <property name="use_underline">True</property>
+                    <property name="mnemonic_widget">crypttab-options-entry</property>
+                    <style>
+                      <class name="dim-label"/>
+                    </style>
+                  </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="crypttab-name-entry">
+                    <property name="visible">True</property>
+                    <property name="can_focus">True</property>
+                    <property name="has_tooltip">True</property>
+                    <property name="tooltip_markup" translatable="yes">The name to use for the unlocked device - the device is set up as the name prefixed with /dev/mapper/</property>
+                    <property name="tooltip_text" translatable="yes">The name to use for the unlocked device - the device is set up as the name prefixed with /dev/mapper/</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">2</property>
+                    <property name="width">1</property>
+                    <property name="height">1</property>
+                  </packing>
+                </child>
+                <child>
+                  <object class="GtkEntry" id="crypttab-options-entry">
+                    <property name="visible">True</property>
+                    <property name="can_focus">True</property>
+                    <property name="has_tooltip">True</property>
+                    <property name="tooltip_markup" translatable="yes">Options to use when unlocking the device</property>
+                    <property name="tooltip_text" translatable="yes">Options to use when unlocking 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">1</property>
+                    <property name="width">1</property>
+                    <property name="height">1</property>
+                  </packing>
+                </child>
+                <child>
+                  <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 File</property>
+                    <property name="use_underline">True</property>
+                    <style>
+                      <class name="dim-label"/>
+                    </style>
+                  </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="crypttab-passphrase-path-value-label">
+                    <property name="visible">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">5</property>
+                    <property name="width">1</property>
+                    <property name="height">1</property>
+                  </packing>
+                </child>
+                <child>
+                  <object class="GtkCheckButton" id="crypttab-show-passphrase-checkbutton">
+                    <property name="label" translatable="yes">Sho_w passphrase</property>
+                    <property name="use_action_appearance">False</property>
+                    <property name="visible">True</property>
+                    <property name="can_focus">True</property>
+                    <property name="receives_default">False</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">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-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="use_underline">True</property>
+                    <property name="mnemonic_widget">crypttab-passphrase-entry</property>
+                    <style>
+                      <class name="dim-label"/>
+                    </style>
+                  </object>
+                  <packing>
+                    <property name="left_attach">0</property>
+                    <property name="top_attach">3</property>
+                    <property name="width">1</property>
+                    <property name="height">1</property>
+                  </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="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">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>
+                      <object class="GtkCheckButton" id="crypttab-neg-noauto-checkbutton">
+                        <property name="label" translatable="yes">Unlock at startup</property>
                         <property name="use_action_appearance">False</property>
-                        <property name="use_underline">False</property>
-                        <property name="xalign">0</property>
-                        <property name="draw_indicator">True</property>
-                      </object>
-                      <packing>
-                        <property name="left_attach">1</property>
-                        <property name="top_attach">2</property>
-                        <property name="width">1</property>
-                        <property name="height">1</property>
-                      </packing>
-                    </child>
-                    <child>
-                      <object class="GtkCheckButton" id="crypttab-nofail-checkbutton">
-                        <property name="label" translatable="yes">Don't wait for device at startup</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 system won't wait for the device at startup [nofail]</property>
+                        <property name="has_tooltip">True</property>
+                        <property name="tooltip_markup" translatable="yes">If checked, the device will be unlocked at startup [!noauto]</property>
                         <property name="use_action_appearance">False</property>
-                        <property name="use_underline">False</property>
                         <property name="xalign">0</property>
                         <property name="draw_indicator">True</property>
                       </object>
                       <packing>
-                        <property name="left_attach">1</property>
-                        <property name="top_attach">3</property>
+                        <property name="left_attach">0</property>
+                        <property name="top_attach">0</property>
                         <property name="width">1</property>
                         <property name="height">1</property>
                       </packing>
@@ -310,57 +293,61 @@
                     <child>
                       <object class="GtkCheckButton" id="crypttab-auth-checkbutton">
                         <property name="label" translatable="yes">Require additional authorization to unlock</property>
+                        <property name="use_action_appearance">False</property>
                         <property name="visible">True</property>
                         <property name="can_focus">True</property>
                         <property name="receives_default">False</property>
+                        <property name="has_tooltip">True</property>
+                        <property name="tooltip_markup" translatable="yes">If checked, additional authorization is required to unlock the device [x-udisks-auth]</property>
                         <property name="tooltip_text" translatable="yes">If checked, additional authorization is required to unlock the device [x-udisks-auth]</property>
                         <property name="use_action_appearance">False</property>
-                        <property name="use_underline">False</property>
                         <property name="xalign">0</property>
                         <property name="draw_indicator">True</property>
                       </object>
                       <packing>
-                        <property name="left_attach">1</property>
-                        <property name="top_attach">4</property>
+                        <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>
-                      <placeholder/>
-                    </child>
-                    <child>
-                      <placeholder/>
-                    </child>
                   </object>
                   <packing>
-                    <property name="expand">False</property>
-                    <property name="fill">True</property>
-                    <property name="position">0</property>
+                    <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="GtkLinkButton" id="linkbutton2">
-                    <property name="label" translatable="yes">What's this?</property>
-                    <property name="visible">True</property>
-                    <property name="can_focus">True</property>
-                    <property name="receives_default">True</property>
-                    <property name="has_tooltip">True</property>
-                    <property name="use_action_appearance">False</property>
-                    <property name="relief">none</property>
-                    <property name="xalign">0</property>
-                    <property name="uri">man:crypttab</property>
-                  </object>
-                  <packing>
-                    <property name="expand">False</property>
-                    <property name="fill">True</property>
-                    <property name="position">1</property>
-                  </packing>
+                  <placeholder/>
+                </child>
+                <child>
+                  <placeholder/>
                 </child>
               </object>
               <packing>
                 <property name="expand">False</property>
                 <property name="fill">True</property>
+                <property name="position">1</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkLinkButton" id="linkbutton2">
+                <property name="label" translatable="yes">What's this?</property>
+                <property name="use_action_appearance">False</property>
+                <property name="visible">True</property>
+                <property name="can_focus">True</property>
+                <property name="receives_default">True</property>
+                <property name="has_tooltip">True</property>
+                <property name="use_action_appearance">False</property>
+                <property name="relief">none</property>
+                <property name="xalign">0</property>
+                <property name="uri">man:crypttab</property>
+              </object>
+              <packing>
+                <property name="expand">False</property>
+                <property name="fill">True</property>
                 <property name="position">2</property>
               </packing>
             </child>
@@ -374,8 +361,9 @@
       </object>
     </child>
     <action-widgets>
-      <action-widget response="0">button10</action-widget>
-      <action-widget response="-10">button9</action-widget>
+      <action-widget response="0">crypttab-cancel-button</action-widget>
+      <action-widget response="-10">crypttab-apply-button</action-widget>
+      <action-widget response="1">crypttab-reset-button</action-widget>
     </action-widgets>
   </object>
 </interface>
diff --git a/data/ui/palimpsest.ui b/data/ui/palimpsest.ui
index d8bf55e..36329c3 100644
--- a/data/ui/palimpsest.ui
+++ b/data/ui/palimpsest.ui
@@ -172,7 +172,7 @@
         <property name="visible">True</property>
         <property name="can_focus">False</property>
         <property name="use_action_appearance">False</property>
-        <property name="label" translatable="yes">Edit crypttab entry...</property>
+        <property name="label" translatable="yes">Edit Crypt Options...</property>
         <property name="use_underline">True</property>
       </object>
     </child>
diff --git a/src/palimpsest/gducrypttabdialog.c b/src/palimpsest/gducrypttabdialog.c
index ea612b3..31cd446 100644
--- a/src/palimpsest/gducrypttabdialog.c
+++ b/src/palimpsest/gducrypttabdialog.c
@@ -45,13 +45,12 @@ typedef struct
   GtkWidget *infobar_vbox;
   GtkWidget *passphrase_warning_infobar;
 
-  GtkWidget *configure_checkbutton;
+  GtkWidget *reset_button;
   GtkWidget *grid;
 
   GtkWidget *name_entry;
   GtkWidget *options_entry;
-  GtkWidget *noauto_checkbutton;
-  GtkWidget *nofail_checkbutton;
+  GtkWidget *neg_noauto_checkbutton;
   GtkWidget *auth_checkbutton;
   GtkWidget *passphrase_label;
   GtkWidget *passphrase_entry;
@@ -82,7 +81,6 @@ static void
 update (CrypttabDialogData *data,
         GtkWidget          *widget)
 {
-  gboolean ui_configured;
   const gchar *ui_name;
   const gchar *ui_options;
   const gchar *ui_passphrase_contents;
@@ -112,7 +110,6 @@ update (CrypttabDialogData *data,
       passphrase_contents = "";
     }
 
-  ui_configured = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (data->configure_checkbutton));
   ui_name = gtk_entry_get_text (GTK_ENTRY (data->name_entry));
   ui_options = gtk_entry_get_text (GTK_ENTRY (data->options_entry));
   ui_passphrase_contents = gtk_entry_get_text (GTK_ENTRY (data->passphrase_entry));
@@ -156,26 +153,17 @@ update (CrypttabDialogData *data,
   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, FALSE, FALSE);
-  gdu_options_update_check_option (data->options_entry, "nofail", widget, data->nofail_checkbutton, FALSE, FALSE);
+  gdu_options_update_check_option (data->options_entry, "noauto", widget, data->neg_noauto_checkbutton, TRUE, FALSE);
   gdu_options_update_check_option (data->options_entry, "x-udisks-auth", widget, data->auth_checkbutton, FALSE, FALSE);
   g_object_thaw_notify (G_OBJECT (data->options_entry));
 
   can_apply = FALSE;
-  if (configured != ui_configured)
+  if (g_strcmp0 (ui_name, name) != 0 ||
+      g_strcmp0 (ui_options, options) != 0 ||
+      g_strcmp0 (ui_passphrase_contents, passphrase_contents) != 0)
     {
       can_apply = TRUE;
     }
-  else if (ui_configured)
-    {
-      if (g_strcmp0 (ui_name, name) != 0 ||
-          g_strcmp0 (ui_options, options) != 0 ||
-          g_strcmp0 (ui_passphrase_contents, passphrase_contents) != 0)
-        {
-          can_apply = TRUE;
-        }
-    }
-
   gtk_dialog_set_response_sensitive (GTK_DIALOG (data->dialog),
                                      GTK_RESPONSE_APPLY,
                                      can_apply);
@@ -215,10 +203,9 @@ crypttab_dialog_present (CrypttabDialogData *data)
       options = "nofail";
       /* propose noauto if the media is removable - otherwise e.g. systemd will time out at boot */
       if (data->drive != NULL && udisks_drive_get_removable (data->drive))
-        options = "noauto";
+        options = "nofail,noauto";
       passphrase_contents = "";
     }
-  gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (data->configure_checkbutton), configured);
   gtk_entry_set_text (GTK_ENTRY (data->name_entry), name);
   gtk_entry_set_text (GTK_ENTRY (data->options_entry), options);
   gtk_entry_set_text (GTK_ENTRY (data->passphrase_entry), passphrase_contents);
@@ -229,21 +216,11 @@ crypttab_dialog_present (CrypttabDialogData *data)
                           "visibility",
                           G_BINDING_SYNC_CREATE);
 
-  g_object_bind_property (data->configure_checkbutton,
-                          "active",
-                          data->grid,
-                          "sensitive",
-                          G_BINDING_SYNC_CREATE);
-
-  g_signal_connect (data->configure_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->options_entry,
                     "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->nofail_checkbutton,
+  g_signal_connect (data->neg_noauto_checkbutton,
                     "notify::active", G_CALLBACK (on_property_changed), data);
   g_signal_connect (data->auth_checkbutton,
                     "notify::active", G_CALLBACK (on_property_changed), data);
@@ -252,31 +229,51 @@ crypttab_dialog_present (CrypttabDialogData *data)
 
   gtk_widget_show_all (data->dialog);
 
+  /* Show "Reset" button only if already configured */
+  if (!configured)
+    gtk_widget_hide (data->reset_button);
+
   update (data, NULL);
 
   response = gtk_dialog_run (GTK_DIALOG (data->dialog));
 
-  if (response == GTK_RESPONSE_APPLY)
+  if (response == 1) /* application-defined for "crypttab-button-reset" */
+    {
+      GError *error;
+
+      error = NULL;
+      if (!udisks_block_call_remove_configuration_item_sync (data->block,
+                                                             g_variant_new ("(s a{sv})", "crypttab",
+                                                                            data->orig_crypttab_entry),
+                                                             g_variant_new ("a{sv}", NULL), /* options */
+                                                             NULL, /* GCancellable */
+                                                             &error))
+        {
+          gdu_window_show_error (data->window,
+                                 _("Error removing /etc/crypttab entry"),
+                                 error);
+          g_error_free (error);
+          goto out;
+        }
+    }
+  else if (response == GTK_RESPONSE_APPLY)
     {
-      gboolean ui_configured;
       const gchar *ui_name;
       const gchar *ui_options;
       const gchar *ui_passphrase_contents;
       const gchar *old_passphrase_path;
       GError *error;
-      GVariant *old_item;
-      GVariant *new_item;
+      GVariant *old_item = NULL;
+      GVariant *new_item = NULL;
+      GVariantBuilder builder;
+      gchar *s;
 
-      ui_configured = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (data->configure_checkbutton));
       ui_name = gtk_entry_get_text (GTK_ENTRY (data->name_entry));
       ui_options = gtk_entry_get_text (GTK_ENTRY (data->options_entry));
       ui_passphrase_contents = gtk_entry_get_text (GTK_ENTRY (data->passphrase_entry));
 
       gtk_widget_hide (data->dialog);
 
-      old_item = NULL;
-      new_item = NULL;
-
       old_passphrase_path = NULL;
       if (data->orig_crypttab_entry != NULL)
         {
@@ -291,63 +288,40 @@ crypttab_dialog_present (CrypttabDialogData *data)
                                     data->orig_crypttab_entry);
         }
 
-      if (ui_configured)
+      g_variant_builder_init (&builder, G_VARIANT_TYPE_VARDICT);
+      s = g_strdup_printf ("UUID=%s", udisks_block_get_id_uuid (data->block));
+      g_variant_builder_add (&builder, "{sv}", "device", g_variant_new_bytestring (s));
+      g_free (s);
+      g_variant_builder_add (&builder, "{sv}", "name", g_variant_new_bytestring (ui_name));
+      g_variant_builder_add (&builder, "{sv}", "options", g_variant_new_bytestring (ui_options));
+      if (strlen (ui_passphrase_contents) > 0)
         {
-          GVariantBuilder builder;
-          gchar *s;
-          g_variant_builder_init (&builder, G_VARIANT_TYPE_VARDICT);
-          s = g_strdup_printf ("UUID=%s", udisks_block_get_id_uuid (data->block));
-          g_variant_builder_add (&builder, "{sv}", "device", g_variant_new_bytestring (s));
-          g_free (s);
-          g_variant_builder_add (&builder, "{sv}", "name", g_variant_new_bytestring (ui_name));
-          g_variant_builder_add (&builder, "{sv}", "options", g_variant_new_bytestring (ui_options));
-          if (strlen (ui_passphrase_contents) > 0)
+          /* use old/existing passphrase file, if available */
+          if (old_passphrase_path != NULL)
             {
-              /* use old/existing passphrase file, if available */
-              if (old_passphrase_path != NULL)
-                {
-                  g_variant_builder_add (&builder, "{sv}", "passphrase-path",
-                                         g_variant_new_bytestring (old_passphrase_path));
-                }
-              else
-                {
-                  /* otherwise fall back to the requested name */
-                  s = g_strdup_printf ("/etc/luks-keys/%s", ui_name);
-                  g_variant_builder_add (&builder, "{sv}", "passphrase-path", g_variant_new_bytestring (s));
-                  g_free (s);
-                }
-              g_variant_builder_add (&builder, "{sv}", "passphrase-contents",
-                                     g_variant_new_bytestring (ui_passphrase_contents));
-
+              g_variant_builder_add (&builder, "{sv}", "passphrase-path",
+                                     g_variant_new_bytestring (old_passphrase_path));
             }
           else
             {
-              g_variant_builder_add (&builder, "{sv}", "passphrase-path",
-                                     g_variant_new_bytestring (""));
-              g_variant_builder_add (&builder, "{sv}", "passphrase-contents",
-                                     g_variant_new_bytestring (""));
+              /* otherwise fall back to the requested name */
+              s = g_strdup_printf ("/etc/luks-keys/%s", ui_name);
+              g_variant_builder_add (&builder, "{sv}", "passphrase-path", g_variant_new_bytestring (s));
+              g_free (s);
             }
-
-          new_item = g_variant_new ("(sa{sv})", "crypttab", &builder);
+          g_variant_builder_add (&builder, "{sv}", "passphrase-contents",
+                                 g_variant_new_bytestring (ui_passphrase_contents));
         }
-
-      if (old_item != NULL && new_item == NULL)
+      else
         {
-          error = NULL;
-          if (!udisks_block_call_remove_configuration_item_sync (data->block,
-                                                                 old_item,
-                                                                 g_variant_new ("a{sv}", NULL), /* options */
-                                                                 NULL, /* GCancellable */
-                                                                 &error))
-            {
-              gdu_window_show_error (data->window,
-                                     _("Error removing /etc/crypttab entry"),
-                                     error);
-              g_error_free (error);
-              goto out;
-            }
+          g_variant_builder_add (&builder, "{sv}", "passphrase-path",
+                                 g_variant_new_bytestring (""));
+          g_variant_builder_add (&builder, "{sv}", "passphrase-contents",
+                                 g_variant_new_bytestring (""));
         }
-      else if (old_item == NULL && new_item != NULL)
+      new_item = g_variant_new ("(sa{sv})", "crypttab", &builder);
+
+      if (old_item == NULL && new_item != NULL)
         {
           error = NULL;
           if (!udisks_block_call_add_configuration_item_sync (data->block,
@@ -483,12 +457,11 @@ gdu_crypttab_dialog_show (GduWindow    *window,
 
   data->dialog = dialog;
   data->infobar_vbox = GTK_WIDGET (gtk_builder_get_object (data->builder, "infobar-vbox"));
-  data->configure_checkbutton = GTK_WIDGET (gtk_builder_get_object (data->builder, "crypttab-configure-checkbutton"));
+  data->reset_button = GTK_WIDGET (gtk_builder_get_object (data->builder, "crypttab-reset-button"));
   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->nofail_checkbutton = GTK_WIDGET (gtk_builder_get_object (data->builder, "crypttab-nofail-checkbutton"));
+  data->neg_noauto_checkbutton = GTK_WIDGET (gtk_builder_get_object (data->builder, "crypttab-neg-noauto-checkbutton"));
   data->auth_checkbutton = GTK_WIDGET (gtk_builder_get_object (data->builder, "crypttab-auth-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"));



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