Gtk--: Accelerators and ItemFactory the hard way


I'm trying to add menu accelerators to my application, but have
trouble figuring out the specifics. I have some gtk+ source code
that uses itemfactory, but the semantics of my use in Gtk-- are
different enough so that a straight 1:1 translation is impossible ...

Given these definitions:

void MyClass:ShowMenu (gpointer  callback_data,
                guint     callback_action,
                Gtk_Widget *widget)
     g_message ("ItemFactory: activated \"%s\", action %d",
          d_itemFactory->path_from_widget (*widget),
          (int) callback_action);

<and the following code>:

     Gtk_AccelGroup d_accelGroup ();
     Gtk_ItemFactor      d_itemFactory (new Gtk_ItemFactory_MenuBar("<Main>"));

     d_itemFactory->create_item (MENU_FILE_BRANCH, 0, "<Branch>", 0);
     d_itemFactory->create_item (MENU_FILE_NEW, "<control>N", "",
          ItemFactoryConnector<TFWindow, string>(this,&fileMenuCallback,
     d_accelGroup.add (???, ???, ???);
     d_itemFactory->create_item (MENU_FILE_EXIT, 0, "",
          ItemFactoryConnector<TFWindow, string>(this,&fileMenuCallback,
     d_accelGroup.attach (someWindow);

I'm using itemfactory the hard way (I have not been able to properly integrate
callbacks into the short-hand notation) so I have to add the accelerators one
by one. Can anybody confirm that the above use of d_accelGroup.add what
I want (I'm pretty sure it is) and more imortantly, can anybody tell me what
the parameters that should go with it are?

--> R

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