2002-01-24 Mark McLoughlin <mark@skynet.ie>
[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 /**
181  * AccessibleRole_getName:
182  * @role: an #AccessibleRole object to query.
183  *
184  * Get a localizeable string that indicates the name of an #AccessibleRole.
185  * <em>DEPRECATED.</em>
186  *
187  * Returns: a localizable string name for an #AccessibleRole enumerated type.
188  **/
189 char *
190 AccessibleRole_getName (AccessibleRole role)
191 {
192   if (role < MAX_ROLES)
193     {
194       return g_strdup (role_names [(int) role]);
195     }
196   else
197     {
198       return g_strdup ("");
199     }
200 }
201
202 /**
203  * Accessible_ref:
204  * @obj: a pointer to the #Accessible object on which to operate.
205  *
206  * Increment the reference count for an #Accessible object.
207  **/
208 void
209 Accessible_ref (Accessible *obj)
210 {
211   cspi_object_ref (obj);
212 }
213
214 /**
215  * Accessible_unref:
216  * @obj: a pointer to the #Accessible object on which to operate.
217  *
218  * Decrement the reference count for an #Accessible object.
219  **/
220 void
221 Accessible_unref (Accessible *obj)
222 {
223   cspi_object_unref (obj);
224 }
225
226 /**
227  * Accessible_getName:
228  * @obj: a pointer to the #Accessible object on which to operate.
229  *
230  * Get the name of an #Accessible object.
231  *
232  * Returns: a UTF-8 string indicating the name of the #Accessible object.
233  * or NULL on exception
234  **/
235 char *
236 Accessible_getName (Accessible *obj)
237 {
238   char *retval;
239
240   cspi_return_val_if_fail (obj != NULL, NULL);
241
242   retval = (char *)
243     Accessibility_Accessible__get_name (CSPI_OBJREF (obj), cspi_ev ());
244
245   cspi_return_val_if_ev ("getName", NULL); 
246
247   return retval;
248 }
249
250 /**
251  * Accessible_getDescription:
252  * @obj: a pointer to the #Accessible object on which to operate.
253  *
254  * Get the description of an #Accessible object.
255  *
256  * Returns: a UTF-8 string describing the #Accessible object.
257  * or NULL on exception
258  **/
259 char *
260 Accessible_getDescription (Accessible *obj)
261 {
262   char *retval;
263
264   cspi_return_val_if_fail (obj != NULL, NULL);
265
266   retval = (char *)
267     Accessibility_Accessible__get_description (CSPI_OBJREF (obj),
268                                                cspi_ev ());
269
270   cspi_return_val_if_ev ("getDescription", NULL); 
271
272   return retval;
273 }
274
275 /**
276  * Accessible_getParent:
277  * @obj: a pointer to the #Accessible object to query.
278  *
279  * Get an #Accessible object's parent container.
280  *
281  * Returns: a pointer tothe #Accessible object which contains the given
282  *          #Accessible instance, or NULL if the @obj has no parent container.
283  *
284  **/
285 Accessible *
286 Accessible_getParent (Accessible *obj)
287 {
288   Accessible *retval;
289
290   cspi_return_val_if_fail (obj != NULL, NULL);
291
292   retval = cspi_object_add (
293     Accessibility_Accessible__get_parent (CSPI_OBJREF (obj),
294                                           cspi_ev ()));
295
296   cspi_return_val_if_ev ("getParent", NULL); 
297
298   return retval;
299 }
300
301 /**
302  * Accessible_getChildCount:
303  * @obj: a pointer to the #Accessible object on which to operate.
304  *
305  * Get the number of children contained by an #Accessible object.
306  *
307  * Returns: a #long indicating the number of #Accessible children
308  *          contained by an #Accessible object. or -1 on exception
309  *
310  **/
311 long
312 Accessible_getChildCount (Accessible *obj)
313 {
314   long retval;
315
316   cspi_return_val_if_fail (obj != NULL, -1);
317
318   retval = (long) 
319     Accessibility_Accessible__get_childCount (CSPI_OBJREF (obj),
320                                               cspi_ev ());
321
322   cspi_return_val_if_ev ("getChildCount", -1); 
323
324   return retval;
325 }
326
327 /**
328  * Accessible_getChildAtIndex:
329  * @obj: a pointer to the #Accessible object on which to operate.
330  * @childIndex: a #long indicating which child is specified.
331  *
332  * Get the #Accessible child of an #Accessible object at a given index.
333  *
334  * Returns: a pointer to the #Accessible child object at index
335  *          @childIndex. or NULL on exception
336  **/
337 Accessible *
338 Accessible_getChildAtIndex (Accessible *obj,
339                             long int    childIndex)
340 {
341   Accessible *retval;
342
343   cspi_return_val_if_fail (obj != NULL, NULL);
344
345   retval = cspi_object_add (
346     Accessibility_Accessible_getChildAtIndex (CSPI_OBJREF (obj),
347                                               childIndex, cspi_ev ()));
348
349   return retval;
350 }
351
352 /**
353  * Accessible_getIndexInParent:
354  * @obj: a pointer to the #Accessible object on which to operate.
355  *
356  * Get the index of an #Accessible object in its containing #Accessible.
357  *
358  * Returns: a #long indicating the index of the #Accessible object
359  *          in its parent (i.e. containing) #Accessible instance,
360  *          or -1 if @obj has no containing parent or on exception.
361  **/
362 long
363 Accessible_getIndexInParent (Accessible *obj)
364 {
365   long retval;
366
367   cspi_return_val_if_fail (obj != NULL, -1);
368
369   retval = (long)
370     Accessibility_Accessible_getIndexInParent (CSPI_OBJREF (obj), cspi_ev ());
371
372   cspi_return_val_if_ev ("getIndexInparent", -1); 
373   return retval;
374 }
375
376 /**
377  * Accessible_getRelationSet:
378  * @obj: a pointer to the #Accessible object on which to operate.
379  *
380  * Get the set of #AccessibleRelation objects which describe this #Accessible object's
381  *       relationships with other #Accessible objects.
382  *
383  * Returns: an array of #AccessibleRelation pointers. or NULL on exception
384  **/
385 AccessibleRelation **
386 Accessible_getRelationSet (Accessible *obj)
387 {
388   int i;
389   int n_relations;
390   AccessibleRelation **relations;
391   Accessibility_RelationSet *relation_set;
392
393   cspi_return_val_if_fail (obj != NULL, NULL);
394
395   relation_set =
396     Accessibility_Accessible_getRelationSet (CSPI_OBJREF (obj), cspi_ev ());
397
398   cspi_return_val_if_ev ("getRelationSet", NULL); 
399   
400   /* this looks hack-ish, but it's based on the CORBA C bindings spec */
401   n_relations = relation_set->_length;
402   relations = malloc (sizeof (AccessibleRelation *) * n_relations);
403   
404   for (i = 0; i < n_relations; ++i)
405     {
406       relations[i] = cspi_object_add (CORBA_Object_duplicate (
407               relation_set->_buffer[i], cspi_ev ()));
408     }
409   relations[i] = NULL;
410
411   CORBA_free (relation_set);
412
413   return relations;
414 }
415
416 /**
417  * Accessible_getRole:
418  * @obj: a pointer to the #Accessible object on which to operate.
419  *
420  * Get the UI role of an #Accessible object.
421  * A UTF-8 string describing this role can be obtained via Accessible_getRoleName ().
422  *
423  * Returns: the #AccessibleRole of the object.
424  *
425  **/
426 AccessibleRole
427 Accessible_getRole (Accessible *obj)
428 {
429   AccessibleRole retval;
430
431   cspi_return_val_if_fail (obj != NULL, SPI_ROLE_INVALID);
432
433   retval = 
434     Accessibility_Accessible_getRole (CSPI_OBJREF (obj), cspi_ev ());
435
436   cspi_return_val_if_ev ("getRole", SPI_ROLE_INVALID); 
437
438   return cspi_role_from_spi_role (retval);
439 }
440
441 /**
442  * Accessible_getRoleName:
443  * @obj: a pointer to the #Accessible object on which to operate.
444  *
445  * Get a UTF-8 string describing the role this object plays in the UI.
446  * This method will return useful values for roles that fall outside the
447  * enumeration used in Accessible_getRole ().
448  *
449  * Returns: a UTF-8 string specifying the role of this #Accessible object.
450  *
451  **/
452 char *
453 Accessible_getRoleName (Accessible *obj)
454 {
455   char *retval;
456
457   cspi_return_val_if_fail (obj != NULL, CORBA_string_dup ("invalid"));
458
459   retval = 
460     Accessibility_Accessible_getRoleName (CSPI_OBJREF (obj), cspi_ev ());
461
462   cspi_return_val_if_ev ("getRoleName", CORBA_string_dup ("invalid")); 
463
464   return retval;
465 }
466
467 /**
468  * Accessible_getStateSet:
469  * @obj: a pointer to the #Accessible object on which to operate.
470  *
471  * Not Yet Implemented.
472  *
473  * Returns: a pointer to an #AccessibleStateSet representing the object's current state.
474  **/
475 AccessibleStateSet *
476 Accessible_getStateSet (Accessible *obj)
477 {
478   return NULL;
479 }
480
481 /* Interface query methods */
482
483 /**
484  * Accessible_isAction:
485  * @obj: a pointer to the #Accessible instance to query.
486  *
487  * Query whether the specified #Accessible implements #AccessibleAction.
488  *
489  * Returns: #TRUE if @obj implements the #AccessibleAction interface,
490  *          #FALSE otherwise.
491  **/
492 SPIBoolean
493 Accessible_isAction (Accessible *obj)
494 {
495   return cspi_accessible_is_a (obj,
496                               "IDL:Accessibility/Action:1.0");
497 }
498
499 /**
500  * Accessible_isApplication:
501  * @obj: a pointer to the #Accessible instance to query.
502  *
503  * Query whether the specified #Accessible implements #AccessibleApplication.
504  *
505  * Returns: #TRUE if @obj implements the #AccessibleApplication interface,
506  *          #FALSE otherwise.
507  **/
508 SPIBoolean
509 Accessible_isApplication (Accessible *obj)
510 {
511   return cspi_accessible_is_a (obj,
512                               "IDL:Accessibility/Application:1.0");
513 }
514
515 /**
516  * Accessible_isComponent:
517  * @obj: a pointer to the #Accessible instance to query.
518  *
519  * Query whether the specified #Accessible implements #AccessibleComponent.
520  *
521  * Returns: #TRUE if @obj implements the #AccessibleComponent interface,
522  *          #FALSE otherwise.
523  **/
524 SPIBoolean
525 Accessible_isComponent (Accessible *obj)
526 {
527   return cspi_accessible_is_a (obj,
528                               "IDL:Accessibility/Component:1.0");
529 }
530
531 /**
532  * Accessible_isEditableText:
533  * @obj: a pointer to the #Accessible instance to query.
534  *
535  * Query whether the specified #Accessible implements #AccessibleEditableText.
536  *
537  * Returns: #TRUE if @obj implements the #AccessibleEditableText interface,
538  *          #FALSE otherwise.
539  **/
540 SPIBoolean
541 Accessible_isEditableText (Accessible *obj)
542 {
543   return cspi_accessible_is_a (obj,
544                               "IDL:Accessibility/EditableText:1.0");
545 }
546
547 /**
548  * Accessible_isHypertext:
549  * @obj: a pointer to the #Accessible instance to query.
550  *
551  * Query whether the specified #Accessible implements #AccessibleHypertext.
552  *
553  * Returns: #TRUE if @obj implements the #AccessibleHypertext interface,
554  *          #FALSE otherwise.
555  **/
556 SPIBoolean
557 Accessible_isHypertext (Accessible *obj)
558 {
559   return cspi_accessible_is_a (obj,
560                               "IDL:Accessibility/Hypertext:1.0");
561 }
562
563 /**
564  * Accessible_isImage:
565  * @obj: a pointer to the #Accessible instance to query.
566  *
567  * Query whether the specified #Accessible implements #AccessibleImage.
568  *
569  * Returns: #TRUE if @obj implements the #AccessibleImage interface,
570  *          #FALSE otherwise.
571 **/
572 SPIBoolean
573 Accessible_isImage (Accessible *obj)
574 {
575   return cspi_accessible_is_a (obj,
576                               "IDL:Accessibility/Image:1.0");
577 }
578
579 /**
580  * Accessible_isSelection:
581  * @obj: a pointer to the #Accessible instance to query.
582  *
583  * Query whether the specified #Accessible implements #AccessibleSelection.
584  *
585  * Returns: #TRUE if @obj implements the #AccessibleSelection interface,
586  *          #FALSE otherwise.
587 **/
588 SPIBoolean
589 Accessible_isSelection (Accessible *obj)
590 {
591   return cspi_accessible_is_a (obj,
592                               "IDL:Accessibility/Selection:1.0");
593 }
594
595 /**
596  * Accessible_isTable:
597  * @obj: a pointer to the #Accessible instance to query.
598  *
599  * Query whether the specified #Accessible implements #AccessibleTable.
600  *
601  * Returns: #TRUE if @obj implements the #AccessibleTable interface,
602  *          #FALSE otherwise.
603 **/
604 SPIBoolean
605 Accessible_isTable (Accessible *obj)
606 {
607   return cspi_accessible_is_a (obj,
608                               "IDL:Accessibility/Table:1.0");
609 }
610
611 /**
612  * Accessible_isStreamableContent:
613  * @obj: a pointer to the #Accessible instance to query.
614  *
615  * Query whether the specified #Accessible implements
616  *          #AccessibleStreamableContent.
617  *
618  * Returns: #TRUE if @obj implements the #AccessibleStreamableContent interface,
619  *          #FALSE otherwise.
620 **/
621 SPIBoolean
622 Accessible_isStreamableContent (Accessible *obj)
623 {
624   return cspi_accessible_is_a (obj,
625                               "IDL:Accessibility/StreamableContent:1.0");
626 }
627
628 /**
629  * Accessible_isText:
630  * @obj: a pointer to the #Accessible instance to query.
631  *
632  * Query whether the specified #Accessible implements #AccessibleText.
633  *
634  * Returns: #TRUE if @obj implements the #AccessibleText interface,
635  *          #FALSE otherwise.
636 **/
637 SPIBoolean
638 Accessible_isText (Accessible *obj)
639 {
640   return cspi_accessible_is_a (obj,
641                               "IDL:Accessibility/Text:1.0");
642 }
643
644 /**
645  * Accessible_isValue:
646  * @obj: a pointer to the #Accessible instance to query.
647  *
648  * Query whether the specified #Accessible implements #AccessibleValue.
649  *
650  * Returns: #TRUE if @obj implements the #AccessibleValue interface,
651  *          #FALSE otherwise.
652 **/
653 SPIBoolean
654 Accessible_isValue (Accessible *obj)
655 {
656   return cspi_accessible_is_a (obj,
657                               "IDL:Accessibility/Value:1.0");
658 }
659
660 /**
661  * Accessible_getApplication:
662  * @obj: a pointer to the #Accessible instance to query.
663  *
664  * Get the #AccessibleApplication interface for an #Accessible.
665  *
666  * Returns: a pointer to an #AccessibleApplication interface instance, or
667  *          NULL if @obj does not implement #AccessibleApplication.
668  **/
669 AccessibleApplication *
670 Accessible_getApplication (Accessible *obj)
671 {
672   return (AccessibleApplication *) Accessible_queryInterface (
673           obj, "IDL:Accessibility/Application:1.0");
674 }
675
676 /**
677  * Accessible_getAction:
678  * @obj: a pointer to the #Accessible instance to query.
679  *
680  * Get the #AccessibleAction interface for an #Accessible.
681  *
682  * Returns: a pointer to an #AccessibleAction interface instance, or
683  *          NULL if @obj does not implement #AccessibleAction.
684  **/
685 AccessibleAction *
686 Accessible_getAction (Accessible *obj)
687 {
688   return (AccessibleAction *) Accessible_queryInterface (
689           obj, "IDL:Accessibility/Action:1.0");
690 }
691
692 /**
693  * Accessible_getComponent:
694  * @obj: a pointer to the #Accessible instance to query.
695  *
696  * Get the #AccessibleComponent interface for an #Accessible.
697  *
698  * Returns: a pointer to an #AccessibleComponent interface instance, or
699  *          NULL if @obj does not implement #AccessibleComponent.
700  **/
701 AccessibleComponent *
702 Accessible_getComponent (Accessible *obj)
703 {
704   return (AccessibleComponent *) Accessible_queryInterface (
705           obj, "IDL:Accessibility/Component:1.0");
706 }
707
708 /**
709  * Accessible_getEditableText:
710  * @obj: a pointer to the #Accessible instance to query.
711  *
712  * Get the #AccessibleEditableText interface for an #Accessible.
713  *
714  * Returns: a pointer to an #AccessibleEditableText interface instance, or
715  *          NULL if @obj does not implement #AccessibleEditableText.
716  **/
717 AccessibleEditableText *
718 Accessible_getEditableText (Accessible *obj)
719 {
720   return (AccessibleEditableText *) Accessible_queryInterface (
721           obj, "IDL:Accessibility/EditableText:1.0");
722 }
723
724
725
726 /**
727  * Accessible_getHypertext:
728  * @obj: a pointer to the #Accessible instance to query.
729  *
730  * Get the #AccessibleHypertext interface for an #Accessible.
731  *
732  * Returns: a pointer to an #AccessibleHypertext interface instance, or
733  *          NULL if @obj does not implement #AccessibleHypertext.
734  **/
735 AccessibleHypertext *
736 Accessible_getHypertext (Accessible *obj)
737 {
738   return (AccessibleHypertext *) Accessible_queryInterface (
739           obj, "IDL:Accessibility/Hypertext:1.0");
740 }
741
742
743
744 /**
745  * Accessible_getImage:
746  * @obj: a pointer to the #Accessible instance to query.
747  *
748  * Get the #AccessibleImage interface for an #Accessible.
749  *
750  * Returns: a pointer to an #AccessibleImage interface instance, or
751  *          NULL if @obj does not implement #AccessibleImage.
752  **/
753 AccessibleImage *
754 Accessible_getImage (Accessible *obj)
755 {
756   return (AccessibleImage *) Accessible_queryInterface (
757           obj, "IDL:Accessibility/Image:1.0");
758 }
759
760
761
762 /**
763  * Accessible_getSelection:
764  * @obj: a pointer to the #Accessible instance to query.
765  *
766  * Get the #AccessibleSelection interface for an #Accessible.
767  *
768  * Returns: a pointer to an #AccessibleSelection interface instance, or
769  *          NULL if @obj does not implement #AccessibleSelection.
770  **/
771 AccessibleSelection *
772 Accessible_getSelection (Accessible *obj)
773 {
774   return (AccessibleSelection *) Accessible_queryInterface (
775           obj, "IDL:Accessibility/Selection:1.0");
776 }
777
778
779
780 /**
781  * Accessible_getStreamableContent:
782  * @obj: a pointer to the #Accessible instance to query.
783  *
784  * Get the #AccessibleStreamableContent interface for an #Accessible.
785  *
786  * Returns: a pointer to an #AccessibleStreamableContent interface instance, or
787  *          NULL if @obj does not implement #AccessibleStreamableContent.
788  **/
789 AccessibleStreamableContent *
790 Accessible_getStreamableContent (Accessible *obj)
791 {
792   return (AccessibleStreamableContent *) Accessible_queryInterface (
793           obj, "IDL:Accessibility/StreamableContent:1.0");
794 }
795
796 /**
797  * Accessible_getTable:
798  * @obj: a pointer to the #Accessible instance to query.
799  *
800  * Get the #AccessibleTable interface for an #Accessible.
801  *
802  * Returns: a pointer to an #AccessibleTable interface instance, or
803  *          NULL if @obj does not implement #AccessibleTable.
804  **/
805 AccessibleTable *
806 Accessible_getTable (Accessible *obj)
807 {
808   return (AccessibleTable *) Accessible_queryInterface (
809           obj, "IDL:Accessibility/Table:1.0");
810 }
811
812 /**
813  * Accessible_getText:
814  * @obj: a pointer to the #Accessible instance to query.
815  *
816  * Get the #AccessibleText interface for an #Accessible.
817  *
818  * Returns: a pointer to an #AccessibleText interface instance, or
819  *          NULL if @obj does not implement #AccessibleText.
820  **/
821 AccessibleText *
822 Accessible_getText (Accessible *obj)
823 {
824   return (AccessibleText *) Accessible_queryInterface (
825           obj, "IDL:Accessibility/Text:1.0");
826 }
827
828
829
830 /**
831  * Accessible_getValue:
832  * @obj: a pointer to the #Accessible instance to query.
833  *
834  * Get the #AccessibleValue interface for an #Accessible.
835  *
836  * Returns: a pointer to an #AccessibleValue interface instance, or
837  *          NULL if @obj does not implement #AccessibleValue.
838  **/
839 AccessibleValue *
840 Accessible_getValue (Accessible *obj)
841 {
842   return (AccessibleValue *) Accessible_queryInterface (
843           obj, "IDL:Accessibility/Value:1.0");
844 }
845
846
847
848 /**
849  * Accessible_queryInterface:
850  * @obj: a pointer to the #Accessible instance to query.
851  * @interface_name: a UTF-8 character string specifiying the requested interface.
852  *
853  * Query an #Accessible object to for a named interface.
854  *
855  * Returns: an instance of the named interface object, if it is implemented
856  *          by @obj, or NULL otherwise.
857  *
858  **/
859 AccessibleUnknown *
860 Accessible_queryInterface (Accessible *obj,
861                            const char *interface_name)
862 {
863   Bonobo_Unknown iface;
864   
865   if (!obj)
866     {
867       return NULL;
868     }
869
870   iface = Accessibility_Accessible_queryInterface (CSPI_OBJREF (obj),
871                                                    interface_name,
872                                                    cspi_ev ());
873
874
875   cspi_return_val_if_ev ("queryInterface", NULL); 
876
877   /*
878    * FIXME: we need to be fairly sure that references are going
879    * to mach up if we are going to expose QueryInterface, ie. we
880    * can't allow people to do:
881    * b = a.qi ("b"); b.unref, b.unref to release a's reference.
882    * this should be no real problem though for this level of API
883    * user.
884    */
885
886   return cspi_object_add (iface);
887 }
888
889
890 /**
891  * AccessibleRelation_ref:
892  * @obj: a pointer to the #AccessibleRelation object on which to operate.
893  *
894  * Increment the reference count for an #AccessibleRelation object.
895  *
896  **/
897 void
898 AccessibleRelation_ref (AccessibleRelation *obj)
899 {
900   cspi_object_ref (obj);
901 }
902
903 /**
904  * AccessibleRelation_unref:
905  * @obj: a pointer to the #AccessibleRelation object on which to operate.
906  *
907  * Decrement the reference count for an #AccessibleRelation object.
908  *
909  **/
910 void
911 AccessibleRelation_unref (AccessibleRelation *obj)
912 {
913   cspi_object_unref (obj);
914 }
915
916 /**
917  * AccessibleRelation_getRelationType:
918  * @obj: a pointer to the #AccessibleRelation object to query.
919  *
920  * Get the type of relationship represented by an #AccessibleRelation.
921  *
922  * Returns: an #AccessibleRelationType indicating the type of relation
923  *         encapsulated in this #AccessibleRelation object.
924  *
925  **/
926 AccessibleRelationType
927 AccessibleRelation_getRelationType (AccessibleRelation *obj)
928 {
929   AccessibleRelationType retval;
930   
931   cspi_return_val_if_fail (obj, SPI_RELATION_NULL);
932   retval =
933     Accessibility_Relation_getRelationType (CSPI_OBJREF (obj), cspi_ev());
934   cspi_return_val_if_ev ("getRelationType", SPI_RELATION_NULL);
935   return retval;
936 }
937
938 /**
939  * AccessibleRelation_getNTargets:
940  * @obj: a pointer to the #AccessibleRelation object to query.
941  *
942  * Get the number of objects which this relationship has as its
943  *       target objects (the subject is the #Accessible from which this
944  *       #AccessibleRelation originated).
945  *
946  * Returns: a short integer indicating how many target objects which the
947  *       originating #Accessible object has the #AccessibleRelation
948  *       relationship with.
949  **/
950 int
951 AccessibleRelation_getNTargets (AccessibleRelation *obj)
952 {
953   int retval;
954   
955   cspi_return_val_if_fail (obj, -1);
956   retval = (int)
957     Accessibility_Relation_getNTargets (CSPI_OBJREF (obj), cspi_ev());
958   cspi_return_val_if_ev ("getNTargets", -1);
959   return retval;
960 }
961
962 /**
963  * AccessibleRelation_getTarget:
964  * @obj: a pointer to the #AccessibleRelation object to query.
965  * @i: a (zero-index) integer indicating which (of possibly several) target is requested.
966  *
967  * Get the @i-th target of a specified #AccessibleRelation relationship.
968  *
969  * Returns: an #Accessible which is the @i-th object with which the
970  *      originating #Accessible has relationship specified in the
971  *      #AccessibleRelation object.
972  *
973  **/
974 Accessible *
975 AccessibleRelation_getTarget (AccessibleRelation *obj, int i)
976 {
977   Accessible *retval;
978
979   cspi_return_val_if_fail (obj, NULL);
980
981   retval = cspi_object_add (
982                          Accessibility_Relation_getTarget (CSPI_OBJREF(obj),
983                                                            (CORBA_short) i, cspi_ev()));
984   cspi_return_val_if_ev ("getTarget", NULL);
985   return retval;
986 }
987
988 /**
989  * AccessibleStateSet_ref:
990  * @obj: a pointer to the #AccessibleStateSet object on which to operate.
991  *
992  * Increment the reference count for an #AccessibleStateSet object.
993  *
994  **/
995 void
996 AccessibleStateSet_ref (AccessibleStateSet *obj)
997 {
998   cspi_object_ref (obj);
999 }
1000
1001 /**
1002  * AccessibleStateSet_unref:
1003  * @obj: a pointer to the #AccessibleStateSet object on which to operate.
1004  *
1005  * Decrement the reference count for an #AccessibleStateSet object.
1006  *
1007  **/
1008 void
1009 AccessibleStateSet_unref (AccessibleStateSet *obj)
1010 {
1011   cspi_object_unref (obj);
1012 }
1013
1014 /**
1015  * AccessibleStateSet_contains:
1016  * @obj: a pointer to the #AccessibleStateSet object on which to operate.
1017  * @state: an #AccessibleState for which the specified #AccessibleStateSet
1018  *       will be queried.
1019  *
1020  * Determine whether a given #AccessibleStateSet includes a given state; that is,
1021  *       whether @state is true for the stateset in question.
1022  *
1023  * Returns: #TRUE if @state is true/included in the given #AccessibleStateSet,
1024  *          otherwise #FALSE.
1025  *
1026  **/
1027 SPIBoolean
1028 AccessibleStateSet_contains (AccessibleStateSet *obj,
1029                              AccessibleState state)
1030 {
1031   CORBA_boolean retval;
1032
1033   cspi_return_val_if_fail (obj != NULL, FALSE);
1034
1035   retval = Accessibility_StateSet_contains (CSPI_OBJREF (obj),
1036                                             state, cspi_ev ());
1037
1038   cspi_return_val_if_ev ("contains", FALSE);
1039
1040   return (SPIBoolean) retval;
1041 }
1042
1043 /**
1044  * AccessibleStateSet_add:
1045  * @obj: a pointer to the #AccessibleStateSet object on which to operate.
1046  * @state: an #AccessibleState to be added to the specified #AccessibleStateSet
1047  *
1048  * Add a particular #AccessibleState to an #AccessibleStateSet (i.e. set the
1049  *       given state to #TRUE in the stateset.
1050  *
1051  **/
1052 void
1053 AccessibleStateSet_add (AccessibleStateSet *obj,
1054                         AccessibleState state)
1055 {
1056   cspi_return_if_fail (obj != NULL);
1057
1058   Accessibility_StateSet_add (CSPI_OBJREF (obj), state, cspi_ev ());
1059   cspi_check_ev ("add");
1060 }
1061
1062 /**
1063  * AccessibleStateSet_remove:
1064  * @obj: a pointer to the #AccessibleStateSet object on which to operate.
1065  * @state: an #AccessibleState to be removed from the specified #AccessibleStateSet
1066  *
1067  * Remove a particular #AccessibleState to an #AccessibleStateSet (i.e. set the
1068  *       given state to #FALSE in the stateset.)
1069  *
1070  **/
1071 void
1072 AccessibleStateSet_remove (AccessibleStateSet *obj,
1073                            AccessibleState state)
1074 {
1075   cspi_return_if_fail (obj != NULL);
1076
1077   Accessibility_StateSet_remove (CSPI_OBJREF (obj), state, cspi_ev ());
1078   cspi_check_ev ("remove");
1079 }
1080
1081 /**
1082  * AccessibleStateSet_equals:
1083  * @obj: a pointer to the first #AccessibleStateSet object on which to operate.
1084  * @obj2: a pointer to the second #AccessibleStateSet object on which to operate.
1085  *
1086  * Determine whether two instances of #AccessibleStateSet are equivalent (i.e.
1087  *         consist of the same #AccessibleStates).  Useful for checking multiple
1088  *         state variables at once; construct the target state then compare against it.
1089  *
1090  * @see AccessibleStateSet_compare().
1091  *
1092  * Returns: #TRUE if the two #AccessibleStateSets are equivalent,
1093  *          otherwise #FALSE.
1094  *
1095  **/
1096 SPIBoolean
1097 AccessibleStateSet_equals (AccessibleStateSet *obj,
1098                            AccessibleStateSet *obj2)
1099 {
1100   if (obj == obj2)
1101     {
1102       return TRUE;
1103     }
1104
1105   cspi_return_val_if_fail (obj != NULL, FALSE);
1106   cspi_return_val_if_fail (obj2 != NULL, FALSE);
1107
1108   return Accessibility_StateSet_equals (CSPI_OBJREF (obj),
1109                                         CSPI_OBJREF (obj2), cspi_ev ());
1110 }
1111
1112 /**
1113  * AccessibleStateSet_compare:
1114  * @obj: a pointer to the first #AccessibleStateSet object on which to operate.
1115  * @obj2: a pointer to the second #AccessibleStateSet object on which to operate.
1116  *
1117  * Determine the differences between two instances of #AccessibleStateSet.
1118  * Not Yet Implemented.
1119  *.
1120  * @see AccessibleStateSet_equals().
1121  *
1122  * Returns: an #AccessibleStateSet object containing all states contained on one of
1123  *          the two sets but not the other.
1124  *
1125  **/
1126 AccessibleStateSet *
1127 AccessibleStateSet_compare (AccessibleStateSet *obj,
1128                             AccessibleStateSet *obj2)
1129 {
1130   cspi_return_val_if_fail (obj != NULL, NULL);
1131   cspi_return_val_if_fail (obj2 != NULL, NULL);
1132   return NULL;  
1133 }
1134
1135 /**
1136  * AccessibleStateSet_isEmpty:
1137  * @obj: a pointer to the #AccessibleStateSet object on which to operate.
1138  *
1139  * Determine whether a given #AccessibleStateSet is the empty set.
1140  *
1141  * Returns: #TRUE if the given #AccessibleStateSet contains no (true) states,
1142  *          otherwise #FALSE.
1143  *
1144  **/
1145 SPIBoolean
1146 AccessibleStateSet_isEmpty (AccessibleStateSet *obj)
1147 {
1148   cspi_return_val_if_fail (obj != NULL, FALSE);
1149   return TRUE;  
1150   /*  return Accessibility_StateSet_isEmpty (CSPI_OBJREF (obj), cspi_ev ());*/
1151 }
1152
1153