[orca] Add preference and unbound keybinding to have Orca speak numbers as digits
- From: Joanmarie Diggs <joanied src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [orca] Add preference and unbound keybinding to have Orca speak numbers as digits
- Date: Wed, 11 Nov 2015 00:38:01 +0000 (UTC)
commit b66aa07cea9514c5644b028414e8a5e051da1bfd
Author: Joanmarie Diggs <jdiggs igalia com>
Date: Tue Nov 10 19:35:50 2015 -0500
Add preference and unbound keybinding to have Orca speak numbers as digits
help/C/commands_speech_settings.page | 3 +++
help/C/preferences_voice.page | 11 +++++++++++
src/orca/cmdnames.py | 6 ++++++
src/orca/common_keyboardmap.py | 3 +++
src/orca/messages.py | 28 ++++++++++++++++++++++++++++
src/orca/orca-setup.ui | 30 ++++++++++++++++++++++++------
src/orca/orca_gui_prefs.py | 2 ++
src/orca/script_utilities.py | 11 +++++++++++
src/orca/scripts/default.py | 21 +++++++++++++++++++++
src/orca/settings.py | 2 ++
10 files changed, 111 insertions(+), 6 deletions(-)
---
diff --git a/help/C/commands_speech_settings.page b/help/C/commands_speech_settings.page
index 34e9ce0..d0cf762 100644
--- a/help/C/commands_speech_settings.page
+++ b/help/C/commands_speech_settings.page
@@ -48,6 +48,9 @@
</p>
</item>
<item>
+ <p>Change the spoken number style: (Unbound)</p>
+ </item>
+ <item>
<p>Cycle to the next spoken punctuation level: (Unbound)</p>
</item>
<item>
diff --git a/help/C/preferences_voice.page b/help/C/preferences_voice.page
index cbb7044..d8957e5 100644
--- a/help/C/preferences_voice.page
+++ b/help/C/preferences_voice.page
@@ -98,6 +98,17 @@
Default value: not checked
</p>
</section>
+ <section id="numbers_as_digits">
+ <title>Speak numbers as digits</title>
+ <p>
+ Checking the <gui>Speak numbers as digits</gui> checkbox will cause
+ <app>Orca</app> to break a number like "123" into separate digits
+ ("1," "2," and "3") prior to passing it along to the speech synthesizer.
+ </p>
+ <p>
+ Default value: not checked
+ </p>
+ </section>
<section id="say_all_by">
<title>Say All By</title>
<p>
diff --git a/src/orca/cmdnames.py b/src/orca/cmdnames.py
index 1a6b4d7..17cff8e 100644
--- a/src/orca/cmdnames.py
+++ b/src/orca/cmdnames.py
@@ -424,6 +424,12 @@ SHOW_APP_PREFERENCES_GUI = \
TOGGLE_SPOKEN_INDENTATION_AND_JUSTIFICATION = \
_("Toggles the speaking of indentation and justification.")
+# Translators: Orca has a setting through which users can control how a number is
+# spoken. The options are digits ("1 2 3") and words ("one hundred and twenty
+# three"). This string to be translated refers to an Orca command for quickly
+# toggling between the two options.
+CHANGE_NUMBER_STYLE = _("Changes spoken number style.")
+
# Translators: Orca allows users to cycle through punctuation levels. None,
# some, most, or all, punctuation will be spoken.
CYCLE_PUNCTUATION_LEVEL = _("Cycles to the next speaking of punctuation level.")
diff --git a/src/orca/common_keyboardmap.py b/src/orca/common_keyboardmap.py
index b34ac91..f7c186a 100644
--- a/src/orca/common_keyboardmap.py
+++ b/src/orca/common_keyboardmap.py
@@ -174,6 +174,9 @@ keymap = (
"cycleKeyEchoHandler"),
("", defaultModifierMask, NO_MODIFIER_MASK,
+ "changeNumberStyleHandler"),
+
+ ("", defaultModifierMask, NO_MODIFIER_MASK,
"repeatLastNotificationMessageHandler"),
("", defaultModifierMask, NO_MODIFIER_MASK,
diff --git a/src/orca/messages.py b/src/orca/messages.py
index 1aad633..3207391 100644
--- a/src/orca/messages.py
+++ b/src/orca/messages.py
@@ -1599,6 +1599,34 @@ NOTIFICATION_LIST_TUTORIAL = \
# is empty.
NOTIFICATION_NO_MESSAGES = _("No notification messages")
+# Translators: Orca has a setting through which users can control how a number is
+# spoken. The options are digits ("1 2 3") and words ("one hundred and twenty
+# three"). There is an associated Orca command for quickly toggling between the
+# two options. This string to be translated is the brief message spoken when the
+# user has enabled speaking numbers as digits.
+NUMBER_STYLE_DIGITS_BRIEF = C_("number style", "digits")
+
+# Translators: Orca has a setting through which users can control how a number is
+# spoken. The options are digits ("1 2 3") and words ("one hundred and twenty
+# three"). There is an associated Orca command for quickly toggling between the
+# two options. This string to be translated is the verbose message spoken when
+# the user has enabled speaking numbers as digits.
+NUMBER_STYLE_DIGITS_FULL = _("Speak numbers as digits.")
+
+# Translators: Orca has a setting through which users can control how a number is
+# spoken. The options are digits ("1 2 3") and words ("one hundred and twenty
+# three"). There is an associated Orca command for quickly toggling between the
+# two options. This string to be translated is the brief message spoken when the
+# user has enabled speaking numbers as words.
+NUMBER_STYLE_WORDS_BRIEF = C_("number style", "words")
+
+# Translators: Orca has a setting through which users can control how a number is
+# spoken. The options are digits ("1 2 3") and words ("one hundred and twenty
+# three"). There is an associated Orca command for quickly toggling between the
+# two options. This string to be translated is the verbose message spoken when
+# the user has enabled speaking numbers as words.
+NUMBER_STYLE_WORDS_FULL = _("Speak numbers as words.")
+
# Translators: This brief message is presented to indicate the state of widgets
# (checkboxes, push buttons, toggle buttons) on a toolbar which are associated
# with text formatting (bold, italics, underlining, justification, etc.).
diff --git a/src/orca/orca-setup.ui b/src/orca/orca-setup.ui
index 65b15a7..3a7841b 100644
--- a/src/orca/orca-setup.ui
+++ b/src/orca/orca-setup.ui
@@ -741,7 +741,7 @@
<property name="can_focus">False</property>
<property name="border_width">12</property>
<property name="row_spacing">10</property>
- <property name="column_spacing">10</property>
+ <property name="column_spacing">40</property>
<child>
<object class="GtkFrame" id="voiceTypeSettingsFrame">
<property name="visible">True</property>
@@ -1069,6 +1069,26 @@
</packing>
</child>
<child>
+ <object class="GtkCheckButton" id="speakNumbersAsDigitsCheckButton">
+ <property name="label" translatable="yes" comments="Translators: If this
this setting is enabled, '123' will be spoken as the individual digits '1 2 3'; otherwise, it will be sent to
the synthesizer and (likely) spoken as 'one hundred and twenty three'.">Speak _numbers as digits</property>
+ <property name="use_action_appearance">False</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">False</property>
+ <property name="use_action_appearance">False</property>
+ <property name="use_underline">True</property>
+ <property name="active">True</property>
+ <property name="draw_indicator">True</property>
+ <signal name="toggled" handler="checkButtonToggled" swapped="no"/>
+ </object>
+ <packing>
+ <property name="left_attach">0</property>
+ <property name="top_attach">2</property>
+ <property name="width">1</property>
+ <property name="height">1</property>
+ </packing>
+ </child>
+ <child>
<object class="GtkGrid" id="sayAllGrid">
<property name="visible">True</property>
<property name="can_focus">False</property>
@@ -1115,7 +1135,7 @@
</object>
<packing>
<property name="left_attach">0</property>
- <property name="top_attach">2</property>
+ <property name="top_attach">3</property>
<property name="width">1</property>
<property name="height">1</property>
</packing>
@@ -1136,10 +1156,8 @@
</child>
</object>
<packing>
- <property name="left_attach">0</property>
- <property name="top_attach">1</property>
- <property name="width">1</property>
- <property name="height">1</property>
+ <property name="left_attach">1</property>
+ <property name="top_attach">0</property>
</packing>
</child>
</object>
diff --git a/src/orca/orca_gui_prefs.py b/src/orca/orca_gui_prefs.py
index e7d1740..d8b5826 100644
--- a/src/orca/orca_gui_prefs.py
+++ b/src/orca/orca_gui_prefs.py
@@ -1312,6 +1312,8 @@ class OrcaSetupGUI(orca_gtkbuilder.GtkBuilderWrapper):
prefs["speakBlankLines"])
self.get_widget("speakMultiCaseStringsAsWordsCheckButton").set_active(\
prefs["speakMultiCaseStringsAsWords"])
+ self.get_widget("speakNumbersAsDigitsCheckButton").set_active(
+ prefs.get("speakNumbersAsDigits", settings.speakNumbersAsDigits))
self.get_widget("enableTutorialMessagesCheckButton").set_active(\
prefs["enableTutorialMessages"])
self.get_widget("enablePauseBreaksCheckButton").set_active(\
diff --git a/src/orca/script_utilities.py b/src/orca/script_utilities.py
index 4ecc981..79d8e6f 100644
--- a/src/orca/script_utilities.py
+++ b/src/orca/script_utilities.py
@@ -2256,6 +2256,13 @@ class Utilities:
def _processMultiCaseString(string):
return re.sub(r'(?<=[a-z])(?=[A-Z])', ' ', string)
+ @staticmethod
+ def _convertWordToDigits(word):
+ if not word.isnumeric():
+ return word
+
+ return ' '.join(list(word))
+
def adjustForPronunciation(self, line):
"""Adjust the line to replace words in the pronunciation dictionary,
with what those words actually sound like.
@@ -2273,6 +2280,10 @@ class Utilities:
if self.speakMathSymbolNames():
line = mathsymbols.adjustForSpeech(line)
+ if settings.speakNumbersAsDigits:
+ words = self.WORDS_RE.split(line)
+ line = ''.join(map(self._convertWordToDigits, words))
+
if not settings.usePronunciationDictionary:
return line
diff --git a/src/orca/scripts/default.py b/src/orca/scripts/default.py
index 65af5a6..d21fccf 100644
--- a/src/orca/scripts/default.py
+++ b/src/orca/scripts/default.py
@@ -437,6 +437,12 @@ class Script(script.Script):
Script.toggleSpeakingIndentationJustification,
cmdnames.TOGGLE_SPOKEN_INDENTATION_AND_JUSTIFICATION)
+ self.inputEventHandlers[ \
+ "changeNumberStyleHandler"] = \
+ input_event.InputEventHandler(
+ Script.changeNumberStyle,
+ cmdnames.CHANGE_NUMBER_STYLE)
+
self.inputEventHandlers["cycleSpeakingPunctuationLevelHandler"] = \
input_event.InputEventHandler(
Script.cycleSpeakingPunctuationLevel,
@@ -1970,6 +1976,21 @@ class Script(script.Script):
self.presentMessage(full, brief)
return True
+ def changeNumberStyle(self, inputEvent=None):
+ """Changes spoken number style between digits and words."""
+
+ speakDigits = _settingsManager.getSetting('speakNumbersAsDigits')
+ if speakDigits:
+ brief = messages.NUMBER_STYLE_WORDS_BRIEF
+ full = messages.NUMBER_STYLE_WORDS_FULL
+ else:
+ brief = messages.NUMBER_STYLE_DIGITS_BRIEF
+ full = messages.NUMBER_STYLE_DIGITS_FULL
+
+ _settingsManager.setSetting('speakNumbersAsDigits', not speakDigits)
+ self.presentMessage(full, brief)
+ return True
+
def toggleTableCellReadMode(self, inputEvent=None):
"""Toggles an indicator for whether we should just read the current
table cell or read the whole row."""
diff --git a/src/orca/settings.py b/src/orca/settings.py
index 64989dc..b44eab5 100644
--- a/src/orca/settings.py
+++ b/src/orca/settings.py
@@ -74,6 +74,7 @@ userCustomizableSettings = [
"keyboardLayout",
"speakBlankLines",
"speakMultiCaseStringsAsWords",
+ "speakNumbersAsDigits",
"enabledSpokenTextAttributes",
"enabledBrailledTextAttributes",
"textAttributesBrailleIndicator",
@@ -203,6 +204,7 @@ speakCellSpan = True
speakCellHeaders = True
speakSpreadsheetCoordinates = True
speakMultiCaseStringsAsWords = False
+speakNumbersAsDigits = False
useColorNames = True
usePronunciationDictionary = True
sayAllStyle = SAYALL_STYLE_SENTENCE
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]