diff options
author | Rob <rob.manea@gmail.com> | 2010-03-12 12:35:47 +0100 |
---|---|---|
committer | Rob <rob.manea@gmail.com> | 2010-03-12 12:35:47 +0100 |
commit | ca118d293041c241e1ab2ca07398ca11fd193518 (patch) | |
tree | 3c006f19229756be6a02259b704248162a4e7f3f /src | |
parent | 5aa9a876c8a0e6812a1ca2217227f99e24635f6e (diff) |
remove obsolete new_window handler and fix some potential segfault issues
Diffstat (limited to 'src')
-rw-r--r-- | src/callbacks.c | 8 | ||||
-rw-r--r-- | src/uzbl-core.c | 66 | ||||
-rw-r--r-- | src/uzbl-core.h | 4 |
3 files changed, 28 insertions, 50 deletions
diff --git a/src/callbacks.c b/src/callbacks.c index 145bc19..298b3db 100644 --- a/src/callbacks.c +++ b/src/callbacks.c @@ -629,17 +629,22 @@ navigation_decision_cb (WebKitWebView *web_view, WebKitWebFrame *frame, WebKitNe } gboolean -new_window_cb (WebKitWebView *web_view, WebKitWebFrame *frame, WebKitNetworkRequest *request, WebKitWebNavigationAction *navigation_action, WebKitWebPolicyDecision *policy_decision, gpointer user_data) { +new_window_cb (WebKitWebView *web_view, WebKitWebFrame *frame, + WebKitNetworkRequest *request, WebKitWebNavigationAction *navigation_action, + WebKitWebPolicyDecision *policy_decision, gpointer user_data) { (void) web_view; (void) frame; (void) navigation_action; (void) policy_decision; (void) user_data; const gchar* uri = webkit_network_request_get_uri (request); + if (uzbl.state.verbose) printf("New window requested -> %s \n", uri); + webkit_web_policy_decision_use(policy_decision); send_event(NEW_WINDOW, uri, NULL); + return TRUE; } @@ -680,7 +685,6 @@ create_web_view_cb (WebKitWebView *web_view, WebKitWebFrame *frame, gpointer us if (uzbl.state.selected_url != NULL) { if (uzbl.state.verbose) printf("\nNew web view -> %s\n",uzbl.state.selected_url); - new_window_load_uri(uzbl.state.selected_url); } else { if (uzbl.state.verbose) printf("New web view -> %s\n","Nothing to open, exiting"); diff --git a/src/uzbl-core.c b/src/uzbl-core.c index d449ab3..5ee8243 100644 --- a/src/uzbl-core.c +++ b/src/uzbl-core.c @@ -100,7 +100,6 @@ const struct var_name_to_ptr_t { { "forward_keys", PTR_V_INT(uzbl.behave.forward_keys, 1, NULL)}, { "cookie_handler", PTR_V_STR(uzbl.behave.cookie_handler, 1, NULL)}, { "authentication_handler", PTR_V_STR(uzbl.behave.authentication_handler, 1, set_authentication_handler)}, - { "new_window", PTR_V_STR(uzbl.behave.new_window, 1, NULL)}, { "scheme_handler", PTR_V_STR(uzbl.behave.scheme_handler, 1, NULL)}, { "fifo_dir", PTR_V_STR(uzbl.behave.fifo_dir, 1, cmd_fifo_dir)}, { "socket_dir", PTR_V_STR(uzbl.behave.socket_dir, 1, cmd_socket_dir)}, @@ -493,25 +492,40 @@ parseenv (gchar* string) { return out; } - void clean_up(void) { - send_event(INSTANCE_EXIT, uzbl.info.pid_str, NULL); - g_free(uzbl.info.pid_str); + if(uzbl.info.pid_str) { + send_event(INSTANCE_EXIT, uzbl.info.pid_str, NULL); + g_free(uzbl.info.pid_str); + uzbl.info.pid_str = NULL; + } + + if(uzbl.state.executable_path) { + g_free(uzbl.state.executable_path); + uzbl.state.executable_path = NULL; + } - g_free(uzbl.state.executable_path); if (uzbl.behave.commands) { g_hash_table_destroy(uzbl.behave.commands); uzbl.behave.commands = NULL; } - if(uzbl.state.event_buffer) + if(uzbl.state.event_buffer) { g_ptr_array_free(uzbl.state.event_buffer, TRUE); + uzbl.state.event_buffer = NULL; + } - if (uzbl.behave.fifo_dir) + if (uzbl.behave.fifo_dir) { unlink (uzbl.comm.fifo_path); - if (uzbl.behave.socket_dir) + g_free(uzbl.comm.fifo_path); + uzbl.comm.fifo_path = NULL; + } + + if (uzbl.behave.socket_dir) { unlink (uzbl.comm.socket_path); + g_free(uzbl.comm.socket_path); + uzbl.comm.socket_path = NULL; + } } gint @@ -1220,42 +1234,6 @@ dehilight (WebKitWebView *page, GArray *argv, GString *result) { webkit_web_view_set_highlight_text_matches (page, FALSE); } - -void -new_window_load_uri (const gchar * uri) { - if (uzbl.behave.new_window) { - GString *s = g_string_new (""); - g_string_printf(s, "'%s'", uri); - run_handler(uzbl.behave.new_window, s->str); - send_event(NEW_WINDOW, s->str, NULL); - return; - } - GString* to_execute = g_string_new (""); - g_string_append_printf (to_execute, "%s --uri '%s'", uzbl.state.executable_path, uri); - int i; - for (i = 0; entries[i].long_name != NULL; i++) { - if ((entries[i].arg == G_OPTION_ARG_STRING) && - !strcmp(entries[i].long_name,"uri") && - !strcmp(entries[i].long_name,"name")) { - gchar** str = (gchar**)entries[i].arg_data; - if (*str!=NULL) - g_string_append_printf (to_execute, " --%s '%s'", entries[i].long_name, *str); - } - else if(entries[i].arg == G_OPTION_ARG_STRING_ARRAY) { - int j; - gchar **str = *((gchar ***)entries[i].arg_data); - for(j=0; str[j]; j++) - g_string_append_printf(to_execute, " --%s '%s'", entries[i].long_name, str[j]); - } - } - if (uzbl.state.verbose) - printf("\n%s\n", to_execute->str); - g_spawn_command_line_async (to_execute->str, NULL); - /* TODO: should we just report the uri as event detail? */ - send_event(NEW_WINDOW, to_execute->str, NULL); - g_string_free (to_execute, TRUE); -} - void chain (WebKitWebView *page, GArray *argv, GString *result) { (void) page; (void) result; diff --git a/src/uzbl-core.h b/src/uzbl-core.h index 73ec7c1..e3a5020 100644 --- a/src/uzbl-core.h +++ b/src/uzbl-core.h @@ -123,7 +123,6 @@ typedef struct { gchar* socket_dir; gchar* cookie_handler; gchar* authentication_handler; - gchar* new_window; gchar* default_font_family; gchar* monospace_font_family; gchar* sans_serif_font_family; @@ -267,9 +266,6 @@ void load_uri (WebKitWebView * web_view, GArray *argv, GString *result); void -new_window_load_uri (const gchar * uri); - -void chain (WebKitWebView *page, GArray *argv, GString *result); void |