X-Git-Url: https://git.danieliu.xyz/?a=blobdiff_plain;f=surf.c;h=804e54688b019b3e6b74c9f7b2196a9cebb8fb4d;hb=7e9a85a5cb31a2ddefd06498eff33df724bdc6cf;hp=601887a8ed4932119cdbdc0dfeaebd94e8fff11a;hpb=5bca2223399bb18bada2a48db7411d181e3186e6;p=surf.git diff --git a/surf.c b/surf.c index 601887a..804e546 100644 --- a/surf.c +++ b/surf.c @@ -109,7 +109,6 @@ static gboolean showxid = FALSE; static char winid[64]; static char togglestats[10]; static char pagestats[2]; -static GTlsDatabase *tlsdb; static int cookiepolicy; static char *stylefile = NULL; static const char *useragent; @@ -124,7 +123,6 @@ static void clipboard(Client *c, const Arg *a); static WebKitCookieAcceptPolicy cookiepolicy_get(void); static char cookiepolicy_set(const WebKitCookieAcceptPolicy p); -static char *copystr(char **str, const char *src); static GtkWidget *createview(WebKitWebView *v, WebKitNavigationAction *a, Client *c); static gboolean decidepolicy(WebKitWebView *v, WebKitPolicyDecision *d, @@ -379,19 +377,6 @@ clipboard(Client *c, const Arg *a) } } -char * -copystr(char **str, const char *src) -{ - char *tmp; - tmp = g_strdup(src); - - if (str && *str) { - g_free(*str); - *str = tmp; - } - return tmp; -} - GtkWidget * createview(WebKitWebView *v, WebKitNavigationAction *a, Client *c) { @@ -876,7 +861,6 @@ Client * newclient(Client *rc) { Client *c; - gdouble dpi; if (!(c = calloc(1, sizeof(Client)))) die("Cannot malloc!\n"); @@ -1052,45 +1036,56 @@ showview(WebKitWebView *v, Client *c) } void -newwindow(Client *c, const Arg *arg, gboolean noembed) +newwindow(Client *c, const Arg *a, int noembed) { - guint i = 0; - const char *cmd[18], *uri; - const Arg a = { .v = (void *)cmd }; + int i = 0; char tmp[64]; + const char *cmd[26], *uri; + const Arg arg = { .v = cmd }; cmd[i++] = argv0; cmd[i++] = "-a"; cmd[i++] = cookiepolicies; - if (!enablescrollbars) - cmd[i++] = "-b"; + cmd[i++] = enablescrollbars ? "-B" : "-b"; + if (cookiefile && g_strcmp0(cookiefile, "")) { + cmd[i++] = "-c"; + cmd[i++] = cookiefile; + } + cmd[i++] = enablecache ? "-D" : "-d"; if (embed && !noembed) { cmd[i++] = "-e"; - snprintf(tmp, LENGTH(tmp), "%u", (int)embed); + snprintf(tmp, LENGTH(tmp), "%lu", embed); cmd[i++] = tmp; } - if (!allowgeolocation) - cmd[i++] = "-g"; - if (!loadimages) - cmd[i++] = "-i"; - if (kioskmode) - cmd[i++] = "-k"; - if (!enableplugins) - cmd[i++] = "-p"; - if (!enablescripts) - cmd[i++] = "-s"; + cmd[i++] = runinfullscreen ? "-F" : "-f"; + cmd[i++] = allowgeolocation ? "-G" : "-g"; + cmd[i++] = loadimages ? "-I" : "-i"; + cmd[i++] = kioskmode ? "-K" : "-k"; + cmd[i++] = enablestyle ? "-M" : "-m"; + cmd[i++] = enableinspector ? "-N" : "-n"; + cmd[i++] = enableplugins ? "-P" : "-p"; + if (scriptfile && g_strcmp0(scriptfile, "")) { + cmd[i++] = "-r"; + cmd[i++] = scriptfile; + } + cmd[i++] = enablescripts ? "-S" : "-s"; + if (stylefile && g_strcmp0(stylefile, "")) { + cmd[i++] = "-t"; + cmd[i++] = stylefile; + } + if (fulluseragent && g_strcmp0(fulluseragent, "")) { + cmd[i++] = "-u"; + cmd[i++] = fulluseragent; + } if (showxid) cmd[i++] = "-x"; - if (enablecache) - cmd[i++] = "-D"; - cmd[i++] = "-c"; - cmd[i++] = cookiefile; + /* do not keep zoom level */ cmd[i++] = "--"; - uri = arg->v ? (char *)arg->v : c->linkhover; - if (uri) + if ((uri = a->v)) cmd[i++] = uri; - cmd[i++] = NULL; - spawn(NULL, &a); + cmd[i] = NULL; + + spawn(c, &arg); } GtkWidget * @@ -1224,8 +1219,6 @@ void setup(void) { int i; - WebKitWebContext *context; - GError *error = NULL; /* clean up any zombies immediately */ sigchld(0);