from clientmanager import ClientManager
from factorymanager import FactoryManager
from connection import Connection
-from panel import panel
+from panel import Panel, DummyPanel
class IBus (ibus.Object):
def __init__ (self):
self._connections = {}
self._client_manager = ClientManager ()
self._factory_manager = FactoryManager ()
- self._panel = None
+ self._panel = DummyPanel ()
self._focused_client = None
self._last_focused_client = None
# methods for panel
##########################################################
def register_panel (self, object_path, replace, dbusconn):
- if self._panel and replace == False:
- raise ibus.Exception ("has a panel!")
+ if not isinstance (self._panel, DummyPanel) and replace == False:
+ raise ibus.Exception ("has have a panel!")
+ if not isinstance (self._panel, DummyPanel):
+ self._panel.destroy ()
ibusconn = self._lookup_ibus_connection (dbusconn)
- self._panel = Panel (object_path, ibusconn)
+ self._panel = Panel (ibusconn, object_path)
+ self._panel.connect ("destroy", self._panel_destroy_cb)
+
+
+ def _panel_destroy_cb (self, panel):
+ if panel == self._panel:
+ self._panel = DummyPanel ()
class IBusProxy (ibus.IIBus):
SUPPORTS_MULTIPLE_CONNECTIONS = True
class Engine (ibus.Object):
__gsignals__ = {
"commit-string" : (
- gobject.SIGNAL_RUN_FIRST,
+ gobject.SIGNAL_RUN_FIRST,
gobject.TYPE_NONE,
(gobject.TYPE_STRING, )),
+ "forward-key-event" : (
+ gobject.SIGNAL_RUN_FIRST,
+ gobject.TYPE_NONE,
+ (gobject.TYPE_UINT, gobject.TYPE_UINT, gobject.TYPE_UINT )),
"preedit-changed" : (
- gobject.SIGNAL_RUN_FIRST,
+ gobject.SIGNAL_RUN_FIRST,
+ gobject.TYPE_NONE,
+ (gobject.TYPE_STRING, gobject.TYPE_PYOBJECT, gobject.TYPE_UINT)),
+ "aux-string-changed" : (
+ gobject.SIGNAL_RUN_FIRST,
+ gobject.TYPE_NONE,
+ (gobject.TYPE_STRING, gobject.TYPE_PYOBJECT)),
+ "update-lookup-table" : (
+ gobject.SIGNAL_RUN_FIRST,
+ gobject.TYPE_NONE,
+ (gobject.TYPE_PYOBJECT, )),
+ "show-lookup-table" : (
+ gobject.SIGNAL_RUN_FIRST,
gobject.TYPE_NONE,
- (gobject.TYPE_STRING, gobject.TYPE_PYOBJECT, gobject.TYPE_UINT))
+ ()),
+ "hide-lookup-table" : (
+ gobject.SIGNAL_RUN_FIRST,
+ gobject.TYPE_NONE,
+ ())
}
def __init__ (self, ibusconn, object_path):
args = message.get_args_list ()
self.emit ("commit-string", args[0])
return True
+ elif message.is_signal (ibus.IBUS_ENGINE_IFACE, "ForwardKeyEvent"):
+ args = message.get_args_list ()
+ self.emit ("forward-key-event", args[0], arg[1], arg[2])
+ return True
elif message.is_signal (ibus.IBUS_ENGINE_IFACE, "PreeditChanged"):
args = message.get_args_list ()
- self.emit ("preedit-changed", args[0], args[1], args[2])
+ attrs = ibus.attr_list_from_dbus_value (args[1])
+ self.emit ("preedit-changed", args[0], attrs, args[2])
+ return True
+ elif message.is_signal (ibus.IBUS_ENGINE_IFACE, "AuxStringChanged"):
+ args = message.get_args_list ()
+ attrs = ibus.attr_list_from_dbus_value (args[1])
+ self.emit ("aux-string-changed", args[0], attrs)
+ return True
+ elif message.is_signal (ibus.IBUS_ENGINE_IFACE, "UpdateLookupTable"):
+ args = message.get_args_list ()
+ lookup_table = ibus.lookup_table_from_dbus_value (args[0])
+ self.emit ("update-lookup-table", lookup_table)
+ return True
+ elif message.is_signal (ibus.IBUS_ENGINE_IFACE, "ShowLookupTable"):
+ args = message.get_args_list ()
+ self.emit ("show-lookup-table")
+ return True
+ elif message.is_signal (ibus.IBUS_ENGINE_IFACE, "HideLookupTable"):
+ args = message.get_args_list ()
+ self.emit ("hide-lookup-table")
return True
else:
return False