def _build_buttons(self): log.debug('FileSystemView: building buttons') self.done = Toggleable(done_btn(_("Done"), on_press=self.done)) if not self.model.can_install(): self.done.disable() return [ self.done, reset_btn(_("Reset"), on_press=self.reset), back_btn(_("Back"), on_press=self.cancel), ]
def __init__(self, controller): self.controller = controller self.ongoing = {} # context -> line containing a spinner self.reboot_btn = Toggleable(ok_btn( _("Reboot Now"), on_press=self.reboot)) self.view_error_btn = cancel_btn( _("View error report"), on_press=self.view_error) self.view_log_btn = other_btn( _("View full log"), on_press=self.view_log) self.continue_btn = other_btn( _("Continue"), on_press=self.continue_) self.event_listbox = ListBox() self.event_linebox = MyLineBox(self.event_listbox) self.event_buttons = button_pile([self.view_log_btn]) event_body = [ ('weight', 1, Padding.center_79(self.event_linebox, min_width=76)), ('pack', Text("")), ('pack', self.event_buttons), ('pack', Text("")), ] self.event_pile = Pile(event_body) self.log_listbox = ListBox() log_linebox = MyLineBox(self.log_listbox, _("Full installer output")) log_body = [ ('weight', 1, log_linebox), ('pack', button_pile([other_btn(_("Close"), on_press=self.close_log)])), ] self.log_pile = Pile(log_body) super().__init__(self.event_pile)
def __init__(self, controller): self.controller = controller self.spinner = Spinner(controller.loop) self.reboot_btn = Toggleable( ok_btn(_("Reboot Now"), on_press=self.reboot)) self.exit_btn = cancel_btn(_("Exit To Shell"), on_press=self.quit) self.view_log_btn = other_btn(_("View full log"), on_press=self.view_log) self.event_listbox = ListBox() self.event_linebox = MyLineBox(self.event_listbox) self.event_buttons = button_pile([self.view_log_btn]) event_body = [ ('pack', Text("")), ('weight', 1, Padding.center_79(self.event_linebox, min_width=76)), ('pack', Text("")), ('pack', self.event_buttons), ('pack', Text("")), ] self.event_pile = Pile(event_body) self.log_listbox = ListBox() log_linebox = MyLineBox(self.log_listbox, _("Full installer output")) log_body = [ ('weight', 1, log_linebox), ('pack', button_pile([other_btn(_("Close"), on_press=self.close_log)])), ] self.log_pile = Pile(log_body) super().__init__(self.event_pile)
def _build_buttons(self): self.done = Toggleable(done_btn(_("Done"), on_press=self.done)) return [ self.done, reset_btn(_("Reset"), on_press=self.reset), back_btn(_("Back"), on_press=self.cancel), ]
def __init__(self, model, controller): self.model = model self.controller = controller self.mount_list = MountList(self) self.avail_list = DeviceList(self, True) self.used_list = DeviceList(self, False) self.avail_list.table.bind(self.used_list.table) self._create_raid_btn = Toggleable( menu_btn(label=_("Create software RAID (md)"), on_press=self.create_raid)) self._create_vg_btn = Toggleable( menu_btn(label=_("Create volume group (LVM)"), on_press=self.create_vg)) bp = button_pile([self._create_raid_btn, self._create_vg_btn]) bp.align = 'left' body = [ Text(_("FILE SYSTEM SUMMARY")), Text(""), self.mount_list, Text(""), Text(""), Text(_("AVAILABLE DEVICES")), Text(""), self.avail_list, Text(""), bp, Text(""), Text(""), Text(_("USED DEVICES")), Text(""), self.used_list, Text(""), ] self.lb = ListBox(body) self.lb.base_widget.offset_rows = 2 super().__init__( screen(self.lb, self._build_buttons(), focus_buttons=self.model.can_install())) self.frame = self._w.base_widget self.showing_guidance = False self.refresh_model_inputs()
def __init__(self, model, controller): log.debug('FileSystemView init start()') self.model = model self.controller = controller self.mount_list = MountList(self) self.avail_list = DeviceList(self, True) self.used_list = DeviceList(self, False) self.avail_list.table.bind(self.used_list.table) self._create_raid_btn = Toggleable( menu_btn(label=_("Create software RAID (md)"), on_press=self.create_raid)) self._create_vg_btn = Toggleable( menu_btn(label=_("Create volume group (LVM)"), on_press=self.create_vg)) bp = button_pile([self._create_raid_btn, self._create_vg_btn]) bp.align = 'left' body = [ Text(_("FILE SYSTEM SUMMARY")), Text(""), Padding.push_2(self.mount_list), Text(""), Text(""), Text(_("AVAILABLE DEVICES")), Text(""), Padding.push_2(self.avail_list), Text(""), Padding.push_2(bp), Text(""), Text(""), Text(_("USED DEVICES")), Text(""), Padding.push_2(self.used_list), Text(""), ] self.lb = ListBox(body) frame = screen(self.lb, self._build_buttons(), focus_buttons=self.model.can_install()) frame.width = ('relative', 95) super().__init__(frame) self.refresh_model_inputs() log.debug('FileSystemView init complete()')
def __init__(self, app, tty): self.app = app self.btn = Toggleable( other_btn(_("Switch to a shell"), on_press=self._debug_shell)) self.btn.enabled = False self.app.aio_loop.call_later(0.5, self._enable) widgets = [ Text(rewrap(_(running_text).format(tty=tty))), Text(''), button_pile([self.btn]), ] super().__init__("", widgets, stretchy_index=0, focus_index=2)
def set_bound_form_field(self, bff): super().set_bound_form_field(bff) self.all_rows = [] for kind, device in bff.form.all_devices: if kind == LABEL: self.all_rows.append(TableRow([ Text(" " + device.label), Text(humanize_size(device.size), align='right') ])) self.no_selector_rows.append(self.all_rows[-1]) self.all_rows.append(TableRow([ (2, Color.info_minor(Text(" " + device.desc()))) ])) self.no_selector_rows.append(self.all_rows[-1]) else: if kind == DEVICE: label = device.label prefix = " " elif kind == PART: label = _(" partition {}").format(device._number) prefix = " " else: raise Exception("unexpected kind {}".format(kind)) box = CheckBox( label, on_state_change=self._state_change_device, user_data=device) self.device_to_checkbox[device] = box size = Text(humanize_size(device.size), align='right') self.all_rows.append(Color.menu_button(TableRow([box, size]))) self.no_selector_rows.append(self.all_rows[-1]) selector = Selector(['active', 'spare']) connect_signal( selector, 'select', self._select_active_spare, device) selector = Toggleable( UrwidPadding( Color.menu_button(selector), left=len(prefix))) 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)
class FilesystemView(BaseView): title = _("Filesystem setup") footer = _("Select available disks to format and mount") def __init__(self, model, controller): log.debug('FileSystemView init start()') self.model = model self.controller = controller self.mount_list = MountList(self) self.avail_list = DeviceList(self, True) self.used_list = DeviceList(self, False) self.avail_list.table.bind(self.used_list.table) body = [ Text(_("FILE SYSTEM SUMMARY")), Text(""), Padding.push_2(self.mount_list), Text(""), Text(""), Text(_("AVAILABLE DEVICES")), Text(""), Padding.push_2(self.avail_list), Text(""), Text(""), Text(_("USED DEVICES")), Text(""), Padding.push_2(self.used_list), Text(""), ] self.lb = ListBox(body) frame = screen(self.lb, self._build_buttons(), focus_buttons=self.model.can_install()) frame.width = ('relative', 95) super().__init__(frame) log.debug('FileSystemView init complete()') def _build_buttons(self): log.debug('FileSystemView: building buttons') self.done = Toggleable(done_btn(_("Done"), on_press=self.done)) if not self.model.can_install(): self.done.disable() return [ self.done, reset_btn(_("Reset"), on_press=self.reset), back_btn(_("Back"), on_press=self.cancel), ] def refresh_model_inputs(self): self.mount_list.refresh_model_inputs() self.avail_list.refresh_model_inputs() self.used_list.refresh_model_inputs() # If refreshing the view has left the focus widget with no # selectable widgets, simulate a tab to move to the next # selectable widget. while not self.lb.base_widget.focus.selectable(): self.lb.base_widget.keypress((10, 10), 'tab') if self.model.can_install(): self.done.enable() else: self.done.disable() def cancel(self, button=None): self.controller.default() def reset(self, button): self.controller.reset() def done(self, button): self.show_stretchy_overlay( FilesystemConfirmation(self, self.controller))