[orca/orca-gnome3: 48/87] Fix for bug #645286 - Orca should announce when WebKitGtk content has started or finished loading



commit cc9bc58b597d6ac0901afe6c8c9bafa3cdccd492
Author: Joanmarie Diggs <joanmarie diggs gmail com>
Date:   Sun Mar 20 02:52:38 2011 -0400

    Fix for bug #645286 - Orca should announce when WebKitGtk content has started or finished loading

 src/orca/scripts/toolkits/WebKitGtk/script.py |   67 +++++++++++++++++++++++++
 1 files changed, 67 insertions(+), 0 deletions(-)
---
diff --git a/src/orca/scripts/toolkits/WebKitGtk/script.py b/src/orca/scripts/toolkits/WebKitGtk/script.py
index a3c2033..d79a28c 100644
--- a/src/orca/scripts/toolkits/WebKitGtk/script.py
+++ b/src/orca/scripts/toolkits/WebKitGtk/script.py
@@ -31,6 +31,7 @@ import orca.scripts.default as default
 import orca.orca as orca
 import orca.orca_state as orca_state
 import orca.speech as speech
+from orca.orca_i18n import _
 
 from structural_navigation import StructuralNavigation
 from braille_generator import BrailleGenerator
@@ -55,6 +56,23 @@ class Script(default.Script):
         """
 
         default.Script.__init__(self, app)
+        self._loadingDocumentContent = False
+
+    def getListeners(self):
+        """Sets up the AT-SPI event listeners for this script."""
+
+        listeners = default.Script.getListeners(self)
+
+        listeners["document:reload"]                        = \
+            self.onDocumentReload
+        listeners["document:load-complete"]                 = \
+            self.onDocumentLoadComplete
+        listeners["document:load-stopped"]                  = \
+            self.onDocumentLoadStopped
+        listeners["object:state-changed:busy"]              = \
+            self.onStateChanged
+
+        return listeners
 
     def setupInputEventHandlers(self):
         """Defines InputEventHandler fields for this script that can be
@@ -115,6 +133,24 @@ class Script(default.Script):
 
         default.Script.onCaretMoved(self, event)
 
+    def onDocumentReload(self, event):
+        """Called when the reload button is hit for a web page."""
+
+        if event.source.getRole() == pyatspi.ROLE_DOCUMENT_FRAME:
+            self._loadingDocumentContent = True
+
+    def onDocumentLoadComplete(self, event):
+        """Called when a web page load is completed."""
+
+        if event.source.getRole() == pyatspi.ROLE_DOCUMENT_FRAME:
+            self._loadingDocumentContent = False
+
+    def onDocumentLoadStopped(self, event):
+        """Called when a web page load is interrupted."""
+
+        if event.source.getRole() == pyatspi.ROLE_DOCUMENT_FRAME:
+            self._loadingDocumentContent = False
+
     def onFocus(self, event):
         """Called whenever an object gets focus.
 
@@ -136,6 +172,37 @@ class Script(default.Script):
 
         default.Script.onFocus(self, event)
 
+    def onStateChanged(self, event):
+        """Called whenever an object's state changes.
+
+        Arguments:
+        - event: the Event
+        """
+
+        if not event.type.startswith("object:state-changed:busy"):
+            default.Script.onStateChanged(self, event)
+            return
+
+        if not event.source \
+           or event.source.getRole() != pyatspi.ROLE_DOCUMENT_FRAME:
+            return
+
+        if event.detail1:
+            # Translators: this is in reference to loading a web page
+            # or some other content.
+            #
+            self.presentMessage(_("Loading.  Please wait."))
+        elif event.source.name:
+            # Translators: this is in reference to loading a web page
+            # or some other content.
+            #
+            self.presentMessage(_("Finished loading %s.") % event.source.name)
+        else:
+            # Translators: this is in reference to loading a web page
+            # or some other content.
+            #
+            self.presentMessage(_("Finished loading."))
+
     def onTextSelectionChanged(self, event):
         """Called when an object's text selection changes.
 



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