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

Source Code for Module Adapters.ATSPI.ImageAdapter

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