Package AccessEngine :: Package AEAccAdapters :: Package ATSPI :: Module ImageAdapter
[hide private]
[frames] | no frames]

Source Code for Module AccessEngine.AEAccAdapters.ATSPI.ImageAdapter

 1  ''' 
 2  Defines an L{AEAccAdapter.AEAccAdapter}s for the  
 3  L{AEAccInterfaces.IAccessibleInfo} interface to report text information about  
 4  images. 
 5   
 6  @author: Peter Parente 
 7  @organization: IBM Corporation 
 8  @copyright: Copyright (c) 2005, 2007 IBM Corporation 
 9  @license: The BSD License 
10   
11  @author: Frank Zenker 
12  @organization: IT Science Center Ruegen gGmbH, Germany 
13  @copyright: Copyright (c) 2007, 2008 ITSC Ruegen 
14  @license: The BSD License 
15   
16  All rights reserved. This program and the accompanying materials are made 
17  available under the terms of the BSD license which accompanies 
18  this distribution, and is available at 
19  U{http://www.opensource.org/licenses/bsd-license.php} 
20  ''' 
21   
22  from DefaultInfo import * 
23  from AccessEngine.AEAccInterfaces import * 
24  import pyatspi 
25   
26 -class ImageAccInfoAdapter(DefaultAccInfoAdapter):
27 ''' 28 Overrides L{DefaultNavAdapter} to provide text information about images. 29 Expects the subject to be a L{AEPor}. 30 31 Adapts accessibles that provide the Image interface and 32 have a role of image or icon. 33 ''' 34 provides = [IAccessibleInfo] 35 36 @staticmethod
37 - def when(subject):
38 ''' 39 Tests if the given subject can be adapted by this class. 40 41 @param subject: L{AEPor} containing an accessible to test 42 @type subject: L{AEPor} 43 @return: True when the subject meets the condition named in the docstring 44 for this class, False otherwise 45 @rtype: boolean 46 ''' 47 acc = subject.accessible 48 r = acc.getRole() 49 return ((r == pyatspi.ROLE_ICON or r == pyatspi.ROLE_IMAGE) and 50 acc.queryImage() is not None)
51 52
53 - def getAccItemText(self):
54 ''' 55 Gets the accessible description of the image. Ignores the given item offset 56 because images shouldn't have children. 57 58 @return: Accessible name of requested object 59 @rtype: string 60 @raise LookupError: When the accessible object is dead 61 ''' 62 acc = self.accessible 63 s = acc.name or acc.queryImage().imageDescription 64 return unicode(s, 'utf-8')
65