[gnome-games] lightsoff: Watch for Gtk theme changes, and update theme coloring



commit c809c903da8d3cc7c40294b655f472ceb4e492f4
Author: Tim Horton <hortont424 gmail com>
Date:   Sun Oct 11 12:24:59 2009 -0400

    lightsoff: Watch for Gtk theme changes, and update theme coloring

 lightsoff/data/themes/tango/theme.js |    2 +-
 lightsoff/src/Game.js                |    7 ++++++-
 lightsoff/src/Settings.js            |   16 ++++++++++++++++
 3 files changed, 23 insertions(+), 2 deletions(-)
---
diff --git a/lightsoff/data/themes/tango/theme.js b/lightsoff/data/themes/tango/theme.js
index bd515d4..71056a4 100644
--- a/lightsoff/data/themes/tango/theme.js
+++ b/lightsoff/data/themes/tango/theme.js
@@ -100,7 +100,7 @@ function reload_theme()
     var gtk_settings = Gtk.Settings.get_default();
     var gtk_color_scheme = gtk_settings.gtk_color_scheme;
     var c = new Clutter.Color();
-    c.from_string(gtk_color_scheme.match(/selected_bg_color: (.*)/)[1]);
+    c.from_string(gtk_color_scheme.match(/selected_bg_color: (.*);?/)[1]);
     
     // Remove the previous theme's cached lights
     if(light.length > 0)
diff --git a/lightsoff/src/Game.js b/lightsoff/src/Game.js
index 1d35859..2f17d28 100644
--- a/lightsoff/src/Game.js
+++ b/lightsoff/src/Game.js
@@ -53,7 +53,7 @@ GameView = new GType({
 			board_view = new_board_view;
 			board_view.set_playable(true);
 			keycursor_view.raise_top();
-			new_board_view = timeline = 0;
+			new_board_view = timeline = null;
 			
 			if(queue_theme_change)
 			{
@@ -184,6 +184,11 @@ GameView = new GType({
 		
 		// Public
 		
+		this.is_animating = function ()
+		{
+		    return (timeline != null);
+		}
+		
 		// Queue an actor to be removed after the board is finished reloading
 		this.queue_actor_remove = function (actor)
 		{
diff --git a/lightsoff/src/Settings.js b/lightsoff/src/Settings.js
index 1a7de4d..74d6b17 100644
--- a/lightsoff/src/Settings.js
+++ b/lightsoff/src/Settings.js
@@ -68,6 +68,22 @@ SettingsWatcher = new GType({
 
 var Watcher = new SettingsWatcher();
 
+// Watch for Gtk theme change, reload theme!
+
+function reload_on_theme_change(widget, last_style, user_data)
+{
+    if(main.game.is_animating())
+        return;
+
+    theme.reload_theme();
+    ThemeLoader.load_theme(main.stage, theme);
+    Watcher.signal.theme_changed.emit();
+}
+
+var fakeWindow = new Gtk.Window();
+fakeWindow.realize();
+fakeWindow.signal.style_set.connect(reload_on_theme_change);
+
 // Settings UI
 
 handlers = {



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