blam r576 - in trunk: libblam src
- From: cmartin svn gnome org
- To: svn-commits-list gnome org
- Subject: blam r576 - in trunk: libblam src
- Date: Mon, 5 May 2008 18:16:11 +0100 (BST)
Author: cmartin
Date: Mon May 5 17:16:11 2008
New Revision: 576
URL: http://svn.gnome.org/viewvc/blam?rev=576&view=rev
Log:
Initial attempt at doing a popup menu at gecko.
Modified:
trunk/libblam/blam-gecko-utils.cpp
trunk/src/Application.cs
trunk/src/Utils.cs
Modified: trunk/libblam/blam-gecko-utils.cpp
==============================================================================
--- trunk/libblam/blam-gecko-utils.cpp (original)
+++ trunk/libblam/blam-gecko-utils.cpp Mon May 5 17:16:11 2008
@@ -37,6 +37,7 @@
#elif defined(MOZ_NSIXULCHROMEREGISTRY_SELECTSKIN)
#include <nsIChromeRegistry.h>
#endif
+#include <nsIDOMMouseEvent.h>
#ifdef ALLOW_PRIVATE_API
// FIXME: For setting the locale. hopefully gtkmozembed will do itself soon
@@ -190,6 +191,18 @@
gecko_utils_init_chrome ();
}
+// Shamelessly copied from Liferea's mozsupport functions.
+extern "C" int
+blam_gecko_get_mouse_button(gpointer dom_event)
+{
+ int button = 0;
+
+ nsIDOMMouseEvent *mouse_ev = (nsIDOMMouseEvent *)dom_event;
+ mouse_ev->GetButton((PRUint16 *)&button);
+
+ return button;
+}
+
extern "C" void
blam_gecko_utils_set_proxy (gboolean use_proxy, gchar *host, gint port)
{
Modified: trunk/src/Application.cs
==============================================================================
--- trunk/src/Application.cs (original)
+++ trunk/src/Application.cs Mon May 5 17:16:11 2008
@@ -187,6 +187,7 @@
itemPaned.Add2 (f);
f.Show ();
itemView.OnUrl += OnUrl;
+ itemView.Widget.DomMouseClick += new Gecko.DomMouseClickHandler(OnButtonPressEvent);
itemList = new ItemList(itemView);
((Container)itemListSw).Child = itemList;
@@ -266,6 +267,32 @@
}
#endif
+ private void OnButtonPressEvent(object o, Gecko.DomMouseClickArgs args)
+ {
+ int button = Utils.GeckoGetMouseButton(args.DomEvent);
+
+ if(button == 2){ // Right button
+ Gtk.Menu popup = new Gtk.Menu();
+
+ /* GtkUtil.AppendMenuItem(popup,
+ Catalog.GetString("_Open link in browser"),
+ new EventHandler(Goto), true);
+*/
+ GtkUtil.AppendMenuItem(popup,
+ Catalog.GetString("_Copy link location"),
+ "gtk-copy", new EventHandler(CopyLink), true);
+ popup.Popup();
+ }
+
+ args.RetVal = 0;
+ }
+
+ void CopyLink(object o, EventArgs args)
+ {
+ Clipboard clip = Clipboard.Get(Gdk.Atom.Intern("CLIPBOARD", true));
+ clip.Text = itemView.Widget.LinkMessage;
+ }
+
private void ChannelSelected(Channel channel)
{
if (channel == null) {
Modified: trunk/src/Utils.cs
==============================================================================
--- trunk/src/Utils.cs (original)
+++ trunk/src/Utils.cs Mon May 5 17:16:11 2008
@@ -34,6 +34,13 @@
}
[DllImport("libblam.so")]
+ static extern int blam_gecko_get_mouse_button(IntPtr dom_event);
+ public static int GeckoGetMouseButton(IntPtr dom_event)
+ {
+ return blam_gecko_get_mouse_button(dom_event);
+ }
+
+ [DllImport("libblam.so")]
static extern void blam_gecko_utils_set_font (int type, string font);
public static void GeckoSetFont (int type, string font)
{
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]