GTK+

From Wikipedia, the free encyclopedia
  (Redirected from GTK)
Jump to: navigation, search
"GTK" redirects here. For other uses, see GTK (disambiguation).
For technical reasons, "Gtk#" redirects here. For the article on Gtk#, see Gtk Sharp.
GTK+
GTK+ logo.svg
Gtk3-widget-factory-3.14.0.png
gtk3-widget-factory, a program which demonstrates GUI widgets in GTK+ version 3
Original author(s) Spencer Kimball, Peter Mattis, eXperimental Computing Facility (XCF)
Developer(s) The GNOME Project
Initial release April 14, 1998 (1998-04-14)
Stable release 3.14.0 (September 22, 2014; 0 days ago (2014-09-22)[1]) [±]
Preview release 3.11.9 (March 18, 2014; 6 months ago (2014-03-18)[2]) [±]
Development status Active
Written in C[3]
Operating system Unix-like, Mac OS X, Microsoft Windows
Available in Multilingual
Type Widget toolkit
License GNU Lesser General Public License (LGPL) version 2.1
Website www.gtk.org

GTK+ (previously GIMP Toolkit, sometimes incorrectly referred to as the GNOME Toolkit) is a cross-platform[4] widget toolkit for creating graphical user interfaces. It is licensed under the terms of the GNU LGPL, allowing both free and proprietary software to use it. It is one of the most popular toolkits for the Wayland and X11 windowing systems, along with Qt.[5]

Software architecture[edit]

Simplified software architecture of GTK+. Pango, GDK, ATK, GIO, Cairo and GLib.
GDK contains back-ends to X11, Wayland, Broadway (HTTP), Quartz and GDI and relies on Cairo for the rendering. Its new SceneGraph is work-in-progress.

The GTK+ library contains a set of graphical control elements (widgets), version 3.13.3 contains 203 active and 37 deprecated widgets. 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 system based upon X11 and Wayland, it works on other platforms, including Microsoft Windows (interfaced with the Windows API), and Mac OS X (interfaced with Quartz). An HTML5 back-end called Broadway is in development.

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 from 2005 GTK+ uses Cairo to render the majority of its graphical control elements.[6] Since GTK+ version 3, all the rendering is done using Cairo.

GTK+ Scene Graph Kit (GSK)[edit]

  • GTK+ Scene Graph Kit (GSK) is the forthcoming scene graph (canvas) for GTK+ in the process of being written by Emanuelle Bassi.[7]
    • Graphene is a collection of geometry types — points, sizes, rectangles, vectors, quads, quaternions, matrices. It tries to optimize them so that the naive, four floats for vertex/four vertices for matrix implementation is not the only one available. Graphene's API makes it possible to avoid exposing C arrays of floating point values, or opaque memory regions, enabling the manipulation of vectors and matrices in other languages as well.

Having OpenGL (or OpenGL ES) support in GDK facilitates a slightly better control of the graphics pipeline; OpenGL is well suited for compositing textured data but totally unsuited for drawing.[8]

GtkInspector[edit]

GtkInspector will be introduced with version 3.14.[9][10]

Language bindings[edit]

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.[11]

GUI designers[edit]

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[12]
  • Crow Designer, relies on its own GuiXml format and GuiLoader library.[13]
  • Stetic, part of MonoDevelop, oriented towards Gtk#.

GtkBuilder[edit]

The "Gtk.Builder class"[14] offers you the opportunity to design user interfaces without writing a single line of code. This is possible through describing the interface by a XML file and then loading the XML description at runtime and create the objects automatically, which the Builder class does for you. For the purpose of not needing to write the XML manually the Glade Interface Designer lets you create the user interface in a WYSIWYG manner.

This method has several advantages:

  • Less code needs to be written.
  • UI changes can be seen more quickly, so UIs are able to improve.
  • Designers without programming skills can create and edit UIs.
  • The description of the user interface is independent from the programming language being used.

There is still code required for handling interface changes triggered by the user, but Gtk.Builder allows you to focus on implementing that functionality.[15]

