[orca/570658] Work on Gecko braille generator for links and images
- From: William Walker <wwalker src gnome org>
- To: svn-commits-list gnome org
- Subject: [orca/570658] Work on Gecko braille generator for links and images
- Date: Tue, 30 Jun 2009 18:13:10 +0000 (UTC)
commit bac7c4a51165f05daffc33a3fc6ecd96c8faaea6
Author: Willie Walker <william walker sun com>
Date: Tue Jun 30 13:53:23 2009 -0400
Work on Gecko braille generator for links and images
All the bug_*.py tests run well with this latest set of changes.
.../scripts/toolkits/Gecko/braille_generator.py | 88 +++++---------------
src/orca/scripts/toolkits/Gecko/formatting.py | 19 ++++-
2 files changed, 39 insertions(+), 68 deletions(-)
---
diff --git a/src/orca/scripts/toolkits/Gecko/braille_generator.py b/src/orca/scripts/toolkits/Gecko/braille_generator.py
index e777f20..23efcaa 100644
--- a/src/orca/scripts/toolkits/Gecko/braille_generator.py
+++ b/src/orca/scripts/toolkits/Gecko/braille_generator.py
@@ -50,73 +50,26 @@ class BrailleGenerator(braille_generator.BrailleGenerator):
def __init__(self, script):
braille_generator.BrailleGenerator.__init__(self, script)
+ def _generateImageLink(self, obj, **args):
+ """Returns the link (if any) for this image.
+ """
+ imageLink = None
+ role = args.get('role', obj.getRole())
+ if role == pyatspi.ROLE_IMAGE:
+ imageLink = self._script.getAncestor(obj,
+ [pyatspi.ROLE_LINK],
+ [pyatspi.ROLE_DOCUMENT_FRAME])
+ return imageLink
+
def _generateRoleName(self, obj, **args):
"""Prevents some roles from being spoken."""
result = []
role = args.get('role', obj.getRole())
- force = args.get('force', False)
-
- # Saying "menu item" for a combo box can confuse users. Therefore,
- # speak the combo box role instead. Also, only do it if the menu
- # item is not focused (if the menu item is focused, it means we're
- # navigating in the combo box)
- #
- if not obj.getState().contains(pyatspi.STATE_FOCUSED):
- comboBox = self._script.getAncestor(obj,
- [pyatspi.ROLE_COMBO_BOX],
- [pyatspi.ROLE_DOCUMENT_FRAME])
- if comboBox:
- return self._generateRoleName(comboBox, **args)
-
- if not force:
- doNotSpeak = [pyatspi.ROLE_FORM,
- pyatspi.ROLE_LABEL,
- pyatspi.ROLE_MENU_ITEM,
- pyatspi.ROLE_PARAGRAPH,
- pyatspi.ROLE_SECTION,
- pyatspi.ROLE_UNKNOWN]
- else:
- # We never ever want to speak 'unknown'
- #
- doNotSpeak = [pyatspi.ROLE_UNKNOWN]
-
- if not force and self._script.inDocumentContent(obj):
- doNotSpeak.append(pyatspi.ROLE_TABLE_CELL)
- if not self._script.isAriaWidget(obj) \
- and args.get('formatType', 'unfocused') != 'basicWhereAmI':
- doNotSpeak.append(pyatspi.ROLE_LIST_ITEM)
- doNotSpeak.append(pyatspi.ROLE_LIST)
-
- if not (role in doNotSpeak):
- if role == pyatspi.ROLE_IMAGE:
- link = self._script.getAncestor(obj,
- [pyatspi.ROLE_LINK],
- [pyatspi.ROLE_DOCUMENT_FRAME])
- if link:
- result.append(rolenames.getBrailleForRoleName(link))
-
- if role == pyatspi.ROLE_HEADING:
- level = self._script.getHeadingLevel(obj)
- if level:
- # Translators: the %(level)d is in reference to a heading
- # level in HTML (e.g., For <h3>, the level is 3)
- # and the %(role)s is in reference to a previously
- # translated rolename for the heading.
- #
- result.append(_("%(role)s level %(level)d") % {
- 'role': rolenames.getBrailleForRoleName(obj, role),
- 'level': level})
- else:
- result.append(rolenames.getBrailleForRoleName(obj, role))
- else:
- result.append(rolenames.getBrailleForRoleName(obj, role))
-
- if role == pyatspi.ROLE_LINK \
- and obj.childCount and obj[0].getRole() == pyatspi.ROLE_IMAGE:
- # If this is a link with a child which is an image, we
- # want to indicate that.
- #
- result.append(rolenames.getBrailleForRoleName(obj[0]))
+ if not obj.getRole() in [pyatspi.ROLE_SECTION,
+ pyatspi.ROLE_FORM,
+ pyatspi.ROLE_UNKNOWN]:
+ result.extend(braille_generator.BrailleGenerator._generateRoleName(
+ self, obj, **args))
return result
@@ -165,9 +118,7 @@ class BrailleGenerator(braille_generator.BrailleGenerator):
if role == pyatspi.ROLE_LINK:
link = obj
elif role == pyatspi.ROLE_IMAGE and not result:
- link = self._script.getAncestor(obj,
- [pyatspi.ROLE_LINK],
- [pyatspi.ROLE_DOCUMENT_FRAME])
+ link = self._generateImageLink(obj, **args)
if link and (not result or len(result[0].strip()) == 0):
# If there's no text for the link, expose part of the
# URI to the user.
@@ -481,6 +432,11 @@ class BrailleGenerator(braille_generator.BrailleGenerator):
#
# return [regions, textRegion]
#
+#
+# WDW - I *tried* to do up to here.
+#
+########################################################################
+#
# def _getBrailleRegionsForComboBox(self, obj):
# """Get the braille for a combo box. If the combo box already has
# focus, then only the selection is displayed.
diff --git a/src/orca/scripts/toolkits/Gecko/formatting.py b/src/orca/scripts/toolkits/Gecko/formatting.py
index 9d3c15b..b57466f 100644
--- a/src/orca/scripts/toolkits/Gecko/formatting.py
+++ b/src/orca/scripts/toolkits/Gecko/formatting.py
@@ -33,6 +33,13 @@ import orca.formatting
# pylint: disable-msg=C0301
+########################################################################
+# #
+# Formatting for things that are not ARIA widgets. For things that #
+# are ARIA widgets, we use the default formatting (see the #
+# getFormat method). #
+# #
+########################################################################
formatting = {
'speech': {
'suffix': {
@@ -88,12 +95,20 @@ formatting = {
'focused': '[Component(obj, asString(roleName))]',
'unfocused': '[Component(obj, asString(roleName))]'
},
+ pyatspi.ROLE_IMAGE: {
+ 'focused': '(imageLink\
+ and [Link(obj, asString(((label + displayedText) or name) + value + roleName))]\
+ or [Component(obj, asString(((label + displayedText) or name) + value + roleName))])',
+ 'unfocused': '(imageLink\
+ and [Link(obj, asString(((label + displayedText) or name) + value + roleName))]\
+ or [Component(obj, asString(((label + displayedText) or name) + value + roleName))])'
+ },
# [[[TODO: WDW - yikes! We need more parameters to send to
# the Link constructor.]]]
#
pyatspi.ROLE_LINK: {
- 'focused': '[Link(obj, asString(displayedText))]',
- 'unfocused': '[Link(obj, asString(displayedText))]'
+ 'focused': '[Link(obj, asString(currentLineText))]',
+ 'unfocused': '[Link(obj, asString(currentLineText))]'
}
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]