diff options
author | Josh Rickmar <jrick@devio.us> | 2012-06-01 17:15:52 -0400 |
---|---|---|
committer | Josh Rickmar <jrick@devio.us> | 2012-06-01 17:15:52 -0400 |
commit | 1df03fd0b17313e7d953dcb0e14d6849207ca0dc (patch) | |
tree | 885f8eb5280e5b5143001f82df89d93988b5427f /xombrero.c | |
parent | e3380aecad73c5e9114862db9d39368beb76a48c (diff) | |
download | xombrero-1df03fd0b17313e7d953dcb0e14d6849207ca0dc.tar.gz |
Add a custom_uri setting to check if a URI should be handled by an
external script rather then through xombrero. This makes it possible to use scripts to support things such as mailto URIs. Fixes FS#253
Diffstat (limited to 'xombrero.c')
-rw-r--r-- | xombrero.c | 32 |
1 files changed, 31 insertions, 1 deletions
diff --git a/xombrero.c b/xombrero.c index 6835fb7..67dac8b 100644 --- a/xombrero.c +++ b/xombrero.c @@ -221,6 +221,7 @@ struct undo_tailq undos; struct keybinding_list kbl; struct sp_list spl; struct user_agent_list ua_list; +struct custom_uri_list cul; int user_agent_count = 0; struct command_list chl; struct command_list shl; @@ -3290,7 +3291,29 @@ tab_close_cb(GtkWidget *btn, GdkEventButton *e, struct tab *t) return (FALSE); } +int +parse_custom_uri(struct tab *t, const char *uri) +{ + struct custom_uri *u; + int handled = 0; + char *cmd, *esc_uri; + + TAILQ_FOREACH(u, &cul, entry) { + if (strncmp(uri, u->uri, strlen(u->uri))) + continue; + + handled = 1; + esc_uri = g_strescape(uri, ""); + cmd = g_strdup_printf("%s \"%s\"", u->cmd, esc_uri); + if (system(cmd)) + show_oops(t, "custom uri command failed: %s", + cmd); + g_free(esc_uri); + g_free(cmd); + } + return (handled); +} void activate_uri_entry_cb(GtkWidget* entry, struct tab *t) @@ -3315,6 +3338,9 @@ activate_uri_entry_cb(GtkWidget* entry, struct tab *t) if (parse_xtp_url(t, uri)) return; + if (parse_custom_uri(t, uri)) + return; + /* otherwise continue to load page normally */ load_uri(t, (gchar *)uri); focus_webview(t); @@ -4535,7 +4561,10 @@ webview_npd_cb(WebKitWebView *wv, WebKitWebFrame *wf, /* If this is an xtp url, we don't load anything else. */ if (parse_xtp_url(t, uri)) - return (TRUE); + return (TRUE); + + if (parse_custom_uri(t, uri)) + return (TRUE); if ((t->mode == XT_MODE_HINT && t->new_tab) || t->ctrl_click) { t->ctrl_click = 0; @@ -7734,6 +7763,7 @@ main(int argc, char **argv) TAILQ_INIT(&chl); TAILQ_INIT(&shl); TAILQ_INIT(&ua_list); + TAILQ_INIT(&cul); #ifndef XT_RESOURCE_LIMITS_DISABLE struct rlimit rlp; |