From b4c88233aa6dabd2d9301350a240b8ddcf09255a Mon Sep 17 00:00:00 2001 From: necoro <> Date: Fri, 16 Feb 2007 18:14:08 +0000 Subject: Use icon instead of the asterisk Renamed wrong param name "allowed" to "use_keywords" in package.is_testing() --- portato/gui/gtk/windows.py | 42 +++++++++++++++++++++++++++++------------- portato/gui/gui_helper.py | 14 ++++++-------- 2 files changed, 35 insertions(+), 21 deletions(-) (limited to 'portato/gui') diff --git a/portato/gui/gtk/windows.py b/portato/gui/gtk/windows.py index 6eb6dde..a872f3a 100644 --- a/portato/gui/gtk/windows.py +++ b/portato/gui/gtk/windows.py @@ -505,7 +505,7 @@ class PackageTable: self.maskedCheck.hide() self.testingCheck.hide() self.emergeBtn.set_sensitive(False) - else: + else: # normal package self.missingLabel.hide() self.notInSysLabel.hide() self.installedCheck.show() @@ -515,12 +515,12 @@ class PackageTable: self.emergeBtn.set_sensitive(True) self.installedCheck.set_active(pkg.is_installed()) self.maskedCheck.set_active(pkg.is_masked()) - if pkg.is_testing(allowed = False) and not pkg.is_testing(allowed=True): + if pkg.is_testing(use_keywords = False) and not pkg.is_testing(use_keywords = True): self.testingCheck.set_label("(Testing)") self.testingCheck.get_child().set_use_markup(True) else: self.testingCheck.set_label("Testing") - self.testingCheck.set_active(pkg.is_testing(allowed = False)) + self.testingCheck.set_active(pkg.is_testing(use_keywords = False)) if self.doEmerge: # set emerge-button-label @@ -577,16 +577,16 @@ class PackageTable: """Callback for toggled testing-checkbox.""" status = button.get_active() - if self.actual_package().is_testing(allowed = False) == status: + if self.actual_package().is_testing(use_keywords = False) == status: return False - if not self.actual_package().is_testing(allowed = True): + if not self.actual_package().is_testing(use_keywords = True): self.actual_package().set_testing(False) button.set_label("Testing") button.set_active(True) else: self.actual_package().set_testing(True) - if self.actual_package().is_testing(allowed=False): + if self.actual_package().is_testing(use_keywords=False): button.set_label("(Testing)") button.get_child().set_use_markup(True) button.set_active(True) @@ -626,7 +626,7 @@ class MainWindow (Window): PKG_PAGE = 0 QUEUE_PAGE = 1 CONSOLE_PAGE = 2 - + def __init__ (self): """Build up window""" @@ -640,6 +640,9 @@ class MainWindow (Window): # booleans self.doUpdate = False self.packageInit = True + + # installed pixbuf + self.instPixbuf = self.window.render_icon(gtk.STOCK_YES, gtk.ICON_SIZE_MENU) # package db self.db = Database() @@ -743,13 +746,24 @@ class MainWindow (Window): @param name: name of the selected catetegory @type name: string""" - store = gtk.ListStore(str) + store = gtk.ListStore(str, gtk.gdk.Pixbuf) self.fill_pkg_store(store,name) # build view self.pkgList.set_model(store) + + col = gtk.TreeViewColumn("Packages") + + # adding the pixbuf + cell = gtk.CellRendererPixbuf() + col.pack_start(cell, False) + col.add_attribute(cell, "pixbuf", 1) + + # adding the package name cell = gtk.CellRendererText() - col = gtk.TreeViewColumn("Packages", cell, text = 0) + col.pack_start(cell, True) + col.add_attribute(cell, "text", 0) + self.pkgList.append_column(col) def fill_pkg_store (self, store, name = None): @@ -763,8 +777,12 @@ class MainWindow (Window): @rtype: gtk.ListStore""" if name: - for p in self.db.get_cat(name): - store.append([p]) + for pkg, is_inst in self.db.get_cat(name): + if is_inst: + icon = self.instPixbuf + else: + icon = None + store.append([pkg, icon]) return store def jump_to (self, cp): @@ -778,7 +796,6 @@ class MainWindow (Window): gobject.idle_add(self.notebook.set_tab_label_text, self.termHB, title) - def cb_cat_list_selection (self, view): """Callback for a category-list selection. Updates the package list with the packages in the category.""" # get the selected category @@ -796,7 +813,6 @@ class MainWindow (Window): store, it = sel.get_selected() if it: package = store.get_value(it, 0) - if package[-1] == '*': package = package[:-1] self.show_package(self.selCatName+"/"+package, self.queue) return True diff --git a/portato/gui/gui_helper.py b/portato/gui/gui_helper.py index 7808298..be42b52 100644 --- a/portato/gui/gui_helper.py +++ b/portato/gui/gui_helper.py @@ -213,21 +213,19 @@ class Database: list = p.split("/") cat = list[0] pkg = list[1] - if p in installed: - pkg += "*" if not cat in self._db: self._db[cat] = [] - self._db[cat].append(pkg) + self._db[cat].append((pkg, p in installed)) for key in self._db: # sort alphabetically - self._db[key].sort(cmp=cmp, key=str.lower) + self._db[key].sort(cmp=cmp, key=lambda x: str.lower(x[0])) def get_cat (self, cat): """Returns the packages in the category. @param cat: category to return the packages from @type cat: string - @return: list of packages or [] - @rtype: string[]""" + @return: list of tuples: (name, is_installed) or [] + @rtype: (string, boolean)[]""" try: return self._db[cat] @@ -297,7 +295,7 @@ class EmergeQueue: # for the beginning: let us create a package object - but it is not guaranteed, that it actually exists in portage pkg = backend.Package(cpv) - masked = not (pkg.is_masked() or pkg.is_testing(allowed=True)) # we are setting this to True in case we have unmasked it already, but portage does not know this + masked = not (pkg.is_masked() or pkg.is_testing(use_keywords=True)) # we are setting this to True in case we have unmasked it already, but portage does not know this # and now try to find it in portage pkg = backend.find_packages("="+cpv, masked = masked) @@ -307,7 +305,7 @@ class EmergeQueue: elif unmask: # no pkg returned, but we are allowed to unmask it pkg = backend.find_packages("="+cpv, masked = True)[0] - if pkg.is_testing(allowed = True): + if pkg.is_testing(use_keywords = True): pkg.set_testing(True) if pkg.is_masked(): pkg.set_masked() -- cgit v1.2.3-54-g00ecf