From 5e185532a02996c8086f88821bffc7b476b55ead Mon Sep 17 00:00:00 2001 From: Hannes Schueller Date: Sat, 15 Jan 2011 16:18:18 +0100 Subject: [PATCH] Add field for customising HTTP Accept-Language header Patch by Stephen Morgan --- config.h | 2 ++ main.c | 8 ++++++++ vimprobablerc.1 | 3 +++ 3 files changed, 13 insertions(+) diff --git a/config.h b/config.h index e4ea17e..e3ca4a5 100644 --- a/config.h +++ b/config.h @@ -14,6 +14,7 @@ /* general settings */ char startpage[1024] = "http://www.vimprobable.org/"; char useragent[1024] = "Vimprobable2/" VERSION; +char acceptlanguage[1024] = ""; static const gboolean enablePlugins = TRUE; /* TRUE keeps plugins enabled */ static const gboolean enableJava = TRUE; /* FALSE disables Java applets */ static const gboolean enablePagecache = FALSE; /* TRUE turns on the page cache. */ @@ -174,6 +175,7 @@ static Setting browsersettings[] = { { "statuscolor", statuscolor, "", FALSE, FALSE, TRUE, TRUE }, { "sslbgcolor", sslbgcolor, "", FALSE, FALSE, TRUE, TRUE }, { "sslcolor", sslcolor, "", FALSE, FALSE, TRUE, TRUE }, + { "acceptlanguage", acceptlanguage, "", FALSE, FALSE, FALSE, FALSE }, { "qmark", NULL, "", FALSE, FALSE, FALSE, FALSE }, { "proxy", NULL, "", FALSE, TRUE, FALSE, FALSE }, { "scrollbars", NULL, "", FALSE, TRUE, FALSE, FALSE }, diff --git a/main.c b/main.c index 13f03eb..7c69a2d 100644 --- a/main.c +++ b/main.c @@ -1689,6 +1689,12 @@ process_set_line(char *line) { /* mandatory argument not provided */ if (strlen(my_pair.value) == 0) return FALSE; + /* process acceptlanguage */ + if (strlen(my_pair.what) == 14 && strncmp("acceptlanguage", my_pair.what, 14) == 0) { + strncpy(acceptlanguage, my_pair.value, strlen(my_pair.value) + 1); + g_object_set(G_OBJECT(session), "accept-language", acceptlanguage, NULL); + return TRUE; + } /* process qmark? */ if (strlen(my_pair.what) == 5 && strncmp("qmark", my_pair.what, 5) == 0) { return (process_save_qmark(my_pair.value, webview)); @@ -2104,6 +2110,8 @@ setup_signals() { /* Headers. */ g_signal_connect_after((GObject*)session, "request-started", (GCallback)new_generic_request, NULL); #endif + /* Accept-language header */ + g_object_set(G_OBJECT(session), "accept-language", acceptlanguage, NULL); /* window */ g_object_connect((GObject*)window, "signal::destroy", (GCallback)window_destroyed_cb, NULL, diff --git a/vimprobablerc.1 b/vimprobablerc.1 index 6494ff8..4d6b30c 100644 --- a/vimprobablerc.1 +++ b/vimprobablerc.1 @@ -65,6 +65,9 @@ Set the URL of the homepage. .IP useragent= Replace the default useragent-string. +.IP acceptlanguage= +Replace the default acceptlanguage-string. + .IP scripts=[true|false] Enable or disable scripts. -- 2.11.4.GIT