aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCarlos Garcia Campos <cgarcia@igalia.com>2012-08-22 23:45:14 +0800
committerCarlos Garcia Campos <carlosgc@gnome.org>2012-08-23 00:12:26 +0800
commitb09ae523dc5d2dda70661233f66df2c9683cb7a9 (patch)
tree74ec533876517cbb4591720b1987cee0708ed5c0
parent4bd8690c2a13b3cb1566297c6b6167ee17d78118 (diff)
downloadgsoc2013-epiphany-b09ae523dc5d2dda70661233f66df2c9683cb7a9.tar
gsoc2013-epiphany-b09ae523dc5d2dda70661233f66df2c9683cb7a9.tar.gz
gsoc2013-epiphany-b09ae523dc5d2dda70661233f66df2c9683cb7a9.tar.bz2
gsoc2013-epiphany-b09ae523dc5d2dda70661233f66df2c9683cb7a9.tar.lz
gsoc2013-epiphany-b09ae523dc5d2dda70661233f66df2c9683cb7a9.tar.xz
gsoc2013-epiphany-b09ae523dc5d2dda70661233f66df2c9683cb7a9.tar.zst
gsoc2013-epiphany-b09ae523dc5d2dda70661233f66df2c9683cb7a9.zip
ephy-embed-prefs: Pass an array of languages to spellchecker in WebKit2
The API has changed to receive a char ** instead of a string containing a comma-separated list of languages.
-rw-r--r--embed/ephy-embed-prefs.c36
1 files changed, 24 insertions, 12 deletions
diff --git a/embed/ephy-embed-prefs.c b/embed/ephy-embed-prefs.c
index e7d7d9379..67c118bb1 100644
--- a/embed/ephy-embed-prefs.c
+++ b/embed/ephy-embed-prefs.c
@@ -492,22 +492,30 @@ webkit_pref_callback_gnome_fonts (GSettings *ephy_settings,
}
}
-static void
-replace_system_language_with_concrete_language_string (char **languages)
+static char **
+normalize_languages (char **languages)
{
int i;
+ GPtrArray *langs;
+
+ langs = g_ptr_array_new ();
- for (i = 0; i < g_strv_length (languages); i++) {
+ for (i = 0; languages && languages[i]; i++) {
if (g_str_equal (languages[i], "system")) {
- char **sys_langs;
+ char **sys_langs = ephy_langs_get_languages ();
+ int j;
- g_free (languages[i]);
- sys_langs = ephy_langs_get_languages ();
- languages[i] = g_strjoinv (", ", sys_langs);
+ for (j = 0; sys_langs && sys_langs[j]; j++)
+ g_ptr_array_add (langs, g_strdelimit (g_strdup (sys_langs[i]), "-", '_'));
g_strfreev (sys_langs);
- }
+ } else
+ g_ptr_array_add (langs, g_strdelimit (g_strdup (languages[i]), "-", '_'));
}
+
+ g_ptr_array_add (langs, NULL);
+
+ return (char **)g_ptr_array_free (langs, FALSE);
}
static void
@@ -525,23 +533,27 @@ webkit_pref_callback_enable_spell_checking (GSettings *settings,
value = g_settings_get_boolean (settings, key);
if (value) {
+ char **normalized;
+
languages = g_settings_get_strv (settings, EPHY_PREFS_WEB_LANGUAGE);
- replace_system_language_with_concrete_language_string (languages);
- langs = g_strjoinv (",", languages);
- g_strdelimit (langs, "-", '_');
+ normalized = normalize_languages (languages);
g_strfreev (languages);
+
+ languages = normalized;
+ langs = g_strjoinv (",", languages);
}
#ifdef HAVE_WEBKIT2
web_context = webkit_web_context_get_default ();
webkit_web_context_set_spell_checking_enabled (web_context, value);
- webkit_web_context_set_spell_checking_languages (web_context, langs);
+ webkit_web_context_set_spell_checking_languages (web_context, languages);
#else
g_object_set (webkit_settings, "enable-spell-checking", value, NULL);
g_object_set (webkit_settings, "spell-checking-languages", langs, NULL);
#endif
g_free (langs);
+ g_strfreev (languages);
}
static const PrefData webkit_pref_entries[] =