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:16:53 +0000 (06:16 +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.

libchimara/chimara-glk.c
libchimara/style.c
libchimara/style.h

index 29a7dce9cbd5356ad5200b41410600c6b9118d51..4bbb3aa4e87cfd838bc9843de8322068195ceb31 100644 (file)
@@ -1206,7 +1206,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 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);
 
     /* Run in a separate thread */
        priv->thread = g_thread_try_new("glk", (GThreadFunc)glk_enter, startup, error);
 
index 67240764ebf33e2b3c9922f6cf16a94cbb657d35..b4aa029367a61443955c413b832235a9caea33b3 100644 (file)
@@ -231,8 +231,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 *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 */
        GtkTextTag *tag;
 
        /* Initialise the default styles for a text grid */
@@ -335,6 +333,21 @@ style_init(ChimaraGlk *glk)
        priv->styles->text_grid = default_text_grid_styles;
        priv->styles->text_buffer = default_text_buffer_styles;
 
        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;
        for(i=0; i<style_NUMSTYLES; i++) {
        /* Initialize the GLK styles to empty tags */
        int i;
        for(i=0; i<style_NUMSTYLES; i++) {
index ee456d88c8ab3dab868009f3f8570b647a708021..ceb036c021242667bef4f50350c5fe9483fbeaa3 100644 (file)
@@ -10,6 +10,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(ChimaraGlk *glk);
 G_GNUC_INTERNAL void style_init_textbuffer(GtkTextBuffer *buffer);
 G_GNUC_INTERNAL void style_init_textgrid(GtkTextBuffer *buffer);
 G_GNUC_INTERNAL void style_init(ChimaraGlk *glk);
+G_GNUC_INTERNAL void style_reset_glk(ChimaraGlk *glk);
 G_GNUC_INTERNAL const gchar** style_get_tag_names();
 G_GNUC_INTERNAL void reset_default_styles(ChimaraGlk *glk);
 G_GNUC_INTERNAL GScanner *create_css_file_scanner(void);
 G_GNUC_INTERNAL const gchar** style_get_tag_names();
 G_GNUC_INTERNAL void reset_default_styles(ChimaraGlk *glk);
 G_GNUC_INTERNAL GScanner *create_css_file_scanner(void);