From a1e50b775982c1eed6f44aa5f027e4b4bddfb8b7 Mon Sep 17 00:00:00 2001 From: fliep Date: Fri, 11 Sep 2009 22:11:42 +0000 Subject: [PATCH] Added a test program which runs two ChimaraGlk widgets side by side in the same program. It doesn't work, but it should, so I will add a ticket. --- tests/Makefile.am | 6 +++- tests/test-multisession.c | 70 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 75 insertions(+), 1 deletion(-) create mode 100644 tests/test-multisession.c diff --git a/tests/Makefile.am b/tests/Makefile.am index 9033f42..76654ed 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -3,7 +3,7 @@ AM_CPPFLAGS = -I$(top_srcdir) dist_data_DATA = chimara.ui chimara.menus -noinst_PROGRAMS = test-chimara +noinst_PROGRAMS = test-chimara test-multisession test_chimara_SOURCES = main.c callbacks.c callbacks.h error.c error.h test_chimara_CPPFLAGS = $(AM_CPPFLAGS) \ @@ -13,6 +13,10 @@ test_chimara_CPPFLAGS = $(AM_CPPFLAGS) \ test_chimara_CFLAGS = @TEST_CFLAGS@ $(AM_CFLAGS) test_chimara_LDADD = @TEST_LIBS@ $(top_builddir)/libchimara/libchimara.la +test_multisession_SOURCES = test-multisession.c +test_multisession_CFLAGS = @TEST_CFLAGS@ $(AM_CFLAGS) +test_multisession_LDADD = @TEST_LIBS@ $(top_builddir)/libchimara/libchimara.la + pkglib_LTLIBRARIES = first.la model.la gridtest.la splittest.la multiwin.la PLUGIN_LIBTOOL_FLAGS=-module -avoid-version -export-symbols-regex "^glk_main$$" diff --git a/tests/test-multisession.c b/tests/test-multisession.c new file mode 100644 index 0000000..7f984c8 --- /dev/null +++ b/tests/test-multisession.c @@ -0,0 +1,70 @@ +/* Program for testing multisessionality, i.e. whether two ChimaraGlk widgets + can run in the same application. */ + +#include +#include +#include + +static void +on_started(ChimaraGlk *glk, const gchar *data) +{ + g_printerr("%s started!\n", data); +} + +static void +on_stopped(ChimaraGlk *glk, const gchar *data) +{ + g_printerr("%s stopped!\n", data); +} + +int +main(int argc, char **argv) +{ + if( !g_thread_supported() ) + g_thread_init(NULL); + + gdk_threads_init(); + + gtk_set_locale(); + gtk_init(&argc, &argv); + + GtkWidget *window = gtk_window_new(GTK_WINDOW_TOPLEVEL); + gtk_widget_set_size_request(window, 800, 500); + + GtkWidget *hpaned = gtk_hpaned_new(); + gtk_paned_set_position(GTK_PANED(hpaned), 400); + + GtkWidget *frotz = chimara_glk_new(); + chimara_glk_set_default_font_string(CHIMARA_GLK(frotz), "Lucida Sans Unicode 12"); + chimara_glk_set_monospace_font_string(CHIMARA_GLK(frotz), "Lucida Console 12"); + g_signal_connect(frotz, "started", G_CALLBACK(on_started), "Frotz"); + g_signal_connect(frotz, "stopped", G_CALLBACK(on_stopped), "Frotz"); + + GtkWidget *nitfol = chimara_glk_new(); + chimara_glk_set_default_font_string(CHIMARA_GLK(nitfol), "Bitstream Charter 12"); + chimara_glk_set_monospace_font_string(CHIMARA_GLK(nitfol), "Luxi Mono 12"); + g_signal_connect(nitfol, "started", G_CALLBACK(on_started), "Nitfol"); + g_signal_connect(nitfol, "stopped", G_CALLBACK(on_stopped), "Nitfol"); + + gtk_paned_pack1(GTK_PANED(hpaned), frotz, TRUE, TRUE); + gtk_paned_pack2(GTK_PANED(hpaned), nitfol, TRUE, TRUE); + gtk_container_add(GTK_CONTAINER(window), hpaned); + + gtk_widget_show_all(window); + + if(!chimara_glk_run(CHIMARA_GLK(frotz), "../interpreters/frotz/.libs/frotz.so", argc, argv, NULL)) + return 1; + if(!chimara_glk_run(CHIMARA_GLK(nitfol), "../interpreters/nitfol/.libs/nitfol.so", argc, argv, NULL)) + return 1; + + gdk_threads_enter(); + gtk_main(); + gdk_threads_leave(); + + chimara_glk_stop(CHIMARA_GLK(frotz)); + chimara_glk_stop(CHIMARA_GLK(nitfol)); + + return 0; +} + + \ No newline at end of file -- 2.30.2