orca r4426 - in trunk: . src/orca
- From: wwalker svn gnome org
- To: svn-commits-list gnome org
- Subject: orca r4426 - in trunk: . src/orca
- Date: Sat, 17 Jan 2009 02:21:34 +0000 (UTC)
Author: wwalker
Date: Sat Jan 17 02:21:34 2009
New Revision: 4426
URL: http://svn.gnome.org/viewvc/orca?rev=4426&view=rev
Log:
Fix for bug #535221 - Automatic shortcut information spoken.
Modified:
trunk/ChangeLog
trunk/src/orca/default.py
trunk/src/orca/orca-setup.glade
trunk/src/orca/orca_gui_prefs.py
trunk/src/orca/settings.py
trunk/src/orca/speechgenerator.py
Modified: trunk/src/orca/default.py
==============================================================================
--- trunk/src/orca/default.py (original)
+++ trunk/src/orca/default.py Sat Jan 17 02:21:34 2009
@@ -6813,7 +6813,7 @@
Arguments:
- obj: the Accessible object
- Returns: list containing strings: [mnemonic, accelerator, shortcut]
+ Returns: list containing strings: [mnemonic, shortcut, accelerator]
"""
try:
@@ -6828,7 +6828,7 @@
#
# The keybindings in <full-path> should be separated by ":"
#
- bindingStrings = action.getKeyBinding(0).split(';')
+ bindingStrings = action.getKeyBinding(0).decode("UTF-8").split(';')
if len(bindingStrings) == 3:
mnemonic = bindingStrings[0]
Modified: trunk/src/orca/orca-setup.glade
==============================================================================
--- trunk/src/orca/orca-setup.glade (original)
+++ trunk/src/orca/orca-setup.glade Sat Jan 17 02:21:34 2009
@@ -1407,6 +1407,26 @@
</child>
<child>
+ <widget class="GtkCheckButton" id="speakMnemonicsCheckButton">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="label" translatable="yes">Spea_k object mnemonics</property>
+ <property name="use_underline">True</property>
+ <property name="relief">GTK_RELIEF_NORMAL</property>
+ <property name="focus_on_click">True</property>
+ <property name="active">True</property>
+ <property name="inconsistent">False</property>
+ <property name="draw_indicator">True</property>
+ <signal name="toggled" handler="mnemonicSpeakingChecked" last_modification_time="Mon, 04 Aug 2008 17:11:04 GMT"/>
+ </widget>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ </packing>
+ </child>
+
+ <child>
<widget class="GtkHBox" id="hbox39">
<property name="visible">True</property>
<property name="homogeneous">False</property>
Modified: trunk/src/orca/orca_gui_prefs.py
==============================================================================
--- trunk/src/orca/orca_gui_prefs.py (original)
+++ trunk/src/orca/orca_gui_prefs.py Sat Jan 17 02:21:34 2009
@@ -1488,6 +1488,9 @@
self.get_widget("speakTutorialMessagesCheckButton").set_active(\
prefs["enableTutorialMessages"])
+ self.get_widget("speakMnemonicsCheckButton").set_active(\
+ prefs["enableMnemonicSpeaking"])
+
self.get_widget("sayAllStyle").set_active(prefs["sayAllStyle"])
# Set the sensitivity of the "Update Interval" items, depending
@@ -2486,6 +2489,17 @@
self.prefsDict["enableTutorialMessages"] = widget.get_active()
+ def mnemonicSpeakingChecked (self, widget):
+ """Signal handler for the "toggled" signal for the
+ speakMnemonicsCheckButton GtkCheckButton widget.
+ Set the 'Speak mnemonics automaticaly' preference to the new value.
+
+ Arguments:
+ - widget: the component that generated the signal.
+ """
+
+ self.prefsDict["enableMnemonicSpeaking"] = widget.get_active()
+
def brailleSupportChecked(self, widget):
"""Signal handler for the "toggled" signal for the
brailleSupportCheckbutton GtkCheckButton widget. The user has
Modified: trunk/src/orca/settings.py
==============================================================================
--- trunk/src/orca/settings.py (original)
+++ trunk/src/orca/settings.py Sat Jan 17 02:21:34 2009
@@ -105,6 +105,7 @@
"enableActionKeys",
"enableNavigationKeys",
"enableTutorialMessages",
+ "enableMnemonicSpeaking",
"enableBraille",
"enableBrailleContext",
"enableBrailleGrouping",
@@ -574,9 +575,14 @@
#
enableNavigationKeys = False
-# If True, roles that have tutorial strings defined will be spoken.
+# If True, tutorial strings defined will be spoken.
+#
enableTutorialMessages = False
+# If True, mnemonics will be spoken.
+#
+enableMnemonicSpeaking = False
+
# If True, show the main Orca window.
#
showMainWindow = True
Modified: trunk/src/orca/speechgenerator.py
==============================================================================
--- trunk/src/orca/speechgenerator.py (original)
+++ trunk/src/orca/speechgenerator.py Sat Jan 17 02:21:34 2009
@@ -155,25 +155,53 @@
self.speechGenerators[pyatspi.ROLE_WINDOW] = \
self._getSpeechForWindow
- def _getSpeechForObjectAccelerator(self, obj):
- """Returns a list of utterances that describes the keyboard
- accelerator (and possibly shortcut) for the given object.
+ def _addSpeechForObjectAccelerator(self, obj, utterances):
+ """Adds an utterance that describes the keyboard accelerator for the
+ given object to the list of utterances passed in.
Arguments:
- obj: the Accessible object
+ - utterances: the list of utterances to add to.
Returns a list of utterances to be spoken.
"""
- utterances = []
-
- result = self._script.getKeyBinding(obj)
- accelerator = result[2]
+ if settings.speechVerbosityLevel == settings.VERBOSITY_LEVEL_VERBOSE:
+ [mnemonic, shortcut, accelerator] = self._script.getKeyBinding(obj)
+ if accelerator:
+ # Add punctuation for better prosody.
+ #
+ #if utterances:
+ # utterances[-1] += "."
+ utterances.append(accelerator)
+
+ def _addSpeechForObjectMnemonic(self, obj, utterances):
+ """Adds an utterance that describes the mnemonic for the given object
+ to the utterances passed in.
- if len(accelerator) > 0:
- utterances.append(accelerator)
+ Arguments:
+ - obj: the Accessible object
+ - utterances: the list of utterances to add to.
+ """
- return utterances
+ if settings.enableMnemonicSpeaking:
+ # The mnemonic is what we're really looking for. But,
+ # some objects (e.g., menu items) only expose the mnemonic
+ # via the full shortcut (e.g., "Alt f c" for a "Close"
+ # menu item). So, we fall back to the last character in
+ # the shortcut if the shortcut exists.
+ #
+ [mnemonic, shortcut, accelerator] = self._script.getKeyBinding(obj)
+ if mnemonic:
+ mnemonic = mnemonic[-1] # we just want a single character
+ if not mnemonic and shortcut:
+ mnemonic = shortcut
+ if mnemonic:
+ # Add punctuation for better prosody.
+ #
+ #if utterances:
+ # utterances[-1] += "."
+ utterances.append(mnemonic)
def _getSpeechForObjectAvailability(self, obj):
"""Returns a list of utterances that describes the availability
@@ -294,7 +322,7 @@
The default speech will be of the following form:
- label name role availability
+ label name role availability mnemonic
Arguments:
- obj: an Accessible
@@ -315,8 +343,9 @@
utterances.extend(name)
utterances.extend(self._getSpeechForAllTextSelection(obj))
utterances.extend(self.getSpeechForObjectRole(obj, role))
-
- utterances.extend(self._getSpeechForObjectAvailability(obj))
+ utterances.extend(self._getSpeechForObjectAvailability(obj))
+ if obj == orca_state.locusOfFocus:
+ self._addSpeechForObjectMnemonic(obj, utterances)
self._debugGenerator("_getDefaultSpeech",
obj,
@@ -416,6 +445,7 @@
"""
utterances = []
+
state = obj.getState()
if state.contains(pyatspi.STATE_INDETERMINATE):
# Translators: this represents the state of a checkbox.
@@ -445,8 +475,9 @@
else:
utterances.extend(self.getSpeechForObjectRole(obj))
utterances.append(checkedState)
- utterances.extend(self._getSpeechForObjectAvailability(obj))
utterances.extend(self._getSpeechForRequiredObject(obj))
+ utterances.extend(self._getSpeechForObjectAvailability(obj))
+ self._addSpeechForObjectMnemonic(obj, utterances)
else:
utterances.append(checkedState)
@@ -470,9 +501,8 @@
utterances = self._getSpeechForCheckBox(obj, already_focused)
- if (settings.speechVerbosityLevel == settings.VERBOSITY_LEVEL_VERBOSE)\
- and not already_focused:
- utterances.extend(self._getSpeechForObjectAccelerator(obj))
+ if not already_focused:
+ self._addSpeechForObjectAccelerator(obj, utterances)
self._debugGenerator("_getSpeechForCheckMenuItem",
obj,
@@ -526,12 +556,13 @@
if not already_focused:
utterances.extend(self.getSpeechForObjectRole(obj))
- utterances.extend(self._getSpeechForObjectAvailability(obj))
-
for child in obj:
if child.getRole() == pyatspi.ROLE_TEXT:
utterances.extend(self._getSpeechForAllTextSelection(child))
+ utterances.extend(self._getSpeechForObjectAvailability(obj))
+ self._addSpeechForObjectMnemonic(obj, utterances)
+
self._debugGenerator("_getSpeechForComboBox",
obj,
already_focused,
@@ -687,7 +718,7 @@
alertAndDialogCount) % alertAndDialogCount
utterances.append(line)
- utterances.extend(self._getSpeechForObjectAvailability(obj))
+ utterances.extend(self._getSpeechForObjectAvailability(obj))
self._debugGenerator("_getSpeechForFrame",
obj,
@@ -864,7 +895,7 @@
"""
utterances = []
-
+
if not already_focused:
label = self._getSpeechForObjectLabel(obj)
utterances.extend(label)
@@ -872,7 +903,6 @@
if name != label:
utterances.extend(name)
utterances.extend(self._getSpeechForAllTextSelection(obj))
- utterances.extend(self._getSpeechForObjectAvailability(obj))
# If already in focus then the tree probably collapsed or expanded
state = obj.getState()
@@ -890,6 +920,8 @@
#
utterances.append(_("collapsed"))
+ utterances.extend(self._getSpeechForObjectAvailability(obj))
+
self._debugGenerator("_getSpeechForListItem",
obj,
already_focused,
@@ -906,12 +938,19 @@
Returns a list of utterances to be spoken for the object.
"""
- utterances = self._getDefaultSpeech(obj, already_focused)
+ utterances = []
- if (obj == orca_state.locusOfFocus) \
- and (settings.speechVerbosityLevel \
- == settings.VERBOSITY_LEVEL_VERBOSE):
- utterances.extend(self._getSpeechForObjectAccelerator(obj))
+ if not already_focused:
+ label = self._getSpeechForObjectLabel(obj)
+ utterances.extend(label)
+ name = self._getSpeechForObjectName(obj)
+ if name != label:
+ utterances.extend(name)
+ utterances.extend(self._getSpeechForAllTextSelection(obj))
+ utterances.extend(self.getSpeechForObjectRole(obj))
+ utterances.extend(self._getSpeechForObjectAvailability(obj))
+ self._addSpeechForObjectMnemonic(obj, utterances)
+ self._addSpeechForObjectAccelerator(obj, utterances)
self._debugGenerator("_getSpeechForMenu",
obj,
@@ -931,7 +970,6 @@
"""
utterances = self._getDefaultSpeech(obj, already_focused)
-
self._debugGenerator("_getSpeechForMenuBar",
obj,
already_focused,
@@ -949,12 +987,11 @@
Returns a list of utterances to be spoken for the object.
"""
+ utterances = []
+
# No need to say "menu item" because we already know that.
#
- utterances = self._getSpeechForObjectName(obj)
- if settings.speechVerbosityLevel == settings.VERBOSITY_LEVEL_VERBOSE:
- utterances.extend(self._getSpeechForObjectAvailability(obj))
- utterances.extend(self._getSpeechForObjectAccelerator(obj))
+ utterances.extend(self._getSpeechForObjectName(obj))
# OpenOffice check menu items currently have a role of "menu item"
# rather then "check menu item", so we need to test if one of the
@@ -969,6 +1006,11 @@
#
utterances.append(_("checked"))
+ if not already_focused:
+ utterances.extend(self._getSpeechForObjectAvailability(obj))
+ self._addSpeechForObjectMnemonic(obj, utterances)
+ self._addSpeechForObjectAccelerator(obj, utterances)
+
self._debugGenerator("_getSpeechForMenuItem",
obj,
already_focused,
@@ -1008,6 +1050,8 @@
utterances.extend(self._getSpeechForAllTextSelection(obj))
+ self._addSpeechForObjectMnemonic(obj, utterances)
+
self._debugGenerator("_getSpeechForText",
obj,
already_focused,
@@ -1146,6 +1190,7 @@
"""
utterances = []
+
state = obj.getState()
if state.contains(pyatspi.STATE_CHECKED):
# Translators: this is in reference to a radio button being
@@ -1172,6 +1217,7 @@
utterances.append(selectionState)
utterances.extend(self.getSpeechForObjectRole(obj))
utterances.extend(self._getSpeechForObjectAvailability(obj))
+ self._addSpeechForObjectMnemonic(obj, utterances)
else:
utterances.append(selectionState)
@@ -1187,17 +1233,17 @@
already had focus, then only the state is spoken.
Arguments:
- - obj: the check menu item
+ - obj: the radio menu item
- already_focused: False if object just received focus
Returns a list of utterances to be spoken for the object.
"""
- utterances = self._getSpeechForRadioButton(obj, False)
+ utterances = []
+ utterances.extend(self._getSpeechForRadioButton(obj, False))
- if settings.speechVerbosityLevel == settings.VERBOSITY_LEVEL_VERBOSE:
- utterances.extend(self._getSpeechForObjectAvailability(obj))
- utterances.extend(self._getSpeechForObjectAccelerator(obj))
+ if not already_focused:
+ self._addSpeechForObjectAccelerator(obj, utterances)
self._debugGenerator("_getSpeechForRadioMenuItem",
obj,
@@ -1280,9 +1326,9 @@
utterances.extend(self._getSpeechForObjectName(obj))
utterances.extend(self.getSpeechForObjectRole(obj))
utterances.append(valueString)
- utterances.extend(self._getSpeechForObjectAvailability(obj))
utterances.extend(self._getSpeechForRequiredObject(obj))
-
+ utterances.extend(self._getSpeechForObjectAvailability(obj))
+ self._addSpeechForObjectMnemonic(obj, utterances)
self._debugGenerator("_getSpeechForSlider",
obj,
already_focused,
@@ -1336,6 +1382,7 @@
utterances.extend(self.getSpeechForObjectRole(obj))
utterances.append(valueString)
utterances.extend(self._getSpeechForObjectAvailability(obj))
+ self._addSpeechForObjectMnemonic(obj, utterances)
self._debugGenerator("_getSpeechForSplitPane",
obj,
@@ -1701,6 +1748,7 @@
"""
utterances = []
+
state = obj.getState()
if state.contains(pyatspi.STATE_CHECKED) \
or state.contains(pyatspi.STATE_PRESSED):
@@ -1723,6 +1771,7 @@
utterances.extend(self.getSpeechForObjectRole(obj))
utterances.append(checkedState)
utterances.extend(self._getSpeechForObjectAvailability(obj))
+ self._addSpeechForObjectMnemonic(obj, utterances)
else:
utterances.append(checkedState)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]