[orca] fix bgo#618589 - when debugging in eclipse, sometimes orca reads the same line twice
- From: Joanmarie Diggs <joanied src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [orca] fix bgo#618589 - when debugging in eclipse, sometimes orca reads the same line twice
- Date: Fri, 21 May 2010 03:50:24 +0000 (UTC)
commit 1424a9ea408cb71caed401491defa13c87648562
Author: José Vilmar Estácio de Souza <vilmar informal com br>
Date: Fri May 21 00:25:56 2010 -0300
fix bgo#618589 - when debugging in eclipse, sometimes orca reads the same line twice
There are two situations in which this happened:
1. When a breakpoint is in a different file.
2. when a breakpoint is in different method.
in the first case the line wass announced twice because the events
object:state-changed:focused and
object:text-caret-moved were received by orca.
in the second case the line wass announced twice because two events
object:text-caret-moved were received by orca.
The patch compares the object to be announced with the objectthe
announced previously.
If they identical and they contain the same caret offset, the
object is discarded.
src/orca/scripts/apps/Eclipse/Makefile.am | 3 +-
src/orca/scripts/apps/Eclipse/script.py | 35 +++++++++-
src/orca/scripts/apps/Eclipse/script_utilities.py | 73 +++++++++++++++++++++
3 files changed, 108 insertions(+), 3 deletions(-)
---
diff --git a/src/orca/scripts/apps/Eclipse/Makefile.am b/src/orca/scripts/apps/Eclipse/Makefile.am
index cbfb0b5..86d449c 100644
--- a/src/orca/scripts/apps/Eclipse/Makefile.am
+++ b/src/orca/scripts/apps/Eclipse/Makefile.am
@@ -2,7 +2,8 @@ orca_pathdir=$(pyexecdir)
orca_python_PYTHON = \
__init__.py \
- script.py
+ script.py \
+ script_utilities.py
orca_pythondir=$(pyexecdir)/orca/scripts/apps/Eclipse
diff --git a/src/orca/scripts/apps/Eclipse/script.py b/src/orca/scripts/apps/Eclipse/script.py
index aa666a2..c0823ca 100644
--- a/src/orca/scripts/apps/Eclipse/script.py
+++ b/src/orca/scripts/apps/Eclipse/script.py
@@ -27,13 +27,14 @@ __license__ = "LGPL"
import orca.default as default
import orca.orca_state as orca_state
+import pyatspi
+from script_utilities import Utilities
########################################################################
# #
# The Eclipse script class. #
# #
########################################################################
-
class Script(default.Script):
def __init__(self, app):
@@ -43,7 +44,11 @@ class Script(default.Script):
def _presentTextAtNewCaretPosition(self, event, otherObj=None):
"""Updates braille, magnification, and outputs speech for the
event.source or the otherObj. Overridden here so that we can
- speak the line when a breakpoint is reached."""
+ speak the line when a breakpoint is reached.
+ """
+
+ if self.utilities.isDuplicateEvent(event):
+ return
# Let the default script's normal behavior do its thing
#
@@ -55,3 +60,29 @@ class Script(default.Script):
obj = otherObj or event.source
self.sayLine(obj)
+ def onFocus(self, event):
+ """Called whenever an object gets focus.
+ Overridden here so that we can save the current text cursor position when:
+ event is an object:state-changed:focused and
+ source is a pyatspi.ROLE_TEXT
+ Perhaps this should be moved to the default.py???
+
+ Arguments:
+ - event: the Event
+ """
+
+ # Let the default script's normal behavior do its thing
+ #
+ default.Script.onFocus(self, event)
+ #
+ if event.type.startswith("object:state-changed:focused") \
+ and event.source.getRole() == pyatspi.ROLE_TEXT:
+ # probably it was announced, time to save.
+ self._saveLastCursorPosition(event.source, \
+ event.source.queryText().caretOffset)
+
+ def getUtilities(self):
+ """Returns the utilites for this script."""
+
+ return Utilities(self)
+
diff --git a/src/orca/scripts/apps/Eclipse/script_utilities.py b/src/orca/scripts/apps/Eclipse/script_utilities.py
new file mode 100644
index 0000000..fc6c12c
--- /dev/null
+++ b/src/orca/scripts/apps/Eclipse/script_utilities.py
@@ -0,0 +1,73 @@
+# Orca
+#
+# Copyright 2010 Joanmarie Diggs.
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Library General Public
+# License as published by the Free Software Foundation; either
+# version 2 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
+# Library General Public License for more details.
+#
+# You should have received a copy of the GNU Library 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.
+
+"""Commonly-required utility methods needed by -- and potentially
+ customized by -- application and toolkit scripts. They have
+ been pulled out from the scripts because certain scripts had
+ gotten way too large as a result of including these methods."""
+
+__id__ = "$Id$"
+__version__ = "$Revision$"
+__date__ = "$Date$"
+__copyright__ = "Copyright (c) 2010 Joanmarie Diggs."
+__license__ = "LGPL"
+
+import orca.script_utilities as script_utilities
+
+#############################################################################
+# #
+# Utilities #
+# #
+#############################################################################
+
+class Utilities(script_utilities.Utilities):
+
+ def __init__(self, script):
+ """Creates an instance of the Utilities class.
+
+ Arguments:
+ - script: the script with which this instance is associated.
+ """
+
+ script_utilities.Utilities.__init__(self, script)
+
+ def isDuplicateEvent(self, event):
+ """Returns True if we believe this event is a duplicate which we
+ wish to ignore."""
+
+ if not event:
+ return False
+
+ if event.type.startswith("object:text-caret-moved"):
+ try:
+ obj, offset = \
+ self._script.pointOfReference["lastCursorPosition"]
+ except:
+ return False
+ else:
+ # Doing an intentional equality check rather than calling
+ # isSameObject() because we'd rather double-present an
+ # object than not present it at all.
+ #
+
+ return obj == event.source and offset == \
+ event.source.queryText().caretOffset
+
+ return False
+
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]