Пример #1
0
 def test_getIbusBus_ReturnsBus(self, MockIbusBusClass):
     # Setup
     mock_ibusBusInstance = MockIbusBusClass.return_value
     # Execute/Verify
     self.assertIsNotNone(get_ibus_bus())
     self.assertTrue(MockIbusBusClass.called, "IBus.Bus called")
     self.assertFalse(mock_ibusBusInstance.destroy.called)
Пример #2
0
 def test_getIbusBus_NotConnected_ReturnsNone(self, MockIbusBusClass):
     # Setup
     mock_ibusBusInstance = MockIbusBusClass.return_value
     mock_ibusBusInstance.is_connected.return_value = False
     # Execute/Verify
     self.assertIsNone(get_ibus_bus())
     self.assertTrue(mock_ibusBusInstance.is_connected.called)
     self.assertTrue(MockIbusBusClass.called, "IBus.Bus called")
     self.assertTrue(mock_ibusBusInstance.destroy.called)
Пример #3
0
def uninstall_keyboards_from_ibus(keyboards, packageDir):
    bus = get_ibus_bus()
    if bus:
        # install all kmx for first lang not just packageID
        for kb in keyboards:
            ibus_keyboard_id = get_ibus_keyboard_id(kb, packageDir)
            uninstall_from_ibus(bus, ibus_keyboard_id)
        restart_ibus(bus)
    else:
        logging.warning("could not uninstall keyboards from IBus")
Пример #4
0
def install_keyboards_to_ibus(keyboards, packageDir, language=None):
    bus = get_ibus_bus()
    if bus:
        # install all kmx for first lang not just packageID
        for kb in keyboards:
            ibus_keyboard_id = get_ibus_keyboard_id(kb, packageDir, language)
            install_to_ibus(bus, ibus_keyboard_id)
        restart_ibus(bus)
        bus.destroy()
    else:
        logging.debug("could not install keyboards to IBus")
Пример #5
0
def uninstall_keyboards_from_ibus(keyboards, packageDir):
		bus = get_ibus_bus()
		if bus:
			# install all kmx for first lang not just packageID
			for kb in keyboards:
				kmx_file = os.path.join(packageDir, kb['id'] + ".kmx")
				if "languages" in kb and len(kb["languages"]) > 0:
					logging.debug(kb["languages"][0])
					keyboard_id = "%s:%s" % (kb["languages"][0]['id'], kmx_file)
				else:
					keyboard_id = kmx_file
				uninstall_from_ibus(bus, keyboard_id)
			restart_ibus(bus)
		else:
			logging.warning("could not uninstall keyboards from IBus")
Пример #6
0
def uninstall_keyboards_from_ibus(keyboards, packageDir):
    bus = get_ibus_bus()
    if bus:
        # install all kmx for first lang not just packageID
        for kb in keyboards:
            kmx_file = os.path.join(packageDir, kb['id'] + ".kmx")
            if "languages" in kb and len(kb["languages"]) > 0:
                logging.debug(kb["languages"][0])
                keyboard_id = "%s:%s" % (kb["languages"][0]['id'], kmx_file)
            else:
                keyboard_id = kmx_file
            uninstall_from_ibus(bus, keyboard_id)
        restart_ibus(bus)
    else:
        logging.warning("could not uninstall keyboards from IBus")