diff options
author | 2009-05-20 15:23:39 +0100 | |
---|---|---|
committer | 2009-05-20 15:23:39 +0100 | |
commit | 383a6b111366f2266e097ecabda3d54582804019 (patch) | |
tree | 0b0611d37cbdf14fb4421275ced972d096f9320b /uzbl.c | |
parent | 36c780a3afa026723b93abd4f48d3fcec055c9f3 (diff) | |
parent | 426e4841c5a30a20bfcd05754504f958d15a43b8 (diff) |
Merge branch 'experimental' of git://github.com/DuClare/uzbl into experimental
Diffstat (limited to 'uzbl.c')
-rw-r--r-- | uzbl.c | 46 |
1 files changed, 21 insertions, 25 deletions
@@ -57,8 +57,20 @@ static Uzbl uzbl; +typedef void (*Command)(WebKitWebView*, GArray *argv); -/* define names and pointers to all config specific variables */ +/* commandline arguments (set initial values for the state variables) */ +static GOptionEntry entries[] = +{ + { "uri", 'u', 0, G_OPTION_ARG_STRING, &uzbl.state.uri, "Uri to load at startup (equivalent to 'set uri = URI')", "URI" }, + { "verbose", 'v', 0, G_OPTION_ARG_NONE, &uzbl.state.verbose, "Whether to print all messages or just errors.", NULL }, + { "name", 'n', 0, G_OPTION_ARG_STRING, &uzbl.state.instance_name, "Name of the current instance (defaults to Xorg window id)", "NAME" }, + { "config", 'c', 0, G_OPTION_ARG_STRING, &uzbl.state.config_file, "Config file (this is pretty much equivalent to uzbl < FILE )", "FILE" }, + { NULL, 0, 0, 0, NULL, NULL, NULL } +}; + + +/* associate command names to their properties */ typedef const struct { void **ptr; int type; @@ -84,7 +96,7 @@ const struct { { "insert_mode", {.ptr = (void *)&uzbl.behave.insert_mode, .type = TYPE_INT, .func = NULL}}, { "always_insert_mode", {.ptr = (void *)&uzbl.behave.always_insert_mode, .type = TYPE_INT, .func = cmd_always_insert_mode}}, { "reset_command_mode", {.ptr = (void *)&uzbl.behave.reset_command_mode, .type = TYPE_INT, .func = NULL}}, - { "modkey" , {.ptr = (void *)&uzbl.behave.modkey, .type = TYPE_STRING, .func = cmd_modkey}}, + { "modkey", {.ptr = (void *)&uzbl.behave.modkey, .type = TYPE_STRING, .func = cmd_modkey}}, { "load_finish_handler",{.ptr = (void *)&uzbl.behave.load_finish_handler, .type = TYPE_STRING, .func = NULL}}, { "load_start_handler", {.ptr = (void *)&uzbl.behave.load_start_handler, .type = TYPE_STRING, .func = NULL}}, { "load_commit_handler",{.ptr = (void *)&uzbl.behave.load_commit_handler, .type = TYPE_STRING, .func = NULL}}, @@ -138,17 +150,6 @@ make_var_to_name_hash() { } } -/* commandline arguments (set initial values for the state variables) */ -static GOptionEntry entries[] = -{ - { "uri", 'u', 0, G_OPTION_ARG_STRING, &uzbl.state.uri, "Uri to load at startup (equivalent to 'set uri = URI')", "URI" }, - { "verbose", 'v', 0, G_OPTION_ARG_NONE, &uzbl.state.verbose, "Whether to print all messages or just errors.", NULL }, - { "name", 'n', 0, G_OPTION_ARG_STRING, &uzbl.state.instance_name, "Name of the current instance (defaults to Xorg window id)", "NAME" }, - { "config", 'c', 0, G_OPTION_ARG_STRING, &uzbl.state.config_file, "Config file (this is pretty much equivalent to uzbl < FILE )", "FILE" }, - { NULL, 0, 0, 0, NULL, NULL, NULL } -}; - -typedef void (*Command)(WebKitWebView*, GArray *argv); /* --- UTILITY FUNCTIONS --- */ @@ -901,6 +902,7 @@ run_command (const gchar *command, const guint npre, const gchar **args, for (i = npre; i < g_strv_length((gchar**)args); i++) sharg_append(a, args[i]); + gboolean result; if (sync) result = g_spawn_sync(NULL, (gchar **)a->data, NULL, G_SPAWN_SEARCH_PATH, NULL, NULL, stdout, NULL, NULL, &err); @@ -1004,9 +1006,9 @@ parse_command(const char *cmd, const char *param) { gchar **par = split_quoted(param, TRUE); GArray *a = g_array_new (TRUE, FALSE, sizeof(gchar*)); - if (c[1]) { /* don't split */ + if (c[1] == NOSPLIT) { /* don't split */ sharg_append(a, param); - } else { + } else if (par) { for (i = 0; i < g_strv_length(par); i++) sharg_append(a, par[i]); } @@ -1145,9 +1147,10 @@ cmd_modkey() { buf = g_utf8_strup(uzbl.behave.modkey, -1); uzbl.behave.modmask = 0; - + if(uzbl.behave.modkey) free(uzbl.behave.modkey); + uzbl.behave.modkey = buf; for (i = 0; modkeys[i].key != NULL; i++) { if (g_strrstr(buf, modkeys[i].key)) @@ -1162,7 +1165,7 @@ cmd_useragent() { buf = set_useragent(uzbl.net.useragent); if(uzbl.net.useragent) free(uzbl.net.useragent); - + uzbl.net.useragent = buf?buf:g_strdup(""); } @@ -1189,10 +1192,8 @@ move_statusbar() { static gboolean set_var_value(gchar *name, gchar *val) { - void *p = NULL; uzbl_cmdprop *c = NULL; char *endp = NULL; - char *buf=NULL; if( (c = g_hash_table_lookup(uzbl.comm.proto_var, name)) ) { /* check for the variable type */ @@ -1200,17 +1201,12 @@ set_var_value(gchar *name, gchar *val) { free(*c->ptr); *c->ptr = g_strdup(val); } else if(c->type == TYPE_INT) { - int *ip = c->ptr; + int *ip = GPOINTER_TO_INT(c->ptr); *ip = (int)strtoul(val, &endp, 10); } /* invoke a command specific function */ if(c->func) c->func(); - - /* this will be removed as soon as we have converted to - * the callback interface - */ - p = *c->ptr; } return TRUE; } |