def createPEOptionMenu(self, default=4096): peCombo = datacombo.DataComboBox() actualPE = lvm.getPossiblePhysicalExtents(floor=1024) for curpe in actualPE: # don't show PE over 128M, unless it's the default if curpe > 131072 and curpe != default: continue val = self.prettyFormatPESize(curpe) peCombo.append(val, curpe) # First try to set the combo's active value to the default we're # passed. If that doesn't work, just set it to the first one to # prevent TypeErrors everywhere. try: peCombo.set_active(actualPE.index(default)) except ValueError: peCombo.set_active(0) peCombo.set_data("lastidx", peCombo.get_active()) peCombo.connect("changed", self.peChangeCB) peCombo.set_data("lastpe", default) return peCombo
def _combo_box(self, entries, credentials, rev_credentials): combo_store = gtk.TreeStore(gobject.TYPE_STRING, gobject.TYPE_INT) combo = datacombo.DataComboBox(store=combo_store) for entry in entries: combo.append(entry[1], entry[0]) if len(entries) > 0: combo.set_active(0) combo.show_all() combo.connect("changed", self._authentication_kind_changed, credentials, rev_credentials) return combo
def createRaidMinorMenu(self, minors, reqminor): minorcombo = datacombo.DataComboBox() defindex = 0 i = 0 for minor in minors: minorcombo.append("md%d" % (minor, ), minor) if reqminor and minor == reqminor: defindex = i i = i + 1 minorcombo.set_active(defindex) return minorcombo
def createFSTypeMenu(format, fstypechangeCB, mountCombo, availablefstypes=None, ignorefs=None): store = gtk.TreeStore(gobject.TYPE_STRING, gobject.TYPE_PYOBJECT) fstypecombo = datacombo.DataComboBox(store) if availablefstypes: names = availablefstypes else: names = device_formats.keys() if format and format.supported and format.formattable: default = format.type else: default = get_default_filesystem_type() names.sort() defindex = 0 i = 0 for name in names: # we could avoid instantiating them all if we made a static class # method that does what the supported property does format = device_formats[name]() if not format.supported: continue if ignorefs and name in ignorefs: continue if format.formattable: fstypecombo.append(format.name, device_formats[name]) if default == name: defindex = i defismountable = format.mountable i = i + 1 fstypecombo.set_active(defindex) if fstypechangeCB and mountCombo: fstypecombo.connect("changed", fstypechangeCB, mountCombo) if mountCombo: mountCombo.set_data("prevmountable", fstypecombo.get_active_value()().mountable) mountCombo.connect("changed", mountptchangeCB, fstypecombo) return fstypecombo
def createRaidMinorMenu(self, minors, reqminor): minorcombo = datacombo.DataComboBox() defindex = 0 i = 0 for minor in minors: name = "md%d" % minor if name in self.storage.devicetree._ignoredDisks: continue minorcombo.append(name, minor) if reqminor and minor == reqminor: defindex = i i = i + 1 minorcombo.set_active(defindex) return minorcombo
def createFSTypeMenu(fstype, fstypechangeCB, mountCombo, availablefstypes = None, ignorefs = None, lukscb = None): store = gtk.TreeStore(gobject.TYPE_STRING, gobject.TYPE_PYOBJECT) fstypecombo = datacombo.DataComboBox(store) types = fileSystemTypeGetTypes() if availablefstypes: names = availablefstypes else: names = types.keys() if fstype and fstype.isSupported() and fstype.isFormattable(): default = fstype else: default = fileSystemTypeGetDefault() names.sort() defindex = 0 i = 0 for name in names: if not fileSystemTypeGet(name).isSupported(): continue if ignorefs and name in ignorefs: continue if fileSystemTypeGet(name).isFormattable(): fstypecombo.append(name, types[name]) if default and default.getName() == name: defindex = i defismountable = types[name].isMountable() i = i + 1 fstypecombo.set_active(defindex) if fstypechangeCB and mountCombo: fstypecombo.connect("changed", fstypechangeCB, (mountCombo, lukscb)) if mountCombo: mountCombo.set_data("prevmountable", fstypecombo.get_active_value().isMountable()) mountCombo.connect("changed", mountptchangeCB, fstypecombo) return fstypecombo
def editOther(self, oldDevice, oldLabel, isDefault, isRoot = 0): dialog = gtk.Dialog(_("Image"), self.parent) dialog.add_button('gtk-cancel', 2) dialog.add_button('gtk-ok', 1) dialog.set_position(gtk.WIN_POS_CENTER) gui.addFrame(dialog) dialog.vbox.pack_start(gui.WrappingLabel( _("Enter a label to be displayed in the boot loader menu. The " "device (or hard drive and partition number) is the device " "from which it boots."))) spacer = gtk.Label("") spacer.set_size_request(10, 1) dialog.vbox.pack_start(spacer, False) table = gtk.Table(2, 5) table.set_row_spacings(5) table.set_col_spacings(5) label = gui.MnemonicLabel(_("_Label")) table.attach(label, 0, 1, 1, 2, gtk.FILL, 0, 10) labelEntry = gtk.Entry(32) label.set_mnemonic_widget(labelEntry) table.attach(labelEntry, 1, 2, 1, 2, gtk.FILL, 0, 10) if oldLabel: labelEntry.set_text(oldLabel) label = gui.MnemonicLabel(_("_Device")) table.attach(label, 0, 1, 2, 3, gtk.FILL, 0, 10) if not isRoot: # XXX should potentially abstract this out into a function pedparts = [] parts = [] disks = self.diskset.disks for drive in disks.keys(): pedparts.extend(partedUtils.get_all_partitions(disks[drive])) for part in pedparts: parts.append(partedUtils.get_partition_name(part)) del pedparts parts.sort() deviceCombo = datacombo.DataComboBox() defindex = 0 i = 0 for part in parts: deviceCombo.append("/dev/%s" %(part,), part) if oldDevice and oldDevice == part: defindex = i i = i + 1 deviceCombo.set_active(defindex) table.attach(deviceCombo, 1, 2, 2, 3, gtk.FILL, 0, 10) label.set_mnemonic_widget(deviceCombo) else: table.attach(gtk.Label(oldDevice), 1, 2, 2, 3, gtk.FILL, 0, 10) default = gtk.CheckButton(_("Default Boot _Target")) table.attach(default, 0, 2, 3, 4, gtk.FILL, 0, 10) if isDefault != 0: default.set_active(True) if self.numentries == 1 and oldDevice != None: default.set_sensitive(False) else: default.set_sensitive(True) dialog.vbox.pack_start(table) dialog.show_all() while 1: rc = dialog.run() # cancel if rc == 2: break label = labelEntry.get_text() if not isRoot: dev = deviceCombo.get_active_value() else: dev = oldDevice if not label: self.intf.messageWindow(_("Error"), _("You must specify a label for the " "entry"), type="warning") continue foundBad = 0 for char in self.illegalChars: if char in label: self.intf.messageWindow(_("Error"), _("Boot label contains illegal " "characters"), type="warning") foundBad = 1 break if foundBad: continue # verify that the label hasn't been used foundBad = 0 for key in self.imagelist.keys(): if dev == key: continue if self.blname == "GRUB": thisLabel = self.imagelist[key][1] else: thisLabel = self.imagelist[key][0] # if the label is the same as it used to be, they must # have changed the device which is fine if thisLabel == oldLabel: continue if thisLabel == label: self.intf.messageWindow(_("Duplicate Label"), _("This label is already in " "use for another boot entry."), type="warning") foundBad = 1 break if foundBad: continue # XXX need to do some sort of validation of the device? # they could be duplicating a device, which we don't handle if dev in self.imagelist.keys() and (not oldDevice or dev != oldDevice): self.intf.messageWindow(_("Duplicate Device"), _("This device is already being " "used for another boot entry."), type="warning") continue # if we're editing a previous, get what the old info was for # labels. otherwise, make it something safe for grub and the # device name for lilo for lack of any better ideas if oldDevice: (oldshort, oldlong, oldisroot) = self.imagelist[oldDevice] else: (oldshort, oldlong, oldisroot) = (dev, label, None) # if we're editing and the device has changed, delete the old if oldDevice and dev != oldDevice: del self.imagelist[oldDevice] # go ahead and add it if self.blname == "GRUB": self.imagelist[dev] = (oldshort, label, isRoot) else: self.imagelist[dev] = (label, oldlong, isRoot) if default.get_active(): self.defaultDev = dev # refill the os list store self.fillOSList() break dialog.destroy()