[orca] Add a new, unbound command to cycle amongst saved settings profiles
- From: Joanmarie Diggs <joanied src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [orca] Add a new, unbound command to cycle amongst saved settings profiles
- Date: Fri, 28 Dec 2012 20:12:04 +0000 (UTC)
commit 3dc49975bcc5ee3bd4eb9cde1a16dfa7835bbeda
Author: Joanmarie Diggs <jdiggs igalia com>
Date: Fri Dec 28 15:11:20 2012 -0500
Add a new, unbound command to cycle amongst saved settings profiles
src/orca/common_keyboardmap.py | 3 ++
src/orca/scripts/default.py | 46 ++++++++++++++++++++++++++++++++++++++++
src/orca/settings_manager.py | 3 ++
3 files changed, 52 insertions(+), 0 deletions(-)
---
diff --git a/src/orca/common_keyboardmap.py b/src/orca/common_keyboardmap.py
index 71d41a4..e60c8dc 100644
--- a/src/orca/common_keyboardmap.py
+++ b/src/orca/common_keyboardmap.py
@@ -165,6 +165,9 @@ keymap = (
#####################################################################
("", defaultModifierMask, NO_MODIFIER_MASK,
+ "cycleSettingsProfileHandler"),
+
+ ("", defaultModifierMask, NO_MODIFIER_MASK,
"cycleCapitalizationStyleHandler"),
("", defaultModifierMask, NO_MODIFIER_MASK,
diff --git a/src/orca/scripts/default.py b/src/orca/scripts/default.py
index 06c12bd..15b6353 100644
--- a/src/orca/scripts/default.py
+++ b/src/orca/scripts/default.py
@@ -875,6 +875,19 @@ class Script(script.Script):
#
_("Cycles to the next speaking of punctuation level."))
+ self.inputEventHandlers["cycleSettingsProfileHandler"] = \
+ input_event.InputEventHandler(
+ Script.cycleSettingsProfile,
+ # Translators: Orca has a feature whereby users can set up
+ # different "profiles," which are collection of settings which
+ # apply to a given task, such as a "Spanish" profile which would
+ # use Spanish text-to-speech and Spanish braille and selected
+ # when reading Spanish content. This string to be translated
+ # refers to an Orca command which makes it possible for users
+ # to quickly cycle amongst their saved profiles without having
+ # to get into a GUI.
+ _("Cycles to the next settings profile."))
+
self.inputEventHandlers["cycleCapitalizationStyleHandler"] = \
input_event.InputEventHandler(
Script.cycleCapitalizationStyle,
@@ -2773,6 +2786,39 @@ class Script(script.Script):
speech.updatePunctuationLevel()
return True
+ def cycleSettingsProfile(self, inputEvent=None):
+ """Cycle through the user's existing settings profiles."""
+
+ profiles = _settingsManager.availableProfiles()
+ if not (profiles and profiles[0]):
+ # Translators: This is an error message presented when the user
+ # attempts to cycle among his/her saved profiles, but no profiles
+ # can be found. A profile is a collection of settings which apply
+ # to a given task, such as a "Spanish" profile which would use
+ # Spanish text-to-speech and Spanish braille and selected when
+ # reading Spanish content.
+ #
+ self.presentMessage(_("No profiles found."))
+ return True
+
+ isMatch = lambda x: x[1] == _settingsManager.getProfile()
+ current = list(filter(isMatch, profiles))[0]
+ try:
+ name, profileID = profiles[profiles.index(current) + 1]
+ except IndexError:
+ name, profileID = profiles[0]
+
+ _settingsManager.setProfile(profileID)
+ # Translators: This is a detailed message which will be presented
+ # as the user cycles amongst his/her saved profiles. A "profile"
+ # is a collection of settings which apply to a given task, such
+ # as a "Spanish" profile which would use Spanish text-to-speech
+ # and Spanish braille and selected when reading Spanish content.
+ # The string representing the profile name is something created
+ # by the user.
+ self.presentMessage(_("Profile set to %s.") % name, name)
+ return True
+
def cycleCapitalizationStyle(self, inputEvent=None):
""" Cycle through the speech-dispatcher capitalization styles. """
diff --git a/src/orca/settings_manager.py b/src/orca/settings_manager.py
index ad51192..1891a02 100644
--- a/src/orca/settings_manager.py
+++ b/src/orca/settings_manager.py
@@ -354,6 +354,9 @@ class SettingsManager(object):
profile = settings.profile
self._backend._setProfileKey('startingProfile', profile)
+ def getProfile(self):
+ return self.profile
+
def setProfile(self, profile='default'):
"""Set a specific profile as the active one.
Also the settings from that profile will be loading
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]