[orca/570658] Move getRoleName from Gecko to default area
- From: William Walker <wwalker src gnome org>
- To: svn-commits-list gnome org
- Subject: [orca/570658] Move getRoleName from Gecko to default area
- Date: Thu, 21 May 2009 07:12:38 -0400 (EDT)
commit 363bc7a8486e1b0d659404cc7cd459bc71511f02
Author: Willie Walker <william walker sun com>
Date: Thu May 21 07:11:21 2009 -0400
Move getRoleName from Gecko to default area
---
.../scripts/toolkits/Gecko/speech_generator.py | 3 -
src/orca/scripts/toolkits/Gecko/where_am_i.py | 35 ++++++-------
src/orca/speechgenerator.py | 3 +
src/orca/where_am_I.py | 54 ++++++++++---------
4 files changed, 48 insertions(+), 47 deletions(-)
diff --git a/src/orca/scripts/toolkits/Gecko/speech_generator.py b/src/orca/scripts/toolkits/Gecko/speech_generator.py
index f9a47c4..3f6b27b 100644
--- a/src/orca/scripts/toolkits/Gecko/speech_generator.py
+++ b/src/orca/scripts/toolkits/Gecko/speech_generator.py
@@ -221,9 +221,6 @@ class SpeechGenerator(speechgenerator.SpeechGenerator):
return result
- def getRoleName(self, obj):
- return self._getRoleName(obj)
-
def _getExpandedEOCs(self, obj, **args):
"""Returns the expanded embedded object characters for an object."""
result = []
diff --git a/src/orca/scripts/toolkits/Gecko/where_am_i.py b/src/orca/scripts/toolkits/Gecko/where_am_i.py
index ac7e570..2a7ebaa 100644
--- a/src/orca/scripts/toolkits/Gecko/where_am_i.py
+++ b/src/orca/scripts/toolkits/Gecko/where_am_i.py
@@ -1,6 +1,6 @@
# Orca
#
-# Copyright 2005-2008 Sun Microsystems Inc.
+# Copyright 2005-2009 Sun Microsystems Inc.
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Library General Public
@@ -26,7 +26,7 @@ http://developer.mozilla.org/en/docs/Accessibility/ATSPI_Support
__id__ = "$Id$"
__version__ = "$Revision$"
__date__ = "$Date$"
-__copyright__ = "Copyright (c) 2005-2008 Sun Microsystems Inc."
+__copyright__ = "Copyright (c) 2005-2009 Sun Microsystems Inc."
__license__ = "LGPL"
import pyatspi
@@ -44,7 +44,7 @@ from orca.orca_i18n import ngettext # for ngettext support
# #
# Custom WhereAmI #
# #
-########################################################################
+########################################################################
class GeckoWhereAmI(where_am_I.WhereAmI):
def __init__(self, script):
@@ -54,7 +54,7 @@ class GeckoWhereAmI(where_am_I.WhereAmI):
"""
where_am_I.WhereAmI.__init__(self, script)
self._script = script
-
+
def whereAmI(self, obj, basicOnly):
"""Calls the base class method for basic information and Gecko
specific presentation methods for detailed/custom information.
@@ -87,7 +87,7 @@ class GeckoWhereAmI(where_am_I.WhereAmI):
"""Returns the rolename to be spoken for the object. Overridden
here because there are times when we do not want the speech
generator returning a role to speak (e.g. navigating within
- a document), but other times when we would (e.g. during a
+ a document), but other times when we would (e.g. during a
whereAmI).
"""
@@ -130,14 +130,14 @@ class GeckoWhereAmI(where_am_I.WhereAmI):
speech.speak(_("image map link"))
def _collectionPageSummary(self):
- """Uses the Collection interface to get the quantity of headings,
+ """Uses the Collection interface to get the quantity of headings,
forms, tables, visited and unvisited links.
"""
docframe = self._script.getDocumentFrame()
col = docframe.queryCollection()
# We will initialize these after the queryCollection() call in case
# Collection is not supported
- headings = 0
+ headings = 0
forms = 0
tables = 0
vlinks = 0
@@ -146,7 +146,7 @@ class GeckoWhereAmI(where_am_I.WhereAmI):
stateset = pyatspi.StateSet()
roles = [pyatspi.ROLE_HEADING, pyatspi.ROLE_LINK, pyatspi.ROLE_TABLE,
pyatspi.ROLE_FORM]
- rule = col.createMatchRule(stateset.raw(), col.MATCH_NONE,
+ rule = col.createMatchRule(stateset.raw(), col.MATCH_NONE,
"", col.MATCH_NONE,
roles, col.MATCH_ANY,
"", col.MATCH_NONE,
@@ -171,12 +171,12 @@ class GeckoWhereAmI(where_am_I.WhereAmI):
uvlinks += 1
self._outputPageSummary(headings, forms, tables, vlinks, uvlinks, None)
-
+
def _iterativePageSummary(self, obj):
- """Reads the quantity of headings, forms, tables, visited and
+ """Reads the quantity of headings, forms, tables, visited and
unvisited links.
"""
- headings = 0
+ headings = 0
forms = 0
tables = 0
vlinks = 0
@@ -213,10 +213,10 @@ class GeckoWhereAmI(where_am_I.WhereAmI):
else:
percentread = None
- self._outputPageSummary(headings, forms, tables,
+ self._outputPageSummary(headings, forms, tables,
vlinks, uvlinks, percentread)
- def _outputPageSummary(self, headings, forms, tables,
+ def _outputPageSummary(self, headings, forms, tables,
vlinks, uvlinks, percent):
utterances = []
@@ -252,11 +252,10 @@ class GeckoWhereAmI(where_am_I.WhereAmI):
('%d unvisited link', '%d unvisited links', uvlinks) %uvlinks)
if percent is not None:
# Translators: Announces the percentage of the document that has
- # been read. This is calculated by knowing the index of the
- # current position divided by the total number of objects on the
+ # been read. This is calculated by knowing the index of the
+ # current position divided by the total number of objects on the
# page.
- #
+ #
utterances.append(_('%d percent of document read') %percent)
- speech.speak(utterances)
-
+ speech.speak(utterances)
diff --git a/src/orca/speechgenerator.py b/src/orca/speechgenerator.py
index 5ac0c14..3ee983d 100644
--- a/src/orca/speechgenerator.py
+++ b/src/orca/speechgenerator.py
@@ -158,6 +158,9 @@ class SpeechGenerator:
result.append(rolenames.getSpeechForRoleName(obj, role))
return result
+ def getRoleName(self, obj, **args):
+ return self._getRoleName(obj, **args)
+
def _getLabel(self, obj, **args):
result = []
label = self._script.getDisplayedLabel(obj)
diff --git a/src/orca/where_am_I.py b/src/orca/where_am_I.py
index 451e39e..b109e2c 100644
--- a/src/orca/where_am_I.py
+++ b/src/orca/where_am_I.py
@@ -1,6 +1,6 @@
# Orca
#
-# Copyright 2005-2008 Sun Microsystems Inc.
+# Copyright 2005-2009 Sun Microsystems Inc.
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Library General Public
@@ -22,13 +22,12 @@
__id__ = "$Id$"
__version__ = "$Revision$"
__date__ = "$Date$"
-__copyright__ = "Copyright (c) 2005-2008 Sun Microsystems Inc."
+__copyright__ = "Copyright (c) 2005-2009 Sun Microsystems Inc."
__license__ = "LGPL"
import pyatspi
import debug
import orca_state
-import rolenames
import settings
import speech
import text_attribute_names
@@ -137,7 +136,7 @@ class WhereAmI:
elif role == pyatspi.ROLE_ICON:
self._speakIconPanel(obj, basicOnly)
-
+
elif role == pyatspi.ROLE_LINK:
self._speakLink(obj, basicOnly)
@@ -303,7 +302,7 @@ class WhereAmI:
name = self._getObjName(obj)
if name != label:
utterances.append(name)
-
+
utterances.extend(self._getSpeechForAllTextSelection(obj))
text = self._getObjAccelerator(obj)
@@ -449,7 +448,7 @@ class WhereAmI:
utterances.append(text)
if obj.parent \
- and obj.parent.getRole() in [pyatspi.ROLE_MENU,
+ and obj.parent.getRole() in [pyatspi.ROLE_MENU,
pyatspi.ROLE_MENU_BAR]:
text = self._getObjMnemonic(obj)
utterances.append(text)
@@ -659,7 +658,7 @@ class WhereAmI:
"second table cell utterances=%s" % \
utterances)
speech.speak(utterances)
-
+
utterances = []
state = obj.getState()
if state.contains(pyatspi.STATE_EXPANDABLE):
@@ -789,9 +788,9 @@ class WhereAmI:
utterances.extend(getTutorial(frame, False, forceMessage=True))
speech.speak(utterances)
-
+
def _speakLink(self, obj, basicOnly):
- """Speaks information about a link including protocol, domain
+ """Speaks information about a link including protocol, domain
comparisons and size of file if possible.
Also tutorial string if enableTutorialMessages is set.
@@ -799,9 +798,9 @@ class WhereAmI:
- obj: the icon object that currently has focus.
- basicOnly: True if the user is performing a standard/basic whereAmI.
"""
-
+
# get the URI for the link of interest and parse it.
- # parsed URI is returned as a tuple containing six components:
+ # parsed URI is returned as a tuple containing six components:
# scheme://netloc/path;parameters?query#fragment.
link_uri = self._script.getURI(obj)
if link_uri:
@@ -810,15 +809,15 @@ class WhereAmI:
# It might be an anchor. Try to speak the text.
#
return self._speakText(obj, basicOnly)
-
+
# Try to get the URI of the active document and parse it
doc_uri = self._script.getDocumentFrameURI()
if doc_uri:
doc_uri_info = urlparse.urlparse(doc_uri)
else:
doc_uri_info = None
-
- # initialize our three outputs. Output may change below for some
+
+ # initialize our three outputs. Output may change below for some
# protocols.
# Translators: this is the protocol of a link eg. http, mailto.
#
@@ -842,7 +841,7 @@ class WhereAmI:
domainoutput = ''
sizeoutput = ''
-
+
# get size and other protocol specific information
if link_uri_info[0] == 'ftp' or \
link_uri_info[0] == 'ftps' or \
@@ -852,7 +851,7 @@ class WhereAmI:
linkoutput = _('%s link to %s') %(link_uri_info[0], filename[-1])
sizestr = self.__extractSize(link_uri)
sizeoutput = self.__formatSizeOutput(sizestr)
-
+
# determine location differences if doc uri info is available
if doc_uri_info:
if link_uri_info[1] == doc_uri_info[1]:
@@ -869,7 +868,7 @@ class WhereAmI:
if len(linkdomain) > 1 and docdomain > 1 \
and linkdomain[-1] == docdomain[-1] \
and linkdomain[-2] == docdomain[-2]:
- domainoutput = _('same site')
+ domainoutput = _('same site')
else:
domainoutput = _('different site')
@@ -908,7 +907,7 @@ class WhereAmI:
utterances.extend(getTutorial(obj, False, forceMessage=True))
speech.speak(utterances)
-
+
def _speakSplitPane(self, obj, basicOnly):
"""Speak split pane information:
1. Name/Label
@@ -1006,7 +1005,7 @@ class WhereAmI:
def _getSelectedItemCount(self, obj, basicOnly):
"""Return an utterance indicating how many items are selected in this
object, the current item, and (if a detailed whereAmI), the names of
- all the selected items. This object will be an icon panel or a
+ all the selected items. This object will be an icon panel or a
layered pane.
Arguments:
@@ -1061,7 +1060,7 @@ class WhereAmI:
return None
except (ValueError, urllib2.URLError, OSError):
return None
-
+
def __formatSizeOutput(self, sizestr):
"""Format the size output announcement. Changes wording based on
size.
@@ -1081,7 +1080,7 @@ class WhereAmI:
elif size >= 1000000:
# Translators: This is the size of a file in megabytes
#
- return _('%.2f megabytes') % (float(size) * .000001)
+ return _('%.2f megabytes') % (float(size) * .000001)
def _speakGenericObject(self, obj, basicOnly):
"""Speak a generic object; one not specifically handled by
@@ -1160,7 +1159,10 @@ class WhereAmI:
"""
try:
- return rolenames.getSpeechForRoleName(obj, role)
+ if role:
+ return self._script.speechGenerator.getRoleName(obj, role=role)
+ else:
+ return self._script.speechGenerator.getRoleName(obj)
except:
return ""
@@ -1262,7 +1264,7 @@ class WhereAmI:
return text
def _getObjAccelerator(self,
- obj,
+ obj,
fallbackToMnemonic=True,
fallbackToFullPath=True):
"""Returns the accelerator for the object, if it exists.
@@ -1415,7 +1417,7 @@ class WhereAmI:
Arguments:
- obj: the text object to extract the selected text from.
- Returns: the selected text contents plus the start and end
+ Returns: the selected text contents plus the start and end
offsets within the text.
"""
@@ -1804,9 +1806,9 @@ class WhereAmI:
def speakStatusBar(self, obj):
"""Speak the contents of the status bar of the window with focus.
"""
-
+
utterances = []
-
+
results = self._getFrameAndDialog(obj)
if results[0]:
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]