orca r4262 - branches/phase2/src/orca/plugins/structural_navigation
- From: wwalker svn gnome org
- To: svn-commits-list gnome org
- Subject: orca r4262 - branches/phase2/src/orca/plugins/structural_navigation
- Date: Sat, 27 Sep 2008 01:57:16 +0000 (UTC)
Author: wwalker
Date: Sat Sep 27 01:57:16 2008
New Revision: 4262
URL: http://svn.gnome.org/viewvc/orca?rev=4262&view=rev
Log:
Get structural navigation working with the new keybindings format.
Removed:
branches/phase2/src/orca/plugins/structural_navigation/braille_bindings.py
branches/phase2/src/orca/plugins/structural_navigation/keyboard_bindings.py
Modified:
branches/phase2/src/orca/plugins/structural_navigation/Makefile.am
branches/phase2/src/orca/plugins/structural_navigation/plugin.py
Modified: branches/phase2/src/orca/plugins/structural_navigation/Makefile.am
==============================================================================
--- branches/phase2/src/orca/plugins/structural_navigation/Makefile.am (original)
+++ branches/phase2/src/orca/plugins/structural_navigation/Makefile.am Sat Sep 27 01:57:16 2008
@@ -2,8 +2,6 @@
orca_python_PYTHON = \
__init__.py \
- braille_bindings.py \
- keyboard_bindings.py \
plugin.py
orca_pythondir=$(pyexecdir)/orca/plugins/structural_navigation
Modified: branches/phase2/src/orca/plugins/structural_navigation/plugin.py
==============================================================================
--- branches/phase2/src/orca/plugins/structural_navigation/plugin.py (original)
+++ branches/phase2/src/orca/plugins/structural_navigation/plugin.py Sat Sep 27 01:57:16 2008
@@ -25,19 +25,12 @@
import logging
log = logging.getLogger('orca.plugins.structural_navigation.plugin')
-import orca.input_bindings as input_bindings
+import orca.input_binding as input_binding
+import orca.input_event as input_event
import orca.plugin as plugin
from orca.orca_i18n import _ # for gettext support
-from keyboard_bindings import bindings as keyboardBindings
-
-try:
- from braille_bindings import bindings as brailleBindings
-except:
- log.exception("Not using braille bindings because of this exception:")
- brailleBindings = []
-
class Plugin(plugin.Plugin):
"""A plugin for handling Structural Navigation.
"""
@@ -50,221 +43,267 @@
- owner: the Script owning this Plugin
- scriptSettings: the Settings for the script
"""
+ plugin.Plugin.__init__(self, owner, scriptSettings)
+
self._handlerDescriptions = {
"anchor": {
# Translators: this is for navigating among anchors in a
# document. An anchor is a named spot that one can jump to.
#
- "previous" : _("Goes to previous anchor."),
+ "previous" : (_("Goes to previous anchor."),
+ [("a", input_event.SHIFT_MODIFIER_MASK)]),
# Translators: this is for navigating among anchors in a
# document. An anchor is a named spot that one can jump to.
#
- "next" : _("Goes to next anchor.")
- },
+ "next" : (_("Goes to next anchor."),
+ [("a", input_event.NO_MODIFIER_MASK)]),
+ },
"blockquote": {
# Translators: this is for navigating among blockquotes in a
# document.
#
- "previous" : _("Goes to previous blockquote."),
+ "previous" : (_("Goes to previous blockquote."),
+ [("q", input_event.SHIFT_MODIFIER_MASK)]),
# Translators: this is for navigating among blockquotes in a
# document.
#
- "next" : _("Goes to next blockquote.")
- },
+ "next" : (_("Goes to next blockquote."),
+ [("q", input_event.NO_MODIFIER_MASK)]),
+ },
"button": {
# Translators: this is for navigating among buttons in a form
# within a document.
#
- "previous" : _("Goes to previous button."),
+ "previous" : (_("Goes to previous button."),
+ [("b", input_event.SHIFT_MODIFIER_MASK)]),
# Translators: this is for navigating among buttons in a form
# within a document.
#
- "next" : _("Goes to next button.")
- },
+ "next" : (_("Goes to next button."),
+ [("b", input_event.NO_MODIFIER_MASK)]),
+
+ },
"checkBox": {
# Translators: this is for navigating among check boxes in a
# form within a document.
#
- "previous" : _("Goes to previous check box."),
+ "previous" : (_("Goes to previous check box."),
+ [("x", input_event.SHIFT_MODIFIER_MASK)]),
# Translators: this is for navigating among check boxes in a
# form within a document.
#
- "next" : _("Goes to next check box.")
- },
+ "next" : (_("Goes to next check box."),
+ [("x", input_event.NO_MODIFIER_MASK)]),
+ },
"chunk": {
# Translators: this is for navigating a document in a
# structural manner, where a "large object" is a logical
# chunk of text, such as a paragraph, a list, a table, etc.
#
- "previous" : _("Goes to previous large object."),
+ "previous" : (_("Goes to previous large object."),
+ [("o", input_event.SHIFT_MODIFIER_MASK)]),
# Translators: this is for navigating a document in a
# structural manner, where a "large object" is a logical
# chunk of text, such as a paragraph, a list, a table, etc.
#
- "next" : _("Goes to next large object.")
- },
+ "next" : (_("Goes to next large object."),
+ [("o", input_event.NO_MODIFIER_MASK)]),
+ },
"comboBox": {
# Translators: this is for navigating among combo boxes in a
# form within a document.
#
- "previous" : _("Goes to previous combo box."),
+ "previous" : (_("Goes to previous combo box."),
+ [("c", input_event.SHIFT_MODIFIER_MASK)]),
# Translators: this is for navigating among combo boxes in a
# form within a document.
#
- "next" : _("Goes to next combo box.")
- },
+ "next" : (_("Goes to next combo box."),
+ [("c", input_event.NO_MODIFIER_MASK)]),
+ },
"entry": {
# Translators: this is for navigating among text entries in a
# form within a document.
#
- "previous" : _("Goes to previous entry."),
+ "previous" : (_("Goes to previous entry."),
+ [("e", input_event.SHIFT_MODIFIER_MASK)]),
# Translators: this is for navigating among text entries in a
# form within a document.
#
- "next" : _("Goes to next entry.")
- },
+ "next" : (_("Goes to next entry."),
+ [("e", input_event.NO_MODIFIER_MASK)]),
+ },
"formField": {
# Translators: this is for navigating among fields in a form
# within a document.
#
- "previous" : _("Goes to previous form field."),
+ "previous" : (_("Goes to previous form field."),
+ [("Tab", input_event.SHIFT_MODIFIER_MASK)]),
# Translators: this is for navigating among fields in a form
# within a document.
#
- "next" : _("Goes to next form field.")
- },
+ "next" : (_("Goes to next form field."),
+ [("Tab", input_event.NO_MODIFIER_MASK)]),
+ },
"heading": {
# Translators: this is for navigating in a document by
# heading. (e.g. <h1>)
#
- "previous" : _("Goes to previous heading."),
+ "previous" : (_("Goes to previous heading."),
+ [("h", input_event.SHIFT_MODIFIER_MASK)]),
# Translators: this is for navigating in a document by
# heading. (e.g. <h1>)
#
- "next" : _("Goes to next heading.")
- },
+ "next" : (_("Goes to next heading."),
+ [("h", input_event.NO_MODIFIER_MASK)]),
+ },
"landmark": {
# Translators: this is for navigating to the previous ARIA
# role landmark. ARIA role landmarks are the W3C defined
# HTML tag attribute "role" used to identify important part
# of webpage like banners, main context, search etc.
#
- "previous" : _("Goes to previous landmark."),
+ "previous" : (_("Goes to previous landmark."),
+ [("d", input_event.SHIFT_MODIFIER_MASK)]),
# Translators: this is for navigating to the next ARIA
# role landmark. ARIA role landmarks are the W3C defined
# HTML tag attribute "role" used to identify important part
# of webpage like banners, main context, search etc.
#
- "next" : _("Goes to next landmark.")
- },
+ "next" : (_("Goes to next landmark."),
+ [("d", input_event.NO_MODIFIER_MASK)]),
+ },
"list": {
# Translators: this is for navigating among bulleted/numbered
# lists in a document.
#
- "previous" : _("Goes to previous list."),
+ "previous" : (_("Goes to previous list."),
+ [("l", input_event.SHIFT_MODIFIER_MASK)]),
# Translators: this is for navigating among bulleted/numbered
# lists in a document.
#
- "next" : _("Goes to next list.")
- },
+ "next" : (_("Goes to next list."),
+ [("l", input_event.NO_MODIFIER_MASK)]),
+ },
"listItem": {
# Translators: this is for navigating among bulleted/numbered
# list items in a document.
#
- "previous" : _("Goes to previous list item."),
+ "previous" : (_("Goes to previous list item."),
+ [("i", input_event.SHIFT_MODIFIER_MASK)]),
# Translators: this is for navigating among bulleted/numbered
# list items in a document.
#
- "next" : _("Goes to next list item.")
- },
+ "next" : (_("Goes to next list item."),
+ [("i", input_event.NO_MODIFIER_MASK)]),
+ },
"liveRegion": {
# Translators: this is for navigating between live regions
#
- "previous" : _("Goes to previous live region."),
+ "previous" : (_("Goes to previous live region."),
+ [("r", input_event.SHIFT_MODIFIER_MASK)]),
# Translators: this is for navigating between live regions
#
- "next" : _("Goes to next live region."),
+ "next" : (_("Goes to next live region."),
+ [("r", input_event.NO_MODIFIER_MASK)]),
# Translators: this is for navigating to the last live region
# to make an announcement.
#
- "last" : _("Goes to last live region.")
- },
+ "last" : (_("Goes to last live region."),
+ [("y", input_event.NO_MODIFIER_MASK)]),
+ },
"paragraph": {
# Translators: this is for navigating among paragraphs in a
# document.
#
- "previous" : _("Goes to previous paragraph."),
+ "previous" : (_("Goes to previous paragraph."),
+ [("p", input_event.SHIFT_MODIFIER_MASK)]),
# Translators: this is for navigating among paragraphs in a
# document.
#
- "next" : _("Goes to next paragraph.")
- },
+ "next" : (_("Goes to next paragraph."),
+ [("p", input_event.NO_MODIFIER_MASK)]),
+ },
"radioButton": {
# Translators: this is for navigating among radio buttons in
# a form within a document.
#
- "previous" : _("Goes to previous radio button."),
+ "previous" : (_("Goes to previous radio button."),
+ [("r", input_event.ORCA_SHIFT_MODIFIER_MASK)]),
# Translators: this is for navigating among radio buttons in
# a form within a document.
#
- "next" : _("Goes to next radio button.")
- },
+ "next" : (_("Goes to next radio button."),
+ [("r", input_event.ORCA_MODIFIER_MASK)]),
+ },
"table": {
# Translators: this is for navigating among tables in a
# document.
#
- "previous" : _("Goes to previous table."),
+ "previous" : (_("Goes to previous table."),
+ [("t", input_event.SHIFT_MODIFIER_MASK)]),
# Translators: this is for navigating among tables in a
# document.
#
- "next" : _("Goes to next table.")
- },
+ "next" : (_("Goes to next table."),
+ [("t", input_event.NO_MODIFIER_MASK)]),
+ },
"tableCell": {
# Translators: this is for navigating among table cells in a
# document.
#
- "left" : _("Goes left one cell."),
+ "left" : (_("Goes left one cell."),
+ [("Left", input_event.SHIFT_ALT_MODIFIER_MASK)]),
# Translators: this is for navigating among table cells in a
# document.
#
- "right" : _("Goes right one cell."),
+ "right" : (_("Goes right one cell."),
+ [("Right", input_event.SHIFT_ALT_MODIFIER_MASK)]),
# Translators: this is for navigating among table cells in a
# document.
#
- "up" : _("Goes up one cell."),
+ "up" : (_("Goes up one cell."),
+ [("Up", input_event.SHIFT_ALT_MODIFIER_MASK)]),
# Translators: this is for navigating among table cells in a
# document.
#
- "down" : _("Goes down one cell."),
+ "down" : (_("Goes down one cell."),
+ [("Down", input_event.SHIFT_ALT_MODIFIER_MASK)]),
# Translators: this is for navigating among table cells in a
# document.
#
- "first" : _("Goes to the first cell in a table."),
+ "first" : (_("Goes to the first cell in a table."),
+ [("Home", input_event.SHIFT_ALT_MODIFIER_MASK)]),
# Translators: this is for navigating among table cells in a
# document.
#
- "last" : _("Goes to the last cell in a table.")
- },
+ "last" : (_("Goes to the last cell in a table."),
+ [("End", input_event.SHIFT_ALT_MODIFIER_MASK)]),
+ },
"unvisitedLink": {
# Translators: this is for navigating among unvisited links
# in a document.
#
- "previous" : _("Goes to previous unvisited link."),
+ "previous" : (_("Goes to previous unvisited link."),
+ [("u", input_event.SHIFT_MODIFIER_MASK)]),
# Translators: this is for navigating among unvisited links
# in a document.
#
- "next" : _("Goes to next unvisited link.")
- },
+ "next" : (_("Goes to next unvisited link."),
+ [("u", input_event.NO_MODIFIER_MASK)]),
+ },
"visitedLink": {
# Translators: this is for navigating among visited links in
# a document.
#
- "previous" : _("Goes to previous visited link."),
+ "previous" : (_("Goes to previous visited link."),
+ [("v", input_event.SHIFT_MODIFIER_MASK)]),
# Translators: this is for navigating among visited links in
# a document.
#
- "next" : _("Goes to next visited link.")
- }
+ "next" : (_("Goes to next visited link."),
+ [("v", input_event.NO_MODIFIER_MASK)]),
+ }
}
minLevel, maxLevel = self._headingLevels()
for i in range(minLevel, maxLevel + 1):
@@ -272,67 +311,29 @@
# Translators: this is for navigating in a document by
# heading. (e.g. <h1> is a heading at level 1).
#
- "previous" : _("Goes to previous heading at level %d.") % i,
+ "previous" : (_("Goes to previous heading at level %d.") % i,
+ [(str(i), input_event.SHIFT_MODIFIER_MASK)]),
# Translators: this is for navigating in a document by heading.
# (e.g. <h1> is a heading at level 1).
#
- "next" : _("Goes to next heading at level %d.") % i
+ "next" : (_("Goes to next heading at level %d.") % i,
+ [(str(i), input_event.NO_MODIFIER_MASK)]),
}
- plugin.Plugin.__init__(self, owner, scriptSettings)
-
- def _createInputEventHandlers(self):
- """Defines InputEventHandler fields for this script that can be
- called by the key and braille bindings.
- """
- handlers = plugin.Plugin._createInputEventHandlers(self)
- handlers.update({
- "toggleStructuralNavigationHandler" : input_bindings.Handler(
- Plugin._toggleStructuralNavigation,
- # Translators: the structural navigation keys are designed
- # to move the caret around the document content by object
- # type. Thus H moves you to the next heading, Shift H to
- # the previous heading, T to the next table, and so on.
- # This feature needs to be toggle-able so that it does not
- # interfere with normal writing functions.
- #
- _("Toggles structural navigation keys.")),
- })
for objectType, descriptions in self._handlerDescriptions.items():
- objectType = objectType[0].capitalize() + objectType[1:]
+ objectType = objectType.capitalize()
for direction, description in descriptions.items():
- handler = "go%s%sHandler" % \
- (direction.capitalize(), objectType)
function = self._goDirectionFactory(objectType, direction)
- handlers.update({
- handler : input_bindings.Handler(
- function,
- description)
- })
- return handlers
-
- def _createKeyboardBindings(self, handlers):
- """Defines the key bindings for this script.
-
- Returns an instance of input_bindings.KeyboardBindings.
- """
- bindings = plugin.Plugin._createKeyboardBindings(self, handlers)
- bindings.extend(keyboardBindings)
- return bindings
-
- def _createBrailleBindings(self, handlers):
- """Defines the braille bindings for this script.
-
- Returns an instance of input_bindings.BrailleBindings.
- """
- bindings = plugin.Plugin._createBrailleBindings(self, handlers)
- bindings.extend(brailleBindings)
- return bindings
-
- def _toggleStructuralNavigation(self, inputEvent=None, modifiers=None):
- """Toggles structural navigation keys.
- """
- log.debug("_toggleStructuralNavigation: %s" % inputEvent)
+ bindings = []
+ for command, modifiers in description[1]:
+ bindings.append(input_binding.KeyboardBinding(
+ command,
+ input_event.defaultModifierMask,
+ modifiers))
+ self._inputEventHandlers.append(input_binding.InputHandler(
+ function,
+ description[0],
+ bindings))
def _headingLevels(self):
"""Returns the [minimum heading level, maximum heading level]
@@ -350,15 +351,14 @@
"first")
"""
- def _go(self, inputEvent=None, modifiers=None):
+ def _go(inputEvent=None):
"""Moves to the next instance of an object of a particular type
in a particular direction.
"""
- self._goObject(objectType, direction, inputEvent, modifiers)
+ self._goObject(objectType, direction, inputEvent)
return _go
- def _goObject(self, objectType, direction, inputEvent=None,
- modifiers=None):
+ def _goObject(self, objectType, direction, inputEvent=None):
"""Moves to the next (or previous) instance of an object of
objectType.
@@ -369,6 +369,26 @@
"""
log.debug("_goObject: %s %s %s" % (direction, objectType, inputEvent))
+ def _toggleStructuralNavigationHandler(self, inputEvent=None):
+ """Toggles structural navigation keys.
+ """
+ log.debug("_toggleStructuralNavigation: %s" % inputEvent)
+ # Translators: the structural navigation keys are designed
+ # to move the caret around the document content by object
+ # type. Thus H moves you to the next heading, Shift H to
+ # the previous heading, T to the next table, and so on.
+ # This feature needs to be toggle-able so that it does not
+ # interfere with normal writing functions.
+ #
+ _toggleStructuralNavigationHandler.description = \
+ _("Toggles structural navigation keys.")
+ _toggleStructuralNavigationHandler.bindings = [
+ input_binding.KeyboardBinding(
+ "z",
+ input_event.defaultModifierMask,
+ input_event.ORCA_MODIFIER_MASK)
+ ]
+
if __name__ == "__main__":
logging.basicConfig(format="%(name)s %(message)s")
log.setLevel(logging.DEBUG)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]