def set_correct_ibus_trigger_keys(self): """Set the correct keys to trigger IBus. This method configures the ibus trigger keys inside gconf, and also sets self.activate_binding and self.activate_release_binding. This method adds a cleanUp to reset the old keys once the test is done. """ bus = get_ibus_bus() config = bus.get_config() variant = config.get_value('general/hotkey', 'triggers') shortcuts = [] # If none, assume default if variant != None: shortcuts = variant.unpack() else: shortcuts = ['<Super>space'] # IBus uses the format '<mod><mod><mod>key' # Autopilot uses the format 'mod+mod+mod+key' # replace all > with a +, and ignore the < char shortcut = "" for c in shortcuts[0]: if c == '>': shortcut += '+' elif c != '<': shortcut += c self.activate_binding = shortcut activate_release_binding_option = 'Alt+Release+Control_L' self.activate_release_binding = 'Alt+Control_L'
def try_ibus_query(self): """This helper method tries to query ibus, and if it has connection problems, it restarts the ibus connection. It is to be used in a loop until it returns True, which means we probably got a proper result - stored in self.result """ self.result = None try: self._ibus_query = IBusQuery() except: # Here is a tricky situation. Probably for some reason the ibus connection # got busted. In this case, restarting the connection from IBusQuery is not # enough. We have to restart the global ibus connection to be sure self._ibus_query = None get_ibus_bus() return False self.result = self._ibus_query.poll(self.engine_name, self.input) return self.result is not None
def tearDownClass(cls): if cls._old_engines is not None: set_active_engines(cls._old_engines) bus = get_ibus_bus() bus.exit(restart=True)