Introduction
Our first GTK+ program will be nothing more than a basic window. There are no event handlers, which means that the window will not respond to any user input such as mouse clicks. Although clicking the X button on the title bar to exit the program will cause the window to disappear, the process is still active. You will have to press ctrl-c from the command line from which you executed the program in order to kill it.
When you compile the source code, please note that the quotes used in the command gcc -Wall -g window.c -o window `gtk-config –cflags` `gtk-config –libs` are single backquotes (the one on the ~ key). I don’t know why this is, but it won’t work any other way.
As you can see, it doesn’t take very much code to get something basic on the screen.
Remember that you will have to press ctrl-c in the terminal from which you executed the program in order to kill it.
Source Code
/*
*File name: window.c
*/#include
#includeint main (int argc, char *argv[])
{
/*– Declare the GTK Widgets used in the program –*/
GtkWidget *window;/*– Initialize GTK –*/
gtk_init (&argc, &argv);/*– Create the new window –*/
window = gtk_window_new(GTK_WINDOW_TOPLEVEL);/*– Display the window –*/
gtk_widget_show(window);/*– Start the GTK event loop –*/
gtk_main();/*– Return 0 if exit is successful –*/
return 0;
}
Compile the Source Code
gcc -Wall -g window.c -o window `gtk-config –cflags` `gtk-config –libs`
Execute the Program
./window






