From 4f64141c0c14e8ac6894a2d20a0c9dae58cbcab6 Mon Sep 17 00:00:00 2001
From: David Lehman <dlehman@redhat.com>
Date: Wed, 4 Jan 2012 11:43:32 -0600
Subject: [PATCH 9/9] Add handling for custom checkbox and fixups requested by
 clumens.

---
 pyanaconda/ui/gui/spokes/storage.py |   26 ++++--
 pyanaconda/ui/gui/spokes/storage.ui |  197 ++++++++++++++++++++---------------
 2 files changed, 134 insertions(+), 89 deletions(-)

diff --git a/pyanaconda/ui/gui/spokes/storage.py b/pyanaconda/ui/gui/spokes/storage.py
index b140b6e..d7972be 100644
--- a/pyanaconda/ui/gui/spokes/storage.py
+++ b/pyanaconda/ui/gui/spokes/storage.py
@@ -239,8 +239,8 @@ class InstallOptions1Dialog(UIObject):
 
     def setup(self, required_space, disk_free, fs_free):
         custom = not self.data.autopart.autopart
-        custom_checkbutton = self.builder.get_object("options1_custom_check")
-        custom_checkbutton.set_active(custom)
+        self.custom_checkbutton = self.builder.get_object("options1_custom_check")
+        self.custom_checkbutton.set_active(custom)
 
         options_label = self.builder.get_object("options1_label")
 
@@ -264,6 +264,13 @@ class InstallOptions1Dialog(UIObject):
                    % (productName, required_space_text))
         return sw_text
 
+    @property
+    def customize_state(self):
+        if hasattr(self, "custom_checkbutton"):
+            return self.custom_checkbutton.get_active()
+
+        return False
+
     # signal handlers
     def on_cancel_clicked(self, button):
         # return to the spoke without making any changes
@@ -290,8 +297,8 @@ class InstallOptions2Dialog(InstallOptions1Dialog):
 
     def setup(self, required_space, disk_free, fs_free):
         custom = not self.data.autopart.autopart
-        custom_checkbutton = self.builder.get_object("options2_custom_check")
-        custom_checkbutton.set_active(custom)
+        self.custom_checkbutton = self.builder.get_object("options2_custom_check")
+        self.custom_checkbutton.set_active(custom)
 
         sw_text = self._get_sw_needs_text(required_space)
         label_text = _("%s\nThe disks you've selected have the following "
@@ -308,6 +315,11 @@ class InstallOptions2Dialog(InstallOptions1Dialog):
                       % productName)
         self.builder.get_object("options2_label2").set_markup(label_text)
 
+    def on_custom_toggled(self, checkbutton):
+        custom = checkbutton.get_active()
+        self.builder.get_object("options2_cancel_button").set_sensitive(not custom)
+        self.builder.get_object("options2_modify_sw_button").set_sensitive(not custom)
+
 class InstallOptions3Dialog(InstallOptions1Dialog):
     builderObjects = ["options3_dialog"]
     mainWidgetName = "options3_dialog"
@@ -357,7 +369,7 @@ class StorageSpoke(NormalSpoke):
             msg = "%d disks selected" % len(self.data.ignoredisk.onlyuse)
 
             if self.data.autopart.autopart:
-                msg = "automatic partitioning selected"
+                msg = "Automatic partitioning selected"
 
                 # if we had a storage instance we could check for a defined root
 
@@ -475,7 +487,7 @@ class StorageSpoke(NormalSpoke):
         # show the installation options dialog
         disks = [d for d in self.disks if d.name in self.data.ignoredisk.onlyuse]
         (disk_free, fs_free) = get_free_space_info(disks, self.devicetree)
-        required_space = 10000      # TODO: find out where to get this
+        required_space = 16000      # TODO: find out where to get this
         if disk_free >= required_space:
             dialog = InstallOptions1Dialog(self.data)
         elif disk_free + fs_free >= required_space:
@@ -488,7 +500,7 @@ class StorageSpoke(NormalSpoke):
         if rc == dialog.RESPONSE_CONTINUE:
             # depending on custom/autopart, either set up autopart or show
             # custom partitioning ui
