[orca] Add support for structural navigation by image
- From: Joanmarie Diggs <joanied src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [orca] Add support for structural navigation by image
- Date: Sat, 16 Aug 2014 15:11:52 +0000 (UTC)
commit 4841c1949787d4d2664591bddd1539bcbc9c6a12
Author: Joanmarie Diggs <jdiggs igalia com>
Date: Sat Aug 16 11:11:31 2014 -0400
Add support for structural navigation by image
src/orca/cmdnames.py | 9 +++
src/orca/guilabels.py | 11 ++++
src/orca/messages.py | 5 ++
src/orca/scripts/toolkits/Gecko/script.py | 1 +
src/orca/structural_navigation.py | 84 +++++++++++++++++++++++++++++
5 files changed, 110 insertions(+), 0 deletions(-)
---
diff --git a/src/orca/cmdnames.py b/src/orca/cmdnames.py
index 2b71686..b30a333 100644
--- a/src/orca/cmdnames.py
+++ b/src/orca/cmdnames.py
@@ -823,6 +823,15 @@ HEADING_AT_LEVEL_NEXT = _("Goes to next heading at level %d.")
# <h1> is a heading at level 1, <h2> is a heading at level 2, etc.
HEADING_AT_LEVEL_LIST = _("Displays a list of headings at level %d.")
+# Translators: this is for navigating among images in a document.
+IMAGE_PREV = _("Goes to previous image.")
+
+# Translators: this is for navigating among images in a document.
+IMAGE_NEXT = _("Goes to next image.")
+
+# Translators: this is for navigating among images in a document.
+IMAGE_LIST = _("Displays a list of images.")
+
# Translators: this is for navigating among ARIA landmarks in a document. ARIA
# role landmarks are the W3C defined HTML tag attribute 'role' used to identify
# important part of webpage like banners, main context, search etc.
diff --git a/src/orca/guilabels.py b/src/orca/guilabels.py
index ba7674d..5d12c82 100644
--- a/src/orca/guilabels.py
+++ b/src/orca/guilabels.py
@@ -396,6 +396,12 @@ SN_HEADER_HEADING = C_("structural navigation", "Heading")
# Translators: Orca has a command that presents a list of structural navigation
# objects in a dialog box so that users can navigate more quickly than they
# could with native keyboard navigation. This is the title for a column which
+# contains the text (alt text, title, etc.) associated with an image.
+SN_HEADER_IMAGE = C_("structural navigation", "Image")
+
+# Translators: Orca has a command that presents a list of structural navigation
+# objects in a dialog box so that users can navigate more quickly than they
+# could with native keyboard navigation. This is the title for a column which
# contains the label of a form field.
SN_HEADER_LABEL = C_("structural navigation", "Label")
@@ -532,6 +538,11 @@ SN_TITLE_HEADING = C_("structural navigation", "Headings")
# Translators: Orca has a command that presents a list of structural navigation
# objects in a dialog box so that users can navigate more quickly than they
# could with native keyboard navigation. This is the title of such a dialog box.
+SN_TITLE_IMAGE = C_("structural navigation", "Images")
+
+# Translators: Orca has a command that presents a list of structural navigation
+# objects in a dialog box so that users can navigate more quickly than they
+# could with native keyboard navigation. This is the title of such a dialog box.
# Level will be a "1" for <h1>, a "2" for <h2>, and so on.
SN_TITLE_HEADING_AT_LEVEL = C_("structural navigation", "Headings at Level %d")
diff --git a/src/orca/messages.py b/src/orca/messages.py
index 1fc1bc7..ffc550e 100644
--- a/src/orca/messages.py
+++ b/src/orca/messages.py
@@ -1199,6 +1199,11 @@ NO_MORE_HEADINGS = _("No more headings.")
# at the desired level can be found.
NO_MORE_HEADINGS_AT_LEVEL = _("No more headings at level %d.")
+# Translators: This is for navigating document content by moving from image
+# to image. This is a detailed message which will be presented to the user
+# if no more images can be found.
+NO_MORE_IMAGES = _("No more images.")
+
# 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.
diff --git a/src/orca/scripts/toolkits/Gecko/script.py b/src/orca/scripts/toolkits/Gecko/script.py
index 1fc41fd..3111e97 100644
--- a/src/orca/scripts/toolkits/Gecko/script.py
+++ b/src/orca/scripts/toolkits/Gecko/script.py
@@ -291,6 +291,7 @@ class Script(default.Script):
GeckoStructuralNavigation.ENTRY,
GeckoStructuralNavigation.FORM_FIELD,
GeckoStructuralNavigation.HEADING,
+ GeckoStructuralNavigation.IMAGE,
GeckoStructuralNavigation.LANDMARK,
GeckoStructuralNavigation.LINK,
GeckoStructuralNavigation.LIST,
diff --git a/src/orca/structural_navigation.py b/src/orca/structural_navigation.py
index f0a34d6..230eac0 100644
--- a/src/orca/structural_navigation.py
+++ b/src/orca/structural_navigation.py
@@ -532,6 +532,7 @@ class StructuralNavigation:
ENTRY = "entry"
FORM_FIELD = "formField"
HEADING = "heading"
+ IMAGE = "image"
LANDMARK = "landmark"
LINK = "link"
LIST = "list" # Bulleted/numbered lists
@@ -574,6 +575,9 @@ class StructuralNavigation:
pyatspi.ROLE_DOCUMENT_FRAME,
pyatspi.ROLE_DOCUMENT_WEB]
+ IMAGE_ROLES = [pyatspi.ROLE_IMAGE,
+ pyatspi.ROLE_IMAGE_MAP]
+
def __init__(self, script, enabledTypes, enabled=False):
"""Creates an instance of the StructuralNavigation class.
@@ -1699,6 +1703,15 @@ class StructuralNavigation:
item = self._getSelectedItem(obj)
if item:
text = item.name
+ if not text and obj.getRole() == pyatspi.ROLE_IMAGE:
+ try:
+ image = obj.queryImage()
+ except:
+ text = obj.description
+ else:
+ text = image.imageDescription or obj.description
+ if not text and obj.parent.getRole() == pyatspi.ROLE_LINK:
+ text = self._script.utilities.linkBasename(obj.parent)
return text
@@ -2525,6 +2538,77 @@ class StructuralNavigation:
########################
# #
+ # Images #
+ # #
+ ########################
+
+ def _imageBindings(self):
+ """Returns a dictionary of [keysymstring, modifiers, description]
+ lists for navigating amongst images."""
+
+ bindings = {}
+ prevDesc = cmdnames.IMAGE_PREV
+ bindings["previous"] = ["g", keybindings.SHIFT_MODIFIER_MASK, prevDesc]
+
+ nextDesc = cmdnames.IMAGE_NEXT
+ bindings["next"] = ["g", keybindings.NO_MODIFIER_MASK, nextDesc]
+
+ listDesc = cmdnames.IMAGE_LIST
+ bindings["list"] = ["g", keybindings.SHIFT_ALT_MODIFIER_MASK, listDesc]
+ return bindings
+
+ def _imageCriteria(self, collection, arg=None):
+ """Returns the MatchCriteria to be used for locating images
+ 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).
+ """
+
+ return MatchCriteria(collection, roles=self.IMAGE_ROLES)
+
+ def _imagePredicate(self, obj, arg=None):
+ """The predicate to be used for verifying that the object
+ obj is an image.
+
+ 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() in self.IMAGE_ROLES)
+
+ def _imagePresentation(self, obj, arg=None):
+ """Presents the image/graphic 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:
+ full = messages.NO_MORE_IMAGES
+ brief = messages.STRUCTURAL_NAVIGATION_NOT_FOUND
+ self._script.presentMessage(full, brief)
+
+ def _imageDialogData(self):
+ columnHeaders = [guilabels.SN_HEADER_IMAGE]
+
+ def rowData(obj):
+ return [self._getText(obj) or self._getRoleName(obj)]
+
+ return guilabels.SN_TITLE_IMAGE, columnHeaders, rowData
+
+ ########################
+ # #
# Landmarks #
# #
########################
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]