summaryrefslogtreecommitdiff
path: root/portato/gui/windows/main.py
diff options
context:
space:
mode:
Diffstat (limited to 'portato/gui/windows/main.py')
-rw-r--r--portato/gui/windows/main.py98
1 files changed, 78 insertions, 20 deletions
diff --git a/portato/gui/windows/main.py b/portato/gui/windows/main.py
index 29eb728..a06756d 100644
--- a/portato/gui/windows/main.py
+++ b/portato/gui/windows/main.py
@@ -3,7 +3,7 @@
# File: portato/gui/windows/main.py
# This file is part of the Portato-Project, a graphical portage-frontend.
#
-# Copyright (C) 2006-2009 René 'Necoro' Neumann
+# Copyright (C) 2006-2010 René 'Necoro' Neumann
# This is free software. You may redistribute copies of it under the terms of
# the GNU General Public License version 2.
# There is NO WARRANTY, to the extent permitted by law.
@@ -29,6 +29,7 @@ from ... import get_listener
from ...helper import debug, warning, error, info
from ...session import Session
from ...db import Database
+from ...db.database import UnsupportedSearchTypeError
from ...constants import CONFIG_LOCATION, VERSION, APP_ICON, ICON_DIR
from ...backend.exceptions import PackageNotFoundException, BlockedException, VersionsNotFoundException
@@ -50,7 +51,7 @@ from .about import AboutWindow
from .plugin import PluginWindow
from .preference import PreferenceWindow
from .search import SearchWindow
-from .update import UpdateWindow
+from .pkglist import UpdateWindow, WorldListWindow
class PackageTable:
"""A window with data about a specfic package."""
@@ -565,6 +566,10 @@ class MainWindow (Window):
splash(_("Finishing startup"))
+ # depends on session
+ self.typeCombo = self.tree.get_widget("typeCombo")
+ self.build_type_combo()
+
self.window.show_all()
def show_package (self, pkg = None, cpv = None, cp = None, version = None, **kwargs):
@@ -884,6 +889,26 @@ class MainWindow (Window):
else: # no selCatName -> so no category selected --> ignore
debug("No category selected --> should be no harm.")
+ def build_type_combo (self):
+ model = gtk.ListStore(int, str)
+ for k,v in self.db.TYPES.iteritems():
+ model.append((k,v))
+
+ self.typeCombo.set_model(model)
+ cell = gtk.CellRendererText()
+ self.typeCombo.pack_start(cell)
+ self.typeCombo.set_attributes(cell, text = 1)
+
+
+ for i, (k, v) in enumerate(model):
+ if k == self.db.type: break
+
+ self.typeCombo.set_active(i)
+
+ types = self.db.search_types()
+ if types == 1 or types % 2 == 0:
+ self.typeCombo.set_sensitive(False)
+
def load_session(self, sessionEx = None, defaults_only = False):
"""
Loads the session data.
@@ -1000,6 +1025,14 @@ class MainWindow (Window):
return _save
+ # SEARCH TYPE
+ def load_search_type (t):
+ t = int(t)
+ try:
+ self.db.type = t
+ except UnsupportedSearchTypeError:
+ info("Cannot set search type. '%s' not supported by database '%s'.", t, self.db.__class__.__name__)
+
# SESSION VERSION
def load_session_version (version):
@@ -1028,7 +1061,8 @@ class MainWindow (Window):
(["width", "height"], lambda w,h: self.window.resize(int(w), int(h)), self.window.get_size),
(["vpanedpos", "hpanedpos"], load_paned, save_paned),
(["catsel"], load_cat_selection, save_cat_selection, ["app-portage@0"]),
- (["pkgsel"], load_pkg_selection, save_pkg_selection, ["portato@0"])
+ (["pkgsel"], load_pkg_selection, save_pkg_selection, ["portato@0"]),
+ (["searchtype"], load_search_type, lambda: self.db.type)
#([("merge", "queue"), ("unmerge", "queue"), ("oneshot", "queue")], load_queue, save_queue),
])
@@ -1575,7 +1609,13 @@ class MainWindow (Window):
return False # not again ;)
- gobject.timeout_add(100, __update)
+ gobject.timeout_add(200, __update)
+
+ def cb_type_combo_changed (self, *args):
+ model = self.typeCombo.get_model()
+ active = self.typeCombo.get_active()
+
+ self.db.type = model[active][0]
def cb_delete_search_clicked (self, *args):
self.searchEntry.set_text("")
@@ -1607,34 +1647,52 @@ class MainWindow (Window):
PluginWindow(self.window, plugins, self.queue)
return True
-
- def cb_show_updates_clicked (self, *args):
- """
- Show the list of updateble packages.
- """
- def __update():
- def cb_idle_show(packages):
- """
- Callback opening the menu when the calculation is finished.
+ def show_package_list (self, pkg_generator, klass, thread_name = "PkgList Update Thread"):
+
+ def cb_idle_show(packages):
+ """
+ Callback opening the menu when the calculation is finished.
- @returns: False to signal that it is finished
- """
- UpdateWindow(self.window, packages, self.queue, self.jump_to)
- return False
-
+ @returns: False to signal that it is finished
+ """
+ klass(self.window, packages, self.queue, self.jump_to)
+ return False
+
+ def __update():
watch = gtk.gdk.Cursor(gtk.gdk.WATCH)
self.window.window.set_cursor(watch)
packages = []
try:
- packages.extend(system.get_updated_packages())
+ packages.extend(pkg_generator())
finally:
self.window.window.set_cursor(None)
gobject.idle_add(cb_idle_show, packages)
- GtkThread(name="Show Updates Thread", target = __update).start()
+ GtkThread(name = thread_name, target = __update).start()
+ return True
+
+ def cb_show_updates_clicked (self, *args):
+ """
+ Show the list of updateble packages.
+ """
+
+ self.show_package_list(
+ lambda: (x.get_cpv() for x in system.get_updated_packages()),
+ UpdateWindow, "Show Updates Thread")
+
+ return True
+
+ def cb_show_world_clicked (self, *args):
+ """
+ Show the list of world packages.
+ """
+ self.show_package_list(
+ lambda: system.find_packages(pkgSet = "world", only_cpv = True),
+ WorldListWindow)
+
return True
def cb_show_installed_toggled (self, *args):