[orca] Fix for bgo#618633 - Remove keybindings code from Gecko script.



commit 140dae78dd45e641f927af5c1db552ac3eba19f2
Author: Mesar Hameed <mhameed src gnome org>
Date:   Fri May 14 15:34:08 2010 +0100

    Fix for bgo#618633 - Remove keybindings code from Gecko script.

 src/orca/scripts/apps/evolution/script.py   |    2 +-
 src/orca/scripts/toolkits/Gecko/Makefile.am |    1 +
 src/orca/scripts/toolkits/Gecko/keymaps.py  |  105 +++++++++++++++++
 src/orca/scripts/toolkits/Gecko/script.py   |  161 ++-------------------------
 4 files changed, 117 insertions(+), 152 deletions(-)
---
diff --git a/src/orca/scripts/apps/evolution/script.py b/src/orca/scripts/apps/evolution/script.py
index 0e2b475..7561af2 100644
--- a/src/orca/scripts/apps/evolution/script.py
+++ b/src/orca/scripts/apps/evolution/script.py
@@ -182,7 +182,7 @@ class Script(default.Script):
 
         keymap = (
           ("n", settings.defaultModifierMask, settings.ORCA_MODIFIER_MASK,
-          "toggleReadMailHandler")
+          "toggleReadMailHandler"),
         )
         keyBindings.load(keymap, self.inputEventHandlers)
         return keyBindings
diff --git a/src/orca/scripts/toolkits/Gecko/Makefile.am b/src/orca/scripts/toolkits/Gecko/Makefile.am
index 9ab1ca4..98f6877 100644
--- a/src/orca/scripts/toolkits/Gecko/Makefile.am
+++ b/src/orca/scripts/toolkits/Gecko/Makefile.am
@@ -5,6 +5,7 @@ orca_python_PYTHON = \
 	bookmarks.py \
 	braille_generator.py \
 	formatting.py \
+	keymaps.py \
 	script.py \
 	script_settings.py \
 	script_utilities.py \
