aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar Dieter Plaetinck <dieter@plaetinck.be>2009-06-02 22:23:45 +0200
committerGravatar Dieter Plaetinck <dieter@plaetinck.be>2009-06-02 22:23:45 +0200
commite91f5b5d31aea3436ec0edffb7aab322f189420e (patch)
tree2efcdd7766d020a3620ef88048dbf9b91d8655cc
parent22f1e1bd7d2393b526f88929b6a980b142d92856 (diff)
parent8d3ba4e27da46a84fbc4df3960ce2c17d1106fca (diff)
merge from Uli Schlachter: policy callback + experimental Makefile + tiny fixes
-rw-r--r--AUTHORS1
-rw-r--r--Makefile-new-test51
-rw-r--r--uzbl.c22
-rw-r--r--uzbl.h3
4 files changed, 76 insertions, 1 deletions
diff --git a/AUTHORS b/AUTHORS
index 24597f1..4ee7f0c 100644
--- a/AUTHORS
+++ b/AUTHORS
@@ -18,6 +18,7 @@ Contributors:
Sylvester Johansson (scj) - form filler script & different take on link follower
(mxf) - uzblcat
Mark Nevill - misc patches
+ Uli Schlachter (psychon) - basic mime_policy_cb & Makefile patch
Originaly based on http://trac.webkit.org/browser/trunk/WebKitTools/GtkLauncher/main.c
Which is copyrighted:
diff --git a/Makefile-new-test b/Makefile-new-test
new file mode 100644
index 0000000..5985c90
--- /dev/null
+++ b/Makefile-new-test
@@ -0,0 +1,51 @@
+LIBS := gtk+-2.0 webkit-1.0
+ARCH := $(shell uname -m)
+COMMIT := $(shell git log | head -n1 | sed "s/.* //")
+DEBUG := -ggdb -Wall -W -DG_ERRORCHECK_MUTEXES
+
+CFLAGS := $(shell --cflags $(LIBS)) $(DEBUG) -DARCH="$(ARCH)" -DCOMMIT="\"$(COMMIT)\""
+LDFLAGS := $(shell --libs $(LIBS)) $(LDFLAGS)
+
+PREFIX ?= $(DESTDIR)/usr
+BINDIR ?= $(PREFIX)/bin
+UZBLDATA ?= $(PREFIX)/share/uzbl
+DOCSDIR ?= $(PREFIX)/share/uzbl/docs
+EXMPLSDIR ?= $(PREFIX)/share/uzbl/examples
+
+all: uzbl uzblctrl
+
+uzbl: uzbl.c uzbl.h config.h
+
+%: %.c
+ $(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) $(LIBS) -o $@ $<
+
+test: uzbl
+ ./uzbl --uri http://www.uzbl.org
+
+test-config: uzbl
+ ./uzbl --uri http://www.uzbl.org < examples/configs/sampleconfig-dev
+
+test-config-real: uzbl
+ ./uzbl --uri http://www.uzbl.org < $(EXMPLSDIR)/configs/sampleconfig
+
+clean:
+ rm -f uzbl
+ rm -f uzblctrl
+
+install:
+ install -d $(BINDIR)
+ install -d $(DOCSDIR)
+ install -d $(EXMPLSDIR)
+ install -D -m755 uzbl $(BINDIR)/uzbl
+ install -D -m755 uzblctrl $(BINDIR)/uzblctrl
+ cp -ax docs/* $(DOCSDIR)
+ cp -ax config.h $(DOCSDIR)
+ cp -ax examples/* $(EXMPLSDIR)
+ install -D -m644 AUTHORS $(DOCSDIR)
+ install -D -m644 README $(DOCSDIR)
+
+
+uninstall:
+ rm -rf $(BINDIR)/uzbl
+ rm -rf $(BINDIR)/uzblctrl
+ rm -rf $(UZBLDATA)
diff --git a/uzbl.c b/uzbl.c
index bb11fcf..b444c97 100644
--- a/uzbl.c
+++ b/uzbl.c
@@ -392,6 +392,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;
@@ -952,7 +969,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) {
@@ -1980,6 +1997,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 +2145,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);
}
diff --git a/uzbl.h b/uzbl.h
index 846dad6..1a22513 100644
--- a/uzbl.h
+++ b/uzbl.h
@@ -248,6 +248,9 @@ print(WebKitWebView *page, GArray *argv);
static gboolean
new_window_cb (WebKitWebView *web_view, WebKitWebFrame *frame, WebKitNetworkRequest *request, WebKitWebNavigationAction *navigation_action, WebKitWebPolicyDecision *policy_decision, gpointer user_data);
+static gboolean
+mime_policy_cb(WebKitWebView *web_view, WebKitWebFrame *frame, WebKitNetworkRequest *request, gchar *mime_type, WebKitWebPolicyDecision *policy_decision, gpointer user_data);
+
WebKitWebView*
create_web_view_cb (WebKitWebView *web_view, WebKitWebFrame *frame, gpointer user_data);