def __init__(self, parent, obj): self.parent = parent self.obj = obj delete_ok, reason = can_delete(obj) if delete_ok: title = _("Confirm deletion of {}").format(obj.desc()) lines = [ _("Do you really want to delete {}?").format(obj.label), "", ] new_lines, delete_funcs = delete_consequences( self.parent.controller, obj) lines.extend(new_lines) self.delete_funcs = delete_funcs else: title = "Cannot delete {}".format(obj.desc()) lines = [ _("Cannot delete {} because {}").format(obj.label, reason) ] delete_btn = danger_btn(label=_("Delete"), on_press=self.confirm) if not delete_ok: delete_btn = WidgetDisable( Color.info_minor(delete_btn.original_widget)) widgets = [ Text("\n".join(lines)), Text(""), button_pile([ delete_btn, other_btn(label=_("Cancel"), on_press=self.cancel), ]), ] super().__init__(title, widgets, 0, 2)
def __init__(self, parent, obj): self.parent = parent self.obj = obj title = _("Confirm deletion of {}").format(obj.desc()) lines = [ _("Do you really want to delete {}?").format(obj.label), "", ] fs = obj.fs() if fs is not None: m = fs.mount() if m is not None: lines.append( _("It is formatted as {fstype} and mounted at " "{path}").format(fstype=fs.fstype, path=m.path)) else: lines.append( _("It is formatted as {fstype} and not mounted.").format( fstype=fs.fstype)) else: lines.append(_("It is not formatted or mounted.")) delete_btn = danger_btn(label=_("Delete"), on_press=self.confirm) widgets = [ Text("\n".join(lines)), Text(""), button_pile([ delete_btn, other_btn(label=_("Cancel"), on_press=self.cancel), ]), ] super().__init__(title, widgets, 0, 2)
def __init__(self, parent, thing, delete_func): self.parent = parent self.thing = thing self.delete_func = delete_func title = _("Confirm deletion of {}").format(thing.desc()) lines = [ _("Do you really want to delete {}?").format(thing.label), ] if isinstance(thing, Partition): lines.append("") if thing.fs(): fs = thing.fs() desc = _("It is formatted as {}").format(fs.fstype) if fs.mount(): desc += _(" and mounted at {}.").format(fs.mount().path) else: desc += _(" and not mounted.") else: desc = _("It is not formatted.") lines.append(desc) else: raise Exception("deletion of {} not yet supported".format( thing.desc())) widgets = [ Text("\n".join(lines)), Text(""), button_pile([ danger_btn(label=_("Delete"), on_press=self.confirm), other_btn(label=_("Cancel"), on_press=self.cancel), ]), ] super().__init__(title, widgets, 0, 2)
def __init__(self, parent, obj): self.parent = parent self.obj = obj lines = [ Text( _("Do you really want to delete the {desc} {label}?").format( desc=obj.desc(), label=obj.label)), Text(""), ] stretchy_index = 0 fs = obj.fs() if fs is not None: m = fs.mount() if m is not None: lines.append( Text( _("It is formatted as {fstype} and mounted at " "{path}").format(fstype=fs.fstype, path=m.path))) else: lines.append( Text( _("It is formatted as {fstype} and not mounted."). format(fstype=fs.fstype))) elif hasattr(obj, 'partitions') and len(obj.partitions()) > 0: n = len(obj.partitions()) if obj.type == "lvm_volgroup": if n == 1: things = _("logical volume") else: things = _("logical volumes") else: if n == 1: things = _("partition") else: things = _("partitions") lines.append( Text( _("It contains {n} {things}:").format(n=n, things=things))) lines.append(Text("")) stretchy_index = len(lines) rows = [] for p, cells in summarize_device(obj): if p not in [None, obj]: rows.append(TableRow(cells)) lines.append(TablePile(rows)) else: lines.append(Text(_("It is not formatted or mounted."))) delete_btn = danger_btn(label=_("Delete"), on_press=self.confirm) widgets = lines + [ Text(""), button_pile([ delete_btn, other_btn(label=_("Cancel"), on_press=self.cancel), ]), ] super().__init__("", widgets, stretchy_index, len(lines) + 1)
def __init__(self, parent, controller): self.parent = parent self.controller = controller pile = Pile([ UrwidPadding(Text(confirmation_text), left=2, right=2), button_pile([ cancel_btn(_("No"), on_press=self.cancel), danger_btn(_("Continue"), on_press=self.ok)]), Text(""), ]) lb = LineBox(pile, title=_("Confirm destructive action")) super().__init__(lb)
def __init__(self, app): self.app = app widgets = [ Text(rewrap(_(confirmation_text))), Text(""), button_pile([ cancel_btn(_("No"), on_press=self.cancel), danger_btn(_("Continue"), on_press=self.ok)]), ] super().__init__( _("Confirm destructive action"), widgets, stretchy_index=0, focus_index=2)
def __init__(self, parent, controller): self.parent = parent self.controller = controller widgets = [ Text(_(confirmation_text)), Text(""), button_pile([ cancel_btn(_("No"), on_press=self.cancel), danger_btn(_("Continue"), on_press=self.ok) ]), ] super().__init__(_("Confirm destructive action"), widgets, stretchy_index=0, focus_index=2)
def __init__(self, parent, obj): self.parent = parent self.obj = obj fs = obj.fs() if fs is not None: title = _("Remove filesystem from {device}").format( device=obj.desc()) lines = [ _("Do you really want to remove the existing filesystem " "from {device}?").format(device=obj.label), "", ] m = fs.mount() if m is not None: lines.append( _("It is formatted as {fstype} and mounted at " "{path}").format(fstype=fs.fstype, path=m.path)) else: lines.append( _("It is formatted as {fstype} and not mounted.").format( fstype=fs.fstype)) else: if obj.type == "lvm_volgroup": things = _("logical volumes") else: things = _("partitions") # things is either "logical volumes" or "partitions" title = _("Remove all {things} from {obj}").format(things=things, obj=obj.desc()) lines = [ _("Do you really want to remove all {things} from " "{obj}?").format(things=things, obj=obj.label), "", ] # XXX summarize partitions here? delete_btn = danger_btn(label=_("Reformat"), on_press=self.confirm) widgets = [ Text("\n".join(lines)), Text(""), button_pile([ delete_btn, other_btn(label=_("Cancel"), on_press=self.cancel), ]), ] super().__init__(title, widgets, 0, 2)
def __init__(self, controller, selection): self.controller = controller buttons = [ danger_btn("CONFIRM", on_press=self.confirm), back_btn("BACK", on_press=self.back), ] fmt = self.canned_summary.get(selection.action.mode, self.default_summary) summary = fmt.format(action=selection.action.title, action_lower=selection.action.title.lower(), model=selection.system.model.display_name, publisher=selection.system.brand.display_name, version=selection.system.label) rows = [ Text(summary), ] super().__init__( controller.model.current, screen(rows=rows, buttons=button_pile(buttons), focus_buttons=False))