Applet menu

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

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

Hi,

In [email protected]
“[ruby-gnome2-devel-en] applet menu” on Fri, 22 May 2009 19:14:06
+0200,
Detlef R. [email protected] 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

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? :slight_smile:

Cheers, detlef

http://det.cable.nu

Hi,

In [email protected]
“Re: [ruby-gnome2-devel-en] applet menu” on Sat, 23 May 2009 03:12:00
+0200,
Detlef R. [email protected] wrote:

Please commit.

I have no SVN account.

Really?
I can find your name in developer list:
Ruby-GNOME 2 Project Member List

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

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

Hi,

Kouhei S. schrieb:

Really?
I can find your name in developer list:
Ruby-GNOME 2 Project Member List

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. :slight_smile:

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

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

Hi,

In [email protected]
“Re: [ruby-gnome2-devel-en] applet menu” on Sat, 23 May 2009 03:50:25
+0200,
Detlef R. [email protected] wrote:

Really?
I can find your name in developer list:
Ruby-GNOME 2 Project Member List

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. :slight_smile:

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

Good night. :wink:

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

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

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:

Cheers
Grant

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

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 :slight_smile:

http://det.cable.nu

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 :slight_smile:

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

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

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 :slight_smile:

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

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