[gnome-disk-utility] Remove some "madness" from the Drive Settings dialog



commit 00bc40129ae6096d29fc8a7d9c98259b3e2f81c9
Author: David Zeuthen <zeuthen gmail com>
Date:   Tue Jun 26 12:23:41 2012 -0400

    Remove some "madness" from the Drive Settings dialog
    
    Suggestions from Jakub Steiner <jimmac gmail com>, thanks.
    
    http://people.freedesktop.org/~david/gnome-disks-disk-settings-dialog-v2.png
    
    We still support some, uhm, weird crazytown corner cases such as
    disabling APM (subtly different from setting to switch to OFF) but
    that is now a lot more hidden:
    
    http://people.freedesktop.org/~david/gnome-disks-disk-settings-dialog-v2-corner-cases.png
    
    Signed-off-by: David Zeuthen <zeuthen gmail com>

 data/ui/disk-settings-dialog.ui   |  403 +++++++++++++++++--------------------
 src/disks/gdudisksettingsdialog.c |  380 ++++++++++++++++------------------
 2 files changed, 366 insertions(+), 417 deletions(-)
---
diff --git a/data/ui/disk-settings-dialog.ui b/data/ui/disk-settings-dialog.ui
index 391af4a..9b8f866 100644
--- a/data/ui/disk-settings-dialog.ui
+++ b/data/ui/disk-settings-dialog.ui
@@ -2,7 +2,7 @@
 <interface>
   <!-- interface-requires gtk+ 3.0 -->
   <object class="GtkAdjustment" id="aam-adjustment">
-    <property name="lower">128</property>
+    <property name="lower">127</property>
     <property name="upper">254</property>
     <property name="value">128</property>
     <property name="step_increment">1</property>
@@ -10,7 +10,7 @@
   </object>
   <object class="GtkAdjustment" id="apm-adjustment">
     <property name="lower">1</property>
-    <property name="upper">254</property>
+    <property name="upper">255</property>
     <property name="value">127</property>
     <property name="step_increment">1</property>
     <property name="page_increment">10</property>
@@ -74,18 +74,20 @@
           </packing>
         </child>
         <child>
-          <object class="GtkNotebook" id="settings-notebook">
+          <object class="GtkBox" id="box">
             <property name="visible">True</property>
-            <property name="can_focus">True</property>
+            <property name="can_focus">False</property>
+            <property name="border_width">5</property>
+            <property name="orientation">vertical</property>
+            <property name="spacing">12</property>
             <child>
-              <object class="GtkBox" id="power-management-page">
+              <object class="GtkBox" id="standby-box">
                 <property name="visible">True</property>
                 <property name="can_focus">False</property>
-                <property name="border_width">12</property>
                 <property name="orientation">vertical</property>
                 <property name="spacing">6</property>
                 <child>
-                  <object class="GtkBox" id="box3">
+                  <object class="GtkBox" id="box6">
                     <property name="visible">True</property>
                     <property name="can_focus">False</property>
                     <property name="spacing">12</property>
@@ -93,8 +95,9 @@
                       <object class="GtkLabel" id="label3">
                         <property name="visible">True</property>
                         <property name="can_focus">False</property>
-                        <property name="label" translatable="yes">Apply Power Management _Settings When Drive Is Connected</property>
+                        <property name="label" translatable="yes">_Standby Timeout</property>
                         <property name="use_underline">True</property>
+                        <property name="mnemonic_widget">standby-switch</property>
                         <attributes>
                           <attribute name="weight" value="bold"/>
                           <attribute name="scale" value="1"/>
@@ -107,7 +110,7 @@
                       </packing>
                     </child>
                     <child>
-                      <object class="GtkSwitch" id="pm-apply-settings-switch">
+                      <object class="GtkSwitch" id="standby-switch">
                         <property name="use_action_appearance">False</property>
                         <property name="visible">True</property>
                         <property name="can_focus">True</property>
@@ -117,6 +120,7 @@
                       <packing>
                         <property name="expand">False</property>
                         <property name="fill">True</property>
+                        <property name="pack_type">end</property>
                         <property name="position">1</property>
                       </packing>
                     </child>
@@ -128,27 +132,24 @@
                   </packing>
                 </child>
                 <child>
-                  <object class="GtkBox" id="pm-settings-box">
+                  <object class="GtkBox" id="standby-widgets-box">
                     <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">6</property>
                     <child>
-                      <object class="GtkBox" id="standby-box">
+                      <object class="GtkBox" id="box10">
                         <property name="visible">True</property>
                         <property name="can_focus">False</property>
-                        <property name="orientation">vertical</property>
                         <property name="spacing">6</property>
                         <child>
-                          <object class="GtkLabel" id="label5">
+                          <object class="GtkLabel" id="standby-label">
                             <property name="visible">True</property>
                             <property name="can_focus">False</property>
-                            <property name="xalign">0</property>
-                            <property name="label" translatable="yes">&lt;b&gt;Standby _Timeout&lt;/b&gt;</property>
-                            <property name="use_markup">True</property>
-                            <property name="use_underline">True</property>
-                            <property name="mnemonic_widget">standby-scale</property>
+                            <property name="xalign">1</property>
+                            <property name="label" translatable="yes">Enter Standby After</property>
+                            <style><class name="dim-label"/></style>
                           </object>
                           <packing>
                             <property name="expand">False</property>
@@ -157,57 +158,9 @@
                           </packing>
                         </child>
                         <child>
-                          <object class="GtkBox" id="box6">
+                          <object class="GtkLabel" id="standby-value-label">
                             <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">6</property>
