Submitted By: Christopher Gregory Date: 2014-08-30 Initial Package Version: 1.5.8 Upstream Status: Fixed Upstream Origin: Upstream Description: Fixes preedit color on external preedit window with x11 From 2e8de03a949bf1a7dabe8217d42017bf75685b1a Mon Sep 17 00:00:00 2001 From: fujiwarat Date: Thu, 7 Aug 2014 11:45:00 +0900 Subject: [PATCH] Enable preedit color on external preedit window with x11 applications. BUG=http://code.google.com/p/ibus/issues/detail?id=1731 TEST=ui/gtk3/ibus-ui-gtk3 Review URL: https://codereview.appspot.com/119480043 --- ui/gtk3/candidatepanel.vala | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/ui/gtk3/candidatepanel.vala b/ui/gtk3/candidatepanel.vala index 1440b2b..1b7bec7 100644 --- a/ui/gtk3/candidatepanel.vala +++ b/ui/gtk3/candidatepanel.vala @@ -110,6 +110,25 @@ public class CandidatePanel : Gtk.Box{ m_candidate_area.set_labels(labels); } + private void set_attributes(Gtk.Label label, IBus.Text text) { + Pango.AttrList attrs = get_pango_attr_list_from_ibus_text(text); + + Gtk.StyleContext context = label.get_style_context(); + Gdk.RGBA color; + + if (context.lookup_color("placeholder_text_color", out color)) { + Pango.Attribute pango_attr = Pango.attr_foreground_new( + (uint16)(color.red * uint16.MAX), + (uint16)(color.green * uint16.MAX), + (uint16)(color.blue * uint16.MAX)); + pango_attr.start_index = 0; + pango_attr.end_index = label.get_text().length; + attrs.insert((owned)pango_attr); + } + + label.set_attributes(attrs); + } + public void set_preedit_text(IBus.Text? text, uint cursor) { if (text != null) { var str = text.get_text(); @@ -117,6 +136,7 @@ public class CandidatePanel : Gtk.Box{ if (str.length > 0) { m_preedit_label.set_text(str); m_preedit_label.show(); + set_attributes(m_preedit_label, text); } else { m_preedit_label.set_text(""); m_preedit_label.hide();