Beispiel #1
0
 def select_layout(self, sender, layout):
     log.debug("%s", layout)
     opts = []
     for variant, variant_desc in self.model.variants[layout].items():
         opts.append(Option((variant_desc, True, variant)))
     opts.sort(key=lambda o:o.label)
     opts.insert(0, Option(("default", True, None)))
     self.form.variant.widget._options = opts
     self.form.variant.widget.index = 0
     self.form.variant.enabled = len(opts) > 1
Beispiel #2
0
    def __init__(self, model, controller, opts):
        self.model = model
        self.controller = controller
        self.opts = opts

        self.form = KeyboardForm()
        opts = []
        for layout, desc in model.layouts.items():
            opts.append(Option((desc, True, layout)))
        opts.sort(key=lambda o: o.label)
        connect_signal(self.form, 'submit', self.done)
        connect_signal(self.form, 'cancel', self.cancel)
        connect_signal(self.form.layout.widget, "select", self.select_layout)
        self.form.layout.widget._options = opts
        setting = model.setting.for_ui()
        try:
            self.form.layout.widget.value = setting.layout
            self.form.variant.widget.value = setting.variant
        except AttributeError:
            # Don't crash on pre-existing invalid config.
            pass

        lb_contents = self.form.as_rows(self)
        if not self.opts.run_on_serial:
            lb_contents.extend([
                Text(""),
                button_pile([
                    other_btn(label=_("Identify keyboard"),
                              on_press=self.detect)
                ]),
            ])
        super().__init__(screen(lb_contents, self.form.buttons))
Beispiel #3
0
    def __init__(self, model, controller, disk, partition=None):
        log.debug('PartitionView: selected_disk=[{}]'.format(disk.path))
        self.model = model
        self.controller = controller
        self.disk = disk
        self.partition = partition

        max_size = disk.free
        if partition is None:
            initial = {'partnum': disk.next_partnum}
            label = _("Create")
        else:
            max_size += partition.size
            initial = {
                'partnum': partition.number,
                'size': humanize_size(partition.size),
            }
            label = _("Save")
        super().__init__(max_size, partition, initial,
                         lambda: self.controller.partition_disk(disk))
        self.form.buttons.base_widget[0].set_label(label)
        if partition is not None and partition.flag == "boot":
            opts = [Option(("fat32", True, self.model.fs_by_name["fat32"]))]
            self.form.fstype.widget._options = opts
            self.form.fstype.widget.index = 0
            self.form.mount.enabled = False
            self.form.fstype.enabled = False
Beispiel #4
0
 def select_layout(self, sender, layout):
     log.debug("%s", layout)
     opts = []
     default_i = -1
     layout_items = enumerate(self.model.variants[layout].items())
     for i, (variant, variant_desc) in layout_items:
         if variant == "":
             default_i = i
         opts.append(Option((variant_desc, True, variant)))
     opts.sort(key=lambda o: o.label)
     if default_i < 0:
         opts.insert(0, Option(("default", True, "")))
     self.form.variant.widget._options = opts
     if default_i < 0:
         self.form.variant.widget.index = 0
     else:
         self.form.variant.widget.index = default_i
     self.form.variant.enabled = len(opts) > 1
 def __init__(self, opts):
     self._options = []
     for opt in opts:
         if not isinstance(opt, Option):
             opt = Option(opt)
         self._options.append(opt)
     self._button = SelectableIcon(self.icon, 0)
     super().__init__(self._button)
     self._dialog = _ActionMenuDialog(self)
Beispiel #6
0
 def select_layout(self, sender, layout):
     if sender is not None:
         log.debug("select_layout %s", layout)
     opts = []
     for variant in layout.variants:
         opts.append(Option((variant.name, True, variant)))
     # ./scripts/make-kbd-info.py checks that the default is always
     # at index 0
     opts[1:] = sorted(opts[1:], key=lambda o: locale.strxfrm(o.label.text))
     self.form.variant.widget.options = opts
     self.form.variant.widget.index = 0
     self.form.variant.enabled = len(opts) > 1
