From 4150fa8856e8992c30885877f558fa9a5a76630d Mon Sep 17 00:00:00 2001 From: Fabio Erculiani Date: Mon, 13 Feb 2012 16:49:45 +0100 Subject: [PATCH] [rigo] implement more methods in AppListStore --- rigo/rigo/models/application.py | 13 +++++++++++++ rigo/rigo_app.py | 23 ++++++++++++++++++----- 2 files changed, 31 insertions(+), 5 deletions(-) diff --git a/rigo/rigo/models/application.py b/rigo/rigo/models/application.py index 9b803643a..195e22e15 100644 --- a/rigo/rigo/models/application.py +++ b/rigo/rigo/models/application.py @@ -504,6 +504,9 @@ class Application(object): return name.capitalize() def is_installed(self): + """ + Return if Application is currently installed. + """ inst_repo = self._entropy.installed_repository() repo = self._entropy.open_repository(self._repo_id) if repo is inst_repo: @@ -517,6 +520,16 @@ class Application(object): return True return False + def is_available(self): + """ + Return if Application is actually available in repos, + for cache reasons? + The actual semantics of this method in softwarecenter + seems quite ambiguous to me. + """ + repo = self._entropy.open_repository(self._repo_id) + return repo.isPackageIdAvailable(self._pkg_id) + def get_markup(self): repo = self._entropy.open_repository(self._repo_id) name = repo.retrieveName(self._pkg_id) diff --git a/rigo/rigo_app.py b/rigo/rigo_app.py index 0d86f4053..1e7835398 100644 --- a/rigo/rigo_app.py +++ b/rigo/rigo_app.py @@ -192,9 +192,6 @@ class AppListStore(Gtk.ListStore): if not os.path.isfile(icon_path): return self._missing_icon - # FIXME, parallelize this? - # get current image size - # expensive? img = Gtk.Image() img.set_from_file(icon_path) img_buf = img.get_pixbuf() @@ -228,6 +225,11 @@ class AppListStore(Gtk.ListStore): redraw_callback=self._ui_redraw_callback) return app.is_installed() + def is_available(self, pkg_match): + app = Application(self._entropy, self._entropy_ws, pkg_match, + redraw_callback=self._ui_redraw_callback) + return app.is_available() + def get_markup(self, pkg_match): app = Application(self._entropy, self._entropy_ws, pkg_match, redraw_callback=self._ui_redraw_callback) @@ -238,6 +240,11 @@ class AppListStore(Gtk.ListStore): redraw_callback=self._ui_redraw_callback) return app.get_review_stats() + def get_application(self, pkg_match): + app = Application(self._entropy, self._entropy_ws, pkg_match, + redraw_callback=self._ui_redraw_callback) + return app + def get_transaction_progress(self, pkg_match): # TODO: complete # int from 0 - 100, or -1 for no transaction @@ -404,7 +411,12 @@ class Rigo(Gtk.Application): class RigoHandler: def onDeleteWindow(self, *args): - Gtk.main_quit(*args) + while True: + try: + Gtk.main_quit(*args) + except KeyboardInterrupt: + continue + break def __init__(self): self._builder = Gtk.Builder() @@ -416,7 +428,8 @@ class Rigo(Gtk.Application): self._scrolled_view = self._builder.get_object("scrolledView") self._static_view = self._builder.get_object("staticViewVbox") icons = get_sc_icon_theme(DATA_DIR) - self._view = AppTreeView(self._app_vbox, icons, True, store=None) + self._view = AppTreeView(self._app_vbox, icons, True, + AppListStore.ICON_SIZE, store=None) self._scrolled_view.add(self._view) self._notification = self._builder.get_object("notificationBox")