Adapt newwindow()

Reorder cmdline options alphabetically and try to keep settings as they
have been toggled in this surf client.
This commit is contained in:
Quentin Rameau 2015-11-20 17:39:45 +01:00
parent 5bca222339
commit adc650f399
1 changed files with 36 additions and 25 deletions

61
surf.c
View File

@ -1052,45 +1052,56 @@ showview(WebKitWebView *v, Client *c)
} }
void void
newwindow(Client *c, const Arg *arg, gboolean noembed) newwindow(Client *c, const Arg *a, int noembed)
{ {
guint i = 0; int i = 0;
const char *cmd[18], *uri;
const Arg a = { .v = (void *)cmd };
char tmp[64]; char tmp[64];
const char *cmd[26], *uri;
const Arg arg = { .v = cmd };
cmd[i++] = argv0; cmd[i++] = argv0;
cmd[i++] = "-a"; cmd[i++] = "-a";
cmd[i++] = cookiepolicies; cmd[i++] = cookiepolicies;
if (!enablescrollbars) cmd[i++] = enablescrollbars ? "-B" : "-b";
cmd[i++] = "-b"; if (cookiefile && g_strcmp0(cookiefile, "")) {
cmd[i++] = "-c";
cmd[i++] = cookiefile;
}
cmd[i++] = enablecache ? "-D" : "-d";
if (embed && !noembed) { if (embed && !noembed) {
cmd[i++] = "-e"; cmd[i++] = "-e";
snprintf(tmp, LENGTH(tmp), "%u", (int)embed); snprintf(tmp, LENGTH(tmp), "%lu", embed);
cmd[i++] = tmp; cmd[i++] = tmp;
} }
if (!allowgeolocation) cmd[i++] = runinfullscreen ? "-F" : "-f";
cmd[i++] = "-g"; cmd[i++] = allowgeolocation ? "-G" : "-g";
if (!loadimages) cmd[i++] = loadimages ? "-I" : "-i";
cmd[i++] = "-i"; cmd[i++] = kioskmode ? "-K" : "-k";
if (kioskmode) cmd[i++] = enablestyle ? "-M" : "-m";
cmd[i++] = "-k"; cmd[i++] = enableinspector ? "-N" : "-n";
if (!enableplugins) cmd[i++] = enableplugins ? "-P" : "-p";
cmd[i++] = "-p"; if (scriptfile && g_strcmp0(scriptfile, "")) {
if (!enablescripts) cmd[i++] = "-r";
cmd[i++] = "-s"; 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) if (showxid)
cmd[i++] = "-x"; cmd[i++] = "-x";
if (enablecache) /* do not keep zoom level */
cmd[i++] = "-D";
cmd[i++] = "-c";
cmd[i++] = cookiefile;
cmd[i++] = "--"; cmd[i++] = "--";
uri = arg->v ? (char *)arg->v : c->linkhover; if ((uri = a->v))
if (uri)
cmd[i++] = uri; cmd[i++] = uri;
cmd[i++] = NULL; cmd[i] = NULL;
spawn(NULL, &a);
spawn(c, &arg);
} }
GtkWidget * GtkWidget *