deb496ab0bf3509304d0a8dfa425d60ae35e562a
[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_isStreamableContent:
611  * @obj: a pointer to the #Accessible instance to query.
612  *
613  * Query whether the specified #Accessible implements
614  *          #AccessibleStreamableContent.
615  *
616  * Returns: #TRUE if @obj implements the #AccessibleStreamableContent interface,
617  *          #FALSE otherwise.
618 **/
619 SPIBoolean
620 Accessible_isStreamableContent (Accessible *obj)
621 {
622   return cspi_accessible_is_a (obj,
623                               "IDL:Accessibility/StreamableContent:1.0");
624 }
625
626 /**
627  * Accessible_isText:
628  * @obj: a pointer to the #Accessible instance to query.
629  *
630  * Query whether the specified #Accessible implements #AccessibleText.
631  *
632  * Returns: #TRUE if @obj implements the #AccessibleText interface,
633  *          #FALSE otherwise.
634 **/
635 SPIBoolean
636 Accessible_isText (Accessible *obj)
637 {
638   return cspi_accessible_is_a (obj,
639                               "IDL:Accessibility/Text:1.0");
640 }
641
642 /**
643  * Accessible_isValue:
644  * @obj: a pointer to the #Accessible instance to query.
645  *
646  * Query whether the specified #Accessible implements #AccessibleValue.
647  *
648  * Returns: #TRUE if @obj implements the #AccessibleValue interface,
649  *          #FALSE otherwise.
650 **/
651 SPIBoolean
652 Accessible_isValue (Accessible *obj)
653 {
654   return cspi_accessible_is_a (obj,
655                               "IDL:Accessibility/Value:1.0");
656 }
657
658 /**
659  * Accessible_getApplication:
660  * @obj: a pointer to the #Accessible instance to query.
661  *
662  * Get the #AccessibleApplication interface for an #Accessible.
663  *
664  * Returns: a pointer to an #AccessibleApplication interface instance, or
665  *          NULL if @obj does not implement #AccessibleApplication.
666  **/
667 AccessibleApplication *
668 Accessible_getApplication (Accessible *obj)
669 {
670   return (AccessibleApplication *) Accessible_queryInterface (
671           obj, "IDL:Accessibility/Application:1.0");
672 }
673
674 /**
675  * Accessible_getAction:
676  * @obj: a pointer to the #Accessible instance to query.
677  *
678  * Get the #AccessibleAction interface for an #Accessible.
679  *
680  * Returns: a pointer to an #AccessibleAction interface instance, or
681  *          NULL if @obj does not implement #AccessibleAction.
682  **/
683 AccessibleAction *
684 Accessible_getAction (Accessible *obj)
685 {
686   return (AccessibleAction *) Accessible_queryInterface (
687           obj, "IDL:Accessibility/Action:1.0");
688 }
689
690 /**
691  * Accessible_getComponent:
692  * @obj: a pointer to the #Accessible instance to query.
693  *
694  * Get the #AccessibleComponent interface for an #Accessible.
695  *
696  * Returns: a pointer to an #AccessibleComponent interface instance, or
697  *          NULL if @obj does not implement #AccessibleComponent.
698  **/
699 AccessibleComponent *
700 Accessible_getComponent (Accessible *obj)
701 {
702   return (AccessibleComponent *) Accessible_queryInterface (
703           obj, "IDL:Accessibility/Component:1.0");
704 }
705
706 /**
707  * Accessible_getEditableText:
708  * @obj: a pointer to the #Accessible instance to query.
709  *
710  * Get the #AccessibleEditableText interface for an #Accessible.
711  *
712  * Returns: a pointer to an #AccessibleEditableText interface instance, or
713  *          NULL if @obj does not implement #AccessibleEditableText.
714  **/
715 AccessibleEditableText *
716 Accessible_getEditableText (Accessible *obj)
717 {
718   return (AccessibleEditableText *) Accessible_queryInterface (
719           obj, "IDL:Accessibility/EditableText:1.0");
720 }
721
722
723
724 /**
725  * Accessible_getHypertext:
726  * @obj: a pointer to the #Accessible instance to query.
727  *
728  * Get the #AccessibleHypertext interface for an #Accessible.
729  *
730  * Returns: a pointer to an #AccessibleHypertext interface instance, or
731  *          NULL if @obj does not implement #AccessibleHypertext.
732  **/
733 AccessibleHypertext *
734 Accessible_getHypertext (Accessible *obj)
735 {
736   return (AccessibleHypertext *) Accessible_queryInterface (
737           obj, "IDL:Accessibility/Hypertext:1.0");
738 }
739
740
741
742 /**
743  * Accessible_getImage:
744  * @obj: a pointer to the #Accessible instance to query.
745  *
746  * Get the #AccessibleImage interface for an #Accessible.
747  *
748  * Returns: a pointer to an #AccessibleImage interface instance, or
749  *          NULL if @obj does not implement #AccessibleImage.
750  **/
751 AccessibleImage *
752 Accessible_getImage (Accessible *obj)
753 {
754   return (AccessibleImage *) Accessible_queryInterface (
755           obj, "IDL:Accessibility/Image:1.0");
756 }
757
758
759
760 /**
761  * Accessible_getSelection:
762  * @obj: a pointer to the #Accessible instance to query.
763  *
764  * Get the #AccessibleSelection interface for an #Accessible.
765  *
766  * Returns: a pointer to an #AccessibleSelection interface instance, or
767  *          NULL if @obj does not implement #AccessibleSelection.
768  **/
769 AccessibleSelection *
770 Accessible_getSelection (Accessible *obj)
771 {
772   return (AccessibleSelection *) Accessible_queryInterface (
773           obj, "IDL:Accessibility/Selection:1.0");
774 }
775
776
777
778 /**
779  * Accessible_getStreamableContent:
780  * @obj: a pointer to the #Accessible instance to query.
781  *
782  * Get the #AccessibleStreamableContent interface for an #Accessible.
783  *
784  * Returns: a pointer to an #AccessibleStreamableContent interface instance, or
785  *          NULL if @obj does not implement #AccessibleStreamableContent.
786  **/
787 AccessibleStreamableContent *
788 Accessible_getStreamableContent (Accessible *obj)
789 {
790   return (AccessibleStreamableContent *) Accessible_queryInterface (
791           obj, "IDL:Accessibility/StreamableContent:1.0");
792 }
793
794 /**
795  * Accessible_getTable:
796  * @obj: a pointer to the #Accessible instance to query.
797  *
798  * Get the #AccessibleTable interface for an #Accessible.
799  *
800  * Returns: a pointer to an #AccessibleTable interface instance, or
801  *          NULL if @obj does not implement #AccessibleTable.
802  **/
803 AccessibleTable *
804 Accessible_getTable (Accessible *obj)
805 {
806   return (AccessibleTable *) Accessible_queryInterface (
807           obj, "IDL:Accessibility/Table:1.0");
808 }
809
810 /**
811  * Accessible_getText:
812  * @obj: a pointer to the #Accessible instance to query.
813  *
814  * Get the #AccessibleText interface for an #Accessible.
815  *
816  * Returns: a pointer to an #AccessibleText interface instance, or
817  *          NULL if @obj does not implement #AccessibleText.
818  **/
819 AccessibleText *
820 Accessible_getText (Accessible *obj)
821 {
822   return (AccessibleText *) Accessible_queryInterface (
823           obj, "IDL:Accessibility/Text:1.0");
824 }
825
826
827
828 /**
829  * Accessible_getValue:
830  * @obj: a pointer to the #Accessible instance to query.
831  *
832  * Get the #AccessibleValue interface for an #Accessible.
833  *
834  * Returns: a pointer to an #AccessibleValue interface instance, or
835  *          NULL if @obj does not implement #AccessibleValue.
836  **/
837 AccessibleValue *
838 Accessible_getValue (Accessible *obj)
839 {
840   return (AccessibleValue *) Accessible_queryInterface (
841           obj, "IDL:Accessibility/Value:1.0");
842 }
843
844
845
846 /**
847  * Accessible_queryInterface:
848  * @obj: a pointer to the #Accessible instance to query.
849  * @interface_name: a UTF-8 character string specifiying the requested interface.
850  *
851  * Query an #Accessible object to for a named interface.
852  *
853  * Returns: an instance of the named interface object, if it is implemented
854  *          by @obj, or NULL otherwise.
855  *
856  **/
857 AccessibleUnknown *
858 Accessible_queryInterface (Accessible *obj,
859                            const char *interface_name)
860 {
861   Bonobo_Unknown iface;
862   
863   if (!obj)
864     {
865       return NULL;
866     }
867
868   iface = Accessibility_Accessible_queryInterface (CSPI_OBJREF (obj),
869                                                    interface_name,
870                                                    cspi_ev ());
871
872
873   cspi_return_val_if_ev ("queryInterface", NULL); 
874
875   /*
876    * FIXME: we need to be fairly sure that references are going
877    * to mach up if we are going to expose QueryInterface, ie. we
878    * can't allow people to do:
879    * b = a.qi ("b"); b.unref, b.unref to release a's reference.
880    * this should be no real problem though for this level of API
881    * user.
882    */
883
884   return cspi_object_add (iface);
885 }
886
887
888 /**
889  * AccessibleRelation_ref:
890  * @obj: a pointer to the #AccessibleRelation object on which to operate.
891  *
892  * Increment the reference count for an #AccessibleRelation object.
893  *
894  **/
895 void
896 AccessibleRelation_ref (AccessibleRelation *obj)
897 {
898   cspi_object_ref (obj);
899 }
900
901 /**
902  * AccessibleRelation_unref:
903  * @obj: a pointer to the #AccessibleRelation object on which to operate.
904  *
905  * Decrement the reference count for an #AccessibleRelation object.
906  *
907  **/
908 void
909 AccessibleRelation_unref (AccessibleRelation *obj)
910 {
911   cspi_object_unref (obj);
912 }
913
914 /**
915  * AccessibleRelation_getRelationType:
916  * @obj: a pointer to the #AccessibleRelation object to query.
917  *
918  * Get the type of relationship represented by an #AccessibleRelation.
919  *
920  * Returns: an #AccessibleRelationType indicating the type of relation
921  *         encapsulated in this #AccessibleRelation object.
922  *
923  **/
924 AccessibleRelationType
925 AccessibleRelation_getRelationType (AccessibleRelation *obj)
926 {
927   cspi_return_val_if_fail (obj != NULL, -1);
928   return 0;
929 }
930
931 /**
932  * AccessibleRelation_getNTargets:
933  * @obj: a pointer to the #AccessibleRelation object to query.
934  *
935  * Get the number of objects which this relationship has as its
936  *       target objects (the subject is the #Accessible from which this
937  *       #AccessibleRelation originated).
938  *
939  * Returns: a short integer indicating how many target objects which the
940  *       originating #Accessible object has the #AccessibleRelation
941  *       relationship with.
942  **/
943 int
944 AccessibleRelation_getNTargets (AccessibleRelation *obj)
945 {
946   cspi_return_val_if_fail (obj != NULL, -1);
947   return 0;
948 }
949
950 /**
951  * AccessibleRelation_getTarget:
952  * @obj: a pointer to the #AccessibleRelation object to query.
953  * @i: a (zero-index) integer indicating which (of possibly several) target is requested.
954  *
955  * Get the @i-th target of a specified #AccessibleRelation relationship.
956  *
957  * Returns: an #Accessible which is the @i-th object with which the
958  *      originating #Accessible has relationship specified in the
959  *      #AccessibleRelation object.
960  *
961  **/
962 Accessible *
963 AccessibleRelation_getTarget (AccessibleRelation *obj, int i)
964 {
965   cspi_return_val_if_fail (obj != NULL, NULL);
966   return NULL;
967 }
968
969 /**
970  * AccessibleStateSet_ref:
971  * @obj: a pointer to the #AccessibleStateSet object on which to operate.
972  *
973  * Increment the reference count for an #AccessibleStateSet object.
974  *
975  **/
976 void
977 AccessibleStateSet_ref (AccessibleStateSet *obj)
978 {
979   cspi_object_ref (obj);
980 }
981
982 /**
983  * AccessibleStateSet_unref:
984  * @obj: a pointer to the #AccessibleStateSet object on which to operate.
985  *
986  * Decrement the reference count for an #AccessibleStateSet object.
987  *
988  **/
989 void
990 AccessibleStateSet_unref (AccessibleStateSet *obj)
991 {
992   cspi_object_unref (obj);
993 }
994
995 /**
996  * AccessibleStateSet_contains:
997  * @obj: a pointer to the #AccessibleStateSet object on which to operate.
998  * @state: an #AccessibleState for which the specified #AccessibleStateSet
999  *       will be queried.
1000  *
1001  * Determine whether a given #AccessibleStateSet includes a given state; that is,
1002  *       whether @state is true for the stateset in question.
1003  *
1004  * Returns: #TRUE if @state is true/included in the given #AccessibleStateSet,
1005  *          otherwise #FALSE.
1006  *
1007  **/
1008 SPIBoolean
1009 AccessibleStateSet_contains (AccessibleStateSet *obj,
1010                              AccessibleState state)
1011 {
1012   CORBA_boolean retval;
1013
1014   cspi_return_val_if_fail (obj != NULL, FALSE);
1015
1016   retval = Accessibility_StateSet_contains (CSPI_OBJREF (obj),
1017                                             state, cspi_ev ());
1018
1019   cspi_return_val_if_ev ("contains", FALSE);
1020
1021   return (SPIBoolean) retval;
1022 }
1023
1024 /**
1025  * AccessibleStateSet_add:
1026  * @obj: a pointer to the #AccessibleStateSet object on which to operate.
1027  * @state: an #AccessibleState to be added to the specified #AccessibleStateSet
1028  *
1029  * Add a particular #AccessibleState to an #AccessibleStateSet (i.e. set the
1030  *       given state to #TRUE in the stateset.
1031  *
1032  **/
1033 void
1034 AccessibleStateSet_add (AccessibleStateSet *obj,
1035                         AccessibleState state)
1036 {
1037   cspi_return_if_fail (obj != NULL);
1038
1039   Accessibility_StateSet_add (CSPI_OBJREF (obj), state, cspi_ev ());
1040   cspi_check_ev ("add");
1041 }
1042
1043 /**
1044  * AccessibleStateSet_remove:
1045  * @obj: a pointer to the #AccessibleStateSet object on which to operate.
1046  * @state: an #AccessibleState to be removed from the specified #AccessibleStateSet
1047  *
1048  * Remove a particular #AccessibleState to an #AccessibleStateSet (i.e. set the
1049  *       given state to #FALSE in the stateset.)
1050  *
1051  **/
1052 void
1053 AccessibleStateSet_remove (AccessibleStateSet *obj,
1054                            AccessibleState state)
1055 {
1056   cspi_return_if_fail (obj != NULL);
1057
1058   Accessibility_StateSet_remove (CSPI_OBJREF (obj), state, cspi_ev ());
1059   cspi_check_ev ("remove");
1060 }
1061
1062 /**
1063  * AccessibleStateSet_equals:
1064  * @obj: a pointer to the first #AccessibleStateSet object on which to operate.
1065  * @obj2: a pointer to the second #AccessibleStateSet object on which to operate.
1066  *
1067  * Determine whether two instances of #AccessibleStateSet are equivalent (i.e.
1068  *         consist of the same #AccessibleStates).  Useful for checking multiple
1069  *         state variables at once; construct the target state then compare against it.
1070  *
1071  * @see AccessibleStateSet_compare().
1072  *
1073  * Returns: #TRUE if the two #AccessibleStateSets are equivalent,
1074  *          otherwise #FALSE.
1075  *
1076  **/
1077 SPIBoolean
1078 AccessibleStateSet_equals (AccessibleStateSet *obj,
1079                            AccessibleStateSet *obj2)
1080 {
1081   if (obj == obj2)
1082     {
1083       return TRUE;
1084     }
1085
1086   cspi_return_val_if_fail (obj != NULL, FALSE);
1087   cspi_return_val_if_fail (obj2 != NULL, FALSE);
1088
1089   return Accessibility_StateSet_equals (CSPI_OBJREF (obj),
1090                                         CSPI_OBJREF (obj2), cspi_ev ());
1091 }
1092
1093 /**
1094  * AccessibleStateSet_compare:
1095  * @obj: a pointer to the first #AccessibleStateSet object on which to operate.
1096  * @obj2: a pointer to the second #AccessibleStateSet object on which to operate.
1097  *
1098  * Determine the differences between two instances of #AccessibleStateSet.
1099  * Not Yet Implemented.
1100  *.
1101  * @see AccessibleStateSet_equals().
1102  *
1103  * Returns: an #AccessibleStateSet object containing all states contained on one of
1104  *          the two sets but not the other.
1105  *
1106  **/
1107 AccessibleStateSet *
1108 AccessibleStateSet_compare (AccessibleStateSet *obj,
1109                             AccessibleStateSet *obj2)
1110 {
1111   cspi_return_val_if_fail (obj != NULL, NULL);
1112   cspi_return_val_if_fail (obj2 != NULL, NULL);
1113   return NULL;  
1114 }
1115
1116 /**
1117  * AccessibleStateSet_isEmpty:
1118  * @obj: a pointer to the #AccessibleStateSet object on which to operate.
1119  *
1120  * Determine whether a given #AccessibleStateSet is the empty set.
1121  *
1122  * Returns: #TRUE if the given #AccessibleStateSet contains no (true) states,
1123  *          otherwise #FALSE.
1124  *
1125  **/
1126 SPIBoolean
1127 AccessibleStateSet_isEmpty (AccessibleStateSet *obj)
1128 {
1129   cspi_return_val_if_fail (obj != NULL, FALSE);
1130   return TRUE;  
1131   /*  return Accessibility_StateSet_isEmpty (CSPI_OBJREF (obj), cspi_ev ());*/
1132 }
1133
1134