コード例 #1
0
ファイル: debug.py プロジェクト: systembugtj/ubuntu-tweak-old
def run_traceback(level):
    output = StringIO.StringIO()
    exc = traceback.print_exc(file=output)

    worker = GuiWorker("traceback.glade")
    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()
コード例 #2
0
    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)
コード例 #3
0
    def __init__(self, type, parent):
        super(AddAppDialog, self).__init__()

        worker = GuiWorker('type_edit.glade')

        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 the 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)
コード例 #4
0
class PreferencesDialog:
    def __init__(self):
        self.worker = GuiWorker('preferences.glade')
        self.dialog = self.worker.get_object('preferences_dialog')

        self.setup_window_preference()
        self.setup_color_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_color_preference(self):
        colorbutton = self.worker.get_object('colorbutton')
        colorbutton.set_color(TweakSettings.get_toolbar_color(True))
        colorbutton.connect('color-set', self.on_color_set)

        reset_button = self.worker.get_object('reset_button')
        set_label_for_stock_button(reset_button, _('Reset'))
        reset_button.connect('clicked', self.on_reset_clicked, colorbutton)

        font_colorbutton = self.worker.get_object('font_colorbutton')
        font_colorbutton.set_color(TweakSettings.get_toolbar_font_color(True))
        font_colorbutton.connect('color-set', self.on_font_color_set)

        font_reset_button = self.worker.get_object('font_reset_button')
        set_label_for_stock_button(font_reset_button, _('Reset'))
        font_reset_button.connect('clicked', self.on_font_reset_clicked, font_colorbutton)

    def setup_launch_function(self):
        from mainwindow import MODULES
        from mainwindow import MODULE_ID, MODULE_LOGO, MODULE_TITLE
        function_box = self.worker.get_object('function_box')

        module_list = []
        for module in MODULES:
            if module[-1] == 2:
                module_list.append(module)

        model = gtk.ListStore(
                gobject.TYPE_INT,
                gtk.gdk.Pixbuf,
                gobject.TYPE_STRING)

        iter = model.append(None)
        model.set(iter,
                MODULE_ID, 0,
                MODULE_LOGO, None,
                MODULE_TITLE, _('None')
        )
        for module in module_list:
            icon = gtk.gdk.pixbuf_new_from_file(os.path.join(DATA_DIR, 'pixmaps', module[MODULE_LOGO])).scale_simple(18, 18, gtk.gdk.INTERP_NEAREST)

            iter = model.append(None)

            model.set(iter,
                    MODULE_ID, module[MODULE_ID],
                    MODULE_LOGO, icon,
                    MODULE_TITLE, module[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', MODULE_TITLE)
        function_box.add_attribute(pixbufcell, 'pixbuf', MODULE_LOGO)
        id = TweakSettings.get_default_launch()
        for i, row in enumerate(model):
            _id = model.get_value(row.iter, MODULE_ID)
            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 = _('Enable PowerUser Mode'), 
                                      key = 'power_user',
                                      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()