X-Git-Url: https://git.stderr.nl/gitweb?a=blobdiff_plain;f=libchimara%2Fstyle.c;h=0df3bbdd62927c2035f819ba9e1bde2a9ad7d340;hb=eee4d0cf128d86aaac5c81c6ac404819770c49d0;hp=6cd3bd0b53762ec243c4170b0b6246218800e513;hpb=207745dc22dd7d17bcb7bf26ec991cc1ac8199ed;p=projects%2Fchimara%2Fchimara.git diff --git a/libchimara/style.c b/libchimara/style.c index 6cd3bd0..0df3bbd 100644 --- a/libchimara/style.c +++ b/libchimara/style.c @@ -13,7 +13,6 @@ extern GPrivate *glk_data_key; static gboolean style_accept(GScanner *scanner, GTokenType token); static gboolean style_accept_style_selector(GScanner *scanner, ChimaraGlk *glk); static gboolean style_accept_style_hint(GScanner *scanner, GtkTextTag *current_tag); -static void style_add_tag_to_textbuffer(gpointer key, gpointer tag, gpointer tag_table); static void style_copy_tag_to_textbuffer(gpointer key, gpointer tag, gpointer target_table); static void text_tag_to_attr_list(GtkTextTag *tag, PangoAttrList *list); GtkTextTag* gtk_text_tag_copy(GtkTextTag *tag); @@ -165,17 +164,6 @@ style_init_textgrid(GtkTextBuffer *buffer) g_hash_table_foreach(glk_data->glk_styles->text_grid, style_copy_tag_to_textbuffer, gtk_text_buffer_get_tag_table(buffer)); } -/* Internal function used to iterate over the default text tag table, applying them to a textbuffer */ -static void -style_add_tag_to_textbuffer(gpointer key, gpointer tag, gpointer tag_table) -{ - g_return_if_fail(key != NULL); - g_return_if_fail(tag != NULL); - g_return_if_fail(tag_table != NULL); - - gtk_text_tag_table_add(tag_table, tag); -} - /* Internal function used to iterate over a style table, copying it */ static void style_copy_tag_to_textbuffer(gpointer key, gpointer tag, gpointer target_table) @@ -400,21 +388,6 @@ reset_default_styles(ChimaraGlk *glk) /* TODO: write this function */ } -/* Copy the default styles to the current styles - FIXME: This function is temporary and will not be needed later on */ -void -copy_default_styles_to_current_styles(ChimaraGlk *glk) -{ - /* - CHIMARA_GLK_USE_PRIVATE(glk, priv); - g_hash_table_foreach(priv->styles->text_grid, style_table_copy, priv->glk_styles->text_grid); - g_hash_table_foreach(priv->styles->text_buffer, style_table_copy, priv->glk_styles->text_buffer); - - GtkTextTag *pager_tag = GTK_TEXT_TAG( g_hash_table_lookup(priv->styles->text_buffer, "pager") ); - text_tag_to_attr_list(pager_tag, priv->pager_attr_list); - */ -} - /* Create the CSS file scanner */ GScanner * create_css_file_scanner(void) @@ -672,6 +645,26 @@ glkcolor_to_gdkcolor(glui32 val, GdkColor *color) color->blue = 256 * (val & 0x0000ff); } +/* Internal function: parses a glk color to a hex string */ +gchar* +glkcolor_to_hex(glui32 val) +{ + return g_strdup_printf("%04X%04X%04X", + 256 * ((val & 0xff0000) >> 16), + 256 * ((val & 0x00ff00) >> 8), + 256 * (val & 0x0000ff) + ); +} + +/* Internal function: parses a gdk color to a hex string */ +gchar* +gdkcolor_to_hex(GdkColor *color) +{ + return g_strdup_printf("%04X%04X%04X", + color->red, color->green, color->blue + ); +} + /* Internal function: parses a GdkColor to a glk color */ static glui32 gdkcolor_to_glkcolor(GdkColor *color)