[orca/570658] Fix speaking of combo boxes
- From: William Walker <wwalker src gnome org>
- To: svn-commits-list gnome org
- Subject: [orca/570658] Fix speaking of combo boxes
- Date: Tue, 19 May 2009 21:08:27 -0400 (EDT)
commit e28cf5fdb44ad4ecb1a8f431ee2d598db2e0ea12
Author: Willie Walker <william walker sun com>
Date: Tue May 19 20:58:43 2009 -0400
Fix speaking of combo boxes
---
.../scripts/toolkits/Gecko/speech_generator.py | 80 +++++++++----------
1 files changed, 38 insertions(+), 42 deletions(-)
diff --git a/src/orca/scripts/toolkits/Gecko/speech_generator.py b/src/orca/scripts/toolkits/Gecko/speech_generator.py
index 140f60b..9bbef13 100644
--- a/src/orca/scripts/toolkits/Gecko/speech_generator.py
+++ b/src/orca/scripts/toolkits/Gecko/speech_generator.py
@@ -53,8 +53,45 @@ class SpeechGenerator(speechgenerator.SpeechGenerator):
speechgenerator.SpeechGenerator.__init__(self, script)
def _getName(self, obj, **args):
- result = speechgenerator.SpeechGenerator._getName(self, obj, **args)
+ result = []
role = args.get('role', obj.getRole())
+ if role == pyatspi.ROLE_COMBO_BOX:
+ # With Gecko, a combo box has a menu as a child. The text being
+ # displayed for the combo box can be obtained via the selected
+ # menu item.
+ #
+ menu = None
+ for child in obj:
+ if child.getRole() == pyatspi.ROLE_MENU:
+ menu = child
+ break
+ if menu:
+ child = None
+ try:
+ # This should work...
+ #
+ child = menu.querySelection().getSelectedChild(0)
+ if not child:
+ # It's probably a Gtk combo box.
+ #
+ result = \
+ speechgenerator.SpeechGenerator._getDisplayedText(
+ self, obj, **args)
+ except:
+ # But just in case, we'll fall back on this.
+ # [[[TODO - JD: Will we ever have a case where the first
+ # fails, but this will succeed???]]]
+ #
+ for item in menu:
+ if item.getState().contains(pyatspi.STATE_SELECTED):
+ child = item
+ break
+ if child and child.name:
+ result.append(child.name)
+ else:
+ result.extend(speechgenerator.SpeechGenerator._getName(self,
+ obj,
+ **args))
if role == pyatspi.ROLE_LINK:
# Handle empty alt tags.
#
@@ -185,47 +222,6 @@ class SpeechGenerator(speechgenerator.SpeechGenerator):
result.append(text)
return result
- def _getDisplayedText(self, obj, **args):
- result = []
- if obj.getRole() == pyatspi.ROLE_COMBO_BOX:
- # With Gecko, a combo box has a menu as a child. The text being
- # displayed for the combo box can be obtained via the selected
- # menu item.
- #
- menu = None
- for child in obj:
- if child.getRole() == pyatspi.ROLE_MENU:
- menu = child
- break
- if menu:
- child = None
- try:
- # This should work...
- #
- child = menu.querySelection().getSelectedChild(0)
- if not child:
- # It's probably a Gtk combo box.
- #
- result = \
- speechgenerator.SpeechGenerator._getDisplayedText(
- self, obj, **args)
- except:
- # But just in case, we'll fall back on this.
- # [[[TODO - JD: Will we ever have a case where the first
- # fails, but this will succeed???]]]
- #
- for item in menu:
- if item.getState().contains(pyatspi.STATE_SELECTED):
- child = item
- break
- if child and child.name:
- result.append(child.name)
- else:
- result = \
- speechgenerator.SpeechGenerator._getDisplayedText(
- self, obj, **args)
- return result
-
def _getNumberOfChildren(self, obj, **args):
result = []
role = args.get('role', obj.getRole())
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]