1
# Copyright (C) 2009 Canonical
6
# This program is free software; you can redistribute it and/or modify it under
7
# the terms of the GNU General Public License as published by the Free Software
8
# Foundation; version 3.
10
# This program is distributed in the hope that it will be useful, but WITHOUT
11
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12
# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
15
# You should have received a copy of the GNU General Public License along with
16
# this program; if not, write to the Free Software Foundation, Inc.,
17
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
23
from softwarecenter.db.application import Application
25
#FIXME: These need to come from the main app
27
MISSING_APP_ICON = "applications-other"
29
LOG = logging.getLogger(__name__)
31
class PkgNamesView(gtk.TreeView):
32
""" show a bunch of pkgnames with description """
37
def __init__(self, header, cache, pkgnames, icons, db):
38
super(PkgNamesView, self).__init__()
39
model = gtk.ListStore(gtk.gdk.Pixbuf, str)
41
tp = gtk.CellRendererPixbuf()
42
column = gtk.TreeViewColumn("Icon", tp, pixbuf=self.COL_ICON)
43
self.append_column(column)
44
tr = gtk.CellRendererText()
45
tr.set_property("ellipsize", pango.ELLIPSIZE_END)
46
column = gtk.TreeViewColumn(header, tr, markup=self.COL_TEXT)
47
self.append_column(column)
48
for pkgname in sorted(pkgnames):
49
s = "%s \n<small>%s</small>" % (
50
cache[pkgname].installed.summary.capitalize(), pkgname)
52
app_details = Application("", pkgname).get_details(db)
53
proposed_icon = app_details.icon
54
if not proposed_icon or not icons.has_icon(proposed_icon):
55
proposed_icon = MISSING_APP_ICON
57
pix = icons.load_icon(proposed_icon, ICON_SIZE, ()).scale_simple(ICON_SIZE,
58
ICON_SIZE, gtk.gdk.INTERP_BILINEAR)
60
LOG.warning("cant set icon for '%s' " % pkgname)
61
pix = icons.load_icon(MISSING_APP_ICON, ICON_SIZE, ()).scale_simple(ICON_SIZE,
62
ICON_SIZE, gtk.gdk.INTERP_BILINEAR)
63
row = model.append([pix, s])