[gnome-games/gsoc-seed-games] [lightsoff] Don't load themes twice, don't fade between the same theme



commit bda09dca3f7a45bc19b78c578f485ad28cf89b0f
Author: Tim Horton <hortont svn gnome org>
Date:   Fri Jun 12 19:12:59 2009 -0400

    [lightsoff] Don't load themes twice, don't fade between the same theme

 lightsoff/Settings.js.in           |    8 +++++++-
 lightsoff/themes/tango/theme.js.in |    8 ++++++--
 lightsoff/themes/up/theme.js.in    |    8 ++++++--
 3 files changed, 19 insertions(+), 5 deletions(-)
---
diff --git a/lightsoff/Settings.js.in b/lightsoff/Settings.js.in
index a79536c..9649bb9 100644
--- a/lightsoff/Settings.js.in
+++ b/lightsoff/Settings.js.in
@@ -44,7 +44,13 @@ var Watcher = new SettingsWatcher();
 handlers = {
 	select_theme: function(selector, ud)
 	{
-		theme = imports.themes[selector.get_active_text()].theme;
+		new_theme = imports.themes[selector.get_active_text()].theme;
+		
+		if(new_theme == theme)
+			return;
+		
+		theme = new_theme;
+		theme.map_stuff(main.stage);
 		
 		try
 		{
diff --git a/lightsoff/themes/tango/theme.js.in b/lightsoff/themes/tango/theme.js.in
index 5e7a906..acd1a78 100644
--- a/lightsoff/themes/tango/theme.js.in
+++ b/lightsoff/themes/tango/theme.js.in
@@ -1,9 +1,9 @@
-file_prefix = '/usr/local' + "/share/gnome-games/lightsoff/";
+file_prefix = '@prefix@' + "/share/gnome-games/lightsoff/";
 
 Clutter = imports.gi.Clutter;
 
 var name = "tango";
-
+var mapped = false;
 var light = [ load_svg("off.svg"), load_svg("on.svg") ];
 var arrow = load_svg("arrow.svg");
 var backing = load_svg("backing.svg");
@@ -14,6 +14,10 @@ var led_front = load_svg("led-front.svg");
 
 function map_stuff(a)
 {
+	if(mapped)
+		return;
+	mapped = true;
+	
 	a.add_actor(light[0]);
 	a.add_actor(light[1]);
 	a.add_actor(arrow);
diff --git a/lightsoff/themes/up/theme.js.in b/lightsoff/themes/up/theme.js.in
index 8d49a5c..aaefa47 100644
--- a/lightsoff/themes/up/theme.js.in
+++ b/lightsoff/themes/up/theme.js.in
@@ -1,9 +1,9 @@
-file_prefix = '/usr/local' + "/share/gnome-games/lightsoff/";
+file_prefix = '@prefix@' + "/share/gnome-games/lightsoff/";
 
 Clutter = imports.gi.Clutter;
 
 var name = "up";
-
+var mapped = false;
 var light = [ load_svg("off.svg"), load_svg("on.svg") ];
 var arrow = load_svg("arrow.svg");
 var backing = load_svg("backing.svg");
@@ -14,6 +14,10 @@ var led_front = load_svg("led-front.svg");
 
 function map_stuff(a)
 {
+	if(mapped)
+		return;
+	mapped = true;
+
 	a.add_actor(light[0]);
 	a.add_actor(light[1]);
 	a.add_actor(arrow);



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