[orca] Fix for the following bugs:



commit 7939dc6fdcac69d1b0895f272d6d5f5fe4fe37c9
Author: Joanmarie Diggs <joanmarie diggs gmail com>
Date:   Sat Jan 8 23:47:27 2011 -0500

    Fix for the following bugs:
    
    * bug #639673 - Orca should support the creation and use of version-
      specific scripts for applications
    
    * bug #607854 - Yelp+WebKit not working well

 configure.in                                       |    2 +
 src/orca/script_manager.py                         |    5 +-
 src/orca/scripts/apps/yelp/Makefile.am             |    8 +-
 src/orca/scripts/apps/yelp/__init__.py             |   24 ++++++--
 src/orca/scripts/apps/yelp/yelp_v2/Makefile.am     |    9 +++
 .../{script_settings.py => yelp_v2/__init__.py}    |    7 +-
 src/orca/scripts/apps/yelp/{ => yelp_v2}/script.py |    0
 .../apps/yelp/{ => yelp_v2}/script_settings.py     |    0
 .../apps/yelp/{ => yelp_v2}/script_utilities.py    |   12 ----
 src/orca/scripts/apps/yelp/yelp_v3/Makefile.am     |    7 ++
 .../{script_settings.py => yelp_v3/__init__.py}    |   11 ++--
 src/orca/scripts/apps/yelp/yelp_v3/script.py       |   64 ++++++++++++++++++++
 12 files changed, 117 insertions(+), 32 deletions(-)
---
diff --git a/configure.in b/configure.in
index 93d0ca6..f5d406b 100644
--- a/configure.in
+++ b/configure.in
@@ -130,6 +130,8 @@ src/orca/scripts/apps/rhythmbox/Makefile
 src/orca/scripts/apps/soffice/Makefile
 src/orca/scripts/apps/Thunderbird/Makefile
 src/orca/scripts/apps/yelp/Makefile
+src/orca/scripts/apps/yelp/yelp_v2/Makefile
+src/orca/scripts/apps/yelp/yelp_v3/Makefile
 src/orca/scripts/toolkits/Makefile
 src/orca/scripts/toolkits/Gecko/Makefile
 src/orca/scripts/toolkits/J2SE-access-bridge/Makefile
diff --git a/src/orca/script_manager.py b/src/orca/script_manager.py
index 3619d40..da0c3af 100644
--- a/src/orca/script_manager.py
+++ b/src/orca/script_manager.py
@@ -133,7 +133,10 @@ class ScriptManager:
 
             debug.println(debug.LEVEL_FINE, "Found %s.py" % moduleName)
             try:
-                script = module.Script(app)
+                if hasattr(module, 'getScript'):
+                    script = module.getScript(app)
+                else:
+                    script = module.Script(app)
                 debug.println(debug.LEVEL_FINE, "Loaded %s.py" % moduleName)
                 break
             except:
diff --git a/src/orca/scripts/apps/yelp/Makefile.am b/src/orca/scripts/apps/yelp/Makefile.am
index 6af5e0a..a31ac91 100644
--- a/src/orca/scripts/apps/yelp/Makefile.am
+++ b/src/orca/scripts/apps/yelp/Makefile.am
@@ -1,10 +1,10 @@
 orca_pathdir=$(pyexecdir)
 
 orca_python_PYTHON = \
-	__init__.py \
-	script.py \
-	script_settings.py \
-	script_utilities.py
+	__init__.py
 
 orca_pythondir=$(pyexecdir)/orca/scripts/apps/yelp
 
+SUBDIRS = \
+	yelp_v2 \
+	yelp_v3
diff --git a/src/orca/scripts/apps/yelp/__init__.py b/src/orca/scripts/apps/yelp/__init__.py
index 1013677..aacda7d 100644
--- a/src/orca/scripts/apps/yelp/__init__.py
+++ b/src/orca/scripts/apps/yelp/__init__.py
@@ -1,6 +1,6 @@
 # Orca
 #
-# Copyright 2005-2010 Sun Microsystems Inc.
+# Copyright 2011 The Orca Team.
 #
 # This library is free software; you can redistribute it and/or
 # modify it under the terms of the GNU Lesser General Public
@@ -17,13 +17,27 @@
 # Free Software Foundation, Inc., Franklin Street, Fifth Floor,
 # Boston MA  02110-1301 USA.
 
