summaryrefslogtreecommitdiff
path: root/portato/gui
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--portato/gui/windows/main.py141
1 files changed, 73 insertions, 68 deletions
diff --git a/portato/gui/windows/main.py b/portato/gui/windows/main.py
index 7b88e23..19fa35f 100644
--- a/portato/gui/windows/main.py
+++ b/portato/gui/windows/main.py
@@ -1045,73 +1045,19 @@ class MainWindow (Window):
# SELECTION
def load_pkg_selection (name):
pos = "0"
- col = 1
- model = self.pkgList.get_model()
-
- if name:
- if oldVersion > 1: # newer one
- name, pos = name.split("@")
-
- if model[pos][col] != name: # need to search :(
- debug("Pkg path does not match. Searching...")
- for cname, path in ((x[col], x.path) for x in model):
- if cname == name:
- pos = path
- break
+ if name and oldVersion > 1: # newer one
+ name, pos = name.split("@")
- debug("Selecting pkg path '%s'. Value: '%s'", pos, model[pos][col])
- self.pkgList.get_selection().select_path(pos)
- self.pkgList.scroll_to_cell(pos)
+ self.jump_to_pkg(name, pos)
def load_cat_selection (name):
pos = "0"
- col = 0
- model = self.catList.get_model()
-
- if name:
- if oldVersion > 1: # newer one
- name, pos = name.split("@")
- if self.cfg.get_boolean("collapseCats", "GUI"):
- try:
- sname = name.split("-", 1)
- except ValueError: # nothing to split
- sname = None
- else:
- sname = None
+ if name and oldVersion > 1: # newer one
+ name, pos = name.split("@")
- if sname is None and model[pos][col] != name: # need to search in normal list
- debug("Cat path does not match. Searching...")
- for cname, path in ((x[col], x.path) for x in model):
- if cname == name:
- pos = path
- break
-
- elif sname: # the collapse case
- row = model[pos.split(":")[0]]
- no_match = False
- if row[col] != sname[0]: # first part does not match :(
- debug("First part of cat path does not match. Searching...")
- no_match = True
- for r in model:
- if r[col] == sname[0]:
- row = r
- break
-
- if no_match or model[pos][col] != sname[1]:
- debug("Second part of cat path does not match. Searching...")
- for cname, path in ((x[col], x.path) for x in row.iterchildren()):
- if cname == sname[1]: # found second
- pos = ":".join(map(str,path))
- break
-
- self.catList.expand_to_path(pos)
-
-
- debug("Selecting cat path '%s'. Value: '%s'", pos, model[pos][col])
- self.catList.get_selection().select_path(pos)
- self.catList.scroll_to_cell(pos)
+ self.jump_to_cat(name, pos)
def save_pkg_selection ():
store, iter = self.pkgList.get_selection().get_selected()
@@ -1231,17 +1177,76 @@ class MainWindow (Window):
cat, pkg = cp.split("/")
- for list, idx, what, expr in ((self.catList, 0, "categories", cat), (self.pkgList, 1, "packages", pkg)):
- pathes = [row.path for row in list.get_model() if row[idx] == expr]
+ self.jump_to_cat(cat)
+ self.jump_to_pkg(pkg)
+
+ self.show_package(cp = cp, version = version, queue = self.queue)
+
+ def jump_to_pkg (self, name = None, pos = "0"):
+ if isinstance(pos, int):
+ pos = str(pos)
+
+ col = 1
+ model = self.pkgList.get_model()
+
+ if name:
+ if model[pos][col] != name: # need to search :(
+ debug("Pkg path does not match. Searching...")
+ for cname, path in ((x[col], x.path) for x in model):
+ if cname == name:
+ pos = path
+ break
+
+ debug("Selecting pkg path '%s'. Value: '%s'", pos, model[pos][col])
+ self.pkgList.get_selection().select_path(pos)
+ self.pkgList.scroll_to_cell(pos)
- if len(pathes) == 1:
- list.get_selection().select_path(pathes[0])
- list.scroll_to_cell(pathes[0])
+ def jump_to_cat (self, name = None, pos = "0"):
+ if isinstance(pos, int):
+ pos = str(pos)
+
+ col = 0
+ model = self.catList.get_model()
+
+ if name:
+ if self.cfg.get_boolean("collapseCats", "GUI"):
+ try:
+ sname = name.split("-", 1)
+ except ValueError: # nothing to split
+ sname = None
else:
- debug("Unexpected number of %s returned after search: %d", what, len(pathes))
- break
+ sname = None
+
+ if sname is None and model[pos][col] != name: # need to search in normal list
+ debug("Cat path does not match. Searching...")
+ for cname, path in ((x[col], x.path) for x in model):
+ if cname == name:
+ pos = path
+ break
+
+ elif sname: # the collapse case
+ row = model[pos.split(":")[0]]
+ no_match = False
+ if row[col] != sname[0]: # first part does not match :(
+ debug("First part of cat path does not match. Searching...")
+ no_match = True
+ for r in model:
+ if r[col] == sname[0]:
+ row = r
+ break
- self.show_package(cp = cp, version = version, queue = self.queue)
+ if no_match or model[pos][col] != sname[1]:
+ debug("Second part of cat path does not match. Searching...")
+ for cname, path in ((x[col], x.path) for x in row.iterchildren()):
+ if cname == sname[1]: # found second
+ pos = ":".join(map(str,path))
+ break
+
+ self.catList.expand_to_path(pos)
+
+ debug("Selecting cat path '%s'. Value: '%s'", pos, model[pos][col])
+ self.catList.get_selection().select_path(pos)
+ self.catList.scroll_to_cell(pos)
def set_uri_hook (self, browser):
"""
-14(no commit message)Necoro10-758/+1014 2008-01-14 r621@Devoty: necoro | 2008-01-14 20:21:40 +0100Necoro2-21/+61 adjust changelog r622@Devoty: necoro | 2008-01-14 21:01:11 +0100 Some new views 2008-01-14 r618@Devoty: necoro | 2008-01-14 20:19:05 +0100Necoro2-35/+57 An ALL category 2008-01-14 r617@Devoty: necoro | 2008-01-14 19:12:59 +0100Necoro2-10/+10 Remove unnecessairy loads of the shm module 2008-01-14 r609@Devoty: necoro | 2008-01-14 17:04:38 +0100Necoro9-394/+477 Allowed '-' and '_' in key names. Also use group names instead of their number. r610@Devoty: necoro | 2008-01-14 17:05:42 +0100 Disabled saving of the queues r611@Devoty: necoro | 2008-01-14 17:08:53 +0100 Added the possibility to permanently en-/disable plugins r612@Devoty: necoro | 2008-01-14 17:14:09 +0100 adjust changelog and translations r613@Devoty: necoro | 2008-01-14 17:40:53 +0100 Dropdown should be localized too 2008-01-14 r605@Devoty: necoro | 2008-01-14 11:43:34 +0100Necoro2-26/+129 Updated shm module to version 1.1.4 2008-01-14 r603@Devoty: necoro | 2008-01-14 11:30:26 +0100Necoro4-26/+38 Improved 'update world'; really support new use defaults 2008-01-11 r598@Devoty: necoro | 2008-01-10 16:36:29 +0100Necoro4-10/+50 Handle the new useflag format correctly 2008-01-11 r597@Devoty: necoro | 2008-01-10 14:12:35 +0100Necoro1-3/+3 updated todo 2008-01-10 r595@Devoty: necoro | 2008-01-10 04:04:15 +0100Necoro1-52/+3 Re-Introduced etc-proposals 2008-01-09 r586@Devoty: necoro | 2008-01-09 14:54:18 +0100Necoro1-1/+1 Disabled catapult till it is really usable 2007-12-06 r577@Devoty: necoro | 2007-12-06 20:37:36 +0100Necoro1-1/+1 Fixed desktop file 2007-12-06 r572@Devoty: necoro | 2007-11-28 08:48:15 +0100Necoro1-0/+1 2007-11-27 r570@Devoty: necoro | 2007-11-27 02:08:21 +0100Necoro3-84/+108 Added scrollbars to update window