surf-0.3-agent.diff - sites - public wiki contents of suckless.org | |
git clone git://git.suckless.org/sites | |
Log | |
Files | |
Refs | |
--- | |
surf-0.3-agent.diff (2094B) | |
--- | |
1 diff -r 46d516fd2167 config.def.h | |
2 --- a/config.def.h Fri Oct 30 13:38:14 2009 +0100 | |
3 +++ b/config.def.h Fri Oct 30 10:26:39 2009 -0700 | |
4 @@ -29,6 +29,7 @@ | |
5 { MODKEY, GDK_k, scroll, { .i = -1 } }, | |
6 { 0, GDK_Escape, stop, { 0 } }, | |
7 { MODKEY, GDK_o, source, { 0 } }, | |
8 + { MODKEY, GDK_a, spawn, SETPROP("_SURF_AGEN… | |
9 { MODKEY, GDK_g, spawn, SETPROP("_SURF_URI"… | |
10 { MODKEY, GDK_slash, spawn, SETPROP("_SURF_FIND… | |
11 { MODKEY, GDK_n, find, { .b = TRUE } }, | |
12 diff -r 46d516fd2167 surf.c | |
13 --- a/surf.c Fri Oct 30 13:38:14 2009 +0100 | |
14 +++ b/surf.c Fri Oct 30 10:26:39 2009 -0700 | |
15 @@ -55,7 +55,7 @@ | |
16 } Key; | |
17 | |
18 static Display *dpy; | |
19 -static Atom uriprop, findprop; | |
20 +static Atom uriprop, findprop, agentprop; | |
21 static SoupCookieJar *cookies; | |
22 static SoupSession *session; | |
23 static Client *clients = NULL; | |
24 @@ -119,6 +119,16 @@ | |
25 /* configuration, allows nested code to access above variables */ | |
26 #include "config.h" | |
27 | |
28 +void | |
29 +agent(Client *c, const Arg *arg) { | |
30 + const char *s; | |
31 + WebKitWebSettings *settings; | |
32 + | |
33 + s = getatom(c, agentprop); | |
34 + settings = webkit_web_view_get_settings(c->view); | |
35 + g_object_set(G_OBJECT(settings), "user-agent", s, NULL); | |
36 +} | |
37 + | |
38 char * | |
39 buildpath(const char *path) { | |
40 char *apath, *p; | |
41 @@ -537,6 +547,7 @@ | |
42 g_object_set(G_OBJECT(settings), "user-stylesheet-uri", uri, NU… | |
43 g_free(uri); | |
44 setatom(c, findprop, ""); | |
45 + setatom(c, agentprop, useragent); | |
46 | |
47 c->download = NULL; | |
48 c->title = NULL; | |
49 @@ -605,6 +616,10 @@ | |
50 arg.b = TRUE; | |
51 find(c, &arg); | |
52 } | |
53 + else if(ev->atom == agentprop) { | |
54 + arg.v = getatom(c, agentprop); | |
55 + agent(c, &arg); | |
56 + } | |
57 return GDK_FILTER_REMOVE; | |
58 } | |
59 } | |
60 @@ -692,6 +707,7 @@ | |
61 session = webkit_get_default_session(); | |
62 uriprop = XInternAtom(dpy, "_SURF_URI", False); | |
63 findprop = XInternAtom(dpy, "_SURF_FIND", False); | |
64 + agentprop = XInternAtom(dpy, "_SURF_AGENT", False); | |
65 | |
66 /* create dirs and files */ | |
67 cookiefile = buildpath(cookiefile); |