This is a patch for the GTK2.Container bug I found today. I tested and it works. If everybody is okay with it, I will commit it.
diff -u -r1.7 gtkcontainer.pre --- gtkcontainer.pre 19 Jan 2008 15:09:07 -0000 1.7 +++ gtkcontainer.pre 25 Jun 2009 21:44:07 -0000 @@ -22,10 +22,19 @@ //! padding around the container. //! Calling this function might result in a resize of the container.
-void add(GTK2.Widget widget); +void add(GTK2.Widget widget) //! Add a subwidget to the container. Don't forget to call show() in //! the subwidget. Some (even most) containers can only contain one child. //! Calling this function might result in a resize of the container. +{ + pgtk2_verify_inited(); + { + struct object *o1; + get_all_args("add",args,"%o",&o1); + gtk_container_add(GTK_CONTAINER(THIS->obj),GTK_WIDGET(get_gobject(o1))); + } + RETURN_THIS(); +}
void remove(GTK2.Widget widget); //! Remove a child from the container. The argument is the child to remove.
----- Original Message ---- From: Lance Dillon riffraff169@yahoo.com To: pike-devel@lists.lysator.liu.se Sent: Thursday, June 25, 2009 2:41:23 PM Subject: GTK2.Container
I just found a bug in the GTK2.Container:
object a=GTK2.Window(GTK2.WindowToplevel); object b=GTK2.Button(); a->add(b); object c=GTK2.Label("text"); b->add(c);
c->add(b);
(Pike GTK:31904): Gtk-CRITICAL **: gtk_container_add: assertion `GTK_IS_WIDGET (widget)' failed
But, GTK2.Label is a GTK2.Widget. (it inherits form GTK2.Misc, which inherits from GTK2.Widget).
I may have to customize the add() method to do some checks and allow the add, rather than autogenerating the code.