Beispiel #7
0
    def __init__(self, model, controller, opts):
        self.model = model
        self.controller = controller
        self.opts = opts

        self.form = KeyboardForm()
        opts = []
        for layout, desc in model.layouts.items():
            opts.append(Option((desc, True, layout)))
        opts.sort(key=lambda o: o.label.text)
        connect_signal(self.form, 'submit', self.done)
        connect_signal(self.form, 'cancel', self.cancel)
        connect_signal(self.form.layout.widget, "select", self.select_layout)
        self.form.layout.widget.options = opts
        setting = model.setting.for_ui()
        try:
            self.form.layout.widget.value = setting.layout
        except AttributeError:
            # Don't crash on pre-existing invalid config.
            pass
        self.select_layout(None, setting.layout)
        try:
            self.form.variant.widget.value = setting.variant
        except AttributeError:
            # Don't crash on pre-existing invalid config.
            pass

        if self.opts.run_on_serial:
            excerpt = _('Please select the layout of the keyboard directly '
                        'attached to the system, if any.')
        else:
            excerpt = _('Please select your keyboard layout below, or select '
                        '"Identify keyboard" to detect your layout '
                        'automatically.')

        lb_contents = self.form.as_rows()
        if not self.opts.run_on_serial:
            lb_contents.extend([
                Text(""),
                button_pile([
                    other_btn(label=_("Identify keyboard"),
                              on_press=self.detect)
                ]),
            ])
        super().__init__(
            screen(lb_contents,
                   self.form.buttons,
                   excerpt=excerpt,
                   narrow_rows=True))
Beispiel #8
0
 def __init__(self, parent):
     super().__init__(parent)
     options = []
     tables = []
     for disk in parent.model.all_disks():
         for obj, cells in summarize_device(disk):
             table = TablePile([TableRow(cells)])
             tables.append(table)
             options.append(Option((table, obj is disk, obj)))
     t0 = tables[0]
     for t in tables[1:]:
         t0.bind(t)
     self.disk.widget.options = options
     self.disk.widget.index = 0
     connect_signal(self.use_lvm.widget, 'change', self._toggle)
     self.lvm_options.enabled = self.use_lvm.value
Beispiel #9
0
    def __init__(self, model, controller, disk, partition=None):
        log.debug('PartitionView: selected_disk=[{}]'.format(disk.path))
        self.model = model
        self.controller = controller
        self.disk = disk
        self.partition = partition
        self.title = _("Partition, format, and mount {}").format(disk.label)

        max_size = disk.free
        initial = {}
        if partition is None:
            label = _("Create")
            self.footer = _("Enter partition details, format and mount.")
        else:
            max_size += partition.size
            initial['size'] = humanize_size(partition.size)
            if partition.flag == "bios_grub":
                label = None
                initial['mount'] = None
            else:
                self.footer = _("Edit partition details, format and mount.")
                label = _("Save")
        super().__init__(max_size,
                         partition,
                         initial,
                         lambda: self.controller.partition_disk(disk),
                         focus_buttons=label is None)
        if label is not None:
            self.form.buttons.base_widget[0].set_label(label)
        else:
            del self.form.buttons.base_widget.contents[0]
            self.form.buttons.base_widget[0].set_label(_("OK"))
        if partition is not None:
            if partition.flag == "boot":
                opts = [
                    Option(("fat32", True, self.model.fs_by_name["fat32"]))
                ]
                self.form.fstype.widget._options = opts
                self.form.fstype.widget.index = 0
                self.form.mount.enabled = False
                self.form.fstype.enabled = False
            elif partition.flag == "bios_grub":
                self.form.mount.enabled = False
                self.form.fstype.enabled = False
                self.form.size.enabled = False
