summaryrefslogtreecommitdiff
path: root/src/themes/theme.vala
diff options
context:
space:
mode:
authorJörg Frings-Fürst <debian@jff-webhosting.net>2015-10-04 13:00:55 +0200
committerJörg Frings-Fürst <debian@jff-webhosting.net>2015-10-04 13:00:55 +0200
commite9b06dcd5df3f22bc3a7acd5c57a4bfdf4ef38f5 (patch)
tree6e9494073395f49fb3eec61d2c5ae40f5f3de2af /src/themes/theme.vala
parent19fe9cfe9a84ba453271d8d8e32f4aa9fe2be14e (diff)
parent7556967bf57453d412a8f18633599f38806f8620 (diff)
Merge tag 'upstream/0.6.7'
Upstream version 0.6.7
Diffstat (limited to 'src/themes/theme.vala')
-rw-r--r--src/themes/theme.vala46
1 files changed, 43 insertions, 3 deletions
diff --git a/src/themes/theme.vala b/src/themes/theme.vala
index 98e8994..2e256f9 100644
--- a/src/themes/theme.vala
+++ b/src/themes/theme.vala
@@ -87,14 +87,44 @@ public class Theme : GLib.Object {
this.active_slice_layers.clear();
this.inactive_slice_layers.clear();
+ if (!GLib.File.new_for_path(this.directory).query_exists()) {
+ return false;
+ }
+
+ string config_file = this.directory + "/theme.xml";
+
+ if (!GLib.File.new_for_path(config_file).query_exists()) {
+ try {
+ // detect whether theme is one directory deeper
+ string child;
+ bool success = false;
+
+ // load global themes
+ var d = Dir.open(this.directory);
+ while ((child = d.read_name()) != null && !success) {
+ config_file = this.directory + "/" + child + "/theme.xml";
+ if (GLib.File.new_for_path(config_file).query_exists()) {
+ this.directory = this.directory + "/" + child;
+ success = true;
+ }
+ }
+
+ if (!success) {
+ return false;
+ }
+ } catch (Error e) {
+ warning (e.message);
+ return false;
+ }
+ }
+
this.preview_icon = new Icon(this.directory + "/preview.png", 36);
Xml.Parser.init();
- string path = this.directory + "/theme.xml";
- Xml.Doc* themeXML = Xml.Parser.parse_file(path);
+ Xml.Doc* themeXML = Xml.Parser.parse_file(config_file);
if (themeXML == null) {
- warning("Failed to add theme: \"" + path + "\" not found!");
+ warning("Failed to add theme: \"" + config_file + "\" not found!");
return false;
}
@@ -151,6 +181,7 @@ public class Theme : GLib.Object {
}
}
+
/////////////////////////////////////////////////////////////////////
/// Loads all images of the theme.
/////////////////////////////////////////////////////////////////////
@@ -165,6 +196,15 @@ public class Theme : GLib.Object {
}
/////////////////////////////////////////////////////////////////////
+ /// Returns true if the theme is installed to the local themes
+ /// directory.
+ /////////////////////////////////////////////////////////////////////
+
+ public bool is_local() {
+ return this.directory.has_prefix(Paths.local_themes);
+ }
+
+ /////////////////////////////////////////////////////////////////////
/// The following methods parse specific parts of the theme file.
/// Nothing special here, just some boring code.
/////////////////////////////////////////////////////////////////////