[gnome-games/gsoc-seed-games] [same-gnome-clutter] Pull ThemeLoader over from LightsOff
- From: Tim Horton <hortont src gnome org>
- To: svn-commits-list gnome org
- Subject: [gnome-games/gsoc-seed-games] [same-gnome-clutter] Pull ThemeLoader over from LightsOff
- Date: Sun, 12 Jul 2009 03:23:11 +0000 (UTC)
commit 11ec106f4bcfa20a5c2f9ac2847343b0aea47fdd
Author: Tim Horton <hortont424 gmail com>
Date: Sat Jul 11 23:12:37 2009 -0400
[same-gnome-clutter] Pull ThemeLoader over from LightsOff
configure.in | 2 +-
same-gnome-clutter/Makefile.am | 6 ++-
same-gnome-clutter/data/themes/tango/Makefile.am | 8 ++--
same-gnome-clutter/data/themes/tango/theme.js | 12 ++++++
same-gnome-clutter/src/ThemeLoader.js | 38 ++++++++++++++++++++
same-gnome-clutter/src/light.js | 17 +--------
same-gnome-clutter/src/main.js | 7 +++-
.../src/{settings.js.in => path.js.in} | 0
8 files changed, 65 insertions(+), 25 deletions(-)
---
diff --git a/configure.in b/configure.in
index 26773cd..194ff9b 100644
--- a/configure.in
+++ b/configure.in
@@ -1093,7 +1093,7 @@ same-gnome-clutter/data/themes/tango/Makefile
same-gnome-clutter/same-gnome-clutter
same-gnome-clutter/same-gnome-clutter.desktop.in
same-gnome-clutter/same-gnome-clutter-c.desktop.in
-same-gnome-clutter/src/settings.js
+same-gnome-clutter/src/path.js
lightsoff/Makefile
lightsoff/help/Makefile
lightsoff/src/lightsoff
diff --git a/same-gnome-clutter/Makefile.am b/same-gnome-clutter/Makefile.am
index 6935331..3abc1c3 100644
--- a/same-gnome-clutter/Makefile.am
+++ b/same-gnome-clutter/Makefile.am
@@ -9,7 +9,8 @@ same_DATA = \
src/main.js \
data/same-gnome.ui \
src/score.js \
- src/settings.js
+ src/path.js \
+ src/ThemeLoader.js
same_gnome_clutter_c_SOURCES = same.c
same_gnome_clutter_c_CFLAGS = `pkg-config --cflags clutter-0.9 glib-2.0`
@@ -32,5 +33,6 @@ EXTRA_DIST = \
src/main.js \
data/same-gnome.ui \
src/score.js \
- src/settings.js.in
+ src/path.js.in \
+ src/ThemeLoader.js.in
diff --git a/same-gnome-clutter/data/themes/tango/Makefile.am b/same-gnome-clutter/data/themes/tango/Makefile.am
index fa1efd4..54a265d 100644
--- a/same-gnome-clutter/data/themes/tango/Makefile.am
+++ b/same-gnome-clutter/data/themes/tango/Makefile.am
@@ -4,14 +4,14 @@ theme_DATA = \
blue.svg \
green.svg \
red.svg \
- yellow.svg
+ yellow.svg \
+ theme.js
EXTRA_DIST = \
bkg.svg \
blue.svg \
green.svg \
red.svg \
- yellow.svg
-
-CLEANFILES = theme.js
+ yellow.svg \
+ theme.js
diff --git a/same-gnome-clutter/data/themes/tango/theme.js b/same-gnome-clutter/data/themes/tango/theme.js
new file mode 100644
index 0000000..23210b5
--- /dev/null
+++ b/same-gnome-clutter/data/themes/tango/theme.js
@@ -0,0 +1,12 @@
+ThemeLoader = imports.ThemeLoader;
+
+var name = "Tango";
+
+var colors = [ ThemeLoader.load_svg("tango", "blue.svg"),
+ ThemeLoader.load_svg("tango", "green.svg"),
+ ThemeLoader.load_svg("tango", "red.svg"),
+ ThemeLoader.load_svg("tango", "yellow.svg") ];
+
+var loaded = false;
+var textures = [colors[0], colors[1], colors[2], colors[3]];
+
diff --git a/same-gnome-clutter/src/ThemeLoader.js b/same-gnome-clutter/src/ThemeLoader.js
new file mode 100644
index 0000000..cae4caa
--- /dev/null
+++ b/same-gnome-clutter/src/ThemeLoader.js
@@ -0,0 +1,38 @@
+Clutter = imports.gi.Clutter;
+Gio = imports.gi.Gio;
+
+function load_svg(theme, file)
+{
+ var tx = new Clutter.Texture({filename: imports.path.file_prefix + "themes/"
+ + theme + "/" + file});
+ tx.filter_quality = Clutter.TextureQuality.HIGH;
+ tx.hide();
+ return tx;
+}
+
+function load_theme(stage, theme)
+{
+ if(theme.loaded)
+ return;
+
+ theme.loaded = true;
+
+ for(actor in theme.textures)
+ stage.add_actor(theme.textures[actor]);
+}
+
+function load_themes()
+{
+ themes = {};
+
+ file = Gio.file_new_for_path(imports.path.file_prefix + "/themes");
+ enumerator = file.enumerate_children("standard::name");
+
+ while((child = enumerator.next_file()))
+ {
+ var c_theme = imports.themes[child.get_name()].theme;
+ themes[c_theme.name] = c_theme;
+ }
+
+ return themes;
+}
diff --git a/same-gnome-clutter/src/light.js b/same-gnome-clutter/src/light.js
index b6706df..929bbd6 100644
--- a/same-gnome-clutter/src/light.js
+++ b/same-gnome-clutter/src/light.js
@@ -1,20 +1,9 @@
Clutter = imports.gi.Clutter;
GLib = imports.gi.GLib;
main = imports.main;
-settings = imports.settings;
var tile_svg_size = 50;
-function load_svg(file)
-{
- var tx = new Clutter.Texture({filename: settings.file_prefix+"/themes/tango/" + file});
- tx.filter_quality = Clutter.TextureQuality.HIGH;
- return tx;
-}
-
-var colors = ["blue.svg", "green.svg", "red.svg", "yellow.svg"];
-var loaded_colors = {};
-
Light = new GType({
parent: Clutter.Group.type,
name: "Light",
@@ -28,11 +17,7 @@ Light = new GType({
// Public
this.visited = false;
- if(loaded_colors[state])
- this.on = new Clutter.Clone({source: loaded_colors[state]});
- else
- this.on = loaded_colors[state] = load_svg(colors[state]);
-
+ this.on = new Clutter.Clone({source: main.theme.colors[state]});
this.get_state = function ()
{
diff --git a/same-gnome-clutter/src/main.js b/same-gnome-clutter/src/main.js
index 98367f8..146cfbf 100755
--- a/same-gnome-clutter/src/main.js
+++ b/same-gnome-clutter/src/main.js
@@ -22,6 +22,7 @@ GLib = imports.gi.GLib;
Pango = imports.gi.Pango;
GObject = imports.gi.GObject;
GnomeGamesSupport = imports.gi.GnomeGamesSupport;
+ThemeLoader = imports.ThemeLoader;
GtkClutter.init(Seed.argv);
GnomeGamesSupport.runtime_init("same-gnome");
@@ -32,7 +33,6 @@ GConf.init(Seed.argv);
light = imports.light;
board = imports.board;
score = imports.score;
-settings = imports.settings;
about = imports.about;
handlers = {
@@ -55,7 +55,7 @@ handlers = {
};
b = new Gtk.Builder();
-b.add_from_file(settings.file_prefix + "/same-gnome.ui");
+b.add_from_file(imports.path.file_prefix + "/same-gnome.ui");
b.connect_signals(handlers);
var window = b.get_object("game_window");
@@ -76,6 +76,9 @@ clutter_embed.set_size_request((tiles_w * tile_size),(tiles_h * tile_size));
window.show_all();
stage.show_all();
+theme = ThemeLoader.load_themes().Tango;
+ThemeLoader.load_theme(stage, theme);
+
var board = new board.Board();
stage.add_actor(board);
stage.show_all();
diff --git a/same-gnome-clutter/src/settings.js.in b/same-gnome-clutter/src/path.js.in
similarity index 100%
rename from same-gnome-clutter/src/settings.js.in
rename to same-gnome-clutter/src/path.js.in
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]