1 #Copyright (C) 2008 Codethink Ltd
3 #This library is free software; you can redistribute it and/or
4 #modify it under the terms of the GNU Lesser General Public
5 #License version 2 as published by the Free Software Foundation.
7 #This program is distributed in the hope that it will be useful,
8 #but WITHOUT ANY WARRANTY; without even the implied warranty of
9 #MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 #GNU General Public License for more details.
11 #You should have received a copy of the GNU Lesser General Public License
12 #along with this program; if not, write to the Free Software
13 #Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
16 from factory import create_accessible
22 #------------------------------------------------------------------------------
24 class Accessible(BaseProxy):
26 The base interface which is implemented by all accessible objects.
27 All objects support interfaces for querying their contained
28 'children' and position in the accessible-object hierarchy,
29 whether or not they actually have children.
32 def getApplication(self):
34 Get the containing Application for this object.
35 @return the Application instance to which this object belongs.
39 def getAttributes(self):
41 Get a list of properties applied to this object as a whole, as
42 an AttributeSet consisting of name-value pairs. As such these
43 attributes may be considered weakly-typed properties or annotations,
44 as distinct from the strongly-typed interface instance data declared
45 using the IDL "attribute" keyword.
46 Not all objects have explicit "name-value pair" AttributeSet
48 Attribute names and values may have any UTF-8 string value, however
49 where possible, in order to facilitate consistent use and exposure
50 of "attribute" properties by applications and AT clients, attribute
51 names and values should chosen from a publicly-specified namespace
53 Where possible, the names and values in the name-value pairs
54 should be chosen from well-established attribute namespaces using
55 standard semantics. For example, attributes of Accessible objects
56 corresponding to XHTML content elements should correspond to
57 attribute names and values specified in the w3c XHTML specification,
58 at http://www.w3.org/TR/xhtml2, where such values are not already
59 exposed via a more strongly-typed aspect of the AT-SPI API. Metadata
60 names and values should be chosen from the 'Dublin Core' Metadata
61 namespace using Dublin Core semantics: http://dublincore.org/dcregistry/
62 Similarly, relevant structural metadata should be exposed using
63 attribute names and values chosen from the CSS2 and WICD specification:
64 http://www.w3.org/TR/1998/REC-CSS2-19980512 WICD (http://www.w3.org/TR/2005/WD-WICD-20051121/).
66 @return : An AttributeSet encapsulating any "attribute values"
67 currently defined for the object. An attribute set is a list of strings
68 with each string comprising an name-value pair format 'name:value'.
72 def getChildAtIndex(self, index):
74 Get the accessible child of this object at index.
76 an in parameter indicating which child is requested (zero-indexed).
77 @return : the 'nth' Accessible child of this object.
79 path = self.cached_data.children[index]
80 return create_accessible(self._cache,
83 interfaces.ATSPI_ACCESSIBLE,
84 connection=self._cache._connection)
86 def getIndexInParent(self):
88 Get the index of this object in its parent's child list.
89 @return : a long integer indicating this object's index in the
94 def getLocalizedRoleName(self):
96 Get a string indicating the type of UI role played by this object,
97 translated to the current locale.
98 @return : a UTF-8 string indicating the type of UI role played
101 #TODO Need to localize this somehow. Hmmmmm
104 def getRelationSet(self):
106 Get a set defining this object's relationship to other accessible
108 @return : a RelationSet defining this object's relationships.
114 Get the Role indicating the type of UI role played by this object.
115 @return : a Role indicating the type of UI role played by this
118 return self.cached_data.role
120 def getRoleName(self):
122 Get a string indicating the type of UI role played by this object.
123 @return : a UTF-8 string indicating the type of UI role played
130 Get the current state of the object as a StateSet.
131 @return : a StateSet encapsulating the currently true states
136 def isEqual(self, accessible):
138 Determine whether an Accessible refers to the same object as
139 another. This method should be used rather than brute-force comparison
140 of object references (i.e. "by-value" comparison), as two object
141 references may have different apparent values yet refer to the
144 an Accessible object reference to compare to
145 @return : a boolean indicating whether the two object references
146 point to the same object.
148 return (self._app_name == accessible._app_name) and \
149 (self._acc_path == accessible._acc_path)
151 def get_childCount(self):
152 return len(self.cached_data.children)
155 childCount: the number of children contained by this object.
157 childCount = property(fget=get_childCount, doc=_childCountDoc)
159 def get_description(self):
163 a string describing the object in more detail than name.
165 description = property(fget=get_description, doc=_descriptionDoc)
171 a (short) string representing the object's name.
173 name = property(fget=get_name, doc=_nameDoc)
175 def get_parent(self):
179 An Accessible object which is this object's containing object.
181 parent = property(fget=get_parent, doc=_parentDoc)
183 #END----------------------------------------------------------------------------