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



 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); // ???
    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
//

  I just use this code somewhere in my first gtk app ...
Yes some parts are ripped from terraform 0.2.x, but who cares :)

 (I'm not sure about the "???" things,
  I should take a look at the latest terraform source,
  it's my only example of real Gtk-- coding - even if the menu handling
  is ugly, I wonder if Motif is better there :)))

 You'll note the "new" around there - I'm reluctant to create
 widgets on the stack ...

 This morning I also had the funny warning in the gtk_widget_destroy()
 assertion. Looks like I should not return from the callback connected
 to the "destroy" signal of my window
 (I wanted to do this to put a "delete w" in an idle cb)

 Perhaps there's a better way to handle window closing via window manager ...
 (it happens only when quitting this way)

-- 
David Le Corfec, <lecorfec@etudiant.univ-mlv.fr>



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