From 64aae5f99b69042f0e23398c71bcdb1fec78fce9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20=27Necoro=27=20Neumann?= Date: Sun, 8 Jun 2008 01:57:02 +0200 Subject: Make the new behavior configurable --- portato/gui/templates/PreferenceWindow.glade | 34 ++++++++++++++++++++++------ portato/gui/windows/main.py | 17 +++++++------- portato/gui/windows/preference.py | 12 +++++++--- 3 files changed, 44 insertions(+), 19 deletions(-) (limited to 'portato') diff --git a/portato/gui/templates/PreferenceWindow.glade b/portato/gui/templates/PreferenceWindow.glade index fcdc4ec..6dbf17a 100644 --- a/portato/gui/templates/PreferenceWindow.glade +++ b/portato/gui/templates/PreferenceWindow.glade @@ -1,6 +1,6 @@ - + 5 @@ -749,13 +749,33 @@ 12 5 - + True - True - GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK - Show slots in the version list - 0 - True + + + True + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + Show slots in the version list + 0 + True + + + + + True + True + True + 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 + True + + + 1 + + diff --git a/portato/gui/windows/main.py b/portato/gui/windows/main.py index 1cda7bd..8a2f170 100644 --- a/portato/gui/windows/main.py +++ b/portato/gui/windows/main.py @@ -775,10 +775,7 @@ class MainWindow (Window): Builds the category list. """ - if False: - store = gtk.ListStore(str) - else: - store = gtk.TreeStore(str) + store = gtk.TreeStore(str) self.fill_cat_store(store) @@ -804,9 +801,9 @@ class MainWindow (Window): cats = self.db.get_categories(installed = not self.showAll) - if False: + if not self.cfg.get_boolean("collapseCats", "GUI"): for p in cats: - store.append([p]) + store.append(None, [p]) else: splitCats = defaultdict(list) for c in cats: @@ -1038,7 +1035,9 @@ class MainWindow (Window): pos = path break - if pos == "0" and isinstance(list.get_model(), gtk.TreeStore): # try the new split up + if self.cfg.get_boolean("collapseCats", "GUI") and \ + pos == "0" and isinstance(list.get_model(), gtk.TreeStore): # try the new split up + try: pre, post = name.split("-", 1) except ValueError: # nothing to split @@ -1225,7 +1224,7 @@ class MainWindow (Window): # get the selected category store, it = selection.get_selected() if it: - if False: + if not self.cfg.get_boolean("collapseCats", "GUI"): self.selCatName = store.get_value(it, 0) else: parent = store.iter_parent(it) @@ -1532,7 +1531,7 @@ class MainWindow (Window): """ User wants to open preferences. """ - PreferenceWindow(self.window, self.cfg, self.console.set_font_from_string, self.set_uri_hook, self.set_notebook_tabpos) + PreferenceWindow(self.window, self.cfg, self.console.set_font_from_string, self.set_uri_hook, self.set_notebook_tabpos, self.fill_cat_store) return True def cb_about_clicked (self, *args): diff --git a/portato/gui/windows/preference.py b/portato/gui/windows/preference.py index 54db879..d35666d 100644 --- a/portato/gui/windows/preference.py +++ b/portato/gui/windows/preference.py @@ -24,6 +24,7 @@ class PreferenceWindow (AbstractDialog): # all checkboxes in the window # widget name -> option name checkboxes = { + "collapseCatCheck" : ("collapseCats", "GUI"), "consoleUpdateCheck" : ("updateConsole", "GUI"), "debugCheck" : "debug", "deepCheck" : "deep", @@ -56,7 +57,7 @@ class PreferenceWindow (AbstractDialog): 4 : gtk.POS_RIGHT } - def __init__ (self, parent, cfg, console_fn, linkbtn_fn, tabpos_fn): + def __init__ (self, parent, cfg, console_fn, linkbtn_fn, tabpos_fn, catmodel_fn): """Constructor. @param parent: parent window @@ -68,7 +69,9 @@ class PreferenceWindow (AbstractDialog): @param linkbtn_fn: function to call to set the linkbutton behavior @type linkbtn_fn: function(string) @param tabpos_fn: function to call to set the tabposition of the notebooks - @type tabpos_fn: function(gtk.ComboBox,int)""" + @type tabpos_fn: function(gtk.ComboBox,int) + @param catmodel_fn: function to call to set the model of the cat list (collapsed/not collapsed) + @type catmodel_fn: function()""" AbstractDialog.__init__(self, parent) @@ -79,6 +82,7 @@ class PreferenceWindow (AbstractDialog): self.console_fn = console_fn self.linkbtn_fn = linkbtn_fn self.tabpos_fn = tabpos_fn + self.catmodel_fn = catmodel_fn # set the bg-color of the hint hintEB = self.tree.get_widget("hintEB") @@ -144,7 +148,7 @@ class PreferenceWindow (AbstractDialog): self.cfg.set("consolefont", font, section = "GUI") self.console_fn(font) - self.cfg.set("titlelength", self.titleLengthSpinBtn.get_value(), section = "GUI") + self.cfg.set("titlelength", str(self.titleLengthSpinBtn.get_value_as_int()), section = "GUI") pkgPos = self.pkgTabCombo.get_active()+1 sysPos = self.systemTabCombo.get_active()+1 @@ -156,6 +160,8 @@ class PreferenceWindow (AbstractDialog): self.linkbtn_fn(self.cfg.get("browserCmd", section="GUI")) + self.catmodel_fn() + def cb_ok_clicked(self, button): """Saves, writes to config-file and closes the window.""" self._save() -- cgit v1.2.3