# Popup menus with Gtk::MozEmbed?

**URL:** <https://www.ruby-forum.com/t/popup-menus-with-gtk-mozembed/82838>\
**Category:** Ruby-Gnome 2\
**Created:** [January 21, 2007, 6:48pm UTC](https://www.ruby-forum.com/t/popup-menus-with-gtk-mozembed/82838 "2007-01-21T18:48:29Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![subroutine](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/fbc32d/32.png) [@subroutine](https://www.ruby-forum.com/u/subroutine)\
**Post date:** [January 21, 2007, 6:48pm UTC](https://www.ruby-forum.com/t/popup-menus-with-gtk-mozembed/82838/1 "2007-01-21T18:48:29Z")

</div>

Hi

I’m trying to add right-click context menus to a Gtk::MozEmbed widget,  
but  
found that the usual ‘popup-menu’ and ‘button-press-event’ don’t get  
fired.  
After some searching I discovered an undocumented ‘dom\_mouse\_down’  
event,  
which works but unfortunately only returns a GLib::Pointer as argument.

Is there a way to convert this pointer to a real Gdk::Event, or some  
other  
way to find out if the right button was pressed? Also, I’d like to check  
if the mouse was clicked over a link, I guess this info is also included  
in that pointer. Did anybody find out how to do this?

Thanks,  
Markus

* * *

Take Surveys. Earn Cash. Influence the Future of IT  
Join [SourceForge.net](http://SourceForge.net)’s Techsay panel and you’ll get the chance to share  
your  
opinions on IT & business topics through brief surveys - and earn cash  
[http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV](http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV)

---

<div class="post-metadata">

**Author:** ![subroutine](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/fbc32d/32.png) [@subroutine](https://www.ruby-forum.com/u/subroutine)\
**Post date:** [January 21, 2007, 7:03pm UTC](https://www.ruby-forum.com/t/popup-menus-with-gtk-mozembed/82838/2 "2007-01-21T19:03:31Z")

</div>

Hi

Markus K. wrote:

> Hi
> 
> I’m trying to add right-click context menus to a Gtk::MozEmbed widget, but  
> found that the usual ‘popup-menu’ and ‘button-press-event’ don’t get fired.  
> After some searching I discovered an undocumented ‘dom\_mouse\_down’ event,  
> which works but unfortunately only returns a GLib::Pointer as argument.

I see this event in the source code, but it’s not documented and as such  
i’m  
not sure if it’s safe to implement in the binding.

> Is there a way to convert this pointer to a real Gdk::Event, or some other  
> way to find out if the right button was pressed? Also, I’d like to check  
> if the mouse was clicked over a link, I guess this info is also included  
> in that pointer. Did anybody find out how to do this?

I think this should be done in the binding (like  
set\_on\_new\_window\_block/clear\_on\_new\_window\_block), but one must first  
know  
what kind of data this pointer points to.

–  
Mirko M.

* * *

Take Surveys. Earn Cash. Influence the Future of IT  
Join [SourceForge.net](http://SourceForge.net)’s Techsay panel and you’ll get the chance to share  
your  
opinions on IT & business topics through brief surveys - and earn cash  
[http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV](http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV)

---

<div class="post-metadata">

**Author:** ![subroutine](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/fbc32d/32.png) [@subroutine](https://www.ruby-forum.com/u/subroutine)\
**Post date:** [January 21, 2007, 8:10pm UTC](https://www.ruby-forum.com/t/popup-menus-with-gtk-mozembed/82838/3 "2007-01-21T20:10:40Z")

</div>

On Sun, Jan 21, 2007 at 07:01:53PM +0100, Mirko M. wrote:

> I think this should be done in the binding (like  
> set\_on\_new\_window\_block/clear\_on\_new\_window\_block), but one must first know  
> what kind of data this pointer points to.

I poked a little around the gtkmozembed source, and found the relevant  
parts. The signal gets raised in  
[http://lxr.mozilla.org/seamonkey/source/embedding/browser/gtk/src/EmbedEventListener.cpp#295](http://lxr.mozilla.org/seamonkey/source/embedding/browser/gtk/src/EmbedEventListener.cpp#295),  
and the passed pointer is a nsIDOMMouseEvent, which is defined in  
[http://lxr.mozilla.org/seamonkey/source/dom/public/idl/events/nsIDOMMouseEvent.idl](http://lxr.mozilla.org/seamonkey/source/dom/public/idl/events/nsIDOMMouseEvent.idl).  
One of the fields is a nsIDOMEventTarget, which I suppose describes the  
DOM element which received the click.

Now, I don’t know how hard it would be to implement this in the binding,  
as I have absolutely no experience with either C++ or the Mozilla  
codebase.  
But maybe someone else wants to give it a shot?

Cheers,  
Markus

* * *

Take Surveys. Earn Cash. Influence the Future of IT  
Join [SourceForge.net](http://SourceForge.net)’s Techsay panel and you’ll get the chance to share  
your  
opinions on IT & business topics through brief surveys - and earn cash  
[http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV](http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV)

---

<div class="post-metadata">

**Author:** ![subroutine](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/fbc32d/32.png) [@subroutine](https://www.ruby-forum.com/u/subroutine)\
**Post date:** [January 22, 2007, 2:30pm UTC](https://www.ruby-forum.com/t/popup-menus-with-gtk-mozembed/82838/4 "2007-01-22T14:30:50Z")

</div>

Hi Markus,

Markus K. wrote:

> One of the fields is a nsIDOMEventTarget, which I suppose describes the  
> DOM element which received the click.

Thank you for your pointers. This is mozilla C++ code not wrapped by  
gtkmozembed.

I think that starting from the Event there is no end to the chain of the  
C++  
data structures involved.

> Now, I don’t know how hard it would be to implement this in the binding,  
> as I have absolutely no experience with either C++ or the Mozilla codebase.  
> But maybe someone else wants to give it a shot?

I think that this has to be implemented in the gtkmozembed C code before  
it  
can find its way into the ruby binding. There is no C++ code in  
ruby-gnome2  
afaik. Masao? Do you think we might introduce some C++ in the binding to  
support this undocumented feature of gtkmozembed?

Mirko

–  
Mirko M.

* * *

Take Surveys. Earn Cash. Influence the Future of IT  
Join [SourceForge.net](http://SourceForge.net)’s Techsay panel and you’ll get the chance to share  
your  
opinions on IT & business topics through brief surveys - and earn cash  
[http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV](http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV)

---

<div class="post-metadata">

**Author:** ![subroutine](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/fbc32d/32.png) [@subroutine](https://www.ruby-forum.com/u/subroutine)\
**Post date:** [January 22, 2007, 10:39pm UTC](https://www.ruby-forum.com/t/popup-menus-with-gtk-mozembed/82838/5 "2007-01-22T22:39:50Z")

</div>

Markus K. wrote:

> On Mon, Jan 22, 2007 at 02:23:03PM +0100, Mirko M. wrote:  
> … I remember some module in the Pickaxe which  
> allows you to convert C structures into pure Ruby objects by describing the  
> sizes of the individual fields. Would this also be possible with C++? I guess  
> this solution wouldn’t be clean enough for the binding, but maybe it would work  
> fine in my application.

If i remember correctly, unlike a C structure, a C++ class can not be  
unpacked in any safe way. You can eventually access the data you need  
but  
there is no guarantee that it will work if mozilla is compiled with  
another  
C++ compiler.

–  
Mirko M.

* * *

Take Surveys. Earn Cash. Influence the Future of IT  
Join [SourceForge.net](http://SourceForge.net)’s Techsay panel and you’ll get the chance to share  
your  
opinions on IT & business topics through brief surveys - and earn cash  
[http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV](http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV)

---

<div class="post-metadata">

**Author:** ![subroutine](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/fbc32d/32.png) [@subroutine](https://www.ruby-forum.com/u/subroutine)\
**Post date:** [January 25, 2007, 9:18am UTC](https://www.ruby-forum.com/t/popup-menus-with-gtk-mozembed/82838/6 "2007-01-25T09:18:54Z")

</div>

Mirko M. wrote:

> Markus K. wrote:
> 
> > On Mon, Jan 22, 2007 at 02:23:03PM +0100, Mirko M. wrote:  
> > … I remember some module in the Pickaxe which  
> > allows you to convert C structures into pure Ruby objects by describing the  
> > sizes of the individual fields. Would this also be possible with C++? I guess  
> > this solution wouldn’t be clean enough for the binding, but maybe it would work  
> > fine in my application.
> 
> If i remember correctly, unlike a C structure, a C++ class can not be  
> unpacked in any safe way.

But i may be wrong. C++ mangles function names, but C++ structure are  
compatible with C structures.

I’ve not tried this but you can try to make gtkmozembed unsensitive and  
put  
it in an event box… just a try.

–  
Mirko M.  
Ubuntu: an African word meaning “I can’t figure out how to configure  
Debian”

* * *

Take Surveys. Earn Cash. Influence the Future of IT  
Join [SourceForge.net](http://SourceForge.net)’s Techsay panel and you’ll get the chance to share  
your  
opinions on IT & business topics through brief surveys - and earn cash  
[http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV](http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV)

---

<div class="post-metadata">

**Author:** ![subroutine](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/fbc32d/32.png) [@subroutine](https://www.ruby-forum.com/u/subroutine)\
**Post date:** [January 22, 2007, 7:44pm UTC](https://www.ruby-forum.com/t/popup-menus-with-gtk-mozembed/82838/7 "2007-01-22T19:44:18Z")

</div>

On Mon, Jan 22, 2007 at 02:23:03PM +0100, Mirko M. wrote:

> Thank you for your pointers. This is mozilla C++ code not wrapped by  
> gtkmozembed.
> 
> I think that starting from the Event there is no end to the chain of the C++  
> data structures involved.

Hmm… I had a feeling this would be the case 😉

> I think that this has to be implemented in the gtkmozembed C code before it  
> can find its way into the ruby binding. There is no C++ code in ruby-gnome2  
> afaik. Masao? Do you think we might introduce some C++ in the binding to  
> support this undocumented feature of gtkmozembed?

It would be really worthwile, as a browser without a context menu is a  
bit lame.  
On the other hand, it looks like it needs a lot of effort, so maybe  
there’s  
another way to get at the data? I remember some module in the Pickaxe  
which  
allows you to convert C structures into pure Ruby objects by describing  
the  
sizes of the individual fields. Would this also be possible with C++? I  
guess  
this solution wouldn’t be clean enough for the binding, but maybe it  
would work  
fine in my application.

> Mirko

Anyway, thanks for your help!

Markus

* * *

Take Surveys. Earn Cash. Influence the Future of IT  
Join [SourceForge.net](http://SourceForge.net)’s Techsay panel and you’ll get the chance to share  
your  
opinions on IT & business topics through brief surveys - and earn cash  
[http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV](http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV)

---

<div class="post-metadata">

**Author:** ![subroutine](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/fbc32d/32.png) [@subroutine](https://www.ruby-forum.com/u/subroutine)\
**Post date:** [January 25, 2007, 2:13pm UTC](https://www.ruby-forum.com/t/popup-menus-with-gtk-mozembed/82838/8 "2007-01-25T14:13:52Z")

</div>

On Thu, Jan 25, 2007 at 09:17:27AM +0100, Mirko M. wrote:

> Mirko M. wrote:
> 
> But i may be wrong. C++ mangles function names, but C++ structure are  
> compatible with C structures.

Ok, then I’ll have a look at that module…

> I’ve not tried this but you can try to make gtkmozembed unsensitive and put  
> it in an event box… just a try.

Unfortunately if I set it to unsensitive, it doesn’t receive any events,  
so  
I can’t click on links etc.

But thanks for your help, anyway!

Cheers,  
Markus

* * *

Take Surveys. Earn Cash. Influence the Future of IT  
Join [SourceForge.net](http://SourceForge.net)’s Techsay panel and you’ll get the chance to share  
your  
opinions on IT & business topics through brief surveys - and earn cash  
[http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV](http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV)
