- gchar* foreground_color;
- gchar* background_color;
- g_object_get(tag_object, "foreground", &foreground_color, NULL);
- g_object_get(tag_object, "background", &background_color, NULL);
- g_object_set(tag_object, "foreground", background_color, NULL);
- g_object_set(tag_object, "background", foreground_color, NULL);
- g_free(foreground_color);
- g_free(background_color);
+ GdkColor* foreground_color;
+ GdkColor* background_color;
+ gint f_set, b_set = 0;
+ g_object_get(tag_object, "foreground-set", &f_set, "background-set", &b_set, NULL);
+
+ if(f_set)
+ g_object_get(tag_object, "foreground-gdk", &foreground_color, NULL);
+ if(b_set)
+ g_object_get(tag_object, "background-gdk", &background_color, NULL);
+
+ if(b_set)
+ g_object_set(tag_object, "foreground-gdk", background_color, NULL);
+ else
+ g_object_set(tag_object, "foreground", "#ffffff", NULL);
+
+ if(f_set)
+ g_object_set(tag_object, "background-gdk", foreground_color, NULL);
+ else
+ g_object_set(tag_object, "background", "#000000", NULL);
+ }
+ break;
+
+ default:
+ WARNING("Unknown style hint");
+ }
+}
+/*Internal function: queries a text tag for the value of a given style hint */
+static gint
+query_tag(GtkTextTag *tag, glui32 hint)
+{
+ gint intval;
+ GObject *objval;
+ GdkColor *colval;
+
+ g_return_val_if_fail(tag != NULL, 0);
+
+ ChimaraGlkPrivate *glk_data = g_private_get(glk_data_key);
+
+ switch(hint) {
+ case stylehint_Indentation:
+ g_object_get(tag, "left_margin", &intval, NULL);
+ return intval/5;
+ break;
+
+ case stylehint_ParaIndentation:
+ g_object_get(tag, "indent", &intval, NULL);
+ return intval/5;
+ break;
+
+ case stylehint_Justification:
+ g_object_get(tag, "justification", &intval, NULL);
+ switch(intval) {
+ case GTK_JUSTIFY_LEFT: return stylehint_just_LeftFlush; break;
+ case GTK_JUSTIFY_FILL: return stylehint_just_LeftRight; break;
+ case GTK_JUSTIFY_CENTER: return stylehint_just_Centered; break;
+ case GTK_JUSTIFY_RIGHT: return stylehint_just_RightFlush; break;
+ default:
+ WARNING("Unknown justification");
+ return stylehint_just_LeftFlush;
+ }
+ break;
+
+ case stylehint_Weight:
+ g_object_get(tag, "weight", &intval, NULL);
+ switch(intval) {
+ case PANGO_WEIGHT_LIGHT: return -1; break;
+ case PANGO_WEIGHT_NORMAL: return 0; break;
+ case PANGO_WEIGHT_BOLD: return 1; break;
+ default: WARNING("Unknown font weight"); return 0;