# Applet menu

**URL:** <https://www.ruby-forum.com/t/applet-menu/168597>\
**Category:** Ruby-Gnome 2\
**Created:** [May 22, 2009, 7:16pm UTC](https://www.ruby-forum.com/t/applet-menu/168597 "2009-05-22T19:16:12Z")\
**Posts on this page:** 15\
**Page:** 1

<div class="post-metadata">

**Author:** ![Detlef\_R](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/58f4c7/32.png) [@Detlef\_R](https://www.ruby-forum.com/u/Detlef_R)\
**Post date:** [May 22, 2009, 7:16pm UTC](https://www.ruby-forum.com/t/applet-menu/168597/1 "2009-05-22T19:16:12Z")

</div>

Hi,

attached is a patch, that makes it possible to create context menus  
(right click menus) for panel applets.

The syntax to the PanelApplet::set\_menu call is:

@applet.set\_menu xml, [[verb, proc], …]

where  
xml is the XML description for the menu entries; it is the  
same that is used for applets which are written in C  
verb is a name to refer to a menu entry  
proc is an Proc object, that will be called if the menu  
item gets activated

So a menu with an about and a preferences entry can look like this:

xml = “\<popup name=“button3”\>\n” +  
" \<menuitem name=“Item 1” verb=“about” \_label=“About”\n" +  
" pixtype=“stock” pixname=“gtk-about”/\>\n" +  
" \<menuitem name=“Item 2” verb=“pref”  
\_label=“Preferences”\n" +  
" pixtype=“stock” pixname=“gtk-properties”/\>\n" +  
“\n”

@applet.set\_menu xml, [[‘about’, Proc.new{callback\_about}],  
[‘pref’, Proc.new{callback\_preferences}]]

A call with an empty set

@applet.set\_menu “”, []

will clear the menu, so that it can be filled after this with new  
content.

Cheers, detlef

---

<div class="post-metadata">

**Author:** ![Detlef\_R](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/58f4c7/32.png) [@Detlef\_R](https://www.ruby-forum.com/u/Detlef_R)\
**Post date:** [May 23, 2009, 1:21am UTC](https://www.ruby-forum.com/t/applet-menu/168597/2 "2009-05-23T01:21:32Z")

</div>

On Fri, 2009-05-22 at 19:14 +0200, Detlef R. wrote:

> Hi,
> 
> attached is a patch, that makes it possible to create context menus  
> (right click menus) for panel applets.

You’re awesome! As the author of the SSHMenu applet, I get asked for  
that feature all the time.

Thanks  
Grant

---

<div class="post-metadata">

**Author:** ![Detlef\_R](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/58f4c7/32.png) [@Detlef\_R](https://www.ruby-forum.com/u/Detlef_R)\
**Post date:** [May 23, 2009, 2:56am UTC](https://www.ruby-forum.com/t/applet-menu/168597/3 "2009-05-23T02:56:51Z")

</div>

Hi,

In [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
“[ruby-gnome2-devel-en] applet menu” on Fri, 22 May 2009 19:14:06  
+0200,  
Detlef R. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> xml is the XML description for the menu entries; it is the  
> " \<menuitem name="Item 1" verb="about" \_label="About"\n" +  
> A call with an empty set
> 
> @applet.set\_menu “”,
> 
> will clear the menu, so that it can be filled after this with new content.

Thanks for the patch.  
Please commit.

If you are interested in Ruby/PanelApplet, could you become  
a maintainer of the package?

## Thanks,

kou

---

<div class="post-metadata">

**Author:** ![Detlef\_R](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/58f4c7/32.png) [@Detlef\_R](https://www.ruby-forum.com/u/Detlef_R)\
**Post date:** [May 23, 2009, 3:13am UTC](https://www.ruby-forum.com/t/applet-menu/168597/4 "2009-05-23T03:13:51Z")

</div>

Hi,

Kouhei S. schrieb:

> Please commit.

I have no SVN account.

> If you are interested in Ruby/PanelApplet, could you become  
> a maintainer of the package?

I have not much experience on the binding side of ruby-gnome. So I  
don’t know if I’m really the right one. On the other hand, I don’t  
think that there is much work beside of a patch here and there,  
because AFAIK all useful things are ready.

Why not? 🙂

## Cheers, detlef

[http://det.cable.nu](http://det.cable.nu)

---

<div class="post-metadata">

**Author:** ![Detlef\_R](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/58f4c7/32.png) [@Detlef\_R](https://www.ruby-forum.com/u/Detlef_R)\
**Post date:** [May 23, 2009, 3:30am UTC](https://www.ruby-forum.com/t/applet-menu/168597/5 "2009-05-23T03:30:14Z")

</div>

Hi,

In [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
“Re: [ruby-gnome2-devel-en] applet menu” on Sat, 23 May 2009 03:12:00  
+0200,  
Detlef R. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> > Please commit.
> 
> I have no SVN account.

Really?  
I can find your name in developer list:  
[https://sourceforge.net/project/memberlist.php?group\_id=53614](https://sourceforge.net/project/memberlist.php?group_id=53614)

Could you try to commit? If you get failure, I’ll commit it  
or give you a right permission. 🙂

> > If you are interested in Ruby/PanelApplet, could you become  
> > a maintainer of the package?
> 
> I have not much experience on the binding side of ruby-gnome. So I  
> don’t know if I’m really the right one. On the other hand, I don’t  
> think that there is much work beside of a patch here and there,  
> because AFAIK all useful things are ready.

Yes. A maintainer of the package will just maintain. New  
development will be a little work.

His main work will be accepting (or rejecting) patches and  
bug reports. He will receive a few patches and bug reports  
per year.

## Thanks,

kou

---

<div class="post-metadata">

**Author:** ![Detlef\_R](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/58f4c7/32.png) [@Detlef\_R](https://www.ruby-forum.com/u/Detlef_R)\
**Post date:** [May 23, 2009, 4:18am UTC](https://www.ruby-forum.com/t/applet-menu/168597/6 "2009-05-23T04:18:13Z")

</div>

Hi,

Kouhei S. schrieb:

> Really?  
> I can find your name in developer list:  
> [https://sourceforge.net/project/memberlist.php?group\_id=53614](https://sourceforge.net/project/memberlist.php?group_id=53614)

_Upss_ I have totaly forgot it…

> Could you try to commit? If you get failure, I’ll commit it  
> or give you a right permission. 🙂

I will do it tomorrow, caus in one, two hours the sun rises here,  
and my bed is calling 🙂

> development will be a little work.
> 
> His main work will be accepting (or rejecting) patches and  
> bug reports. He will receive a few patches and bug reports  
> per year.

Thats OK with me

Cheers, detlef

–  
[http://det.cable.nu](http://det.cable.nu)

---

<div class="post-metadata">

**Author:** ![Detlef\_R](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/58f4c7/32.png) [@Detlef\_R](https://www.ruby-forum.com/u/Detlef_R)\
**Post date:** [May 23, 2009, 5:19am UTC](https://www.ruby-forum.com/t/applet-menu/168597/7 "2009-05-23T05:19:34Z")

</div>

Hi,

In [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
“Re: [ruby-gnome2-devel-en] applet menu” on Sat, 23 May 2009 03:50:25  
+0200,  
Detlef R. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> > Really?  
> > I can find your name in developer list:  
> > [https://sourceforge.net/project/memberlist.php?group\_id=53614](https://sourceforge.net/project/memberlist.php?group_id=53614)
> 
> _Upss_ I have totaly forgot it…

X\<

> > Could you try to commit? If you get failure, I’ll commit it  
> > or give you a right permission. 🙂
> 
> I will do it tomorrow, caus in one, two hours the sun rises here,  
> and my bed is calling 🙂

Good night. 😉

> > development will be a little work.
> > 
> > His main work will be accepting (or rejecting) patches and  
> > bug reports. He will receive a few patches and bug reports  
> > per year.
> 
> Thats OK with me

Wow! Thanks!!!

–  
kou

---

<div class="post-metadata">

**Author:** ![Detlef\_R](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/58f4c7/32.png) [@Detlef\_R](https://www.ruby-forum.com/u/Detlef_R)\
**Post date:** [May 26, 2009, 1:08pm UTC](https://www.ruby-forum.com/t/applet-menu/168597/8 "2009-05-26T13:08:17Z")

</div>

On Fri, 2009-05-22 at 19:14 +0200, Detlef R. wrote:

> Hi,
> 
> attached is a patch, that makes it possible to create context menus  
> (right click menus) for panel applets.

I just tried to apply your patch and hit a snag. Up until now I have  
never tried compiling the bindings so it is most likely that I’m doing  
something wrong however I thought I’d mention it here in case the error  
meant something to you …

I’m running Ubuntu 8.10 (intrepid), so I grabbed all the build  
dependencies and the source package with these commands:

$ sudo apt-get build-dep libpanel-applet2-ruby1.8  
$ apt-get source libpanel-applet2-ruby1.8

I then chdir’d into the panel-applet directory and applied the patch:

$ cd ruby-gnome2-0.17.0~rc1/panel-applet  
$ patch -p0 \< panel-menu.diff

Finally I bumped the debian package version number and rebuilt the  
package:

$ cd ..  
$ debchange -i “patch from Detlef R. to add context menu support”  
$ dpkg-buildpackage -b -rfakeroot

The build proceeded OK until it got to the panel-applet directory when  
it failed with this error:

rbpanel-applet.c:28: error: static declaration of â€˜id\_callâ€™ follows  
non-static declaration /home/grant/build/ruby-gnome2-0.17.0~rc1/gtk/  
src/global.h:31: error: previous declaration of â€˜id\_callâ€™ was here

The header file with the conflicting declaration is one that was added  
to rbpanel-applet.c by the patch.

I repeated the above steps without applying the patch and the package  
build proceeded without errors.

Cheers  
Grant

---

<div class="post-metadata">

**Author:** ![Detlef\_R](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/58f4c7/32.png) [@Detlef\_R](https://www.ruby-forum.com/u/Detlef_R)\
**Post date:** [May 26, 2009, 1:15pm UTC](https://www.ruby-forum.com/t/applet-menu/168597/9 "2009-05-26T13:15:19Z")

</div>

On Fri, 2009-05-22 at 19:14 +0200, Detlef R. wrote:

> Hi,
> 
> attached is a patch, that makes it possible to create context menus  
> (right click menus) for panel applets.

Since you’ve had some success modifiying the libpanelapplet Ruby  
bindings I thought I’d mention a problem I encountered this evening.

I added a small text entry box to one of my applets (similar to the  
gnome dictionary applet) but when I click in the entry box it does not  
receive the focus and does not respond to keystrokes.

It appears that my applet needs to call the panel\_applet\_request\_focus  
method to achieve what I want, but it’s not implemented in the Ruby  
bindings. It doesn’t seem to be a complicated method but I’m not sure  
what is required.

The C code from gdict-applet.c calls it like this:

static gboolean  
gdict\_applet\_entry\_button\_press\_event\_cb (GtkWidget \*widget,  
GdkEventButton \*event,  
GdictApplet \*applet)  
{  
panel\_applet\_request\_focus (PANEL\_APPLET (applet), event-\>time);

return FALSE;  
}

I snipped that code from here:

> **[Sign in · GitLab](https://gitlab.gnome.org/users/sign_in)**
>
> Welcome to GNOME GitLab

Cheers  
Grant

---

<div class="post-metadata">

**Author:** ![Detlef\_R](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/58f4c7/32.png) [@Detlef\_R](https://www.ruby-forum.com/u/Detlef_R)\
**Post date:** [May 26, 2009, 2:09pm UTC](https://www.ruby-forum.com/t/applet-menu/168597/10 "2009-05-26T14:09:58Z")

</div>

Hi,

Grant McLean schrieb:

> The build proceeded OK until it got to the panel-applet directory when  
> it failed with this error:
> 
> rbpanel-applet.c:28: error: static declaration of â€˜id\_callâ€™ follows  
> non-static declaration /home/grant/build/ruby-gnome2-0.17.0~rc1/gtk/  
> src/global.h:31: error: previous declaration of â€˜id\_callâ€™ was here
> 
> The header file with the conflicting declaration is one that was added  
> to rbpanel-applet.c by the patch.

I think, I found the bug. Would you please test the attached patch  
against your build, to see if it fixes the problem?

Thanks!  
detlef

---

<div class="post-metadata">

**Author:** ![Detlef\_R](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/58f4c7/32.png) [@Detlef\_R](https://www.ruby-forum.com/u/Detlef_R)\
**Post date:** [May 26, 2009, 4:12pm UTC](https://www.ruby-forum.com/t/applet-menu/168597/11 "2009-05-26T16:12:06Z")

</div>

Hi Grant

Grant McLean schrieb:

> I added a small text entry box to one of my applets (similar to the  
> gnome dictionary applet) but when I click in the entry box it does not  
> receive the focus and does not respond to keystrokes.
> 
> It appears that my applet needs to call the panel\_applet\_request\_focus  
> method to achieve what I want, but it’s not implemented in the Ruby  
> bindings. It doesn’t seem to be a complicated method but I’m not sure  
> what is required.

I have the method ready to commit, but first I like to know, if my  
last patch solved your build problems, so I can commit both in one go.

Cheer, detlef

## Ps. I think it’s time to write some docs for the PanelApplet 🙂

[http://det.cable.nu](http://det.cable.nu)

---

<div class="post-metadata">

**Author:** ![Detlef\_R](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/58f4c7/32.png) [@Detlef\_R](https://www.ruby-forum.com/u/Detlef_R)\
**Post date:** [May 26, 2009, 9:26pm UTC](https://www.ruby-forum.com/t/applet-menu/168597/12 "2009-05-26T21:26:50Z")

</div>

On Tue, 2009-05-26 at 15:44 +0200, Detlef R. wrote:

> > bindings. It doesn’t seem to be a complicated method but I’m not sure  
> > what is required.
> 
> I have the method ready to commit, but first I like to know, if my  
> last patch solved your build problems, so I can commit both in one go.

That’s great! And yes your last patch solved the build problem.

> Ps. I think it’s time to write some docs for the PanelApplet 🙂

I agree. The project web site used to have documentation for the  
PanelApplet class so maybe someone still has a copy somewhere.

If not, I should be able to help with the documentation.

Cheers  
Grant

---

<div class="post-metadata">

**Author:** ![Detlef\_R](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/58f4c7/32.png) [@Detlef\_R](https://www.ruby-forum.com/u/Detlef_R)\
**Post date:** [May 26, 2009, 9:22pm UTC](https://www.ruby-forum.com/t/applet-menu/168597/13 "2009-05-26T21:22:44Z")

</div>

On Tue, 2009-05-26 at 14:07 +0200, Detlef R. wrote:

> > The header file with the conflicting declaration is one that was added  
> > to rbpanel-applet.c by the patch.
> 
> I think, I found the bug. Would you please test the attached patch  
> against your build, to see if it fixes the problem?

Yes, with the second patch applied on top of the first one the build  
completed successfully.

I haven’t had a chance to try the context menu feature yet and probably  
won’t have a chance for a few days.

Thanks  
Grant

---

<div class="post-metadata">

**Author:** ![Detlef\_R](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/58f4c7/32.png) [@Detlef\_R](https://www.ruby-forum.com/u/Detlef_R)\
**Post date:** [May 26, 2009, 9:38pm UTC](https://www.ruby-forum.com/t/applet-menu/168597/14 "2009-05-26T21:38:35Z")

</div>

Hi,

Grant McLean schrieb:

> On Tue, 2009-05-26 at 15:44 +0200, Detlef R. wrote:
> 
> > I have the method ready to commit, but first I like to know, if my  
> > last patch solved your build problems, so I can commit both in one go.
> 
> That’s great! And yes your last patch solved the build problem.

Both are committed.

> > Ps. I think it’s time to write some docs for the PanelApplet 🙂
> 
> I agree. The project web site used to have documentation for the  
> PanelApplet class so maybe someone still has a copy somewhere.
> 
> If not, I should be able to help with the documentation.

I’ve started with it. It would be useful if someone can review it,  
mainly cause I’m not a native English speaker.

Cheers, detlef

–  
[http://det.cable.nu](http://det.cable.nu)

---

<div class="post-metadata">

**Author:** ![Detlef\_R](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/58f4c7/32.png) [@Detlef\_R](https://www.ruby-forum.com/u/Detlef_R)\
**Post date:** [May 30, 2009, 10:47pm UTC](https://www.ruby-forum.com/t/applet-menu/168597/15 "2009-05-30T22:47:03Z")

</div>

On Fri, 2009-05-22 at 19:14 +0200, Detlef R. wrote:

> Hi,
> 
> attached is a patch, that makes it possible to create context menus  
> (right click menus) for panel applets.

I finally got a chance to try out this feature today and it works well -  
a very useful addition.

I’d be happy to lend a hand with the docs if someone could set me up  
with a wiki login.

Thanks  
Grant
