Beispiel #1
0
    import apt
    import cPickle
    import pdb

    cache = apt.Cache()
    progress = apt.progress.OpTextProgress()
    to_add = []

    datadir = "/usr/share/app-install"
    desktopdir = "/usr/share/app-install"
    cachedir = "/var/cache/app-install"

    treeview_categories = gtk.TreeView()
    treeview_packages = gtk.TreeView()

    menu = CoreApplicationMenu(datadir)
    menu.pickle = cPickle.load(open("/var/cache/app-install/menu.p"))

    available = []
    available_extras = []
    installed = []
    installed_extras = []

    print menu.pickle.keys()
    for app in menu.pickle[menu.pickle.keys()[0]]:
        if cache.has_key(app.pkgname) and cache[app.pkgname].is_installed:
            if app.execCmd:
                installed.append(app)
            else:
                installed_extras.append(app)
        else:
    import apt
    import cPickle
    import pdb

    cache = apt.Cache()
    progress = apt.progress.OpTextProgress()
    to_add = []

    datadir = "/usr/share/app-install"
    desktopdir = "/usr/share/app-install"
    cachedir = "/var/cache/app-install"

    treeview_categories = gtk.TreeView()
    treeview_packages = gtk.TreeView()

    menu = CoreApplicationMenu(datadir)
    menu.pickle = cPickle.load(open("/var/cache/app-install/menu.p"))

    available = []
    available_extras = []
    installed = []
    installed_extras = []

    print menu.pickle.keys()
    for app in menu.pickle[menu.pickle.keys()[0]]:
        if cache.has_key(app.pkgname) and cache[app.pkgname].isInstalled:
            if app.execCmd:
                installed.append(app)
            else:
                installed_extras.append(app)
        else:
if __name__ == "__main__":
    parser = OptionParser()
    parser.add_option("-s", "--srcdir", dest="srcdir",
                      default="/usr/share/app-install/desktop/",
                      help="directory for the menu-data")
    parser.add_option("-d", "--destdir", dest="destdir",
                      default="output",
                      help="dir for the output")
    (options, args) = parser.parse_args()

    # get a cache
    cache = apt.Cache()

    # read menu
    menu = CoreApplicationMenu(options.srcdir)
    root = xdg.Menu.parse(os.path.join(options.srcdir, "applications.menu"))
    menu._populateFromEntry(root)

    # output per section
    index_file = open(os.path.join(options.destdir,"sections.txt"),"w")
    sections = menu.pickle.keys()
    sections.sort()
    for section in sections:
        name = unescape(section.name)
        index_file.write("%s\n" % name)
        section_file = open(os.path.join(options.destdir,name+".txt"),"w")
        for app in menu.pickle[section]:
            if not cache.has_key(app.pkgname):
                print "ERROR: can't find '%s' in apt cache" % app.pkgname
                continue
#import sys
#sys.path.insert(0, "..")
#sys.path.insert(0, "../..")

from AppInstall.Menu import CategoryStore, COL_CAT_NAME, COL_CAT_PIXBUF
from AppInstall.CoreMenu import CoreApplicationMenu

class CategoriesView(gtk.IconView):
    def __init__(self, model=None):
        gtk.IconView.__init__(self, model)
        self.set_markup_column(COL_CAT_NAME)
        self.set_pixbuf_column(COL_CAT_PIXBUF)

if __name__ == "__main__":
    # run in toplevel with
    # PYTHONPATH=. python -v AppInstall/widgets/CategoryView.py
    
    # data setup
    cs = CategoryStore()
    menu = CoreApplicationMenu("/usr/share/app-install")
    menu.loadMenuCache("/var/cache/app-install/menu.p")
    cs.init_from_application_menu(menu)
    # gui
    w = gtk.Window()
    w.set_size_request(500,700)
    cv = CategoriesView(cs)
    cv.grab_focus()
    w.add(cv)
    w.show_all()
    gtk.main()