-                            <child>
-                              <object class="GtkLabel" id="label6">
-                                <property name="width_request">500</property>
-                                <property name="visible">True</property>
-                                <property name="can_focus">False</property>
-                                <property name="label" translatable="yes">This timeout value is used by the drive to determine how long to wait (with no disk activity) before turning off the spindle motor to save power. Under such circumstances, the drive may take as long as 30 seconds to respond to a subsequent disk access, though most drives are much quicker</property>
-                                <property name="wrap">True</property>
-                              </object>
-                              <packing>
-                                <property name="expand">False</property>
-                                <property name="fill">True</property>
-                                <property name="position">0</property>
-                              </packing>
-                            </child>
-                            <child>
-                              <object class="GtkScale" id="standby-scale">
-                                <property name="visible">True</property>
-                                <property name="can_focus">True</property>
-                                <property name="adjustment">standby-adjustment</property>
-                                <property name="round_digits">1</property>
-                              </object>
-                              <packing>
-                                <property name="expand">False</property>
-                                <property name="fill">True</property>
-                                <property name="position">1</property>
-                              </packing>
-                            </child>
-                            <child>
-                              <object class="GtkCheckButton" id="standby-disable-checkbutton">
-                                <property name="label" translatable="yes">_Disable Standby Timeout</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="expand">False</property>
-                                <property name="fill">True</property>
-                                <property name="position">2</property>
-                              </packing>
-                            </child>
                           </object>
                           <packing>
                             <property name="expand">False</property>
@@ -223,20 +176,103 @@
                       </packing>
                     </child>
                     <child>
-                      <object class="GtkBox" id="apm-box">
+                      <object class="GtkScale" id="standby-scale">
+                        <property name="visible">True</property>
+                        <property name="can_focus">True</property>
+                        <property name="adjustment">standby-adjustment</property>
+                        <property name="round_digits">1</property>
+                        <property name="draw_value">False</property>
+                      </object>
+                      <packing>
+                        <property name="expand">False</property>
+                        <property name="fill">True</property>
+                        <property name="position">1</property>
+                      </packing>
+                    </child>
+                  </object>
+                  <packing>
+                    <property name="expand">False</property>
+                    <property name="fill">True</property>
+                    <property name="position">1</property>
+                  </packing>
+                </child>
+              </object>
+              <packing>
+                <property name="expand">False</property>
+                <property name="fill">True</property>
+                <property name="position">0</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkBox" id="apm-box">
+                <property name="visible">True</property>
+                <property name="can_focus">False</property>
+                <property name="orientation">vertical</property>
+                <property name="spacing">6</property>
+                <child>
+                  <object class="GtkBox" id="box2">
+                    <property name="visible">True</property>
+                    <property name="can_focus">False</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="label" translatable="yes">_Advanced Power Management</property>
+                        <property name="use_underline">True</property>
+                        <property name="mnemonic_widget">apm-switch</property>
+                        <attributes>
+                          <attribute name="weight" value="bold"/>
+                          <attribute name="scale" value="1"/>
+                        </attributes>
+                      </object>
+                      <packing>
+                        <property name="expand">False</property>
+                        <property name="fill">True</property>
+                        <property name="position">0</property>
+                      </packing>
+                    </child>
+                    <child>
+                      <object class="GtkSwitch" id="apm-switch">
+                        <property name="use_action_appearance">False</property>
+                        <property name="visible">True</property>
+                        <property name="can_focus">True</property>
+                        <property name="has_tooltip">True</property>
+                        <property name="use_action_appearance">False</property>
+                      </object>
+                      <packing>
+                        <property name="expand">False</property>
+                        <property name="fill">True</property>
+                        <property name="pack_type">end</property>
+                        <property name="position">1</property>
+                      </packing>
+                    </child>
+                  </object>
+                  <packing>
+                    <property name="expand">False</property>
+                    <property name="fill">True</property>
+                    <property name="position">0</property>
+                  </packing>
+                </child>
+                <child>
+                  <object class="GtkBox" id="apm-widgets-box">
+                    <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">6</property>
+                    <child>
+                      <object class="GtkBox" id="box8">
                         <property name="visible">True</property>
                         <property name="can_focus">False</property>
-                        <property name="orientation">vertical</property>
                         <property name="spacing">6</property>
                         <child>
-                          <object class="GtkLabel" id="label7">
+                          <object class="GtkLabel" id="apm-label">
                             <property name="visible">True</property>
                             <property name="can_focus">False</property>
-                            <property name="xalign">0</property>
-                            <property name="label" translatable="yes" comments="Don't translate &quot;APM&quot; - it's an acronym">&lt;b&gt;Advanced Power _Management (APM)&lt;/b&gt;</property>
-                            <property name="use_markup">True</property>
-                            <property name="use_underline">True</property>
-                            <property name="mnemonic_widget">apm-scale</property>
+                            <property name="xalign">1</property>
+                            <property name="label" translatable="yes">APM Level</property>
+                            <style><class name="dim-label"/></style>
                           </object>
                           <packing>
                             <property name="expand">False</property>
@@ -245,57 +281,9 @@
                           </packing>
                         </child>
                         <child>
-                          <object class="GtkBox" id="box7">
+                          <object class="GtkLabel" id="apm-value-label">
                             <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">6</property>
