Well, I would really recommend that you lean using libglade and not auto-generated code as you'd be learning a lot of obsolete code. Start with something simple, a tutorial, and then build from there.
In you glade file, I have added a signal handler to the window's "destroy" event which will call gtk_main_quit when you destroy the window (clicking the 'x' in the titlebar). This is how you will handle events in your application. You will define "handlers" for "signals" in Glade and then write code to do whatever you want.
In your example, using Glade 3, I click on the window and then click the 'Signals" tab of the 'Properties" pane and add 'gtk_main_quit' as the handler for the "destroy" event. The new glade file looks like this:
example.glade
Code:
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE glade-interface SYSTEM "glade-2.0.dtd">
<!--Generated with glade3 3.1.2 on Tue Jan 16 02:00:11 2007 by sorg@euforia-->
<glade-interface>
<widget class="GtkWindow" id="window1">
<signal name="destroy" handler="gtk_main_quit" last_modification_time="Sun, 14 Jan 2007 01:56:55 GMT"/>
<child>
<widget class="GtkImage" id="image1">
<property name="visible">True</property>
<property name="stock">gtk-missing-image</property>
</widget>
</child>
</widget>
</glade-interface>
I then wrote a simple C file to read the .glade file and set the image to /usr/share/gtk-2.0/demo/gnome-foot.png before showing the window.
example.cCode:
#include <gtk/gtk.h>
#include <glade/glade.h>
#define GLADE_FILE "example.glade"
#define IMAGE_FILE "/usr/share/gtk-2.0/demo/gnome-foot.png"
int
main (int argc, char *argv[])
{
GladeXML *gxml = NULL;
GtkWidget *window = NULL;
GtkWidget *image = NULL;
/* initialize GTK+ libraries */
gtk_init (&argc, &argv);
/* build from Glade XML object from the .glade file */
gxml = glade_xml_new (GLADE_FILE, NULL, NULL);
/* get widgets from Glade XML object */
window = glade_xml_get_widget (gxml, "window1");
image = glade_xml_get_widget (gxml, "image1");
/* auto-connect signal callbacks specified in the .glade file */
glade_xml_signal_autoconnect (gxml);
/* free Glade XML object now that we're done with it */
g_object_unref (G_OBJECT (gxml));
/* set the image from a filename */
gtk_image_set_from_file (GTK_IMAGE (image), IMAGE_FILE);
/* show the main window */
gtk_widget_show_all (window);
/* begin GTK+ main loop */
gtk_main ();
return 0;
}
Which you can compile using:
Code:
gcc -Wall -g `pkg-config --cflags --libs gtk+-2.0` `pkg-config --cflags --libs libglade-2.0` -export-dynamic -o example example.c