예제 #1
0
    def __init__(
            self,
            datadir,
            desktopdir,
            cache,
            db,
            icons,
            apps_filter=None,  # FIXME: kill this, its not needed anymore?
            apps_limit=0):
        """ init the widget, takes

        datadir - the base directory of the app-store data
        desktopdir - the dir where the applications.menu file can be found
        db - a Database object
        icons - a Gtk.IconTheme
        apps_filter - ?
        apps_limit - the maximum amount of items to display to query for
        """

        self.cache = cache
        self.db = db
        self.icons = icons
        self.properties_helper = AppPropertiesHelper(self.db, self.cache,
                                                     self.icons)
        self.section = None

        Viewport.__init__(self)
        CategoriesParser.__init__(self, db)

        self.set_name("category-view")

        # setup base widgets
        # we have our own viewport so we know when the viewport grows/shrinks
        # setup widgets

        self.vbox = Gtk.VBox()
        self.add(self.vbox)

        # atk stuff
        atk_desc = self.get_accessible()
        atk_desc.set_name(_("Departments"))

        # appstore stuff
        self.categories = []
        self.header = ""
        #~ self.apps_filter = apps_filter
        self.apps_limit = apps_limit
        # for comparing on refreshes
        self._supported_only = False

        # more stuff
        self._poster_sigs = []
        self._allocation = None

        self._cache_art_assets()
        #~ assets = self._cache_art_assets()
        #~ self.vbox.connect("draw", self.on_draw, assets)
        self._prev_alloc = None
        self.connect("size-allocate", self.on_size_allocate)
        return
예제 #2
0
    def __init__(self, db, cache, icons, show_ratings):
        Gtk.VBox.__init__(self)
        #~ self.set_name("app-view")
        # app properties helper
        self.helper = AppPropertiesHelper(db, cache, icons)
        # misc internal containers
        self.header_hbox = Gtk.HBox()
        self.header_hbox.set_border_width(StockEms.MEDIUM)
        self.pack_start(self.header_hbox, False, False, 0)
        self.tree_view_scroll = Gtk.ScrolledWindow()
        self.pack_start(self.tree_view_scroll, True, True, 0)

        # category label
        self.header_label = Gtk.Label()
        self.header_label.set_use_markup(True)
        self.header_hbox.pack_start(self.header_label, False, False, 0)

        # sort methods comboboxs
        # variant 1 includes sort by search relevance
        self.sort_methods_combobox = self._get_sort_methods_combobox()
        combo_alignment = Gtk.Alignment.new(0.5, 0.5, 1.0, 0.0)
        combo_alignment.add(self.sort_methods_combobox)
        self.header_hbox.pack_end(combo_alignment, False, False, 0)

        # content views
        self.tree_view = AppTreeView(self, db, icons, show_ratings, store=None)
        self.tree_view_scroll.add(self.tree_view)

        self.appcount = None

        self.user_defined_sort_method = False
        self._handler = self.sort_methods_combobox.connect(
            "changed", self.on_sort_method_changed)
        return
예제 #3
0
    def __init__(self,
                 datadir,
                 desktopdir,
                 cache,
                 db,
                 icons,
                 apps_filter=None,  # FIXME: kill this, its not needed anymore?
                 apps_limit=0):

        """ init the widget, takes

        datadir - the base directory of the app-store data
        desktopdir - the dir where the applications.menu file can be found
        db - a Database object
        icons - a Gtk.IconTheme
        apps_filter - ?
        apps_limit - the maximum amount of items to display to query for
        """

        self.cache = cache
        self.db = db
        self.icons = icons
        self.properties_helper = AppPropertiesHelper(
            self.db, self.cache, self.icons)
        self.section = None

        Viewport.__init__(self)
        CategoriesParser.__init__(self, db)

        self.set_name("category-view")

        # setup base widgets
        # we have our own viewport so we know when the viewport grows/shrinks
        # setup widgets

        self.vbox = Gtk.VBox()
        self.add(self.vbox)

        # atk stuff
        atk_desc = self.get_accessible()
        atk_desc.set_name(_("Departments"))

        # appstore stuff
        self.categories = []
        self.header = ""
        #~ self.apps_filter = apps_filter
        self.apps_limit = apps_limit
        # for comparing on refreshes
        self._supported_only = False

        # more stuff
        self._poster_sigs = []
        self._allocation = None

        self._cache_art_assets()
        #~ assets = self._cache_art_assets()
        #~ self.vbox.connect("draw", self.on_draw, assets)
        self._prev_alloc = None
        self.connect("size-allocate", self.on_size_allocate)
        return