-                            <child>
-                              <object class="GtkLabel" id="label8">
-                                <property name="width_request">500</property>
-                                <property name="visible">True</property>
-                                <property name="can_focus">False</property>
-                                <property name="label" translatable="yes">A low value means aggressive power management and a high value means better performance. If you enable this feature, please pay attention to SMART attributes such as  âStart/Stop Countâ as an aggressive spin-down policy may wear out the drive faster than anticipated</property>
-                                <property name="wrap">True</property>
-                              </object>
-                              <packing>
-                                <property name="expand">False</property>
-                                <property name="fill">True</property>
-                                <property name="position">0</property>
-                              </packing>
-                            </child>
-                            <child>
-                              <object class="GtkScale" id="apm-scale">
-                                <property name="visible">True</property>
-                                <property name="can_focus">True</property>
-                                <property name="adjustment">apm-adjustment</property>
-                                <property name="round_digits">1</property>
-                              </object>
-                              <packing>
-                                <property name="expand">False</property>
-                                <property name="fill">True</property>
-                                <property name="position">1</property>
-                              </packing>
-                            </child>
-                            <child>
-                              <object class="GtkCheckButton" id="apm-disable-checkbutton">
-                                <property name="label" translatable="yes">D_isable Advanced Power Management</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="expand">False</property>
-                                <property name="fill">True</property>
-                                <property name="position">2</property>
-                              </packing>
-                            </child>
                           </object>
                           <packing>
                             <property name="expand">False</property>
@@ -307,9 +295,41 @@
                       <packing>
                         <property name="expand">False</property>
                         <property name="fill">True</property>
+                        <property name="position">0</property>
+                      </packing>
+                    </child>
+                    <child>
+                      <object class="GtkScale" id="apm-scale">
+                        <property name="visible">True</property>
+                        <property name="can_focus">True</property>
+                        <property name="adjustment">apm-adjustment</property>
+                        <property name="round_digits">1</property>
+                        <property name="draw_value">False</property>
+                      </object>
+                      <packing>
+                        <property name="expand">False</property>
+                        <property name="fill">True</property>
                         <property name="position">1</property>
                       </packing>
                     </child>
+                    <child>
+                      <object class="GtkLabel" id="label7">
+                        <property name="width_request">500</property>
+                        <property name="visible">True</property>
+                        <property name="can_focus">False</property>
+                        <property name="xalign">0</property>
+                        <property name="label" translatable="yes">Agressive spin-down may wear out the drive faster than anticipated. Please check the âStart/Stop Countâ SMART attribute from time to time</property>
+                        <property name="wrap">True</property>
+                        <attributes>
+                          <attribute name="style" value="italic"/>
+                        </attributes>
+                      </object>
+                      <packing>
+                        <property name="expand">False</property>
+                        <property name="fill">True</property>
+                        <property name="position">2</property>
+                      </packing>
+                    </child>
                   </object>
                   <packing>
                     <property name="expand">False</property>
@@ -318,27 +338,20 @@
                   </packing>
                 </child>
               </object>
-            </child>
-            <child type="tab">
-              <object class="GtkLabel" id="label1">
-                <property name="visible">True</property>
-                <property name="can_focus">False</property>
-                <property name="label" translatable="yes">_Power Management</property>
-                <property name="use_underline">True</property>
-              </object>
               <packing>
-                <property name="tab_fill">False</property>
+                <property name="expand">False</property>
+                <property name="fill">True</property>
+                <property name="position">1</property>
               </packing>
             </child>
             <child>
-              <object class="GtkBox" id="acoustic-page">
+              <object class="GtkBox" id="aam-box">
                 <property name="visible">True</property>
                 <property name="can_focus">False</property>
-                <property name="border_width">12</property>
                 <property name="orientation">vertical</property>
                 <property name="spacing">6</property>
                 <child>
-                  <object class="GtkBox" id="box5">
+                  <object class="GtkBox" id="box1">
                     <property name="visible">True</property>
                     <property name="can_focus">False</property>
                     <property name="spacing">12</property>
@@ -346,8 +359,9 @@
                       <object class="GtkLabel" id="label4">
                         <property name="visible">True</property>
                         <property name="can_focus">False</property>
-                        <property name="label" translatable="yes">Apply Acoustic _Settings When Drive Is Connected</property>
+                        <property name="label" translatable="yes">Automatic Aco_ustic Management</property>
                         <property name="use_underline">True</property>
+                        <property name="mnemonic_widget">aam-switch</property>
                         <attributes>
                           <attribute name="weight" value="bold"/>
                           <attribute name="scale" value="1"/>
@@ -360,7 +374,7 @@
                       </packing>
                     </child>
                     <child>
-                      <object class="GtkSwitch" id="acoustic-apply-settings-switch">
+                      <object class="GtkSwitch" id="aam-switch">
                         <property name="use_action_appearance">False</property>
                         <property name="visible">True</property>
                         <property name="can_focus">True</property>
@@ -370,6 +384,7 @@
                       <packing>
                         <property name="expand">False</property>
                         <property name="fill">True</property>
+                        <property name="pack_type">end</property>
                         <property name="position">1</property>
                       </packing>
                     </child>
@@ -381,26 +396,24 @@
                   </packing>
                 </child>
                 <child>
-                  <object class="GtkBox" id="acoustic-settings-box">
+                  <object class="GtkBox" id="aam-widgets-box">
                     <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">6</property>
                     <child>
-                      <object class="GtkBox" id="aam-box">
+                      <object class="GtkBox" id="box3">
                         <property name="visible">True</property>
                         <property name="can_focus">False</property>
-                        <property name="orientation">vertical</property>
                         <property name="spacing">6</property>
                         <child>
-                          <object class="GtkLabel" id="label9">
+                          <object class="GtkLabel" id="aam-label">
                             <property name="visible">True</property>
                             <property name="can_focus">False</property>
-                            <property name="xalign">0</property>
-                            <property name="label" translatable="yes" comments="Don't translate &quot;AAM&quot; - it's an acronym">&lt;b&gt;Automatic Acoustic _Management (AAM)&lt;/b&gt;</property>
-                            <property name="use_markup">True</property>
-                            <property name="use_underline">True</property>
-                            <property name="mnemonic_widget">aam-scale</property>
+                            <property name="xalign">1</property>
+                            <property name="label" translatable="yes">AAM Level</property>
+                            <style><class name="dim-label"/></style>
                           </object>
                           <packing>
                             <property name="expand">False</property>
