[PATCH] Round float values coming from the Gtk stack (#1034232)

Vratislav Podzimek vpodzime at redhat.com
Tue Nov 26 08:25:01 UTC 2013


When we put some float value to a TreeStore or when we ask some widget for
a float value it is C-style float with a lot of digits causing problems in our
arithmetics. Since we probably don't have to care about hundredths of megabytes,
we can safely round those values.

Signed-off-by: Vratislav Podzimek <vpodzime at redhat.com>
---
 pyanaconda/ui/gui/spokes/lib/resize.py | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/pyanaconda/ui/gui/spokes/lib/resize.py b/pyanaconda/ui/gui/spokes/lib/resize.py
index 041c8ca..aebe526 100644
--- a/pyanaconda/ui/gui/spokes/lib/resize.py
+++ b/pyanaconda/ui/gui/spokes/lib/resize.py
@@ -439,14 +439,14 @@ class ResizeDialog(GUIObject):
     def on_resize_value_changed(self, rng):
         (model, itr) = self._selection.get_selected()
 
-        old_delta = rng.get_adjustment().get_upper()-model[itr][RESIZE_TARGET_COL]
+        old_delta = rng.get_adjustment().get_upper()- round(model[itr][RESIZE_TARGET_COL], 2)
         self._selectedReclaimableSpace -= old_delta
 
         # Update the target size in the store.
-        model[itr][RESIZE_TARGET_COL] = rng.get_value()
+        model[itr][RESIZE_TARGET_COL] = round(rng.get_value(), 2)
 
         # Update the "Total selected space" label.
-        delta = rng.get_adjustment().get_upper()-rng.get_value()
+        delta = rng.get_adjustment().get_upper() - round(rng.get_value(), 2)
         self._selectedReclaimableSpace += delta
         self._update_labels(selectedReclaimable=self._selectedReclaimableSpace)
 
-- 
1.8.4.2



More information about the anaconda-patches mailing list