[rigo] implement more methods in AppListStore

This commit is contained in:
Fabio Erculiani
2012-02-13 16:49:45 +01:00
parent d16a384519
commit 4150fa8856
2 changed files with 31 additions and 5 deletions

View File

@@ -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)

View File

@@ -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")