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