Add PropertyShow & PropertyHide methods.
authorHuang Peng <shawn.p.huang@gmail.com>
Tue, 24 Jun 2008 08:41:44 +0000 (16:41 +0800)
committerHuang Peng <shawn.p.huang@gmail.com>
Tue, 24 Jun 2008 08:41:44 +0000 (16:41 +0800)
ibus/interface/iengine.py
ibus/interface/ipanel.py
ibusdaemon/bus.py
ibusdaemon/engine.py
ibusdaemon/inputcontext.py
ibusdaemon/panel.py

index 62cc501..25ccb0a 100644 (file)
@@ -77,6 +77,12 @@ class IEngine (dbus.service.Object):
        @method (in_signature = "si")
        def PropertyActivate (self, prop_name, prop_state): pass
 
+       @method (in_signature = "s")
+       def PropertyShow (self, prop_name): pass
+
+       @method (in_signature = "s")
+       def PropertyHide (self, prop_name): pass
+
        @method ()
        def Destroy (self): pass
 
index 0dfb3dc..5b830a8 100644 (file)
@@ -86,3 +86,10 @@ class IPanel (dbus.service.Object):
 
        @signal ()
        def PropertyActivate (self, prop_name, prop_state): pass
+
+       @signal ()
+       def PropertyShow (self, prop_name): pass
+
+       @signal ()
+       def PropertyHide (self, prop_name): pass
+
index b60a235..ada940e 100644 (file)
@@ -230,6 +230,8 @@ class IBus (ibus.Object):
                self._panel.connect ("cursor-up", self._panel_cursor_up_cb)
                self._panel.connect ("cursor-down", self._panel_cursor_down_cb)
                self._panel.connect ("property-activate", self._panel_property_active_cb)
+               self._panel.connect ("property-show", self._panel_property_show_cb)
+               self._panel.connect ("property-hide", self._panel_property_hide_cb)
                self._panel.connect ("destroy", self._panel_destroy_cb)
 
        def _panel_page_up_cb (self, panel):
@@ -257,6 +259,16 @@ class IBus (ibus.Object):
                if self._focused_context:
                        self._focused_context.property_activate (prop_name, prop_state)
 
+       def _panel_property_show_cb (self, panel, prop_name):
+               assert panel == self._panel
+               if self._focused_context:
+                       self._focused_context.property_show (prop_name)
+
+       def _panel_property_hide_cb (self, panel, prop_name):
+               assert panel == self._panel
+               if self._focused_context:
+                       self._focused_context.property_hide (prop_name)
+
        def _panel_destroy_cb (self, panel):
                if panel == self._panel:
                        self._panel = DummyPanel ()
index d9d32eb..fd44111 100644 (file)
@@ -124,10 +124,10 @@ class Engine (ibus.Object):
 
        def page_down (self):
                self._engine.PageDown (**ibus.DEFAULT_ASYNC_HANDLERS)
-       
+
        def cursor_up (self):
                self._engine.CursorUp (**ibus.DEFAULT_ASYNC_HANDLERS)
-       
+
        def cursor_down (self):
                self._engine.CursorDown (**ibus.DEFAULT_ASYNC_HANDLERS)
 
@@ -135,6 +135,14 @@ class Engine (ibus.Object):
                self._engine.PropertyActivate (prop_name, prop_state,
                                **ibus.DEFAULT_ASYNC_HANDLERS)
 
+       def property_show (self, prop_name):
+               self._engine.PropertyShow (prop_name,
+                               **ibus.DEFAULT_ASYNC_HANDLERS)
+
+       def property_hide (self, prop_name):
+               self._engine.PropertyHide (prop_name,
+                               **ibus.DEFAULT_ASYNC_HANDLERS)
+
        def destroy (self):
                ibus.Object.destroy (self)
                if self._engine:
index 3df443e..02271d2 100644 (file)
@@ -131,6 +131,14 @@ class InputContext (ibus.Object):
                if self._engine:
                        self._engine.property_activate (prop_name, prop_state)
 
+       def property_show (self, prop_name):
+               if self._engine:
+                       self._engine.property_show (prop_name)
+
+       def property_hide (self, prop_name):
+               if self._engine:
+                       self._engine.property_hide (prop_name)
+
        def is_enabled (self):
                return self._enable
 
index 3d39549..526bfc9 100644 (file)
@@ -45,6 +45,14 @@ class Panel (ibus.Object):
                        gobject.SIGNAL_RUN_FIRST,
                        gobject.TYPE_NONE,
                        (gobject.TYPE_STRING, gobject.TYPE_INT)),
+               "property-show" : (
+                       gobject.SIGNAL_RUN_FIRST,
+                       gobject.TYPE_NONE,
+                       (gobject.TYPE_STRING, )),
+               "property-hide" : (
+                       gobject.SIGNAL_RUN_FIRST,
+                       gobject.TYPE_NONE,
+                       (gobject.TYPE_STRING, )),
        }
 
        def __init__ (self, ibusconn, object_path):
@@ -114,6 +122,12 @@ class Panel (ibus.Object):
                elif message.is_signal (ibus.IBUS_PANEL_IFACE, "PropertyActivate"):
                        args = message.get_args_list ()
                        self.emit ("property-activate", args[0], args[1])
+               elif message.is_signal (ibus.IBUS_PANEL_IFACE, "PropertyShow"):
+                       args = message.get_args_list ()
+                       self.emit ("property-show", args[0])
+               elif message.is_signal (ibus.IBUS_PANEL_IFACE, "PropertyHide"):
+                       args = message.get_args_list ()
+                       self.emit ("property-hide", args[0])
                else:
                        return False
                return True