orca r3496 - in trunk: . src/orca src/orca/scripts



Author: richb
Date: Thu Jan 24 17:40:12 2008
New Revision: 3496
URL: http://svn.gnome.org/viewvc/orca?rev=3496&view=rev

Log:
        * src/orca/scripts/gnome-terminal.py:
          src/orca/orca.py:
          src/orca/script.py:
          Fix for bug #511447 â Orca speaks passwords when they are 
          been typed.


Modified:
   trunk/ChangeLog
   trunk/src/orca/orca.py
   trunk/src/orca/script.py
   trunk/src/orca/scripts/gnome-terminal.py

Modified: trunk/src/orca/orca.py
==============================================================================
--- trunk/src/orca/orca.py	(original)
+++ trunk/src/orca/orca.py	Thu Jan 24 17:40:12 2008
@@ -316,7 +316,7 @@
 #
 _orcaModifierPressed = False
 
-def _isPrintableKey(event_string):
+def isPrintableKey(event_string):
     """Return an indication of whether this is an alphanumeric or
        punctuation key.
 
@@ -334,10 +334,10 @@
                 and (unicodeString.isalnum() or unicodeString.isspace()
                 or unicodedata.category(unicodeString)[0] in ('P', 'S'))
     debug.println(debug.LEVEL_FINEST,
-                  "orca._isPrintableKey: returning: %s" % reply)
+                  "orca.isPrintableKey: returning: %s" % reply)
     return reply
 
-def _isModifierKey(event_string):
+def isModifierKey(event_string):
     """Return an indication of whether this is a modifier key.
 
     Arguments:
@@ -352,10 +352,10 @@
 
     reply = event_string in modifierKeys
     debug.println(debug.LEVEL_FINEST,
-                  "orca._isModifierKey: returning: %s" % reply)
+                  "orca.isModifierKey: returning: %s" % reply)
     return reply
 
-def _isLockingKey(event_string):
+def isLockingKey(event_string):
     """Return an indication of whether this is a locking key.
 
     Arguments:
@@ -369,10 +369,10 @@
     reply = event_string in lockingKeys \
             and not event_string in settings.orcaModifierKeys
     debug.println(debug.LEVEL_FINEST,
-                  "orca._isLockingKey: returning: %s" % reply)
+                  "orca.isLockingKey: returning: %s" % reply)
     return reply
 
-def _isFunctionKey(event_string):
+def isFunctionKey(event_string):
     """Return an indication of whether this is a function key.
 
     Arguments:
@@ -390,10 +390,10 @@
 
     reply = event_string in functionKeys
     debug.println(debug.LEVEL_FINEST,
-                  "orca._isFunctionKey: returning: %s" % reply)
+                  "orca.isFunctionKey: returning: %s" % reply)
     return reply
 
-def _isActionKey(event_string):
+def isActionKey(event_string):
     """Return an indication of whether this is an action key.
 
     Arguments:
@@ -407,10 +407,10 @@
 
     reply = event_string in actionKeys
     debug.println(debug.LEVEL_FINEST,
-                  "orca._isActionKey: returning: %s" % reply)
+                  "orca.isActionKey: returning: %s" % reply)
     return reply
 
-def _isNavigationKey(event_string):
+def isNavigationKey(event_string):
     """Return an indication of whether this is a navigation (arrow) key
     or if the user has the Orca modifier key held done.
 
@@ -426,7 +426,7 @@
     reply = (event_string in navigationKeys) or _orcaModifierPressed
 
     debug.println(debug.LEVEL_FINEST,
-                  "orca._isNavigationKey: returning: %s" % reply)
+                  "orca.isNavigationKey: returning: %s" % reply)
     return reply
 
 class KeyEventType:
@@ -459,7 +459,7 @@
     def __init__(self):
         pass
 
-def _keyEcho(event):
+def keyEcho(event):
     """If the keyEcho setting is enabled, check to see what type of key
     event it is and echo it via speech, if the user wants that type of
     key echoed.
@@ -480,7 +480,7 @@
 
     event_string = event.event_string
     debug.println(debug.LEVEL_FINEST,
-                  "orca._keyEcho: string to echo: %s" % event_string)
+                  "orca.keyEcho: string to echo: %s" % event_string)
 
     # If key echo is enabled, then check to see what type of key event
     # it is and echo it via speech, if the user wants that type of key
@@ -488,22 +488,22 @@
     #
     if settings.enableKeyEcho:
 
-        if _isModifierKey(event_string):
+        if isModifierKey(event_string):
             if not settings.enableModifierKeys:
                 return
             eventType = KeyEventType.MODIFIER
 
-        elif _isNavigationKey(event_string):
+        elif isNavigationKey(event_string):
             if not settings.enableNavigationKeys:
                 return
             eventType = KeyEventType.NAVIGATION
 
-        elif _isPrintableKey(event_string):
+        elif isPrintableKey(event_string):
             if not settings.enablePrintableKeys:
                 return
             eventType = KeyEventType.PRINTABLE
 
-        elif _isLockingKey(event_string):
+        elif isLockingKey(event_string):
             if not settings.enableLockingKeys:
                 return
             eventType = KeyEventType.LOCKING
@@ -528,23 +528,23 @@
                 #    eventType = KeyEventType.LOCKING_LOCKED
                 pass
 
-        elif _isFunctionKey(event_string):
+        elif isFunctionKey(event_string):
             if not settings.enableFunctionKeys:
                 return
             eventType = KeyEventType.FUNCTION
 
-        elif _isActionKey(event_string):
+        elif isActionKey(event_string):
             if not settings.enableActionKeys:
                 return
             eventType = KeyEventType.ACTION
 
         else:
             debug.println(debug.LEVEL_FINEST,
-                  "orca._keyEcho: event string not handled: %s" % event_string)
+                  "orca.keyEcho: event string not handled: %s" % event_string)
             return
 
         debug.println(debug.LEVEL_FINEST,
-                      "orca._keyEcho: speaking: %s" % event_string)
+                      "orca.keyEcho: speaking: %s" % event_string)
 
         # We keep track of the time as means to let others know that
         # we are probably echoing a key and should not be interrupted.
@@ -559,8 +559,8 @@
     """
 
     if event.type == 0:
