diff options
Diffstat (limited to 'portato')
61 files changed, 450 insertions, 195 deletions
diff --git a/portato/__init__.py b/portato/__init__.py index 44a4da4..61d6a42 100644 --- a/portato/__init__.py +++ b/portato/__init__.py @@ -3,7 +3,7 @@ # File: portato/__init__.py # This file is part of the Portato-Project, a graphical portage-frontend. # -# Copyright (C) 2006-2009 René 'Necoro' Neumann +# Copyright (C) 2006-2010 René 'Necoro' Neumann # This is free software. You may redistribute copies of it under the terms of # the GNU General Public License version 2. # There is NO WARRANTY, to the extent permitted by law. @@ -17,9 +17,13 @@ import sys, os from optparse import OptionParser, SUPPRESS_HELP from .log import start as logstart -from .constants import LOCALE_DIR, APP, VERSION +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 diff --git a/portato/backend/__init__.py b/portato/backend/__init__.py index 8eae806..5f32818 100644 --- a/portato/backend/__init__.py +++ b/portato/backend/__init__.py @@ -3,7 +3,7 @@ # File: portato/backend/__init__.py # This file is part of the Portato-Project, a graphical portage-frontend. # -# Copyright (C) 2006-2009 René 'Necoro' Neumann +# Copyright (C) 2006-2010 René 'Necoro' Neumann # This is free software. You may redistribute copies of it under the terms of # the GNU General Public License version 2. # There is NO WARRANTY, to the extent permitted by law. @@ -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/exceptions.py b/portato/backend/exceptions.py index f20a33e..dc2c7cd 100644 --- a/portato/backend/exceptions.py +++ b/portato/backend/exceptions.py @@ -3,7 +3,7 @@ # File: portato/backend/exceptions.py # This file is part of the Portato-Project, a graphical portage-frontend. # -# Copyright (C) 2006-2009 René 'Necoro' Neumann +# Copyright (C) 2006-2010 René 'Necoro' Neumann # This is free software. You may redistribute copies of it under the terms of # the GNU General Public License version 2. # There is NO WARRANTY, to the extent permitted by law. diff --git a/portato/backend/flags.py b/portato/backend/flags.py index 9c5b93d..810b607 100644 --- a/portato/backend/flags.py +++ b/portato/backend/flags.py @@ -3,7 +3,7 @@ # File: portato/backend/flags.py # This file is part of the Portato-Project, a graphical portage-frontend. # -# Copyright (C) 2006-2009 René 'Necoro' Neumann +# Copyright (C) 2006-2010 René 'Necoro' Neumann # This is free software. You may redistribute copies of it under the terms of # the GNU General Public License version 2. # There is NO WARRANTY, to the extent permitted by law. diff --git a/portato/backend/package.py b/portato/backend/package.py index 8a80fd5..34cdbe4 100644 --- a/portato/backend/package.py +++ b/portato/backend/package.py @@ -3,7 +3,7 @@ # File: portato/backend/package.py # This file is part of the Portato-Project, a graphical portage-frontend. # -# Copyright (C) 2006-2009 René 'Necoro' Neumann +# Copyright (C) 2006-2010 René 'Necoro' Neumann # This is free software. You may redistribute copies of it under the terms of # the GNU General Public License version 2. # There is NO WARRANTY, to the extent permitted by law. @@ -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/__init__.py b/portato/backend/portage/__init__.py index 1daf51b..e559f9e 100644 --- a/portato/backend/portage/__init__.py +++ b/portato/backend/portage/__init__.py @@ -3,7 +3,7 @@ # File: portato/backend/portage/__init__.py # This file is part of the Portato-Project, a graphical portage-frontend. # -# Copyright (C) 2006-2009 René 'Necoro' Neumann +# Copyright (C) 2006-2010 René 'Necoro' Neumann # This is free software. You may redistribute copies of it under the terms of # the GNU General Public License version 2. # There is NO WARRANTY, to the extent permitted by law. diff --git a/portato/backend/portage/package.py b/portato/backend/portage/package.py index 2b40e41..b34e3ef 100644 --- a/portato/backend/portage/package.py +++ b/portato/backend/portage/package.py @@ -3,7 +3,7 @@ # File: portato/backend/portage/package.py # This file is part of the Portato-Project, a graphical portage-frontend. # -# Copyright (C) 2006-2009 René 'Necoro' Neumann +# Copyright (C) 2006-2010 René 'Necoro' Neumann # This is free software. You may redistribute copies of it under the terms of # the GNU General Public License version 2. # There is NO WARRANTY, to the extent permitted by law. @@ -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/package_22.py b/portato/backend/portage/package_22.py index ed804ce..23e8ed5 100644 --- a/portato/backend/portage/package_22.py +++ b/portato/backend/portage/package_22.py @@ -3,7 +3,7 @@ # File: portato/backend/portage/package_22.py # This file is part of the Portato-Project, a graphical portage-frontend. # -# Copyright (C) 2006-2009 René 'Necoro' Neumann +# Copyright (C) 2006-2010 René 'Necoro' Neumann # This is free software. You may redistribute copies of it under the terms of # the GNU General Public License version 2. # There is NO WARRANTY, to the extent permitted by law. diff --git a/portato/backend/portage/sets.py b/portato/backend/portage/sets.py index 234047b..c1971b7 100644 --- a/portato/backend/portage/sets.py +++ b/portato/backend/portage/sets.py @@ -3,7 +3,7 @@ # File: portato/backend/portage/sets.py # This file is part of the Portato-Project, a graphical portage-frontend. # -# Copyright (C) 2006-2009 René 'Necoro' Neumann +# Copyright (C) 2006-2010 René 'Necoro' Neumann # This is free software. You may redistribute copies of it under the terms of # the GNU General Public License version 2. # There is NO WARRANTY, to the extent permitted by law. @@ -102,7 +102,7 @@ class InstalledSet (Set): else: t = system.settings.vartree.dbapi.match(key) if not with_version: - t = itt.imap(portage.dep.dep_getkey, t) + t = itt.imap(portage.cpv_getkey, t) return set(t) diff --git a/portato/backend/portage/settings.py b/portato/backend/portage/settings.py index 8211f3b..2f3b780 100644 --- a/portato/backend/portage/settings.py +++ b/portato/backend/portage/settings.py @@ -3,7 +3,7 @@ # File: portato/backend/portage/settings.py # This file is part of the Portato-Project, a graphical portage-frontend. # -# Copyright (C) 2006-2009 René 'Necoro' Neumann +# Copyright (C) 2006-2010 René 'Necoro' Neumann # This is free software. You may redistribute copies of it under the terms of # the GNU General Public License version 2. # There is NO WARRANTY, to the extent permitted by law. diff --git a/portato/backend/portage/settings_22.py b/portato/backend/portage/settings_22.py index bae3424..ba4f1e8 100644 --- a/portato/backend/portage/settings_22.py +++ b/portato/backend/portage/settings_22.py @@ -3,7 +3,7 @@ # File: portato/backend/portage/settings_22.py # This file is part of the Portato-Project, a graphical portage-frontend. # -# Copyright (C) 2006-2009 René 'Necoro' Neumann +# Copyright (C) 2006-2010 René 'Necoro' Neumann # This is free software. You may redistribute copies of it under the terms of # the GNU General Public License version 2. # There is NO WARRANTY, to the extent permitted by law. diff --git a/portato/backend/portage/system.py b/portato/backend/portage/system.py index d7c7806..3aaa060 100644 --- a/portato/backend/portage/system.py +++ b/portato/backend/portage/system.py @@ -3,7 +3,7 @@ # File: portato/backend/portage/system.py # This file is part of the Portato-Project, a graphical portage-frontend. # -# Copyright (C) 2006-2009 René 'Necoro' Neumann +# Copyright (C) 2006-2010 René 'Necoro' Neumann # This is free software. You may redistribute copies of it under the terms of # the GNU General Public License version 2. # There is NO WARRANTY, to the extent permitted by law. @@ -68,7 +68,12 @@ class PortageSystem (SystemInterface): return PortagePackage(cpv) def get_config_path (self): - return portage.USER_CONFIG_PATH + path = portage.USER_CONFIG_PATH + + if path[0] != "/": + return os.path.join(self.settings.settings["ROOT"], path) + else: + return path def get_merge_command (self): return ["/usr/bin/python", "/usr/bin/emerge"] @@ -120,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. @@ -218,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): @@ -240,7 +262,7 @@ class PortageSystem (SystemInterface): if not best: return - if not best.is_installed() and (best.is_masked() or best.is_testing(True)): # check to not update unnecessairily + if not best.is_installed() and (best.is_masked() or best.is_testing(True)): # check to not update unnecessarily for i in inst: if i.matches(crit): debug("The installed %s matches %s. Discarding upgrade to masked version %s.", i.get_cpv(), crit, best.get_version()) diff --git a/portato/backend/portage/system_22.py b/portato/backend/portage/system_22.py index f69e15c..c3bfa5f 100644 --- a/portato/backend/portage/system_22.py +++ b/portato/backend/portage/system_22.py @@ -3,7 +3,7 @@ # File: portato/backend/portage/system_22.py # This file is part of the Portato-Project, a graphical portage-frontend. # -# Copyright (C) 2006-2009 René 'Necoro' Neumann +# Copyright (C) 2006-2010 René 'Necoro' Neumann # This is free software. You may redistribute copies of it under the terms of # the GNU General Public License version 2. # There is NO WARRANTY, to the extent permitted by law. @@ -63,11 +63,3 @@ class PortageSystem_22 (PortageSystem): def new_package (self, cpv): return PortagePackage_22(cpv) - - def get_config_path (self): - path = PortageSystem.get_config_path(self) - - if path[0] != "/": - return os.path.join(self.settings.settings["ROOT"], path) - else: - return path diff --git a/portato/backend/system_interface.py b/portato/backend/system_interface.py index be79de2..a156d2b 100644 --- a/portato/backend/system_interface.py +++ b/portato/backend/system_interface.py @@ -3,7 +3,7 @@ # File: portato/backend/system_interface.py # This file is part of the Portato-Project, a graphical portage-frontend. # -# Copyright (C) 2006-2009 René 'Necoro' Neumann +# Copyright (C) 2006-2010 René 'Necoro' Neumann # This is free software. You may redistribute copies of it under the terms of # the GNU General Public License version 2. # There is NO WARRANTY, to the extent permitted by law. @@ -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. @@ -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/config_parser.py b/portato/config_parser.py index 39234a9..2ef52c5 100644 --- a/portato/config_parser.py +++ b/portato/config_parser.py @@ -3,7 +3,7 @@ # File: portato/config_parser.py # This file is part of the Portato-Project, a graphical portage-frontend. # -# Copyright (C) 2006-2009 René 'Necoro' Neumann +# Copyright (C) 2006-2010 René 'Necoro' Neumann # This is free software. You may redistribute copies of it under the terms of # the GNU General Public License version 2. # There is NO WARRANTY, to the extent permitted by law. diff --git a/portato/constants.py b/portato/constants.py index 7d2a9d6..a8e930c 100644 --- a/portato/constants.py +++ b/portato/constants.py @@ -3,7 +3,7 @@ # File: portato/constants.py # This file is part of the Portato-Project, a graphical portage-frontend. # -# Copyright (C) 2006-2009 René 'Necoro' Neumann +# Copyright (C) 2006-2010 René 'Necoro' Neumann # This is free software. You may redistribute copies of it under the terms of # the GNU General Public License version 2. # There is NO WARRANTY, to the extent permitted by law. @@ -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 9d21d3b..21f72ce 100644 --- a/portato/db/__init__.py +++ b/portato/db/__init__.py @@ -3,7 +3,7 @@ # File: portato/db/__init__.py # This file is part of the Portato-Project, a graphical portage-frontend. # -# Copyright (C) 2006-2009 René 'Necoro' Neumann +# Copyright (C) 2006-2010 René 'Necoro' Neumann # This is free software. You may redistribute copies of it under the terms of # the GNU General Public License version 2. # There is NO WARRANTY, to the extent permitted by law. @@ -26,7 +26,7 @@ _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.")), - "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.")) + "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.\nAdditionally, this is the only database allowing searching in descriptions.")) } def Database(type = None): diff --git a/portato/db/database.py b/portato/db/database.py index 7a23e5e..6e92d79 100644 --- a/portato/db/database.py +++ b/portato/db/database.py @@ -3,7 +3,7 @@ # File: portato/db/database.py # This file is part of the Portato-Project, a graphical portage-frontend. # -# Copyright (C) 2006-2009 René 'Necoro' Neumann +# Copyright (C) 2006-2010 René 'Necoro' Neumann # This is free software. You may redistribute copies of it under the terms of # the GNU General Public License version 2. # There is NO WARRANTY, to the extent permitted by law. @@ -14,6 +14,10 @@ from __future__ import absolute_import, with_statement from threading import RLock from functools import wraps +from ..helper import warning + +class UnsupportedSearchTypeError(Exception): + pass class PkgData (object): __slots__ = ("cat", "pkg", "inst", "disabled") @@ -37,8 +41,19 @@ class Database (object): ALL = _("ALL") + SEARCH_NAME = 1 + SEARCH_DESCRIPTION = 2 + + TYPES = { + SEARCH_NAME : _("Name"), + SEARCH_DESCRIPTION : _("Description"), + SEARCH_NAME | SEARCH_DESCRIPTION : "%s + %s" % (_("Name"), _("Description")) + } + + def __init__ (self): self._lock = RLock() + self.type = self.SEARCH_NAME @staticmethod def lock (f): @@ -51,6 +66,24 @@ class Database (object): return wrapper + def search_types (self): + """The types of search supported by the database. + + @return: type + @rtype: int""" + raise NotImplentedError + + def set_type (self, type): + if type & self.search_types() != type: + raise UnsupportedSearchTypeError, type + + self._type = type + + def get_type (self): + return self._type + + type = property(get_type, set_type) + def populate (self, category = None): """Populates the database. diff --git a/portato/db/eix_sql.py b/portato/db/eix_sql.py index c2d2292..75bcb1e 100644 --- a/portato/db/eix_sql.py +++ b/portato/db/eix_sql.py @@ -3,7 +3,7 @@ # 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 +# Copyright (C) 2006-2010 René 'Necoro' Neumann # This is free software. You may redistribute copies of it under the terms of # the GNU General Public License version 2. # There is NO WARRANTY, to the extent permitted by law. @@ -41,6 +41,9 @@ class EixSQLDatabase (SQLDatabase): SQLDatabase.__init__(self, session) + def search_types(self): + return self.SEARCH_NAME | self.SEARCH_DESCRIPTION + def updated (self): mtime = os.stat(self.cache).st_mtime old = self.session.get("mtime", 0) @@ -63,7 +66,7 @@ class EixSQLDatabase (SQLDatabase): 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) + yield (cat.name, pkg.name, pkg.description, p in inst, False) - connection.executemany("INSERT INTO packages (cat, name, inst, disabled) VALUES (?, ?, ?, ?)", _get()) + connection.executemany("INSERT INTO packages (cat, name, descr, inst, disabled) VALUES (?, ?, ?, ?, ?)", _get()) connection.commit() diff --git a/portato/db/hash.py b/portato/db/hash.py index 8cea6f2..4a6958b 100644 --- a/portato/db/hash.py +++ b/portato/db/hash.py @@ -3,7 +3,7 @@ # File: portato/db/hash.py # This file is part of the Portato-Project, a graphical portage-frontend. # -# Copyright (C) 2006-2009 René 'Necoro' Neumann +# Copyright (C) 2006-2010 René 'Necoro' Neumann # This is free software. You may redistribute copies of it under the terms of # the GNU General Public License version 2. # There is NO WARRANTY, to the extent permitted by law. @@ -32,6 +32,9 @@ class HashDatabase (Database): self.__initialize() self.populate() + def search_types(self): + return Database.SEARCH_NAME + def __initialize (self): self._db = defaultdict(list) self.inst_cats = set([self.ALL]) diff --git a/portato/db/sql.py b/portato/db/sql.py index fbc01e6..a9c27ab 100644 --- a/portato/db/sql.py +++ b/portato/db/sql.py @@ -3,7 +3,7 @@ # File: portato/db/sql.py # This file is part of the Portato-Project, a graphical portage-frontend. # -# Copyright (C) 2006-2009 René 'Necoro' Neumann +# Copyright (C) 2006-2010 René 'Necoro' Neumann # This is free software. You may redistribute copies of it under the terms of # the GNU General Public License version 2. # There is NO WARRANTY, to the extent permitted by law. @@ -34,7 +34,7 @@ from .database import Database, PkgData class SQLDatabase (Database): - FORMAT = "1" + FORMAT = "2" FORBIDDEN = (".bzr", ".svn", ".git", "CVS", ".hg", "_darcs") lock = Database.lock @@ -68,6 +68,7 @@ class SQLDatabase (Database): ( name TEXT, cat TEXT, + descr TEXT DEFAULT "", inst INTEGER, disabled INTEGER )""") @@ -83,6 +84,9 @@ class SQLDatabase (Database): pkg_conn.close() + def search_types(self): + return self.SEARCH_NAME + def updated (self): changed = False @@ -253,12 +257,22 @@ class SQLDatabase (Database): self._restrict = "" else: restrict = restrict.replace(".*","%").replace(".","_") + rest = "" + + if self._type & self.SEARCH_NAME: + if "/" in restrict: + rest = "(name LIKE '%s%%' AND cat LIKE '%s')" % (pkg, cat) + else: + rest = "(name LIKE '%%%(restrict)s%%' OR cat LIKE '%(restrict)s%%')" % {"restrict":restrict} - if "/" in restrict: - cat,pkg = restrict.split("/") - self._restrict = "AND name LIKE '%s%%' AND cat LIKE '%s'" % (pkg, cat) - else: - self._restrict = "AND (name LIKE '%%%(restrict)s%%' OR cat LIKE '%(restrict)s%%')" % {"restrict":restrict} + if self._type & self.SEARCH_DESCRIPTION: + r = "descr LIKE '%%%(restrict)s%%'" % {"restrict":restrict} + if rest: + rest = "(%s OR %s)" % (r, rest) + else: + rest = r + + self._restrict = "AND " + rest restrict = property(get_restrict, set_restrict) con = staticmethod(con) diff --git a/portato/dependency.py b/portato/dependency.py index bda20eb..4b505e6 100644 --- a/portato/dependency.py +++ b/portato/dependency.py @@ -3,7 +3,7 @@ # File: portato/dependency.py # This file is part of the Portato-Project, a graphical portage-frontend. # -# Copyright (C) 2006-2009 René 'Necoro' Neumann +# Copyright (C) 2006-2010 René 'Necoro' Neumann # This is free software. You may redistribute copies of it under the terms of # the GNU General Public License version 2. # There is NO WARRANTY, to the extent permitted by law. diff --git a/portato/eix/__init__.py b/portato/eix/__init__.py index 346fe82..8fa1da6 100644 --- a/portato/eix/__init__.py +++ b/portato/eix/__init__.py @@ -3,7 +3,7 @@ # File: portato/eix/__init__.py # This file is part of the Portato-Project, a graphical portage-frontend. # -# Copyright (C) 2006-2009 René 'Necoro' Neumann +# Copyright (C) 2006-2010 René 'Necoro' Neumann # This is free software. You may redistribute copies of it under the terms of # the GNU General Public License version 2. # There is NO WARRANTY, to the extent permitted by law. diff --git a/portato/eix/exceptions.py b/portato/eix/exceptions.py index 8145af4..1ca05e1 100644 --- a/portato/eix/exceptions.py +++ b/portato/eix/exceptions.py @@ -3,7 +3,7 @@ # File: portato/eix/exceptions.py # This file is part of the Portato-Project, a graphical portage-frontend. # -# Copyright (C) 2006-2009 René 'Necoro' Neumann +# Copyright (C) 2006-2010 René 'Necoro' Neumann # This is free software. You may redistribute copies of it under the terms of # the GNU General Public License version 2. # There is NO WARRANTY, to the extent permitted by law. diff --git a/portato/eix/parser.pyx b/portato/eix/parser.pyx index 01a673f..d4bd3af 100644 --- a/portato/eix/parser.pyx +++ b/portato/eix/parser.pyx @@ -3,7 +3,7 @@ # File: portato/eix/_parser.pyx # This file is part of the Portato-Project, a graphical portage-frontend. # -# Copyright (C) 2006-2009 René 'Necoro' Neumann +# Copyright (C) 2006-2010 René 'Necoro' Neumann # This is free software. You may redistribute copies of it under the terms of # the GNU General Public License version 2. # There is NO WARRANTY, to the extent permitted by law. @@ -260,7 +260,7 @@ cdef class package: cdef LLong _offset cdef readonly object name - #cdef readonly object description + cdef readonly object description #cdef readonly object provide #cdef readonly object homepage #cdef readonly object license @@ -279,9 +279,9 @@ cdef class package: after_offset = ftell(cfile) self.name = string(file) + self.description = 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) diff --git a/portato/eix/py_parser.py b/portato/eix/py_parser.py index cc42553..231c206 100644 --- a/portato/eix/py_parser.py +++ b/portato/eix/py_parser.py @@ -3,7 +3,7 @@ # File: portato/eix/parser.py # This file is part of the Portato-Project, a graphical portage-frontend. # -# Copyright (C) 2006-2009 René 'Necoro' Neumann +# Copyright (C) 2006-2010 René 'Necoro' Neumann # This is free software. You may redistribute copies of it under the terms of # the GNU General Public License version 2. # There is NO WARRANTY, to the extent permitted by law. diff --git a/portato/gui/__init__.py b/portato/gui/__init__.py index e3f1172..bbe21d8 100644 --- a/portato/gui/__init__.py +++ b/portato/gui/__init__.py @@ -3,7 +3,7 @@ # File: portato/gui/__init__.py # This file is part of the Portato-Project, a graphical portage-frontend. # -# Copyright (C) 2006-2009 René 'Necoro' Neumann +# Copyright (C) 2006-2010 René 'Necoro' Neumann # This is free software. You may redistribute copies of it under the terms of # the GNU General Public License version 2. # There is NO WARRANTY, to the extent permitted by law. @@ -27,9 +27,11 @@ def run (): from .windows.main import MainWindow try: m = MainWindow(s) - s.hide() + s.destroy() + del s + m.main() except PreReqError, e: error("Prerequisite not matched. Aborting.") prereq_error_dialog(e) - s.hide() + s.destroy() diff --git a/portato/gui/dialogs.py b/portato/gui/dialogs.py index d7ac41b..6044a5b 100644 --- a/portato/gui/dialogs.py +++ b/portato/gui/dialogs.py @@ -3,7 +3,7 @@ # File: portato/gui/dialogs.py # This file is part of the Portato-Project, a graphical portage-frontend. # -# Copyright (C) 2006-2009 René 'Necoro' Neumann +# Copyright (C) 2006-2010 René 'Necoro' Neumann # This is free software. You may redistribute copies of it under the terms of # the GNU General Public License version 2. # There is NO WARRANTY, to the extent permitted by law. @@ -68,7 +68,7 @@ def nothing_found_dialog (): def changed_flags_dialog (what = "flags"): check = gtk.CheckButton(_("Do not show this dialog again.")) hintMB = gtk.MessageDialog(None, gtk.DIALOG_MODAL, gtk.MESSAGE_INFO, gtk.BUTTONS_OK, _("Changed %s") % what) - hintMB.format_secondary_text(_("Portato will write these changes into the appropriate files.\nPlease backup them if you think it is necessairy.")) + hintMB.format_secondary_text(_("Portato will write these changes into the appropriate files.\nPlease backup them if you think it is necessary.")) hintMB.vbox.add(check) hintMB.vbox.show_all() ret = hintMB.run() diff --git a/portato/gui/exception_handling.py b/portato/gui/exception_handling.py index c973e6b..dbafa7e 100644 --- a/portato/gui/exception_handling.py +++ b/portato/gui/exception_handling.py @@ -3,7 +3,7 @@ # File: portato/gui/exception_handling.py # This file is part of the Portato-Project, a graphical portage-frontend. # -# Copyright (C) 2006-2009 René 'Necoro' Neumann +# Copyright (C) 2006-2010 René 'Necoro' Neumann # This is free software. You may redistribute copies of it under the terms of # the GNU General Public License version 2. # There is NO WARRANTY, to the extent permitted by law. @@ -97,10 +97,13 @@ 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()), diff --git a/portato/gui/exceptions.py b/portato/gui/exceptions.py index 17041dc..3e35caa 100644 --- a/portato/gui/exceptions.py +++ b/portato/gui/exceptions.py @@ -3,7 +3,7 @@ # File: portato/gui/exceptions.py # This file is part of the Portato-Project, a graphical portage-frontend. # -# Copyright (C) 2006-2009 René 'Necoro' Neumann +# Copyright (C) 2006-2010 René 'Necoro' Neumann # This is free software. You may redistribute copies of it under the terms of # the GNU General Public License version 2. # There is NO WARRANTY, to the extent permitted by law. diff --git a/portato/gui/queue.py b/portato/gui/queue.py index e73891d..b18e4e7 100644 --- a/portato/gui/queue.py +++ b/portato/gui/queue.py @@ -3,7 +3,7 @@ # File: portato/gui/queue.py # This file is part of the Portato-Project, a graphical portage-frontend. # -# Copyright (C) 2006-2009 René 'Necoro' Neumann +# Copyright (C) 2006-2010 René 'Necoro' Neumann # This is free software. You may redistribute copies of it under the terms of # the GNU General Public License version 2. # There is NO WARRANTY, to the extent permitted by law. @@ -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/session.py b/portato/gui/session.py index 7aa890d..549a2c9 100644 --- a/portato/gui/session.py +++ b/portato/gui/session.py @@ -3,7 +3,7 @@ # File: portato/gui/session.py # This file is part of the Portato-Project, a graphical portage-frontend. # -# Copyright (C) 2006-2009 René 'Necoro' Neumann +# Copyright (C) 2006-2010 René 'Necoro' Neumann # This is free software. You may redistribute copies of it under the terms of # the GNU General Public License version 2. # There is NO WARRANTY, to the extent permitted by law. diff --git a/portato/gui/slots.py b/portato/gui/slots.py index c7f20e6..75f4d77 100644 --- a/portato/gui/slots.py +++ b/portato/gui/slots.py @@ -3,7 +3,7 @@ # File: portato/gui/slots.py # This file is part of the Portato-Project, a graphical portage-frontend. # -# Copyright (C) 2006-2009 René 'Necoro' Neumann +# Copyright (C) 2006-2010 René 'Necoro' Neumann # This is free software. You may redistribute copies of it under the terms of # the GNU General Public License version 2. # There is NO WARRANTY, to the extent permitted by law. diff --git a/portato/gui/templates/AboutWindow.ui b/portato/gui/templates/AboutWindow.ui index ce612b3..5590e2b 100644 --- a/portato/gui/templates/AboutWindow.ui +++ b/portato/gui/templates/AboutWindow.ui @@ -16,7 +16,7 @@ <property name="has_separator">False</property> <property name="program_name">Portato</property> <property name="copyright">This software is licensed under the terms of the GPLv2. -Copyright (C) 2006-2009 René 'Necoro' Neumann <necoro@necoro.net></property> +Copyright (C) 2006-2010 René 'Necoro' Neumann <necoro@necoro.net></property> <property name="comments">A Portage GUI</property> <property name="website">http://portato.necoro.net</property> <property name="authors">René 'Necoro' Neumann @@ -27,6 +27,7 @@ Thanks goto: - the Sabayon-Distro for making Portato the default Portage-GUI</property> <property name="translator_credits">Catalan - Roger Calvó German - René 'Necoro' Neumann +Italian - Ponsi Polish - Tomasz Osiński Portugese (Brazilian) - Alberto Federman Neto Spanish - Daniel Halens @@ -40,6 +41,39 @@ Turkish - Gürkan 'seqizz' Gür</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"> diff --git a/portato/gui/templates/MainWindow.menu b/portato/gui/templates/MainWindow.menu index 1cce3be..e9c8f7a 100644 --- a/portato/gui/templates/MainWindow.menu +++ b/portato/gui/templates/MainWindow.menu @@ -16,7 +16,7 @@ <child> <object class="GtkAction" id="fileMenuAction"> <property name="name">fileMenuAction</property> - <property name="label" translatable="yes">_File</property> + <property name="label" translatable="yes">_General</property> </object> </child> <child> @@ -72,7 +72,7 @@ <child> <object class="GtkAction" id="updateAction"> <property name="name">updateAction</property> - <property name="label" translatable="yes">Update _World</property> + <property name="label" translatable="yes">Up_date World</property> <signal handler="cb_update_clicked" name="activate"/> </object> </child> @@ -84,6 +84,13 @@ </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> @@ -151,7 +158,7 @@ <object class="GtkAction" id="pluginsAction"> <property name="stock_id">gtk-connect</property> <property name="name">pluginsAction</property> - <property name="label" translatable="yes">_Plugins</property> + <property name="label" translatable="yes">Plu_gins</property> <signal handler="cb_plugins_clicked" name="activate"/> </object> </child> @@ -161,6 +168,7 @@ <menubar name="menubar"> <menu name="fileMenu" action="fileMenuAction"> <menuitem name="prefMenuItem" action="prefAction"/> + <menuitem name="pluginsMenuItem" action="pluginsAction"/> <menuitem name="reloadMenuItem" action="reloadAction"/> <separator/> <menuitem name="closeMenuItem" action="closeAction"/> @@ -170,6 +178,7 @@ <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"/> @@ -181,7 +190,6 @@ <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"> diff --git a/portato/gui/templates/MainWindow.ui b/portato/gui/templates/MainWindow.ui index 8e8c3b4..05e9545 100644 --- a/portato/gui/templates/MainWindow.ui +++ b/portato/gui/templates/MainWindow.ui @@ -30,6 +30,16 @@ <property name="visible">True</property> <property name="border_width">3</property> <child> + <object class="GtkComboBox" id="typeCombo"> + <property name="visible">True</property> + <signal name="changed" handler="cb_type_combo_changed"/> + </object> + <packing> + <property name="expand">False</property> + <property name="position">0</property> + </packing> + </child> + <child> <object class="GtkEntry" id="searchEntry"> <property name="visible">True</property> <signal name="changed" handler="cb_search_changed"/> @@ -38,12 +48,12 @@ </object> <packing> <property name="padding">5</property> - <property name="position">0</property> + <property name="position">1</property> </packing> </child> <child> <object class="GtkButton" id="deleteSearchButton"> - <property name="label">gtk-delete</property> + <property name="label">gtk-clear</property> <property name="visible">True</property> <property name="can_focus">True</property> <property name="receives_default">True</property> @@ -54,7 +64,7 @@ <packing> <property name="expand">False</property> <property name="padding">5</property> - <property name="position">1</property> + <property name="position">2</property> </packing> </child> <child> @@ -69,7 +79,7 @@ <packing> <property name="expand">False</property> <property name="padding">5</property> - <property name="position">2</property> + <property name="position">3</property> </packing> </child> </object> diff --git a/portato/gui/templates/UpdateWindow.ui b/portato/gui/templates/PkgListWindow.ui index ec8288e..fdcdb23 100644 --- a/portato/gui/templates/UpdateWindow.ui +++ b/portato/gui/templates/PkgListWindow.ui @@ -2,9 +2,8 @@ <interface> <requires lib="gtk+" version="2.14"/> <!-- interface-naming-policy toplevel-contextual --> - <object class="GtkWindow" id="UpdateWindow"> + <object class="GtkWindow" id="PkgListWindow"> <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property> - <property name="title" translatable="yes">Updatable Packages</property> <property name="window_position">center-on-parent</property> <property name="destroy_with_parent">True</property> <property name="urgency_hint">True</property> @@ -92,6 +91,22 @@ <property name="position">2</property> </packing> </child> + <child> + <object class="GtkButton" id="uninstallBtn"> + <property name="label" translatable="yes">_Uninstall Selected</property> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">True</property> + <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property> + <property name="use_underline">True</property> + <signal name="clicked" handler="cb_uninstall_clicked"/> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">False</property> + <property name="position">3</property> + </packing> + </child> </object> <packing> <property name="expand">False</property> diff --git a/portato/gui/templates/PreferenceWindow.ui b/portato/gui/templates/PreferenceWindow.ui index c7a00e0..d2135d0 100644 --- a/portato/gui/templates/PreferenceWindow.ui +++ b/portato/gui/templates/PreferenceWindow.ui @@ -784,8 +784,6 @@ <child> <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"> diff --git a/portato/gui/updater.py b/portato/gui/updater.py index 7ce7c51..6539913 100644 --- a/portato/gui/updater.py +++ b/portato/gui/updater.py @@ -3,7 +3,7 @@ # File: portato/gui/updater.py # This file is part of the Portato-Project, a graphical portage-frontend. # -# Copyright (C) 2006-2009 René 'Necoro' Neumann +# Copyright (C) 2006-2010 René 'Necoro' Neumann # This is free software. You may redistribute copies of it under the terms of # the GNU General Public License version 2. # There is NO WARRANTY, to the extent permitted by law. diff --git a/portato/gui/utils.py b/portato/gui/utils.py index 8b88b23..ce5971e 100644 --- a/portato/gui/utils.py +++ b/portato/gui/utils.py @@ -3,7 +3,7 @@ # File: portato/gui/utils.py # This file is part of the Portato-Project, a graphical portage-frontend. # -# Copyright (C) 2006-2009 René 'Necoro' Neumann +# Copyright (C) 2006-2010 René 'Necoro' Neumann # This is free software. You may redistribute copies of it under the terms of # the GNU General Public License version 2. # There is NO WARRANTY, to the extent permitted by law. @@ -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/views.py b/portato/gui/views.py index 3fc965f..699a832 100644 --- a/portato/gui/views.py +++ b/portato/gui/views.py @@ -3,7 +3,7 @@ # File: portato/gui/views.py # This file is part of the Portato-Project, a graphical portage-frontend. # -# Copyright (C) 2006-2009 René 'Necoro' Neumann +# Copyright (C) 2006-2010 René 'Necoro' Neumann # This is free software. You may redistribute copies of it under the terms of # the GNU General Public License version 2. # There is NO WARRANTY, to the extent permitted by law. diff --git a/portato/gui/windows/__init__.py b/portato/gui/windows/__init__.py index 6a4ac82..5be95ce 100644 --- a/portato/gui/windows/__init__.py +++ b/portato/gui/windows/__init__.py @@ -3,7 +3,7 @@ # File: portato/gui/gtk/__init__.py # This file is part of the Portato-Project, a graphical portage-frontend. # -# Copyright (C) 2006-2009 René 'Necoro' Neumann +# Copyright (C) 2006-2010 René 'Necoro' Neumann # This is free software. You may redistribute copies of it under the terms of # the GNU General Public License version 2. # There is NO WARRANTY, to the extent permitted by law. diff --git a/portato/gui/windows/about.py b/portato/gui/windows/about.py index 1b8a981..a15fd24 100644 --- a/portato/gui/windows/about.py +++ b/portato/gui/windows/about.py @@ -3,7 +3,7 @@ # File: portato/gui/windows/about.py # This file is part of the Portato-Project, a graphical portage-frontend. # -# Copyright (C) 2006-2009 René 'Necoro' Neumann +# Copyright (C) 2006-2010 René 'Necoro' Neumann # This is free software. You may redistribute copies of it under the terms of # the GNU General Public License version 2. # There is NO WARRANTY, to the extent permitted by law. @@ -15,7 +15,7 @@ from __future__ import absolute_import import gtk from .basic import AbstractDialog -from ...constants import VERSION +from ...constants import VERSION, REVISION class AboutWindow (AbstractDialog): """A window showing the "about"-informations.""" @@ -27,5 +27,11 @@ class AboutWindow (AbstractDialog): self.window.set_version(VERSION) self.window.set_logo(None) + 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 542cf7f..92c35f4 100644 --- a/portato/gui/windows/basic.py +++ b/portato/gui/windows/basic.py @@ -3,7 +3,7 @@ # File: portato/gui/windows/basic.py # This file is part of the Portato-Project, a graphical portage-frontend. # -# Copyright (C) 2006-2009 René 'Necoro' Neumann +# Copyright (C) 2006-2010 René 'Necoro' Neumann # This is free software. You may redistribute copies of it under the terms of # the GNU General Public License version 2. # There is NO WARRANTY, to the extent permitted by law. @@ -32,6 +32,7 @@ except OSError: else: getlib.textdomain(APP) getlib.bindtextdomain(APP, LOCALE_DIR) + getlib.bind_textdomain_codeset(APP, "UTF-8") # some debugging output about the current codeset used nll = getlib.nl_langinfo diff --git a/portato/gui/windows/mailinfo.py b/portato/gui/windows/mailinfo.py index 0cc79f2..0ee232a 100644 --- a/portato/gui/windows/mailinfo.py +++ b/portato/gui/windows/mailinfo.py @@ -3,7 +3,7 @@ # File: portato/gui/windows/mailinfo.py # This file is part of the Portato-Project, a graphical portage-frontend. # -# Copyright (C) 2006-2009 René 'Necoro' Neumann +# Copyright (C) 2006-2010 René 'Necoro' Neumann # This is free software. You may redistribute copies of it under the terms of # the GNU General Public License version 2. # There is NO WARRANTY, to the extent permitted by law. diff --git a/portato/gui/windows/main.py b/portato/gui/windows/main.py index 29eb728..a06756d 100644 --- a/portato/gui/windows/main.py +++ b/portato/gui/windows/main.py @@ -3,7 +3,7 @@ # File: portato/gui/windows/main.py # This file is part of the Portato-Project, a graphical portage-frontend. # -# Copyright (C) 2006-2009 René 'Necoro' Neumann +# Copyright (C) 2006-2010 René 'Necoro' Neumann # This is free software. You may redistribute copies of it under the terms of # the GNU General Public License version 2. # There is NO WARRANTY, to the extent permitted by law. @@ -29,6 +29,7 @@ from ... import get_listener from ...helper import debug, warning, error, info from ...session import Session from ...db import Database +from ...db.database import UnsupportedSearchTypeError from ...constants import CONFIG_LOCATION, VERSION, APP_ICON, ICON_DIR from ...backend.exceptions import PackageNotFoundException, BlockedException, VersionsNotFoundException @@ -50,7 +51,7 @@ from .about import AboutWindow from .plugin import PluginWindow from .preference import PreferenceWindow from .search import SearchWindow -from .update import UpdateWindow +from .pkglist import UpdateWindow, WorldListWindow class PackageTable: """A window with data about a specfic package.""" @@ -565,6 +566,10 @@ class MainWindow (Window): splash(_("Finishing startup")) + # depends on session + self.typeCombo = self.tree.get_widget("typeCombo") + self.build_type_combo() + self.window.show_all() def show_package (self, pkg = None, cpv = None, cp = None, version = None, **kwargs): @@ -884,6 +889,26 @@ class MainWindow (Window): else: # no selCatName -> so no category selected --> ignore debug("No category selected --> should be no harm.") + def build_type_combo (self): + model = gtk.ListStore(int, str) + for k,v in self.db.TYPES.iteritems(): + model.append((k,v)) + + self.typeCombo.set_model(model) + cell = gtk.CellRendererText() + self.typeCombo.pack_start(cell) + self.typeCombo.set_attributes(cell, text = 1) + + + for i, (k, v) in enumerate(model): + if k == self.db.type: break + + self.typeCombo.set_active(i) + + types = self.db.search_types() + if types == 1 or types % 2 == 0: + self.typeCombo.set_sensitive(False) + def load_session(self, sessionEx = None, defaults_only = False): """ Loads the session data. @@ -1000,6 +1025,14 @@ class MainWindow (Window): return _save + # SEARCH TYPE + def load_search_type (t): + t = int(t) + try: + self.db.type = t + except UnsupportedSearchTypeError: + info("Cannot set search type. '%s' not supported by database '%s'.", t, self.db.__class__.__name__) + # SESSION VERSION def load_session_version (version): @@ -1028,7 +1061,8 @@ class MainWindow (Window): (["width", "height"], lambda w,h: self.window.resize(int(w), int(h)), self.window.get_size), (["vpanedpos", "hpanedpos"], load_paned, save_paned), (["catsel"], load_cat_selection, save_cat_selection, ["app-portage@0"]), - (["pkgsel"], load_pkg_selection, save_pkg_selection, ["portato@0"]) + (["pkgsel"], load_pkg_selection, save_pkg_selection, ["portato@0"]), + (["searchtype"], load_search_type, lambda: self.db.type) #([("merge", "queue"), ("unmerge", "queue"), ("oneshot", "queue")], load_queue, save_queue), ]) @@ -1575,7 +1609,13 @@ class MainWindow (Window): return False # not again ;) - gobject.timeout_add(100, __update) + gobject.timeout_add(200, __update) + + def cb_type_combo_changed (self, *args): + model = self.typeCombo.get_model() + active = self.typeCombo.get_active() + + self.db.type = model[active][0] def cb_delete_search_clicked (self, *args): self.searchEntry.set_text("") @@ -1607,34 +1647,52 @@ class MainWindow (Window): PluginWindow(self.window, plugins, self.queue) return True - - def cb_show_updates_clicked (self, *args): - """ - Show the list of updateble packages. - """ - def __update(): - def cb_idle_show(packages): - """ - Callback opening the menu when the calculation is finished. + def show_package_list (self, pkg_generator, klass, thread_name = "PkgList Update Thread"): + + def cb_idle_show(packages): + """ + Callback opening the menu when the calculation is finished. - @returns: False to signal that it is finished - """ - UpdateWindow(self.window, packages, self.queue, self.jump_to) - return False - + @returns: False to signal that it is finished + """ + klass(self.window, packages, self.queue, self.jump_to) + return False + + def __update(): watch = gtk.gdk.Cursor(gtk.gdk.WATCH) self.window.window.set_cursor(watch) packages = [] try: - packages.extend(system.get_updated_packages()) + packages.extend(pkg_generator()) finally: self.window.window.set_cursor(None) gobject.idle_add(cb_idle_show, packages) - GtkThread(name="Show Updates Thread", target = __update).start() + GtkThread(name = thread_name, target = __update).start() + return True + + def cb_show_updates_clicked (self, *args): + """ + Show the list of updateble packages. + """ + + self.show_package_list( + lambda: (x.get_cpv() for x in system.get_updated_packages()), + UpdateWindow, "Show Updates Thread") + + return True + + def cb_show_world_clicked (self, *args): + """ + Show the list of world packages. + """ + self.show_package_list( + lambda: system.find_packages(pkgSet = "world", only_cpv = True), + WorldListWindow) + return True def cb_show_installed_toggled (self, *args): diff --git a/portato/gui/windows/update.py b/portato/gui/windows/pkglist.py index 8e32dd9..df3ef46 100644 --- a/portato/gui/windows/update.py +++ b/portato/gui/windows/pkglist.py @@ -1,9 +1,9 @@ # -*- 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 +# Copyright (C) 2006-2010 René 'Necoro' Neumann # This is free software. You may redistribute copies of it under the terms of # the GNU General Public License version 2. # There is NO WARRANTY, to the extent permitted by law. @@ -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/gui/windows/plugin.py b/portato/gui/windows/plugin.py index 755ad58..89d38f5 100644 --- a/portato/gui/windows/plugin.py +++ b/portato/gui/windows/plugin.py @@ -3,7 +3,7 @@ # File: portato/gui/windows/plugin.py # This file is part of the Portato-Project, a graphical portage-frontend. # -# Copyright (C) 2006-2009 René 'Necoro' Neumann +# Copyright (C) 2006-2010 René 'Necoro' Neumann # This is free software. You may redistribute copies of it under the terms of # the GNU General Public License version 2. # There is NO WARRANTY, to the extent permitted by law. diff --git a/portato/gui/windows/preference.py b/portato/gui/windows/preference.py index 4bd7551..021788c 100644 --- a/portato/gui/windows/preference.py +++ b/portato/gui/windows/preference.py @@ -3,7 +3,7 @@ # File: portato/gui/windows/preference.py # This file is part of the Portato-Project, a graphical portage-frontend. # -# Copyright (C) 2006-2009 René 'Necoro' Neumann +# Copyright (C) 2006-2010 René 'Necoro' Neumann # This is free software. You may redistribute copies of it under the terms of # the GNU General Public License version 2. # There is NO WARRANTY, to the extent permitted by law. diff --git a/portato/gui/windows/search.py b/portato/gui/windows/search.py index c531507..f9191d7 100644 --- a/portato/gui/windows/search.py +++ b/portato/gui/windows/search.py @@ -3,7 +3,7 @@ # File: portato/gui/windows/search.py # This file is part of the Portato-Project, a graphical portage-frontend. # -# Copyright (C) 2006-2009 René 'Necoro' Neumann +# Copyright (C) 2006-2010 René 'Necoro' Neumann # This is free software. You may redistribute copies of it under the terms of # the GNU General Public License version 2. # There is NO WARRANTY, to the extent permitted by law. diff --git a/portato/gui/windows/splash.py b/portato/gui/windows/splash.py index 39ba00d..2e9d5a8 100644 --- a/portato/gui/windows/splash.py +++ b/portato/gui/windows/splash.py @@ -3,7 +3,7 @@ # File: portato/gui/windows/splash.py # This file is part of the Portato-Project, a graphical portage-frontend. # -# Copyright (C) 2006-2009 René 'Necoro' Neumann +# Copyright (C) 2006-2010 René 'Necoro' Neumann # This is free software. You may redistribute copies of it under the terms of # the GNU General Public License version 2. # There is NO WARRANTY, to the extent permitted by law. @@ -40,6 +40,7 @@ class SplashScreen (Window): gtk.main_iteration() def show (self): + self.window.set_keep_above(True) self.window.show_all() self.do_iteration() @@ -47,4 +48,8 @@ class SplashScreen (Window): self.window.hide() self.do_iteration() + def destroy(self): + self.window.destroy() + self.do_iteration() + __call__ = set_descr diff --git a/portato/helper.py b/portato/helper.py index d32aa82..eb8ae2d 100644 --- a/portato/helper.py +++ b/portato/helper.py @@ -3,7 +3,7 @@ # File: portato/helper.py # This file is part of the Portato-Project, a graphical portage-frontend. # -# Copyright (C) 2006-2009 René 'Necoro' Neumann +# Copyright (C) 2006-2010 René 'Necoro' Neumann # This is free software. You may redistribute copies of it under the terms of # the GNU General Public License version 2. # There is NO WARRANTY, to the extent permitted by law. diff --git a/portato/ipc.pxd b/portato/ipc.pxd index 64ca05d..38e6d30 100644 --- a/portato/ipc.pxd +++ b/portato/ipc.pxd @@ -3,7 +3,7 @@ # File: portato/ipc.pxd # This file is part of the Portato-Project, a graphical portage-frontend. # -# Copyright (C) 2006-2009 René 'Necoro' Neumann +# Copyright (C) 2006-2010 René 'Necoro' Neumann # This is free software. You may redistribute copies of it under the terms of # the GNU General Public License version 2. # There is NO WARRANTY, to the extent permitted by law. diff --git a/portato/ipc.pyx b/portato/ipc.pyx index f3fb4af..abb26fe 100644 --- a/portato/ipc.pyx +++ b/portato/ipc.pyx @@ -3,7 +3,7 @@ # File: portato/ipc.pyx # This file is part of the Portato-Project, a graphical portage-frontend. # -# Copyright (C) 2006-2009 René 'Necoro' Neumann +# Copyright (C) 2006-2010 René 'Necoro' Neumann # This is free software. You may redistribute copies of it under the terms of # the GNU General Public License version 2. # There is NO WARRANTY, to the extent permitted by law. diff --git a/portato/listener.py b/portato/listener.py index c96b637..b3a3ba0 100644 --- a/portato/listener.py +++ b/portato/listener.py @@ -3,7 +3,7 @@ # File: portato/listener.py # This file is part of the Portato-Project, a graphical portage-frontend. # -# Copyright (C) 2006-2009 René 'Necoro' Neumann +# Copyright (C) 2006-2010 René 'Necoro' Neumann # This is free software. You may redistribute copies of it under the terms of # the GNU General Public License version 2. # There is NO WARRANTY, to the extent permitted by law. diff --git a/portato/log.py b/portato/log.py index 486aa51..b6462e9 100644 --- a/portato/log.py +++ b/portato/log.py @@ -3,7 +3,7 @@ # File: portato/log.py # This file is part of the Portato-Project, a graphical portage-frontend. # -# Copyright (C) 2006-2009 René 'Necoro' Neumann +# Copyright (C) 2006-2010 René 'Necoro' Neumann # This is free software. You may redistribute copies of it under the terms of # the GNU General Public License version 2. # There is NO WARRANTY, to the extent permitted by law. @@ -100,3 +100,13 @@ def start(file = True): def set_log_level (lvl): for h in streamhandlers: h.setLevel(lvl) + +# embed warnings in our logging functionality +import warnings +def showwarnings(msg, cat, filename, lineno, file = None, line = None): + msg = warnings.formatwarning(msg, cat, filename, lineno, line) + + record = logging.LogRecord("portatoLogger", logging.WARNING, filename, lineno, "Portage Warning: %s", (msg,), None) + logging.getLogger("portatoLogger").handle(record) + +warnings.showwarning = showwarnings diff --git a/portato/plugin.py b/portato/plugin.py index 052dcd0..ec52314 100644 --- a/portato/plugin.py +++ b/portato/plugin.py @@ -3,7 +3,7 @@ # File: portato/plugin.py # This file is part of the Portato-Project, a graphical portage-frontend. # -# Copyright (C) 2006-2009 René 'Necoro' Neumann +# Copyright (C) 2006-2010 René 'Necoro' Neumann # This is free software. You may redistribute copies of it under the terms of # the GNU General Public License version 2. # There is NO WARRANTY, to the extent permitted by law. diff --git a/portato/plugins/__init__.py b/portato/plugins/__init__.py index 22d98be..772be8c 100644 --- a/portato/plugins/__init__.py +++ b/portato/plugins/__init__.py @@ -3,7 +3,7 @@ # File: portato/plugins/__init__.py # This file is part of the Portato-Project, a graphical portage-frontend. # -# Copyright (C) 2006-2009 René 'Necoro' Neumann +# Copyright (C) 2006-2010 René 'Necoro' Neumann # This is free software. You may redistribute copies of it under the terms of # the GNU General Public License version 2. # There is NO WARRANTY, to the extent permitted by law. diff --git a/portato/session.py b/portato/session.py index 2017544..54761a2 100644 --- a/portato/session.py +++ b/portato/session.py @@ -3,7 +3,7 @@ # File: portato/session.py # This file is part of the Portato-Project, a graphical portage-frontend. # -# Copyright (C) 2006-2009 René 'Necoro' Neumann +# Copyright (C) 2006-2010 René 'Necoro' Neumann # This is free software. You may redistribute copies of it under the terms of # the GNU General Public License version 2. # There is NO WARRANTY, to the extent permitted by law. @@ -124,7 +124,7 @@ class Session (object): for options, lfn, sfn, default in self._handlers: vals = sfn() - # map into list if necessairy + # map into list if necessary if not hasattr(vals, "__iter__"): vals = [vals] debug("Saving %s with values %s", options, vals) diff --git a/portato/su.py b/portato/su.py index b87c75b..eb1f031 100644 --- a/portato/su.py +++ b/portato/su.py @@ -3,7 +3,7 @@ # File: portato/su.py # This file is part of the Portato-Project, a graphical portage-frontend. # -# Copyright (C) 2006-2009 René 'Necoro' Neumann +# Copyright (C) 2006-2010 René 'Necoro' Neumann # This is free software. You may redistribute copies of it under the terms of # the GNU General Public License version 2. # There is NO WARRANTY, to the extent permitted by law. diff --git a/portato/waiting_queue.py b/portato/waiting_queue.py index 33791a3..1e3f7ad 100644 --- a/portato/waiting_queue.py +++ b/portato/waiting_queue.py @@ -3,7 +3,7 @@ # File: portato/waiting_queue.py # This file is part of the Portato-Project, a graphical portage-frontend. # -# Copyright (C) 2006-2009 René 'Necoro' Neumann +# Copyright (C) 2006-2010 René 'Necoro' Neumann # This is free software. You may redistribute copies of it under the terms of # the GNU General Public License version 2. # There is NO WARRANTY, to the extent permitted by law. |