[gnome-tweak-tool] Tweak windo theme



commit af1c8d78a39a3912a60c3bc7759f4ee8b78b367e
Author: John Stowers <john stowers gmail com>
Date:   Wed Apr 27 08:37:46 2011 +1200

    Tweak windo theme

 NEWS                             |    1 +
 gtweak/tweaks/tweak_interface.py |    5 ++---
 gtweak/tweaks/tweak_windows.py   |   22 ++++++++++++++++++++++
 3 files changed, 25 insertions(+), 3 deletions(-)
---
diff --git a/NEWS b/NEWS
index ade2749..68ca9d7 100644
--- a/NEWS
+++ b/NEWS
@@ -1,5 +1,6 @@
 3.0.1
    * Fix localization
+   * Tweak window theme
    * Tweak week date in calendar (Emmanuele Bassi)
    * Tweak cursor themes (Andrea Fagiani)
    * Support user installed themes in $HOME (Andrea Fagiani)
diff --git a/gtweak/tweaks/tweak_interface.py b/gtweak/tweaks/tweak_interface.py
index d941960..de21220 100644
--- a/gtweak/tweaks/tweak_interface.py
+++ b/gtweak/tweaks/tweak_interface.py
@@ -15,7 +15,6 @@
 # You should have received a copy of the GNU General Public License
 # along with gnome-tweak-tool.  If not, see <http://www.gnu.org/licenses/>.
 
-import os
 import os.path
 
 from gi.repository import Gtk
@@ -24,7 +23,7 @@ import gtweak
 from gtweak.tweakmodel import TweakGroup
 from gtweak.widgets import GSettingsSwitchTweak, GSettingsComboTweak, build_horizontal_sizegroup
 
-class ThemeSwitcher(GSettingsComboTweak):
+class GtkThemeSwitcher(GSettingsComboTweak):
     def __init__(self, **options):
         GSettingsComboTweak.__init__(self,
             "org.gnome.desktop.interface",
@@ -89,7 +88,7 @@ TWEAK_GROUPS = (
             "Interface",
             GSettingsSwitchTweak("org.gnome.desktop.interface", "menus-have-icons"),
             GSettingsSwitchTweak("org.gnome.desktop.interface", "buttons-have-icons"),
-            ThemeSwitcher(size_group=sg),
+            GtkThemeSwitcher(size_group=sg),
             IconThemeSwitcher(size_group=sg),
             CursorThemeSwitcher(size_group=sg)),
 )
diff --git a/gtweak/tweaks/tweak_windows.py b/gtweak/tweaks/tweak_windows.py
index 7c43c9f..13cfe3d 100644
--- a/gtweak/tweaks/tweak_windows.py
+++ b/gtweak/tweaks/tweak_windows.py
@@ -15,6 +15,9 @@
 # You should have received a copy of the GNU General Public License
 # along with gnome-tweak-tool.  If not, see <http://www.gnu.org/licenses/>.
 
+import os.path
+
+import gtweak
 from gtweak.tweakmodel import TweakGroup
 from gtweak.widgets import GConfComboTweak, build_horizontal_sizegroup
 
@@ -31,11 +34,30 @@ class ActionClickTitlebarTweak(GConfComboTweak):
             [(o, o.replace("_"," ").title()) for o in schema_options],
             **options)
 
+class WindowThemeSwitcher(GConfComboTweak):
+    def __init__(self, **options):
+        GConfComboTweak.__init__(self,
+            "/apps/metacity/general/theme",
+            str,
+            [(t, t) for t in self._get_valid_themes()],
+            **options)
+
+    def _get_valid_themes(self):
+        valid = []
+        dirs = ( os.path.join(gtweak.DATA_DIR, "themes"),
+                 os.path.join(os.path.expanduser("~"), ".themes"))
+        for thdir in dirs:
+            for t in os.listdir(thdir):
+                if os.path.exists(os.path.join(thdir, t, "metacity-1")):
+                     valid.append(t)
+        return valid
+
 sg = build_horizontal_sizegroup()
 
 TWEAK_GROUPS = (
         TweakGroup(
             "Windows",
+            WindowThemeSwitcher(size_group=sg),
             ActionClickTitlebarTweak("/apps/metacity/general/action_double_click_titlebar", size_group=sg),
             ActionClickTitlebarTweak("/apps/metacity/general/action_middle_click_titlebar", size_group=sg),
             ActionClickTitlebarTweak("/apps/metacity/general/action_right_click_titlebar", size_group=sg)),



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]