Styles should be initialized once per widget, not once per program
authorPhilip Chimento <philip.chimento@gmail.com>
Mon, 26 Oct 2009 20:17:06 +0000 (20:17 +0000)
committerPhilip Chimento <philip.chimento@gmail.com>
Mon, 26 Oct 2009 20:17:06 +0000 (20:17 +0000)
git-svn-id: http://lassie.dyndns-server.com/svn/gargoyle-gtk@153 ddfedd41-794f-dd11-ae45-00112f111e67

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

index 3b1460a812c124de8a438c54e57e42cd4a9472fd..33e8ebf5b8ea20d26d4a1658a006f697bf870df1 100644 (file)
@@ -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 */
index c21e9cc499202ba32d86919eaea0ad95cd13749c..907c1214c0bafe87466f5b25422b33b9a9f97570 100644 (file)
@@ -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;
 }
index 1b13e61e7ebbd4fbf77f24c17bf92a9478602e7e..0734fd37847ce1244b7ed209acb846072a46c34e 100644 (file)
@@ -3,7 +3,6 @@
 #include <fcntl.h>
 
 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();
        }