Προγραμματισμός με GTK

  • View
    73

  • Download
    1

Embed Size (px)

DESCRIPTION

Προγραμματισμός με GTK. ΠΑΡΟΥΣΙΑΣΗ ΣΤΑ ΠΛΑΙΣΙΑ ΤΟΥ ΜΑΘΗΜΑΤΟΣ «ΕΠΙΚΟΙΝΩΝΙΑ ΑΝΘΡΩΠΟΥ-ΜΗΧΑΝΗΣ» ΑΛΕΞΑΝΔΡΟΣ Κ. ΓΙΔΑΡΑΚΟΣ kanenas2005@yahoo.gr parsifal@cs.uoi.gr. Δημιουργία GUI με υψηλού επιπέδου Widget Toolkits. Μερικές γενικές αρχές - PowerPoint PPT Presentation

Text of Προγραμματισμός με GTK

  • GTK

    -

    . kanenas2005@yahoo.grparsifal@cs.uoi.gr

  • GUI Widget Toolkits

    1. (Widgets), ,

    2. Widgets (, , check boxes)

    3. (containers) Widgets (, panels)

    4. Widgets

    5. (user events)

    6. event (back-end)

  • ;

    / , Native APIs GUI. Toolkits, , :

    1.

    2. R.A.D.

    3. , Native APIs

    4. ,

    5.

  • ; Toolkits, (GNOME) ...;

  • GTK (1)#include

    static gint delete_event_cb(GtkWidget* w, GdkEventAny* e, gpointer data);static void button_click_cb(GtkWidget* w, gpointer data);

    int main(int argc, char* argv[]) {GtkWidget* window;GtkWidget* button;GtkWidget* label;

    gtk_init(&argc, &argv);

    window = gtk_window_new(GTK_WINDOW_TOPLEVEL);button = gtk_button_new();label = gtk_label_new("Hello, World!");gtk_container_add(GTK_CONTAINER(button), label);gtk_container_add(GTK_CONTAINER(window), button);gtk_window_set_title(GTK_WINDOW(window), "Hello");gtk_container_set_border_width(GTK_CONTAINER(button), 10);gtk_signal_connect(GTK_OBJECT(window), "delete_event", GTK_SIGNAL_FUNC(delete_event_cb), NULL);gtk_signal_connect(GTK_OBJECT(button), "clicked", GTK_SIGNAL_FUNC(button_click_cb), label);gtk_widget_show_all(window);

    gtk_main();

    return 0;}

    static gint delete_event_cb(GtkWidget* window, GdkEventAny* e, gpointer data) {gtk_main_quit();return FALSE;}

    static void button_click_cb(GtkWidget* w, gpointer data) {GtkWidget* label;gchar* text;gchar* tmp;

    label = GTK_WIDGET(data);gtk_label_get(GTK_LABEL(label), &text);tmp = g_strdup(text);g_strreverse(tmp);gtk_label_set_text(GTK_LABEL(label), tmp);g_free(tmp);}

    * HelloWorld :p* , , ,, , ...! :)

  • GTK (2) , !

    1. C ( bindings )

    2. C GTK,

    3. GTK

    4. .

  • GTK (3) -

    1.#include , GTK

    2.gtk_init(&argc, &argv); , (signal handlers). GTK-specific

    3.window = gtk_window_new(GTK_WINDOW_TOPLEVEL);button = gtk_button_new();label = gtk_label_new("Hello, World!");

    ( :GtkWidget* window;GtkWidget* button;GtkWidget* label;)

  • C;;;1. custom (- )

    2. bindings GTK managed (interpreted)

    3. widgets: GtkWidget

    4. widgets GtkWidget*/gtk__new() GtkWidget*

    5. .

    6..:gtk_container_add(GTK_CONTAINER(button), label); GtkContainer* GTK_CONTAINER() casting GtkWidget*, C .

  • HelloWorld revisited... ' , HelloWorld:

    window = gtk_window_new(GTK_WINDOW_TOPLEVEL);button = gtk_button_new();label = gtk_label_new("Hello, World!");gtk_container_add(GTK_CONTAINER(button), label);gtk_container_add(GTK_CONTAINER(window), button);gtk_window_set_title(GTK_WINDOW(window), "Hello");gtk_container_set_border_width(GTK_CONTAINER(button), 10);

    , ( ). . , :

  • Signals1. widget .

    2. signals widget ( instance GtkObject)

    3. callback

    4. gtk_signal_connect:gtk_signal_connect(GTK_OBJECT(window), "delete_event", GTK_SIGNAL_FUNC(delete_event_cb), NULL);gtk_signal_connect(GTK_OBJECT(button), "clicked", GTK_SIGNAL_FUNC(button_click_cb), label);

    5.: , callback user_data .

    6.gtk_widget_show_all(window); ( gtk_widget_show window )gtk_main(); .

  • interface1. GTK layouts: free-form

    2. containers widgets

    3.Abstract GtkContainer

    4. :

    GtkVBox( )GtkTable( )

  • 1.GTK+ Official Website:http://www.gtk.org

    2.GTK+ 2.0 Official Tutorial:http://www.gtk.org/tutorial/

    3.Widget toolkits - Wikipedia:http://en.wikipedia.org/wiki/Widget_toolkit

    4.GTK+ - Wikipedia:http://en.wikipedia.org/wiki/GTK+(GTK logo)

    5.GTK+ / Gnome Application Development:http://developer.gnome.org/doc/GGAD/