Commit 0f6b751a authored by John Stowers's avatar John Stowers

Add shell tweaks

parent 567cade4
......@@ -14,6 +14,7 @@ class GConfSetting:
def _run_gconftool(self, command):
if command not in self._cmd_cache:
print "executing gconftool. YUCK!"
p = subprocess.Popen(["gconftool-2", command, self._key], stdin=subprocess.PIPE, stdout=subprocess.PIPE, close_fds=True)
stdout, stderr = p.communicate()
if p.returncode == 0:
......@@ -39,6 +40,14 @@ class GConfSetting:
else:
assert(False)
def set_value(self, value):
if self._type == bool:
self._client.set_bool(self._key, value)
elif self._type == str:
self._client.set_string(self._key, value)
else:
assert(False)
if __name__ == "__main__":
key = "/apps/metacity/general/compositing_manager"
s = GConfSetting(key, bool)
......
......@@ -2,13 +2,13 @@ from gi.repository import Gtk
from gtweak.gsettings import GSettingsSetting
from gtweak.tweakmodel import Tweak, TweakGroup
from gtweak.widgets import TweakSwitch
from gtweak.widgets import GSettingsSwitch
class GSettingsSwitchTweak(Tweak):
def __init__(self, schema_name, key_name):
settings = GSettingsSetting(schema_name)
Tweak.__init__(self, settings.schema_get_summary(key_name), settings.schema_get_description(key_name))
self.widget = TweakSwitch(settings, key_name)
self.widget = GSettingsSwitch(settings, key_name)
TWEAK_GROUPS = (
TweakGroup(
......
from gi.repository import Gtk
from gtweak.gconf import GConfSetting
from gtweak.tweakmodel import Tweak, TweakGroup
from gtweak.widgets import build_label_beside_widget, build_combo_box_text
#class GSettingsSwitchTweak(Tweak):
# def __init__(self, schema_name, key_name):
# settings = GSettingsSetting(schema_name)
# Tweak.__init__(self, settings.schema_get_summary(key_name), settings.schema_get_description(key_name))
# self.widget = TweakSwitch(settings, key_name)
class ShowWindowButtons(Tweak):
def __init__(self):
Tweak.__init__(self, "Window buttons", "Should the maximize and minimize buttons be shown")
self._gconf = GConfSetting("/desktop/gnome/shell/windows/button_layout", str)
combo = build_combo_box_text(
self._gconf.get_value(),
(':close', 'Close Only'),
(':minimize,close', 'Minimize and Close'),
(':maximize,close', 'Maximize and Close'),
(':minimize,maximize,close', 'All'))
combo.connect('changed', self._on_combo_changed)
self.widget = build_label_beside_widget(self.name, combo)
def _on_combo_changed(self, combo):
_iter = combo.get_active_iter()
if _iter:
value = combo.get_model().get_value(_iter, 0)
print "selected", value
self._gconf.set_value(value)
TWEAK_GROUPS = (
TweakGroup(
"GNOME Shell",
ShowWindowButtons()),
)
from gi.repository import Gtk, Gio
class TweakSwitch(Gtk.HBox):
def build_label_beside_widget(txt, widget, hbox=None):
if not hbox:
hbox = Gtk.HBox()
lbl = Gtk.Label(txt)
lbl.props.xalign = 0.0
hbox.pack_start(lbl, True, False, 0)
hbox.pack_start(widget, False, False, 0)
return hbox
def build_combo_box_text(selected, *values):
store = Gtk.ListStore(str, str)
selected_iter = None
for (val, name) in values:
_iter = store.append( (val, name) )
if val == selected:
selected_iter = _iter
combo = Gtk.ComboBox(model=store)
renderer = Gtk.CellRendererText()
combo.pack_start(renderer, True)
combo.add_attribute(renderer, 'text', 1)
if selected_iter:
combo.set_active_iter(selected_iter)
return combo
class GSettingsSwitch(Gtk.HBox):
def __init__(self, settings, key):
Gtk.HBox.__init__(self)
self._settings = settings
lbl = Gtk.Label(self._settings.schema_get_summary(key))
lbl.props.xalign = 0.0
self.pack_start(lbl, True, False, 0)
self._sw = Gtk.Switch()
self.pack_start(self._sw, False, False, 0)
build_label_beside_widget(self._settings.schema_get_summary(key), self._sw, self)
self._settings.bind(key, self._sw, "active", Gio.SettingsBindFlags.DEFAULT)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment