[orca] Create a dedicated object:state-changed callback for the "expanded" state



commit f995235a52bbd83b6decf3e0d8db455f66440c22
Author: Joanmarie Diggs <jdiggs igalia com>
Date:   Mon Nov 4 13:55:45 2013 -0500

    Create a dedicated object:state-changed callback for the "expanded" state
    
    Also make gnome-shell's Alt+Tab switcher a bit less chatty when an item
    gets expanded or collapsed.

 src/orca/formatting.py                             |    1 +
 src/orca/scripts/apps/pidgin/script.py             |   26 +++++++-------------
 src/orca/scripts/default.py                        |   24 ++++++++++-------
 .../scripts/toolkits/J2SE-access-bridge/script.py  |    8 ------
 4 files changed, 24 insertions(+), 35 deletions(-)
---
diff --git a/src/orca/formatting.py b/src/orca/formatting.py
index cd06602..5cb9c19 100644
--- a/src/orca/formatting.py
+++ b/src/orca/formatting.py
@@ -224,6 +224,7 @@ formatting = {
             'unfocused': 'labelAndName + percentage'
             },
         pyatspi.ROLE_PUSH_BUTTON: {
+            'focused': 'expandableState',
             'unfocused': 'labelAndName + expandableState + roleName + availability + ' + MNEMONIC + ' + 
accelerator',
             'basicWhereAmI': 'labelAndName + expandableState + roleName + ' + MNEMONIC + ' + accelerator'
             },
diff --git a/src/orca/scripts/apps/pidgin/script.py b/src/orca/scripts/apps/pidgin/script.py
index c78d615..9b9ed94 100644
--- a/src/orca/scripts/apps/pidgin/script.py
+++ b/src/orca/scripts/apps/pidgin/script.py
@@ -200,26 +200,18 @@ class Script(default.Script):
 
         default.Script.onWindowActivated(self, event)
 
-    def visualAppearanceChanged(self, event, obj):
-        """Called when the visual appearance of an object changes.
-        Overridden here because we get object:state-changed:expanded
-        events for the buddy list, but the obj is in a hidden column.
+    def onExpandedChanged(self, event):
+        """Callback for object:state-changed:expanded accessibility events."""
 
-        Arguments:
-        - event: if not None, the Event that caused this to happen
-        - obj: the Accessible whose visual appearance changed.
-        """
-
-        if self.chat.isInBuddyList(obj) \
-           and event.type.startswith("object:state-changed:expanded"):
-
-            # The event is associated with the invisible cell. Set it
-            # to the visible cell and then let the default script do
-            # its thing.
-            #
+        # Overridden here because the event.source is in a hidden column.
+        obj = event.source
+        if self.chat.isInBuddyList(obj):
             obj = obj.parent[obj.getIndexInParent() + 1]
+            self.updateBraille(obj)
+            speech.speak(self.speechGenerator.generateSpeech(obj, alreadyFocused=True))
+            return
             
-        default.Script.visualAppearanceChanged(self, event, obj)
+        default.Script.onExpandedChanged(self, event)
 
     def skipObjectEvent(self, event):
         # NOTE: This is here temporarily as part of the preparation for the
diff --git a/src/orca/scripts/default.py b/src/orca/scripts/default.py
index 524fd96..aec40b6 100644
--- a/src/orca/scripts/default.py
+++ b/src/orca/scripts/default.py
@@ -542,7 +542,7 @@ class Script(script.Script):
         listeners["object:state-changed:indeterminate"]     = \
             self.onStateChanged
         listeners["object:state-changed:expanded"]          = \
-            self.onStateChanged
+            self.onExpandedChanged
         listeners["object:state-changed:selected"]          = \
             self.onStateChanged
         listeners["object:text-attributes-changed"]         = \
@@ -2314,6 +2314,16 @@ class Script(script.Script):
 
         self._presentTextAtNewCaretPosition(event)
 
+    def onExpandedChanged(self, event):
+        """Callback for object:state-changed:expanded accessibility events."""
+
+        obj = event.source
+        if not self.utilities.isSameObject(obj, orca_state.locusOfFocus):
+            return
+
+        self.updateBraille(obj)
+        speech.speak(self.speechGenerator.generateSpeech(obj, alreadyFocused=True))
+
     def onFocus(self, event):
         """Called whenever an object gets focus.
 
@@ -5053,17 +5063,11 @@ state_change_notifiers[pyatspi.ROLE_CHECK_BOX]       = ("checked",
                                                         "indeterminate",
                                                         None)
 state_change_notifiers[pyatspi.ROLE_PANEL]           = ("showing", None)
-state_change_notifiers[pyatspi.ROLE_LABEL]           = ("showing",
-                                                        "expanded",
-                                                        None)
+state_change_notifiers[pyatspi.ROLE_LABEL]           = ("showing", None)
 state_change_notifiers[pyatspi.ROLE_NOTIFICATION]    = ("showing", None)
-state_change_notifiers[pyatspi.ROLE_PUSH_BUTTON]     = ("expanded", None)
 state_change_notifiers[pyatspi.ROLE_RADIO_BUTTON]    = ("checked", None)
 state_change_notifiers[pyatspi.ROLE_TOGGLE_BUTTON]   = ("checked",
                                                         "pressed",
                                                         None)
-state_change_notifiers[pyatspi.ROLE_TABLE_CELL]      = ("checked",
-                                                        "expanded",
-                                                        None)
-state_change_notifiers[pyatspi.ROLE_LIST_ITEM]       = ("expanded", None)
-state_change_notifiers[pyatspi.ROLE_MENU_ITEM]       = ("expanded", None)
+state_change_notifiers[pyatspi.ROLE_TABLE_CELL]      = ("checked", None)
+
diff --git a/src/orca/scripts/toolkits/J2SE-access-bridge/script.py 
b/src/orca/scripts/toolkits/J2SE-access-bridge/script.py
index 794e438..591365f 100644
--- a/src/orca/scripts/toolkits/J2SE-access-bridge/script.py
+++ b/src/orca/scripts/toolkits/J2SE-access-bridge/script.py
@@ -242,14 +242,6 @@ class Script(default.Script):
         - event: the Event
         """
 
-        # Handle state changes when JTree labels become expanded
-        # or collapsed.
-        #
-        if (event.source.getRole() == pyatspi.ROLE_LABEL) and \
-            event.type.startswith("object:state-changed:expanded"):
-            self.visualAppearanceChanged(event, event.source)
-            return
-
         # This is a workaround for a java-access-bridge bug (Bug 355011)
         # where popup menu events are not sent to Orca.
         #


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