Fixed memory management in styles
[projects/chimara/chimara.git] / tests / test-close.c
1 #include <gtk/gtk.h>
2 #include <libchimara/chimara-if.h>
3
4 int
5 main(int argc, char *argv[])
6 {
7     GtkWidget *window, *glk;
8
9     /* Initialize threads and GTK */
10     if(!g_thread_supported())
11         g_thread_init(NULL);
12     gdk_threads_init();
13     gtk_init(&argc, &argv);
14     
15     /* Construct the window and its contents. We quit the GTK main loop
16      * when the window's close button is clicked. */
17     window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
18     g_signal_connect(window, "delete-event", G_CALLBACK(gtk_main_quit), NULL);
19     glk = chimara_glk_new();
20     gtk_container_add(GTK_CONTAINER(window), glk);
21     gtk_widget_show_all(window);
22     
23     /* Add a reference to the ChimaraGlk widget, because we want to keep it
24     around after gtk_main() exits */
25     g_object_ref(glk);
26     
27     /* Start the GTK main loop */
28     gdk_threads_enter();
29     gtk_main();
30     gdk_threads_leave();
31
32     /* After the GTK main loop exits, signal the Glk program to shut down if
33      * it is still running, and wait for it to exit. */
34     chimara_glk_stop(CHIMARA_GLK(glk));
35     chimara_glk_wait(CHIMARA_GLK(glk));
36     g_object_unref(glk);
37
38     return 0;
39 }