From 16fe2e5d0525422ba6ca5db9e92a93d17caae302 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Frings-F=C3=BCrst?= Date: Sun, 27 Sep 2015 15:05:13 +0200 Subject: Imported Upstream version 0.6.6 --- src/utilities/config.vala | 35 +++++++++++++++++++++++++++-------- 1 file changed, 27 insertions(+), 8 deletions(-) (limited to 'src/utilities/config.vala') diff --git a/src/utilities/config.vala b/src/utilities/config.vala index 538602d..5dedddb 100644 --- a/src/utilities/config.vala +++ b/src/utilities/config.vala @@ -161,7 +161,9 @@ public class Config : GLib.Object { load_themes(theme_name); - if (error_occrured) save(); + if (error_occrured) { + save(); + } } ///////////////////////////////////////////////////////////////////// @@ -177,18 +179,19 @@ public class Config : GLib.Object { // load global themes var d = Dir.open(Paths.global_themes); while ((name = d.read_name()) != null) { - var theme = new Theme(Paths.global_themes + "/" + name); + var new_theme = new Theme(Paths.global_themes + "/" + name); - if (theme.load()) - themes.add(theme); + if (new_theme.load()) { + themes.add(new_theme); + } } // load local themes d = Dir.open(Paths.local_themes); while ((name = d.read_name()) != null) { - var theme = new Theme(Paths.local_themes + "/" + name); - if (theme.load()) - themes.add(theme); + var new_theme = new Theme(Paths.local_themes + "/" + name); + if (new_theme.load()) + themes.add(new_theme); } } catch (Error e) { @@ -211,10 +214,26 @@ public class Config : GLib.Object { warning("Theme \"" + current + "\" not found! Using fallback..."); } theme.load_images(); + } else { + error("No theme found!"); } - else error("No theme found!"); } + ///////////////////////////////////////////////////////////////////// + /// Returns true if a loaded theme has the given name or is in a + /// directory with the given name. + ///////////////////////////////////////////////////////////////////// + + public bool has_theme(string name) { + + foreach (var theme in themes) { + if (theme.name == name || theme.directory.has_suffix(name)) { + return true; + } + } + + return false; + } } } -- cgit v1.2.3