[orca] Fix for bgo#590382 - Orca should have a script for packagemanager
- From: Joanmarie Diggs <joanied src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [orca] Fix for bgo#590382 - Orca should have a script for packagemanager
- Date: Fri, 31 Jul 2009 21:47:26 +0000 (UTC)
commit 2df3f4d9dee7a82e139edcdbd46606afb6991991
Author: Joanmarie Diggs <joanmarie diggs gmail com>
Date: Fri Jul 31 16:34:34 2009 -0400
Fix for bgo#590382 - Orca should have a script for packagemanager
configure.in | 1 +
po/POTFILES.in | 2 +
src/orca/scripts/apps/Makefile.am | 1 +
src/orca/scripts/apps/packagemanager/Makefile.am | 8 +
src/orca/scripts/apps/packagemanager/__init__.py | 23 +++
src/orca/scripts/apps/packagemanager/script.py | 156 ++++++++++++++++++++
.../apps/packagemanager/tutorialgenerator.py | 66 ++++++++
src/orca/scripts/toolkits/Gecko/script.py | 9 +-
8 files changed, 263 insertions(+), 3 deletions(-)
---
diff --git a/configure.in b/configure.in
index 9c1e34a..6ee0c1b 100644
--- a/configure.in
+++ b/configure.in
@@ -139,6 +139,7 @@ src/orca/scripts/apps/Makefile
src/orca/scripts/apps/soffice/Makefile
src/orca/scripts/apps/evolution/Makefile
src/orca/scripts/apps/gcalctool/Makefile
+src/orca/scripts/apps/packagemanager/Makefile
src/orca/scripts/apps/pidgin/Makefile
src/orca/scripts/apps/planner/Makefile
src/orca/scripts/apps/rhythmbox/Makefile
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 08af188..7b5e288 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -44,6 +44,8 @@ src/orca/scripts/apps/metacity.py
src/orca/scripts/apps/nautilus.py
src/orca/scripts/apps/notification-daemon.py
src/orca/scripts/apps/notify-osd.py
+src/orca/scripts/apps/packagemanager/script.py
+src/orca/scripts/apps/packagemanager/tutorialgenerator.py
src/orca/scripts/apps/pidgin/script.py
src/orca/scripts/apps/planner/braille_generator.py
src/orca/scripts/apps/planner/speech_generator.py
diff --git a/src/orca/scripts/apps/Makefile.am b/src/orca/scripts/apps/Makefile.am
index a4c6537..9fe2e7e 100644
--- a/src/orca/scripts/apps/Makefile.am
+++ b/src/orca/scripts/apps/Makefile.am
@@ -2,6 +2,7 @@ SUBDIRS = \
soffice \
evolution \
gcalctool \
+ packagemanager \
pidgin \
planner \
rhythmbox \
diff --git a/src/orca/scripts/apps/packagemanager/Makefile.am b/src/orca/scripts/apps/packagemanager/Makefile.am
new file mode 100644
index 0000000..4da7e38
--- /dev/null
+++ b/src/orca/scripts/apps/packagemanager/Makefile.am
@@ -0,0 +1,8 @@
+orca_pathdir=$(pyexecdir)
+
+orca_python_PYTHON = \
+ __init__.py \
+ script.py \
+ tutorialgenerator.py
+
+orca_pythondir=$(pyexecdir)/orca/scripts/apps/packagemanager
\ No newline at end of file
diff --git a/src/orca/scripts/apps/packagemanager/__init__.py b/src/orca/scripts/apps/packagemanager/__init__.py
new file mode 100644
index 0000000..eca2ae7
--- /dev/null
+++ b/src/orca/scripts/apps/packagemanager/__init__.py
@@ -0,0 +1,23 @@
+# Orca
+#
+# 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
+# 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.
+
+"""Custom script for Packagemanager."""
+
+from script import Script
+
diff --git a/src/orca/scripts/apps/packagemanager/script.py b/src/orca/scripts/apps/packagemanager/script.py
new file mode 100644
index 0000000..3ca4d96
--- /dev/null
+++ b/src/orca/scripts/apps/packagemanager/script.py
@@ -0,0 +1,156 @@
+# Orca
+#
+# 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
+# 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.
+
+"""Custom script for Packagemanager."""
+
+__id__ = "$Id$"
+__version__ = "$Revision$"
+__date__ = "$Date$"
+__copyright__ = "Copyright (c) 2005-2009 Sun Microsystems Inc."
+__license__ = "LGPL"
+
+import pyatspi
+
+import orca.default as default
+import orca.orca_state as orca_state
+import orca.speech as speech
+
+from orca.orca_i18n import _
+
+from tutorialgenerator import TutorialGenerator
+
+########################################################################
+# #
+# The Packagemanager script class. #
+# #
+########################################################################
+
+class Script(default.Script):
+
+ def __init__(self, app):
+ """Creates a new script for the given application.
+
+ Arguments:
+ - app: the application to create a script for.
+ """
+
+ default.Script.__init__(self, app)
+ self._isBusy = False
+
+ def getListeners(self):
+ """Sets up the AT-SPI event listeners for this script."""
+
+ listeners = default.Script.getListeners(self)
+ listeners["object:state-changed:busy"] = self.onStateChanged
+
+ return listeners
+
+ def getTutorialGenerator(self):
+ """Returns the tutorial generator for this script."""
+
+ return TutorialGenerator(self)
+
+ def onStateChanged(self, event):
+ """Called whenever an object's state changes.
+
+ Arguments:
+ - event: the Event
+ """
+
+ # TODO - JD: This might be a good candidate for a braille "flash
+ # message."
+ #
+ if event.source.getRole() == pyatspi.ROLE_FRAME \
+ and event.type.startswith("object:state-changed:busy"):
+ # The busy cursor gets set/unset frequently. It's only worth
+ # presenting if we're in the Search entry (handles both search
+ # and catalog refreshes).
+ #
+ if not self.isSearchEntry(orca_state.locusOfFocus):
+ return
+
+ if event.detail1 == 1 and not self._isBusy:
+ # Translators: this is in reference to loading a web page
+ # or some other content.
+ #
+ speech.speak(_("Loading. Please wait."))
+ self._isBusy = True
+ elif event.detail1 == 0 and self._isBusy:
+ # Translators: this is in reference to loading a web page
+ # or some other content.
+ #
+ speech.speak(_("Finished loading."))
+ self._isBusy = False
+ return
+
+ default.Script.onStateChanged(self, event)
+
+ def findStatusBar(self, obj):
+ """Returns the status bar in the window which contains obj.
+ Overridden here because Packagemanager seems to have multiple
+ status bars which claim to be SHOWING and VISIBLE. The one we
+ want should be displaying text, whereas the others are not.
+ """
+
+ # There are some objects which are not worth descending.
+ #
+ skipRoles = [pyatspi.ROLE_TREE,
+ pyatspi.ROLE_TREE_TABLE,
+ pyatspi.ROLE_TABLE]
+
+ if obj.getState().contains(pyatspi.STATE_MANAGES_DESCENDANTS) \
+ or obj.getRole() in skipRoles:
+ return
+
+ statusBar = None
+ for i in range(obj.childCount - 1, -1, -1):
+ if obj[i].getRole() == pyatspi.ROLE_STATUS_BAR:
+ statusBar = obj[i]
+ elif not obj[i] in skipRoles:
+ statusBar = self.findStatusBar(obj[i])
+
+ if statusBar:
+ try:
+ text = statusBar.queryText()
+ except:
+ pass
+ else:
+ if text.characterCount:
+ break
+
+ return statusBar
+
+ def isSearchEntry(self, obj):
+ """Attempts to distinguish the Search entry from other accessibles.
+
+ Arguments:
+ -obj: the accessible being examined
+
+ Returns True if we think obj is the Search entry.
+ """
+
+ # The Search entry is the only entry inside a toolbar. If that
+ # should change, we'll need to make our criteria more specific.
+ #
+ if obj and obj.getRole() == pyatspi.ROLE_TEXT \
+ and self.getAncestor( \
+ obj, [pyatspi.ROLE_TOOL_BAR], [pyatspi.ROLE_FRAME]):
+ return True
+
+ return False
diff --git a/src/orca/scripts/apps/packagemanager/tutorialgenerator.py b/src/orca/scripts/apps/packagemanager/tutorialgenerator.py
new file mode 100644
index 0000000..68907b8
--- /dev/null
+++ b/src/orca/scripts/apps/packagemanager/tutorialgenerator.py
@@ -0,0 +1,66 @@
+# Orca
+#
+# Copyright 2008-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
+# 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.
+
+__id__ = "$Id$"
+__version__ = "$Revision$"
+__date__ = "$Date$"
+__copyright__ = "Copyright (c) 2008-2009 Sun Microsystems Inc."
+__license__ = "LGPL"
+
+import orca.tutorialgenerator as tutorialgenerator
+
+from orca.orca_i18n import _ # for gettext support
+
+class TutorialGenerator(tutorialgenerator.TutorialGenerator):
+ """Overridden here so that we can provide a custom message regarding
+ how to move focus to the search results after a search has been
+ executed. This is needed because focus remains in the Search entry,
+ and an object in between the entry and the list of results clears
+ the search automatically when given focus."""
+
+ def __init__(self, script):
+ tutorialgenerator.TutorialGenerator.__init__(self, script)
+
+ def _getTutorialForText(self, obj, alreadyFocused, forceTutorial):
+ """Get the tutorial string for a text object.
+
+ Arguments:
+ - obj: the text component
+ - alreadyFocused: False if object just received focus
+ - forceTutorial: used for when whereAmI really needs the tutorial
+ string
+
+ Returns a list of tutorial utterances to be spoken for the object.
+ """
+
+ utterances = tutorialgenerator.TutorialGenerator.\
+ _getTutorialForText(self, obj, alreadyFocused, forceTutorial)
+ if utterances and self._script.isSearchEntry(obj):
+ # Translators: This is the tutorial string associated with a
+ # specific search field in the Packagemanager application.
+ # It is designed to inform the user how to move directly to
+ # the search results after the search has been completed.
+ #
+ utterances.append(_("Use Ctrl+L to move focus to the results."))
+ self._debugGenerator("_getTutorialForText",
+ obj,
+ alreadyFocused,
+ utterances)
+
+ return utterances
diff --git a/src/orca/scripts/toolkits/Gecko/script.py b/src/orca/scripts/toolkits/Gecko/script.py
index 13d5896..1a0abb8 100644
--- a/src/orca/scripts/toolkits/Gecko/script.py
+++ b/src/orca/scripts/toolkits/Gecko/script.py
@@ -1922,18 +1922,21 @@ class Script(default.Script):
#
self._loadingDocumentContent = True
- # Translators: this is in reference to loading a web page.
+ # Translators: this is in reference to loading a web page
+ # or some other content.
#
message = _("Loading. Please wait.")
elif event.source.name:
- # Translators: this is in reference to loading a web page.
+ # Translators: this is in reference to loading a web page
+ # or some other content.
#
message = _("Finished loading %s.") % event.source.name
finishedLoading = True
else:
- # Translators: this is in reference to loading a web page.
+ # Translators: this is in reference to loading a web page
+ # or some other content.
#
message = _("Finished loading.")
finishedLoading = True
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]