[gtkada] Getting Parent Window from Gtk_Image_Menu_Item_Record

Emmanuel Briot briot at adacore.com
Mon Jan 10 09:17:56 CET 2005



jeff at thecreems.com wrote:
> Ugg..Forget it.. I knew this sounded like a familiar question....Turns 
> out I asked it (and got an answer) abour 4 years ago or so.
> 
> The problem is that menus actually get their own little "pop-up" window 
> associated with them so their top-level window is not the window that 
> they are "attatched" to.
> 
> In any case, there are a few different ways to address this problem. For 
> my use I think the "easiest" approach is to get the parent menu for the 
> item, then use Get_Attach_Widget and then use the toplevel call from there.
> 
> There are a few other approaches suggested in that original thread that 
> probably are better in many cases as well.


I personnally avoid using Get_Parent and Get_Toplevel_Widget, since this 
means that you cannot easily change the way your interface looks later 
on without also changing the code.
I think it is better to use the OO paradigm, and always derive your own 
widget types from GtkAda's standard widgets in such cases.
For instance, I would create a new Menu_Item widget type, in which I 
would store a pointer to the toplevel window.

Or use the User_Data parameter when connecting the callback.

Emmanuel



More information about the gtkada mailing list