Re: [gtk-list] gtk_container_remove?



GTK+ uses a reference count to determine what widgets
are still needed.  When you removed your "button" from the
container, you decreased the reference count (automatically) by one,
down to zero, thus indicating no-one needed it.   Use gtk_object_ref()
on the button before removing it from the container.   This increases
the reference count, showing the object's still being used. (Eventually,
you should unref it when you really do want to get rid of it).
  Also, a point to consider...can you hide & show rather than
add & remove?

Hope that helps!
Donna
----- Original Message -----
From: Richard D. Jackson <richardj@1gig.net>
To: <gtk-list@redhat.com>
Sent: Thursday, October 07, 1999 9:01 PM
Subject: [gtk-list] gtk_container_remove?


>
> Short description of the problem. I have a dynamically allocated struct
> that contains widget pointers. At various points in my code I want to
> change the widget in one of my containers ( for arguments sake lets say
> a button ). Using these widget pointers I can use gtk_container_remove
> to remove the widget from the container and then use gtk_container_add
> to stick a new one in the container. For both of these operations I use
> widgets that were created earlier in the code with their pointers saved
> in the dynamic struct. Every thing works as expected the first time
> through when I remove one widget and stick another in. But when I want
> to change it back to the original widget I get all kinds of gtk errors
> about object->ref_count > 0 failed. What I think this means is that when
> I did the gtk_container_remove the widget was destroyed verses just
> removed from the container. Am I right in this? If so is there a way to
> remove a widget from a container without destroying it. I really don't
> want to have to create the widgets each time I want to change them I
> just want to create them once and then switch them out as needed as this
> will be happening pretty often.
>
> Richard Jackson
>
> If you need it I can put together a sample piece of code demonstrating
> what I'm trying to do.
>
> --
> To unsubscribe: mail -s unsubscribe gtk-list-request@redhat.com <
/dev/null
>
>
>



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]