|
|
(1 промежуточная версия не показана) |
Строка 1: |
Строка 1: |
- | <h1>Introduction to GTK+</h1>
| |
| | | |
- | == About this tutorial ==
| |
- |
| |
- | This is an introductory GTK+ programming tutorial. The tutorial is targeted for the C programming language.
| |
- | It has been created and tested on Linux. The GTK+ programming tutorial is suited for novice and intermediate programmers.
| |
- |
| |
- | == GTK+ ==
| |
- |
| |
- | <img src="../images/gtk.png" style="float: left; margin-right:10px">
| |
- |
| |
- | The <b>GTK+</b> is a library for creating graphical user interfaces. The library is created in C programming language. The GTK+ library is also called the GIMP Toolkit. Originally, the library was created while developing the GIMP image manipulation program. Since then, the GTK+ became one of the most popular toolkits under Linux and BSD Unix. Today, most of the GUI software in the open source world is created in Qt or in GTK+.
| |
- | The GTK+ is an object oriented application programming interface. The object oriented system is created with the Glib object system, which is a base for the GTK+ library. The <b>GObject</b> also enables to create language bindings for various other programming languages. Language bindings exist for C++, Python, Perl, Java, C# and other programming languages.
| |
- |
| |
- | The GTK+ itself depends on the following libraries.
| |
- |
| |
- | * Glib
| |
- | * Pango
| |
- | * ATK
| |
- | * GDK
| |
- | * GdkPixbuf
| |
- | * Cairo
| |
- |
| |
- | The <b>Glib</b> is a general purpose utility library. It provides various data types, string utilities, enables error reporting, message logging, working with threads and other useful programming features.
| |
- | The <b>Pango</b> is a library which enables internationalization.
| |
- | The <b>ATK</b> is the accessibility toolkit. This toolkit provides tools which help physically challenged people work with computers. The <b>Cairo</b> is a library for creating 2D vector graphics.
| |
- | It has been included in GTK+ since version 2.8.
| |
- |
| |
- | Gnome and XFce desktop environments have been created using the GTK+ library. SWT and wxWidgets are well known programming frameworks, that use GTK+. Prominent software applications that use GTK+ include Firefox or Inkscape.
| |
- |
| |
- | == Compiling GTK+ applications ==
| |
- |
| |
- | To compile GTK+ applications, we have a handy tool called <b>pkg-config</b>.
| |
- | The pgk-config returns metadata about installed libraries. Simply put, if we want to use a specific library, it will provide us necessary dependent libraries and include files, that we need. The pkg-config program retrieves information about packages from special metadata files.
| |
- |
| |
- | <source lang="cpp">
| |
- | gcc -o simple simple.c `pkg-config --libs --cflags gtk+-2.0`
| |
- |
| |
- | </source>
| |
- |
| |
- | Here we show, how we can compile a simple program. The source code consists of one file, simple.c.
| |
- |
| |
- | <source lang="cpp">
| |
- | $ pkg-config --cflags gtk+-2.0
| |
- | -I/usr/include/gtk-2.0 -I/usr/lib/gtk-2.0/include -I/usr/include/atk-1.0
| |
- | -I/usr/include/cairo -I/usr/include/pango-1.0 -I/usr/include/glib-2.0
| |
- | -I/usr/lib/glib-2.0/include -I/usr/include/freetype2 -I/usr/include/libpng12
| |
- | </source>
| |
- |
| |
- | This list shows all necessary include files for GTK+ programming.
| |
- |
| |
- | <source lang="cpp">
| |
- | $ pkg-config --libs gtk+-2.0
| |
- | -lgtk-x11-2.0 -lgdk-x11-2.0 -latk-1.0 -lgdk_pixbuf-2.0 -lm -lpangocairo-1.0
| |
- | -lfontconfig -lXext -lXrender -lXinerama -lXi -lXrandr
| |
- | -lXcursor -lXfixes -lpango-1.0 -lcairo -lX11 -lgobject-2.0
| |
- | -lgmodule-2.0 -ldl -lglib-2.0
| |
- | </source>
| |
- |
| |
- | And this list shows the necessary libraries.
| |
- |
| |
- | == Sources ==
| |
- |
| |
- | * [http://www.gtk.org gtk.org]
| |
- | * [http://www.gtkforums.com gtkforums.com]
| |
- | * GTK+ / Gnome application development
| |
- |
| |
- | [[Категория:GTK+]]
| |