예제 #1
0
class SpinButton(Gtk.SpinButton):
    def __init__(self, key, min=0, max=0, step=0, backend=GConf):
        if backend == GConf:
            self.setting = GconfSetting(key=key, type=int)
        else:
            #TODO Gio
            pass

        adjust = Gtk.Adjustment(self.setting.get_value(), min, max, step)
        gobject.GObject.__init__(self, adjustment=adjust)
        self.connect('value-changed', self.on_value_changed)

    def on_value_changed(self, widget):
        self.setting.set_value(widget.get_value())
예제 #2
0
    def __init__(self, key=None, texts=None, values=None,
                 type="string", backend=GConf):
        gobject.GObject.__init__(self)

        if backend == GConf:
            self.setting = GconfSetting(key=key, type=str)
        else:
            #TODO Gio
            pass

        if type == 'int':
            model = Gtk.ListStore(gobject.TYPE_STRING, gobject.TYPE_INT)
        else:
            model = Gtk.ListStore(gobject.TYPE_STRING, gobject.TYPE_STRING)
        self.set_model(model)

        cell = Gtk.CellRendererText()
        self.pack_start(cell, True)
        self.add_attribute(cell, 'text', 0)

        current_value = self.setting.get_value()

        for text, value in dict(zip(texts, values)).items():
            iter = model.append((text, value))
            if current_value == value:
                self.set_active_iter(iter)

        self.connect("changed", self.value_changed_cb)
예제 #3
0
    def __init__(self, key=None, min=None, max=None, digits=0,
                 reversed=False, backend=GConf):
        gobject.GObject.__init__(self)

        if digits > 0:
            type = float
        else:
            type = int

        if backend == GConf:
            self.setting = GconfSetting(key=key, type=type)
        else:
            #TODO Gio
            pass

        if reversed:
            self._reversed = True
        else:
            self._reversed = False

        self.set_range(min, max)
        self.set_digits(digits)
        self.set_value_pos(Gtk.PositionType.RIGHT)
        if self._reversed:
            self.set_value(max - self.setting.get_value())
        else:
            self.set_value(self.setting.get_value())

        self.connect("value-changed", self.on_value_changed)
예제 #4
0
    def __init__(self, **kwargs):
        key = kwargs['key']
        backend = kwargs['backend']
        default = kwargs['default']
        type = kwargs['type']

        if backend == 'gconf':
            self._setting = GconfSetting(key=key, default=default, type=type)
        elif backend == 'gsettings':
            self._setting = GSetting(key=key, default=default, type=type)
        elif backend == 'config':
            self._setting = ConfigSetting(key=key, type=type)
        elif backend == 'compiz':
            self._setting = CompizSetting(key=key)
        elif backend == 'systemconfig':
            self._setting = SystemConfigSetting(key=key, default=default, type=type)

        if hasattr(self._setting, 'connect_notify') and \
                hasattr(self, 'on_value_changed'):
            log.debug("Connect the setting notify to on_value_changed: %s" % key)
            self.get_setting().connect_notify(self.on_value_changed)
예제 #5
0
 def test_schema(self):
     self.assertEqual('Ambiance', Schema.load_schema(self.interface_schema, self.gtk_theme_key))
     light_theme_setting = GconfSetting(self.light_theme)
     self.assertEqual('close,minimize,maximize:', light_theme_setting.get_schema_value())
     self.assertEqual('Ubuntu Bold 11', GconfSetting(self.title_font).get_schema_value())
예제 #6
0
 def on_compositing_enabled(self, widget, prop):
      setting = GconfSetting("/apps/metacity/general/compositor_effects")
      setting.set_value(widget.get_active())
