Informatika Komputer    
   
Daftar Isi
(Sebelumnya) Gtk SharpGtk2-Perl (Berikutnya)

GTK+

New Gtk+.svg
GTK+ Logo
Original author(s)Spencer Kimball, Peter Mattis, eXperimental Computing Facility (XCF)
Developer(s)GNOME Foundation
Initial release14 April 1998 (1998-04-14)
Stable release

3.8.0 (March 25, 2013; 3 days ago (2013-03-25)) [±]

[±]
Preview release

3.7.14 (March 19, 2013; 9 days ago (2013-03-19)) [±]

[±]
Development statusActive
Written inC
Operating systemCross-platform
PlatformCross-platform
Available inMultilingual
TypeWidget toolkit
LicenseGNU LGPL version 2.1
Websitewww.gtk.org

GTK+ (GIMP Toolkit) is a cross-platform 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 X Window System, along with Qt.[1]

The name GTK+ originates from GTK; the plus was added to distinguish an enhanced version.[2] 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.

Contents

Design

GTK+ is an object-oriented widget toolkit written in the C programming language; it uses the GLib object system for the object orientation. On the X11 display server, GTK+ uses Xlib to draw widgets. Using Xlib provides flexibility and allows GTK+ to be used on platforms where the X Window System is unavailable. While GTK+ is primarily targeted at the X Window System, it works on other platforms, including Microsoft Windows (interfaced with the Windows API), and Mac OS X (interfaced with Quartz). HTML5 and Wayland backends are 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.

Programming language bindings

A library written in one programming language may be used in another language if bindings are written; GTK+ has bindings in many languages.[3]

See the table below:

