[geary/wip/default-spellcheck-lang: 3/4] Try harder to ensure a spell checker is enabled by default



commit f27f2fb91fca6749f4993838a238fe42104c14ba
Author: Michael Gratton <mike vee net>
Date:   Thu May 23 00:04:45 2019 +0200

    Try harder to ensure a spell checker is enabled by default
    
    When no spell checker langauges are explicitly set, use the set of
    preferred languages for spell checking. Make spell-check-languages
    setting nullable so we can differenciate between "use default"
    and "disable spellchecking".

 desktop/org.gnome.Geary.gschema.xml      | 10 ++++----
 src/client/application/geary-config.vala | 39 +++++++++++++++++++++++++-------
 2 files changed, 37 insertions(+), 12 deletions(-)
---
diff --git a/desktop/org.gnome.Geary.gschema.xml b/desktop/org.gnome.Geary.gschema.xml
index e48283e8..6c9d77b5 100644
--- a/desktop/org.gnome.Geary.gschema.xml
+++ b/desktop/org.gnome.Geary.gschema.xml
@@ -63,10 +63,12 @@
         <description>True if we should display a short preview of each message.</description>
     </key>
 
-    <key name="spell-check-languages" type="as">
-         <default>[]</default>
-         <summary>Languages that shall be used in the spell checker</summary>
-         <description>List of the languages to use in the spell checker.</description>
+    <key name="spell-check-languages" type="mas">
+        <default>nothing</default>
+        <summary>Languages that shall be used in the spell checker</summary>
+        <description>A list of POSIX locales, with the empty list
+        disabling spell checking and the null list using desktop
+        languages by default.</description>
     </key>
 
     <key name="spell-check-visible-languages" type="as">
diff --git a/src/client/application/geary-config.vala b/src/client/application/geary-config.vala
index 2dd94f53..446b3584 100644
--- a/src/client/application/geary-config.vala
+++ b/src/client/application/geary-config.vala
@@ -114,22 +114,45 @@ public class Configuration {
         get { return settings.get_boolean(DISPLAY_PREVIEW_KEY); }
     }
 
+    /**
+     * The set of enabled spell checker languages.
+     *
+     * This specifies the languages used for spell checking by the
+     * client. By default, the set will contain languages based on
+     * environment variables.
+     *
+     * @see Util.International.get_user_preferred_languages
+     */
     public string[] spell_check_languages {
         owned get {
-            return settings.get_strv(SPELL_CHECK_LANGUAGES);
+            GLib.Variant? value =
+                settings.get_value(SPELL_CHECK_LANGUAGES).get_maybe();
+            string[] langs = (value != null)
+                    ? value.get_strv()
+                    : Util.International.get_user_preferred_languages();
+            return langs;
+        }
+        set {
+            settings.set_value(
+                SPELL_CHECK_LANGUAGES,
+                new GLib.Variant.maybe(null, new GLib.Variant.strv(value))
+            );
         }
-        set { settings.set_strv(SPELL_CHECK_LANGUAGES, value); }
     }
 
+    /**
+     * The set of visible spell checker languages.
+     *
+     * This is the list of languages shown when selecting languages to
+     * be used for spell checking.
+     */
     public string[] spell_check_visible_languages {
         owned get {
-            string[] langs = settings.get_strv(SPELL_CHECK_VISIBLE_LANGUAGES);
-            if (langs.length == 0) {
-                langs = Util.International.get_user_preferred_languages();
-            }
-            return langs;
+            return settings.get_strv(SPELL_CHECK_VISIBLE_LANGUAGES);
+        }
+        set {
+            settings.set_strv(SPELL_CHECK_VISIBLE_LANGUAGES, value);
         }
-        set { settings.set_strv(SPELL_CHECK_VISIBLE_LANGUAGES, value); }
     }
 
     public bool play_sounds {


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