Re: [gtk-list] Re: gtk_container_remove?



Thanks it solved my problem. I will look into the show and hide as I'm
sure that is faster than add and remove. 

Richard Jackson

"Donna S. Martin" wrote:
> 
> 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>
> >
> > 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
> >



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