[PATCH] The Update Settings button should only be sensitive if you change something.

Chris Lumens clumens at redhat.com
Mon Apr 1 15:28:49 UTC 2013


This won't catch all cases.  For instance, if you change a value and then
change it back to the original, the button will still be marked sensitive.
I think how it works now is probably good enough for most people.
---
 pyanaconda/ui/gui/spokes/custom.glade | 11 +++++++++++
 pyanaconda/ui/gui/spokes/custom.py    | 10 ++++++++++
 2 files changed, 21 insertions(+)

diff --git a/pyanaconda/ui/gui/spokes/custom.glade b/pyanaconda/ui/gui/spokes/custom.glade
index 258e473..98f4911 100644
--- a/pyanaconda/ui/gui/spokes/custom.glade
+++ b/pyanaconda/ui/gui/spokes/custom.glade
@@ -587,6 +587,7 @@ use.  Try something else?</property>
                                     <property name="hexpand">True</property>
                                     <property name="invisible_char">●</property>
                                     <property name="completion">mountPointCompletion</property>
+                                    <signal name="changed" handler="on_value_changed" swapped="no"/>
                                   </object>
                                   <packing>
                                     <property name="left_attach">1</property>
@@ -618,6 +619,7 @@ use.  Try something else?</property>
                                     <property name="can_focus">True</property>
                                     <property name="hexpand">True</property>
                                     <property name="invisible_char">●</property>
+                                    <signal name="changed" handler="on_value_changed" swapped="no"/>
                                   </object>
                                   <packing>
                                     <property name="left_attach">1</property>
@@ -650,6 +652,7 @@ use.  Try something else?</property>
                                     <property name="visible">True</property>
                                     <property name="can_focus">True</property>
                                     <property name="invisible_char">●</property>
+                                    <signal name="changed" handler="on_value_changed" swapped="no"/>
                                   </object>
                                   <packing>
                                     <property name="left_attach">1</property>
@@ -683,6 +686,7 @@ use.  Try something else?</property>
                                     <property name="halign">start</property>
                                     <property name="invisible_char">●</property>
                                     <property name="width_chars">10</property>
+                                    <signal name="changed" handler="on_value_changed" swapped="no"/>
                                   </object>
                                   <packing>
                                     <property name="left_attach">1</property>
@@ -745,6 +749,7 @@ use.  Try something else?</property>
                                           <item translatable="yes">RAID</item>
                                         </items>
                                         <signal name="changed" handler="on_device_type_changed" swapped="no"/>
+                                        <signal name="changed" handler="on_value_changed" swapped="no"/>
                                       </object>
                                       <packing>
                                         <property name="left_attach">1</property>
@@ -761,6 +766,7 @@ use.  Try something else?</property>
                                         <property name="entry_text_column">0</property>
                                         <property name="id_column">1</property>
                                         <signal name="changed" handler="on_fs_type_changed" swapped="no"/>
+                                        <signal name="changed" handler="on_value_changed" swapped="no"/>
                                       </object>
                                       <packing>
                                         <property name="left_attach">1</property>
@@ -779,6 +785,7 @@ use.  Try something else?</property>
                                         <property name="use_underline">True</property>
                                         <property name="xalign">0</property>
                                         <property name="draw_indicator">True</property>
+                                        <signal name="toggled" handler="on_value_changed" swapped="no"/>
                                       </object>
                                       <packing>
                                         <property name="left_attach">2</property>
@@ -797,6 +804,7 @@ use.  Try something else?</property>
                                         <property name="xalign">0</property>
                                         <property name="draw_indicator">True</property>
                                         <signal name="toggled" handler="on_reformat_toggled" swapped="no"/>
+                                        <signal name="toggled" handler="on_value_changed" swapped="no"/>
                                       </object>
                                       <packing>
                                         <property name="left_attach">2</property>
@@ -831,6 +839,7 @@ use.  Try something else?</property>
                                         <property name="entry_text_column">0</property>
                                         <property name="id_column">1</property>
                                         <signal name="changed" handler="on_vg_changed" swapped="no"/>
