lewisforlife
December 29th, 2009, 04:31 AM
I am writing a GTK+ C Program and want to call a function when an image is clicked, basically I want the image to act like a button. Here is basically what I want to do:
image = gtk_image_new_from_file ("image.png");
g_signal_connect (G_OBJECT (image), "clicked", G_CALLBACK (callback), NULL);
gtk_widget_show (image);
I quickly learned that you can't do this with a GtkImage, so I tried to use an event box:
event_box = gtk_event_box_new ();
g_signal_connect (G_OBJECT (event_box), "clicked", G_CALLBACK (callback), NULL);
gtk_container_add (GTK_CONTAINER (window), event_box);
gtk_widget_show (event_box);
image = gtk_image_new_from_file ("image.png");
gtk_container_add (GTK_CONTAINER (event_box), image);
gtk_widget_show (image);This did not work either, how can I make an image call a function when it is clicked?
image = gtk_image_new_from_file ("image.png");
g_signal_connect (G_OBJECT (image), "clicked", G_CALLBACK (callback), NULL);
gtk_widget_show (image);
I quickly learned that you can't do this with a GtkImage, so I tried to use an event box:
event_box = gtk_event_box_new ();
g_signal_connect (G_OBJECT (event_box), "clicked", G_CALLBACK (callback), NULL);
gtk_container_add (GTK_CONTAINER (window), event_box);
gtk_widget_show (event_box);
image = gtk_image_new_from_file ("image.png");
gtk_container_add (GTK_CONTAINER (event_box), image);
gtk_widget_show (image);This did not work either, how can I make an image call a function when it is clicked?