Add middle-click-to-open-tab plugin
authorChip Black <bytex64@bytex64.net>
Mon, 8 Jun 2009 22:00:11 +0000 (17:00 -0500)
committerChip Black <bytex64@bytex64.net>
Mon, 8 Jun 2009 22:00:28 +0000 (17:00 -0500)
plugins.conf
plugins/Makefile
plugins/MiddleClickOpen.cs [new file with mode: 0644]

index e8d29e4..81c4cb9 100644 (file)
@@ -1,4 +1,5 @@
-LoadProgress
-Vimish
-FFNav
-DefaultPage
+Plugin LoadProgress
+Plugin Vimish
+Plugin FFNav
+Plugin MiddleClickOpen
+Plugin DefaultPage
index 993f955..b122c20 100644 (file)
@@ -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
new file mode 100644 (file)
index 0000000..e67e795
--- /dev/null
@@ -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!?
+            }
+        }
+    }
+}