summaryrefslogtreecommitdiff
path: root/portato/gui/windows
diff options
context:
space:
mode:
Diffstat (limited to 'portato/gui/windows')
-rw-r--r--portato/gui/windows/about.py8
-rw-r--r--portato/gui/windows/basic.py26
-rw-r--r--portato/gui/windows/main.py52
-rw-r--r--portato/gui/windows/pkglist.py (renamed from portato/gui/windows/update.py)69
4 files changed, 117 insertions, 38 deletions
diff --git a/portato/gui/windows/about.py b/portato/gui/windows/about.py
index 937ed8b..6c6fec5 100644
--- a/portato/gui/windows/about.py
+++ b/portato/gui/windows/about.py
@@ -15,7 +15,7 @@ from __future__ import absolute_import
import gtk
from .basic import AbstractDialog
-from ...constants import VERSION, APP_ICON
+from ...constants import VERSION, REVISION, APP_ICON
class AboutWindow (AbstractDialog):
"""A window showing the "about"-informations."""
@@ -30,5 +30,11 @@ class AboutWindow (AbstractDialog):
self.window.set_version(VERSION)
self.window.set_logo(img.get_pixbuf())
+ if REVISION:
+ gitlabel = self.tree.get_widget("gitLabel")
+ gitlabel.set_label(REVISION)
+ else:
+ self.tree.get_widget("gitHB").hide()
+
self.window.show_all()
diff --git a/portato/gui/windows/basic.py b/portato/gui/windows/basic.py
index 3cedd69..20d8009 100644
--- a/portato/gui/windows/basic.py
+++ b/portato/gui/windows/basic.py
@@ -20,10 +20,11 @@ from functools import wraps
import os.path
from ...constants import TEMPLATE_DIR, APP, LOCALE_DIR
-from ...helper import error
+from ...helper import error, debug
# for the GtkBuilder to translate correctly :)
import ctypes
+from locale import CODESET
try:
getlib = ctypes.cdll.LoadLibrary("libgettextlib.so")
except OSError:
@@ -33,6 +34,13 @@ else:
getlib.bindtextdomain(APP, LOCALE_DIR)
getlib.bind_textdomain_codeset(APP, "UTF-8")
+ # some debugging output about the current codeset used
+ nll = getlib.nl_langinfo
+ nll.restype = ctypes.c_char_p
+ debug("Switching from '%s' to 'UTF-8'.", nll(CODESET))
+
+ getlib.bind_textdomain_codeset(APP, "UTF-8")
+
class WrappedTree (object):
__slots__ = ("klass", "tree", "get_widget", "get_ui")
def __init__ (self, klass, tree):
@@ -70,10 +78,24 @@ class UIBuilder (object):
if not hasattr(self, "__file__"):
self.__file__ = self.__class__.__name__
+ # general setup
self._builder = gtk.Builder()
self._builder.add_from_file(os.path.join(TEMPLATE_DIR, self.__file__+".ui"))
self._builder.set_translation_domain(APP)
+
+ self.tree = WrappedTree(self.__class__.__name__, self._builder)
+ # load menu if existing
+ menufile = os.path.join(TEMPLATE_DIR, self.__file__+".menu")
+ if os.path.exists(menufile):
+ debug("There is a menu-file for '%s'. Trying to load it.", self.__file__)
+ barbox = self.tree.get_widget("menubar_box")
+ if barbox is not None:
+ self._builder.add_from_file(menufile)
+ bar = self.tree.get_ui("menubar")
+ barbox.pack_start(bar, expand = False, fill = False)
+
+ # signal connections
if connector is None: connector = self
unconnected = self._builder.connect_signals(connector)
@@ -82,8 +104,6 @@ class UIBuilder (object):
for uc in set(unconnected):
error("Signal '%s' not connected in class '%s'.", uc, self.__class__.__name__)
- self.tree = WrappedTree(self.__class__.__name__, self._builder)
-
class Window (UIBuilder):
def __init__ (self):
diff --git a/portato/gui/windows/main.py b/portato/gui/windows/main.py
index 1b67747..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
+from .pkglist import UpdateWindow, WorldListWindow
class PackageTable:
"""A window with data about a specfic package."""
@@ -1594,34 +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.
+ """
+ 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 8e32dd9..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()
@@ -115,3 +141,12 @@ class UpdateWindow (AbstractDialog):
store = self.view.get_model()
store[path][0] = not store[path][0]
return True
+
+class UpdateWindow (PkgListWindow):
+ def __init__ (self, *args, **kwargs):
+ PkgListWindow.__init__(self, _("Updatable Packages"), *args, **kwargs)
+
+class WorldListWindow (UpdateWindow):
+ def __init__ (self, *args, **kwargs):
+ PkgListWindow.__init__(self, _("World Packages"), *args, **kwargs)
+ self.installBtn.hide()