Beispiel #10
0
    def __init__(self, model, controller, opts):
        self.model = model
        self.controller = controller
        self.opts = opts

        self.form = KeyboardForm()
        opts = []
        for layout, desc in model.layouts.items():
            opts.append(Option((desc, True, layout)))
        opts.sort(key=lambda o:o.label)
        connect_signal(self.form, 'submit', self.done)
        connect_signal(self.form, 'cancel', self.cancel)
        connect_signal(self.form.layout.widget, "select", self.select_layout)
        self.form.layout.widget._options = opts
        try:
            self.form.layout.widget.value = model.layout
            self.form.variant.widget.value = model.variant
        except AttributeError:
            # Don't crash on pre-existing invalid config.
            pass

        self._rows = self.form.as_rows(self)

        lb_contents = [self._rows]
        if not self.opts.run_on_serial:
            lb_contents.extend([
                Text(""),
                button_pile([
                    other_btn(label=_("Identify keyboard"), on_press=self.detect)]),
                ])
        lb = ListBox(lb_contents)
        pile = Pile([
            ('pack', Text("")),
            Padding.center_90(lb),
            ('pack', Pile([
                Text(""),
                self.form.buttons,
                Text(""),
                ])),
            ])
        lb._select_last_selectable()
        pile.focus_position = 2
        super().__init__(pile)
Beispiel #11
0
 def __init__(self, parent):
     super().__init__(parent)
     options = []
     tables = []
     initial = -1
     for disk in parent.model.all_disks():
         for obj, cells in summarize_device(disk):
             table = TablePile([TableRow(cells)])
             tables.append(table)
             enabled = False
             if obj is disk and disk.size > 6 * (2**30):
                 enabled = True
                 if initial < 0:
                     initial = len(options)
             options.append(Option((table, enabled, obj)))
     t0 = tables[0]
     for t in tables[1:]:
         t0.bind(t)
     self.disk.widget.options = options
     self.disk.widget.index = initial
     connect_signal(self.use_lvm.widget, 'change', self._toggle)
     self.lvm_options.enabled = self.use_lvm.value
Beispiel #12
0
    def __init__(self, controller, setup):
        self.controller = controller
        self.initial_setting = setup.setting
        self.layouts = setup.layouts

        self.form = KeyboardForm()
        opts = []
        for layout in self.layouts:
            opts.append(Option((layout.name, True, layout)))
        opts.sort(key=lambda o: locale.strxfrm(o.label.text))
        connect_signal(self.form, 'submit', self.done)
        connect_signal(self.form, 'cancel', self.cancel)
        connect_signal(self.form.layout.widget, "select", self.select_layout)
        self.form.layout.widget.options = opts
        layout, variant = self.lookup(
            setup.setting.layout, setup.setting.variant)
        self.set_values(layout, variant)

        if self.controller.opts.run_on_serial:
            excerpt = _('Please select the layout of the keyboard directly '
                        'attached to the system, if any.')
        else:
            excerpt = _('Please select your keyboard layout below, or select '
                        '"Identify keyboard" to detect your layout '
                        'automatically.')

        lb_contents = self.form.as_rows()
        if not self.controller.opts.run_on_serial:
            lb_contents.extend([
                Text(""),
                button_pile([
                    other_btn(label=_("Identify keyboard"),
                              on_press=self.detect)]),
                ])
        super().__init__(screen(
            lb_contents,
            self.form.buttons,
            excerpt=excerpt,
            narrow_rows=True))
    def __init__(self, parent, disk, partition=None):

        self.disk = disk
        self.partition = partition
        self.model = parent.model
        self.controller = parent.controller
        self.parent = parent
        max_size = disk.free_for_partitions
        mountpoint_to_devpath_mapping = (
            self.model.get_mountpoint_to_devpath_mapping())

        initial = {}
        label = _("Create")
        if self.partition:
            if self.partition.flag == "bios_grub":
                label = None
                initial['mount'] = None
            else:
                label = _("Save")
            initial['size'] = humanize_size(self.partition.size)
            max_size += self.partition.size
            fs = self.partition.fs()
            if fs is not None:
                if partition.flag != "boot":
                    initial['fstype'] = self.model.fs_by_name[fs.fstype]
                mount = fs.mount()
                if mount is not None:
                    initial['mount'] = mount.path
                    if mount.path in mountpoint_to_devpath_mapping:
                        del mountpoint_to_devpath_mapping[mount.path]
            else:
                initial['fstype'] = self.model.fs_by_name[None]

        self.form = PartitionForm(mountpoint_to_devpath_mapping, max_size,
                                  initial)

        if label is not None:
            self.form.buttons.base_widget[0].set_label(label)
        else:
            del self.form.buttons.base_widget.contents[0]
            self.form.buttons.base_widget[0].set_label(_("OK"))

        if partition is not None:
            if partition.flag == "boot":
                opts = [
                    Option(("fat32", True, self.model.fs_by_name["fat32"])),
                ]
                self.form.fstype.widget._options = opts
                self.form.fstype.widget.index = 0
                self.form.mount.enabled = False
                self.form.fstype.enabled = False
            elif partition.flag == "bios_grub":
                self.form.mount.enabled = False
                self.form.fstype.enabled = False
                self.form.size.enabled = False

        connect_signal(self.form, 'submit', self.done)
        connect_signal(self.form, 'cancel', self.cancel)

        rows = []
        focus_index = 0
        if partition is not None:
            if self.partition.flag == "boot":
                rows.extend([
                    Text(_(boot_partition_description)),
                    Text(""),
                ])
            elif self.partition.flag == "bios_grub":
                rows.extend([
                    Text(_(bios_grub_partition_description)),
                    Text(""),
                ])
                focus_index = 2
        rows.extend(self.form.as_rows())
        widgets = [
            Pile(rows),
            Text(""),
            self.form.buttons,
        ]

        if partition is None:
            title = _("Adding partition to {}").format(disk.label)
        else:
            title = _("Editing partition {} of {}").format(
                partition._number, disk.label)

        super().__init__(title, widgets, 0, focus_index)
