Introduction
Introduction Statistics Contact Development Disclaimer Help
tAdapt toggle(), clean some config parameters - surf - customized build of surf…
git clone git://src.adamsgaard.dk/surf
Log
Files
Refs
README
LICENSE
---
commit 82abf5154f0ab94716223f556638f073f01dbc11
parent 526b974c33a17b7ef77f4268bd8602e2d51ad1b9
Author: Quentin Rameau <[email protected]>
Date: Fri, 20 Nov 2015 15:48:04 +0100
Adapt toggle(), clean some config parameters
Regroup all toggles in an enum and handle them with a unique function
via a switch. That lets us take different actions for each toggle.
Add a frame flatenning and a dns preteching options.
Diffstat:
M config.def.h | 23 ++++++++++++-----------
M surf.c | 83 ++++++++++++++++++++++-------…
2 files changed, 71 insertions(+), 35 deletions(-)
---
diff --git a/config.def.h b/config.def.h
t@@ -8,7 +8,6 @@ static char *cachedir = "~/.surf/cache/";
static Bool kioskmode = FALSE; /* Ignore shortcuts */
static Bool showindicators = TRUE; /* Show indicators in window title */
-static Bool zoomto96dpi = TRUE; /* Zoom pages to always emulate 96dpi */
static Bool runinfullscreen = FALSE; /* Run in fullscreen mode by default */
static guint defaultfontsize = 12; /* Default font size */
t@@ -18,15 +17,12 @@ static gfloat zoomlevel = 1.0; /* Default zoom level…
static char *cookiefile = "~/.surf/cookies.txt";
static char *cookiepolicies = "Aa@"; /* A: accept all; a: accept nothing,
* @: accept no third party */
-static char *cafile = "/etc/ssl/certs/ca-certificates.crt";
static Bool strictssl = FALSE; /* Refuse untrusted SSL connections */
-static time_t sessiontime = 3600;
/* Webkit default features */
static Bool enablescrollbars = TRUE;
-static Bool enablespatialbrowsing = TRUE;
-static Bool enablediskcache = TRUE;
-static int diskcachebytes = 5 * 1024 * 1024;
+static Bool enablecaretbrowsing = TRUE;
+static Bool enablecache = TRUE;
static Bool enableplugins = TRUE;
static Bool enablescripts = TRUE;
static Bool enableinspector = TRUE;
t@@ -34,6 +30,8 @@ static Bool enablestyle = TRUE;
static Bool loadimages = TRUE;
static Bool hidebackground = FALSE;
static Bool allowgeolocation = TRUE;
+static Bool enablednsprefetching = FALSE;
+static Bool enableframeflattening = FALSE;
static WebKitFindOptions findopts = WEBKIT_FIND_OPTIONS_CASE_INSENSITIVE |
WEBKIT_FIND_OPTIONS_WRAP_AROUND;
t@@ -122,13 +120,16 @@ static Key keys[] = {
{ MODKEY, GDK_KEY_n, find, { .i = +1 } },
{ MODKEY|GDK_SHIFT_MASK, GDK_KEY_n, find, { .i = -1 } },
- { MODKEY|GDK_SHIFT_MASK, GDK_KEY_c, toggle, { .v = "enable-ca…
- { MODKEY|GDK_SHIFT_MASK, GDK_KEY_i, toggle, { .v = "auto-load…
- { MODKEY|GDK_SHIFT_MASK, GDK_KEY_s, toggle, { .v = "enable-sc…
- { MODKEY|GDK_SHIFT_MASK, GDK_KEY_v, toggle, { .v = "enable-pl…
+ { MODKEY|GDK_SHIFT_MASK, GDK_KEY_c, toggle, { .i = CaretBrows…
+ { MODKEY|GDK_SHIFT_MASK, GDK_KEY_f, toggle, { .i = FrameFlatt…
+ { MODKEY|GDK_SHIFT_MASK, GDK_KEY_g, toggle, { .i = Geolocatio…
+ { MODKEY|GDK_SHIFT_MASK, GDK_KEY_s, toggle, { .i = JavaScript…
+ { MODKEY|GDK_SHIFT_MASK, GDK_KEY_i, toggle, { .i = LoadImages…
+ { MODKEY|GDK_SHIFT_MASK, GDK_KEY_v, toggle, { .i = Plugins } …
+ { MODKEY|GDK_SHIFT_MASK, GDK_KEY_b, toggle, { .i = ScrollBars…
+
{ MODKEY|GDK_SHIFT_MASK, GDK_KEY_a, togglecookiepolicy, { 0 } },
{ MODKEY|GDK_SHIFT_MASK, GDK_KEY_m, togglestyle, { 0 } },
- { MODKEY|GDK_SHIFT_MASK, GDK_KEY_g, togglegeolocation, { 0 } },
};
/* button definitions */
diff --git a/surf.c b/surf.c
t@@ -47,6 +47,16 @@ enum {
OnAny = OnDoc | OnLink | OnImg | OnMedia | OnEdit | OnBar | OnSel,
};
+enum {
+ CaretBrowsing,
+ FrameFlattening,
+ Geolocation,
+ JavaScript,
+ LoadImages,
+ Plugins,
+ ScrollBars,
+};
+
typedef union Arg Arg;
union Arg {
gboolean b;
t@@ -176,9 +186,8 @@ static void sigchld(int unused);
static void spawn(Client *c, const Arg *arg);
static void stop(Client *c, const Arg *arg);
static void titlechanged(WebKitWebView *view, GParamSpec *ps, Client *c);
-static void toggle(Client *c, const Arg *arg);
+static void toggle(Client *c, const Arg *a);
static void togglecookiepolicy(Client *c, const Arg *arg);
-static void togglegeolocation(Client *c, const Arg *arg);
static void togglestyle(Client *c, const Arg *arg);
static void updatetitle(Client *c);
static void updatewinid(Client *c);
t@@ -1064,7 +1073,7 @@ newwindow(Client *c, const Arg *arg, gboolean noembed)
cmd[i++] = "-s";
if (showxid)
cmd[i++] = "-x";
- if (enablediskcache)
+ if (enablecache)
cmd[i++] = "-D";
cmd[i++] = "-c";
cmd[i++] = cookiefile;
t@@ -1306,18 +1315,53 @@ winevent(GtkWidget *w, GdkEvent *e, Client *c)
}
void
-toggle(Client *c, const Arg *arg)
+toggle(Client *c, const Arg *a)
{
- WebKitWebSettings *settings;
- char *name = (char *)arg->v;
- gboolean value;
- Arg a = { .b = FALSE };
+ WebKitSettings *s;
- 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);
+ s = webkit_web_view_get_settings(c->view);
- reload(c, &a);
+ switch ((unsigned int)a->i) {
+ case CaretBrowsing:
+ enablecaretbrowsing = !enablecaretbrowsing;
+ webkit_settings_set_enable_caret_browsing(s,
+ enablecaretbrowsing);
+ updatetitle(c);
+ return; /* do not reload */
+ break;
+ case FrameFlattening:
+ enableframeflattening = !enableframeflattening;
+ webkit_settings_set_enable_frame_flattening(s,
+ enableframeflattening);
+ break;
+ case Geolocation:
+ allowgeolocation = !allowgeolocation;
+ break;
+ case JavaScript:
+ enablescripts = !enablescripts;
+ webkit_settings_set_enable_javascript(s, enablescripts);
+ break;
+ case LoadImages:
+ loadimages = !loadimages;
+ webkit_settings_set_auto_load_images(s, loadimages);
+ break;
+ case Plugins:
+ enableplugins = !enableplugins;
+ webkit_settings_set_enable_plugins(s, enableplugins);
+ break;
+ case ScrollBars:
+ /* Disabled until we write some WebKitWebExtension for
+ * manipulating the DOM directly.
+ enablescrollbars = !enablescrollbars;
+ evalscript(c, "document.documentElement.style.overflow = '%s'",
+ enablescrollbars ? "auto" : "hidden");
+ */
+ return; /* do not reload */
+ break;
+ default:
+ break;
+ }
+ reload(c, a);
}
void
t@@ -1336,15 +1380,6 @@ togglecookiepolicy(Client *c, const Arg *arg)
}
void
-togglegeolocation(Client *c, const Arg *arg)
-{
- Arg a = { .b = FALSE };
-
- allowgeolocation ^= 1;
- reload(c, &a);
-}
-
-void
togglestyle(Client *c, const Arg *arg)
{
enablestyle = !enablestyle;
t@@ -1368,7 +1403,7 @@ gettogglestat(Client *c)
togglestat[p++] = allowgeolocation? 'G': 'g';
- togglestat[p++] = enablediskcache? 'D': 'd';
+ togglestat[p++] = enablecache? 'D': 'd';
g_object_get(G_OBJECT(settings), "auto-load-images", &value, NULL);
togglestat[p++] = value? 'I': 'i';
t@@ -1473,10 +1508,10 @@ main(int argc, char *argv[])
cookiefile = EARGF(usage());
break;
case 'd':
- enablediskcache = 0;
+ enablecache = 0;
break;
case 'D':
- enablediskcache = 1;
+ enablecache = 1;
break;
case 'e':
embed = strtol(EARGF(usage()), NULL, 0);
You are viewing proxied material from mx1.adamsgaard.dk. The copyright of proxied material belongs to its original authors. Any comments or complaints in relation to proxied material should be directed to the original authors of the content concerned. Please see the disclaimer for more details.