예제 #4
0
파일: catview.py 프로젝트: sti-lyneos/shop
    def __init__(self,
                 cache,
                 db,
                 icons,
                 apps_filter,
                 apps_limit=0,
                 root_category=None):
        CategoriesView.__init__(self, cache, db, icons, apps_filter,
                                apps_limit)
        # state
        self._built = False
        # data
        self.root_category = root_category
        self.enquire = AppEnquire(self.cache, self.db)
        self.properties_helper = AppPropertiesHelper(self.db, self.cache,
                                                     self.icons)

        # sections
        self.current_category = None
        self.departments = None
        self.top_rated = None
        self.recommended_for_you_in_cat = None
        self.appcount = None

        # widgetry
        self.vbox.set_margin_left(StockEms.MEDIUM - 2)
        self.vbox.set_margin_right(StockEms.MEDIUM - 2)
        self.vbox.set_margin_top(StockEms.MEDIUM)
        return
예제 #5
0
파일: windows.py 프로젝트: sti-lyneos/shop
def get_test_window_recommendations(panel_type="lobby"):
    cache = get_test_pkg_info()
    db = get_test_db()
    icons = get_test_gtk3_icon_cache()
    from softwarecenter.ui.gtk3.models.appstore2 import AppPropertiesHelper
    properties_helper = AppPropertiesHelper(db, cache, icons)

    if panel_type is "lobby":
        view = recommendations.RecommendationsPanelLobby(db, properties_helper)
    elif panel_type is "category":
        cats = get_test_categories(db)
        view = recommendations.RecommendationsPanelCategory(
            db, properties_helper, cats[0])
    else:  # panel_type is "details":
        view = recommendations.RecommendationsPanelDetails(
            db, properties_helper)

    win = get_test_window(child=view, width=600, height=300)
    win.set_data("rec_panel", view)
    return win
예제 #6
0
    def _get_toprated_category_content(self):
        toprated_cat = get_category_by_name(self.categories,
                                            u"Top Rated")  # unstranslated name
        if toprated_cat is None:
            LOG.warn("No 'toprated' category found!!")
            return None, []

        enq = AppEnquire(self.cache, self.db)
        app_filter = AppFilter(self.db, self.cache)
        enq.set_query(toprated_cat.query,
                      limit=TOP_RATED_CAROUSEL_LIMIT,
                      sortmode=toprated_cat.sortmode,
                      filter=app_filter,
                      nonapps_visible=NonAppVisibility.ALWAYS_VISIBLE,
                      nonblocking_load=False)

        if not hasattr(self, "helper"):
            self.helper = AppPropertiesHelper(self.db, self.cache, self.icons)

        return toprated_cat, enq.get_documents()
예제 #7
0
    def _get_new_category_content(self):
        whatsnew_cat = get_category_by_name(
            self.categories, u"What\u2019s New")  # unstranslated name
        if whatsnew_cat is None:
            LOG.warn("No 'new' category found!!")
            return None, []

        enq = AppEnquire(self.cache, self.db)
        app_filter = AppFilter(self.db, self.cache)
        app_filter.set_available_only(True)
        app_filter.set_not_installed_only(True)
        enq.set_query(whatsnew_cat.query,
                      limit=8,
                      filter=app_filter,
                      sortmode=SortMethods.BY_CATALOGED_TIME,
                      nonapps_visible=NonAppVisibility.ALWAYS_VISIBLE,
                      nonblocking_load=False)

        if not hasattr(self, "helper"):
            self.helper = AppPropertiesHelper(self.db, self.cache, self.icons)

        return whatsnew_cat, enq.get_documents()
