[Contents] [Next]

1. Introduction

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.

For more details visit the official GTK+ site: http://www.gtk.org. The name GIMP toolkit was given to GTK+, because it was originally written for developing the General 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). The primary authors of GTK are:

Peter Mattis    Spencer Kimball    Josh MacDonald

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.

This tutorial describes the PASCAL interface to GTK. There are GTK bindings for many other languages including C, C++, Guile, Perl, Python, TOM, Ada95, Objective C, and Eiffel. 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 translation of the GTKv1.2 Tutorial for use with the Free Pascal Compiler. 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.

I would very much like to hear of any problems you have learning GTK+ from this document, and would appreciate input as to how it may be improved. Please see the section on Contributing for further information.

[Contents] [Next]