[orca] Fix for bgo#611576 - Present date/time.



commit acfcdc22478ff62910b15e15c9a1d8d9bea27ffa
Author: Mesar Hameed <mhameed src gnome org>
Date:   Mon Jun 14 17:43:11 2010 +0100

    Fix for bgo#611576 - Present date/time.
    
    Thanks to Rui Batista and Hammer Attila.

 src/orca/common_keyboardmap.py |    6 ++++++
 src/orca/default.py            |   30 ++++++++++++++++++++++++++++++
 src/orca/orca_prefs.py         |   24 ++++++++++++++++++++++++
 src/orca/settings.py           |   36 ++++++++++++++++++++++++++++++++++++
 4 files changed, 96 insertions(+), 0 deletions(-)
---
diff --git a/src/orca/common_keyboardmap.py b/src/orca/common_keyboardmap.py
index 5ddca3d..81b0cc2 100644
--- a/src/orca/common_keyboardmap.py
+++ b/src/orca/common_keyboardmap.py
@@ -71,6 +71,12 @@ keymap = (
     ("s", defaultModifierMask, ORCA_MODIFIER_MASK,
     "toggleSilenceSpeechHandler"),
 
+    ("t", defaultModifierMask, ORCA_MODIFIER_MASK,
+    "presentTimeHandler", 1),
+
+    ("t", defaultModifierMask, ORCA_MODIFIER_MASK,
+    "presentDateHandler", 2),
+
     ("End", defaultModifierMask, ORCA_CTRL_ALT_MODIFIER_MASK,
     "listAppsHandler"),
     ("Home", defaultModifierMask, ORCA_CTRL_ALT_MODIFIER_MASK,
diff --git a/src/orca/default.py b/src/orca/default.py
index e69053b..1b80af9 100644
--- a/src/orca/default.py
+++ b/src/orca/default.py
@@ -1058,6 +1058,24 @@ class Script(script.Script):
                 #
                 _("Toggle mouse review mode."))
 
+        self.inputEventHandlers["presentTimeHandler"] = \
+            input_event.InputEventHandler(
+                Script.presentTime,
+                # Translators: Orca can present the current time to the
+                # user when the user presses 
+                # a shortcut key.
+                #
+                _("Present current time."))
+
+        self.inputEventHandlers["presentDateHandler"] = \
+            input_event.InputEventHandler(
+                Script.presentDate,
+                # Translators: Orca can present the current date to the
+                # user when the user presses 
+                # a shortcut key.
+                #
+                _("Present current date."))
+
         self.inputEventHandlers["bypassNextCommandHandler"] = \
             input_event.InputEventHandler(
                 Script.bypassNextCommand,
@@ -5645,6 +5663,18 @@ class Script(script.Script):
         speech.speak(_("Unicode %s") % \
                          self.utilities.unicodeValueString(character))
 
+    def presentTime(self, inputEvent):
+        """ Presents the current time. """
+        message = time.strftime(settings.presentTimeFormat, time.localtime())
+        self.presentMessage(message)
+        return True
+
+    def presentDate(self, inputEvent):
+        """ Presents the current date. """
+        message = time.strftime(settings.presentDateFormat, time.localtime())
+        self.presentMessage(message)
+        return True
+
 # Dictionary that defines the state changes we care about for various
 # objects.  The key represents the role and the value represents a list
 # of states that we care about.
diff --git a/src/orca/orca_prefs.py b/src/orca/orca_prefs.py
index 67d42e3..d06fa9f 100644
--- a/src/orca/orca_prefs.py
+++ b/src/orca/orca_prefs.py
@@ -338,6 +338,26 @@ class OrcaPrefs:
         else:
             return "orca.settings.PUNCTUATION_STYLE_ALL"
 
+    def _getPresentTimeString(self, val):
+        if val == settings.TIME_FORMAT_24_HMS:
+            return "orca.settings.TIME_FORMAT_24_HMS"
+        elif val == settings.TIME_FORMAT_24_HMS_WITH_WORDS:
+            return "orca.settings.TIME_FORMAT_24_HMS_WITH_WORDS"
+        elif val == settings.TIME_FORMAT_24_HM:
+            return "orca.settings.TIME_FORMAT_24_HM"
+        elif val == settings.TIME_FORMAT_24_HM_WITH_WORDS:
+            return "orca.settings.TIME_FORMAT_24_HM_WITH_WORDS"
+        else:
+            return "orca.settings.TIME_FORMAT_LOCALE"
+
+    def _getPresentDateString(self, val):
+        if val == settings.DATE_FORMAT_WITH_LONG_NAMES:
+            return "orca.settings.DATE_FORMAT_WITH_LONG_NAMES"
+        elif val == settings.DATE_FORMAT_WITH_SHORT_NAMES:
+            return "orca.settings.DATE_FORMAT_WITH_SHORT_NAMES"
+        else:
+            return "orca.settings.DATE_FORMAT_LOCALE"
+
     def _getSayAllStyleString(self, sayAllStyle):
         """Returns a string that represents the say all style passed in."""
 
@@ -717,6 +737,10 @@ class OrcaPrefs:
                 value = self._getBrailleAlignmentStyleString(prefsDict[key])
             elif key == "verbalizePunctuationStyle":
                 value = self._getVerbalizePunctuationStyleString(prefsDict[key])
+            elif key == "presentDateFormat":
+                value = self._getPresentDateString(prefsDict[key])
+            elif key == "presentTimeFormat":
+                value = self._getPresentTimeString(prefsDict[key])
             elif key == "sayAllStyle":
                 value = self._getSayAllStyleString(prefsDict[key])
             elif key in ["magCursorColor",
diff --git a/src/orca/settings.py b/src/orca/settings.py
index 94121ae..5740428 100644
--- a/src/orca/settings.py
+++ b/src/orca/settings.py
@@ -196,6 +196,8 @@ userCustomizableSettings = [
     "flashIsPersistent",
     "flashVerbosityLevel",
     "messageVerbosityLevel",
+    "presentDateFormat",
+    "presentTimeFormat",
 ]
 
 # The name of the module that hold the user interface for the main window
@@ -1484,3 +1486,37 @@ useExperimentalSpeechProsody = True
 # some introduce unnaturally long pauses between requests to speak.
 #
 enablePauseBreaks = True
+
+# Format directives to use in presentTime function.
+# By default we use the time format according to the current locale.
+# These format strings are passed to python's time.strftime function. To see
+# possible directives to embed in the format strings check:
+# http://docs.python.org/library/time.html#time.strftime
+#
+TIME_FORMAT_LOCALE = "%X"
+TIME_FORMAT_24_HMS = "%H:%M:%S"
+# Translators: Orca has a feature to speak the time
+# when the user presses a shortcut key.
+# This is one of the alternative formats that the 
+# user may wish to be presented with.
+#
+TIME_FORMAT_24_HMS_WITH_WORDS = _("%H hours, %M minutes and %S seconds.")
+TIME_FORMAT_24_HM = "%H:%M"
+# Translators: Orca has a feature to speak the time
+# when the user presses a shortcut key.
+# This is one of the alternative formats that the 
+# user may wish to be presented with.
+#
+TIME_FORMAT_24_HM_WITH_WORDS = _("%H hours and %M minutes.")
+presentTimeFormat = TIME_FORMAT_LOCALE
+
+# Format directives to use in presentDate function.
+# By default we use the date format according to the current locale.
+# These format strings are passed to python's time.strftime function. To see
+# possible directives to embed in the format strings check:
+# http://docs.python.org/library/time.html#time.strftime
+#
+DATE_FORMAT_LOCALE = "%x"
+DATE_FORMAT_WITH_LONG_NAMES = "%A, %d, %B, %Y."
+DATE_FORMAT_WITH_SHORT_NAMES = "%a, %d, %b, %Y."
+presentDateFormat = DATE_FORMAT_LOCALE



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]