Commit 6b910cf7 authored by John Stowers's avatar John Stowers

Annotate default values in theme combo boxes

parent 68ee4d51
......@@ -20,7 +20,7 @@ import os.path
from gi.repository import Gtk
import gtweak
from gtweak.utils import walk_directories
from gtweak.utils import walk_directories, make_combo_list_with_default
from gtweak.tweakmodel import TweakGroup
from gtweak.widgets import GSettingsSwitchTweak, GSettingsComboTweak, build_horizontal_sizegroup
......@@ -29,7 +29,7 @@ class GtkThemeSwitcher(GSettingsComboTweak):
GSettingsComboTweak.__init__(self,
"org.gnome.desktop.interface",
"gtk-theme",
[(t, t) for t in self._get_valid_themes()],
make_combo_list_with_default(self._get_valid_themes(), "Adwaita"),
**options)
def _get_valid_themes(self):
......@@ -46,7 +46,7 @@ class IconThemeSwitcher(GSettingsComboTweak):
GSettingsComboTweak.__init__(self,
"org.gnome.desktop.interface",
"icon-theme",
[(t, t) for t in self._get_valid_icon_themes()],
make_combo_list_with_default(self._get_valid_icon_themes(), "gnome"),
**options)
def _get_valid_icon_themes(self):
......@@ -62,7 +62,7 @@ class CursorThemeSwitcher(GSettingsComboTweak):
GSettingsComboTweak.__init__(self,
"org.gnome.desktop.interface",
"cursor-theme",
[(t, t) for t in self._get_valid_cursor_themes()],
make_combo_list_with_default(self._get_valid_cursor_themes(), "Adwaita"),
**options)
def _get_valid_cursor_themes(self):
......
......@@ -105,7 +105,7 @@ class ShellThemeTweak(Tweak):
#manually add Adwaita to represent the default
cb = build_combo_box_text(
self._settings.get_string(ShellThemeTweak.THEME_GSETTINGS_NAME),
("", "Adwaita"),
("", "default"),
*[(v,v) for v in valid])
cb.connect('changed', self._on_combo_changed)
hb.pack_start(cb, False, False, 0)
......
......@@ -18,7 +18,7 @@
import os.path
import gtweak
from gtweak.utils import walk_directories
from gtweak.utils import walk_directories, make_combo_list_with_default
from gtweak.tweakmodel import TweakGroup
from gtweak.widgets import GConfComboTweak, build_horizontal_sizegroup
from gtweak.gconf import GConfSetting
......@@ -49,7 +49,7 @@ class WindowThemeSwitcher(GConfComboTweak):
GConfComboTweak.__init__(self,
"/desktop/gnome/shell/windows/theme",
str,
[(t, t) for t in self._get_valid_themes()],
make_combo_list_with_default(self._get_valid_themes(), "Adwaita"),
**options)
#also need to change the fallback (metacity) window theme
......
......@@ -26,6 +26,23 @@ from gtweak.gconf import GConfSetting
from gi.repository import GLib
def make_combo_list_with_default(opts, default, title=True):
themes = []
for t in opts:
if t == "default":
continue
if title:
name = t[0].upper() + t[1:]
else:
name = t
if t == default:
name ="%s <i>(default)</i>" % name
themes.append((t, name))
return themes
def walk_directories(dirs, filter_func):
valid = []
try:
......
......@@ -47,7 +47,7 @@ def build_combo_box_text(selected, *values):
combo = Gtk.ComboBox(model=store)
renderer = Gtk.CellRendererText()
combo.pack_start(renderer, True)
combo.add_attribute(renderer, 'text', 1)
combo.add_attribute(renderer, 'markup', 1)
if selected_iter:
combo.set_active_iter(selected_iter)
......
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