[orca] Part of the fix for bgo#616848 - Application and toolkit scripts should not call methods in braille.
- From: Joanmarie Diggs <joanied src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [orca] Part of the fix for bgo#616848 - Application and toolkit scripts should not call methods in braille.
- Date: Tue, 27 Apr 2010 03:18:19 +0000 (UTC)
commit 47af91a92e5c2882b2b8980e18dee469f815c97f
Author: Joanmarie Diggs <joanmarie diggs gmail com>
Date: Mon Apr 26 23:08:43 2010 -0400
Part of the fix for bgo#616848 - Application and toolkit scripts should not call methods in braille.py
src/orca/chat.py | 3 +-
src/orca/default.py | 436 +++++++++++++++++++++---
src/orca/scripts/apps/Instantbird/script.py | 3 +-
src/orca/scripts/apps/acroread.py | 13 +-
src/orca/scripts/apps/ekiga.py | 3 +-
src/orca/scripts/apps/evolution/script.py | 18 +-
src/orca/scripts/apps/gcalctool/script.py | 7 +-
src/orca/scripts/apps/gedit/script.py | 12 +-
src/orca/scripts/apps/gnome-panel.py | 3 +-
src/orca/scripts/apps/gnome-system-monitor.py | 15 +-
src/orca/scripts/apps/gtk-window-decorator.py | 3 +-
src/orca/scripts/apps/liferea.py | 13 +-
src/orca/scripts/apps/metacity.py | 3 +-
src/orca/scripts/apps/nautilus.py | 3 +-
src/orca/scripts/apps/packagemanager/script.py | 36 +-
src/orca/scripts/apps/pidgin/script.py | 3 +-
src/orca/scripts/apps/soffice/script.py | 25 +-
src/orca/structural_navigation.py | 3 +-
18 files changed, 459 insertions(+), 143 deletions(-)
---
diff --git a/src/orca/chat.py b/src/orca/chat.py
index e381520..0964bc7 100644
--- a/src/orca/chat.py
+++ b/src/orca/chat.py
@@ -27,7 +27,6 @@ __license__ = "LGPL"
import pyatspi
-import braille
import input_event
import keybindings
import orca_state
@@ -660,7 +659,7 @@ class Chat:
if len(text.strip()):
speech.speak(text)
- braille.displayMessage(text)
+ self._script.displayBrailleMessage(text)
def getMessageFromEvent(self, event):
"""Get the actual displayed message. This will almost always be the
diff --git a/src/orca/default.py b/src/orca/default.py
index 7205b68..1bbf7c9 100644
--- a/src/orca/default.py
+++ b/src/orca/default.py
@@ -1,6 +1,7 @@
# Orca
#
# Copyright 2004-2009 Sun Microsystems Inc.
+# 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
@@ -25,7 +26,8 @@ for GTK."""
__id__ = "$Id$"
__version__ = "$Revision$"
__date__ = "$Date$"
-__copyright__ = "Copyright (c) 2004-2009 Sun Microsystems Inc."
+__copyright__ = "Copyright (c) 2004-2009 Sun Microsystems Inc." \
+ "Copyright (c) 2010 Joanmarie Diggs"
__license__ = "LGPL"
import locale
@@ -2640,7 +2642,7 @@ class Script(script.Script):
if speechResult:
speech.speak(speechResult)
if brailleResult:
- braille.displayMessage(brailleResult)
+ self.displayBrailleMessage(brailleResult)
def doWhereAmI(self, inputEvent, basicOnly):
"""Peforms the whereAmI operation.
@@ -3217,9 +3219,9 @@ class Script(script.Script):
if not obj:
return
- braille.clear()
+ self.clearBraille()
- line = braille.Line()
+ line = self.getNewBrailleLine()
braille.addLine(line)
# For multiline text areas, we only show the context if we
@@ -3232,17 +3234,17 @@ class Script(script.Script):
text = None
result = self.brailleGenerator.generateBraille(obj)
- line.addRegions(result[0])
+ self.addBrailleRegionsToLine(result[0], line)
if extraRegion:
- line.addRegion(extraRegion)
+ self.addBrailleRegionToLine(extraRegion, line)
if extraRegion:
- braille.setFocus(extraRegion)
+ self.setBrailleFocus(extraRegion)
else:
- braille.setFocus(result[1])
+ self.setBrailleFocus(result[1])
- braille.refresh(True)
+ self.refreshBraille(True)
########################################################################
# #
@@ -3434,7 +3436,7 @@ class Script(script.Script):
if isinstance(region, braille.Text) \
and (region.accessible == obj):
if region.repositionCursor():
- braille.refresh(True)
+ self.refreshBraille(True)
brailleNeedsRepainting = False
break
@@ -4352,7 +4354,7 @@ class Script(script.Script):
# focus to an inaccessible application. See bug #519901 for
# more details.
#
- braille.clear()
+ self.clearBraille()
# Hide the flat review window and reset it so that it will be
# recreated.
@@ -4759,7 +4761,7 @@ class Script(script.Script):
debug.println(debug.LEVEL_OFF, infoString)
print infoString
speech.speak(infoString)
- braille.displayMessage(infoString)
+ self.displayBrailleMessage(infoString)
return True
@@ -4812,7 +4814,7 @@ class Script(script.Script):
# This text here is what is to be presented on the braille
# display.
#
- braille.displayMessage(_("Learn mode. Press escape to exit."))
+ self.displayBrailleMessage(_("Learn mode. Press escape to exit."))
settings.learnModeEnabled = True
return True
@@ -4962,7 +4964,7 @@ class Script(script.Script):
# keep the position the same as we move to characters above
# and below us.
#
- self.targetCursorCell = braille.cursorCell
+ self.targetCursorCell = self.getBrailleCursorCell()
return self.flatReviewContext
@@ -5024,19 +5026,19 @@ class Script(script.Script):
regions = []
regionWithFocus = None
- line = braille.Line()
- line.addRegions(regions)
+ line = self.getNewBrailleLine()
+ self.addBrailleRegionsToLine(regions, line)
braille.setLines([line])
- braille.setFocus(regionWithFocus, False)
+ self.setBrailleFocus(regionWithFocus, False)
if regionWithFocus:
- braille.panToOffset(regionWithFocus.brailleOffset \
- + regionWithFocus.cursorOffset)
+ self.panBrailleToOffset(regionWithFocus.brailleOffset \
+ + regionWithFocus.cursorOffset)
if self.justEnteredFlatReviewMode:
- braille.refresh(True, self.targetCursorCell)
+ self.refreshBraille(True, self.targetCursorCell)
self.justEnteredFlatReviewMode = False
else:
- braille.refresh(True, targetCursorCell)
+ self.refreshBraille(True, targetCursorCell)
def _setFlatReviewContextToBeginningOfBrailleDisplay(self):
"""Sets the character of interest to be the first character showing
@@ -5079,11 +5081,11 @@ class Script(script.Script):
associated with cell 0."""
if self.flatReviewContext:
- if braille.beginningIsShowing:
+ if self.isBrailleBeginningShowing():
self.flatReviewContext.goBegin(flat_review.Context.LINE)
self.reviewPreviousCharacter(inputEvent)
else:
- braille.panLeft(panAmount)
+ self.panBrailleInDirection(panAmount, panToLeft=True)
# This will update our target cursor cell
#
@@ -5095,7 +5097,7 @@ class Script(script.Script):
self.targetCursorCell = 1
self.updateBrailleReview(self.targetCursorCell)
- elif braille.beginningIsShowing and orca_state.locusOfFocus \
+ elif self.isBrailleBeginningShowing() and orca_state.locusOfFocus \
and self.isTextArea(orca_state.locusOfFocus):
# If we're at the beginning of a line of a multiline text
@@ -5125,11 +5127,11 @@ class Script(script.Script):
context.goBegin(flat_review.Context.LINE)
self.reviewPreviousCharacter(inputEvent)
else:
- braille.panLeft(panAmount)
+ self.panBrailleInDirection(panAmount, panToLeft=True)
# We might be panning through a flashed message.
#
braille.resetFlashTimer()
- braille.refresh(False, stopFlash=False)
+ self.refreshBraille(False, stopFlash=False)
return True
@@ -5153,11 +5155,11 @@ class Script(script.Script):
associated with cell 0."""
if self.flatReviewContext:
- if braille.endIsShowing:
+ if self.isBrailleEndShowing():
self.flatReviewContext.goEnd(flat_review.Context.LINE)
self.reviewNextCharacter(inputEvent)
else:
- braille.panRight(panAmount)
+ self.panBrailleInDirection(panAmount, panToLeft=False)
# This will update our target cursor cell
#
@@ -5170,7 +5172,7 @@ class Script(script.Script):
self.targetCursorCell = 1
self.updateBrailleReview(self.targetCursorCell)
- elif braille.endIsShowing and orca_state.locusOfFocus \
+ elif self.isBrailleEndShowing() and orca_state.locusOfFocus \
and self.isTextArea(orca_state.locusOfFocus):
# If we're at the end of a line of a multiline text area, then
# force it's caret to the beginning of the next line. The
@@ -5186,11 +5188,11 @@ class Script(script.Script):
if endOffset < text.characterCount:
text.setCaretOffset(endOffset)
else:
- braille.panRight(panAmount)
+ self.panBrailleInDirection(panAmount, panToLeft=False)
# We might be panning through a flashed message.
#
braille.resetFlashTimer()
- braille.refresh(False, stopFlash=False)
+ self.refreshBraille(False, stopFlash=False)
return True
@@ -5214,7 +5216,7 @@ class Script(script.Script):
def setContractedBraille(self, inputEvent=None):
"""Toggles contracted braille."""
- braille.setContractedBraille(inputEvent)
+ self._setContractedBraille(inputEvent)
return True
def processRoutingKey(self, inputEvent=None):
@@ -5228,7 +5230,7 @@ class Script(script.Script):
active text area.
"""
- obj, caretOffset = braille.getCaretContext(inputEvent)
+ obj, caretOffset = self.getBrailleCaretContext(inputEvent)
if caretOffset >= 0:
self.clearTextSelection(obj)
@@ -5240,7 +5242,7 @@ class Script(script.Script):
"""Extends the text selection in the currently active text
area and also copies the selected text to the system clipboard."""
- obj, caretOffset = braille.getCaretContext(inputEvent)
+ obj, caretOffset = self.getBrailleCaretContext(inputEvent)
if caretOffset >= 0:
self.adjustTextSelection(obj, caretOffset)
@@ -5408,7 +5410,7 @@ class Script(script.Script):
if moved:
self._reviewCurrentLine(inputEvent)
- self.targetCursorCell = braille.cursorCell
+ self.targetCursorCell = self.getBrailleCursorCell()
return True
@@ -5421,7 +5423,7 @@ class Script(script.Script):
context.goBegin()
self._reviewCurrentLine(inputEvent)
- self.targetCursorCell = braille.cursorCell
+ self.targetCursorCell = self.getBrailleCursorCell()
return True
@@ -5437,7 +5439,7 @@ class Script(script.Script):
if moved:
self._reviewCurrentLine(inputEvent)
- self.targetCursorCell = braille.cursorCell
+ self.targetCursorCell = self.getBrailleCursorCell()
return True
@@ -5451,7 +5453,7 @@ class Script(script.Script):
context.goEnd(flat_review.Context.WINDOW)
context.goBegin(flat_review.Context.LINE)
self._reviewCurrentLine(inputEvent)
- self.targetCursorCell = braille.cursorCell
+ self.targetCursorCell = self.getBrailleCursorCell()
return True
@@ -5464,7 +5466,7 @@ class Script(script.Script):
context.goEnd()
self._reviewCurrentLine(inputEvent)
- self.targetCursorCell = braille.cursorCell
+ self.targetCursorCell = self.getBrailleCursorCell()
return True
@@ -5589,7 +5591,7 @@ class Script(script.Script):
if moved:
self._reviewCurrentItem(inputEvent)
- self.targetCursorCell = braille.cursorCell
+ self.targetCursorCell = self.getBrailleCursorCell()
return True
@@ -5604,7 +5606,7 @@ class Script(script.Script):
if moved:
self._reviewCurrentItem(inputEvent)
- self.targetCursorCell = braille.cursorCell
+ self.targetCursorCell = self.getBrailleCursorCell()
return True
@@ -5725,7 +5727,7 @@ class Script(script.Script):
if moved:
self._reviewCurrentCharacter(inputEvent)
- self.targetCursorCell = braille.cursorCell
+ self.targetCursorCell = self.getBrailleCursorCell()
return True
@@ -5737,7 +5739,7 @@ class Script(script.Script):
context.goEnd(flat_review.Context.LINE)
self.reviewCurrentCharacter(inputEvent)
- self.targetCursorCell = braille.cursorCell
+ self.targetCursorCell = self.getBrailleCursorCell()
return True
@@ -5752,7 +5754,7 @@ class Script(script.Script):
if moved:
self._reviewCurrentCharacter(inputEvent)
- self.targetCursorCell = braille.cursorCell
+ self.targetCursorCell = self.getBrailleCursorCell()
return True
@@ -5823,13 +5825,13 @@ class Script(script.Script):
# they were searching for was not found.
#
message = _("string not found")
- braille.displayMessage(message)
+ self.displayBrailleMessage(message)
speech.speak(message)
else:
context.setCurrent(location.lineIndex, location.zoneIndex, \
location.wordIndex, location.charIndex)
self.reviewCurrentItem(None)
- self.targetCursorCell = braille.cursorCell
+ self.targetCursorCell = self.getBrailleCursorCell()
def findNext(self, inputEvent):
"""Searches forward for the next instance of the string
@@ -8557,6 +8559,348 @@ class Script(script.Script):
return text_contents[start+a:start+b], start+a, start+b
return '', 0, 0
+ ########################################################################
+ # #
+ # Braille methods #
+ # (scripts should not call methods in braille.py directly) #
+ # #
+ ########################################################################
+
+ # [[[TODO - JD: Soon I'll add a check to only do the braille
+ # presentation if the user has braille or the braille monitor
+ # enabled. For now, the easiest way to regression test these
+ # changes is to always present braille.]]]
+
+ @staticmethod
+ def addBrailleRegionToLine(region, line):
+ """Adds the braille region to the line.
+
+ Arguments:
+ - region: a braille.Region (e.g. what is returned by the braille
+ generator's generateBraille() method.
+ - line: a braille.Line
+ """
+
+ line.addRegion(region)
+
+ @staticmethod
+ def addBrailleRegionsToLine(regions, line):
+ """Adds the braille region to the line.
+
+ Arguments:
+ - regions: a series of braille.Region instances (a single instance
+ being what is returned by the braille generator's generateBraille()
+ method.
+ - line: a braille.Line
+ """
+
+ line.addRegions(regions)
+
+ @staticmethod
+ def addToLineAsBrailleRegion(string, line):
+ """Creates a Braille Region out of string and adds it to the line.
+
+ Arguments:
+ - string: the string to be displayed
+ - line: a braille.Line
+ """
+
+ line.addRegion(braille.Region(string))
+
+ @staticmethod
+ def brailleRegionsFromStrings(strings):
+ """Creates a list of braille regions from the list of strings.
+
+ Arguments:
+ - strings: a list of strings from which to create the list of
+ braille Region instances
+
+ Returns the list of braille Region instances
+ """
+
+ brailleRegions = []
+ for string in strings:
+ brailleRegions.append(braille.Region(string))
+
+ return brailleRegions
+
+ @staticmethod
+ def clearBraille():
+ """Clears the logical structure, but keeps the Braille display as is
+ (until a refresh operation)."""
+
+ braille.clear()
+
+ @staticmethod
+ def displayBrailleMessage(message, cursor=-1, flashTime=0):
+ """Displays a single line, setting the cursor to the given position,
+ ensuring that the cursor is in view.
+
+ Arguments:
+ - message: the string to display
+ - cursor: the 0-based cursor position, where -1 (default) means no
+ cursor
+ - flashTime: if non-0, the number of milliseconds to display the
+ regions before reverting back to what was there before. A 0 means
+ to not do any flashing. A negative number means to display the
+ message until some other message comes along or the user presses
+ a cursor routing key.
+ """
+
+ braille.displayMessage(message, cursor, flashTime)
+
+ @staticmethod
+ def displayBrailleRegions(regionInfo, flashTime=0):
+ """Displays a list of regions on a single line, setting focus to the
+ specified region. The regionInfo parameter is something that is
+ typically returned by a call to braille_generator.generateBraille.
+
+ Arguments:
+ - regionInfo: a list where the first element is a list of regions
+ to display and the second element is the region with focus (must
+ be in the list from element 0)
+ - flashTime: if non-0, the number of milliseconds to display the
+ regions before reverting back to what was there before. A 0 means
+ to not do any flashing. A negative number means to display the
+ message until some other message comes along or the user presses
+ a cursor routing key.
+ """
+
+ braille.displayRegions(regionInfo, flashTime)
+
+ def displayBrailleForObject(self, obj):
+ """Convenience method for scripts combining the call to the braille
+ generator for the script with the call to displayBrailleRegions.
+
+ Arguments:
+ - obj: the accessible object to display in braille
+ """
+
+ regions = self.brailleGenerator.generateBraille(obj)
+ self.displayBrailleRegions(regions)
+
+ @staticmethod
+ def getBrailleCaretContext(event):
+ """Gets the accesible and caret offset associated with the given
+ event. The event should have a BrlAPI event that contains an
+ argument value that corresponds to a cell on the display.
+
+ Arguments:
+ - event: an instance of input_event.BrailleEvent. event.event is
+ the dictionary form of the expanded BrlAPI event.
+ """
+
+ return braille.getCaretContext(event)
+
+ @staticmethod
+ def getBrailleCursorCell():
+ """Returns the value of position of the braille cell which has the
+ cursor. A value of 0 means no cell has the cursor."""
+
+ return braille.cursorCell
+
+ @staticmethod
+ def getNewBrailleLine(clearBraille=False, addLine=False):
+ """Creates a new braille Line.
+
+ Arguments:
+ - clearBraille: Whether the display should be cleared.
+ - addLine: Whether the line should be added to the logical display
+ for painting.
+
+ Returns the new Line.
+ """
+
+ if clearBraille:
+ braille.clear()
+ line = braille.Line()
+ if addLine:
+ braille.addLine(line)
+
+ return braille.Line()
+
+ @staticmethod
+ def getNewBrailleComponent(accessible, string, cursorOffset=0,
+ indicator='', expandOnCursor=False):
+ """Creates a new braille Component.
+
+ Arguments:
+ - accessible: the accessible associated with this region
+ - string: the string to be displayed
+ - cursorOffset: a 0-based index saying where to draw the cursor
+ for this Region if it gets focus
+
+ Returns the new Component.
+ """
+
+ return braille.Component(accessible, string, cursorOffset,
+ indicator, expandOnCursor)
+
+ @staticmethod
+ def getNewBrailleRegion(string, cursorOffset=0, expandOnCursor=False):
+ """Creates a new braille Region.
+
+ Arguments:
+ - string: the string to be displayed
+ - cursorOffset: a 0-based index saying where to draw the cursor
+ for this Region if it gets focus
+
+ Returns the new Region.
+ """
+
+ return braille.Region(string, cursorOffset, expandOnCursor)
+
+ @staticmethod
+ def getNewBrailleText(accessible, label="", eol="", startOffset=None,
+ endOffset=None):
+
+ """Creates a new braille Text region.
+
+ Arguments:
+ - accessible: the accessible associated with this region and which
+ implements AtkText
+ - label: an optional label to display
+ - eol: the endOfLine indicator
+
+ Returns the new Text region.
+ """
+
+ return braille.Text(accessible, label, eol, startOffset, endOffset)
+
+ @staticmethod
+ def isBrailleBeginningShowing():
+ """If True, the beginning of the line is showing on the braille
+ display."""
+
+ return braille.beginningIsShowing
+
+ @staticmethod
+ def isBrailleEndShowing():
+ """If True, the end of the line is showing on the braille display."""
+
+ return braille.endIsShowing
+
+ @staticmethod
+ def panBrailleInDirection(panAmount=0, panToLeft=True):
+ """Pans the display to the left, limiting the pan to the beginning
+ of the line being displayed.
+
+ Arguments:
+ - panAmount: the amount to pan. A value of 0 means the entire
+ width of the physical display.
+ - panToLeft: if True, pan to the left; otherwise to the right
+
+ Returns True if a pan actually happened.
+ """
+
+ if panToLeft:
+ return braille.panLeft(panAmount)
+ else:
+ return braille.panRight(panAmount)
+
+ @staticmethod
+ def panBrailleToOffset(offset):
+ """Automatically pan left or right to make sure the current offset
+ is showing."""
+
+ braille.panToOffset(offset)
+
+ @staticmethod
+ def presentItemsInBraille(items):
+ """Method to braille a list of items. Scripts should call this
+ method rather than handling the creation and displaying of a
+ braille line directly.
+
+ Arguments:
+ - items: a list of strings to be presented
+ """
+
+ line = braille.getShowingLine()
+ for item in items:
+ line.addRegion(braille.Region(" " + item))
+
+ braille.refresh()
+
+ @staticmethod
+ def refreshBraille(panToCursor=True, targetCursorCell=0, getLinkMask=True,
+ stopFlash=True):
+ """This is the method scripts should use to refresh braille rather
+ than calling self.refreshBraille() directly. The intent is to centralize
+ such calls into as few places as possible so that we can easily and
+ safely not perform braille-related functions for users who do not
+ have braille and/or the braille monitor enabled.
+
+ Arguments:
+
+ - panToCursor: if True, will adjust the viewport so the cursor is
+ showing.
+ - targetCursorCell: Only effective if panToCursor is True.
+ 0 means automatically place the cursor somewhere on the display so
+ as to minimize movement but show as much of the line as possible.
+ A positive value is a 1-based target cell from the left side of
+ the display and a negative value is a 1-based target cell from the
+ right side of the display.
+ - getLinkMask: Whether or not we should take the time to get the
+ attributeMask for links. Reasons we might not want to include
+ knowing that we will fail and/or it taking an unreasonable
+ amount of time (AKA Gecko).
+ - stopFlash: if True, kill any flashed message that may be showing.
+ """
+
+ braille.refresh(panToCursor, targetCursorCell, getLinkMask, stopFlash)
+
+ @staticmethod
+ def setBrailleFocus(region, panToFocus=True, getLinkMask=True):
+ """Specififes the region with focus. This region will be positioned
+ at the home position if panToFocus is True.
+
+ Arguments:
+ - region: the given region, which much be in a line that has been
+ added to the logical display
+ - panToFocus: whether or not to position the region at the home
+ position
+ - getLinkMask: Whether or not we should take the time to get the
+ attributeMask for links. Reasons we might not want to include
+ knowning that we will fail and/or it taking an unreasonable
+ amount of time (AKA Gecko).
+ """
+
+ braille.setFocus(region, panToFocus, getLinkMask)
+
+ @staticmethod
+ def _setContractedBraille(event):
+ """Turns contracted braille on or off based upon the event.
+
+ Arguments:
+ - event: an instance of input_event.BrailleEvent. event.event is
+ the dictionary form of the expanded BrlAPI event.
+ """
+
+ braille.setContractedBraille(event)
+
+ ########################################################################
+ # #
+ # Speech methods #
+ # (scripts should not call methods in speech.py directly) #
+ # #
+ ########################################################################
+
+ @staticmethod
+ def presentItemsInSpeech(items):
+ """Method to speak a list of items. Scripts should call this
+ method rather than handling the creation and speaking of
+ utterances directly.
+
+ Arguments:
+ - items: a list of strings to be presented
+ """
+
+ utterances = []
+ for item in items:
+ utterances.append(item)
+
+ speech.speak(utterances)
+
# Dictionary that defines the state changes we care about for various
# objects. The key represents the role and the value represents a list
# of states that we care about.
diff --git a/src/orca/scripts/apps/Instantbird/script.py b/src/orca/scripts/apps/Instantbird/script.py
index 84e42b6..826d17f 100644
--- a/src/orca/scripts/apps/Instantbird/script.py
+++ b/src/orca/scripts/apps/Instantbird/script.py
@@ -28,7 +28,6 @@ __license__ = "LGPL"
import pyatspi
import orca.bookmarks as bookmarks
-import orca.braille as braille
import orca.default as default
import orca.orca as orca
import orca.orca_state as orca_state
@@ -234,7 +233,7 @@ class Script(Gecko.Script):
room2 = self.chat.getChatRoomName(event.source)
if room1 != room2:
speech.speak(room2)
- braille.displayMessage(
+ self.displayBrailleMessage(
room2, flashTime=settings.brailleFlashTime)
orca.setLocusOfFocus(event, event.source)
return
diff --git a/src/orca/scripts/apps/acroread.py b/src/orca/scripts/apps/acroread.py
index 617e852..1364a1c 100644
--- a/src/orca/scripts/apps/acroread.py
+++ b/src/orca/scripts/apps/acroread.py
@@ -27,7 +27,6 @@ __license__ = "LGPL"
import pyatspi
-import orca.braille as braille
import orca.debug as debug
import orca.default as default
import orca.input_event as input_event
@@ -441,9 +440,7 @@ class Script(default.Script):
utterances = \
self.speechGenerator.generateSpeech(newLocusOfFocus)
speech.speak(utterances)
- brailleRegions = \
- self.brailleGenerator.generateBraille(newLocusOfFocus)
- braille.displayRegions(brailleRegions)
+ self.displayBrailleForObject(newLocusOfFocus)
orca.setLocusOfFocus(
event, newLocusOfFocus, notifyPresentationManager=False)
return
@@ -475,9 +472,7 @@ class Script(default.Script):
for utterance in utterances:
adjustedUtterances.append(self.adjustForRepeats(utterance))
speech.speak(adjustedUtterances)
- brailleRegions = \
- self.brailleGenerator.generateBraille(newLocusOfFocus)
- braille.displayRegions(brailleRegions)
+ self.displayBrailleForObject(newLocusOfFocus)
orca.setLocusOfFocus(
event, newLocusOfFocus, notifyPresentationManager=False)
return
@@ -557,9 +552,7 @@ class Script(default.Script):
utterances = \
self.speechGenerator.generateSpeech(event.source)
speech.speak(utterances)
- brailleRegions = \
- self.brailleGenerator.generateBraille(event.source)
- braille.displayRegions(brailleRegions)
+ self.displayBrailleForObject(event.source)
orca.setLocusOfFocus(
event, event.source, notifyPresentationManager=False)
return
diff --git a/src/orca/scripts/apps/ekiga.py b/src/orca/scripts/apps/ekiga.py
index 94cb31d..c532999 100644
--- a/src/orca/scripts/apps/ekiga.py
+++ b/src/orca/scripts/apps/ekiga.py
@@ -27,7 +27,6 @@ __license__ = "LGPL"
import pyatspi
-import orca.braille as braille
import orca.default as default
import orca.orca as orca
import orca.orca_state as orca_state
@@ -136,7 +135,7 @@ class Script(default.Script):
if self.isChatRoomMsg(event.source):
speech.speak(event.any_data)
- braille.displayMessage(event.any_data)
+ self.displayBrailleMessage(event.any_data)
return
default.Script.onTextInserted(self, event)
diff --git a/src/orca/scripts/apps/evolution/script.py b/src/orca/scripts/apps/evolution/script.py
index 1ca925e..9dd1251 100644
--- a/src/orca/scripts/apps/evolution/script.py
+++ b/src/orca/scripts/apps/evolution/script.py
@@ -276,7 +276,7 @@ class Script(default.Script):
speech.speak(utterances)
settings.speechVerbosityLevel = savedSpeechVerbosityLevel
- braille.displayRegions(brailleGen.generateBraille(tab))
+ self.displayBrailleRegions(brailleGen.generateBraille(tab))
def getTimeForCalRow(self, row, noIncs):
"""Return a string equivalent to the time of the given row in
@@ -842,12 +842,12 @@ class Script(default.Script):
cell = cell[0]
if cell.getRole() == pyatspi.ROLE_TEXT:
- regions.append(braille.Text(cell))
+ regions.append(self.getNewBrailleText(cell))
[string, caretOffset, startOffset] = \
self.getTextLineAtCaret(cell)
utterances.append(string)
- braille.displayRegions([regions, regions[0]])
+ self.displayBrailleRegions([regions, regions[0]])
speech.speak(utterances)
return
@@ -943,7 +943,7 @@ class Script(default.Script):
if orca_state.locusOfFocus.getRole() != pyatspi.ROLE_TABLE_CELL:
speakAll = True
message = "%d messages" % parentTable.nRows
- brailleRegions.append(braille.Region(message))
+ brailleRegions.append(self.brailleRegionsFromStrings(message))
speech.speak(message)
for i in range(0, parentTable.nColumns):
@@ -1106,7 +1106,7 @@ class Script(default.Script):
speech.speak(utterances)
if brailleRegions != []:
- braille.displayRegions([brailleRegions, cellWithFocus])
+ self.displayBrailleRegions([brailleRegions, cellWithFocus])
settings.brailleVerbosityLevel = savedBrailleVerbosityLevel
settings.speechVerbosityLevel = savedSpeechVerbosityLevel
@@ -1179,7 +1179,7 @@ class Script(default.Script):
self.getTimeForCalRow(j + apptLen, noRows)
brailleRegions.append(braille.Region(endTime))
speech.speak(endTime)
- braille.displayRegions([brailleRegions,
+ self.displayBrailleRegions([brailleRegions,
brailleRegions[0]])
return
@@ -1243,7 +1243,7 @@ class Script(default.Script):
self.getTimeForCalRow(index + apptLen, noRows)
brailleRegions.append(braille.Region(endTime))
speech.speak(endTime)
- braille.displayRegions([brailleRegions,
+ self.displayBrailleRegions([brailleRegions,
brailleRegions[0]])
found = True
@@ -1258,7 +1258,7 @@ class Script(default.Script):
utterance = _("No appointments")
speech.speak(utterance)
brailleRegions.append(braille.Region(utterance))
- braille.displayRegions([brailleRegions,
+ self.displayBrailleRegions([brailleRegions,
brailleRegions[0]])
return
@@ -1335,7 +1335,7 @@ class Script(default.Script):
utterance = _("Directories button")
speech.speak(utterance)
brailleRegions.append(braille.Region(utterance))
- braille.displayRegions([brailleRegions,
+ self.displayBrailleRegions([brailleRegions,
brailleRegions[0]])
return
diff --git a/src/orca/scripts/apps/gcalctool/script.py b/src/orca/scripts/apps/gcalctool/script.py
index 9c094bb..a1f6f42 100644
--- a/src/orca/scripts/apps/gcalctool/script.py
+++ b/src/orca/scripts/apps/gcalctool/script.py
@@ -25,7 +25,6 @@ __date__ = "$Date$"
__copyright__ = "Copyright (c) 2005-2008 Sun Microsystems Inc."
__license__ = "LGPL"
-import orca.braille as braille
import orca.default as default
import orca.input_event as input_event
import orca.orca_state as orca_state
@@ -85,11 +84,11 @@ class Script(default.Script):
#
contents = _("Unable to get calculator display")
speech.speak(contents)
- braille.displayMessage(contents)
+ self.displayBrailleMessage(contents)
else:
self._resultsDisplay = objs[0]
contents = self.getText(self._resultsDisplay, 0, -1)
- braille.displayMessage(contents)
+ self.displayBrailleMessage(contents)
# The status line in gcalctool 5.29 is a sibling of the
# edit bar.
#
@@ -123,7 +122,7 @@ class Script(default.Script):
#
if self.isSameObject(event.source, self._resultsDisplay):
contents = self.getText(self._resultsDisplay, 0, -1)
- braille.displayMessage(contents)
+ self.displayBrailleMessage(contents)
if (orca_state.lastInputEvent is None) \
or \
diff --git a/src/orca/scripts/apps/gedit/script.py b/src/orca/scripts/apps/gedit/script.py
index 6f21a43..1dca9bb 100644
--- a/src/orca/scripts/apps/gedit/script.py
+++ b/src/orca/scripts/apps/gedit/script.py
@@ -27,7 +27,6 @@ __license__ = "LGPL"
import pyatspi
-import orca.braille as braille
import orca.debug as debug
import orca.default as default
import orca.input_event as input_event
@@ -419,17 +418,12 @@ class Script(default.Script):
if self.isDesiredFocusedItem(event.source, rolesList):
debug.println(self.debugLevel,
"gedit.onStateChanged - print preview - page #.")
- line = braille.getShowingLine()
parent = event.source.parent
label1 = self.getDisplayedText(parent[1])
label2 = self.getDisplayedText(parent[2])
-
- utterances = [ label1, label2 ]
- line.addRegion(braille.Region(" " + label1))
- line.addRegion(braille.Region(" " + label2))
-
- speech.speak(utterances)
- braille.refresh()
+ items = [label1, label2]
+ self.presentItemsInSpeech(items)
+ self.presentItemsInBraille(items)
# This method tries to detect and handle the following cases:
# 1) check spelling dialog.
diff --git a/src/orca/scripts/apps/gnome-panel.py b/src/orca/scripts/apps/gnome-panel.py
index f1528b1..f6d17a2 100644
--- a/src/orca/scripts/apps/gnome-panel.py
+++ b/src/orca/scripts/apps/gnome-panel.py
@@ -28,7 +28,6 @@ __license__ = "LGPL"
import orca.default as default
import orca.debug as debug
-import orca.braille as braille
import orca.speech as speech
import pyatspi
@@ -87,7 +86,7 @@ class Script(default.Script):
if obj.getRole() == pyatspi.ROLE_TOOL_TIP:
if event.type.startswith("object:state-changed:showing") and \
event.detail1 == 1:
- braille.displayMessage(obj.name)
+ self.displayBrailleMessage(obj.name)
utterances = self.speechGenerator.generateSpeech(obj)
speech.speak(utterances)
diff --git a/src/orca/scripts/apps/gnome-system-monitor.py b/src/orca/scripts/apps/gnome-system-monitor.py
index fc8922d..5bc5fc0 100644
--- a/src/orca/scripts/apps/gnome-system-monitor.py
+++ b/src/orca/scripts/apps/gnome-system-monitor.py
@@ -28,10 +28,8 @@ __license__ = "LGPL"
import pyatspi
-import orca.braille as braille
import orca.default as default
import orca.debug as debug
-import orca.speech as speech
########################################################################
# #
@@ -82,17 +80,14 @@ class Script(default.Script):
if self.isDesiredFocusedItem(event.source, rolesList):
debug.println(self.debugLevel,
"GNOME System Monitor.locusOfFocusChanged - page tab.")
- line = braille.getShowingLine()
- utterances = []
+ context = []
panels = self.findByRole(newLocusOfFocus, pyatspi.ROLE_PANEL)
for panel in panels:
if panel.name and len(panel.name) > 0:
- line.addRegion(braille.Region(" " + panel.name))
- utterances.append(panel.name)
+ context.append(panel.name)
labels = self.findUnrelatedLabels(panel)
for label in labels:
- line.addRegion(braille.Region(" " + label.name))
- utterances.append(label.name)
+ context.append(label.name)
- speech.speak(utterances)
- braille.refresh()
+ self.presentItemsInSpeech(context)
+ self.presentItemsInBraille(context)
diff --git a/src/orca/scripts/apps/gtk-window-decorator.py b/src/orca/scripts/apps/gtk-window-decorator.py
index 3814452..fe0fdde 100644
--- a/src/orca/scripts/apps/gtk-window-decorator.py
+++ b/src/orca/scripts/apps/gtk-window-decorator.py
@@ -25,7 +25,6 @@ __date__ = "$Date$"
__copyright__ = "Copyright (c) 2005-2008 Sun Microsystems Inc."
__license__ = "LGPL"
-import orca.braille as braille
import orca.default as default
import orca.speech as speech
import pyatspi
@@ -89,7 +88,7 @@ class Script(default.Script):
#
text += ". " + _("inaccessible")
- braille.displayMessage(text)
+ self.displayBrailleMessage(text)
speech.stop()
speech.speak(text)
diff --git a/src/orca/scripts/apps/liferea.py b/src/orca/scripts/apps/liferea.py
index 40898a4..12dcc00 100644
--- a/src/orca/scripts/apps/liferea.py
+++ b/src/orca/scripts/apps/liferea.py
@@ -21,7 +21,6 @@
import orca.debug as debug
import orca.default as default
-import orca.braille as braille
import orca.orca_state as orca_state
import orca.speech as speech
import orca.eventsynthesizer as eventsynthesizer
@@ -72,7 +71,7 @@ class Script(default.Script):
if self.isDesiredFocusedItem(orca_state.locusOfFocus, rolesList):
speech.stop()
speech.speak(event.source.name)
- braille.displayMessage(event.source.name)
+ self.displayBrailleMessage(event.source.name)
def locusOfFocusChanged(self, event, oldLocusOfFocus, newLocusOfFocus):
"""Called when the visual object with focus changes.
@@ -90,6 +89,12 @@ class Script(default.Script):
event,
debug.getAccessibleDetails(event.source))
+ # [[[TODO - JD: what follows here should be replaced with methods
+ # in this script's speech and braille generators. That will require
+ # making each generator, moving this script into a new directory,
+ # etc.]]]
+ #
+
# Here we handle the case when focus is in the "Work online/offline"
# button near the status bar that has an image without a description.
# We speak and braille "Online/Offline button" here, until the
@@ -126,8 +131,8 @@ class Script(default.Script):
speech.speak(utterances)
regions = brailleGen.generateBraille(event.source)
- regions[0].insert(0, braille.Region(utterances[0] + " "))
- braille.displayRegions(regions)
+ regions[0].insert(0, self.getNewBrailleRegion(utterances[0] + " "))
+ self.displayBrailleRegions(regions)
return
diff --git a/src/orca/scripts/apps/metacity.py b/src/orca/scripts/apps/metacity.py
index 37d2799..3e2e0c6 100644
--- a/src/orca/scripts/apps/metacity.py
+++ b/src/orca/scripts/apps/metacity.py
@@ -25,7 +25,6 @@ __date__ = "$Date$"
__copyright__ = "Copyright (c) 2005-2008 Sun Microsystems Inc."
__license__ = "LGPL"
-import orca.braille as braille
import orca.default as default
try:
import orca.gsmag as mag
@@ -114,7 +113,7 @@ class Script(default.Script):
#
text += ". " + _("inaccessible")
- braille.displayMessage(text)
+ self.displayBrailleMessage(text)
speech.speak(text)
mag.magnifyAccessible(None, obj)
diff --git a/src/orca/scripts/apps/nautilus.py b/src/orca/scripts/apps/nautilus.py
index ad57274..bb39fe1 100644
--- a/src/orca/scripts/apps/nautilus.py
+++ b/src/orca/scripts/apps/nautilus.py
@@ -26,7 +26,6 @@ __copyright__ = "Copyright (c) 2006-2009 Sun Microsystems Inc."
__license__ = "LGPL"
import pyatspi
-import orca.braille as braille
import orca.debug as debug
import orca.default as default
import orca.speech as speech
@@ -209,7 +208,7 @@ class Script(default.Script):
string += self.getItemCount(event.source)
debug.println(debug.LEVEL_INFO, string)
speech.speak(string)
- braille.displayMessage(string)
+ self.displayBrailleMessage(string)
self.oldFolderName = newFolderName
return
diff --git a/src/orca/scripts/apps/packagemanager/script.py b/src/orca/scripts/apps/packagemanager/script.py
index a4a955a..99cad2f 100644
--- a/src/orca/scripts/apps/packagemanager/script.py
+++ b/src/orca/scripts/apps/packagemanager/script.py
@@ -1,6 +1,7 @@
# Orca
#
-# Copyright 2005-2010 Sun Microsystems Inc.
+# Copyright 2009-2010 Sun Microsystems Inc.
+# 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
@@ -22,13 +23,13 @@
__id__ = "$Id$"
__version__ = "$Revision$"
__date__ = "$Date$"
-__copyright__ = "Copyright (c) 2005-2010 Sun Microsystems Inc."
+__copyright__ = "Copyright (c) 2009-2010 Sun Microsystems Inc." \
+ "Copyright (c) 2010 Joanmarie Diggs"
__license__ = "LGPL"
import gtk
import pyatspi
-import orca.braille as braille
import orca.default as default
import orca.input_event as input_event
import orca.orca as orca
@@ -220,7 +221,8 @@ class Script(default.Script):
#
msg = _("Loading. Please wait.")
speech.speak(msg)
- braille.displayMessage(msg, flashTime=settings.brailleFlashTime)
+ self.displayBrailleMessage(
+ msg, flashTime=settings.brailleFlashTime)
self._isBusy = True
elif event.detail1 == 0 and self._isBusy:
# Translators: this is in reference to loading a web page
@@ -228,7 +230,8 @@ class Script(default.Script):
#
msg = _("Finished loading.")
speech.speak(msg)
- braille.displayMessage(msg, flashTime=settings.brailleFlashTime)
+ self.displayBrailleMessage(
+ msg, flashTime=settings.brailleFlashTime)
self._isBusy = False
return
@@ -249,7 +252,8 @@ class Script(default.Script):
#
msg = _("An error occurred. View the error log for details.")
speech.speak(msg)
- braille.displayMessage(msg, flashTime=settings.brailleFlashTime)
+ self.displayBrailleMessage(
+ msg, flashTime=settings.brailleFlashTime)
self._presentedStatusBarIcon = True
default.Script.onStateChanged(self, event)
@@ -418,29 +422,25 @@ class Script(default.Script):
except:
return default.Script.updateBraille(self, obj, extraRegion)
- braille.clear()
- line = braille.Line()
- braille.addLine(line)
-
+ line = self.getNewBrailleLine(clearBraille=True, addLine=True)
focusedRegion = None
contents = self.getLineContentsAtOffset(obj, text.caretOffset)
for i, content in enumerate(contents):
child, startOffset, endOffset, string = content
isFocusedObj = self.isSameObject(child, obj)
- regions = [braille.Text(child,
- startOffset=startOffset,
- endOffset=endOffset)]
-
+ regions = [self.getNewBrailleText(child,
+ startOffset=startOffset,
+ endOffset=endOffset)]
if isFocusedObj:
focusedRegion = regions[0]
- line.addRegions(regions)
+ self.addBrailleRegionsToLine(regions, line)
if extraRegion:
- line.addRegion(extraRegion)
+ self.addBrailleRegionToLine(extraRegion, line)
- braille.setFocus(focusedRegion, getLinkMask=False)
- braille.refresh(panToCursor=True, getLinkMask=False)
+ self.setBrailleFocus(focusedRegion, getLinkMask=False)
+ self.refreshBraille(panToCursor=True, getLinkMask=False)
def sayCharacter(self, obj):
"""Speak the character at the caret. Overridden here because the
diff --git a/src/orca/scripts/apps/pidgin/script.py b/src/orca/scripts/apps/pidgin/script.py
index 6ee7756..0fc8608 100644
--- a/src/orca/scripts/apps/pidgin/script.py
+++ b/src/orca/scripts/apps/pidgin/script.py
@@ -36,7 +36,6 @@ __license__ = "LGPL"
import gtk
import pyatspi
-import orca.braille as braille
import orca.debug as debug
import orca.default as default
import orca.input_event as input_event
@@ -521,7 +520,7 @@ class Script(default.Script):
if len(text.strip()):
speech.speak(text)
- braille.displayMessage(text)
+ self.displayBrailleMessage(text)
def readPreviousMessage(self, inputEvent):
""" Speak/braille a previous chat room message. Up to nine
diff --git a/src/orca/scripts/apps/soffice/script.py b/src/orca/scripts/apps/soffice/script.py
index 6b621db..a4ef1f5 100644
--- a/src/orca/scripts/apps/soffice/script.py
+++ b/src/orca/scripts/apps/soffice/script.py
@@ -43,7 +43,6 @@ import pyatspi
import orca.debug as debug
import orca.default as default
import orca.input_event as input_event
-import orca.braille as braille
import orca.orca as orca
import orca.orca_state as orca_state
import orca.speech as speech
@@ -1034,7 +1033,7 @@ class Script(default.Script):
#
line = _("Dynamic column header set for row %d") % (row+1)
speech.speak(line)
- braille.displayMessage(line)
+ self.displayBrailleMessage(line)
return True
@@ -1058,7 +1057,7 @@ class Script(default.Script):
line = _("Dynamic column header cleared.")
speech.stop()
speech.speak(line)
- braille.displayMessage(line)
+ self.displayBrailleMessage(line)
except:
pass
@@ -1111,7 +1110,7 @@ class Script(default.Script):
line = _("Dynamic row header set for column %s") \
% self.columnConvert(column+1)
speech.speak(line)
- braille.displayMessage(line)
+ self.displayBrailleMessage(line)
return True
@@ -1135,7 +1134,7 @@ class Script(default.Script):
line = _("Dynamic row header cleared.")
speech.stop()
speech.speak(line)
- braille.displayMessage(line)
+ self.displayBrailleMessage(line)
except:
pass
@@ -1506,8 +1505,7 @@ class Script(default.Script):
result = self.getTextLineAtCaret(event.source)
textToSpeak = result[0].decode("UTF-8")
self._speakWriterText(event, textToSpeak)
- braille.displayRegions(\
- brailleGen.generateBraille(event.source))
+ self.displayBrailleForObject(event.source)
return
# Check to see if the object that just got focus is in the Setup
@@ -2115,12 +2113,10 @@ class Script(default.Script):
# has a formula
# (e.g., "=sum(a1:d1)")
#
- hf = " " + _("has formula")
- speech.speak(hf, None, False)
-
- line = braille.getShowingLine()
- line.addRegion(braille.Region(hf))
- braille.refresh()
+ hf = _("has formula")
+ speech.speak(" %s" % hf,
+ None, False)
+ self.presentItemsInBraille([hf])
#
# Fall-thru to process the event
# with the default handler.
@@ -2279,8 +2275,7 @@ class Script(default.Script):
result = self.getText(event.source, 0, -1)
textToSpeak = result.decode("UTF-8")
self._speakWriterText(event, textToSpeak)
- braille.displayRegions( \
- self.brailleGenerator.generateBraille(event.source))
+ self.displayBrailleForObject(event.source)
else:
# The lists and combo boxes in the Formatting toolbar emit
# object:active-descendant-changed events which cause us
diff --git a/src/orca/structural_navigation.py b/src/orca/structural_navigation.py
index df0eb49..ab5c5ec 100644
--- a/src/orca/structural_navigation.py
+++ b/src/orca/structural_navigation.py
@@ -29,7 +29,6 @@ __license__ = "LGPL"
import pyatspi
-import braille
import debug
import input_event
import keybindings
@@ -657,7 +656,7 @@ class StructuralNavigation:
debug.println(debug.LEVEL_CONFIGURATION, string)
speech.speak(string)
- braille.displayMessage(string)
+ self._script.displayBrailleMessage(string)
#########################################################################
# #
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]