[orca] Fix for bgo 593666 - Add structural navigation key for separators.



commit 5ef2517dca95f8de22b048bbcfda11e606439859
Author: Joanmarie Diggs <joanmarie diggs gmail com>
Date:   Fri Feb 19 11:46:11 2010 -0500

    Fix for bgo 593666 - Add structural navigation key for separators.
    
    This implements an unbound keybinding. Users interested in this navigation
    can bind it to the desired keystroke in the Orca preferences for Firefox.

 src/orca/scripts/toolkits/Gecko/script.py |    1 +
 src/orca/structural_navigation.py         |   71 +++++++++++++++++++++++++++++
 2 files changed, 72 insertions(+), 0 deletions(-)
---
diff --git a/src/orca/scripts/toolkits/Gecko/script.py b/src/orca/scripts/toolkits/Gecko/script.py
index 8b1faa0..40623b8 100644
--- a/src/orca/scripts/toolkits/Gecko/script.py
+++ b/src/orca/scripts/toolkits/Gecko/script.py
@@ -343,6 +343,7 @@ class Script(default.Script):
                         GeckoStructuralNavigation.LIVE_REGION,
                         GeckoStructuralNavigation.PARAGRAPH,
                         GeckoStructuralNavigation.RADIO_BUTTON,
+                        GeckoStructuralNavigation.SEPARATOR,
                         GeckoStructuralNavigation.TABLE,
                         GeckoStructuralNavigation.TABLE_CELL,
                         GeckoStructuralNavigation.UNVISITED_LINK,
diff --git a/src/orca/structural_navigation.py b/src/orca/structural_navigation.py
index e4e56ef..d09d325 100644
--- a/src/orca/structural_navigation.py
+++ b/src/orca/structural_navigation.py
@@ -445,6 +445,7 @@ class StructuralNavigation:
     LIVE_REGION     = "liveRegion"
     PARAGRAPH       = "paragraph"
     RADIO_BUTTON    = "radioButton"
+    SEPARATOR       = "separator"
     TABLE           = "table"
     TABLE_CELL      = "tableCell"
     UNVISITED_LINK  = "unvisitedLink"
@@ -3135,6 +3136,76 @@ class StructuralNavigation:
 
     ########################
     #                      #
+    # Separators           #
+    #                      #
+    ########################
+
+    def _separatorBindings(self):
+        """Returns a dictionary of [keysymstring, modifiers, description]
+        lists for navigating amongst separators.
+        """
+
+        bindings = {}
+        # Translators: this is for navigating among separators, such as the
+        # <hr> tag, in a document.
+        #
+        prevDesc = _("Goes to previous separator.")
+        bindings["previous"] = ["", settings.SHIFT_MODIFIER_MASK, prevDesc]
+        # Translators: this is for navigating among separators, such as the
+        # <hr> tag, in a document.
+        #
+        nextDesc = _("Goes to next separator.")
+        bindings["next"] = ["", settings.NO_MODIFIER_MASK, nextDesc]
+        return bindings
+
+    def _separatorCriteria(self, collection, arg=None):
+        """Returns the MatchCriteria to be used for locating separators
+        by collection.
+
+        Arguments:
+        - collection: the collection interface for the document
+        - arg: an optional argument which may need to be included in
+          the criteria (e.g. the level of a heading).
+        """
+
+        role = [pyatspi.ROLE_SEPARATOR]
+        return MatchCriteria(collection, roles=role, applyPredicate=False)
+
+    def _separatorPredicate(self, obj, arg=None):
+        """The predicate to be used for verifying that the object
+        obj is a separator.
+
+        Arguments:
+        - obj: the accessible object under consideration.
+        - arg: an optional argument which may need to be included in
+          the criteria (e.g. the level of a heading).
+        """
+
+        return obj and obj.getRole() == pyatspi.ROLE_SEPARATOR
+
+    def _separatorPresentation(self, obj, arg=None):
+        """Presents the separator or indicates that one was not found.
+
+        Arguments:
+        - obj: the accessible object under consideration.
+        - arg: an optional argument which may need to be included in
+          the criteria (e.g. the level of a heading).
+        """
+
+        if obj:
+            [newObj, characterOffset] = self._getCaretPosition(obj)
+            self._setCaretPosition(newObj, characterOffset)
+            self._presentObject(obj, 0)
+        else:
+            # Translators: this is for navigating document content by
+            # moving amongst separators (e.g. <hr> tags). This string
+            # is what Orca will say if there are no more separators
+            # found.
+            #
+            speech.speak(_("No more separators."))
+
+    ########################
+    #                      #
     # Tables               #
     #                      #
     ########################



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