Beispiel #14
0
                selector.disable()
                self.device_to_selector[device] = selector
                self.all_rows.append(TableRow([(2, selector)]))
                # Do not append that one to no_selector_rows!
                self.all_rows.append(self._summarize(prefix, device))
                self.no_selector_rows.append(self.all_rows[-1])
        self.table.set_contents(self.all_rows)
        log.debug("%s", self.table._w.focus_position)


MultiDeviceField = simple_field(MultiDeviceChooser)
MultiDeviceField.takes_default_style = False


raidlevel_choices = [
    Option((_(level.name), True, level)) for level in raidlevels]


class RaidForm(Form):

    def __init__(self, mountpoint_to_devpath_mapping,
                 all_devices, initial, raid_names):
        self.mountpoint_to_devpath_mapping = mountpoint_to_devpath_mapping
        self.all_devices = all_devices
        self.raid_names = raid_names
        super().__init__(initial)
        connect_signal(self.fstype.widget, 'select', self.select_fstype)
        self.select_fstype(None, self.fstype.widget.value)

    name = StringField(_("Name:"))
    level = ChoiceField(_("RAID Level:"), choices=raidlevel_choices)
Beispiel #15
0
    def __init__(self, parent, disk, partition=None):

        self.disk = disk
        self.partition = partition
        self.model = parent.model
        self.controller = parent.controller
        self.parent = parent
        max_size = disk.free_for_partitions
        mountpoints = {
            m.path: m.device.volume for m in self.model.all_mounts()}

        initial = {}
        label = _("Create")
        if isinstance(disk, LVM_VolGroup):
            lvm_names = {p.name for p in disk.partitions()}
        else:
            lvm_names = set()
        if self.partition:
            if self.partition.flag == "bios_grub":
                label = None
                initial['mount'] = None
            else:
                label = _("Save")
            initial['size'] = humanize_size(self.partition.size)
            max_size += self.partition.size
            fs = self.partition.fs()
            if fs is not None:
                if partition.flag != "boot":
                    initial['fstype'] = self.model.fs_by_name[fs.fstype]
                mount = fs.mount()
                if mount is not None:
                    initial['mount'] = mount.path
                    del mountpoints[mount.path]
            else:
                initial['fstype'] = self.model.fs_by_name[None]
            if isinstance(disk, LVM_VolGroup):
                initial['name'] = partition.name
                lvm_names.remove(partition.name)
        elif isinstance(disk, LVM_VolGroup):
            x = 0
            while True:
                name = 'lv-{}'.format(x)
                if name not in lvm_names:
                    break
                x += 1
            initial['name'] = name

        self.form = PartitionForm(
            mountpoints, max_size, initial, isinstance(disk, Disk), lvm_names)

        if not isinstance(disk, LVM_VolGroup):
            self.form.remove_field('name')

        if label is not None:
            self.form.buttons.base_widget[0].set_label(label)
        else:
            del self.form.buttons.base_widget.contents[0]
            self.form.buttons.base_widget[0].set_label(_("OK"))

        if partition is not None:
            if partition.flag == "boot":
                opts = [
                    Option(("fat32", True, self.model.fs_by_name["fat32"])),
                ]
                self.form.fstype.widget.options = opts
                self.form.fstype.widget.index = 0
                self.form.mount.enabled = False
                self.form.fstype.enabled = False
            elif partition.flag == "bios_grub":
                self.form.mount.enabled = False
                self.form.fstype.enabled = False
                self.form.size.enabled = False

        connect_signal(self.form, 'submit', self.done)
        connect_signal(self.form, 'cancel', self.cancel)

        rows = []
        focus_index = 0
        if partition is not None:
            if self.partition.flag == "boot":
                rows.extend([
                    Text(_(boot_partition_description)),
                    Text(""),
                ])
            elif self.partition.flag == "bios_grub":
                rows.extend([
                    Text(_(bios_grub_partition_description)),
                    Text(""),
                ])
                focus_index = 2
        rows.extend(self.form.as_rows())
        widgets = [
            Pile(rows),
            Text(""),
            self.form.buttons,
        ]

        if partition is None:
            if isinstance(disk, LVM_VolGroup):
                add_name = _("logical volume")
            else:
                add_name = _("partition")
            title = _("Adding {} to {}").format(add_name, disk.label)
        else:
            if isinstance(disk, LVM_VolGroup):
                desc = _("logical volume {}").format(partition.name)
            else:
                desc = partition.short_label
            title = _("Editing {} of {}").format(desc, disk.label)

        super().__init__(title, widgets, 0, focus_index)
