1 '''
2 Defines a special L{AEScript <AEScript.AEScript>} for the GNOME-Panel.
3
4 @author: Nicole Anacker
5 @organization: IT Science Center Ruegen gGmbH, Germany
6 @copyright: Copyright (c) 2007, 2008 ITSC Ruegen
7
8 @license: I{The BSD License}
9 All rights reserved. This program and the accompanying materials are made
10 available under the terms of the BSD license which is available at
11 U{http://www.opensource.org/licenses/bsd-license.php}.
12 '''
13
14 import logging
15 from AccessEngine import AEScript, AccessEngineAPI
16 from AccessEngine import AEConstants
17
18 from Tools.i18n import bind, _
19 import logging
20
21 log = logging.getLogger('GPanelScript')
22
23
24 __uie__ = dict(kind='script', tier='gnome-panel', all_tiers=False)
25
27 '''
28 A special L{AEScript <AEScript.AEScript>} for handling the gnome panel.
29 It defines the hotkey I{Alt+Shift+F12} that reads the current time.
30 '''
32 '''
33 Registers L{event tasks <AEScript.event_tasks>} to handle
34 L{selector <AEEvent.SelectorChange>}. Registers
35 L{tasks <AEScript.registered_tasks>} that can be mapped to
36 L{AEInput.Gesture}s.
37 '''
38 AccessEngineAPI.setScriptIdealOutput(self, 'audio')
39
40
41 self.registerEventTask('read selector',
42 AEConstants.EVENT_TYPE_SELECTOR_CHANGE, tier=True)
43 self.registerTask('read clock', self.readClock)
44
45
46 kbd = AccessEngineAPI.getInputDevice(None, 'keyboard')
47 pairs = [[kbd.AEK_ALT_L, kbd.AEK_SHIFT_L], [kbd.AEK_ALT_R, kbd.AEK_SHIFT_R]]
48
49 for pair in pairs:
50 self.registerCommand(kbd, 'read clock', 'GPanelScript',
51 True, pair+[kbd.AEK_F12])
52
53
54 self.chainTask('read selector', AEConstants.CHAIN_AROUND,
55 'read selector', 'BasicSpeechScript')
56
58 '''
59 Provides the localized name of this L{AEScript <AEScript.AEScript>}.
60
61 @return: Human readable name of this script.
62 @rtype: string
63 '''
64 return _('Gnome panel')
65
67 '''
68 Describe which L{AETier} this script applies to by default.
69
70 @return: Human readable translated description of this script.
71 @rtype: string
72 '''
73 return _('Applies to gnome-panel by default.')
74
75
76
77
78
97
98
99
100
102 '''
103 Announces the text of the active item. Or if the item the toggle button,
104 then say system clock.
105
106 @param kwargs: Arbitrary keyword arguments to pass to the task
107 @type kwargs: dictionary
108 @return: C{True} to allow other tasks to process this event.
109 @rtype: boolean
110 '''
111 if AccessEngineAPI.hasAccRole('toggle button', kwargs['por']):
112 parent = AccessEngineAPI.getParentAcc(kwargs['por'])
113 name = AccessEngineAPI.getAccName(parent)
114 desc = AccessEngineAPI.getAccDesc(parent)
115 if (name != ''):
116 kwargs['text'] = name
117 elif (desc != ''):
118 kwargs['text'] = desc
119
120 doIt = self.doTask('read selector', 'BasicSpeechScript', chain=False, **kwargs)
121
122 return True
123