Remove AttributeDecoration
authorHuang Peng <shawn.p.huang@gmail.com>
Wed, 28 May 2008 03:01:40 +0000 (11:01 +0800)
committerHuang Peng <shawn.p.huang@gmail.com>
Wed, 28 May 2008 03:01:40 +0000 (11:01 +0800)
Add AttributeUnderline

ibus/gtk.py [new file with mode: 0644]

diff --git a/ibus/gtk.py b/ibus/gtk.py
new file mode 100644 (file)
index 0000000..95168ed
--- /dev/null
@@ -0,0 +1,30 @@
+import pango
+import ibus
+
+class PangoAttrList (pango.AttrList):
+       def __init__ (self, attrs):
+               pango.AttrList.__init__ (self)
+               for attr in attrs:
+                       pango_attr = None
+                       if attr._type == ATTR_TYPE_FOREGROUND:
+                               r = (attr._value & 0x00ff0000) >> 8
+                               g = (attr._value & 0x0000ff00)
+                               b = (attr._value & 0x000000ff) << 8
+                               pango_attr = pango.AttrForeground (r, g, b, 
+                                       attr._start_index, attr._end_index)
+                       elif attr._type == ATTR_TYPE_BACKGROUND:
+                               r = (attr._value & 0x00ff0000) >> 8
+                               g = (attr._value & 0x0000ff00)
+                               b = (attr._value & 0x000000ff) << 8
+                               pango_attr = pango.AttrBackground (r, g, b, 
+                                       attr._start_index, attr._end_index)
+                       elif attr._type == ATTR_TYPE_UNDERLINE:
+                               pango_attr = pango.AttrUnderline (
+                                                                               attr._value,
+                                                                               attr._start_index, attr._end_index)
+                       if pango_attr != None:
+                               self.insert (pango_attr)
+
+
+if __name__ == "__main__":
+       PangoAttrList (None)