commit:7fb9b863fd1a574f5402a3c00640380ee2767c95
author:Chip Black
committer:Chip Black
date:Mon Jun 8 17:00:11 2009 -0500
parents:bf0210888b2c1a7eb26656fdcaec4e0559569772
Add middle-click-to-open-tab plugin
diff --git a/plugins.conf b/plugins.conf
line changes: +5/-4
index e8d29e4..81c4cb9
--- a/plugins.conf
+++ b/plugins.conf
@@ -1,4 +1,5 @@
-LoadProgress
-Vimish
-FFNav
-DefaultPage
+Plugin LoadProgress
+Plugin Vimish
+Plugin FFNav
+Plugin MiddleClickOpen
+Plugin DefaultPage

diff --git a/plugins/Makefile b/plugins/Makefile
line changes: +1/-1
index 993f955..b122c20
--- a/plugins/Makefile
+++ b/plugins/Makefile
@@ -1,7 +1,7 @@
 CSFLAGS = -debug
 references = -r:../webkit-sharp.dll -pkg:gtk-sharp-2.0
 
-all: Vimish.dll FFNav.dll DefaultPage.dll LoadProgress.dll
+all: Vimish.dll FFNav.dll DefaultPage.dll LoadProgress.dll MiddleClickOpen.dll
 
 clean:
 	rm -f *.dll *.mdb *.so

diff --git a/plugins/MiddleClickOpen.cs b/plugins/MiddleClickOpen.cs
line changes: +31/-0
index 0000000..e67e795
--- /dev/null
+++ b/plugins/MiddleClickOpen.cs
@@ -0,0 +1,31 @@
+using System;
+using Gtk;
+using WebKit;
+using bytex64.WebThing;
+
+public class MiddleClickOpen : WebThingPlugin {
+    private string LinkUri = null;
+    private WebThing wt;
+    
+    public override void Init(WebThing wt) {
+        this.wt = wt;
+    }
+
+    public override void InitWebView(WebView wv) {
+        wv.HoveringOverLink += delegate(object o, HoveringOverLinkArgs e) {
+            LinkUri = e.Link;
+        };
+
+        wv.ButtonReleaseEvent += WebView_ButtonRelease;
+    }
+
+    private void WebView_ButtonRelease(object o, Gtk.ButtonReleaseEventArgs e) {
+        if (e.Event.Button == 2) {
+            if (LinkUri != null) {
+                wt.OpenUriTab(LinkUri);
+                wt.WebView.StopLoading();
+                e.RetVal = true;   // WHY DOESN'T THIS WORK!?
+            }
+        }
+    }
+}