Re: [gtk-list] Re: [gtk-1.0.6] GtkToolbar: Two Beginner'squestions



On Thu, 25 Mar 1999, Feiguin wrote:

> > 	1. How can I change one of the pixmap dynamically, e.g,
> > 	   by clicking on one of the buttons in the toolbar ?
> > 	   There seem to be functions to add a widget / button / etc.
> > 	   but no function to remove one (is not a good idea, anyway)
> > 	   or to update one (this would be worthwile, I think).
> > 	   Perhaps there is another solution to this ?
> 	
> Try playing arround with
> gtk_container_remove(GTK_CONTAINER(button), GTK_WIDGET(old_pixmap));
> gtk_container_add(GTK_CONTAINER(button), GTK_WIDGET(new_pixmap));
> 
> You can also try redirecting the pointer
> GTK_PIXMAP(button_pixmap)->pixmap = new/old_pixmap; and then doing a 

you are directly modifying widget contents here, which is NO-NO for
gtk programming. if this doesn't lead to segementation faults, you're
lucky, but you are at least leaking pixmaps with such code. if you want
to set a new pixmap use gtk_pixmap_set(), it'll care about reference
counting, resize computation and neccessary redraws.

> gtk_widget_queue_draw(button_pixmap) but I'm not sure if this will work,
> because of the pixmap mask.
> 
> Good luck, and regards,
> <ADRIAN>
> 

---
ciaoTJ



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