[orca/gnome-3-14] Work around the GNOME Shell issues related to switcher presentation



commit 593e728bd0fc139beb419731789cff28319fba95
Author: Joanmarie Diggs <jdiggs igalia com>
Date:   Fri Oct 17 14:23:52 2014 -0400

    Work around the GNOME Shell issues related to switcher presentation
    
    Orca used to automatically present the selected item in a newly-shown
    switcher. It doesn't in GNOME 3.14. This is due to a couple of issues:
    
    * The ordering of accessible events has changed, so first we get the
      accessible event for the selected item. Then we get the one for the
      window activation. As a result, Orca ignores the selected item because
      it doesn't yet know the user is in a GNOME Shell window. (bgo738701)
    
    * The subsequent focused event for the containing panel, which does come
      after the window activation, should have be enough to cause Orca to
      automatically present the selected item even with the event ordering
      bug above. But this fails because Orca expects containers which contain
      selectable children to implement the accessible selection interface.
      GNOME Shell's switchers don't. (bgo738705)
    
    This commit hacks around the second issue and is sufficient to cause
    Orca to present the initially-selected item in a newly-shown switcher.

 src/orca/scripts/apps/gnome-shell/Makefile.am      |    3 +-
 src/orca/scripts/apps/gnome-shell/script.py        |    4 ++
 .../scripts/apps/gnome-shell/script_utilities.py   |   51 ++++++++++++++++++++
 3 files changed, 57 insertions(+), 1 deletions(-)
---
diff --git a/src/orca/scripts/apps/gnome-shell/Makefile.am b/src/orca/scripts/apps/gnome-shell/Makefile.am
index c49648e..6ef6bb9 100644
--- a/src/orca/scripts/apps/gnome-shell/Makefile.am
+++ b/src/orca/scripts/apps/gnome-shell/Makefile.am
@@ -1,6 +1,7 @@
 orca_python_PYTHON = \
        __init__.py \
        formatting.py \
-       script.py
+       script.py \
+       script_utilities.py
 
 orca_pythondir=$(pkgpythondir)/scripts/apps/gnome-shell
diff --git a/src/orca/scripts/apps/gnome-shell/script.py b/src/orca/scripts/apps/gnome-shell/script.py
index 942983f..1720148 100644
--- a/src/orca/scripts/apps/gnome-shell/script.py
+++ b/src/orca/scripts/apps/gnome-shell/script.py
@@ -33,6 +33,7 @@ import orca.orca as orca
 import orca.scripts.toolkits.clutter as clutter
 
 from .formatting import Formatting
+from .script_utilities import Utilities
 
 class Script(clutter.Script):
 
@@ -45,6 +46,9 @@ class Script(clutter.Script):
         """Returns the formatting strings for this script."""
         return Formatting(self)
 
+    def getUtilities(self):
+        return Utilities(self)
+
     def skipObjectEvent(self, event):
         """Determines whether or not this event should be skipped due to
         being redundant, part of an event flood, etc."""
diff --git a/src/orca/scripts/apps/gnome-shell/script_utilities.py 
b/src/orca/scripts/apps/gnome-shell/script_utilities.py
new file mode 100644
index 0000000..e088fb3
--- /dev/null
+++ b/src/orca/scripts/apps/gnome-shell/script_utilities.py
@@ -0,0 +1,51 @@
+# Orca
+#
+# Copyright (C) 2014 Igalia, S.L.
+#
+# Author: Joanmarie Diggs <jdiggs igalia com>
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the
+# Free Software Foundation, Inc., Franklin Street, Fifth Floor,
+# Boston MA  02110-1301 USA.
+
+__id__        = "$Id$"
+__version__   = "$Revision$"
+__date__      = "$Date$"
+__copyright__ = "Copyright (c) 2014 Igalia, S.L."
+__license__   = "LGPL"
+
+import pyatspi
+import orca.script_utilities as script_utilities
+
+class Utilities(script_utilities.Utilities):
+
+    def __init__(self, script):
+        script_utilities.Utilities.__init__(self, script)
+
+    def selectedChildren(self, obj):
+        try:
+            selection = obj.querySelection()
+        except:
+            # This is a workaround for bgo#738705.
+            if obj.getRole() != pyatspi.ROLE_PANEL:
+                return []
+
+            isSelected = lambda x: x and x.getState().contains(pyatspi.STATE_SELECTED)
+            children = pyatspi.findAllDescendants(obj, isSelected)
+        else:
+            children = []
+            for x in range(selection.nSelectedChildren):
+                children.append(selection.getSelectedChild(x))
+
+        return children


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