Uses[edit]

The GTK+ support for Wayland, co-requisites applications to be adapted to Wayland as well.
Screenshot of GIMP 2.4. GTK+ is responsible for managing the interface components of the program, including the menus, buttons, and input fields.

Applications[edit]

Desktop environments[edit]

Several desktop environments utilize GTK+ as the widget toolkit.

  • Unity, the default desktop environment of Ubuntu.
  • GNOME is based on GTK+, meaning that programs native to GNOME use GTK+
  • Consort, the GNOME 3.4 Fallback Mode - Fork, from SolusOS
  • Cinnamon is a fork of GNOME 3 and uses GTK+ version 3
  • MATE is a fork of GNOME 2 made after the release of GNOME 3 and thus uses GTK+ version 2. Support for GTK+ version 3 is in development.
  • Xfce is currently based on GTK+ version 2 with support for and eventual plans for a migration to GTK+ version 3
  • LXDE (Lightweight X11 Desktop Environment) is based on GTK+ version 2
  • Pantheon uses GTK+ 3 exclusively, it is being developed by elementary OS
  • Sugar is a desktop environment oriented towards children's education, which uses GTK+, especially PyGTK
  • ROX Desktop is a lightweight desktop, with features from the GUI of RISC OS
  • GPE, the GPE Palmtop Environment
  • Access Linux Platform (successor of the Palm OS PDA platform)
  • KDE, though based on Qt, has integration with GTK+-based programs and themes (since version 4.2).

GTK+ programs do not require a desktop environment made with GTK+. If the required libraries are installed, a GTK+ program can run on top of other X11-based desktop environments or window managers; this includes Mac OS X if X11.app is installed. GTK+ can also run under Microsoft Windows, where it is used by some popular cross-platform applications like Pidgin and GIMP. wxWidgets, a cross-platform GUI toolkit, uses GTK+ for GNU/Linux operating systems.[16] Other ports include DirectFB (used by the Debian installer, for example) and ncurses.[17]

Window managers[edit]

The following window managers use GTK+:

Applications[edit]

Some notable applications that use GTK+ as a widget toolkit include:

Examples[edit]

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.

#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;
}

Install the libraries

$ sudo apt-get install libgtk-3-dev

Using pkg-config in a Unix shell, this code can be compiled with the following command (assume above source has file name "helloworld.c"):

$ cc -Wall helloworld.c -o helloworld $(pkg-config --cflags --libs gtk+-3.0)

Invoke the program

$ ./helloworld

History[edit]

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.[19] Finally GTK was re-written to be object-oriented and was renamed GTK+. This was first used in the 0.99 release of GIMP.

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, complete 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 name GTK+ originates from GTK; the plus was added to distinguish an enhanced version.[20] It was originally created for the GNU Image Manipulation Program (GIMP), a free software raster graphics editor, in 1997 by Spencer Kimball and Peter Mattis, members of eXperimental Computing Facility (XCF) at the University of California, Berkeley. It is now maintained by members of the GNOME Foundation.

Releases[edit]

Release series Initial
release date
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 Jpeg2000 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.
GDK has been rewritten to use "client-side windows"
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.24
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.[21] The first draft of the development roadmap was released on 9 April 2009.[22]
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.[23]
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, Add support for touch devices, Add 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
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 menuitems, plus a number of GTK+ settings.
The modern GTK+ drawing model
3.10.7
3.12 2014-03-25 Support for Wayland 1.5; New widgets (Popover) 3.12.0
3.14 TBA GtkInspector introduced;[24][25] improved support for gestures/multi-touch merged[26][27]
Deprecate: GtkMisc, GtkAlignment, GtkArrow, GdkColor, Style regions, Support for .icon files, gdk_window_flush, drawing outside of begin/end paint [28] Most widgets converted to use gestures internally, Wayland supports GNOME Shell classic modus[29]
3.16 TBA
GTK+ 4
4.0 Q2 2014/
Q1 2015
https://wiki.gnome.org/Projects/GTK%2B/Roadmap
Merging the scene graph (canvas) of Clutter into GTK+
GTK+ 4 shall be as rock-stable (and hence "boring") as GTK+ 2[30]

