Changing a previously created GtkImage
- From: tsaud <tom sauder plasmon com>
- To: gtk-app-devel-list gnome org
- Subject: Changing a previously created GtkImage
- Date: Wed, 12 Sep 2007 13:52:43 -0700 (PDT)
I have created an image from a file using
image1 = gtk_image_new_from_file("pictures/Empty.gif");
gtk_widget_set_name (image1, "image1");
and displalyed it using:
gtk_widget_show(image1);
gtk_box_pack_start(GTK_BOX (hbox1), image1, TRUE, TRUE, 0);
and that works fine. The image is correctly displayed where I want it.
Later, when a particular event happens (right now I have assigned it to a
button press), I want to change the image to the image in the file
"pictures/Full.gif" (which is exactly the same size as Empty.gif). To do
that, I did the following:
void on_button1_pressed (GtkButton *button, gpointer user_data)
{
GtkWidget *imageptr;
imageptr = lookup_widget(GTK_WIDGET(button), "image1");
if(imageptr != NULL)
{
gtk_image_set_from_file(GTK_IMAGE(imageptr), "pictures/Full.gif");
}
else
fprintf(stderr, "image1 not found\n");
}
When I press the button, the image is replaced by a broken image icon, not
the new image. What am I doing wrong? I am obviously getting the correct
widget with the lookup_widget call, since the image changed. The file
"Empty.gif" and the file "Full.gif" are in the same directory, and when I
change the gtk_image_new_from_file() call to load the "Full.gif" file, that
works fine as well, so I know the file is there and readable. I just don't
understand why it didn't change to the new image.
Thanks,
T
--
View this message in context:
http://www.nabble.com/Changing-a-previously-created-GtkImage-tf4431950.html#a12643884
Sent from the Gtk+ - Apps Dev mailing list archive at Nabble.com.
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]