diff options
-rw-r--r-- | ibus/attribute.py | 41 | ||||
-rw-r--r-- | ibus/gtk.py | 24 |
2 files changed, 41 insertions, 24 deletions
diff --git a/ibus/attribute.py b/ibus/attribute.py index 5aac6b2..31f3240 100644 --- a/ibus/attribute.py +++ b/ibus/attribute.py @@ -50,16 +50,33 @@ ATTR_UNDERLINE_LOW = 3 class Attribute: def __init__ (self, type, value, start_index, end_index): - self._type = type - self._value = value - self._start_index = start_index - self._end_index = end_index + self.__type = type + self.__value = value + self.__start_index = start_index + self.__end_index = end_index + + def get_type(self): + return self.__type + + def get_value(self): + return self.__value + + def get_start_index(self): + return self.__start_index + + def get_end_index(self): + return self.__end_index + + type = property(get_type) + value = property(get_value) + start_index = property(get_start_index) + end_index = property(get_end_index) def to_dbus_value (self): - values = [dbus.UInt32 (self._type), - dbus.UInt32 (self._value), - dbus.UInt32 (self._start_index), - dbus.UInt32 (self._end_index)] + values = [dbus.UInt32 (self.__type), + dbus.UInt32 (self.__value), + dbus.UInt32 (self.__start_index), + dbus.UInt32 (self.__end_index)] return dbus.Array (values, signature="u") def from_dbus_value (self, value): @@ -69,10 +86,10 @@ class Attribute: if len (value) != 4 or not all (map (lambda x: isinstance (x, dbus.UInt32), value)): raise dbus.Exception ("Attribute must be dbus.Array (uuuu)") - self._type = value[0] - self._value = value[1] - self._start_index = value[2] - self._end_index = value[3] + self.__type = value[0] + self.__value = value[1] + self.__start_index = value[2] + self.__end_index = value[3] def attribute_from_dbus_value (value): attribute = Attribute (0, 0, 0, 0) diff --git a/ibus/gtk.py b/ibus/gtk.py index b70eb35..eb82929 100644 --- a/ibus/gtk.py +++ b/ibus/gtk.py @@ -39,24 +39,24 @@ class PangoAttrList(pango.AttrList): offsets.append(offset) for attr in attrs: pango_attr = None - start_index = attr._start_index if attr._start_index >= 0 else 0 - end_index = attr._end_index if attr._end_index >= 0 else 0 + start_index = attr.start_index if attr.start_index >= 0 else 0 + end_index = attr.end_index if attr.end_index >= 0 else 0 start_index = offsets[start_index] if start_index < len(offsets) else offsets[-1] end_index = offsets[end_index] if end_index < len(offsets) else offsets[-1] - if attr._type == ibus.ATTR_TYPE_FOREGROUND: - r = (attr._value & 0x00ff0000) >> 8 - g = (attr._value & 0x0000ff00) - b = (attr._value & 0x000000ff) << 8 + if attr.type == ibus.ATTR_TYPE_FOREGROUND: + r = (attr.value & 0x00ff0000) >> 8 + g = (attr.value & 0x0000ff00) + b = (attr.value & 0x000000ff) << 8 pango_attr = pango.AttrForeground(r, g, b, start_index, end_index) - elif attr._type == ibus.ATTR_TYPE_BACKGROUND: - r = (attr._value & 0x00ff0000) >> 8 - g = (attr._value & 0x0000ff00) - b = (attr._value & 0x000000ff) << 8 + elif attr.type == ibus.ATTR_TYPE_BACKGROUND: + r = (attr.value & 0x00ff0000) >> 8 + g = (attr.value & 0x0000ff00) + b = (attr.value & 0x000000ff) << 8 pango_attr = pango.AttrBackground(r, g, b, start_index, end_index) - elif attr._type == ibus.ATTR_TYPE_UNDERLINE: - pango_attr = pango.AttrUnderline(int(attr._value), + elif attr.type == ibus.ATTR_TYPE_UNDERLINE: + pango_attr = pango.AttrUnderline(int(attr.value), start_index, end_index) if pango_attr != None: self.insert(pango_attr) |