Gtk--: Upgrading from MenuFactory to ItemFactory



Hi,

since 0.10.2 MenuFactory yells at me that it's deprecated and will
disappear sometime soon. So  I'm trying to upgrade from MenuFactory
to ItemFactory but I'm running into problems with my callbacks.

-- I used to do this:
static GtkMenuEntry menu_items[] = {
{"<Main>/File/New",      "<control>N",   c_file_menu_callback,    "new"},
{"<Main>/File/Open",     "<control>O",   c_file_menu_callback,    "open"}
};
d_menuFactory.add_subfactory (&d_subFactory, "<Main>");
d_menuFactory.add_entries (menu_items, nmenu_items);
this->add_accelerator_table (menu_items);
d_menuBar = new Gtk_mb,
MenuBar(GTK_MENU_BAR(d_subFactory.gtkobj()->widget));
d_vbox.pack_start (*d_menuBar, FALSE,FALSE,0);
d_menuBar->show ();

-- I'm now doing this:
static GtkItemFactoryEntry menu_items[] = {
{"/File",           0, 0, 0, "<Branch>" },
{"/File/New",  0, 0, 0, 0 },
{"/File/Open",      0, 0, 0, 0 } };
d_menuFactory = new Gtk_ItemFactory_MenuBar("<Main>");
d_menuFactory->create_items (nmenu_items, menu_items, 0);
  {  // ugly
  Gtk_ObjectHandle<Gtk_MenuBar> a(d_menuFactory->get_menubar_widget(""));
  d_menuBar = a;
  }
d_vbox.pack_start (*d_menuBar, FALSE, FALSE, 0);
d_menuBar->show ();

This works, but I can't figure out how to add the callback info to the
menu_items definition. I've tried a c-style functions (as in the old code
above), a C++ style method but keep getting compile errors or
just non-working code. So after more than an hour of putzing around
I gave up.

I've briefly looked at the Gtk+ source to see what item_factory does,
but I find it a bit cryptic (expecially when looking at it through the
gtk-- 'filter'). If anyone could give me a hint on how to integrate the
callback function in the menu_items, I'd be most obliged.

Thanks
--> Robert

PS: I'm using gtk+ 1.1.7, gtk-- 0.10.2, egcs 1.1b




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]