예제 #8
0
class CategoriesViewGtk(Viewport, CategoriesParser):

    __gsignals__ = {
        "category-selected": (GObject.SignalFlags.RUN_LAST,
                              None,
                              (GObject.TYPE_PYOBJECT, ),
                             ),

        "application-selected": (GObject.SignalFlags.RUN_LAST,
                                 None,
                                 (GObject.TYPE_PYOBJECT, ),
                                ),

        "application-activated": (GObject.SignalFlags.RUN_LAST,
                                  None,
                                  (GObject.TYPE_PYOBJECT, ),
                                 ),

        "show-category-applist": (GObject.SignalFlags.RUN_LAST,
                                  None,
                                  (),)
        }

    SPACING = PADDING = 3

    # art stuff
    STIPPLE = os.path.join(softwarecenter.paths.datadir,
                           "ui/gtk3/art/stipple.png")

    def __init__(self,
                 datadir,
                 desktopdir,
                 cache,
                 db,
                 icons,
                 apps_filter=None,  # FIXME: kill this, its not needed anymore?
                 apps_limit=0):

        """ init the widget, takes

        datadir - the base directory of the app-store data
        desktopdir - the dir where the applications.menu file can be found
        db - a Database object
        icons - a Gtk.IconTheme
        apps_filter - ?
        apps_limit - the maximum amount of items to display to query for
        """

        self.cache = cache
        self.db = db
        self.icons = icons
        self.properties_helper = AppPropertiesHelper(
            self.db, self.cache, self.icons)
        self.section = None

        Viewport.__init__(self)
        CategoriesParser.__init__(self, db)

        self.set_name("category-view")

        # setup base widgets
        # we have our own viewport so we know when the viewport grows/shrinks
        # setup widgets

        self.vbox = Gtk.VBox()
        self.add(self.vbox)

        # atk stuff
        atk_desc = self.get_accessible()
        atk_desc.set_name(_("Departments"))

        # appstore stuff
        self.categories = []
        self.header = ""
        #~ self.apps_filter = apps_filter
        self.apps_limit = apps_limit
        # for comparing on refreshes
        self._supported_only = False

        # more stuff
        self._poster_sigs = []
        self._allocation = None

        self._cache_art_assets()
        #~ assets = self._cache_art_assets()
        #~ self.vbox.connect("draw", self.on_draw, assets)
        self._prev_alloc = None
        self.connect("size-allocate", self.on_size_allocate)
        return

    def _add_tiles_to_flowgrid(self, docs, flowgrid, amount):
        '''Adds application tiles to a FlowableGrid:
           docs = xapian documents (apps)
           flowgrid = the FlowableGrid to add tiles to
           amount = number of tiles to add from start of doc range'''
        amount = min(len(docs), amount)
        for doc in docs[0:amount]:
            tile = FeaturedTile(self.properties_helper, doc)
            tile.connect('clicked', self.on_app_clicked,
                         self.properties_helper.get_application(doc))
            flowgrid.add_child(tile)
        return

    def on_size_allocate(self, widget, _):
        a = widget.get_allocation()
        prev = self._prev_alloc
        if prev is None or a.width != prev.width or a.height != prev.height:
            self._prev_alloc = a
            self.queue_draw()
        return

    def _cache_art_assets(self):
        global _asset_cache
        if _asset_cache:
            return _asset_cache
        assets = _asset_cache
        # cache the bg pattern
        surf = cairo.ImageSurface.create_from_png(self.STIPPLE)
        ptrn = cairo.SurfacePattern(surf)
        ptrn.set_extend(cairo.EXTEND_REPEAT)
        assets["stipple"] = ptrn
        return assets

    def on_app_clicked(self, btn, app):
        """emit the category-selected signal when a category was clicked"""
        def timeout_emit():
            self.emit("application-selected", app)
            self.emit("application-activated", app)
            return False

        GObject.timeout_add(50, timeout_emit)

    def on_category_clicked(self, btn, cat):
        """emit the category-selected signal when a category was clicked"""
        def timeout_emit():
            self.emit("category-selected", cat)
            return False

        GObject.timeout_add(50, timeout_emit)

    def build(self, desktopdir):
        pass

    def do_draw(self, cr):
        cr.set_source(_asset_cache["stipple"])
        cr.paint_with_alpha(0.5)
        for child in self:
            self.propagate_draw(child, cr)

    def set_section(self, section):
        self.section = section

    def refresh_apps(self):
        raise NotImplementedError
