Add method in inputcontext.py to detach signals.
authorPeng Huang <shawn.p.huang@gmail.com>
Thu, 27 Aug 2009 23:19:47 +0000 (07:19 +0800)
committerPeng Huang <shawn.p.huang@gmail.com>
Thu, 27 Aug 2009 23:19:47 +0000 (07:19 +0800)
ibus/inputcontext.py

index ed14992bc20967dfbfdd762b65f0e9c71e5dbf1b..1eaee97d823e11022b9b8ed1da43f14de614c38e 100644 (file)
@@ -116,13 +116,16 @@ class InputContext(object.Object):
         ),
     }
 
-    def __init__(self, bus, path):
+    def __init__(self, bus, path, watch_signals=False):
         super(InputContext, self).__init__()
 
         self.__bus = bus
         self.__context = bus.get_dbusconn().get_object(common.IBUS_SERVICE_IBUS, path)
         self.__signal_matches = []
 
+        if not watch_signals:
+            return
+
         m = self.__context.connect_to_signal("CommitText", self.__commit_text_cb)
         self.__signal_matches.append(m)
         m = self.__context.connect_to_signal("UpdatePreeditText", self.__update_preedit_text_cb)
@@ -212,7 +215,13 @@ class InputContext(object.Object):
         caps = dbus.UInt32(caps)
         return self.__context.SetCapabilities(caps)
 
+    def detach_signals(self):
+        for m in self.__signal_matchs:
+            m.remove()
+        del self.__signal_matchs[:]
+
     def destroy(self):
+        self.detach_signals()
         self.__context.Destroy()
         super(InputContext, self).destroy()
 
@@ -231,6 +240,7 @@ class InputContext(object.Object):
         return self.__context.Introspect()
 
 
+
 def test():
     import gtk
     import gtk.gdk