[gtkada] Why do I get a contraint error on Get_Child

Preben Randhol randhol at pvv.org
Mon May 7 14:12:58 CEST 2001


Preben Randhol <randhol at pvv.org> wrote on 07/05/2001 (12:53) :
>       Child : Gtk_Widget;
>    begin
> 
>       Child :=  Get_Child (Gui_Window.Gui_Base_Vbox, 1);
> 
> I don't understand why as the documentation says:
> 
>    function Get_Child
>         (Box                : access Gtk_Box_Record;
>            Num                : in     Gint)
>            return Gtk.Widget.Gtk_Widget;
> 
>    Return the Num-th child of the box, or null if there is no such child.
> 
> What I'm trying to do is to remove a Gtk_Frame that is packed in a Vbox
> so that I can pack another Frame there when the display should
> change.

The problem seems to be that I called the procedure from within the
Initialize of my Gui_Window.

But I have a different problem which I don't understand:

The documentation (which I must say is better than the GTK+
documentation, as that contains no info.) say that: 

   procedure Remove
        (Container          : access Gtk_Container_Record;
           Widget             : access Gtk.Widget.Gtk_Widget_Record'Class);

   Remove a child from the container.
   Nothing is done if Widget is not a child of Container. Widget is not
   destroyed, but is deleted from the screen.   This basically sends the
   "remove" signal (see below.)


So I tried this:

   Add (Container, Some_Widget);
   Remove (Container, Some_Widget);
   Add (Container, Some_Widget);

But then I get : Gtk-CRITICAL **: file gtkcontainer.c: line 715
(gtk_container_add): assertion `widget->parent == NULL' failed.

I know the code above does not make sense, but I discovered this problem
as I was switching back and forth between two widget.

The container is a Vbox and the Some_Widget is a Frame.

Thanks in advance.

-- 
Preben Randhol ------------------- http://www.pvv.org/~randhol/ --
                 «For me, Ada95 puts back the joy in programming.»




More information about the gtkada mailing list