Exemple #1
0
    def __init__(self, backend, parent):
        super(RepositoriesDialog, self).__init__('repositories.glade')

        # Set up dynamic elements
        self.overrides_treeview = gtk.TreeView()
        # Add at-spi because we no longer create this widget from glade
        self.overrides_treeview.get_accessible().set_name("Repository View")
        self.no_repos_label, self.no_repos_label_viewport = widgets.get_scrollable_label()
        self.widget_switcher = widgets.WidgetSwitcher(self.scrolledwindow,
                self.no_repos_label_viewport, self.overrides_treeview)

        # We require the backend here so that we can always use its version
        # of Overrides which will guarantee that the CP UEPConnection is up
        # to date.
        # FIXME: We really shouldn't have to worry about our connection info
        #        changing out from under us.
        self.backend = backend
        self.identity = require(IDENTITY)
        self.ent_dir = require(ENT_DIR)

        self.glade.signal_autoconnect({
                "on_dialog_delete_event": self._on_close,
                "on_close_button_clicked": self._on_close,
                "on_reset_button_clicked": self._on_reset_repo,
        })

        self.overrides_store = MappedListStore({
            "repo_id": str,
            "enabled": bool,
            "modified": bool,
            "modified-icon": gtk.gdk.Pixbuf,
            "name": str,
            "baseurl": str,
            "gpgcheck": bool,
            "gpgcheck_modified": bool,
            "repo_data": object,
            "override_data": object
        })

        self.other_overrides = OverridesTable(self.other_overrides_view)

        # Change the background color of the no_repos_label_container to the same color
        # as the label's base color. The event container allows us to change the color.
        label_base_color = self.no_repos_label.style.base[gtk.STATE_NORMAL]
        self.no_repos_label_viewport.modify_bg(gtk.STATE_NORMAL, label_base_color)

        self.overrides_treeview.set_model(self.overrides_store)

        self.modified_icon = self.overrides_treeview.render_icon(gtk.STOCK_APPLY,
                                                                 gtk.ICON_SIZE_MENU)

        sortable_cols = []
        enabled_col = CheckBoxColumn(_("Enabled"), self.overrides_store, 'enabled',
            self._on_enable_repo_toggle)
        self.overrides_treeview.append_column(enabled_col)

        gpgcheck_col = CheckBoxColumn(_("Gpgcheck"), self.overrides_store, 'gpgcheck',
            self._on_gpgcheck_toggle_changed)
        self.overrides_treeview.append_column(gpgcheck_col)

        repo_id_col = TextTreeViewColumn(self.overrides_store, _("Repository ID"), 'repo_id',
                                         expand=True)
        self.overrides_treeview.append_column(repo_id_col)
        sortable_cols.append((repo_id_col, 'text', 'repo_id'))

        modified_col = gtk.TreeViewColumn(_("Modified"), gtk.CellRendererPixbuf(),
                                          pixbuf=self.overrides_store['modified-icon'])
        self.overrides_treeview.append_column(modified_col)
        sortable_cols.append((modified_col, 'text', 'modified'))

        self.set_sorts(self.overrides_store, sortable_cols)

        self.overrides_treeview.get_selection().connect('changed', self._on_selection)
        self.overrides_treeview.set_rules_hint(True)

        self.main_window.set_transient_for(parent)