-            print "user chose to continue to partitioning"
+            print "user chose to continue to partitioning (custom is %s)" % dialog.customize_state
             Gtk.main_quit()
         elif rc == dialog.RESPONSE_CANCEL:
             # stay on this spoke
diff --git a/pyanaconda/ui/gui/spokes/storage.ui b/pyanaconda/ui/gui/spokes/storage.ui
index b4b6eca..7fb941e 100644
--- a/pyanaconda/ui/gui/spokes/storage.ui
+++ b/pyanaconda/ui/gui/spokes/storage.ui
@@ -40,6 +40,7 @@
                 <property name="visible">True</property>
                 <property name="can_focus">True</property>
                 <property name="receives_default">True</property>
+                <property name="halign">center</property>
                 <property name="border_width">6</property>
                 <property name="use_action_appearance">False</property>
                 <property name="use_underline">True</property>
@@ -58,6 +59,7 @@
                 <property name="visible">True</property>
                 <property name="can_focus">True</property>
                 <property name="receives_default">True</property>
+                <property name="halign">center</property>
                 <property name="border_width">6</property>
                 <property name="use_action_appearance">False</property>
                 <property name="use_underline">True</property>
@@ -116,12 +118,13 @@
             </child>
             <child>
               <object class="GtkCheckButton" id="options1_custom_check">
-                <property name="label" translatable="yes">Let me review &amp; customize the partitioning of the disks anyway.</property>
+                <property name="label" translatable="yes">Let me _review &amp; customize the partitioning of the disks anyway.</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>
@@ -154,6 +157,8 @@
     <property name="type">popup</property>
     <property name="modal">True</property>
     <property name="window_position">center-on-parent</property>
+    <property name="default_width">600</property>
+    <property name="default_height">400</property>
     <property name="destroy_with_parent">True</property>
     <property name="type_hint">dialog</property>
     <property name="mnemonics_visible">False</property>
@@ -172,6 +177,7 @@
                 <property name="visible">True</property>
                 <property name="can_focus">True</property>
                 <property name="receives_default">True</property>
+                <property name="halign">center</property>
                 <property name="border_width">6</property>
                 <property name="use_action_appearance">False</property>
                 <property name="use_underline">True</property>
@@ -190,6 +196,7 @@
                 <property name="visible">True</property>
                 <property name="can_focus">True</property>
                 <property name="receives_default">True</property>
+                <property name="halign">center</property>
                 <property name="border_width">6</property>
                 <property name="use_action_appearance">False</property>
                 <property name="use_underline">True</property>
@@ -204,11 +211,12 @@
             </child>
             <child>
               <object class="GtkButton" id="options2_reclaim_button">
-                <property name="label" translatable="yes">_Reclaim space</property>
+                <property name="label" translatable="yes">Reclaim _space</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="halign">center</property>
                 <property name="border_width">6</property>
                 <property name="use_action_appearance">False</property>
                 <property name="use_underline">True</property>
@@ -252,14 +260,16 @@
             </child>
             <child>
               <object class="GtkCheckButton" id="options2_custom_check">
-                <property name="label" translatable="yes">I don't need help; let me review &amp; customize disk partitioning to reclaim space.</property>
+                <property name="label" translatable="yes">I don't need help; let me _review &amp; customize disk partitioning to reclaim space.</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>
+                <signal name="toggled" handler="on_custom_toggled" swapped="no"/>
               </object>
               <packing>
                 <property name="expand">False</property>
@@ -423,11 +433,12 @@
             <property name="can_focus">False</property>
             <child>
               <object class="GtkButton" id="options3_quit_button">
-                <property name="label" translatable="yes">_Quit Installer</property>
+                <property name="label" translatable="yes">_Quit installer</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="halign">center</property>
                 <property name="border_width">6</property>
                 <property name="use_action_appearance">False</property>
                 <property name="use_underline">True</property>
@@ -446,6 +457,7 @@
                 <property name="visible">True</property>
                 <property name="can_focus">True</property>
                 <property name="receives_default">True</property>
+                <property name="halign">center</property>
                 <property name="border_width">6</property>
                 <property name="use_action_appearance">False</property>
                 <property name="use_underline">True</property>
@@ -465,6 +477,7 @@
                 <property name="visible">True</property>
                 <property name="can_focus">True</property>
                 <property name="receives_default">True</property>
