GDK is the "Graphics Drawing Kit", and provides the low-level functionality that GTK uses in drawing objects to the screen. It can be used by a GTK+ application for pixel-level drawing and provides access to the Events that GTK+ uses in generating signals, allowing the programmer to determine which key or mouse button was pressed, for example.
GLIB may be thought of as an alteration of the standard C
libraries, designed to allow for superior portability between
different machine architectures and operating systems. For instance,
instead of the standard C types:
int, char, etc., GLIB
offers the replacement data types
gint, gchar and so on,
as well as some useful new types such as
replacing the use of 0 or 1 as the true or false indicators in a
conditional expression, or
gpointer to replace
* as the generic operator type.
GLIB also offers a number of new structures and functions, including the GString data type and associated functions, which allows for the definition of character strings without having to think explicitly about memory allocation, which is performed automatically by the GString functions. For example
creates a new GString object. The string may be reassigned a new value using
gStr = g_string_new("This is a string.");
which handles the reallocation of memory itself. A GString object is freed using the command
g_string_assign(gStr,"This is a different string.");
The "TRUE" argument here ensures that the memory allocated to the string is completely freed.
GLIB similarly provides functions for setting up linked lists, both singly-linked and double-linked, hash tables and trees.
GLIB offers a degree of error message handling through
g_error, g_warning, g_message and
g_error displays a formatted message and
g_message display a
formatted message indicating the type of message, but do not exit.
g_print is essentially a replacement for
printf, useful for debugging.