GTK+ (formerly GIMP Toolkit) is a 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. It is, along with Qt, one of the most popular tool-kits for the Wayland and X11 windowing systems.
The GTK+ library contains a set of graphical control elements (widgets), version 3.22.16 contains 186 active and 36 deprecated widgets.[1] GTK+ is an object-oriented widget toolkit written in the C programming language; it uses GObject, that is the GLib object system, for the object orientation. While GTK+ is primarily targeted at windowing systems based upon X11 and Wayland, it works on other platforms, including Microsoft Windows (interfaced with the Windows API), and macOS (interfaced with Quartz). There is also an HTML5 back-end called Broadway[2][3].
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 the majority of its graphical control elements.[4] Since GTK+ version 3.0, all the 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 (>3.90), and why.[5]
GDK acts as a wrapper around the low-level functions provided by the underlying windowing and graphics systems.
GDK is found in the /gdk
directory.
GSK is the rendering and scene graph API for GTK+. GSK lies between the graphical control elements (widgets) and the rendering. GSK was finally merged into GTK+ version 3.90 released March 2017.
GSK is found in the /gsk
directory.
GtkInspector has been introduced with version 3.14.[6][7] GtkInspector can only be invoked after installing the development package libgtk-3-dev/gtk+-devel.
There are several GUI designers for GTK+. The following projects are active as of July 2011:
GtkBuilder allows user interfaces to be designed without writing code. The interface is described in an Extensible Markup Language (XML) file, which is then loaded at runtime and the objects created automatically. The Glade Interface Designer allows creation of the user interface in a WYSIWYG manner. The description of the user interface is independent from the programming language being used.
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.[10]
Gtk# is a set of .NET bindings for the GTK+ GUI toolkit and assorted GNOME libraries. The library facilitates building graphical GNOME applications using Mono or any other compliant CLR. Gtk# is an event-driven system like any other modern windowing library where every widget allows you to associate handler methods, which get called when particular events happen.
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 the user to run the X11 server.[11]
Glade can be used with the Glade# bindings to easily design GUI applications. A GUI designer called Stetic is integrated with the MonoDevelop IDE.
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.
For syntax highlighting there is GtkSourceView, "source code editing widget".
GtkSourceView is maintained separately from GTK+ as a library: gtksourceview. There are plans to rename to gsv.
GtkSpell is a distinct library separate to 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.
GTK+ is mainly developed by The GNOME Project, which also develops the GNOME Development Platform and the GNOME Desktop Environment.[12]
GTK+ development is loosely managed. Discussion chiefly occurs on a number of public mailing lists.[13] GNOME developers and users gather at an annual GUADEC meeting to discuss the current state and the future direction of GNOME.[14] GNOME incorporates standards and programs from freedesktop.org to better interoperate with other desktops.
GTK+ is mainly written in C.[15] A number of language bindings are available.
In former times GTK+ (and GNOME, GLib, etc.) utilized the GNU Build System (called Autotools) as the build automation system of choice.
The Meson build system is being prepared to be used with GTK.[16]
The most common criticism towards GTK+ is a lack of backwards-compatibility in major updates, most notably in the API[17] and theming.[18]
The compatibility breaks between minor releases during the GTK+ 3.x development cycle has been 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 towards stability.[19] 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.
Some notable applications that use or once used GTK+ as a widget toolkit include:
Several desktop environments utilize GTK+ as the widget toolkit.
GTK+ programs can be run on top of X11-based desktop environments or window managers even those not made with GTK+, provided the required libraries are installed; this includes macOS if X11.app is installed. GTK+ can be also run under Microsoft Windows, where it is used by some popular cross-platform applications like Pidgin and GIMP. wxWidgets, a cross-platform GUI tool-kit, uses GTK+ on Linux.[25] Other ports include DirectFB (used by the Debian installer, for example) and ncurses.[26]
The following window managers use GTK+:
Documentation is available here:
The following code presents a graphical GTK+ hello-world program in the C programming language. This program has a window with the title "Hello, world!" and a label with similar text.
// helloworld.c #include <gtk/gtk.h> int main (int argc, char *argv[]) { GtkWidget *window; GtkWidget *label; gtk_init(&argc, &argv); /* Create the main, top level window */ window = gtk_window_new(GTK_WINDOW_TOPLEVEL); /* Give it the title */ gtk_window_set_title(GTK_WINDOW(window), "Hello, world!"); /* Center the window */ gtk_window_set_position(GTK_WINDOW(window), GTK_WIN_POS_CENTER); /* Set the window's default size */ gtk_window_set_default_size(GTK_WINDOW(window), 200, 100); /* ** Map the destroy signal of the window to gtk_main_quit; ** When the window is about to be destroyed, we get a notification and ** stop the main GTK+ loop by returning 0 */ g_signal_connect(window, "destroy", G_CALLBACK(gtk_main_quit), NULL); /* ** Assign the variable "label" to a new GTK label, ** with the text "Hello, world!" */ label = gtk_label_new("Hello, world!"); /* Plot the label onto the main window */ gtk_container_add(GTK_CONTAINER(window), label); /* Make sure that everything, window and label, are visible */ gtk_widget_show_all(window); /* ** Start the main loop, and do nothing (block) until ** the application is closed */ gtk_main(); return 0; }
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
GTK+ was originally designed and used in the GNU Image Manipulation Program (GIMP) as a replacement of the Motif toolkit; at some point Peter Mattis became disenchanted with Motif and began to write his own GUI toolkit called the GIMP toolkit and had successfully replaced Motif by the 0.60 release of GIMP.[27] Finally GTK was re-written to be object-oriented and was renamed GTK+.[28] 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.
With Quartz-Backend[29] GTK+ is available in macOS.[30]
HP stated that their goal was to merge the required OpenVMS changes into the GTK+ Version 1.3 development stream[35], however this never materialised. The latest version of GTK+ for OpenVMS is version 1.2.10.[36]
Release history | |||||||
---|---|---|---|---|---|---|---|
Release series | Initial release | Major enhancements | Latest minor version | ||||
1.0 | 1998-04-14 | First stable version | 1.0.6 | ||||
1.2 | 1999-02-27 | New widgets (GtkFontSelector, GtkPacker, GtkItemFactory, GtkCTree, GtkInvisible, GtkCalendar, GtkLayout, GtkPlug, GtkSocket) | 1.2.10 | ||||
GTK+ 2 | |||||||
2.0 | 2002-03-11 | GObject, overall support for UTF-8 | 2.0.9 | ||||
2.2 | 2002-12-22 | Multihead support | 2.2.4 | ||||
2.4 | 2004-03-16 | New widgets (GtkFileChooser, GtkComboBox, GtkComboBoxEntry, GtkExpander, GtkFontButton, GtkColorButton) | 2.4.14 | ||||
2.6 | 2004-12-16 | New widgets (GtkIconView, GtkAboutDialog, GtkCellView). The last to support Windows 98/ME. |
2.6.10 | ||||
2.8 | 2005-08-13 | Majority of the widgets are rendered by Cairo. | 2.8.20 | ||||
2.10 | 2006-07-03 | New widgets (GtkStatusIcon, GtkAssistant, GtkLinkButton, GtkRecentChooser) and print support (GtkPrintOperation) |
2.10.14 | ||||
2.12 | 2007-09-14 | GtkBuilder | 2.12.12 | ||||
2.14 | 2008-09-04 | JPEG 2000 load support | 2.14.7 | ||||
2.16 | 2009-03-13 | New widget (GtkOrientable), Caps Lock warning in password entry. Improvements on GtkScale, GtkStatusIcon, GtkFileChooser. |
2.16.6 | ||||
2.18 | 2009-09-23 | New widget (GtkInfoBar). Improvement on file chooser, printing. To remove much of the necessary IPC between the X11 application and the X11 server, GDK has been rewritten (mainly by Alexander Larsson) to use "client-side windows", i.e. the GdkWindow, which every widget is required to have, belongs now to the client. |
2.18.9 | ||||
2.20 | 2010-03-23 | New widgets (GtkSpinner, GtkToolPalette, GtkOffscreenWindow). Improvement on file chooser, keyboard handling, GDK. Introspection data is now included in GTK+. |
2.20.1 | ||||
2.22 | 2010-09-23 | GdkPixbuf moved to separate module, most GDK drawing are based on Cairo, many internal data are now private and can be sealed in preparation to GTK+ 3. |
2.22.1 | ||||
2.24 | 2011-01-30 | New widget (GtkComboBoxText), the CUPS print backend can send print jobs as PDF, GtkBuilder has gained support for text tags and menu toolbuttons and many introspection annotation fixes were added. |
2.24.32 (2018-01-08) |
||||
GTK+ 3 | |||||||
3.0 | 2011-02-10 | Development and design of the GTK+ 3 release of the toolkit started in February 2009 during the GTK+ Theming Hackfest held in Dublin.[37] The first draft of the development roadmap was released on 9 April 2009.[38] completed mostly Project Ridley, the attempt to consolidate several libraries that were external to GTK+, including libgnome , libgnomeui , libgnomeprint22 , libgnomeprintui22 , libglade , libgnomecanvas , libegg , libeel , gtkglext , and libsexy .[39] all the rendering is done using Cairo; GDK became more X11 agnostic, XInput2, theme API is based upon CSS (worsening the achievable performance for 60 Hz frame rates) |
3.0.12 | ||||
3.2 | 2011-09-25 | New widgets (GtkLockButton, GtkOverlay), New Font Chooser dialog; new experimental backends (Wayland, HTML5 (called "Broadway")); |
3.2.4 | ||||
3.4 | 2012-03-26 | Menu support in GtkApplication, a new color chooser, added support for touch devices, added support for smooth scrolling, GtkScrolledWindow will do kinetic scrolling with touch devices, OS X support has been improved. This is the first version of GTK+ 3 that works well on Windows. The Wayland backend has been updated to the current Wayland version Spin buttons have received a new look. Accessibility: the treeview accessible support has been rewritten More complete CSS Theming support |
3.4.4 | ||||
3.6 | 2012-09-24 | GtkSearchEntry, GtkMenuButton, GtkLevelBar. Vertical spin buttons. CSS animations, blur shadows. Support for cross-fading and transitions in themes. |
3.6.5 | ||||
3.8 | 2013-05-13 | Wayland 1.0 stable support, support for the broadwayd server, improved theming, better geometry management, touch improvements, support with the window manager for the frame synchronization protocol; GdkFrameClock added[40] |
3.8.9 | ||||
3.10 | 2013-09-23 | New widgets (GtkHeaderBar, GtkPlacesSidebar, GtkStack, GtkStackSwitcher, GtkRevealer, GtkSearchBar, GtkListBox). Support for Wayland 1.2 (maximization, animated cursors, multiple monitors, settings, custom surfaces and frame synchronization) Added: client-side decorations, scaled output support on high-dpi screens, fine-adjustment mode for scrolling. Removed: support for the Motif DND protocol, support for multiple screens per display, gdk_window_get_display, gtk_widget_push_composite_child, Tear-off menu-items, plus a number of GTK+ settings. The modern GTK+ drawing model |
3.10.9 | ||||
3.12 | 2014-03-25 | GTK+ 3.12 introduced client-side decorations,[41] support for Wayland 1.5; new widgets: (GtkPopover, an alternative to menus and dialogs) | 3.12.2 | ||||
3.14 | 2014-09-30 | GtkInspector (a copy of gtkparasite) introduced;[42][43] improved support for gestures/multi-touch merged[44][45] Deprecate: GtkMisc, GtkAlignment, GtkArrow, GdkColor, Style regions, support for .icon files, gdk_window_flush, drawing outside of begin/end paint.[46] Most widgets converted to use gestures internally, Wayland supports GNOME Shell classic modus.[47] |
3.14.15 | ||||
3.16 | 2015-03-22 | GDK supports rendering windows using OpenGL for X11 and Wayland using libepoxy, new widgets (GtkGLArea, GtkStackSidebar, GtkModelButton, GtkPopoverMenu), scrolling overhauled (Scrollbar hidden by default[48]), experimental Mir backend[49] | 3.16.7 | ||||
3.18 | 2015-11-22 | Add CSS node infrastructure, More filechooser design refresh and Better filechooser search, Dropped Windows XP support, Model support for list and flow box, Kinetic touchpad scrolling, Touchpad gestures (Wayland), gtk-builder-tool utility, Output-only windows | 3.18.9 | ||||
3.20 | 2016-03-21 | Further Integration of CSS nodes,[50] move drag and drop down to GDK, New widgets: GtkShortcutsWindow: shows keyboard shortcuts and gestures of an application | 3.20.10 | ||||
3.22 | 2016-09-20 | last 3.x released[51] GTK+ Wayland tablet support is merged;[52] Support for graphics tablets is considered feature complete[53] GTK+ 3.22 shall be as rock-stable (and hence "boring") as GTK+ 2[19][54][55] |
for 3+ years 3.22.29 |
||||
3.23 | 2018-06-23 | Dependency bumps: Require libepoxy 1.4, Require pango 1.41 New font chooser features: Allow setting OpenType font features, Show examples for OpenType font features, Allow selecting OpenType font variations, Support levels of details for selection New Emoji features: Support a completion popup for Emoji, Drop Ctrl-Shift-e shortcut Other new apis: gdk_window_move_to_rect Wayland: Use anonymous shared memory on FreeBSD |
3.23.0 | ||||
GTK+ 4 development series | |||||||
3.90 | 2017-03-24 | merge (GTK+ Scene Graph Kit (GSK))[56] remove any API marked as deprecated: before (2016-09-22) vs. after heavy development, break API&ABI.[54][55] A new Vulkan-renderer augments the old Cairo-renderer[57] |
3.89.1 3.89.2 |
||||
3.92 | 2017-10-18 | As GNOME 3.26 was released already on September, 13th. [58] it is not based on GTK+ 3.92! Please browse the git-history to determine what hindered GTK+ to release early enough for the latest GNOME to be based on it: https://git.gnome.org/browse/gtk+/ GNU autotools was replaced with Meson; |
3.91.0 3.91.1 |
||||
3.94 | 2018-06-26[59] | 3.93: GdkScreen, GdkVisual removed, GdkDeviceManager replaced by GdkSeat, Clipboard handling has been moved from GTK to GDK, GdkEvent has been converted to an opaque GObject, The GL renderer in GSK has been substantially completed, and is now on par with the Vulkan renderer, The use of GdkPixbuf in APIs has been reduced, and the GskTexture object has been moved to GDK as GdkTexture, to take its place, The Wayland backend now implements the KDE server-side decoration protocol, Broadway has been ported to GSK, … GdkWindow has been renamed to GdkSurface new powerful abstraction for drawable content: GdkPaintable There is support for displaying media, with: GtkVideo, GtkMediaFile, GtkMediaStream and GtkMediaControls |
3.93 3.94.0 |
||||
3.96 | 2018 autumn | 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 we are making for GTK+ 4, and why we are making them! Some examples of things that will become possible with GTK+ 4. (https://mclasen.fedorapeople.org/gtk4-devconf2018.pdf) | |||||
4.0 | ??? | remove any API marked as deprecated, i.e. at least everything in the deprecated directory |
The GNOME team releases new versions on a regular basis.[56]
The content is sourced from: https://handwiki.org/wiki/Software:GTK%2B