X-Git-Url: http://vcs.maemo.org/git/?a=blobdiff_plain;f=uzbl.c;h=17628b2862e0b3d29ad7d0f1f2e7aa2436cbd7f7;hb=128937eb2af1be25ef4cf8ccdb5c9f20d80e01ae;hp=bb11fcf3a1fda48d99be07de421b40f7906222c0;hpb=0ef46333e1a68130afb16b038852de1344b0e499;p=uzbl-mobile diff --git a/uzbl.c b/uzbl.c index bb11fcf..17628b2 100644 --- a/uzbl.c +++ b/uzbl.c @@ -43,16 +43,14 @@ #include #include #include +#include + #include #include #include #include #include -#include #include -#include -#include -#include #include #include "uzbl.h" #include "config.h" @@ -85,7 +83,7 @@ typedef const struct { void (*func)(void); } uzbl_cmdprop; -enum {TYPE_INT, TYPE_STR}; +enum {TYPE_INT, TYPE_STR, TYPE_FLOAT}; /* an abbreviation to help keep the table's width humane */ #define PTR(var, t, d, fun) { .ptr = (void*)&(var), .type = TYPE_##t, .dump = d, .func = fun } @@ -133,7 +131,8 @@ const struct { { "max_conns", PTR(uzbl.net.max_conns, INT, 1, cmd_max_conns)}, { "max_conns_host", PTR(uzbl.net.max_conns_host, INT, 1, cmd_max_conns_host)}, { "useragent", PTR(uzbl.net.useragent, STR, 1, cmd_useragent)}, - /* exported WebKitWebSettings properties*/ + /* exported WebKitWebSettings properties */ + { "zoom_level", PTR(uzbl.behave.zoom_level, FLOAT,1, cmd_zoom_level)}, { "font_size", PTR(uzbl.behave.font_size, INT, 1, cmd_font_size)}, { "monospace_size", PTR(uzbl.behave.monospace_size, INT, 1, cmd_font_size)}, { "minimum_font_size", PTR(uzbl.behave.minimum_font_size, INT, 1, cmd_minimum_font_size)}, @@ -392,6 +391,23 @@ new_window_cb (WebKitWebView *web_view, WebKitWebFrame *frame, WebKitNetworkRequ return (FALSE); } +static gboolean +mime_policy_cb(WebKitWebView *web_view, WebKitWebFrame *frame, WebKitNetworkRequest *request, gchar *mime_type, WebKitWebPolicyDecision *policy_decision, gpointer user_data) { + (void) frame; + (void) request; + (void) user_data; + + /* If we can display it, let's display it... */ + if (webkit_web_view_can_show_mime_type (web_view, mime_type)) { + webkit_web_policy_decision_use (policy_decision); + return TRUE; + } + + /* ...everything we can't displayed is downloaded */ + webkit_web_policy_decision_download (policy_decision); + return TRUE; +} + WebKitWebView* create_web_view_cb (WebKitWebView *web_view, WebKitWebFrame *frame, gpointer user_data) { (void) web_view; @@ -582,7 +598,6 @@ VIEWFUNC(go_forward) #undef VIEWFUNC /* -- command to callback/function map for things we cannot attach to any signals */ -// TODO: reload static struct {char *name; Command command[2];} cmdlist[] = { /* key function no_split */ { "back", {view_go_back, 0} }, @@ -716,6 +731,10 @@ static void load_uri (WebKitWebView *web_view, GArray *argv) { if (argv_idx(argv, 0)) { GString* newuri = g_string_new (argv_idx(argv, 0)); + if (g_strstr_len (argv_idx(argv, 0), 11, "javascript:") != NULL) { + run_js(web_view, argv); + return; + } if (g_strrstr (argv_idx(argv, 0), "://") == NULL) g_string_prepend (newuri, "http://"); /* if we do handle cookies, ask our handler for them */ @@ -952,7 +971,7 @@ expand_template(const char *template, gboolean escape_markup) { token = g_scanner_get_next_token(uzbl.scan); if(token == G_TOKEN_SYMBOL) { - sym = (int)g_scanner_cur_value(uzbl.scan).v_symbol; + sym = GPOINTER_TO_INT(g_scanner_cur_value(uzbl.scan).v_symbol); switch(sym) { case SYM_URI: if(escape_markup) { @@ -1351,6 +1370,11 @@ cmd_font_size() { } static void +cmd_zoom_level() { + webkit_web_view_set_zoom_level (uzbl.gui.web_view, uzbl.behave.zoom_level); +} + +static void cmd_disable_plugins() { g_object_set (G_OBJECT(view_settings()), "enable-plugins", !uzbl.behave.disable_plugins, NULL); @@ -1530,6 +1554,11 @@ set_var_value(gchar *name, gchar *val) { buf = expand_vars(val); *ip = (int)strtoul(buf, &endp, 10); g_free(buf); + } else if (c->type == TYPE_FLOAT) { + float *fp = (float *)c->ptr; + buf = expand_vars(val); + *fp = strtof(buf, &endp); + g_free(buf); } /* invoke a command specific function */ @@ -1980,6 +2009,7 @@ create_browser () { 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); + g_signal_connect (G_OBJECT (g->web_view), "mime-type-policy-decision-requested", G_CALLBACK (mime_policy_cb), g->web_view); return scrolled_window; } @@ -2127,6 +2157,8 @@ add_binding (const gchar *key, const gchar *act) { printf ("Binding %-10s : %s\n", key, act); action = new_action(parts[0], parts[1]); + if (g_hash_table_remove (uzbl.bindings, key)) + g_warning ("Overwriting existing binding for \"%s\"", key); g_hash_table_replace(uzbl.bindings, g_strdup(key), action); g_strfreev(parts); }