diff options
52 files changed, 3153 insertions, 679 deletions
diff --git a/.bzrignore b/.bzrignore deleted file mode 100644 index 6e92f57..0000000 --- a/.bzrignore +++ /dev/null @@ -1 +0,0 @@ -tags diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..10d85cd --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ +tags +*.pyc +*.so +*.c @@ -1,3 +1,9 @@ +next: + +- allow eix as backend DB +- use an internal messagequeue module instead of external shm +- show the list of world packages + 0.13.1: - fix segfault in GLib - correct config path handling for portage-2.1.7.x diff --git a/doc/TODO b/doc/TODO deleted file mode 100644 index 81c8d5c..0000000 --- a/doc/TODO +++ /dev/null @@ -1,40 +0,0 @@ -Documentation: -============== - -Unittest: -======== - -- ALL! - -Backend: -======== - -- add Paludis support \ -- add pkgcore support |-> not necessairy if catapult is used -- add equo support / - -- rewrite flags handling - -- also check installed packages if they block the current one - -- make sure, a package being removed from the queue is not needed as a dependency by another package -- binary package support - -GUI: -==== - -Main Point: user preferences: - - colors and font sizes - -- rotating systray icon -- if a package has been merged, but there are still dependencies to be merged - move the dependencies up the tree (Updater) -- move GUI prefs out of the system config -- show reverse dependencies -- reload package table when emerge is finished -- show which package has a dependency that causes a block - -[quote] -I would like to be able to see at a glance: -1. How many packages I have installed. (Hopefully in the menubar) -a. How many of the packages are installed, and the number there are in each category. (Just like you do with the queue: "x of y"::"installed of available") -[/quote] diff --git a/doc/TRANSLATING b/doc/TRANSLATING index 4b49fa5..75d1c45 100644 --- a/doc/TRANSLATING +++ b/doc/TRANSLATING @@ -12,15 +12,28 @@ KBabel (kde-base/kbabel) or Gtranslator (app-text/gtranslator). Getting the sources: =================== +You do need the sources to make translations, as the installed program is not sufficient. +Therefore you need to have dev-util/git installed. -You do need the sources to make translations. The installed program is not sufficient. Change into a local directory where you want to have the sources installed. Then do: -> bzr pull lp:portato +> git clone git://github.com/Necoro/portato.git You now should have the actual sources in the "portato" subdirectory. +If you later on want to update these sources, you do: + +> git pull + +Important: If you are working on a given version, you need to change to the correct branch: + +> git checkout -b 0.13 origin/0.13 + +where '0.13' has to be replaced by the version you are going to use. + +Have a look at http://www.git-scm.com for more information on how to use git. + To update an incomplete translation: =================================== diff --git a/epydoc.conf b/epydoc.conf index 62b6c73..0e81aee 100644 --- a/epydoc.conf +++ b/epydoc.conf @@ -27,7 +27,6 @@ sourcecode: yes include-log: no frames: yes css: white -redundant-details: yes # # Project diff --git a/etc/portato.cfg b/etc/portato.cfg index 2429dc7..10f5445 100644 --- a/etc/portato.cfg +++ b/etc/portato.cfg @@ -124,6 +124,7 @@ prefhint = f3f785 ; allowed values: ; - sql : SQLite Database ; - dict : Hashmap in Memory -type = sql +; - eixsql: Eix + SQLite Database +type = eixsql # vim:ts=4:sw=4:noexpandtab:ft=cfg diff --git a/extensions.sh b/extensions.sh new file mode 100755 index 0000000..eb44d92 --- /dev/null +++ b/extensions.sh @@ -0,0 +1,10 @@ +#!/bin/sh + +cflags=$(python -c "from portato.backend import system; print system.get_global_settings('CFLAGS')") + +find -name "*.so" -print0 | xargs -0 rm -f +find -name "*.c" -print0 | xargs -0 rm -f + +CFLAGS=$cflags python setup.py build_ext -i + +rm -rf build diff --git a/i18n/messages.pot b/i18n/messages.pot index aed996a..f148ce2 100644 --- a/i18n/messages.pot +++ b/i18n/messages.pot @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2009-08-31 22:04+0200\n" +"POT-Creation-Date: 2009-08-31 22:12+0200\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" "Language-Team: LANGUAGE <LL@li.org>\n" @@ -573,7 +573,7 @@ msgstr "" msgid "No %(old)s language file installed. Disable highlighting." msgstr "" -#: portato/gui/views.py:130 plugins/package_details.py:102 +#: portato/gui/views.py:130 plugins/package_details.py:108 #, python-format msgid "Error: %s" msgstr "" @@ -836,6 +836,20 @@ msgstr "" msgid "Update" msgstr "" +#: portato/eix/exceptions.py:26 +msgid "Unknown error." +msgstr "" + +#: portato/eix/exceptions.py:37 +#, python-format +msgid "End of file reached though it was not expected: '%s'" +msgstr "" + +#: portato/eix/exceptions.py:45 +#, python-format +msgid "Version '%s' is not supported." +msgstr "" + #: portato/backend/flags.py:527 #, python-format msgid "Conflicting values for masking status: %s" @@ -867,11 +881,11 @@ msgstr "" msgid "BUG in flags.new_masking_status. It returns '%s'" msgstr "" -#: portato/__init__.py:53 +#: portato/__init__.py:50 msgid "do not fork off as root" msgstr "" -#: portato/__init__.py:76 +#: portato/__init__.py:79 msgid "Starting Portato" msgstr "" @@ -906,31 +920,49 @@ msgid "" "regenerated on each startup." msgstr "" -#: portato/db/__init__.py:40 -msgid "Cannot load SQLDatabase." +#: portato/db/__init__.py:26 +msgid "eix + SQLite" +msgstr "" + +#: portato/db/__init__.py:26 +msgid "" +"Similar to SQLite, but now uses the eix database to get the package " +"information.\n" +"This should be much faster on startup, but requires that your eix database " +"is always up-to-date." msgstr "" -#: portato/db/__init__.py:51 +#: portato/db/__init__.py:41 portato/db/__init__.py:56 #, python-format -msgid "Unknown database type: %s" +msgid "Cannot load %s." msgstr "" -#: portato/db/database.py:38 -msgid "ALL" +#: portato/db/__init__.py:62 +#, python-format +msgid "Unknown database type: %s" msgstr "" -#: portato/db/dict.py:94 +#: portato/db/hash.py:94 #, python-format msgid "" "Catched KeyError => %s seems not to be an available category. Have you " "played with rsync-excludes?" msgstr "" -#: portato/db/dict.py:149 +#: portato/db/hash.py:149 #, python-format msgid "Error while compiling search expression: '%s'." msgstr "" +#: portato/db/eix_sql.py:35 +#, python-format +msgid "Cache file '%s' does not exist. Using default instead." +msgstr "" + +#: portato/db/database.py:38 +msgid "ALL" +msgstr "" + #: portato/db/sql.py:79 msgid "Cleaning database..." msgstr "" @@ -964,133 +996,153 @@ msgstr "" msgid "Unrecognized line in configuration: %s" msgstr "" -#: portato/listener.py:94 +#: portato/listener.py:85 msgid "Listener has not been started." msgstr "" -#: portato/plugin.py:438 portato/plugin.py:441 +#: portato/listener.py:94 +#, python-format +msgid "An exception occured while accessing the message queue: %s" +msgstr "" + +#: portato/plugin.py:446 portato/plugin.py:449 +#, python-format +msgid "Loading plugin module '%(plugin)s' failed: %(error)s" +msgstr "" + +#: portato/plugin.py:459 #, python-format -msgid "Loading plugin '%(plugin)s' failed: %(error)s" +msgid "Loading widgets plugin '%(plugin)s' failed: %(error)s" msgstr "" -#: portato/plugin.py:451 +#: portato/plugin.py:462 +#, python-format +msgid "Loading widgets of plugin '%(plugin)s' failed: %(error)s" +msgstr "" + +#: portato/plugin.py:466 #, python-format msgid "Widgets of plugin '%s' loaded." msgstr "" -#: portato/plugin.py:482 +#: portato/plugin.py:497 msgid "Plugin is disabled!" msgstr "" -#: portato/plugin.py:484 +#: portato/plugin.py:499 msgid "Plugin has unresolved dependencies - disabled!" msgstr "" -#: portato/plugin.py:488 +#: portato/plugin.py:503 #, python-format msgid "Plugin '%s' loaded." msgstr "" -#: portato/plugin.py:528 +#: portato/plugin.py:543 #, python-format msgid "Overriding hook '%(hook)s' with plugin '%(plugin)s'." msgstr "" -#: portato/plugin.py:586 +#: portato/plugin.py:601 #, python-format msgid "" "For hook '%(hook)s' an override is already defined by plugin '%(plugin)s'!" msgstr "" -#: portato/plugin.py:587 +#: portato/plugin.py:602 #, python-format msgid "It is now replaced by the one from plugin '%s'!" msgstr "" -#: portato/plugin.py:620 +#: portato/plugin.py:635 #, python-format msgid "" "Dependant '%(dep)s' for '%(hook)s' in plugin '%(plugin)s' not found! Adding " "nevertheless." msgstr "" -#: plugins/etc_proposals.py:34 +#: portato/plugin.py:704 portato/plugin.py:707 +#, python-format +msgid "Registrating plugin '%(plugin)s' failed: %(error)s" +msgstr "" + +#: plugins/etc_proposals.py:32 msgid "Cannot start etc-proposals. Not root!" msgstr "" -#: plugins/package_details.py:67 +#: plugins/package_details.py:73 msgid "Shows the Changelog of a package" msgstr "" -#: plugins/package_details.py:69 +#: plugins/package_details.py:75 msgid "Changelog" msgstr "" -#: plugins/package_details.py:79 +#: plugins/package_details.py:85 msgid "Shows the ebuild of a package" msgstr "" -#: plugins/package_details.py:82 +#: plugins/package_details.py:88 msgid "Ebuild" msgstr "" -#: plugins/package_details.py:89 +#: plugins/package_details.py:95 msgid "Shows the installed files of a package" msgstr "" -#: plugins/package_details.py:91 +#: plugins/package_details.py:97 msgid "Files" msgstr "" -#: plugins/package_details.py:105 +#: plugins/package_details.py:111 msgid "Shows the dependencies of a package" msgstr "" -#: plugins/package_details.py:107 +#: plugins/package_details.py:113 msgid "Dependencies" msgstr "" -#: plugins/package_details.py:179 +#: plugins/package_details.py:185 #, python-format msgid "If '%s' is disabled" msgstr "" -#: plugins/package_details.py:181 +#: plugins/package_details.py:187 #, python-format msgid "If '%s' is enabled" msgstr "" -#: plugins/package_details.py:187 +#: plugins/package_details.py:193 msgid "One of the following" msgstr "" -#: plugins/package_details.py:192 +#: plugins/package_details.py:198 msgid "All of the following" msgstr "" -#: plugins/package_details.py:203 +#: plugins/package_details.py:209 msgid "" "Can't display dependencies: This package has an unsupported dependency " "string." msgstr "" -#: plugins/notify.py:24 +#: plugins/notify.py:23 msgid "Cannot import 'pynotify'." msgstr "" -#: plugins/notify.py:36 +#: plugins/notify.py:35 msgid "Notify called while process is still running!" msgstr "" -#: plugins/notify.py:40 +#: plugins/notify.py:39 msgid "Emerge finished!" msgstr "" -#: plugins/notify.py:44 +#: plugins/notify.py:43 msgid "Emerge failed!" msgstr "" -#: plugins/notify.py:45 +#: plugins/notify.py:44 #, python-format msgid "Error Code: %d" msgstr "" diff --git a/plugins/etc_proposals.py b/plugins/etc_proposals.py index 83b38f7..052f3d3 100644 --- a/plugins/etc_proposals.py +++ b/plugins/etc_proposals.py @@ -10,8 +10,6 @@ # # Written by René 'Necoro' Neumann <necoro@necoro.net> -from portato.helper import error - import os from subprocess import Popen @@ -31,7 +29,7 @@ class EtcProposals (WidgetPlugin): if os.getuid() == 0: Popen(self.prog+options) else: - error("ETC_PROPOSALS :: %s",_("Cannot start etc-proposals. Not root!")) + helper.error("ETC_PROPOSALS :: %s",_("Cannot start etc-proposals. Not root!")) def hook (self, *args, **kwargs): """Entry point for this plugin.""" diff --git a/plugins/new_version.py b/plugins/new_version.py index 94e61ca..9fa5f4e 100644 --- a/plugins/new_version.py +++ b/plugins/new_version.py @@ -12,16 +12,11 @@ from portato.helper import debug, warning -try: - from bzrlib import plugin, branch -except ImportError: - plugin = branch = None - warning("NEW_VERSION :: Cannot import 'bzrlib'") - +from subprocess import Popen, PIPE import gobject from portato import get_listener -from portato.constants import REPOURI, VERSION, APP_ICON, APP +from portato.constants import REPOURI, REVISION, APP_ICON, APP from portato.gui.utils import GtkThread class NewVersionFinder(WidgetPlugin): @@ -29,7 +24,7 @@ class NewVersionFinder(WidgetPlugin): Checks for a new version of portato every 30 minutes and on startup. """ __author__ = "René 'Necoro' Neumann" - __dependency__ = ["dev-util/bzr"] + __dependency__ = ["dev-util/git"] def init (self): self.add_call("main", self.run) @@ -37,20 +32,30 @@ class NewVersionFinder(WidgetPlugin): def widget_init (self): self.create_widget("Plugin Menu", "Check for new _versions", activate = self.menu) + def get_notify_callback (self, rev): + def callback(): + get_listener().send_notify( + base = "New Portato Live Version Found", + descr = "The most recent revision is %s." % rev, + icon = APP_ICON) + return False + + return callback + def find_version (self, rev): - try: - b = branch.Branch.open(REPOURI) - except Exception, e: - warning("NEW_VERSION :: Exception occured while accessing the remote branch: %s", str(e)) - return - - debug("NEW_VERSION :: Installed rev: %s - Current rev: %s", rev, b.revno()) - if int(rev) < int(b.revno()): - def callback(): - get_listener().send_notify(base = "New Portato Live Version Found", descr = "You have rev. %s, but the most recent revision is %s." % (rev, b.revno()), icon = APP_ICON) - return False - - gobject.idle_add(callback) + + repo, branch = REPOURI.split('::') + + remote_rev = Popen(['git', 'ls-remote', repo, branch], stdout = PIPE).communicate()[0].strip().split('\t') + + if len(remote_rev) and remote_rev[1] not in (branch, 'refs/heads/'+branch, 'refs/tags/'+branch): + warning('NEW_VERSION :: Returned revision information looks strange: %s', str(remote_rev)) + else: + remote_rev = remote_rev[0] + debug("NEW_VERSION :: Installed rev: %s - Current rev: %s", remote_rev, rev) + + if rev != remote_rev: + gobject.idle_add(self.get_notify_callback(remote_rev)) def start_thread(self, rev): t = GtkThread(target = self.find_version, name = "Version Updater Thread", args = (rev,)) @@ -62,16 +67,11 @@ class NewVersionFinder(WidgetPlugin): """ Run the thread once. """ - v = VERSION.split() - if len(v) != 3: + if not REVISION: return None - - rev = v[-1] - - plugin.load_plugins() # to have lp: addresses parsed - self.start_thread(rev) - return rev + self.start_thread(REVISION) + return REVISION def run (self, *args, **kwargs): """ @@ -82,4 +82,4 @@ class NewVersionFinder(WidgetPlugin): if rev is not None: gobject.timeout_add(30*60*1000, self.start_thread, rev) # call it every 30 minutes -register(NewVersionFinder, (branch is None)) +register(NewVersionFinder, REVISION == '') diff --git a/plugins/notify.py b/plugins/notify.py index 3670e20..4aba2c6 100644 --- a/plugins/notify.py +++ b/plugins/notify.py @@ -14,14 +14,13 @@ disable = False from portato import get_listener -from portato.helper import warning, error, debug from portato.constants import APP_ICON, APP try: import pynotify except ImportError: disable = True - warning("NOTIFY :: %s", _("Cannot import 'pynotify'.")) + helper.warning("NOTIFY :: %s", _("Cannot import 'pynotify'.")) class Notify (Plugin): __author__ = "René 'Necoro' Neumann" @@ -33,7 +32,7 @@ class Notify (Plugin): def notify (self, retcode, **kwargs): if retcode is None: - warning("NOTIFY :: %s", _("Notify called while process is still running!")) + helper.warning("NOTIFY :: %s", _("Notify called while process is still running!")) else: icon = APP_ICON if retcode == 0: diff --git a/plugins/package_details.py b/plugins/package_details.py index 6a17f1e..19f3126 100644 --- a/plugins/package_details.py +++ b/plugins/package_details.py @@ -23,13 +23,19 @@ class Detail (WidgetPlugin): """ __author__ = "René 'Necoro' Neumann" + _view_ = None _old_pkg = None + _widget_ = None + _widget_name_ = None def init(self): self.add_call("update_table", self._update, type = "after") def widget_init (self): + if (self._widget_ is None) or (self._widget_name_ is None): + raise PluginLoadException, ("Has not set _widget_ or _widget_name_.") + self.add_widget("Package Notebook", (self._widget_, self._widget_name_)) # if the detail was updated before it was actually initialized, update it again :) diff --git a/portato/__init__.py b/portato/__init__.py index 653329c..98c019d 100644 --- a/portato/__init__.py +++ b/portato/__init__.py @@ -14,15 +14,16 @@ from __future__ import absolute_import import gettext, locale import sys, os -import subprocess, threading -import atexit from optparse import OptionParser, SUPPRESS_HELP -from . import log -from .constants import LOCALE_DIR, APP, VERSION -from .su import detect_su_command +from .log import start as logstart +from .constants import LOCALE_DIR, APP, VERSION, REVISION from .helper import debug, info, error +# set better version info +if REVISION: + VERSION = '%s (git: %s)' % (VERSION, REVISION) + # listener-handling __listener = None @@ -46,7 +47,7 @@ def get_parser (use_ = False): parser = OptionParser(version = vers, prog = "portato", description = desc, usage = usage) - parser.add_option("--shm", action = "store", nargs = 3, type="long", dest = "shm", + parser.add_option("--mq", action = "store", nargs = 1, type="long", dest = "mq", default = None, help = SUPPRESS_HELP) parser.add_option("-F", "--no-fork", action = "store_true", dest = "nofork", default = False, @@ -54,31 +55,34 @@ def get_parser (use_ = False): return parser -def start(): - +def _sub_start (): # set gettext stuff locale.setlocale(locale.LC_ALL, '') gettext.install(APP, LOCALE_DIR, unicode = True) +def start(): + + # set gettext stuff + _sub_start() + # start logging - log.start(file=False) + logstart(file=False) # run parser (options, args) = get_parser().parse_args() - # close listener at exit - atexit.register(get_listener().close) - if options.nofork or os.getuid() == 0: # start GUI - log.start(file = True) # start logging to file + + # close listener at exit + import atexit + atexit.register(get_listener().close) + + logstart(file = True) # start logging to file from .gui import run info("%s v. %s", _("Starting Portato"), VERSION) - if options.shm: - get_listener().set_send(*options.shm) - else: - get_listener().set_send() + get_listener().set_send(options.mq) try: run() @@ -87,14 +91,14 @@ def start(): else: # start us again in root modus and launch listener - import shm_wrapper as shm + from . import ipc + import subprocess, threading + from .su import detect_su_command - mem = shm.create_memory(1024, permissions=0600) - sig = shm.create_semaphore(InitialValue = 0, permissions = 0600) - rw = shm.create_semaphore(InitialValue = 1, permissions = 0600) + mq = ipc.MessageQueue(None, create = True, exclusive = True) # start listener - lt = threading.Thread(target=get_listener().set_recv, args = (mem, sig, rw)) + lt = threading.Thread(target=get_listener().set_recv, args = (mq,)) lt.setDaemon(False) lt.start() @@ -106,7 +110,7 @@ def start(): su = detect_su_command() if su: debug("Using '%s' as su command.", su.bin) - cmd = su.cmd("%s --no-fork --shm %ld %ld %ld" % (sys.argv[0], mem.key, sig.key, rw.key)) + cmd = su.cmd("%s --no-fork --mq %ld" % (sys.argv[0], mq.key)) sp = subprocess.Popen(cmd, env = env) @@ -124,3 +128,9 @@ def start(): if lt.isAlive(): debug("Listener is still running. Close it.") get_listener().close() + lt.join() + + try: + mq.remove() + except ipc.MessageQueueRemovedError: + debug("MessageQueue already removed. Ignore.") diff --git a/portato/backend/__init__.py b/portato/backend/__init__.py index 8eae806..4f20a18 100644 --- a/portato/backend/__init__.py +++ b/portato/backend/__init__.py @@ -16,9 +16,6 @@ from ..helper import debug from .system_interface import SystemInterface from .exceptions import BlockedException, PackageNotFoundException, DependencyCalcError, InvalidSystemError -SYSTEM = "portage" # the name of the current system -_sys = None # the SystemInterface-instance - class _Package (object): """Wrapping class from which L{portato.backend.Package} inherits. This is used by the flags module to check whether an object is a package. It cannot use the normal Package class as this results in cyclic dependencies.""" @@ -26,42 +23,48 @@ class _Package (object): def __init__ (self): raise TypeError, "Calling __init__ on portato.backend._Package objects is not allowed." +def is_package(what): + return isinstance(what, _Package) + class SystemWrapper (SystemInterface): """This is a wrapper to the different system interfaces, allowing the direct import via C{from portato.backend import system}. With this wrapper a change of the system is propagated to all imports.""" + __system = 'portage' + __wrapped_sys = None + __slots__ = ('__system', '__wrapped_sys', 'set_system', '__load') + def __getattribute__ (self, name): """Just pass all attribute accesses directly to _sys.""" - return getattr(_sys, name) -def set_system (new_sys): - """Sets the current system to a new one. + if name in SystemWrapper.__slots__: + return object.__getattribute__(self, name) + + if SystemWrapper.__wrapped_sys is None: + SystemWrapper.__load() - @param new_sys: the name of the system to take - @type new_sys: string""" + return getattr(SystemWrapper.__wrapped_sys, name) - global SYSTEM - if new_sys != SYSTEM: - SYSTEM = new_sys - load_system() + @classmethod + def set_system (cls, system): + """Sets the current system to a new one. -def load_system (): - """Loads the current chosen system. + @param system: the name of the system to take + @type system: string""" - @raises InvalidSystemError: if an inappropriate system is set""" - - global _sys + cls.__system = system + cls.__wrapped_sys = None - if SYSTEM == "portage": - debug("Setting Portage System") - from .portage import PortageSystem - _sys = PortageSystem () - else: - raise InvalidSystemError, SYSTEM + @classmethod + def __load (cls): + """Loads the current chosen system. -system = SystemWrapper() + @raises InvalidSystemError: if an inappropriate system is set""" + if cls.__system == "portage": + debug("Setting Portage System") + from .portage import PortageSystem + cls.__wrapped_sys = PortageSystem () + else: + raise InvalidSystemError, cls.__system -def is_package(what): - return isinstance(what, _Package) - -load_system() +system = SystemWrapper() diff --git a/portato/backend/package.py b/portato/backend/package.py index 8a80fd5..c085816 100644 --- a/portato/backend/package.py +++ b/portato/backend/package.py @@ -371,16 +371,6 @@ class Package (_Package): raise NotImplementedError - def compare_version(self, other): - """Compares this package's version to another's CPV; returns -1, 0, 1. - - @param other: the other package - @type other: Package - @returns: -1, 0 or 1 - @rtype: int""" - - raise NotImplementedError - def matches (self, criterion): """This checks, whether this package matches a specific versioning criterion - e.g.: "<=net-im/foobar-1.2". diff --git a/portato/backend/portage/package.py b/portato/backend/portage/package.py index 2b40e41..79af79b 100644 --- a/portato/backend/portage/package.py +++ b/portato/backend/portage/package.py @@ -294,18 +294,8 @@ class PortagePackage (Package): return self.get_package_settings("USE", installed = True).split() else: return [] - def compare_version(self,other): - v1 = self._scpv - v2 = portage.catpkgsplit(other.get_cpv()) - # if category is different - if v1[0] != v2[0]: - return cmp(v1[0],v2[0]) - # if name is different - elif v1[1] != v2[1]: - return cmp(v1[1],v2[1]) - # Compare versions - else: - return portage.pkgcmp(v1[1:],v2[1:]) + def __cmp__ (self, other): + return system.compare_versions(self.get_cpv(), other.get_cpv()) def matches (self, criterion): # cpv_matches needs explicit slot info diff --git a/portato/backend/portage/system.py b/portato/backend/portage/system.py index 94553c6..620ab73 100644 --- a/portato/backend/portage/system.py +++ b/portato/backend/portage/system.py @@ -125,6 +125,20 @@ class PortageSystem (SystemInterface): else: return True + def compare_versions(self, v1, v2): + v1 = self.split_cpv(v1) + v2 = self.split_cpv(v2) + + # if category is different + if v1[0] != v2[0]: + return cmp(v1[0],v2[0]) + # if name is different + elif v1[1] != v2[1]: + return cmp(v1[1],v2[1]) + # Compare versions + else: + return portage.pkgcmp(v1[1:],v2[1:]) + def with_bdeps(self): """Returns whether the "--with-bdeps" option is set to true. @@ -223,8 +237,11 @@ class PortageSystem (SystemInterface): cpv = portage.dep_getcpv(cpv) return portage.catpkgsplit(cpv) - def sort_package_list(self, pkglist): - pkglist.sort(PortagePackage.compare_version) # XXX: waaah ... direct package naming... =/ + def sort_package_list(self, pkglist, only_cpv = False): + if only_cpv: + pkglist.sort(self.compare_versions) + else: + pkglist.sort() return pkglist def reload_settings (self): diff --git a/portato/backend/system_interface.py b/portato/backend/system_interface.py index 43de1ec..f0bfdf6 100644 --- a/portato/backend/system_interface.py +++ b/portato/backend/system_interface.py @@ -68,6 +68,18 @@ class SystemInterface (object): """ raise NotImplementedError + + def compare_versions(self, v1, v2): + """Compares two CPVs; returns -1, 0, 1. + + @param v1: one CPV + @type v1: cpv + @param v2: the second CPV + @type v2: cpv + @returns: -1, 0 or 1 + @rtype: int""" + + raise NotImplementedError def find_best(self, list, only_cpv = False): """Returns the best package out of a list of packages. @@ -108,8 +120,8 @@ class SystemInterface (object): @param key: the key to look for @type key: string - @param all: the package set to use - @type all: string + @param pkgSet: the package set to use + @type pkgSet: string @param masked: if True, also look for masked packages @type masked: boolean @param with_version: if True, return CPVs - else CP @@ -134,11 +146,13 @@ class SystemInterface (object): raise NotImplementedError - def sort_package_list(self, pkglist): + def sort_package_list(self, pkglist, only_cpv = False): """Sorts a package list in the same manner portage does. @param pkglist: list to sort - @type pkglist: Packages[] + @type pkglist: Packages[] or cpv[] + @param only_cpv: flags whether the passed list consists of Packages or of CPVs + @type: bool """ raise NotImplementedError diff --git a/portato/constants.py b/portato/constants.py index 7d2a9d6..bce15d2 100644 --- a/portato/constants.py +++ b/portato/constants.py @@ -42,8 +42,10 @@ These should be set during the installation. @var TEMPLATE_DIR: Directory containing the UI template files. @type TEMPLATE_DIR: string -@var REPOURI: the URI of the bzr repository -- only used in live versions +@var REPOURI: the URI of the git repository -- only used in live versions @type REPOURI: string +@var REVISION: the revision of the live version +@type REVISION: string """ import os from os.path import join as pjoin @@ -70,4 +72,5 @@ SETTINGS_DIR = pjoin(HOME, "."+APP) TEMPLATE_DIR = "portato/gui/templates/" # live versions only -REPOURI = "lp:portato" +REPOURI = "git://github.com/Necoro/portato.git::master" +REVISION = "" diff --git a/portato/db/__init__.py b/portato/db/__init__.py index da8a81e..9d21d3b 100644 --- a/portato/db/__init__.py +++ b/portato/db/__init__.py @@ -19,34 +19,59 @@ class UnknownDatabaseTypeError (Exception): pass _SESSION = None +_TYPE = None +_DEFAULT = "dict" +_DATABASE = None types = { "sql": (_("SQLite"), _("Uses an SQLite-database to store package information.\nMay take longer to generate at the first time, but has advantages if portato is re-started with an unchanged portage tree. Additionally it allows to use fast SQL expressions for fetching the data.")), - "dict": (_("Hashmap"), _("Uses an in-memory hashmap to store package information.\nHas been used since at least version 0.3.3, but all information has to be regenerated on each startup.")) + "dict": (_("Hashmap"), _("Uses an in-memory hashmap to store package information.\nHas been used since at least version 0.3.3, but all information has to be regenerated on each startup.")), + "eixsql" : (_("eix + SQLite"), _("Similar to SQLite, but now uses the eix database to get the package information.\nThis should be much faster on startup, but requires that your eix database is always up-to-date.")) } -def Database(type): - global _SESSION +def Database(type = None): + global _SESSION, _TYPE, _DATABASE + if type is None: + if _DATABASE is None: + warning("No database type specified! Falling back to default.") + return Database(_DEFAULT) + else: + return _DATABASE + if _SESSION is None: _SESSION = Session("db.cfg", name = "DB") _SESSION.load() + _TYPE = type + if type == "sql": debug("Using SQLDatabase") try: from .sql import SQLDatabase except ImportError: - warning(_("Cannot load SQLDatabase.")) - return Database("dict") + warning(_("Cannot load %s."), "SQLDatabase") + _DATABASE = Database("dict") else: - return SQLDatabase(SectionDict(_SESSION, "SQL")) + _DATABASE = SQLDatabase(SectionDict(_SESSION, type)) elif type == "dict": - debug("Using DictDatabase") - from .dict import DictDatabase - return DictDatabase(SectionDict(_SESSION, "dict")) + debug("Using HashDatabase") + from .hash import HashDatabase + _DATABASE = HashDatabase(SectionDict(_SESSION, type)) + elif type == "eixsql": + debug("Using EixSQLDatabase") + try: + from .eix_sql import EixSQLDatabase + except ImportError: + warning(_("Cannot load %s."), "EixSQLDatabase.") + _DATABASE = Database("sql") + else: + _DATABASE = EixSQLDatabase(SectionDict(_SESSION, type)) + else: error(_("Unknown database type: %s"), type) raise UnknownDatabaseTypeError, type + + return _DATABASE diff --git a/portato/db/eix_sql.py b/portato/db/eix_sql.py new file mode 100644 index 0000000..c2d2292 --- /dev/null +++ b/portato/db/eix_sql.py @@ -0,0 +1,69 @@ +# -*- coding: utf-8 -*- +# +# File: portato/db/eix_sql.py +# This file is part of the Portato-Project, a graphical portage-frontend. +# +# Copyright (C) 2006-2009 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. +# +# Written by René 'Necoro' Neumann <necoro@necoro.net> + +from __future__ import absolute_import, with_statement + +try: + import sqlite3 as sql +except ImportError: + from pysqlite2 import dbapi2 as sql + +import os + +from .sql import SQLDatabase +from ..eix import EixReader +from ..helper import debug, warning +from ..backend import system + +class EixSQLDatabase (SQLDatabase): + + CACHE_FILE = "/var/cache/eix" + + def __init__ (self, session): + + self.cache = session.get("cache", self.CACHE_FILE) + if not os.path.exists(self.cache): + warning(_("Cache file '%s' does not exist. Using default instead."), self.cache) + self.cache = self.CACHE_FILE + + debug("Using '%s' as eix cache file.", self.cache) + + session["cache"] = self.cache + + SQLDatabase.__init__(self, session) + + def updated (self): + mtime = os.stat(self.cache).st_mtime + old = self.session.get("mtime", 0) + + self.session["mtime"] = str(mtime) + + return old < mtime + + def generate_cat_expr (self, cat): + # be a noop + return cat + + @SQLDatabase.con + def populate (self, category = None, connection = None): + inst = set(system.find_packages(pkgSet = system.SET_INSTALLED, key = category, with_version = False)) + + def _get(): + with EixReader(self.cache) as eix: + for cat in eix.categories: + if category is None or cat.name == category: + for pkg in cat.packages: + p = "%s/%s" % (cat.name, pkg.name) + yield (cat.name, pkg.name, p in inst, False) + + connection.executemany("INSERT INTO packages (cat, name, inst, disabled) VALUES (?, ?, ?, ?)", _get()) + connection.commit() diff --git a/portato/db/dict.py b/portato/db/hash.py index 279ab97..8cea6f2 100644 --- a/portato/db/dict.py +++ b/portato/db/hash.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- # -# File: portato/db/dict.py +# File: portato/db/hash.py # This file is part of the Portato-Project, a graphical portage-frontend. # # Copyright (C) 2006-2009 René 'Necoro' Neumann @@ -19,7 +19,7 @@ from ..helper import info from ..backend import system from .database import Database, PkgData -class DictDatabase (Database): +class HashDatabase (Database): """An internal database which holds a simple dictionary cat -> [package_list].""" lock = Database.lock diff --git a/portato/db/sql.py b/portato/db/sql.py index db66764..fbc01e6 100644 --- a/portato/db/sql.py +++ b/portato/db/sql.py @@ -166,7 +166,7 @@ class SQLDatabase (Database): def populate (self, category = None, connection = None): def _get(): # get the lists - inst = system.find_packages(pkgSet = system.SET_INSTALLED, key=category, with_version = False) + inst = set(system.find_packages(pkgSet = system.SET_INSTALLED, key=category, with_version = False)) for p in system.find_packages(key = category, with_version = False): cat, pkg = p.split("/") @@ -213,12 +213,26 @@ class SQLDatabase (Database): for cat in l: yield cat["cat"] + def generate_cat_expr (self, cat): + """ + Generates an expression from a category name to match all packages of the category. + + E.g. as SQLDatabase uses regexps internally, return cat/* + + @param cat: the category + @type cat: string + + @returns: expression + """ + + return cat+"/*" + @con def reload (self, cat = None, connection = None): if cat: connection.execute("DELETE FROM packages WHERE cat = ?", (cat,)) connection.commit() - self.populate(cat+"/*", connection = connection) + self.populate(self.generate_cat_expr(cat), connection = connection) else: connection.execute("DELETE FROM packages") connection.commit() @@ -247,3 +261,4 @@ class SQLDatabase (Database): self._restrict = "AND (name LIKE '%%%(restrict)s%%' OR cat LIKE '%(restrict)s%%')" % {"restrict":restrict} restrict = property(get_restrict, set_restrict) + con = staticmethod(con) diff --git a/portato/eix/__init__.py b/portato/eix/__init__.py new file mode 100644 index 0000000..346fe82 --- /dev/null +++ b/portato/eix/__init__.py @@ -0,0 +1,88 @@ +# -*- coding: utf-8 -*- +# +# File: portato/eix/__init__.py +# This file is part of the Portato-Project, a graphical portage-frontend. +# +# Copyright (C) 2006-2009 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. +# +# Written by René 'Necoro' Neumann <necoro@necoro.net> + +""" +A module to parse the eix-cache files. +""" + +from __future__ import absolute_import, with_statement +__docformat__ = "restructuredtext" + +from . import parser +from .exceptions import UnsupportedVersionError + +from ..helper import debug + +class EixReader(object): + """ + The main class to use to have access to the eix-cache. + + Note that the file used internally stays open during the whole operation. + So please call `close()` when you are finished. + + The ``EixReader`` supports the context manager protocol, so you can the ``with ... as ...``. + + :CVariables: + + supported_versions : int[] + The list of versions of the eix-cache, which are supported by this reader. + + :IVariables: + + file : file + The eix cache file. + + header : `parser.header` + The header of the eix cache. + + categories : `parser.category` [] + The list of categories. + """ + + supported_versions = (28,) + + def __init__ (self, filename): + """ + :param filename: Path to the cache file + :type filename: string + """ + + self.file = open(filename, "r") + + try: + version = parser.number(self.file) + + if version not in self.supported_versions: + raise UnsupportedVersionError(self.version) + + debug("Started EixReader for version %s.", version) + + self.file.seek(0) + + self.header = parser.header(self.file) + self.categories = parser.vector(self.file, parser.category, nelems = self.header.ncats) + except: + self.close() + raise + + def __enter__ (self): + return self + + def __exit__ (self, exc_type, exc_val, exc_tb): + self.close() + + def close (self): + """ + Closes the cache file. + """ + self.file.close() + debug("EixReader closed.") diff --git a/portato/eix/eix-format.html b/portato/eix/eix-format.html new file mode 100644 index 0000000..ee77458 --- /dev/null +++ b/portato/eix/eix-format.html @@ -0,0 +1,855 @@ +<?xml version="1.0" encoding="utf-8" ?> +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> +<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> +<head> +<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> +<meta name="generator" content="Docutils 0.5: http://docutils.sourceforge.net/" /> +<title>eix - index file format</title> +<meta name="authors" content="Martin Väth <vaeth AT mathematik DOT uni-wuerzburg DOT de> (active) Emil Beinroth <emilbeinroth AT gmx DOT net> (active) Wolfgang Frisch <xororand AT users DOT sourceforge DOT net> (inactive)" /> +<meta name="copyright" content="This file is part of the eix project and distributed under the terms of the GNU General Public License v2." /> +<style type="text/css"> + +/* +:Author: David Goodger (goodger@python.org) +:Id: $Id: html4css1.css 5196 2007-06-03 20:25:28Z wiemann $ +:Copyright: This stylesheet has been placed in the public domain. + +Default cascading style sheet for the HTML output of Docutils. + +See http://docutils.sf.net/docs/howto/html-stylesheets.html for how to +customize this style sheet. +*/ + +/* used to remove borders from tables and images */ +.borderless, table.borderless td, table.borderless th { + border: 0 } + +table.borderless td, table.borderless th { + /* Override padding for "table.docutils td" with "! important". + The right padding separates the table cells. */ + padding: 0 0.5em 0 0 ! important } + +.first { + /* Override more specific margin styles with "! important". */ + margin-top: 0 ! important } + +.last, .with-subtitle { + margin-bottom: 0 ! important } + +.hidden { + display: none } + +a.toc-backref { + text-decoration: none ; + color: black } + +blockquote.epigraph { + margin: 2em 5em ; } + +dl.docutils dd { + margin-bottom: 0.5em } + +/* Uncomment (and remove this text!) to get bold-faced definition list terms +dl.docutils dt { + font-weight: bold } +*/ + +div.abstract { + margin: 2em 5em } + +div.abstract p.topic-title { + font-weight: bold ; + text-align: center } + +div.admonition, div.attention, div.caution, div.danger, div.error, +div.hint, div.important, div.note, div.tip, div.warning { + margin: 2em ; + border: medium outset ; + padding: 1em } + +div.admonition p.admonition-title, div.hint p.admonition-title, +div.important p.admonition-title, div.note p.admonition-title, +div.tip p.admonition-title { + font-weight: bold ; + font-family: sans-serif } + +div.attention p.admonition-title, div.caution p.admonition-title, +div.danger p.admonition-title, div.error p.admonition-title, +div.warning p.admonition-title { + color: red ; + font-weight: bold ; + font-family: sans-serif } + +/* Uncomment (and remove this text!) to get reduced vertical space in + compound paragraphs. +div.compound .compound-first, div.compound .compound-middle { + margin-bottom: 0.5em } + +div.compound .compound-last, div.compound .compound-middle { + margin-top: 0.5em } +*/ + +div.dedication { + margin: 2em 5em ; + text-align: center ; + font-style: italic } + +div.dedication p.topic-title { + font-weight: bold ; + font-style: normal } + +div.figure { + margin-left: 2em ; + margin-right: 2em } + +div.footer, div.header { + clear: both; + font-size: smaller } + +div.line-block { + display: block ; + margin-top: 1em ; + margin-bottom: 1em } + +div.line-block div.line-block { + margin-top: 0 ; + margin-bottom: 0 ; + margin-left: 1.5em } + +div.sidebar { + margin: 0 0 0.5em 1em ; + border: medium outset ; + padding: 1em ; + background-color: #ffffee ; + width: 40% ; + float: right ; + clear: right } + +div.sidebar p.rubric { + font-family: sans-serif ; + font-size: medium } + +div.system-messages { + margin: 5em } + +div.system-messages h1 { + color: red } + +div.system-message { + border: medium outset ; + padding: 1em } + +div.system-message p.system-message-title { + color: red ; + font-weight: bold } + +div.topic { + margin: 2em } + +h1.section-subtitle, h2.section-subtitle, h3.section-subtitle, +h4.section-subtitle, h5.section-subtitle, h6.section-subtitle { + margin-top: 0.4em } + +h1.title { + text-align: center } + +h2.subtitle { + text-align: center } + +hr.docutils { + width: 75% } + +img.align-left { + clear: left } + +img.align-right { + clear: right } + +ol.simple, ul.simple { + margin-bottom: 1em } + +ol.arabic { + list-style: decimal } + +ol.loweralpha { + list-style: lower-alpha } + +ol.upperalpha { + list-style: upper-alpha } + +ol.lowerroman { + list-style: lower-roman } + +ol.upperroman { + list-style: upper-roman } + +p.attribution { + text-align: right ; + margin-left: 50% } + +p.caption { + font-style: italic } + +p.credits { + font-style: italic ; + font-size: smaller } + +p.label { + white-space: nowrap } + +p.rubric { + font-weight: bold ; + font-size: larger ; + color: maroon ; + text-align: center } + +p.sidebar-title { + font-family: sans-serif ; + font-weight: bold ; + font-size: larger } + +p.sidebar-subtitle { + font-family: sans-serif ; + font-weight: bold } + +p.topic-title { + font-weight: bold } + +pre.address { + margin-bottom: 0 ; + margin-top: 0 ; + font-family: serif ; + font-size: 100% } + +pre.literal-block, pre.doctest-block { + margin-left: 2em ; + margin-right: 2em } + +span.classifier { + font-family: sans-serif ; + font-style: oblique } + +span.classifier-delimiter { + font-family: sans-serif ; + font-weight: bold } + +span.interpreted { + font-family: sans-serif } + +span.option { + white-space: nowrap } + +span.pre { + white-space: pre } + +span.problematic { + color: red } + +span.section-subtitle { + /* font-size relative to parent (h1..h6 element) */ + font-size: 80% } + +table.citation { + border-left: solid 1px gray; + margin-left: 1px } + +table.docinfo { + margin: 2em 4em } + +table.docutils { + margin-top: 0.5em ; + margin-bottom: 0.5em } + +table.footnote { + border-left: solid 1px black; + margin-left: 1px } + +table.docutils td, table.docutils th, +table.docinfo td, table.docinfo th { + padding-left: 0.5em ; + padding-right: 0.5em ; + vertical-align: top } + +table.docutils th.field-name, table.docinfo th.docinfo-name { + font-weight: bold ; + text-align: left ; + white-space: nowrap ; + padding-left: 0 } + +h1 tt.docutils, h2 tt.docutils, h3 tt.docutils, +h4 tt.docutils, h5 tt.docutils, h6 tt.docutils { + font-size: 100% } + +ul.auto-toc { + list-style-type: none } + +</style> +</head> +<body> +<div class="document" id="eix-index-file-format"> +<h1 class="title">eix - index file format</h1> +<table class="docinfo" frame="void" rules="none"> +<col class="docinfo-name" /> +<col class="docinfo-content" /> +<tbody valign="top"> +<tr><th class="docinfo-name">Authors:</th> +<td>Martin Väth <vaeth AT mathematik DOT uni-wuerzburg DOT de> (active) +<br />Emil Beinroth <emilbeinroth AT gmx DOT net> (active) +<br />Wolfgang Frisch <xororand AT users DOT sourceforge DOT net> (inactive)</td></tr> +<tr><th class="docinfo-name">Copyright:</th> +<td>This file is part of the eix project and distributed under the +terms of the GNU General Public License v2.</td></tr> +</tbody> +</table> +<p>This article describes the format of the eix index file, usually located at /var/cache/eix. The +format includes a version field in the <a class="reference internal" href="#header">header</a> block. The current version is <strong>28</strong> (eix 0.17.0).</p> +<div class="contents topic" id="table-of-contents"> +<p class="topic-title first"><strong>Table of Contents</strong>:</p> +<ul class="simple"> +<li><a class="reference internal" href="#overall-layout" id="id3">Overall layout</a></li> +<li><a class="reference internal" href="#basic-datatypes" id="id4">Basic Datatypes</a><ul> +<li><a class="reference internal" href="#number" id="id5">Number</a></li> +<li><a class="reference internal" href="#vector" id="id6">Vector</a></li> +<li><a class="reference internal" href="#string" id="id7">String</a></li> +<li><a class="reference internal" href="#hash" id="id8">Hash</a></li> +<li><a class="reference internal" href="#hashedstring" id="id9">HashedString</a></li> +<li><a class="reference internal" href="#hashedwords" id="id10">HashedWords</a></li> +</ul> +</li> +<li><a class="reference internal" href="#data-blocks" id="id11">Data blocks</a><ul> +<li><a class="reference internal" href="#header" id="id12">Header</a></li> +<li><a class="reference internal" href="#overlay" id="id13">Overlay</a></li> +<li><a class="reference internal" href="#category" id="id14">Category</a></li> +<li><a class="reference internal" href="#package" id="id15">Package</a></li> +<li><a class="reference internal" href="#version" id="id16">Version</a></li> +<li><a class="reference internal" href="#versionpart" id="id17">VersionPart</a></li> +</ul> +</li> +<li><a class="reference internal" href="#historical-notes" id="id18">Historical notes</a></li> +</ul> +</div> +<div class="section" id="overall-layout"> +<h1>Overall layout</h1> +<p>The file is made up of blocks of data, +which may in turn contain other other blocks. <a class="footnote-reference" href="#vector-vs-blocks" id="id1">[1]</a> +The first block is a special header. +The remaining blocks are the categories which in turn contain the package blocks +which contain the version blocks, ...</p> +<blockquote> +<div class="layout-block header-block container"> +<a class="reference internal" href="#header">Header</a></div> +<div class="layout-block category-block container"> +<p>1st <a class="reference internal" href="#category">Category</a></p> +<div class="layout-block package-block container"> +<p>1st <a class="reference internal" href="#package">Package</a> in 1st Category</p> +<div class="layout-block version-block container"> +1st <a class="reference internal" href="#version">Version</a> of this Package</div> +<div class="layout-block version-block container"> +[..]</div> +</div> +<div class="layout-block package-block container"> +<p>2nd <a class="reference internal" href="#package">Package</a> in 1st Category</p> +<p>[..]</p> +</div> +</div> +<div class="layout-block category-block container"> +<p>2nd <a class="reference internal" href="#category">Category</a></p> +<p>[..]</p> +</div> +</blockquote> +<table class="docutils footnote" frame="void" id="vector-vs-blocks" rules="none"> +<colgroup><col class="label" /><col /></colgroup> +<tbody valign="top"> +<tr><td class="label"><a class="fn-backref" href="#id1">[1]</a></td><td>Most blocks here occur as a <cite>vector</cite> (described below), i.e. the +first entry is the number of elements, followed by the individual elements. +However, if not stated explicitly that a block is a <cite>vector</cite>, it is +indicated otherwise in the file how many elements it has. +For example, the number of category blocks is contained in the <a class="reference internal" href="#header">header</a>.</td></tr> +</tbody> +</table> +</div> +<div class="section" id="basic-datatypes"> +<h1>Basic Datatypes</h1> +<p>This section covers the datatypes <cite>number</cite> and <cite>vector</cite> (resp. <cite>string</cite>) which are used in the index file.</p> +<div class="section" id="number"> +<h2>Number</h2> +<p>The index file contains non-negative integer values only. The format we use avoids fixed length +integers by encoding the number of bytes into the integer itself. It has a bias towards numbers +smaller than 0xFF, which are encoded into a single byte.</p> +<blockquote> +<p>To determine the number of bytes used, you must first count how often the byte <strong>0xFF</strong> occurs at +the beginning of the number. +Let <cite>n</cite> be this count (<cite>n</cite> may be 0). Then, as a rule, there will follow <cite>n+1</cite> bytes that +contain the actual integer stored in big-endian byte order (highest byte first).</p> +<p><em>But</em> since it would be impossible to store any number that has a leading 0xFF with this format, +a leading 0xFF is stored as 0x00. Meaning, if a 0x00 byte follows the last 0xFF, you must +interpret this byte as 0xFF inside the number.</p> +</blockquote> +<p>Examples:</p> +<blockquote> +<table border="1" class="docutils"> +<colgroup> +<col width="23%" /> +<col width="77%" /> +</colgroup> +<thead valign="bottom"> +<tr><th class="head">Number</th> +<th class="head">Bytes stored in the file</th> +</tr> +</thead> +<tbody valign="top"> +<tr><td>0x00</td> +<td>0x00</td> +</tr> +<tr><td>0xFE</td> +<td>0xFE</td> +</tr> +<tr><td>0xFF</td> +<td>0xFF 0x00</td> +</tr> +<tr><td>0x0100</td> +<td>0xFF 0x01 0x00</td> +</tr> +<tr><td>0x01FF</td> +<td>0xFF 0x01 0xFF</td> +</tr> +<tr><td>0xFEFF</td> +<td>0xFF 0xFE 0xFF</td> +</tr> +<tr><td>0xFF00</td> +<td>0xFF 0xFF 0x00 0x00</td> +</tr> +<tr><td>0xFF01</td> +<td>0xFF 0xFF 0x00 0x01</td> +</tr> +<tr><td>0x010000</td> +<td>0xFF 0xFF 0x01 0x00 0x00</td> +</tr> +<tr><td>0xABCDEF</td> +<td>0xFF 0xFF 0xAB 0xCD 0xEF</td> +</tr> +<tr><td>0xFFABCD</td> +<td>0xFF 0xFF 0xFF 0x00 0xAB 0xCD</td> +</tr> +<tr><td>0x01ABCDEF</td> +<td>0xFF 0xFF 0xFF 0x01 0xAB 0xCD 0xEF</td> +</tr> +</tbody> +</table> +</blockquote> +</div> +<div class="section" id="vector"> +<h2>Vector</h2> +<p>Vectors (or lists) are extensively used throughout the index file. They are stored as the <a class="reference internal" href="#number">number</a> of +elements, followed by the elements themselves.</p> +<table border="1" class="docutils"> +<colgroup> +<col width="20%" /> +<col width="80%" /> +</colgroup> +<thead valign="bottom"> +<tr><th class="head">Type</th> +<th class="head">Content</th> +</tr> +</thead> +<tbody valign="top"> +<tr><td>Number</td> +<td>Number of elements (<cite>n</cite>)</td> +</tr> +<tr><td></td> +<td>1st element</td> +</tr> +<tr><td></td> +<td>...</td> +</tr> +<tr><td></td> +<td><cite>n</cite>th element</td> +</tr> +</tbody> +</table> +</div> +<div class="section" id="string"> +<h2>String</h2> +<p>Strings are stored as a <a class="reference internal" href="#vector">vector</a> of characters. A trailing '\0' is not included.</p> +</div> +<div class="section" id="hash"> +<h2>Hash</h2> +<p>A hash is a <a class="reference internal" href="#vector">vector</a> of <a class="reference internal" href="#string">string</a>s.</p> +</div> +<div class="section" id="hashedstring"> +<h2>HashedString</h2> +<p>A <a class="reference internal" href="#number">number</a> which is considered as an index in the corresponding <a class="reference internal" href="#hash">hash</a>; +0 denotes the first string of the hash, 1 the second, ...</p> +</div> +<div class="section" id="hashedwords"> +<h2>HashedWords</h2> +<p>A <a class="reference internal" href="#vector">vector</a> of <a class="reference internal" href="#hashedstring">HashedString</a>s. +The resulting strings are meant to be concatenated, with spaces as separators.</p> +</div> +</div> +<div class="section" id="data-blocks"> +<h1>Data blocks</h1> +<div class="section" id="header"> +<h2>Header</h2> +<table border="1" class="docutils"> +<colgroup> +<col width="19%" /> +<col width="81%" /> +</colgroup> +<thead valign="bottom"> +<tr><th class="head">Type</th> +<th class="head">Content</th> +</tr> +</thead> +<tbody valign="top"> +<tr><td>Number</td> +<td>File format version</td> +</tr> +<tr><td>Number</td> +<td>Number of <a class="reference internal" href="#category">Category</a> blocks</td> +</tr> +<tr><td>Vector</td> +<td><a class="reference internal" href="#overlay">Overlay</a>s</td> +</tr> +<tr><td>Hash</td> +<td>Hash for "Provide"</td> +</tr> +<tr><td>Hash</td> +<td>Hash for "Licenses"</td> +</tr> +<tr><td>Hash</td> +<td>Hash for "Keywords"</td> +</tr> +<tr><td>Hash</td> +<td>Hash for "Useflags"</td> +</tr> +<tr><td>Hash</td> +<td>Hash for "Slot"</td> +</tr> +<tr><td>Vector</td> +<td>names of world sets</td> +</tr> +</tbody> +</table> +<p>The names of world sets are the names (without leading @) of the world sets +stored in /var/lib/portage/world_sets. If SAVE_WORLD=false, the list is empty.</p> +</div> +<div class="section" id="overlay"> +<h2>Overlay</h2> +<table border="1" class="docutils"> +<colgroup> +<col width="21%" /> +<col width="79%" /> +</colgroup> +<thead valign="bottom"> +<tr><th class="head">Type</th> +<th class="head">Content</th> +</tr> +</thead> +<tbody valign="top"> +<tr><td>String</td> +<td>overlay path</td> +</tr> +<tr><td>String</td> +<td>label (repository name)</td> +</tr> +</tbody> +</table> +</div> +<div class="section" id="category"> +<h2>Category</h2> +<table border="1" class="docutils"> +<colgroup> +<col width="18%" /> +<col width="82%" /> +</colgroup> +<thead valign="bottom"> +<tr><th class="head">Type</th> +<th class="head">Content</th> +</tr> +</thead> +<tbody valign="top"> +<tr><td>String</td> +<td>Name of category</td> +</tr> +<tr><td>Vector</td> +<td><a class="reference internal" href="#package">Package</a>s in this category</td> +</tr> +</tbody> +</table> +</div> +<div class="section" id="package"> +<h2>Package</h2> +<table border="1" class="docutils"> +<colgroup> +<col width="8%" /> +<col width="92%" /> +</colgroup> +<thead valign="bottom"> +<tr><th class="head">Type</th> +<th class="head">Content</th> +</tr> +</thead> +<tbody valign="top"> +<tr><td>Number</td> +<td>Offset to the next package in the eix cache file (in bytes; counting starts after the number)</td> +</tr> +<tr><td>String</td> +<td>Package name</td> +</tr> +<tr><td>String</td> +<td>Description</td> +</tr> +<tr><td>HashedWords</td> +<td>Provide</td> +</tr> +<tr><td>String</td> +<td>Homepage</td> +</tr> +<tr><td>HashedString</td> +<td>Licenses, e.g. MPL-1.1 NPL-1.1</td> +</tr> +<tr><td>HashedWords</td> +<td>Useflags (all useflags of all versions of the package are added). This might "falsely" be the empty string if per-version IUSE flags are stored.</td> +</tr> +<tr><td>Vector</td> +<td><a class="reference internal" href="#version">Version</a>s</td> +</tr> +</tbody> +</table> +</div> +<div class="section" id="version"> +<h2>Version</h2> +<table border="1" class="docutils"> +<colgroup> +<col width="11%" /> +<col width="89%" /> +</colgroup> +<thead valign="bottom"> +<tr><th class="head">Type</th> +<th class="head">Content</th> +</tr> +</thead> +<tbody valign="top"> +<tr><td>char</td> +<td><p class="first">Mask bitset for the current $ARCH:</p> +<blockquote class="last"> +<table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field"><th class="field-name">0x00:</th><td class="field-body">none of the following</td> +</tr> +<tr class="field"><th class="field-name">0x01:</th><td class="field-body">masked by package.mask</td> +</tr> +<tr class="field"><th class="field-name">0x02:</th><td class="field-body">masked by profile</td> +</tr> +<tr class="field"><th class="field-name">0x04:</th><td class="field-body">version is in @system</td> +</tr> +<tr class="field"><th class="field-name">0x08:</th><td class="field-body">version is in @world (if SAVE_WORLD=true)</td> +</tr> +</tbody> +</table> +</blockquote> +</td> +</tr> +<tr><td>char</td> +<td><dl class="first last docutils"> +<dt>Mask bitset for the PROPERTIES variable:</dt> +<dd><table class="first last docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field"><th class="field-name">0x01:</th><td class="field-body">PROPERTIES=interactive</td> +</tr> +<tr class="field"><th class="field-name">0x02:</th><td class="field-body">PROPERTIES=live</td> +</tr> +<tr class="field"><th class="field-name">0x04:</th><td class="field-body">PROPERTIES=virtual</td> +</tr> +</tbody> +</table> +</dd> +</dl> +</td> +</tr> +<tr><td>Number</td> +<td><dl class="first last docutils"> +<dt>Mask bitset for the RESTRICT variable:</dt> +<dd><table class="first last docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field"><th class="field-name">0x0001:</th><td class="field-body">RESTRICT=binchecks</td> +</tr> +<tr class="field"><th class="field-name">0x0002:</th><td class="field-body">RESTRICT=strip</td> +</tr> +<tr class="field"><th class="field-name">0x0004:</th><td class="field-body">RESTRICT=test</td> +</tr> +<tr class="field"><th class="field-name">0x0008:</th><td class="field-body">RESTRICT=userpriv</td> +</tr> +<tr class="field"><th class="field-name">0x0010:</th><td class="field-body">RESTRICT=installsources</td> +</tr> +<tr class="field"><th class="field-name">0x0020:</th><td class="field-body">RESTRICT=fetch</td> +</tr> +<tr class="field"><th class="field-name">0x0040:</th><td class="field-body">RESTRICT=mirror</td> +</tr> +<tr class="field"><th class="field-name">0x0080:</th><td class="field-body">RESTRICT=primaryuri</td> +</tr> +<tr class="field"><th class="field-name">0x0100:</th><td class="field-body">RESTRICT=bindist</td> +</tr> +</tbody> +</table> +</dd> +</dl> +</td> +</tr> +<tr><td>HashedWords</td> +<td>Full keywords string of the ebuild.</td> +</tr> +<tr><td>Vector</td> +<td><a class="reference internal" href="#versionpart">VersionPart</a>s</td> +</tr> +<tr><td>HashedString</td> +<td>Slot name. The slot name "0" is stored as "".</td> +</tr> +<tr><td>Number</td> +<td>Index of the portage overlay (in the overlays block)</td> +</tr> +<tr><td>HashedWords</td> +<td>Useflags of this version. This might "falsely" be empty if only per-package IUSE flags are stored.</td> +</tr> +</tbody> +</table> +</div> +<div class="section" id="versionpart"> +<h2>VersionPart</h2> +<p>A VersionPart consists of two data: a number (referred to as <em>type</em>) and a "<a class="reference internal" href="#string">string</a>" (referred to as <em>value</em>).</p> +<p>The number is encoded in the lower 5 bits of the length-part of the "<a class="reference internal" href="#string">string</a>"; +of course, the actual length is shifted by the same number of bits.</p> +<p>For the type, these named values are possible:</p> +<blockquote> +<table border="1" class="docutils"> +<colgroup> +<col width="7%" /> +<col width="16%" /> +<col width="77%" /> +</colgroup> +<thead valign="bottom"> +<tr><th class="head">Value</th> +<th class="head">Name</th> +<th class="head">Content of value</th> +</tr> +</thead> +<tbody valign="top"> +<tr><td>0</td> +<td><cite>garbage</cite></td> +<td>garbage that was found after any valid version string</td> +</tr> +<tr><td>1</td> +<td><cite>alpha</cite></td> +<td>number of "_alpha" (may be empty)</td> +</tr> +<tr><td>2</td> +<td><cite>beta</cite></td> +<td>number of "_beta" (may be empty)</td> +</tr> +<tr><td>3</td> +<td><cite>pre</cite></td> +<td>number of "_pre" (may be empty)</td> +</tr> +<tr><td>4</td> +<td><cite>rc</cite></td> +<td>number of "_rc" (may be empty)</td> +</tr> +<tr><td>5</td> +<td><cite>revision</cite></td> +<td>number of "-r" (may be empty)</td> +</tr> +<tr><td>6</td> +<td><cite>inter_rev</cite></td> +<td>number of inter-revision <a class="footnote-reference" href="#inter-revisions" id="id2">[2]</a></td> +</tr> +<tr><td>7</td> +<td><cite>patch</cite></td> +<td>number of "_p" (may be empty)</td> +</tr> +<tr><td>8</td> +<td><cite>char</cite></td> +<td>single character</td> +</tr> +<tr><td>9</td> +<td><cite>primary</cite></td> +<td>numeric version part</td> +</tr> +<tr><td>10</td> +<td><cite>first</cite></td> +<td>first numeric version part</td> +</tr> +</tbody> +</table> +</blockquote> +<p>As an example, we split the version string <cite>1.2c_pre12_alpha-r01.01-foo</cite> like this:</p> +<blockquote> +(first, "1") (primary, "2") (char, "c") (pre, "12") (alpha, "") (revision, "01") (inter_rev, "01") (garbage, "-foo")</blockquote> +<p>To reconstruct a version string, iterate through the vector of parts, +and for each part append a specific prefix and the value stored in the string. +The prefixes you need should be obvious, but here they are listed anyway:</p> +<blockquote> +<table border="1" class="docutils"> +<colgroup> +<col width="33%" /> +<col width="67%" /> +</colgroup> +<thead valign="bottom"> +<tr><th class="head">Prefix</th> +<th class="head">Name</th> +</tr> +</thead> +<tbody valign="top"> +<tr><td>"." (dot)</td> +<td>primary, inter_rev</td> +</tr> +<tr><td>"" (empty)</td> +<td>first, char, garbage</td> +</tr> +<tr><td>"_alpha"</td> +<td>alpha</td> +</tr> +<tr><td>"_beta"</td> +<td>beta</td> +</tr> +<tr><td>"_pre"</td> +<td>pre</td> +</tr> +<tr><td>"_rc"</td> +<td>rc</td> +</tr> +<tr><td>"-r"</td> +<td>revision</td> +</tr> +<tr><td>"_p"</td> +<td>patch</td> +</tr> +</tbody> +</table> +</blockquote> +<table class="docutils footnote" frame="void" id="inter-revisions" rules="none"> +<colgroup><col class="label" /><col /></colgroup> +<tbody valign="top"> +<tr><td class="label"><a class="fn-backref" href="#id2">[2]</a></td><td>inter-revision ares used by gentoo-alt to keep their prefixed portage tree in +sync with the main tree +<a class="reference external" href="http://www.gentoo.org/proj/en/gentoo-alt/prefix/techdocs.xml#doc_chap2_sect5">http://www.gentoo.org/proj/en/gentoo-alt/prefix/techdocs.xml#doc_chap2_sect5</a></td></tr> +</tbody> +</table> +</div> +</div> +<div class="section" id="historical-notes"> +<h1>Historical notes</h1> +<ul class="simple"> +<li>Since version 17, the format of this file is architecture-independent.</li> +</ul> +<!-- vim:set tw=100 ft=rst: --> +</div> +</div> +</body> +</html> diff --git a/portato/eix/exceptions.py b/portato/eix/exceptions.py new file mode 100644 index 0000000..8145af4 --- /dev/null +++ b/portato/eix/exceptions.py @@ -0,0 +1,45 @@ +# -*- coding: utf-8 -*- +# +# File: portato/eix/exceptions.py +# This file is part of the Portato-Project, a graphical portage-frontend. +# +# Copyright (C) 2006-2009 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. +# +# Written by René 'Necoro' Neumann <necoro@necoro.net> + +""" +Different exceptions used in the eix module. +""" + +from __future__ import absolute_import, with_statement +__docformat__ = "restructuredtext" + +class EixError (Exception): + """ + The base class for all exceptions of this module. + + :ivar message: The error message + """ + message = _("Unknown error.") + + def __str__ (self): + return self.message + +class EndOfFileException (EixError): + """ + Denotes the unexpected EOF. + """ + + def __init__ (self, filename): + self.message = _("End of file reached though it was not expected: '%s'") % filename + +class UnsupportedVersionError (EixError): + """ + The version of the cache file found is not supported. + """ + + def __init__ (self, version): + self.message = _("Version '%s' is not supported.") % version diff --git a/portato/eix/parser.pyx b/portato/eix/parser.pyx new file mode 100644 index 0000000..01a673f --- /dev/null +++ b/portato/eix/parser.pyx @@ -0,0 +1,316 @@ +# -*- coding: utf-8 -*- +# +# File: portato/eix/_parser.pyx +# This file is part of the Portato-Project, a graphical portage-frontend. +# +# Copyright (C) 2006-2009 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. +# +# Written by René 'Necoro' Neumann <necoro@necoro.net> + +""" +The cache file supports different types of data. +In this module (nearly) all of these types have a corresponding function. + +For the exact way all the functions work, have a look at the eix format description. +""" + +__docformat__ = "restructuredtext" + +cdef extern from "stdio.h": + ctypedef struct FILE: + pass + + int fgetc(FILE* stream) + long ftell(FILE* stream) + int fseek(FILE* stream, long offset, int whence) + + int EOF + int SEEK_CUR + +cdef extern from "Python.h": + FILE* PyFile_AsFile(object) + +ctypedef unsigned char UChar +ctypedef long long LLong + +from portato.eix.exceptions import EndOfFileException + +# +# Helper +# + +cdef int _get_byte (FILE* file) except -1: + cdef int c = fgetc(file) + + if c == EOF: + raise EndOfFileException + + return c + +# +# Base Types +# + +cdef LLong _number (object pfile): + cdef UChar n + cdef LLong value + cdef int i + + cdef unsigned short count = 1 + cdef FILE* file = PyFile_AsFile(pfile) + + n = <UChar>_get_byte(file) + + if n < 0xFF: + return <LLong>n + else: + + n = <UChar>_get_byte(file) + while (n == 0xFF): + count += 1 + n = <UChar>_get_byte(file) + + if n == 0: + value = <LLong>0xFF # 0xFF is encoded as 0xFF 0x00 + count -= 1 + else: + value = <LLong>n + + for i in range(count): + value = (value << 8) | <LLong>(_get_byte(file)) + + return value + +def number (file): + """ + Returns a number. + + :param file: The file to read from + :type file: file + :rtype: int + """ + + return _number(file) + +def vector (file, get_type, nelems = None): + """ + Returns a vector of elements. + + :Parameters: + + file : file + The file to read from. + + get_type : function(file, bool) + The function determining type of the elements. + + nelems : int + Normally the eix-Vector has the number of elements as the first argument. + If for some reason this is not the case, you can pass it in here. + + :rtype: list + """ + + cdef LLong n + cdef LLong i + + if nelems is None: + n = _number(file) + else: + n = nelems + + return [get_type(file) for i in range(n)] + +def string (file): + """ + Returns a string. + + :param file: The file to read from + :type file: file + :rtype: str + """ + nelems = _number(file) + + s = file.read(nelems) + + if len(s) != nelems: + raise EndOfFileException, file.name + + return s + +# +# Complex Types +# + +cdef class overlay: + """ + Represents an overlay object. + + :IVariables: + + path : string + The path to the overlay + + label : string + The label/name of the overlay + """ + + cdef readonly object path + cdef readonly object label + + def __init__ (self, file): + """ + :param file: The file to read from + :type file: file + """ + + self.path = string(file) + self.label = string(file) + +cdef class header: + """ + Represents the header of the cache. + + :IVariables: + + version : int + The version of the cache file. + + ncats : int + The number of categories. + + overlays : `overlay` [] + The list of overlays. + + provide : string[] + A list of "PROVIDE" values. + + licenses : string[] + The list of licenses. + + keywords : string[] + The list of keywords. + + useflags : string[] + The list of useflags. + + slots : string[] + The list of slots different from "0". + + sets : string[] + The names of world sets are the names (without leading @) of the world sets stored in /var/lib/portage/world_sets. + If SAVE_WORLD=false, the list is empty. + """ + + cdef readonly object version + cdef readonly object ncats + cdef readonly object overlays + cdef readonly object provide + cdef readonly object licenses + cdef readonly object keywords + cdef readonly object useflags + cdef readonly object slots + cdef readonly object sets + + def __init__ (self, file): + """ + :param file: The file to read from + :type file: file + """ + self.version = _number(file) + self.ncats = _number(file) + self.overlays = vector(file, overlay) + self.provide = vector(file, string) + self.licenses = vector(file, string) + self.keywords = vector(file, string) + self.useflags = vector(file, string) + self.slots = vector(file, string) + self.sets = vector(file, string) + +cdef class package: + """ + The representation of one package. + + Currently, version information is not parsed and stored. + So you can gain general infos only. + + :IVariables: + + name : string + The name of the package. + + description : string + Description of the package. + + homepage : string + The homepage of the package. + + provide : int[] + The indices of `header.provide` representing the PROVIDE value of the package. + + license : int + The index of `header.licenses` representing the license of the package. + + useflags : int[] + The indices of `header.useflags` representing the IUSE value of the package. + """ + + cdef LLong _offset + cdef readonly object name + #cdef readonly object description + #cdef readonly object provide + #cdef readonly object homepage + #cdef readonly object license + #cdef readonly object useflags + + def __init__ (self, file): + """ + :param file: The file to read from + :type file: file + """ + cdef FILE* cfile = PyFile_AsFile(file) + cdef long after_offset + + self._offset = _number(file) + + after_offset = ftell(cfile) + + self.name = string(file) + + # skip the rest, as it is currently unneeded + #self.description = string(file) + #self.provide = vector(file, number) + #self.homepage = string(file) + #self.license = number(file) + #self.useflags = vector(file, number) + + # self.versions = LE(typed_vector(version)) + # for the moment just skip the versions + fseek(cfile, self._offset - (ftell(cfile) - after_offset), SEEK_CUR) + +cdef class category: + """ + Represents a whole category. + + :IVariables: + + name : string + The category name. + + packages : `package` [] + All the packages of the category. + """ + + cdef readonly object name + cdef readonly object packages + + def __init__ (self, file): + """ + :param file: The file to read from + :type file: file + """ + self.name = string(file) + self.packages = vector(file, package) diff --git a/portato/eix/py_parser.py b/portato/eix/py_parser.py new file mode 100644 index 0000000..cc42553 --- /dev/null +++ b/portato/eix/py_parser.py @@ -0,0 +1,416 @@ +# -*- coding: utf-8 -*- +# +# File: portato/eix/parser.py +# This file is part of the Portato-Project, a graphical portage-frontend. +# +# Copyright (C) 2006-2009 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. +# +# Written by René 'Necoro' Neumann <necoro@necoro.net> + +""" +The cache file supports different types of data. +In this module (nearly) all of these types have a corresponding function. + +For the exact way all the functions work, have a look at the eix format description. +""" + +from __future__ import absolute_import, with_statement +__docformat__ = "restructuredtext" + +import os +import struct +from functools import partial + +from ..helper import debug +from .exceptions import EndOfFileException + +# +# Helper +# + +def _get_bytes (file, length, expect_list = False): + """ + Return a number of bytes. + + :Parameters: + + file : file + The file to read from. + + length : int + The number of bytes to read. + + expect_list : bool + In case ``length`` is 1, only a single byte is returned. If ``expect_list`` is true, then a list is also returned in this case. + + :rtype: int or int[] + :raises EndOfFileException: if EOF is reached during execution + """ + + s = file.read(length) + + if len(s) != length: + raise EndOfFileException, file.name + + if length == 1 and not expect_list: + return ord(s) # is faster than unpack and we have a scalar + else: + return struct.unpack("%sB" % length, s) + +# +# Base Types +# + +def number (file, skip = False): + """ + Returns a number. + + :Parameters: + + file : file + The file to read from. + + skip : bool + Do not return the actual value, but just skip to the next datum. + + :rtype: int + """ + + n = _get_bytes(file, 1) + + if n < 0xFF: + value = n + else: + count = 0 + + while (n == 0xFF): + count += 1 + n = _get_bytes(file, 1) + + if n == 0: + n = 0xFF # 0xFF is encoded as 0xFF 0x00 + count -= 1 + + value = n << (count*8) + + if count > 0: + + if skip: + file.seek(count, os.SEEK_CUR) + return + + else: + rest = _get_bytes(file, count, expect_list = True) + + for i, r in enumerate(rest): + value += r << ((count - i - 1)*8) + + return value + +def vector (file, get_type, skip = False, nelems = None): + """ + Returns a vector of elements. + + :Parameters: + + file : file + The file to read from. + + get_type : function(file, bool) + The function determining type of the elements. + + skip : bool + Do not return the actual value, but just skip to the next datum. + + nelems : int + Normally the eix-Vector has the number of elements as the first argument. + If for some reason this is not the case, you can pass it in here. + + :rtype: list + """ + + if nelems is None: + nelems = number(file) + + if skip: + for i in range(nelems): + get_type(file, skip = True) + else: + return [get_type(file) for i in range(nelems)] + +def typed_vector(type, nelems = None): + """ + Shortcut to create a function for a special type of vector. + + :Parameters: + + type : function(file, bool) + The function determining type of the elements. + + nelems : int + Normally the eix-Vector has the number of elements as the first argument. + If for some reason this is not the case, you can pass it in here. + Do not return the actual value, but just skip to the next datum. + + :rtype: function(file, bool) + :see: `vector` + """ + + if nelems is None: + return partial(vector, get_type = type) + else: + return partial(vector, get_type = type, nelems = nelems) + +def string (file, skip = False): + """ + Returns a string. + + :Parameters: + + file : file + The file to read from. + + skip : bool + Do not return the actual value, but just skip to the next datum. + + :rtype: str + """ + nelems = number(file) + + if skip: + file.seek(nelems, os.SEEK_CUR) + return + else: + s = file.read(nelems) + + if len(s) != nelems: + raise EndOfFileException, file.name + + return s + +# +# Complex Types +# + +class LazyElement (object): + """ + This class models a value in the cache, which is only read on access. + + If not accessed directly, only the position inside the file is stored. + """ + __slots__ = ("file", "get_type", "_value", "pos") + + def __init__ (self, get_type, file): + """ + :Parameters: + + get_type : function(file, bool) + The function determining type of the elements. + + file : file + The file to read from. + """ + + self.file = file + self.get_type = get_type + self._value = None + + self.pos = file.tell() + get_type(file, skip=True) # skip it for the moment + + @property + def value (self): + """ + The value of the element. + """ + + if self._value is None: + old_pos = self.file.tell() + self.file.seek(self.pos, os.SEEK_SET) + self._value = self.get_type(self.file, skip = False) + self.file.seek(old_pos, os.SEEK_SET) + + return self._value + + def __call__ (self): + """ + Convenience function. Also returns the value. + """ + return self.value + +class overlay (object): + """ + Represents an overlay object. + + :IVariables: + + path : `LazyElement` <string> + The path to the overlay + + label : `LazyElement` <string> + The label/name of the overlay + """ + __slots__ = ("path", "label") + + def __init__ (self, file, skip = False): + """ + :Parameters: + + file : file + The file to read from. + + skip : bool + Do not return the actual value, but just skip to the next datum. + """ + + self.path = LazyElement(string, file) + self.label = LazyElement(string, file) + +class header (object): + """ + Represents the header of the cache. + + :IVariables: + + version : `LazyElement` <int> + The version of the cache file. + + ncats : `LazyElement` <int> + The number of categories. + + overlays : `LazyElement` <`overlay` []> + The list of overlays. + + provide : `LazyElement` <string[]> + A list of "PROVIDE" values. + + licenses : `LazyElement` <string[]> + The list of licenses. + + keywords : `LazyElement` <string[]> + The list of keywords. + + useflags : `LazyElement` <string[]> + The list of useflags. + + slots : `LazyElement` <string[]> + The list of slots different from "0". + + sets : `LazyElement` <string[]> + The names of world sets are the names (without leading @) of the world sets stored in /var/lib/portage/world_sets. + If SAVE_WORLD=false, the list is empty. + """ + __slots__ = ("version", "ncats", "overlays", "provide", + "licenses", "keywords", "useflags", "slots", "sets") + + def __init__ (self, file, skip = False): + """ + :Parameters: + + file : file + The file to read from. + + skip : bool + Do not return the actual value, but just skip to the next datum. + """ + def LE (t): + return LazyElement(t, file) + + self.version = LE(number) + self.ncats = LE(number) + self.overlays = LE(typed_vector(overlay)) + self.provide = LE(typed_vector(string)) + self.licenses = LE(typed_vector(string)) + self.keywords = LE(typed_vector(string)) + self.useflags = LE(typed_vector(string)) + self.slots = LE(typed_vector(string)) + self.sets = LE(typed_vector(string)) + +class package (object): + """ + The representation of one package. + + Currently, version information is not parsed and stored. + So you can gain general infos only. + + :IVariables: + + name : `LazyElement` <string> + The name of the package. + + description : `LazyElement` <string> + Description of the package. + + homepage : `LazyElement` <string> + The homepage of the package. + + provide : `LazyElement` <int[]> + The indices of `header.provide` representing the PROVIDE value of the package. + + license : `LazyElement` <int> + The index of `header.licenses` representing the license of the package. + + useflags : `LazyElement` <int[]> + The indices of `header.useflags` representing the IUSE value of the package. + """ + + __slots__ = ("_offset", "name", "description", "provide", + "homepage", "license", "useflags") + + def __init__ (self, file, skip = False): + """ + :Parameters: + + file : file + The file to read from. + + skip : bool + Do not return the actual value, but just skip to the next datum. + """ + def LE (t): + return LazyElement(t, file) + + self._offset = number(file) + + after_offset = file.tell() + + self.name = LE(string) + self.description = LE(string) + self.provide = LE(typed_vector(number)) + self.homepage = LE(string) + self.license = LE(number) + self.useflags = LE(typed_vector(number)) + + # self.versions = LE(typed_vector(version)) + # for the moment just skip the versions + file.seek(self._offset - (file.tell() - after_offset), os.SEEK_CUR) + +class category (object): + """ + Represents a whole category. + + :IVariables: + + name : `LazyElement` <string> + The category name. + + packages : `LazyElement` <`package` []> + All the packages of the category. + """ + __slots__ = ("name", "packages") + + def __init__ (self, file, skip = False): + """ + :Parameters: + + file : file + The file to read from. + + skip : bool + Do not return the actual value, but just skip to the next datum. + """ + self.name = LazyElement(string, file) + self.packages = LazyElement(typed_vector(package), file) diff --git a/portato/gui/exception_handling.py b/portato/gui/exception_handling.py index 3928680..0ec1e9a 100644 --- a/portato/gui/exception_handling.py +++ b/portato/gui/exception_handling.py @@ -97,14 +97,19 @@ def convert (version): return ".".join(map(str, version)) def get_version_infos(): - from ..constants import VERSION + from ..constants import VERSION, REVISION from ..backend import system + from ..db import _TYPE as db_type + if REVISION: + VERSION = "%s (git: %s)" % (VERSION, REVISION) + return "\n".join(( "Portato version: %s" % VERSION, "System: %s" % " ".join(get_runsystem()), "Python version: %s" % sys.version, "Used backend: %s" % system.get_version(), + "Used database type: %s" % db_type, "pygtk: %s (using GTK+: %s)" % (convert(gtk.pygtk_version), convert(gtk.gtk_version)), "pygobject: %s (using GLib: %s)" % (convert(gobject.pygobject_version), convert(gobject.glib_version)))) 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/AboutWindow.ui b/portato/gui/templates/AboutWindow.ui index 56a7ff6..ec3ed7e 100644 --- a/portato/gui/templates/AboutWindow.ui +++ b/portato/gui/templates/AboutWindow.ui @@ -1,14 +1,15 @@ <?xml version="1.0"?> -<!--*- mode: xml -*--> <interface> + <requires lib="gtk+" version="2.14"/> + <!-- interface-naming-policy toplevel-contextual --> <object class="GtkAboutDialog" id="AboutWindow"> <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property> <property name="border_width">5</property> <property name="title" translatable="yes">About Portato</property> <property name="resizable">False</property> - <property name="window_position">GTK_WIN_POS_CENTER_ON_PARENT</property> + <property name="window_position">center-on-parent</property> <property name="destroy_with_parent">True</property> - <property name="type_hint">GDK_WINDOW_TYPE_HINT_DIALOG</property> + <property name="type_hint">dialog</property> <property name="skip_taskbar_hint">True</property> <property name="skip_pager_hint">True</property> <property name="urgency_hint">True</property> @@ -31,24 +32,59 @@ Portugese (Brazilian) - Alberto Federman Neto Spanish - Daniel Halens Turkish - Gürkan 'seqizz' Gür</property> <property name="artists">p4r4d0x (inspired by wolfden)</property> - <signal handler="close" name="response"/> + <signal name="response" handler="close"/> <child internal-child="vbox"> <object class="GtkVBox" id="dialog-vbox1"> <property name="visible">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="orientation">vertical</property> <property name="spacing">2</property> <child> + <object class="GtkHBox" id="gitHB"> + <property name="visible">True</property> + <property name="no_show_all">True</property> + <property name="spacing">5</property> + <child> + <object class="GtkLabel" id="label1"> + <property name="visible">True</property> + <property name="label"><b>Git revision:</b></property> + <property name="use_markup">True</property> + </object> + <packing> + <property name="expand">False</property> + <property name="position">0</property> + </packing> + </child> + <child> + <object class="GtkLabel" id="gitLabel"> + <property name="visible">True</property> + <property name="xalign">0</property> + <property name="label">label</property> + <property name="use_markup">True</property> + <property name="selectable">True</property> + </object> + <packing> + <property name="position">1</property> + </packing> + </child> + </object> + <packing> + <property name="position">2</property> + </packing> + </child> + <child> <placeholder/> </child> <child internal-child="action_area"> <object class="GtkHButtonBox" id="dialog-action_area1"> <property name="visible">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="layout_style">GTK_BUTTONBOX_END</property> + <property name="layout_style">end</property> </object> <packing> <property name="expand">False</property> - <property name="pack_type">GTK_PACK_END</property> + <property name="pack_type">end</property> + <property name="position">0</property> </packing> </child> </object> diff --git a/portato/gui/templates/MailInfoWindow.ui b/portato/gui/templates/MailInfoWindow.ui index a469bd3..4551cdb 100644 --- a/portato/gui/templates/MailInfoWindow.ui +++ b/portato/gui/templates/MailInfoWindow.ui @@ -1,20 +1,22 @@ <?xml version="1.0"?> -<!--Generated with glade3 3.4.5 on Mon Sep 15 20:20:19 2008 --> <interface> + <requires lib="gtk+" version="2.14"/> + <!-- interface-naming-policy toplevel-contextual --> <object class="GtkWindow" id="MailInfoWindow"> <property name="title" translatable="yes">Send Bug Mail ...</property> <property name="modal">True</property> - <property name="window_position">GTK_WIN_POS_CENTER</property> + <property name="window_position">center</property> <property name="default_width">450</property> <property name="default_height">230</property> <property name="destroy_with_parent">True</property> - <property name="type_hint">GDK_WINDOW_TYPE_HINT_DIALOG</property> + <property name="type_hint">dialog</property> <property name="skip_taskbar_hint">True</property> <property name="skip_pager_hint">True</property> <property name="urgency_hint">True</property> <child> <object class="GtkVBox" id="vbox1"> <property name="visible">True</property> + <property name="orientation">vertical</property> <child> <object class="GtkTable" id="table1"> <property name="visible">True</property> @@ -22,16 +24,13 @@ <property name="n_columns">2</property> <property name="row_spacing">10</property> <child> - <placeholder/> - </child> - <child> <object class="GtkLabel" id="label3"> <property name="visible">True</property> <property name="label" translatable="yes"><b><u>Additional Information</u></b> (all optional)</property> <property name="use_markup">True</property> - <property name="justify">GTK_JUSTIFY_CENTER</property> + <property name="justify">center</property> </object> <packing> <property name="right_attach">2</property> @@ -115,9 +114,9 @@ what did you do to hit the bug?</property> <object class="GtkScrolledWindow" id="scrolledwindow1"> <property name="visible">True</property> <property name="can_focus">True</property> - <property name="hscrollbar_policy">GTK_POLICY_NEVER</property> - <property name="vscrollbar_policy">GTK_POLICY_AUTOMATIC</property> - <property name="shadow_type">GTK_SHADOW_IN</property> + <property name="hscrollbar_policy">never</property> + <property name="vscrollbar_policy">automatic</property> + <property name="shadow_type">in</property> <child> <object class="GtkTextView" id="commentEntry"> <property name="height_request">50</property> @@ -136,10 +135,11 @@ what did you do to hit the bug?</property> </child> <child> <object class="GtkCheckButton" id="logCheck"> + <property name="label" translatable="yes">Attach _Logfile</property> <property name="visible">True</property> <property name="can_focus">True</property> - <property name="tooltip-text" translatable="yes">Attaches the logfile to the mail. This log only contains debug information.</property> - <property name="label" translatable="yes">Attach _Logfile</property> + <property name="receives_default">False</property> + <property name="tooltip_text" translatable="yes">Attaches the logfile to the mail. This log only contains debug information.</property> <property name="use_underline">True</property> <property name="active">True</property> <property name="draw_indicator">True</property> @@ -150,32 +150,41 @@ what did you do to hit the bug?</property> <property name="x_options">GTK_FILL</property> </packing> </child> + <child> + <placeholder/> + </child> </object> <packing> <property name="padding">5</property> + <property name="position">0</property> </packing> </child> <child> <object class="GtkHButtonBox" id="hbuttonbox1"> <property name="visible">True</property> <property name="homogeneous">True</property> - <property name="layout_style">GTK_BUTTONBOX_SPREAD</property> + <property name="layout_style">spread</property> <child> <object class="GtkButton" id="cancelBtn"> + <property name="label">gtk-cancel</property> <property name="visible">True</property> <property name="can_focus">True</property> <property name="receives_default">True</property> - <property name="label">gtk-cancel</property> <property name="use_stock">True</property> - <signal handler="cb_cancel_clicked" name="clicked"/> + <signal name="clicked" handler="cb_cancel_clicked"/> </object> + <packing> + <property name="expand">False</property> + <property name="fill">False</property> + <property name="position">0</property> + </packing> </child> <child> <object class="GtkButton" id="sendBtn"> <property name="visible">True</property> <property name="can_focus">True</property> <property name="receives_default">True</property> - <signal handler="cb_send_clicked" name="clicked"/> + <signal name="clicked" handler="cb_send_clicked"/> <child> <object class="GtkHBox" id="hbox1"> <property name="visible">True</property> @@ -186,6 +195,9 @@ what did you do to hit the bug?</property> <property name="xalign">1</property> <property name="stock">gtk-ok</property> </object> + <packing> + <property name="position">0</property> + </packing> </child> <child> <object class="GtkLabel" id="label5"> @@ -203,6 +215,8 @@ what did you do to hit the bug?</property> </child> </object> <packing> + <property name="expand">False</property> + <property name="fill">False</property> <property name="position">1</property> </packing> </child> diff --git a/portato/gui/templates/MainWindow.menu b/portato/gui/templates/MainWindow.menu new file mode 100644 index 0000000..5d8e8e0 --- /dev/null +++ b/portato/gui/templates/MainWindow.menu @@ -0,0 +1,215 @@ +<?xml version="1.0"?> +<interface> + <object class="GtkUIManager" id="uimanager"> + <child> + <object class="GtkActionGroup" id="pluginActionGroup"> + <child> + <object class="GtkAction" id="pluginMenuAction"> + <property name="name">pluginMenuAction</property> + <property name="label" translatable="yes">Plu_gins</property> + </object> + </child> + </object> + </child> + <child> + <object class="GtkActionGroup" id="generalActionGroup"> + <child> + <object class="GtkAction" id="fileMenuAction"> + <property name="name">fileMenuAction</property> + <property name="label" translatable="yes">_File</property> + </object> + </child> + <child> + <object class="GtkAction" id="prefAction"> + <property name="stock_id">gtk-preferences</property> + <property name="name">prefAction</property> + <property name="label" translatable="yes">_Preferences</property> + <signal handler="cb_preferences_clicked" name="activate"/> + </object> + <accelerator key="P" modifiers="GDK_CONTROL_MASK"/> + </child> + <child> + <object class="GtkAction" id="reloadAction"> + <property name="stock_id">gtk-refresh</property> + <property name="name">reloadAction</property> + <property name="label" translatable="yes">Re_load Portage</property> + <signal handler="cb_reload_clicked" name="activate"/> + </object> + <accelerator key="F5" modifiers=""/> + <accelerator key="R" modifiers="GDK_CONTROL_MASK"/> + </child> + <child> + <object class="GtkAction" id="closeAction"> + <property name="stock_id">gtk-quit</property> + <property name="name">closeAction</property> + <signal handler="cb_close" name="activate"/> + </object> + </child> + <child> + <object class="GtkAction" id="emergeMenuAction"> + <property name="name">emergeMenuAction</property> + <property name="label" translatable="yes">_Emerge</property> + </object> + </child> + <child> + <object class="GtkAction" id="emergeAction"> + <property name="stock_id">gtk-add</property> + <property name="name">emergeAction</property> + <property name="label" translatable="yes">_Install</property> + <signal handler="cb_package_emerge_clicked" name="activate"/> + </object> + <accelerator key="plus" modifiers="GDK_CONTROL_MASK"/> + </child> + <child> + <object class="GtkAction" id="unmergeAction"> + <property name="stock_id">gtk-remove</property> + <property name="name">unmergeAction</property> + <property name="label" translatable="yes">_Uninstall</property> + <signal handler="cb_package_unmerge_clicked" name="activate"/> + </object> + <accelerator key="minus" modifiers="GDK_CONTROL_MASK"/> + </child> + <child> + <object class="GtkAction" id="updateAction"> + <property name="name">updateAction</property> + <property name="label" translatable="yes">Up_date World</property> + <signal handler="cb_update_clicked" name="activate"/> + </object> + </child> + <child> + <object class="GtkAction" id="showUpdatesAction"> + <property name="name">showUpdatesAction</property> + <property name="label" translatable="yes">Show Updatable P_ackages</property> + <signal handler="cb_show_updates_clicked" name="activate"/> + </object> + </child> + <child> + <object class="GtkAction" id="showWorldPkgsAction"> + <property name="name">showWorldPkgsAction</property> + <property name="label" translatable="yes">Show _World Packages</property> + <signal handler="cb_show_world_clicked" name="activate"/> + </object> + </child> + <child> + <object class="GtkToggleAction" id="showInstalledAction"> + <property name="name">showInstalledAction</property> + <property name="label" translatable="yes">Show _Only Installed Packages</property> + <signal handler="cb_show_installed_toggled" name="toggled"/> + </object> + <accelerator key="i" modifiers="GDK_CONTROL_MASK"/> + </child> + <child> + <object class="GtkAction" id="syncAction"> + <property name="stock_id">gtk-refresh</property> + <property name="name">syncAction</property> + <property name="label" translatable="yes">_Sync</property> + <signal handler="cb_sync_clicked" name="activate"/> + </object> + <accelerator key="Y" modifiers="GDK_CONTROL_MASK"/> + </child> + <child> + <object class="GtkAction" id="saveFlagsAction"> + <property name="stock_id">gtk-save</property> + <property name="name">saveFlagsAction</property> + <property name="label" translatable="yes">Save _Flags</property> + <signal handler="cb_save_flags_clicked" name="activate"/> + </object> + </child> + <child> + <object class="GtkToggleAction" id="pauseAction"> + <property name="name">pauseActionMenu</property> + <property name="label" translatable="yes">Emerge _Paused</property> + <signal handler="cb_pause_emerge" name="activate"/> + </object> + <accelerator key="Z" modifiers="GDK_CONTROL_MASK"/> + </child> + <child> + <object class="GtkAction" id="killAction"> + <property name="stock_id">gtk-stop</property> + <property name="name">killAction</property> + <property name="label" translatable="yes">_Kill Emerge</property> + <signal handler="cb_kill_clicked" name="activate"/> + </object> + <accelerator key="K" modifiers="GDK_CONTROL_MASK"/> + </child> + <child> + <object class="GtkAction" id="copyAction"> + <property name="stock_id">gtk-copy</property> + <property name="name">copyAction</property> + <property name="label" translatable="yes">_Copy</property> + <signal handler="cb_copy_clicked" name="activate"/> + </object> + </child> + <child> + <object class="GtkAction" id="helpMenuAction"> + <property name="name">helpMenuAction</property> + <property name="label" translatable="yes">_?</property> + </object> + </child> + <child> + <object class="GtkAction" id="aboutAction"> + <property name="stock_id">gtk-about</property> + <property name="name">aboutAction</property> + <property name="label" translatable="yes">_About</property> + <signal handler="cb_about_clicked" name="activate"/> + </object> + </child> + <child> + <object class="GtkAction" id="pluginsAction"> + <property name="stock_id">gtk-connect</property> + <property name="name">pluginsAction</property> + <property name="label" translatable="yes">_Plugins</property> + <signal handler="cb_plugins_clicked" name="activate"/> + </object> + </child> + </object> + </child> + <ui> + <menubar name="menubar"> + <menu name="fileMenu" action="fileMenuAction"> + <menuitem name="prefMenuItem" action="prefAction"/> + <menuitem name="reloadMenuItem" action="reloadAction"/> + <separator/> + <menuitem name="closeMenuItem" action="closeAction"/> + </menu> + <menu name="emergeMenu" action="emergeMenuAction"> + <menuitem name="emergeMenuItem" action="emergeAction"/> + <menuitem name="unmergeMenuItem" action="unmergeAction"/> + <menuitem name="updateMenuItem" action="updateAction"/> + <menuitem name="showUpdatesMenuItem" action="showUpdatesAction"/> + <menuitem name="showWorldPkgsMenuItem" action="showWorldPkgsAction" /> + <menuitem name="showInstalledMenuItem" action="showInstalledAction"/> + <separator/> + <menuitem name="syncMenuItem" action="syncAction"/> + <menuitem name="saveFlagsMenuItem" action="saveFlagsAction"/> + <separator/> + <menuitem name="pauseMenuItem" action="pauseAction"/> + <menuitem name="killMenuItem" action="killAction"/> + </menu> + <menu name="pluginMenu" action="pluginMenuAction"/> + <menu name="helpMenu" action="helpMenuAction"> + <menuitem name="aboutMenuItem" action="aboutAction"/> + <menuitem name="pluginsMenuItem" action="pluginsAction"/> + </menu> + </menubar> + <popup name="systrayPopup"> + <menuitem action="pauseAction"/> + <menuitem action="killAction"/> + <menuitem action="closeAction"/> + </popup> + <popup name="consolePopup"> + <menuitem name="copyMenuItem" action="copyAction"/> + <menuitem name="killMenuItem" action="killAction"/> + <menuitem name="pauseMenuItem" action="pauseAction"/> + </popup> + </ui> + </object> + <object class="GtkMenu" constructor="uimanager" id="systrayPopup"> + <property name="visible">True</property> + <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property> + </object> + <object class="GtkMenu" constructor="uimanager" id="consolePopup"> + <property name="visible">True</property> + <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property> + </object> +</interface> diff --git a/portato/gui/templates/MainWindow.ui b/portato/gui/templates/MainWindow.ui index e84bfd5..8e8c3b4 100644 --- a/portato/gui/templates/MainWindow.ui +++ b/portato/gui/templates/MainWindow.ui @@ -1,225 +1,28 @@ <?xml version="1.0"?> -<!--Generated with glade3 3.4.5 on Fri Dec 5 12:57:49 2008 --> <interface> - <object class="GtkUIManager" id="uimanager"> - <child> - <object class="GtkActionGroup" id="pluginActionGroup"> - <child> - <object class="GtkAction" id="pluginMenuAction"> - <property name="name">pluginMenuAction</property> - <property name="label" translatable="yes">Plu_gins</property> - </object> - </child> - </object> - </child> - <child> - <object class="GtkActionGroup" id="generalActionGroup"> - <child> - <object class="GtkAction" id="fileMenuAction"> - <property name="name">fileMenuAction</property> - <property name="label" translatable="yes">_File</property> - </object> - </child> - <child> - <object class="GtkAction" id="prefAction"> - <property name="stock_id">gtk-preferences</property> - <property name="name">prefAction</property> - <property name="label" translatable="yes">_Preferences</property> - <signal handler="cb_preferences_clicked" name="activate"/> - </object> - <accelerator key="P" modifiers="GDK_CONTROL_MASK"/> - </child> - <child> - <object class="GtkAction" id="reloadAction"> - <property name="stock_id">gtk-refresh</property> - <property name="name">reloadAction</property> - <property name="label" translatable="yes">Re_load Portage</property> - <signal handler="cb_reload_clicked" name="activate"/> - </object> - <accelerator key="F5" modifiers=""/> - <accelerator key="R" modifiers="GDK_CONTROL_MASK"/> - </child> - <child> - <object class="GtkAction" id="closeAction"> - <property name="stock_id">gtk-quit</property> - <property name="name">closeAction</property> - <signal handler="cb_close" name="activate"/> - </object> - </child> - <child> - <object class="GtkAction" id="emergeMenuAction"> - <property name="name">emergeMenuAction</property> - <property name="label" translatable="yes">_Emerge</property> - </object> - </child> - <child> - <object class="GtkAction" id="emergeAction"> - <property name="stock_id">gtk-add</property> - <property name="name">emergeAction</property> - <property name="label" translatable="yes">_Install</property> - <signal handler="cb_package_emerge_clicked" name="activate"/> - </object> - <accelerator key="plus" modifiers="GDK_CONTROL_MASK"/> - </child> - <child> - <object class="GtkAction" id="unmergeAction"> - <property name="stock_id">gtk-remove</property> - <property name="name">unmergeAction</property> - <property name="label" translatable="yes">_Uninstall</property> - <signal handler="cb_package_unmerge_clicked" name="activate"/> - </object> - <accelerator key="minus" modifiers="GDK_CONTROL_MASK"/> - </child> - <child> - <object class="GtkAction" id="updateAction"> - <property name="name">updateAction</property> - <property name="label" translatable="yes">Update _World</property> - <signal handler="cb_update_clicked" name="activate"/> - </object> - </child> - <child> - <object class="GtkAction" id="showUpdatesAction"> - <property name="name">showUpdatesAction</property> - <property name="label" translatable="yes">Show Updatable P_ackages</property> - <signal handler="cb_show_updates_clicked" name="activate"/> - </object> - </child> - <child> - <object class="GtkToggleAction" id="showInstalledAction"> - <property name="name">showInstalledAction</property> - <property name="label" translatable="yes">Show _Only Installed Packages</property> - <signal handler="cb_show_installed_toggled" name="toggled"/> - </object> - <accelerator key="i" modifiers="GDK_CONTROL_MASK"/> - </child> - <child> - <object class="GtkAction" id="syncAction"> - <property name="stock_id">gtk-refresh</property> - <property name="name">syncAction</property> - <property name="label" translatable="yes">_Sync</property> - <signal handler="cb_sync_clicked" name="activate"/> - </object> - <accelerator key="Y" modifiers="GDK_CONTROL_MASK"/> - </child> - <child> - <object class="GtkAction" id="saveFlagsAction"> - <property name="stock_id">gtk-save</property> - <property name="name">saveFlagsAction</property> - <property name="label" translatable="yes">Save _Flags</property> - <signal handler="cb_save_flags_clicked" name="activate"/> - </object> - </child> - <child> - <object class="GtkToggleAction" id="pauseAction"> - <property name="name">pauseActionMenu</property> - <property name="label" translatable="yes">Emerge _Paused</property> - <signal handler="cb_pause_emerge" name="activate"/> - </object> - <accelerator key="Z" modifiers="GDK_CONTROL_MASK"/> - </child> - <child> - <object class="GtkAction" id="killAction"> - <property name="stock_id">gtk-stop</property> - <property name="name">killAction</property> - <property name="label" translatable="yes">_Kill Emerge</property> - <signal handler="cb_kill_clicked" name="activate"/> - </object> - <accelerator key="K" modifiers="GDK_CONTROL_MASK"/> - </child> - <child> - <object class="GtkAction" id="copyAction"> - <property name="stock_id">gtk-copy</property> - <property name="name">copyAction</property> - <property name="label" translatable="yes">_Copy</property> - <signal handler="cb_copy_clicked" name="activate"/> - </object> - </child> - <child> - <object class="GtkAction" id="helpMenuAction"> - <property name="name">helpMenuAction</property> - <property name="label" translatable="yes">_?</property> - </object> - </child> - <child> - <object class="GtkAction" id="aboutAction"> - <property name="stock_id">gtk-about</property> - <property name="name">aboutAction</property> - <property name="label" translatable="yes">_About</property> - <signal handler="cb_about_clicked" name="activate"/> - </object> - </child> - <child> - <object class="GtkAction" id="pluginsAction"> - <property name="stock_id">gtk-connect</property> - <property name="name">pluginsAction</property> - <property name="label" translatable="yes">_Plugins</property> - <signal handler="cb_plugins_clicked" name="activate"/> - </object> - </child> - </object> - </child> - <ui> - <menubar name="menubar"> - <menu name="fileMenu" action="fileMenuAction"> - <menuitem name="prefMenuItem" action="prefAction"/> - <menuitem name="reloadMenuItem" action="reloadAction"/> - <separator/> - <menuitem name="closeMenuItem" action="closeAction"/> - </menu> - <menu name="emergeMenu" action="emergeMenuAction"> - <menuitem name="emergeMenuItem" action="emergeAction"/> - <menuitem name="unmergeMenuItem" action="unmergeAction"/> - <menuitem name="updateMenuItem" action="updateAction"/> - <menuitem name="showUpdatesMenuItem" action="showUpdatesAction"/> - <menuitem name="showInstalledMenuItem" action="showInstalledAction"/> - <separator/> - <menuitem name="syncMenuItem" action="syncAction"/> - <menuitem name="saveFlagsMenuItem" action="saveFlagsAction"/> - <separator/> - <menuitem name="pauseMenuItem" action="pauseAction"/> - <menuitem name="killMenuItem" action="killAction"/> - </menu> - <menu name="pluginMenu" action="pluginMenuAction"/> - <menu name="helpMenu" action="helpMenuAction"> - <menuitem name="aboutMenuItem" action="aboutAction"/> - <menuitem name="pluginsMenuItem" action="pluginsAction"/> - </menu> - </menubar> - <popup name="systrayPopup"> - <menuitem action="pauseAction"/> - <menuitem action="killAction"/> - <menuitem action="closeAction"/> - </popup> - <popup name="consolePopup"> - <menuitem name="copyMenuItem" action="copyAction"/> - <menuitem name="killMenuItem" action="killAction"/> - <menuitem name="pauseMenuItem" action="pauseAction"/> - </popup> - </ui> - </object> - <object class="GtkMenu" constructor="uimanager" id="systrayPopup"> - <property name="visible">True</property> - <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property> - </object> - <object class="GtkMenu" constructor="uimanager" id="consolePopup"> - <property name="visible">True</property> - <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property> - </object> + <requires lib="gtk+" version="2.14"/> + <!-- interface-naming-policy toplevel-contextual --> <object class="GtkWindow" id="MainWindow"> <property name="border_width">2</property> - <property name="window_position">GTK_WIN_POS_CENTER</property> - <signal handler="cb_destroy" name="destroy"/> - <signal handler="cb_delete" name="delete_event"/> - <signal handler="cb_minimized" name="window_state_event"/> + <property name="window_position">center</property> + <signal name="destroy" handler="cb_destroy"/> + <signal name="delete_event" handler="cb_delete"/> + <signal name="window_state_event" handler="cb_minimized"/> <child> <object class="GtkVBox" id="mainVB"> <property name="visible">True</property> + <property name="orientation">vertical</property> <child> - <object class="GtkMenuBar" constructor="uimanager" id="menubar"> + <object class="GtkVBox" id="menubar_box"> <property name="visible">True</property> + <property name="orientation">vertical</property> + <child> + <placeholder/> + </child> </object> <packing> <property name="expand">False</property> + <property name="position">0</property> </packing> </child> <child> @@ -229,23 +32,24 @@ <child> <object class="GtkEntry" id="searchEntry"> <property name="visible">True</property> - <signal handler="cb_search_changed" name="changed"/> - <signal handler="cb_search_changed" name="delete_text"/> - <signal handler="cb_search_clicked" name="activate" object="searchEntry"/> + <signal name="changed" handler="cb_search_changed"/> + <signal name="delete_text" handler="cb_search_changed"/> + <signal name="activate" handler="cb_search_clicked" object="searchEntry"/> </object> <packing> <property name="padding">5</property> + <property name="position">0</property> </packing> </child> <child> <object class="GtkButton" id="deleteSearchButton"> + <property name="label">gtk-delete</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="label">gtk-delete</property> <property name="use_stock">True</property> - <signal handler="cb_delete_search_clicked" name="clicked"/> + <signal name="clicked" handler="cb_delete_search_clicked"/> </object> <packing> <property name="expand">False</property> @@ -255,10 +59,12 @@ </child> <child> <object class="GtkButton" id="searchButton"> - <property name="visible">True</property> <property name="label">gtk-find</property> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="receives_default">False</property> <property name="use_stock">True</property> - <signal handler="cb_search_clicked" name="clicked" object="searchEntry"/> + <signal name="clicked" handler="cb_search_clicked" object="searchEntry"/> </object> <packing> <property name="expand">False</property> @@ -276,13 +82,14 @@ <child> <object class="GtkVPaned" id="vpaned"> <property name="visible">True</property> + <property name="orientation">vertical</property> <property name="position">300</property> <child> <object class="GtkFrame" id="listFrame"> <property name="visible">True</property> <property name="label_xalign">0</property> <property name="label_yalign">0</property> - <property name="shadow_type">GTK_SHADOW_IN</property> + <property name="shadow_type">in</property> <child> <object class="GtkHBox" id="listHB"> <property name="visible">True</property> @@ -293,8 +100,8 @@ <object class="GtkScrolledWindow" id="catScroll"> <property name="visible">True</property> <property name="can_focus">False</property> - <property name="hscrollbar_policy">GTK_POLICY_AUTOMATIC</property> - <property name="vscrollbar_policy">GTK_POLICY_AUTOMATIC</property> + <property name="hscrollbar_policy">automatic</property> + <property name="vscrollbar_policy">automatic</property> <child> <object class="GtkTreeView" id="catList"> <property name="visible">True</property> @@ -302,13 +109,16 @@ </object> </child> </object> + <packing> + <property name="position">0</property> + </packing> </child> <child> <object class="GtkScrolledWindow" id="pkgScroll"> <property name="visible">True</property> <property name="can_focus">False</property> - <property name="hscrollbar_policy">GTK_POLICY_AUTOMATIC</property> - <property name="vscrollbar_policy">GTK_POLICY_AUTOMATIC</property> + <property name="hscrollbar_policy">automatic</property> + <property name="vscrollbar_policy">automatic</property> <child> <object class="GtkTreeView" id="pkgList"> <property name="visible">True</property> @@ -324,8 +134,8 @@ <object class="GtkScrolledWindow" id="versionScroll"> <property name="visible">True</property> <property name="can_focus">False</property> - <property name="hscrollbar_policy">GTK_POLICY_AUTOMATIC</property> - <property name="vscrollbar_policy">GTK_POLICY_AUTOMATIC</property> + <property name="hscrollbar_policy">automatic</property> + <property name="vscrollbar_policy">automatic</property> <child> <object class="GtkTreeView" id="versionList"> <property name="visible">True</property> @@ -339,7 +149,7 @@ </child> </object> </child> - <child type="label"> + <child type="label_item"> <placeholder/> </child> </object> @@ -357,6 +167,7 @@ <object class="GtkVBox" id="packageVB"> <property name="visible">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="orientation">vertical</property> <child> <object class="GtkHBox" id="packageHeaderHB"> <property name="visible">True</property> @@ -367,9 +178,12 @@ <property name="visible">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="label" translatable="yes">label</property> - <property name="ellipsize">PANGO_ELLIPSIZE_START</property> + <property name="ellipsize">start</property> <property name="single_line_mode">True</property> </object> + <packing> + <property name="position">0</property> + </packing> </child> <child> <object class="GtkButton" id="pkgEmergeBtn"> @@ -377,9 +191,9 @@ <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="tooltip-text" translatable="yes">Install onto system</property> - <property name="relief">GTK_RELIEF_NONE</property> - <signal handler="cb_package_emerge_clicked" name="clicked"/> + <property name="tooltip_text" translatable="yes">Install onto system</property> + <property name="relief">none</property> + <signal name="clicked" handler="cb_package_emerge_clicked"/> <child> <object class="GtkImage" id="image1"> <property name="visible">True</property> @@ -399,9 +213,9 @@ <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="tooltip-text" translatable="yes">Uninstall from system</property> - <property name="relief">GTK_RELIEF_NONE</property> - <signal handler="cb_package_unmerge_clicked" name="clicked"/> + <property name="tooltip_text" translatable="yes">Uninstall from system</property> + <property name="relief">none</property> + <signal name="clicked" handler="cb_package_unmerge_clicked"/> <child> <object class="GtkImage" id="image4"> <property name="visible">True</property> @@ -421,9 +235,9 @@ <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="tooltip-text" translatable="yes">Revert changes</property> - <property name="relief">GTK_RELIEF_NONE</property> - <signal handler="cb_package_revert_clicked" name="clicked"/> + <property name="tooltip_text" translatable="yes">Revert changes</property> + <property name="relief">none</property> + <signal name="clicked" handler="cb_package_revert_clicked"/> <child> <object class="GtkImage" id="image5"> <property name="visible">True</property> @@ -441,26 +255,27 @@ <packing> <property name="expand">False</property> <property name="padding">4</property> + <property name="position">0</property> </packing> </child> <child> <object class="GtkNotebook" id="packageNotebook"> <property name="visible">True</property> - <property name="tab_pos">GTK_POS_BOTTOM</property> + <property name="tab_pos">bottom</property> <property name="scrollable">True</property> <child> <object class="GtkScrolledWindow" id="generalScroll"> <property name="visible">True</property> <property name="can_focus">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="hscrollbar_policy">GTK_POLICY_AUTOMATIC</property> - <property name="vscrollbar_policy">GTK_POLICY_AUTOMATIC</property> + <property name="hscrollbar_policy">automatic</property> + <property name="vscrollbar_policy">automatic</property> <child> <object class="GtkViewport" id="generalVB"> <property name="visible">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="resize_mode">GTK_RESIZE_QUEUE</property> - <property name="shadow_type">GTK_SHADOW_NONE</property> + <property name="resize_mode">queue</property> + <property name="shadow_type">none</property> <child> <object class="GtkTable" id="generalTable"> <property name="visible">True</property> @@ -471,12 +286,6 @@ <property name="column_spacing">5</property> <property name="row_spacing">5</property> <child> - <placeholder/> - </child> - <child> - <placeholder/> - </child> - <child> <object class="GtkLabel" id="licenseLabel"> <property name="visible">True</property> <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property> @@ -490,7 +299,7 @@ <property name="right_attach">2</property> <property name="top_attach">3</property> <property name="bottom_attach">4</property> - <property name="y_options"/> + <property name="y_options"></property> </packing> </child> <child> @@ -506,7 +315,7 @@ <property name="top_attach">3</property> <property name="bottom_attach">4</property> <property name="x_options">GTK_FILL</property> - <property name="y_options"/> + <property name="y_options"></property> <property name="y_padding">5</property> </packing> </child> @@ -522,7 +331,7 @@ <property name="right_attach">2</property> <property name="top_attach">5</property> <property name="bottom_attach">6</property> - <property name="y_options"/> + <property name="y_options"></property> </packing> </child> <child> @@ -537,7 +346,7 @@ <property name="right_attach">2</property> <property name="top_attach">5</property> <property name="bottom_attach">6</property> - <property name="y_options"/> + <property name="y_options"></property> </packing> </child> <child> @@ -554,7 +363,7 @@ <property name="right_attach">2</property> <property name="top_attach">2</property> <property name="bottom_attach">3</property> - <property name="y_options"/> + <property name="y_options"></property> </packing> </child> <child> @@ -568,7 +377,7 @@ </object> <packing> <property name="x_options">GTK_FILL</property> - <property name="y_options"/> + <property name="y_options"></property> <property name="y_padding">5</property> </packing> </child> @@ -586,7 +395,7 @@ <property name="top_attach">1</property> <property name="bottom_attach">2</property> <property name="x_options">GTK_FILL</property> - <property name="y_options"/> + <property name="y_options"></property> <property name="y_padding">5</property> </packing> </child> @@ -601,7 +410,7 @@ <packing> <property name="left_attach">1</property> <property name="right_attach">2</property> - <property name="y_options"/> + <property name="y_options"></property> </packing> </child> <child> @@ -618,7 +427,7 @@ <property name="right_attach">2</property> <property name="top_attach">1</property> <property name="bottom_attach">2</property> - <property name="y_options"/> + <property name="y_options"></property> </packing> </child> <child> @@ -634,44 +443,46 @@ <property name="top_attach">2</property> <property name="bottom_attach">3</property> <property name="x_options">GTK_FILL</property> - <property name="y_options"/> + <property name="y_options"></property> <property name="y_padding">5</property> </packing> </child> <child> <object class="GtkCheckButton" id="installedCheck"> + <property name="label" translatable="yes">Installed</property> <property name="visible">True</property> <property name="can_focus">True</property> + <property name="receives_default">False</property> <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property> <property name="no_show_all">True</property> - <property name="label" translatable="yes">Installed</property> <property name="xalign">0</property> <property name="draw_indicator">True</property> - <signal handler="cb_button_pressed" name="button_press_event"/> + <signal name="button_press_event" handler="cb_button_pressed"/> </object> <packing> <property name="top_attach">6</property> <property name="bottom_attach">7</property> <property name="x_options">GTK_FILL</property> - <property name="y_options"/> + <property name="y_options"></property> </packing> </child> <child> <object class="GtkCheckButton" id="maskedCheck"> + <property name="label" translatable="yes">Masked</property> <property name="visible">True</property> <property name="can_focus">True</property> + <property name="receives_default">False</property> <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property> <property name="no_show_all">True</property> - <property name="label" translatable="yes">Masked</property> <property name="xalign">0</property> <property name="draw_indicator">True</property> - <signal handler="cb_masked_toggled" name="toggled"/> + <signal name="toggled" handler="cb_masked_toggled"/> </object> <packing> <property name="top_attach">8</property> <property name="bottom_attach">9</property> <property name="x_options">GTK_FILL</property> - <property name="y_options"/> + <property name="y_options"></property> </packing> </child> <child> @@ -685,25 +496,26 @@ <property name="right_attach">2</property> <property name="top_attach">8</property> <property name="bottom_attach">9</property> - <property name="y_options"/> + <property name="y_options"></property> </packing> </child> <child> <object class="GtkCheckButton" id="testingCheck"> + <property name="label" translatable="yes">Testing</property> <property name="visible">True</property> <property name="can_focus">True</property> + <property name="receives_default">False</property> <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property> <property name="no_show_all">True</property> - <property name="label" translatable="yes">Testing</property> <property name="xalign">0</property> <property name="draw_indicator">True</property> - <signal handler="cb_testing_toggled" name="toggled"/> + <signal name="toggled" handler="cb_testing_toggled"/> </object> <packing> <property name="top_attach">7</property> <property name="bottom_attach">8</property> <property name="x_options">GTK_FILL</property> - <property name="y_options"/> + <property name="y_options"></property> </packing> </child> <child> @@ -720,7 +532,7 @@ <property name="top_attach">4</property> <property name="bottom_attach">5</property> <property name="x_options">GTK_FILL</property> - <property name="y_options"/> + <property name="y_options"></property> <property name="y_padding">5</property> </packing> </child> @@ -731,7 +543,7 @@ <property name="no_show_all">True</property> <property name="xalign">0</property> <property name="label">use flags</property> - <property name="ellipsize">PANGO_ELLIPSIZE_END</property> + <property name="ellipsize">end</property> <property name="single_line_mode">True</property> </object> <packing> @@ -739,9 +551,15 @@ <property name="right_attach">2</property> <property name="top_attach">4</property> <property name="bottom_attach">5</property> - <property name="y_options"/> + <property name="y_options"></property> </packing> </child> + <child> + <placeholder/> + </child> + <child> + <placeholder/> + </child> </object> </child> </object> @@ -762,12 +580,15 @@ <property name="visible">True</property> <property name="can_focus">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="hscrollbar_policy">GTK_POLICY_AUTOMATIC</property> - <property name="vscrollbar_policy">GTK_POLICY_AUTOMATIC</property> + <property name="hscrollbar_policy">automatic</property> + <property name="vscrollbar_policy">automatic</property> <child> <placeholder/> </child> </object> + <packing> + <property name="position">1</property> + </packing> </child> <child type="tab"> <object class="GtkLabel" id="label20"> @@ -796,22 +617,25 @@ <property name="visible">True</property> <property name="can_focus">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="tab_pos">GTK_POS_BOTTOM</property> + <property name="tab_pos">bottom</property> <property name="scrollable">True</property> <child> <object class="GtkVBox" id="queueVB"> <property name="visible">True</property> + <property name="orientation">vertical</property> <child> <object class="GtkHButtonBox" id="queueBB"> <property name="visible">True</property> <property name="border_width">5</property> <property name="homogeneous">True</property> - <property name="layout_style">GTK_BUTTONBOX_SPREAD</property> + <property name="layout_style">spread</property> <child> <object class="GtkButton" id="executeBtn"> <property name="visible">True</property> - <property name="tooltip-text" translatable="yes">Execute the current selected queue</property> - <signal handler="cb_execute_clicked" name="clicked"/> + <property name="can_focus">False</property> + <property name="receives_default">False</property> + <property name="tooltip_text" translatable="yes">Execute the current selected queue</property> + <signal name="clicked" handler="cb_execute_clicked"/> <child> <object class="GtkHBox" id="hbox7"> <property name="visible">True</property> @@ -822,6 +646,9 @@ <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property> <property name="stock">gtk-execute</property> </object> + <packing> + <property name="position">0</property> + </packing> </child> <child> <object class="GtkLabel" id="label12"> @@ -839,28 +666,41 @@ </object> </child> </object> + <packing> + <property name="expand">False</property> + <property name="fill">False</property> + <property name="position">0</property> + </packing> </child> <child> <object class="GtkButton" id="updateBtn"> - <property name="visible">True</property> - <property name="tooltip-text" translatable="yes">Calculate the packages which will be installed during an "update world"</property> <property name="label" translatable="yes">Update _World</property> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="receives_default">False</property> + <property name="tooltip_text" translatable="yes">Calculate the packages which will be installed during an "update world"</property> <property name="use_underline">True</property> - <signal handler="cb_update_clicked" name="clicked"/> + <signal name="clicked" handler="cb_update_clicked"/> </object> <packing> + <property name="expand">False</property> + <property name="fill">False</property> <property name="position">1</property> </packing> </child> <child> <object class="GtkButton" id="removeBtn"> - <property name="visible">True</property> - <property name="tooltip-text" translatable="yes">Remove the selected package from the queue</property> <property name="label" translatable="yes">_Remove</property> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="receives_default">False</property> + <property name="tooltip_text" translatable="yes">Remove the selected package from the queue</property> <property name="use_underline">True</property> - <signal handler="cb_remove_clicked" name="clicked"/> + <signal name="clicked" handler="cb_remove_clicked"/> </object> <packing> + <property name="expand">False</property> + <property name="fill">False</property> <property name="position">2</property> </packing> </child> @@ -868,6 +708,7 @@ <packing> <property name="expand">False</property> <property name="fill">False</property> + <property name="position">0</property> </packing> </child> <child> @@ -876,14 +717,16 @@ <property name="homogeneous">True</property> <child> <object class="GtkCheckButton" id="oneshotCB"> + <property name="label">--oneshot</property> <property name="visible">True</property> <property name="sensitive">False</property> <property name="can_focus">True</property> - <property name="label">--oneshot</property> + <property name="receives_default">False</property> <property name="draw_indicator">True</property> </object> <packing> <property name="padding">5</property> + <property name="position">0</property> </packing> </child> <child> @@ -902,17 +745,17 @@ <object class="GtkScrolledWindow" id="queueScroll"> <property name="visible">True</property> <property name="can_focus">False</property> - <property name="hscrollbar_policy">GTK_POLICY_AUTOMATIC</property> - <property name="vscrollbar_policy">GTK_POLICY_AUTOMATIC</property> + <property name="hscrollbar_policy">automatic</property> + <property name="vscrollbar_policy">automatic</property> <child> <object class="GtkTreeView" id="queueList"> <property name="visible">True</property> <property name="has_tooltip">True</property> <property name="headers_visible">False</property> <property name="enable_search">False</property> - <signal handler="cb_right_click" name="button_press_event"/> - <signal handler="cb_queue_tooltip_queried" name="query_tooltip"/> - <signal handler="cb_queue_row_activated" name="row_activated"/> + <signal name="button_press_event" handler="cb_right_click"/> + <signal name="query_tooltip" handler="cb_queue_tooltip_queried"/> + <signal name="row_activated" handler="cb_queue_row_activated"/> </object> </child> </object> @@ -942,6 +785,9 @@ <placeholder/> </child> </object> + <packing> + <property name="position">1</property> + </packing> </child> <child type="tab"> <object class="GtkLabel" id="label18"> @@ -960,19 +806,22 @@ <property name="visible">True</property> <property name="can_focus">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="hscrollbar_policy">GTK_POLICY_AUTOMATIC</property> - <property name="vscrollbar_policy">GTK_POLICY_AUTOMATIC</property> + <property name="hscrollbar_policy">automatic</property> + <property name="vscrollbar_policy">automatic</property> <child> <object class="GtkTextView" id="logView"> <property name="visible">True</property> <property name="can_focus">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="editable">False</property> - <property name="wrap_mode">GTK_WRAP_WORD</property> + <property name="wrap_mode">word</property> <property name="cursor_visible">False</property> </object> </child> </object> + <packing> + <property name="position">2</property> + </packing> </child> <child type="tab"> <object class="GtkLabel" id="label19"> diff --git a/portato/gui/templates/UpdateWindow.ui b/portato/gui/templates/PkgListWindow.ui index 69b668d..fdcdb23 100644 --- a/portato/gui/templates/UpdateWindow.ui +++ b/portato/gui/templates/PkgListWindow.ui @@ -1,25 +1,26 @@ <?xml version="1.0"?> -<!--Generated with glade3 3.4.4 on Thu May 15 21:45:30 2008 --> <interface> - <object class="GtkWindow" id="UpdateWindow"> + <requires lib="gtk+" version="2.14"/> + <!-- interface-naming-policy toplevel-contextual --> + <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">GTK_WIN_POS_CENTER_ON_PARENT</property> + <property name="window_position">center-on-parent</property> <property name="destroy_with_parent">True</property> <property name="urgency_hint">True</property> - <signal handler="cb_set_size" name="realize"/> + <signal name="realize" handler="cb_set_size"/> <child> <object class="GtkVBox" id="mainVB"> <property name="visible">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="orientation">vertical</property> <property name="spacing">5</property> <child> <object class="GtkScrolledWindow" id="scrolledwindow1"> <property name="visible">True</property> <property name="can_focus">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="hscrollbar_policy">GTK_POLICY_AUTOMATIC</property> - <property name="vscrollbar_policy">GTK_POLICY_AUTOMATIC</property> + <property name="hscrollbar_policy">automatic</property> + <property name="vscrollbar_policy">automatic</property> <child> <object class="GtkTreeView" id="packageList"> <property name="visible">True</property> @@ -28,56 +29,84 @@ <property name="headers_visible">False</property> <property name="reorderable">True</property> <property name="rules_hint">True</property> - <signal handler="cb_package_selected" name="cursor_changed"/> + <signal name="cursor_changed" handler="cb_package_selected"/> </object> </child> </object> + <packing> + <property name="position">0</property> + </packing> </child> <child> <object class="GtkHButtonBox" id="updateBB"> <property name="visible">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="homogeneous">True</property> - <property name="layout_style">GTK_BUTTONBOX_SPREAD</property> + <property name="layout_style">spread</property> <child> <object class="GtkButton" id="closeBtn"> + <property name="label" translatable="yes">_Close</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="label" translatable="yes">_Close</property> <property name="use_underline">True</property> - <signal handler="close" name="clicked"/> + <signal name="clicked" handler="close"/> </object> + <packing> + <property name="expand">False</property> + <property name="fill">False</property> + <property name="position">0</property> + </packing> </child> <child> <object class="GtkButton" id="selectAllBtn"> + <property name="label" translatable="yes">Select _All</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="label" translatable="yes">Select _All</property> <property name="use_underline">True</property> - <signal handler="cb_select_all_clicked" name="clicked"/> + <signal name="clicked" handler="cb_select_all_clicked"/> </object> <packing> + <property name="expand">False</property> + <property name="fill">False</property> <property name="position">1</property> </packing> </child> <child> <object class="GtkButton" id="installBtn"> + <property name="label" translatable="yes">_Install 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="label" translatable="yes">_Install Selected</property> <property name="use_underline">True</property> - <signal handler="cb_install_clicked" name="clicked"/> + <signal name="clicked" handler="cb_install_clicked"/> </object> <packing> + <property name="expand">False</property> + <property name="fill">False</property> <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/templates/PluginWindow.ui b/portato/gui/templates/PluginWindow.ui index 83d52d8..42a3156 100644 --- a/portato/gui/templates/PluginWindow.ui +++ b/portato/gui/templates/PluginWindow.ui @@ -1,13 +1,14 @@ <?xml version="1.0"?> -<!--Generated with glade3 3.4.5 on Fri Jul 4 15:24:27 2008 --> <interface> + <requires lib="gtk+" version="2.14"/> + <!-- interface-naming-policy toplevel-contextual --> <object class="GtkWindow" id="PluginWindow"> <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property> <property name="border_width">5</property> <property name="title" translatable="yes">Plugins</property> <property name="resizable">False</property> <property name="modal">True</property> - <property name="window_position">GTK_WIN_POS_CENTER_ON_PARENT</property> + <property name="window_position">center-on-parent</property> <property name="destroy_with_parent">True</property> <property name="skip_taskbar_hint">True</property> <property name="skip_pager_hint">True</property> @@ -16,13 +17,14 @@ <object class="GtkVBox" id="vbox5"> <property name="visible">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="orientation">vertical</property> <property name="spacing">5</property> <child> <object class="GtkScrolledWindow" id="pluginListScroll"> <property name="visible">True</property> <property name="can_focus">False</property> - <property name="hscrollbar_policy">GTK_POLICY_NEVER</property> - <property name="vscrollbar_policy">GTK_POLICY_NEVER</property> + <property name="hscrollbar_policy">never</property> + <property name="vscrollbar_policy">never</property> <child> <object class="GtkTreeView" id="pluginList"> <property name="visible">True</property> @@ -32,6 +34,9 @@ </object> </child> </object> + <packing> + <property name="position">0</property> + </packing> </child> <child> <object class="GtkFrame" id="frame1"> @@ -45,19 +50,19 @@ <property name="row_spacing">10</property> <child> <object class="GtkButton" id="installBtn"> + <property name="label" translatable="yes">_Install dependencies</property> <property name="visible">True</property> <property name="can_focus">True</property> <property name="receives_default">True</property> - <property name="label" translatable="yes">_Install dependencies</property> <property name="use_underline">True</property> - <signal handler="cb_install_clicked" name="clicked"/> + <signal name="clicked" handler="cb_install_clicked"/> </object> <packing> <property name="left_attach">1</property> <property name="right_attach">2</property> <property name="top_attach">2</property> <property name="bottom_attach">3</property> - <property name="y_options"/> + <property name="y_options"></property> <property name="x_padding">10</property> </packing> </child> @@ -70,7 +75,6 @@ <property name="visible">True</property> <property name="can_focus">True</property> <property name="headers_visible">False</property> - <property name="headers_clickable">True</property> </object> </child> <child type="label"> @@ -131,46 +135,63 @@ <property name="visible">True</property> <property name="spacing">5</property> <property name="homogeneous">True</property> - <property name="layout_style">GTK_BUTTONBOX_EDGE</property> + <property name="layout_style">edge</property> <child> <object class="GtkRadioButton" id="enabledRB"> + <property name="label" translatable="yes">Enabled</property> <property name="visible">True</property> <property name="can_focus">True</property> - <property name="label" translatable="yes">Enabled</property> + <property name="receives_default">False</property> <property name="active">True</property> - <signal handler="cb_state_toggled" name="toggled"/> + <property name="draw_indicator">False</property> + <signal name="toggled" handler="cb_state_toggled"/> </object> + <packing> + <property name="expand">False</property> + <property name="fill">False</property> + <property name="position">0</property> + </packing> </child> <child> <object class="GtkRadioButton" id="tempEnabledRB"> + <property name="label" translatable="yes">Temporarily enabled</property> <property name="visible">True</property> <property name="can_focus">True</property> - <property name="label" translatable="yes">Temporarily enabled</property> + <property name="receives_default">False</property> + <property name="draw_indicator">False</property> <property name="group">enabledRB</property> </object> <packing> + <property name="expand">False</property> + <property name="fill">False</property> <property name="position">1</property> </packing> </child> <child> <object class="GtkRadioButton" id="tempDisabledRB"> + <property name="label" translatable="yes">Temporarily disabled</property> <property name="visible">True</property> <property name="can_focus">True</property> - <property name="label" translatable="yes">Temporarily disabled</property> + <property name="receives_default">False</property> + <property name="draw_indicator">False</property> <property name="group">enabledRB</property> - <signal handler="cb_state_toggled" name="toggled"/> + <signal name="toggled" handler="cb_state_toggled"/> </object> <packing> + <property name="expand">False</property> + <property name="fill">False</property> <property name="position">2</property> </packing> </child> <child> <object class="GtkRadioButton" id="disabledRB"> + <property name="label" translatable="yes">Disabled</property> <property name="visible">True</property> <property name="can_focus">True</property> - <property name="label" translatable="yes">Disabled</property> + <property name="receives_default">False</property> + <property name="draw_indicator">False</property> <property name="group">enabledRB</property> - <signal handler="cb_state_toggled" name="toggled"/> + <signal name="toggled" handler="cb_state_toggled"/> </object> <packing> <property name="expand">False</property> @@ -188,7 +209,7 @@ </child> </object> </child> - <child type="label"> + <child type="label_item"> <placeholder/> </child> </object> @@ -201,29 +222,36 @@ <property name="visible">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="homogeneous">True</property> - <property name="layout_style">GTK_BUTTONBOX_SPREAD</property> + <property name="layout_style">spread</property> <child> <object class="GtkButton" id="cancelBtn"> + <property name="label">gtk-cancel</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="label">gtk-cancel</property> <property name="use_stock">True</property> - <signal handler="close" name="clicked"/> + <signal name="clicked" handler="close"/> </object> + <packing> + <property name="expand">False</property> + <property name="fill">False</property> + <property name="position">0</property> + </packing> </child> <child> <object class="GtkButton" id="okBtn"> + <property name="label">gtk-apply</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="label">gtk-apply</property> <property name="use_stock">True</property> - <signal handler="cb_ok_clicked" name="clicked"/> + <signal name="clicked" handler="cb_ok_clicked"/> </object> <packing> + <property name="expand">False</property> + <property name="fill">False</property> <property name="position">1</property> </packing> </child> diff --git a/portato/gui/templates/PreferenceWindow.ui b/portato/gui/templates/PreferenceWindow.ui index a257859..c7a00e0 100644 --- a/portato/gui/templates/PreferenceWindow.ui +++ b/portato/gui/templates/PreferenceWindow.ui @@ -18,6 +18,7 @@ <child> <object class="GtkVBox" id="mainVB"> <property name="visible">True</property> + <property name="orientation">vertical</property> <property name="spacing">5</property> <child> <object class="GtkNotebook" id="notebook2"> @@ -29,6 +30,7 @@ <property name="visible">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="border_width">5</property> + <property name="orientation">vertical</property> <child> <object class="GtkFrame" id="generalFrame"> <property name="visible">True</property> @@ -43,6 +45,7 @@ <child> <object class="GtkVBox" id="generalVB"> <property name="visible">True</property> + <property name="orientation">vertical</property> <child> <object class="GtkCheckButton" id="debugCheck"> <property name="label" translatable="yes">Debug</property> @@ -129,6 +132,7 @@ <child> <object class="GtkVBox" id="databaseVB"> <property name="visible">True</property> + <property name="orientation">vertical</property> <child> <object class="GtkHBox" id="hbox5"> <property name="visible">True</property> @@ -232,6 +236,7 @@ <child> <object class="GtkVBox" id="vbox5"> <property name="visible">True</property> + <property name="orientation">vertical</property> <child> <object class="GtkFrame" id="updateFrame"> <property name="visible">True</property> @@ -245,6 +250,7 @@ <child> <object class="GtkVBox" id="updateVB"> <property name="visible">True</property> + <property name="orientation">vertical</property> <child> <object class="GtkCheckButton" id="deepCheck"> <property name="label">--deep</property> @@ -634,6 +640,7 @@ <object class="GtkVBox" id="vbox4"> <property name="visible">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="orientation">vertical</property> <child> <object class="GtkFrame" id="visualGeneralFrame"> <property name="visible">True</property> @@ -650,6 +657,7 @@ <object class="GtkVBox" id="vbox6"> <property name="visible">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="orientation">vertical</property> <child> <object class="GtkCheckButton" id="systrayCheck"> <property name="label" translatable="yes">Enable systray</property> @@ -741,6 +749,7 @@ <object class="GtkVBox" id="vbox7"> <property name="visible">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="orientation">vertical</property> <property name="spacing">5</property> <child> <object class="GtkHBox" id="hbox2"> @@ -776,6 +785,7 @@ <object class="GtkHBox" id="hbox4"> <property name="visible">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="orientation">vertical</property> <property name="homogeneous">True</property> <child> <object class="GtkLabel" id="label21"> @@ -836,6 +846,7 @@ <child> <object class="GtkVBox" id="vbox3"> <property name="visible">True</property> + <property name="orientation">vertical</property> <child> <object class="GtkCheckButton" id="showSlotsCheck"> <property name="label" translatable="yes">Show slots in the version list</property> @@ -898,6 +909,7 @@ As an example: <i>app-admin</i>, <i>app-emacs</i>, and & <child> <object class="GtkVBox" id="vbox1"> <property name="visible">True</property> + <property name="orientation">vertical</property> <child> <object class="GtkHBox" id="hbox1"> <property name="visible">True</property> @@ -1001,6 +1013,7 @@ As an example: <i>app-admin</i>, <i>app-emacs</i>, and & <child> <object class="GtkVBox" id="vbox8"> <property name="visible">True</property> + <property name="orientation">vertical</property> <child> <object class="GtkHBox" id="hbox7"> <property name="visible">True</property> @@ -1125,6 +1138,8 @@ As an example: <i>app-admin</i>, <i>app-emacs</i>, and & <signal name="clicked" handler="cb_cancel_clicked"/> </object> <packing> + <property name="expand">False</property> + <property name="fill">False</property> <property name="position">0</property> </packing> </child> @@ -1139,6 +1154,8 @@ As an example: <i>app-admin</i>, <i>app-emacs</i>, and & <signal name="clicked" handler="cb_ok_clicked"/> </object> <packing> + <property name="expand">False</property> + <property name="fill">False</property> <property name="position">1</property> </packing> </child> diff --git a/portato/gui/templates/SearchWindow.ui b/portato/gui/templates/SearchWindow.ui index 26fa6a8..f62d259 100644 --- a/portato/gui/templates/SearchWindow.ui +++ b/portato/gui/templates/SearchWindow.ui @@ -1,6 +1,7 @@ <?xml version="1.0"?> -<!--Generated with glade3 3.4.1 on Fri Feb 29 00:01:28 2008 --> <interface> + <requires lib="gtk+" version="2.14"/> + <!-- interface-naming-policy toplevel-contextual --> <object class="GtkWindow" id="SearchWindow"> <property name="width_request">350</property> <property name="height_request">250</property> @@ -13,13 +14,14 @@ <object class="GtkVBox" id="vbox1"> <property name="visible">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="orientation">vertical</property> <child> <object class="GtkScrolledWindow" id="scrolledwindow2"> <property name="visible">True</property> <property name="can_focus">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="hscrollbar_policy">GTK_POLICY_AUTOMATIC</property> - <property name="vscrollbar_policy">GTK_POLICY_AUTOMATIC</property> + <property name="hscrollbar_policy">automatic</property> + <property name="vscrollbar_policy">automatic</property> <child> <object class="GtkTreeView" id="searchList"> <property name="visible">True</property> @@ -27,53 +29,65 @@ <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property> <property name="headers_visible">False</property> <property name="rules_hint">True</property> - <signal handler="ok" name="row_activated"/> + <signal name="row_activated" handler="ok"/> </object> </child> </object> + <packing> + <property name="position">0</property> + </packing> </child> <child> <object class="GtkHButtonBox" id="hbuttonbox3"> <property name="visible">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="homogeneous">True</property> - <property name="layout_style">GTK_BUTTONBOX_SPREAD</property> + <property name="layout_style">spread</property> <child> <object class="GtkButton" id="cancelBtn"> + <property name="label">gtk-cancel</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="label">gtk-cancel</property> <property name="use_stock">True</property> - <signal handler="close" name="clicked"/> + <signal name="clicked" handler="close"/> </object> + <packing> + <property name="expand">False</property> + <property name="fill">False</property> + <property name="position">0</property> + </packing> </child> <child> <object class="GtkButton" id="jumpBtn"> + <property name="label">gtk-jump-to</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="label">gtk-jump-to</property> <property name="use_stock">True</property> - <signal handler="jump" name="clicked"/> + <signal name="clicked" handler="jump"/> </object> <packing> + <property name="expand">False</property> + <property name="fill">False</property> <property name="position">1</property> </packing> </child> <child> <object class="GtkButton" id="okBtn"> + <property name="label">gtk-ok</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="label">gtk-ok</property> <property name="use_stock">True</property> - <signal handler="ok" name="clicked"/> + <signal name="clicked" handler="ok"/> </object> <packing> + <property name="expand">False</property> + <property name="fill">False</property> <property name="position">2</property> </packing> </child> diff --git a/portato/gui/templates/SplashScreen.ui b/portato/gui/templates/SplashScreen.ui index 4529fcc..c136062 100644 --- a/portato/gui/templates/SplashScreen.ui +++ b/portato/gui/templates/SplashScreen.ui @@ -1,12 +1,13 @@ <?xml version="1.0"?> -<!--Generated with glade3 3.4.1 on Fri Feb 29 00:02:46 2008 --> <interface> + <requires lib="gtk+" version="2.14"/> + <!-- interface-naming-policy toplevel-contextual --> <object class="GtkWindow" id="SplashScreen"> <property name="width_request">300</property> <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property> <property name="resizable">False</property> - <property name="window_position">GTK_WIN_POS_CENTER_ALWAYS</property> - <property name="type_hint">GDK_WINDOW_TYPE_HINT_SPLASHSCREEN</property> + <property name="window_position">center-always</property> + <property name="type_hint">splashscreen</property> <property name="urgency_hint">True</property> <property name="focus_on_map">False</property> <property name="decorated">False</property> @@ -23,12 +24,16 @@ <object class="GtkVBox" id="vbox3"> <property name="visible">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="orientation">vertical</property> <child> <object class="GtkImage" id="image"> <property name="visible">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="stock">gtk-missing-image</property> </object> + <packing> + <property name="position">0</property> + </packing> </child> <child> <object class="GtkLabel" id="generalLabel"> diff --git a/portato/gui/utils.py b/portato/gui/utils.py index 8b88b23..47f6fb7 100644 --- a/portato/gui/utils.py +++ b/portato/gui/utils.py @@ -21,7 +21,7 @@ from threading import Thread import gtk # some backend things -from ..backend import flags, set_system +from ..backend import flags, system from ..helper import debug, info from ..log import set_log_level from ..constants import APP, LOCALE_DIR @@ -90,9 +90,8 @@ class Config (ConfigParser): set_log_level(level) def modify_system_config (self): - """Sets the system config. - @see: L{backend.set_system()}""" - set_system(self.get("system")) + """Sets the system config.""" + system.set_system(self.get("system")) def modify_external_configs (self): """Convenience function setting all external configs.""" 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() diff --git a/portato/ipc.pxd b/portato/ipc.pxd new file mode 100644 index 0000000..64ca05d --- /dev/null +++ b/portato/ipc.pxd @@ -0,0 +1,52 @@ +# -*- coding: utf-8 -*- +# +# File: portato/ipc.pxd +# This file is part of the Portato-Project, a graphical portage-frontend. +# +# Copyright (C) 2006-2009 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. +# +# Written by René 'Necoro' Neumann <necoro@necoro.net> + +from python_string cimport * +from python_mem cimport * + +cdef extern from "errno.h": + int errno + cdef enum: + EACCES, EEXIST, ENOENT, ENOMEM, ENOSPC, + EINVAL, EPERM, EIDRM, EINTR + +cdef extern from *: + int INT_MAX + int RAND_MAX + ctypedef size_t int + int rand() + +cdef extern from "string.h": + char* strerror(int errno) + void* memcpy (void* dst, void* src, size_t len) + +cdef extern from "sys/msg.h" nogil: + cdef enum: + IPC_CREAT, IPC_EXCL, IPC_NOWAIT, + IPC_RMID + + ctypedef int key_t + + struct msqid_ds: + pass + + int msgget(key_t key, int msgflg) + int msgctl(int msqid, int cmd, msqid_ds* buf) + int msgsnd(int msgid, void* msgp, size_t msgsz, int msgflg) + int msgrcv(int msgid, void* msgp, size_t msgsz, long msgtype, int msgflg) + +cdef struct msg_data: + long mtype + char mtext[1] + +cdef enum: + MAX_MESSAGE_SIZE = 2048 diff --git a/portato/ipc.pyx b/portato/ipc.pyx new file mode 100644 index 0000000..f3fb4af --- /dev/null +++ b/portato/ipc.pyx @@ -0,0 +1,173 @@ +# -*- coding: utf-8 -*- +# +# File: portato/ipc.pyx +# This file is part of the Portato-Project, a graphical portage-frontend. +# +# Copyright (C) 2006-2009 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. +# +# Written by René 'Necoro' Neumann <necoro@necoro.net> + +class MessageQueueError(Exception): + """ + Base class for different queue errors. + """ + pass + +class MessageQueueRemovedError (MessageQueueError): + """ + This class is used iff the queue is already removed. + """ + pass + +cdef class MessageQueue (object): + """ + A simple interface to the SysV message queues. + """ + + cdef int msgid + cdef readonly key_t key + + def __init__ (self, key = None, create = False, exclusive = False): + """ + Create a new MessageQueue instance. Depending on the passed in flags, + different behavior occurs. See man msgget for the details. + + If key is None, a random key is created. + """ + + cdef int flags = 0600 # start mode + + if exclusive and not create: + raise ValueError("'exclusive' must be combined with 'create'.") + + if key is None and not exclusive: + raise ValueError("The key can only be None if 'exclusive' is set.") + + if create: + flags |= IPC_CREAT + + if exclusive: + flags |= IPC_EXCL + + if key is None: + check = True + while check: + self.key = self.random_key() + self.msgid = msgget(self.key, flags) + check = (self.msgid == -1 and errno == EEXIST) + else: + self.key = key + self.msgid = msgget(key, flags) + + if self.msgid == -1: + if errno == EACCES: + raise MessageQueueError("Permission denied.") + elif errno == EEXIST: + raise MessageQueueError("Queue already exists.") + elif errno == ENOENT: + raise MessageQueueError("Queue does not exist and 'create' is not set.") + elif errno == ENOMEM or errno == ENOSPC: + raise MemoryError("Insufficient ressources.") + else: + raise OSError(errno, strerror(errno)) + + def remove (self): + """ + Removes the message queue. + """ + cdef msqid_ds info + cdef int ret + + ret = msgctl(self.msgid, IPC_RMID, &info) + + if ret == -1: + if errno == EIDRM or errno == EINVAL: + raise MessageQueueRemovedError("Queue already removed.") + elif errno == EPERM: + raise MessageQueueError("Permission denied.") + else: + raise OSError(errno, strerror(errno)) + + def send (self, message, int type = 1): + """ + Sends a message with a specific type. + + The type must be larger zero. + Also note, that this is always blocking. + """ + cdef msg_data * msg + cdef int ret + cdef long size = len(message) + + if type <= 0: + raise ValueError("type must be > 0") + + if size >= MAX_MESSAGE_SIZE: + raise ValueError("Message must be smaller than %d" % MAX_MESSAGE_SIZE) + + msg = <msg_data*>PyMem_Malloc(sizeof(msg_data) + size) + + if msg is NULL: + raise MemoryError("Out of memory") + + memcpy(msg.mtext, <char*>message, size) + msg.mtype = type + + with nogil: + ret = msgsnd(self.msgid, msg, size, 0) + + try: + if ret == -1: + if errno == EIDRM or errno == EINVAL: + raise MessageQueueRemovedError("Queue was removed.") + elif errno == EINTR: + raise MessageQueueError("Signaled while waiting.") + elif errno == EACCES: + raise MessageQueueError("Permission denied.") + else: + raise OSError(errno, strerror(errno)) + finally: + PyMem_Free(msg) + + def receive (self): + """ + Receives a message from the queue and returns the (msg, type) pair. + + Note that this method is always blocking. + """ + cdef msg_data * msg + cdef int ret + cdef object retTuple + + msg = <msg_data*>PyMem_Malloc(sizeof(msg_data) + MAX_MESSAGE_SIZE) + + if msg is NULL: + raise MemoryError("Out of memory") + + msg.mtype = 0 + + with nogil: + ret = msgrcv(self.msgid, msg, <size_t>MAX_MESSAGE_SIZE, 0, 0) + + try: + if ret == -1: + if errno == EIDRM or errno == EINVAL: + raise MessageQueueRemovedError("Queue was removed.") + elif errno == EINTR: + raise MessageQueueError("Signaled while waiting.") + elif errno == EACCES: + raise MessageQueueError("Permission denied.") + else: + raise OSError(errno, strerror(errno)) + + retTuple = (PyString_FromStringAndSize(msg.mtext, ret), msg.mtype) + finally: + PyMem_Free(msg) + + return retTuple + + cdef inline key_t random_key (self): + return <int>(<double>rand() / (<double>RAND_MAX + 1) * INT_MAX) diff --git a/portato/listener.py b/portato/listener.py index 3d2dd53..c96b637 100644 --- a/portato/listener.py +++ b/portato/listener.py @@ -21,7 +21,8 @@ except ImportError: pynotify = None from .constants import APP -from .helper import debug, warning +from .helper import debug, warning, error +from . import ipc class Listener (object): """This class handles the communication between the "listener" and the GUI. @@ -32,22 +33,15 @@ class Listener (object): @ivar _send: sender socket @type _send: int""" - def set_recv (self, mem, sig, rw): - self._mem = mem - self._sig = sig - self._rw = rw + def set_recv (self, mq): + + self.mq = mq while True: try: - try: - self._sig.P() - self._rw.P() - len = self._mem.read(NumberOfBytes = 4) - string = self._mem.read(NumberOfBytes = int(len), offset = 4) - finally: - self._rw.V() - - data = string.split("\0") + msg, type = self.mq.receive() + + data = msg.split("\0") debug("Listener received: %s", data) if data[0] == "notify": @@ -59,15 +53,12 @@ class Listener (object): except KeyboardInterrupt: debug("Got KeyboardInterrupt. Aborting.") break + except ipc.MessageQueueRemovedError: + debug("MessageQueue removed. Aborting.") + break - self._mem.remove() - self._sig.remove() - self._rw.remove() - - self._mem = None - self._sig = None - self._rw = None - + self.mq = None + def do_cmd (self, cmdlist): """Starts a command as the user. @@ -89,30 +80,21 @@ class Listener (object): n.set_urgency(int(urgency)) n.show() - def set_send (self, mem = None, sig = None, rw = None): - if mem is None or sig is None or rw is None: + def set_send (self, mq = None): + if mq is None: warning(_("Listener has not been started.")) - self._mem = None - self._sig = None - self._rw = None + self.mq = None else: - import shm_wrapper as shm - - self._mem = shm.SharedMemoryHandle(mem) - self._sig = shm.SemaphoreHandle(sig) - self._rw = shm.SemaphoreHandle(rw) + self.mq = ipc.MessageQueue(mq) def __send (self, string): - self._rw.P() - self._sig.Z() try: - self._mem.write("%4d%s" % (len(string), string)) - self._sig.V() - finally: - self._rw.V() + self.mq.send(string) + except ipc.MessageQueueError, e: + error(_("An exception occured while accessing the message queue: %s"), e) def send_notify (self, base = "", descr = "", icon = "", urgency = None): - if self._sig is None: + if self.mq is None: self.do_notify(base, descr, icon, urgency) else: string = "\0".join(["notify", base, descr, icon]) @@ -125,11 +107,11 @@ class Listener (object): self.__send(string) def send_cmd (self, cmdlist): - if self._sig is None: + if self.mq is None: self.do_cmd(cmdlist) else: self.__send("\0".join(["cmd"] +cmdlist)) def close (self): - if self._sig is not None: + if self.mq is not None: self.__send("close") diff --git a/portato/plugin.py b/portato/plugin.py index 0da14f1..052dcd0 100644 --- a/portato/plugin.py +++ b/portato/plugin.py @@ -23,6 +23,7 @@ import traceback from collections import defaultdict from functools import wraps +from . import helper from .helper import debug, warning, info, error from .constants import PLUGIN_DIR from .backend import system @@ -300,6 +301,11 @@ class Plugin (object): """ self.__calls.append(Call(self, hook, callable, type, dep)) + def __str__ (self): + return self.name + + __repr__ = __str__ + class WidgetPlugin (Plugin): def __init__ (self, *args, **kwargs): @@ -430,25 +436,34 @@ class PluginQueue (object): plugin_module.__builtins__["Plugin"] = Plugin plugin_module.__builtins__["WidgetPlugin"] = WidgetPlugin plugin_module.__builtins__["register"] = register + plugin_module.__builtins__["helper"] = helper + plugin_module.__builtins__["PluginLoadException"] = PluginLoadException for p in plugins: # import them try: exec "from portato.plugins import %s" % p in {} except PluginLoadException, e: - error(_("Loading plugin '%(plugin)s' failed: %(error)s"), {"plugin" : p, "error" : e.message}) + error(_("Loading plugin module '%(plugin)s' failed: %(error)s"), {"plugin" : p, "error" : e}) except: tb = traceback.format_exc() - error(_("Loading plugin '%(plugin)s' failed: %(error)s"), {"plugin" : p, "error" : tb}) + error(_("Loading plugin module '%(plugin)s' failed: %(error)s"), {"plugin" : p, "error" : tb}) self._organize() def load_widgets(self, window): for p in self.plugins: if isinstance(p, WidgetPlugin): - p._widget_init(window) - for w in p.widgets: - WidgetSlot.slots[w.slot].add_widget(w) - info(_("Widgets of plugin '%s' loaded."), p.name) + try: + p._widget_init(window) + except PluginLoadException, e: + error(_("Loading widgets plugin '%(plugin)s' failed: %(error)s"), {"plugin" : p, "error" : e}) + except: + tb = traceback.format_exc() + error(_("Loading widgets of plugin '%(plugin)s' failed: %(error)s"), {"plugin" : p, "error" : tb}) + else: + for w in p.widgets: + WidgetSlot.slots[w.slot].add_widget(w) + info(_("Widgets of plugin '%s' loaded."), p.name) def add (self, plugin, disable = False): """ @@ -683,4 +698,10 @@ def register (plugin, disable = False): :see: `PluginQueue.add` """ if __plugins is not None: - __plugins.add(plugin, disable) + try: + __plugins.add(plugin, disable) + except PluginLoadException, e: + error(_("Registrating plugin '%(plugin)s' failed: %(error)s"), {"plugin" : plugin, "error" : e}) + except: + tb = traceback.format_exc() + error(_("Registrating plugin '%(plugin)s' failed: %(error)s"), {"plugin" : plugin, "error" : tb}) diff --git a/portato/waiting_queue.py b/portato/waiting_queue.py index d946abe..33791a3 100644 --- a/portato/waiting_queue.py +++ b/portato/waiting_queue.py @@ -36,10 +36,9 @@ class WaitingQueue (Queue): def put (self, method, *args, **kwargs): self.counter += 1; - if "caller" in kwargs: - name = "Waiting Thread #%d (called by:%s)" % (self.counter, kwargs["caller"]) - del kwargs["caller"] - else: + try: + name = "Waiting Thread #%d (called by:%s)" % (self.counter, kwargs.pop("caller")) + except KeyError: name = "Waiting Thread #%d" % self.counter t = self.threadClass(name = name, target = method, args = args, kwargs = kwargs) @@ -12,7 +12,12 @@ # Written by René 'Necoro' Neumann <necoro@necoro.net> import os +import sys + from distutils.core import setup +from distutils.extension import Extension +from Cython.Distutils import build_ext + from portato.constants import VERSION, ICON_DIR, PLUGIN_DIR, TEMPLATE_DIR, APP from build_manpage import build_manpage @@ -21,12 +26,31 @@ def plugin_list (*args): """Creates a list of correct plugin pathes out of the arguments.""" return [("plugins/%s.py" % x) for x in args] -packages = ["portato", "portato.db", "portato.gui", "portato.gui.windows", "portato.plugins", "portato.backend", "portato.backend.portage"] +packages = [ + "portato", + "portato.db", + "portato.gui", "portato.gui.windows", + "portato.plugins", + "portato.backend", "portato.backend.portage" + ] + data_files = [ - (TEMPLATE_DIR, [os.path.join("portato/gui/templates",x) for x in os.listdir("portato/gui/templates") if x.endswith(".ui")]), + (TEMPLATE_DIR, [os.path.join("portato/gui/templates",x) for x in os.listdir("portato/gui/templates") if (x.endswith(".ui") or x.endswith(".menu"))]), (ICON_DIR, ["icons/portato-icon.png"]), (PLUGIN_DIR, plugin_list("gpytage", "notify", "etc_proposals", "reload_portage", "package_details"))] +# extension stuff +ext_modules = [Extension("portato.ipc", ["portato/ipc.pyx"])] + +if "--disable-eix" in sys.argv: + sys.argv.remove("--disable-eix") +else: + ext_modules.append(Extension("portato.eix.parser", ["portato/eix/parser.pyx"])) + packages.append("portato.eix") + + if "--enable-eix" in sys.argv: + sys.argv.remove("--enable-eix") + # do the distutils setup setup(name=APP, version = VERSION, @@ -39,5 +63,6 @@ setup(name=APP, author_email = "necoro@necoro.net", packages = packages, data_files = data_files, - cmdclass={'build_manpage': build_manpage} + ext_modules = ext_modules, + cmdclass={'build_manpage': build_manpage, 'build_ext' : build_ext} ) @@ -0,0 +1,29 @@ +from __future__ import with_statement + +from portato import _sub_start +_sub_start() + +from portato.eix import EixReader +from portato.backend import system + +def run(): + with EixReader("/var/cache/eix") as eix: + for c in eix.categories: + c.name + for p in c.packages: + p.name + +def run2(): + for i in system.find_packages(with_version = False): + cat, pkg = i.split("/") + +def run3(): + inst = system.find_packages(pkgSet = system.SET_INSTALLED, with_version = False) + + for i in range(200): + "bla" in inst + +def run4(): + inst = set(system.find_packages(pkgSet = system.SET_INSTALLED, with_version = False)) + for i in range(200): + "bla" in inst |