Commit a4869c79 authored by John Stowers's avatar John Stowers

More cleaning of default handling and presentation for ComboBox lists

parent b739c222
......@@ -78,7 +78,10 @@ class KeyThemeSwitcher(GSettingsComboTweak):
make_combo_list_with_default(self._get_valid_key_themes(), "Default"),
def _get_valid_key_themes(self):
......@@ -24,7 +24,7 @@ import json
from gi.repository import Gtk
from gi.repository import GLib
from gtweak.utils import walk_directories, extract_zip_file
from gtweak.utils import walk_directories, extract_zip_file, make_combo_list_with_default
from gtweak.gsettings import GSettingsSetting
from gtweak.gshellwrapper import GnomeShell
from gtweak.tweakmodel import Tweak, TweakGroup
......@@ -93,13 +93,17 @@ class ShellThemeTweak(Tweak):
valid = walk_directories(dirs, lambda d:
os.path.exists(os.path.join(d, "gnome-shell")) and \
os.path.exists(os.path.join(d, "gnome-shell", "gnome-shell.css")))
#the default value to reset the shell is an empty string
valid.extend( ("",) )
#build a combo box with all the valid theme options
#manually add Adwaita to represent the default
cb = build_combo_box_text(
("", "<i>Default</i>"),
*[(v,v) for v in valid])
cb.connect('changed', self._on_combo_changed)
self._combo = cb
......@@ -26,7 +26,7 @@ from gtweak.gconf import GConfSetting
from gi.repository import GLib
def make_combo_list_with_default(opts, default, title=True):
def make_combo_list_with_default(opts, default, title=True, default_text=None):
Turns a list of values into a list of value,name (where name is the
display name a user will see in a combo box). If a value is opt is
......@@ -38,18 +38,18 @@ def make_combo_list_with_default(opts, default, title=True):
themes = []
for t in opts:
if t == "default" and t != default:
if t.lower() == "default" and t != default:
#some themes etc are actually called default. Ick. Dont show them if they
#are not the actual default value
if title:
if title and len(t):
name = t[0].upper() + t[1:]
name = t
if t == default:
name ="%s <i>(default)</i>" % name
name = default_text or "%s <i>(default)</i>" % name
themes.append((t, name))
return themes
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