[orca/570658] Move more methods from speech_generator.py to generator.py
- From: William Walker <wwalker src gnome org>
- To: svn-commits-list gnome org
- Subject: [orca/570658] Move more methods from speech_generator.py to generator.py
- Date: Fri, 26 Jun 2009 20:10:55 +0000 (UTC)
commit 0719bac5011a3510811ef61826ecffc92d144b6e
Author: Willie Walker <william walker sun com>
Date: Fri Jun 26 16:09:17 2009 -0400
Move more methods from speech_generator.py to generator.py
src/orca/generator.py | 70 ++++++++++++++++++++++++++++++++++++++---
src/orca/speech_generator.py | 58 ----------------------------------
2 files changed, 64 insertions(+), 64 deletions(-)
---
diff --git a/src/orca/generator.py b/src/orca/generator.py
index 6908d4d..5597f91 100644
--- a/src/orca/generator.py
+++ b/src/orca/generator.py
@@ -275,6 +275,33 @@ class Generator:
result.append(obj.description)
return result
+ def _generateLabelAndName(self, obj, **args):
+ """Returns the label and the name as an array of strings for speech
+ and braille. The name will only be present if the name is
+ different from the label.
+ """
+ result = []
+ label = self._generateLabel(obj, **args)
+ name = self._generateName(obj, **args)
+ result.extend(label)
+ if not len(label):
+ result.extend(name)
+ elif len(name) and name[0] != label[0]:
+ result.extend(name)
+ return result
+
+ def _generateLabelOrName(self, obj, **args):
+ """Returns the label as an array of strings for speech and braille.
+ If the label cannot be found, the name will be used instead.
+ If the name cannot be found, an empty array will be returned.
+ """
+ result = []
+ result.extend(self._generateLabel(obj, **args))
+ if not result:
+ if obj.name and (len(obj.name)):
+ result.append(obj.name)
+ return result
+
def _generateDescription(self, obj, **args):
"""Returns an array of strings fo use by speech and braille that
represent the description of the object, if that description
@@ -750,7 +777,7 @@ class Generator:
try:
parentTable = obj.parent.queryTable()
- except NotImplementedError:
+ except:
parentTable = None
isDetailedWhereAmI = args.get('formatType', None) == 'detailedWhereAmI'
if (settings.readTableCellRow or isDetailedWhereAmI) and parentTable \
@@ -765,18 +792,20 @@ class Generator:
# or just the current one (focus has moved left or right in
# the same row).
#
- speakAll = True
+ presentAll = True
if isDetailedWhereAmI:
if parentTable.nColumns <= 1:
return result
elif "lastRow" in self._script.pointOfReference \
and "lastColumn" in self._script.pointOfReference:
pointOfReference = self._script.pointOfReference
- speakAll = \
- (pointOfReference["lastRow"] != row) \
+ presentAll = \
+ (self._mode == 'braille') \
+ or \
+ ((pointOfReference["lastRow"] != row) \
or ((row == 0 or row == parentTable.nRows-1) \
- and pointOfReference["lastColumn"] == column)
- if speakAll:
+ and pointOfReference["lastColumn"] == column))
+ if presentAll:
args['readingRow'] = True
for i in range(0, parentTable.nColumns):
cell = parentTable.getAccessibleAt(row, i)
@@ -859,6 +888,35 @@ class Generator:
pass
return result
+ def _generateRadioButtonGroup(self, obj, **args):
+ """Returns an array of strings for use by speech and braille that
+ represents the radio button group label for the object, or an
+ empty array if the object has no such label.
+ """
+ result = []
+ if obj.getRole() == pyatspi.ROLE_RADIO_BUTTON:
+ radioGroupLabel = None
+ relations = obj.getRelationSet()
+ for relation in relations:
+ if (not radioGroupLabel) \
+ and (relation.getRelationType() \
+ == pyatspi.RELATION_LABELLED_BY):
+ radioGroupLabel = relation.getTarget(0)
+ break
+ if radioGroupLabel:
+ result.append(self._script.getDisplayedText(radioGroupLabel))
+ else:
+ parent = obj.parent
+ while parent and (parent.parent != parent):
+ if parent.getRole() in [pyatspi.ROLE_PANEL,
+ pyatspi.ROLE_FILLER]:
+ label = self._generateLabelAndName(parent)
+ if label:
+ result.extend(label)
+ break
+ parent = parent.parent
+ return result
+
def _generateRealActiveDescendantDisplayedText(self, obj, **args ):
"""Objects, such as tables and trees, can represent individual cells
via a complicated nested hierarchy. This method returns an
diff --git a/src/orca/speech_generator.py b/src/orca/speech_generator.py
index 7d7695a..1162d52 100644
--- a/src/orca/speech_generator.py
+++ b/src/orca/speech_generator.py
@@ -130,34 +130,6 @@ class SpeechGenerator(generator.Generator):
"""
return self._generateRoleName(obj, **args)
- def _generateLabelAndName(self, obj, **args):
- """Returns the label and the name as an array of strings (and possibly
- voice and audio specifications). The name will only be
- present if the name is different from the label.
- """
- result = []
- label = self._generateLabel(obj, **args)
- name = self._generateName(obj, **args)
- result.extend(label)
- if not len(label):
- result.extend(name)
- elif len(name) and name[0] != label[0]:
- result.extend(name)
- return result
-
- def _generateLabelOrName(self, obj, **args):
- """Returns the label as an array of strings (and possibly voice
- specifications). If the label cannot be found, the name will
- be used instead. If the name cannot be found, an empty array
- will be returned.
- """
- result = []
- result.extend(self._generateLabel(obj, **args))
- if not result:
- if obj.name and (len(obj.name)):
- result.append(obj.name)
- return result
-
def _generateUnrelatedLabels(self, obj, **args):
"""Returns, as an array of strings (and possibly voice
specifications), all the labels which are underneath the obj's
@@ -963,36 +935,6 @@ class SpeechGenerator(generator.Generator):
# #
#####################################################################
- def _generateRadioButtonGroup(self, obj, **args):
- """Returns an array of strings (and possibly voice and audio
- specifications) that represents the radio button group label
- for the object, or an empty array if the object has no such
- label.
- """
- result = []
- if obj.getRole() == pyatspi.ROLE_RADIO_BUTTON:
- radioGroupLabel = None
- relations = obj.getRelationSet()
- for relation in relations:
- if (not radioGroupLabel) \
- and (relation.getRelationType() \
- == pyatspi.RELATION_LABELLED_BY):
- radioGroupLabel = relation.getTarget(0)
- break
- if radioGroupLabel:
- result.append(self._script.getDisplayedText(radioGroupLabel))
- else:
- parent = obj.parent
- while parent and (parent.parent != parent):
- if parent.getRole() in [pyatspi.ROLE_PANEL,
- pyatspi.ROLE_FILLER]:
- label = self._generateLabelAndName(parent)
- if label:
- result.extend(label)
- break
- parent = parent.parent
- return result
-
def _generateNewRadioButtonGroup(self, obj, **args):
"""Returns an array of strings (and possibly voice and audio
specifications) that represents the radio button group label
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]