docs
[mirrors/Programs.git] / misc / multiplatform-ui / hello.c
1 /* GTK Hello world! by Harvie 2oo9
2 *
3 * Compile this with:
4 * gcc -o hello hello.c $(pkg-config --cflags --libs gtk+-2.0) -export-dynamic
5 * or
6 * gcc -Wall -g -o hello hello.c `pkg-config --cflags --libs gtk+-2.0` -export-dynamic
7 */
8
9 #include <stdio.h>
10 //#include <string.h>
11 #include <gtk/gtk.h>
12
13 GtkBuilder *builder;
14 GtkWidget *window1, *button1, *entry1;
15
16 void on_window1_destroy (GtkObject *object, gpointer user_data)
17 {
18 gtk_main_quit();
19 }
20
21 void on_button1_clicked() {
22 gtk_button_set_label(button1, gtk_entry_get_text(entry1));
23 puts(gtk_entry_get_text(entry1));
24 }
25
26 int main (int argc, char *argv[])
27 {
28 gtk_init(&argc, &argv);
29
30 builder = gtk_builder_new();
31 gtk_builder_add_from_file(builder, "hello.ui", NULL);
32
33 window1 = GTK_WIDGET (gtk_builder_get_object (builder, "window1"));
34 button1 = GTK_WIDGET (gtk_builder_get_object (builder, "button1"));
35 entry1 = GTK_WIDGET (gtk_builder_get_object (builder, "entry1"));
36
37 gtk_builder_connect_signals(builder, NULL);
38
39 g_object_unref(G_OBJECT (builder));
40
41 gtk_widget_show(window1);
42 gtk_main();
43
44 return 0;
45 }
46
This page took 0.392422 seconds and 4 git commands to generate.