[epiphany] embed-prefs: properly update spell check langs when changed
- From: Michael Catanzaro <mcatanzaro src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [epiphany] embed-prefs: properly update spell check langs when changed
- Date: Tue, 3 Feb 2015 15:53:13 +0000 (UTC)
commit 970d9845e2fac07b1cb4112d075e293d307e4978
Author: Michael Catanzaro <mcatanzaro gnome org>
Date: Fri Jan 16 17:25:25 2015 -0600
embed-prefs: properly update spell check langs when changed
When the list of languages is changed, don't forget to update the list
of languages for which spell checking is enabled. Otherwise, spell
checking for the newly-selected language(s) won't work until the browser
is restarted.
https://bugzilla.gnome.org/show_bug.cgi?id=743068
embed/ephy-embed-prefs.c | 62 +++++++++++++++++++++++++--------------------
1 files changed, 34 insertions(+), 28 deletions(-)
---
diff --git a/embed/ephy-embed-prefs.c b/embed/ephy-embed-prefs.c
index 0cc4114..dfec800 100644
--- a/embed/ephy-embed-prefs.c
+++ b/embed/ephy-embed-prefs.c
@@ -309,6 +309,32 @@ webkit_pref_callback_font_family (GSettings *settings,
g_free (value);
}
+static char **
+normalize_languages (char **languages)
+{
+ int i;
+ GPtrArray *langs;
+
+ langs = g_ptr_array_new ();
+
+ for (i = 0; languages && languages[i]; i++) {
+ if (g_str_equal (languages[i], "system")) {
+ char **sys_langs = ephy_langs_get_languages ();
+ int j;
+
+ 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);
+}
+
/* Based on Christian Persch's code from gecko backend of epiphany
(old transform_accept_languages_list() function) */
static void
@@ -320,6 +346,7 @@ webkit_pref_callback_accept_languages (GSettings *settings,
char **languages;
int i;
EphyEmbedShell *shell = ephy_embed_shell_get_default ();
+ WebKitWebContext *web_context = ephy_embed_shell_get_web_context (shell);
languages = g_settings_get_strv (settings, key);
@@ -336,8 +363,13 @@ webkit_pref_callback_accept_languages (GSettings *settings,
ephy_langs_sanitise (array);
- webkit_web_context_set_preferred_languages (ephy_embed_shell_get_web_context (shell),
- (const char * const *)array->data);
+ webkit_web_context_set_preferred_languages (web_context, (const char * const *)array->data);
+
+ if (g_settings_get_boolean (EPHY_SETTINGS_WEB, EPHY_PREFS_WEB_ENABLE_SPELL_CHECKING)) {
+ char **normalized = normalize_languages ((char **)array->data);
+ webkit_web_context_set_spell_checking_languages (web_context, (const char * const *)normalized);
+ g_strfreev (normalized);
+ }
g_strfreev (languages);
g_array_free (array, TRUE);
@@ -418,32 +450,6 @@ webkit_pref_callback_gnome_fonts (GSettings *ephy_settings,
}
}
-static char **
-normalize_languages (char **languages)
-{
- int i;
- GPtrArray *langs;
-
- langs = g_ptr_array_new ();
-
- for (i = 0; languages && languages[i]; i++) {
- if (g_str_equal (languages[i], "system")) {
- char **sys_langs = ephy_langs_get_languages ();
- int j;
-
- 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
webkit_pref_callback_enable_spell_checking (GSettings *settings,
char *key,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]