def run_traceback(level, textview_only=False, text_only=False): '''Two level: fatal and error''' from ubuntutweak.gui import GuiBuilder output = StringIO.StringIO() exc = traceback.print_exc(file=output) worker = GuiBuilder('traceback.ui') textview = worker.get_object('%s_view' % level) buffer = textview.get_buffer() iter = buffer.get_start_iter() anchor = buffer.create_child_anchor(iter) button = Gtk.Button(label=_('Copy Error Message')) button.show() textview.add_child_at_anchor(button, anchor) error_text = "\nDistribution: %s\nApplication: %s\nDesktop:%s\n\n%s" % (system.DISTRO, system.APP, system.DESKTOP, output.getvalue()) buffer.insert(iter, error_text) button.connect('clicked', on_copy_button_clicked, error_text) if text_only: return error_text if textview_only: return textview else: dialog = worker.get_object('%sDialog' % level.capitalize()) to_report = (dialog.run() == Gtk.ResponseType.YES) dialog.destroy() output.close() if to_report: open_bug_report()
def __init__(self, type, parent): super(AddAppDialog, self).__init__() worker = GuiBuilder('filetypemanager.ui') self.dialog = worker.get_object('add_app_dialog') self.dialog.set_modal(True) self.dialog.set_transient_for(parent) self.app_view = worker.get_object('app_view') self.setup_treeview() self.app_selection = self.app_view.get_selection() self.app_selection.connect('changed', self.on_app_selection_changed) self.info_label = worker.get_object('info_label') self.description_label = worker.get_object('description_label') self.info_label.set_markup(_('Open files of type "%s" with:') % Gio.content_type_get_description(type)) self.add_button = worker.get_object('add_button') self.add_button.connect('clicked', self.on_add_app_button_clicked) self.command_entry = worker.get_object('command_entry') self.browse_button = worker.get_object('browse_button') self.browse_button.connect('clicked', self.on_browse_button_clicked)
def __init__(self, type, parent): super(AddAppDialog, self).__init__() worker = GuiBuilder('filetypemanager.ui') self.dialog = worker.get_object('add_app_dialog') self.dialog.set_modal(True) self.dialog.set_transient_for(parent) self.app_view = worker.get_object('app_view') self.setup_treeview() self.app_selection = self.app_view.get_selection() self.app_selection.connect('changed', self.on_app_selection_changed) self.info_label = worker.get_object('info_label') self.description_label = worker.get_object('description_label') self.info_label.set_markup( _('Open files of type "%s" with:') % Gio.content_type_get_description(type)) self.add_button = worker.get_object('add_button') self.add_button.connect('clicked', self.on_add_app_button_clicked) self.command_entry = worker.get_object('command_entry') self.browse_button = worker.get_object('browse_button') self.browse_button.connect('clicked', self.on_browse_button_clicked)
def run_traceback(level, textview_only=False, text_only=False): '''Two level: fatal and error''' from ubuntutweak.gui import GuiBuilder output = StringIO.StringIO() exc = traceback.print_exc(file=output) worker = GuiBuilder('traceback.ui') textview = worker.get_object('%s_view' % level) buffer = textview.get_buffer() iter = buffer.get_start_iter() anchor = buffer.create_child_anchor(iter) button = Gtk.Button(label=_('Copy Error Message')) button.show() textview.add_child_at_anchor(button, anchor) error_text = "\nDistribution: %s\nApplication: %s\nDesktop:%s\n\n%s" % ( system.DISTRO, system.APP, system.DESKTOP, output.getvalue()) buffer.insert(iter, error_text) button.connect('clicked', on_copy_button_clicked, error_text) if text_only: return error_text if textview_only: return textview else: dialog = worker.get_object('%sDialog' % level.capitalize()) to_report = (dialog.run() == Gtk.ResponseType.YES) dialog.destroy() output.close() if to_report: open_bug_report()
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)