diff --git a/src/orca/scripts/toolkits/Gecko/keymaps.py b/src/orca/scripts/toolkits/Gecko/keymaps.py
new file mode 100644
index 0000000..e5c109e
--- /dev/null
+++ b/src/orca/scripts/toolkits/Gecko/keymaps.py
@@ -0,0 +1,105 @@
+# Orca
+#
+# Copyright 2010 Joanmarie Diggs, Mesar Hameed.
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Library General Public
+# License as published by the Free Software Foundation; either
+# version 2 of the License, or (at your option) any later version.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# Library General Public License for more details.
+#
+# You should have received a copy of the GNU Library General Public
+# License along with this library; if not, write to the
+# Free Software Foundation, Inc., Franklin Street, Fifth Floor,
+# Boston MA  02110-1301 USA.
+
+""" A list of common keybindings and unbound keys
+    pulled out from script.py: __getLaptopBindings()
+    with the goal of being more readable and less monolithic.
+"""
+
+__id__ = "$Id$"
+__version__   = "$Revision$"
+__date__      = "$Date$"
+__copyright__ = "Copyright (c) 2010 Joanmarie Diggs, Mesar Hameed."
+__license__   = "LGPL"
+
+import orca.settings as settings
+
+# Storing values 
+defaultModifierMask = settings.defaultModifierMask
+ORCA_MODIFIER_MASK = settings.ORCA_MODIFIER_MASK
+NO_MODIFIER_MASK = settings.NO_MODIFIER_MASK
+ORCA_SHIFT_MODIFIER_MASK = settings.ORCA_SHIFT_MODIFIER_MASK
+ORCA_CTRL_MODIFIER_MASK = settings.ORCA_CTRL_MODIFIER_MASK
+CTRL_MODIFIER_MASK = settings.CTRL_MODIFIER_MASK
+ALT_MODIFIER_MASK = settings.ALT_MODIFIER_MASK
+SHIFT_MODIFIER_MASK = settings.SHIFT_MODIFIER_MASK
+
+# KeyBindings that use the arrow keys for navigating HTML content.
+arrowKeymap = (
+    ("Right", defaultModifierMask, NO_MODIFIER_MASK, "goNextCharacterHandler"),
+
+    ("Left", defaultModifierMask, NO_MODIFIER_MASK, 
+    "goPreviousCharacterHandler"),
+
+    ("Right", defaultModifierMask, CTRL_MODIFIER_MASK, "goNextWordHandler"),
+    ("Left", defaultModifierMask, CTRL_MODIFIER_MASK, "goPreviousWordHandler"),
+    ("Up", defaultModifierMask, NO_MODIFIER_MASK, "goPreviousLineHandler"),
+    ("Down", defaultModifierMask, NO_MODIFIER_MASK, "goNextLineHandler"),
+    ("Down", defaultModifierMask, ALT_MODIFIER_MASK, "expandComboBoxHandler"),
+    ("Home", defaultModifierMask, CTRL_MODIFIER_MASK, "goTopOfFileHandler"),
+    ("End", defaultModifierMask, CTRL_MODIFIER_MASK, "goBottomOfFileHandler"),
+    ("Home", defaultModifierMask, NO_MODIFIER_MASK, "goBeginningOfLineHandler"),
+    ("End", defaultModifierMask, NO_MODIFIER_MASK, "goEndOfLineHandler"),
+)
+
+commonKeymap = (
+
+    # keybindings to provide chat room message history.
+    ("f1", defaultModifierMask, ORCA_MODIFIER_MASK, "reviewLiveAnnouncement"),
+    ("f2", defaultModifierMask, ORCA_MODIFIER_MASK, "reviewLiveAnnouncement"),
+    ("f3", defaultModifierMask, ORCA_MODIFIER_MASK, "reviewLiveAnnouncement"),
+    ("f4", defaultModifierMask, ORCA_MODIFIER_MASK, "reviewLiveAnnouncement"),
+    ("f5", defaultModifierMask, ORCA_MODIFIER_MASK, "reviewLiveAnnouncement"),
+    ("f6", defaultModifierMask, ORCA_MODIFIER_MASK, "reviewLiveAnnouncement"),
+    ("f7", defaultModifierMask, ORCA_MODIFIER_MASK, "reviewLiveAnnouncement"),
+    ("f8", defaultModifierMask, ORCA_MODIFIER_MASK, "reviewLiveAnnouncement"),
+    ("f9", defaultModifierMask, ORCA_MODIFIER_MASK, "reviewLiveAnnouncement"),
+
+    # misc
+    
+    ("backslash", defaultModifierMask, SHIFT_MODIFIER_MASK,
+    "setLivePolitenessOff"),
+
+    ("backslash", defaultModifierMask, ORCA_SHIFT_MODIFIER_MASK,
+    "monitorLiveRegions"),
+
+    ("backslash", defaultModifierMask, NO_MODIFIER_MASK,
+    "advanceLivePoliteness"),
+
+    ("F12", defaultModifierMask, ORCA_MODIFIER_MASK,
+    "toggleCaretNavigationHandler"),
+
+    ("SunF37", defaultModifierMask, ORCA_MODIFIER_MASK,
+    "toggleCaretNavigationHandler"),
+
+    ("Right", defaultModifierMask, ORCA_MODIFIER_MASK,
+    "goNextObjectInOrderHandler"),
+
+    ("Left", defaultModifierMask, ORCA_MODIFIER_MASK, 
+    "goPreviousObjectInOrderHandler"),
+)
+
+desktopKeymap = (
+    ("KP_Multiply", defaultModifierMask, ORCA_MODIFIER_MASK, 
+    "moveToMouseOverHandler"),
+)
+
+laptopKeymap = (
+    ("0", defaultModifierMask, ORCA_MODIFIER_MASK, "moveToMouseOverHandler"),
+)
diff --git a/src/orca/scripts/toolkits/Gecko/script.py b/src/orca/scripts/toolkits/Gecko/script.py
index 463a861..b310794 100644
--- a/src/orca/scripts/toolkits/Gecko/script.py
+++ b/src/orca/scripts/toolkits/Gecko/script.py
@@ -1,6 +1,7 @@
 # Orca
 #