+                <property name="halign">center</property>
                 <property name="border_width">6</property>
                 <property name="use_action_appearance">False</property>
                 <property name="use_underline">True</property>
@@ -514,7 +527,6 @@
                 <property name="xalign">0</property>
                 <property name="label" translatable="yes">Here we'll describe how much space is needed for the current software selection.</property>
                 <property name="use_markup">True</property>
-                <property name="max_width_chars">100</property>
               </object>
               <packing>
                 <property name="expand">False</property>
@@ -620,7 +632,6 @@
                 <property name="xalign">0</property>
                 <property name="label" translatable="yes">Here we'll describe what your options are.</property>
                 <property name="use_markup">True</property>
-                <property name="max_width_chars">100</property>
               </object>
               <packing>
                 <property name="expand">False</property>
@@ -671,6 +682,7 @@
                 <property name="visible">True</property>
                 <property name="can_focus">True</property>
                 <property name="receives_default">True</property>
+                <property name="halign">center</property>
                 <property name="use_action_appearance">False</property>
                 <property name="use_underline">True</property>
                 <signal name="clicked" handler="on_close_clicked" swapped="no"/>
@@ -701,6 +713,9 @@
                 <property name="can_focus">False</property>
                 <property name="xalign">0</property>
                 <property name="label" translatable="yes">SELECTED DISKS</property>
+                <attributes>
+                  <attribute name="weight" value="bold"/>
+                </attributes>
               </object>
               <packing>
                 <property name="expand">False</property>
@@ -788,6 +803,7 @@
                     <property name="visible">True</property>
                     <property name="can_focus">True</property>
                     <property name="receives_default">True</property>
+                    <property name="halign">center</property>
                     <property name="use_action_appearance">False</property>
                     <property name="use_underline">True</property>
                     <signal name="clicked" handler="on_remove_clicked" swapped="no"/>
@@ -844,80 +860,39 @@
     <property name="border_width">6</property>
     <property name="startup_id">filler</property>
     <property name="mnemonics_visible">False</property>
-    <child internal-child="action_area">
-      <object class="GtkBox" id="storageWindow-action_area1">
+    <child internal-child="main_box">
+      <object class="GtkBox" id="AnacondaSpokeWindow-main_box1">
         <property name="can_focus">False</property>
         <property name="orientation">vertical</property>
         <property name="spacing">6</property>
-        <child>
-          <object class="GtkBox" id="box1">
-            <property name="visible">True</property>
+        <child internal-child="nav_area">
+          <object class="GtkGrid" id="AnacondaSpokeWindow-nav_area1">
             <property name="can_focus">False</property>
-            <property name="border_width">6</property>
-            <property name="orientation">vertical</property>
-            <property name="spacing">6</property>
-            <child>
-              <object class="GtkLabel" id="label1">
-                <property name="visible">True</property>
-                <property name="can_focus">False</property>
-                <property name="xalign">0</property>
-                <property name="label" translatable="yes">LOCAL STANDARD DISKS</property>
-                <property name="track_visited_links">False</property>
-              </object>
-              <packing>
-                <property name="expand">False</property>
-                <property name="fill">True</property>
-                <property name="position">0</property>
-              </packing>
-            </child>
-            <child>
-              <object class="GtkScrolledWindow" id="scrolledwindow1">
-                <property name="visible">True</property>
-                <property name="can_focus">True</property>
-                <property name="vscrollbar_policy">never</property>
-                <property name="shadow_type">in</property>
-                <child>
-                  <object class="GtkViewport" id="viewport1">
-                    <property name="visible">True</property>
-                    <property name="can_focus">False</property>
-                    <child>
-                      <object class="GtkBox" id="local_disks_box">
-                        <property name="visible">True</property>
-                        <property name="can_focus">False</property>
-                        <property name="spacing">6</property>
-                        <property name="homogeneous">True</property>
-                        <child>
-                          <placeholder/>
-                        </child>
-                      </object>
-                    </child>
-                  </object>
-                </child>
-              </object>
-              <packing>
-                <property name="expand">False</property>
-                <property name="fill">True</property>
-                <property name="position">1</property>
-              </packing>
-            </child>
-            <child>
-              <object class="GtkBox" id="box2">
-                <property name="visible">True</property>
+          </object>
+          <packing>
+            <property name="expand">False</property>
+            <property name="fill">False</property>
+            <property name="position">0</property>
+          </packing>
+        </child>
+        <child internal-child="alignment">
+          <object class="GtkAlignment" id="AnacondaSpokeWindow-alignment1">
+            <property name="can_focus">False</property>
+            <property name="yalign">0</property>
+            <property name="xscale">0</property>
+            <property name="yscale">0.5</property>
+            <child internal-child="action_area">
+              <object class="GtkBox" id="storageWindow-action_area1">
                 <property name="can_focus">False</property>
