pinosaur
/
surf.git
/ commitdiff
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (from parent 1:
7c34d50
)
Add plumbing functionality.
author
Christoph Lohmann
<20h@r-36.net>
Mon, 19 Jan 2015 21:15:18 +0000
(22:15 +0100)
committer
Christoph Lohmann
<20h@r-36.net>
Mon, 19 Jan 2015 21:15:18 +0000
(22:15 +0100)
config.def.h
patch
|
blob
|
history
surf.c
patch
|
blob
|
history
diff --git
a/config.def.h
b/config.def.h
index
7b5cf8d
..
2baafef
100644
(file)
--- a/
config.def.h
+++ b/
config.def.h
@@
-53,6
+53,13
@@
static Bool allowgeolocation = TRUE;
} \
}
} \
}
+/* PLUMB(URI) */
+#define PLUMB(u) {\
+ .v = (char *[]){ "/bin/sh", "-c", \
+ "xdg-open \"$0\"", u, NULL \
+ } \
+}
+
/* styles */
/*
* The iteration will stop at the first match, beginning at the beginning of
/* styles */
/*
* The iteration will stop at the first match, beginning at the beginning of
diff --git
a/surf.c
b/surf.c
index
72d26e7
..
9b75829
100644
(file)
--- a/
surf.c
+++ b/
surf.c
@@
-95,7
+95,7
@@
static SoupCache *diskcache = NULL;
static void addaccelgroup(Client *c);
static void beforerequest(WebKitWebView *w, WebKitWebFrame *f,
WebKitWebResource *r, WebKitNetworkRequest *req,
static void addaccelgroup(Client *c);
static void beforerequest(WebKitWebView *w, WebKitWebFrame *f,
WebKitWebResource *r, WebKitNetworkRequest *req,
- WebKitNetworkResponse *resp,
gpointer d
);
+ WebKitNetworkResponse *resp,
Client *c
);
static char *buildpath(const char *path);
static gboolean buttonrelease(WebKitWebView *web, GdkEventButton *e,
GList *gl);
static char *buildpath(const char *path);
static gboolean buttonrelease(WebKitWebView *web, GdkEventButton *e,
GList *gl);
@@
-138,6
+138,8
@@
static void getpagestat(Client *c);
static char *geturi(Client *c);
static gchar *getstyle(const char *uri);
static char *geturi(Client *c);
static gchar *getstyle(const char *uri);
+static void handleplumb(Client *c, WebKitWebView *w, const gchar *uri);
+
static gboolean initdownload(WebKitWebView *v, WebKitDownload *o, Client *c);
static void inspector(Client *c, const Arg *arg);
static gboolean initdownload(WebKitWebView *v, WebKitDownload *o, Client *c);
static void inspector(Client *c, const Arg *arg);
@@
-209,11
+211,19
@@
addaccelgroup(Client *c) {
static void
beforerequest(WebKitWebView *w, WebKitWebFrame *f, WebKitWebResource *r,
WebKitNetworkRequest *req, WebKitNetworkResponse *resp,
static void
beforerequest(WebKitWebView *w, WebKitWebFrame *f, WebKitWebResource *r,
WebKitNetworkRequest *req, WebKitNetworkResponse *resp,
-
gpointer d
) {
+
Client *c
) {
const gchar *uri = webkit_network_request_get_uri(req);
if(g_str_has_suffix(uri, "/favicon.ico"))
webkit_network_request_set_uri(req, "about:blank");
const gchar *uri = webkit_network_request_get_uri(req);
if(g_str_has_suffix(uri, "/favicon.ico"))
webkit_network_request_set_uri(req, "about:blank");
+
+ if(!g_str_has_prefix(uri, "http://") \
+ && !g_str_has_prefix(uri, "https://") \
+ && !g_str_has_prefix(uri, "about:") \
+ && strlen(uri) > 0) {
+ printf("Handle plumb: %s\n", uri);
+ handleplumb(c, w, uri);
+ }
}
static char *
}
static char *
@@
-561,6
+571,15
@@
getstyle(const char *uri) {
return g_strdup("");
}
return g_strdup("");
}
+static void
+handleplumb(Client *c, WebKitWebView *w, const gchar *uri) {
+ Arg arg;
+
+ webkit_web_view_stop_loading(w);
+ arg = (Arg)PLUMB((char *)uri);
+ spawn(c, &arg);
+}
+
static gboolean
initdownload(WebKitWebView *view, WebKitDownload *o, Client *c) {
Arg arg;
static gboolean
initdownload(WebKitWebView *view, WebKitDownload *o, Client *c) {
Arg arg;