[orca/gnome-3-6] Fix for Bug 675288 - Orca doesn't always announce selection changes in Nautilus 3.6's icon view



commit 41542eae79310b52644c5244724dbd50bc4fba8d
Author: Joanmarie Diggs <jdiggs igalia com>
Date:   Mon Oct 15 17:37:13 2012 -0400

    Fix for Bug 675288 - Orca doesn't always announce selection changes in Nautilus 3.6's icon view

 src/orca/formatting.py                   |   16 ++++++++++++++++
 src/orca/scripts/apps/nautilus/script.py |   24 +++++++++++++++++++++++-
 src/orca/speech_generator.py             |    3 ++-
 3 files changed, 41 insertions(+), 2 deletions(-)
---
diff --git a/src/orca/formatting.py b/src/orca/formatting.py
index 1963689..cc67f26 100644
--- a/src/orca/formatting.py
+++ b/src/orca/formatting.py
@@ -109,6 +109,12 @@ formatting = {
         pyatspi.ROLE_ANIMATION: {
             'unfocused': 'labelAndName'
             },
+        pyatspi.ROLE_CANVAS: {
+            'focused': 'labelAndName + imageDescription + roleName + positionInList',
+            'unfocused': 'labelAndName + imageDescription + roleName + positionInList',
+            'basicWhereAmI': 'parentRoleName + labelAndName + selectedItemCount',
+            'detailedWhereAmI': 'parentRoleName + labelAndName + selectedItemCount + selectedItems'
+            },
         pyatspi.ROLE_CHECK_BOX: {
             'focused': 'checkedState',
             'unfocused': 'labelAndName + roleName + checkedState + required + availability + ' + MNEMONIC + ' + accelerator',
@@ -359,6 +365,10 @@ formatting = {
                                      asString(label + displayedText + roleName + (description and space(": ") + description)))]',
             },
         #pyatspi.ROLE_ARROW: 'default'
+        pyatspi.ROLE_CANVAS: {
+            'unfocused': '[Component(obj,\
+                                     asString(((label + displayedText + imageDescription) or name) + roleName))]'
+            },
         pyatspi.ROLE_CHECK_BOX: {
             'unfocused': '[Component(obj,\
                                      asString(label + displayedText + roleName),\
@@ -537,6 +547,12 @@ formatting = {
 }
 
 if settings.useExperimentalSpeechProsody:
+    formatting['speech'][pyatspi.ROLE_CANVAS]['focused'] = 'labelAndName + imageDescription + roleName + pause + positionInList'
+    formatting['speech'][pyatspi.ROLE_CANVAS]['unfocused'] = 'labelAndName + imageDescription + roleName + pause + positionInList'
+    formatting['speech'][pyatspi.ROLE_CANVAS]['basicWhereAmI'] = \
+        'parentRoleName + pause + labelAndName + pause + selectedItemCount + pause'
+    formatting['speech'][pyatspi.ROLE_CANVAS]['detailedWhereAmI'] = \
+        'parentRoleName + pause + labelAndName + pause + selectedItemCount + pause + selectedItems + pause'
     formatting['speech'][pyatspi.ROLE_CHECK_MENU_ITEM]['unfocused'] = \
         'labelAndName + roleName + checkedState + required + availability + ' + MNEMONIC + ' + accelerator + pause + positionInList'
     formatting['speech'][pyatspi.ROLE_CHECK_MENU_ITEM]['basicWhereAmI'] = \
diff --git a/src/orca/scripts/apps/nautilus/script.py b/src/orca/scripts/apps/nautilus/script.py
index 0191070..686136b 100644
--- a/src/orca/scripts/apps/nautilus/script.py
+++ b/src/orca/scripts/apps/nautilus/script.py
@@ -30,7 +30,8 @@ import orca.debug as debug
 import orca.scripts.default as default
 import orca.speech as speech
 
-from orca.orca_i18n import ngettext  # for ngettext support
+from orca.orca_i18n import ngettext
+from orca.orca_i18n import C_
 
 ########################################################################
 #                                                                      #
@@ -250,3 +251,24 @@ class Script(default.Script):
                 return
 
         default.Script.onStateChanged(self, event)
+
+    def onSelectionChanged(self, event):
+        """Called when an object's selection changes.
+
+        Arguments:
+        - event: the Event
+        """
+
+        try:
+            role = event.source.getRole()
+        except:
+            return
+
+        # We present the selection changes in the layered pane as a result
+        # of the child announcing emitting an event for the state change.
+        # And the default script will update the locusOfFocus to the layered
+        # pane if nothing is selected.
+        if role == pyatspi.ROLE_LAYERED_PANE:
+            return
+
+        default.Script.onSelectionChanged(self, event)
diff --git a/src/orca/speech_generator.py b/src/orca/speech_generator.py
index ef1c3ce..589b101 100644
--- a/src/orca/speech_generator.py
+++ b/src/orca/speech_generator.py
@@ -1486,7 +1486,8 @@ class SpeechGenerator(generator.Generator):
         # TODO - JD: Is there a better way to do this other than
         # hard-coding it in?
         #
-        if args.get('role', obj.getRole()) == pyatspi.ROLE_ICON:
+        if args.get('role', obj.getRole()) \
+                in [pyatspi.ROLE_ICON, pyatspi.ROLE_CANVAS]:
             obj = obj.parent
         childCount = obj.childCount
         selectedItems = []



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]