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 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, 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 __init__(self, types, parent): super(TypeEditDialog, self).__init__() self.types = types type_pixbuf = icon.get_from_mime_type(self.types[0], 64) worker = GuiBuilder('filetypemanager.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: 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)
def __init__(self, types, parent): super(TypeEditDialog, self).__init__() self.types = types type_pixbuf = icon.get_from_mime_type(self.types[0], 64) worker = GuiBuilder('filetypemanager.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: 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)