The GNOME team releases new versions on a regular basis.

Future developments[edit]

As of version 3.12 the development of GTK+ is still on-going at a fast pace. Components[which?] are being work on and with the arrival of the new scene graph system (canvas) maybe finally release version 4.0.

Criticisms[edit]

The most common criticism towards GTK+ is a lack of backwards-compatibility in major updates, most notably in the API.[31]

Dirk Hohndel, co-developer of Subsurface and member of Intel's Open-Source Technology Center, criticized the GTK+ developers for being abrasive and ignoring most of the community's requests.[32] 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 LDXE to Qt as a result.[33]

See also[edit]

References[edit]

  1. ^ Matthias Clasen (22 September 2014). "gtk+ 3.14.0". gtk-devel-list mailing list. https://mail.gnome.org/archives/commits-list/2014-September/msg07547.html.
  2. ^ Matthias Clasen (18 March 2014). "gtk+ 3.11.9". Gnome FTP releases mailing list. https://mail.gnome.org/archives/ftp-release-list/2014-March/msg00137.html.
  3. ^ "The GTK+ Open Source Project on Ohloh". Ohloh.net. Retrieved 2014-02-17. 
  4. ^ The GTK+ Team. "GTK+ Features". Retrieved 8 September 2014. 
  5. ^ "Developing X applications". 
  6. ^ "GTK+ to Use Cairo Vector Engine". Retrieved 2009-12-27. 
  7. ^ "The GTK+ Scene Graph Kit". 2014-07-29. 
  8. ^ "Graphene". 2014-05-02. 
  9. ^ "Introducing GtkInspector". 2014-05-15. 
  10. ^ "Another GtkInspector update". 2014-07-11. 
  11. ^ GTK+ Language Bindings
  12. ^ "Gazpacho in Debian". 
  13. ^ "nothing-personal - A development site for Crow Designer, GuiLoader and Rally - Google Project Hosting". Retrieved 2014-02-17. 
  14. ^ "Gtk 3.0 documentation on github". 
  15. ^ "The Python GTK+3 Tutorial". 
  16. ^ "GTK+". WxWidgets Compared To Other Toolkits. 
  17. ^ "GTK+ TTY Port". Slashdot. Retrieved 2010-08-31. 
  18. ^ "We’re switching to Qt.". Gerald Combs. Retrieved 2013-11-02. 
  19. ^ LinuxWorld - Where did Spencer Kimball and Peter Mattis go? at the Wayback Machine (archived April 17, 1999)
  20. ^ "What is the + in GTK+?". 2011. Archived from the original on 2012-03-26. Retrieved 2014-03-18. 
  21. ^ Alberto Ruiz Hackfest announcement
  22. ^ Gtk+ 3 roadmap draft
  23. ^ "Project Ridley". 
  24. ^ Matthias Clasen (2014-05-15). "GtkInspector Author's blog entry". Retrieved 2014-05-17. 
  25. ^ "GtkInspector in GNOME wiki". 2014-05-15. Retrieved 2014-05-17. 
  26. ^ "Merging gestures into 3.14". 2014-05-23. Retrieved 2014-05-23. 
  27. ^ "RFC: gestures". 2014-03-04. Retrieved 2014-05-23. 
  28. ^ "gtk+ 3.13.2". 2014-05-27. 
  29. ^ "gtk+ 3.13.3". 2014-06-24. 
  30. ^ "GUADEC2013: Benjamin Otte on GTK+". GUADEC. 
  31. ^ How Does One Create A Gtk+ Application? « Morten Welinder
  32. ^ Larabel, Michael (2014-01-12). "The Biggest Problem With GTK & What Qt Does Good". Phoronix. Retrieved 2014-09-10. 
  33. ^ Hong Jen Yee (2013-03-26). "PCManFM Qt 0.1.0 released". Retrieved 2014-09-10. 

Bibliography[edit]

External links[edit]