60c269917de13d6049156f29e058fc7fd6cfbee2
[platform/core/uifw/at-spi2-atk.git] / cspi / spi_accessible.c
1 #include <stdlib.h> /* for malloc */
2 #include <cspi/spi-private.h>
3
4 static const char *role_names [] =
5 {
6   "<invalid>",
7   "accelerator label",
8   "alert",
9   "animation",
10   "arrow",
11   "calendar",
12   "canvas",
13   "check box",
14   "check menu item",
15   "color chooser",
16   "column header",
17   "combo box",
18   "date editor",
19   "desktop icon",
20   "desktop frame",
21   "dial",
22   "dialog",
23   "directory pane",
24   "file chooser",
25   "filler",
26   "focus traversable",
27   "font chooser",
28   "frame",
29   "glass pane",
30   "HTML container",
31   "icon",
32   "image",
33   "internal frame",
34   "label",
35   "layered pane",
36   "list",
37   "list item",
38   "menu",
39   "menubar",
40   "menu item",
41   "option pane",
42   "page tab",
43   "page tab list",
44   "panel",
45   "password text",
46   "popup menu",
47   "progress bar",
48   "pushbutton",
49   "radiobutton",
50   "radio menu item",
51   "root pane",
52   "row header",
53   "scrollbar",
54   "scrollpane",
55   "separator",
56   "slider",
57   "spin button",
58   "split pane",
59   "status bar",
60   "table",
61   "table cell",
62   "table column header",
63   "table row header",
64   "tearoff menu item",
65   "text",
66   "toggle button",
67   "toolbar",
68   "tooltip",
69   "tree",
70   "tree-table",
71   "<unknown>",
72   "viewport",
73   "window",
74
75 };
76
77 #define MAX_ROLES (sizeof (role_names) / sizeof (char *))
78
79 static SPIBoolean
80 cspi_init_role_table (AccessibleRole *role_table)
81 {
82   int i;
83   for (i = 0; i < Accessibility_ROLE_LAST_DEFINED; ++i)
84     {
85       role_table [i] = SPI_ROLE_UNKNOWN;
86     }
87   role_table [Accessibility_ROLE_INVALID] = SPI_ROLE_INVALID;
88   role_table [Accessibility_ROLE_ACCELERATOR_LABEL] = SPI_ROLE_ACCEL_LABEL;
89   role_table [Accessibility_ROLE_ALERT] = SPI_ROLE_ALERT;
90   role_table [Accessibility_ROLE_ANIMATION] = SPI_ROLE_ANIMATION;
91   role_table [Accessibility_ROLE_ARROW] = SPI_ROLE_ARROW;
92   role_table [Accessibility_ROLE_CALENDAR] = SPI_ROLE_CALENDAR;
93   role_table [Accessibility_ROLE_CANVAS] = SPI_ROLE_CANVAS;
94   role_table [Accessibility_ROLE_CHECK_BOX] = SPI_ROLE_CHECK_BOX;
95   role_table [Accessibility_ROLE_CHECK_MENU_ITEM] = SPI_ROLE_CHECK_MENU_ITEM;
96   role_table [Accessibility_ROLE_COLOR_CHOOSER] = SPI_ROLE_COLOR_CHOOSER;
97   role_table [Accessibility_ROLE_COLUMN_HEADER] = SPI_ROLE_COLUMN_HEADER;
98   role_table [Accessibility_ROLE_COMBO_BOX] = SPI_ROLE_COMBO_BOX;
99   role_table [Accessibility_ROLE_DATE_EDITOR] = SPI_ROLE_DATE_EDITOR;
100   role_table [Accessibility_ROLE_DESKTOP_ICON] = SPI_ROLE_DESKTOP_ICON;
101   role_table [Accessibility_ROLE_DESKTOP_FRAME] = SPI_ROLE_DESKTOP_FRAME;
102   role_table [Accessibility_ROLE_DIAL] = SPI_ROLE_DIAL;
103   role_table [Accessibility_ROLE_DIALOG] = SPI_ROLE_DIALOG;
104   role_table [Accessibility_ROLE_DIRECTORY_PANE] = SPI_ROLE_DIRECTORY_PANE;
105   role_table [Accessibility_ROLE_FILE_CHOOSER] = SPI_ROLE_FILE_CHOOSER;
106   role_table [Accessibility_ROLE_FILLER] = SPI_ROLE_FILLER;
107   role_table [Accessibility_ROLE_FONT_CHOOSER] = SPI_ROLE_FONT_CHOOSER;
108   role_table [Accessibility_ROLE_FRAME] = SPI_ROLE_FRAME;
109   role_table [Accessibility_ROLE_GLASS_PANE] = SPI_ROLE_GLASS_PANE;
110   role_table [Accessibility_ROLE_HTML_CONTAINER] = SPI_ROLE_HTML_CONTAINER;
111   role_table [Accessibility_ROLE_ICON] = SPI_ROLE_ICON;
112   role_table [Accessibility_ROLE_IMAGE] = SPI_ROLE_IMAGE;
113   role_table [Accessibility_ROLE_INTERNAL_FRAME] = SPI_ROLE_INTERNAL_FRAME;
114   role_table [Accessibility_ROLE_LABEL] = SPI_ROLE_LABEL;
115   role_table [Accessibility_ROLE_LAYERED_PANE] = SPI_ROLE_LAYERED_PANE;
116   role_table [Accessibility_ROLE_LIST] = SPI_ROLE_LIST;
117   role_table [Accessibility_ROLE_LIST_ITEM] = SPI_ROLE_LIST_ITEM;
118   role_table [Accessibility_ROLE_MENU] = SPI_ROLE_MENU;
119   role_table [Accessibility_ROLE_MENU_BAR] = SPI_ROLE_MENU_BAR;
120   role_table [Accessibility_ROLE_MENU_ITEM] = SPI_ROLE_MENU_ITEM;
121   role_table [Accessibility_ROLE_OPTION_PANE] = SPI_ROLE_OPTION_PANE;
122   role_table [Accessibility_ROLE_PAGE_TAB] = SPI_ROLE_PAGE_TAB;
123   role_table [Accessibility_ROLE_PAGE_TAB_LIST] = SPI_ROLE_PAGE_TAB_LIST;
124   role_table [Accessibility_ROLE_PANEL] = SPI_ROLE_PANEL;
125   role_table [Accessibility_ROLE_PASSWORD_TEXT] = SPI_ROLE_PASSWORD_TEXT;
126   role_table [Accessibility_ROLE_POPUP_MENU] = SPI_ROLE_POPUP_MENU;
127   role_table [Accessibility_ROLE_PROGRESS_BAR] = SPI_ROLE_PROGRESS_BAR;
128   role_table [Accessibility_ROLE_PUSH_BUTTON] = SPI_ROLE_PUSH_BUTTON;
129   role_table [Accessibility_ROLE_RADIO_BUTTON] = SPI_ROLE_RADIO_BUTTON;
130   role_table [Accessibility_ROLE_RADIO_MENU_ITEM] = SPI_ROLE_RADIO_MENU_ITEM;
131   role_table [Accessibility_ROLE_ROOT_PANE] = SPI_ROLE_ROOT_PANE;
132   role_table [Accessibility_ROLE_ROW_HEADER] = SPI_ROLE_ROW_HEADER;
133   role_table [Accessibility_ROLE_SCROLL_BAR] = SPI_ROLE_SCROLL_BAR;
134   role_table [Accessibility_ROLE_SCROLL_PANE] = SPI_ROLE_SCROLL_PANE;
135   role_table [Accessibility_ROLE_SEPARATOR] = SPI_ROLE_SEPARATOR;
136   role_table [Accessibility_ROLE_SLIDER] = SPI_ROLE_SLIDER;
137   role_table [Accessibility_ROLE_SPIN_BUTTON] = SPI_ROLE_SPIN_BUTTON;
138   role_table [Accessibility_ROLE_SPLIT_PANE] = SPI_ROLE_SPLIT_PANE;
139   role_table [Accessibility_ROLE_STATUS_BAR] = SPI_ROLE_STATUS_BAR;
140   role_table [Accessibility_ROLE_TABLE] = SPI_ROLE_TABLE;
141   role_table [Accessibility_ROLE_TABLE_CELL] = SPI_ROLE_TABLE_CELL;
142   role_table [Accessibility_ROLE_TEAROFF_MENU_ITEM] = SPI_ROLE_TEAROFF_MENU_ITEM;
143   role_table [Accessibility_ROLE_TEXT] = SPI_ROLE_TEXT;
144   role_table [Accessibility_ROLE_TOGGLE_BUTTON] = SPI_ROLE_TOGGLE_BUTTON;
145   role_table [Accessibility_ROLE_TOOL_BAR] = SPI_ROLE_TOOL_BAR;
146   role_table [Accessibility_ROLE_TOOL_TIP] = SPI_ROLE_TOOL_TIP;
147   role_table [Accessibility_ROLE_TREE] = SPI_ROLE_TREE;
148   role_table [Accessibility_ROLE_TREE_TABLE] = SPI_ROLE_TREE_TABLE;
149   role_table [Accessibility_ROLE_UNKNOWN] = SPI_ROLE_UNKNOWN;
150   role_table [Accessibility_ROLE_VIEWPORT] = SPI_ROLE_VIEWPORT;
151   role_table [Accessibility_ROLE_WINDOW] = SPI_ROLE_WINDOW;
152   role_table [Accessibility_ROLE_EXTENDED] = SPI_ROLE_EXTENDED;
153   role_table [Accessibility_ROLE_LAST_DEFINED] = SPI_ROLE_EXTENDED;
154
155   return TRUE;
156 }
157
158 static AccessibleRole
159 cspi_role_from_spi_role (Accessibility_Role role)
160 {
161   /* array is sized according to IDL roles because IDL roles are the index */   
162   static AccessibleRole cspi_role_table [Accessibility_ROLE_LAST_DEFINED];
163   static SPIBoolean is_initialized = FALSE;
164   AccessibleRole cspi_role;
165   if (!is_initialized)
166     {
167       is_initialized = cspi_init_role_table (cspi_role_table);      
168     }
169   if (role >= 0 && role < Accessibility_ROLE_LAST_DEFINED)
170     {
171       cspi_role = cspi_role_table [role];           
172     }
173   else
174     {
175       cspi_role = SPI_ROLE_EXTENDED;
176     }
177   return cspi_role; 
178 }
179
180 static SPIBoolean
181 init_state_table (Accessibility_StateType *state_table)
182 {
183   int i;
184
185   for (i = 0; i < Accessibility_STATE_LAST_DEFINED; i++)
186     state_table[i] = SPI_STATE_INVALID;
187
188   state_table[SPI_STATE_ACTIVE] = Accessibility_STATE_ACTIVE;
189   state_table[SPI_STATE_ARMED] = Accessibility_STATE_ARMED;
190   state_table[SPI_STATE_BUSY] = Accessibility_STATE_BUSY;
191   state_table[SPI_STATE_CHECKED] = Accessibility_STATE_CHECKED;
192   state_table[SPI_STATE_DEFUNCT] = Accessibility_STATE_DEFUNCT;
193   state_table[SPI_STATE_EDITABLE] = Accessibility_STATE_EDITABLE;
194   state_table[SPI_STATE_ENABLED] = Accessibility_STATE_ENABLED;
195   state_table[SPI_STATE_EXPANDABLE] = Accessibility_STATE_EXPANDABLE;
196   state_table[SPI_STATE_EXPANDED] = Accessibility_STATE_EXPANDED;
197   state_table[SPI_STATE_FOCUSABLE] = Accessibility_STATE_FOCUSABLE;
198   state_table[SPI_STATE_FOCUSED] = Accessibility_STATE_FOCUSED;
199   state_table[SPI_STATE_HORIZONTAL] = Accessibility_STATE_HORIZONTAL;
200   state_table[SPI_STATE_ICONIFIED] = Accessibility_STATE_ICONIFIED;
201   state_table[SPI_STATE_MODAL] = Accessibility_STATE_MODAL;
202   state_table[SPI_STATE_MULTI_LINE] = Accessibility_STATE_MULTI_LINE;
203   state_table[SPI_STATE_MULTISELECTABLE] = Accessibility_STATE_MULTISELECTABLE;
204   state_table[SPI_STATE_OPAQUE] = Accessibility_STATE_OPAQUE;
205   state_table[SPI_STATE_PRESSED] = Accessibility_STATE_PRESSED;
206   state_table[SPI_STATE_RESIZABLE] = Accessibility_STATE_RESIZABLE;
207   state_table[SPI_STATE_SELECTABLE] = Accessibility_STATE_SELECTABLE;
208   state_table[SPI_STATE_SELECTED] = Accessibility_STATE_SELECTED;
209   state_table[SPI_STATE_SENSITIVE] = Accessibility_STATE_SENSITIVE;
210   state_table[SPI_STATE_SHOWING] = Accessibility_STATE_SHOWING;
211   state_table[SPI_STATE_SINGLE_LINE] = Accessibility_STATE_SINGLE_LINE;
212   state_table[SPI_STATE_STALE] = Accessibility_STATE_STALE;
213   state_table[SPI_STATE_TRANSIENT] = Accessibility_STATE_TRANSIENT;
214   state_table[SPI_STATE_VERTICAL] = Accessibility_STATE_VERTICAL;
215   state_table[SPI_STATE_VISIBLE] = Accessibility_STATE_VISIBLE;
216
217   return TRUE;
218 }
219
220
221
222 static Accessibility_StateType
223 spi_state_type_from_accessible_state (AccessibleState type)
224 {
225   static Accessibility_StateType state_table[Accessibility_STATE_LAST_DEFINED];
226   static SPIBoolean table_initialized = FALSE;
227   Accessibility_StateType rv;
228   
229   if (!table_initialized)
230     table_initialized = init_state_table (state_table);  
231   if (type > SPI_STATE_INVALID && type < SPI_STATE_LAST_DEFINED)
232     rv = state_table[type];
233   else
234     rv = Accessibility_STATE_INVALID;
235   return rv;
236 }
237
238
239
240
241 /**
242  * AccessibleRole_getName:
243  * @role: an #AccessibleRole object to query.
244  *
245  * Get a localizeable string that indicates the name of an #AccessibleRole.
246  * <em>DEPRECATED.</em>
247  *
248  * Returns: a localizable string name for an #AccessibleRole enumerated type.
249  **/
250 char *
251 AccessibleRole_getName (AccessibleRole role)
252 {
253   if (role < MAX_ROLES)
254     {
255       return CORBA_string_dup (role_names [(int) role]);
256     }
257   else
258     {
259       return g_strdup ("");
260     }
261 }
262
263 /**
264  * Accessible_ref:
265  * @obj: a pointer to the #Accessible object on which to operate.
266  *
267  * Increment the reference count for an #Accessible object.
268  **/
269 void
270 Accessible_ref (Accessible *obj)
271 {
272   cspi_object_ref (obj);
273 }
274
275 /**
276  * Accessible_unref:
277  * @obj: a pointer to the #Accessible object on which to operate.
278  *
279  * Decrement the reference count for an #Accessible object.
280  **/
281 void
282 Accessible_unref (Accessible *obj)
283 {
284   cspi_object_unref (obj);
285 }
286
287 /**
288  * Accessible_getName:
289  * @obj: a pointer to the #Accessible object on which to operate.
290  *
291  * Get the name of an #Accessible object.
292  *
293  * Returns: a UTF-8 string indicating the name of the #Accessible object.
294  * or NULL on exception
295  **/
296 char *
297 Accessible_getName (Accessible *obj)
298 {
299   char *retval;
300
301   cspi_return_val_if_fail (obj != NULL, NULL);
302
303   retval = (char *)
304     Accessibility_Accessible__get_name (CSPI_OBJREF (obj), cspi_ev ());
305
306   cspi_return_val_if_ev ("getName", NULL); 
307
308   return retval;
309 }
310
311 /**
312  * Accessible_getDescription:
313  * @obj: a pointer to the #Accessible object on which to operate.
314  *
315  * Get the description of an #Accessible object.
316  *
317  * Returns: a UTF-8 string describing the #Accessible object.
318  * or NULL on exception
319  **/
320 char *
321 Accessible_getDescription (Accessible *obj)
322 {
323   char *retval;
324
325   cspi_return_val_if_fail (obj != NULL, NULL);
326
327   retval = (char *)
328     Accessibility_Accessible__get_description (CSPI_OBJREF (obj),
329                                                cspi_ev ());
330
331   cspi_return_val_if_ev ("getDescription", NULL); 
332
333   return retval;
334 }
335
336 /**
337  * Accessible_getParent:
338  * @obj: a pointer to the #Accessible object to query.
339  *
340  * Get an #Accessible object's parent container.
341  *
342  * Returns: a pointer tothe #Accessible object which contains the given
343  *          #Accessible instance, or NULL if the @obj has no parent container.
344  *
345  **/
346 Accessible *
347 Accessible_getParent (Accessible *obj)
348 {
349   Accessible *retval;
350
351   cspi_return_val_if_fail (obj != NULL, NULL);
352
353   retval = cspi_object_add (
354     Accessibility_Accessible__get_parent (CSPI_OBJREF (obj),
355                                           cspi_ev ()));
356
357   cspi_return_val_if_ev ("getParent", NULL); 
358
359   return retval;
360 }
361
362 /**
363  * Accessible_getChildCount:
364  * @obj: a pointer to the #Accessible object on which to operate.
365  *
366  * Get the number of children contained by an #Accessible object.
367  *
368  * Returns: a #long indicating the number of #Accessible children
369  *          contained by an #Accessible object. or -1 on exception
370  *
371  **/
372 long
373 Accessible_getChildCount (Accessible *obj)
374 {
375   long retval;
376
377   cspi_return_val_if_fail (obj != NULL, -1);
378
379   retval = (long) 
380     Accessibility_Accessible__get_childCount (CSPI_OBJREF (obj),
381                                               cspi_ev ());
382
383   cspi_return_val_if_ev ("getChildCount", -1); 
384
385   return retval;
386 }
387
388 /**
389  * Accessible_getChildAtIndex:
390  * @obj: a pointer to the #Accessible object on which to operate.
391  * @childIndex: a #long indicating which child is specified.
392  *
393  * Get the #Accessible child of an #Accessible object at a given index.
394  *
395  * Returns: a pointer to the #Accessible child object at index
396  *          @childIndex. or NULL on exception
397  **/
398 Accessible *
399 Accessible_getChildAtIndex (Accessible *obj,
400                             long int    childIndex)
401 {
402   Accessible *retval;
403
404   cspi_return_val_if_fail (obj != NULL, NULL);
405
406   retval = cspi_object_add (
407     Accessibility_Accessible_getChildAtIndex (CSPI_OBJREF (obj),
408                                               childIndex, cspi_ev ()));
409
410   return retval;
411 }
412
413 /**
414  * Accessible_getIndexInParent:
415  * @obj: a pointer to the #Accessible object on which to operate.
416  *
417  * Get the index of an #Accessible object in its containing #Accessible.
418  *
419  * Returns: a #long indicating the index of the #Accessible object
420  *          in its parent (i.e. containing) #Accessible instance,
421  *          or -1 if @obj has no containing parent or on exception.
422  **/
423 long
424 Accessible_getIndexInParent (Accessible *obj)
425 {
426   long retval;
427
428   cspi_return_val_if_fail (obj != NULL, -1);
429
430   retval = (long)
431     Accessibility_Accessible_getIndexInParent (CSPI_OBJREF (obj), cspi_ev ());
432
433   cspi_return_val_if_ev ("getIndexInparent", -1); 
434   return retval;
435 }
436
437 /**
438  * Accessible_getRelationSet:
439  * @obj: a pointer to the #Accessible object on which to operate.
440  *
441  * Get the set of #AccessibleRelation objects which describe this #Accessible object's
442  *       relationships with other #Accessible objects.
443  *
444  * Returns: an array of #AccessibleRelation pointers. or NULL on exception
445  **/
446 AccessibleRelation **
447 Accessible_getRelationSet (Accessible *obj)
448 {
449   int i;
450   int n_relations;
451   AccessibleRelation **relations;
452   Accessibility_RelationSet *relation_set;
453
454   cspi_return_val_if_fail (obj != NULL, NULL);
455
456   relation_set =
457     Accessibility_Accessible_getRelationSet (CSPI_OBJREF (obj), cspi_ev ());
458
459   cspi_return_val_if_ev ("getRelationSet", NULL); 
460   
461   n_relations = relation_set->_length;
462   relations = malloc (sizeof (AccessibleRelation *) * (n_relations + 1));
463   
464   for (i = 0; i < n_relations; ++i)
465     {
466       relations[i] = cspi_object_add (CORBA_Object_duplicate (
467               relation_set->_buffer[i], cspi_ev ()));
468     }
469   relations[i] = NULL;
470
471   CORBA_free (relation_set);
472
473   return relations;
474 }
475
476 /**
477  * Accessible_getRole:
478  * @obj: a pointer to the #Accessible object on which to operate.
479  *
480  * Get the UI role of an #Accessible object.
481  * A UTF-8 string describing this role can be obtained via Accessible_getRoleName ().
482  *
483  * Returns: the #AccessibleRole of the object.
484  *
485  **/
486 AccessibleRole
487 Accessible_getRole (Accessible *obj)
488 {
489   AccessibleRole retval;
490
491   cspi_return_val_if_fail (obj != NULL, SPI_ROLE_INVALID);
492
493   retval = 
494     Accessibility_Accessible_getRole (CSPI_OBJREF (obj), cspi_ev ());
495
496   cspi_return_val_if_ev ("getRole", SPI_ROLE_INVALID); 
497
498   return cspi_role_from_spi_role (retval);
499 }
500
501 /**
502  * Accessible_getRoleName:
503  * @obj: a pointer to the #Accessible object on which to operate.
504  *
505  * Get a UTF-8 string describing the role this object plays in the UI.
506  * This method will return useful values for roles that fall outside the
507  * enumeration used in Accessible_getRole ().
508  *
509  * Returns: a UTF-8 string specifying the role of this #Accessible object.
510  *
511  **/
512 char *
513 Accessible_getRoleName (Accessible *obj)
514 {
515   char *retval;
516
517   cspi_return_val_if_fail (obj != NULL, CORBA_string_dup ("invalid"));
518
519   retval = 
520     Accessibility_Accessible_getRoleName (CSPI_OBJREF (obj), cspi_ev ());
521
522   cspi_return_val_if_ev ("getRoleName", CORBA_string_dup ("invalid")); 
523
524   return retval;
525 }
526
527 /**
528  * Accessible_getStateSet:
529  * @obj: a pointer to the #Accessible object on which to operate.
530  *
531  * Not Yet Implemented.
532  *
533  * Returns: a pointer to an #AccessibleStateSet representing the object's current state.
534  **/
535 AccessibleStateSet *
536 Accessible_getStateSet (Accessible *obj)
537 {
538   AccessibleStateSet *retval;
539
540   cspi_return_val_if_fail (obj != NULL, NULL);
541
542   retval = cspi_object_add (
543     Accessibility_Accessible_getState (CSPI_OBJREF (obj),
544                                           cspi_ev ()));
545
546   return retval;
547 }
548
549 /* Interface query methods */
550
551 /**
552  * Accessible_isAction:
553  * @obj: a pointer to the #Accessible instance to query.
554  *
555  * Query whether the specified #Accessible implements #AccessibleAction.
556  *
557  * Returns: #TRUE if @obj implements the #AccessibleAction interface,
558  *          #FALSE otherwise.
559  **/
560 SPIBoolean
561 Accessible_isAction (Accessible *obj)
562 {
563   return cspi_accessible_is_a (obj,
564                               "IDL:Accessibility/Action:1.0");
565 }
566
567 /**
568  * Accessible_isApplication:
569  * @obj: a pointer to the #Accessible instance to query.
570  *
571  * Query whether the specified #Accessible implements #AccessibleApplication.
572  *
573  * Returns: #TRUE if @obj implements the #AccessibleApplication interface,
574  *          #FALSE otherwise.
575  **/
576 SPIBoolean
577 Accessible_isApplication (Accessible *obj)
578 {
579   return cspi_accessible_is_a (obj,
580                               "IDL:Accessibility/Application:1.0");
581 }
582
583 /**
584  * Accessible_isComponent:
585  * @obj: a pointer to the #Accessible instance to query.
586  *
587  * Query whether the specified #Accessible implements #AccessibleComponent.
588  *
589  * Returns: #TRUE if @obj implements the #AccessibleComponent interface,
590  *          #FALSE otherwise.
591  **/
592 SPIBoolean
593 Accessible_isComponent (Accessible *obj)
594 {
595   return cspi_accessible_is_a (obj,
596                               "IDL:Accessibility/Component:1.0");
597 }
598
599 /**
600  * Accessible_isEditableText:
601  * @obj: a pointer to the #Accessible instance to query.
602  *
603  * Query whether the specified #Accessible implements #AccessibleEditableText.
604  *
605  * Returns: #TRUE if @obj implements the #AccessibleEditableText interface,
606  *          #FALSE otherwise.
607  **/
608 SPIBoolean
609 Accessible_isEditableText (Accessible *obj)
610 {
611   return cspi_accessible_is_a (obj,
612                               "IDL:Accessibility/EditableText:1.0");
613 }
614
615 /**
616  * Accessible_isHypertext:
617  * @obj: a pointer to the #Accessible instance to query.
618  *
619  * Query whether the specified #Accessible implements #AccessibleHypertext.
620  *
621  * Returns: #TRUE if @obj implements the #AccessibleHypertext interface,
622  *          #FALSE otherwise.
623  **/
624 SPIBoolean
625 Accessible_isHypertext (Accessible *obj)
626 {
627   return cspi_accessible_is_a (obj,
628                               "IDL:Accessibility/Hypertext:1.0");
629 }
630
631 /**
632  * Accessible_isImage:
633  * @obj: a pointer to the #Accessible instance to query.
634  *
635  * Query whether the specified #Accessible implements #AccessibleImage.
636  *
637  * Returns: #TRUE if @obj implements the #AccessibleImage interface,
638  *          #FALSE otherwise.
639 **/
640 SPIBoolean
641 Accessible_isImage (Accessible *obj)
642 {
643   return cspi_accessible_is_a (obj,
644                               "IDL:Accessibility/Image:1.0");
645 }
646
647 /**
648  * Accessible_isSelection:
649  * @obj: a pointer to the #Accessible instance to query.
650  *
651  * Query whether the specified #Accessible implements #AccessibleSelection.
652  *
653  * Returns: #TRUE if @obj implements the #AccessibleSelection interface,
654  *          #FALSE otherwise.
655 **/
656 SPIBoolean
657 Accessible_isSelection (Accessible *obj)
658 {
659   return cspi_accessible_is_a (obj,
660                               "IDL:Accessibility/Selection:1.0");
661 }
662
663 /**
664  * Accessible_isTable:
665  * @obj: a pointer to the #Accessible instance to query.
666  *
667  * Query whether the specified #Accessible implements #AccessibleTable.
668  *
669  * Returns: #TRUE if @obj implements the #AccessibleTable interface,
670  *          #FALSE otherwise.
671 **/
672 SPIBoolean
673 Accessible_isTable (Accessible *obj)
674 {
675   return cspi_accessible_is_a (obj,
676                               "IDL:Accessibility/Table:1.0");
677 }
678
679 /**
680  * Accessible_isStreamableContent:
681  * @obj: a pointer to the #Accessible instance to query.
682  *
683  * Query whether the specified #Accessible implements
684  *          #AccessibleStreamableContent.
685  *
686  * Returns: #TRUE if @obj implements the #AccessibleStreamableContent interface,
687  *          #FALSE otherwise.
688 **/
689 SPIBoolean
690 Accessible_isStreamableContent (Accessible *obj)
691 {
692   return cspi_accessible_is_a (obj,
693                               "IDL:Accessibility/StreamableContent:1.0");
694 }
695
696 /**
697  * Accessible_isText:
698  * @obj: a pointer to the #Accessible instance to query.
699  *
700  * Query whether the specified #Accessible implements #AccessibleText.
701  *
702  * Returns: #TRUE if @obj implements the #AccessibleText interface,
703  *          #FALSE otherwise.
704 **/
705 SPIBoolean
706 Accessible_isText (Accessible *obj)
707 {
708   return cspi_accessible_is_a (obj,
709                               "IDL:Accessibility/Text:1.0");
710 }
711
712 /**
713  * Accessible_isValue:
714  * @obj: a pointer to the #Accessible instance to query.
715  *
716  * Query whether the specified #Accessible implements #AccessibleValue.
717  *
718  * Returns: #TRUE if @obj implements the #AccessibleValue interface,
719  *          #FALSE otherwise.
720 **/
721 SPIBoolean
722 Accessible_isValue (Accessible *obj)
723 {
724   return cspi_accessible_is_a (obj,
725                               "IDL:Accessibility/Value:1.0");
726 }
727
728 /**
729  * Accessible_getApplication:
730  * @obj: a pointer to the #Accessible instance to query.
731  *
732  * Get the #AccessibleApplication interface for an #Accessible.
733  *
734  * Returns: a pointer to an #AccessibleApplication interface instance, or
735  *          NULL if @obj does not implement #AccessibleApplication.
736  **/
737 AccessibleApplication *
738 Accessible_getApplication (Accessible *obj)
739 {
740   return (AccessibleApplication *) Accessible_queryInterface (
741           obj, "IDL:Accessibility/Application:1.0");
742 }
743
744 /**
745  * Accessible_getAction:
746  * @obj: a pointer to the #Accessible instance to query.
747  *
748  * Get the #AccessibleAction interface for an #Accessible.
749  *
750  * Returns: a pointer to an #AccessibleAction interface instance, or
751  *          NULL if @obj does not implement #AccessibleAction.
752  **/
753 AccessibleAction *
754 Accessible_getAction (Accessible *obj)
755 {
756   return (AccessibleAction *) Accessible_queryInterface (
757           obj, "IDL:Accessibility/Action:1.0");
758 }
759
760 /**
761  * Accessible_getComponent:
762  * @obj: a pointer to the #Accessible instance to query.
763  *
764  * Get the #AccessibleComponent interface for an #Accessible.
765  *
766  * Returns: a pointer to an #AccessibleComponent interface instance, or
767  *          NULL if @obj does not implement #AccessibleComponent.
768  **/
769 AccessibleComponent *
770 Accessible_getComponent (Accessible *obj)
771 {
772   return (AccessibleComponent *) Accessible_queryInterface (
773           obj, "IDL:Accessibility/Component:1.0");
774 }
775
776 /**
777  * Accessible_getEditableText:
778  * @obj: a pointer to the #Accessible instance to query.
779  *
780  * Get the #AccessibleEditableText interface for an #Accessible.
781  *
782  * Returns: a pointer to an #AccessibleEditableText interface instance, or
783  *          NULL if @obj does not implement #AccessibleEditableText.
784  **/
785 AccessibleEditableText *
786 Accessible_getEditableText (Accessible *obj)
787 {
788   return (AccessibleEditableText *) Accessible_queryInterface (
789           obj, "IDL:Accessibility/EditableText:1.0");
790 }
791
792
793
794 /**
795  * Accessible_getHypertext:
796  * @obj: a pointer to the #Accessible instance to query.
797  *
798  * Get the #AccessibleHypertext interface for an #Accessible.
799  *
800  * Returns: a pointer to an #AccessibleHypertext interface instance, or
801  *          NULL if @obj does not implement #AccessibleHypertext.
802  **/
803 AccessibleHypertext *
804 Accessible_getHypertext (Accessible *obj)
805 {
806   return (AccessibleHypertext *) Accessible_queryInterface (
807           obj, "IDL:Accessibility/Hypertext:1.0");
808 }
809
810
811
812 /**
813  * Accessible_getImage:
814  * @obj: a pointer to the #Accessible instance to query.
815  *
816  * Get the #AccessibleImage interface for an #Accessible.
817  *
818  * Returns: a pointer to an #AccessibleImage interface instance, or
819  *          NULL if @obj does not implement #AccessibleImage.
820  **/
821 AccessibleImage *
822 Accessible_getImage (Accessible *obj)
823 {
824   return (AccessibleImage *) Accessible_queryInterface (
825           obj, "IDL:Accessibility/Image:1.0");
826 }
827
828
829
830 /**
831  * Accessible_getSelection:
832  * @obj: a pointer to the #Accessible instance to query.
833  *
834  * Get the #AccessibleSelection interface for an #Accessible.
835  *
836  * Returns: a pointer to an #AccessibleSelection interface instance, or
837  *          NULL if @obj does not implement #AccessibleSelection.
838  **/
839 AccessibleSelection *
840 Accessible_getSelection (Accessible *obj)
841 {
842   return (AccessibleSelection *) Accessible_queryInterface (
843           obj, "IDL:Accessibility/Selection:1.0");
844 }
845
846
847
848 /**
849  * Accessible_getStreamableContent:
850  * @obj: a pointer to the #Accessible instance to query.
851  *
852  * Get the #AccessibleStreamableContent interface for an #Accessible.
853  *
854  * Returns: a pointer to an #AccessibleStreamableContent interface instance, or
855  *          NULL if @obj does not implement #AccessibleStreamableContent.
856  **/
857 AccessibleStreamableContent *
858 Accessible_getStreamableContent (Accessible *obj)
859 {
860   return (AccessibleStreamableContent *) Accessible_queryInterface (
861           obj, "IDL:Accessibility/StreamableContent:1.0");
862 }
863
864 /**
865  * Accessible_getTable:
866  * @obj: a pointer to the #Accessible instance to query.
867  *
868  * Get the #AccessibleTable interface for an #Accessible.
869  *
870  * Returns: a pointer to an #AccessibleTable interface instance, or
871  *          NULL if @obj does not implement #AccessibleTable.
872  **/
873 AccessibleTable *
874 Accessible_getTable (Accessible *obj)
875 {
876   return (AccessibleTable *) Accessible_queryInterface (
877           obj, "IDL:Accessibility/Table:1.0");
878 }
879
880 /**
881  * Accessible_getText:
882  * @obj: a pointer to the #Accessible instance to query.
883  *
884  * Get the #AccessibleText interface for an #Accessible.
885  *
886  * Returns: a pointer to an #AccessibleText interface instance, or
887  *          NULL if @obj does not implement #AccessibleText.
888  **/
889 AccessibleText *
890 Accessible_getText (Accessible *obj)
891 {
892   return (AccessibleText *) Accessible_queryInterface (
893           obj, "IDL:Accessibility/Text:1.0");
894 }
895
896
897
898 /**
899  * Accessible_getValue:
900  * @obj: a pointer to the #Accessible instance to query.
901  *
902  * Get the #AccessibleValue interface for an #Accessible.
903  *
904  * Returns: a pointer to an #AccessibleValue interface instance, or
905  *          NULL if @obj does not implement #AccessibleValue.
906  **/
907 AccessibleValue *
908 Accessible_getValue (Accessible *obj)
909 {
910   return (AccessibleValue *) Accessible_queryInterface (
911           obj, "IDL:Accessibility/Value:1.0");
912 }
913
914
915
916 /**
917  * Accessible_queryInterface:
918  * @obj: a pointer to the #Accessible instance to query.
919  * @interface_name: a UTF-8 character string specifiying the requested interface.
920  *
921  * Query an #Accessible object to for a named interface.
922  *
923  * Returns: an instance of the named interface object, if it is implemented
924  *          by @obj, or NULL otherwise.
925  *
926  **/
927 AccessibleUnknown *
928 Accessible_queryInterface (Accessible *obj,
929                            const char *interface_name)
930 {
931   Bonobo_Unknown iface;
932   
933   if (!obj)
934     {
935       return NULL;
936     }
937
938   iface = Accessibility_Accessible_queryInterface (CSPI_OBJREF (obj),
939                                                    interface_name,
940                                                    cspi_ev ());
941
942
943   cspi_return_val_if_ev ("queryInterface", NULL); 
944
945   /*
946    * FIXME: we need to be fairly sure that references are going
947    * to mach up if we are going to expose QueryInterface, ie. we
948    * can't allow people to do:
949    * b = a.qi ("b"); b.unref, b.unref to release a's reference.
950    * this should be no real problem though for this level of API
951    * user.
952    */
953
954   return cspi_object_add (iface);
955 }
956
957
958 /**
959  * AccessibleRelation_ref:
960  * @obj: a pointer to the #AccessibleRelation object on which to operate.
961  *
962  * Increment the reference count for an #AccessibleRelation object.
963  *
964  **/
965 void
966 AccessibleRelation_ref (AccessibleRelation *obj)
967 {
968   cspi_object_ref (obj);
969 }
970
971 /**
972  * AccessibleRelation_unref:
973  * @obj: a pointer to the #AccessibleRelation object on which to operate.
974  *
975  * Decrement the reference count for an #AccessibleRelation object.
976  *
977  **/
978 void
979 AccessibleRelation_unref (AccessibleRelation *obj)
980 {
981   cspi_object_unref (obj);
982 }
983
984 /**
985  * AccessibleRelation_getRelationType:
986  * @obj: a pointer to the #AccessibleRelation object to query.
987  *
988  * Get the type of relationship represented by an #AccessibleRelation.
989  *
990  * Returns: an #AccessibleRelationType indicating the type of relation
991  *         encapsulated in this #AccessibleRelation object.
992  *
993  **/
994 AccessibleRelationType
995 AccessibleRelation_getRelationType (AccessibleRelation *obj)
996 {
997   AccessibleRelationType retval;
998   
999   cspi_return_val_if_fail (obj, SPI_RELATION_NULL);
1000   retval =
1001     Accessibility_Relation_getRelationType (CSPI_OBJREF (obj), cspi_ev());
1002   cspi_return_val_if_ev ("getRelationType", SPI_RELATION_NULL);
1003   return retval;
1004 }
1005
1006 /**
1007  * AccessibleRelation_getNTargets:
1008  * @obj: a pointer to the #AccessibleRelation object to query.
1009  *
1010  * Get the number of objects which this relationship has as its
1011  *       target objects (the subject is the #Accessible from which this
1012  *       #AccessibleRelation originated).
1013  *
1014  * Returns: a short integer indicating how many target objects which the
1015  *       originating #Accessible object has the #AccessibleRelation
1016  *       relationship with.
1017  **/
1018 int
1019 AccessibleRelation_getNTargets (AccessibleRelation *obj)
1020 {
1021   int retval;
1022   
1023   cspi_return_val_if_fail (obj, -1);
1024   retval = (int)
1025     Accessibility_Relation_getNTargets (CSPI_OBJREF (obj), cspi_ev());
1026   cspi_return_val_if_ev ("getNTargets", -1);
1027   return retval;
1028 }
1029
1030 /**
1031  * AccessibleRelation_getTarget:
1032  * @obj: a pointer to the #AccessibleRelation object to query.
1033  * @i: a (zero-index) integer indicating which (of possibly several) target is requested.
1034  *
1035  * Get the @i-th target of a specified #AccessibleRelation relationship.
1036  *
1037  * Returns: an #Accessible which is the @i-th object with which the
1038  *      originating #Accessible has relationship specified in the
1039  *      #AccessibleRelation object.
1040  *
1041  **/
1042 Accessible *
1043 AccessibleRelation_getTarget (AccessibleRelation *obj, int i)
1044 {
1045   Accessible *retval;
1046
1047   cspi_return_val_if_fail (obj, NULL);
1048
1049   retval = cspi_object_add (
1050                          Accessibility_Relation_getTarget (CSPI_OBJREF(obj),
1051                                                            (CORBA_short) i, cspi_ev()));
1052   cspi_return_val_if_ev ("getTarget", NULL);
1053   return retval;
1054 }
1055
1056 /**
1057  * AccessibleStateSet_ref:
1058  * @obj: a pointer to the #AccessibleStateSet object on which to operate.
1059  *
1060  * Increment the reference count for an #AccessibleStateSet object.
1061  *
1062  **/
1063 void
1064 AccessibleStateSet_ref (AccessibleStateSet *obj)
1065 {
1066   cspi_object_ref (obj);
1067 }
1068
1069 /**
1070  * AccessibleStateSet_unref:
1071  * @obj: a pointer to the #AccessibleStateSet object on which to operate.
1072  *
1073  * Decrement the reference count for an #AccessibleStateSet object.
1074  *
1075  **/
1076 void
1077 AccessibleStateSet_unref (AccessibleStateSet *obj)
1078 {
1079   cspi_object_unref (obj);
1080 }
1081
1082 /**
1083  * AccessibleStateSet_contains:
1084  * @obj: a pointer to the #AccessibleStateSet object on which to operate.
1085  * @state: an #AccessibleState for which the specified #AccessibleStateSet
1086  *       will be queried.
1087  *
1088  * Determine whether a given #AccessibleStateSet includes a given state; that is,
1089  *       whether @state is true for the stateset in question.
1090  *
1091  * Returns: #TRUE if @state is true/included in the given #AccessibleStateSet,
1092  *          otherwise #FALSE.
1093  *
1094  **/
1095 SPIBoolean
1096 AccessibleStateSet_contains (AccessibleStateSet *obj,
1097                              AccessibleState state)
1098 {
1099   CORBA_boolean retval;
1100   Accessibility_StateType spi_state;
1101   
1102   cspi_return_val_if_fail (obj != NULL, FALSE);
1103
1104   spi_state = spi_state_type_from_accessible_state (state);
1105   retval = Accessibility_StateSet_contains (CSPI_OBJREF (obj),
1106                                             spi_state, cspi_ev ());
1107
1108   cspi_return_val_if_ev ("contains", FALSE);
1109
1110   return (SPIBoolean) retval;
1111 }
1112
1113 /**
1114  * AccessibleStateSet_add:
1115  * @obj: a pointer to the #AccessibleStateSet object on which to operate.
1116  * @state: an #AccessibleState to be added to the specified #AccessibleStateSet
1117  *
1118  * Add a particular #AccessibleState to an #AccessibleStateSet (i.e. set the
1119  *       given state to #TRUE in the stateset.
1120  *
1121  **/
1122 void
1123 AccessibleStateSet_add (AccessibleStateSet *obj,
1124                         AccessibleState state)
1125 {
1126   Accessibility_StateType spi_state;
1127
1128   cspi_return_if_fail (obj != NULL);
1129
1130   spi_state = spi_state_type_from_accessible_state (state);
1131   Accessibility_StateSet_add (CSPI_OBJREF (obj), spi_state, cspi_ev ());
1132   cspi_check_ev ("add");
1133 }
1134
1135 /**
1136  * AccessibleStateSet_remove:
1137  * @obj: a pointer to the #AccessibleStateSet object on which to operate.
1138  * @state: an #AccessibleState to be removed from the specified #AccessibleStateSet
1139  *
1140  * Remove a particular #AccessibleState to an #AccessibleStateSet (i.e. set the
1141  *       given state to #FALSE in the stateset.)
1142  *
1143  **/
1144 void
1145 AccessibleStateSet_remove (AccessibleStateSet *obj,
1146                            AccessibleState state)
1147 {
1148   Accessibility_StateType spi_state;
1149
1150   cspi_return_if_fail (obj != NULL);
1151
1152   spi_state = spi_state_type_from_accessible_state (state);
1153   Accessibility_StateSet_remove (CSPI_OBJREF (obj), spi_state, cspi_ev ());
1154   cspi_check_ev ("remove");
1155 }
1156
1157 /**
1158  * AccessibleStateSet_equals:
1159  * @obj: a pointer to the first #AccessibleStateSet object on which to operate.
1160  * @obj2: a pointer to the second #AccessibleStateSet object on which to operate.
1161  *
1162  * Determine whether two instances of #AccessibleStateSet are equivalent (i.e.
1163  *         consist of the same #AccessibleStates).  Useful for checking multiple
1164  *         state variables at once; construct the target state then compare against it.
1165  *
1166  * @see AccessibleStateSet_compare().
1167  *
1168  * Returns: #TRUE if the two #AccessibleStateSets are equivalent,
1169  *          otherwise #FALSE.
1170  *
1171  **/
1172 SPIBoolean
1173 AccessibleStateSet_equals (AccessibleStateSet *obj,
1174                            AccessibleStateSet *obj2)
1175 {
1176   if (obj == obj2)
1177     {
1178       return TRUE;
1179     }
1180
1181   cspi_return_val_if_fail (obj != NULL, FALSE);
1182   cspi_return_val_if_fail (obj2 != NULL, FALSE);
1183
1184   return Accessibility_StateSet_equals (CSPI_OBJREF (obj),
1185                                         CSPI_OBJREF (obj2), cspi_ev ());
1186 }
1187
1188 /**
1189  * AccessibleStateSet_compare:
1190  * @obj: a pointer to the first #AccessibleStateSet object on which to operate.
1191  * @obj2: a pointer to the second #AccessibleStateSet object on which to operate.
1192  *
1193  * Determine the differences between two instances of #AccessibleStateSet.
1194  * Not Yet Implemented.
1195  *.
1196  * @see AccessibleStateSet_equals().
1197  *
1198  * Returns: an #AccessibleStateSet object containing all states contained on one of
1199  *          the two sets but not the other.
1200  *
1201  **/
1202 AccessibleStateSet *
1203 AccessibleStateSet_compare (AccessibleStateSet *obj,
1204                             AccessibleStateSet *obj2)
1205 {
1206   Accessibility_StateSet retval;
1207
1208   cspi_return_val_if_fail (obj != NULL, NULL);
1209   cspi_return_val_if_fail (obj2 != NULL, NULL);
1210   retval = Accessibility_StateSet_compare (CSPI_OBJREF(obj), CSPI_OBJREF(obj2), cspi_ev ());
1211   return NULL;  
1212 }
1213
1214 /**
1215  * AccessibleStateSet_isEmpty:
1216  * @obj: a pointer to the #AccessibleStateSet object on which to operate.
1217  *
1218  * Determine whether a given #AccessibleStateSet is the empty set.
1219  *
1220  * Returns: #TRUE if the given #AccessibleStateSet contains no (true) states,
1221  *          otherwise #FALSE.
1222  *
1223  **/
1224 SPIBoolean
1225 AccessibleStateSet_isEmpty (AccessibleStateSet *obj)
1226 {
1227   CORBA_boolean retval;
1228
1229   cspi_return_val_if_fail (obj != NULL, FALSE);
1230   retval = Accessibility_StateSet_isEmpty (CSPI_OBJREF (obj), cspi_ev ());
1231   return (SPIBoolean) retval;
1232 }
1233
1234