@@ -409,57 +422,9 @@
                           </packing>
                         </child>
                         <child>
-                          <object class="GtkBox" id="box4">
+                          <object class="GtkLabel" id="aam-value-label">
                             <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">6</property>
-                            <child>
-                              <object class="GtkLabel" id="label10">
-                                <property name="width_request">500</property>
-                                <property name="visible">True</property>
-                                <property name="can_focus">False</property>
-                                <property name="label" translatable="yes">Most modern hard disks have the ability to speed down the head movements to reduce their noise output. The possible values are between 128 and 254 with 128 being the most quiet (and therefore slowest) setting and 254 the fastest (and loudest)</property>
-                                <property name="wrap">True</property>
-                              </object>
-                              <packing>
-                                <property name="expand">False</property>
-                                <property name="fill">True</property>
-                                <property name="position">0</property>
-                              </packing>
-                            </child>
-                            <child>
-                              <object class="GtkScale" id="aam-scale">
-                                <property name="visible">True</property>
-                                <property name="can_focus">True</property>
-                                <property name="adjustment">aam-adjustment</property>
-                                <property name="round_digits">1</property>
-                              </object>
-                              <packing>
-                                <property name="expand">False</property>
-                                <property name="fill">True</property>
-                                <property name="position">1</property>
-                              </packing>
-                            </child>
-                            <child>
-                              <object class="GtkCheckButton" id="aam-disable-checkbutton">
-                                <property name="label" translatable="yes">_Disable Acoustic Management</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="expand">False</property>
-                                <property name="fill">True</property>
-                                <property name="position">2</property>
-                              </packing>
-                            </child>
                           </object>
                           <packing>
                             <property name="expand">False</property>
@@ -474,6 +439,20 @@
                         <property name="position">0</property>
                       </packing>
                     </child>
+                    <child>
+                      <object class="GtkScale" id="aam-scale">
+                        <property name="visible">True</property>
+                        <property name="can_focus">True</property>
+                        <property name="adjustment">aam-adjustment</property>
+                        <property name="round_digits">1</property>
+                        <property name="draw_value">False</property>
+                      </object>
+                      <packing>
+                        <property name="expand">False</property>
+                        <property name="fill">True</property>
+                        <property name="position">1</property>
+                      </packing>
+                    </child>
                   </object>
                   <packing>
                     <property name="expand">False</property>
@@ -483,27 +462,11 @@
                 </child>
               </object>
               <packing>
-                <property name="position">1</property>
-              </packing>
-            </child>
-            <child type="tab">
-              <object class="GtkLabel" id="label2">
-                <property name="visible">True</property>
-                <property name="can_focus">False</property>
-                <property name="label" translatable="yes">_Acoustic Levels</property>
-                <property name="use_underline">True</property>
-              </object>
-              <packing>
-                <property name="position">1</property>
-                <property name="tab_fill">False</property>
+                <property name="expand">False</property>
+                <property name="fill">True</property>
+                <property name="position">2</property>
               </packing>
             </child>
-            <child>
-              <placeholder/>
-            </child>
-            <child type="tab">
-              <placeholder/>
-            </child>
           </object>
           <packing>
             <property name="expand">False</property>
@@ -518,8 +481,16 @@
       <action-widget response="-5">ok-button</action-widget>
     </action-widgets>
   </object>
+  <object class="GtkSizeGroup" id="sizegroup1">
+    <property name="ignore_hidden">True</property>
+    <widgets>
+      <widget name="standby-label"/>
+      <widget name="apm-label"/>
+      <widget name="aam-label"/>
+    </widgets>
+  </object>
   <object class="GtkAdjustment" id="standby-adjustment">
-    <property name="lower">1</property>
+    <property name="lower">0</property>
     <property name="upper">255</property>
     <property name="value">60</property>
     <property name="step_increment">1</property>
diff --git a/src/disks/gdudisksettingsdialog.c b/src/disks/gdudisksettingsdialog.c
index 16c2af7..44a5d69 100644
--- a/src/disks/gdudisksettingsdialog.c
+++ b/src/disks/gdudisksettingsdialog.c
@@ -50,30 +50,30 @@ typedef struct
 
   GVariant *orig_drive_configuration;
 
-  /* Power Management page */
-  GtkWidget *pm_page;
-  GtkWidget *pm_apply_settings_switch;
-  GtkWidget *pm_settings_box;
-
+  /* Standby */
   GtkWidget *standby_box;
-  GtkAdjustment *standby_adjustment;
+  GtkWidget *standby_switch;
+  GtkWidget *standby_widgets_box;
+  GtkWidget *standby_value_label;
   GtkWidget *standby_scale;
-  GtkWidget *standby_disable_checkbutton;
+  GtkAdjustment *standby_adjustment;
 
+  /* APM */
   GtkWidget *apm_box;
-  GtkAdjustment *apm_adjustment;
+  GtkWidget *apm_switch;
+  GtkWidget *apm_widgets_box;
+  GtkWidget *apm_value_label;
   GtkWidget *apm_scale;
-  GtkWidget *apm_disable_checkbutton;
-
-  /* Acoustic page */
-  GtkWidget *acoustic_page;
-  GtkWidget *acoustic_apply_settings_switch;
-  GtkWidget *acoustic_settings_box;
+  GtkAdjustment *apm_adjustment;
 
+  /* AAM */
   GtkWidget *aam_box;
-  GtkAdjustment *aam_adjustment;
+  GtkWidget *aam_switch;
+  GtkWidget *aam_widgets_box;
+  GtkWidget *aam_value_label;
   GtkWidget *aam_scale;
-  GtkWidget *aam_disable_checkbutton;
+  GtkAdjustment *aam_adjustment;
+
 } DialogData;
 
 G_LOCK_DEFINE (bm_lock);
