[gnome-tweak-tool] More cleaning of default handling and presentation for ComboBox lists
- From: John Stowers <jstowers src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-tweak-tool] More cleaning of default handling and presentation for ComboBox lists
- Date: Mon, 20 Jun 2011 09:16:58 +0000 (UTC)
commit a4869c7959fe63f3a6cd574acdd54e345a789dc0
Author: John Stowers <john stowers gmail com>
Date: Mon Jun 20 10:17:53 2011 +1200
More cleaning of default handling and presentation for ComboBox lists
gtweak/tweaks/tweak_interface.py | 5 ++++-
gtweak/tweaks/tweak_shell.py | 10 +++++++---
gtweak/utils.py | 8 ++++----
3 files changed, 15 insertions(+), 8 deletions(-)
---
diff --git a/gtweak/tweaks/tweak_interface.py b/gtweak/tweaks/tweak_interface.py
index 4b74044..97e8982 100644
--- a/gtweak/tweaks/tweak_interface.py
+++ b/gtweak/tweaks/tweak_interface.py
@@ -78,7 +78,10 @@ class KeyThemeSwitcher(GSettingsComboTweak):
GSettingsComboTweak.__init__(self,
"org.gnome.desktop.interface",
"gtk-key-theme",
- make_combo_list_with_default(self._get_valid_key_themes(), "Default"),
+ make_combo_list_with_default(
+ self._get_valid_key_themes(),
+ "Default",
+ default_text="<i>Default</i>"),
**options)
def _get_valid_key_themes(self):
diff --git a/gtweak/tweaks/tweak_shell.py b/gtweak/tweaks/tweak_shell.py
index 2088e41..c8216ff 100644
--- a/gtweak/tweaks/tweak_shell.py
+++ b/gtweak/tweaks/tweak_shell.py
@@ -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(
self._settings.get_string(ShellThemeTweak.THEME_GSETTINGS_NAME),
- ("", "<i>Default</i>"),
- *[(v,v) for v in valid])
+ *make_combo_list_with_default(
+ valid,
+ "",
+ default_text="<i>Default</i>"))
cb.connect('changed', self._on_combo_changed)
self._combo = cb
diff --git a/gtweak/utils.py b/gtweak/utils.py
index cdfd05d..42d3502 100644
--- a/gtweak/utils.py
+++ b/gtweak/utils.py
@@ -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
continue
- if title:
+ if title and len(t):
name = t[0].upper() + t[1:]
else:
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
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]