[orca] Present child position according to user preference in Suggestions lists
- From: Joanmarie Diggs <joanied src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [orca] Present child position according to user preference in Suggestions lists
- Date: Tue, 18 Aug 2015 23:22:36 +0000 (UTC)
commit a8890ac413d8e165f028c8cd9b5dd99247a6cad7
Author: Joanmarie Diggs <jdiggs igalia com>
Date: Tue Aug 18 19:21:08 2015 -0400
Present child position according to user preference in Suggestions lists
src/orca/scripts/apps/Thunderbird/script.py | 18 +++++++++++-------
src/orca/scripts/apps/Thunderbird/spellcheck.py | 13 +++++++++++++
src/orca/scripts/apps/gedit/script.py | 18 +++++++++++-------
src/orca/scripts/apps/gedit/spellcheck.py | 3 +++
src/orca/scripts/apps/soffice/script.py | 14 ++++++++++----
src/orca/scripts/apps/soffice/spellcheck.py | 4 ++++
src/orca/spellcheck.py | 11 +++++++++++
7 files changed, 63 insertions(+), 18 deletions(-)
---
diff --git a/src/orca/scripts/apps/Thunderbird/script.py b/src/orca/scripts/apps/Thunderbird/script.py
index 7eced35..f6a79b4 100644
--- a/src/orca/scripts/apps/Thunderbird/script.py
+++ b/src/orca/scripts/apps/Thunderbird/script.py
@@ -119,6 +119,17 @@ class Script(Gecko.Script):
Gecko.Script.doWhereAmI(self,inputEvent, basicOnly)
+ def locusOfFocusChanged(self, event, oldFocus, newFocus):
+ """Handles changes of focus of interest to the script."""
+
+ if self.spellcheck.isSuggestionsItem(newFocus):
+ includeLabel = not self.spellcheck.isSuggestionsItem(oldFocus)
+ self.updateBraille(newFocus)
+ self.spellcheck.presentSuggestionListItem(includeLabel=includeLabel)
+ return
+
+ super().locusOfFocusChanged(event, oldFocus, newFocus)
+
def _useFocusMode(self, obj):
if self.isEditableMessage(obj):
return True
@@ -153,13 +164,6 @@ class Script(Gecko.Script):
orca.setLocusOfFocus(event, event.source, False)
self.updateBraille(orca_state.locusOfFocus)
- if self.spellcheck.isSuggestionsItem(event.source) \
- and self.spellcheck.isSuggestionsItem(orca_state.locusOfFocus):
- orca.setLocusOfFocus(event, event.source, False)
- self.updateBraille(orca_state.locusOfFocus)
- self.spellcheck.presentSuggestionListItem()
- return
-
if not self.utilities.inDocumentContent(obj):
default.Script.onFocusedChanged(self, event)
return
diff --git a/src/orca/scripts/apps/Thunderbird/spellcheck.py b/src/orca/scripts/apps/Thunderbird/spellcheck.py
index 317067c..9466ec1 100644
--- a/src/orca/scripts/apps/Thunderbird/spellcheck.py
+++ b/src/orca/scripts/apps/Thunderbird/spellcheck.py
@@ -74,3 +74,16 @@ class SpellCheck(spellcheck.SpellCheck):
isList = lambda x: x and x.getRole() in [pyatspi.ROLE_LIST, pyatspi.ROLE_LIST_BOX] \
and 'Selection' in x.get_interfaces()
return pyatspi.findDescendant(root, isList)
+
+ def _getSuggestionIndexAndPosition(self, suggestion):
+ try:
+ attrs = dict([attr.split(':', 1) for attr in suggestion.getAttributes()])
+ except:
+ attrs = {}
+
+ index = attrs.get("posinset")
+ total = attrs.get("setsize")
+ if index is None or total is None:
+ return super()._getSuggestionIndexAndPosition(suggestion)
+
+ return int(index), int(total)
diff --git a/src/orca/scripts/apps/gedit/script.py b/src/orca/scripts/apps/gedit/script.py
index 099c524..72f9b28 100644
--- a/src/orca/scripts/apps/gedit/script.py
+++ b/src/orca/scripts/apps/gedit/script.py
@@ -71,6 +71,17 @@ class Script(gtk.Script):
gtk.Script.doWhereAmI(self,inputEvent, basicOnly)
+ def locusOfFocusChanged(self, event, oldFocus, newFocus):
+ """Handles changes of focus of interest to the script."""
+
+ if self.spellcheck.isSuggestionsItem(newFocus):
+ includeLabel = not self.spellcheck.isSuggestionsItem(oldFocus)
+ self.updateBraille(newFocus)
+ self.spellcheck.presentSuggestionListItem(includeLabel=includeLabel)
+ return
+
+ super().locusOfFocusChanged(event, oldFocus, newFocus)
+
def onActiveDescendantChanged(self, event):
"""Callback for object:active-descendant-changed accessibility events."""
@@ -94,13 +105,6 @@ class Script(gtk.Script):
if not event.detail1:
return
- if self.spellcheck.isSuggestionsItem(event.source) \
- and self.spellcheck.isSuggestionsItem(orca_state.locusOfFocus):
- orca.setLocusOfFocus(event, event.source, False)
- self.updateBraille(orca_state.locusOfFocus)
- self.spellcheck.presentSuggestionListItem()
- return
-
gtk.Script.onFocusedChanged(self, event)
def onNameChanged(self, event):
diff --git a/src/orca/scripts/apps/gedit/spellcheck.py b/src/orca/scripts/apps/gedit/spellcheck.py
index 62ea95e..b8fd8dc 100644
--- a/src/orca/scripts/apps/gedit/spellcheck.py
+++ b/src/orca/scripts/apps/gedit/spellcheck.py
@@ -64,3 +64,6 @@ class SpellCheck(spellcheck.SpellCheck):
isTable = lambda x: x and x.getRole() == pyatspi.ROLE_TABLE \
and 'Selection' in x.get_interfaces()
return pyatspi.findDescendant(root, isTable)
+
+ def _getSuggestionIndexAndPosition(self, suggestion):
+ return self._script.utilities.getPositionAndSetSize(suggestion)
diff --git a/src/orca/scripts/apps/soffice/script.py b/src/orca/scripts/apps/soffice/script.py
index 74a717c..47ffbf6 100644
--- a/src/orca/scripts/apps/soffice/script.py
+++ b/src/orca/scripts/apps/soffice/script.py
@@ -538,6 +538,12 @@ class Script(default.Script):
if self.flatReviewContext:
self.toggleFlatReviewMode()
+ if self.spellcheck.isSuggestionsItem(newLocusOfFocus) \
+ and not self.spellcheck.isSuggestionsItem(oldLocusOfFocus):
+ self.updateBraille(newLocusOfFocus)
+ self.spellcheck.presentSuggestionListItem(includeLabel=True)
+ return
+
# TODO - JD: Sad hack that wouldn't be needed if LO were fixed.
# If we are in the slide presentation scroll pane, also announce
# the current page tab. See bug #538056 for more details.
@@ -641,8 +647,11 @@ class Script(default.Script):
- event: the Event
"""
+ if self.utilities.isSameObject(event.any_data, orca_state.locusOfFocus):
+ return
+
if event.source == self.spellcheck.getSuggestionsList():
- if self.spellcheck.isSuggestionsItem(orca_state.locusOfFocus):
+ if event.source.getState().contains(pyatspi.STATE_FOCUSED):
orca.setLocusOfFocus(event, event.any_data, False)
self.updateBraille(orca_state.locusOfFocus)
self.spellcheck.presentSuggestionListItem()
@@ -650,9 +659,6 @@ class Script(default.Script):
self.spellcheck.presentErrorDetails()
return
- if self.utilities.isSameObject(event.any_data, orca_state.locusOfFocus):
- return
-
default.Script.onActiveDescendantChanged(self, event)
def onChildrenChanged(self, event):
diff --git a/src/orca/scripts/apps/soffice/spellcheck.py b/src/orca/scripts/apps/soffice/spellcheck.py
index 72bd903..b572b65 100644
--- a/src/orca/scripts/apps/soffice/spellcheck.py
+++ b/src/orca/scripts/apps/soffice/spellcheck.py
@@ -61,6 +61,10 @@ class SpellCheck(spellcheck.SpellCheck):
and x.parent.getRole() != pyatspi.ROLE_COMBO_BOX
return pyatspi.findDescendant(root, isList)
+ def _getSuggestionIndexAndPosition(self, suggestion):
+ index, total = self._script.utilities.getPositionAndSetSize(suggestion)
+ return index + 1, total
+
def getMisspelledWord(self):
try:
text = self._errorWidget.queryText()
diff --git a/src/orca/spellcheck.py b/src/orca/spellcheck.py
index 5a3bc3c..00e17ee 100644
--- a/src/orca/spellcheck.py
+++ b/src/orca/spellcheck.py
@@ -32,6 +32,8 @@ import re
from orca import guilabels
from orca import messages
+from orca import object_properties
+from orca import orca_state
from orca import settings
from orca import settings_manager
@@ -237,6 +239,12 @@ class SpellCheck:
if detailed or _settingsManager.getSetting('spellcheckSpellSuggestion'):
self._script.spellCurrentItem(string)
+ if _settingsManager.getSetting('enablePositionSpeaking') \
+ and items[0] == orca_state.locusOfFocus:
+ index, total = self._getSuggestionIndexAndPosition(items[0])
+ msg = object_properties.GROUP_INDEX_SPEECH % {"index": index, "total": total}
+ self._script.speakMessage(msg)
+
return True
def _clearState(self):
@@ -258,6 +266,9 @@ class SpellCheck:
def _findSuggestionsList(self, root):
return None
+ def _getSuggestionIndexAndPosition(self, suggestion):
+ return -1, -1
+
def getAppPreferencesGUI(self):
from gi.repository import Gtk
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]