Beispiel #1
0
    def refresh_apps(self):
        supported_only = get_global_filter().supported_only
        if (self._supported_only == supported_only):
            return
        self._supported_only = supported_only

        self._update_toprated_content()
        self._update_new_content()
        self._update_appcount()
        return
Beispiel #2
0
    def refresh_apps(self):
        supported_only = get_global_filter().supported_only
        if (self._supported_only == supported_only):
            return
        self._supported_only = supported_only

        self._update_top_rated_content()
        self._update_whats_new_content()
        self._update_recommended_for_you_content()
        self._update_appcount()
        return
Beispiel #3
0
    def refresh_apps(self):
        supported_only = get_global_filter().supported_only
        if (self.current_category is None or
            self._supported_only == supported_only):
            return
        self._supported_only = supported_only

        if not self._built: self._build_subcat_view()
        self._update_subcat_view(self.current_category)
        GObject.idle_add(self.queue_draw)
        return
Beispiel #4
0
    def _update_appcount(self):
        enq = AppEnquire(self.cache, self.db)

        distro = get_distro()
        if get_global_filter().supported_only:
            query = distro.get_supported_query()
        else:
            query = xapian.Query('')

        length = enq.get_estimated_matches_count(query)
        text = gettext.ngettext("%(amount)s item", "%(amount)s items", length
                                ) % {'amount': length}
        self.appcount.set_text(text)
Beispiel #5
0
    def _update_appcount(self):
        enq = AppEnquire(self.cache, self.db)

        distro = get_distro()
        if get_global_filter().supported_only:
            query = distro.get_supported_query()
        else:
            query = xapian.Query('')

        length = enq.get_estimated_matches_count(query)
        text = gettext.ngettext("%(amount)s item", "%(amount)s items", length
                                ) % {'amount': length}
        self.appcount.set_text(text)
Beispiel #6
0
    def _update_subcat_departments(self, category, num_items):
        self.departments.remove_all()

        # set the subcat header
        m = "<b><big>%s</big></b>"
        self.subcat_label.set_markup(m % GLib.markup_escape_text(
            self.header))

        # sort Category.name's alphabetically
        sorted_cats = categories_sorted_by_name(self.categories)
        enquire = xapian.Enquire(self.db.xapiandb)
        app_filter = AppFilter(self.db, self.cache)
        distro = get_distro()
        supported_only = get_global_filter().supported_only
        for cat in sorted_cats:
            # add the subcategory if and only if it is non-empty
            if supported_only:
                enquire.set_query(xapian.Query(xapian.Query.OP_AND,
                                    cat.query,
                                    distro.get_supported_query()))
            else:
                enquire.set_query(cat.query)
            if len(enquire.get_mset(0, 1)):
                tile = CategoryTile(cat.name, cat.iconname)
                tile.connect('clicked', self.on_category_clicked, cat)
                self.departments.add_child(tile)

        # partially work around a (quite rare) corner case
        if num_items == 0:
            enquire.set_query(xapian.Query(xapian.Query.OP_AND,
                                category.query,
                                xapian.Query("ATapplication")))
            # assuming that we only want apps is not always correct ^^^
            tmp_matches = enquire.get_mset(0, len(self.db), None, app_filter)
            num_items = tmp_matches.get_matches_estimated()

        # append an additional button to show all of the items in the category
        all_cat = Category("All", _("All"), "category-show-all",
            category.query)
        name = GLib.markup_escape_text('%s %s' % (_("All"), num_items))
        tile = CategoryTile(name, "category-show-all")
        tile.connect('clicked', self.on_category_clicked, all_cat)
        self.departments.add_child(tile)
        self.departments.queue_draw()
        return num_items
Beispiel #7
0
    def _update_appcount(self):
        enq = AppEnquire(self.cache, self.db)

        distro = get_distro()
        if get_global_filter().supported_only:
            query = distro.get_supported_query()
        else:
            query = xapian.Query('')

        enq.set_query(query,
                      limit=0,
                      nonapps_visible=NonAppVisibility.ALWAYS_VISIBLE,
                      nonblocking_load=True)

        length = len(enq.matches)
        text = gettext.ngettext("%(amount)s item", "%(amount)s items", length
                                ) % { 'amount' : length, }
        self.appcount.set_text(text)
Beispiel #8
0
    def _update_subcat_departments(self, category, num_items):
        self.departments.remove_all()

        # set the subcat header
        m = "<b><big>%s</big></b>"
        self.subcat_label.set_markup(m % GLib.markup_escape_text(self.header))

        # sort Category.name's alphabetically
        sorted_cats = categories_sorted_by_name(self.categories)
        enquire = xapian.Enquire(self.db.xapiandb)
        app_filter = AppFilter(self.db, self.cache)
        distro = get_distro()
        supported_only = get_global_filter().supported_only
        for cat in sorted_cats:
            # add the subcategory if and only if it is non-empty
            if supported_only:
                enquire.set_query(
                    xapian.Query(xapian.Query.OP_AND, cat.query,
                                 distro.get_supported_query()))
            else:
                enquire.set_query(cat.query)
            if len(enquire.get_mset(0, 1)):
                tile = CategoryTile(cat.name, cat.iconname)
                tile.connect('clicked', self.on_category_clicked, cat)
                self.departments.add_child(tile)

        # partially work around a (quite rare) corner case
        if num_items == 0:
            enquire.set_query(
                xapian.Query(xapian.Query.OP_AND, category.query,
                             xapian.Query("ATapplication")))
            # assuming that we only want apps is not always correct ^^^
            tmp_matches = enquire.get_mset(0, len(self.db), None, app_filter)
            num_items = tmp_matches.get_matches_estimated()

        # append an additional button to show all of the items in the category
        all_cat = Category("All", _("All"), "category-show-all",
                           category.query)
        name = GLib.markup_escape_text('%s %s' % (_("All"), num_items))
        tile = CategoryTile(name, "category-show-all")
        tile.connect('clicked', self.on_category_clicked, all_cat)
        self.departments.add_child(tile)
        self.departments.queue_draw()
        return num_items
Beispiel #9
0
    def _update_appcount(self):
        enq = AppEnquire(self.cache, self.db)

        distro = get_distro()
        if get_global_filter().supported_only:
            query = distro.get_supported_query()
        else:
            query = xapian.Query('')

        enq.set_query(query,
                      limit=0,
                      nonapps_visible=NonAppVisibility.ALWAYS_VISIBLE,
                      nonblocking_load=True)

        length = len(enq.matches)
        text = gettext.ngettext("%(amount)s item", "%(amount)s items",
                                length) % {
                                    'amount': length,
                                }
        self.appcount.set_text(text)