diff options
author | David Cantrell <dcantrell@redhat.com> | 2009-03-27 14:58:00 -1000 |
---|---|---|
committer | David Cantrell <dcantrell@redhat.com> | 2009-03-30 09:42:55 -1000 |
commit | cdaa2c6fabcf2976a647c94c738094ad1ee831c7 (patch) | |
tree | 4f1713860879c6b15d86206e69042511259998ae /iw | |
parent | cf8fc45b423d10ddabc20843a283ef2e304ca5a9 (diff) | |
download | anaconda-cdaa2c6fabcf2976a647c94c738094ad1ee831c7.tar.gz anaconda-cdaa2c6fabcf2976a647c94c738094ad1ee831c7.tar.xz anaconda-cdaa2c6fabcf2976a647c94c738094ad1ee831c7.zip |
Correct bounds checking problems in 'Shrink current system'
The 'Shrink current system' dialog had some bounds checking problems.
Users could enter a size that was too small or too large.
Renamed the function and related controls to use 'shrink' instead of
'resize' in the name to better reflect what the code does.
Use the format's size to set the bounds rather than the partition's.
Since we are shrinking here, we only want to let users select a size
smaller than the current format size.
A size smaller than the minimum will automatically be set to the correct
minimum. Likewise, a size larger than the maximum will automatically be
set to the correct maximum.
Diffstat (limited to 'iw')
-rw-r--r-- | iw/autopart_type.py | 26 |
1 files changed, 12 insertions, 14 deletions
diff --git a/iw/autopart_type.py b/iw/autopart_type.py index 6bbca11b9..18b5ccaf5 100644 --- a/iw/autopart_type.py +++ b/iw/autopart_type.py @@ -37,42 +37,40 @@ from storage.deviceaction import * import gettext _ = lambda x: gettext.ldgettext("anaconda", x) -def whichToResize(storage, intf): +def whichToShrink(storage, intf): def getActive(combo): act = combo.get_active_iter() return combo.get_model().get_value(act, 1) - def comboCB(combo, resizeSB): + def comboCB(combo, shrinkSB): # partition to resize changed, let's update our spinbutton + newSize = shrinkSB.get_value_as_int() + part = getActive(combo) - reqlower = part.minSize - requpper = part.maxSize + reqlower = long(math.ceil(part.format.minSize)) + requpper = long(math.floor(part.format.currentSize)) - adj = resizeSB.get_adjustment() + adj = shrinkSB.get_adjustment() adj.lower = reqlower adj.upper = requpper - adj.value = reqlower adj.set_value(reqlower) - (dxml, dialog) = gui.getGladeWidget("autopart.glade", "resizeDialog") + (dxml, dialog) = gui.getGladeWidget("autopart.glade", "shrinkDialog") store = gtk.TreeStore(gobject.TYPE_STRING, gobject.TYPE_PYOBJECT) - combo = dxml.get_widget("resizePartCombo") + combo = dxml.get_widget("shrinkPartCombo") combo.set_model(store) crt = gtk.CellRendererText() combo.pack_start(crt, True) combo.set_attributes(crt, text = 0) - combo.connect("changed", comboCB, dxml.get_widget("resizeSB")) + combo.connect("changed", comboCB, dxml.get_widget("shrinkSB")) biggest = -1 for part in storage.partitions: if not part.exists: continue - # Resize the following storage types: - # resizable filesystem (e.g., ext3 or ntfs) on resizable partition - # resizable filesystem on a resizable logical volume entry = None if part.resizable and part.format.resizable: entry = ("%s (%s, %d MB)" % (part.name, @@ -115,7 +113,7 @@ def whichToResize(storage, intf): return (rc, []) request = getActive(combo) - newSize = dxml.get_widget("resizeSB").get_value_as_int() + newSize = dxml.get_widget("shrinkSB").get_value_as_int() actions = [] try: @@ -159,7 +157,7 @@ class PartitionTypeWindow(InstallWindow): self.dispatch.skipStep("bootloader", skip = 0) else: if val == -2: - (rc, actions) = whichToResize(self.storage, self.intf) + (rc, actions) = whichToShrink(self.storage, self.intf) if rc == gtk.RESPONSE_OK: for action in actions: self.storage.devicetree.registerAction(action) |