-""" Custom script for Yelp.
-"""
+""" Custom script for Yelp."""
 
 __id__        = "$Id$"
 __version__   = "$Revision$"
 __date__      = "$Date$"
-__copyright__ = "Copyright (c) 2005-2010 Sun Microsystems Inc."
+__copyright__ = "Copyright (c) 2011 The Orca Team."
 __license__   = "LGPL"
 
-from script import Script
+import pyatspi
+from orca.script_utilities import Utilities
+
+def getScript(app):
+    """Returns the correct version of the Yelp script based on toolkit."""
+    docFrames = Utilities.descendantsWithRole(app, pyatspi.ROLE_DOCUMENT_FRAME)
+    print docFrames
+    if docFrames:
+        attrs = dict([a.split(':', 1) for a in docFrames[0].getAttributes()])
+        toolkit = attrs.get('toolkit', '')
+        if toolkit == 'WebKitGtk':
+            from yelp_v3 import script
+            return script.Script(app)
+
+    from yelp_v2 import script
+    return script.Script(app)
diff --git a/src/orca/scripts/apps/yelp/yelp_v2/Makefile.am b/src/orca/scripts/apps/yelp/yelp_v2/Makefile.am
new file mode 100644
index 0000000..7c16705
--- /dev/null
+++ b/src/orca/scripts/apps/yelp/yelp_v2/Makefile.am
@@ -0,0 +1,9 @@
+orca_pathdir=$(pyexecdir)
+
+orca_python_PYTHON = \
+	__init__.py \
+	script.py \
+	script_settings.py \
+	script_utilities.py
+
+orca_pythondir=$(pyexecdir)/orca/scripts/apps/yelp/yelp_v2
diff --git a/src/orca/scripts/apps/yelp/script_settings.py b/src/orca/scripts/apps/yelp/yelp_v2/__init__.py
similarity index 87%
copy from src/orca/scripts/apps/yelp/script_settings.py
copy to src/orca/scripts/apps/yelp/yelp_v2/__init__.py
index 9c90fef..212c0ef 100644
--- a/src/orca/scripts/apps/yelp/script_settings.py
+++ b/src/orca/scripts/apps/yelp/yelp_v2/__init__.py
@@ -17,13 +17,12 @@
 # Free Software Foundation, Inc., Franklin Street, Fifth Floor,
 # Boston MA  02110-1301 USA.
 
+""" Custom script for Yelp v2."""
+
 __id__        = "$Id$"
 __version__   = "$Revision$"
 __date__      = "$Date$"
 __copyright__ = "Copyright (c) 2005-2010 Sun Microsystems Inc."
 __license__   = "LGPL"
 
-# Whether we should grab focus on a focusable ancestor when setting
-# the caret position. See bug 608149.
-#
-grabFocusOnAncestor = False
+from script import Script
diff --git a/src/orca/scripts/apps/yelp/script.py b/src/orca/scripts/apps/yelp/yelp_v2/script.py
similarity index 100%
rename from src/orca/scripts/apps/yelp/script.py
rename to src/orca/scripts/apps/yelp/yelp_v2/script.py
diff --git a/src/orca/scripts/apps/yelp/script_settings.py b/src/orca/scripts/apps/yelp/yelp_v2/script_settings.py
similarity index 100%
copy from src/orca/scripts/apps/yelp/script_settings.py
copy to src/orca/scripts/apps/yelp/yelp_v2/script_settings.py
diff --git a/src/orca/scripts/apps/yelp/script_utilities.py b/src/orca/scripts/apps/yelp/yelp_v2/script_utilities.py
similarity index 83%
rename from src/orca/scripts/apps/yelp/script_utilities.py
rename to src/orca/scripts/apps/yelp/yelp_v2/script_utilities.py
index f825dd5..a9eeabb 100644
--- a/src/orca/scripts/apps/yelp/script_utilities.py
+++ b/src/orca/scripts/apps/yelp/yelp_v2/script_utilities.py
@@ -104,15 +104,3 @@ class Utilities(Gecko.Utilities):
             return True
 
         return False
