def run_traceback(level, textview_only=False, text_only=False): '''Two level: fatal and error''' output = StringIO.StringIO() exc = traceback.print_exc(file=output) worker = GuiWorker('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(_('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()) if dialog.run() == gtk.RESPONSE_YES: webbrowser.open('https://bugs.launchpad.net/ubuntu-tweak/+filebug') dialog.destroy() output.close()
def __init__(self): self.worker = GuiWorker('preferences.ui') self.dialog = self.worker.get_object('preferences_dialog') self.setup_window_preference() self.setup_launch_function() self.setup_other_features()
def run_traceback(level): output = StringIO.StringIO() exc = traceback.print_exc(file = output) worker = GuiWorker('traceback.ui') dialog = worker.get_object('%sDialog' % level.capitalize()) textview = worker.get_object('%s_view' % level) buffer = textview.get_buffer() buffer.set_text(output.getvalue()) if dialog.run() == gtk.RESPONSE_YES: webbrowser.open('https://bugs.launchpad.net/ubuntu-tweak/+filebug') dialog.destroy() output.close()
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, type, parent): super(AddAppDialog, self).__init__() worker = GuiWorker('type_edit.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_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): output = StringIO.StringIO() exc = traceback.print_exc(file = output) worker = GuiWorker('traceback.ui') dialog = worker.get_object('%sDialog' % level.capitalize()) textview = worker.get_object('%s_view' % level) buffer = textview.get_buffer() buffer.set_text("Distribution: %s\n" "Application: %s\n" "Desktop: %s\n" "\n" "%s" % (SystemInfo.distro, SystemInfo.app, SystemInfo.desktop, output.getvalue())) if dialog.run() == gtk.RESPONSE_YES: webbrowser.open('https://bugs.launchpad.net/ubuntu-tweak/+filebug') dialog.destroy() output.close()
def __init__(self, types, parent): super(TypeEditDialog, self).__init__() self.types = types type_pixbuf = icon.get_from_mime_type(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: 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 run_traceback(level, textview_only=False, text_only=False): '''Two level: fatal and error''' output = StringIO.StringIO() exc = traceback.print_exc(file=output) worker = GuiWorker('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(_('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()) if dialog.run() == gtk.RESPONSE_YES: webbrowser.open('https://bugs.launchpad.net/ubuntu-tweak/+filebug') dialog.destroy() output.close()
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)
def __init__(self, type, parent): super(AddAppDialog, self).__init__() worker = GuiWorker("type_edit.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_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)
class PreferencesDialog: def __init__(self): self.worker = GuiWorker('preferences.ui') self.dialog = self.worker.get_object('preferences_dialog') self.setup_window_preference() self.setup_launch_function() self.setup_other_features() def setup_window_preference(self): table = self.worker.get_object('table1') height, width = TweakSettings.get_window_size() win_width = WidgetFactory.create('GconfSpinButton', key = 'window_width', min = 640, max = 1280, step = 1) win_width.show() win_width.connect('value-changed', self.on_value_changed) table.attach(win_width, 1, 3, 0, 1) win_height = WidgetFactory.create('GconfSpinButton', key = 'window_height', min = 480, max = 1280, step = 1) win_height.show() win_height.connect('value-changed', self.on_value_changed) table.attach(win_height, 1, 3, 1, 2) toolbar_size = WidgetFactory.create('GconfSpinButton', key = 'toolbar_size', min = 100, max = 500, step = 1) toolbar_size.show() toolbar_size.connect('value-changed', self.on_value_changed) table.attach(toolbar_size, 1, 3, 2, 3) def setup_launch_function(self): from mainwindow import module_loader from mainwindow import ID_COLUMN, LOGO_COLUMN, TITLE_COLUMN function_box = self.worker.get_object('function_box') model = gtk.ListStore( gobject.TYPE_STRING, gtk.gdk.Pixbuf, gobject.TYPE_STRING) iter = model.append(None) model.set(iter, ID_COLUMN, 0, LOGO_COLUMN, None, TITLE_COLUMN, _('None') ) for module in module_loader.get_all_module(): iter = model.append(None) pixbuf = module_loader.get_pixbuf(module.__name__) model.set(iter, ID_COLUMN, module.__name__, LOGO_COLUMN, pixbuf, TITLE_COLUMN, module.__title__, ) function_box.set_model(model) textcell = gtk.CellRendererText() pixbufcell = gtk.CellRendererPixbuf() function_box.pack_start(pixbufcell, False) function_box.pack_start(textcell, True) function_box.add_attribute(textcell, 'text', TITLE_COLUMN) function_box.add_attribute(pixbufcell, 'pixbuf', LOGO_COLUMN) id = TweakSettings.get_default_launch() for i, row in enumerate(model): _id = model.get_value(row.iter, ID_COLUMN) if id == _id: function_box.set_active(i) function_box.connect('changed', self.on_launch_changed) def setup_other_features(self): vbox = self.worker.get_object('vbox5') button = WidgetFactory.create('GconfCheckButton', label=_('Enable Check Update'), key='check_update', default=False) vbox.pack_start(button, False, False, 0) button = WidgetFactory.create('GconfCheckButton', label=_('Use Separated Sources'), key='separated_sources', default=True) vbox.pack_start(button, False, False, 0) button = WidgetFactory.create('GconfCheckButton', label = _('Use Remote Data When Available'), key='use_remote_data', default=True) vbox.pack_start(button, False, False, 0) if os.getenv('LANG').startswith('zh_CN'): button = WidgetFactory.create('GconfCheckButton', label='使用PPA镜像(如果可用)', key='use_mirror_ppa', default=False) vbox.pack_start(button, False, False, 0) vbox.show_all() def on_launch_changed(self, widget): index = widget.get_active() liststore = widget.get_model() iter = liststore.get_iter(index) id = liststore.get_value(iter, 0) TweakSettings.set_default_launch(id) def on_color_set(self, widget): TweakSettings.set_toolbar_color(widget.get_color().to_string()) def on_reset_clicked(self, widget, colorbutton): color = gtk.gdk.Color(32767, 32767, 32767) colorbutton.set_color(color) TweakSettings.set_toolbar_color(color.to_string()) def on_font_color_set(self, widget): TweakSettings.set_toolbar_font_color(widget.get_color().to_string()) def on_font_reset_clicked(self, widget, colorbutton): color = gtk.gdk.Color(65535, 65535, 65535) colorbutton.set_color(color) TweakSettings.set_toolbar_font_color(color.to_string()) def on_value_changed(self, widget): TweakSettings.need_save = False def run(self): self.dialog.run() def destroy(self): self.dialog.destroy()
class PreferencesDialog: def __init__(self): self.worker = GuiWorker('preferences.ui') self.dialog = self.worker.get_object('preferences_dialog') self.setup_window_preference() self.setup_launch_function() self.setup_other_features() def setup_window_preference(self): table = self.worker.get_object('table1') win_width = WidgetFactory.create('GconfSpinButton', key='window_width', min=640, max=1280, step=1) win_width.show() win_width.connect('value-changed', self.on_value_changed) table.attach(win_width, 1, 3, 0, 1) win_height = WidgetFactory.create('GconfSpinButton', key='window_height', min=480, max=1280, step=1) win_height.show() win_height.connect('value-changed', self.on_value_changed) table.attach(win_height, 1, 3, 1, 2) toolbar_size = WidgetFactory.create('GconfSpinButton', key='toolbar_size', min=100, max=500, step=1) toolbar_size.show() toolbar_size.connect('value-changed', self.on_value_changed) table.attach(toolbar_size, 1, 3, 2, 3) def setup_launch_function(self): from ubuntutweak.mainwindow import MLOADER from ubuntutweak.mainwindow import MainWindow as MW function_box = self.worker.get_object('function_box') model = gtk.ListStore( gobject.TYPE_STRING, gtk.gdk.Pixbuf, gobject.TYPE_STRING) iter = model.append(None) model.set(iter, MW.ID_COLUMN, 0, MW.LOGO_COLUMN, None, MW.TITLE_COLUMN, _('None') ) for module in MLOADER.get_all_module(): iter = model.append(None) pixbuf = MLOADER.get_pixbuf(module.__name__) model.set(iter, MW.ID_COLUMN, module.__name__, MW.LOGO_COLUMN, pixbuf, MW.TITLE_COLUMN, module.__title__, ) function_box.set_model(model) textcell = gtk.CellRendererText() pixbufcell = gtk.CellRendererPixbuf() function_box.pack_start(pixbufcell, False) function_box.pack_start(textcell, True) function_box.add_attribute(textcell, 'text', MW.TITLE_COLUMN) function_box.add_attribute(pixbufcell, 'pixbuf', MW.LOGO_COLUMN) id = TweakSettings.get_default_launch() for i, row in enumerate(model): _id = model.get_value(row.iter, MW.ID_COLUMN) if id == _id: function_box.set_active(i) function_box.connect('changed', self.on_launch_changed) def setup_other_features(self): vbox = self.worker.get_object('vbox5') button = WidgetFactory.create('GconfCheckButton', label=_('Check for Updates'), key='check_update', default=False) vbox.pack_start(button, False, False, 0) button = WidgetFactory.create('GconfCheckButton', label=_('Use Separated Sources'), key='separated_sources', default=True) vbox.pack_start(button, False, False, 0) button = WidgetFactory.create('GconfCheckButton', label=_('Enable Synchronous notifications'), key='sync_notify', default=True) vbox.pack_start(button, False, False, 0) button = WidgetFactory.create('GconfCheckButton', label=_('Highlight new items in App and Source Center'), key='enable_new_item', default=True) vbox.pack_start(button, False, False, 0) if os.getenv('LANG').startswith('zh_CN'): button = WidgetFactory.create('GconfCheckButton', label='使用PPA镜像(如果可用)', key='use_mirror_ppa', default=False) vbox.pack_start(button, False, False, 0) vbox.show_all() def on_launch_changed(self, widget, data=None): index = widget.get_active() liststore = widget.get_model() iter = liststore.get_iter(index) id = liststore.get_value(iter, 0) TweakSettings.set_default_launch(id) def on_value_changed(self, widget): TweakSettings.need_save = False def run(self): self.dialog.run() def destroy(self): self.dialog.destroy()
class PreferencesDialog: def __init__(self): self.worker = GuiWorker('preferences.ui') self.dialog = self.worker.get_object('preferences_dialog') self.setup_window_preference() self.setup_launch_function() self.setup_other_features() def setup_window_preference(self): table = self.worker.get_object('table1') win_width = WidgetFactory.create('GconfSpinButton', key='window_width', min=640, max=1280, step=1) win_width.show() win_width.connect('value-changed', self.on_value_changed) table.attach(win_width, 1, 3, 0, 1) win_height = WidgetFactory.create('GconfSpinButton', key='window_height', min=480, max=1280, step=1) win_height.show() win_height.connect('value-changed', self.on_value_changed) table.attach(win_height, 1, 3, 1, 2) toolbar_size = WidgetFactory.create('GconfSpinButton', key='toolbar_size', min=100, max=500, step=1) toolbar_size.show() toolbar_size.connect('value-changed', self.on_value_changed) table.attach(toolbar_size, 1, 3, 2, 3) def setup_launch_function(self): from ubuntutweak.mainwindow import MLOADER from ubuntutweak.mainwindow import MainWindow as MW function_box = self.worker.get_object('function_box') model = gtk.ListStore(gobject.TYPE_STRING, gtk.gdk.Pixbuf, gobject.TYPE_STRING) iter = model.append(None) model.set(iter, MW.ID_COLUMN, '', MW.LOGO_COLUMN, None, MW.TITLE_COLUMN, _('None')) for module in MLOADER.get_all_module(): iter = model.append(None) model.set( iter, MW.ID_COLUMN, module.get_name(), MW.LOGO_COLUMN, module.get_pixbuf(), MW.TITLE_COLUMN, module.get_title(), ) function_box.set_model(model) textcell = gtk.CellRendererText() pixbufcell = gtk.CellRendererPixbuf() function_box.pack_start(pixbufcell, False) function_box.pack_start(textcell, True) function_box.add_attribute(textcell, 'text', MW.TITLE_COLUMN) function_box.add_attribute(pixbufcell, 'pixbuf', MW.LOGO_COLUMN) id = TweakSettings.get_default_launch() for i, row in enumerate(model): _id = model.get_value(row.iter, MW.ID_COLUMN) if id == _id: function_box.set_active(i) function_box.connect('changed', self.on_launch_changed) def setup_other_features(self): vbox = self.worker.get_object('vbox5') button = WidgetFactory.create('GconfCheckButton', label=_('Check for Updates'), key='check_update', default=False) vbox.pack_start(button, False, False, 0) button = WidgetFactory.create('GconfCheckButton', label=_('Use Separated Sources'), key='separated_sources', default=True) vbox.pack_start(button, False, False, 0) button = WidgetFactory.create( 'GconfCheckButton', label=_('Enable Synchronous notifications'), key='sync_notify', default=True) vbox.pack_start(button, False, False, 0) button = WidgetFactory.create( 'GconfCheckButton', label=_('Highlight new items in App and Source Center'), key='enable_new_item', default=True) vbox.pack_start(button, False, False, 0) if os.getenv('LANG').startswith('zh_CN'): button = WidgetFactory.create('GconfCheckButton', label='使用PPA镜像(如果可用)', key='use_mirror_ppa', default=False) vbox.pack_start(button, False, False, 0) vbox.show_all() def on_launch_changed(self, widget, data=None): index = widget.get_active() liststore = widget.get_model() iter = liststore.get_iter(index) id = liststore.get_value(iter, 0) TweakSettings.set_default_launch(id) def on_value_changed(self, widget): TweakSettings.need_save = False def run(self): self.dialog.run() def destroy(self): self.dialog.destroy()