[Glade-users] New parent for widget?

Tristan Van Berkom Tristan Van Berkom <tristan.van.berkom@gmail.com>
Thu, 30 Dec 2004 22:25:15 -0500


On Thu, 30 Dec 2004 22:09:48 +0100, Kaare Rasmussen <kar@kakidata.dk> wrote:
> Hi
> 
> Here's what I'd like to do:
[...]
> Can it be done?

Sure it can be done, just make sure that the widget you are parenting
doesn't already have a parent, and get the ref_count bookkeeping right:

/* Need an explicit reference to make sure that
 * `widget' survives the transition.
 */
g_object_ref (widget);
gtk_container_remove (old_container, widget);
gtk_container_add (new_container, widget);
g_object_unref (widget);

Cheers,
                                           -Tristan