-
-    #########################################################################
-    #                                                                       #
-    # Utilities for working with the accessible text interface              #
-    #                                                                       #
-    #########################################################################
-
-    #########################################################################
-    #                                                                       #
-    # Miscellaneous Utilities                                               #
-    #                                                                       #
-    #########################################################################
diff --git a/src/orca/scripts/apps/yelp/yelp_v3/Makefile.am b/src/orca/scripts/apps/yelp/yelp_v3/Makefile.am
new file mode 100644
index 0000000..ff91537
--- /dev/null
+++ b/src/orca/scripts/apps/yelp/yelp_v3/Makefile.am
@@ -0,0 +1,7 @@
+orca_pathdir=$(pyexecdir)
+
+orca_python_PYTHON = \
+	__init__.py \
+	script.py
+
+orca_pythondir=$(pyexecdir)/orca/scripts/apps/yelp/yelp_v3
diff --git a/src/orca/scripts/apps/yelp/script_settings.py b/src/orca/scripts/apps/yelp/yelp_v3/__init__.py
similarity index 77%
rename from src/orca/scripts/apps/yelp/script_settings.py
rename to src/orca/scripts/apps/yelp/yelp_v3/__init__.py
index 9c90fef..ca2fdf1 100644
--- a/src/orca/scripts/apps/yelp/script_settings.py
+++ b/src/orca/scripts/apps/yelp/yelp_v3/__init__.py
@@ -1,6 +1,6 @@
 # Orca
 #
-# Copyright 2005-2010 Sun Microsystems Inc.
+# Copyright 2011 The Orca Team.
 #
 # This library is free software; you can redistribute it and/or
 # modify it under the terms of the GNU Lesser General Public
@@ -17,13 +17,12 @@
 # Free Software Foundation, Inc., Franklin Street, Fifth Floor,
 # Boston MA  02110-1301 USA.
 
+""" Custom script for Yelp v3."""
+
 __id__        = "$Id$"
 __version__   = "$Revision$"
 __date__      = "$Date$"
-__copyright__ = "Copyright (c) 2005-2010 Sun Microsystems Inc."
+__copyright__ = "Copyright (c) 2011 The Orca Team."
 __license__   = "LGPL"
 
-# Whether we should grab focus on a focusable ancestor when setting
-# the caret position. See bug 608149.
-#
-grabFocusOnAncestor = False
+from script import Script
diff --git a/src/orca/scripts/apps/yelp/yelp_v3/script.py b/src/orca/scripts/apps/yelp/yelp_v3/script.py
new file mode 100644
index 0000000..c7064b0
--- /dev/null
+++ b/src/orca/scripts/apps/yelp/yelp_v3/script.py
@@ -0,0 +1,64 @@
+# Orca
+#
+# Copyright 2011 The Orca Team.
+#
+# 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.
+
+""" Custom script for Yelp v3."""
+
+__id__        = "$Id$"
+__version__   = "$Revision$"
+__date__      = "$Date$"
+__copyright__ = "Copyright (c) 2011 The Orca Team."
+__license__   = "LGPL"
+
+import orca.scripts.toolkits.WebKitGtk as WebKitGtk
+
+from orca.structural_navigation import StructuralNavigation
+
+class Script(WebKitGtk.Script):
+
+    def __init__(self, app):
+        """Creates a new script for the given application."""
+
+        WebKitGtk.Script.__init__(self, app)
+
+    def getEnabledStructuralNavigationTypes(self):
+        """Returns a list of the structural navigation object types
+        enabled in this script."""
+
+        enabledTypes = [StructuralNavigation.ANCHOR,
+                        StructuralNavigation.BLOCKQUOTE,
+                        StructuralNavigation.BUTTON,
+                        StructuralNavigation.CHECK_BOX,
+                        StructuralNavigation.CHUNK,
+                        StructuralNavigation.COMBO_BOX,
+                        StructuralNavigation.ENTRY,
+                        StructuralNavigation.FORM_FIELD,
+                        StructuralNavigation.HEADING,
+                        StructuralNavigation.LANDMARK,
+                        StructuralNavigation.LIST,
+                        StructuralNavigation.LIST_ITEM,
+                        StructuralNavigation.LIVE_REGION,
+                        StructuralNavigation.PARAGRAPH,
+                        StructuralNavigation.RADIO_BUTTON,
+                        StructuralNavigation.SEPARATOR,
+                        StructuralNavigation.TABLE,
+                        StructuralNavigation.TABLE_CELL,
+                        StructuralNavigation.UNVISITED_LINK,
+                        StructuralNavigation.VISITED_LINK]
+
+        return enabledTypes



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