-# Copyright 2005-2008 Sun Microsystems Inc.
+# Copyright 2005-2009 Sun Microsystems Inc.
+# Copyright 2010 Joanmarie Diggs, Mesar Hameed.
 #
 # This library is free software; you can redistribute it and/or
 # modify it under the terms of the GNU Library General Public
@@ -37,7 +38,7 @@ http://developer.mozilla.org/en/docs/Accessibility/ATSPI_Support
 __id__        = "$Id$"
 __version__   = "$Revision$"
 __date__      = "$Date$"
-__copyright__ = "Copyright (c) 2005-2008 Sun Microsystems Inc."
+__copyright__ = "Copyright (c) 2010 Joanmarie Diggs, Mesar Hameed."
 __license__   = "LGPL"
 
 import atk
@@ -65,6 +66,7 @@ import orca.settings as settings
 import orca.speech as speech
 import orca.speechserver as speechserver
 
+import keymaps
 import script_settings
 from braille_generator import BrailleGenerator
 from speech_generator import SpeechGenerator
@@ -625,84 +627,7 @@ class Script(default.Script):
         """
 
         keyBindings = keybindings.KeyBindings()
-
-        keyBindings.add(
-            keybindings.KeyBinding(
-                "Right",
-                settings.defaultModifierMask,
-                settings.NO_MODIFIER_MASK,
-                self.inputEventHandlers["goNextCharacterHandler"]))
-
-        keyBindings.add(
-            keybindings.KeyBinding(
-                "Left",
-                settings.defaultModifierMask,
-                settings.NO_MODIFIER_MASK,
-                self.inputEventHandlers["goPreviousCharacterHandler"]))
-
-        keyBindings.add(
-            keybindings.KeyBinding(
-                "Right",
-                settings.defaultModifierMask,
-                settings.CTRL_MODIFIER_MASK,
-                self.inputEventHandlers["goNextWordHandler"]))
-
-        keyBindings.add(
-            keybindings.KeyBinding(
-                "Left",
-                settings.defaultModifierMask,
-                settings.CTRL_MODIFIER_MASK,
-                self.inputEventHandlers["goPreviousWordHandler"]))
-
-        keyBindings.add(
-            keybindings.KeyBinding(
-                "Up",
-                settings.defaultModifierMask,
-                settings.NO_MODIFIER_MASK,
-                self.inputEventHandlers["goPreviousLineHandler"]))
-
-        keyBindings.add(
-            keybindings.KeyBinding(
-                "Down",
-                settings.defaultModifierMask,
-                settings.NO_MODIFIER_MASK,
-                self.inputEventHandlers["goNextLineHandler"]))
-
-        keyBindings.add(
-            keybindings.KeyBinding(
-                "Down",
-                settings.defaultModifierMask,
-                settings.ALT_MODIFIER_MASK,
-                self.inputEventHandlers["expandComboBoxHandler"]))
-
-        keyBindings.add(
-            keybindings.KeyBinding(
-                "Home",
-                settings.defaultModifierMask,
-                settings.CTRL_MODIFIER_MASK,
-                self.inputEventHandlers["goTopOfFileHandler"]))
-
-        keyBindings.add(
-            keybindings.KeyBinding(
-                "End",
-                settings.defaultModifierMask,
-                settings.CTRL_MODIFIER_MASK,
-                self.inputEventHandlers["goBottomOfFileHandler"]))
-
-        keyBindings.add(
-            keybindings.KeyBinding(
-                "Home",
-                settings.defaultModifierMask,
-                settings.NO_MODIFIER_MASK,
-                self.inputEventHandlers["goBeginningOfLineHandler"]))
-
-        keyBindings.add(
-            keybindings.KeyBinding(
-                "End",
-                settings.defaultModifierMask,
-                settings.NO_MODIFIER_MASK,
-                self.inputEventHandlers["goEndOfLineHandler"]))
-
+        keyBindings.load(keymaps.arrowKeymap, self.inputEventHandlers)
         return keyBindings
 
     def getKeyBindings(self):
@@ -713,80 +638,14 @@ class Script(default.Script):
 
         keyBindings = default.Script.getKeyBindings(self)
 
-        # keybindings to provide chat room message history.
-        messageKeys = [ "F1", "F2", "F3", "F4", "F5", "F6", "F7", "F8", "F9" ]
-        for messageKey in messageKeys:
-            keyBindings.add(
-                keybindings.KeyBinding(
-                    messageKey,
-                    settings.defaultModifierMask,
-                    settings.ORCA_MODIFIER_MASK,
-                    self.inputEventHandlers["reviewLiveAnnouncement"]))
-
-        keyBindings.add(
-            keybindings.KeyBinding(
-                "backslash",
-                settings.defaultModifierMask,
-                settings.SHIFT_MODIFIER_MASK,
-                self.inputEventHandlers["setLivePolitenessOff"]))
-
-        keyBindings.add(
-            keybindings.KeyBinding(
-                "backslash",
-                settings.defaultModifierMask,
-                settings.ORCA_SHIFT_MODIFIER_MASK,
-                self.inputEventHandlers["monitorLiveRegions"]))
-
-        keyBindings.add(
-            keybindings.KeyBinding(
-                "backslash",
-                settings.defaultModifierMask,
-                settings.NO_MODIFIER_MASK,
-                self.inputEventHandlers["advanceLivePoliteness"]))
-
-        keyBindings.add(
-            keybindings.KeyBinding(
-                "F12",
-                settings.defaultModifierMask,
-                settings.ORCA_MODIFIER_MASK,
-                self.inputEventHandlers["toggleCaretNavigationHandler"]))
-
-        keyBindings.add(
-            keybindings.KeyBinding(
-                "SunF37",
-                settings.defaultModifierMask,
-                settings.ORCA_MODIFIER_MASK,
-                self.inputEventHandlers["toggleCaretNavigationHandler"]))
-
-        keyBindings.add(
-            keybindings.KeyBinding(
-                "Right",
-                settings.defaultModifierMask,
-                settings.ORCA_MODIFIER_MASK,
-                self.inputEventHandlers["goNextObjectInOrderHandler"]))
-
-        keyBindings.add(
-            keybindings.KeyBinding(
-                "Left",
-                settings.defaultModifierMask,
-                settings.ORCA_MODIFIER_MASK,
-                self.inputEventHandlers["goPreviousObjectInOrderHandler"]))
+        # load common keymap
+        keyBindings.load(keymaps.commonKeymap, self.inputEventHandlers)
 
         if orca.settings.keyboardLayout == \
-                orca.settings.GENERAL_KEYBOARD_LAYOUT_DESKTOP:
-            keyBindings.add(
-                keybindings.KeyBinding(
-                    "KP_Multiply",
-                    settings.defaultModifierMask,
-                    settings.ORCA_MODIFIER_MASK,
-                    self.inputEventHandlers["moveToMouseOverHandler"]))
+          orca.settings.GENERAL_KEYBOARD_LAYOUT_DESKTOP:
+            keyBindings.load(keymaps.desktopKeymap, self.inputEventHandlers)
         else:
-            keyBindings.add(
-                keybindings.KeyBinding(
-                    "0",
-                    settings.defaultModifierMask,
-                    settings.ORCA_MODIFIER_MASK,
-                    self.inputEventHandlers["moveToMouseOverHandler"]))
+            keyBindings.load(keymaps.laptopKeymap, self.inputEventHandlers)
 
         if script_settings.controlCaretNavigation:
             for keyBinding in self.__getArrowBindings().keyBindings:



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