orca.util (version 2029, $Date$)
index
/usr/lib/python2.5/site-packages/orca/util.py

Provides various utility functions for Orca.

 
Modules
       
orca.atspi
orca.chnames
orca.debug
gtk
orca.input_event
linecache
orca.orca_prefs
orca.orca_state
orca.phonnames
orca.pronunciation_dict
orca.punctuation_settings
orca.rolenames
orca.settings
orca.speech
orca.speechserver
string

 
Functions
       
adjustForPronunciation(line)
Adjust the line to replace words in the pronunciation dictionary,
with what those words actually sound like.
 
Arguments:
- line: the string to adjust for words in the pronunciation dictionary.
 
Returns: a new line adjusted for words found in the pronunciation
dictionary.
adjustForRepeats(line)
Adjust line to include repeat character counts.
As some people will want this and others might not,
there is a setting in settings.py that determines
whether this functionality is enabled.
 
repeatCharacterLimit = <n>
 
If <n> is 0, then there would be no repeat characters.
Otherwise <n> would be the number of same characters (or more)
in a row that cause the repeat character count output.
If the value is set to 1, 2 or 3 then it's treated as if it was
zero. In other words, no repeat character count is given.
 
Arguments:
- line: the string to adjust for repeat character counts.
 
Returns: a new line adjusted for repeat character counts (if enabled).
appendString(text, newText, delimiter=' ')
Appends the newText to the given text with the delimiter in between
and returns the new string.  Edge cases, such as no initial text or
no newText, are handled gracefully.
drawOutline(x, y, width, height, erasePrevious=True)
Draws a rectangular outline around the accessible, erasing the
last drawn rectangle in the process.
findActiveWindow()
Traverses the list of known apps looking for one who has an
immediate child (i.e., a window) whose state includes the active state.
 
Returns the Python Accessible of the window that's active or None if
no windows are active.
findByRole(root, role, onlyShowing=True)
Returns a list of all objects of a specific role beneath the
given root.  [[[TODO: MM - This is very inefficient - this should
do it's own traversal and not add objects to the list that aren't
of the specified role.  Instead it uses the traversal from
getObjects and then deletes objects from the list that aren't of
the specified role.  Logged as bugzilla bug 319740.]]]
 
Arguments:
- root the Accessible object to traverse
- role the string describing the Accessible role of the object
- onlyShowing: examine only those objects that are SHOWING
 
Returns a list of descendants of the root that are of the given role.
findFocusedObject(root)
Returns the accessible that has focus under or including the
given root.
 
TODO: This will currently traverse all children, whether they are
visible or not and/or whether they are children of parents that
manage their descendants.  At some point, this method should be
optimized to take such things into account.
 
Arguments:
- root: the root object where to start searching
 
Returns the object with the FOCUSED state or None if no object with
the FOCUSED state can be found.
findUnrelatedLabels(root)
Returns a list containing all the unrelated (i.e., have no
relations to anything and are not a fundamental element of a
more atomic component like a combo box) labels under the given
root.  Note that the labels must also be showing on the display.
 
Arguments:
- root the Accessible object to traverse
 
Returns a list of unrelated labels under the given root.
getAcceleratorAndShortcut(obj)
Gets the accelerator string (and possibly shortcut) for the given
object.
 
Arguments:
- obj: the Accessible object
 
A list containing the accelerator and shortcut for the given object,
where the first element is the accelerator and the second element is
the shortcut.
getClickCount(lastInputEvent, inputEvent)
Return the count of the number of clicks a user has made to one of the
keys on the keyboard.
 
Arguments:
- lastInputEvent: the last input event.
- inputEvent: the current input event.
getDisplayedLabel(object)
If there is an object labelling the given object, return the
text being displayed for the object labelling this object.
Otherwise, return None.
 
Argument:
- object: the object in question
 
Returns the string of the object labelling this object, or None
if there is nothing of interest here.
getDisplayedText(obj)
Returns the text being displayed for an object.
 
Arguments:
- obj: the object
 
Returns the text being displayed for an object or None if there isn't
any text being shown.
getFrame(obj)
Returns the frame containing this object, or None if this object
is not inside a frame.
 
Arguments:
- obj: the Accessible object
getKnownApplications()
Retrieves the list of currently running apps for the desktop
as a list of Accessible objects.
getLinkIndex(obj, characterIndex)
A brute force method to see if an offset is a link.  This
is provided because not all Accessible Hypertext implementations
properly support the getLinkIndex method.  Returns an index of
0 or greater of the characterIndex is on a hyperlink.
 
Arguments:
-obj: the Accessible object with the Accessible Hypertext specialization
-characterIndex: the text position to check
getNodeLevel(obj)
Determines the node level of this object if it is in a tree
relation, with 0 being the top level node.  If this object is
not in a tree relation, then -1 will be returned.
 
