def get_test_window_pkgnamesview(): from softwarecenter.db.pkginfo import get_pkg_info cache = get_pkg_info() cache.open() from softwarecenter.db.database import StoreDatabase xapian_base_path = "/var/cache/software-center" pathname = os.path.join(xapian_base_path, "xapian") db = StoreDatabase(pathname, cache) db.open() import softwarecenter.paths datadir = softwarecenter.paths.datadir from softwarecenter.ui.gtk3.utils import get_sc_icon_theme icons = get_sc_icon_theme(datadir) pkgs = ["apt", "software-center"] view = PackageNamesView("header", cache, pkgs, icons, 32, db) view.show() win = Gtk.Window() win.add(view) win.set_size_request(600, 400) win.show() win.connect('destroy', Gtk.main_quit) return win
def get_test_catview(): def on_category_selected(view, cat): print("on_category_selected %s %s" % view, cat) from softwarecenter.db.pkginfo import get_pkg_info cache = get_pkg_info() cache.open() from softwarecenter.db.database import StoreDatabase xapian_base_path = "/var/cache/software-center" pathname = os.path.join(xapian_base_path, "xapian") db = StoreDatabase(pathname, cache) db.open() import softwarecenter.paths datadir = softwarecenter.paths.datadir from softwarecenter.ui.gtk3.utils import get_sc_icon_theme icons = get_sc_icon_theme(datadir) import softwarecenter.distro distro = softwarecenter.distro.get_distro() apps_filter = AppFilter(db, cache) from softwarecenter.paths import APP_INSTALL_PATH cat_view = LobbyViewGtk(datadir, APP_INSTALL_PATH, cache, db, icons, distro, apps_filter) return cat_view
def get_test_window_catview(): def on_category_selected(view, cat): print("on_category_selected %s %s" % view, cat) from softwarecenter.db.pkginfo import get_pkg_info cache = get_pkg_info() cache.open() from softwarecenter.db.database import StoreDatabase xapian_base_path = "/var/cache/software-center" pathname = os.path.join(xapian_base_path, "xapian") db = StoreDatabase(pathname, cache) db.open() import softwarecenter.paths datadir = softwarecenter.paths.datadir from softwarecenter.ui.gtk3.utils import get_sc_icon_theme icons = get_sc_icon_theme(datadir) import softwarecenter.distro distro = softwarecenter.distro.get_distro() apps_filter = AppFilter(db, cache) # gui win = Gtk.Window() n = Gtk.Notebook() from softwarecenter.paths import APP_INSTALL_PATH view = LobbyViewGtk(datadir, APP_INSTALL_PATH, cache, db, icons, distro, apps_filter) win.set_data("lobby", view) scroll = Gtk.ScrolledWindow() scroll.add(view) n.append_page(scroll, Gtk.Label(label="Lobby")) # find a cat in the LobbyView that has subcategories subcat_cat = None for cat in reversed(view.categories): if cat.subcategories: subcat_cat = cat break view = SubCategoryViewGtk(datadir, APP_INSTALL_PATH, cache, db, icons, apps_filter) view.connect("category-selected", on_category_selected) view.set_subcategory(subcat_cat) win.set_data("subcat", view) scroll = Gtk.ScrolledWindow() scroll.add(view) n.append_page(scroll, Gtk.Label(label="Subcats")) win.add(n) win.set_size_request(800, 600) win.show_all() win.connect('destroy', Gtk.main_quit) return win
def get_test_window_catview(): def on_category_selected(view, cat): print("on_category_selected %s %s" % view, cat) cache = get_pkg_info() cache.open() from softwarecenter.db.database import StoreDatabase xapian_base_path = "/var/cache/software-center" pathname = os.path.join(xapian_base_path, "xapian") db = StoreDatabase(pathname, cache) db.open() import softwarecenter.paths datadir = softwarecenter.paths.datadir from softwarecenter.ui.gtk3.utils import get_sc_icon_theme icons = get_sc_icon_theme(datadir) import softwarecenter.distro distro = softwarecenter.distro.get_distro() apps_filter = AppFilter(db, cache) # gui win = Gtk.Window() n = Gtk.Notebook() from softwarecenter.paths import APP_INSTALL_PATH view = LobbyViewGtk(datadir, APP_INSTALL_PATH, cache, db, icons, distro, apps_filter) win.set_data("lobby", view) scroll = Gtk.ScrolledWindow() scroll.add(view) n.append_page(scroll, Gtk.Label(label="Lobby")) # find a cat in the LobbyView that has subcategories subcat_cat = None for cat in reversed(view.categories): if cat.subcategories: subcat_cat = cat break view = SubCategoryViewGtk(datadir, APP_INSTALL_PATH, cache, db, icons, apps_filter) view.connect("category-selected", on_category_selected) view.set_subcategory(subcat_cat) win.set_data("subcat", view) scroll = Gtk.ScrolledWindow() scroll.add(view) n.append_page(scroll, Gtk.Label(label="Subcats")) win.add(n) win.set_size_request(800, 800) win.show_all() win.connect('destroy', Gtk.main_quit) return win
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
def get_test_window_pkgnamesview(): 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() pkgs = ["apt", "software-center"] view = pkgnamesview.PackageNamesView("header", cache, pkgs, icons, 32, db) view.show() win = get_test_window(child=view) return win
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
def get_test_window_appdetails(pkgname=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() icons = get_sc_icon_theme() distro = softwarecenter.distro.get_distro() # gui scroll = Gtk.ScrolledWindow() view = appdetailsview.AppDetailsView(db, distro, icons, cache) if pkgname is None: pkgname = "totem" view.show_app(application.Application("", pkgname)) #view.show_app(application.Application("Pay App Example", "pay-app")) #view.show_app(application.Application("3D Chess", "3dchess")) #view.show_app(application.Application("Movie Player", "totem")) #view.show_app(application.Application("ACE", "unace")) #~ view.show_app(application.Application("", "apt")) #view.show_app("AMOR") #view.show_app("Configuration Editor") #view.show_app("Artha") #view.show_app("cournol") #view.show_app("Qlix") scroll.add(view) scroll.show() win = get_test_window(child=scroll, width=800, height=800) win.set_data("view", view) return win
def get_test_gtk3_icon_cache(): from softwarecenter.ui.gtk3.utils import get_sc_icon_theme import softwarecenter.paths icons = get_sc_icon_theme(softwarecenter.paths.datadir) return icons
return False if __name__ == "__main__": import sys import os if len(sys.argv) > 1: datadir = sys.argv[1] elif os.path.exists("./data"): datadir = "./data" else: datadir = "/usr/share/software-center" from softwarecenter.ui.gtk3.utils import get_sc_icon_theme icons = get_sc_icon_theme(datadir) Gtk.Window.set_default_icon_name("softwarecenter") from softwarecenter.db.pkginfo import get_pkg_info cache = get_pkg_info() cache.open() # xapian import xapian from softwarecenter.paths import XAPIAN_BASE_PATH from softwarecenter.db.database import StoreDatabase xapian_base_path = XAPIAN_BASE_PATH pathname = os.path.join(xapian_base_path, "xapian") try: db = StoreDatabase(pathname, cache)
return False if __name__ == "__main__": import sys import os if len(sys.argv) > 1: datadir = sys.argv[1] elif os.path.exists("./data"): datadir = "./data" else: datadir = "/usr/share/software-center" from softwarecenter.ui.gtk3.utils import get_sc_icon_theme icons = get_sc_icon_theme() Gtk.Window.set_default_icon_name("softwarecenter") from softwarecenter.db.pkginfo import get_pkg_info cache = get_pkg_info() cache.open() # xapian import xapian from softwarecenter.paths import XAPIAN_BASE_PATH from softwarecenter.db.database import StoreDatabase xapian_base_path = XAPIAN_BASE_PATH pathname = os.path.join(xapian_base_path, "xapian") try: db = StoreDatabase(pathname, cache)
def get_test_gtk3_icon_cache(): icons = get_sc_icon_theme() return icons