summaryrefslogtreecommitdiff
path: root/geneticone/gui
diff options
context:
space:
mode:
Diffstat (limited to 'geneticone/gui')
-rw-r--r--geneticone/gui/gui_helper.py44
-rw-r--r--geneticone/gui/windows.py25
2 files changed, 43 insertions, 26 deletions
diff --git a/geneticone/gui/gui_helper.py b/geneticone/gui/gui_helper.py
index b485bf0..0113342 100644
--- a/geneticone/gui/gui_helper.py
+++ b/geneticone/gui/gui_helper.py
@@ -20,10 +20,37 @@ from threading import Thread
import pty
import vte
+class Database:
+
+ def __init__ (self):
+ self.db = {}
+
+ def populate (self, cat = None):
+ packages = backend.find_all_packages(name = cat, withVersion = False)
+ installed = backend.find_all_installed_packages(name = cat, withVersion = False)
+ for p in packages:
+ 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)
+
+ def get_cat (self, cat):
+ try:
+ return self.db[cat]
+ except KeyError: # cat is in category list - but not in portage
+ return []
+
+ def reload (self, cat):
+ del self.db[cat]
+ self.populate(cat+"/")
+
class EmergeQueue:
"""This class manages the emerge queue."""
- def __init__ (self, tree = None, console = None, packages = None):
+ def __init__ (self, tree = None, console = None, db = None):
"""Constructor.
@param tree: Tree to append all the items to. Default: None.
@@ -39,7 +66,7 @@ class EmergeQueue:
self.deps = {}
self.tree = tree
self.console = console
- self.packages = packages
+ self.db = db
if self.tree:
self.emergeIt = self.tree.append(None, ["Emerge"])
@@ -133,14 +160,11 @@ class EmergeQueue:
if process: process.wait()
for p in packages:
- try:
- cat = backend.split_package_name(p)[0] # get category
- while cat[0] in ["=",">","<","!"]:
- cat = cat[1:]
- del self.packages[cat]
- debug("Category %s marked for refreshing" % cat)
- except KeyError: # not in self.packages - ignore
- pass
+ cat = backend.split_package_name(p)[0] # get category
+ while cat[0] in ["=",">","<","!"]:
+ cat = cat[1:]
+ self.db.reload(cat)
+ debug("Category %s refreshed" % cat)
def _emerge (self, options, packages, it):
"""Calls emerge and updates the terminal.
diff --git a/geneticone/gui/windows.py b/geneticone/gui/windows.py
index 1cb39a1..4259848 100644
--- a/geneticone/gui/windows.py
+++ b/geneticone/gui/windows.py
@@ -244,7 +244,7 @@ class PackageWindow:
not_root_dialog()
else:
try:
- self.queue.append(self.actual_package().get_cpv(), False)
+ self.queue.append(self.actual_package().get_cpv(), unmerge = False)
except backend.PackageNotFoundException, e:
masked_dialog(e[0])
self.window.destroy()
@@ -256,7 +256,7 @@ class PackageWindow:
not_root_dialog()
else:
try:
- self.queue.append(self.actual_package().get_cpv(), False)
+ self.queue.append(self.actual_package().get_cpv(), unmerge = True)
except backend.PackageNotFoundException, e:
masked_dialog(e[0])
@@ -360,6 +360,10 @@ class MainWindow:
self.window.set_geometry_hints (self.window, min_width = 600, min_height = 800, max_height = gtk.gdk.screen_height(), max_width = gtk.gdk.screen_width())
self.window.set_resizable(True)
+ # package db
+ self.db = Database()
+ self.db.populate()
+
# main vb
vb = gtk.VBox(False, 1)
self.window.add(vb)
@@ -459,7 +463,7 @@ class MainWindow:
self.window.show_all()
# set emerge queue
- self.queue = EmergeQueue(console=term, tree = emergeStore, packages = self.packages)
+ self.queue = EmergeQueue(console=term, tree = emergeStore, db = self.db)
def cb_delete (self, widget, data = None):
"""Returns false -> window is deleted."""
@@ -543,16 +547,7 @@ class MainWindow:
# calculate packages
if name:
- if name not in self.packages and not force: # only calc packages if not already done
- self.packages[name] = []
- list = backend.find_all_packages(name = name+"/", withVersion = False)
- installed = backend.find_all_installed_packages(name = name+"/", withVersion=False)
- for p in list:
- if p in installed:
- p += "*" # append a '*' if the package is installed
- self.packages[name].append(p.split("/")[1])
-
- for p in self.packages[name]:
+ for p in self.db.get_cat(name):
store.append([p])
# sort alphabetically
@@ -607,15 +602,13 @@ class MainWindow:
def cb_search_clicked (self, button, data = None):
"""Do a search."""
if self.searchEntry.get_text() != "":
- packages = backend.find_all_packages(self.searchEntry.get_text())
+ packages = backend.find_all_packages(self.searchEntry.get_text(), withVersion = False)
if packages == []:
dialog = gtk.MessageDialog(None, gtk.DIALOG_MODAL, gtk.MESSAGE_INFO, gtk.BUTTONS_OK, "Package not found!")
dialog.run()
dialog.destroy()
else:
- packages = unique_array([p.get_cp() for p in packages])
-
if len(packages) == 1:
self.jump_to(packages[0])
else: