aboutsummaryrefslogtreecommitdiffhomepage
path: root/uzbl-core.c
diff options
context:
space:
mode:
authorGravatar Robert Manea <gotmor@gmail.com>2009-09-07 15:47:29 +0200
committerGravatar Robert Manea <gotmor@gmail.com>2009-09-07 15:47:29 +0200
commit7fdc33ac081da4b819e5be228eb53272b7eca32f (patch)
tree768da70709bfccd7acdfa144e0d272f5e0f5a0ce /uzbl-core.c
parenta6ba3396bc6a60e5fb946a8f6be753e6e7eb7257 (diff)
parentde8504736fd87147dcc588fe27165a5bf7c01507 (diff)
Merge branch 'event-messages' of git://github.com/Dieterbe/uzbl into event-messages
Conflicts: uzbl-core.c uzbl-core.h
Diffstat (limited to 'uzbl-core.c')
-rw-r--r--uzbl-core.c161
1 files changed, 98 insertions, 63 deletions
diff --git a/uzbl-core.c b/uzbl-core.c
index e843182..3d4bea8 100644
--- a/uzbl-core.c
+++ b/uzbl-core.c
@@ -193,31 +193,31 @@ const struct var_name_to_ptr_t {
};
/* Event id to name mapping
- * Event names must be in the same
+ * Event names must be in the same
* order as in 'enum event_type'
*
* TODO: Add more useful events
*/
const char *event_table[LAST_EVENT] = {
- "LOAD_START" ,
- "LOAD_COMMIT" ,
- "LOAD_FINISH" ,
- "LOAD_ERROR" ,
+ "LOAD_START" ,
+ "LOAD_COMMIT" ,
+ "LOAD_FINISH" ,
+ "LOAD_ERROR" ,
"KEY_PRESS" ,
"KEY_RELEASE" ,
- "DOWNLOAD_REQUEST" ,
+ "DOWNLOAD_REQUEST" ,
"COMMAND_EXECUTED" ,
"LINK_HOVER" ,
"TITLE_CHANGED" ,
"GEOMETRY_CHANGED" ,
"WEBINSPECTOR" ,
- "COOKIE" ,
"NEW_WINDOW" ,
"SELECTION_CHANGED",
- "VARIABLE_SET",
- "FIFO_SET",
- "INSTANCE_START",
- "INSTANCE_EXIT",
+ "VARIABLE_SET" ,
+ "FIFO_SET" ,
+ "SOCKET_SET" ,
+ "INSTANCE_START" ,
+ "INSTANCE_EXIT"
};
@@ -891,43 +891,44 @@ VIEWFUNC(go_forward)
/* -- command to callback/function map for things we cannot attach to any signals */
struct {const char *key; CommandInfo value;} cmdlist[] =
-{ /* key function no_split */
- { "back", {view_go_back, 0} },
- { "forward", {view_go_forward, 0} },
- { "scroll_vert", {scroll_vert, 0} },
- { "scroll_horz", {scroll_horz, 0} },
- { "scroll_begin", {scroll_begin, 0} },
- { "scroll_end", {scroll_end, 0} },
- { "reload", {view_reload, 0}, },
- { "reload_ign_cache", {view_reload_bypass_cache, 0} },
- { "stop", {view_stop_loading, 0}, },
- { "zoom_in", {view_zoom_in, 0}, }, //Can crash (when max zoom reached?).
- { "zoom_out", {view_zoom_out, 0}, },
- { "toggle_zoom_type", {toggle_zoom_type, 0}, },
- { "uri", {load_uri, TRUE} },
- { "js", {run_js, TRUE} },
- { "script", {run_external_js, 0} },
- { "toggle_status", {toggle_status_cb, 0} },
- { "spawn", {spawn, 0} },
- { "sync_spawn", {spawn_sync, 0} }, // needed for cookie handler
- { "sh", {spawn_sh, 0} },
- { "sync_sh", {spawn_sh_sync, 0} }, // needed for cookie handler
- { "talk_to_socket", {talk_to_socket, 0} },
- { "exit", {close_uzbl, 0} },
- { "search", {search_forward_text, TRUE} },
- { "search_reverse", {search_reverse_text, TRUE} },
- { "dehilight", {dehilight, 0} },
- { "toggle_insert_mode", {toggle_insert_mode, 0} },
- { "set", {set_var, TRUE} },
- //{ "get", {get_var, TRUE} },
- { "bind", {act_bind, TRUE} },
- { "dump_config", {act_dump_config, 0} },
- { "keycmd", {keycmd, TRUE} },
- { "keycmd_nl", {keycmd_nl, TRUE} },
- { "keycmd_bs", {keycmd_bs, 0} },
- { "chain", {chain, 0} },
- { "print", {print, TRUE} },
- { "update_gui", {update_gui, TRUE} }
+{ /* key function no_split */
+ { "back", {view_go_back, 0} },
+ { "forward", {view_go_forward, 0} },
+ { "scroll_vert", {scroll_vert, 0} },
+ { "scroll_horz", {scroll_horz, 0} },
+ { "scroll_begin", {scroll_begin, 0} },
+ { "scroll_end", {scroll_end, 0} },
+ { "reload", {view_reload, 0}, },
+ { "reload_ign_cache", {view_reload_bypass_cache, 0} },
+ { "stop", {view_stop_loading, 0}, },
+ { "zoom_in", {view_zoom_in, 0}, }, //Can crash (when max zoom reached?).
+ { "zoom_out", {view_zoom_out, 0}, },
+ { "toggle_zoom_type", {toggle_zoom_type, 0}, },
+ { "uri", {load_uri, TRUE} },
+ { "js", {run_js, TRUE} },
+ { "script", {run_external_js, 0} },
+ { "toggle_status", {toggle_status_cb, 0} },
+ { "spawn", {spawn, 0} },
+ { "sync_spawn", {spawn_sync, 0} }, // needed for cookie handler
+ { "sh", {spawn_sh, 0} },
+ { "sync_sh", {spawn_sh_sync, 0} }, // needed for cookie handler
+ { "talk_to_socket", {talk_to_socket, 0} },
+ { "exit", {close_uzbl, 0} },
+ { "search", {search_forward_text, TRUE} },
+ { "search_reverse", {search_reverse_text, TRUE} },
+ { "dehilight", {dehilight, 0} },
+ { "toggle_insert_mode", {toggle_insert_mode, 0} },
+ { "set", {set_var, TRUE} },
+ //{ "get", {get_var, TRUE} },
+ { "bind", {act_bind, TRUE} },
+ { "dump_config", {act_dump_config, 0} },
+ { "dump_config_as_events", {act_dump_config_as_events, 0} },
+ { "keycmd", {keycmd, TRUE} },
+ { "keycmd_nl", {keycmd_nl, TRUE} },
+ { "keycmd_bs", {keycmd_bs, 0} },
+ { "chain", {chain, 0} },
+ { "print", {print, TRUE} },
+ { "update_gui", {update_gui, TRUE} }
};
void
@@ -1015,6 +1016,11 @@ act_dump_config() {
}
void
+act_dump_config_as_events() {
+ dump_config_as_events();
+}
+
+void
set_keycmd() {
run_keycmd(FALSE);
update_title();
@@ -1971,25 +1977,31 @@ set_var_value(const gchar *name, gchar *val) {
if( (c = g_hash_table_lookup(uzbl.comm.proto_var, name)) ) {
if(!c->writeable) return FALSE;
+ msg = g_string_new(name);
+
/* check for the variable type */
if (c->type == TYPE_STR) {
buf = expand(val, 0);
g_free(*c->ptr.s);
*c->ptr.s = buf;
- msg = g_string_new(name);
- g_string_append_printf(msg, " %s", buf);
- send_event(VARIABLE_SET, msg->str);
- g_string_free(msg,TRUE);
+ g_string_append_printf(msg, " str %s", buf);
+
} else if(c->type == TYPE_INT) {
buf = expand(val, 0);
*c->ptr.i = (int)strtoul(buf, &endp, 10);
g_free(buf);
+ g_string_append_printf(msg, " int %d", *c->ptr.i);
+
} else if (c->type == TYPE_FLOAT) {
buf = expand(val, 0);
*c->ptr.f = strtod(buf, &endp);
g_free(buf);
+ g_string_append_printf(msg, " float %f", *c->ptr.f);
}
+ send_event(VARIABLE_SET, msg->str);
+ g_string_free(msg,TRUE);
+
/* invoke a command specific function */
if(c->func) c->func();
} else {
@@ -2011,6 +2023,11 @@ set_var_value(const gchar *name, gchar *val) {
*c->ptr.s = buf;
g_hash_table_insert(uzbl.comm.proto_var,
g_strdup(name), (gpointer) c);
+
+ msg = g_string_new(name);
+ g_string_append_printf(msg, " str %s", buf);
+ send_event(VARIABLE_SET, msg->str);
+ g_string_free(msg,TRUE);
}
return TRUE;
}
@@ -2240,6 +2257,7 @@ init_socket(gchar *dir) { /* return dir or, on error, free dir and return NULL *
if( (chan = g_io_channel_unix_new(sock)) ) {
g_io_add_watch(chan, G_IO_IN|G_IO_HUP, (GIOFunc) control_socket, chan);
uzbl.comm.socket_path = path;
+ send_event(SOCKET_SET, path);
return dir;
}
} else g_warning ("init_socket: could not open in %s: %s\n", path, strerror(errno));
@@ -2297,7 +2315,7 @@ configure_event_cb(GtkWidget* window, GdkEventConfigure* event) {
(void) event;
retrieve_geometry();
- send_event(GEOMETRY_CHANGED, uzbl.gui.geometry);
+ send_event(GEOMETRY_CHANGED, uzbl.gui.geometry);
return FALSE;
}
@@ -2346,7 +2364,7 @@ key_release_cb (GtkWidget* window, GdkEventKey* event) {
void
run_keycmd(const gboolean key_ret) {
-
+
/* run the keycmd immediately if it isn't incremental and doesn't take args */
Action *act;
gchar *tmp;
@@ -2659,6 +2677,7 @@ void
settings_init () {
State *s = &uzbl.state;
Network *n = &uzbl.net;
+
int i;
for (i = 0; default_config[i].command != NULL; i++) {
parse_cmd_line(default_config[i].command, NULL);
@@ -2704,7 +2723,6 @@ void handle_cookies (SoupSession *session, SoupMessage *msg, gpointer user_data)
g_string_printf(s, "GET '%s' '%s' '%s'", soup_uri->scheme, soup_uri->host, soup_uri->path);
if(uzbl.behave.cookie_handler)
run_handler(uzbl.behave.cookie_handler, s->str);
- send_event(COOKIE, s->str);
if(uzbl.behave.cookie_handler &&
uzbl.comm.sync_stdout && strcmp (uzbl.comm.sync_stdout, "") != 0) {
@@ -2730,7 +2748,6 @@ save_cookies (SoupMessage *msg, gpointer user_data){
GString *s = g_string_new ("");
g_string_printf(s, "PUT '%s' '%s' '%s' '%s'", soup_uri->scheme, soup_uri->host, soup_uri->path, cookie);
run_handler(uzbl.behave.cookie_handler, s->str);
- send_event(COOKIE, s->str);
g_free (cookie);
g_string_free(s, TRUE);
}
@@ -2849,18 +2866,36 @@ dump_var_hash(gpointer k, gpointer v, gpointer ud) {
}
void
-dump_key_hash(gpointer k, gpointer v, gpointer ud) {
+dump_config() {
+ g_hash_table_foreach(uzbl.comm.proto_var, dump_var_hash, NULL);
+}
+
+void
+dump_var_hash_as_event(gpointer k, gpointer v, gpointer ud) {
(void) ud;
- Action *a = v;
+ uzbl_cmdprop *c = v;
+ GString *msg;
+
+ if(!c->dump)
+ return;
+
+ /* check for the variable type */
+ msg = g_string_new((char *)k);
+ if (c->type == TYPE_STR) {
+ g_string_append_printf(msg, " str %s", *c->ptr.s ? *c->ptr.s : " ");
+ } else if(c->type == TYPE_INT) {
+ g_string_append_printf(msg, " int %d", *c->ptr.i);
+ } else if (c->type == TYPE_FLOAT) {
+ g_string_append_printf(msg, " float %f", *c->ptr.f);
+ }
- printf("bind %s = %s %s\n", (char *)k ,
- (char *)a->name, a->param?(char *)a->param:"");
+ send_event(VARIABLE_SET, msg->str);
+ g_string_free(msg, TRUE);
}
void
-dump_config() {
- g_hash_table_foreach(uzbl.comm.proto_var, dump_var_hash, NULL);
- g_hash_table_foreach(uzbl.bindings, dump_key_hash, NULL);
+dump_config_as_events() {
+ g_hash_table_foreach(uzbl.comm.proto_var, dump_var_hash_as_event, NULL);
}
void