31
31
from softwarecenter.utils import ExecutionTime, SimpleFileDownloader, split_icon_ext
32
32
from softwarecenter.backend import get_install_backend
33
33
from softwarecenter.backend.reviews import get_review_loader
34
from softwarecenter.db.database import Application
35
34
from softwarecenter.paths import SOFTWARE_CENTER_ICON_CACHE_DIR
37
36
import softwarecenter.paths
77
class _AppPropertiesHelper(GObject.GObject):
76
class AppPropertiesHelper(GObject.GObject):
78
77
""" Baseclass that contains common functions for our
79
78
liststore/treestore, only useful for subclassing
88
def __init__(self, db, cache, icons, icon_size=48, global_icon_cache=False):
90
89
GObject.GObject.__init__(self)
94
cat_parser = CategoriesParser(db)
95
self.all_categories = cat_parser.parse_applications_menu(
96
softwarecenter.paths.APP_INSTALL_PATH)
98
# reviews stats loader
99
self.review_loader = get_review_loader(cache, db)
103
self.icon_size = icon_size
105
# cache the 'missing icon' used in the treeview for apps without an icon
106
self._missing_icon = icons.load_icon(Icons.MISSING_APP, icon_size, 0)
107
if global_icon_cache:
108
self.icon_cache = _app_icon_cache
92
113
def _download_icon_and_show_when_ready(self, url, pkgname, icon_file_name):
93
114
LOG.debug("did not find the icon locally, must download %s" % icon_file_name)
138
159
return self.db.get_pkgname(doc)
140
161
def get_application(self, doc):
141
appname = doc.get_value(XapianValues.APPNAME)
142
pkgname = self.db.get_pkgname(doc)
144
return Application(appname, pkgname, "")
162
return self.db.get_application(doc)
146
164
def get_appname(self, doc):
147
appname = doc.get_value(XapianValues.APPNAME)
149
appname = self.db.get_summary(doc)
151
if self.db.is_appname_duplicated(appname):
152
appname = "%s (%s)" % (appname, self.get_pkgname(doc))
165
app = self.db.get_application(doc)
166
return app.get_display_name(self.db, doc)
155
168
def get_markup(self, doc):
156
appname = doc.get_value(XapianValues.APPNAME)
169
app = self.db.get_application(doc)
171
# the logic is that "apps" are displayed normally
172
# but "packages" are displayed with their summary as name
174
appname = self.get_appname(doc)
175
summary = self.db.get_summary(doc)
159
177
appname = self.db.get_summary(doc)
160
178
summary = self.get_pkgname(doc)
162
if self.db.is_appname_duplicated(appname):
163
appname = "%s (%s)" % (appname, self.get_pkgname(doc))
165
summary = self.db.get_summary(doc)
167
180
return "%s\n<small>%s</small>" % (
168
181
GObject.markup_escape_text(appname),
242
class AppPropertiesHelper(_AppPropertiesHelper):
244
def __init__(self, db, cache, icons, icon_size=48, global_icon_cache=False):
245
super(AppPropertiesHelper, self).__init__()
249
cat_parser = CategoriesParser(db)
250
self.all_categories = cat_parser.parse_applications_menu(
251
softwarecenter.paths.APP_INSTALL_PATH)
253
# reviews stats loader
254
self.review_loader = get_review_loader(cache, db)
258
self.icon_size = icon_size
259
# cache the 'missing icon' used in the treeview for apps without an icon
260
self._missing_icon = icons.load_icon(Icons.MISSING_APP,
263
if global_icon_cache:
264
self.icon_cache = _app_icon_cache
269
255
def get_icon_at_size(self, doc, width, height):
270
256
pixbuf = self.get_icon(doc)
271
257
pixbuf = pixbuf.scale_simple(width, height,
272
258
GdkPixbuf.InterpType.BILINEAR)
275
def get_transaction_progress(self, doc):
279
class AppGenericStore(_AppPropertiesHelper):
262
class AppGenericStore(AppPropertiesHelper):
282
265
COL_TYPES = (GObject.TYPE_PYOBJECT,)
291
274
LOAD_INITIAL = 75
293
276
def __init__(self, db, cache, icons, icon_size, global_icon_cache):
298
# reviews stats loader
299
self.review_loader = get_review_loader(cache, db)
277
AppPropertiesHelper.__init__(self, db, cache, icons, icon_size,
302
281
self.backend = get_install_backend()
307
286
# keep track of paths for transactions in progress
308
287
self.transaction_path_map = {}
312
self.icon_size = icon_size
314
if global_icon_cache:
315
self.icon_cache = _app_icon_cache
319
289
# active row path
320
290
self.active_row = None
322
# cache the 'missing icon' used in the treeview for apps without an icon
323
self._missing_icon = icons.load_icon(Icons.MISSING_APP, icon_size, 0)
325
292
self._in_progress = False
326
293
self._break = False
396
363
GObject.idle_add(buffer_icons)
366
def load_range(self, indices, step):
399
370
class AppListStore(Gtk.ListStore, AppGenericStore):
400
371
""" use for flat applist views. for large lists this appends rows approx
401
372
three times faster than the AppTreeStore equivalent