Merge lp:~thomir-deactivatedaccount/autopilot/fix-ibus into lp:autopilot

Proposed by Thomi Richards
Status: Merged
Approved by: Brandon Schaefer
Approved revision: 107
Merged at revision: 98
Proposed branch: lp:~thomir-deactivatedaccount/autopilot/fix-ibus
Merge into: lp:autopilot
Diff against target: 140 lines (+26/-45)
3 files modified
autopilot/emulators/ibus.py (+25/-44)
debian/changelog (+1/-0)
debian/control (+0/-1)
To merge this branch: bzr merge lp:~thomir-deactivatedaccount/autopilot/fix-ibus
Reviewer Review Type Date Requested Status
PS Jenkins bot continuous-integration Approve
Brandon Schaefer (community) Approve
Łukasz Zemczak Approve
Review via email: mp+135009@code.launchpad.net

Commit message

Make autopilot use gir IBus module, instead of older python-ibus module.

Description of the change

Problem:

Autopilot still used the 'ibus' module, which in turn imported 'gobject', which should not be imported together with 'gi.repository.GObject', which we're using elsewhere in autopilot.

Solution:

The solution is to convert autopilot to use the gi.repository.IBus module.

To post a comment you must log in.
93. By Thomi Richards

Fixed error in debian/control

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
94. By Thomi Richards

Fix get_name issue.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
95. By Thomi Richards

Fix another place where config setting API changed.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
96. By Thomi Richards

Perhaps you don't need to restart the bus anymore?

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
97. By Thomi Richards

Removed unused method from the ibus emulator module.:

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Łukasz Zemczak (sil2100) wrote :

Looks and works fine. +1. Not approving globally to fix failing ibus tests first.

review: Approve
98. By Thomi Richards

re-introduce daemon restart.

99. By Thomi Richards

Wait until the new bus is connected.

100. By Thomi Richards

Kill the daemon if we can't connect after 10 seconds.

101. By Thomi Richards

bug fix.

102. By Thomi Richards

Try caching the bus object.

103. By Thomi Richards

Don't call .new() on IBus.Bus to create a new Bus object.

104. By Thomi Richards

Steal code from upstream to start the bus.

105. By Thomi Richards

Fixed bug.

106. By Thomi Richards

Small cleanup.

107. By Thomi Richards

whitespace cleanup.

Revision history for this message
Brandon Schaefer (brandontschaefer) wrote :

Sweet, fixes it for me unity side :). (And changes look good!)

review: Approve
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'autopilot/emulators/ibus.py'
2--- autopilot/emulators/ibus.py 2012-10-26 13:34:34 +0000
3+++ autopilot/emulators/ibus.py 2012-11-21 00:53:22 +0000
4@@ -10,13 +10,11 @@
5
6 from __future__ import absolute_import
7
8-import ibus
9-import ibus.common
10+from gi.repository import IBus, GLib
11 import os
12 import logging
13 import subprocess
14 from gi.repository import GConf
15-from time import sleep
16
17
18 logger = logging.getLogger(__name__)
19@@ -29,27 +27,35 @@
20 :raises: **RuntimeError** in the case of ibus-daemon being unavailable.
21
22 """
23- max_tries = 5
24- for i in range(max_tries):
25- if ibus.common.get_address() is None:
26- pid = os.spawnlp(os.P_NOWAIT, "ibus-daemon", "ibus-daemon", "-d", "--xim")
27- logger.info("Started ibus-daemon with pid %i." % (pid))
28- sleep(2)
29- else:
30- return ibus.Bus()
31- raise RuntimeError("Could not start ibus-daemon after %d tries." % (max_tries))
32+ bus = IBus.Bus()
33+ if bus.is_connected():
34+ return bus
35+
36+ main_loop = GLib.MainLoop()
37+
38+ timeout = 5
39+ GLib.timeout_add_seconds(timeout, lambda *args: main_loop.quit())
40+ bus.connect("connected", lambda *args: main_loop.quit())
41+
42+ os.spawnlp(os.P_NOWAIT, "ibus-daemon", "ibus-daemon", "--xim")
43+
44+ main_loop.run()
45+
46+ if not bus.is_connected():
47+ raise RuntimeError("Could not start ibus-daemon after %d seconds." % (timeout))
48+ return bus
49
50
51 def get_available_input_engines():
52 """Get a list of available input engines."""
53 bus = get_ibus_bus()
54- return [e.name for e in bus.list_engines()]
55+ return [e.get_name() for e in bus.list_engines()]
56
57
58 def get_active_input_engines():
59 """Get the list of input engines that have been activated."""
60 bus = get_ibus_bus()
61- return [e.name for e in bus.list_active_engines()]
62+ return [e.get_name() for e in bus.list_active_engines()]
63
64
65 def set_active_engines(engine_list):
66@@ -85,45 +91,20 @@
67
68 config.set_value("general",
69 "preload_engine_mode",
70- ibus.common.PRELOAD_ENGINE_MODE_USER)
71+ GLib.Variant.new_int32(IBus.PreloadEngineMode.USER))
72
73 old_engines = get_active_input_engines()
74- config.set_list("general", "preload_engines", engine_list, "s")
75+ config.set_value("general",
76+ "preload_engines",
77+ GLib.Variant("as", engine_list)
78+ )
79 # need to restart the ibus bus before it'll pick up the new engine.
80 # see bug report here:
81 # http://code.google.com/p/ibus/issues/detail?id=1418&thanks=1418&ts=1329885137
82 bus.exit(restart=True)
83- sleep(1)
84 return old_engines
85
86
87-def set_global_input_engine(engine_name):
88- """Set the global iBus input engine by name.
89-
90- This function enables the global input engine. To turn it off again, pass None
91- as the engine name.
92-
93- :raises: **TypeError** on invalid *engine_name* parameter.
94- :raises: **ValueError** when *engine_name* is an unknown engine.
95-
96- """
97- if not (engine_name is None or isinstance(engine_name, basestring)):
98- raise TypeError("engine_name type must be either str or None.")
99-
100- bus = get_ibus_bus()
101-
102- if engine_name:
103- available_engines = get_available_input_engines()
104- if not engine_name in available_engines:
105- raise ValueError("Unknown engine '%s'" % (engine_name))
106- bus.get_config().set_value("general", "use_global_engine", True)
107- bus.set_global_engine(engine_name)
108- logger.info('Enabling global ibus engine "%s".' % (engine_name))
109- else:
110- bus.get_config().set_value("general", "use_global_engine", False)
111- logger.info('Disabling global ibus engine.')
112-
113-
114 def set_gconf_option(path, value):
115 """Set the gconf setting on `path` to the defined `value`"""
116 _set_gconf_list (path, value)
117
118=== modified file 'debian/changelog'
119--- debian/changelog 2012-11-01 14:38:33 +0000
120+++ debian/changelog 2012-11-21 00:53:22 +0000
121@@ -6,6 +6,7 @@
122
123 [ Thomi Richards ]
124 * Build sphinx documentation and package it in python-autopilot.
125+ * Change autopilot to use gir IBus module (lp: #1078917).
126
127 -- Didier Roche <didrocks@ubuntu.com> Fri, 28 Sep 2012 08:40:21 +0200
128
129
130=== modified file 'debian/control'
131--- debian/control 2012-11-15 06:59:42 +0000
132+++ debian/control 2012-11-21 00:53:22 +0000
133@@ -20,7 +20,6 @@
134 gir1.2-ibus-1.0,
135 python-compizconfig,
136 python-dbus,
137- python-ibus,
138 python-junitxml,
139 python-qt4,
140 python-testscenarios,

Subscribers

People subscribed via source and target branches