summaryrefslogtreecommitdiff
path: root/portato/gui/windows
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--portato/gui/windows/main.py47
-rw-r--r--portato/gui/windows/pkglist.py (renamed from portato/gui/windows/update.py)70
2 files changed, 78 insertions, 39 deletions
diff --git a/portato/gui/windows/main.py b/portato/gui/windows/main.py
index c99790c..5a149f8 100644
--- a/portato/gui/windows/main.py
+++ b/portato/gui/windows/main.py
@@ -50,7 +50,7 @@ from .about import AboutWindow
from .plugin import PluginWindow
from .preference import PreferenceWindow
from .search import SearchWindow
-from .update import UpdateWindow, WorldListWindow
+from .pkglist import UpdateWindow, WorldListWindow
class PackageTable:
"""A window with data about a specfic package."""
@@ -1594,41 +1594,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.
"""
- WorldListWindow(self.window, system.find_packages(pkgSet = "world"), self.queue, self.jump_to)
+ self.show_package_list(
+ lambda: system.find_packages(pkgSet = "world", only_cpv = True),
+ WorldListWindow)
+
return True
def cb_show_installed_toggled (self, *args):
diff --git a/portato/gui/windows/update.py b/portato/gui/windows/pkglist.py
index d77d257..90915cb 100644
--- a/portato/gui/windows/update.py
+++ b/portato/gui/windows/pkglist.py
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
#
-# File: portato/gui/windows/update.py
+# File: portato/gui/windows/pkglist.py
# This file is part of the Portato-Project, a graphical portage-frontend.
#
# Copyright (C) 2006-2009 René 'Necoro' Neumann
@@ -19,15 +19,27 @@ from ...backend import system
from ...backend.exceptions import PackageNotFoundException, BlockedException
from ...helper import debug
-class UpdateWindow (AbstractDialog):
+class PkgListWindow (AbstractDialog):
- def __init__ (self, parent, packages, queue, jump_to):
+ # need this, so it can be safely subclassed
+ __file__ = __window__ = "PkgListWindow"
+
+ def __init__ (self, title, parent, packages, queue, jump_to):
AbstractDialog.__init__(self, parent)
+ self.window.set_title(title)
+
+ self.installBtn = self.tree.get_widget("installBtn")
+ self.uninstallBtn = self.tree.get_widget("uninstallBtn")
+
+ self.selectBtnLabels = {
+ False: _("Select _All"),
+ True: _("Unselect _All")}
+
+ self.all_selected = False
self.queue = queue
self.jump = jump_to
-
- self.packages = system.sort_package_list(packages)
+ self.packages = system.sort_package_list(packages, only_cpv = True)
self.build_list()
@@ -48,7 +60,7 @@ class UpdateWindow (AbstractDialog):
self.view.append_column(gtk.TreeViewColumn(_("Package"), cell, text = 1))
for p in self.packages:
- store.append([False, p.get_cpv()])
+ store.append([False, p])
def cb_set_size (self, *args):
"""
@@ -66,16 +78,20 @@ class UpdateWindow (AbstractDialog):
self.window.set_geometry_hints(self.window, min_height = val)
def cb_select_all_clicked (self, btn):
+ sel = self.all_selected = not self.all_selected
+
+ btn.set_label(self.selectBtnLabels[sel])
+
model = self.view.get_model()
iter = model.get_iter_first()
while iter:
- model.set_value(iter, 0, True)
+ model.set_value(iter, 0, sel)
iter = model.iter_next(iter)
return True
- def cb_install_clicked (self, btn):
+ def install_uninstall (self, type):
model = self.view.get_model()
iter = model.get_iter_first()
if iter is None: return
@@ -86,20 +102,30 @@ class UpdateWindow (AbstractDialog):
items.append(model.get_value(iter, 1))
iter = model.iter_next(iter)
- for item in items:
- try:
+ if type == "install":
+ for item in items:
try:
- self.queue.append(item, type = "install", oneshot = True)
- except PackageNotFoundException, e:
- if unmask_dialog(e[0]) == gtk.RESPONSE_YES :
- self.queue.append(item, type = "install", unmask = True, oneshot = True)
-
- except BlockedException, e:
- blocked_dialog(e[0], e[1])
+ try:
+ self.queue.append(item, "install", oneshot = True)
+ except PackageNotFoundException, e:
+ if unmask_dialog(e[0]) == gtk.RESPONSE_YES :
+ self.queue.append(item, "install", unmask = True, oneshot = True)
+
+ except BlockedException, e:
+ blocked_dialog(e[0], e[1])
+ else:
+ for item in items:
+ self.queue.append(item, "uninstall")
self.close()
return True
+ def cb_install_clicked (self, btn):
+ return self.install_uninstall("install")
+
+ def cb_uninstall_clicked (self, btn):
+ return self.install_uninstall("uninstall")
+
def cb_package_selected (self, view):
sel = view.get_selection()
store, it = sel.get_selected()
@@ -116,9 +142,11 @@ class UpdateWindow (AbstractDialog):
store[path][0] = not store[path][0]
return True
-class WorldListWindow (UpdateWindow):
- __file__ = __window__ = "UpdateWindow"
+class UpdateWindow (PkgListWindow):
+ def __init__ (self, *args, **kwargs):
+ PkgListWindow.__init__(self, _("Updatable Packages"), *args, **kwargs)
+class WorldListWindow (UpdateWindow):
def __init__ (self, *args, **kwargs):
- UpdateWindow.__init__(self, *args, **kwargs)
- self.window.set_title(_("World Packages"))
+ PkgListWindow.__init__(self, _("World Packages"), *args, **kwargs)
+ self.installBtn.hide()