Re: [gtk-list] Re: Gtk--: Accelerators and ItemFactory the hardway



On Wed, 17 Mar 1999, David LE CORFEC wrote:

>  Hi,
> 
>  I just figured out how to add accelerators :) (hi Tero :)
>  (discovered GtkAccelGroup very lately :)
> 
> //
>     Gtk_AccelGroup    *accelGroup;
> 
>     accelGroup = new Gtk_AccelGroup();
>     itemFactory = new Gtk_ItemFactory_MenuBar("<Main>", *accelGroup);
>     ...
>     s = strdup (MENU_APPLICATION_OPEN); // ???

the strdup() shouldn't be neccessary, at least GtkItemFactory will copy
the string internally and i highly doubt that gtk-- wants to keep the string
around.

>     item = itemFactory->create_item (s, "<control>F", "",
>          ItemFactoryConnector<Gui, string>(this,&appMenuCallback, s));
>     menuHash->insert (s, item);         // ???
>     ...
>     accelGroup->attach(*this);  // "this" inherits from Gtk_Window
      ^^^^^^^^^^^^^^^^^^

what is this? i guess this is gtk-- member function to invoke
gtk_accel_group_attach()?

gtk_accel_group_attach() is an internal gtk function (seem like this can not
be stressed enough), there are only two situations where accel groups need
to be "attached", that is for windows and for menus, and for both cases, gtk
provides the corresponding functions:

gtk_window_add_accel_group()
and
gtk_menu_set_accel_group()

so that should probably read this->add_accel_group(accelGroup) (or simply
this->add(accelGroup) or however you prefer to wrap that in c++).

tero?

---
ciaoTJ




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