Example #1
0
 def _get_selected_repo_id(self):
     selected = None
     override_selection = SelectionWrapper(self.overrides_treeview.get_selection(),
                                           self.overrides_store)
     if override_selection.is_valid():
         selected = override_selection['repo_id']
     return selected
Example #2
0
    def _on_reset_repo(self, button):
        selection = SelectionWrapper(self.overrides_treeview.get_selection(),
                                     self.overrides_store)

        if not selection.is_valid():
            return

        confirm = YesNoDialog(_("Are you sure you want to remove all overrides for <b>%s</b>?") % selection['repo_id'],
                                 self._get_dialog_widget(), _("Confirm Remove All Overrides"))
        confirm.connect("response", self._on_reset_repo_response)
Example #3
0
    def _on_selection(self, tree_selection):
        selection = SelectionWrapper(tree_selection, self.overrides_store)

        self.other_overrides.clear()
        self.reset_button.set_sensitive(selection.is_valid() and selection['modified'])
        if selection.is_valid():
            self.name_text.get_buffer().set_text(selection['name'])
            self.baseurl_text.get_buffer().set_text(selection['baseurl'])

            for key, value in (selection['override_data'] or {}).items():
                if key not in ['gpgcheck', 'enabled']:
                    self.other_overrides.add_override(key, value)
Example #4
0
    def _on_reset_repo_response(self, dialog, response):
        if not response:
            return

        selection = SelectionWrapper(self.overrides_treeview.get_selection(),
                                     self.overrides_store)

        if not selection.is_valid():
            return

        repo_id = selection['repo_id']

        self._show_progress_bar(_("Removing Repository Overrides"), _("Removing all overrides for repository <b>%s</b>") % repo_id)
        self.async_update.remove_all_overrides([repo_id], self._on_async_delete_all_overrides_success,
                                          self._on_async_delete_all_overrides_failure)
Example #5
0
    def _on_async_delete_all_overrides_success(self, current_overrides,
                                               current_repos):
        selection = SelectionWrapper(self.overrides_treeview.get_selection(),
                                     self.overrides_store)

        repo_id = selection['repo_id']
        repo_data = None
        for repo in current_repos:
            if repo_id == repo.id:
                repo_data = repo
                break

        if repo_data:
            override_data = None
            for override in current_overrides:
                if repo_id == override.repo_id:
                    override_data = override
                    break

            row_data = self._build_table_row_data(repo_data, override_data)
            self.overrides_store.update_map(selection.tree_iter, row_data)

        # Update the UI based on the current selection as no selection change is
        # triggered, but data may enable/disable different widgets based on data
        # change.
        self._on_selection(self.overrides_treeview.get_selection())

        self._clear_progress_bar()
Example #6
0
    def _on_reset_repo_response(self, dialog, response):
        if not response:
            return

        selection = SelectionWrapper(self.overrides_treeview.get_selection(),
                                     self.overrides_store)

        if not selection.is_valid():
            return

        repo_id = selection['repo_id']

        try:
            self._delete_all_overrides(repo_id)
        except Exception, e:
            handle_gui_exception(e, _("Unable to reset repository overrides."),
                                 self._get_dialog_widget())
Example #7
0
    def _on_selection(self, tree_selection):
        selection = SelectionWrapper(tree_selection, self.overrides_store)

        self.other_overrides.clear()
        reset_enabled = False
        if selection.is_valid():
            overrides = selection['override_data']
            reset_enabled = overrides is not None and len(overrides) > 0

            self.name_text.set_text(selection['name'])
            self.baseurl_text.set_text(selection['baseurl'])

            for key, value in list((selection['override_data'] or {}).items()):
                if key not in ['gpgcheck', 'enabled']:
                    self.other_overrides.add_override(key, value)

        self.reset_button.set_sensitive(reset_enabled)
    def _on_selection(self, tree_selection):
        selection = SelectionWrapper(tree_selection, self.overrides_store)

        self.other_overrides.clear()
        reset_enabled = False
        if selection.is_valid():
            overrides = selection['override_data']
            reset_enabled = overrides is not None and len(overrides) > 0

            self.name_text.set_text(selection['name'])
            self.baseurl_text.set_text(selection['baseurl'])

            for key, value in (selection['override_data'] or {}).items():
                if key not in ['gpgcheck', 'enabled']:
                    self.other_overrides.add_override(key, value)

        self.reset_button.set_sensitive(reset_enabled)
Example #9
0
    def _on_selection(self, tree_selection):
        selection = SelectionWrapper(tree_selection, self.overrides_store)

        self._set_details_visible(selection.is_valid())
        self.reset_button.set_sensitive(selection.is_valid() and selection['modified'])
        if selection.is_valid():
            gpgcheck_enabled = selection['gpgcheck']
            gpgcheck_str = _("Enabled")
            if not gpgcheck_enabled:
                gpgcheck_str = _("Disabled")

            self.name_text.get_buffer().set_text(selection['name'])
            self.baseurl_text.get_buffer().set_text(selection['baseurl'])
            self.gpgcheck_text.get_buffer().set_text(gpgcheck_str)
            # Used 'not' here because we enabled is index 0 in the model.
            self.gpgcheck_combo_box.set_active(int(not gpgcheck_enabled))
            self._set_gpg_lock_state(not selection['gpgcheck_modified'])
Example #10
0
    def _on_remove_gpgcheck_confirmation(self, dialog, response):
        if not response:
            return

        override_selection = SelectionWrapper(self.overrides_treeview.get_selection(),
                                              self.overrides_store)
        if not override_selection.is_valid():
            # TODO Should never happen, but we should update the UI somehow
            # to make sure that nothing bad can happen.
            return

        # Delete the override
        try:
            self._delete_override(override_selection['repo_id'], 'gpgcheck')
        except Exception, e:
            handle_gui_exception(e, _("Unable to delete the gpgcheck override."),
                                 self._get_dialog_widget())
            return
Example #11
0
    def _on_gpgcheck_edit_button_clicked(self, button):
        override_selection = SelectionWrapper(self.overrides_treeview.get_selection(),
                                              self.overrides_store)
        if not override_selection.is_valid():
            # TODO Should never happen, but we should update the UI somewho
            # to make sure that nothing bad can happen.
            return

        current_value = override_selection['gpgcheck']
        self.gpgcheck_combo_box.set_active(not current_value)

        # Create an override despite the fact that the values are likely the same.
        try:
            self._add_override(override_selection['repo_id'], "gpgcheck",
                               int(current_value))
        except Exception, e:
            handle_gui_exception(e, _("Unable to update the gpgcheck override."),
                                 self._get_dialog_widget())
            return
Example #12
0
    def _on_gpgcheck_combo_box_changed(self, combo_box):
        override_selection = SelectionWrapper(self.overrides_treeview.get_selection(),
                                              self.overrides_store)

        # Ignore combo box changes when the dialog is first loadded.
        if not override_selection.is_valid():
            return

        column = self.gpgcheck_combo_box.get_active()
        if column < 0:
            return

        current_cb_value = self.gpgcheck_cb_model[column][1]
        override_value = override_selection['gpgcheck']

        # Ignore combo box changes that are identical to the current model value.
        # This can happen on initial data load.
        if current_cb_value == override_value:
            return

        self._add_override(override_selection['repo_id'], "gpgcheck", int(current_cb_value))