pkgnamesview.py 文件源码

python
阅读 20 收藏 0 点赞 0 评论 0

项目:x-mario-center 作者: fossasia 项目源码 文件源码
def __init__(self, header, cache, pkgnames, icons, icon_size, db):
        super(PackageNamesView, self).__init__()
        model = Gtk.ListStore(GdkPixbuf.Pixbuf, str)
        self.set_model(model)
        tp = Gtk.CellRendererPixbuf()
        column = Gtk.TreeViewColumn("Icon", tp, pixbuf=self.COL_ICON)
        self.append_column(column)
        tr = Gtk.CellRendererText()
        tr.set_property("ellipsize", Pango.EllipsizeMode.END)
        column = Gtk.TreeViewColumn(header, tr, markup=self.COL_TEXT)
        self.append_column(column)
        for pkgname in sorted(pkgnames):
            if (not pkgname in cache or
                not cache[pkgname].installed):
                continue
            s = "%s \n<small>%s</small>" % (
                cache[pkgname].installed.summary.capitalize(), pkgname)

            app_details = Application("", pkgname).get_details(db)
            proposed_icon = app_details.icon
            if not proposed_icon or not icons.has_icon(proposed_icon):
                proposed_icon = Icons.MISSING_APP
            if icons.has_icon(proposed_icon):
                icon = icons.load_icon(proposed_icon, icon_size, 0)
                pb = icon.scale_simple(
                    icon_size, icon_size, GdkPixbuf.InterpType.BILINEAR)
            else:
                LOG.warn("cant set icon for '%s' " % pkgname)
                pb = icons.load_icon(Icons.MISSING_APP,
                                     icon_size,
                                     Gtk.IconLookupFlags.GENERIC_FALLBACK)
                pb = pb.scale_simple(icon_size,
                                     icon_size, GdkPixbuf.InterpType.BILINEAR)
            model.append([pb, s])

        # finally, we don't allow selection, it's just a simple display list
        tree_selection = self.get_selection()
        tree_selection.set_mode(Gtk.SelectionMode.NONE)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号