def update_model(self): self.model.clear() if len(self.types) > 1: app_dict = {} default_list = [] for type in self.types: def_app = gio.app_info_get_default_for_type(type, False) for appinfo in gio.app_info_get_all_for_type(type): appname = appinfo.get_name() if def_app.get_name() == appname and appname not in default_list: default_list.append(appname) if not app_dict.has_key(appname): app_dict[appname] = appinfo for appname, appinfo in app_dict.items(): applogo = icon.get_from_app(appinfo) iter = self.model.append() if len(default_list) == 1 and appname in default_list: enabled = True else: enabled = False self.model.set( iter, TYPE_EDIT_ENABLE, enabled, TYPE_EDIT_TYPE, "", TYPE_EDIT_APPINFO, appinfo, TYPE_EDIT_APPLOGO, applogo, TYPE_EDIT_APPNAME, appname, ) else: type = self.types[0] def_app = gio.app_info_get_default_for_type(type, False) for appinfo in gio.app_info_get_all_for_type(type): applogo = icon.get_from_app(appinfo) appname = appinfo.get_name() iter = self.model.append() self.model.set( iter, TYPE_EDIT_ENABLE, def_app.get_name() == appname, TYPE_EDIT_TYPE, type, TYPE_EDIT_APPINFO, appinfo, TYPE_EDIT_APPLOGO, applogo, TYPE_EDIT_APPNAME, appname, )
def setup_treeview(self): model = Gtk.ListStore(GObject.GObject, GdkPixbuf.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.add_attribute(renderer, 'pixbuf', self.ADD_TYPE_APPLOGO) renderer = Gtk.CellRendererText() column.pack_start(renderer, False) column.add_attribute(renderer, 'text', self.ADD_TYPE_APPNAME) column.set_sort_column_id(self.ADD_TYPE_APPNAME) self.app_view.append_column(column) app_list = [] for appinfo in Gio.app_info_get_all(): if appinfo.supports_files() or appinfo.supports_uris(): appname = appinfo.get_name() if appname not in app_list: app_list.append(appname) else: continue applogo = icon.get_from_app(appinfo) model.append((appinfo, applogo, appname))
def update_model(self, filter=False, all=False): self.model.clear() theme = Gtk.IconTheme.get_default() for mime_type in Gio.content_types_get_registered(): if filter and filter != mime_type.split('/')[0]: continue # TODO why enabling this will make ui freeze even I try to add @post_ui # while Gtk.events_pending (): # Gtk.main_iteration () pixbuf = icon.get_from_mime_type(mime_type) description = Gio.content_type_get_description(mime_type) app = Gio.app_info_get_default_for_type(mime_type, False) if app: appname = app.get_name() applogo = icon.get_from_app(app) elif all and not app: appname = _('None') applogo = None else: continue self.model.append((mime_type, pixbuf, description, applogo, appname))
def update_model(self, filter=False, all=False): self.model.clear() mainwindow = self.get_toplevel().window if mainwindow: mainwindow.set_cursor(Gdk.Cursor.new(Gdk.CursorType.WATCH)) while Gtk.events_pending (): Gtk.main_iteration () theme = Gtk.IconTheme.get_default() for type in Gio.content_types_get_registered(): if filter and filter != type.split('/')[0]: continue pixbuf = icon.get_from_mime_type(type) description = Gio.content_type_get_description(type) app = Gio.app_info_get_default_for_type(type, False) if app: appname = app.get_name() applogo = icon.get_from_app(app) elif all and not app: appname = _('None') applogo = None else: continue self.model.append((type, pixbuf, description, applogo, appname)) if mainwindow: mainwindow.set_cursor(None)
def update_model(self, filter=False, all=False): self.model.clear() theme = Gtk.IconTheme.get_default() for mime_type in Gio.content_types_get_registered(): if filter and filter != mime_type.split('/')[0]: continue # TODO why enabling this will make ui freeze even I try to add @post_ui # while Gtk.events_pending (): # Gtk.main_iteration () pixbuf = icon.get_from_mime_type(mime_type) description = Gio.content_type_get_description(mime_type) app = Gio.app_info_get_default_for_type(mime_type, False) if app: appname = app.get_name() applogo = icon.get_from_app(app) elif all and not app: appname = _('None') applogo = None else: continue self.model.append( (mime_type, pixbuf, description, applogo, appname))
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 = icon.get_from_app(appinfo) appname = appinfo.get_name() iter = model.append() model.set(iter, TYPE_ADD_APPINFO, appinfo, TYPE_ADD_APPLOGO, applogo, TYPE_ADD_APPNAME, appname)
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)) while gtk.events_pending(): gtk.main_iteration() for type in gio.content_types_get_registered(): if filter and filter != type.split('/')[0]: continue pixbuf = icon.get_from_mime_type(type) description = gio.content_type_get_description(type) app = gio.app_info_get_default_for_type(type, False) if app: appname = app.get_name() applogo = icon.get_from_app(app) 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)
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 = icon.get_from_app(appinfo) appname = appinfo.get_name() iter = model.append() model.set(iter, TYPE_ADD_APPINFO, appinfo, TYPE_ADD_APPLOGO, applogo, TYPE_ADD_APPNAME, appname)
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)) while gtk.events_pending (): gtk.main_iteration () for type in gio.content_types_get_registered(): if filter and filter != type.split('/')[0]: continue pixbuf = icon.get_from_mime_type(type) description = gio.content_type_get_description(type) app = gio.app_info_get_default_for_type(type, False) if app: appname = app.get_name() applogo = icon.get_from_app(app) 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)
def update_model(self): self.model.clear() if len(self.types) > 1: app_dict = {} default_list = [] for type in self.types: def_app = gio.app_info_get_default_for_type(type, False) for appinfo in gio.app_info_get_all_for_type(type): appname = appinfo.get_name() if def_app.get_name( ) == appname and appname not in default_list: default_list.append(appname) if not app_dict.has_key(appname): app_dict[appname] = appinfo for appname, appinfo in app_dict.items(): applogo = icon.get_from_app(appinfo) iter = self.model.append() if len(default_list) == 1 and appname in default_list: enabled = True else: enabled = False self.model.set(iter, TYPE_EDIT_ENABLE, enabled, TYPE_EDIT_TYPE, '', TYPE_EDIT_APPINFO, appinfo, TYPE_EDIT_APPLOGO, applogo, TYPE_EDIT_APPNAME, appname) else: type = self.types[0] def_app = gio.app_info_get_default_for_type(type, False) for appinfo in gio.app_info_get_all_for_type(type): applogo = icon.get_from_app(appinfo) appname = appinfo.get_name() iter = self.model.append() self.model.set(iter, TYPE_EDIT_ENABLE, def_app.get_name() == appname, TYPE_EDIT_TYPE, type, TYPE_EDIT_APPINFO, appinfo, TYPE_EDIT_APPLOGO, applogo, TYPE_EDIT_APPNAME, appname)
def update_model(self): self.model.clear() if len(self.types) > 1: app_dict = {} default_list = [] for type in self.types: def_app = Gio.app_info_get_default_for_type(type, False) for appinfo in Gio.app_info_get_all_for_type(type): appname = appinfo.get_name() if (def_app.get_name() == appname and appname not in default_list): default_list.append(appname) if not app_dict.has_key(appname): app_dict[appname] = appinfo for appname, appinfo in app_dict.items(): applogo = icon.get_from_app(appinfo) if len(default_list) == 1 and appname in default_list: enabled = True else: enabled = False self.model.append((enabled, '', appinfo, applogo, appname)) else: type = self.types[0] def_app = Gio.app_info_get_default_for_type(type, False) for appinfo in Gio.app_info_get_all_for_type(type): applogo = icon.get_from_app(appinfo) appname = appinfo.get_name() self.model.append((def_app.get_name() == appname, type, appinfo, applogo, appname))
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 = icon.get_from_app(app) model.set(iter, TYPE_APPICON, applogo, TYPE_APP, appname) else: model.set(iter, TYPE_APPICON, None, TYPE_APP, _("None"))
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 = icon.get_from_app(app) model.set(iter, TYPE_APPICON, applogo, TYPE_APP, appname) else: model.set(iter, TYPE_APPICON, None, TYPE_APP, _('None'))