[caribou] Separate event registering in methods while creating the window.



commit 07a79a29d9c38235bc8c80ee7ee2240751e14c39
Author: David Pellicer <davidpellicermartin gmail com>
Date:   Mon Jul 19 11:47:35 2010 -0700

    Separate event registering in methods while creating the window.

 caribou/ui/main.py |   15 ++++++++++++++-
 1 files changed, 14 insertions(+), 1 deletions(-)
---
diff --git a/caribou/ui/main.py b/caribou/ui/main.py
index 81d41f2..3c70bb3 100644
--- a/caribou/ui/main.py
+++ b/caribou/ui/main.py
@@ -7,6 +7,7 @@ import signal
 from window import CaribouWindowEntry
 from keyboard import CaribouKeyboard
 from caribou.ui.i18n import _
+import caribou.common.const as const
 
 debug = False
 
@@ -18,6 +19,10 @@ class Caribou:
             raise Exception, "AT-SPI 1 or 2 needs to be enabled."
         self.__current_acc = None
         self.window = window_factory(kb_factory())
+        self._register_events()
+        signal.signal(signal.SIGINT, self.signal_handler)
+
+    def _register_events(self):
         pyatspi.Registry.registerEventListener(
             self.on_focus, "object:state-changed:focused")
         pyatspi.Registry.registerEventListener(self.on_focus, "focus")
@@ -25,7 +30,15 @@ class Caribou:
             self.on_text_caret_moved, "object:text-caret-moved")
         pyatspi.Registry.registerKeystrokeListener(
             self.on_key_down, mask=None, kind=(pyatspi.KEY_PRESSED_EVENT,))
-        signal.signal(signal.SIGINT, self.signal_handler)
+
+    def _deregister_events(self):
+        pyatspi.Registry.deregisterEventListener(
+            self.on_focus, "object:state-changed:focused")
+        pyatspi.Registry.deregisterEventListener(self.on_focus, "focus")
+        pyatspi.Registry.deregisterEventListener(
+            self.on_text_caret_moved, "object:text-caret-moved")
+        pyatspi.Registry.deregisterKeystrokeListener(
+            self.on_key_down, mask=None, kind=(pyatspi.KEY_PRESSED_EVENT,))
 
     def _get_a11y_enabled(self):
         try:



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]