GTK+

From Infogalactic: the planetary knowledge core
(Redirected from Gtk Sharp)
Jump to: navigation, search

<templatestyles src="Module:Hatnote/styles.css"></templatestyles>

GTK+
GTK+ logo.svg
300px
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; 26 years ago (1998-04-14)
Stable release 3.20.6 (May 23, 2016; 7 years ago (2016-05-23)) [±]
Preview release 3.21.2 (May 26, 2016; 7 years ago (2016-05-26)) [±]
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, sometimes incorrectly termed the GNOME Toolkit) is a cross-platform[2] widget toolkit for creating graphical user interfaces. It is licensed under the terms of the 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.[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.13.3 contains 203 active and 37 deprecated widgets.[citation needed] 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 Mac OS X (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.[4] Since GTK+ version 3.0, all the rendering is done using Cairo.[citation needed]

GTK+ Scene Graph Kit (GSK)

  • GTK+ Scene Graph Kit (GSK) is the forthcoming scene graph (canvas) for GTK+ in the process of being written by Emanuele Bassi.[5]

GTK+ never had a scene graph and it worked without it. Clutter then came with its own scene graph, and developers preferred to use Clutter's scene graph with GTK+, facilitated by a library called clutter-gtk.[6] Clutter can be embedded into every GNOME application by using the clutter-gtk library. The clutter-gtk library provides a GtkClutterEmbed GTK+ widget which can be used to display a ClutterStage.

Some thought went into how to merge Clutter and GTK+ in a better way than the clutter-gtk library.

There was a presentation at the 2014 Developer Experience Hackfest regarding a new scene graph for GTK+ aimed at being merged into GTK+ 3.16.[7] Then GSK was planned to be ready and fully integrated into GTK+ version 3.20, to be released in March 2016. This was postponed to 3.22.[8]

  • 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.[9]

Before the adoption of GSK, application developers could optionally use Clutter. The way widgets were drawn in GTK+, was, that a draw function drew everything. There was no way to know, what has just been drawn. To know where the mouse pointer was currently hovering over, the current position had to be computed.

With GSK, it should be fairly easy to write complex graphical control elements (widgets) and still track easily the whereabout of the mouse pointer. Getting more conformation with CSS should also arrive.

GTK+ input system

The GTK+ input system is basically the X input system. To handle anything more complicated than a simple mouse button press, e.g. a double click or a long button press, the developer is required to track time and add a time out somewhere.

GtkInspector

GtkInspector has been introduced with version 3.14.[10][11] 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:

  • 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

GtkBuilder 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.[14]

Language bindings

<templatestyles src="Module:Hatnote/styles.css"></templatestyles>

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

Gtk#

Gtk#
Gtk Sharp Logo.png
Developer(s) Xamarin
Stable release 2.12.22 / April 5, 2012; 12 years ago (2012-04-05)
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 OS X. 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 Mac OS X no longer requires the user to run the X11 server.[16]

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.

Development

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

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

GTK+ is mainly written in C.[20] A number of language bindings are available.

Criticisms

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

The compatibility breaks between minor releases during the GTK+ 3.x development cycle has been explained by Benjamin Otte to be due to the strong request for innovation. 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]

  • 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 community requests.[23]
  • 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 PCManFM to Qt as a result.[24]
  • The Audacious music player plans to move back to GTK+ version 2 starting with version 3.6, with the long-term goal of migrating to Qt.[25] 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."[26]
  • Wireshark also is transitioning to use Qt for poor GTK+'s cross-platform support.[27]

Uses

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

<templatestyles src="Module:Hatnote/styles.css"></templatestyles>

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

<templatestyles src="Div col/styles.css"/>

Desktop environments

<templatestyles src="Module:Hatnote/styles.css"></templatestyles>

Several desktop environments utilize GTK+ as the widget toolkit.

  • Unity, the default desktop environment of Ubuntu
  • GNOME, based on GTK+, meaning that programs native to GNOME use GTK+
  • Consort, the GNOME 3.4 Fallback Mode – fork from SolusOS
  • Cinnamon, a fork of GNOME 3 and uses GTK+ version 3
  • MATE, a fork of GNOME 2, which has been updated to support GTK+ 3
  • Xfce, currently based on GTK+ 2 with support for and eventual plans for a migration to GTK+ 3
  • LXDE (Lightweight X11 Desktop Environment) is based on GTK+ 2
  • Pantheon uses GTK+ 3 exclusively, being developed by elementary OS
  • Sugar is a desktop environment oriented towards children's education, which uses GTK+, especially PyGTK
  • ROX Desktop, 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 can 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 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.[28] Other ports include DirectFB (used by the Debian installer, for example) and ncurses.[29]

Window managers

The following window managers use GTK+:

<templatestyles src="Div col/styles.css"/>

Example

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

Release series Initial release Major enhancements Latest minor version
Old version, no longer supported: 1.0 1998-04-14 First stable version 1.0.6
Old version, no longer supported: 1.2 1999-02-27 New widgets (GtkFontSelector, GtkPacker, GtkItemFactory, GtkCTree, GtkInvisible, GtkCalendar, GtkLayout, GtkPlug, GtkSocket) 1.2.10
GTK+ 2
Old version, no longer supported: 2.0 2002-03-11 GObject, overall support for UTF-8 2.0.9
Old version, no longer supported: 2.2 2002-12-22 Multihead support 2.2.4
Old version, no longer supported: 2.4 2004-03-16 New widgets (GtkFileChooser, GtkComboBox, GtkComboBoxEntry, GtkExpander, GtkFontButton, GtkColorButton) 2.4.14
Old version, no longer supported: 2.6 2004-12-16 New widgets (GtkIconView, GtkAboutDialog, GtkCellView).
The last to support Windows 98/ME.
2.6.10
Old version, no longer supported: 2.8 2005-08-13 Majority of the widgets are rendered by Cairo. 2.8.20
Old version, no longer supported: 2.10 2006-07-03 New widgets (GtkStatusIcon, GtkAssistant, GtkLinkButton,
GtkRecentChooser) and print support (GtkPrintOperation)
2.10.14
Old version, no longer supported: 2.12 2007-09-14 GtkBuilder 2.12.12
Old version, no longer supported: 2.14 2008-09-04 Jpeg2000 load support 2.14.7
Old version, no longer supported: 2.16 2009-03-13 New widget (GtkOrientable), Caps Lock warning in password entry.
Improvements on GtkScale, GtkStatusIcon, GtkFileChooser.
2.16.6
Old version, no longer supported: 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
Old version, no longer supported: 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
Old version, no longer supported: 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
Older version, yet still supported: 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.29
GTK+ 3
Old version, no longer supported: 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.[32] The first draft of the development roadmap was released on 9 April 2009.[33]
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.[34]
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
Old version, no longer supported: 3.2 2011-09-25 New widgets (GtkLockButton, GtkOverlay), New Font Chooser dialog;
new experimental backends (Wayland, HTML5 (called "Broadway"));
3.2.4
Old version, no longer supported: 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
Old version, no longer supported: 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
Old version, no longer supported: 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
Old version, no longer supported: 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
Old version, no longer supported: 3.12 2014-03-25 GTK 3.12 introduced client-side decorations,[35] support for Wayland 1.5; new widgets: (GtkPopover, an alternative to menus and dialogs) 3.12.2
Old version, no longer supported: 3.14 2014-09-30 GtkInspector introduced;[36][37] improved support for gestures/multi-touch merged[38][39]
Deprecate: GtkMisc, GtkAlignment, GtkArrow, GdkColor, Style regions, support for .icon files, gdk_window_flush, drawing outside of begin/end paint.[40] Most widgets converted to use gestures internally, Wayland supports GNOME Shell classic modus.[41]
3.14.13
Old version, no longer supported: 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[42]), experimental Mir backend[43] 3.16.7
Old version, no longer supported: 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.5
Current stable version: 3.20 2016-03-21 Further Integration of CSS nodes,[44] move DND down to GDK, New widgets: GtkShortcutsWindow: shows keyboard shortcuts and gestures of an application 3.20.3
Future release: 3.22 2016-09-20 GTK+ Wayland tablet support is merged,[45] finally merge GSK (GTK+ Scene Graph Kit)[8]
GTK+ 4
Future release: 4.0 GTK+ 4 shall be as rock-stable (and hence "boring") as GTK+ 2[22]
Legend:
Old version
Older version, still supported
Latest version
Latest preview version
Future release