@@ -82,34 +82,39 @@ static const struct {
   goffset offset;
   const gchar *name;
 } widget_mapping[] = {
-  /* Power Management page */
-  {G_STRUCT_OFFSET (DialogData, pm_page), "power-management-page"},
-  {G_STRUCT_OFFSET (DialogData, pm_apply_settings_switch), "pm-apply-settings-switch"},
-  {G_STRUCT_OFFSET (DialogData, pm_settings_box), "pm-settings-box"},
+  /* Standby */
   {G_STRUCT_OFFSET (DialogData, standby_box), "standby-box"},
-  {G_STRUCT_OFFSET (DialogData, standby_adjustment), "standby-adjustment"},
+  {G_STRUCT_OFFSET (DialogData, standby_switch), "standby-switch"},
+  {G_STRUCT_OFFSET (DialogData, standby_widgets_box), "standby-widgets-box"},
+  {G_STRUCT_OFFSET (DialogData, standby_value_label), "standby-value-label"},
   {G_STRUCT_OFFSET (DialogData, standby_scale), "standby-scale"},
-  {G_STRUCT_OFFSET (DialogData, standby_disable_checkbutton), "standby-disable-checkbutton"},
+  {G_STRUCT_OFFSET (DialogData, standby_adjustment), "standby-adjustment"},
+
+  /* APM */
   {G_STRUCT_OFFSET (DialogData, apm_box), "apm-box"},
-  {G_STRUCT_OFFSET (DialogData, apm_adjustment), "apm-adjustment"},
+  {G_STRUCT_OFFSET (DialogData, apm_switch), "apm-switch"},
+  {G_STRUCT_OFFSET (DialogData, apm_widgets_box), "apm-widgets-box"},
+  {G_STRUCT_OFFSET (DialogData, apm_value_label), "apm-value-label"},
   {G_STRUCT_OFFSET (DialogData, apm_scale), "apm-scale"},
-  {G_STRUCT_OFFSET (DialogData, apm_disable_checkbutton), "apm-disable-checkbutton"},
+  {G_STRUCT_OFFSET (DialogData, apm_adjustment), "apm-adjustment"},
 
-  /* Acoustic page */
-  {G_STRUCT_OFFSET (DialogData, acoustic_page), "acoustic-page"},
-  {G_STRUCT_OFFSET (DialogData, acoustic_apply_settings_switch), "acoustic-apply-settings-switch"},
-  {G_STRUCT_OFFSET (DialogData, acoustic_settings_box), "acoustic-settings-box"},
+  /* AAM */
   {G_STRUCT_OFFSET (DialogData, aam_box), "aam-box"},
-  {G_STRUCT_OFFSET (DialogData, aam_adjustment), "aam-adjustment"},
+  {G_STRUCT_OFFSET (DialogData, aam_switch), "aam-switch"},
+  {G_STRUCT_OFFSET (DialogData, aam_widgets_box), "aam-widgets-box"},
+  {G_STRUCT_OFFSET (DialogData, aam_value_label), "aam-value-label"},
   {G_STRUCT_OFFSET (DialogData, aam_scale), "aam-scale"},
-  {G_STRUCT_OFFSET (DialogData, aam_disable_checkbutton), "aam-disable-checkbutton"},
+  {G_STRUCT_OFFSET (DialogData, aam_adjustment), "aam-adjustment"},
 
   {0, NULL}
 };
 
 static void update_dialog (DialogData *data);
+static void update_standby_label (DialogData *data);
+static void update_apm_label (DialogData *data);
+static void update_aam_label (DialogData *data);
 
-static void disable_unused_pages (DialogData *data);
+static void disable_unused_widgets (DialogData *data);
 
 /* ---------------------------------------------------------------------------------------------------- */
 
@@ -179,34 +184,36 @@ compute_configuration (DialogData *data)
         }
     }
 
-  /* Power Management page */
-  if (gtk_switch_get_active (GTK_SWITCH (data->pm_apply_settings_switch)))
+  /* Standby */
+  if (gtk_switch_get_active (GTK_SWITCH (data->standby_switch)))
     {
-      gint ata_pm_standby = 0;
-      gint ata_apm_level = 255;
-
-      if (!gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (data->standby_disable_checkbutton)))
-        ata_pm_standby = (gint) gtk_adjustment_get_value (data->standby_adjustment);
-
-      if (!gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (data->apm_disable_checkbutton)))
-        ata_apm_level = (gint) gtk_adjustment_get_value (data->apm_adjustment);
-
       if (udisks_drive_ata_get_pm_supported (data->ata))
-        g_variant_builder_add (&builder, "{sv}", "ata-pm-standby", g_variant_new_int32 (ata_pm_standby));
-      if (udisks_drive_ata_get_apm_supported (data->ata))
-        g_variant_builder_add (&builder, "{sv}", "ata-apm-level", g_variant_new_int32 (ata_apm_level));
+        {
+          gint value = (gint) gtk_adjustment_get_value (data->standby_adjustment);
+          g_variant_builder_add (&builder, "{sv}", "ata-pm-standby", g_variant_new_int32 (value));
+        }
     }
 
-  /* Acoustic page */
-  if (gtk_switch_get_active (GTK_SWITCH (data->acoustic_apply_settings_switch)))
+  /* APM */
+  if (gtk_switch_get_active (GTK_SWITCH (data->apm_switch)))
     {
-      gint ata_aam_level = 0;
-
-      if (!gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (data->aam_disable_checkbutton)))
-        ata_aam_level = (gint) gtk_adjustment_get_value (data->aam_adjustment);
+      if (udisks_drive_ata_get_pm_supported (data->ata))
+        {
+          gint value = (gint) gtk_adjustment_get_value (data->apm_adjustment);
+          g_variant_builder_add (&builder, "{sv}", "ata-apm-level", g_variant_new_int32 (value));
+        }
+    }
 
