X-Git-Url: https://git.stderr.nl/gitweb?a=blobdiff_plain;f=libchimara%2Finit.c;fp=libchimara%2Finit.c;h=bfc67dd033bb4d994a9d2fc9cb21c29ea89c228f;hb=030e31fda2fd37c7cd4237bc325c82cac9d31689;hp=0000000000000000000000000000000000000000;hpb=d5610e149e0384a24d00727a5815df12e85de026;p=projects%2Fchimara%2Fchimara.git diff --git a/libchimara/init.c b/libchimara/init.c new file mode 100644 index 0000000..bfc67dd --- /dev/null +++ b/libchimara/init.c @@ -0,0 +1,30 @@ +#include +#include +#include + +static gboolean chimara_initialized = FALSE; + +/* This function is called at every entry point of the library, to set up +threads and gettext. It is NOT called from Glk functions. */ +void +chimara_init(void) +{ + if( G_UNLIKELY(!chimara_initialized) ) + { + /* Setup gettext */ + bindtextdomain(GETTEXT_PACKAGE, LOCALEDIR); + bind_textdomain_codeset(GETTEXT_PACKAGE, "UTF-8"); + + /* Make sure threads have been initialized */ + if(!g_thread_supported()) + g_error(_("In order to use the Chimara library, you must initialize" + " the thread system by calling g_threads_init() and " + "gdk_threads_init() BEFORE the initial call to gtk_init() in " + "your main program.")); + + /* Initialize thread-private data */ + extern GPrivate *glk_data_key; + glk_data_key = g_private_new(NULL); + } +} +