The GNOME team releases new versions on a regular basis.

Future developments

As of version 3.14.1 the development of GTK+ is still ongoing at a fast pace. Components[which?] are being worked on and with the arrival of the new scene graph system (canvas) may be finally released with version 4.0.

See also

References

  1. Lua error in package.lua at line 80: module 'strict' not found.
  2. Lua error in package.lua at line 80: module 'strict' not found.
  3. Lua error in package.lua at line 80: module 'strict' not found.
  4. Lua error in package.lua at line 80: module 'strict' not found.
  5. Lua error in package.lua at line 80: module 'strict' not found.
  6. Lua error in package.lua at line 80: module 'strict' not found.
  7. Lua error in package.lua at line 80: module 'strict' not found.
  8. 8.0 8.1 Lua error in package.lua at line 80: module 'strict' not found.
  9. Lua error in package.lua at line 80: module 'strict' not found.
  10. Lua error in package.lua at line 80: module 'strict' not found.
  11. Lua error in package.lua at line 80: module 'strict' not found.
  12. Lua error in package.lua at line 80: module 'strict' not found.
  13. Lua error in package.lua at line 80: module 'strict' not found.
  14. Lua error in package.lua at line 80: module 'strict' not found.
  15. GTK+ Language Bindings
  16. Lua error in package.lua at line 80: module 'strict' not found.
  17. Lua error in package.lua at line 80: module 'strict' not found.
  18. Lua error in package.lua at line 80: module 'strict' not found.
  19. Lua error in package.lua at line 80: module 'strict' not found.
  20. Lua error in package.lua at line 80: module 'strict' not found.
  21. How Does One Create A Gtk+ Application? « Morten Welinder
  22. 22.0 22.1 Lua error in package.lua at line 80: module 'strict' not found.
  23. Lua error in package.lua at line 80: module 'strict' not found.
  24. Lua error in package.lua at line 80: module 'strict' not found.
  25. Lua error in package.lua at line 80: module 'strict' not found.
  26. Lua error in package.lua at line 80: module 'strict' not found.
  27. Lua error in package.lua at line 80: module 'strict' not found.
  28. Lua error in package.lua at line 80: module 'strict' not found.
  29. Lua error in package.lua at line 80: module 'strict' not found.
  30. LinuxWorld - Where did Spencer Kimball and Peter Mattis go? at the Wayback Machine (archived April 17, 1999)
  31. Lua error in package.lua at line 80: module 'strict' not found.
  32. Alberto Ruiz Hackfest announcement
  33. Gtk+ 3 roadmap draft
  34. Lua error in package.lua at line 80: module 'strict' not found.
  35. Lua error in package.lua at line 80: module 'strict' not found.
  36. Lua error in package.lua at line 80: module 'strict' not found.
  37. Lua error in package.lua at line 80: module 'strict' not found.
  38. Lua error in package.lua at line 80: module 'strict' not found.
  39. Lua error in package.lua at line 80: module 'strict' not found.
  40. Lua error in package.lua at line 80: module 'strict' not found.
  41. Lua error in package.lua at line 80: module 'strict' not found.
  42. Linux-Desktop: Neues Gnome zeigt Nachrichten oben
  43. GTK+ 3.16.0 released
  44. Lua error in package.lua at line 80: module 'strict' not found.
  45. Lua error in package.lua at line 80: module 'strict' not found.

Bibliography

  • Lua error in package.lua at line 80: module 'strict' not found.
  • Lua error in package.lua at line 80: module 'strict' not found.
  • Lua error in package.lua at line 80: module 'strict' not found.

External links