[orca] Fix for bug #645474 - Orca should provide the option of performing a Say All when WebKitGtk content
- From: Joanmarie Diggs <joanied src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [orca] Fix for bug #645474 - Orca should provide the option of performing a Say All when WebKitGtk content
- Date: Mon, 21 Mar 2011 23:39:06 +0000 (UTC)
commit 318e8f0691e78a0b177cf542ce945585169444f1
Author: Joanmarie Diggs <joanmarie diggs gmail com>
Date: Mon Mar 21 19:37:47 2011 -0400
Fix for bug #645474 - Orca should provide the option of performing a Say All when WebKitGtk content is loaded
src/orca/scripts/toolkits/WebKitGtk/Makefile.am | 1 +
src/orca/scripts/toolkits/WebKitGtk/script.py | 71 +++++++++++++++++--
.../scripts/toolkits/WebKitGtk/script_settings.py | 31 +++++++++
3 files changed, 95 insertions(+), 8 deletions(-)
---
diff --git a/src/orca/scripts/toolkits/WebKitGtk/Makefile.am b/src/orca/scripts/toolkits/WebKitGtk/Makefile.am
index 308fda1..d589e53 100644
--- a/src/orca/scripts/toolkits/WebKitGtk/Makefile.am
+++ b/src/orca/scripts/toolkits/WebKitGtk/Makefile.am
@@ -4,6 +4,7 @@ orca_python_PYTHON = \
__init__.py \
braille_generator.py \
script.py \
+ script_settings.py \
speech_generator.py \
script_utilities.py \
structural_navigation.py
diff --git a/src/orca/scripts/toolkits/WebKitGtk/script.py b/src/orca/scripts/toolkits/WebKitGtk/script.py
index 335f172..58d24e2 100644
--- a/src/orca/scripts/toolkits/WebKitGtk/script.py
+++ b/src/orca/scripts/toolkits/WebKitGtk/script.py
@@ -1,8 +1,8 @@
# Orca
#
-# Copyright (C) 2010 Joanmarie Diggs
+# Copyright (C) 2010-2011 The Orca Team
#
-# Author: Joanmarie Diggs <joanied gnome org>
+# Author: Joanmarie Diggs <joanmarie diggs gmail com>
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
@@ -22,7 +22,7 @@
__id__ = "$Id$"
__version__ = "$Revision$"
__date__ = "$Date$"
-__copyright__ = "Copyright (c) 2010 Joanmarie Diggs"
+__copyright__ = "Copyright (c) 2010-2011 The Orca Team"
__license__ = "LGPL"
import pyatspi
@@ -37,6 +37,7 @@ import orca.orca_state as orca_state
import orca.speech as speech
from orca.orca_i18n import _
+import script_settings
from structural_navigation import StructuralNavigation
from braille_generator import BrailleGenerator
from speech_generator import SpeechGenerator
@@ -65,6 +66,8 @@ class Script(default.Script):
self._loadingDocumentContent = False
self._isBrowser = isBrowser
+ self.sayAllOnLoadCheckButton = None
+
def getListeners(self):
"""Sets up the AT-SPI event listeners for this script."""
@@ -116,6 +119,46 @@ class Script(default.Script):
return keyBindings
+ def getAppPreferencesGUI(self):
+ """Return a GtkVBox contain the application unique configuration
+ GUI items for the current application.
+ """
+
+ import gtk
+
+ vbox = gtk.VBox(False, 0)
+ vbox.set_border_width(12)
+ vbox.show()
+
+ # Translators: when the user loads a new page in WebKit, they
+ # can optionally tell Orca to automatically start reading a
+ # page from beginning to end.
+ #
+ label = \
+ _("Automatically start speaking a page when it is first _loaded")
+ self.sayAllOnLoadCheckButton = gtk.CheckButton(label)
+ self.sayAllOnLoadCheckButton.show()
+ vbox.pack_start(self.sayAllOnLoadCheckButton, False, False, 0)
+ self.sayAllOnLoadCheckButton.set_active(script_settings.sayAllOnLoad)
+
+ return vbox
+
+ def setAppPreferences(self, prefs):
+ """Write out the application specific preferences lines and set the
+ new values.
+
+ Arguments:
+ - prefs: file handle for application preferences.
+ """
+
+ prefs.writelines("\n")
+ prefix = "orca.scripts.toolkits.WebKitGtk.script_settings"
+ prefs.writelines("import %s\n\n" % prefix)
+
+ value = self.sayAllOnLoadCheckButton.get_active()
+ prefs.writelines("%s.sayAllOnLoad = %s\n" % (prefix, value))
+ script_settings.sayAllOnLoad = value
+
def getBrailleGenerator(self):
"""Returns the braille generator for this script."""
@@ -169,11 +212,23 @@ class Script(default.Script):
def onDocumentLoadComplete(self, event):
"""Called when a web page load is completed."""
- if event.source.getRole() == pyatspi.ROLE_DOCUMENT_FRAME:
- self._loadingDocumentContent = False
- if self._isBrowser:
- obj, offset = self.setCaretAtStart(event.source)
- orca.setLocusOfFocus(event, obj, False)
+ if event.source.getRole() != pyatspi.ROLE_DOCUMENT_FRAME:
+ return
+
+ self._loadingDocumentContent = False
+ if not self._isBrowser:
+ return
+
+ # TODO: We need to see what happens in Epiphany on pages where focus
+ # is grabbed rather than set the caret at the start. But for simple
+ # content in both Yelp and Epiphany this is alright for now.
+ obj, offset = self.setCaretAtStart(event.source)
+ orca.setLocusOfFocus(event, obj, False)
+
+ self.updateBraille(obj)
+ if script_settings.sayAllOnLoad \
+ and _settingsManager.getSetting('enableSpeech'):
+ self.sayAll(None)
def onDocumentLoadStopped(self, event):
"""Called when a web page load is interrupted."""
diff --git a/src/orca/scripts/toolkits/WebKitGtk/script_settings.py b/src/orca/scripts/toolkits/WebKitGtk/script_settings.py
new file mode 100644
index 0000000..1c0a7c4
--- /dev/null
+++ b/src/orca/scripts/toolkits/WebKitGtk/script_settings.py
@@ -0,0 +1,31 @@
+# Orca
+#
+# Copyright (C) 2010-2011 The Orca Team
+#
+# Author: Joanmarie Diggs <joanmarie diggs gmail 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) 2010-2011 The Orca Team"
+__license__ = "LGPL"
+
+# If True, it tells Orca to automatically perform a SayAll operation
+# when a page is first loaded.
+#
+sayAllOnLoad = True
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]