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 = 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)
def __init__(self, type, parent): super(TypeEditDialog, self).__init__() self.type = type type_pixbuf = mime_type_get_icon(type, 64) worker = GuiWorker('type_edit.ui') 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 __init__(self, types, parent): super(TypeEditDialog, self).__init__() self.types = types type_pixbuf = mime_type_get_icon(self.types[0], 64) worker = GuiWorker('type_edit.ui') 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') if len(self.types) > 1: markup_text = ", ".join([gio.content_type_get_description(filetype) for filetype in self.types]) else: markup_text = self.types[0] type_label.set_markup(ngettext('Select an application to open files of type: <b>%s</b>', 'Select an application to open files for these types: <b>%s</b>', len(self.types)) % markup_text) 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 should not available in multiple selection if len(self.types) > 1: add_button.hide() remove_button.hide() 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)