diff -up a/config.def.h b/config.def.h --- a/config.def.h 2010-03-25 14:24:49.000000000 +0100 +++ b/config.def.h 2010-03-25 14:33:04.000000000 +0100 @@ -7,6 +7,7 @@ static char *scriptfile = ".surf/scr static char *cookiefile = ".surf/cookies.txt"; static char *dldir = ".surf/dl/"; static time_t sessiontime = 3600; +static gboolean loadimage = 1, plugin = 1, script = 1; #define SETPROP(p) { .v = (char *[]){ "/bin/sh", "-c", \ "prop=\"`xprop -id $1 $0 | cut -d '\"' -f 2 | dmenu`\" &&" \ @@ -18,6 +19,9 @@ static Key keys[] = { { MODKEY|GDK_SHIFT_MASK,GDK_r, reload, { .b = TRUE } }, { MODKEY, GDK_r, reload, { .b = FALSE } }, { MODKEY|GDK_SHIFT_MASK,GDK_p, print, { 0 } }, + { MODKEY, GDK_i, toggleimages,{ 0 } }, + { MODKEY, GDK_f, toggleplugin,{ 0 } }, + { MODKEY, GDK_s, togglescript,{ 0 } }, { MODKEY, GDK_p, clipboard, { .b = TRUE } }, { MODKEY, GDK_y, clipboard, { .b = FALSE } }, { MODKEY|GDK_SHIFT_MASK,GDK_j, zoom, { .i = -1 } }, diff -up a/surf.1 b/surf.1 --- a/surf.1 2010-03-25 14:02:58.000000000 +0100 +++ b/surf.1 2010-03-25 14:38:30.000000000 +0100 @@ -4,9 +4,6 @@ surf \- simple webkit-based browser .SH SYNOPSIS .B surf .RB [-e\ xid] -.RB [-i] -.RB [-p] -.RB [-s] .RB [-v] .RB [-x] .RB "URI" @@ -20,15 +17,6 @@ one can point surf to another URI by set .B \-e xid Reparents to window specified by xid. .TP -.B \-i -Disable Images -.TP -.B \-p -Disable Plugins -.TP -.B \-s -Disable Javascript -.TP .B \-v Prints version information to standard output, then exits. .TP diff -up a/surf.c b/surf.c --- a/surf.c 2010-03-25 14:02:58.000000000 +0100 +++ b/surf.c 2010-03-25 14:49:10.000000000 +0100 @@ -62,7 +62,6 @@ static gboolean showxid = FALSE; static int ignorexprop = 0; static char winid[64]; static char *progname; -static gboolean loadimage = 1, plugin = 1, script = 1; static char *buildpath(const char *path); static void cleanup(void); @@ -108,6 +107,9 @@ static void source(Client *c, const Arg static void spawn(Client *c, const Arg *arg); static void stop(Client *c, const Arg *arg); static void titlechange(WebKitWebView *v, WebKitWebFrame* frame, const char* title, Client *c); +static void toggleimages(Client *c, const Arg *arg); +static void toggleplugin(Client *c, const Arg *arg); +static void togglescript(Client *c, const Arg *arg); static void update(Client *c); static void updatedownload(WebKitDownload *o, GParamSpec *pspec, Client *c); static void updatewinid(Client *c); @@ -431,6 +433,7 @@ loadstatuschange(WebKitWebView *view, GP update(c); break; case WEBKIT_LOAD_PROVISIONAL: + case WEBKIT_LOAD_FAILED: case WEBKIT_LOAD_FIRST_VISUALLY_NON_EMPTY_LAYOUT: break; } @@ -608,12 +611,6 @@ newwindow(Client *c, const Arg *arg) { snprintf(tmp, LENGTH(tmp), "%u\n", (int)embed); cmd[i++] = tmp; } - if(!script) - cmd[i++] = "-s"; - if(!plugin) - cmd[i++] = "-p"; - if(!loadimage) - cmd[i++] = "-l"; if(showxid) cmd[i++] = "-x"; cmd[i++] = "--"; @@ -813,6 +810,30 @@ titlechange(WebKitWebView *v, WebKitWebF } void +toggleimages(Client *c, const Arg *arg) { + WebKitWebSettings *settings = webkit_web_view_get_settings(c->view); + g_object_set(G_OBJECT(settings), "auto-load-images", !loadimage, NULL); + (loadimage) ? (loadimage = 0) : (loadimage = 1); + reload(c, arg); +} + +void +toggleplugin(Client *c, const Arg *arg) { + WebKitWebSettings *settings = webkit_web_view_get_settings(c->view); + g_object_set(G_OBJECT(settings), "enable-plugins", !plugin, NULL); + (plugin) ? (plugin = 0) : (plugin = 1); + reload(c, arg); +} + +void +togglescript(Client *c, const Arg *arg) { + WebKitWebSettings *settings = webkit_web_view_get_settings(c->view); + g_object_set(G_OBJECT(settings), "enable-scripts", !script, NULL); + (script) ? (script = 0) : (script = 1); + reload(c, arg); +} + +void update(Client *c) { char *t; @@ -849,7 +870,7 @@ updatewinid(Client *c) { void usage(void) { fputs("surf - simple browser\n", stderr); - die("usage: surf [-e xid] [-i] [-p] [-s] [-v] [-x] [uri]\n"); + die("usage: surf [-e xid] [-v] [-x] [uri]\n"); } void @@ -898,15 +919,6 @@ main(int argc, char *argv[]) { else usage(); break; - case 'i': - loadimage = 0; - break; - case 'p': - plugin = 0; - break; - case 's': - script = 0; - break; case 'x': showxid = TRUE; break;