diff options
Diffstat (limited to '')
-rw-r--r-- | portato/gui/queue.py | 2 | ||||
-rw-r--r-- | portato/gui/templates/PkgListWindow.ui (renamed from portato/gui/templates/UpdateWindow.ui) | 19 | ||||
-rw-r--r-- | portato/gui/windows/main.py | 47 | ||||
-rw-r--r-- | portato/gui/windows/pkglist.py (renamed from portato/gui/windows/update.py) | 70 |
4 files changed, 96 insertions, 42 deletions
diff --git a/portato/gui/queue.py b/portato/gui/queue.py index e73891d..6d3d19d 100644 --- a/portato/gui/queue.py +++ b/portato/gui/queue.py @@ -144,7 +144,7 @@ class EmergeQueue: old = system.find_packages(pkg.get_slot_cp(), system.SET_INSTALLED) if old: old = old[0] # assume we have only one there - cmp = pkg.compare_version(old) + cmp = pkg.__cmp__(old) if cmp > 0: update = True elif cmp < 0: diff --git a/portato/gui/templates/UpdateWindow.ui b/portato/gui/templates/PkgListWindow.ui index ec8288e..fdcdb23 100644 --- a/portato/gui/templates/UpdateWindow.ui +++ b/portato/gui/templates/PkgListWindow.ui @@ -2,9 +2,8 @@ <interface> <requires lib="gtk+" version="2.14"/> <!-- interface-naming-policy toplevel-contextual --> - <object class="GtkWindow" id="UpdateWindow"> + <object class="GtkWindow" id="PkgListWindow"> <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property> - <property name="title" translatable="yes">Updatable Packages</property> <property name="window_position">center-on-parent</property> <property name="destroy_with_parent">True</property> <property name="urgency_hint">True</property> @@ -92,6 +91,22 @@ <property name="position">2</property> </packing> </child> + <child> + <object class="GtkButton" id="uninstallBtn"> + <property name="label" translatable="yes">_Uninstall Selected</property> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">True</property> + <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property> + <property name="use_underline">True</property> + <signal name="clicked" handler="cb_uninstall_clicked"/> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">False</property> + <property name="position">3</property> + </packing> + </child> </object> <packing> <property name="expand">False</property> 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() |