1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
|
/* gtkatspiutils.c: Shared utilities for ATSPI
*
* Copyright 2020 GNOME Foundation
*
* SPDX-License-Identifier: LGPL-2.1-or-later
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, see <http://www.gnu.org/licenses/>.
*/
#include "config.h"
#include "gtkatspiutilsprivate.h"
#include "gtkenums.h"
#include "gtkpasswordentry.h"
#include "gtkscrolledwindow.h"
/*< private >
* gtk_accessible_role_to_atspi_role:
* @role: a #GtkAccessibleRole
*
* Converts a #GtkAccessibleRole value to the equivalent ATSPI role.
*
* Returns: an #AtspiRole
*/
static AtspiRole
gtk_accessible_role_to_atspi_role (GtkAccessibleRole role)
{
switch (role)
{
case GTK_ACCESSIBLE_ROLE_ALERT:
return ATSPI_ROLE_ALERT;
case GTK_ACCESSIBLE_ROLE_ALERT_DIALOG:
return ATSPI_ROLE_DIALOG;
case GTK_ACCESSIBLE_ROLE_BANNER:
break;
case GTK_ACCESSIBLE_ROLE_BUTTON:
return ATSPI_ROLE_PUSH_BUTTON;
case GTK_ACCESSIBLE_ROLE_CAPTION:
return ATSPI_ROLE_CAPTION;
case GTK_ACCESSIBLE_ROLE_CELL:
return ATSPI_ROLE_TABLE_CELL;
case GTK_ACCESSIBLE_ROLE_CHECKBOX:
return ATSPI_ROLE_CHECK_BOX;
case GTK_ACCESSIBLE_ROLE_COLUMN_HEADER:
break;
case GTK_ACCESSIBLE_ROLE_COMBO_BOX:
return ATSPI_ROLE_COMBO_BOX;
case GTK_ACCESSIBLE_ROLE_COMMAND:
break;
case GTK_ACCESSIBLE_ROLE_COMPOSITE:
break;
case GTK_ACCESSIBLE_ROLE_DIALOG:
return ATSPI_ROLE_DIALOG;
case GTK_ACCESSIBLE_ROLE_DOCUMENT:
return ATSPI_ROLE_DOCUMENT_TEXT;
case GTK_ACCESSIBLE_ROLE_FEED:
break;
case GTK_ACCESSIBLE_ROLE_FORM:
return ATSPI_ROLE_FORM;
case GTK_ACCESSIBLE_ROLE_GENERIC:
break;
case GTK_ACCESSIBLE_ROLE_GRID:
return ATSPI_ROLE_TABLE;
case GTK_ACCESSIBLE_ROLE_GRID_CELL:
return ATSPI_ROLE_TABLE_CELL;
case GTK_ACCESSIBLE_ROLE_GROUP:
return ATSPI_ROLE_PANEL;
case GTK_ACCESSIBLE_ROLE_HEADING:
return ATSPI_ROLE_HEADING;
case GTK_ACCESSIBLE_ROLE_IMG:
return ATSPI_ROLE_IMAGE;
case GTK_ACCESSIBLE_ROLE_INPUT:
return ATSPI_ROLE_ENTRY;
case GTK_ACCESSIBLE_ROLE_LABEL:
return ATSPI_ROLE_LABEL;
case GTK_ACCESSIBLE_ROLE_LANDMARK:
break;
case GTK_ACCESSIBLE_ROLE_LEGEND:
return ATSPI_ROLE_LABEL;
case GTK_ACCESSIBLE_ROLE_LINK:
return ATSPI_ROLE_LINK;
case GTK_ACCESSIBLE_ROLE_LIST:
return ATSPI_ROLE_LIST;
case GTK_ACCESSIBLE_ROLE_LIST_BOX:
return ATSPI_ROLE_LIST_BOX;
case GTK_ACCESSIBLE_ROLE_LIST_ITEM:
return ATSPI_ROLE_LIST_ITEM;
case GTK_ACCESSIBLE_ROLE_LOG:
return ATSPI_ROLE_LOG;
case GTK_ACCESSIBLE_ROLE_MAIN:
break;
case GTK_ACCESSIBLE_ROLE_MARQUEE:
return ATSPI_ROLE_MARQUEE;
case GTK_ACCESSIBLE_ROLE_MATH:
return ATSPI_ROLE_MATH;
case GTK_ACCESSIBLE_ROLE_METER:
return ATSPI_ROLE_LEVEL_BAR;
case GTK_ACCESSIBLE_ROLE_MENU:
return ATSPI_ROLE_MENU;
case GTK_ACCESSIBLE_ROLE_MENU_BAR:
return ATSPI_ROLE_MENU_BAR;
case GTK_ACCESSIBLE_ROLE_MENU_ITEM:
return ATSPI_ROLE_MENU_ITEM;
case GTK_ACCESSIBLE_ROLE_MENU_ITEM_CHECKBOX:
return ATSPI_ROLE_CHECK_MENU_ITEM;
case GTK_ACCESSIBLE_ROLE_MENU_ITEM_RADIO:
return ATSPI_ROLE_RADIO_MENU_ITEM;
case GTK_ACCESSIBLE_ROLE_NAVIGATION:
return ATSPI_ROLE_FILLER;
case GTK_ACCESSIBLE_ROLE_NONE:
return ATSPI_ROLE_INVALID;
case GTK_ACCESSIBLE_ROLE_NOTE:
return ATSPI_ROLE_FOOTNOTE;
case GTK_ACCESSIBLE_ROLE_OPTION:
return ATSPI_ROLE_OPTION_PANE;
case GTK_ACCESSIBLE_ROLE_PRESENTATION:
return ATSPI_ROLE_SECTION;
case GTK_ACCESSIBLE_ROLE_PROGRESS_BAR:
return ATSPI_ROLE_PROGRESS_BAR;
case GTK_ACCESSIBLE_ROLE_RADIO:
return ATSPI_ROLE_RADIO_BUTTON;
case GTK_ACCESSIBLE_ROLE_RADIO_GROUP:
return ATSPI_ROLE_GROUPING;
case GTK_ACCESSIBLE_ROLE_RANGE:
break;
case GTK_ACCESSIBLE_ROLE_REGION:
return ATSPI_ROLE_FILLER;
case GTK_ACCESSIBLE_ROLE_ROW:
return ATSPI_ROLE_TABLE_ROW;
case GTK_ACCESSIBLE_ROLE_ROW_GROUP:
return ATSPI_ROLE_GROUPING;
case GTK_ACCESSIBLE_ROLE_ROW_HEADER:
return ATSPI_ROLE_ROW_HEADER;
case GTK_ACCESSIBLE_ROLE_SCROLLBAR:
return ATSPI_ROLE_SCROLL_BAR;
case GTK_ACCESSIBLE_ROLE_SEARCH:
return ATSPI_ROLE_FORM;
case GTK_ACCESSIBLE_ROLE_SEARCH_BOX:
return ATSPI_ROLE_ENTRY;
case GTK_ACCESSIBLE_ROLE_SECTION:
return ATSPI_ROLE_FILLER;
case GTK_ACCESSIBLE_ROLE_SECTION_HEAD:
return ATSPI_ROLE_FILLER;
case GTK_ACCESSIBLE_ROLE_SELECT:
return ATSPI_ROLE_FILLER;
case GTK_ACCESSIBLE_ROLE_SEPARATOR:
return ATSPI_ROLE_SEPARATOR;
case GTK_ACCESSIBLE_ROLE_SLIDER:
return ATSPI_ROLE_SLIDER;
case GTK_ACCESSIBLE_ROLE_SPIN_BUTTON:
return ATSPI_ROLE_SPIN_BUTTON;
case GTK_ACCESSIBLE_ROLE_STATUS:
return ATSPI_ROLE_STATUS_BAR;
case GTK_ACCESSIBLE_ROLE_STRUCTURE:
return ATSPI_ROLE_FILLER;
case GTK_ACCESSIBLE_ROLE_SWITCH:
return ATSPI_ROLE_CHECK_BOX;
case GTK_ACCESSIBLE_ROLE_TAB:
return ATSPI_ROLE_PAGE_TAB;
case GTK_ACCESSIBLE_ROLE_TABLE:
return ATSPI_ROLE_TABLE;
case GTK_ACCESSIBLE_ROLE_TAB_LIST:
return ATSPI_ROLE_PAGE_TAB_LIST;
case GTK_ACCESSIBLE_ROLE_TAB_PANEL:
return ATSPI_ROLE_PANEL;
case GTK_ACCESSIBLE_ROLE_TEXT_BOX:
return ATSPI_ROLE_TEXT;
case GTK_ACCESSIBLE_ROLE_TIME:
return ATSPI_ROLE_TEXT;
case GTK_ACCESSIBLE_ROLE_TIMER:
return ATSPI_ROLE_TIMER;
case GTK_ACCESSIBLE_ROLE_TOOLBAR:
return ATSPI_ROLE_TOOL_BAR;
case GTK_ACCESSIBLE_ROLE_TOOLTIP:
return ATSPI_ROLE_TOOL_TIP;
case GTK_ACCESSIBLE_ROLE_TREE:
return ATSPI_ROLE_TREE;
case GTK_ACCESSIBLE_ROLE_TREE_GRID:
return ATSPI_ROLE_TREE_TABLE;
case GTK_ACCESSIBLE_ROLE_TREE_ITEM:
return ATSPI_ROLE_TREE_ITEM;
case GTK_ACCESSIBLE_ROLE_WIDGET:
return ATSPI_ROLE_FILLER;
case GTK_ACCESSIBLE_ROLE_WINDOW:
return ATSPI_ROLE_FRAME;
default:
break;
}
return ATSPI_ROLE_FILLER;
}
/*<private>
* gtk_atspi_role_for_context:
* @context: a #GtkATContext
*
* Returns a suitable ATSPI role for a context, taking into account
* both the #GtkAccessibleRole set on the context and the type
* of accessible.
*
* Returns: an #AtspiRole
*/
AtspiRole
gtk_atspi_role_for_context (GtkATContext *context)
{
GtkAccessible *accessible = gtk_at_context_get_accessible (context);
GtkAccessibleRole role = gtk_at_context_get_accessible_role (context);
/* ARIA does not have a "password entry" role, so we need to fudge it here */
if (GTK_IS_PASSWORD_ENTRY (accessible))
return ATSPI_ROLE_PASSWORD_TEXT;
/* ARIA does not have a "scroll area" role */
if (GTK_IS_SCROLLED_WINDOW (accessible))
return ATSPI_ROLE_SCROLL_PANE;
return gtk_accessible_role_to_atspi_role (role);
}
GVariant *
gtk_at_spi_null_ref (void)
{
return g_variant_new ("(so)", "", "/org/a11y/atspi/null");
}
void
gtk_at_spi_emit_children_changed (GDBusConnection *connection,
const char *path,
GtkAccessibleChildState state,
int idx,
GVariant *child_ref,
GVariant *sender_ref)
{
const char *change;
switch (state)
{
case GTK_ACCESSIBLE_CHILD_STATE_ADDED:
change = "add";
break;
case GTK_ACCESSIBLE_CHILD_STATE_REMOVED:
change = "remove";
break;
default:
g_assert_not_reached ();
return;
}
g_dbus_connection_emit_signal (connection,
NULL,
path,
"org.a11y.atspi.Event.Object",
"ChildrenChanged",
g_variant_new ("(siiv@(so))", change, idx, 0, child_ref, sender_ref),
NULL);
}
|