Ticket #1212: test.c

File test.c, 0.7 kB (added by guest, 3 years ago)

Equivalent C Version

Line 
1#include <gtk/gtk.h>
2
3static gboolean quit(GtkWidget *widget, GdkEvent *event, gpointer data)
4{
5        gtk_main_quit();
6        return FALSE;
7}
8
9static void test(GtkWidget *widget, gpointer data)
10{ printf("%s\n", (gchar *) data); }
11
12int main(int argc, char *argv[])
13{
14        GtkWidget *window, *button;
15
16        gtk_init(&argc, &argv);
17        window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
18        g_signal_connect(window, "delete-event", G_CALLBACK(quit), NULL);
19        button = gtk_button_new_with_label("Test");
20        g_signal_connect(button, "clicked", G_CALLBACK(test),
21                         (gpointer) "data");
22        gtk_container_add(GTK_CONTAINER (window), button);
23        gtk_widget_show(button);
24        gtk_widget_show(window);
25
26        gtk_main();
27        return 0;
28}