From 5fb29158df45248e3a4734e00bc1a9e7a9871044 Mon Sep 17 00:00:00 2001 From: Philip Chimento Date: Tue, 25 Mar 2014 06:16:53 +0000 Subject: [PATCH] Reset Glk style hints at beginning of program The Glk program can change the style hints so that different styles display differently. These style hints should not carry over into the next execution of the Glk program, or even a different Glk program. This resets them at the beginning of a Glk program execution. Conflicts: libchimara/style.c libchimara/style.h --- libchimara/chimara-glk.c | 5 ++++- libchimara/style.c | 16 ++++++++++++++-- libchimara/style.h | 1 + 3 files changed, 19 insertions(+), 3 deletions(-) diff --git a/libchimara/chimara-glk.c b/libchimara/chimara-glk.c index 265b007..832b0dc 100644 --- a/libchimara/chimara-glk.c +++ b/libchimara/chimara-glk.c @@ -1268,7 +1268,10 @@ chimara_glk_run(ChimaraGlk *glk, const gchar *plugin, int argc, char *argv[], GE /* Set the program name */ priv->program_name = g_path_get_basename(plugin); g_object_notify(G_OBJECT(glk), "program-name"); - + + /* Set Glk styles to defaults */ + style_reset_glk(glk); + /* Run in a separate thread */ priv->thread = g_thread_try_new("glk", (GThreadFunc)glk_enter, startup, error); diff --git a/libchimara/style.c b/libchimara/style.c index 0e7d763..ece22a7 100644 --- a/libchimara/style.c +++ b/libchimara/style.c @@ -242,8 +242,6 @@ style_init(ChimaraGlk *glk) GHashTable *default_text_grid_styles = g_hash_table_new_full(g_str_hash, g_str_equal, NULL, g_object_unref); GHashTable *default_text_buffer_styles = g_hash_table_new_full(g_str_hash, g_str_equal, NULL, g_object_unref); - GHashTable *glk_text_grid_styles = g_hash_table_new_full(g_str_hash, g_str_equal, NULL, g_object_unref); - GHashTable *glk_text_buffer_styles = g_hash_table_new_full(g_str_hash, g_str_equal, NULL, g_object_unref); GtkTextTag *tag; /* Initialise the default styles for a text grid */ @@ -351,6 +349,20 @@ style_init(ChimaraGlk *glk) priv->styles->text_grid = default_text_grid_styles; priv->styles->text_buffer = default_text_buffer_styles; + style_reset_glk(glk); +} + +/* Reset the style hints set from the Glk program to be blank. Call this when +starting a new game so that style hints from the previous game don't carry +over. */ +void +style_reset_glk(ChimaraGlk *glk) +{ + CHIMARA_GLK_USE_PRIVATE(glk, priv); + + GHashTable *glk_text_grid_styles = g_hash_table_new_full(g_str_hash, g_str_equal, NULL, g_object_unref); + GHashTable *glk_text_buffer_styles = g_hash_table_new_full(g_str_hash, g_str_equal, NULL, g_object_unref); + GtkTextTag *tag; /* Initialize the GLK styles to empty tags */ int i; diff --git a/libchimara/style.h b/libchimara/style.h index ba9939a..c4305c0 100644 --- a/libchimara/style.h +++ b/libchimara/style.h @@ -11,6 +11,7 @@ G_GNUC_INTERNAL void style_init_textbuffer(GtkTextBuffer *buffer); G_GNUC_INTERNAL void style_init_textgrid(GtkTextBuffer *buffer); G_GNUC_INTERNAL void style_init_more_prompt(winid_t win); G_GNUC_INTERNAL void style_init(ChimaraGlk *glk); +G_GNUC_INTERNAL void style_reset_glk(ChimaraGlk *glk); G_GNUC_INTERNAL void style_update(ChimaraGlk *glk); G_GNUC_INTERNAL const gchar** style_get_tag_names(); G_GNUC_INTERNAL void reset_default_styles(ChimaraGlk *glk); -- 2.30.2