Arguments:
-obj: the Accessible object
getObjects(root, onlyShowing=True)
Returns a list of all objects under the given root.  Objects
are returned in no particular order - this function does a simple
tree traversal, ignoring the children of objects which report the
MANAGES_DESCENDANTS state.
 
Arguments:
- root:        the Accessible object to traverse
- onlyShowing: examine only those objects that are SHOWING
 
Returns: a list of all objects under the specified object
getRealActiveDescendant(obj)
Given an object that should be a child of an object that
manages its descendants, return the child that is the real
active descendant carrying useful information.
 
Arguments:
- obj: an object that should be a child of an object that
manages its descendants.
getTextLineAtCaret(obj)
Gets the line of text where the caret is.
 
Argument:
- obj: an Accessible object that implements the AccessibleText
       interface
 
Returns the [string, caretOffset, startOffset] for the line of text
where the caret is.
getTopLevel(obj)
Returns the top-level object (frame, dialog ...) containing this
object, or None if this object is not inside a top-level object.
 
Arguments:
- obj: the Accessible object
getTopLevelName(obj)
Returns the name of the top-level object. See getTopLevel.
getUnicodeCurrencySymbols()
Return a list of the unicode currency symbols, populating the list
if this is the first time that this routine has been called.
 
Returns a list of unicode currency symbols.
isDesiredFocusedItem(obj, rolesList)
Called to determine if the given object and it's hierarchy of
   parent objects, each have the desired roles.
 
Arguments:
- obj: the accessible object to check.
- rolesList: the list of desired roles for the components and the
  hierarchy of its parents.
 
Returns True if all roles match.
isInActiveApp(obj)
Returns True if the given object is from the same application that
currently has keyboard focus.
 
Arguments:
- obj: an Accessible object
isSameObject(obj1, obj2)
isTextSelected(obj, startOffset, endOffset)
Returns an indication of whether the text is selected by
comparing the text offset with the various selected regions of
text for this accessible object.
 
Arguments:
- obj: the Accessible object.
- startOffset: text start offset.
- endOffset: text end offset.
 
Returns an indication of whether the text is selected.
isWordDelimiter(character)
Returns True if the given character is a word delimiter.
 
Arguments:
- character: the character in question
 
Returns True if the given character is a word delimiter.
outlineAccessible(accessible, erasePrevious=True)
Draws a rectangular outline around the accessible, erasing the
last drawn rectangle in the process.
phoneticSpellCurrentItem(string)
Phonetically spell the current flat review word or line.
 
Arguments:
- string: the string to phonetically spell.
printActiveApp()
Prints the active application.
printAncestry(child)
Prints a hierarchical view of a child's ancestry.
printApps()
Prints a list of all applications to stdout.
printHierarchy(root, ooi, indent='', onlyShowing=True, omitManaged=True)
Prints the accessible hierarchy of all children
 
Arguments:
-indent:      Indentation string
-root:        Accessible where to start
-ooi:         Accessible object of interest
-onlyShowing: If True, only show children painted on the screen
-omitManaged: If True, omit children that are managed descendants
restoreOldAppSettings(prefsDict)
Restore a copy of all the previous saved application settings.
 
Arguments:
- prefsDict: the dictionary containing the old application settings.
saveOldAppSettings()
Save a copy of all the existing application specific settings
(as specified by the settings.userCustomizableSettings dictionary).
speakMisspeltWord(allTokens, badWord)
Called by various spell checking routine to speak the misspelt word,
   plus the context that it is being used in.
 
Arguments:
- allTokens: a list of all the words.
- badWord: the misspelt word.
speakTextSelectionState(obj, startOffset, endOffset)
Speak "selected" if the text was just selected, "unselected" if
it was just unselected.
 
Arguments:
- obj: the Accessible object.
- startOffset: text start offset.
- endOffset: text end offset.
textLines(obj)
Creates a generator that can be used to iterate over each line
of a text object, starting at the caret offset.
 
Arguments:
- obj: an Accessible that has a text specialization
 
Returns an iterator that produces elements of the form:
[SayAllContext, acss], where SayAllContext has the text to be
spoken and acss is an ACSS instance for speaking the text.
traceit(frame, event, arg)
Line tracing utility to output all lines as they are executed by
the interpreter.  This is to be used by sys.settrace and is for
debugging purposes.
 
Arguments:
- frame: is the current stack frame
- event: 'call', 'line', 'return', 'exception', 'c_call', 'c_return',
         or 'c_exception'
- arg:   depends on the event type (see docs for sys.settrace)

 
Data
        EMBEDDED_OBJECT_CHARACTER = u'\ufffc'
__copyright__ = 'Copyright (c) 2005-2007 Sun Microsystems Inc.'
__date__ = '$Date$'
__id__ = '$Id$'
__license__ = 'LGPL'
__version__ = '$Revision$'