summaryrefslogtreecommitdiff
path: root/gtk/gtktextlayout.c
diff options
context:
space:
mode:
authorDaiki Ueno <ueno@unixuser.org>2013-01-29 14:49:22 +0900
committerDaiki Ueno <ueno@unixuser.org>2013-01-31 11:22:06 +0900
commit7a9553cfb5d465df79161f61f7c01d872e90b983 (patch)
tree2f4e3ce6fd088677927baac833a43abbb329c08c /gtk/gtktextlayout.c
parenta687cbaae82198f92d0914fbe0d09715308d7aa8 (diff)
downloadgtk+-7a9553cfb5d465df79161f61f7c01d872e90b983.tar.gz
textlayout: respect preedit color attribute
gtk_text_renderer_prepare_run now checks appearance.rgba, rather than appearance.{fg_color,bg_color}. https://bugzilla.gnome.org/show_bug.cgi?id=692766
Diffstat (limited to 'gtk/gtktextlayout.c')
-rw-r--r--gtk/gtktextlayout.c20
1 files changed, 14 insertions, 6 deletions
diff --git a/gtk/gtktextlayout.c b/gtk/gtktextlayout.c
index 825f7223e6..73be6b417c 100644
--- a/gtk/gtktextlayout.c
+++ b/gtk/gtktextlayout.c
@@ -1846,12 +1846,13 @@ allocate_child_widgets (GtkTextLayout *text_layout,
}
static void
-convert_color (GdkColor *result,
+convert_color (GdkRGBA *result,
PangoAttrColor *attr)
{
- result->red = attr->color.red;
- result->blue = attr->color.blue;
- result->green = attr->color.green;
+ result->red = attr->color.red / 65535.;
+ result->blue = attr->color.blue / 65535.;
+ result->green = attr->color.green / 65535.;
+ result->alpha = 1;
}
/* This function is used to convert the preedit string attributes, which are
@@ -1891,14 +1892,21 @@ add_preedit_attrs (GtkTextLayout *layout,
while (tmp_list)
{
PangoAttribute *attr = tmp_list->data;
+ GdkRGBA rgba;
switch (attr->klass->type)
{
case PANGO_ATTR_FOREGROUND:
- convert_color (&appearance.fg_color, (PangoAttrColor *)attr);
+ convert_color (&rgba, (PangoAttrColor *)attr);
+ if (appearance.rgba[1])
+ gdk_rgba_free (appearance.rgba[1]);
+ appearance.rgba[1] = gdk_rgba_copy (&rgba);
break;
case PANGO_ATTR_BACKGROUND:
- convert_color (&appearance.bg_color, (PangoAttrColor *)attr);
+ convert_color (&rgba, (PangoAttrColor *)attr);
+ if (appearance.rgba[0])
+ gdk_rgba_free (appearance.rgba[0]);
+ appearance.rgba[0] = gdk_rgba_copy (&rgba);
appearance.draw_bg = TRUE;
break;
case PANGO_ATTR_UNDERLINE: