[orca] More of the keybindings and event refactor.
- From: Joanmarie Diggs <joanied src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [orca] More of the keybindings and event refactor.
- Date: Tue, 27 Dec 2011 03:07:04 +0000 (UTC)
commit 2048f8f0ebcb6b2daf0a214d04f73c110859449c
Author: Joanmarie Diggs <jdiggs igalia com>
Date: Mon Dec 26 22:06:34 2011 -0500
More of the keybindings and event refactor.
src/orca/input_event.py | 2 -
src/orca/orca.py | 2 +-
src/orca/script.py | 17 ++++---
src/orca/scripts/apps/Instantbird/script.py | 16 +-----
src/orca/scripts/apps/empathy/script.py | 16 +-----
src/orca/scripts/apps/evolution/script.py | 24 ++++-----
src/orca/scripts/apps/gajim/script.py | 16 +-----
src/orca/scripts/apps/gnome-mud/script.py | 9 +--
src/orca/scripts/apps/gnome-terminal/script.py | 5 +-
src/orca/scripts/apps/pidgin/script.py | 16 +-----
src/orca/scripts/apps/soffice/script.py | 69 +++++++++++++++---------
src/orca/scripts/default.py | 25 ++++++++-
src/orca/scripts/toolkits/Gecko/script.py | 10 +---
src/orca/scripts/toolkits/WebKitGtk/script.py | 15 +----
src/orca/speech.py | 31 +++--------
src/orca/speechserver.py | 20 +------
16 files changed, 124 insertions(+), 169 deletions(-)
---
diff --git a/src/orca/input_event.py b/src/orca/input_event.py
index 07d34a9..e9cfd32 100644
--- a/src/orca/input_event.py
+++ b/src/orca/input_event.py
@@ -40,8 +40,6 @@ from orca_i18n import C_
KEYBOARD_EVENT = "keyboard"
BRAILLE_EVENT = "braille"
MOUSE_BUTTON_EVENT = "mouse:button"
-MOUSE_MOTION_EVENT = "mouse:motion"
-SPEECH_EVENT = "speech"
class InputEvent:
diff --git a/src/orca/orca.py b/src/orca/orca.py
index a6912f3..38cf9fc 100644
--- a/src/orca/orca.py
+++ b/src/orca/orca.py
@@ -1269,7 +1269,7 @@ def listShortcuts(event):
_("Use Up and Down Arrow to navigate the list. Press Escape to exit.")
if event.type == pyatspi.KEY_PRESSED_EVENT:
- clickCount = orca_state.activeScript.getClickCount()
+ clickCount = event.getClickCount()
if (event.event_string == "1"):
if not numShortcuts or orca_state.typeOfShortcuts != "default":
orca_state.listOfShortcuts = getListOfShortcuts("default")
diff --git a/src/orca/script.py b/src/orca/script.py
index 3406cc6..736e84b 100644
--- a/src/orca/script.py
+++ b/src/orca/script.py
@@ -139,6 +139,16 @@ class Script:
"""
return keybindings.KeyBindings()
+ def getToolkitKeyBindings(self):
+ """Returns the toolkit-specific keybindings for this script."""
+
+ return keybindings.KeyBindings()
+
+ def getAppKeyBindings(self):
+ """Returns the application-specific keybindings for this script."""
+
+ return keybindings.KeyBindings()
+
def getKeyBindingsForInputHandler(self, inputEventHandler):
""" Returns a KeyBindings object with the list of KeyBindings that
matche the passed inputEventHandler as argument (at least the
@@ -321,13 +331,6 @@ class Script:
"""
return
- def getClickCount(self):
- """Return the count of the number of clicks a user has made to one
- of the keys on the keyboard.
- """
-
- return orca_state.clickCount
-
def getSettings(self):
"""Returns the settings associated with this script, regardless of
whether or not the script is active.
diff --git a/src/orca/scripts/apps/Instantbird/script.py b/src/orca/scripts/apps/Instantbird/script.py
index 6f13e6b..ccf1d91 100644
--- a/src/orca/scripts/apps/Instantbird/script.py
+++ b/src/orca/scripts/apps/Instantbird/script.py
@@ -95,20 +95,10 @@ class Script(Gecko.Script):
Gecko.Script.setupInputEventHandlers(self)
self.inputEventHandlers.update(self.chat.inputEventHandlers)
- def getKeyBindings(self):
- """Defines the key bindings for this script. Here we need to add
- the keybindings associated with chat functionality.
+ def getAppKeyBindings(self):
+ """Returns the application-specific keybindings for this script."""
- Returns an instance of keybindings.KeyBindings.
- """
-
- keyBindings = Gecko.Script.getKeyBindings(self)
-
- bindings = self.chat.keyBindings
- for keyBinding in bindings.keyBindings:
- keyBindings.add(keyBinding)
-
- return keyBindings
+ return self.chat.keyBindings
def getAppPreferencesGUI(self):
"""Return a GtkGrid containing the application unique configuration
diff --git a/src/orca/scripts/apps/empathy/script.py b/src/orca/scripts/apps/empathy/script.py
index 8b7a363..d9f6c89 100644
--- a/src/orca/scripts/apps/empathy/script.py
+++ b/src/orca/scripts/apps/empathy/script.py
@@ -71,20 +71,10 @@ class Script(default.Script):
default.Script.setupInputEventHandlers(self)
self.inputEventHandlers.update(self.chat.inputEventHandlers)
- def getKeyBindings(self):
- """Defines the key bindings for this script. Here we need to add
- the keybindings associated with chat functionality.
+ def getAppKeyBindings(self):
+ """Returns the application-specific keybindings for this script."""
- Returns an instance of keybindings.KeyBindings.
- """
-
- keyBindings = default.Script.getKeyBindings(self)
-
- bindings = self.chat.keyBindings
- for keyBinding in bindings.keyBindings:
- keyBindings.add(keyBinding)
-
- return keyBindings
+ return self.chat.keyBindings
def getAppPreferencesGUI(self):
"""Return a GtkGrid containing the application unique configuration
diff --git a/src/orca/scripts/apps/evolution/script.py b/src/orca/scripts/apps/evolution/script.py
index 2d7b54d..38cb293 100644
--- a/src/orca/scripts/apps/evolution/script.py
+++ b/src/orca/scripts/apps/evolution/script.py
@@ -29,6 +29,7 @@ import pyatspi
import orca.debug as debug
import orca.scripts.default as default
+import orca.keybindings as keybindings
import orca.input_event as input_event
import orca.rolenames as rolenames
import orca.braille as braille
@@ -170,23 +171,18 @@ class Script(default.Script):
_("Toggle whether we present new mail " \
"if we are not the active script."))
- def getKeyBindings(self):
- """Defines the new key binding for this script. Setup the default
- key bindings, then add one in for toggling whether we present new
- mail if we not not the active script.
+ def getAppKeyBindings(self):
+ """Returns the application-specific keybindings for this script."""
- Returns an instance of keybindings.KeyBindings.
- """
-
- debug.println(self.debugLevel, "Evolution.getKeyBindings.")
+ keyBindings = keybindings.KeyBindings()
- keyBindings = default.Script.getKeyBindings(self)
+ keyBindings.add(
+ keybindings.KeyBinding(
+ "n",
+ settings.defaultModifierMask,
+ settings.ORCA_MODIFIER_MASK,
+ self.inputEventHandlers["toggleReadMailHandler"]))
- keymap = (
- ("n", settings.defaultModifierMask, settings.ORCA_MODIFIER_MASK,
- "toggleReadMailHandler"),
- )
- keyBindings.load(keymap, self.inputEventHandlers)
return keyBindings
def getListeners(self):
diff --git a/src/orca/scripts/apps/gajim/script.py b/src/orca/scripts/apps/gajim/script.py
index 4f9d13d..72ed844 100644
--- a/src/orca/scripts/apps/gajim/script.py
+++ b/src/orca/scripts/apps/gajim/script.py
@@ -66,20 +66,10 @@ class Script(default.Script):
default.Script.setupInputEventHandlers(self)
self.inputEventHandlers.update(self.chat.inputEventHandlers)
- def getKeyBindings(self):
- """Defines the key bindings for this script. Here we need to add
- the keybindings associated with chat functionality.
+ def getAppKeyBindings(self):
+ """Returns the application-specific keybindings for this script."""
- Returns an instance of keybindings.KeyBindings.
- """
-
- keyBindings = default.Script.getKeyBindings(self)
-
- bindings = self.chat.keyBindings
- for keyBinding in bindings.keyBindings:
- keyBindings.add(keyBinding)
-
- return keyBindings
+ return self.chat.keyBindings
def getAppPreferencesGUI(self):
"""Return a GtkGrid containing the application unique configuration
diff --git a/src/orca/scripts/apps/gnome-mud/script.py b/src/orca/scripts/apps/gnome-mud/script.py
index b6db2ac..038779c 100644
--- a/src/orca/scripts/apps/gnome-mud/script.py
+++ b/src/orca/scripts/apps/gnome-mud/script.py
@@ -119,14 +119,11 @@ class Script(default.Script):
_('Read the latest n messages in the incoming messages text '
'area.'))
- def getKeyBindings(self):
+ def getAppKeyBindings(self):
+ """Returns the application-specific keybindings for this script."""
- debug.println(self.debugLevel, "gnome-mud.getKeyBindings.")
+ keyBindings = keybindings.KeyBindings()
- keyBindings = default.Script.getKeyBindings(self)
-
- # Here we define keybindings Orca+F1 to Orca+F9 for reading a previous
- # message.
messageKeys = [ "F1", "F2", "F3", "F4", "F5", "F6", "F7", "F8", "F9"]
for messagekey in messageKeys:
keyBindings.add(
diff --git a/src/orca/scripts/apps/gnome-terminal/script.py b/src/orca/scripts/apps/gnome-terminal/script.py
index bbdd452..2ff9c82 100644
--- a/src/orca/scripts/apps/gnome-terminal/script.py
+++ b/src/orca/scripts/apps/gnome-terminal/script.py
@@ -212,8 +212,7 @@ class Script(default.Script):
# 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 call orca.keyEcho() to echo it (based on the user's key
- # echo preferences).
+ # then 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
@@ -246,7 +245,7 @@ class Script(default.Script):
speakThis = True
if matchFound:
- echoed = orca.keyEcho(orca_state.lastInputEvent)
+ echoed = orca_state.lastInputEvent.present()
else:
echoed = False
diff --git a/src/orca/scripts/apps/pidgin/script.py b/src/orca/scripts/apps/pidgin/script.py
index 0ee1e0d..e66cd93 100644
--- a/src/orca/scripts/apps/pidgin/script.py
+++ b/src/orca/scripts/apps/pidgin/script.py
@@ -88,20 +88,10 @@ class Script(default.Script):
default.Script.setupInputEventHandlers(self)
self.inputEventHandlers.update(self.chat.inputEventHandlers)
- def getKeyBindings(self):
- """Defines the key bindings for this script. Here we need to add
- the keybindings associated with chat functionality.
+ def getAppKeyBindings(self):
+ """Returns the application-specific keybindings for this script."""
- Returns an instance of keybindings.KeyBindings.
- """
-
- keyBindings = default.Script.getKeyBindings(self)
-
- bindings = self.chat.keyBindings
- for keyBinding in bindings.keyBindings:
- keyBindings.add(keyBinding)
-
- return keyBindings
+ return self.chat.keyBindings
def getAppPreferencesGUI(self):
"""Return a GtkGrid containing the application unique configuration
diff --git a/src/orca/scripts/apps/soffice/script.py b/src/orca/scripts/apps/soffice/script.py
index 78e5909..16cc0e1 100644
--- a/src/orca/scripts/apps/soffice/script.py
+++ b/src/orca/scripts/apps/soffice/script.py
@@ -42,6 +42,7 @@ import pyatspi
import orca.debug as debug
import orca.scripts.default as default
+import orca.keybindings as keybindings
import orca.input_event as input_event
import orca.orca as orca
import orca.orca_state as orca_state
@@ -261,32 +262,50 @@ class Script(default.Script):
#
_("Clears the dynamic row headers"))
- def getKeyBindings(self):
- """Defines the key bindings for this script. Setup the default
- key bindings, then add one in for reading the input line.
+ def getAppKeyBindings(self):
+ """Returns the application-specific keybindings for this script."""
+
+ keyBindings = keybindings.KeyBindings()
+
+ keyBindings.add(
+ keybindings.KeyBinding(
+ "a",
+ settings.defaultModifierMask,
+ settings.ORCA_MODIFIER_MASK,
+ self.inputEventHandlers["presentInputLineHandler"]))
+
+ keyBindings.add(
+ keybindings.KeyBinding(
+ "r",
+ settings.defaultModifierMask,
+ settings.ORCA_MODIFIER_MASK,
+ self.inputEventHandlers["setDynamicColumnHeadersHandler"],
+ 1))
+
+ keyBindings.add(
+ keybindings.KeyBinding(
+ "r",
+ settings.defaultModifierMask,
+ settings.ORCA_MODIFIER_MASK,
+ self.inputEventHandlers["clearDynamicColumnHeadersHandler"],
+ 2))
+
+ keyBindings.add(
+ keybindings.KeyBinding(
+ "c",
+ settings.defaultModifierMask,
+ settings.ORCA_MODIFIER_MASK,
+ self.inputEventHandlers["setDynamicRowHeadersHandler"],
+ 1))
+
+ keyBindings.add(
+ keybindings.KeyBinding(
+ "c",
+ settings.defaultModifierMask,
+ settings.ORCA_MODIFIER_MASK,
+ self.inputEventHandlers["clearDynamicRowHeadersHandler"],
+ 2))
- Returns an instance of keybindings.KeyBindings.
- """
-
- keyBindings = default.Script.getKeyBindings(self)
-
- keymap = (
- ("a", settings.defaultModifierMask, settings.ORCA_MODIFIER_MASK,
- "presentInputLineHandler"),
-
- ("r", settings.defaultModifierMask, settings.ORCA_MODIFIER_MASK,
- "setDynamicColumnHeadersHandler", 1),
-
- ("r", settings.defaultModifierMask, settings.ORCA_MODIFIER_MASK,
- "clearDynamicColumnHeadersHandler", 2),
-
- ("c", settings.defaultModifierMask, settings.ORCA_MODIFIER_MASK,
- "setDynamicRowHeadersHandler", 1),
-
- ("c", settings.defaultModifierMask, settings.ORCA_MODIFIER_MASK,
- "clearDynamicRowHeadersHandler", 2),
- )
- keyBindings.load(keymap, self.inputEventHandlers)
bindings = self.structuralNavigation.keyBindings
for keyBinding in bindings.keyBindings:
keyBindings.add(keyBinding)
diff --git a/src/orca/scripts/default.py b/src/orca/scripts/default.py
index f14a961..5d6c309 100644
--- a/src/orca/scripts/default.py
+++ b/src/orca/scripts/default.py
@@ -1134,6 +1134,26 @@ class Script(script.Script):
keyBindings = script.Script.getKeyBindings(self)
+ bindings = self.getDefaultKeyBindings()
+ for keyBinding in bindings.keyBindings:
+ keyBindings.add(keyBinding)
+
+ bindings = self.getToolkitKeyBindings()
+ for keyBinding in bindings.keyBindings:
+ keyBindings.add(keyBinding)
+
+ bindings = self.getAppKeyBindings()
+ for keyBinding in bindings.keyBindings:
+ keyBindings.add(keyBinding)
+
+ return keyBindings
+
+ def getDefaultKeyBindings(self):
+ """Returns the default script's keybindings, i.e. without any of
+ the toolkit or application specific commands added."""
+
+ keyBindings = keybindings.KeyBindings()
+
layout = _settingsManager.getSetting('keyboardLayout')
if layout == settings.GENERAL_KEYBOARD_LAYOUT_DESKTOP:
for keyBinding in self.__getDesktopBindings().keyBindings:
@@ -2497,7 +2517,10 @@ class Script(script.Script):
self.flatReviewContext = None
def sayAll(self, inputEvent):
- clickCount = self.getClickCount()
+ try:
+ clickCount = inputEvent.getClickCount()
+ except:
+ clickCount = 1
doubleClick = clickCount == 2
self.lastSayAllEvent = inputEvent
diff --git a/src/orca/scripts/toolkits/Gecko/script.py b/src/orca/scripts/toolkits/Gecko/script.py
index 86ed868..9c587a2 100644
--- a/src/orca/scripts/toolkits/Gecko/script.py
+++ b/src/orca/scripts/toolkits/Gecko/script.py
@@ -631,15 +631,11 @@ class Script(default.Script):
keyBindings.load(keymaps.arrowKeymap, self.inputEventHandlers)
return keyBindings
- def getKeyBindings(self):
- """Defines the key bindings for this script.
+ def getToolkitKeyBindings(self):
+ """Returns the toolkit-specific keybindings for this script."""
- Returns an instance of keybindings.KeyBindings.
- """
-
- keyBindings = default.Script.getKeyBindings(self)
+ keyBindings = keybindings.KeyBindings()
- # load common keymap
keyBindings.load(keymaps.commonKeymap, self.inputEventHandlers)
if _settingsManager.getSetting('keyboardLayout') == \
diff --git a/src/orca/scripts/toolkits/WebKitGtk/script.py b/src/orca/scripts/toolkits/WebKitGtk/script.py
index 495060c..d6ac98d 100644
--- a/src/orca/scripts/toolkits/WebKitGtk/script.py
+++ b/src/orca/scripts/toolkits/WebKitGtk/script.py
@@ -107,19 +107,10 @@ class Script(default.Script):
#
_("Speaks entire document."))
- def getKeyBindings(self):
- """Defines the key bindings for this script. Setup the default
- key bindings, then add one in for reading the input line.
+ def getToolkitKeyBindings(self):
+ """Returns the toolkit-specific keybindings for this script."""
- Returns an instance of keybindings.KeyBindings.
- """
-
- keyBindings = default.Script.getKeyBindings(self)
- bindings = self.structuralNavigation.keyBindings
- for keyBinding in bindings.keyBindings:
- keyBindings.add(keyBinding)
-
- return keyBindings
+ return self.structuralNavigation.keyBindings
def getAppPreferencesGUI(self):
"""Return a GtkGrid containing the application unique configuration
diff --git a/src/orca/speech.py b/src/orca/speech.py
index bcad38c..3c5712d 100644
--- a/src/orca/speech.py
+++ b/src/orca/speech.py
@@ -34,14 +34,12 @@ import time
import chnames
import debug
-import keynames
import orca_state
import settings
import sound
import speech_generator
from acss import ACSS
-from orca_i18n import _ # for gettext support
# The speech server to use for all speech operations.
#
@@ -281,26 +279,15 @@ def speakKeyEvent(event):
if _speechserver:
_speechserver.speakKeyEvent(event)
- else:
- # Check to see if there are localized words to be spoken for
- # this key event.
- #
- event_string = keynames.getKeyName(event.event_string)
- lockingState = event.getLockingState()
- if lockingState == True:
- # Translators: this represents the state of a locking modifier
- # key (e.g., Caps Lock)
- #
- event_string += " " + _("on")
- elif lockingState == False:
- # Translators: this represents the state of a locking modifier
- # key (e.g., Caps Lock)
- #
- event_string += " " + _("off")
-
- logLine = "SPEECH OUTPUT: '" + event_string +"'"
- debug.println(debug.LEVEL_INFO, logLine)
- log.info(logLine)
+ return
+
+ # This should only happen during regression tests.
+ keyname = event.getKeyName()
+ lockingStateString = event.getLockingStateString()
+ msg = "%s %s" % (keyname, lockingStateString)
+ logLine = "SPEECH OUTPUT: '%s'" % msg
+ debug.println(debug.LEVEL_INFO, logLine)
+ log.info(logLine)
def speakCharacter(character, acss=None):
"""Speaks a single character immediately.
diff --git a/src/orca/speechserver.py b/src/orca/speechserver.py
index 4e373c1..2c7ed76 100644
--- a/src/orca/speechserver.py
+++ b/src/orca/speechserver.py
@@ -31,7 +31,6 @@ __copyright__ = "Copyright (c) 2005-2008 Sun Microsystems Inc."
__license__ = "LGPL"
import logging
-import keynames
import settings
import orca_state
@@ -40,7 +39,6 @@ log = logging.getLogger("speech")
import debug
from acss import ACSS
-from orca_i18n import _ # for gettext support
class VoiceFamily(dict):
"""Holds the family description for a voice."""
@@ -195,25 +193,13 @@ class SpeechServer(object):
else:
voice = ACSS(settings.voices[settings.DEFAULT_VOICE])
- # Check to see if there are localized words to be spoken for
- # this key event.
- #
- event_string = keynames.getKeyName(event.event_string)
+ event_string = event.getKeyName()
if orca_state.activeScript and orca_state.usePronunciationDictionary:
event_string = orca_state.activeScript.\
utilities.adjustForPronunciation(event_string)
- lockingState = event.getLockingState()
- if lockingState == True:
- # Translators: this represents the state of a locking modifier
- # key (e.g., Caps Lock)
- #
- event_string += " " + _("on")
- elif lockingState == False:
- # Translators: this represents the state of a locking modifier
- # key (e.g., Caps Lock)
- #
- event_string += " " + _("off")
+ lockingStateString = event.getLockingStateString()
+ event_string = "%s %s" % (event_string, lockingStateString)
logLine = "SPEECH OUTPUT: '" + event_string +"'"
debug.println(debug.LEVEL_INFO, logLine)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]