E D R , A S I H C RSS

GTK+

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.
- 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 ๋ช…๋ นํ–‰์— ๋ช‡๊ฐ€์ง€ ํŒŒ๋ผ๋ฉ”ํ„ฐ๋ฅผ ๋” ์ฃผ์–ด์•ผ ํ•œ๋‹ค. ์•„๋ž˜๋Š” ํ•œ ์˜ˆ.
gcc hello.c -o hello `pkg-config --cflags --libs gtk+-2.0`
์˜ค์˜ค ์ด์ œ ์œˆ๋„์šฐ๊ฐ€ ๋œจ๋Š”๊ตฌ๋‚˜!!
----
ํ”„๋กœ๊ทธ๋ž˜๋ฐ๋ถ„๋ฅ˜
Valid XHTML 1.0! Valid CSS! powered by MoniWiki
last modified 2021-02-07 05:23:18
Processing time 0.0042 sec