Commit 9fd4cf74 authored by Mathieu Bridon's avatar Mathieu Bridon

Fallback to the IBus.Property.new() constructor

IBus 1.5.x introduced some very nice GI overrides for its classes, which
make the API much more Python-friendly.

I had refrained from using them though, because I wanted to keep the
compatibility with Python 1.4.2 as it is still used on (at least) Ubuntu
13.04 and Debian Sid.

However, when I worked on the IBus.Property stuff, I didn't pay enough
attention and used the overridden constructor, which doesn't exist on
IBus 1.4.2.

This fixes issue #23.
parent 756f8c5d
......@@ -70,15 +70,27 @@ class Engine(IBus.Engine):
stored_value = self.config.read(key)
state = IBus.PropState.CHECKED if stored_value else IBus.PropState.UNCHECKED
prop = IBus.Property(key=key,
prop_type=IBus.PropType.TOGGLE,
label=IBus.Text.new_from_string(p["label"]),
symbol=IBus.Text.new_from_string(""),
icon='',
sensitive=True,
visible=True,
state=state,
sub_props=None)
try:
# Try the new constructor from IBus >= 1.5
prop = IBus.Property(key=key,
prop_type=IBus.PropType.TOGGLE,
label=IBus.Text.new_from_string(p["label"]),
symbol=IBus.Text.new_from_string(""),
icon='',
sensitive=True,
visible=True,
state=state,
sub_props=None)
except TypeError:
# IBus 1.4.x didn't have the GI overrides for the nice
# constructor, so let's do it the old, non-pythonic way.
# IBus.Property.new(key, type, label, icon, tooltip,
# sensitive, visible, state, sub_props)
prop = IBus.Property.new(key, IBus.PropType.TOGGLE,
IBus.Text.new_from_string(p["label"]),
'', IBus.Text.new_from_string(''),
True, True, state, None)
self.prop_list.append(prop)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment