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".
This commit is contained in:
Michael Gratton 2019-05-23 00:04:45 +02:00 committed by Michael James Gratton
parent adea4618d6
commit f27f2fb91f
2 changed files with 41 additions and 16 deletions

View file

@ -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">

View file

@ -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);
}
set { settings.set_strv(SPELL_CHECK_LANGUAGES, value); }
}
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();
}
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_strv(SPELL_CHECK_VISIBLE_LANGUAGES, value); }
set {
settings.set_value(
SPELL_CHECK_LANGUAGES,
new GLib.Variant.maybe(null, new GLib.Variant.strv(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 {
return settings.get_strv(SPELL_CHECK_VISIBLE_LANGUAGES);
}
set {
settings.set_strv(SPELL_CHECK_VISIBLE_LANGUAGES, value);
}
}
public bool play_sounds {