This simplifies the edit partition dialog and adds resizing support --- iw/lvm_dialog_gui.py | 18 ++----- iw/partition_dialog_gui.py | 43 ++++------------ iw/partition_ui_helpers_gui.py | 111 +++++++++++++++++++++------------------- iw/raid_dialog_gui.py | 22 ++------ 4 files changed, 78 insertions(+), 116 deletions(-) diff --git a/iw/lvm_dialog_gui.py b/iw/lvm_dialog_gui.py index 5d81064..472bcf1 100644 --- a/iw/lvm_dialog_gui.py +++ b/iw/lvm_dialog_gui.py @@ -479,25 +479,15 @@ class VolumeGroupEditor: format = 1 migrate = 0 else: - if self.fsoptionsDict.has_key("formatrb"): - formatrb = self.fsoptionsDict["formatrb"] - else: - formatrb = None - - if formatrb: - format = formatrb.get_active() + if self.fsoptionsDict.has_key("formatcb"): + format = self.fsoptionsDict["formatcb"].get_active() if format: fsystem = self.fsoptionsDict["fstypeCombo"].get_active_value() else: format = 0 - if self.fsoptionsDict.has_key("migraterb"): - migraterb = self.fsoptionsDict["migraterb"] - else: - migraterb = None - - if migraterb: - migrate = migraterb.get_active() + if self.fsoptionsDict.has_key("migratecb"): + migrate = self.fsoptionsDict["migratecb"].get_active() if migrate: fsystem = self.fsoptionsDict["migfstypeCombo"].get_active_value() else: diff --git a/iw/partition_dialog_gui.py b/iw/partition_dialog_gui.py index 7c757ae..fa7a6fd 100644 --- a/iw/partition_dialog_gui.py +++ b/iw/partition_dialog_gui.py @@ -206,30 +206,26 @@ class PartitionEditor: # preexisting partition, just set mount point and format flag request = copy.copy(self.origrequest) - if self.fsoptionsDict.has_key("formatrb"): - formatrb = self.fsoptionsDict["formatrb"] - else: - formatrb = None - - if formatrb: - request.format = formatrb.get_active() + if self.fsoptionsDict.has_key("formatcb"): + request.format = self.fsoptionsDict["formatcb"].get_active() if request.format: request.fstype = self.fsoptionsDict["fstypeCombo"].get_active_value() else: request.format = 0 - if self.fsoptionsDict.has_key("migraterb"): - migraterb = self.fsoptionsDict["migraterb"] - else: - migraterb = None - - if migraterb: - request.migrate = migraterb.get_active() + if self.fsoptionsDict.has_key("migratecb"): + request.migrate = self.fsoptionsDict["migratecb"].get_active() if request.migrate: request.fstype =self.fsoptionsDict["migfstypeCombo"].get_active_value() else: request.migrate = 0 + if self.fsoptionsDict.has_key("resizecb") and self.fsoptionsDict["resizecb"].get_active(): + request.targetSize = self.fsoptionsDict["resizesb"].get_value_as_int() + else: + request.targetSize = None + print "the target size for %s is %s" %(request.mountpoint, request.targetSize) + # set back if we are not formatting or migrating origfstype = self.origrequest.origfstype if not request.format and not request.migrate: @@ -337,21 +333,6 @@ class PartitionEditor: lbl.set_mnemonic_widget(self.newfstypeCombo) maintable.attach(self.newfstypeCombo, 1, 2, row, row + 1) else: - maintable.attach(createAlignedLabel(_("Original File System " - "Type:")), - 0, 1, row, row + 1) - - if self.origrequest.origfstype: - typestr = self.origrequest.origfstype.getName() - if self.origrequest.origfstype.getName() == "foreign": - part = get_partition_by_name(self.diskset.disks, - self.origrequest.device) - typestr = map_foreign_to_fsname(part.native_type) - else: - typestr = _("Unknown") - - fstypelabel = gtk.Label(typestr) - maintable.attach(fstypelabel, 1, 2, row, row + 1) self.newfstypeCombo = None row = row + 1 @@ -455,10 +436,6 @@ class PartitionEditor: cursize = (endsec - startsec)/2048 bycyl_sizelabel.set_text("%s" % (int(cursize))) else: - maintable.attach(createAlignedLabel(_("Size (MB):")), - 0, 1, row, row + 1) - sizelabel = gtk.Label("%d" % (origrequest.size)) - maintable.attach(sizelabel, 1, 2, row, row + 1) self.sizespin = None row = row + 1 diff --git a/iw/partition_ui_helpers_gui.py b/iw/partition_ui_helpers_gui.py index 5fa5f25..4ad6af5 100644 --- a/iw/partition_ui_helpers_gui.py +++ b/iw/partition_ui_helpers_gui.py @@ -29,6 +29,11 @@ from partedUtils import * import rhpl from rhpl.translate import _, N_ +def istruefalse(val): + if val is None or not val: + return False + return True + class WideCheckList(checklist.CheckList): def toggled_item(self, data, row): @@ -206,6 +211,9 @@ def mountptchangeCB(widget, fstypecombo): if rhpl.getArch() == "ia64" and widget.get_children()[0].get_text() == "/boot/efi": fstypecombo.set_active_text("vfat") +def resizeOptionCB(widget, resizesb): + resizesb.set_sensitive(widget.get_active()) + def formatOptionCB(widget, data): (combowidget, mntptcombo, ofstype, lukscb) = data combowidget.set_sensitive(widget.get_active()) @@ -239,100 +247,97 @@ def noformatCB(widget, data): Returns the value of row after packing into the maintable, and a dictionary consistenting of: - noformatrb - radiobutton for 'leave fs unchanged' - formatrb - radiobutton for 'format as new fs' + noformatcb - checkbutton for 'format as new fs' fstype - part of format fstype menu fstypeMenu - part of format fstype menu - migraterb - radiobutton for migrate fs - migfstype - menu for migrate fs types + migratecb - checkbutton for migrate fs migfstypeMenu - menu for migrate fs types lukscb - checkbutton for 'encrypt using LUKS/dm-crypt' + resizecb - checkbutton for 'resize fs' + resizesb - spinbutton with resize target """ def createPreExistFSOptionSection(origrequest, maintable, row, mountCombo, ignorefs=[]): + rc = {} ofstype = origrequest.fstype - maintable.attach(gtk.HSeparator(), 0, 2, row, row + 1) - row = row + 1 - - label = gtk.Label(_("How would you like to prepare the file system " - "on this partition?")) - label.set_line_wrap(1) - label.set_alignment(0.0, 0.0) - - maintable.attach(label, 0, 2, row, row + 1) - row = row + 1 - - noformatrb = gtk.RadioButton(label=_("Leave _unchanged " - "(preserve data)")) - noformatrb.set_active(1) - maintable.attach(noformatrb, 0, 2, row, row + 1) - row = row + 1 - - formatrb = gtk.RadioButton(label=_("_Format partition as:"), - group=noformatrb) - formatrb.set_active(0) - if origrequest.format: - formatrb.set_active(1) + formatcb = gtk.CheckButton(label=_("_Format as:")) + maintable.attach(formatcb, 0, 1, row, row + 1) + formatcb.set_active(istruefalse(origrequest.format)) + rc["formatcb"] = formatcb - maintable.attach(formatrb, 0, 1, row, row + 1) fstypeCombo = createFSTypeMenu(ofstype, fstypechangeCB, mountCombo, ignorefs=ignorefs) - fstypeCombo.set_sensitive(formatrb.get_active()) + fstypeCombo.set_sensitive(formatcb.get_active()) maintable.attach(fstypeCombo, 1, 2, row, row + 1) - row = row + 1 + row += 1 + rc["fstypeCombo"] = fstypeCombo - if not formatrb.get_active() and not origrequest.migrate: + if not formatcb.get_active() and not origrequest.migrate: mountCombo.set_data("prevmountable", ofstype.isMountable()) # this gets added to the table a bit later on lukscb = gtk.CheckButton(_("Encrypt Partition")) - formatrb.connect("toggled", formatOptionCB, + formatcb.connect("toggled", formatOptionCB, (fstypeCombo, mountCombo, ofstype, lukscb)) - noformatrb.connect("toggled", noformatCB, - (fstypeCombo, mountCombo, origrequest.origfstype)) if origrequest.origfstype.isMigratable(): - migraterb = gtk.RadioButton(label=_("Mi_grate partition to:"), - group=noformatrb) - migraterb.set_active(0) - if origrequest.migrate: - migraterb.set_active(1) + migratecb = gtk.CheckButton(label=_("Mi_grate filesystem to:")) + migratecb.set_active(istruefalse(origrequest.migrate)) migtypes = origrequest.origfstype.getMigratableFSTargets() - maintable.attach(migraterb, 0, 1, row, row + 1) + maintable.attach(migratecb, 0, 1, row, row + 1) migfstypeCombo = createFSTypeMenu(ofstype, None, None, availablefstypes = migtypes) - migfstypeCombo.set_sensitive(migraterb.get_active()) + migfstypeCombo.set_sensitive(migratecb.get_active()) maintable.attach(migfstypeCombo, 1, 2, row, row + 1) row = row + 1 - - migraterb.connect("toggled", formatOptionCB, + migratecb.connect("toggled", formatOptionCB, + (migfstypeCombo, mountCombo, ofstype)) + rc["migratecb"] = migratecb + rc["migfstypeCombo"] = migfstypeCombo + migratecb.connect("toggled", formatOptionCB, (migfstypeCombo, mountCombo, ofstype, None)) else: - migraterb = None + migratecb = None migfstypeCombo = None - row = row + 1 + # FIXME: we should support resizing LVs too + if origrequest.origfstype.isResizable() and origrequest.type == REQUEST_PREEXIST: + resizecb = gtk.CheckButton(label=_("_Resize partition")) + resizecb.set_active(origrequest.targetSize is not None) + rc["resizecb"] = resizecb + maintable.attach(resizecb, 0, 1, row, row + 1) - if origrequest.encryption and formatrb.get_active(): + if origrequest.targetSize is not None: + value = origrequest.targetSize + else: + value = origrequest.size + adj = gtk.Adjustment(value = value, + lower = origrequest.getMinimumResizeMB(), + upper = origrequest.getMaximumResizeMB(), + step_incr = 1) + resizesb = gtk.SpinButton(adj, digits = 0) + resizesb.set_property('numeric', True) + rc["resizesb"] = resizesb + maintable.attach(resizesb, 1, 2, row, row + 1) + resizecb.connect('toggled', resizeOptionCB, resizesb) + resizeOptionCB(resizecb, resizesb) + row = row + 1 + + if origrequest.encryption and formatcb.get_active(): # probably never happen lukscb.set_active(1) - lukscb.set_sensitive(formatrb.get_active()) - lukscb.set_data("formatstate", formatrb.get_active()) + lukscb.set_sensitive(formatcb.get_active()) + lukscb.set_data("formatstate", formatcb.get_active()) + rc["lukscb"] = lukscb maintable.attach(lukscb, 0, 2, row, row + 1) row = row + 1 - rc = {} - for var in ['noformatrb', 'formatrb', 'fstypeCombo', - 'migraterb', 'migfstypeCombo', 'lukscb']: - if eval("%s" % (var,)) is not None: - rc[var] = eval("%s" % (var,)) - return (row, rc) # do tests we just want in UI for now, not kickstart diff --git a/iw/raid_dialog_gui.py b/iw/raid_dialog_gui.py index d90a3d0..22123f8 100644 --- a/iw/raid_dialog_gui.py +++ b/iw/raid_dialog_gui.py @@ -183,27 +183,17 @@ class RaidEditor: else: request.encryption = None else: - if self.fsoptionsDict.has_key("formatrb"): - formatrb = self.fsoptionsDict["formatrb"] - else: - formatrb = None - - if formatrb: - request.format = formatrb.get_active() + if self.fsoptionsDict.has_key("formatcb"): + request.format = self.fsoptionsDict["formatcb"].get_active() if request.format: - request.fstype = self.fsoptionsDict["fstypeCombo"].get_active_value() + request.fsystem = self.fsoptionsDict["fstypeCombo"].get_active_value() else: request.format = 0 - if self.fsoptionsDict.has_key("migraterb"): - migraterb = self.fsoptionsDict["migraterb"] - else: - migraterb = None - - if migraterb: - request.migrate = migraterb.get_active() + if self.fsoptionsDict.has_key("migratecb"): + request.migrate = self.fsoptionsDict["migratecb"].get_active() if request.migrate: - request.fstype =self.fsoptionsDict["migfstypeCombo"].get_active_value() + request.fsystem = self.fsoptionsDict["migfstypeCombo"].get_active_value() else: request.migrate = 0 -- 1.5.3.4 _______________________________________________ Anaconda-devel-list mailing list Anaconda-devel-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/anaconda-devel-list