From 85ce664e4532065dbea066f283d0fd50fe71714a Mon Sep 17 00:00:00 2001 From: Necoro <> Date: Wed, 31 Oct 2007 15:28:06 +0000 Subject: 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. --- portato/gui/gtk/exception_handling.py | 2 +- portato/gui/gtk/windows.py | 38 +++- portato/gui/gui_helper.py | 25 ++- portato/gui/templates/portato.glade | 337 +++++++++++++++++++++++++++++++--- 4 files changed, 362 insertions(+), 40 deletions(-) (limited to 'portato/gui') diff --git a/portato/gui/gtk/exception_handling.py b/portato/gui/gtk/exception_handling.py index 673dd7e..c44f554 100644 --- a/portato/gui/gtk/exception_handling.py +++ b/portato/gui/gtk/exception_handling.py @@ -70,7 +70,7 @@ class UncaughtExceptionDialog(gtk.MessageDialog): textbuffer = self.textview.get_buffer() self.text = get_trace(type, value, tb) if thread: - self.text = _("Exception in thread \"%(thread)s\":\n%(trace)s") % {"thread": thread, "trace": text} + self.text = _("Exception in thread \"%(thread)s\":\n%(trace)s") % {"thread": thread, "trace": self.text} textbuffer.set_text(self.text) self.textview.set_size_request(gtk.gdk.screen_width()/2, gtk.gdk.screen_height()/3) diff --git a/portato/gui/gtk/windows.py b/portato/gui/gtk/windows.py index 476411d..ff3c4d1 100644 --- a/portato/gui/gtk/windows.py +++ b/portato/gui/gtk/windows.py @@ -890,6 +890,7 @@ class MainWindow (Window): # booleans self.doUpdate = False + self.showAll = True # show only installed or all packages? # installed pixbuf self.instPixbuf = self.window.render_icon(gtk.STOCK_YES, gtk.ICON_SIZE_MENU) @@ -1024,17 +1025,26 @@ class MainWindow (Window): store = gtk.ListStore(str) - # build categories - for p in system.list_categories(): - store.append([p]) - # sort them alphabetically - store.set_sort_column_id(0, gtk.SORT_ASCENDING) - self.catList.set_model(store) cell = gtk.CellRendererText() col = gtk.TreeViewColumn(_("Categories"), cell, text = 0) self.catList.append_column(col) + self.fill_cat_store(store) + + def fill_cat_store (self, store): + + if self.showAll: + cats = system.list_categories() + else: + cats = self.db.get_installed_categories() + + for p in cats: + store.append([p]) + + # sort them alphabetically + store.set_sort_column_id(0, gtk.SORT_ASCENDING) + def build_pkg_list (self, name = None): """Builds the package list. @@ -1077,6 +1087,8 @@ class MainWindow (Window): for pkg, is_inst in self.db.get_cat(name, self.sortPkgListByName): if is_inst: icon = self.instPixbuf + elif not self.showAll: + continue # ignore not installed packages else: icon = None store.append([icon, pkg]) @@ -1324,6 +1336,20 @@ class MainWindow (Window): GtkThread(name="Show Updates Thread", target = __update).start() return True + def cb_show_installed_toggled (self, *args): + self.showAll = not self.showAll + + store = self.catList.get_model() + store.clear() + self.fill_cat_store(store) + + store = self.pkgList.get_model() + store.clear() + try: + self.fill_pkg_store(store, self.selCatName) + except AttributeError: # no selCatName -> so no category selected --> ignore + debug("AttributeError occured --> should be no harm.") + def cb_right_click (self, object, event): if event.button == 3: x = int(event.x) 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+"/") diff --git a/portato/gui/templates/portato.glade b/portato/gui/templates/portato.glade index a42bc25..ed33a7e 100644 --- a/portato/gui/templates/portato.glade +++ b/portato/gui/templates/portato.glade @@ -15,12 +15,13 @@ True - + True + fileMenu _File True - + True @@ -76,12 +77,13 @@ - + True + emergeMenu _Emerge True - + True @@ -129,6 +131,16 @@ + + + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + Show Only _Installed Packages + True + + + + True @@ -205,6 +217,7 @@ False True + queuePopup _Queue True @@ -225,6 +238,7 @@ False True + consolePopup _Console True @@ -279,6 +293,7 @@ True + pluginMenu _Plugins True @@ -289,12 +304,13 @@ - + True + helpMenu _? True - + True @@ -387,7 +403,6 @@ True - 0 0 GTK_SHADOW_IN @@ -748,7 +763,6 @@ - False False @@ -759,7 +773,6 @@ tab - False False @@ -896,7 +909,6 @@ 1 - False @@ -908,7 +920,6 @@ tab 1 - False False @@ -924,7 +935,6 @@ 2 - False @@ -936,7 +946,6 @@ tab 2 - False False @@ -1087,7 +1096,6 @@ True - 0 True @@ -1151,7 +1159,6 @@ True - 0 True @@ -1204,7 +1211,6 @@ True - 0 True @@ -1253,7 +1259,6 @@ True - 0 True @@ -1325,7 +1330,6 @@ True - 0 GTK_SHADOW_OUT @@ -1480,9 +1484,6 @@ - - False - @@ -1492,7 +1493,6 @@ tab - False False @@ -1601,7 +1601,6 @@ 1 - False @@ -1613,7 +1612,6 @@ tab 1 - False False @@ -1668,6 +1666,288 @@ + + True + + + True + _Preferences + True + + + + + True + 0 + 0 + gtk-preferences + 1 + + + + + + + True + Re_load Portage + True + + + + True + 0 + 0 + gtk-refresh + 1 + + + + + + + True + + + + + True + gtk-quit + True + True + + + + + + True + + + True + E_merge + True + + + + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | GDK_ENTER_NOTIFY_MASK + gtk-add + + + + + + + True + _Unmerge + True + + + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | GDK_ENTER_NOTIFY_MASK + gtk-remove + + + + + + + True + Update _World + True + + + + + + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + Show Updatable P_ackages + True + + + + + + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + Show Only _Installed Packages + True + + + + + + + True + + + + + True + _Sync + True + + + + + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | GDK_ENTER_NOTIFY_MASK + gtk-refresh + + + + + + + True + Save _Flags + True + + + + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | GDK_ENTER_NOTIFY_MASK + gtk-save + + + + + + + True + + + + + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + Emerge _Paused + True + + + + + + True + _Kill Emerge + True + + + + + True + 0 + 0 + gtk-stop + 1 + + + + + + + True + + + True + Oneshot + + + + + + True + + + True + _Copy + True + + + + True + 0 + 0 + gtk-copy + 1 + + + + + + + True + _Kill Emerge + True + + + + True + 0 + 0 + gtk-stop + 1 + + + + + + + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + Emerge _Paused + True + + + + + True + + + True + _About + True + + + + True + 0 + 0 + gtk-about + 1 + + + + + + + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + _Plugins + True + + + + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + gtk-connect + + + + + + + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + Show _Log + True + + + + + + True + True GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK @@ -1870,18 +2150,17 @@ True True False - Portato This software is licensed under the terms of the GPLv2. Copyright (C) 2006-2007 René 'Necoro' Neumann <necoro@necoro.net> A Portage GUI http://portato.necoro.net René 'Necoro' Neumann -uses code from: Daniel J. Popowich + uses code from: Daniel J. Popowich -Many thanks to the Porthole team which often inspired me or gave me hints. -(And sometimes I even copied files ^^ ;)) - + Many thanks to the Porthole team which often inspired me or gave me hints. + (And sometimes I even copied files ^^ ;)) + p4r4d0x (inspired by wolfden) -- cgit v1.2.3-54-g00ecf