-      if (udisks_drive_ata_get_aam_supported (data->ata))
-        g_variant_builder_add (&builder, "{sv}", "ata-aam-level", g_variant_new_int32 (ata_aam_level));
+  /* AAM */
+  if (gtk_switch_get_active (GTK_SWITCH (data->aam_switch)))
+    {
+      if (udisks_drive_ata_get_pm_supported (data->ata))
+        {
+          gint value = (gint) gtk_adjustment_get_value (data->aam_adjustment);
+          if (value < 128)
+            value = 0;
+          g_variant_builder_add (&builder, "{sv}", "ata-aam-level", g_variant_new_int32 (value));
+        }
     }
 
   return g_variant_builder_end (&builder);
@@ -240,6 +247,12 @@ update_dialog (DialogData *data)
     changed = TRUE;
   g_variant_unref (new_drive_configuration);
   gtk_dialog_set_response_sensitive (GTK_DIALOG (data->dialog), GTK_RESPONSE_OK, changed);
+
+  /* update labels */
+
+  update_standby_label (data);
+  update_apm_label (data);
+  update_aam_label (data);
 }
 
 static void
@@ -253,94 +266,86 @@ on_property_changed (GObject     *object,
 
 /* ---------------------------------------------------------------------------------------------------- */
 
-static gchar *
-on_apm_scale_format_value (GtkScale *scale,
-                           gdouble   value,
-                           gpointer  user_data)
+static void
+update_standby_label (DialogData *data)
 {
-  DialogData *data = user_data;
-  gchar *ret = NULL;
+  gint value;
+  gchar *s = NULL;
 
-  if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (data->apm_disable_checkbutton)))
+  value = gtk_adjustment_get_value (data->standby_adjustment);
+  if (value == 0)
     {
-      ret = g_strdup (C_("apm-level", "Disabled"));
+      s = g_strdup (C_("standby-value", "Never"));
     }
-  else if (value <= 127)
+  else if (value < 241)
     {
-      ret = g_strdup_printf (C_("apm-level", "%d (Spin-down permitted)"), (gint) value);
+      s = gdu_utils_format_duration_msec (value * 5 * 1000);
     }
-  else
+  else if (value < 252)
     {
-      ret = g_strdup_printf (C_("apm-level", "%d (Spin-down not permitted)"), (gint) value);
+      s = gdu_utils_format_duration_msec ((value - 240) * 30 * 60 * 1000);
     }
-
-  return ret;
-}
-
-/* ---------------------------------------------------------------------------------------------------- */
-
-static gchar *
-on_aam_scale_format_value (GtkScale *scale,
-                           gdouble   value,
-                           gpointer  user_data)
-{
-  DialogData *data = user_data;
-  gchar *ret = NULL;
-
-  if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (data->aam_disable_checkbutton)))
+  else if (value == 252)
     {
-      ret = g_strdup (C_("aam-level", "Disabled"));
+      s = gdu_utils_format_duration_msec (21 * 60 * 1000);
     }
-  else
+  else if (value == 253)
     {
-      ret = g_strdup_printf ("%d", (gint) value);
+      s = g_strdup (C_("standby-value", "Vendor-defined"));
     }
-
-  return ret;
+  else if (value == 254)
+    {
+      s = g_strdup (C_("standby-value", "Reserved"));
+    }
+  else if (value == 255)
+    {
+      s = gdu_utils_format_duration_msec ((21 * 60 + 15) * 1000);
+    }
+  gtk_label_set_text (GTK_LABEL (data->standby_value_label), s);
+  g_free (s);
 }
 
-/* ---------------------------------------------------------------------------------------------------- */
 
-static gchar *
-on_standby_scale_format_value (GtkScale *scale,
-                               gdouble   value,
-                               gpointer  user_data)
+static void
+update_apm_label (DialogData *data)
 {
-  DialogData *data = user_data;
-  gchar *ret = NULL;
+  gint value;
+  gchar *s = NULL;
 
-  value = floor (value);
-
-  if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (data->standby_disable_checkbutton)))
-    {
-      ret = g_strdup (C_("standby-value", "Disabled"));
-    }
-  else if (value < 241)
-    {
-      ret = gdu_utils_format_duration_msec (value * 5 * 1000);
-    }
-  else if (value < 252)
+  value = gtk_adjustment_get_value (data->apm_adjustment);
+  if (value == 255)
     {
-      ret = gdu_utils_format_duration_msec ((value - 240) * 30 * 60 * 1000);
+      s = g_strdup (C_("apm-level", "255 (Disabled)"));
     }
-  else if (value == 252)
+  else if (value <= 127)
     {
-      ret = gdu_utils_format_duration_msec (21 * 60 * 1000);
+      s = g_strdup_printf (C_("apm-level", "%d (Spin-down permitted)"), value);
     }
-  else if (value == 253)
+  else
     {
-      ret = g_strdup (C_("standby-value", "Vendor-defined"));
+      s = g_strdup_printf (C_("apm-level", "%d (Spin-down not permitted)"), value);
     }
-  else if (value == 254)
+  gtk_label_set_text (GTK_LABEL (data->apm_value_label), s);
+  g_free (s);
+}
+
+static void
+update_aam_label (DialogData *data)
+{
+  gint value;
+  gchar *s = NULL;
+
+  value = gtk_adjustment_get_value (data->aam_adjustment);
+  if (value == 127)
     {
-      ret = g_strdup (C_("standby-value", "Reserved"));
+      s = g_strdup (C_("aam-level", "0 (Disabled)"));
     }
-  else if (value == 255)
+  else
     {
-      ret = gdu_utils_format_duration_msec ((21 * 60 + 15) * 1000);
+      s = g_strdup_printf ("%d", value);
     }
-
-  return ret;
+  gtk_label_set_text (GTK_LABEL (data->aam_value_label), s);
+  g_free (s);
 }
 
 /* ---------------------------------------------------------------------------------------------------- */