Beispiel #16
0
    def __init__(self, parent, disk, partition=None):
        self.disk = disk
        self.partition = partition
        self.model = parent.model
        self.controller = parent.controller
        self.parent = parent
        max_size = disk.free_for_partitions

        initial = {}
        label = _("Create")
        if isinstance(disk, LVM_VolGroup):
            lvm_names = {p.name for p in disk.partitions()}
        else:
            lvm_names = None
        if self.partition:
            if self.partition.flag in ["bios_grub", "prep"]:
                label = None
                initial['mount'] = None
            else:
                label = _("Save")
            initial['size'] = humanize_size(self.partition.size)
            max_size += self.partition.size

            if partition.flag != "boot":
                initial.update(initial_data_for_fs(self.partition.fs()))
            else:
                if partition.fs() and partition.fs().mount():
                    initial['mount'] = '/boot/efi'
                else:
                    initial['mount'] = None
            if isinstance(disk, LVM_VolGroup):
                initial['name'] = partition.name
                lvm_names.remove(partition.name)
        else:
            initial['fstype'] = 'ext4'
            if isinstance(disk, LVM_VolGroup):
                x = 0
                while True:
                    name = 'lv-{}'.format(x)
                    if name not in lvm_names:
                        break
                    x += 1
                initial['name'] = name

        self.form = PartitionForm(
            self.model, max_size, initial, lvm_names, partition)

        if not isinstance(disk, LVM_VolGroup):
            self.form.remove_field('name')

        if label is not None:
            self.form.buttons.base_widget[0].set_label(label)
        else:
            del self.form.buttons.base_widget.contents[0]
            self.form.buttons.base_widget[0].set_label(_("OK"))

        if partition is not None:
            if partition.flag == "boot":
                if partition.original_fstype():
                    opts = [
                        Option((
                            _("Use existing fat32 filesystem"),
                            True,
                            None
                            )),
                        Option(("---", False)),
                        Option((
                                _("Reformat as fresh fat32 filesystem"),
                                True,
                                "fat32"
                            )),
                        ]
                    self.form.fstype.widget.options = opts
                    if partition.fs().preserve:
                        self.form.fstype.widget.index = 0
                    else:
                        self.form.fstype.widget.index = 2
                    self.form.mount.enabled = False
                else:
                    opts = [Option(("fat32", True))]
                    self.form.fstype.widget.options = opts
                    self.form.fstype.widget.index = 0
                    self.form.mount.enabled = False
                    self.form.fstype.enabled = False
            elif partition.flag in ["bios_grub", "prep"]:
                self.form.mount.enabled = False
                self.form.fstype.enabled = False
                self.form.size.enabled = False
            if partition.preserve:
                self.form.name.enabled = False
                self.form.size.enabled = False

        connect_signal(self.form, 'submit', self.done)
        connect_signal(self.form, 'cancel', self.cancel)

        rows = []
        focus_index = 0
        if partition is not None:
            if self.partition.flag == "boot":
                desc = boot_partition_description
                if self.partition.preserve:
                    desc += boot_partition_description_reformat
                else:
                    desc += boot_partition_description_size
                rows.extend([
                    Text(_(desc)),
                    Text(""),
                ])
            elif self.partition.flag == "bios_grub":
                rows.extend([
                    Text(_(bios_grub_partition_description)),
                    Text(""),
                ])
                focus_index = 2
            elif self.partition.flag == "prep":
                rows.extend([
                    Text(_(prep_partition_description)),
                    Text(""),
                ])
                focus_index = 2
        rows.extend(self.form.as_rows())
        self.form.form_pile = Pile(rows)
        widgets = [
            self.form.form_pile,
            Text(""),
            self.form.buttons,
        ]

        if partition is None:
            if isinstance(disk, LVM_VolGroup):
                add_name = _("logical volume")
            else:
                add_name = _("partition")
            title = _("Adding {} to {}").format(add_name, disk.label)
        else:
            if isinstance(disk, LVM_VolGroup):
                desc = _("logical volume {}").format(partition.name)
            else:
                desc = partition.short_label
            title = _("Editing {} of {}").format(desc, disk.label)

        super().__init__(title, widgets, 0, focus_index)
