diff options
Diffstat (limited to 'src/callbacks.c')
-rw-r--r-- | src/callbacks.c | 43 |
1 files changed, 34 insertions, 9 deletions
diff --git a/src/callbacks.c b/src/callbacks.c index 446e868..23b8d55 100644 --- a/src/callbacks.c +++ b/src/callbacks.c @@ -8,6 +8,7 @@ #include "events.h" #include "menu.h" #include "type.h" +#include "variables.h" void link_hover_cb (WebKitWebView *page, const gchar *title, const gchar *link, gpointer data) { @@ -113,16 +114,15 @@ destroy_cb (GtkWidget* widget, gpointer data) { gboolean configure_event_cb(GtkWidget* window, GdkEventConfigure* event) { - (void) window; - (void) event; - gchar *lastgeo = NULL; + (void) window; (void) event; - lastgeo = g_strdup(uzbl.gui.geometry); - retrieve_geometry(); + gchar *last_geo = uzbl.gui.geometry; + gchar *current_geo = get_geometry(); - if(strcmp(lastgeo, uzbl.gui.geometry)) - send_event(GEOMETRY_CHANGED, NULL, TYPE_STR, uzbl.gui.geometry, NULL); - g_free(lastgeo); + if(!last_geo || strcmp(last_geo, current_geo)) + send_event(GEOMETRY_CHANGED, NULL, TYPE_STR, current_geo, NULL); + + g_free(current_geo); return FALSE; } @@ -165,12 +165,13 @@ button_press_cb (GtkWidget* window, GdkEventButton* event) { gboolean propagate = FALSE, sendev = FALSE; + context = get_click_context(NULL); + if(event->type == GDK_BUTTON_PRESS) { if(uzbl.state.last_button) gdk_event_free((GdkEvent *)uzbl.state.last_button); uzbl.state.last_button = (GdkEventButton *)gdk_event_copy((GdkEvent *)event); - context = get_click_context(NULL); /* left click */ if(event->button == 1) { if((context & WEBKIT_HIT_TEST_RESULT_CONTEXT_EDITABLE)) @@ -357,7 +358,31 @@ request_starting_cb(WebKitWebView *web_view, WebKitWebFrame *frame, WebKitWebRes (void) response; (void) user_data; + const gchar* uri = webkit_network_request_get_uri (request); + + if (uzbl.state.verbose) + printf("Request starting -> %s\n", uri); send_event (REQUEST_STARTING, NULL, TYPE_STR, webkit_network_request_get_uri(request), NULL); + + if (uzbl.behave.request_handler) { + GString *result = g_string_new (""); + GArray *a = g_array_new (TRUE, FALSE, sizeof(gchar*)); + const CommandInfo *c = parse_command_parts(uzbl.behave.request_handler, a); + + if(c) { + g_array_append_val(a, uri); + run_parsed_command(c, a, result); + } + g_array_free(a, TRUE); + + if(result->len > 0) { + char *p = strchr(result->str, '\n' ); + if ( p != NULL ) *p = '\0'; + webkit_network_request_set_uri(request, result->str); + } + + g_string_free(result, TRUE); + } } void |