| 1 | /* |
| 2 | First run tutorial.glade through gtk-builder-convert with this command: |
| 3 | gtk-builder-convert tutorial.glade tutorial.xml |
| 4 | |
| 5 | Then save this file as main.c and compile it using this command |
| 6 | (those are backticks, not single quotes): |
| 7 | gcc -Wall -g -o tutorial main.c `pkg-config --cflags --libs gtk+-2.0` -export-dynamic |
| 8 | |
| 9 | Then execute it using: |
| 10 | ./tutorial |
| 11 | */ |
| 12 | |
| 13 | #include <stdio.h> |
| 14 | #include <string.h> |
| 15 | #include <gtk/gtk.h> |
| 16 | |
| 17 | GtkBuilder *builder; |
| 18 | GtkWidget *window, *button1, *entry1; |
| 19 | |
| 20 | |
| 21 | void on_window_destroy (GtkObject *object, gpointer user_data) |
| 22 | { |
| 23 | gtk_main_quit (); |
| 24 | } |
| 25 | |
| 26 | void on_button1_clicked() { |
| 27 | puts("click!"); |
| 28 | puts(gtk_entry_get_text(entry1)); |
| 29 | //gtk_button_set_label(button1, "lol"); |
| 30 | gtk_button_set_label(button1, gtk_entry_get_text(entry1)); |
| 31 | } |
| 32 | |
| 33 | int main (int argc, char *argv[]) |
| 34 | { |
| 35 | gtk_init (&argc, &argv); |
| 36 | |
| 37 | builder = gtk_builder_new (); |
| 38 | gtk_builder_add_from_file (builder, "test.xml", NULL); |
| 39 | window = GTK_WIDGET (gtk_builder_get_object (builder, "window")); |
| 40 | |
| 41 | button1 = GTK_WIDGET (gtk_builder_get_object (builder, "button1")); |
| 42 | entry1 = GTK_WIDGET (gtk_builder_get_object (builder, "entry1")); |
| 43 | |
| 44 | |
| 45 | gtk_builder_connect_signals (builder, NULL); |
| 46 | |
| 47 | g_object_unref (G_OBJECT (builder)); |
| 48 | |
| 49 | gtk_widget_show (window); |
| 50 | gtk_main (); |
| 51 | |
| 52 | return 0; |
| 53 | } |
| 54 | |