Beispiel #1
0
def get_test_window_appview():
    db = get_test_db()
    cache = get_test_pkg_info()
    icons = get_test_gtk3_icon_cache()

    # create a filter
    app_filter = appfilter.AppFilter(db, cache)
    app_filter.set_supported_only(False)
    app_filter.set_installed_only(True)

    # appview
    enquirer = enquire.AppEnquire(cache, db)
    store = appstore2.AppListStore(db, cache, icons)

    view = appview.AppView(db, cache, icons, show_ratings=True)
    view.set_model(store)

    entry = Gtk.Entry()
    entry.stamp = 0
    entry.connect("changed", on_entry_changed, (view, enquirer))
    entry.set_text("gtk3")

    box = Gtk.VBox()
    box.pack_start(entry, False, True, 0)
    box.pack_start(view, True, True, 0)

    win = get_test_window(child=box)
    win.set_data("appview", view)
    win.set_data("entry", entry)

    return win
Beispiel #2
0
def get_test_window_apptreeview():
    cache = get_test_pkg_info()
    db = get_test_db()
    icons = get_test_gtk3_icon_cache()

    # create a filter
    app_filter = appfilter.AppFilter(db, cache)
    app_filter.set_supported_only(False)
    app_filter.set_installed_only(True)

    # get the TREEstore
    store = appstore2.AppTreeStore(db, cache, icons)

    # populate from data
    cats = get_test_categories(db)
    for cat in cats[:3]:
        with ExecutionTime("query cat '%s'" % cat.name):
            docs = db.get_docs_from_query(cat.query)
            store.set_category_documents(cat, docs)

    # ok, this is confusing - the AppView contains the AppTreeView that
    #                         is a tree or list depending on the model
    app_view = appview.AppView(db, cache, icons, show_ratings=True)
    app_view.set_model(store)

    box = Gtk.VBox()
    box.pack_start(app_view, True, True, 0)

    win = get_test_window(child=box)
    return win
Beispiel #3
0
def get_test_window_catview(db=None, selected_category="Internet"):
    ''' 
        Note that selected_category must specify a category that includes
        subcategories, else a ValueError will be raised.
    '''
    def on_category_selected(view, cat):
        print("on_category_selected view: ", view)
        print("on_category_selected cat: ", cat)

    if db is None:
        cache = pkginfo.get_pkg_info()
        cache.open()

        xapian_base_path = "/var/cache/software-center"
        pathname = os.path.join(xapian_base_path, "xapian")
        db = database.StoreDatabase(pathname, cache)
        db.open()
    else:
        cache = db._aptcache

    icons = get_sc_icon_theme()
    distro = softwarecenter.distro.get_distro()
    apps_filter = appfilter.AppFilter(db, cache)

    # gui
    notebook = Gtk.Notebook()

    lobby_view = lobbyview.LobbyView(cache, db, icons, distro, apps_filter)

    scroll = Gtk.ScrolledWindow()
    scroll.add(lobby_view)
    notebook.append_page(scroll, Gtk.Label.new("Lobby"))

    subcat_cat = None
    for cat in lobby_view.categories:
        if cat.name == selected_category:
            if not cat.subcategories:
                raise ValueError('The value specified for selected_category '
                                 '*must* specify a '
                                 'category that contains subcategories!!')
            subcat_cat = cat
            break

    subcat_view = catview.SubCategoryView(cache, db, icons, apps_filter)
    subcat_view.connect("category-selected", on_category_selected)
    subcat_view.set_subcategory(subcat_cat)

    scroll = Gtk.ScrolledWindow()
    scroll.add(subcat_view)
    notebook.append_page(scroll, Gtk.Label.new("Subcats"))

    win = get_test_window(child=notebook, width=800, height=800)
    win.set_data("subcat", subcat_view)
    win.set_data("lobby", lobby_view)
    return win
Beispiel #4
0
def get_test_catview():
    def on_category_selected(view, cat):
        print("on_category_selected %s %s" % (view, cat))

    cache = pkginfo.get_pkg_info()
    cache.open()

    xapian_base_path = "/var/cache/software-center"
    pathname = os.path.join(xapian_base_path, "xapian")
    db = database.StoreDatabase(pathname, cache)
    db.open()

    icons = get_sc_icon_theme()
    distro = softwarecenter.distro.get_distro()
    apps_filter = appfilter.AppFilter(db, cache)

    cat_view = lobbyview.LobbyView(cache, db, icons, distro, apps_filter)

    return cat_view