예제 #9
0
class CategoriesViewGtk(Viewport, CategoriesParser):

    __gsignals__ = {
        "category-selected": (
            GObject.SignalFlags.RUN_LAST,
            None,
            (GObject.TYPE_PYOBJECT, ),
        ),
        "application-selected": (
            GObject.SignalFlags.RUN_LAST,
            None,
            (GObject.TYPE_PYOBJECT, ),
        ),
        "application-activated": (
            GObject.SignalFlags.RUN_LAST,
            None,
            (GObject.TYPE_PYOBJECT, ),
        ),
        "show-category-applist": (
            GObject.SignalFlags.RUN_LAST,
            None,
            (),
        )
    }

    SPACING = PADDING = 3

    # art stuff
    STIPPLE = os.path.join(softwarecenter.paths.datadir,
                           "ui/gtk3/art/stipple.png")

    def __init__(
            self,
            datadir,
            desktopdir,
            cache,
            db,
            icons,
            apps_filter=None,  # FIXME: kill this, its not needed anymore?
            apps_limit=0):
        """ init the widget, takes

        datadir - the base directory of the app-store data
        desktopdir - the dir where the applications.menu file can be found
        db - a Database object
        icons - a Gtk.IconTheme
        apps_filter - ?
        apps_limit - the maximum amount of items to display to query for
        """

        self.cache = cache
        self.db = db
        self.icons = icons
        self.properties_helper = AppPropertiesHelper(self.db, self.cache,
                                                     self.icons)
        self.section = None

        Viewport.__init__(self)
        CategoriesParser.__init__(self, db)

        self.set_name("category-view")

        # setup base widgets
        # we have our own viewport so we know when the viewport grows/shrinks
        # setup widgets

        self.vbox = Gtk.VBox()
        self.add(self.vbox)

        # atk stuff
        atk_desc = self.get_accessible()
        atk_desc.set_name(_("Departments"))

        # appstore stuff
        self.categories = []
        self.header = ""
        #~ self.apps_filter = apps_filter
        self.apps_limit = apps_limit
        # for comparing on refreshes
        self._supported_only = False

        # more stuff
        self._poster_sigs = []
        self._allocation = None

        self._cache_art_assets()
        #~ assets = self._cache_art_assets()
        #~ self.vbox.connect("draw", self.on_draw, assets)
        self._prev_alloc = None
        self.connect("size-allocate", self.on_size_allocate)
        return

    def _add_tiles_to_flowgrid(self, docs, flowgrid, amount):
        '''Adds application tiles to a FlowableGrid:
           docs = xapian documents (apps)
           flowgrid = the FlowableGrid to add tiles to
           amount = number of tiles to add from start of doc range'''
        amount = min(len(docs), amount)
        for doc in docs[0:amount]:
            tile = FeaturedTile(self.properties_helper, doc)
            tile.connect('clicked', self.on_app_clicked,
                         self.properties_helper.get_application(doc))
            flowgrid.add_child(tile)
        return

    def on_size_allocate(self, widget, _):
        a = widget.get_allocation()
        prev = self._prev_alloc
        if prev is None or a.width != prev.width or a.height != prev.height:
            self._prev_alloc = a
            self.queue_draw()
        return

    def _cache_art_assets(self):
        global _asset_cache
        if _asset_cache:
            return _asset_cache
        assets = _asset_cache
        # cache the bg pattern
        surf = cairo.ImageSurface.create_from_png(self.STIPPLE)
        ptrn = cairo.SurfacePattern(surf)
        ptrn.set_extend(cairo.EXTEND_REPEAT)
        assets["stipple"] = ptrn
        return assets

    def on_app_clicked(self, btn, app):
        """emit the category-selected signal when a category was clicked"""
        def timeout_emit():
            self.emit("application-selected", app)
            self.emit("application-activated", app)
            return False

        GObject.timeout_add(50, timeout_emit)

    def on_category_clicked(self, btn, cat):
        """emit the category-selected signal when a category was clicked"""
        def timeout_emit():
            self.emit("category-selected", cat)
            return False

        GObject.timeout_add(50, timeout_emit)

    def build(self, desktopdir):
        pass

    def do_draw(self, cr):
        cr.set_source(_asset_cache["stipple"])
        cr.paint_with_alpha(0.5)
        for child in self:
            self.propagate_draw(child, cr)

    def set_section(self, section):
        self.section = section

    def refresh_apps(self):
        raise NotImplementedError