|
Module UpdateNotifierScript
|
|
1 '''
2 Defines a L{AEScript <AEScript.AEScript>} for the Update Notifier.
3 Inform the user when he is on the icon in the gnome panel.
4
5 @author: Nicole Anacker
6 @organization: IT Science Center Ruegen gGmbH, Germany
7 @copyright: Copyright (c) 2007, 2008 ITSC Ruegen
8
9 @license: I{The BSD License}
10 All rights reserved. This program and the accompanying materials are made
11 available under the terms of the BSD license which is available at
12 http://www.opensource.org/licenses/bsd-license.php
13 '''
14
15 import logging
16 from AccessEngine import AEScript, AccessEngineAPI
17 from AccessEngine import AEConstants
18
19 from Tools.i18n import bind, _
20 import logging
21
22 log = logging.getLogger('UpdateNotifierScript')
23
24
25 __uie__ = dict(kind='script', tier='update-notifier', all_tiers=False)
26
28 '''
29 A special L{AEScript <AEScript.AEScript>} for the UpdateNotifier.
30 Inform the user when he is on the icon in the gnome panel.
31 '''
33 '''
34 Registers L{event tasks <AEScript.event_tasks>} to handle
35 L{focus <AEEvent.FocusChange>}, L{selector <AEEvent.SelectorChange>} and
36 L{state <AEEvent.StateChange>} events.
37 '''
38 AccessEngineAPI.setScriptIdealOutput(self, 'audio')
39
40
41 self.registerEventTask('read focus', AEConstants.EVENT_TYPE_FOCUS_CHANGE,
42 focus=True, all=True)
43 self.registerEventTask('read selector', AEConstants.EVENT_TYPE_SELECTOR_CHANGE,
44 all=True)
45 self.registerEventTask('read tooltip', AEConstants.EVENT_TYPE_STATE_CHANGE,
46 all=True)
47
48
49
50
51 self.chainTask('read focus', AEConstants.CHAIN_AROUND,
52 'read focus', 'BasicSpeechScript')
53 self.chainTask('read selector', AEConstants.CHAIN_AROUND,
54 'read selector', 'BasicSpeechScript')
55
57 '''
58 Describe which L{AETier} this script applies to by default.
59
60 @return: Human readable translated description of this script.
61 @rtype: string
62 '''
63 return _('Applies to update-notifier by default.')
64
65
66
67
69 '''
70 Handle focus events if the events received by this L{AETier} on each
71 selected layer B{focus}, B{tier} and B{background}. Set the layer on
72 focus for reading.
73
74 @param kwargs: Arbitrary keyword arguments to pass to the task
75 @type kwargs: dictionary
76 @return: C{True} to allow other tasks to process this event.
77 @rtype: boolean
78 '''
79 kwargs['layer'] = 0
80 self.doTask('read focus', 'BasicSpeechScript', chain=False, **kwargs)
81 return True
82
84 '''
85 Announces the text of the active item.
86
87 @param kwargs: Arbitrary keyword arguments to pass to the task
88 @type kwargs: dictionary
89 @return: C{True} to allow other tasks to process this event.
90 @rtype: boolean
91 '''
92 kwargs['layer'] = 0
93 kwargs['text'] = _('Update-Notifier')
94 self.doTask('read selector', 'BasicSpeechScript', chain=False, **kwargs)
95 return True
96
98 '''
99 Handles text being displayed as tooltip.
100
101 @param kwargs: Arbitrary keyword arguments to pass to the task
102 @type kwargs: dictionary
103 @return: C{True} to allow other tasks to process this event.
104 @rtype: boolean
105 '''
106 if (kwargs['name'] == 'visible' and kwargs['value'] and
107 AccessEngineAPI.hasAccRole('tool tip', kwargs['por'])):
108 AccessEngineAPI.mayStop(self, cap='audio', role='output', **kwargs)
109 tooltip = AccessEngineAPI.getAccName(kwargs['por'])
110 AccessEngineAPI.sayInfo(self, cap='audio', role='output', text=tooltip,
111 **kwargs)
112 AccessEngineAPI.inhibitMayStop()
113 return True
114