Beispiel #17
0
    def __init__(self, parent, disk, partition=None):
        self.disk = disk
        self.partition = partition
        self.model = parent.model
        self.controller = parent.controller
        self.parent = parent
        max_size = disk.free_for_partitions

        initial = {}
        label = _("Create")
        if isinstance(disk, LVM_VolGroup):
            lvm_names = {p.name for p in disk.partitions()}
        else:
            lvm_names = None
        if self.partition:
            if partition.flag in ["bios_grub", "prep"]:
                label = None
                initial['mount'] = None
            elif boot.is_esp(partition) and not partition.grub_device:
                label = None
            else:
                label = _("Save")
            initial['size'] = humanize_size(self.partition.size)
            max_size += self.partition.size

            if not boot.is_esp(partition):
                initial.update(initial_data_for_fs(self.partition.fs()))
            else:
                if partition.fs() and partition.fs().mount():
                    initial['mount'] = '/boot/efi'
                else:
                    initial['mount'] = None
            if isinstance(disk, LVM_VolGroup):
                initial['name'] = partition.name
                lvm_names.remove(partition.name)
        else:
            initial['fstype'] = 'ext4'
            if isinstance(disk, LVM_VolGroup):
                x = 0
                while True:
                    name = 'lv-{}'.format(x)
                    if name not in lvm_names:
                        break
                    x += 1
                initial['name'] = name

        self.form = PartitionForm(
            self.model, max_size, initial, lvm_names, partition)

        if not isinstance(disk, LVM_VolGroup):
            self.form.remove_field('name')

        if label is not None:
            self.form.buttons.base_widget[0].set_label(label)
        else:
            del self.form.buttons.base_widget.contents[0]
            self.form.buttons.base_widget[0].set_label(_("OK"))

        if partition is not None:
            if boot.is_esp(partition):
                if partition.original_fstype():
                    opts = [
                        Option((
                            _("Use existing fat32 filesystem"),
                            True,
                            None
                            )),
                        Option(("---", False)),
                        Option((
                                _("Reformat as fresh fat32 filesystem"),
                                True,
                                "fat32"
                            )),
                        ]
                    self.form.fstype.widget.options = opts
                    if partition.fs().preserve:
                        self.form.fstype.widget.index = 0
                    else:
                        self.form.fstype.widget.index = 2
                    if not self.partition.grub_device:
                        self.form.fstype.enabled = False
                    self.form.mount.enabled = False
                else:
                    opts = [Option(("fat32", True))]
                    self.form.fstype.widget.options = opts
                    self.form.fstype.widget.index = 0
                    self.form.mount.enabled = False
                    self.form.fstype.enabled = False
            elif partition.flag in ["bios_grub", "prep"]:
                self.form.mount.enabled = False
                self.form.fstype.enabled = False
                self.form.size.enabled = False
            if partition.preserve:
                self.form.name.enabled = False
                self.form.size.enabled = False

        connect_signal(self.form, 'submit', self.done)
        connect_signal(self.form, 'cancel', self.cancel)

        rows = []
        focus_index = 0
        if partition is not None:
            if boot.is_esp(self.partition):
                if self.partition.grub_device:
                    desc = _(configured_boot_partition_description)
                    if self.partition.preserve:
                        desc += _(boot_partition_description_reformat)
                    else:
                        desc += _(boot_partition_description_size)
                else:
                    focus_index = 2
                    desc = _(unconfigured_boot_partition_description)
                rows.extend([
                    Text(rewrap(desc)),
                    Text(""),
                ])
            elif self.partition.flag == "bios_grub":
                if self.partition.device.grub_device:
                    middle = _(configured_bios_grub_partition_middle)
                else:
                    middle = _(unconfigured_bios_grub_partition_middle)
                desc = _(bios_grub_partition_description).format(middle=middle)
                rows.extend([
                    Text(rewrap(desc)),
                    Text(""),
                ])
                focus_index = 2
            elif self.partition.flag == "prep":
                if self.partition.grub_device:
                    desc = _(configured_prep_partition_description)
                else:
                    desc = _(unconfigured_prep_partition_description)
                rows.extend([
                    Text(rewrap(desc)),
                    Text(""),
                ])
                focus_index = 2
        rows.extend(self.form.as_rows())
        self.form.form_pile = Pile(rows)
        widgets = [
            self.form.form_pile,
            Text(""),
            self.form.buttons,
        ]

        if partition is None:
            if isinstance(disk, LVM_VolGroup):
                title = _("Adding logical volume to {vgname}").format(
                    vgname=labels.label(disk))
            else:
                title = _("Adding {ptype} partition to {device}").format(
                    ptype=disk.ptable_for_new_partition().upper(),
                    device=labels.label(disk))
        else:
            if isinstance(disk, LVM_VolGroup):
                title = _(
                    "Editing logical volume {lvname} of {vgname}"
                    ).format(
                        lvname=partition.name,
                        vgname=labels.label(disk))
            else:
                title = _("Editing partition {number} of {device}").format(
                    number=partition.number,
                    device=labels.label(disk))

        super().__init__(title, widgets, 0, focus_index)