[gnome-games] [lightsoff] Implement pretty-printed theme names
- From: Tim Horton <hortont src gnome org>
- To: svn-commits-list gnome org
- Subject: [gnome-games] [lightsoff] Implement pretty-printed theme names
- Date: Thu, 16 Jul 2009 22:30:26 +0000 (UTC)
commit a0216a8cfaaf8f2c008bca0263e2691cfded0075
Author: Tim Horton <hortont424 gmail com>
Date: Fri Jun 26 23:47:27 2009 -0400
[lightsoff] Implement pretty-printed theme names
lightsoff/Settings.js | 39 ++++++++++++++++++++++-------------
lightsoff/themes/tango/theme.js.in | 4 +-
lightsoff/themes/up/theme.js.in | 4 +-
3 files changed, 28 insertions(+), 19 deletions(-)
---
diff --git a/lightsoff/Settings.js b/lightsoff/Settings.js
index b83c8e9..7ffc9dc 100644
--- a/lightsoff/Settings.js
+++ b/lightsoff/Settings.js
@@ -9,23 +9,40 @@ GConf.init(Seed.argv);
// Defaults
var theme, score;
+// Map theme names to themes
+var themes = {};
+
+load_themes();
+
try
{
gconf_client = GConf.Client.get_default();
score = gconf_client.get_int("/apps/lightsoff/score");
- theme = imports.themes[gconf_client.get_string("/apps/lightsoff/theme")].theme;
+ theme = themes[gconf_client.get_string("/apps/lightsoff/theme")];
}
catch(e)
{
print("Couldn't load settings from GConf.");
- theme = imports.themes["tango"].theme;
+ theme = themes["Tango"];
score = 1;
}
+function load_themes()
+{
+ file = Gio.file_new_for_path(main.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;
+ }
+}
+
// Settings Event Handler
SettingsWatcher = new GType({
- parent: Gtk.Button.type, // Can I make something inherit directly from GObject?!
+ parent: Gtk.Button.type, // TODO: Can I make something inherit directly from GObject?!
name: "SettingsWatcher",
signals: [{name: "theme_changed"}],
init: function()
@@ -41,7 +58,7 @@ var Watcher = new SettingsWatcher();
handlers = {
select_theme: function(selector, ud)
{
- new_theme = imports.themes[selector.get_active_text()].theme;
+ new_theme = themes[selector.get_active_text()];
if(new_theme == theme)
return;
@@ -59,10 +76,6 @@ handlers = {
}
Watcher.signal.theme_changed.emit();
- },
- close_settings: function()
- {
- //settings_dialog.hide_all();
}
};
@@ -92,17 +105,13 @@ function populate_theme_selector(selector)
selector.pack_start(cell, true);
selector.add_attribute(cell, "text", 0);
- file = Gio.file_new_for_path(main.file_prefix+"/themes");
- enumerator = file.enumerate_children("standard::name");
-
var i = 0;
- while((child = enumerator.next_file()))
+ for(var th in themes)
{
- var fname = child.get_name();
- selector.append_text(fname);
+ selector.append_text(themes[th].name);
- if(fname == theme.name)
+ if(themes[th].name == theme.name)
selector.set_active(i);
i++;
diff --git a/lightsoff/themes/tango/theme.js.in b/lightsoff/themes/tango/theme.js.in
index 0fbe597..d6cb044 100644
--- a/lightsoff/themes/tango/theme.js.in
+++ b/lightsoff/themes/tango/theme.js.in
@@ -2,7 +2,7 @@ file_prefix = '@prefix@' + "/share/gnome-games/lightsoff/";
Clutter = imports.gi.Clutter;
-var name = "tango";
+var name = "Tango";
var mapped = false;
var light = [ load_svg("off.svg"), load_svg("on.svg") ];
var arrow = load_svg("arrow.svg");
@@ -38,7 +38,7 @@ function load_svg(file)
// TODO: either imports should set the cwd (and this can go away),
// or we need some quick way to compose paths. Really, we need that anyway.
- var tx = new Clutter.Texture({filename: file_prefix + "themes/" + name + "/" + file});
+ var tx = new Clutter.Texture({filename: file_prefix + "themes/tango/" + file});
tx.filter_quality = Clutter.TextureQuality.HIGH;
return tx;
}
diff --git a/lightsoff/themes/up/theme.js.in b/lightsoff/themes/up/theme.js.in
index 3394808..efc097e 100644
--- a/lightsoff/themes/up/theme.js.in
+++ b/lightsoff/themes/up/theme.js.in
@@ -2,7 +2,7 @@ file_prefix = '@prefix@' + "/share/gnome-games/lightsoff/";
Clutter = imports.gi.Clutter;
-var name = "up";
+var name = "Shine";
var mapped = false;
var light = [ load_svg("off.svg"), load_svg("on.svg") ];
var arrow = load_svg("arrow.svg");
@@ -38,7 +38,7 @@ function load_svg(file)
// TODO: either imports should set the cwd (and this can go away),
// or we need some quick way to compose paths. Really, we need that anyway.
- var tx = new Clutter.Texture({filename: file_prefix + "themes/" + name + "/" + file});
+ var tx = new Clutter.Texture({filename: file_prefix + "themes/up/" + file});
tx.filter_quality = Clutter.TextureQuality.HIGH;
return tx;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]