diff options
author | Mario Sanchez Prada <msanchez@igalia.com> | 2009-10-02 20:13:03 +0800 |
---|---|---|
committer | Xan Lopez <xan@gnome.org> | 2009-12-19 02:50:51 +0800 |
commit | dcdebec53b1da88a6b3477d13437af2c53ac73b4 (patch) | |
tree | c829bcca0021247da9bbbb37e6bae994f6668192 | |
parent | 6f69c3f879cc880d53dfb85081aef8462c3fad36 (diff) | |
download | gsoc2013-epiphany-dcdebec53b1da88a6b3477d13437af2c53ac73b4.tar.gz gsoc2013-epiphany-dcdebec53b1da88a6b3477d13437af2c53ac73b4.tar.zst gsoc2013-epiphany-dcdebec53b1da88a6b3477d13437af2c53ac73b4.zip |
Properly manage the list of languages for the "Accept-Language" header
New handler added to watch for changes in the GConf key with the list
of languages for the "Accept-Language" HTTP header, and update the
SoupSession's "accept-language" property (since libsoup 2.29.4).
Bug #528893
-rw-r--r-- | configure.ac | 2 | ||||
-rw-r--r-- | embed/ephy-embed-prefs.c | 57 |
2 files changed, 57 insertions, 2 deletions
diff --git a/configure.ac b/configure.ac index 9848ea51a..715a85e54 100644 --- a/configure.ac +++ b/configure.ac @@ -101,7 +101,7 @@ LIBSTARTUP_NOTIFICATION_REQUIRED=0.5 LIBNOTIFY_REQUIRED=0.4 DBUS_GLIB_REQUIRED=0.35 WEBKIT_GTK_REQUIRED=1.1.18 -LIBSOUP_GNOME_REQUIRED=2.27.91 +LIBSOUP_GNOME_REQUIRED=2.29.4 GNOME_KEYRING_REQUIRED=2.26.0 PKG_CHECK_EXISTS([libnotify >= $LIBNOTIFY_REQUIRED],[have_libnotify=yes],[have_libnotify=no]) diff --git a/embed/ephy-embed-prefs.c b/embed/ephy-embed-prefs.c index 82885faf1..cb64b3012 100644 --- a/embed/ephy-embed-prefs.c +++ b/embed/ephy-embed-prefs.c @@ -26,6 +26,7 @@ #include "ephy-embed-prefs.h" #include "ephy-embed-utils.h" #include "ephy-file-helpers.h" +#include "ephy-langs.h" typedef struct { @@ -194,6 +195,57 @@ webkit_pref_callback_font_family (GConfClient *client, } } +/* Based on Christian Persch's code from gecko backend of epiphany + (old transform_accept_languages_list() function) */ +static void +webkit_pref_callback_accept_languages (GConfClient *client, + guint cnxn_id, + GConfEntry *entry, + gpointer data) +{ + SoupSession *session; + GConfValue *gcvalue; + GArray *array; + GSList *languages, *l; + char **langs; + char *langs_str; + char *webkit_pref; + + webkit_pref = data; + gcvalue = gconf_entry_get_value (entry); + if (gcvalue == NULL || + gcvalue->type != GCONF_VALUE_LIST || + gconf_value_get_list_type (gcvalue) != GCONF_VALUE_STRING) + return; + + languages = gconf_value_get_list (gcvalue); + + array = g_array_new (TRUE, FALSE, sizeof (char *)); + + for (l = languages; l != NULL; l = l->next) { + const char *lang = gconf_value_get_string ((GConfValue *) l->data); + + if ((lang != NULL) && !g_strcmp0 (lang, "system")) { + ephy_langs_append_languages (array); + } else if (lang != NULL && lang[0] != '\0') { + char *str = g_ascii_strdown (lang, -1); + g_array_append_val (array, str); + } + } + + ephy_langs_sanitise (array); + + langs = (char **) g_array_free (array, FALSE); + langs_str = g_strjoinv (", ", langs); + + /* Update Soup session */ + session = webkit_get_default_session (); + g_object_set (G_OBJECT (session), webkit_pref, langs_str, NULL); + + g_strfreev (langs); + g_free (langs_str); +} + static const PrefData webkit_pref_entries[] = { { CONF_RENDERING_FONT_MIN_SIZE, @@ -231,7 +283,10 @@ static const PrefData webkit_pref_entries[] = webkit_pref_callback_boolean }, { CONF_SECURITY_ALLOW_POPUPS, "javascript-can-open-windows-automatically", - webkit_pref_callback_boolean } + webkit_pref_callback_boolean }, + { CONF_RENDERING_LANGUAGE, + "accept-language", + webkit_pref_callback_accept_languages } }; static void |