aboutsummaryrefslogtreecommitdiffhomepage
path: root/uzbl.c
diff options
context:
space:
mode:
authorGravatar Dieter Plaetinck <dieter@plaetinck.be>2009-08-25 22:21:20 +0200
committerGravatar Dieter Plaetinck <dieter@plaetinck.be>2009-08-25 22:21:20 +0200
commitcbdf7cf74b708e717dfe79d0cfc470ecfa93f520 (patch)
tree7f36e73da7b302a855339bc74d8239b9d751fdfc /uzbl.c
parentfa4f3430215808ae4f9af78f00869e9a96b244ef (diff)
parent948630efe45e6573e02ac142855229fb3198d480 (diff)
merge holizz' scheme handler
Diffstat (limited to 'uzbl.c')
-rw-r--r--uzbl.c55
1 files changed, 48 insertions, 7 deletions
diff --git a/uzbl.c b/uzbl.c
index e90d220..8de3faf 100644
--- a/uzbl.c
+++ b/uzbl.c
@@ -140,7 +140,8 @@ const struct var_name_to_ptr_t {
{ "history_handler", PTR_V_STR(uzbl.behave.history_handler, 1, NULL)},
{ "download_handler", PTR_V_STR(uzbl.behave.download_handler, 1, NULL)},
{ "cookie_handler", PTR_V_STR(uzbl.behave.cookie_handler, 1, cmd_cookie_handler)},
- { "new_window", PTR_V_STR(uzbl.behave.new_window, 1, cmd_new_window)},
+ { "new_window", PTR_V_STR(uzbl.behave.new_window, 1, NULL)},
+ { "scheme_handler", PTR_V_STR(uzbl.behave.scheme_handler, 1, cmd_scheme_handler)},
{ "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)},
{ "http_debug", PTR_V_INT(uzbl.behave.http_debug, 1, cmd_http_debug)},
@@ -510,6 +511,44 @@ catch_sigint(int s) {
/* --- CALLBACKS --- */
gboolean
+navigation_decision_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) user_data;
+
+ const gchar* uri = webkit_network_request_get_uri (request);
+ gboolean decision_made = FALSE;
+
+ if (uzbl.state.verbose)
+ printf("Navigation requested -> %s\n", uri);
+
+ if (uzbl.behave.scheme_handler) {
+ GString *s = g_string_new ("");
+ g_string_printf(s, "'%s'", uri);
+
+ run_handler(uzbl.behave.scheme_handler, s->str);
+
+ if(uzbl.comm.sync_stdout && strcmp (uzbl.comm.sync_stdout, "") != 0) {
+ char *p = strchr(uzbl.comm.sync_stdout, '\n' );
+ if ( p != NULL ) *p = '\0';
+ if (!strcmp(uzbl.comm.sync_stdout, "USED")) {
+ webkit_web_policy_decision_ignore(policy_decision);
+ decision_made = TRUE;
+ }
+ }
+ if (uzbl.comm.sync_stdout)
+ uzbl.comm.sync_stdout = strfree(uzbl.comm.sync_stdout);
+
+ g_string_free(s, TRUE);
+ }
+ if (!decision_made)
+ webkit_web_policy_decision_use(policy_decision);
+
+ return TRUE;
+}
+
+gboolean
new_window_cb (WebKitWebView *web_view, WebKitWebFrame *frame, WebKitNetworkRequest *request, WebKitWebNavigationAction *navigation_action, WebKitWebPolicyDecision *policy_decision, gpointer user_data) {
(void) web_view;
(void) frame;
@@ -951,7 +990,7 @@ load_uri (WebKitWebView *web_view, GArray *argv, GString *result) {
run_js(web_view, argv, NULL);
return;
}
- if (g_strrstr (argv_idx(argv, 0), "://") == NULL && g_strstr_len (argv_idx(argv, 0), 5, "data:") == NULL)
+ if (!soup_uri_new(argv_idx(argv, 0)))
g_string_prepend (newuri, "http://");
/* if we do handle cookies, ask our handler for them */
webkit_web_view_load_uri (web_view, newuri->str);
@@ -1759,14 +1798,14 @@ cmd_cookie_handler() {
}
void
-cmd_new_window() {
- gchar **split = g_strsplit(uzbl.behave.new_window, " ", 2);
+cmd_scheme_handler() {
+ gchar **split = g_strsplit(uzbl.behave.scheme_handler, " ", 2);
/* pitfall: doesn't handle chain actions; must the sync_ action manually */
if ((g_strcmp0(split[0], "sh") == 0) ||
(g_strcmp0(split[0], "spawn") == 0)) {
- g_free (uzbl.behave.new_window);
- uzbl.behave.new_window =
- g_strdup_printf("%s %s", split[0], split[1]);
+ g_free (uzbl.behave.scheme_handler);
+ uzbl.behave.scheme_handler =
+ g_strdup_printf("sync_%s %s", split[0], split[1]);
}
g_strfreev (split);
}
@@ -2321,6 +2360,7 @@ create_browser () {
g_signal_connect (G_OBJECT (g->web_view), "load-finished", G_CALLBACK (log_history_cb), g->web_view);
g_signal_connect (G_OBJECT (g->web_view), "load-finished", G_CALLBACK (load_finish_cb), g->web_view);
g_signal_connect (G_OBJECT (g->web_view), "hovering-over-link", G_CALLBACK (link_hover_cb), g->web_view);
+ g_signal_connect (G_OBJECT (g->web_view), "navigation-policy-decision-requested", G_CALLBACK (navigation_decision_cb), g->web_view);
g_signal_connect (G_OBJECT (g->web_view), "new-window-policy-decision-requested", G_CALLBACK (new_window_cb), g->web_view);
g_signal_connect (G_OBJECT (g->web_view), "download-requested", G_CALLBACK (download_cb), g->web_view);
g_signal_connect (G_OBJECT (g->web_view), "create-web-view", G_CALLBACK (create_web_view_cb), g->web_view);
@@ -2858,6 +2898,7 @@ main (int argc, char* argv[]) {
printf("window_id %i\n",(int) uzbl.xwin);
printf("pid %i\n", getpid ());
printf("name: %s\n", uzbl.state.instance_name);
+ printf("commit: %s\n", uzbl.info.commit);
}
uzbl.gui.scbar_v = (GtkScrollbar*) gtk_vscrollbar_new (NULL);