summaryrefslogtreecommitdiff
path: root/caribou/ui
diff options
context:
space:
mode:
authorEitan Isaacson <eitan@monotonous.org>2010-06-16 09:06:30 -0700
committerEitan Isaacson <eitan@monotonous.org>2010-06-16 09:13:06 -0700
commit6e45a8d17495f3ade0c57cb74d3ff9b942ec1c60 (patch)
tree507f6787f886b47d4e3bea963fe571881e2fa585 /caribou/ui
parenta8b8762021c41e31263401a909f54e1ffbe4af37 (diff)
downloadcaribou-6e45a8d17495f3ade0c57cb74d3ff9b942ec1c60.tar.gz
Unpress modifier when Caribou quites (bug #621596). Thanks Daniel Baeyens!
Diffstat (limited to 'caribou/ui')
-rw-r--r--caribou/ui/main.py64
1 files changed, 37 insertions, 27 deletions
diff --git a/caribou/ui/main.py b/caribou/ui/main.py
index 0cf8fe3..81d41f2 100644
--- a/caribou/ui/main.py
+++ b/caribou/ui/main.py
@@ -2,6 +2,8 @@ import gtk.gdk as gdk
import pyatspi
import gconf
import gtk
+import signal
+
from window import CaribouWindowEntry
from keyboard import CaribouKeyboard
from caribou.ui.i18n import _
@@ -23,6 +25,7 @@ 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 _get_a11y_enabled(self):
try:
@@ -116,30 +119,37 @@ class Caribou:
# TODO: implement keyboard scanning
pass
elif event.event_string == "Control_R":
- if debug == True:
- print "quitting ..."
- result = pyatspi.Registry.deregisterEventListener(self.on_text_caret_moved, "object:text-caret-moved")
- if debug == True:
- print "deregisterEventListener - object:text-caret-moved ...",
- if result == False:
- print "OK"
- else:
- print "FAIL"
- result = pyatspi.Registry.deregisterEventListener(self.on_focus, "object:state-changed:focused")
- if debug == True:
- print "deregisterEventListener - object:state-changed:focused ...",
- if result == False:
- print "OK"
- else:
- print "FAIL"
- result = pyatspi.Registry.deregisterEventListener(self.on_focus, "focus")
- if debug == True:
- print "deregisterEventListener - focus ...",
- if result == False:
- print "OK"
- else:
- print "FAIL"
- result = pyatspi.Registry.deregisterKeystrokeListener(self.on_key_down, mask=None, kind=(pyatspi.KEY_PRESSED_EVENT,))
- if debug == True:
- print "deregisterKeystrokeListener"
- gtk.main_quit()
+ self.clean_exit()
+
+ def signal_handler(self,signal,frame):
+ # Clean exit pressing Control + C
+ self.clean_exit()
+
+ def clean_exit(self):
+ if debug == True:
+ print "quitting ..."
+ result = pyatspi.Registry.deregisterEventListener(self.on_text_caret_moved, "object:text-caret-moved")
+ if debug == True:
+ print "deregisterEventListener - object:text-caret-moved ...",
+ if result == False:
+ print "OK"
+ else:
+ print "FAIL"
+ result = pyatspi.Registry.deregisterEventListener(self.on_focus, "object:state-changed:focused")
+ if debug == True:
+ print "deregisterEventListener - object:state-changed:focused ...",
+ if result == False:
+ print "OK"
+ else:
+ print "FAIL"
+ result = pyatspi.Registry.deregisterEventListener(self.on_focus, "focus")
+ if debug == True:
+ print "deregisterEventListener - focus ...",
+ if result == False:
+ print "OK"
+ else:
+ print "FAIL"
+ result = pyatspi.Registry.deregisterKeystrokeListener(self.on_key_down, mask=None, kind=(pyatspi.KEY_PRESSED_EVENT,))
+ if debug == True:
+ print "deregisterKeystrokeListener"
+ gtk.main_quit()