git: Line endings of README.txt
[projects/chimara/chimara.git] / tests / test-multisession.c
1 /* Program for testing multisessionality, i.e. whether two ChimaraGlk widgets
2  can run in the same application. */
3
4 #include <glib.h>
5 #include <gtk/gtk.h>
6 #include <libchimara/chimara-glk.h>
7
8 static void
9 on_started(ChimaraGlk *glk, const gchar *data)
10 {
11     g_printerr("%s started!\n", data);
12 }
13
14 static void
15 on_stopped(ChimaraGlk *glk, const gchar *data)
16 {
17     g_printerr("%s stopped!\n", data);
18 }
19
20 static gboolean
21 on_delete_event(void)
22 {
23         gtk_main_quit();
24         return TRUE;
25 }
26
27 int
28 main(int argc, char **argv)
29 {
30         gdk_threads_init();
31         gtk_init(&argc, &argv);
32
33         GtkWidget *window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
34         gtk_widget_set_size_request(window, 800, 500);
35         g_signal_connect(window, "delete_event", G_CALLBACK(on_delete_event), NULL);
36         
37         GtkWidget *hpaned = gtk_hpaned_new();
38         gtk_paned_set_position(GTK_PANED(hpaned), 400);
39         
40         GtkWidget *frotz = chimara_glk_new();
41         chimara_glk_set_css_from_string(CHIMARA_GLK(frotz),
42             "buffer.normal { font-family: 'Lucida Sans'; font-size: 12; }"
43             "grid.normal { font-family: 'Lucida Console'; font-size: 12; }");
44         g_signal_connect(frotz, "started", G_CALLBACK(on_started), "Frotz");
45         g_signal_connect(frotz, "stopped", G_CALLBACK(on_stopped), "Frotz");
46         
47         GtkWidget *nitfol = chimara_glk_new();
48         chimara_glk_set_css_from_string(CHIMARA_GLK(frotz),
49             "buffer.normal { font-family: 'Bitstream Charter'; font-size: 12; }"
50             "grid.normal { font-family: 'Luxi Mono'; font-size: 12; }");
51         g_signal_connect(nitfol, "started", G_CALLBACK(on_started), "Nitfol");
52         g_signal_connect(nitfol, "stopped", G_CALLBACK(on_stopped), "Nitfol");
53
54         gtk_paned_pack1(GTK_PANED(hpaned), frotz, TRUE, TRUE);
55         gtk_paned_pack2(GTK_PANED(hpaned), nitfol, TRUE, TRUE);
56         gtk_container_add(GTK_CONTAINER(window), hpaned);
57
58         gtk_widget_show_all(window);
59
60         if(!chimara_glk_run(CHIMARA_GLK(frotz), "../interpreters/frotz/.libs/frotz.so", argc, argv, NULL))
61                 return 1;
62         if(!chimara_glk_run(CHIMARA_GLK(nitfol), "../interpreters/nitfol/.libs/nitfol.so", argc, argv, NULL))
63                 return 1;
64         
65     gdk_threads_enter();
66         gtk_main();
67         gdk_threads_leave();
68         
69         chimara_glk_stop(CHIMARA_GLK(frotz));
70         chimara_glk_stop(CHIMARA_GLK(nitfol));
71
72         return 0;
73 }
74         
75