summaryrefslogtreecommitdiff
path: root/portato/gui
diff options
context:
space:
mode:
authorRené 'Necoro' Neumann <necoro@necoro.net>2008-06-08 00:59:22 +0200
committerRené 'Necoro' Neumann <necoro@necoro.net>2008-06-08 00:59:22 +0200
commit484cef45413af0eadcc8f312a0df66de83ff4ba9 (patch)
treec374f9a272a5702c5f31316858810133e4a44ec3 /portato/gui
parent5f9e42aa2ecac5c718496c95bc631830b92ae4ef (diff)
downloadportato-484cef45413af0eadcc8f312a0df66de83ff4ba9.tar.gz
portato-484cef45413af0eadcc8f312a0df66de83ff4ba9.tar.bz2
portato-484cef45413af0eadcc8f312a0df66de83ff4ba9.zip
Porthole like display in the cat list
Diffstat (limited to '')
-rw-r--r--portato/gui/windows/main.py43
1 files changed, 39 insertions, 4 deletions
diff --git a/portato/gui/windows/main.py b/portato/gui/windows/main.py
index 4eac88b..5444f81 100644
--- a/portato/gui/windows/main.py
+++ b/portato/gui/windows/main.py
@@ -19,6 +19,7 @@ import gobject
# other
import os.path
import itertools as itt
+from collections import defaultdict
# our backend stuff
from ...backend import flags, system # must be the first to avoid circular deps
@@ -774,7 +775,11 @@ class MainWindow (Window):
Builds the category list.
"""
- store = gtk.ListStore(str)
+ if False:
+ store = gtk.ListStore(str)
+ else:
+ store = gtk.TreeStore(str)
+
self.fill_cat_store(store)
self.catList.set_model(store)
@@ -799,8 +804,27 @@ class MainWindow (Window):
cats = self.db.get_categories(installed = not self.showAll)
- for p in cats:
- store.append([p])
+ if False:
+ for p in cats:
+ store.append([p])
+ else:
+ splitCats = defaultdict(list)
+ for c in cats:
+ try:
+ pre, post = c.split("-", 1)
+ except ValueError: # no "-" in cat name -- do not split
+ debug("Category '%s' can't be split up. Should be no harm.", c)
+ splitCats["not-split"].append(c)
+ else:
+ splitCats[pre].append(post)
+
+ for sc in splitCats:
+ if sc == "not-split":
+ it = None # append not splitted stuff to root
+ else:
+ it = store.append(None, [sc])
+ for cat in splitCats[sc]:
+ store.append(it, [cat])
# sort them alphabetically
store.set_sort_column_id(0, gtk.SORT_ASCENDING)
@@ -1183,7 +1207,18 @@ class MainWindow (Window):
# get the selected category
store, it = selection.get_selected()
if it:
- self.selCatName = store.get_value(it, 0)
+ if False:
+ self.selCatName = store.get_value(it, 0)
+ else:
+ parent = store.iter_parent(it)
+ if parent is None:
+ if store.iter_has_child(it): # this is a split up selector -> do nothing
+ return True
+ else:
+ self.selCatName = store.get_value(it, 0) # this is a non-split up top
+ else:
+ self.selCatName = ("%s-%s" % (store.get_value(parent, 0), store.get_value(it, 0)))
+
self.fill_pkg_store(name = self.selCatName)
return True