Hey,

I have been thinking about a Xanadu-style web browser (e.g.
http://xanadu.com.au/ted/XUsurvey/pingshot.gif) where you have two
panes, and each link opens in the other pane; this is especially nice
instead of the "click -> read -> back button"-cycle common when browsing
lists of search results, forum topics, etc.  I built a quick prototype as
a patch to surf(1).  (You can shift-click to open in the same pane.)


diff -r 2533f186089d surf.c
--- a/surf.c    Thu Mar 31 12:52:35 2011 +0200
+++ b/surf.c    Sat Jun 11 19:24:54 2011 +0200
@@ -207,6 +207,18 @@
        return FALSE;
 }
 
+WebKitNavigationResponse
+decidenavigation(WebKitWebView *view, WebKitWebFrame *f, WebKitNetworkRequest 
*r, WebKitWebNavigationAction *n, WebKitWebPolicyDecision *p, Client *c) {
+       if(webkit_web_navigation_action_get_reason(n) ==
+          WEBKIT_WEB_NAVIGATION_REASON_LINK_CLICKED
+          && !(webkit_web_navigation_action_get_modifier_state(n) & 1)) 
{//shift
+               webkit_web_policy_decision_ignore(p);
+               fprintf(stderr, "%s %s\n", winid, 
webkit_network_request_get_uri(r));
+               return TRUE;
+       }
+       return FALSE;
+}
+
 void
 destroyclient(Client *c) {
        Client *p;
@@ -459,6 +471,7 @@
        g_signal_connect(G_OBJECT(c->view), "hovering-over-link", 
G_CALLBACK(linkhover), c);
        g_signal_connect(G_OBJECT(c->view), "create-web-view", 
G_CALLBACK(createwindow), c);
        g_signal_connect(G_OBJECT(c->view), 
"new-window-policy-decision-requested", G_CALLBACK(decidewindow), c);
+       g_signal_connect(G_OBJECT(c->view), 
"navigation-policy-decision-requested", G_CALLBACK(decidenavigation), c);
        g_signal_connect(G_OBJECT(c->view), 
"mime-type-policy-decision-requested", G_CALLBACK(decidedownload), c);
        g_signal_connect(G_OBJECT(c->view), "window-object-cleared", 
G_CALLBACK(windowobjectcleared), c);
        g_signal_connect(G_OBJECT(c->view), "notify::load-status", 
G_CALLBACK(loadstatuschange), c);


You can drive it with this small shell script, 2surf:


#!/bin/sh
(surf -x $1 2>&1 & surf -x $2 2>&1) | awk '
/^[0-9]+$/ {
  if (a==0) { a = $1 } else { b = $1 }
}
/^[0-9]+ / {
  if (a==$1) { to = b } else { to = a }
  system("xprop -id " to " -f _SURF_GO 8s -set _SURF_GO " $2)
}'


(Somehow it didnt work with plain output to stdout due to weird
buffering issues, any ideas?)

I think its pretty nice and certainly worth a try, especially with the
common big wide screens these days.

Enjoy,
-- 
Christian Neukirchen  <chneukirc...@gmail.com>  http://chneukirchen.org


Reply via email to