+                                        <signal name="changed" handler="on_value_changed" swapped="no"/>
                                       </object>
                                       <packing>
                                         <property name="left_attach">1</property>
@@ -878,6 +887,7 @@ use.  Try something else?</property>
                                         <property name="visible">True</property>
                                         <property name="can_focus">False</property>
                                         <property name="model">raidStoreFiltered</property>
+                                        <signal name="changed" handler="on_value_changed" swapped="no"/>
                                         <child>
                                           <object class="GtkCellRendererText" id="raidLevelRenderer"/>
                                           <attributes>
@@ -914,6 +924,7 @@ use.  Try something else?</property>
                               <object class="GtkButton" id="applyButton">
                                 <property name="label" translatable="yes">_Update Settings</property>
                                 <property name="visible">True</property>
+                                <property name="sensitive">False</property>
                                 <property name="can_focus">True</property>
                                 <property name="receives_default">True</property>
                                 <property name="halign">end</property>
diff --git a/pyanaconda/ui/gui/spokes/custom.py b/pyanaconda/ui/gui/spokes/custom.py
index 0229350..4d0a1ec 100644
--- a/pyanaconda/ui/gui/spokes/custom.py
+++ b/pyanaconda/ui/gui/spokes/custom.py
@@ -505,6 +505,8 @@ class CustomPartitioningSpoke(NormalSpoke, StorageChecker):
         self._reformatCheckbox = self.builder.get_object("reformatCheckbox")
         self._sizeEntry = self.builder.get_object("sizeEntry")
 
+        self._applyButton = self.builder.get_object("applyButton")
+
     def initialize(self):
         NormalSpoke.initialize(self)
 
@@ -649,6 +651,7 @@ class CustomPartitioningSpoke(NormalSpoke, StorageChecker):
         self._setCurrentFreeSpace()
 
         self._updateSpaceDisplay()
+        self._applyButton.set_sensitive(False)
 
     @property
     def translated_new_install_name(self):
@@ -778,6 +781,8 @@ class CustomPartitioningSpoke(NormalSpoke, StorageChecker):
         self._accordion.expandPage(firstPage.pageTitle)
         self.on_page_clicked(firstPage, mountpointToShow=mountpointToShow)
 
+        self._applyButton.set_sensitive(False)
+
     ###
     ### RIGHT HAND SIDE METHODS
     ###
@@ -2111,6 +2116,7 @@ class CustomPartitioningSpoke(NormalSpoke, StorageChecker):
         selector.set_chosen(True)
         self._current_selector = selector
 
+        self._applyButton.set_sensitive(False)
         self._configButton.set_sensitive(not selector._device.exists and
                                          not selector._device.protected and
                                          devicefactory.get_device_type(selector._device) != DEVICE_TYPE_LVM)
@@ -2414,6 +2420,7 @@ class CustomPartitioningSpoke(NormalSpoke, StorageChecker):
     def on_apply_clicked(self, button):
         """ call _save_right_side, then, perhaps, populate_right_side. """
         self._save_right_side(self._current_selector)
+        self._applyButton.set_sensitive(False)
 
     def on_unlock_clicked(self, button):
         """ try to open the luks device, populate, then call _do_refresh. """
@@ -2455,6 +2462,9 @@ class CustomPartitioningSpoke(NormalSpoke, StorageChecker):
         self._current_selector = None
         self._do_refresh()
 
+    def on_value_changed(self, *args):
+        self._applyButton.set_sensitive(True)
+
 help_text_template = N_("""You have chosen to manually set up the filesystems for your new %(productName)s installation. Before you begin, you might want to take a minute to learn the lay of the land. Quite a bit has changed.
 
 The most important change is that creation of new filesystems has been streamlined. You no longer have to build complex devices like LVM logical volumes in stages (physical volume, then volume group, then logical volume) -- now you just create a logical volume and we'll handle the legwork of setting up the physical volumes and volume group to contain it. We'll also handle adjusting the volume group as you add, remove, and resize logical volumes so you don't have to worry about the mundane details.
-- 
1.8.1.2



More information about the anaconda-patches mailing list