[orca/570658-whereami] More work on text where am I
- From: William Walker <wwalker src gnome org>
- To: svn-commits-list gnome org
- Subject: [orca/570658-whereami] More work on text where am I
- Date: Thu, 4 Jun 2009 21:38:51 -0400 (EDT)
commit 920c16876234e4600772ac2ec7f78ad091f4b932
Author: Willie Walker <william walker sun com>
Date: Thu Jun 4 21:30:13 2009 -0400
More work on text where am I
This addresses more text-like objects and also makes it easier to
see what code can be removed and what remains to be done.
---
src/orca/formatting.py | 20 +++++++++-
src/orca/where_am_I.py | 99 +++++++++++++++++++++++++++++++-----------------
2 files changed, 82 insertions(+), 37 deletions(-)
diff --git a/src/orca/formatting.py b/src/orca/formatting.py
index 7215249..bebeea9 100644
--- a/src/orca/formatting.py
+++ b/src/orca/formatting.py
@@ -76,7 +76,9 @@ formatting = {
},
pyatspi.ROLE_ENTRY: {
'focused': 'labelOrName + readOnly + textRole + currentLineText + allTextSelection',
- 'unfocused': 'labelOrName + readOnly + textRole + currentLineText + allTextSelection + mnemonic'
+ 'unfocused': 'labelOrName + readOnly + textRole + currentLineText + allTextSelection + mnemonic',
+ 'basicWhereAmI': 'label + readOnly + textRole + textContent + anyTextSelection + mnemonic + tutorial',
+ 'detailedWhereAmI': 'label + readOnly + textRole + textContentWithAttributes + anyTextSelection + mnemonic + tutorial'
},
pyatspi.ROLE_FRAME: {
'focused': '[]',
@@ -202,7 +204,9 @@ formatting = {
},
pyatspi.ROLE_TERMINAL: {
'focused': 'terminal',
- 'unfocused': 'terminal'
+ 'unfocused': 'terminal',
+ 'basicWhereAmI': 'label + readOnly + textRole + textContent + anyTextSelection + mnemonic + tutorial',
+ 'detailedWhereAmI': 'label + readOnly + textRole + textContentWithAttributes + anyTextSelection + mnemonic + tutorial'
},
pyatspi.ROLE_TEXT: {
'focused': 'labelOrName + readOnly + textRole + currentLineText + allTextSelection',
@@ -225,6 +229,18 @@ formatting = {
'basicWhereAmI': 'label + readOnly + textRole + textContent + anyTextSelection + mnemonic + tutorial',
'detailedWhereAmI': 'label + readOnly + textRole + textContentWithAttributes + anyTextSelection + mnemonic + tutorial'
},
+ pyatspi.ROLE_SECTION: {
+ 'basicWhereAmI': 'label + readOnly + textRole + textContent + anyTextSelection + mnemonic + tutorial',
+ 'detailedWhereAmI': 'label + readOnly + textRole + textContentWithAttributes + anyTextSelection + mnemonic + tutorial'
+ },
+ pyatspi.ROLE_HEADING: {
+ 'basicWhereAmI': 'label + readOnly + textRole + textContent + anyTextSelection + mnemonic + tutorial',
+ 'detailedWhereAmI': 'label + readOnly + textRole + textContentWithAttributes + anyTextSelection + mnemonic + tutorial'
+ },
+ pyatspi.ROLE_DOCUMENT_FRAME: {
+ 'basicWhereAmI': 'label + readOnly + textRole + textContent + anyTextSelection + mnemonic + tutorial',
+ 'detailedWhereAmI': 'label + readOnly + textRole + textContentWithAttributes + anyTextSelection + mnemonic + tutorial'
+ },
pyatspi.ROLE_EMBEDDED: {
'focused': 'embedded',
'unfocused': 'embedded'
diff --git a/src/orca/where_am_I.py b/src/orca/where_am_I.py
index 47ba375..f0bbc62 100644
--- a/src/orca/where_am_I.py
+++ b/src/orca/where_am_I.py
@@ -34,11 +34,9 @@ import text_attribute_names
from orca_i18n import _ # for gettext support
from orca_i18n import C_ # to provide qualified translatable strings
-# TODO - JD: As I remove duplicate/unnecessary methods from where_am_I.py,
-# I am replacing some with temporary calls to protected methods in the
-# speechgenerator. Therefore, disabling that complaint so I can find real
-# screw-ups. :-)
-# pylint: disable-msg=W0212
+# [[[TODO: WDW - need to handle the old _speakText functionality that changes
+# settings.verbalizePunctuationStyle = settings.PUNCTUATION_STYLE_SOME
+# if we're doing an extended where am I.]]]
class WhereAmI:
@@ -68,24 +66,52 @@ class WhereAmI:
role = obj.getRole()
if role in [pyatspi.ROLE_ENTRY,
- pyatspi.ROLE_TEXT,
- pyatspi.ROLE_TERMINAL]:
- self._speakText(obj, basicOnly)
-
- elif role in [pyatspi.ROLE_PARAGRAPH,
- pyatspi.ROLE_SECTION,
- pyatspi.ROLE_HEADING,
- pyatspi.ROLE_DOCUMENT_FRAME]:
- self._speakParagraph(obj, basicOnly)
-
+ pyatspi.ROLE_TEXT,
+ pyatspi.ROLE_PASSWORD_TEXT,
+ pyatspi.ROLE_TERMINAL,
+ pyatspi.ROLE_PARAGRAPH,
+ pyatspi.ROLE_SECTION,
+ pyatspi.ROLE_HEADING,
+ pyatspi.ROLE_DOCUMENT_FRAME]:
+ if True:
+ self._oldSpeakText(obj, basicOnly)
+ else:
+ self._speakText(obj, basicOnly)
else:
speech.speak(self.getWhereAmI(obj, basicOnly))
- self._lastAttributeString = ""
-
return True
def _speakText(self, obj, basicOnly):
+ # [[[TODO: WDW - we handle ROLE_ENTRY specially here because
+ # there is a bug in getRealActiveDescendant: it doesn't dive
+ # deep enough into the hierarchy (see comment #12 of bug
+ # #542714). So, we'll do this nasty hack until we can feel
+ # more comfortable with mucking around with
+ # getRealActiveDescendant.]]]
+ #
+ ancestor = self._script.getAncestor(obj,
+ [pyatspi.ROLE_TABLE_CELL,
+ pyatspi.ROLE_LIST_ITEM],
+ [pyatspi.ROLE_FRAME])
+ if ancestor and not self._script.isLayoutOnly(ancestor.parent):
+ if ancestor.getRole() == pyatspi.ROLE_TABLE_CELL:
+ if obj.getRole() != pyatspi.ROLE_ENTRY:
+ speech.speak(self.getWhereAmI(ancestor, basicOnly))
+ return
+ else:
+ speech.speak(self.getWhereAmI(ancestor, basicOnly))
+ return
+ speech.speak(self.getWhereAmI(obj, basicOnly))
+
+ ###########################################################################
+ # #
+ # WDW - all this can go... #
+ # vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv #
+ # #
+ ###########################################################################
+
+ def _oldSpeakText(self, obj, basicOnly):
"""Text boxes present the following information (an example is
'Source display: text, blank, Alt O'):
@@ -102,24 +128,27 @@ class WhereAmI:
Gaim, gedit, OpenOffice Writer and Terminal
"""
+ self._lastAttributeString = ""
+ # [[[TODO: WDW - we handle ROLE_ENTRY specially here because
+ # there is a bug in getRealActiveDescendant: it doesn't dive
+ # deep enough into the hierarchy (see comment #12 of bug
+ # #542714). So, we'll do this nasty hack until we can feel
+ # more comfortable with mucking around with
+ # getRealActiveDescendant.]]]
+ #
ancestor = self._script.getAncestor(obj,
[pyatspi.ROLE_TABLE_CELL,
pyatspi.ROLE_LIST_ITEM],
[pyatspi.ROLE_FRAME])
if ancestor and not self._script.isLayoutOnly(ancestor.parent):
- # [[[TODO: WDW - we handle ROLE_ENTRY specially here because
- # there is a bug in getRealActiveDescendant: it doesn't dive
- # deep enough into the hierarchy (see comment #12 of bug
- # #542714). So, we'll do this nasty hack until we can feel
- # more comfortable with mucking around with
- # getRealActiveDescendant.]]]
- #
if ancestor.getRole() == pyatspi.ROLE_TABLE_CELL:
if obj.getRole() != pyatspi.ROLE_ENTRY:
- return speech.speak(self.getWhereAmI(ancestor, basicOnly))
+ speech.speak(self.getWhereAmI(ancestor, basicOnly))
+ return
else:
- return speech.speak(self.getWhereAmI(ancestor, basicOnly))
+ speech.speak(self.getWhereAmI(ancestor, basicOnly))
+ return
utterances = []
text = self._script.speechGenerator._getLabel(obj)
@@ -147,8 +176,6 @@ class WhereAmI:
debug.println(self._debugLevel, "first text utterances=%s" % \
utterances)
print "OLD:", utterances
- print "NEW:", self.getWhereAmI(obj, basicOnly)
- print "================"
speech.speak(utterances)
if not basicOnly:
@@ -171,14 +198,9 @@ class WhereAmI:
debug.println(self._debugLevel, "text utterances=%s" % \
utterances)
speech.speak(utterances)
-
- def _speakParagraph(self, obj, basicOnly):
- """Speak a paragraph object.
- """
-
- print self.getWhereAmI(obj, basicOnly)
+ print "OLD:", utterances
+ print "NEW:", self.getWhereAmI(obj, basicOnly)
print "================"
- self._speakText(obj, basicOnly)
def _getTextContents(self, obj, basicOnly):
"""Returns utterences for text.
@@ -343,6 +365,13 @@ class WhereAmI:
else:
return ""
+ ###########################################################################
+ # #
+ # ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ #
+ # WDW - all this can go... #
+ # #
+ ###########################################################################
+
def getWhereAmI(self, obj, basicOnly):
"""Returns an array of strings (and possibly voice and audio
specifications) that represent the complete speech for the
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]