From 7fb9b863fd1a574f5402a3c00640380ee2767c95 Mon Sep 17 00:00:00 2001 From: Chip Black Date: Mon, 8 Jun 2009 17:00:11 -0500 Subject: [PATCH] Add middle-click-to-open-tab plugin --- plugins.conf | 9 +++++---- plugins/Makefile | 2 +- plugins/MiddleClickOpen.cs | 31 +++++++++++++++++++++++++++++++ 3 files changed, 37 insertions(+), 5 deletions(-) create mode 100644 plugins/MiddleClickOpen.cs diff --git a/plugins.conf b/plugins.conf index e8d29e4..81c4cb9 100644 --- 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 index 993f955..b122c20 100644 --- 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 new file mode 100644 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!? + } + } + } +} -- 2.25.1