X-Git-Url: https://git.stderr.nl/gitweb?a=blobdiff_plain;f=libchimara%2Fchimara-glk.c;h=c7d0c52c91c9ff7710eee3af82e846708f0371d0;hb=4317ae2d1e6440527b22c0b0f0fcd71d902a5bb6;hp=f4cd156fe3da9ae3a1d06127dde408aed12efd5d;hpb=40c961bdf2523ebdcb6717f2537f97156fd19ab4;p=rodin%2Fchimara.git diff --git a/libchimara/chimara-glk.c b/libchimara/chimara-glk.c index f4cd156..c7d0c52 100644 --- a/libchimara/chimara-glk.c +++ b/libchimara/chimara-glk.c @@ -85,9 +85,10 @@ chimara_glk_init(ChimaraGlk *self) priv->protect = FALSE; priv->default_font_desc = pango_font_description_from_string("Serif"); priv->monospace_font_desc = pango_font_description_from_string("Monospace"); - priv->css_file = "style.css"; + priv->css_file = NULL; priv->default_styles = g_new0(StyleSet,1); priv->current_styles = g_new0(StyleSet,1); + priv->pager_attr_list = pango_attr_list_new(); priv->style_initialized = FALSE; priv->final_message = g_strdup("[ The game has finished ]"); priv->running = FALSE; @@ -191,6 +192,7 @@ chimara_glk_finalize(GObject *object) g_hash_table_destroy(priv->default_styles->text_grid); g_hash_table_destroy(priv->current_styles->text_buffer); g_hash_table_destroy(priv->current_styles->text_grid); + pango_attr_list_unref(priv->pager_attr_list); priv->style_initialized = FALSE; /* Free the event queue */ @@ -577,11 +579,6 @@ chimara_glk_stopped(ChimaraGlk *self) { CHIMARA_GLK_USE_PRIVATE(self, priv); priv->running = FALSE; - - /* Free the plugin */ - if( priv->program && !g_module_close(priv->program) ) - g_warning( "Error closing module: %s", g_module_error() ); - priv->program = NULL; } static void @@ -615,9 +612,16 @@ chimara_glk_text_buffer_output(ChimaraGlk *self, guint window_rock, gchar *text) /* 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 @@ -840,6 +844,7 @@ chimara_glk_set_interactive(ChimaraGlk *glk, gboolean interactive) ChimaraGlkPrivate *priv = CHIMARA_GLK_PRIVATE(glk); priv->interactive = interactive; + g_object_notify(G_OBJECT(glk), "interactive"); } /** @@ -876,6 +881,7 @@ chimara_glk_set_protect(ChimaraGlk *glk, gboolean protect) ChimaraGlkPrivate *priv = CHIMARA_GLK_PRIVATE(glk); priv->protect = protect; + g_object_notify(G_OBJECT(glk), "protect"); } /** @@ -913,7 +919,7 @@ chimara_glk_set_default_font_description(ChimaraGlk *glk, PangoFontDescription * ChimaraGlkPrivate *priv = CHIMARA_GLK_PRIVATE(glk); pango_font_description_free(priv->default_font_desc); priv->default_font_desc = pango_font_description_copy(font); - + g_object_notify(G_OBJECT(glk), "default-font-description"); /* TODO: Apply the font description to all the windows and recalculate the sizes */ } @@ -941,6 +947,7 @@ chimara_glk_set_default_font_string(ChimaraGlk *glk, const gchar *font) ChimaraGlkPrivate *priv = CHIMARA_GLK_PRIVATE(glk); pango_font_description_free(priv->default_font_desc); priv->default_font_desc = fontdesc; + g_object_notify(G_OBJECT(glk), "default-font-description"); /* TODO: Apply the font description to all the windows and recalculate the sizes */ } @@ -980,6 +987,7 @@ chimara_glk_set_monospace_font_description(ChimaraGlk *glk, PangoFontDescription ChimaraGlkPrivate *priv = CHIMARA_GLK_PRIVATE(glk); pango_font_description_free(priv->monospace_font_desc); priv->monospace_font_desc = pango_font_description_copy(font); + g_object_notify(G_OBJECT(glk), "monospace-font-description"); /* TODO: Apply the font description to all the windows and recalculate the sizes */ } @@ -1008,6 +1016,7 @@ chimara_glk_set_monospace_font_string(ChimaraGlk *glk, const gchar *font) ChimaraGlkPrivate *priv = CHIMARA_GLK_PRIVATE(glk); pango_font_description_free(priv->monospace_font_desc); priv->monospace_font_desc = fontdesc; + g_object_notify(G_OBJECT(glk), "monospace-font-description"); /* TODO: Apply the font description to all the windows and recalculate the sizes */ } @@ -1045,6 +1054,7 @@ chimara_glk_set_spacing(ChimaraGlk *glk, guint spacing) ChimaraGlkPrivate *priv = CHIMARA_GLK_PRIVATE(glk); priv->spacing = spacing; + g_object_notify(G_OBJECT(glk), "spacing"); } /** @@ -1099,7 +1109,9 @@ glk_enter(struct StartupData *startup) /* Run main function */ glk_main_t glk_main = startup->glk_main; - g_slice_free(struct StartupData, startup); + + /* COMPAT: avoid usage of slices */ + g_free(startup); g_signal_emit_by_name(startup->glk_data->self, "started"); glk_main(); glk_exit(); /* Run shutdown code in glk_exit() even if glk_main() returns normally */ @@ -1138,10 +1150,16 @@ chimara_glk_run(ChimaraGlk *glk, const gchar *plugin, int argc, char *argv[], GE } ChimaraGlkPrivate *priv = CHIMARA_GLK_PRIVATE(glk); - struct StartupData *startup = g_slice_new0(struct StartupData); + + /* COMPAT: avoid usage of slices */ + struct StartupData *startup = g_new0(struct StartupData,1); - /* Open the module to run */ g_assert( g_module_supported() ); + /* If there is already a module loaded, free it first -- you see, we want to + * keep modules loaded as long as possible to avoid crashes in stack unwinding */ + if( priv->program && !g_module_close(priv->program) ) + g_warning( "Error closing module :%s", g_module_error() ); + /* Open the module to run */ priv->program = g_module_open(plugin, G_MODULE_BIND_LAZY); if(!priv->program)