GTK+

GTK+

gtk3-widget-factory, is a collection of examples demonstrating many of the 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.22.15 (May 11, 2017 (2017-05-11)) [±]
Preview release 3.91.0 (May 23, 2017 (2017-05-23)) [±]
Repository git.gnome.org/browse/gtk+
Development status Active
Written in C[1]
Operating system Linux, Unix-like, OS X, Windows
Available in Multilingual
Type Widget toolkit
License LGPL version 2.1
Website www.gtk.org

GTK+ (formerly GIMP Toolkit) is a cross-platform widget toolkit for creating graphical user interface.[2] 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.[3]

Software architecture

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.22.16 contains 186 active and 36 deprecated widgets.[4] 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.

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.[5] Since GTK+ version 3.0, all the rendering is done using Cairo.

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 /gdk directory.

GTK+ Scene Graph Kit (GSK)

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

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.

GUI designers

There are several GUI designers for GTK+. The following projects are active as of July 2011:

GtkBuilder

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.

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

Gtk#

Gtk#
Developer(s) Xamarin
Stable release
2.12.41[11] / September 22, 2016 (2016-09-22)
Preview release
2.99.3[12] / June 6, 2014 (2014-06-06)
Repository git.gnome.org/browse/gtk+
Written in C#, XML, Perl, C
Operating system Windows, OS X, Linux
Type Widget toolkit
License GNU Lesser General Public License
Website mono-project.com/GtkSharp

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

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.

GtkSourceView

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

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.

Development

GTK+ is mainly developed by The GNOME Project, which also develops the GNOME Development Platform and the GNOME Desktop Environment.[14]

GTK+ development is loosely managed. Discussion chiefly occurs on a number of public mailing lists.[15] GNOME developers and users gather at an annual GUADEC meeting to discuss the current state and the future direction of GNOME.[16] GNOME incorporates standards and programs from freedesktop.org to better interoperate with other desktops.

GTK+ is mainly written in C.[17] A number of 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+.[18] GTK+ version 3.22 from autumn 2016 shall be the last 3.x release. After that all resources will flow into the GTK+ 4 development series with the version names 3.90, 3.92, etc. Whether the numerous application that still use GTK+ 2.x, even the Wikipedia has a couple of articles on those, will be ported to 3.22 or not, only the future can show.

Build automation

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

On Saturday 13 August at GUADEC2016 Nirbheek Chauhan held a talk titled "Making your GNOME app compile 2.4x faster". The video is available on YouTube:

Criticisms

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

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

Usage

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

Applications

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

Desktop environments

Several desktop environments utilize GTK+ as the widget toolkit.

Current

Inactive

Miscellaneous

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.[28] Other ports include DirectFB (used by the Debian installer, for example) and ncurses.[29]

Window managers

The following window managers use GTK+:

Example

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.

#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 (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

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.[30] Finally GTK was re-written to be object-oriented and was renamed GTK+.[31] 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.

Releases

The GNOME team releases new versions on a regular basis.

See also

References

  1. "The GTK+ Open Source Project on Ohloh". Ohloh.net. Retrieved 2014-02-17.
  2. The GTK+ Team. "GTK+ Features". Retrieved 8 September 2014.
  3. "Developing X applications".
  4. "GTK+ 3 Reference Manual". Retrieved 2017-07-15.
  5. "GTK+ to Use Cairo Vector Engine". Retrieved 2009-12-27.
  6. "Introducing GtkInspector". 2014-05-15.
  7. "Another GtkInspector update". 2014-07-11.
  8. "Gazpacho in Debian".
  9. "nothing-personal - A development site for Crow Designer, GuiLoader and Rally - Google Project Hosting". Retrieved 2014-02-17.
  10. Team, The GTK+. "GTK+ Language Bindings". www.gtk.org. Retrieved 3 June 2017.
  11. "Release 2.12.41".
  12. "Release 2.99.3".
  13. "Download [Gtk#]". The GTK+ Project.
  14. "GNOME Quick SWOT Analysis". The GNOME Project. Retrieved March 18, 2014.
  15. "GTK+ and GNOME Mailing Lists". The GNOME Project. Retrieved December 4, 2011.
  16. "About". GUADEC. Archived from the original on October 4, 2011. Retrieved December 3, 2011.
  17. "GNOME Languages". Ohloh. Black Duck Software. Retrieved May 22, 2014.
  18. 1 2 "Versioning and long term stability promise in GTK+". GTK development blog. 2016-09-01.
  19. "Adaptation of Meson".
  20. "How Does One Create A Gtk+ Application? – Morten Welinder". blogs.gnome.org. Retrieved 3 June 2017.
  21. A GTK+ update, by mclasen, November 20, 2015, Goings on:
  22. 1 2 "GUADEC2013: Benjamin Otte talks about GTK+". GUADEC.
  23. Larabel, Michael (2014-01-12). "The Biggest Problem With GTK & What Qt Does Good". Phoronix. Retrieved 2014-09-10.
  24. Hong Jen Yee (2013-03-26). "PCManFM Qt 0.1.0 released". Retrieved 2014-09-10.
  25. Web Upd8 (2014-06-23). "Audacious Going Back To GTK2 Starting With Version 3.6". Retrieved 2014-10-21.
  26. Lindgren, John (2014-05-06). "Ugly window decorations and how to fix them (GTK+ 3.12)". Retrieved 2014-10-21.
  27. Gerald Combs (2013-10-15). "We’re switching to Qt.". Retrieved 2015-08-19.
  28. "GTK+". WxWidgets Compared To Other Toolkits.
  29. "GTK+ TTY Port". Slashdot. Retrieved 2010-08-31.
  30. LinuxWorld - Where did Spencer Kimball and Peter Mattis go? at the Wayback Machine (archived April 17, 1999)
  31. "What is the + in GTK+?". 2011. Archived from the original on 2012-03-26. Retrieved 2014-03-18.
  32. "Gtk+ 3.0 Theming API Hackfest". Silicon Island. Retrieved 3 June 2017.
  33. "Gtk+ 3 roadmap draft". Retrieved 3 June 2017.
  34. "Project Ridley".
  35. "GdkFrameClock".
  36. "GTK 3.12 introduced client-side decorations".
  37. Matthias Clasen (2014-05-15). "GtkInspector Author's blog entry". Retrieved 2014-05-17.
  38. "GtkInspector in GNOME wiki". 2014-05-15. Retrieved 2014-05-17.
  39. "Merging gestures into 3.14". 2014-05-23. Retrieved 2014-05-23.
  40. "RFC: gestures". 2014-03-04. Retrieved 2014-05-23.
  41. "gtk+ 3.13.2". 2014-05-27.
  42. "gtk+ 3.13.3". 2014-06-24.
  43. online, heise. "Linux-Desktop: Neues Gnome zeigt Nachrichten oben". heise online. Retrieved 3 June 2017.
  44. "GTK+ 3.16.0 released". mail.gnome.org. Retrieved 3 June 2017.
  45. "GTK+ 3.20 – Style Classes and Element Names". 2015-11-20.
  46. "GTK+ Wayland tablet support merged".
  47. "libinput as of September 2016".
  48. 1 2 "Gtk 4.0 will not be stable until Gtk 4.6". 2016-06-13.
  49. 1 2 "Gtk 5.0 will not be stable until Gtk 5.6". 2016-06-14.
  50. "GNOME Wiki: roadmap for GTK+".

Bibliography

This article is issued from Wikipedia. The text is licensed under Creative Commons - Attribution - Sharealike. Additional terms may apply for the media files.