Hopefully trivial question regarding UIManager & Menu items

Hi,

I’m playing around with the new (to me) UIManager class to build
application menus, and I was wondering how you can access each of the
menu items to add a handler for the “selected” signal.

If I have to walk the menu items after getting the top-level menus with
uimanager[“/MenuBar”], that’s fine, but I’m actually not sure which
methods I’m supposed to use to traverse the children. Using

uimanager[…].each

doesn’t seem to give me the menu items as I would expect. I get things
like:

#<Gtk::ImageMenuItem:0x7fe166e4abc0 ptr=0xc500c0>
#<Gtk::AccelLabel:0x7fe166e4a878 ptr=0xd37130>
#<Gtk::Image:0x7fe166e4a800 ptr=0xc50170>

What I’m actually trying to do is add a selected handler to each menu
item so that I can update the status bar with additional information.
Anyone with a better idea on how to do this (code would be nice! :),
please feel free to adjust my thinking.

I don’t seem to find any examples for this anywhere. I know I could do
it if I added the menu items manually, but I’m trying to use the new
tools (and the merge stuff will be handy for my app too).

Thanks in advance,

ast

Andrew S. Townley [email protected]
http://atownley.org

Ok,

I’ve discovered the signal in the UIManager, “connect-proxy”, that I
need to access. I missed it when I was looking before, sorry.

However, now that I’m trying to use this signal, I don’t understand
what’s happening.

Normally, you’d do something like this:

@uimanager.signal_connect(“connect-proxy”) do |uimanager, action, proxy|
proxy.signal_connect(“select”) do |item|
set_status_text(action.tooltip)
end
end

However, when I try this, I get messages like:

example.rb:101: warning: GRClosure invoking callback: already destroyed

each time the “select” signal is fired.

I’ve tried making the block to “connect-proxy” an external block, but I
still get half as many messages.

Based on the way you need to connect signals, I don’t see how this is
really supposed to work if the internal proc objects are already
destroyed. Is this because they’re doubly nested?

$ ruby -v
ruby 1.8.6 (2007-09-24 patchlevel 111) [x86_64-linux]

Any advice on the correct way to do this would be most appreciated.

BTW: is there a way to get a bundle of the ruby-gnome2 documentation
for off-line use (without building the whole project from scratch)?

Cheers,

ast

On Fri, 2008-10-10 at 00:01 +0100, Andrew S. Townley wrote:

uimanager[…].each
Anyone with a better idea on how to do this (code would be nice! :),
please feel free to adjust my thinking.

I don’t seem to find any examples for this anywhere. I know I could do
it if I added the menu items manually, but I’m trying to use the new
tools (and the merge stuff will be handy for my app too).

Thanks in advance,

ast

Andrew S. Townley [email protected]
http://atownley.org

Hi,

In 1223718947.23429.17.camel@linna
“[ruby-gnome2-devel-en] Additional info Re: Hopefully trivial question
regarding UIManager & Menu items” on Sat, 11 Oct 2008 10:55:47 +0100,
“Andrew S. Townley” [email protected] wrote:

example.rb:101: warning: GRClosure invoking callback: already destroyed

each time the “select” signal is fired.

Thanks for reporting.
I’ve fixed it in trunk.

Workaround:
proxies = []
@uimanager.signal_connect(“connect-proxy”) do |uimanager, action,
proxy|
proxies << proxy
proxy.signal_connect(“select”) do |item|
set_status_text(action.tooltip)
end
end

BTW: is there a way to get a bundle of the ruby-gnome2 documentation
for off-line use (without building the whole project from scratch)?

You can get it as RD format:
% svn co

You can see it by rbbr:
http://ruby-gnome2.sourceforge.jp/hiki.cgi?rbbr

Put RD formatted documentation to rbbr’s data
dir. (e.g. /usr/share/rbbr/rd/, /usr/local/share/rbbr/rd/
and so on)

Thanks,

kou