def on_reset_button_clicked(self, *args): msg = _("Continuing with this action will reset all your partitioning selections " "to their current on-disk state.") dlg = Gtk.MessageDialog(flags=Gtk.DialogFlags.MODAL, message_type=Gtk.MessageType.WARNING, buttons=Gtk.ButtonsType.NONE, message_format=msg) dlg.set_decorated(False) dlg.add_buttons(C_("GUI|Custom Partitioning|Reset Dialog", "_Reset selections"), 0, C_("GUI|Custom Partitioning|Reset Dialog", "_Preserve current selections"), 1) dlg.set_default_response(1) with self.main_window.enlightbox(dlg): rc = dlg.run() dlg.destroy() if rc == 0: self.refresh() self.blivetgui.reload() # XXX: Reset currently preserves actions set in previous runs # of the spoke, so we need to 're-add' these to the ui current_actions = self._storage_playground.devicetree.actions.find() if current_actions: self.blivetgui.set_actions(current_actions)
def prompt(self, args=None): """Show an alternative prompt if the hub contains only one spoke. Otherwise it is not readily apparent that the user needs to press 1 to enter the single visible spoke. :param args: optional argument passed from switch_screen calls :type args: anything :return: returns text to be shown next to the prompt for input or None to skip further input processing :rtype: str|None """ if self._spoke_count == 1: return _(u" Please make your choice from [ '1' to enter the %(spoke_title)s spoke | '%(quit)s' to quit |\n" " '%(continue)s' to continue | '%(refresh)s' to refresh]: ") % { 'spoke_title': self._spokes.values()[0].title, # TRANSLATORS: 'q' to quit 'quit': C_('TUI|Spoke Navigation', 'q'), # TRANSLATORS:'c' to continue 'continue': C_('TUI|Spoke Navigation', 'c'), # TRANSLATORS:'r' to refresh 'refresh': C_('TUI|Spoke Navigation', 'r') } else: return super(TUIHub, self).prompt(args)
def refresh(self, mountpoint, device, rootName, snapshots=False): GUIObject.refresh(self) label = self.builder.get_object("confirmLabel") if rootName and "_" in rootName: rootName = rootName.replace("_", "__") delete_all_text = (C_( "GUI|Custom Partitioning|Confirm Delete Dialog", "Delete _all other file systems in the %s root as well." ) + "\n" + C_( "GUI|Custom Partitioning|Confirm Delete Dialog", "(This includes those shared with other installed operating systems.)" )) self._removeAll.set_label(delete_all_text % rootName) self._removeAll.set_sensitive(rootName is not None) if mountpoint: txt = "%s (%s)" % (mountpoint, device) else: txt = device if not snapshots: label_text = _( "Are you sure you want to delete all of the data on %s?") % txt else: label_text = _( "Are you sure you want to delete all of the data on %s, including snapshots and/or subvolumes?" ) % txt label.set_text(label_text)
def input(self, args, key): """Handle user input. Numbers are used to show a spoke, the rest is passed to the higher level for processing.""" if self._container.process_user_input(key): return InputState.PROCESSED else: # If we get a continue, check for unfinished spokes. If unfinished # don't continue # TRANSLATORS: 'b' to begin installation if key == C_('TUI|Spoke Navigation', 'b'): for spoke in self._spokes.values(): if not spoke.completed and spoke.mandatory: print( _("Please complete all spokes before continuing")) return InputState.DISCARDED # do a bit of final sanity checking, making sure pkg selection # size < available fs space if self._checker and not self._checker.check(): print(self._checker.error_message) return InputState.DISCARDED self.close() return InputState.PROCESSED # TRANSLATORS: 'c' to continue elif key == C_('TUI|Spoke Navigation', 'c'): # Kind of a hack, but we want to ignore if anyone presses 'c' # which is the global TUI key to close the current screen return InputState.DISCARDED else: return super(SummaryHub, self).input(args, key)
def _toggle_button_text(self, row): if row[IS_BOOT_COL]: self._set_button.set_label( C_("GUI|Selected Disks Dialog", "_Do not install boot loader")) else: self._set_button.set_label( C_("GUI|Selected Disks Dialog", "_Set as Boot Device"))
def input(self, args, key): """Handle user input. Numbers are used to show a spoke, the rest is passed to the higher level for processing.""" try: number = int(key) self.app.switch_screen_with_return(self._keys[number]) return None except (ValueError, KeyError): # If we get a continue, check for unfinished spokes. If unfinished # don't continue # TRANSLATORS: 'b' to begin installation if key == C_('TUI|Spoke Navigation', 'b'): for spoke in self._spokes.values(): if not spoke.completed and spoke.mandatory: print( _("Please complete all spokes before continuing")) return False # do a bit of final sanity checking, making sure pkg selection # size < available fs space if self._checker and not self._checker.check(): print(self._checker.error_message) return False if self.app._screens: self.app.close_screen() return True # TRANSLATORS: 'c' to continue elif key == C_('TUI|Spoke Navigation', 'c'): # Kind of a hack, but we want to ignore if anyone presses 'c' # which is the global TUI key to close the current screen return False else: return super(SummaryHub, self).input(args, key)
def __init__(self, *args, **kwargs): buttons = kwargs.pop("buttons", []) label = kwargs.pop("label", None) GUIObject.__init__(self, *args, **kwargs) if not buttons: widget = self.window.add_button( C_("GUI|Detailed Error Dialog", "_Cancel"), 0) else: buttonbox = self.builder.get_object("detailedButtonBox") i = 0 for button in buttons: widget = self.window.add_button(button, i) # Quit buttons should always appear left-most, unless it's the # only button. Then it should appear on the right. if button == C_("GUI|Detailed Error Dialog", "_Quit") and len(buttons) > 1: buttonbox.set_child_secondary(widget, True) i += 1 widget.set_can_default(True) widget.grab_default() if label: self.builder.get_object("detailedLabel").set_text(label)
def input(self, args, key): """ Grab the choice and update things. """ if not self._container.process_user_input(key): # TRANSLATORS: 's' to rescan devices if key.lower() == C_('TUI|Spoke Navigation|Partitioning', 's'): text = _( "Warning: This will revert all changes done so far.\nDo you want to proceed?\n" ) question_window = YesNoDialog(text) ScreenHandler.push_screen_modal(question_window) if question_window.answer: # unset self.data.ignoredisk.onlyuse temporarily so that # storage_initialize() processes all devices ignoredisk = self.data.ignoredisk.onlyuse self.data.ignoredisk.onlyuse = [] print(_("Scanning disks. This may take a moment...")) storage_initialize( self.storage, self.data, self.storage.devicetree.protected_dev_names) self.data.ignoredisk.onlyuse = ignoredisk self.data.mount.clear_mount_data() self._gather_mount_data_info() self.redraw() return InputState.PROCESSED # TRANSLATORS: 'c' to continue elif key.lower() == C_('TUI|Spoke Navigation', 'c'): self.apply() return super(MountPointAssignSpoke, self).input(args, key) return InputState.PROCESSED
def prompt(self, args = None): return _("Please select the timezone.\nUse numbers or type names directly ['%(back)s' to region list, '%(quit)s' to quit]: ") % { # TRANSLATORS: 'b' to go back 'back': C_('TUI|Spoke Navigation|Time Settings', 'b'), # TRANSLATORS:'q' to quit 'quit': C_('TUI|Spoke Navigation|Time Settings', 'q') }
def prompt(self, args=None): return _("Please respond '%(yes)s' or '%(no)s': ") % { # TRANSLATORS: 'yes' as positive reply "yes": C_('TUI|Spoke Navigation', 'yes'), # TRANSLATORS: 'no' as negative reply "no": C_('TUI|Spoke Navigation', 'no') }
def on_info_bar_clicked(self, *args): if not self._errorMsgs: return label = _("The software marked for installation has the following errors. " "This is likely caused by an error with your installation source. " "You can quit the installer, change your software source, or change " "your software selections.") dialog = DetailedErrorDialog(self.data, buttons=[C_("GUI|Software Selection|Error Dialog", "_Quit"), C_("GUI|Software Selection|Error Dialog", "_Modify Software Source"), C_("GUI|Software Selection|Error Dialog", "Modify _Selections")], label=label) with self.main_window.enlightbox(dialog.window): dialog.refresh(self._errorMsgs) rc = dialog.run() dialog.window.destroy() if rc == 0: # Quit. iutil.ipmi_report(constants.IPMI_ABORTED) sys.exit(0) elif rc == 1: # Send the user to the installation source spoke. self.skipTo = "SourceSpoke" self.window.emit("button-clicked") elif rc == 2: # Close the dialog so the user can change selections. pass else: pass
def on_info_bar_clicked(self, *args): if not self._errorMsgs: return label = _("The following software marked for installation has errors. " "This is likely caused by an error with\nyour installation source. " "You can change your installation source or quit the installer.") dialog = DetailedErrorDialog(self.data, buttons=[C_("GUI|Software Selection|Error Dialog", "_Quit"), C_("GUI|Software Selection|Error Dialog", "_Cancel"), C_("GUI|Software Selection|Error Dialog", "_Modify Software Source")], label=label) with enlightbox(self.window, dialog.window): dialog.refresh(self._errorMsgs) rc = dialog.run() dialog.window.destroy() if rc == 0: # Quit. sys.exit(0) elif rc == 1: # Close the dialog so the user can change selections. pass elif rc == 2: # Send the user to the installation source spoke. self.skipTo = "SourceSpoke" self.window.emit("button-clicked") else: pass
def prompt(self, args=None): incompleteSpokes = [ spoke for spoke in self._keys.values() if spoke.mandatory and not spoke.completed ] # Kickstart space check failure either stops the automated install or # raises an error when using cmdline mode. # # For non-cmdline, prompt for input but continue to treat it as an # automated install. The spokes (in particular software selection, # which expects an environment for interactive install) will continue # to behave the same, so the user can hit 'b' at the prompt and ignore # the warning. if flags.automatedInstall and self._checker and not self._checker.check( ): print(self._checker.error_message) log.error(self._checker.error_message) # Unset the checker so everything passes next time self._checker = None if not flags.ksprompt: return None else: # TRANSLATORS: 'b' to begin installation print( _("Enter '%s' to ignore the warning and attempt to install anyway." ) % # TRANSLATORS: 'b' to begin installation C_("TUI|Spoke Navigation", "b")) elif flags.automatedInstall and not incompleteSpokes: # Space is ok and spokes are complete, continue self.close() return None # cmdline mode and incomplete spokes raises and error if not flags.ksprompt and incompleteSpokes: errtxt = _("The following mandatory spokes are not completed:") + \ "\n" + "\n".join(spoke.title for spoke in incompleteSpokes) log.error("CmdlineError: %s", errtxt) raise CmdlineError(errtxt) # if we ever need to halt the flow of a ks install to prompt users for # input, flip off the automatedInstall flag -- this way installation # does not automatically proceed once all spokes are complete, and a # user must confirm they want to begin installation if incompleteSpokes: flags.automatedInstall = False # override the default prompt since we want to offer the 'b' to begin # installation option here prompt = super(SummaryHub, self).prompt(args) # this screen cannot be closed prompt.remove_option(Prompt.CONTINUE) # TRANSLATORS: 'b' to begin installation prompt.add_option(C_("TUI|Spoke Navigation", "b"), _("to begin installation")) return prompt
def prompt(self, args=None): """ Override default prompt with a custom prompt. """ return _("Please select language support to install.\n[%(back)s to return to language list, %(continue)s to continue, %(quit)s to quit]: ") % { # TRANSLATORS: 'b' to go back 'back': C_('TUI|Spoke Navigation|Language Support', 'b'), # TRANSLATORS:'c' to continue 'continue': C_('TUI|Spoke Navigation|Language Support', 'c'), # TRANSLATORS:'q' to quit 'quit': C_('TUI|Spoke Navigation|Language Support', 'q') }
def input(self, args, key): """Method called internally to process unhandled input key presses. Also handles the main quit and close commands. :param args: optional argument passed from switch_screen calls :type args: anything :param key: the string entered by user :type key: str :return: True if key was processed, False if it was not recognized :rtype: True|False """ # delegate the handling to active screen first if self._screens: try: key = self._screens[-1][0].input(args, key) if key is None: return True except ExitMainLoop: raise except Exception: # pylint: disable=broad-except send_exception(self.queue_instance, sys.exc_info()) return False # global refresh command # TRANSLATORS: 'r' to refresh if self._screens and (key == C_('TUI|Spoke Navigation', 'r')): self._do_redraw() return True # global close command # TRANSLATORS: 'c' to continue if self._screens and (key == C_('TUI|Spoke Navigation', 'c')): self.close_screen() return True # global quit command # TRANSLATORS: 'q' to quit elif self._screens and (key == C_('TUI|Spoke Navigation', 'q')): if self.quit_question: d = self.quit_question(self, _(self.quit_message)) self.switch_screen_modal(d) if d.answer: raise ExitAllMainLoops() iutil.ipmi_report(constants.IPMI_ABORTED) return True return False
def input(self, args, key): # TRANSLATORS: 'yes' as positive reply if key == C_('TUI|Spoke Navigation', 'yes'): self._response = True self.close() return None # TRANSLATORS: 'no' as negative reply elif key == C_('TUI|Spoke Navigation', 'no'): self._response = False self.close() return None else: return False
def showYesNoQuestion(self, message): dlg = Gtk.MessageDialog(flags=Gtk.DialogFlags.MODAL, message_type=Gtk.MessageType.QUESTION, buttons=Gtk.ButtonsType.NONE, message_format=message) dlg.set_decorated(False) dlg.add_buttons(C_("GUI|Yes No Dialog", "_No"), 0, C_("GUI|Yes No Dialog", "_Yes"), 1) dlg.set_default_response(1) with self.mainWindow.enlightbox(dlg): rc = dlg.run() dlg.destroy() return bool(rc)
def _storageResetHandler(self, exn): message = (_("There is a problem with your existing storage " "configuration: %(errortxt)s\n\n" "You must resolve this matter before the installation can " "proceed. There is a shell available for use which you " "can access by pressing ctrl-alt-f1 and then ctrl-b 2." "\n\nOnce you have resolved the issue you can retry the " "storage scan. If you do not fix it you will have to exit " "the installer.") % {"errortxt": exn}) details = _(exn.suggestion) buttons = (C_("GUI|Storage Detailed Error Dialog", "_Exit Installer"), C_("GUI|Storage Detailed Error Dialog", "_Retry")) if self.ui.showDetailedError(message, details, buttons=buttons): return ERROR_RETRY else: return ERROR_RAISE
def input(self, args, key): if self._container.process_user_input(key): return InputState.PROCESSED else: if key.lower().replace("_", " ") in self._lower_zones: index = self._lower_zones.index(key.lower().replace("_", " ")) self._selection = self._zones[index] self.apply() self.close() return InputState.PROCESSED elif key.lower() in self._lower_regions: index = self._lower_regions.index(key.lower()) if len(self._timezones[self._regions[index]]) == 1: self._selection = "%s/%s" % ( self._regions[index], self._timezones[self._regions[index]][0]) self.apply() self.close() else: ScreenHandler.replace_screen(self, self._regions[index]) return InputState.PROCESSED # TRANSLATORS: 'b' to go back elif key.lower() == C_('TUI|Spoke Navigation|Time Settings', 'b'): ScreenHandler.replace_screen(self) return InputState.PROCESSED else: return key
def input(self, args, key): """ Handle the input; this chooses the desktop environment. """ if self._container is not None and self._container.process_user_input(key): self.redraw() else: # TRANSLATORS: 'c' to continue if key.lower() == C_('TUI|Spoke Navigation', 'c'): # No environment was selected, close if self._selected_environment is None: self.close() # The environment was selected, switch screen elif args is None: # Get addons for the selected environment environment = self._translate_env_selection_to_name(self._selected_environment) environment_id = self._translate_env_name_to_id(environment) addons = self._get_available_addons(environment_id) # Switch the screen ScreenHandler.replace_screen(self, addons) # The addons were selected, apply and close else: self.apply() self.close() return InputState.PROCESSED else: return super(SoftwareSpoke, self).input(args, key) return InputState.PROCESSED
def input(self, args, key): """Override input so that we can launch the VNC password spoke""" try: keyid = int(key) - 1 if 0 <= keyid < len(self._choices): choice = self._choices[keyid] if choice == _(USETEXT): self._usevnc = False else: self._usevnc = True newspoke = VNCPassSpoke(self.app, self.data, self.storage, self.payload, self.instclass) self.app.switch_screen_modal(newspoke) self.apply() self.close() return INPUT_PROCESSED except ValueError: pass # TRANSLATORS: 'q' to quit if key.lower() == C_('TUI|Spoke Navigation', 'q'): d = YesNoDialog(self.app, _(self.app.quit_message)) self.app.switch_screen_modal(d) if d.answer: ipmi_abort(scripts=self.data.scripts) if can_touch_runtime_system("Quit and Reboot"): execWithRedirect("systemctl", ["--no-wall", "reboot"]) else: sys.exit(1) else: return super(AskVNCSpoke, self).input(args, key)
def prompt(self, args=None): """ Customize default prompt. """ prompt = NormalTUISpoke.prompt(self, args) prompt.set_message(_("Please select the timezone. Use numbers or type names directly")) # TRANSLATORS: 'b' to go back prompt.add_option(C_('TUI|Spoke Navigation|Time Settings', 'b'), _("back to region list")) return prompt
def prompt(self, args=None): """ Override the default TUI prompt.""" return _( "Please make your selection from the above list.\nPress '%(continue)s' " "to continue after you have made your selection. ") % { # TRANSLATORS:'c' to continue 'continue': C_('TUI|Root Selection', 'c'), }
def prompt(self, args=None): """ Customize default prompt. """ prompt = NormalTUISpoke.prompt(self, args) prompt.set_message(_("Please select language support to install")) # TRANSLATORS: 'b' to go back prompt.add_option(C_("TUI|Spoke Navigation|Language Support", "b"), _("to return to language list")) return prompt
def prompt(self, args=None): incompleteSpokes = [ spoke for spoke in self._keys.values() if spoke.mandatory and not spoke.completed ] # do a bit of final sanity checking, make sure pkg selection # size < available fs space if flags.automatedInstall: if self._checker and not self._checker.check(): print(self._checker.error_message) if not incompleteSpokes: self.close() return None if flags.ksprompt: for spoke in incompleteSpokes: log.info("kickstart installation stopped for info: %s", spoke.title) else: errtxt = _("The following mandatory spokes are not completed:") + \ "\n" + "\n".join(spoke.title for spoke in incompleteSpokes) log.error("CmdlineError: %s", errtxt) raise CmdlineError(errtxt) # if we ever need to halt the flow of a ks install to prompt users for # input, flip off the automatedInstall flag -- this way installation # does not automatically proceed once all spokes are complete, and a # user must confirm they want to begin installation flags.automatedInstall = False # override the default prompt since we want to offer the 'b' to begin # installation option here return _( " Please make your choice from above ['%(quit)s' to quit | '%(begin)s' to begin installation |\n '%(refresh)s' to refresh]: " ) % { # TRANSLATORS: 'q' to quit 'quit': C_('TUI|Spoke Navigation', 'q'), # TRANSLATORS: 'b' to begin installation 'begin': C_('TUI|Spoke Navigation', 'b'), # TRANSLATORS: 'r' to refresh 'refresh': C_('TUI|Spoke Navigation', 'r') }
def prompt(self, args=None): """Return the text to be shown as prompt or handle the prompt and return None. :param args: optional argument passed from switch_screen calls :type args: anything :return: returns text to be shown next to the prompt for input or None to skip further input processing :rtype: str|None """ return _(u" Please make your choice from above ['%(quit)s' to quit | '%(continue)s' to continue |\n '%(refresh)s' to refresh]: ") % { # TRANSLATORS: 'q' to quit 'quit': C_('TUI|Spoke Navigation', 'q'), # TRANSLATORS:'c' to continue 'continue': C_('TUI|Spoke Navigation', 'c'), # TRANSLATORS:'r' to refresh 'refresh': C_('TUI|Spoke Navigation', 'r') }
def showDetailedError(self, message, details, buttons=None): from pyanaconda.ui.gui.spokes.lib.detailederror import DetailedErrorDialog buttons = buttons or [C_("GUI|Detailed Error Dialog", "_Quit")] dlg = DetailedErrorDialog(None, buttons=buttons, label=message) with self.mainWindow.enlightbox(dlg.window): dlg.refresh(details) rc = dlg.run() dlg.window.destroy() return rc
def input(self, args, key): """ Handle user input. """ if self._container.process_user_input(key): return InputState.PROCESSED else: # TRANSLATORS: 'b' to go back if key.lower() == C_("TUI|Spoke Navigation|Language Support", "b"): ScreenHandler.replace_screen(self) return InputState.PROCESSED else: return super(LangSpoke, self).input(args, key)
def on_delete_all_clicked(self, button, *args): if button.get_label() == C_("GUI|Reclaim Dialog", "Delete _all"): action = DELETE button.set_label(C_("GUI|Reclaim Dialog", "Preserve _all")) else: action = PRESERVE button.set_label(C_("GUI|Reclaim Dialog", "Delete _all")) itr = self._diskStore.get_iter_first() while itr: obj = PartStoreRow(*self._diskStore[itr]) if not obj.editable: itr = self._diskStore.iter_next(itr) continue device = self.storage.devicetree.getDeviceByID(obj.id) if device.isDisk: self._actionChanged(itr, action) itr = self._diskStore.iter_next(itr)
def input(self, args, key): if self._container is not None and self._container.process_user_input( key): return InputState.PROCESSED # TRANSLATORS: 'c' to continue elif key.lower() == C_('TUI|Spoke Navigation', 'c'): self.apply() self.close() return InputState.PROCESSED else: return super(SelectISOSpoke, self).input(args, key)