[ease] Properly load themes from data directories.
- From: Nate Stedman <natesm src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [ease] Properly load themes from data directories.
- Date: Fri, 11 Jun 2010 04:49:08 +0000 (UTC)
commit b8a1f53fc1d1762cca6a77f65912ba2ef91eae47
Author: Nate Stedman <natesm gmail com>
Date: Fri Jun 11 00:49:02 2010 -0400
Properly load themes from data directories.
src/WelcomeWindow.vala | 30 ++++++++++++++++++++----------
1 files changed, 20 insertions(+), 10 deletions(-)
---
diff --git a/src/WelcomeWindow.vala b/src/WelcomeWindow.vala
index 3e43dbf..0582672 100644
--- a/src/WelcomeWindow.vala
+++ b/src/WelcomeWindow.vala
@@ -35,8 +35,8 @@ public class Ease.WelcomeWindow : Gtk.Window
// themes
private Gee.ArrayList<Theme> themes = new Gee.ArrayList<Theme>();
private Theme selected_theme;
- // TODO : don't hardcode the theme path.
- private const string THEME_DIR = "/usr/share/ease/themes";
+ private const string EASE_DIR = "ease";
+ private const string THEME_DIR = "themes";
// clutter view
private ScrollableEmbed embed;
@@ -154,14 +154,24 @@ public class Ease.WelcomeWindow : Gtk.Window
// load themes
try
{
- var dir = GLib.Dir.open(THEME_DIR, 0);
-
- string name = dir.read_name();
- while (name != null)
+ string[] data_dirs = Environment.get_system_data_dirs();
+ foreach (string dir in data_dirs)
{
- var path = Path.build_filename(THEME_DIR, name);
- themes.add(JSONParser.theme(path));
- name = dir.read_name();
+ var filename = Path.build_filename(dir, EASE_DIR, THEME_DIR);
+ var file = File.new_for_path(filename);
+
+ if (file.query_exists(null))
+ {
+ var directory = GLib.Dir.open(filename, 0);
+
+ string name = directory.read_name();
+ while (name != null)
+ {
+ var path = Path.build_filename(filename, name);
+ themes.add(JSONParser.theme(path));
+ name = directory.read_name();
+ }
+ }
}
}
catch (Error e) { error_dialog("Error Loading Themes", e.message); }
@@ -418,4 +428,4 @@ public class Ease.WelcomeWindow : Gtk.Window
preview_background.height = embed.height;
}
}
-}
\ No newline at end of file
+}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]