# 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 Lesser General Public # License as published by the Free Software Foundation; either # version 2.1 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 # Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser 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 pyatspi from . import cmdnames from . import debug from . import input_event from . import messages from . import orca_state # 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 # number of keys invalid while in when in list notification mode. # if > 3, call _help() invalidKeys = 0 # input event handlers inputEventHandlers = {} def repeatLastNotificationMessage(script, inputEvent=None): """ Repeats the last notification message. """ _showNotificationMessage(script, 1) return True def repeatPreviousNotificationMessage(script, inputEvent=None): """ Repeats the previous notification message. """ _showNotificationMessage(script, 2) return True def enableNotificationMessageListMode(script, inputEvent=None): """ Enables the list of notification message. """ _listModeEnable(script) return True inputEventHandlers["repeatLastNotificationMessageHandler"] = \ input_event.InputEventHandler( repeatLastNotificationMessage, cmdnames.NOTIFICATION_MESSAGES_LAST) inputEventHandlers["repeatPreviousNotificationMessageHandler"] = \ input_event.InputEventHandler( repeatPreviousNotificationMessage, cmdnames.NOTIFICATION_MESSAGES_PREVIOUS) inputEventHandlers["enableNotificationMessageListModeHandler"] = \ input_event.InputEventHandler( enableNotificationMessageListMode, cmdnames.NOTIFICATION_MESSAGES_LIST) def _showMessage(script, msg): script.presentMessage(msg) 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(script): if size() <= 0: _showMessage(script, messages.NOTIFICATION_NO_MESSAGES) return False return True def _listModeEnable(script): """ enable the list mode if the queue is not empty """ global indexNotificationMessages global invalidKeys if _messagesPresent(script): indexNotificationMessages = 1 invalidKeys = 0 orca_state.listNotificationsModeEnabled = True _help(script, True) _showNotificationMessage(script, indexNotificationMessages) return True def _showNotificationMessage(script, index): global indexNotificationMessages if not _messagesPresent(script): return if index < 1: index = 1 _showMessage(script, messages.NOTIFICATION_LIST_TOP) elif index > size(): index = size() _showMessage(script, messages.NOTIFICATION_LIST_BOTTOM) 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(script, msg) def exitListNotificationMessagesMode(script): """ Turns list notification messages mode off. """ orca_state.listNotificationsModeEnabled = False _showMessage(script, messages.NOTIFICATION_LIST_EXIT) def listNotificationMessages(script, 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 script.presentationInterrupt() if event.event_string == "Escape": exitListNotificationMessagesMode(script) 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(script, True) speak = False elif event.event_string == "space": pass else: speak = False invalidKeys += 1 if invalidKeys > 2: _help(script) invalidKeys = 0 if speak: _showNotificationMessage(script, indexNotificationMessages) invalidKeys = 0 return consumed def _help(script, longHelp = False): msg = messages.messagesCount(size()) msg += messages.NOTIFICATION_LIST_HELP if longHelp: msg += messages.NOTIFICATION_LIST_TUTORIAL _showMessage(script, msg)
Name | Type | Size | Permission | Actions |
---|---|---|---|---|
__pycache__ | Folder | 0755 |
|
|
backends | Folder | 0755 |
|
|
scripts | Folder | 0755 |
|
|
__init__.py | File | 115 B | 0644 |
|
acss.py | File | 3.49 KB | 0644 |
|
bookmarks.py | File | 8.37 KB | 0644 |
|
braille.py | File | 59.87 KB | 0644 |
|
braille_generator.py | File | 20.5 KB | 0644 |
|
braille_rolenames.py | File | 10.33 KB | 0644 |
|
brlmon.py | File | 6.45 KB | 0644 |
|
brltablenames.py | File | 7.15 KB | 0644 |
|
caret_navigation.py | File | 13.67 KB | 0644 |
|
chat.py | File | 33.63 KB | 0644 |
|
chnames.py | File | 23.03 KB | 0644 |
|
cmdnames.py | File | 55.65 KB | 0644 |
|
colornames.py | File | 38.13 KB | 0644 |
|
common_keyboardmap.py | File | 6.64 KB | 0644 |
|
debug.py | File | 17.16 KB | 0644 |
|
desktop_keyboardmap.py | File | 4.62 KB | 0644 |
|
event_manager.py | File | 31.81 KB | 0644 |
|
eventsynthesizer.py | File | 17.82 KB | 0644 |
|
find.py | File | 12.77 KB | 0644 |
|
flat_review.py | File | 51.84 KB | 0644 |
|
formatting.py | File | 53.94 KB | 0644 |
|
generator.py | File | 59.09 KB | 0644 |
|
guilabels.py | File | 45.78 KB | 0644 |
|
input_event.py | File | 36.41 KB | 0644 |
|
keybindings.py | File | 16.39 KB | 0644 |
|
keynames.py | File | 9.71 KB | 0644 |
|
label_inference.py | File | 19.38 KB | 0644 |
|
laptop_keyboardmap.py | File | 4.61 KB | 0644 |
|
liveregions.py | File | 21.55 KB | 0644 |
|
logger.py | File | 1.97 KB | 0644 |
|
mathsymbols.py | File | 88.14 KB | 0644 |
|
messages.py | File | 140.32 KB | 0644 |
|
mouse_review.py | File | 18.91 KB | 0644 |
|
notification_messages.py | File | 6.18 KB | 0644 |
|
object_properties.py | File | 32.74 KB | 0644 |
|
orca.py | File | 25 KB | 0644 |
|
orca_gtkbuilder.py | File | 5.35 KB | 0644 |
|
orca_gui_commandlist.py | File | 4.19 KB | 0644 |
|
orca_gui_find.py | File | 8.12 KB | 0644 |
|
orca_gui_navlist.py | File | 6.66 KB | 0644 |
|
orca_gui_prefs.py | File | 139.07 KB | 0644 |
|
orca_gui_profile.py | File | 4.06 KB | 0644 |
|
orca_i18n.py | File | 3.18 KB | 0644 |
|
orca_platform.py | File | 1.41 KB | 0644 |
|
orca_state.py | File | 2.1 KB | 0644 |
|
phonnames.py | File | 2.76 KB | 0644 |
|
pronunciation_dict.py | File | 2.61 KB | 0644 |
|
punctuation_settings.py | File | 13.64 KB | 0644 |
|
script.py | File | 19.04 KB | 0644 |
|
script_manager.py | File | 13.31 KB | 0644 |
|
script_utilities.py | File | 183.59 KB | 0644 |
|
settings.py | File | 12.82 KB | 0644 |
|
settings_manager.py | File | 20.73 KB | 0644 |
|
sound.py | File | 5.17 KB | 0644 |
|
sound_generator.py | File | 11.99 KB | 0644 |
|
speech.py | File | 11.4 KB | 0644 |
|
speech_generator.py | File | 108.24 KB | 0644 |
|
speechdispatcherfactory.py | File | 24.54 KB | 0644 |
|
speechserver.py | File | 7.41 KB | 0644 |
|
spellcheck.py | File | 10.07 KB | 0644 |
|
structural_navigation.py | File | 122.53 KB | 0644 |
|
text_attribute_names.py | File | 28.62 KB | 0644 |
|
tutorialgenerator.py | File | 30.41 KB | 0644 |
|