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.0137 sec