@@ -388,7 +393,7 @@ gdu_disk_settings_dialog_show (GduWindow    *window,
   guint n;
   Mark standby_marks[5] = {
     /* Translators: This is a mark on the Standby scale. The string should be as short as possible */
-    { 12.0, N_("1 minute")},
+    { 0.0, N_("Never")},
     /* Translators: This is a mark on the Standby scale. The string should be as short as possible */
     { 60.0, N_("5 minutes")},
     /* Translators: This is a mark on the Standby scale. The string should be as short as possible */
@@ -400,17 +405,17 @@ gdu_disk_settings_dialog_show (GduWindow    *window,
   };
   Mark apm_marks[3] = {
     /* Translators: This is a mark on the APM scale. The string should be as short as possible */
-    {  1.0, N_("Power Savings")},
+    {  1.0, N_("Save Power")},
     /* Translators: This is a mark on the APM scale. The string should be as short as possible. The left arrow ("â") is to signify that the left part of the scale offers spindown. In RTL locales, please use a right arrow ("â") instead. */
     {127.0, N_("â Spindown")},
     /* Translators: This is a mark on the APM scale. The string should be as short as possible */
-    {254.0, N_("Performance")}
+    {254.0, N_("Perform Better")},
   };
   Mark aam_marks[2] = {
     /* Translators: This is a mark on the AAM scale. The string should be as short as possible */
-    {128.0, N_("Quiet")},
+    {128.0, N_("Quiet (Slow)")},
     /* Translators: This is a mark on the AAM scale. The string should be as short as possible */
-    {254.0, N_("Loud")}
+    {254.0, N_("Loud (Fast)")}
   };
 
   data = g_new0 (DialogData, 1);
@@ -454,119 +459,98 @@ gdu_disk_settings_dialog_show (GduWindow    *window,
       g_free (s);
     }
 
+#if 0
   g_signal_connect (data->standby_scale, "format-value", G_CALLBACK (on_standby_scale_format_value), data);
   g_signal_connect (data->apm_scale, "format-value", G_CALLBACK (on_apm_scale_format_value), data);
   g_signal_connect (data->aam_scale, "format-value", G_CALLBACK (on_aam_scale_format_value), data);
+#endif
 
   gtk_window_set_transient_for (GTK_WINDOW (data->dialog), GTK_WINDOW (window));
 
-  disable_unused_pages (data);
+  disable_unused_widgets (data);
 
   /* initialize dialog with values from current configuration */
   if (data->orig_drive_configuration != NULL)
     {
-      gint ata_pm_standby = -1;
-      gint ata_apm_level = -1;
-      gint ata_aam_level = -1;
+      gint standby_value = -1;
+      gint apm_value = -1;
+      gint aam_value = -1;
 
       /* Power Management page */
-      g_variant_lookup (data->orig_drive_configuration, "ata-pm-standby", "i", &ata_pm_standby);
-      g_variant_lookup (data->orig_drive_configuration, "ata-apm-level", "i", &ata_apm_level);
-      if (ata_pm_standby == -1 && ata_apm_level == -1)
+      g_variant_lookup (data->orig_drive_configuration, "ata-pm-standby", "i", &standby_value);
+      g_variant_lookup (data->orig_drive_configuration, "ata-apm-level", "i", &apm_value);
+      g_variant_lookup (data->orig_drive_configuration, "ata-aam-level", "i", &aam_value);
+
+      /* Standby (default to 10 minutes -> 120) */
+      if (standby_value == -1)
+        {
+          gtk_switch_set_active (GTK_SWITCH (data->standby_switch), FALSE);
+          gtk_adjustment_set_value (data->standby_adjustment, 120);
+        }
+      else
+        {
+          gtk_adjustment_set_value (data->standby_adjustment, standby_value);
+          gtk_switch_set_active (GTK_SWITCH (data->standby_switch), TRUE);
+        }
+
+      /* APM (default to 127) */
+      if (apm_value == -1)
         {
-          /* No settings at all, set Switch to OFF and chose some good defaults */
-          gtk_switch_set_active (GTK_SWITCH (data->pm_apply_settings_switch), FALSE);
-          gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (data->standby_disable_checkbutton), FALSE);
-          gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (data->apm_disable_checkbutton), FALSE);
-          gtk_adjustment_set_value (data->standby_adjustment, 180);
+          gtk_switch_set_active (GTK_SWITCH (data->apm_switch), FALSE);
           gtk_adjustment_set_value (data->apm_adjustment, 127);
         }
       else
         {
-          /* Set "Disable" buttons as appropriate and set slider values to something reasonable */
-          if (ata_pm_standby == 0 || ata_pm_standby == -1)
-            {
-              ata_pm_standby = 180;
-              gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (data->standby_disable_checkbutton), TRUE);
-            }
-          if (ata_apm_level == 255 || ata_apm_level == -1)
-            {
-              ata_apm_level = 127;
-              gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (data->apm_disable_checkbutton), TRUE);
-            }
-          gtk_adjustment_set_value (data->standby_adjustment, ata_pm_standby);
-          gtk_adjustment_set_value (data->apm_adjustment, ata_apm_level);
-          gtk_switch_set_active (GTK_SWITCH (data->pm_apply_settings_switch), TRUE);
+          gtk_adjustment_set_value (data->apm_adjustment, apm_value);
+          gtk_switch_set_active (GTK_SWITCH (data->apm_switch), TRUE);
         }
 
