2 Defines constants used throughout this wrapper.
6 @organization: IBM Corporation
7 @copyright: Copyright (c) 2005, 2007 IBM Corporation
10 This library is free software; you can redistribute it and/or
11 modify it under the terms of the GNU Library General Public
12 License as published by the Free Software Foundation; either
13 version 2 of the License, or (at your option) any later version.
15 This library is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 Library General Public License for more details.
20 You should have received a copy of the GNU Library General Public
21 License along with this library; if not, write to the
22 Free Software Foundation, Inc., 59 Temple Place - Suite 330,
23 Boston, MA 02111-1307, USA.
25 Portions of this code originally licensed and copyright (c) 2005, 2007
26 IBM Corporation under the BSD license, available at
27 U{http://www.opensource.org/licenses/bsd-license.php}
33 # pull dictionary of Accessibility module namespace into local var, temporarily
34 acc_dict = vars(Accessibility)
36 # run through all objects in the Accessibility module
38 # list of classes that are not queriable interfaces
39 not_interfaces = ['RoleSet', 'StateSet', 'DeviceEventListener', 'LoginHelper',
40 'ContentStream', 'DeviceEventController', 'Registry'
41 'DeviceEventListener', 'EventListener', 'Relation',
42 'CommandListener', 'Selector']
43 for obj in acc_dict.values():
45 # see if the object has a typecode
46 kind = obj.__typecode__.kind
47 except AttributeError:
49 # compare the typecode to the one for CORBA objects, and to our list of
50 # classes that are not queriable interfaces
51 if (kind == ORBit.CORBA.tk_objref and
52 utils.getInterfaceName(obj) not in not_interfaces):
53 # this is an interface class
54 ALL_INTERFACES.append(obj)
55 # get rid of our temporary list
58 # constants used in the Component interface to get screen coordinates
62 # constants used to synthesize mouse events
78 # defines levels of caching where if x > y, x caches all of y plus more
82 # events that clear cached properties
83 CACHE_EVENTS = ['object:property-change:accessible-name',
84 'object:property-change:accessible-description',
85 'object:property-change:accessible-role',
86 'object:property-change:accessible-parent']
88 # dictionary used to correct the bug of not being able to register for all the
89 # subevents given only an AT-SPI event class (i.e. first part of the event
90 # name) keys are event names having subevents and values are the subevents
91 # under the key event; handlers *can* be registered for events not in this tree
94 ['terminal:line-changed',
95 'terminal:columncount-changed',
96 'terminal:linecount-changed',
97 'terminal:application-changed',
98 'terminal:charwidth-changed'
101 ['document:load-complete',
103 'document:load-stopped',
104 'document:content-changed',
105 'document:attributes-changed'
108 ['object:property-change',
109 'object:bounds-changed',
110 'object:link-selected',
111 'object:state-changed',
112 'object:children-changed',
113 'object:visible-data-changed',
114 'object:selection-changed',
115 'object:model-changed',
116 'object:active-descendant-changed',
117 'object:row-inserted',
118 'object:row-reordered',
119 'object:row-deleted',
120 'object:column-inserted',
121 'object:column-reordered',
122 'object:column-deleted',
123 'object:text-bounds-changed',
124 'object:text-selection-changed',
125 'object:text-changed',
126 'object:text-attributes-changed',
127 'object:text-caret-moved',
128 'object:attributes-changed'],
129 'object:text-changed' :
130 ['object:text-changed:insert',
131 'object:text-changed:delete'],
132 'object:property-change' :
133 ['object:property-change:accessible-parent',
134 'object:property-change:accessible-name',
135 'object:property-change:accessible-description',
136 'object:property-change:accessible-value',
137 'object:property-change:accessible-role',
138 'object:property-change:accessible-table-caption',
139 'object:property-change:accessible-table-column-description',
140 'object:property-change:accessible-table-column-header',
141 'object:property-change:accessible-table-row-description',
142 'object:property-change:accessible-table-row-header',
143 'object:property-change:accessible-table-summary'],
144 'object:children-changed' :
145 ['object:children-changed:add',
146 'object:children-changed:remove'],
147 'object:state-changed' :
148 ['object:state-changed:'],
167 'window:desktop-create',
168 'window:desktop-destroy',
182 # pull ROLE_*, STATE_*, TEXT_*, MODIFIER_*, LOCALE_*, and RELATION_*, etc.
183 # constants into the local namespace for convenient access
184 # grab all the variable names and their values from the Accessibility module
186 # get the dictionary for the local namespace
188 # these are the prefixes for the variable names we want to pull out of the
189 # Accessibility module
190 prefixes = ['ROLE_', 'STATE_', 'TEXT_', 'MODIFIER_', 'LOCALE_', 'RELATION_',
191 'KEY_', 'MATCH_', 'SORT_', 'LAYER_']
192 # for each variable name in the Accessibility namespace, check if it starts
193 # with at least one of the prefixes above; if it does, add a 2-tuple of
194 # variable name and value to the values list
195 values = ((name, value) for name, value in acc_dict.items()
196 if len([p for p in prefixes if name.startswith(p)]))
197 # create a new dictionary from the list of tuples and then update the local
198 # namespace dictionary with that dictionary
199 loc_dict.update(dict(values))
201 # build a dictionary mapping state values to names based on the prefix of the
202 # constant name imported from Accessibility
203 STATE_VALUE_TO_NAME = dict(((value, name[6:].lower().replace('_', ' '))
206 if name.startswith('STATE_')))
208 # build a dictionary mapping relation values to names based on the prefix of
209 # the constant name imported from Accessibility
210 RELATION_VALUE_TO_NAME = dict(((value, name[9:].lower().replace('_', ' '))
213 if name.startswith('RELATION_')))
215 # throw away any temporary variables so they don't hang around in this module
216 del acc_dict, loc_dict, prefixes, values