Commit 884869a0 authored by John Stowers's avatar John Stowers

Factor out a GConfComboTweak

parent 273226d6
......@@ -6,33 +6,21 @@ import tempfile
from gi.repository import Gtk
from gi.repository import GLib
from gtweak.gconf import GConfSetting
from gtweak.gsettings import GSettingsSetting
from gtweak.gshellwrapper import GnomeShell
from gtweak.tweakmodel import Tweak, TweakGroup
from gtweak.widgets import GSettingsComboEnumTweak, build_label_beside_widget, build_combo_box_text, build_horizontal_sizegroup
from gtweak.widgets import GConfComboTweak, GSettingsComboEnumTweak, build_label_beside_widget, build_horizontal_sizegroup
class ShowWindowButtons(Tweak):
class ShowWindowButtons(GConfComboTweak):
def __init__(self, **options):
Tweak.__init__(self, "Window buttons", "Should the maximize and minimize buttons be shown", **options)
self._gconf = GConfSetting("/desktop/gnome/shell/windows/button_layout", str)
combo = build_combo_box_text(
self._gconf.get_value(),
(':close', 'Close Only'),
GConfComboTweak.__init__(self,
"/desktop/gnome/shell/windows/button_layout",
str,
((':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)
self.widget_for_size_group = combo
def _on_combo_changed(self, combo):
_iter = combo.get_active_iter()
if _iter:
value = combo.get_model().get_value(_iter, 0)
self._gconf.set_value(value)
(':minimize,maximize,close', 'All')),
**options)
class _ThemeZipChooser(Gtk.FileChooserButton):
def __init__(self):
......
......@@ -2,6 +2,7 @@ from gi.repository import Gtk, Gio
from gtweak.tweakmodel import Tweak
from gtweak.gsettings import GSettingsSetting
from gtweak.gconf import GConfSetting
def build_label_beside_widget(txt, widget, hbox=None):
if not hbox:
......@@ -103,7 +104,7 @@ class GSettingsComboEnumTweak(_GSettingsTweak):
model = self.combo.get_model()
for row in model:
if val == row[0]:
self.combo.set_active_iter(row.iter) #iter_ = self.combo.get_model().get_iter(row)
self.combo.set_active_iter(row.iter)
break
def _on_combo_changed(self, combo):
......@@ -111,3 +112,31 @@ class GSettingsComboEnumTweak(_GSettingsTweak):
if self._values_are_different():
self.settings.set_value(self.key_name, val)
class _GConfTweak(Tweak):
def __init__(self, key_name, key_type, **options):
self.gconf = GConfSetting(key_name, key_type)
Tweak.__init__(self,
self.gconf.schema_get_summary(),
self.gconf.schema_get_description(),
**options)
class GConfComboTweak(_GConfTweak):
def __init__(self, key_name, key_type, key_options, **options):
_GConfTweak.__init__(self, key_name, key_type, **options)
assert len(key_options) > 0
assert len(key_options[0]) == 2
combo = build_combo_box_text(
self.gconf.get_value(),
*key_options)
combo.connect('changed', self._on_combo_changed)
self.widget = build_label_beside_widget(self.name, combo)
self.widget_for_size_group = combo
def _on_combo_changed(self, combo):
_iter = combo.get_active_iter()
if _iter:
value = combo.get_model().get_value(_iter, 0)
self.gconf.set_value(value)
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