Fixed 'make dist', and added:
[platform/core/uifw/at-spi2-atk.git] / cspi / spi_accessible.c
1 #define MAX_ROLES 100
2
3 static char *role_names [MAX_ROLES] =
4 {
5   " ",
6   "accelerator label",
7   "alert",
8   "animation",
9   "arrow",
10   "calendar",
11   "canvas",
12   "check box",
13   "menu item",
14   "color chooser",
15   "column header",
16   "combo box",
17   "date editor",
18   "desktop icon",
19   "desktop frame",
20   "dial",
21   "dialog",
22   "directory pane",
23   "drawing area",
24   "file chooser",
25   "filler",
26   "font chooser",
27   "frame",
28   "glass pane",
29   "HTML container",
30   "icon",
31   "image",
32   "internal frame",
33   "label",
34   "layered pane",
35   "list",
36   "list item",
37   "menu",
38   "menubar",
39   "menu item",
40   "option pane",
41   "page tab",
42   "page tab list",
43   "panel",
44   "password text",
45   "popup menu",
46   "progress bar",
47   "pushbutton",
48   "radiobutton",
49   "radio menu item",
50   "root pane",
51   "row header",
52   "scrollbar",
53   "scrollpane",
54   "separator",
55   "slider",
56   "split pane",
57   "spin button",
58   "status bar",
59   "table",
60   "table cell",
61   "table column header",
62   "table row header",
63   "tearoff menu item",
64   "text",
65   "toggle button",
66   "toolbar",
67   "tooltip",
68   "tree",
69   " ",
70   "viewport",
71   "window",
72 };
73
74 /*
75  * Returns a localizable string name for an AtkRole enumerated type.
76  */
77 char*
78 Accessible_Role_getName (Accessibility_Role role)
79 {
80   if (role < MAX_ROLES) return role_names [(int) role];
81   else return "";
82 }
83
84
85
86 /**
87  * Accessible_ref:
88  * @obj: a pointer to the #Accessible object on which to operate.
89  *
90  * Increment the reference count for an #Accessible object.
91  *
92  * Returns: (no return code implemented yet).
93  *
94  **/
95 int
96 Accessible_ref (Accessible *obj)
97 {
98   Accessibility_Accessible_ref (*obj, &ev);
99   return 0;
100 }
101
102
103 /**
104  * Accessible_unref:
105  * @obj: a pointer to the #Accessible object on which to operate.
106  *
107  * Decrement the reference count for an #Accessible object.
108  *
109  * Returns: (no return code implemented yet).
110  *
111  **/
112 int
113 Accessible_unref (Accessible *obj)
114 {
115   Accessibility_Accessible_unref (*obj, &ev);
116   return 0;
117 }
118
119 /**
120  * Accessible_getName:
121  * @obj: a pointer to the #Accessible object on which to operate.
122  *
123  * Get the name of an #Accessible object.
124  *
125  * Returns: a UTF-8 string indicating the name of the #Accessible object.
126  *
127  **/
128 char *
129 Accessible_getName (Accessible *obj)
130 {
131   return (char *)
132     Accessibility_Accessible__get_name (*obj, &ev);
133 }
134
135 /**
136  * Accessible_getDescription:
137  * @obj: a pointer to the #Accessible object on which to operate.
138  *
139  * Get the description of an #Accessible object.
140  *
141  * Returns: a UTF-8 string describing the #Accessible object.
142  *
143  **/
144 char *
145 Accessible_getDescription (Accessible *obj)
146 {
147   return (char *)
148     Accessibility_Accessible__get_description (*obj, &ev);
149 }
150
151 /**
152  * Accessible_getParent:
153  * @obj: a pointer to the #Accessible object to query.
154  *
155  * Get an #Accessible object's parent container.
156  *
157  * Returns: a pointer to the #Accessible object which contains the given
158  *          #Accessible instance, or NULL if the @obj has no parent container.
159  *
160  **/
161 Accessible *
162 Accessible_getParent (Accessible *obj)
163 {
164   return Obj_Add (Accessibility_Accessible__get_parent (*obj, &ev));
165 }
166
167 /**
168  * Accessible_getChildCount:
169  *
170  * @obj: a pointer to the #Accessible object on which to operate.
171  *
172  * Get the number of children contained by an #Accessible object.
173  *
174  * Returns: a #long indicating the number of #Accessible children
175  *          contained by an #Accessible object.
176  *
177  **/
178 long
179 Accessible_getChildCount (Accessible *obj)
180 {
181   return Accessibility_Accessible__get_childCount (*obj, &ev);
182 }
183
184 /**
185  * Accessible_getChildAtIndex:
186  *
187  * @obj: a pointer to the #Accessible object on which to operate.
188  * @childIndex: a #long indicating which child is specified.
189  *
190  * Get the #Accessible child of an #Accessible object at a given index.
191  *
192  * Returns: a pointer to the #Accessible child object at index
193  *          @childIndex.
194  *
195  **/
196 Accessible *
197 Accessible_getChildAtIndex (Accessible *obj,
198                             long childIndex)
199 {
200   return Obj_Add (Accessibility_Accessible_getChildAtIndex (*obj, childIndex, &ev));
201 }
202
203 /**
204  * Accessible_getIndexInParent:
205  *
206  * @obj: a pointer to the #Accessible object on which to operate.
207  *
208  * Get the index of an #Accessible object in its containing #Accessible.
209  *
210  * Returns: a #long indicating the index of the #Accessible object
211  *          in its parent (i.e. containing) #Accessible instance,
212  *          or -1 if @obj has no containing parent.
213  *
214  **/
215 long
216 Accessible_getIndexInParent (Accessible *obj)
217 {
218   return Accessibility_Accessible_getIndexInParent (*obj, &ev);
219 }
220
221 /**
222  * Accessible_getRelationSet:
223  *
224  * Not Yet Implemented.
225  *
226  * Returns: a pointer to an array of #AccessibleRelations.
227  *
228  **/
229 AccessibleRelation **
230 Accessible_getRelationSet (Accessible *obj)
231 {
232   return NULL;
233 }
234
235 /**
236  * Accessible_getRole:
237  * @obj: a pointer to the #Accessible object on which to operate.
238  *
239  * Get the UI role of an #Accessible object.
240  *
241  * Returns: a UTF-8 string indicating the UI role of the #Accessible object.
242  *
243  **/
244 char *
245 Accessible_getRole (Accessible *obj)
246 {
247   return Accessible_Role_getName (
248                   Accessibility_Accessible_getRole (*obj, &ev));
249 }
250
251 /**
252  * Accessible_getStateSet:
253  *
254  * Not Yet Implemented.
255  *
256  * Returns: a pointer to an #AccessibleStateSet representing the object's current state.
257  **/
258 AccessibleStateSet *
259 Accessible_getStateSet (Accessible *obj)
260 {
261   return NULL;
262 }
263
264 /* Interface query methods */
265
266 /**
267  * Accessible_isAction:
268  * @obj: a pointer to the #Accessible instance to query.
269  *
270  * Query whether the specified #Accessible implements #AccessibleAction.
271  * Not Yet Implemented.
272  *
273  * Returns: #TRUE if @obj implements the #AccessibleAction interface,
274  *          #FALSE otherwise.
275  **/
276 boolean
277 Accessible_isAction (Accessible *obj)
278 {
279   Bonobo_Unknown iface =
280     Accessibility_Accessible_queryInterface (*obj,
281                                              "IDL:Accessibility/Action:1.0",
282                                              &ev);
283   return (iface != NULL) ? TRUE : FALSE;
284 }
285
286 /**
287  * Accessible_isComponent:
288  * @obj: a pointer to the #Accessible instance to query.
289  *
290  * Query whether the specified #Accessible implements #AccessibleComponent.
291  *
292  * Returns: #TRUE if @obj implements the #AccessibleComponent interface,
293  *          #FALSE otherwise.
294  **/
295 boolean
296 Accessible_isComponent (Accessible *obj)
297 {
298   Bonobo_Unknown iface =
299     Accessibility_Accessible_queryInterface (*obj,
300                                              "IDL:Accessibility/Component:1.0",
301                                              &ev);
302   return (iface != NULL) ? TRUE : FALSE;
303 }
304
305 /**
306  * Accessible_isEditableText:
307  * @obj: a pointer to the #Accessible instance to query.
308  *
309  * Query whether the specified #Accessible implements #AccessibleEditableText.
310  * Not Yet Implemented.
311  *
312  * Returns: #TRUE if @obj implements the #AccessibleEditableText interface,
313  *          #FALSE otherwise.
314  **/
315 boolean
316 Accessible_isEditableText (Accessible *obj)
317 {
318   Bonobo_Unknown iface =
319     Accessibility_Accessible_queryInterface (*obj,
320                                              "IDL:Accessibility/EditableText:1.0",
321                                              &ev);
322   return (iface != NULL) ? TRUE : FALSE;
323 }
324
325 /**
326  * Accessible_isHypertext:
327  * @obj: a pointer to the #Accessible instance to query.
328  *
329  * Query whether the specified #Accessible implements #AccessibleHypertext.
330  * Not Yet Implemented.
331  *
332  * Returns: #TRUE if @obj implements the #AccessibleHypertext interface,
333  *          #FALSE otherwise.
334  **/
335 boolean
336 Accessible_isHypertext (Accessible *obj)
337 {
338   Bonobo_Unknown iface =
339     Accessibility_Accessible_queryInterface (*obj,
340                                              "IDL:Accessibility/Hypertext:1.0",
341                                              &ev);
342   return (iface != NULL) ? TRUE : FALSE;
343 }
344
345 /**
346  * Accessible_isImage:
347  * @obj: a pointer to the #Accessible instance to query.
348  *
349  * Query whether the specified #Accessible implements #AccessibleImage.
350  * Not Yet Implemented.
351  *
352  * Returns: #TRUE if @obj implements the #AccessibleImage interface,
353  *          #FALSE otherwise.
354 **/
355 boolean
356 Accessible_isImage (Accessible *obj)
357 {
358   Bonobo_Unknown iface =
359     Accessibility_Accessible_queryInterface (*obj,
360                                              "IDL:Accessibility/Image:1.0",
361                                              &ev);
362   return (iface != NULL) ? TRUE : FALSE;
363 }
364
365 /**
366   * Accessible_isSelection:
367  * @obj: a pointer to the #Accessible instance to query.
368  *
369  * Query whether the specified #Accessible implements #AccessibleSelection.
370  * Not Yet Implemented.
371  *
372  * Returns: #TRUE if @obj implements the #AccessibleSelection interface,
373  *          #FALSE otherwise.
374 **/
375 boolean
376 Accessible_isSelection (Accessible *obj)
377 {
378   Bonobo_Unknown iface =
379     Accessibility_Accessible_queryInterface (*obj,
380                                              "IDL:Accessibility/Selection:1.0",
381                                              &ev);
382   return (iface != NULL) ? TRUE : FALSE;
383 }
384
385 /**
386  * Accessible_isTable:
387  * @obj: a pointer to the #Accessible instance to query.
388  *
389  * Query whether the specified #Accessible implements #AccessibleTable.
390  * Not Yet Implemented.
391  *
392  * Returns: #TRUE if @obj implements the #AccessibleTable interface,
393  *          #FALSE otherwise.
394 **/
395 boolean
396 Accessible_isTable (Accessible *obj)
397 {
398   Bonobo_Unknown iface =
399     Accessibility_Accessible_queryInterface (*obj,
400                                              "IDL:Accessibility/Table:1.0",
401                                              &ev);
402   return (iface != NULL) ? TRUE : FALSE;
403 }
404
405 /**
406  * Accessible_isText:
407  * @obj: a pointer to the #Accessible instance to query.
408  *
409  * Query whether the specified #Accessible implements #AccessibleText.
410  * Not Yet Implemented.
411  *
412  * Returns: #TRUE if @obj implements the #AccessibleText interface,
413  *          #FALSE otherwise.
414 **/
415 boolean
416 Accessible_isText (Accessible *obj)
417 {
418   Bonobo_Unknown iface =
419     Accessibility_Accessible_queryInterface (*obj,
420                                              "IDL:Accessibility/Text:1.0",
421                                              &ev);
422   return (iface != NULL) ? TRUE : FALSE;
423 }
424
425 /**
426  * Accessible_getAction:
427  *
428  * Not Yet Implemented.
429  *
430  **/
431 AccessibleAction *
432 Accessible_getAction (Accessible *obj)
433 {
434   AccessibleComponent iface =
435     Accessibility_Accessible_queryInterface (*obj,
436                                              "IDL:Accessibility/Action:1.0",
437                                              &ev);
438   return Obj_Add (iface);
439 }
440
441 /**
442  * Accessible_getComponent:
443  * @obj: a pointer to the #Accessible instance to query.
444  *
445  * Get the #AccessibleComponent interface for an #Accessible.
446  *
447  * Returns: a pointer to an #AccessibleComponent interface instance, or
448  *          NULL if @obj does not implement #AccessibleComponent.
449  **/
450 AccessibleComponent *
451 Accessible_getComponent (Accessible *obj)
452 {
453   AccessibleComponent iface =
454     Accessibility_Accessible_queryInterface (*obj,
455                                              "IDL:Accessibility/Component:1.0",
456                                              &ev);
457   return Obj_Add (iface);
458 }
459
460 AccessibleEditableText *
461 Accessible_getEditableText (Accessible *obj)
462 {
463   AccessibleComponent iface =
464     Accessibility_Accessible_queryInterface (*obj,
465                                              "IDL:Accessibility/EditableText:1.0",
466                                              &ev);
467   return Obj_Add (iface);
468 }
469
470
471
472 AccessibleHypertext *
473 Accessible_getHypertext (Accessible *obj)
474 {
475   AccessibleComponent iface =
476     Accessibility_Accessible_queryInterface (*obj,
477                                              "IDL:Accessibility/Hypertext:1.0",
478                                              &ev);
479   return Obj_Add (iface);
480 }
481
482
483
484 AccessibleImage *
485 Accessible_getImage (Accessible *obj)
486 {
487   AccessibleImage iface =
488     Accessibility_Accessible_queryInterface (*obj,
489                                              "IDL:Accessibility/Image:1.0",
490                                              &ev);
491   return Obj_Add (iface);
492 }
493
494
495
496 AccessibleSelection *
497 Accessible_getSelection (Accessible *obj)
498 {
499   AccessibleSelection iface =
500     Accessibility_Accessible_queryInterface (*obj,
501                                              "IDL:Accessibility/Selection:1.0",
502                                              &ev);
503   return Obj_Add (iface);
504 }
505
506
507
508 AccessibleTable *
509 Accessible_getTable (Accessible *obj)
510 {
511   AccessibleTable iface =
512     Accessibility_Accessible_queryInterface (*obj,
513                                              "IDL:Accessibility/Table:1.0",
514                                              &ev);
515   return Obj_Add (iface);
516 }
517
518
519
520 AccessibleText *
521 Accessible_getText (Accessible *obj)
522 {
523   AccessibleText iface =
524     Accessibility_Accessible_queryInterface (*obj,
525                                              "IDL:Accessibility/Text:1.0",
526                                              &ev);
527   return Obj_Add (iface);
528 }
529
530
531
532 AccessibleValue *
533 Accessible_getValue (Accessible *obj)
534 {
535   AccessibleComponent iface =
536     Accessibility_Accessible_queryInterface (*obj,
537                                              "IDL:Accessibility/Value:1.0",
538                                              &ev);
539   return Obj_Add (iface);
540 }
541
542
543
544 /**
545  * Accessible_queryInterface:
546  * @obj: a pointer to the #Accessible instance to query.
547  * @interface_name: a UTF-8 character string specifiying the requested interface.
548  *
549  * Query an #Accessible object to for a named interface.
550  *
551  * Returns: an instance of the named interface object, if it is implemented
552  *          by @obj, or NULL otherwise.
553  *
554  **/
555 GenericInterface *
556 Accessible_queryInterface (Accessible *obj, char *interface_name)
557 {
558   GenericInterface iface;
559   iface = Accessibility_Accessible_queryInterface (*obj,
560                                                     interface_name,
561                                                     &ev);
562   return (iface != NULL) ? Obj_Add (iface) : NULL;
563 }
564