Adding Nibbles patch

This commit is contained in:
Enno Boland (tox) 2010-05-28 13:20:17 +02:00
parent 8cc71f8216
commit ca1c7f434b
2 changed files with 8 additions and 14 deletions

View File

@ -12,15 +12,13 @@ static time_t sessiontime = 0;
"prop=\"`xprop -id $2 $0 | cut -d '\"' -f 2 | dmenu`\" &&" \ "prop=\"`xprop -id $2 $0 | cut -d '\"' -f 2 | dmenu`\" &&" \
"xprop -id $2 -f $1 8s -set $1 \"$prop\"", \ "xprop -id $2 -f $1 8s -set $1 \"$prop\"", \
p, q, winid, NULL } } p, q, winid, NULL } }
#define DOWNLOAD(p) { \ #define DOWNLOAD(d) { \
.v = (char *[]){ "/bin/sh", "-c", \ .v = (char *[]){ "/bin/sh", "-c", \
"prop=\"`xprop -id $1 $0 | cut -d '\"' -f 2`\";" \ "xterm -e \"wget --load-cookies ~/.surf/cookies.txt '$0';\"", \
"xterm -e \"wget --load-cookies ~/.surf/cookies.txt $prop;\"", \ d, NULL } }
p, winid, NULL } }
#define MODKEY GDK_CONTROL_MASK #define MODKEY GDK_CONTROL_MASK
static Key keys[] = { static Key keys[] = {
/* modifier keyval function arg Focus */ /* modifier keyval function arg Focus */
{ MODKEY, GDK_s, spawn, DOWNLOAD("_SURF_HILIGHT") },
{ MODKEY|GDK_SHIFT_MASK,GDK_r, reload, { .b = TRUE } }, { MODKEY|GDK_SHIFT_MASK,GDK_r, reload, { .b = TRUE } },
{ MODKEY, GDK_r, reload, { .b = FALSE } }, { MODKEY, GDK_r, reload, { .b = FALSE } },
{ MODKEY|GDK_SHIFT_MASK,GDK_p, print, { 0 } }, { MODKEY|GDK_SHIFT_MASK,GDK_p, print, { 0 } },

14
surf.c
View File

@ -23,7 +23,7 @@
#define LENGTH(x) (sizeof x / sizeof x[0]) #define LENGTH(x) (sizeof x / sizeof x[0])
#define CLEANMASK(mask) (mask & ~(GDK_MOD2_MASK)) #define CLEANMASK(mask) (mask & ~(GDK_MOD2_MASK))
enum { AtomFind, AtomGo, AtomUri, AtomHiLight, AtomLast }; enum { AtomFind, AtomGo, AtomUri, AtomLast };
typedef union Arg Arg; typedef union Arg Arg;
union Arg { union Arg {
@ -188,10 +188,7 @@ createwindow(WebKitWebView *v, WebKitWebFrame *f, Client *c) {
gboolean gboolean
decidedownload(WebKitWebView *v, WebKitWebFrame *f, WebKitNetworkRequest *r, gchar *m, WebKitWebPolicyDecision *p, Client *c) { decidedownload(WebKitWebView *v, WebKitWebFrame *f, WebKitNetworkRequest *r, gchar *m, WebKitWebPolicyDecision *p, Client *c) {
if(!webkit_web_view_can_show_mime_type(v, m)) { if(!webkit_web_view_can_show_mime_type(v, m)) {
webkit_web_policy_decision_ignore(p); webkit_web_policy_decision_download(p);
webkit_web_view_load_html_string(c->view,
"Can't display content.",
webkit_network_request_get_uri(r));
return TRUE; return TRUE;
} }
return FALSE; return FALSE;
@ -334,7 +331,7 @@ initdownload(WebKitWebView *view, WebKitDownload *o, Client *c) {
Arg arg; Arg arg;
updatewinid(c); updatewinid(c);
arg = (Arg)DOWNLOAD("_SURF_HILIGHT"); arg = (Arg)DOWNLOAD((char *)webkit_download_get_uri(o));
spawn(c, &arg); spawn(c, &arg);
return FALSE; return FALSE;
} }
@ -503,11 +500,12 @@ newclient(void) {
g_object_set(G_OBJECT(settings), "auto-load-images", loadimage, NULL); g_object_set(G_OBJECT(settings), "auto-load-images", loadimage, NULL);
g_object_set(G_OBJECT(settings), "enable-plugins", plugin, NULL); g_object_set(G_OBJECT(settings), "enable-plugins", plugin, NULL);
g_object_set(G_OBJECT(settings), "enable-scripts", script, NULL); g_object_set(G_OBJECT(settings), "enable-scripts", script, NULL);
g_object_set(G_OBJECT(settings), "enable-spatial-navigation", true, NULL);
g_free(uri); g_free(uri);
setatom(c, AtomFind, ""); setatom(c, AtomFind, "");
setatom(c, AtomUri, "about:blank"); setatom(c, AtomUri, "about:blank");
setatom(c, AtomHiLight, "about:blank");
if(NOBACKGROUND) if(NOBACKGROUND)
webkit_web_view_set_transparent(c->view, TRUE); webkit_web_view_set_transparent(c->view, TRUE);
@ -688,7 +686,6 @@ setup(void) {
atoms[AtomFind] = XInternAtom(dpy, "_SURF_FIND", False); atoms[AtomFind] = XInternAtom(dpy, "_SURF_FIND", False);
atoms[AtomGo] = XInternAtom(dpy, "_SURF_GO", False); atoms[AtomGo] = XInternAtom(dpy, "_SURF_GO", False);
atoms[AtomUri] = XInternAtom(dpy, "_SURF_URI", False); atoms[AtomUri] = XInternAtom(dpy, "_SURF_URI", False);
atoms[AtomHiLight] = XInternAtom(dpy, "_SURF_HILIGHT", False);
/* dirs and files */ /* dirs and files */
cookiefile = buildpath(cookiefile); cookiefile = buildpath(cookiefile);
@ -763,7 +760,6 @@ update(Client *c) {
t = g_strdup(c->linkhover); t = g_strdup(c->linkhover);
else else
t = g_strdup(c->title); t = g_strdup(c->title);
setatom(c, AtomHiLight, c->linkhover ? c->linkhover : geturi(c));
drawindicator(c); drawindicator(c);
gtk_window_set_title(GTK_WINDOW(c->win), t); gtk_window_set_title(GTK_WINDOW(c->win), t);
g_free(t); g_free(t);