[PATCH 1/2] Tie "Reclaim Space" button sensitivity to how much space the user freed (#869375).

Chris Lumens clumens at redhat.com
Tue Oct 23 20:56:56 UTC 2012


---
 pyanaconda/ui/gui/spokes/lib/resize.glade | 1 +
 pyanaconda/ui/gui/spokes/lib/resize.py    | 9 ++++++++-
 2 files changed, 9 insertions(+), 1 deletion(-)

diff --git a/pyanaconda/ui/gui/spokes/lib/resize.glade b/pyanaconda/ui/gui/spokes/lib/resize.glade
index 15f90af..e3aa001 100644
--- a/pyanaconda/ui/gui/spokes/lib/resize.glade
+++ b/pyanaconda/ui/gui/spokes/lib/resize.glade
@@ -72,6 +72,7 @@
               <object class="GtkButton" id="resizeButton">
                 <property name="label" translatable="yes">_Reclaim space</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/lib/resize.py b/pyanaconda/ui/gui/spokes/lib/resize.py
index 3781807..19d16e3 100644
--- a/pyanaconda/ui/gui/spokes/lib/resize.py
+++ b/pyanaconda/ui/gui/spokes/lib/resize.py
@@ -61,6 +61,7 @@ class ResizeDialog(GUIObject):
     def __init__(self, data, storage, payload):
         GUIObject.__init__(self, data)
         self.storage = storage
+        self.payload = payload
 
         self._actionStore = self.builder.get_object("actionStore")
         self._diskStore = self.builder.get_object("diskStore")
@@ -72,10 +73,12 @@ class ResizeDialog(GUIObject):
 
         self._required_label = self.builder.get_object("requiredSpaceLabel")
         markup = self._required_label.get_label()
-        self._required_label.set_markup(markup % size_str(payload.spaceRequired))
+        self._required_label.set_markup(markup % size_str(self.payload.spaceRequired))
 
         self._reclaimDescLabel = self.builder.get_object("reclaimDescLabel")
 
+        self._resizeButton = self.builder.get_object("resizeButton")
+
     def _description(self, part):
         # First, try to find the partition in some known Root.  If we find
         # it, return the mountpoint as the description.
@@ -224,6 +227,10 @@ class ResizeDialog(GUIObject):
         self._diskStore.foreach(self._sumReclaimableSpace, None)
         self._update_labels(selectedReclaimable=self._selectedReclaimableSpace)
 
+        got = Size(spec="%s MB" % self._selectedReclaimableSpace)
+        need = self.payload.spaceRequired
+        self._resizeButton.set_sensitive(got >= need)
+
     def _scheduleActions(self, model, path, itr, *args):
         (editable, action, ident) = model.get(itr, EDITABLE_COL, ACTION_COL, DEVICE_ID_COL)
 
-- 
1.7.11.2



More information about the anaconda-patches mailing list