-      /* Acoustic page */
-      g_variant_lookup (data->orig_drive_configuration, "ata-aam-level", "i", &ata_aam_level);
-      if (ata_aam_level == -1)
+      /* AAM (default to 128) */
+      if (aam_value == -1)
         {
-          /* No settings at all, set Switch to OFF and chose some good defaults */
-          gtk_switch_set_active (GTK_SWITCH (data->acoustic_apply_settings_switch), FALSE);
-          gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (data->aam_disable_checkbutton), FALSE);
+          gtk_switch_set_active (GTK_SWITCH (data->aam_switch), FALSE);
           gtk_adjustment_set_value (data->aam_adjustment, 128);
         }
       else
         {
-          /* Set "Disable" buttons as appropriate and set slider values to something reasonable */
-          if (ata_aam_level == 0 || ata_aam_level == -1)
-            {
-              ata_aam_level = 128;
-              gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (data->aam_disable_checkbutton), TRUE);
-            }
-          gtk_adjustment_set_value (data->aam_adjustment, ata_aam_level);
-          gtk_switch_set_active (GTK_SWITCH (data->acoustic_apply_settings_switch), TRUE);
+          if (aam_value < 128)
+            aam_value = 127;
+          gtk_adjustment_set_value (data->aam_adjustment, aam_value);
+          gtk_switch_set_active (GTK_SWITCH (data->aam_switch), TRUE);
         }
     }
 
-  g_signal_connect (data->pm_apply_settings_switch,
+  g_signal_connect (data->standby_switch,
+                    "notify::active", G_CALLBACK (on_property_changed), data);
+  g_signal_connect (data->apm_switch,
                     "notify::active", G_CALLBACK (on_property_changed), data);
-  g_signal_connect (data->acoustic_apply_settings_switch,
+  g_signal_connect (data->aam_switch,
                     "notify::active", G_CALLBACK (on_property_changed), data);
+
   g_signal_connect (data->standby_adjustment,
                     "notify::value", G_CALLBACK (on_property_changed), data);
-  g_signal_connect (data->standby_disable_checkbutton,
-                    "notify::active", G_CALLBACK (on_property_changed), data);
   g_signal_connect (data->apm_adjustment,
                     "notify::value", G_CALLBACK (on_property_changed), data);
-  g_signal_connect (data->apm_disable_checkbutton,
-                    "notify::active", G_CALLBACK (on_property_changed), data);
   g_signal_connect (data->aam_adjustment,
                     "notify::value", G_CALLBACK (on_property_changed), data);
-  g_signal_connect (data->aam_disable_checkbutton,
-                    "notify::active", G_CALLBACK (on_property_changed), data);
 
-  g_object_bind_property (data->pm_apply_settings_switch,
+  g_object_bind_property (data->standby_switch,
                           "active",
-                          data->pm_settings_box,
+                          data->standby_widgets_box,
                           "sensitive",
                           G_BINDING_SYNC_CREATE);
 
-  g_object_bind_property (data->acoustic_apply_settings_switch,
+  g_object_bind_property (data->apm_switch,
                           "active",
-                          data->acoustic_settings_box,
+                          data->apm_widgets_box,
                           "sensitive",
                           G_BINDING_SYNC_CREATE);
 
-  g_object_bind_property (data->standby_disable_checkbutton,
-                          "active",
-                          data->standby_scale,
-                          "sensitive",
-                          G_BINDING_SYNC_CREATE|G_BINDING_INVERT_BOOLEAN);
-
-  g_object_bind_property (data->apm_disable_checkbutton,
-                          "active",
-                          data->apm_scale,
-                          "sensitive",
-                          G_BINDING_SYNC_CREATE|G_BINDING_INVERT_BOOLEAN);
-
-  g_object_bind_property (data->aam_disable_checkbutton,
+  g_object_bind_property (data->aam_switch,
                           "active",
-                          data->aam_scale,
+                          data->aam_widgets_box,
                           "sensitive",
-                          G_BINDING_SYNC_CREATE|G_BINDING_INVERT_BOOLEAN);
+                          G_BINDING_SYNC_CREATE);
 
   update_dialog (data);
 
@@ -605,24 +589,18 @@ hide_forever (GtkWidget *widget)
 }
 
 static void
-disable_unused_pages (DialogData *data)
+disable_unused_widgets (DialogData *data)
 {
-  /* Disable pages (and parts of pages) not relevant for a drive - see also gdu_disk_settings_dialog_should_show() */
+  /* Disable widgets not relevant for a drive - see also gdu_disk_settings_dialog_should_show() */
 
-  if (!(udisks_drive_ata_get_pm_supported (data->ata) || udisks_drive_ata_get_apm_supported (data->ata)))
-    {
-      hide_forever (data->pm_page);
-    }
-  else
-    {
-      if (!udisks_drive_ata_get_pm_supported (data->ata))
-        hide_forever (data->standby_box);
-      if (!udisks_drive_ata_get_apm_supported (data->ata))
-        hide_forever (data->apm_box);
-    }
+  if (!udisks_drive_ata_get_pm_supported (data->ata))
+    hide_forever (data->standby_box);
+
+  if (!udisks_drive_ata_get_apm_supported (data->ata))
+    hide_forever (data->apm_box);
 
   if (!udisks_drive_ata_get_aam_supported (data->ata))
-    hide_forever (data->acoustic_page);
+    hide_forever (data->aam_box);
 }
 
 gboolean
@@ -634,7 +612,7 @@ gdu_disk_settings_dialog_should_show (UDisksObject *object)
 
   g_return_val_if_fail (UDISKS_IS_OBJECT (object), FALSE);
 
-  /* see also disabled_unused_pages() above */
+  /* see also disabled_unused_widgets() above */
 
   drive = udisks_object_peek_drive (object);
   if (drive == NULL)



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