Added a test program which runs two ChimaraGlk widgets side by side in the same progr...
authorPhilip Chimento <philip.chimento@gmail.com>
Fri, 11 Sep 2009 22:11:42 +0000 (22:11 +0000)
committerPhilip Chimento <philip.chimento@gmail.com>
Fri, 11 Sep 2009 22:11:42 +0000 (22:11 +0000)
git-svn-id: http://lassie.dyndns-server.com/svn/gargoyle-gtk@119 ddfedd41-794f-dd11-ae45-00112f111e67

tests/Makefile.am
tests/test-multisession.c [new file with mode: 0644]

index 9033f4287e9c8c8d5bb7559025aee7dbe567818f..76654eddb4eb008b0d27a5ef454b8f9941db4e3a 100644 (file)
@@ -3,7 +3,7 @@ AM_CPPFLAGS = -I$(top_srcdir)
 
 dist_data_DATA = chimara.ui chimara.menus
 
 
 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) \
 
 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_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$$"
 
 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 (file)
index 0000000..7f984c8
--- /dev/null
@@ -0,0 +1,70 @@
+/* Program for testing multisessionality, i.e. whether two ChimaraGlk widgets
+ can run in the same application. */
+
+#include <glib.h>
+#include <gtk/gtk.h>
+#include <libchimara/chimara-glk.h>
+
+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