X-Git-Url: https://git.stderr.nl/gitweb?a=blobdiff_plain;f=libchimara%2Fstyle.c;h=b4aa029367a61443955c413b832235a9caea33b3;hb=HEAD;hp=406a8848969f6d4cce70a9533694bac5401b374e;hpb=fd95bbfc8f01fe812d9f24d1d377079df5f968d5;p=projects%2Fchimara%2Fchimara.git diff --git a/libchimara/style.c b/libchimara/style.c index 406a884..b4aa029 100644 --- a/libchimara/style.c +++ b/libchimara/style.c @@ -8,7 +8,7 @@ #include "stream.h" #include "strio.h" -extern GPrivate *glk_data_key; +extern GPrivate glk_data_key; static gboolean style_accept(GScanner *scanner, GTokenType token); static gboolean style_accept_style_selector(GScanner *scanner, ChimaraGlk *glk); @@ -34,7 +34,7 @@ static void style_cascade_colors(GtkTextTag *tag, GtkTextTag *glk_tag, GtkTextTa void glk_set_style(glui32 styl) { - ChimaraGlkPrivate *glk_data = g_private_get(glk_data_key); + ChimaraGlkPrivate *glk_data = g_private_get(&glk_data_key); g_return_if_fail(glk_data->current_stream != NULL); glk_set_style_stream(glk_data->current_stream, styl); } @@ -128,7 +128,7 @@ style_init_textbuffer(GtkTextBuffer *buffer) { g_return_if_fail(buffer != NULL); - ChimaraGlkPrivate *glk_data = g_private_get(glk_data_key); + ChimaraGlkPrivate *glk_data = g_private_get(&glk_data_key); /* Place the default text tags in the textbuffer's tag table */ g_hash_table_foreach(glk_data->styles->text_buffer, style_copy_tag_to_textbuffer, gtk_text_buffer_get_tag_table(buffer)); @@ -146,8 +146,8 @@ void style_init_textgrid(GtkTextBuffer *buffer) { g_return_if_fail(buffer != NULL); - - ChimaraGlkPrivate *glk_data = g_private_get(glk_data_key); + + ChimaraGlkPrivate *glk_data = g_private_get(&glk_data_key); /* Place the default text tags in the textbuffer's tag table */ g_hash_table_foreach(glk_data->styles->text_grid, style_copy_tag_to_textbuffer, gtk_text_buffer_get_tag_table(buffer)); @@ -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 *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 */ @@ -335,6 +333,21 @@ 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; for(i=0; irock=%d, styl=%d, hint=%d, result=...)\n", win->rock, styl, hint); #endif - ChimaraGlkPrivate *glk_data = g_private_get(glk_data_key); + ChimaraGlkPrivate *glk_data = g_private_get(&glk_data_key); GtkTextTag *tag; switch(win->type) { @@ -1083,7 +1096,7 @@ glk_style_measure(winid_t win, glui32 styl, glui32 hint, glui32 *result) PangoFontDescription * get_current_font(guint32 wintype) { - ChimaraGlkPrivate *glk_data = g_private_get(glk_data_key); + ChimaraGlkPrivate *glk_data = g_private_get(&glk_data_key); GHashTable *styles, *glk_styles; PangoFontDescription *font;