+                <property name="orientation">vertical</property>
                 <property name="spacing">6</property>
                 <child>
-                  <object class="GtkButton" id="summary_button">
-                    <property name="label" translatable="yes">summary</property>
-                    <property name="use_action_appearance">False</property>
+                  <object class="GtkLabel" id="label1">
                     <property name="visible">True</property>
-                    <property name="can_focus">True</property>
-                    <property name="receives_default">True</property>
-                    <property name="use_action_appearance">False</property>
-                    <property name="relief">none</property>
-                    <property name="use_underline">True</property>
-                    <property name="focus_on_click">False</property>
+                    <property name="can_focus">False</property>
                     <property name="xalign">0</property>
-                    <signal name="clicked" handler="on_summary_clicked" swapped="no"/>
+                    <property name="label" translatable="yes">LOCAL STANDARD DISKS</property>
+                    <property name="track_visited_links">False</property>
                   </object>
                   <packing>
                     <property name="expand">False</property>
@@ -926,36 +901,94 @@
                   </packing>
                 </child>
                 <child>
-                  <object class="GtkButton" id="continue_button">
-                    <property name="label" translatable="yes">_Continue</property>
-                    <property name="use_action_appearance">False</property>
+                  <object class="GtkScrolledWindow" id="scrolledwindow1">
                     <property name="visible">True</property>
                     <property name="can_focus">True</property>
-                    <property name="receives_default">True</property>
-                    <property name="use_action_appearance">False</property>
-                    <property name="use_underline">True</property>
-                    <property name="xalign">1</property>
-                    <signal name="clicked" handler="on_continue_clicked" swapped="no"/>
+                    <property name="hexpand">True</property>
+                    <property name="vscrollbar_policy">never</property>
+                    <property name="shadow_type">in</property>
+                    <child>
+                      <object class="GtkViewport" id="viewport1">
+                        <property name="visible">True</property>
+                        <property name="can_focus">False</property>
+                        <child>
+                          <object class="GtkBox" id="local_disks_box">
+                            <property name="visible">True</property>
+                            <property name="can_focus">False</property>
+                            <property name="spacing">6</property>
+                            <property name="homogeneous">True</property>
+                            <child>
+                              <placeholder/>
+                            </child>
+                          </object>
+                        </child>
+                      </object>
+                    </child>
                   </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>
+            </child>
+          </object>
+          <packing>
+            <property name="expand">True</property>
+            <property name="fill">True</property>
+            <property name="position">3</property>
+          </packing>
+        </child>
+        <child>
+          <object class="GtkBox" id="box2">
+            <property name="visible">True</property>
+            <property name="can_focus">False</property>
+            <property name="spacing">6</property>
+            <child>
+              <object class="GtkButton" id="summary_button">
+                <property name="label" translatable="yes">summary</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>
+                <property name="relief">none</property>
+                <property name="use_underline">True</property>
+                <property name="focus_on_click">False</property>
+                <property name="xalign">0</property>
+                <signal name="clicked" handler="on_summary_clicked" swapped="no"/>
+              </object>
               <packing>
                 <property name="expand">False</property>
                 <property name="fill">True</property>
-                <property name="position">2</property>
+                <property name="position">0</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkButton" id="continue_button">
+                <property name="label" translatable="yes">_Continue</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>
+                <property name="use_underline">True</property>
+                <property name="xalign">1</property>
+                <signal name="clicked" handler="on_continue_clicked" swapped="no"/>
+              </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">1</property>
+            <property name="position">4</property>
           </packing>
         </child>
       </object>
-- 
1.7.8

