def _update_luks_combo(self): if self._encryptCheckbutton.get_active(): really_show(self._luks_label) really_show(self._luks_combo) else: really_hide(self._luks_label) really_hide(self._luks_combo)
def _populate_raid(self): """ Set up the raid-specific portion of the device details. Hide the RAID level menu if this device type does not support RAID. Choose a default RAID level. """ if not containerRaidLevelsSupported(self.device_type): for widget in [self._raidLevelLabel, self._raidLevelCombo]: really_hide(widget) return raid_level = self.raid_level or defaultContainerRaidLevel( self.device_type) raid_level_name = raidLevelSelection(raid_level) # Set a default RAID level in the combo. for (i, row) in enumerate(self._raidLevelCombo.get_model()): log.debug("container dialog: raid level %s", row[1]) if row[1] == raid_level_name: self._raidLevelCombo.set_active(i) break for widget in [self._raidLevelLabel, self._raidLevelCombo]: really_show(widget) fancy_set_sensitive(self._raidLevelCombo, not self.exists)
def _populate_raid(self): """Set up the raid-specific portion of the device details. Hide the RAID level menu if this device type does not support RAID. Choose a default RAID level. """ self._raidStoreFilter.set_visible_func(self._raid_level_visible) self._raidStoreFilter.refilter() if not self._supported_raid_levels: for widget in [self._raidLevelLabel, self._raidLevelCombo]: really_hide(widget) return raid_level = self._request.container_raid_level for (i, row) in enumerate(self._raidLevelCombo.get_model()): if row[1] == raid_level: self._raidLevelCombo.set_active(i) break for widget in [self._raidLevelLabel, self._raidLevelCombo]: really_show(widget) fancy_set_sensitive(self._raidLevelCombo, self._permissions.container_raid_level)
def initialize(self): NormalSpoke.initialize(self) self._grabObjects() # I shouldn't have to do this outside GtkBuilder, but it really doesn't # want to let me pass in user data. self._autodetectButton.connect("toggled", self.on_source_toggled, self._autodetectBox) self._isoButton.connect("toggled", self.on_source_toggled, self._isoBox) self._networkButton.connect("toggled", self.on_source_toggled, self._networkBox) # Show or hide the updates option based on the installclass if self.instclass.installUpdates: really_show(self._updatesBox) else: really_hide(self._updatesBox) self._repoNameWarningBox = self.builder.get_object( "repoNameWarningBox") self._repoNameWarningLabel = self.builder.get_object( "repoNameWarningLabel") self._repoNamesWarningBox = self.builder.get_object( "repoNamesWarningBox") self._repoNamesWarningLabel = self.builder.get_object( "repoNamesWarningLabel") threadMgr.add( AnacondaThread(name=constants.THREAD_SOURCE_WATCHER, target=self._initialize))
def _update_summary(self): summary_button = self.builder.get_object("summary_button") label = self.builder.get_object("summary_button_label") # We need to remove ancestor devices from the count. Otherwise, we'll # end up in a situation where selecting one multipath device could # potentially show three devices selected (mpatha, sda, sdb for instance). count = len([ disk for disk in self._selected_disks if disk not in self._ancestors ]) summary = CP_( "GUI|Installation Destination|Filter", "{} _storage device selected", "{} _storage devices selected", count ).format(count) if count > 0: really_show(summary_button) label.set_text(summary) label.set_use_underline(True) else: really_hide(summary_button)
def __init__(self, title): Gtk.Box.__init__(self, orientation=Gtk.Orientation.VERTICAL, spacing=6) # Create the Data label and a box to store all its members in. self._dataBox = Gtk.Box(orientation=Gtk.Orientation.VERTICAL) self._dataLabel = self._make_category_label(_("DATA")) really_hide(self._dataLabel) self._dataBox.add(self._dataLabel) self._dataBox.connect("add", self._onSelectorAdded, self._dataLabel) self._dataBox.connect("remove", self._onSelectorRemoved, self._dataLabel) self.add(self._dataBox) # Create the System label and a box to store all its members in. self._systemBox = Gtk.Box(orientation=Gtk.Orientation.VERTICAL) self._systemLabel = self._make_category_label(_("SYSTEM")) really_hide(self._systemLabel) self._systemBox.add(self._systemLabel) self._systemBox.connect("add", self._onSelectorAdded, self._systemLabel) self._systemBox.connect("remove", self._onSelectorRemoved, self._systemLabel) self.add(self._systemBox) self.members = [] self.pageTitle = title
def _wrong_content(self, msg): content_discovery.clear_all(self._policy_data) really_hide(self._progress_spinner) self._fetch_button.set_sensitive(True) self._content_url_entry.set_sensitive(True) self._content_url_entry.grab_focus() self._content_url_entry.select_region(0, -1) self._set_error(msg)
def _wrong_content(self): self._addon_data.content_url = "" self._addon_data.content_type = "" really_hide(self._progress_spinner) self._fetch_button.set_sensitive(True) self._content_url_entry.set_sensitive(True) self._content_url_entry.grab_focus() self._content_url_entry.select_region(0, -1)
def _wrong_content(self, msg): self._addon_data.clear_all() really_hide(self._progress_spinner) self._fetch_button.set_sensitive(True) self._content_url_entry.set_sensitive(True) self._content_url_entry.grab_focus() self._content_url_entry.select_region(0, -1) self._content_handling_cls = None self._set_error(msg)
def __init__(self, data): """Create a new UIObject instance, including loading its uiFile and all UI-related objects. Instance attributes: data -- An instance of a pykickstart Handler object. The Hub never directly uses this instance. Instead, it passes it down into Spokes when they are created and applied. The Hub simply stores this instance so it doesn't need to be passed by the user. skipTo -- If this attribute is set to something other than None, it must be the name of a class (as a string). Then, the interface will skip to the first instance of that class in the action list instead of going on to whatever the next action is normally. Note that actions may only skip ahead, never backwards. Also, standalone spokes may not skip to an individual spoke off a hub. They can only skip to the hub itself. """ super().__init__(data) if self.__class__ is GUIObject: raise TypeError("GUIObject is an abstract class") self.skipTo = None self.applyOnSkip = False self.builder = Gtk.Builder() self.builder.set_translation_domain(self.translationDomain) self._window = None if self.builderObjects: self.builder.add_objects_from_file(self._findUIFile(), self.builderObjects) else: self.builder.add_from_file(self._findUIFile()) self.builder.connect_signals(self) # Hide keyboard indicator if we can't configure the keyboard # It doesn't really give you any benefit of seeing something which could # give you wrong values. # This has to be applied to every spoke and hub - we have to ignore dialog and other # non full screen parts. if not can_configure_keyboard() and isinstance( self.window, AnacondaWidgets.BaseWindow): layout_indicator = self.window.get_layout_indicator_box() really_hide(layout_indicator) layout_indicator.set_sensitive(False)
def _display_repo_names_message(self): """ Displays a warning if the list of repo names is not valid. Returns the warning message displayed, if any. """ warning_msg = self._verify_repo_names() if warning_msg: self._repoNamesWarningLabel.set_text(_(warning_msg)) really_show(self._repoNamesWarningBox) self.set_warning(_("Duplicate repository names not allowed; choose a unique name for each repository.")) self.window.show_all() else: self._repoNamesWarningLabel.set_text("") really_hide(self._repoNamesWarningBox) self.clear_info() return warning_msg
def _display_repo_name_message(self, repo, name): """ Displays a warning if the repo name is not valid. Returns the warning message displayed, if any. :param repo: kickstart repository object :type repo: RepoData :param name: the designated name for the repo :type name: string """ warning_msg = self._verify_repo_name(repo, name) if warning_msg: self._repoNameWarningLabel.set_text(_(warning_msg)) really_show(self._repoNameWarningBox) else: self._repoNameWarningLabel.set_text("") really_hide(self._repoNameWarningBox) return warning_msg
def _display_repo_names_message(self): """ Displays a warning if the list of repo names is not valid. Returns the warning message displayed, if any. """ warning_msg = self._verify_repo_names() if warning_msg: self._repoNamesWarningLabel.set_text(_(warning_msg)) really_show(self._repoNamesWarningBox) self.set_warning( _("Duplicate repository names not allowed; choose a unique name for each repository." )) self.window.show_all() else: self._repoNamesWarningLabel.set_text("") really_hide(self._repoNamesWarningBox) self.clear_info() return warning_msg
def _update_ids_visibility(self): """ Updates visibility of the combo boxes that are used to select the DS and XCCDF IDs. """ if self._using_ds: # only show the combo boxes if there are multiple data streams or # multiple xccdfs (IOW if there's something to choose from) ds_ids = list(self._ds_checklists.keys()) if len(ds_ids) > 1 or len(self._ds_checklists[ds_ids[0]]) > 1: really_show(self._ids_box) return # not showing, hide instead really_hide(self._ids_box)
def initialize(self): NormalSpoke.initialize(self) self._grabObjects() # I shouldn't have to do this outside GtkBuilder, but it really doesn't # want to let me pass in user data. self._autodetectButton.connect("toggled", self.on_source_toggled, self._autodetectBox) self._isoButton.connect("toggled", self.on_source_toggled, self._isoBox) self._networkButton.connect("toggled", self.on_source_toggled, self._networkBox) # Show or hide the updates option based on the installclass if self.instclass.installUpdates: really_show(self._updatesBox) else: really_hide(self._updatesBox) threadMgr.add(AnacondaThread(name=constants.THREAD_SOURCE_WATCHER, target=self._initialize))
def _set_status(self, error_message): """Set UI element states according to passphrase check results. NOTE: This method is called every time the checker finishes running all checks. """ success = not error_message if success: really_hide(self._passphrase_warning_image) really_hide(self._passphrase_warning_label) else: if not self._ascii_check.result.success: # ASCII check runs last, so if just it has failed the result is only a warning result_icon = "dialog-warning-symbolic" else: # something else failed and that's a critical error result_icon = "dialog-error-symbolic" self._passphrase_warning_image.set_from_icon_name( result_icon, Gtk.IconSize.BUTTON) self._passphrase_warning_label.set_text(error_message) really_show(self._passphrase_warning_image) really_show(self._passphrase_warning_label) # The save button should only be sensitive if both passphrases match # and are valid enough for current policy self._passphrase_good_enough = False if self._checker.success: self._passphrase_good_enough = True elif len( self._checker.failed_checks ) == 1 and self._validity_check in self._checker._failed_checks: # only the password validity check failed if self._checker.policy.is_strict: # this is not fine for the strict password policy self._passphrase_good_enough = False else: # but is totally fine under the non-strict policy self._passphrase_good_enough = True elif len(self._checker.failed_checks ) == 1 and self._ascii_check in self._checker._failed_checks: # enable the save button if only the ascii check has failed self._passphrase_good_enough = True # set the save button sensitivity accordingly self._save_button.set_sensitive(self._passphrase_good_enough)
def __init__(self, title): Gtk.Box.__init__(self, orientation=Gtk.Orientation.VERTICAL, spacing=6) # Create the Data label and a box to store all its members in. self._dataBox = Gtk.Box(orientation=Gtk.Orientation.VERTICAL) self._dataLabel = self._make_category_label(_("DATA")) really_hide(self._dataLabel) self._dataBox.add(self._dataLabel) self._dataBox.connect("add", self._onDataAdded) self._dataBox.connect("remove", self._onDataRemoved) self.add(self._dataBox) # Create the System label and a box to store all its members in. self._systemBox = Gtk.Box(orientation=Gtk.Orientation.VERTICAL) self._systemBox.add(self._make_category_label(_("SYSTEM"))) self.add(self._systemBox) self.members = [] self.pageTitle = title
def __init__(self, title): super().__init__(title) # Create the Data label and a box to store all its members in. self._data_box = Gtk.Box(orientation=Gtk.Orientation.VERTICAL) self._data_label = self._make_category_label(_("DATA")) really_hide(self._data_label) self._data_box.add(self._data_label) self._data_box.connect("add", self._on_selector_added, self._data_label) self._data_box.connect("remove", self._on_selector_removed, self._data_label) self.add(self._data_box) # Create the System label and a box to store all its members in. self._system_box = Gtk.Box(orientation=Gtk.Orientation.VERTICAL) self._system_label = self._make_category_label(_("SYSTEM")) really_hide(self._system_label) self._system_box.add(self._system_label) self._system_box.connect("add", self._on_selector_added, self._system_label) self._system_box.connect("remove", self._on_selector_removed, self._system_label) self.add(self._system_box)
def __init__(self, title): super().__init__(title) # Create the Data label and a box to store all its members in. self._dataBox = Gtk.Box(orientation=Gtk.Orientation.VERTICAL) self._dataLabel = self._make_category_label(_("DATA")) really_hide(self._dataLabel) self._dataBox.add(self._dataLabel) self._dataBox.connect("add", self._on_selector_added, self._dataLabel) self._dataBox.connect("remove", self._on_selector_removed, self._dataLabel) self.add(self._dataBox) # Create the System label and a box to store all its members in. self._systemBox = Gtk.Box(orientation=Gtk.Orientation.VERTICAL) self._systemLabel = self._make_category_label(_("SYSTEM")) really_hide(self._systemLabel) self._systemBox.add(self._systemLabel) self._systemBox.connect("add", self._on_selector_added, self._systemLabel) self._systemBox.connect("remove", self._on_selector_removed, self._systemLabel) self.add(self._systemBox)
def set_status(self, inputcheck): # Set the warning message with the result from the first failed check failed_check = next(self.failed_checks_with_message, None) if failed_check: result_icon, result_message = failed_check.check_status self._passphrase_warning_image.set_from_icon_name(result_icon, Gtk.IconSize.BUTTON) self._passphrase_warning_label.set_text(result_message) really_show(self._passphrase_warning_image) really_show(self._passphrase_warning_label) else: really_hide(self._passphrase_warning_image) really_hide(self._passphrase_warning_label) # The save button should only be sensitive if the match check passes if self._passphrase_match_check.check_status == InputCheck.CHECK_OK and \ (not self.policy.strict or self._strength_check.check_status == InputCheck.CHECK_OK): self._save_button.set_sensitive(True) else: self._save_button.set_sensitive(False)
def set_status(self, inputcheck): # Set the warning message with the result from the first failed check failed_check = next(self.failed_checks_with_message, None) if failed_check: result_icon, result_message = failed_check.check_status self._passphrase_warning_image.set_from_icon_name( result_icon, Gtk.IconSize.BUTTON) self._passphrase_warning_label.set_text(result_message) really_show(self._passphrase_warning_image) really_show(self._passphrase_warning_label) else: really_hide(self._passphrase_warning_image) really_hide(self._passphrase_warning_label) # The save button should only be sensitive if the match check passes if self._passphrase_match_check.check_status == InputCheck.CHECK_OK and \ (not self.policy.strict or self._strength_check.check_status == InputCheck.CHECK_OK): self._save_button.set_sensitive(True) else: self._save_button.set_sensitive(False)
def _set_status(self, error_message): """Set UI element states according to passphrase check results. NOTE: This method is called every time the checker finishes running all checks. """ success = not error_message if success: really_hide(self._passphrase_warning_image) really_hide(self._passphrase_warning_label) else: if not self._ascii_check.result.success: # ASCII check runs last, so if just it has failed the result is only a warning result_icon = "dialog-warning" else: # something else failed and that's a critical error result_icon = "dialog-error" self._passphrase_warning_image.set_from_icon_name(result_icon, Gtk.IconSize.BUTTON) self._passphrase_warning_label.set_text(error_message) really_show(self._passphrase_warning_image) really_show(self._passphrase_warning_label) # The save button should only be sensitive if both passphrases match # and are valid enough for current policy self._passphrase_good_enough = False if self._checker.success: self._passphrase_good_enough = True elif len(self._checker.failed_checks) == 1 and self._validity_check in self._checker._failed_checks: # only the password validity check failed if self._checker.policy.strict: # this is not fine for the strict password policy self._passphrase_good_enough = False else: # but is totally fine under the non-strict policy self._passphrase_good_enough = True elif len(self._checker.failed_checks) == 1 and self._ascii_check in self._checker._failed_checks: # enable the save button if only the ascii check has failed self._passphrase_good_enough = True # set the save button sensitivity accordingly self._save_button.set_sensitive(self._passphrase_good_enough)
def _populate_raid(self): """ Set up the raid-specific portion of the device details. Hide the RAID level menu if this device type does not support RAID. Choose a default RAID level. """ if not containerRaidLevelsSupported(self.device_type): for widget in [self._raidLevelLabel, self._raidLevelCombo]: really_hide(widget) return raid_level = self.raid_level or defaultContainerRaidLevel(self.device_type) raid_level_name = raidLevelSelection(raid_level) # Set a default RAID level in the combo. for (i, row) in enumerate(self._raidLevelCombo.get_model()): log.debug("container dialog: raid level %s", row[1]) if row[1] == raid_level_name: self._raidLevelCombo.set_active(i) break for widget in [self._raidLevelLabel, self._raidLevelCombo]: really_show(widget) fancy_set_sensitive(self._raidLevelCombo, not self.exists)
def _onDataRemoved(self, container, widget): # This runs before widget is removed from container, so if it's the last # item then the container will still not be empty. if len(container.get_children()) == 1: really_hide(self._dataLabel)
def refresh(self): """ The refresh method that is called every time the spoke is displayed. It should update the UI elements according to the contents of self.data. :see: pyanaconda.ui.common.UIObject.refresh """ if not self._addon_data.content_defined: # hide the control buttons really_hide(self._control_buttons) # provide SSG if available if common.ssg_available(): # show the SSG button and tweak the rest of the line # (the label) really_show(self._ssg_button) # TRANSLATORS: the other choice if SCAP Security Guide is also # available tip = _(" or enter data stream content or archive URL below:") else: # hide the SSG button really_hide(self._ssg_button) tip = _( "No content found. Please enter data stream content or " "archive URL below:") self._no_content_label.set_text(tip) # hide the progress box, no progress now with self._fetch_flag_lock: if not self._fetching: really_hide(self._progress_box) self._content_url_entry.set_sensitive(True) self._fetch_button.set_sensitive(True) if not self._content_url_entry.get_text(): # no text -> no info/warning self._progress_label.set_text("") # switch to the page allowing user to enter content URL and fetch # it self._main_notebook.set_current_page(GET_CONTENT_PAGE) self._content_url_entry.grab_focus() # nothing more to do here return else: # show control buttons really_show(self._control_buttons) self._main_notebook.set_current_page(SET_PARAMS_PAGE) self._active_profile = self._addon_data.profile_id self._update_ids_visibility() if self._using_ds: if self._addon_data.datastream_id: set_combo_selection(self._ds_combo, self._addon_data.datastream_id, unset_first=True) else: try: default_ds = next(iter(self._ds_checklists.keys())) set_combo_selection(self._ds_combo, default_ds, unset_first=True) except StopIteration: # no data stream available pass if self._addon_data.datastream_id and self._addon_data.xccdf_id: set_combo_selection(self._xccdf_combo, self._addon_data.xccdf_id, unset_first=True) else: # no combobox changes --> need to update profiles store manually self._update_profiles_store() if self._addon_data.profile_id: set_treeview_selection(self._profiles_view, self._addon_data.profile_id) self._rule_data = self._addon_data.rule_data self._update_message_store()
def refresh(self): """ The refresh method that is called every time the spoke is displayed. It should update the UI elements according to the contents of self.data. :see: pyanaconda.ui.common.UIObject.refresh """ if not self._addon_data.content_defined: # hide the control buttons really_hide(self._control_buttons) # provide SSG if available if common.ssg_available(): # show the SSG button and tweak the rest of the line # (the label) really_show(self._ssg_button) # TRANSLATORS: the other choice if SCAP Security Guide is also # available tip = _(" or enter data stream content or archive URL below:") else: # hide the SSG button really_hide(self._ssg_button) tip = _("No content found. Please enter data stream content or " "archive URL below:") self._no_content_label.set_text(tip) # hide the progress box, no progress now with self._fetch_flag_lock: if not self._fetching: really_hide(self._progress_box) self._content_url_entry.set_sensitive(True) self._fetch_button.set_sensitive(True) if not self._content_url_entry.get_text(): # no text -> no info/warning self._progress_label.set_text("") # switch to the page allowing user to enter content URL and fetch # it self._main_notebook.set_current_page(GET_CONTENT_PAGE) self._content_url_entry.grab_focus() # nothing more to do here return else: # show control buttons really_show(self._control_buttons) self._main_notebook.set_current_page(SET_PARAMS_PAGE) self._active_profile = self._addon_data.profile_id self._update_ids_visibility() if self._using_ds: if self._addon_data.datastream_id: set_combo_selection(self._ds_combo, self._addon_data.datastream_id, unset_first=True) else: try: default_ds = next(iter(self._ds_checklists.keys())) set_combo_selection(self._ds_combo, default_ds, unset_first=True) except StopIteration: # no data stream available pass if self._addon_data.datastream_id and self._addon_data.xccdf_id: set_combo_selection(self._xccdf_combo, self._addon_data.xccdf_id, unset_first=True) else: # no combobox changes --> need to update profiles store manually self._update_profiles_store() if self._addon_data.profile_id: set_treeview_selection(self._profiles_view, self._addon_data.profile_id) self._rule_data = self._addon_data.rule_data self._update_message_store()
def _onSelectorRemoved(self, container, widget, label): # This runs before widget is removed from container, so if it's the last # item then the container will still not be empty. if len(container.get_children()) == 1: really_hide(label)
def _on_finished(self, obj): """Handler for RegisterWidget's 'finished' signal.""" self._done = True really_hide(self.button_box)
def finished(self, obj): self._done = True really_hide(self.button_box)