def __init__(self, type, parent): super(TypeEditDialog, self).__init__() self.type = type type_pixbuf = mime_type_get_icon(type, 64) worker = GuiWorker('type_edit.glade') self.dialog = worker.get_object('type_edit_dialog') self.dialog.set_transient_for(parent) self.dialog.set_modal(True) self.dialog.connect('destroy', self.on_dialog_destroy) type_logo = worker.get_object('type_edit_logo') type_logo.set_from_pixbuf(type_pixbuf) type_label = worker.get_object('type_edit_label') type_label.set_markup(_('Select an application to open the type <b>%s</b>') % gio.content_type_get_description(type)) self.type_edit_view = worker.get_object('type_edit_view') self.setup_treeview() add_button = worker.get_object('type_edit_add_button') add_button.connect('clicked', self.on_add_button_clicked) remove_button = worker.get_object('type_edit_remove_button') remove_button.connect('clicked', self.on_remove_button_clicked) close_button = worker.get_object('type_edit_close_button') close_button.connect('clicked', self.on_dialog_destroy)
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)