orca r3908 - in trunk: . src/orca src/orca/scripts/apps/gedit src/orca/scripts/apps/soffice
- From: richb svn gnome org
- To: svn-commits-list gnome org
- Subject: orca r3908 - in trunk: . src/orca src/orca/scripts/apps/gedit src/orca/scripts/apps/soffice
- Date: Tue, 20 May 2008 20:22:44 +0000 (UTC)
Author: richb
Date: Tue May 20 20:22:44 2008
New Revision: 3908
URL: http://svn.gnome.org/viewvc/orca?rev=3908&view=rev
Log:
* src/orca/scripts/apps/gedit/speech_generator.py:
src/orca/scripts/apps/gedit/Makefile.am:
src/orca/scripts/apps/gedit/script.py:
src/orca/scripts/apps/soffice/script.py:
src/orca/speechgenerator.py:
src/orca/default.py:
src/orca/where_am_I.py:
src/orca/braillegenerator.py:
Fixed bug #463646 - Orca doesn't announce the presence of
unfocused dialogs when an app gains focus.
Removed:
trunk/src/orca/scripts/apps/gedit/speech_generator.py
Modified:
trunk/ChangeLog
trunk/src/orca/braillegenerator.py
trunk/src/orca/default.py
trunk/src/orca/scripts/apps/gedit/Makefile.am
trunk/src/orca/scripts/apps/gedit/script.py
trunk/src/orca/scripts/apps/soffice/script.py
trunk/src/orca/speechgenerator.py
trunk/src/orca/where_am_I.py
Modified: trunk/src/orca/braillegenerator.py
==============================================================================
--- trunk/src/orca/braillegenerator.py (original)
+++ trunk/src/orca/braillegenerator.py Tue May 20 20:22:44 2008
@@ -37,6 +37,7 @@
import settings
from orca_i18n import _ # for gettext support
+from orca_i18n import ngettext # for ngettext support
class BrailleGenerator:
"""Takes accessible objects and produces a list of braille Regions
@@ -534,7 +535,38 @@
self._debugGenerator("_getBrailleRegionsForFrame", obj)
- return self._getDefaultBrailleRegions(obj)
+ regions = []
+
+ text = ""
+ text = self._script.appendString(
+ text, self._script.getDisplayedLabel(obj))
+ text = self._script.appendString(
+ text, self._script.getDisplayedText(obj))
+ text = self._script.appendString(text,
+ self._script.getTextForValue(obj))
+ text = self._script.appendString(text, self._getTextForRole(obj))
+
+ # If this application has more than one unfocused alert or
+ # dialog window, then add '(<m> dialogs)' to the braille context,
+ # to let the user know.
+ #
+ alertAndDialogCount = \
+ self._script.getUnfocusedAlertAndDialogCount(obj)
+ if alertAndDialogCount > 0:
+ # Translators: this tells the user how many unfocused
+ # alert and dialog windows plus the total number of
+ # windows that this application has.
+ #
+ line = ngettext("(%d dialog)",
+ "(%d dialogs)",
+ alertAndDialogCount) % alertAndDialogCount
+ text = self._script.appendString(text, line)
+
+ regions = []
+ componentRegion = braille.Component(obj, text)
+ regions.append(componentRegion)
+
+ return [regions, componentRegion]
def _getBrailleRegionsForHtmlContainer(self, obj):
"""Get the braille for an HTML container.
Modified: trunk/src/orca/default.py
==============================================================================
--- trunk/src/orca/default.py (original)
+++ trunk/src/orca/default.py Tue May 20 20:22:44 2008
@@ -2362,6 +2362,40 @@
else:
speech.speakCharacter(character, voice)
+
+ def isFunctionalDialog(self, obj):
+ """Returns true if the window is a functioning as a dialog.
+ This method should be subclassed by application scripts as needed.
+ """
+
+ return False
+
+ def getUnfocusedAlertAndDialogCount(self, obj):
+ """If the current application has one or more alert or dialog
+ windows and the currently focused window is not an alert or a dialog,
+ return a count of the number of alert and dialog windows, otherwise
+ return a count of zero.
+
+ Arguments:
+ - obj: the Accessible object
+
+ Returns the alert and dialog count.
+ """
+
+ alertAndDialogCount = 0
+ app = obj.getApplication()
+ window = self.getTopLevel(obj)
+ if window.getRole() != pyatspi.ROLE_ALERT and \
+ window.getRole() != pyatspi.ROLE_DIALOG and \
+ not self.isFunctionalDialog(window):
+ for child in app:
+ if child.getRole() == pyatspi.ROLE_ALERT or \
+ child.getRole() == pyatspi.ROLE_DIALOG or \
+ self.isFunctionalDialog(child):
+ alertAndDialogCount += 1
+
+ return alertAndDialogCount
+
def presentTooltip(self, obj):
"""
Speaks the tooltip for the current object of interest.
Modified: trunk/src/orca/scripts/apps/gedit/Makefile.am
==============================================================================
--- trunk/src/orca/scripts/apps/gedit/Makefile.am (original)
+++ trunk/src/orca/scripts/apps/gedit/Makefile.am Tue May 20 20:22:44 2008
@@ -2,8 +2,7 @@
orca_python_PYTHON = \
__init__.py \
- script.py \
- speech_generator.py
+ script.py
orca_pythondir=$(pyexecdir)/orca/scripts/apps/gedit
Modified: trunk/src/orca/scripts/apps/gedit/script.py
==============================================================================
--- trunk/src/orca/scripts/apps/gedit/script.py (original)
+++ trunk/src/orca/scripts/apps/gedit/script.py Tue May 20 20:22:44 2008
@@ -38,8 +38,6 @@
from orca.orca_i18n import _
-from speech_generator import SpeechGenerator
-
class Script(default.Script):
def __init__(self, app):
@@ -68,11 +66,6 @@
self.lastBadWord = ''
self.lastEventType = ''
- def getSpeechGenerator(self):
- """Returns the speech generator for this script.
- """
- return SpeechGenerator(self)
-
def getListeners(self):
"""Sets up the AT-SPI event listeners for this script.
"""
Modified: trunk/src/orca/scripts/apps/soffice/script.py
==============================================================================
--- trunk/src/orca/scripts/apps/soffice/script.py (original)
+++ trunk/src/orca/scripts/apps/soffice/script.py Tue May 20 20:22:44 2008
@@ -2053,3 +2053,33 @@
rv, start, end = \
default.Script.getTextAttributes(self, acc, offset, get_defaults)
return rv, start, end - 1
+
+ def isFunctionalDialog(self, obj):
+ """Returns true if the window is functioning as a dialog."""
+
+ # The OOo Navigator window looks like a dialog, acts like a
+ # dialog, and loses focus requiring the user to know that it's
+ # there and needs Alt+F6ing into. But officially it's a normal
+ # window.
+
+ # There doesn't seem to be (an efficient) top-down equivalent
+ # of isDesiredFocusedItem(). But OOo documents have root panes;
+ # this thing does not.
+ #
+ rolesList = [pyatspi.ROLE_FRAME,
+ pyatspi.ROLE_PANEL,
+ pyatspi.ROLE_PANEL,
+ pyatspi.ROLE_TOOL_BAR,
+ pyatspi.ROLE_PUSH_BUTTON]
+
+ if obj.getRole() != rolesList[0]:
+ # We might be looking at the child.
+ #
+ rolesList.pop(0)
+
+ while obj and obj.childCount and len(rolesList):
+ if obj.getRole() != rolesList.pop(0):
+ return False
+ obj = obj[0]
+
+ return True
Modified: trunk/src/orca/speechgenerator.py
==============================================================================
--- trunk/src/orca/speechgenerator.py (original)
+++ trunk/src/orca/speechgenerator.py Tue May 20 20:22:44 2008
@@ -604,13 +604,33 @@
Returns a list of utterances to be spoken for the object.
"""
- # [[[TODO: richb - readjusted to just get the default speech instead
- # of treating the frame like an alert and speaking all unrelated
- # labels. We'll need to see if this has any adverse effects and
- # adjust accordingly.]]]
- #
- utterances = self._getDefaultSpeech(obj, already_focused)
- #utterances = self._getSpeechForAlert(obj, already_focused)
+ utterances = []
+
+ if not already_focused:
+ label = self._getSpeechForObjectLabel(obj)
+ utterances.extend(label)
+ name = self._getSpeechForObjectName(obj)
+ if name != label:
+ utterances.extend(name)
+ utterances.extend(self._getSpeechForAllTextSelection(obj))
+ utterances.extend(self._getSpeechForObjectRole(obj))
+
+ # If this application has more than one unfocused alert or
+ # dialog window, then speak '<m> unfocused dialogs'
+ # to let the user know.
+ #
+ alertAndDialogCount = \
+ self._script.getUnfocusedAlertAndDialogCount(obj)
+ if alertAndDialogCount > 0:
+ # Translators: this tells the user how many unfocused
+ # alert and dialog windows that this application has.
+ #
+ line = ngettext("%d unfocused dialog",
+ "%d unfocused dialogs",
+ alertAndDialogCount) % alertAndDialogCount
+ utterances.append(line)
+
+ utterances.extend(self._getSpeechForObjectAvailability(obj))
self._debugGenerator("_getSpeechForFrame",
obj,
Modified: trunk/src/orca/where_am_I.py
==============================================================================
--- trunk/src/orca/where_am_I.py (original)
+++ trunk/src/orca/where_am_I.py Tue May 20 20:22:44 2008
@@ -1603,7 +1603,9 @@
1. The contents of the title bar of the application main window
2. If in a dialog box within an application, the contents of the
title bar of the dialog box.
- 3. Orca will pause briefly between these two pieces of information
+ 3. '<n> unfocused dialogs' if this application has more than
+ one unfocused alert or dialog window.
+ 4. Orca will pause briefly between these two pieces of information
so that the speech user can distinguish each.
"""
@@ -1618,6 +1620,17 @@
text = self.getObjLabelAndName(results[1])
utterances.append(text)
+ alertAndDialogCount = \
+ self._script.getUnfocusedAlertAndDialogCount(obj)
+ if alertAndDialogCount > 0:
+ # Translators: this tells the user how many unfocused
+ # alert and dialog windows that this application has.
+ #
+ line = ngettext("%d unfocused dialog",
+ "%d unfocused dialogs",
+ alertAndDialogCount) % alertAndDialogCount
+ utterances.append(line)
+
debug.println(self._debugLevel, "titlebar utterances=%s" % \
utterances)
speech.speakUtterances(utterances)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]