Hi,

Here is a simple patch to toggle binary webkit features by name.

--s_
diff -r 51a6d05c2c84 config.def.h
--- a/config.def.h      Mon Mar 26 09:33:42 2012 +0200
+++ b/config.def.h      Thu May 31 09:31:38 2012 +0200
@@ -42,4 +42,8 @@
     { MODKEY,               GDK_f,      spawn,      SETPROP("_SURF_FIND", 
"_SURF_FIND") },
     { MODKEY,               GDK_n,      find,       { .b = TRUE } },
     { MODKEY|GDK_SHIFT_MASK,GDK_n,      find,       { .b = FALSE } },
+    { MODKEY,               GDK_v,      toggle,     { .v = "enable-plugins" } 
},
+    { MODKEY|GDK_SHIFT_MASK,GDK_i,      toggle,     { .v = "auto-load-images" 
} },
+    { MODKEY,               GDK_c,      toggle,     { .v = 
"enable-caret-browsing" } },
+    { MODKEY|GDK_SHIFT_MASK,GDK_s,      toggle,     { .v = "enable-scripts" } 
},
 };
diff -r 51a6d05c2c84 surf.c
--- a/surf.c    Mon Mar 26 09:33:42 2012 +0200
+++ b/surf.c    Thu May 31 09:31:38 2012 +0200
@@ -106,6 +106,7 @@
 static void eval(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 toggle(Client *c, const Arg *arg);
 static void update(Client *c);
 static void updatewinid(Client *c);
 static void usage(void);
@@ -796,6 +797,20 @@
 }
 
 void
+toggle(Client *c, const Arg *arg) { 
+  WebKitWebSettings *settings;
+  char *name = (char *)arg->v;
+  gboolean value;
+  Arg a = { .b = FALSE };
+
+  settings = webkit_web_view_get_settings(c->view);
+  g_object_get(G_OBJECT(settings), name, &value, NULL);
+  g_object_set(G_OBJECT(settings), name, !value, NULL);
+
+  reload(c,&a);
+}
+
+void
 update(Client *c) {
        char *t;
 

Reply via email to