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