[orca] Replace some old table-related code with new utility methods
- From: Joanmarie Diggs <joanied src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [orca] Replace some old table-related code with new utility methods
- Date: Wed, 15 Feb 2017 21:14:41 +0000 (UTC)
commit e85ac72a3ea0e7dccceb4e99d56d5fdb1d47ab13
Author: Joanmarie Diggs <jdiggs igalia com>
Date: Wed Feb 15 16:13:29 2017 -0500
Replace some old table-related code with new utility methods
src/orca/scripts/default.py | 16 ++-------
src/orca/speech_generator.py | 78 +++--------------------------------------
2 files changed, 9 insertions(+), 85 deletions(-)
---
diff --git a/src/orca/scripts/default.py b/src/orca/scripts/default.py
index 2e170ee..8a4bc2d 100644
--- a/src/orca/scripts/default.py
+++ b/src/orca/scripts/default.py
@@ -769,19 +769,9 @@ class Script(script.Script):
# We want to save the current row and column of a newly focused
# or selected table cell so that on subsequent cell focus/selection
# we only present the changed location.
- self.pointOfReference['lastColumn'] = -1
- self.pointOfReference['lastRow'] = -1
- if role == pyatspi.ROLE_TABLE_CELL:
- try:
- table = obj.parent.queryTable()
- index = self.utilities.cellIndex(obj)
- column = table.getColumnAtIndex(index)
- row = table.getRowAtIndex(index)
- except:
- pass
- else:
- self.pointOfReference['lastColumn'] = column
- self.pointOfReference['lastRow'] = row
+ row, column = self.utilities.coordinatesForCell(obj)
+ self.pointOfReference['lastColumn'] = column
+ self.pointOfReference['lastRow'] = row
self.pointOfReference['checkedChange'] = \
hash(obj), state.contains(pyatspi.STATE_CHECKED)
diff --git a/src/orca/speech_generator.py b/src/orca/speech_generator.py
index 658aa32..7ae90a1 100644
--- a/src/orca/speech_generator.py
+++ b/src/orca/speech_generator.py
@@ -734,44 +734,11 @@ class SpeechGenerator(generator.Generator):
dictionary. The 'priorObj' is typically set by Orca to be the
previous object with focus.
"""
- result = []
- acss = self.voice(DEFAULT)
- if obj:
- priorObj = args.get('priorObj', None)
- try:
- priorParent = priorObj.parent
- except:
- priorParent = None
- if (obj.getRole() == pyatspi.ROLE_TABLE_CELL) \
- or (obj.parent and obj.parent.getRole() == pyatspi.ROLE_TABLE):
- try:
- table = priorParent.queryTable()
- except:
- table = None
- if table \
- and ((priorObj.getRole() == pyatspi.ROLE_TABLE_CELL) \
- or (priorObj.getRole() == pyatspi.ROLE_TABLE)):
- index = self._script.utilities.cellIndex(priorObj)
- oldRow = table.getRowAtIndex(index)
- else:
- oldRow = -1
+ if not self._script.utilities.cellRowChanged(obj):
+ return []
- try:
- table = obj.parent.queryTable()
- except:
- pass
- else:
- index = self._script.utilities.cellIndex(obj)
- newRow = table.getRowAtIndex(index)
- if (newRow >= 0) \
- and (index != newRow) \
- and ((newRow != oldRow) \
- or (obj.parent != priorParent)):
- result = self._generateRowHeader(obj, **args)
- if result:
- result.extend(acss)
- return result
+ return self._generateRowHeader(obj, **args)
def _generateNewColumnHeader(self, obj, **args):
"""Returns an array of strings (and possibly voice and audio
@@ -783,44 +750,11 @@ class SpeechGenerator(generator.Generator):
dictionary. The 'priorObj' is typically set by Orca to be the
previous object with focus.
"""
- result = []
- acss = self.voice(DEFAULT)
- if obj and not args.get('readingRow', False):
- priorObj = args.get('priorObj', None)
- try:
- priorParent = priorObj.parent
- except:
- priorParent = None
- if (obj.getRole() == pyatspi.ROLE_TABLE_CELL) \
- or (obj.parent and obj.parent.getRole() == pyatspi.ROLE_TABLE):
- try:
- table = priorParent.queryTable()
- except:
- table = None
- if table \
- and ((priorObj.getRole() == pyatspi.ROLE_TABLE_CELL) \
- or (priorObj.getRole() == pyatspi.ROLE_TABLE)):
- index = self._script.utilities.cellIndex(priorObj)
- oldCol = table.getColumnAtIndex(index)
- else:
- oldCol = -1
+ if not self._script.utilities.cellColumnChanged(obj):
+ return []
- try:
- table = obj.parent.queryTable()
- except:
- pass
- else:
- index = self._script.utilities.cellIndex(obj)
- newCol = table.getColumnAtIndex(index)
- if (newCol >= 0) \
- and (index != newCol) \
- and ((newCol != oldCol) \
- or (obj.parent != priorParent)):
- result = self._generateColumnHeader(obj, **args)
- if result:
- result.extend(acss)
- return result
+ return self._generateColumnHeader(obj, **args)
def _generateRealTableCell(self, obj, **args):
"""Orca has a feature to automatically read an entire row of a table
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]