WIP.
authorHuang Peng <shawn.p.huang@gmail.com>
Wed, 21 May 2008 07:58:47 +0000 (15:58 +0800)
committerHuang Peng <shawn.p.huang@gmail.com>
Wed, 21 May 2008 07:58:47 +0000 (15:58 +0800)
ibus/interface.py
ibusdaemon/bus.py
ibusdaemon/engine.py
ibusdaemon/factorymanager.py
ibusdaemon/panel.py

index 7a5f051..9e1db41 100644 (file)
@@ -129,7 +129,7 @@ class IEngine (dbus.service.Object):
        def ForwardKeyEvent (self, keyval, is_press, state): pass
 
        @signal ()
-       def PreeditStringChanged (self, text, attrs, cursor_pos): pass
+       def PreeditChanged (self, text, attrs, cursor_pos): pass
 
        # below signals are optional. The engine could create and maintain panel by self.
        @signal ()
index dec535a..0db476a 100644 (file)
@@ -6,7 +6,7 @@ from ibus import keysyms
 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):
@@ -14,7 +14,7 @@ class IBus (ibus.Object):
                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
@@ -122,10 +122,18 @@ class IBus (ibus.Object):
        # 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
index 2d2cd39..360dbcb 100644 (file)
@@ -5,13 +5,33 @@ import ibus
 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):
@@ -27,9 +47,32 @@ class Engine (ibus.Object):
                        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
index dc72190..3a1bb1e 100644 (file)
@@ -1,7 +1,7 @@
 import weakref
 import gobject
 import ibus
-from engine import EngineFactory
+from enginefactory import EngineFactory
 
 class FactoryManager (ibus.Object):
        __gsignals__ = {
index fa8df6a..f7182da 100644 (file)
@@ -17,12 +17,12 @@ class Panel (ibus.Object):
                self._lookup_table = lookup_table
 
        def destroy (self):
-               ibus.Object.destroy (self)
                if self._ibusconn != None:
                        self._panel.Destroy ()
 
                self._ibusconn = None
                self._panel = None
+               ibus.Object.destroy (self)
 
        # signal callbacks
        def _ibusconn_destroy_cb (self, ibusconn):
@@ -45,3 +45,5 @@ class Panel (ibus.Object):
        #               if x[1] > y[1]: return True
        #               if x[1] == y[1]: return x[0] > y[0]
 
+class DummyPanel:
+       pass