[gtkada] Getting Parent Window from Gtk_Image_Menu_Item_Record

jeff at thecreems.com jeff at thecreems.com
Mon Jan 10 05:57:10 CET 2005


On Sun, 09 Jan 2005 22:28:46 -0500
  <jeff at thecreems.com> wrote:
> 
> I am guessing that I am approaching this all wrong or 
>that there must be a better way....but..
> 
> I used glade to design a window with a few menus. I want 
>to have my program be able to have multiple copies of the 
>window open at the same time. So far so good.
> 
> The problem comes in when I get callbacks from things 
>like
> Gtk_Image_Menu_Item_Record indicating that they are 
>"activated". I'd like to be able to get back to my own 
>type extended window record (the one that gate generates) 
>given only the existing parameter to the callback.
> 
> I tried using something like:
> 
> 
>     Parent_Window : 
> Sensor_Data_Tool_Main_Pkg.Sensor_Data_Tool_Main_Access 
>:=
>       Sensor_Data_Tool_Main_Pkg.Sensor_Data_Tool_Main_Access(Get_Toplevel(Object));
> 
> but this fails with a constraint_error at run time (tag 
>checked failed).
> 
> 
> Is this even the right way to approach this problem or 
>am I missing some obvious alternate approach?
> 
> _______________________________________________
> gtkada mailing list
> gtkada at lists.adacore.com
> http://lists.adacore.com/mailman/listinfo/gtkada




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.




More information about the gtkada mailing list