175
175
self.whatsnew_carousel = None
176
176
self.departments = None
178
# this means that the departments don't jump down once the cache loads
179
# it doesn't look odd if the recommends are never loaded
180
self.recommended = gtk.Label()
181
self.vbox.pack_start(self.recommended, False, False)
178
183
self.build(desktopdir)
275
280
@wait_for_apt_cache_ready
276
281
def _append_recommendations(self):
277
282
""" get recommendations from zeitgeist and add to the view """
279
def _show_recommended_apps_widget(query, r_apps):
280
recommended = gtk.Label()
281
recommended_text = gettext.ngettext(
283
# FIXME: the whole process of finding mimetypes, querying db etc seems
284
# to be a bit duplicated
286
def _show_recommended_apps_widget(query):
287
# determine correctly how many apps will be shown
288
enquire = xapian.Enquire(self.db.xapiandb)
289
enquire.set_query(query)
290
tmp_matches = enquire.get_mset(0, len(self.db), None, self.apps_filter)
291
nr_apps = tmp_matches.get_matches_estimated()
294
text = gettext.ngettext(
282
295
"Welcome back! There is <a href=\"\">%i new recommendation</a>"
283
" for you." % len(r_apps),
296
" for you." % nr_apps,
284
297
"Welcome back! There are <a href=\"\">%i new recommendations</a>"
285
" for you." % len(r_apps),
287
recommended.set_markup(recommended_text)
288
recommended.set_visible(True)
289
recommended.get_accessible().set_role(atk.ROLE_PUSH_BUTTON)
290
recommended.set_alignment(0,-1)
291
self.vbox.pack_start(recommended, False, False)
292
self.vbox.reorder_child(recommended, 0)
298
" for you." % nr_apps,
300
self.recommended.set_markup(text)
301
self.recommended.get_accessible().set_role(atk.ROLE_PUSH_BUTTON)
302
self.recommended.set_alignment(0,-1)
295
305
rec_cat = Category("Recommendations",
297
307
"category-recommendations",
299
309
sortmode=SORT_BY_SEARCH_RANKING)
300
recommended.connect('activate-link',
301
self._on_recommended_clicked,
310
self.recommended.connect('activate-link',
311
self._on_recommended_clicked,
304
314
def _popular_mimetypes_callback(mimetypes):
305
315
def _find_applications(mimetypes):
319
329
results.append("AP"+app.pkgname)
322
def _make_query(r_apps):
324
return xapian.Query(xapian.Query.OP_OR, r_apps)
326
332
# get the recommended apps
327
333
r_apps =_find_applications(mimetypes)
330
_show_recommended_apps_widget(_make_query(r_apps), r_apps)
335
_show_recommended_apps_widget(xapian.Query(xapian.Query.OP_OR, r_apps))
332
337
zeitgeist_singleton.get_popular_mimetypes(_popular_mimetypes_callback)
536
541
for cat in sorted_cats:
537
cat_btn = SubcategoryButton(cat.name, cat.iconname)
538
cat_btn.connect('clicked', self._on_category_clicked, cat)
539
buttons.append(cat_btn)
542
# add the subcategory if and only if it is non-empty
543
enquire = xapian.Enquire(self.db.xapiandb)
544
enquire.set_query(cat.query)
545
if len(enquire.get_mset(0, 1, None, self.apps_filter)):
546
cat_btn = SubcategoryButton(cat.name, cat.iconname)
547
cat_btn.connect('clicked', self._on_category_clicked, cat)
548
buttons.append(cat_btn)
550
# partialy work around a (quite rare) corner case
552
enquire = xapian.Enquire(self.db.xapiandb)
553
enquire.set_query(xapian.Query(xapian.Query.OP_AND,
555
xapian.Query("ATapplication")))
556
# assuming that we only want apps is not always correct ^^^
557
tmp_matches = enquire.get_mset(0, len(self.db), None, self.apps_filter)
558
num_items = tmp_matches.get_matches_estimated()
541
560
# append an additional button to show all of the items in the category
542
561
name = gobject.markup_escape_text('%s %s' % (_("All"), num_items))
560
579
def set_subcategory(self, root_category, num_items=0, block=False):
580
self.current_category = root_category
562
582
if self.categories == root_category.subcategories: