[orca] Announce when all items in a container have been selected
- From: Joanmarie Diggs <joanied src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [orca] Announce when all items in a container have been selected
- Date: Thu, 26 Jul 2018 14:39:45 +0000 (UTC)
commit 6bf2f4eb0b3c09f53d6769bf15bfe13ba5f08e3f
Author: Joanmarie Diggs <jdiggs igalia com>
Date: Thu Jul 26 10:38:23 2018 -0400
Announce when all items in a container have been selected
src/orca/messages.py | 4 ++++
src/orca/script_utilities.py | 31 +++++++++++++++++++++++++++++++
src/orca/scripts/default.py | 2 ++
src/orca/scripts/toolkits/gtk/script.py | 5 +++++
4 files changed, 42 insertions(+)
---
diff --git a/src/orca/messages.py b/src/orca/messages.py
index 62a3767c0..0ff4f0d2c 100644
--- a/src/orca/messages.py
+++ b/src/orca/messages.py
@@ -427,6 +427,10 @@ CONTAINER_END = _("End of container.")
# not a container, this message will be presented.
CONTAINER_NOT_IN_A = _("Not in a container.")
+# Translators: This message is presented when the user selects all of the items
+# in a container that supports selection, such as a GUI table or a list of icons.
+CONTAINER_SELECTED_ALL = _("all items selected")
+
# Translators: The "default" button in a dialog box is the button that gets
# activated when Enter is pressed anywhere within that dialog box.
DEFAULT_BUTTON_IS = _("Default button is %s")
diff --git a/src/orca/script_utilities.py b/src/orca/script_utilities.py
index 6aa7996a5..a581eacba 100644
--- a/src/orca/script_utilities.py
+++ b/src/orca/script_utilities.py
@@ -4974,6 +4974,37 @@ class Utilities:
return True
return False
+ def allItemsSelected(self, obj):
+ interfaces = pyatspi.listInterfaces(obj)
+ if "Selection" not in interfaces:
+ return False
+
+ if self.selectedChildCount(obj) == obj.childCount:
+ return True
+
+ if "Table" not in interfaces:
+ return False
+
+ table = obj.queryTable()
+ if table.nSelectedRows == table.nRows or table.nSelectedColumns == table.nColumns:
+ return True
+
+ return False
+
+ def handleContainerSelectionChange(self, obj):
+ allAlreadySelected = self._script.pointOfReference.get('allItemsSelected')
+ allCurrentlySelected = self.allItemsSelected(obj)
+ if allAlreadySelected and allCurrentlySelected:
+ return True
+
+ self._script.pointOfReference['allItemsSelected'] = allCurrentlySelected
+ if self.lastInputEventWasSelectAll() and allCurrentlySelected:
+ self._script.presentMessage(messages.CONTAINER_SELECTED_ALL)
+ orca.setLocusOfFocus(None, obj, False)
+ return True
+
+ return False
+
def handleTextSelectionChange(self, obj):
# Note: This guesswork to figure out what actually changed with respect
# to text selection will get eliminated once the new text-selection API
diff --git a/src/orca/scripts/default.py b/src/orca/scripts/default.py
index d94818137..06c02d86a 100644
--- a/src/orca/scripts/default.py
+++ b/src/orca/scripts/default.py
@@ -2462,6 +2462,8 @@ class Script(script.Script):
if self.utilities.handlePasteLocusOfFocusChange():
orca.setLocusOfFocus(event, event.source, False)
+ elif self.utilities.handleContainerSelectionChange(event.source):
+ return
else:
if state.contains(pyatspi.STATE_MANAGES_DESCENDANTS):
return
diff --git a/src/orca/scripts/toolkits/gtk/script.py b/src/orca/scripts/toolkits/gtk/script.py
index 494d19e66..1e0d0df4e 100644
--- a/src/orca/scripts/toolkits/gtk/script.py
+++ b/src/orca/scripts/toolkits/gtk/script.py
@@ -166,6 +166,11 @@ class Script(default.Script):
orca.setLocusOfFocus(event, None)
return
+ role = event.source.getRole()
+ if role in [pyatspi.ROLE_CANVAS, pyatspi.ROLE_ICON] \
+ and self.utilities.handleContainerSelectionChange(event.source.parent):
+ return
+
super().onSelectedChanged(event)
def onSelectionChanged(self, event):
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]