diff options
Diffstat (limited to 'portato')
-rw-r--r-- | portato/db/database.py | 5 | ||||
-rw-r--r-- | portato/gui/windows/main.py | 18 |
2 files changed, 17 insertions, 6 deletions
diff --git a/portato/db/database.py b/portato/db/database.py index 8e10a40..c4ab680 100644 --- a/portato/db/database.py +++ b/portato/db/database.py @@ -14,7 +14,7 @@ from __future__ import absolute_import, with_statement from threading import RLock from functools import wraps -from ..helper import error +from ..helper import warning class UnsupportedSearchTypeError(Exception): pass @@ -74,8 +74,7 @@ class Database (object): raise NotImplentedError def set_type (self, type): - if type & self.search_types() == 0: - error("Search type %s not supported by database '%s'.", type, self.__class__.__name__) + if type & self.search_types() != type: raise UnsupportedSearchTypeError, type self._type = type diff --git a/portato/gui/windows/main.py b/portato/gui/windows/main.py index 4a9971f..a29664a 100644 --- a/portato/gui/windows/main.py +++ b/portato/gui/windows/main.py @@ -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 from ...backend.exceptions import PackageNotFoundException, BlockedException, VersionsNotFoundException @@ -496,8 +497,6 @@ class MainWindow (Window): # search entry self.searchEntry = self.tree.get_widget("searchEntry") - self.typeCombo = self.tree.get_widget("typeCombo") - self.build_type_combo() # queue list self.queueOneshot = self.tree.get_widget("oneshotCB") @@ -558,6 +557,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): @@ -1009,6 +1012,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): @@ -1037,7 +1048,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), ]) |