X-Git-Url: https://git.stderr.nl/gitweb?a=blobdiff_plain;f=libchimara%2Fchimara-if.c;h=2c26fbf7290c748ad25be18edb5a077b2f05065b;hb=7e8eb7e80c6d900fc07412037d5b0a835d8ca1cd;hp=c7e4575f41fdc25363c8958806a5b5654ef917dc;hpb=cc7434f897ab31bb797b519404100aae1da4fd81;p=rodin%2Fchimara.git diff --git a/libchimara/chimara-if.c b/libchimara/chimara-if.c index c7e4575..2c26fbf 100644 --- a/libchimara/chimara-if.c +++ b/libchimara/chimara-if.c @@ -6,6 +6,7 @@ #include #include "chimara-if.h" #include "chimara-glk.h" +#include "chimara-glk-private.h" #include "chimara-marshallers.h" #include "init.h" @@ -13,11 +14,17 @@ * SECTION:chimara-if * @short_description: Widget which plays an interactive fiction game * @stability: Unstable - * @include: chimara/chimara-if.h + * @include: libchimara/chimara-if.h * * The #ChimaraIF widget, given an interactive fiction game file to run, selects * an appropriate interpreter plugin and runs it. Interpreter options are set by * setting properties on the widget. + * + * Using it in a GTK program is similar to using #ChimaraGlk (which see). + * Threads must be initialized before using #ChimaraIF and the call to + * gtk_main() must be bracketed between gdk_threads_enter() and + * gdk_threads_leave(). Use chimara_if_run_game() to start playing an + * interactive fiction game. */ static gboolean supported_formats[CHIMARA_IF_NUM_FORMATS][CHIMARA_IF_NUM_INTERPRETERS] = { @@ -248,9 +255,16 @@ chimara_if_command(ChimaraIF *self, gchar *input, gchar *response) /* Default signal handler */ } -/* G_PARAM_STATIC_STRINGS only appeared in GTK 2.13.0 */ +/* COMPAT: G_PARAM_STATIC_STRINGS only appeared in GTK 2.13.0 */ #ifndef G_PARAM_STATIC_STRINGS + +/* COMPAT: G_PARAM_STATIC_NAME and friends only appeared in GTK 2.8 */ +#if GTK_CHECK_VERSION(2,8,0) #define G_PARAM_STATIC_STRINGS (G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB) +#else +#define G_PARAM_STATIC_STRINGS (0) +#endif + #endif static void @@ -272,8 +286,7 @@ chimara_if_class_init(ChimaraIFClass *klass) * * Emitted once for each input-response cycle of an interactive fiction * game. Note that games with nontraditional input systems (i.e. not all - * taking place in the same text buffer window) may throw this signal for a - * loop. + * taking place in the same text buffer window) may confuse this signal. */ chimara_if_signals[COMMAND] = g_signal_new("command", G_OBJECT_CLASS_TYPE(klass), 0, @@ -630,7 +643,14 @@ chimara_if_run_game(ChimaraIF *self, gchar *gamefile, GError **error) GSList *ptr; for(count = 0, ptr = args; ptr; count++, ptr = g_slist_next(ptr)) argv[count] = ptr->data; - + + /* Set the story name */ + /* We peek into ChimaraGlk's private data here, because GObject has no + equivalent to "protected" */ + CHIMARA_GLK_USE_PRIVATE(self, glk_priv); + glk_priv->story_name = g_path_get_basename(gamefile); + g_object_notify(G_OBJECT(self), "story-name"); + gboolean retval = chimara_glk_run(CHIMARA_GLK(self), pluginpath, argc, argv, error); g_free(argv); if(terpnumstr)