GTK

GTK ( GIMP Toolkit ) is a free component library under the LGPL, with the graphical user interface (GUI ) can be created for software.

It was initially developed by Peter Mattis, Spencer Kimball and Josh MacDonald to get off to create a Motif user interface for the graphics program GIMP. In the meantime, however, GTK uses of a variety of applications and in the GNOME desktop environment or Xfce and is therefore, in addition to Qt, one of the most successful graphic toolkits for the X Window System.

History and Development

GTK is written in the C programming language. The first version of GTK contained some helper routines for solving basic programming tasks, such as to store various data. These are quite time consuming especially in the case of the repeated development of programs for the programmer. So contained the first versions of GTK as data structures for linked lists, binary trees or " growing" string. It was also developed with GTK is a system to do object oriented programming in C. These tools also proved to be for programs without a graphical interface to be useful and therefore were outsourced later in a separate library that GLib library of C functions. The object-oriented system was outsourced to the GObject library, system-oriented drawing methods in the GDK library ( GTK Drawing Kit). The latter makes it possible that GTK cross-platform can run identical among others on Windows, X Window System and Mac OS X.

The version of GTK 2 received new and improved functions to render text using the Pango library, a new theme engine, a more flexible API and a new library ( ATK ) to improve the accessibility of the toolkit for disabled people, with, for example, reader software, magnification tools, and alternative input devices can be addressed. GTK 2 is not compatible with GTK 1, so existing applications had to be ported.

Since version 2.8 GTK , the vector-based library Cairo, which uses hardware acceleration for rendering if possible used. GTK 2.24, latest version of the 2.x series.

On 10 February 2011, version 3.0 was released. Many classified as obsolete functions have been removed, as well as improving existing interfaces. GTK 3 is not backward compatible with GTK 2.x. However, libraries of both versions are installed in parallel.

GTK 3.0 includes among other things a new interface for the drawing of widgets, which is based entirely now at Cairo, a CSS-based theming engine that allows animated state transitions, improved layout options, a new slide switch widget, an application class that support for multiple pointing devices ( multi- pointer) and symbolic icons that can change their color by state. Internal structures were separated and hidden, so that it will be easier in the future to make changes without an interface fracture must arise from the public interface. Furthermore, multiple GDK backends support simultaneously within the same library. So far, for different libraries were necessary.

With GTK 3.2, two new backends have been introduced: a applications can be operated remotely via the network in the browser for display server Wayland and HTML5 backend called Broadway, with the GTK.

Programming Example

The classic way to program with GTK is to first define the properties of the graphic elements used to group them and then link them with specific event handlers ( a possible event would be, for example, the click of a button ). However, there are also graphical design tools for GTK surfaces such as Glade or Stetic contained in MonoDevelop that can one avoid the first two steps, extend GTK to prototyping capabilities and allow you to make changes to the surface of a program without the having to change the source code of the software.

A typical Hello World program that displays the window on the right might look something like this:

It is first generated in the main routine main a new window and set its title and the frame distance to the inner elements. Thereafter, a button is formed with a corresponding label, and placed in the window. A window is always a container, ie an element that contains other controls (widgets ) can be included.

Subsequently, the destroy signal, which generates the window widget, for example, when you click on the " Close " button, linked gtk_main_quit with the GTK function that terminates the program. Even the previously created button is connected to a callback function called on_button_clicked, which is implemented above. For the connecting signals with callback functions directly involves functions of GLib, whose name prefix g_ instead gtk_ is.

Since all controls are invisible at first, they must be made visible, either individually or all together, by calling gtk_widget_show_all. With the call of gtk_main finally the main event loop is started that waits for events and then distributed to the appropriate signals.

The function that is executed when you click on the button that represents an example, can be used as to the calling control by there read the label on the button and is output to the standard output. Then the program is terminated. The second data parameter of the callback function can contain any data that was specified when connecting. In this example, there is only the value is NULL, so nothing passed.

The sample program is by calling gcc -o gtkhello.c gtkhello ` pkg -config gtk -3.0 - libs ` compiled within the folder in which the file is located - cflags.

Links to other programming languages

Since GTK is a pure C library, it can be easily connected to many other programming languages. In object-oriented programming using the GObjects omitted, usually can be there GTK objects use as native language objects. The Vala programming language used directly as a GObject object system and therefore requires no run-time library for the language binding.

Look and Feel

The appearance of the toolkit is configurable for the most part by the user. Thus, different themes to choose from, some of which mimic the appearance of other user interfaces, such as Windows, Motif or Next Step.

Environments that use GTK

Gnome, Xfce, LXDE and ROX desktop use GTK as the basis, which means that the programs rely on GTK when drawing the window elements. GTK is not just limited to these desktops; each GTK program can be run on any other desktop environment such as KDE or CDE, if there the GTK libraries are installed. Order (eg KDE) to improve the optical integration in Qt-based desktops, there are gtk -qt. GTK is also available for Microsoft Windows and Apple Mac OS X ( nativ/X11 ) and thus makes it possible to write applications that can easily be ported between relatively Unix, Windows and Mac OS X.

Alternatives

265281
de