* iw/lvm_dialog_gui.py: (editLogicalVolume): call the temporary function createPreExistFSOptionSectionT to create the fs options. * iw/partition_ui_helpers_gui (createPreExistFSOptionSectionT): Temporary function to help in the transition. * iw/partition_ui_helpers_gui (createPreExistFSOptionSectionT): this new function has the a new argument "useropts". We need to pass this argument because we need to reflect user changes in the various screens. --- iw/lvm_dialog_gui.py | 39 +++++----- iw/partition_ui_helpers_gui.py | 163 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 183 insertions(+), 19 deletions(-) diff --git a/iw/lvm_dialog_gui.py b/iw/lvm_dialog_gui.py index 59d5a2b..b97a7b9 100644 --- a/iw/lvm_dialog_gui.py +++ b/iw/lvm_dialog_gui.py @@ -383,10 +383,12 @@ class VolumeGroupEditor: maxsizelabel = None # Maximum size label #mountCombo = None # Mount Point Combo Box #tstr = None # String that appears on top of the window + lukscb = None # luks check box. different from self.lukscb tempvg = self.getTempVG() # copy of self.vg templv = None cpefsos = None # lambda function that represents # createPreExistFSOptionSection + self.fsoptionsDict = {} # make sure there is no garbage. # Define the string if isNew: @@ -452,6 +454,8 @@ class VolumeGroupEditor: else: self.lukscb.set_active(0) + lukscb = self.lukscb + else: # File system type lable & combo newfstypelabel = createAlignedLabel(_("Original File System Type:")) @@ -475,7 +479,6 @@ class VolumeGroupEditor: lvsizeentry = gtk.Label(str(lv['size'])) # Create the File System Format Section - self.fsoptionsDict = {} templuks = None reallv = None for _lv in self.vg.lvs: @@ -489,11 +492,11 @@ class VolumeGroupEditor: break # We are going to lambda the createPreExistFSOptionSection so we can call # it latter with two arguments, row and mainttable. - cpefsos = lambda table, row: createPreExistFSOptionSection(reallv, - maintable, row, mountCombo, self.storage, - ignorefs = ["software RAID", "physical volume (LVM)", "vfat"], - luksdev=templuks) + ignorefs = ["software RAID", "physical volume (LVM)", "vfat"] + (row, self.fsoptionsDict) = createPreExistFSOptionSectionT(reallv, + mountCombo, ignorefs=ignorefs, luksdev=templuks, useropts=lv) + self.lukscb = self.fsoptionsDict.get("lukscb") # Here is where the gtk crap begins. dialog = gtk.Dialog(tstr, self.parent) @@ -540,21 +543,19 @@ class VolumeGroupEditor: if maxsizelabel is not None: maintable.attach(maxsizelabel, 1, 2, row, row + 1) - # If we have the createPreExistFSOptionSection lamda function it means - # that we have a preexisting lv and we must call the lambda function - # to create the Pre exsisting FS option section. - if cpefsos is not None: - (row, self.fsoptionsDict) = cpefsos(maintable, row) - - # checkbutton for encryption using dm-crypt/LUKS - # FIXME: Here we could not decouple the gtk stuff from the logic because - # of the createPreExistFSOptionSection function call. We must - # decouple that function. - if not lv['exists']: - maintable.attach(self.lukscb, 0, 2, row, row + 1) + # Some lines up we called createPreExistFSOptionSection which created + # the gtk optiosn for the fssection and put them in a list for us. + # if that list is present, use it. + if self.fsoptionsDict.has_key("list"): + for trow in self.fsoptionsDict["list"]: + for i in range(len(trow)): + maintable.attach(trow[i], i, 1+i, row, row + 1) + row += 1 + + if lukscb is not None: + # note that in this case lukscb == self.lukscb + maintable.attach(lukscb, 0, 2, row, row + 1) row = row + 1 - else: - self.lukscb = self.fsoptionsDict.get("lukscb") dialog.vbox.pack_start(maintable) dialog.show_all() diff --git a/iw/partition_ui_helpers_gui.py b/iw/partition_ui_helpers_gui.py index 66234ad..b613ef0 100644 --- a/iw/partition_ui_helpers_gui.py +++ b/iw/partition_ui_helpers_gui.py @@ -291,6 +291,169 @@ def formatMigrateOptionCB(widget, data): setMntPtComboStateFromType(fs, mntptcombo) +def createPreExistFSOptionSectionT(origrequest, mountCombo, ignorefs=[], + useropts=None, luksdev=None, table=None, row=None): + """ Create the elements for the FSOptionSection. + + origrequest - the original request + useropts - list that hols all the temporary stuff that the user is + doing while playing with storage. + + if table and row are passed it adds the created options immediately + and returns a (row, dict) + if row or dict are not passed it returns the dictionary but a None + where the row is suppose to be (None, dict) + + Returns the value of row after packing into the maintable, + dictionary: + list - List containing all the created gtk obs in order. + each element of the list is a list in itself, + representing the horizondal elements. + list = [ [a,b,c], #row 1 + [a,b] #row 2 + .... + ] + formatcb - checkbutton for 'format as new fs' + fstype - part of format fstype menu + fstypeMenu - part of format fstype menu + 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 + """ + rc = {} + rc["list"] = [] + formatcb = None # File system type checkbox and combo. + fstypeCombo = None # formatcb is the checkbox for "Format as" + #lukscb # LUKS checkbox + migratecb = None # migrate check box and combo + migfstypeCombo = None + resizecb = None # resize ceckbox and spin button. + resizesb = None + + if luksdev: + origfs = luksdev.format + else: + origfs = origrequest.format + + # this gets added to the table a bit later on + lukscb = gtk.CheckButton(_("_Encrypt")) + + # Formatable stuff + if origfs.formattable: + # gtk initializers + formatcb = gtk.CheckButton(label=_("_Format as:")) + formatcb.set_active(origfs.formattable and not origfs.exists) + # here we want the user to see what he was selecting previously. + fstypeCombo = createFSTypeMenu(useropts['format'], fstypechangeCB, + mountCombo, ignorefs=ignorefs) + fstypeCombo.set_sensitive(formatcb.get_active()) + if not formatcb.get_active() and not origfs.migrate: + mountCombo.set_data("prevmountable", origfs.mountable) + + # Updates the return value + rc["formatcb"] = formatcb + rc["fstypeCombo"] = fstypeCombo + rc["list"].append([formatcb, fstypeCombo]) + + # Migratable stuff + if origfs.migratable: + # gtk initializers + migratecb = gtk.CheckButton(label=_("Mi_grate filesystem to:")) + if formatcb is not None: + migratecb.set_active(origfs.migrate and (not formatcb.get_active())) + else: + migratecb.set_active(origfs.migrate) + + migfstypeCombo = createFSTypeMenu(origfs, None, None, + availablefstypes = [origfs.migrationTarget]) + migfstypeCombo.set_sensitive(migratecb.get_active()) + migratecb.connect("toggled", formatMigrateOptionCB, + (migfstypeCombo, mountCombo, origfs, None, + fstypeCombo, formatcb, FLAG_MIGRATE)) + + + # Update the return value + rc["migratecb"] = migratecb + rc["migfstypeCombo"] = migfstypeCombo + rc["list"].append([migratecb, migfstypeCombo]) + + if formatcb: + formatcb.connect("toggled", formatMigrateOptionCB, + (fstypeCombo, mountCombo, origfs, lukscb, + migfstypeCombo, migratecb, FLAG_FORMAT)) + # Resize stuff. + if origrequest.resizable: + resizecb = gtk.CheckButton(label=_("_Resize")) + resizecb.set_active(origfs.resizable and \ + (origfs.currentSize != origfs.targetSize) and \ + (origfs.currentSize != 0)) + + if origrequest.targetSize is not None: + value = origrequest.targetSize + else: + value = origrequest.size + + if origfs.exists: + lower = origrequest.minSize + else: + lower = 1 + adj = gtk.Adjustment(value=value, lower=lower, upper=origrequest.maxSize, + step_incr = 1) + resizesb = gtk.SpinButton(adj, digits = 0) + resizesb.set_property('numeric', True) + resizesb.set_data("requpper", origrequest.maxSize) + resizesb.set_data("reqlower", origrequest.minSize) + resizecb.connect('toggled', resizeOptionCB, resizesb) + resizeOptionCB(resizecb, resizesb) + + if formatcb is not None: + formatcb.connect("toggled", formatOptionResizeCB, (resizesb, origfs)) + + # Update return value. + rc["resizecb"] = resizecb + rc["resizesb"] = resizesb + rc["list"].append([resizecb, resizesb]) + + # LUKS stuff + if luksdev: + lukscb.set_active(1) + lukscb.set_data("encrypted", 1) + else: + lukscb.set_data("encrypted", 0) + + lukscb.set_sensitive(formatcb.get_active()) + lukscb.set_data("formatstate", formatcb.get_active()) + rc["lukscb"] = lukscb + rc["list"].append([lukscb]) + + if row is not None and table is not None: + # Here starts the gtk crap. + if formatcb is not None and fstypeCombo is not None: + table.attach(formatcb, 0, 1, row, row + 1) + table.attach(fstypeCombo, 1, 2, row, row + 1) + row += 1 + + if migratecb is not None and migfstypeCombo is not None: + table.attach(migratecb, 0, 1, row, row + 1) + table.attach(migfstypeCombo, 1, 2, row, row + 1) + row += 1 + + if resizecb is not None and resizesb is not None: + table.attach(resizecb, 0, 1, row, row + 1) + table.attach(resizesb, 1, 2, row, row + 1) + row += 1 + + table.attach(lukscb, 0, 2, row, row + 1) + row = row + 1 + # Here ends the gtk crap. + else: + #make sure row is None + row = None + + return (row, rc) + def createPreExistFSOptionSection(origrequest, maintable, row, mountCombo, partitions, ignorefs=[], luksdev=None): -- 1.6.0.6 _______________________________________________ Anaconda-devel-list mailing list Anaconda-devel-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/anaconda-devel-list