[orca] Web: Present the number of values present for a given dl term
- From: Joanmarie Diggs <joanied src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [orca] Web: Present the number of values present for a given dl term
- Date: Fri, 17 Jun 2022 15:42:07 +0000 (UTC)
commit 73ed2dc5c6819ddf641630379e28e909e3d8c201
Author: Joanmarie Diggs <jdiggs igalia com>
Date: Fri Jun 17 17:40:05 2022 +0200
Web: Present the number of values present for a given dl term
* In speech, only present the count after the role if it's not 1.
We do this to minimize chattiness.
* Always display the count for braille, at the end of the term's text.
See issue #248
src/orca/braille_generator.py | 7 +++++++
src/orca/formatting.py | 5 ++++-
src/orca/generator.py | 3 +++
src/orca/messages.py | 7 +++++++
src/orca/script_utilities.py | 20 ++++++++++++++++++++
src/orca/speech_generator.py | 10 ++++++++++
6 files changed, 51 insertions(+), 1 deletion(-)
---
diff --git a/src/orca/braille_generator.py b/src/orca/braille_generator.py
index 65e8efd50..9693a7ac3 100644
--- a/src/orca/braille_generator.py
+++ b/src/orca/braille_generator.py
@@ -345,6 +345,13 @@ class BrailleGenerator(generator.Generator):
return result
+ def _generateTermValueCount(self, obj, **args):
+ count = self._script.utilities.getValueCountForTerm(obj)
+ if count < 0:
+ return []
+
+ return ["(%s)" % messages.valueCountForTerm(count)]
+
def _generateStatusBar(self, obj, **args):
statusBar = self._script.utilities.statusBar(obj)
if not statusBar:
diff --git a/src/orca/formatting.py b/src/orca/formatting.py
index 7f0f40cbb..7c35ec528 100644
--- a/src/orca/formatting.py
+++ b/src/orca/formatting.py
@@ -205,7 +205,7 @@ formatting = {
'unfocused': 'labelOrName + pause + focusedItem + pause + multiselectableState +
(numberOfChildren or roleName) + pause'
},
pyatspi.ROLE_DESCRIPTION_TERM: {
- 'unfocused': '(labelOrName or (displayedText + allTextSelection) + roleName)',
+ 'unfocused': '(labelOrName or (displayedText + allTextSelection) + roleName + pause +
termValueCount)',
},
pyatspi.ROLE_DESCRIPTION_VALUE: {
'unfocused': '(labelOrName or (displayedText + allTextSelection) + roleName)',
@@ -630,6 +630,9 @@ formatting = {
'unfocused': '[Component(obj, asString(labelOrName + value + roleName), \
labelOrName and (len(asString(labelOrName)) + 1) or 0)]'
},
+ pyatspi.ROLE_DESCRIPTION_TERM: {
+ 'unfocused': BRAILLE_TEXT + ' + ([Region(" " + asString(termValueCount))])',
+ },
#pyatspi.ROLE_DESKTOP_ICON: 'default'
pyatspi.ROLE_DIAL: {
'unfocused': '[Component(obj,\
diff --git a/src/orca/generator.py b/src/orca/generator.py
index 805a32d35..7a8d5df76 100644
--- a/src/orca/generator.py
+++ b/src/orca/generator.py
@@ -510,6 +510,9 @@ class Generator:
return self._generateStatusBar(obj, **args)
+ def _generateTermValueCount(self, obj, **args):
+ return []
+
#####################################################################
# #
# Image information #
diff --git a/src/orca/messages.py b/src/orca/messages.py
index 545f3ede7..0cb2ffd10 100644
--- a/src/orca/messages.py
+++ b/src/orca/messages.py
@@ -2569,6 +2569,13 @@ def descriptionListTermCount(count):
return ngettext("Description list with %d term",
"Description list with %d terms", count) % count
+def valueCountForTerm(count):
+ # Translators: This message describes a description list.
+ # A given term ("dt" element) can have 0 or more values ("dd" elements).
+ # This message presents the number values a particular term has.
+ # See https://developer.mozilla.org/en-US/docs/Web/HTML/Element/dl
+ return ngettext("%d value", "%d values", count) % count
+
def mathTableSize(nRows, nColumns):
# Translators: this represents the number of rows in a mathematical table.
# See http://www.w3.org/TR/MathML3/chapter3.html#presm.mtable
diff --git a/src/orca/script_utilities.py b/src/orca/script_utilities.py
index f5fea3f57..1626e1302 100644
--- a/src/orca/script_utilities.py
+++ b/src/orca/script_utilities.py
@@ -5188,6 +5188,26 @@ class Utilities:
setSize = len(siblings)
return position, setSize
+ def getValueCountForTerm(self, obj):
+ if not self.isDescriptionListTerm(obj):
+ return -1
+
+ try:
+ index = obj.getIndexInParent()
+ total = obj.parent.childCount
+ except:
+ msg = "ERROR: Exception getting index and sibling count for %s" % obj
+ debug.println(debug.LEVEL_INFO, msg, True)
+ return -1
+
+ count = 0
+ for i in range(index + 1, total):
+ if not self.isDescriptionListDescription(obj.parent[i]):
+ break
+ count += 1
+
+ return count
+
def getRoleDescription(self, obj, isBraille=False):
return ""
diff --git a/src/orca/speech_generator.py b/src/orca/speech_generator.py
index e4e6a2ccf..40cc0ab48 100644
--- a/src/orca/speech_generator.py
+++ b/src/orca/speech_generator.py
@@ -1646,6 +1646,16 @@ class SpeechGenerator(generator.Generator):
result.extend(self.voice(DEFAULT, obj=obj, **args))
return result
+ def _generateTermValueCount(self, obj, **args):
+ count = self._script.utilities.getValueCountForTerm(obj)
+ # If we have a simple 1-term, 1-value situation, this announcment is chatty.
+ if count in (-1, 1):
+ return []
+
+ result = [messages.valueCountForTerm(count)]
+ result.extend(self.voice(SYSTEM, obj=obj, **args))
+ return result
+
def _generateNumberOfChildren(self, obj, **args):
"""Returns an array of strings (and possibly voice and audio
specifications) that represents the number of children the
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]