diff options
author | Jörg Frings-Fürst <debian@jff-webhosting.net> | 2015-10-04 13:00:51 +0200 |
---|---|---|
committer | Jörg Frings-Fürst <debian@jff-webhosting.net> | 2015-10-04 13:00:51 +0200 |
commit | 7556967bf57453d412a8f18633599f38806f8620 (patch) | |
tree | b7403b6ac1b5cf5db9462c3ca6d52b973df24819 /src/themes/theme.vala | |
parent | 16fe2e5d0525422ba6ca5db9e92a93d17caae302 (diff) |
Imported Upstream version 0.6.7upstream/0.6.7
Diffstat (limited to 'src/themes/theme.vala')
-rw-r--r-- | src/themes/theme.vala | 46 |
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. ///////////////////////////////////////////////////////////////////// |