LanguageNameSupported?
AdaGtkAdaPartially supported up to 2.24[4]
CGTK+Native (no binding needed)
C++gtkmmYes
DGtkDSupported since 2.12
ErlanggtkNodePartially supported up to 2.16
Fortrangtk-fortranSupported since 2.12 until 2.18. Partially supported since 2.24
Free Pascal(header) integrated into the core distributionSupported up to 2.24
FreeBASICGladeToBacSupported up to 2.8 and since 2.22
Gambasgambas3-gb-gtkYes
Genielanguage written for GObject systemYes
GObject (GOB)written as a central component of GTK+Yes
Gogo-gtkPartially supported on 2.24
Guile Supported up to 2.12, partially supported on 2.14
Haskellgtk2hsSupported up to 2.24
JJ namespaceYes
Javajava-gnomeYes (unavailable on Windows)
JavaScriptseed/GJSYes
LualgobPartial; all versions from 2.16
LuaLuaGtkSupported up to 2.16, and since 3.0
.NET languages (C#, others)Gtk#Supported up to 2.12
OCamlLablGTKSupported up to 2.16
ooRexxRexxGTKv2.0 or later
PerlGtk2-PerlYes
PHPPHP-GTKSupported up to 2.16
PythonPyGTK (native as of GTK3)Yes
RRGtk2Yes
Rubyruby-gtk2Supported up to 2.12, partially supported on 2.14
SmalltalkSmalltalk GTKGNU Smalltalk, Smalltalk YX, Squeak
TclGnoclYes
Valalanguage written for GObject systemYes
WraplWraplGTKNo, almost full up to 2.22
manywxWidgets2.24, 3 in development

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 towards Gtk#.

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.[5] 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 in GTK+ 2.

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.

Release seriesInitial release dateMajor enhancementsLatest minor version
1.014 April 1998First stable version1.0.6
1.227 February 1999New widgets (GtkFontSelector, GtkPacker, GtkItemFactory, GtkCTree,
GtkInvisible, GtkCalendar, GtkLayout, GtkPlug, GtkSocket)
1.2.10
2.011 March 2002GObject, Universal Unicode UTF-82.0.9
2.222 December 2002Multihead support2.2.4
2.416 March 2004New widgets (GtkFileChooser, GtkComboBox, GtkComboBoxEntry,
GtkExpander, GtkFontButton, GtkColorButton)
2.4.14
2.616 December 2004New widgets (GtkIconView, GtkAboutDialog, GtkCellView).
The last to support Windows 98/ME.
2.6.10
2.813 August 2005Cairo integration2.8.20
2.103 July 2006New widgets (GtkStatusIcon, GtkAssistant, GtkLinkButton,
GtkRecentChooser) and print support (GtkPrintOperation)
2.10.14
2.1214 September 2007GtkBuilder2.12.12
2.144 September 2008Jpeg2000 load support2.14.7
2.1613 March 2009New GtkOrientable, Caps Lock warning in password Entry.
Improvement on GtkScale, GtkStatusIcon, GtkFileChooser.
2.16.6
2.1823 September 2009New GtkInfoBar. Improvement on file chooser, printing.
GDK has been rewritten to use 'client-side windows'
2.18.9
2.2023 March 2010New GtkSpinner and GtkToolPalette, GtkOffscreenWindow. Improvement on file chooser,
keyboard handling, GDK.Introspection data is now included in GTK+
2.20.1
2.2223 September 2010gdk-pixbuf 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.2430 January 2011New simple combo box widget (GtkComboBoxText) added, 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.17
3.010 February 2011Cairo, more X11 agnostic, XInput2, CSS-based theme API3.0.12
3.225 September 2011New experimental Wayland and HTML5 backends, New Font Chooser dialog, New widgets: GtkLockButton and GtkOverlay3.2.4
3.426 March 2012Menu 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 API, and the backend is much more complete now, Spin buttons have received a new look, Accessibility: the treeview accessible support has been rewritten and works much better now, More complete CSS Theming support.3.4.4
3.624 September 2012GtkSearchEntry, GtkMenuButton, GtkLevelBar. Vertical spin buttons. CSS animations, blur shadows. Support for cross-fading and transitions in themes.3.6.3
3.825 March 2013Wayland 1.0 stable support, support for the broadwayd server, improved themeing, better geometry management, touch improvements, support with the window manager for the frame synchronization protocol3.8.0

Future developments

Project Ridley is an attempt to consolidate several libraries that are currently external to GTK+, including libgnome, libgnomeui, libgnomeprint22, libgnomeprintui22, libglade, libgnomecanvas, libegg, libeel, gtkglext, and libsexy.[6]

Developers are also considering new directions for the library, including removing deprecated API components and adding an integrated scene graph system, similar to the Clutter graphics library, effectively integrating GTK+ with OpenGL.[7][8]

Development and design of the GTK+ 3 release of the toolkit started in February 2009 during the GTK+ Theming Hackfest held in Dublin.[9] The first draft of the development roadmap was released on 9 April 2009.[10]

GTK+ hello world

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!"); /* ** 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;}

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

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

Example using Vala instead of C

The following is a "Hello World" program in Vala:

using Gtk; int main (string[] args) { Gtk.init (ref args); /* Create the main, top level window */ var window = new Window(); /* Give it the title, border, position, and size */ window.title = "Hello, World!"; window.border_width = 10; window.window_position = WindowPosition.CENTER; window.set_default_size(350, 70); /* ** 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 */ window.destroy.connect(Gtk.main_quit); /* ** Assign the variable "label" to a new GTK label, ** with the text "Hello, world!" */ var label = new Label("Hello, World!"); /* Add the label onto the main window */ window.add(label); /* Make sure that everything, window and label, are visible */ window.show_all(); /* ** Start the main loop, and do nothing (block) until ** the application is closed */ Gtk.main(); return 0;}

which would be compiled with:

$ valac --pkg gtk+-3.0 HelloWorldGtk.vala

Uses

Screenshot of GIMP 2.4. GTK+ is responsible for managing the interface components of the program, including the menus, buttons, and input fields.
Environments that use GTK+
  • GNOME is based on GTK+, meaning that programs native to GNOME use GTK+
  • Consort, the GNOME 3.4 Fallback Mode - Fork, from SolusOS
  • MATE (desktop environment), a fork of GNOME 2 Desktop Environment
  • Xfce is based on GTK+
  • LXDE (Lightweight X11 Desktop Environment) is based on GTK+
  • ROX Desktop is a lightweight desktop, with features from the GUI of RISC OS
  • GPE Palmtop Environment
  • Access Linux Platform (successor of the Palm OS PDA platform)
  • Sugar is a desktop environment oriented towards children's education, which uses GTK+ and PyGTK
  • 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 (which is the default since the Leopard release). 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 Linux operating systems.[11] Other ports include DirectFB (used by the Debian installer, for example) and ncurses.[12]

Window managers

The following window managers use GTK+

Applications

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

See also

References

Bibliography

External links

(Sebelumnya) Gtk SharpGtk2-Perl (Berikutnya)