Re: Change an image on a button

Guillaume Charhon writes:
I've some problems to change an image on a button.
See the example :
gtk_button_set_image(GTK_BUTTON(theButton), ImageOne); // ok
gtk_button_set_image(GTK_BUTTON(theButton), ImageTwo); // ok
gtk_button_set_image(GTK_BUTTON(theButton), ImageOne); // ImageOne doesn't appear !

GtkImage, like other GtkWidgets, is created floating. The first call to gtk_button_set_image() sinks the floating ref, then the second call unrefs it and the GtkImage ImageOne is destroyed. This method is used because it simplifies refcount handling for the usual case. If you want to reuse ImageOne you need to ref or sink it yourself.
Ed Catmur

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