GTK (GIMP Toolkit) is a library for creating graphical user interfaces. It is licensed using the LGPL license, so you can develop open software, free software,or even commercial non-free software using GTK without having to spend anything for licenses or royalties.
It's called the GIMP toolkit because it was originally written for developing the GNU Image Manipulation Program (GIMP), but GTK has now been used in a large number of software projects, including the GNU Network Object Model Environment (GNOME) project. GTK is built on top of GDK (GIMP Drawing Kit) which is basically a wrapper around the low-level functions for accessing the underlying windowing functions (Xlib in the case of the X windows system), and gdk-pixbuf, a library for client-side image manipulation.
The primary authors of GTK are:
GTK is currently maintained by:
GTK is essentially an object oriented application programmers interface (API). Although written completely in C, it is implemented using the idea of classes and callback functions (pointers to functions).
There is also a third component called GLib which contains a few replacements for some standard calls, as well as some additional functions for handling linked lists, etc. The replacement functions are used to increase GTK's portability, as some of the functions implemented here are not available or are nonstandard on other unixes such as g_strerror(). Some also contain enhancements to the libc versions, such as g_malloc that has enhanced debugging utilities.
In version 2.0, GLib has picked up the type system which forms the foundation for GTK's class hierarchy, the signal system which is used throughout GTK, a thread API which abstracts the different native thread APIs of the various platforms and a facility for loading modules.
As the last component, GTK uses the Pango library for internationalized text output.
This tutorial describes the Pascal interface to GTK+2. There are GTK+2 bindings for many other languages including C, C++, Guile, Perl, Python, TOM, Ada95, Objective C, Eiffel, Java and C#. If you intend to use another language's bindings to GTK, look at that binding's documentation first. In some cases that documentation may describe some important conventions (which you should know first) and then refer you back to this tutorial. There are also some cross-platform APIs (such as wxWindows and V) which use GTK as one of their target platforms; again, consult their documentation first.
This tutorial is an attempt to document as much as possible of GTK, but it is by no means complete. This tutorial assumes a reasonable understanding of Pascal, and how to create Pascal programs. It would be a great benefit for the reader to have previous X programming experience, but it shouldn't be necessary. If you are learning GTK as your first widget set, please comment on how you found this tutorial, and what you had trouble with.
This document is a "work in progress". Please look for updates on http://www.mimuw.edu.pl/~zbyszek/gtk2/tutorial.
This document is a translation of the GTK+2 Tutorial for use with the Free Pascal Compiler. This is the second translation of GTK tutorial, the previous one has been done by Mark Howe for GTK+1 and is accessible from Free Pascal pages, but now it has mostly historical value, so new one was necessary.
All but the smallest fragments of code have been tested - as testified by screen captures of the output. If you'd like to compile and run the examples yourself you should be able to copy and paste from your web browser. Alternatively, you can download a tarred and gzipped bundle of all the source code here.