GTK
GTK is a free and open-source cross-platform widget toolkit for creating graphical user interfaces. It is licensed under the terms of the GNU Lesser General Public License, allowing both free and proprietary software to use it. Along with Qt, it is one of the most popular toolkits for the Wayland and X11 windowing systems.
Software architecture
The GTK library contains a set of graphical control elements ; version 3.22.16 contains 186 active and 36 deprecated widgets. GTK is an object-oriented widget toolkit written in the programming language C; it uses GObject, that is the GLib object system, for the object orientation. While GTK is mainly for windowing systems based on X11 and Wayland, it works on other platforms, including Microsoft Windows, and macOS. There is also an HTML5 back-end named Broadway.GTK can be configured to change the look of the widgets drawn; this is done using different display engines. Several display engines exist which try to emulate the look of the native widgets on the platform in use.
Starting with version 2.8, released in 2005, GTK began the transition to using Cairo to render most of its graphical control elements widgets. Since GTK version 3.0, all rendering is done using Cairo.
On 2018-Jan-26 at DevConf.cz Matthias Clasen gave an overview of the current state of GTK 4 development, including a high-level explanation of how rendering and input worked in GTK 3, what changes are being made in GTK 4, and why. In February it was announced that GTK 4 will drop the “+” from the project's name.
GIMP Drawing Kit (GDK)
GDK acts as a wrapper around the low-level functions provided by the underlying windowing and graphics systems.GDK is found in the
directory.GTK Scene Graph Kit (GSK)
GSK is the rendering and scene graph API for GTK. GSK lies between the graphical control elements and the rendering. GSK was finally merged into GTK+ version 3.90 released March 2017.GSK is found in the
directory.GtkInspector
GtkInspector was introduced with version 3.14.GtkInspector can only be invoked after installing the development package /.
GUI designers
There are several GUI designers for GTK. The following projects are active as of July 2011:- Glade, supports GtkBuilder, which is a GTK built-in GUI description format.
- Gazpacho, GUI builder for the GTK toolkit written in Python
- Crow Designer, relies on its own GuiXml format and GuiLoader library.
- Stetic, part of MonoDevelop, oriented toward Gtk#.
GtkBuilder
Language bindings
A library written in one programming language may be used in another language if bindings are written; GTK has a range of bindings for various languages.Gtk#
Gtk# is a set of.NET Framework bindings for the GTK graphical user interface toolkit and assorted GNOME libraries. The library facilitates building graphical GNOME applications using Mono or any other compliant Common Language Runtime. Gtk# is an event-driven system like any other modern windowing library where every widget allows associating handler methods, which get called when certain events occur.Applications built using Gtk# will run on many platforms including Linux, Windows and macOS. The Mono packages for Windows include GTK, Gtk# and a native theme to make applications look like native Windows applications. Starting with Mono 1.9, running Gtk# applications on macOS no longer requires running an X11 server.
Glade Interface Designer can be used with the Glade# bindings to easily design GUI applications. A GUI designer named Stetic is integrated with the MonoDevelop integrated development environment.
In addition to support the standard GTK/GNOME stack of development tools, the gtk-dotnet.dll assembly provides a bridge to consume functionality available on the.NET stack. At this point this includes the functionality to use System.Drawing to draw on a widget.
The lack of a released version with support for GTK3 was cited as a reason to remove the Banshee media player in Ubuntu 12.04., Gtk3 support for Gtk# remains in the preview phase.
Development
GTK is mainly developed by The GNOME Project, which also develops the GNOME Development Platform and the GNOME Desktop Environment.GTK development is loosely managed. Discussion chiefly occurs on several public mailing lists. GNOME developers and users gather at an annual GNOME Users And Developers European Conference GUADEC meeting to discuss GNOME's current state and future direction. GNOME incorporates standards and programs from freedesktop.org to better interoperate with other desktops.
GTK is mainly written in C. Many language bindings are available.
On September 1, 2016 a post on the GTK development blog denoted, among other things, the future numbering scheme of GTK. GTK version 3.22 from autumn 2016 shall be the last 3.x release. After that all resources will move to the GTK 4 development series with the version names 3.90, 3.92, etc. Even as the 4.x series enters development, notable applications still use GTK 2.x and have not been ported to 3.22. Regarding the future of legacy :Category:Software that uses GTK|software using GTK, there is no collective project to port GTK 2.x software to 3.22.
Build automation
In former times GTK utilized the GNU Build System as the build automation system of choice.Since 14 Aug 2017, the master branch of GTK builds with Meson, and the Autotools build system files have been dropped.
Criticism
The most common criticism of GTK is the lack of backward-compatibility in major updates, most notably in the application programming interface and theming.The compatibility breaks between minor releases during the GTK 3.x development cycle was explained by Benjamin Otte as due to strong pressures to innovate, such as providing the features modern users expect and supporting the increasingly influential Wayland display server protocol. With the release of GTK 4, the pressure from the need to innovate will have been released and the balance between stability and innovation will tip toward stability. Similarly, recent changes to theming are specifically intended to improve and stabilise that part of the API, meaning some investment now should be rewarded later.
- Dirk Hohndel, codeveloper of Subsurface and member of Intel's Open-Source Technology Center, criticized the GTK developers for being abrasive and ignoring most community requests.
- Hong Jen Yee, developer of LXDE, expressed disdain for version 3 of the GTK toolkit's radical API changes and increased memory usage, and ported PCMan File Manager to Qt. PCManFM is being developed with a GTK and with a Qt backend at the same time.
- The Audacious music player moved to Qt in version 3.6. The reasons stated by the developers for this include a transition to client-side window decorations, which they claim cause the application to look "GNOME-y and out of place."
- Wireshark has switched to Qt due to not having a good experience with GTK's cross-platform support.
Use
Applications
Some notable applications that use or once used GTK as a widget toolkit include:- GNOME Core Applications – as part of GNOME desktop environment, developed in concert with GTK itself.
- AbiWord – Word processor
- Anjuta – Integrated development environment
- Ardour – Digital audio workstation
- Chromium – Web browser
- Ekiga – VoIP and video conferencing application
- GNU Emacs can use GTK when running on X.
- Evolution – Personal information manager
- gconfig – Linux kernel source configuration utility.
- Geany – a lightweight cross-platform IDE and GTK text editor based on Scintilla.
- GIMP – Raster graphics editor
- Gnumeric – Spreadsheet application
- Gramps – Genealogy software
- Inkscape – Vector graphics editor for SVG
- LiVES – Video editor
- Midori – Minimalistic web browser using GTKWebKit as rendering engine and GTK as widget toolkit
- Pidgin – Instant messenger application
Desktop environments
Current
- GNOME, based on GTK, meaning that programs native to GNOME use GTK
- Budgie, built from scratch for the SolusOS successor, Solus Operating System
- Cinnamon, a fork of GNOME 3 and uses GTK version 3
- MATE, a fork of GNOME 2 and uses GTK 3 since version 1.18
- Xfce, based on GTK 3 since version 4.14
- Pantheon uses GTK 3 exclusively, being developed by elementary OS
- Sugar, a desktop environment for youth primary education, which uses GTK, especially PyGTK
- KDE, though based on Qt, has integration with GTK written programs and themes since version 4.2
- Phosh, a mobile UI designed for PureOS
Inactive
- Unity, the former default desktop environment of Ubuntu
- LXDE is based on GTK 2
- Access Linux Platform
- Consort, the GNOME 3.4 Fallback Mode – fork from SolusOS
- GPE, the GPE Palmtop Environment
- ROX Desktop, a lightweight desktop, with features from the GUI of RISC OS
Miscellaneous
Window managers
The following window managers use GTK:GtkSpell is a library separate from GTK. GtkSpell depends on GTK and Enchant. Enchant is a wrapper for ispell, hunspell, etc, the actual spell checker engine/software. GtkSpell uses GTK's GtkTextView widget, to highlight misspelled words and offer replacement.
Example
// helloworld.c
- include
Needs installing the libraries first in Debian or derivatives:
$ sudo apt-get install libgtk-3-dev
Using pkg-config in a Unix shell, this code can be compiled with the following command:
$ cc -Wall `pkg-config --cflags gtk+-3.0` -o helloworld helloworld.c `pkg-config --libs gtk+-3.0`
Invoke the program:
$./helloworld
History
Linux/Unix
GTK was originally designed and used in the GNU Image Manipulation Program as a replacement of the Motif toolkit; at some point Peter Mattis became disenchanted with Motif and began to write his own GUI toolkit named the GIMP toolkit and had successfully replaced Motif by the 0.60 release of GIMP. Finally GTK was re-written to be object-oriented and was renamed GTK+. This was first used in the 0.99 release of GIMP. GTK was subsequently adopted for maintenance by the GNOME Foundation, which uses it in the GNOME desktop environment.The GTK 2.0.0 release series introduced new features which include improved text rendering using Pango, a new theme engine, improved accessibility using the Accessibility Toolkit, transition to Unicode using UTF-8 strings, and a more flexible API. Starting with version 2.8, GTK 2 depends on the Cairo graphics library for rendering vector graphics.
GTK version 3.0.0 included revised input device handling, support for themes written with CSS-like syntax, and the ability to receive information about other opened GTK applications.
The '+' was dropped returning to simply 'GTK' in February 2019 during a Hackathon.
macOS
With Quartz-Backend GTK is available in macOS.Windows
- After GTK 2.24.10 and 3.6.4 Development of Windows with Installer was closed by Gnome. Installation of MSYS2 on Windows is a good way to use actual GTK.
- GTK 2.24.10 and 3.6.4 is available in Internet, but very buggy and limited against actual versions.
- A Version for Windows 64-bit is prepared by Tom Schoonjans with 2.24.32 and 3.22.30 available.
- Windows 10's Fall Creators Update includes Windows Subsystem for Linux. With Linux distributions like Ubuntu or Debian available from the Windows Store and an X server like Xming or VcXsvr, thousands of programs like GTK 2 or 3 can run with X or terminal support.
OpenVMS
4.x
One of the cardinal novelties implemented during the GTK 4 development cycle has been the delegation of functionality to ancillary objects instead of encoding it into the base classes provided by GTK.- the event handling from signal handlers described by GtkWidget is delegated to event controllers
- the rendering is delegated to GtkSnapshot objects
- the layout mechanism from GtkWidget is delegated to GtkLayoutManager