From ed25f6521c1715c564d945cf5edc236eca65b27f Mon Sep 17 00:00:00 2001 From: Philip Chimento Date: Mon, 26 Oct 2009 20:17:06 +0000 Subject: [PATCH] Styles should be initialized once per widget, not once per program git-svn-id: http://lassie.dyndns-server.com/svn/gargoyle-gtk@153 ddfedd41-794f-dd11-ae45-00112f111e67 --- libchimara/chimara-glk-private.h | 2 ++ libchimara/chimara-glk.c | 1 + libchimara/style.c | 21 +++++++++------------ 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/libchimara/chimara-glk-private.h b/libchimara/chimara-glk-private.h index 3b1460a..33e8ebf 100644 --- a/libchimara/chimara-glk-private.h +++ b/libchimara/chimara-glk-private.h @@ -81,6 +81,8 @@ struct _ChimaraGlkPrivate { void (*unregister_obj)(void *, glui32, gidispatch_rock_t); gidispatch_rock_t (*register_arr)(void *, glui32, char *); void (*unregister_arr)(void *, glui32, char *, gidispatch_rock_t); + /* Have styles been initialized */ + gboolean style_initialized; /* *** Platform-dependent Glk library data *** */ /* Flag for functions to find out if they are being called from startup code */ diff --git a/libchimara/chimara-glk.c b/libchimara/chimara-glk.c index c21e9cc..907c121 100644 --- a/libchimara/chimara-glk.c +++ b/libchimara/chimara-glk.c @@ -108,6 +108,7 @@ chimara_glk_init(ChimaraGlk *self) priv->current_stream = NULL; priv->stream_list = NULL; priv->timer_id = 0; + priv->style_initialized = FALSE; priv->in_startup = FALSE; priv->current_dir = NULL; } diff --git a/libchimara/style.c b/libchimara/style.c index 1b13e61..0734fd3 100644 --- a/libchimara/style.c +++ b/libchimara/style.c @@ -3,7 +3,6 @@ #include extern GPrivate *glk_data_key; -static gboolean chimara_style_initialized = FALSE; static gboolean style_accept(GScanner *scanner, GTokenType token); static gboolean style_accept_style_selector(GScanner *scanner); @@ -77,11 +76,10 @@ style_init_textbuffer(GtkTextBuffer *buffer) { g_return_if_fail(buffer != NULL); - if( G_UNLIKELY(!chimara_style_initialized) ) { + ChimaraGlkPrivate *glk_data = g_private_get(glk_data_key); + if( G_UNLIKELY(!glk_data->style_initialized) ) { style_init(); } - - ChimaraGlkPrivate *glk_data = g_private_get(glk_data_key); g_hash_table_foreach(glk_data->current_styles->text_buffer, style_add_tag_to_textbuffer, gtk_text_buffer_get_tag_table(buffer)); } @@ -90,12 +88,11 @@ void style_init_textgrid(GtkTextBuffer *buffer) { g_return_if_fail(buffer != NULL); - - if( G_UNLIKELY(!chimara_style_initialized) ) { + + ChimaraGlkPrivate *glk_data = g_private_get(glk_data_key); + if( G_UNLIKELY(!glk_data->style_initialized) ) { style_init(); } - - ChimaraGlkPrivate *glk_data = g_private_get(glk_data_key); g_hash_table_foreach(glk_data->current_styles->text_grid, style_add_tag_to_textbuffer, gtk_text_buffer_get_tag_table(buffer)); } @@ -173,8 +170,8 @@ style_init() g_return_if_fail(f != -1); g_scanner_input_file(scanner, f); scanner->input_name = glk_data->css_file; - scanner->config->cset_identifier_first = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ#"; - scanner->config->cset_identifier_nth = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ-_0123456789"; + scanner->config->cset_identifier_first = G_CSET_a_2_z G_CSET_A_2_Z "#"; + scanner->config->cset_identifier_nth = G_CSET_a_2_z G_CSET_A_2_Z "-_" G_CSET_DIGITS; scanner->config->symbol_2_token = TRUE; scanner->config->cpair_comment_single = NULL; scanner->config->scan_float = FALSE; @@ -232,7 +229,7 @@ style_init() g_scanner_destroy(scanner); - chimara_style_initialized = TRUE; + glk_data->style_initialized = TRUE; } /* Internal function: parses a token */ @@ -678,7 +675,7 @@ glk_stylehint_set(glui32 wintype, glui32 styl, glui32 hint, glsi32 val) { ChimaraGlkPrivate *glk_data = g_private_get(glk_data_key); - if( G_UNLIKELY(!chimara_style_initialized) ) { + if( G_UNLIKELY(!glk_data->style_initialized) ) { style_init(); } -- 2.30.2