Exemple #2
0
    def __init__(self, backend, parent):
        super(RepositoriesDialog, self).__init__()

        # Label wrapping on resize does not work very well on GTK2+
        # so we resize on the fly.
        if gtk_compat.GTK_COMPAT_VERSION == "2":
            # Set the title to wrap and connect to size-allocate to
            # properly resize the label so that it takes up the most
            # space it can.
            self.description_text.set_line_wrap(True)
            self.description_text.connect(
                'size-allocate',
                lambda label, size: label.set_size_request(size.width - 1, -1))

            self.name_text.set_line_wrap(True)
            self.name_text.connect(
                'size-allocate',
                lambda label, size: label.set_size_request(size.width - 1, -1))

            self.baseurl_text.set_line_wrap(True)
            self.baseurl_text.connect(
                'size-allocate',
                lambda label, size: label.set_size_request(size.width - 1, -1))

        # Set up dynamic elements
        self.overrides_treeview = ga_Gtk.TreeView()
        # Add at-spi because we no longer create this widget from glade
        self.overrides_treeview.get_accessible().set_name("Repository View")
        self.no_repos_label, self.no_repos_label_viewport = widgets.get_scrollable_label(
        )
        self.widget_switcher = widgets.WidgetSwitcher(
            self.scrolledwindow, self.no_repos_label_viewport,
            self.overrides_treeview)

        # We require the backend here so that we can always use its version
        # of Overrides which will guarantee that the CP UEPConnection is up
        # to date.
        # FIXME: We really shouldn't have to worry about our connection info
        #        changing out from under us.
        self.backend = backend
        self.async_update = AsyncRepoOverridesUpdate(self.backend.overrides)
        self.identity = require(IDENTITY)
        self.ent_dir = require(ENT_DIR)

        self.connect_signals({
            "on_dialog_delete_event": self._on_close,
            "on_close_button_clicked": self._on_close,
            "on_apply_button_clicked": self._on_apply_request,
            "on_reset_button_clicked": self._on_reset_repo
        })

        self.overrides_store = MappedListStore({
            "repo_id": str,
            "enabled": bool,
            "modified": bool,
            "modified-icon": ga_GdkPixbuf.Pixbuf,
            "name": str,
            "baseurl": str,
            "gpgcheck": bool,
            "gpgcheck_modified": bool,
            "repo_data": object,
            "override_data": object
        })

        self.other_overrides = OverridesTable(self.other_overrides_view)

        # FIXME: think this needs get_style_context() and possible a
        # Gtk.StyleProvider for gtk3
        # Change the background color of the no_repos_label_container to the same color
        # as the label's base color. The event container allows us to change the color.
        #label_base_color = self.no_repos_label.get_style_context().base[Gtk.StateType.NORMAL]
        #self.no_repos_label_viewport.modify_bg(Gtk.StateType.NORMAL, label_base_color)

        self.overrides_treeview.set_model(self.overrides_store)

        self.modified_icon = self.overrides_treeview.render_icon(
            ga_Gtk.STOCK_APPLY, ga_Gtk.IconSize.MENU)

        sortable_cols = []
        enabled_col = CheckBoxColumn(_("Enabled"), self.overrides_store,
                                     'enabled', self._on_enable_repo_toggle)
        self.overrides_treeview.append_column(enabled_col)

        gpgcheck_col = CheckBoxColumn(_("Gpgcheck"), self.overrides_store,
                                      'gpgcheck',
                                      self._on_gpgcheck_toggle_changed)
        self.overrides_treeview.append_column(gpgcheck_col)

        repo_id_col = TextTreeViewColumn(self.overrides_store,
                                         _("Repository ID"),
                                         'repo_id',
                                         expand=True)
        self.overrides_treeview.append_column(repo_id_col)
        sortable_cols.append((repo_id_col, 'text', 'repo_id'))

        modified_col = ga_Gtk.TreeViewColumn(
            _("Modified"),
            ga_Gtk.CellRendererPixbuf(),
            pixbuf=self.overrides_store['modified-icon'])
        self.overrides_treeview.append_column(modified_col)
        sortable_cols.append((modified_col, 'text', 'modified'))

        self.set_sorts(self.overrides_store, sortable_cols)

        self.overrides_treeview.get_selection().connect(
            'changed', self._on_selection)
        self.overrides_treeview.set_rules_hint(True)

        # Progress bar
        self.pb = None
        self.timer = 0

        self.parent = parent
        self.main_window.set_transient_for(parent)