From 9eb714ea374b04cc8beed223106f1c9615accc60 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20=27Necoro=27=20Neumann?= Date: Wed, 9 Jul 2008 21:20:04 +0200 Subject: Added set selection in preferences --- etc/portato.cfg | 5 ++++ portato/gui/templates/PreferenceWindow.glade | 42 ++++++++++++++++++++++++++-- portato/gui/windows/preference.py | 39 ++++++++++++++++++++++++++ 3 files changed, 83 insertions(+), 3 deletions(-) diff --git a/etc/portato.cfg b/etc/portato.cfg index ca20fd9..4095c23 100644 --- a/etc/portato.cfg +++ b/etc/portato.cfg @@ -47,6 +47,11 @@ keywordperversion = True maskperversion = True useperversion = False +; the sets which are going to be updated on "update world" +; this is only important for >=portage-2.2 +; values: comma-speparated set-names +updatesets = system, world + # # Frontend section for options common to more than one GUI. # Not all frontends have to support all of the options. diff --git a/portato/gui/templates/PreferenceWindow.glade b/portato/gui/templates/PreferenceWindow.glade index 3dc556b..7c144e7 100644 --- a/portato/gui/templates/PreferenceWindow.glade +++ b/portato/gui/templates/PreferenceWindow.glade @@ -1,6 +1,6 @@ - + 5 @@ -121,6 +121,42 @@ 1 + + + True + 0 + GTK_SHADOW_NONE + + + True + 0 + 0 + 10 + + + True + True + False + True + + + + + + + True + <b>Package sets to update</b> + True + + + label_item + + + + + 2 + + @@ -517,7 +553,7 @@ True GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK True - Update the package list with the current search results while you are typing. + Update the package list with the current search results while you are typing. <b>Note</b>: Will slow down the typing process. Search while typing 0.47999998927116394 @@ -766,7 +802,7 @@ True True True - Organize the categories in a tree. Thereby collapse categories with the same prefix: + Organize the categories in a tree. Thereby collapse categories with the same prefix: As an example: <i>app-admin</i>, <i>app-emacs</i>, and <i>app-vim</i> would be collapsed into <i><b>app</b></i> as root and <i>admin</i>, <i>emacs</i>, and <i>vim</i> as children. Collapse categories with same prefix 0 diff --git a/portato/gui/windows/preference.py b/portato/gui/windows/preference.py index d35666d..ae95cc5 100644 --- a/portato/gui/windows/preference.py +++ b/portato/gui/windows/preference.py @@ -14,6 +14,8 @@ from __future__ import absolute_import import gtk +from ...backend import system + from .basic import AbstractDialog from ..dialogs import io_ex_dialog from ...helper import debug @@ -106,6 +108,12 @@ class PreferenceWindow (AbstractDialog): self.tree.get_widget(edit).\ set_text(self.cfg.get(val)) + # the set list + self.setList = self.tree.get_widget("setList") + if system.has_set_support(): + self.fill_setlist() + self.tree.get_widget("setFrame").show() + # the console font button self.consoleFontBtn = self.tree.get_widget("consoleFontBtn") self.consoleFontBtn.set_font_name(self.cfg.get("consolefont", section = "GUI")) @@ -144,6 +152,8 @@ class PreferenceWindow (AbstractDialog): else: self.cfg.set(val,self.tree.get_widget(edit).get_text()) + self.cfg.set("updatesets", ", ".join(sorted(name for enabled, markup, descr, name in self.setList.get_model() if enabled))) + font = self.consoleFontBtn.get_font_name() self.cfg.set("consolefont", font, section = "GUI") self.console_fn(font) @@ -162,6 +172,29 @@ class PreferenceWindow (AbstractDialog): self.catmodel_fn() + def fill_setlist (self): + store = gtk.ListStore(bool, str, str, str) + + enabled = [x.strip() for x in self.cfg.get("updatesets").split(",")] + + for set, descr in system.get_sets(): + store.append([set in enabled, "%s" % set, descr, set]) + + tCell = gtk.CellRendererToggle() + tCell.set_property("activatable", True) + tCell.connect("toggled", self.cb_check_toggled) # emulate the normal toggle behavior ... + + sCell = gtk.CellRendererText() + + col = gtk.TreeViewColumn(_("Package Set"), tCell, active = 0) + col.pack_start(sCell) + col.add_attribute(sCell, "markup", 1) + self.setList.append_column(col) + + self.setList.append_column(gtk.TreeViewColumn(_("Description"), sCell, text = 2)) + + self.setList.set_model(store) + def cb_ok_clicked(self, button): """Saves, writes to config-file and closes the window.""" self._save() @@ -175,3 +208,9 @@ class PreferenceWindow (AbstractDialog): def cb_cancel_clicked (self, button): """Just closes - w/o saving.""" self.window.destroy() + + def cb_check_toggled (self, cell, path): + # for whatever reason we have to define normal toggle behavior explicitly + store = self.setList.get_model() + store[path][0] = not store[path][0] + return True -- cgit v1.2.3