-        if _isModifierKey(event.event_string) \
-           or _isLockingKey(event.event_string):
+        if isModifierKey(event.event_string) \
+           or isLockingKey(event.event_string):
             return True
         else:
             # We want to capture this event, after first doing a little
@@ -667,8 +667,9 @@
 
         # If learn mode is enabled, it will echo the keys.
         #
-        if not settings.learnModeEnabled:
-            _keyEcho(keyboardEvent)
+        if not settings.learnModeEnabled and \
+           orca_state.activeScript.echoKey(keyboardEvent):
+            keyEcho(keyboardEvent)
 
     elif isOrcaModifier \
         and (keyboardEvent.type == pyatspi.KEY_RELEASED_EVENT):
@@ -720,7 +721,7 @@
     # has been pressed, and we might get the key events in different orders.
     # See comment #15 of bug #435201 for more details.
     #
-    if not _isModifierKey(keyboardEvent.event_string):
+    if not isModifierKey(keyboardEvent.event_string):
         orca_state.lastNonModifierKeyEvent = keyboardEvent
 
     return consumed or isOrcaModifier

Modified: trunk/src/orca/script.py
==============================================================================
--- trunk/src/orca/script.py	(original)
+++ trunk/src/orca/script.py	Thu Jan 24 17:40:12 2008
@@ -189,6 +189,21 @@
         """
         return where_am_I.WhereAmI(self)
     
+    def echoKey(self, keyEvent):
+        """Determine whether this script should echo the current key event.
+        Note that the keyEcho() method in orca.py will still take into 
+        account whatever the user's various preferences for key echoing
+        are, which may override what is return by this echoKey() method.
+
+        Arguments:
+        - keyEvent - the key event
+
+        Returns an indication of whether a key echo event should be
+        allowed to happen for this script.
+        """
+
+        return True
+
     def getBookmarks(self):
         """Returns the "bookmarks" class for this script.
         """

Modified: trunk/src/orca/scripts/gnome-terminal.py
==============================================================================
--- trunk/src/orca/scripts/gnome-terminal.py	(original)
+++ trunk/src/orca/scripts/gnome-terminal.py	Thu Jan 24 17:40:12 2008
@@ -31,6 +31,7 @@
 
 import orca.default as default
 import orca.input_event as input_event
+import orca.orca as orca
 import orca.orca_state as orca_state
 import orca.settings as settings
 import orca.speech as speech
@@ -57,6 +58,26 @@
         #
         self.presentIfInactive = False
 
+    def echoKey(self, keyEvent):
+        """Determine whether this script should echo the current key event.
+        If this is a printable key, then return False.
+
+        Note that the keyEcho() method in orca.py will still take into
+        account whatever the user's various preferences for key echoing
+        are, which may override what is return by this echoKey() method.
+
+        Arguments:
+        - keyEvent - the key event
+
+        Returns an indication of whether a key echo event should be
+        allowed to happen for this script.
+        """
+
+        if orca.isPrintableKey(keyEvent.event_string):
+            return False
+
+        return True
+
     #def onWindowActivated(self, event):
     #    # Sets the context to the top level window first, so we can
     #    # get information about it the window we just moved to.
@@ -163,7 +184,8 @@
 
             # If the last input event was a keyboard event, check to see if
             # the text for this event matches what the user typed. If it does,
-            # then don't speak it.
+            # then call orca.keyEcho() to echo it (based on the user's key
+            # echo preferences).
             #
             # Note that the text widgets sometimes compress their events,
             # thus we might get a longer string from a single text inserted
@@ -204,6 +226,9 @@
              orca_state.lastInputEvent.button == "2":
             speakThis = True
 
+        if matchFound:
+            orca.keyEcho(orca_state.lastInputEvent)
+
         if speakThis:
             if text.isupper():
                 speech.speak(text, self.voices[settings.UPPERCASE_VOICE])



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