Module GdmScript
[hide private]
[frames] | no frames]

Source Code for Module GdmScript

  1  ''' 
  2  Defines a special L{AEScript <AEScript.AEScript>} for the gdm login screen. 
  3   
  4  @author: Peter Parente 
  5  @organization: IBM Corporation 
  6  @copyright: Copyright (c) 2005, 2007 IBM Corporation 
  7   
  8  @author: Nicole Anacker 
  9  @organization: IT Science Center Ruegen gGmbH, Germany 
 10  @copyright: Copyright (c) 2007, 2008 ITSC Ruegen 
 11   
 12  @license: I{The BSD License}. 
 13  All rights reserved. This program and the accompanying materials are made  
 14  available under the terms of the BSD license which accompanies 
 15  this distribution, and is available at 
 16  U{http://www.opensource.org/licenses/bsd-license.php} 
 17  ''' 
 18  # import useful modules for Scripts 
 19  from AccessEngine import AEScript, AccessEngineAPI 
 20  from AccessEngine import AEConstants 
 21  #from AccessEngine.AEPor import AEPor 
 22  from Tools.i18n import _ 
 23   
 24  # metadata describing this Script 
 25  # apply it to all AETiers since the login greeter name can change and run it in 
 26  # a special login profile 
 27  __uie__ = dict(kind='script', tier=None, all_tiers=True) 
 28   
29 -class GdmScript(AEScript.EventScript):
30 ''' 31 A special L{AEScript <AEScript.AEScript>} for the gdm login screen. 32 Registers tasks to announce the focused control on startup, typically the 33 username field. 34 35 @ivar first: If C{True} then the text box requires the input of the username. 36 If C{False} then the text box requires the input of the password. 37 @type first: boolean 38 39 @todo: NA: test functions 40 '''
41 - def init(self):
42 ''' 43 Registers L{event tasks <AEScript.event_tasks>} to handle 44 L{view <AEEvent.ViewChange>} and L{caret change <AEEvent.CaretChange>} 45 events. 46 ''' 47 # set an audio device as the default output 48 AccessEngineAPI.setScriptIdealOutput('audio') 49 50 self.first = True 51 52 # register events 53 self.registerEventTask('gdm startup', AEConstants.EVENT_TYPE_VIEW_CHANGE) 54 self.registerEventTask('gdm label change', 55 AEConstants.EVENT_TYPE_CARET_CHANGE)
56
57 - def getName(self):
58 ''' 59 Return the name of the supported application. 60 61 @return: Translated name of the supported application. 62 @rtype: string 63 ''' 64 return _('GNOME login')
65
66 - def getDescription(self):
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 _('Corrects username/password accessibility problems at login. ' 74 'Applies to gdm by default. Works best with the plain greeter.')
75
76 - def onViewFirstGained(self, **kwargs):
77 ''' 78 Announces the control that has the focus on startup. 79 80 @param kwargs: Arbitrary keyword arguments to pass to the task 81 @type kwargs: dictionary 82 @return: C{True} to allow other tasks to process this event. 83 @rtype: boolean 84 ''' 85 AccessEngineAPI.sayWindow(self, cap='audtio', role='output', 86 text=_('GDM Login'), **kwargs) 87 # find the widget that has the focus; search for it since we weren't 88 # started in time for the focus event 89 por = AccessEngineAPI.findAccByPredicate( 90 lambda por: AccessEngineAPI.hasAccState('focused', kwargs['por'])) 91 # set the focus to that location 92 AccessEngineAPI.setAccPOR(por) 93 kwargs['por'] = por 94 self.doTask('pointer to por', 'ReviewScript', **kwargs) 95 return False
96
97 - def onCaretChange(self, **kwargs):
98 ''' 99 Announces the changing label of the text box as it serves dual duty as the 100 username and password field. 101 102 @param kwargs: Arbitrary keyword arguments to pass to the task 103 @type kwargs: dictionary 104 @return: C{True} to allow other tasks to process this event. 105 @rtype: boolean 106 ''' 107 if not text and text_offset == 0 and added is not None: 108 if added: 109 if not self.first: 110 self.doTask('pointer to por', 'ReviewScript', **kwargs) 111 self.first = False 112 return False
113