[orca] Add support for longdesc



commit f7d5fd83c711ad99bc2da5f587da5b0e3d208917
Author: Joanmarie Diggs <jdiggs igalia com>
Date:   Tue Aug 19 14:34:38 2014 -0400

    Add support for longdesc

 src/orca/formatting.py                             |    1 +
 src/orca/generator.py                              |   10 ++++++++++
 src/orca/object_properties.py                      |    4 ++++
 src/orca/script_utilities.py                       |    3 +++
 src/orca/scripts/toolkits/Gecko/formatting.py      |    2 +-
 .../scripts/toolkits/Gecko/script_utilities.py     |   15 +++++++++++++++
 src/orca/speech_generator.py                       |   10 ++++++++++
 7 files changed, 44 insertions(+), 1 deletions(-)
---
diff --git a/src/orca/formatting.py b/src/orca/formatting.py
index 08ce450..60a6ea0 100644
--- a/src/orca/formatting.py
+++ b/src/orca/formatting.py
@@ -65,6 +65,7 @@ formatting = {
             'iconindex': object_properties.ICON_INDEX_SPEECH,
             'groupindex': object_properties.GROUP_INDEX_SPEECH,
             'clickable': object_properties.STATE_CLICKABLE,
+            'haslongdesc': object_properties.STATE_HAS_LONGDESC,
         },
         'braille': {
             'eol': object_properties.EOL_INDICATOR_BRAILLE,
diff --git a/src/orca/generator.py b/src/orca/generator.py
index 83023eb..28acbe7 100644
--- a/src/orca/generator.py
+++ b/src/orca/generator.py
@@ -421,6 +421,16 @@ class Generator:
 
         return []
 
+    def _generateHasLongDesc(self, obj, **args):
+        if not args.get('mode', None):
+            args['mode'] = self._mode
+        args['stringType'] = 'haslongdesc'
+
+        if self._script.utilities.hasLongDesc(obj):
+            return [self._script.formatting.getString(**args)]
+
+        return []
+
     def _generateAvailability(self, obj, **args):
         """Returns an array of strings for use by speech and braille that
         represent the grayed/sensitivity/availability state of the
diff --git a/src/orca/object_properties.py b/src/orca/object_properties.py
index bd50294..08d936d 100644
--- a/src/orca/object_properties.py
+++ b/src/orca/object_properties.py
@@ -90,6 +90,10 @@ STATE_COLLAPSED = _("collapsed")
 # means the item's children are not showing; expanded means they are.
 STATE_EXPANDED = _("expanded")
 
+# Translators: This is a state which applies to elements in document conent
+# which have a longdesc attribute. http://www.w3.org/TR/WCAG20-TECHS/H45.html
+STATE_HAS_LONGDESC = _("has long description")
+
 # Translators: This is a state which applies to the orientation of widgets
 # such as sliders and scroll bars.
 STATE_HORIZONTAL = _("horizontal")
diff --git a/src/orca/script_utilities.py b/src/orca/script_utilities.py
index 96f4aab..5105e3b 100644
--- a/src/orca/script_utilities.py
+++ b/src/orca/script_utilities.py
@@ -2722,3 +2722,6 @@ class Utilities:
 
     def isClickableElement(self, obj):
         return False
+
+    def hasLongDesc(self, obj):
+        return False
diff --git a/src/orca/scripts/toolkits/Gecko/formatting.py b/src/orca/scripts/toolkits/Gecko/formatting.py
index b4ffa93..16a6de2 100644
--- a/src/orca/scripts/toolkits/Gecko/formatting.py
+++ b/src/orca/scripts/toolkits/Gecko/formatting.py
@@ -36,7 +36,7 @@ formatting = {
     'speech': {
         'suffix': {
             'focused': '[]',
-            'unfocused': 'newNodeLevel + unselectedCell + clickable + ' + orca.formatting.TUTORIAL + ' + 
description ',
+            'unfocused': 'newNodeLevel + unselectedCell + clickable + hasLongDesc + ' + 
orca.formatting.TUTORIAL + ' + description ',
             'basicWhereAmI': orca.formatting.TUTORIAL + ' + description + liveRegionDescription',
             'detailedWhereAmI' : '[]'
             },
diff --git a/src/orca/scripts/toolkits/Gecko/script_utilities.py 
b/src/orca/scripts/toolkits/Gecko/script_utilities.py
index 8caf788..b17698f 100644
--- a/src/orca/scripts/toolkits/Gecko/script_utilities.py
+++ b/src/orca/scripts/toolkits/Gecko/script_utilities.py
@@ -622,3 +622,18 @@ class Utilities(script_utilities.Utilities):
                 return True
 
         return False
+
+    def hasLongDesc(self, obj):
+        if not self._script.inDocumentContent(obj):
+            return False
+
+        try:
+            action = obj.queryAction()
+        except NotImplementedError:
+            return False
+
+        for i in range(action.nActions):
+            if action.getName(i) in ["showlongdesc"]:
+                return True
+
+        return False
diff --git a/src/orca/speech_generator.py b/src/orca/speech_generator.py
index 53340c6..02c6ba1 100644
--- a/src/orca/speech_generator.py
+++ b/src/orca/speech_generator.py
@@ -232,6 +232,16 @@ class SpeechGenerator(generator.Generator):
             result.extend(acss)
         return result
 
+    def _generateHasLongDesc(self, obj, **args):
+        if _settingsManager.getSetting('onlySpeakDisplayedText'):
+            return []
+
+        acss = self.voice(SYSTEM)
+        result = generator.Generator._generateHasLongDesc(self, obj, **args)
+        if result:
+            result.extend(acss)
+        return result
+
     def _generateTextRole(self, obj, **args):
         """A convenience method to prevent the pyatspi.ROLE_PARAGRAPH role
         from being spoken. In the case of a pyatspi.ROLE_PARAGRAPH


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