[iagno] Flag that theme has been set.



commit 8d0b0fc5d6fcc5a4d79983ed5c8a69ffe3b54de3
Author: Arnaud Bonatti <arnaud bonatti gmail com>
Date:   Fri Jan 17 17:10:15 2020 +0100

    Flag that theme has been set.

 src/iagno.vala         |  2 +-
 src/theme-manager.vala | 19 +++++++++++--------
 2 files changed, 12 insertions(+), 9 deletions(-)
---
diff --git a/src/iagno.vala b/src/iagno.vala
index 888de5e..d1fa006 100644
--- a/src/iagno.vala
+++ b/src/iagno.vala
@@ -451,7 +451,7 @@ private class Iagno : Gtk.Application, BaseApplication
 
         settings.bind ("highlight-playable-tiles", view,            "show-playable-tiles", 
SettingsBindFlags.GET);
         settings.bind ("highlight-turnable-tiles", view,            "show-turnable-tiles", 
SettingsBindFlags.GET);
-        settings.bind ("theme",                    theme_manager,   "theme",               
SettingsBindFlags.GET);
+        settings.bind ("theme",                    theme_manager,   "theme",               
SettingsBindFlags.GET | SettingsBindFlags.NO_SENSITIVITY);
 
         /* New-game screen signals */
         alternate_who_starts_action = (SimpleAction) lookup_action ("alternate-who-starts");
diff --git a/src/theme-manager.vala b/src/theme-manager.vala
index 2b0aaeb..9ae179c 100644
--- a/src/theme-manager.vala
+++ b/src/theme-manager.vala
@@ -28,23 +28,25 @@ private class ThemeManager : Object
 
     internal void gtk_theme_changed ()
     {
-        if (theme == null || (!) theme == "default")
+        if (theme == "" || theme == "default")
             theme = "default";  // yes
     }
 
-    private string? _theme = null;
-    [CCode (notify = false)] internal string? theme
+    private bool theme_set = false;
+    private string _theme;
+    [CCode (notify = false)] internal string theme
     {
-        get { return _theme; }
-        set {
+        private  get { if (!theme_set) assert_not_reached (); return _theme; }
+        internal set
+        {
             KeyFile key = new KeyFile ();
-            if (value == null || (!) value == "default")
+            if (value == "" || value == "default")
                 set_default_theme (ref key);
             else
                 try
                 {
                     string key_path = Path.build_filename (DATA_DIRECTORY, "themes", "key");
-                    string filepath = Path.build_filename (key_path, (!) value);
+                    string filepath = Path.build_filename (key_path, value);
                     if (Path.get_dirname (filepath) != key_path)
                         throw new FileError.FAILED ("Theme file is not in the \"key\" directory.");
 
@@ -57,8 +59,9 @@ private class ThemeManager : Object
                     value = "default";
                 }
 
-            load_theme (key);
+            load_theme (key);   // FIXME loading could (even partially) fail here also
             _theme = value;
+            theme_set = true;
 
             /* redraw all */
             theme_changed ();


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]