예제 #7
0
    def __init__(self):
        TweakModule.__init__(self)

        changeicon_hbox = self.create_change_icon_hbox()

        box = TablePack(_("Panel Settings"), (
                    WidgetFactory.create("CheckButton",
                                    label=_("Display warning when removing a panel"),
                                    enable_reset=True,
                                    backend=GConf,
                                    key="/apps/panel/global/confirm_panel_remove"),
                    WidgetFactory.create("CheckButton",
                                    label=_("Complete lockdown of all panels"),
                                    enable_reset=True,
                                    backend=GConf,
                                    key="/apps/panel/global/locked_down"),
                    WidgetFactory.create("CheckButton",
                                    label=_("Enable panel animations"),
                                    enable_reset=True,
                                    backend=GConf,
                                    key="/apps/panel/global/enable_animations"),
                    WidgetFactory.create('ComboBox',
                                         label=_('Me Menu Setting'),
                                         key='/system/indicator/me/display',
                                         texts=[_("Don't Display"), _('Display user name'), _('Display real name')],
                                         values=[0, 1, 2],
                                         backend=GConf,
                                         type='int')
            ))
        self.add_start(box, False, False, 0)

        box = ListPack(_("Menu Settings"), (
                    WidgetFactory.create("CheckButton",
                                    label=_("Show Input Method menu in the context menu"),
                                    enable_reset=True,
                                    backend=GConf,
                                    key="/desktop/gnome/interface/show_input_method_menu"),
                    WidgetFactory.create("CheckButton",
                                    label=_("Show Unicode Control Character menu in the context menu"),
                                    enable_reset=True,
                                    backend=GConf,
                                    key="/desktop/gnome/interface/show_unicode_menu"),
                    WidgetFactory.create("CheckButton",
                                    label=_('Show icons in menus'),
                                    enable_reset=True,
                                    backend=GConf,
                                    key='/desktop/gnome/interface/menus_have_icons'),
                    WidgetFactory.create("CheckButton",
                                    label=_('Show icons on buttons'),
                                    enable_reset=True,
                                    backend=GConf,
                                    key='/desktop/gnome/interface/buttons_have_icons'),
                    changeicon_hbox,
            ))
        self.add_start(box, False, False, 0)

        box = ListPack(_("Screensaver"), (
                    WidgetFactory.create("CheckButton",
                                         label=_("Enable user switching whilst screen is locked."),
                                         backend=GConf,
                                         enable_reset=True,
                                         key="/apps/gnome-screensaver/user_switch_enabled"),
            ))
        self.add_start(box, False, False, 0)

        current_terminal_profile_key = GconfSetting('/apps/gnome-terminal/global/default_profile')
        current_terminal_profile = current_terminal_profile_key.get_value()
        default_show_menubar_key = '/apps/gnome-terminal/profiles/%s/default_show_menubar' % current_terminal_profile
        box = ListPack(_("Terminal"), (
                    WidgetFactory.create("CheckButton",
                                         label=_("Display menubar when Terminal starts up (for current profile)"),
                                         backend=GConf,
                                         enable_reset=True,
                                         key=default_show_menubar_key),
            ))
        self.add_start(box, False, False, 0)

        #TODO unity don't have it
        self.recently_used = Gtk.CheckButton(_('Enable system-wide "Recent Documents" list'))
        self.recently_used.set_active(self.get_state())
        self.recently_used.connect('toggled', self.colleague_changed)
        box = ListPack(_("History"), (
                    self.recently_used,
            ))
        self.add_start(box, False, False, 0)
