What is GTK+? ¶
GTK+ is a multi-platform toolkit for creating graphical user interfaces. Offering a complete set of widgets, GTK+ is suitable for projects ranging from small one-off projects to complete application suites.
GTK+ is free software and part of the GNU Project. However, the licensing terms for GTK+, the GNU LGPL, allow it to be used by all developers, including those developing proprietary software, without any license fees or royalties.
GTK+ is based on three libraries developed by the GTK+ team:
GLib is the low-level core library that forms the basis of GTK+ and GNOME. It provides data structure handling for C, portability wrappers, and interfaces for such runtime functionality as an event loop, threads, dynamic loading, and an object system.
Pango is a library for layout and rendering of text, with an emphasis on internationalization. It forms the core of text and font handling for GTK+-2.0.
The ATK library provides a set of interfaces for accessibility. By supporting the ATK interfaces, an application or toolkit can be used with such tools as screen readers, magnifiers, and alternative input devices.
GTK+ has been designed from the ground up to support a range of languages, not only C/C++. Using GTK+ from languages such as Perl and Python (especially in combination with the Glade GUI builder) provides an effective method of rapid application development.
GLib is the low-level core library that forms the basis of GTK+ and GNOME. It provides data structure handling for C, portability wrappers, and interfaces for such runtime functionality as an event loop, threads, dynamic loading, and an object system.
Pango is a library for layout and rendering of text, with an emphasis on internationalization. It forms the core of text and font handling for GTK+-2.0.
The ATK library provides a set of interfaces for accessibility. By supporting the ATK interfaces, an application or toolkit can be used with such tools as screen readers, magnifiers, and alternative input devices.
- quoted from http://gtk.org
Hello world program with GTK+ ¶
- ์ฐ์ GTK+ ๋ผ์ด๋ธ๋ฌ๋ฆฌ๊ฐ ํ์ํ๋ค. Hello, World๋ผ๋ ๋ฒํผ์ด ์๊ณ ์ด ๋ฒํผ์ ๋๋ฅด๋ฉด ์ฝ์์ Hello, World๋ฅผ ์ฐ๊ณ ์๋์ฐ๋ฅผ ์ข
๋ฃ์ํค๋ ๊ฐ๋จํ ์์
#include <gtk/gtk.h> static void hello(GtkWidget *widget, gpointer data) { g_print("Hello, World!!\n"); } static gboolean delete_event(GtkWidget *widget, GdkEvent *event, gpointer data) { g_print("delete event occurred\n"); return TRUE; } static void destroy(GtkWidget *widget, gpointer data) { gtk_main_quit(); } int main(int argc, char* argv[]) { GtkWidget *window; GtkWidget *button; gtk_init(&argc, &argv); window = gtk_window_new(GTK_WINDOW_TOPLEVEL); g_signal_connect(G_OBJECT(window), "delete_event", G_CALLBACK(delete_event), NULL); g_signal_connect(G_OBJECT(window), "destroy", G_CALLBACK(destroy), NULL); gtk_container_set_border_width(GTK_CONTAINER(window), 10); button = gtk_button_new_with_label("Hello World"); g_signal_connect(G_OBJECT(button), "clicked", G_CALLBACK(hello), NULL); g_signal_connect_swapped(G_OBJECT(button), "clicked", G_CALLBACK(gtk_widget_destroy), G_OBJECT(window)); gtk_container_add(GTK_CONTAINER(window), button); gtk_widget_show(button); gtk_widget_show(window); gtk_main(); return 0; }
gcc hello.c -o hello `pkg-config --cflags --libs gtk+-2.0`์ค์ค ์ด์ ์๋์ฐ๊ฐ ๋จ๋๊ตฌ๋!!
----
ํ๋ก๊ทธ๋๋ฐ๋ถ๋ฅ