286 Introduction to C++ Programming and Graphics
the graphics display by entering the main loop. If we do not enter the main
loop, nothing will happen.
Now, we want not only the window to close, but also the application to
quit when we click the button. This is done by introducing the function:
static void destroy( GtkWidget *widget, gpointer data)
{
gtkmainquit ();
}
and adding the callback:
gsignalconnect (GOBJECT (window), "destroy",
GCALLBACK (destroy), NULL);
immediately before thegsignalconnectswappedcallback. In this way, we
associate the “destroy” with a signal handler event that occurs when the com-
mandgtkwidgetdestroy()is executed.
Programming inGtk+requires familiarization with the application pro-
tocols. Once the widgets have been mastered, the development of GUIs is
tedious yet straightforward. A user interface designer with an integrated de-
velopment environment (IDE) is available for rapid application development
(RAD) (seehttp://glade.gnome.org).
Problems
8.5.1. Modify thehorses.cccode so that the window closes and the applica-
tion quits when the “q” button is pressed.
8.5.2. Adapt to C++ and run aGtk+code of your choice from theGtk+dis-
tribution.