예제 #8
0
class Window(TweakModule):
    __title__ = _('Window')
    __desc__ = _('Manage Window Manager settings')
    __icon__ = 'preferences-system-windows'
    __category__ = 'desktop'
    __desktop__ = [
        'ubuntu', 'ubuntu-2d', 'gnome', 'gnome-classic', 'gnome-shell',
        'gnome-fallback'
    ]

    left_default = 'close,minimize,maximize:'
    right_default = ':minimize,maximize,close'

    if system.DESKTOP in ('gnome', 'gnome-shell'):
        config = GSetting(key='org.gnome.shell.overrides.button-layout')
    else:
        if system.CODENAME == 'quantal':
            config = GSetting(
                key='org.gnome.desktop.wm.preferences.button-layout')
        else:
            config = GconfSetting(key='/apps/metacity/general/button_layout')

    utext_window_button = _('Window control button position:')
    utext_only_close_button = _('"Close" button only')
    utext_titlebar_wheel = _('Titlebar mouse wheel action:')
    utext_titlebar_double = _('Titlebar double-click action:')
    utext_titlebar_middle = _('Titlebar middle-click action:')
    utext_titlebar_right = _('Titlebar right-click action:')

    def __init__(self):
        TweakModule.__init__(self, 'window.ui')

        close_pattern = re.compile('\w+')

        only_close_switch = Gtk.Switch()
        only_close_switch.connect('notify::active', self.on_switch_activate)
        button_value = self.config.get_value()
        if len(close_pattern.findall(
                button_value)) == 1 and 'close' in button_value:
            only_close_switch.set_active(True)
        only_close_label = Gtk.Label(self.utext_only_close_button)

        if system.CODENAME == 'quantal' and system.DESKTOP == 'ubuntu':
            box = GridPack(
                        (Gtk.Label(self.utext_window_button),
                         self.place_hbox),
                        (only_close_label, only_close_switch),
                        Gtk.Separator(),
                        WidgetFactory.create('ComboBox',
                            label=self.utext_titlebar_wheel,
                            key='org.compiz.gwd.mouse-wheel-action',
                            enable_reset=True,
                            backend='gsettings',
                            texts=[_('None'), _('Roll up')],
                            values=['none', 'shade']),
                        WidgetFactory.create('ComboBox',
                            label=self.utext_titlebar_double,
                            key='org.gnome.desktop.wm.preferences.action-double-click-titlebar',
                            enable_reset=True,
                            backend='gsettings',
                            texts=[_('None'), _('Maximize'), \
                                   _('Minimize'), _('Roll up'), \
                                   _('Lower'), _('Menu')],
                            values=['none', 'toggle-maximize', \
                                    'minimize', 'toggle-shade', \
                                    'lower', 'menu']),
                        WidgetFactory.create('ComboBox',
                            label=self.utext_titlebar_middle,
                            key='org.gnome.desktop.wm.preferences.action-middle-click-titlebar',
                            enable_reset=True,
                            backend="gsettings",
                            texts=[_('None'), _('Maximize'), \
                                   _('Minimize'), _('Roll up'), \
                                   _('Lower'), _('Menu')],
                            values=['none', 'toggle-maximize', \
                                    'minimize', 'toggle-shade', \
                                    'lower', 'menu']),
                        WidgetFactory.create('ComboBox',
                            label=self.utext_titlebar_right,
                            key='org.gnome.desktop.wm.preferences.action-right-click-titlebar',
                            enable_reset=True,
                            backend="gsettings",
                            texts=[_('None'), _('Maximize'), \
                                   _('Minimize'), _('Roll up'), \
                                   _('Lower'), _('Menu')],
                            values=['none', 'toggle-maximize', \
                                    'minimize', 'toggle-shade', \
                                    'lower', 'menu']),
                        )

            self.add_start(box)
        else:
            box = GridPack(
                        (Gtk.Label(self.utext_window_button),
                         self.place_hbox),
                        (only_close_label, only_close_switch),
                        Gtk.Separator(),
                        WidgetFactory.create('ComboBox',
                            label=self.utext_titlebar_wheel,
                            key='/apps/gwd/mouse_wheel_action',
                            enable_reset=True,
                            backend='gconf',
                            texts=[_('None'), _('Roll up')],
                            values=['none', 'shade']),
                        WidgetFactory.create('ComboBox',
                            label=self.utext_titlebar_double,
                            key='/apps/metacity/general/action_double_click_titlebar',
                            enable_reset=True,
                            backend='gconf',
                            texts=[_('None'), _('Maximize'), \
                                    _('Minimize'), _('Roll up'), \
                                    _('Lower'), _('Menu')],
                            values=['none', 'toggle_maximize', \
                                    'minimize', 'toggle_shade', \
                                    'lower', 'menu']),
                        WidgetFactory.create('ComboBox',
                            label=self.utext_titlebar_middle,
                            key='/apps/metacity/general/action_middle_click_titlebar',
                            enable_reset=True,
                            backend="gconf",
                            texts=[_('None'), _('Maximize'), \
                                   _('Maximize Horizontally'), \
                                   _('Maximize Vertically'), \
                                   _('Minimize'), _('Roll up'), \
                                   _('Lower'), _('Menu')],
                                   values=['none', 'toggle_maximize', \
                                           'toggle_maximize_horizontally', \
                                           'toggle_maximize_vertically', \
                                           'minimize', 'toggle_shade', \
                                           'lower', 'menu']),
                        WidgetFactory.create('ComboBox',
                            label=self.utext_titlebar_right,
                            key='/apps/metacity/general/action_right_click_titlebar',
                            enable_reset=True,
                            backend="gconf",
                            texts=[_('None'), _('Maximize'), \
                                    _('Maximize Horizontally'), \
                                    _('Maximize Vertically'), \
                                    _('Minimize'), _('Roll up'), \
                                    _('Lower'), _('Menu')],
                            values=['none', 'toggle_maximize', \
                                    'toggle_maximize_horizontally', \
                                    'toggle_maximize_vertically', \
                                    'minimize', 'toggle_shade', \
                                    'lower', 'menu']),
                    )

            self.add_start(box)

    def on_switch_activate(self, widget, value):
        if widget.get_active():
            self.left_default = 'close:'
            self.right_default = ':close'
        else:
            self.left_default = 'close,minimize,maximize:'
            self.right_default = ':minimize,maximize,close'

        self.on_right_radio_toggled(self.right_radio)
        self.on_left_radio_toggled(self.left_radio)

    def on_right_radio_toggled(self, widget):
        if widget.get_active():
            self.config.set_value(self.right_default)

    def on_left_radio_toggled(self, widget):
        if widget.get_active():
            self.config.set_value(self.left_default)
예제 #9
0
 def on_compositing_enabled(self, widget, prop):
     setting = GconfSetting("/apps/metacity/general/compositor_effects")
     setting.set_value(widget.get_active())