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