X-Git-Url: https://git.stderr.nl/gitweb?a=blobdiff_plain;f=libchimara%2Fstyle.c;h=9b82a6637d260241f017d5b2c7289b55364d3aff;hb=4ab49e6ed54603ca26040c43cf4628cd0186632f;hp=6cd3bd0b53762ec243c4170b0b6246218800e513;hpb=207745dc22dd7d17bcb7bf26ec991cc1ac8199ed;p=projects%2Fchimara%2Fchimara.git
diff --git a/libchimara/style.c b/libchimara/style.c
index 6cd3bd0..9b82a66 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)
@@ -1082,6 +1075,9 @@ glk_style_distinguish(winid_t win, glui32 styl1, glui32 styl2)
* colors are reversed.
*
*
+ * Signed values, such as the %stylehint_Weight value, are cast to
+ * glui32. They may be cast to glsi32 to be dealt with
+ * in a more natural context.
*
* Returns: TRUE upon successul retrieval, otherwise FALSE.
*/