swap images on click event.



Hi, I'm trying to change an image with another when I click on my applet button, but it doesn't work, can anyone help me out?

CODE:
play_button = gtk_image_new_from_file ("/usr/local/pixmaps/play.png");
pause_button = gtk_image_new_from_file("/usr/local/pixmaps/pause.png");

....

gtk_widget_ref(GTK_WIDGET(pause_button));
gtk_container_remove (GTK_CONTAINER (play_event_box), pause_button);
gtk_widget_unref(play_button);
gtk_widget_reparent(play_button, play_event_box);
gtk_container_add (GTK_CONTAINER (play_event_box), play_button);
gtk_widget_show_all(play_event_box);

....

I've looked at the faq and following the unref and ref directions, but am I missing something here?

And when I debug the applet, I get the following warnings and errors:

(xmms-applet:4997): Gtk-CRITICAL **: file gtkcontainer.c: line 992 (gtk_containe
r_remove): assertion `GTK_IS_TOOLBAR (container) || widget->parent == GTK_WIDGET
 (container)' failed

(xmms-applet:4997): Gtk-WARNING **: Attempting to add a widget with type GtkImag
e to a container of type GtkEventBox, but the widget is already inside a contain
er of type GtkEventBox, the GTK+ FAQ at http://www.gtk.org/faq/ explains how to
reparent a widget.


thanks for any help.



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