diff options
author | Christoph Lohmann <20h@r-36.net> | 2017-02-05 08:57:22 +0100 |
---|---|---|
committer | Quentin Rameau <quinq@fifth.space> | 2017-02-06 11:30:44 +0100 |
commit | dcabd0239e7bd35bee765f4b88cdf898bd14373d (patch) | |
tree | 7973642a599f479ed3838e2a5f54c030c743972a | |
parent | 6c8da4c851b85c6167f3104158089d9a4fe11ca7 (diff) | |
download | surf-dcabd0239e7bd35bee765f4b88cdf898bd14373d.tar.gz surf-dcabd0239e7bd35bee765f4b88cdf898bd14373d.tar.bz2 surf-dcabd0239e7bd35bee765f4b88cdf898bd14373d.zip |
Add a way to toggle proxy usage while running.
-rw-r--r-- | config.def.h | 2 | ||||
-rw-r--r-- | surf.1 | 3 | ||||
-rw-r--r-- | surf.c | 38 |
3 files changed, 42 insertions, 1 deletions
diff --git a/config.def.h b/config.def.h index 7c2b10f..5996854 100644 --- a/config.def.h +++ b/config.def.h @@ -127,6 +127,7 @@ static Key keys[] = { { MODKEY|GDK_SHIFT_MASK,GDK_m, togglestyle, { 0 } }, { MODKEY|GDK_SHIFT_MASK,GDK_b, togglescrollbars, { 0 } }, { MODKEY|GDK_SHIFT_MASK,GDK_g, togglegeolocation, { 0 } }, + { MODKEY|GDK_SHIFT_MASK,GDK_y, toggleproxy, { 0 } }, }; /* button definitions */ @@ -139,3 +140,4 @@ static Button buttons[] = { { ClkAny, 0, 8, navigate, { .i = -1 } }, { ClkAny, 0, 9, navigate, { .i = +1 } }, }; + @@ -221,6 +221,9 @@ Toggle script execution. This will reload the page. Toggle the enabling of plugins on that surf instance. This will reload the page. .TP +.B Ctrl\-Shift\-y +Toggle if a proxy should be used (if one is set in the environment). +.TP .B F11 Toggle fullscreen mode. .SH INDICATORS OF OPERATION @@ -198,6 +198,7 @@ static void scroll_v(Client *c, const Arg *arg); static void scroll(GtkAdjustment *a, const Arg *arg); static void setatom(Client *c, int a, const char *v); static void setup(void); +static void setup_proxy(void); static void sigchld(int unused); static void sighup(int unused); static void source(Client *c, const Arg *arg); @@ -208,6 +209,7 @@ static void titlechangeleave(void *a, void *b, Client *c); static void toggle(Client *c, const Arg *arg); static void togglecookiepolicy(Client *c, const Arg *arg); static void togglegeolocation(Client *c, const Arg *arg); +static void toggleproxy(Client *c, const Arg *arg); static void togglescrollbars(Client *c, const Arg *arg); static void togglestyle(Client *c, const Arg *arg); static void updatetitle(Client *c); @@ -1323,7 +1325,6 @@ void setup(void) { int i; - char *proxy, *new_proxy, *no_proxy, **new_no_proxy; char *styledirfile, *stylepath; GProxyResolver *pr; SoupSession *s; @@ -1399,6 +1400,19 @@ setup(void) g_object_set(G_OBJECT(s), "tls-database", tlsdb, NULL); g_object_set(G_OBJECT(s), "ssl-strict", strictssl, NULL); + setup_proxy(); +} + +void +setup_proxy(void) +{ + char *proxy, *new_proxy, *no_proxy, **new_no_proxy; + GProxyResolver *pr; + SoupSession *s; + + /* request handler */ + s = webkit_get_default_session(); + /* proxy */ if ((proxy = getenv("http_proxy")) && strcmp(proxy, "")) { new_proxy = g_strrstr(proxy, "http://") @@ -1416,6 +1430,8 @@ setup(void) g_free(new_proxy); g_strfreev(new_no_proxy); usingproxy = 1; + } else { + usingproxy = 0; } } @@ -1480,6 +1496,7 @@ void titlechange(WebKitWebView *view, GParamSpec *pspec, Client *c) { const gchar *t = webkit_web_view_get_title(view); + if (t) { c->title = copystr(&c->title, t); updatetitle(c); @@ -1558,6 +1575,25 @@ twitch(Client *c, const Arg *arg) } void +toggleproxy(Client *c, const Arg *arg) +{ + SoupSession *s; + + /* request handler */ + s = webkit_get_default_session(); + + if (usingproxy) { + g_object_set(G_OBJECT(s), "proxy-resolver", NULL, NULL); + usingproxy = 0; + } else { + setup_proxy(); + } + + updatetitle(c); + /* Do not reload. */ +} + +void togglescrollbars(Client *c, const Arg *arg) { GtkPolicyType vspolicy; |