[orca] Fix for bug #627451 - Orca needs a way to repeat the latest notification messages.
- From: Alejandro Leiva <aleiva src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [orca] Fix for bug #627451 - Orca needs a way to repeat the latest notification messages.
- Date: Mon, 30 Aug 2010 20:08:42 +0000 (UTC)
commit 3f8034549b1e03282677ace7c38f700e9233d5f8
Author: José Vilmar Estácio de Souza <vilmar informal com br>
Date: Mon Aug 30 21:11:48 2010 +0200
Fix for bug #627451 - Orca needs a way to repeat the latest notification messages.
po/POTFILES.in | 1 +
src/orca/Makefile.am | 1 +
src/orca/common_keyboardmap.py | 9 +
src/orca/default.py | 3 +
src/orca/notification_messages.py | 258 ++++++++++++++++++++++++++++
src/orca/orca.py | 3 +
src/orca/scripts/apps/notify-osd/script.py | 4 +-
7 files changed, 278 insertions(+), 1 deletions(-)
---
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 558961f..6248cce 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -20,6 +20,7 @@ src/orca/keybindings.py
src/orca/keynames.py
src/orca/liveregions.py
src/orca/mag.py
+src/orca/notification_messages.py
src/orca/openttsfactory.py
[type: gettext/glade]src/orca/orca-advanced-magnification.ui
src/orca/orca_console_prefs.py
diff --git a/src/orca/Makefile.am b/src/orca/Makefile.am
index 83b9ec1..17530dd 100644
--- a/src/orca/Makefile.am
+++ b/src/orca/Makefile.am
@@ -41,6 +41,7 @@ orca_python_PYTHON = \
liveregions.py \
mag.py \
mouse_review.py \
+ notification_messages.py \
openttsfactory.py \
orca.py \
orca_console_prefs.py \
diff --git a/src/orca/common_keyboardmap.py b/src/orca/common_keyboardmap.py
index 81b0cc2..03bc0a7 100644
--- a/src/orca/common_keyboardmap.py
+++ b/src/orca/common_keyboardmap.py
@@ -216,4 +216,13 @@ keymap = (
("", defaultModifierMask, NO_MODIFIER_MASK,
"cycleKeyEchoHandler"),
+ ("", defaultModifierMask, NO_MODIFIER_MASK,
+ "repeatLastNotificationMessageHandler"),
+
+ ("", defaultModifierMask, NO_MODIFIER_MASK,
+ "repeatPreviousNotificationMessageHandler"),
+
+ ("", defaultModifierMask, NO_MODIFIER_MASK,
+ "enableNotificationMessageListModeHandler"),
+
)
diff --git a/src/orca/default.py b/src/orca/default.py
index d298e47..8011de5 100644
--- a/src/orca/default.py
+++ b/src/orca/default.py
@@ -56,6 +56,7 @@ import speech
import speechserver
import mouse_review
import text_attribute_names
+import notification_messages
from orca_i18n import _ # for gettext support
from orca_i18n import ngettext # for ngettext support
@@ -1095,6 +1096,8 @@ class Script(script.Script):
#
_("Passes the next command on to the current application."))
+ self.inputEventHandlers.update(notification_messages.inputEventHandlers)
+
def getInputEventHandlerKey(self, inputEventHandler):
"""Returns the name of the key that contains an inputEventHadler
passed as argument
diff --git a/src/orca/notification_messages.py b/src/orca/notification_messages.py
new file mode 100644
index 0000000..a4ca942
--- /dev/null
+++ b/src/orca/notification_messages.py
@@ -0,0 +1,258 @@
+# Orca
+#
+# Copyright 2010 Informal Informatica LTDA.
+# Author: Jose Vilmar <vilmar informal com br>
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Library General Public
+# License as published by the Free Software Foundation; either
+# version 2 of the License, or (at your option) any later version.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Library General Public License for more details.
+#
+# You should have received a copy of the GNU Library General Public
+# License along with this library; if not, write to the
+# Free Software Foundation, Inc., Franklin Street, Fifth Floor,
+# Boston MA 02110-1301 USA.
+
+"""Module for notification messages"""
+__id__ = "$Id$"
+__version__ = "$Revision$"
+__date__ = "$Date$"
+__copyright__ = "Copyright (c) 2010 Informal Informatica LTDA."
+__license__ = "LGPL"
+
+import settings
+import pyatspi
+import input_event
+import orca_state
+import speech
+import debug
+
+from orca_i18n import _
+from orca_i18n import C_
+from orca_i18n import ngettext
+
+# to store the messages generated by the notification daemon
+notificationMessages = []
+
+# max size of the list
+maxSizeList = 55
+
+# a index to walk in the list of messages
+indexNotificationMessages = 0
+
+# when True the list mode is enabled
+listNotificationMessagesModeEnabled = False
+
+# number of keys invalid while in when in list notification mode.
+# if > 3, call _help()
+invalidKeys = 0
+
+# input event handlers
+inputEventHandlers = {}
+
+def repeatLastNotificationMessage(script=None, inputEvent=None):
+ """ Repeats the last notification message. """
+
+ _showNotificationMessage(1)
+ return True
+
+def repeatPreviousNotificationMessage(script=None, inputEvent=None):
+ """ Repeats the previous notification message. """
+
+ _showNotificationMessage(2)
+ return True
+
+def enableNotificationMessageListMode(script=None, inputEvent=None):
+ """ Enables the list of notification message. """
+
+ _listModeEnable()
+ return True
+
+inputEventHandlers["repeatLastNotificationMessageHandler"] = \
+ input_event.InputEventHandler(
+ repeatLastNotificationMessage,
+ # Translators: Orca can present the last notification message
+ # to the user when the user presses a shortcut key.
+ #
+ _("Present last notification message."))
+
+inputEventHandlers["repeatPreviousNotificationMessageHandler"] = \
+ input_event.InputEventHandler(
+ repeatPreviousNotificationMessage,
+ # Translators: Orca can present the previous notification message
+ # to the user when the user presses a shortcut key.
+ #
+ _("Present previous notification message."))
+
+inputEventHandlers["enableNotificationMessageListModeHandler"] = \
+ input_event.InputEventHandler(
+ enableNotificationMessageListMode,
+ # Translators: Orca can enable the notification messages
+ # list mode when the user presses a shortcut key.
+ #
+ _("Enable notification message list mode. " \
+ "Press Escape to exit or h for help"))
+
+def _showMessage(msg):
+ speech.speak(msg, None, True)
+ orca_state.activeScript.displayBrailleMessage(msg, \
+ flashTime=settings.brailleFlashTime)
+
+def saveMessage(msg):
+ """save the message in a list to be presented later"""
+
+ while size() >= maxSizeList:
+ del notificationMessages[0]
+
+ notificationMessages.append(msg)
+
+ debug.println(debug.LEVEL_FINEST, \
+ "saveMessage (queue length: %s)"\
+ % (size()))
+
+def size():
+ """ return the size of the queue messages """
+
+ return len(notificationMessages)
+
+def _messagesPresent():
+
+ if size() <= 0:
+ # Translators: This is a brief message presented to the user
+ # the list of notifications is empty.
+ #
+ msg = _("No notification messages")
+ _showMessage(msg)
+ return False
+
+ return True
+
+def _listModeEnable():
+ """ enable the list mode if the queue is not empty """
+
+ global indexNotificationMessages
+ global listNotificationMessagesModeEnabled
+ global invalidKeys
+ if _messagesPresent():
+ indexNotificationMessages = 1
+ invalidKeys = 0
+ listNotificationMessagesModeEnabled = True
+ _help()
+ _showNotificationMessage(indexNotificationMessages)
+
+ return True
+
+def _showNotificationMessage(index):
+ global indexNotificationMessages
+ if not _messagesPresent():
+ return
+
+ if index < 1:
+ index = 1
+ # Translators: This is a brief message presented to the user when
+ # when the top of a list of notifications is reached.
+ #
+ msg = C_("notification", "Top")
+ _showMessage(msg)
+ elif index > size():
+ index = size()
+ # Translators: This is a brief message presented to the user when
+ # when the bottom of a list of notifications is reached.
+ #
+ msg = C_("notification", "Bottom")
+ _showMessage(msg)
+
+ indexNotificationMessages = index
+ index = size() - index
+ debug.println(debug.LEVEL_FINEST, \
+ "_showNotificationMessage (queue length: %s, index: %s)"\
+ % (size(), index))
+ if index >= 0 and index < size():
+ msg = notificationMessages[index]
+ _showMessage(msg)
+
+def exitListNotificationMessagesMode():
+ """ Turns list notification messages mode off. """
+
+ global listNotificationMessagesModeEnabled
+ listNotificationMessagesModeEnabled = False
+ # Translators: Orca has a "List notification messages Mode" that allows
+ # the user to list the latest notification messages received.
+ # Escape exits this mode.
+ # This string is the prompt which will be presented to the user
+ # in both speech and braille upon exiting this mode.
+ #
+ message = _("Exiting list notification messages mode.")
+ _showMessage(message)
+
+def listNotificationMessages(event):
+ """ When list notification messages mode is enabled, this function
+ provides a means by which users can navigate through the list the
+ notification messages. User can use the navigation keys or press
+ the number of the message. Pressing escape key disable the mode.
+ """
+
+ global indexNotificationMessages
+ global invalidKeys
+ consumed = True
+ speak = True
+
+ if event.type != pyatspi.KEY_PRESSED_EVENT:
+ return False
+ speech.stop()
+ if event.event_string == "Escape":
+ exitListNotificationMessagesMode()
+ speak = False
+ elif event.event_string == "Home":
+ indexNotificationMessages = 1
+ elif event.event_string == "End":
+ indexNotificationMessages = size()
+ elif event.event_string == "Up":
+ indexNotificationMessages -= 1
+ elif event.event_string == "Down":
+ indexNotificationMessages += 1
+ elif event.event_string in\
+ [ '1', '2', '3', '4', '5', '6', '7', '8', '9' ]:
+ indexNotificationMessages = int(event.event_string)
+ elif event.event_string in [ 'h', 'H']:
+ _help(True)
+ speak = False
+ elif event.event_string == "space":
+ pass
+ else:
+ speak = False
+ invalidKeys += 1
+ if invalidKeys > 2:
+ _help()
+ invalidKeys = 0
+
+ if speak:
+ _showNotificationMessage(indexNotificationMessages)
+ invalidKeys = 0
+
+ return consumed
+
+def _help(longHelp = False):
+
+ # Translators: This message inform to the user the number of
+ # messages in the list.
+ msg = ngettext("%d message.\n", "%d messages.\n", int(size())) % (size())
+ # Translators: This is a help message.
+ msg += _("Press h for help.\n")
+ if longHelp:
+ # Translators: The following string instructs the user how to navigate
+ # amongst the list of commands presented in list notification
+ # messages mode as well as how to exit the list.
+ #
+ msg += \
+ _("Use Up, Down, Home or End to navigate in the list.\n"\
+ "Press Escape to exit.\n"\
+ "Press Space to repeat the last message read.\n"\
+ "Press one digit to read a specific message.\n")
+
+ _showMessage(msg)
diff --git a/src/orca/orca.py b/src/orca/orca.py
index 94153b8..00c562c 100644
--- a/src/orca/orca.py
+++ b/src/orca/orca.py
@@ -84,6 +84,7 @@ import keybindings
import orca_state
import orca_platform
import speech
+import notification_messages
from input_event import BrailleEvent
from input_event import KeyboardEvent
@@ -920,6 +921,8 @@ def _processKeyboardEvent(event):
else:
if settings.listShortcutsModeEnabled:
consumed = listShortcuts(keyboardEvent)
+ elif notification_messages.listNotificationMessagesModeEnabled:
+ consumed = notification_messages.listNotificationMessages(keyboardEvent)
if (not consumed):
consumed = _keyBindings.consumeKeyboardEvent( \
None, keyboardEvent)
diff --git a/src/orca/scripts/apps/notify-osd/script.py b/src/orca/scripts/apps/notify-osd/script.py
index c7fc49a..636c670 100644
--- a/src/orca/scripts/apps/notify-osd/script.py
+++ b/src/orca/scripts/apps/notify-osd/script.py
@@ -28,6 +28,7 @@ __license__ = "LGPL"
import orca.default as default
import orca.settings as settings
import orca.speech as speech
+import orca.notification_messages as notification_messages
from orca.orca_i18n import _
@@ -93,7 +94,8 @@ class Script(default.Script):
message = '%s %d' % (event.source.name, value)
utterances.append(message)
utterances.append(self.voices.get(settings.SYSTEM_VOICE))
-
+
speech.speak(utterances, None, True)
self.displayBrailleMessage(message, flashTime=settings.brailleFlashTime)
+ notification_messages.saveMessage(message)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]