Change implemented Glk spec to 0.7.3.
[projects/chimara/chimara.git] / libchimara / init.c
1 #include <config.h>
2 #include <glib.h>
3 #include <glib/gi18n-lib.h>
4 #ifdef GSTREAMER_SOUND
5 #include <gst/gst.h>
6 #endif
7
8 static gboolean chimara_initialized = FALSE;
9
10 /* This function is called at every entry point of the library, to set up
11 threads and gettext. It is NOT called from Glk functions. */
12 void
13 chimara_init(void)
14 {
15         if( G_UNLIKELY(!chimara_initialized) )
16         {
17                 /* Setup gettext */
18                 bindtextdomain(GETTEXT_PACKAGE, LOCALEDIR);
19                 bind_textdomain_codeset(GETTEXT_PACKAGE, "UTF-8");
20                 
21                 /* Make sure threads have been initialized */
22                 if(!g_thread_supported())
23                         g_error(_("In order to use the Chimara library, you must initialize"
24                                 " the thread system by calling g_threads_init() and "
25                                 "gdk_threads_init() BEFORE the initial call to gtk_init() in "
26                                 "your main program."));
27
28 #ifdef GSTREAMER_SOUND
29                 /* Make sure GStreamer has been initialized if it hasn't been already;
30                 in particular, if you want your program to parse GStreamer command line
31                 options then you should do it yourself, before gtk_init(). */
32                 
33                 /* SUCKY DEBIAN: gst_is_initialized() supported from 0.10.30 onward */
34                 /*if( !gst_is_initialized() )*/
35                         gst_init(NULL, NULL);
36 #endif
37
38                 /* Initialize thread-private data */
39                 extern GPrivate *glk_data_key;
40                 glk_data_key = g_private_new(NULL);
41         }
42 }
43