Reset Glk style hints at beginning of program
authorPhilip Chimento <philip.chimento@gmail.com>
Tue, 25 Mar 2014 06:16:53 +0000 (06:16 +0000)
committerPhilip Chimento <philip.chimento@gmail.com>
Tue, 25 Mar 2014 06:20:18 +0000 (06:20 +0000)
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
libchimara/style.c
libchimara/style.h

index 265b007110de1c6b4404059798148e7b078d3c8d..832b0dc2d956f157413979c95afe09d5167a4482 100644 (file)
@@ -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);
 
index 0e7d7639ba0d29f53f8d56d879da9c5211f515b3..ece22a738061ad9681569bf24154a08290f9cc5c 100644 (file)
@@ -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;
index ba9939a1f3218eb22bd5aa6949e1a1fdddbbd488..c4305c065a5c5dafdefe080611bd70478f6a4c4b 100644 (file)
@@ -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);