diff options
| author | Huang Peng <shawn.p.huang@gmail.com> | 2008-05-19 22:14:16 +0800 |
|---|---|---|
| committer | Huang Peng <shawn.p.huang@gmail.com> | 2008-05-19 22:14:16 +0800 |
| commit | f3bbca058655c155758519064b16372e6589d2e6 (patch) | |
| tree | 688198d0d119383f6c547c22c8d93652daead53f /ibus/attribute.py | |
| parent | 82b3002e5860094118c43ecb390a2bf9497fe1fc (diff) | |
| download | ibus-f3bbca058655c155758519064b16372e6589d2e6.tar.gz ibus-f3bbca058655c155758519064b16372e6589d2e6.tar.xz ibus-f3bbca058655c155758519064b16372e6589d2e6.zip | |
WIP.
Diffstat (limited to 'ibus/attribute.py')
| -rw-r--r-- | ibus/attribute.py | 26 |
1 files changed, 17 insertions, 9 deletions
diff --git a/ibus/attribute.py b/ibus/attribute.py index 35a78bc..2840619 100644 --- a/ibus/attribute.py +++ b/ibus/attribute.py @@ -17,24 +17,28 @@ class Attribute: self._end_index = end_index def to_dbus_value (self): - values = (dbus.UInt32 (self._type), + values = [dbus.UInt32 (self._type), dbus.UInt32 (self._value), dbus.UInt32 (self._start_index), - dbus.UInt32 (self._end_index)) - return dbus.Struct (values) + dbus.UInt32 (self._end_index)] + return dbus.Array (values) def from_dbus_value (self, value): - if not isinstance (value, dbus.Struct): - raise dbus.Exception ("Attribute must be dbus.Struct (uuuu)") + if not isinstance (value, dbus.Array): + raise dbus.Exception ("Attribute must be dbus.Array (uuuu)") if len (value) != 4 or not all (map (lambda x: isinstance (x, dbus.UInt32), value)): - raise dbus.Exception ("Attribute must be dbus.Struct (uuuu)") + 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] - + +def attribute_from_dbus_value (value): + attribute = Attribute (0, 0, 0, 0) + attribute.from_dbus_value (value) + return attribute class AttributeDecoration (Attribute): def __init__(self, value, start_index, end_index): @@ -77,8 +81,12 @@ class AttrList: raise IBusException ("AttrList must from dbus.Array (iiii)") for v in value: - attr = Attribute (0, 0, 0, 0) - attr.from_dbus_value (v) + attr = attribute_from_dbus_value (v) attrs.append (attr) self._attrs = attrs + +def attr_list_from_dbus_value (value): + attrs = AttrList () + attrs.from_dbus_value (value) + return attrs |
