Dynamic menu odd display behaviour

Hi,

I want to add menu items dynamically to a menu when it is activated.
The following code almost works. But the first time you hit the
the File menu button, it looks like the area for the menu is drawn, but
the items do not appear on it. Subsequent presses work correctly, but
the first
lot of items added always appear blank in the menu.

Any ideas on where I’ve gone wrong?

This is on windows, gtk 2.0.11 rubygnome 2-0.16.

Thanks in advance,
Martin

require ‘gtk2’
Gtk.init
win = Gtk::Window.new

menu = Gtk::MenuBar.new
file_menu = Gtk::MenuItem.new(“File”)
file_sub_menu = Gtk::Menu.new
file_menu.set_submenu( file_sub_menu )

file_menu.signal_connect(“select”){
%w( cut copy paste).each{|name|
item = Gtk::MenuItem.new( name )
file_sub_menu.append( item )
item.show_all
}
}

menu.append( file_menu )
menu.show_all

vbox = Gtk::VBox.new(false)
vbox.pack_start( menu , false ,true , 0 )
win.add( vbox )
win.show_all
Gtk.main

Hi Martin,

But the first time you hit the the File menu button, it looks like the area for > the menu is drawn, but the items do not appear on it.

That works for me. When I click the first time on “File” I see the three
menu items.

I’m using gtk version 2.10.11-ubuntu3 and ruby-gtk 0.16. Maybe this is a
windows related gtk bug?

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs