diff options
author | Necoro <> | 2007-10-31 15:28:06 +0000 |
---|---|---|
committer | Necoro <> | 2007-10-31 15:28:06 +0000 |
commit | 85ce664e4532065dbea066f283d0fd50fe71714a (patch) | |
tree | d18fdc0546cf0d601d009025061ae6d4d4386e4e /portato/gui/gui_helper.py | |
parent | 11933586a448ad6bd8b6aae6fa4a36dd48cbc136 (diff) | |
download | portato-85ce664e4532065dbea066f283d0fd50fe71714a.tar.gz portato-85ce664e4532065dbea066f283d0fd50fe71714a.tar.bz2 portato-85ce664e4532065dbea066f283d0fd50fe71714a.zip |
r93@Devoty: necoro | 2007-10-31 11:37:04 +0100
Make menu management work again with glade
r94@Devoty: necoro | 2007-10-31 14:38:28 +0100
Fixed bug (missing self)
r95@Devoty: necoro | 2007-10-31 16:22:40 +0100
Added "Show only installed packages" option
r96@Devoty: necoro | 2007-10-31 16:27:07 +0100
New translations.
Diffstat (limited to '')
-rw-r--r-- | portato/gui/gui_helper.py | 25 |
1 files changed, 21 insertions, 4 deletions
diff --git a/portato/gui/gui_helper.py b/portato/gui/gui_helper.py index ef7a508..0090c84 100644 --- a/portato/gui/gui_helper.py +++ b/portato/gui/gui_helper.py @@ -188,12 +188,14 @@ class Database: def __init__ (self): """Constructor.""" self._db = {} + self.inst_cats = set() def populate (self, category = None): """Populates the database. @param category: An optional category - so only packages of this category are inserted. - @type category: string""" + @type category: string + """ # get the lists packages = system.find_all_packages(name = category, withVersion = False) @@ -203,7 +205,11 @@ class Database: for p in packages: cat, pkg = p.split("/") if not cat in self._db: self._db[cat] = [] - self._db[cat].append((pkg, p in installed)) + inst = p in installed + self._db[cat].append((pkg, inst)) + + if inst: + self.inst_cats.add(cat) for key in self._db: # sort alphabetically self._db[key].sort(cmp=cmp, key=lambda x: x[0].lower()) @@ -216,7 +222,8 @@ class Database: @param byName: selects whether to return the list sorted by name or by installation @type byName: boolean @return: list of tuples: (name, is_installed) or [] - @rtype: (string, boolean)[]""" + @rtype: (string, boolean)[] + """ try: if byName: @@ -236,11 +243,21 @@ class Database: info(_("Catched KeyError => %s seems not to be an available category. Have you played with rsync-excludes?"), cat) return [] + def get_installed_categories (self): + """Returns all categories which have installed packages in them. + + @returns: the list of categories + @rtype: string[] + """ + + return list(self.inst_cats) + def reload (self, cat): """Reloads the given category. @param cat: category - @type cat: string""" + @type cat: string + """ del self._db[cat] self.populate(cat+"/") |