コード例 #1
0
    def setup_treeview(self):
        model = gtk.ListStore(gobject.GObject,
                              gtk.gdk.Pixbuf,
                              gobject.TYPE_STRING)

        self.app_view.set_model(model)
        self.app_view.set_headers_visible(False)

        column = gtk.TreeViewColumn()
        renderer = gtk.CellRendererPixbuf()
        column.pack_start(renderer, False)
        column.set_attributes(renderer, pixbuf = TYPE_ADD_APPLOGO)
        
        renderer = gtk.CellRendererText()
        column.pack_start(renderer, False)
        column.set_attributes(renderer, text = TYPE_ADD_APPNAME)
        column.set_sort_column_id(TYPE_DESCRIPTION)
        self.app_view.append_column(column)

        for appinfo in gio.app_info_get_all():
            if appinfo.supports_files() or appinfo.supports_uris():
                applogo = get_icon_with_app(appinfo, 24)
                appname = appinfo.get_name()

                iter = model.append()
                model.set(iter, 
                        TYPE_ADD_APPINFO, appinfo,
                        TYPE_ADD_APPLOGO, applogo,
                        TYPE_ADD_APPNAME, appname)
コード例 #2
0
    def update_model(self, filter = False, all = False):
        self.model.clear()
        mainwindow = self.get_toplevel().window
        if mainwindow:
            mainwindow.set_cursor(gtk.gdk.Cursor(gtk.gdk.WATCH))
        for type in gio.content_types_get_registered():
            while gtk.events_pending ():
                gtk.main_iteration ()

            if filter and filter != type.split('/')[0]:
                continue

            pixbuf = mime_type_get_icon(type, 24)
            description = gio.content_type_get_description(type)
            app = gio.app_info_get_default_for_type(type, False)

            if app:
                appname = app.get_name()
                applogo = get_icon_with_app(app, 24)
            elif all and not app:
                appname = _('None')
                applogo = None
            else:
                continue
            
            iter = self.model.append()
            self.model.set(iter, 
                    TYPE_MIME, type,
                    TYPE_ICON, pixbuf, 
                    TYPE_DESCRIPTION, description,
                    TYPE_APPICON, applogo,
                    TYPE_APP, appname)

        if mainwindow:
            mainwindow.set_cursor(None)
コード例 #3
0
    def update_model(self):
        self.model.clear()

        def_app = gio.app_info_get_default_for_type(self.type, False)
        for appinfo in gio.app_info_get_all_for_type(self.type):
            applogo = get_icon_with_app(appinfo, 24)
            appname = appinfo.get_name()

            iter = self.model.append()
            self.model.set(iter, 
                    TYPE_EDIT_ENABLE, def_app.get_name() == appname,
                    TYPE_EDIT_TYPE, self.type,
                    TYPE_EDIT_APPINFO, appinfo,
                    TYPE_EDIT_APPLOGO, applogo,
                    TYPE_EDIT_APPNAME, appname)
コード例 #4
0
    def do_update_for_type(self, model, path, iter, type):
        this_type = model.get_value(iter, TYPE_MIME)

        if this_type == type:
            app = gio.app_info_get_default_for_type(type, False)

            if app:
                appname = app.get_name()
                applogo = get_icon_with_app(app, 24)
                
                model.set(iter, 
                        TYPE_APPICON, applogo,
                        TYPE_APP, appname)
            else:
                model.set(iter, 
                        TYPE_APPICON, None,
                        TYPE_APP, _('None'))