[gnome-tweak-tool] Annotate default values in theme combo boxes
- From: John Stowers <jstowers src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-tweak-tool] Annotate default values in theme combo boxes
- Date: Mon, 6 Jun 2011 04:53:43 +0000 (UTC)
commit 6b910cf72e5e73f5b56219315f8c44f8b2ea7d00
Author: John Stowers <john stowers gmail com>
Date: Mon Jun 6 16:43:23 2011 +1200
Annotate default values in theme combo boxes
gtweak/tweaks/tweak_interface.py | 8 ++++----
gtweak/tweaks/tweak_shell.py | 2 +-
gtweak/tweaks/tweak_windows.py | 4 ++--
gtweak/utils.py | 17 +++++++++++++++++
gtweak/widgets.py | 2 +-
5 files changed, 25 insertions(+), 8 deletions(-)
---
diff --git a/gtweak/tweaks/tweak_interface.py b/gtweak/tweaks/tweak_interface.py
index 33ee362..81dae59 100644
--- a/gtweak/tweaks/tweak_interface.py
+++ b/gtweak/tweaks/tweak_interface.py
@@ -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):
diff --git a/gtweak/tweaks/tweak_shell.py b/gtweak/tweaks/tweak_shell.py
index f902590..dab5509 100644
--- a/gtweak/tweaks/tweak_shell.py
+++ b/gtweak/tweaks/tweak_shell.py
@@ -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)
diff --git a/gtweak/tweaks/tweak_windows.py b/gtweak/tweaks/tweak_windows.py
index f36acd5..275728e 100644
--- a/gtweak/tweaks/tweak_windows.py
+++ b/gtweak/tweaks/tweak_windows.py
@@ -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
diff --git a/gtweak/utils.py b/gtweak/utils.py
index c8cb19c..90d782a 100644
--- a/gtweak/utils.py
+++ b/gtweak/utils.py
@@ -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:
diff --git a/gtweak/widgets.py b/gtweak/widgets.py
index 5138f25..d1b3907 100644
--- a/gtweak/widgets.py
+++ b/gtweak/widgets.py
@@ -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)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]