1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72
|
# Copyright (C) 2009 Canonical
#
# Authors:
# Michael Vogt
#
# This program is free software; you can redistribute it and/or modify it under
# the terms of the GNU General Public License as published by the Free Software
# Foundation; version 3.
#
# This program is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
# details.
#
# You should have received a copy of the GNU General Public License along with
# this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
import logging
import gtk
import gobject
import apt
import os
import xapian
from appview import *
class InstalledFilter(object):
def __init__(self, cache):
self.cache = cache
def filter(self, pkgname):
if pkgname in self.cache and self.cache[pkgname].is_installed:
return True
return False
if __name__ == "__main__":
logging.basicConfig(level=logging.DEBUG)
xapian_base_path = "/var/cache/software-center"
pathname = os.path.join(xapian_base_path, "xapian")
db = xapian.Database(pathname)
# additional icons come from app-install-data
icons = gtk.icon_theme_get_default()
icons.append_search_path("/usr/share/app-install/icons/")
cache = apt.Cache()
installed_filter = InstalledFilter(cache)
# now the store
store = AppStore(db, icons, filter=installed_filter.filter)
print len(store)
# gui
scroll = gtk.ScrolledWindow()
view = AppView(store)
entry = gtk.Entry()
entry.connect("changed", on_entry_changed, (db, view))
box = gtk.VBox()
box.pack_start(entry, expand=False)
box.pack_start(scroll)
win = gtk.Window()
scroll.add(view)
win.add(box)
win.set_size_request(400,400)
win.show_all()
gtk.main()
|