c59ba1c74da355690b26363ff6142cb5400fe23b
[platform/core/uifw/at-spi2-atk.git] / cspi / spi_accessible.c
1 /*
2  * AT-SPI - Assistive Technology Service Provider Interface
3  * (Gnome Accessibility Project; http://developer.gnome.org/projects/gap)
4  *
5  * Copyright 2001, 2002 Sun Microsystems Inc.,
6  * Copyright 2001, 2002 Ximian, Inc.
7  *
8  * This library is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU Library General Public
10  * License as published by the Free Software Foundation; either
11  * version 2 of the License, or (at your option) any later version.
12  *
13  * This library is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16  * Library General Public License for more details.
17  *
18  * You should have received a copy of the GNU Library General Public
19  * License along with this library; if not, write to the
20  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
21  * Boston, MA 02111-1307, USA.
22  */
23
24 #include <stdlib.h> /* for malloc */
25 #include <libspi/stateset.h>
26 #include <cspi/spi-private.h>
27
28 static const char *role_names [] =
29 {
30   "invalid",
31   "accel-label",
32   "alert",
33   "animation",
34   "arrow",
35   "calendar",
36   "canvas",
37   "check-box",
38   "check-menu-item",
39   "color-chooser",
40   "column-header",
41   "combo-box",
42   "date-editor",
43   "desktop-icon",
44   "desktop-frame",
45   "dial",
46   "dialog",
47   "directory-pane",
48   "drawing-area",
49   "file-chooser",
50   "filler",
51   "font-chooser",
52   "frame",
53   "glass-pane",
54   "html-container",
55   "icon",
56   "image",
57   "internalframe",
58   "label",
59   "layered-pane",
60   "list",
61   "list-item",
62   "menu",
63   "menu-bar",
64   "menu-item",
65   "option-pane",
66   "page-tab",
67   "page-tab-list",
68   "panel",
69   "password-text",
70   "popup-menu",
71   "progress-bar",
72   "push-button",
73   "radio-button",
74   "radio-menu-item",
75   "root-pane",
76   "row-header",
77   "scroll-bar",
78   "scroll-pane",
79   "separator",
80   "slider",
81   "spin-button",
82   "split-pane",
83   "statusbar",
84   "table",
85   "table-cell",
86   "table-column-header",
87   "table-row-header",
88   "tear-off-menu-item",
89   "terminal",
90   "text",
91   "toggle-button",
92   "tool-bar",
93   "tool-tip",
94   "tree",
95   "tree-table",
96   "unknown",
97   "viewport",
98   "window",
99   NULL,
100   "header",
101   "fooler",
102   "paragraph",
103   "ruler",
104   "application",
105   "autocomplete",
106   "editbar",
107   "embedded",
108   "entry",
109   "chart",
110   "caption",
111   "document_frame",
112   "heading",
113   "page",
114   "section",
115   "form",
116   "redundant object",
117   "link",
118   "input method window"
119 };
120
121 #define MAX_ROLES (sizeof (role_names) / sizeof (char *))
122
123 static SPIBoolean
124 cspi_init_role_table (AccessibleRole *role_table)
125 {
126   int i;
127   for (i = 0; i < Accessibility_ROLE_LAST_DEFINED; ++i)
128     {
129       role_table [i] = SPI_ROLE_UNKNOWN;
130     }
131   role_table [Accessibility_ROLE_INVALID] = SPI_ROLE_INVALID;
132   role_table [Accessibility_ROLE_ACCELERATOR_LABEL] = SPI_ROLE_ACCEL_LABEL;
133   role_table [Accessibility_ROLE_ALERT] = SPI_ROLE_ALERT;
134   role_table [Accessibility_ROLE_ANIMATION] = SPI_ROLE_ANIMATION;
135   role_table [Accessibility_ROLE_ARROW] = SPI_ROLE_ARROW;
136   role_table [Accessibility_ROLE_CALENDAR] = SPI_ROLE_CALENDAR;
137   role_table [Accessibility_ROLE_CANVAS] = SPI_ROLE_CANVAS;
138   role_table [Accessibility_ROLE_CHECK_BOX] = SPI_ROLE_CHECK_BOX;
139   role_table [Accessibility_ROLE_CHECK_MENU_ITEM] = SPI_ROLE_CHECK_MENU_ITEM;
140   role_table [Accessibility_ROLE_COLOR_CHOOSER] = SPI_ROLE_COLOR_CHOOSER;
141   role_table [Accessibility_ROLE_COLUMN_HEADER] = SPI_ROLE_COLUMN_HEADER;
142   role_table [Accessibility_ROLE_COMBO_BOX] = SPI_ROLE_COMBO_BOX;
143   role_table [Accessibility_ROLE_DATE_EDITOR] = SPI_ROLE_DATE_EDITOR;
144   role_table [Accessibility_ROLE_DESKTOP_ICON] = SPI_ROLE_DESKTOP_ICON;
145   role_table [Accessibility_ROLE_DESKTOP_FRAME] = SPI_ROLE_DESKTOP_FRAME;
146   role_table [Accessibility_ROLE_DIAL] = SPI_ROLE_DIAL;
147   role_table [Accessibility_ROLE_DIALOG] = SPI_ROLE_DIALOG;
148   role_table [Accessibility_ROLE_DIRECTORY_PANE] = SPI_ROLE_DIRECTORY_PANE;
149   role_table [Accessibility_ROLE_DRAWING_AREA] = SPI_ROLE_DRAWING_AREA;
150   role_table [Accessibility_ROLE_FILE_CHOOSER] = SPI_ROLE_FILE_CHOOSER;
151   role_table [Accessibility_ROLE_FILLER] = SPI_ROLE_FILLER;
152   role_table [Accessibility_ROLE_FONT_CHOOSER] = SPI_ROLE_FONT_CHOOSER;
153   role_table [Accessibility_ROLE_FRAME] = SPI_ROLE_FRAME;
154   role_table [Accessibility_ROLE_GLASS_PANE] = SPI_ROLE_GLASS_PANE;
155   role_table [Accessibility_ROLE_HTML_CONTAINER] = SPI_ROLE_HTML_CONTAINER;
156   role_table [Accessibility_ROLE_ICON] = SPI_ROLE_ICON;
157   role_table [Accessibility_ROLE_IMAGE] = SPI_ROLE_IMAGE;
158   role_table [Accessibility_ROLE_INTERNAL_FRAME] = SPI_ROLE_INTERNAL_FRAME;
159   role_table [Accessibility_ROLE_LABEL] = SPI_ROLE_LABEL;
160   role_table [Accessibility_ROLE_LAYERED_PANE] = SPI_ROLE_LAYERED_PANE;
161   role_table [Accessibility_ROLE_LIST] = SPI_ROLE_LIST;
162   role_table [Accessibility_ROLE_LIST_ITEM] = SPI_ROLE_LIST_ITEM;
163   role_table [Accessibility_ROLE_MENU] = SPI_ROLE_MENU;
164   role_table [Accessibility_ROLE_MENU_BAR] = SPI_ROLE_MENU_BAR;
165   role_table [Accessibility_ROLE_MENU_ITEM] = SPI_ROLE_MENU_ITEM;
166   role_table [Accessibility_ROLE_OPTION_PANE] = SPI_ROLE_OPTION_PANE;
167   role_table [Accessibility_ROLE_PAGE_TAB] = SPI_ROLE_PAGE_TAB;
168   role_table [Accessibility_ROLE_PAGE_TAB_LIST] = SPI_ROLE_PAGE_TAB_LIST;
169   role_table [Accessibility_ROLE_PANEL] = SPI_ROLE_PANEL;
170   role_table [Accessibility_ROLE_PASSWORD_TEXT] = SPI_ROLE_PASSWORD_TEXT;
171   role_table [Accessibility_ROLE_POPUP_MENU] = SPI_ROLE_POPUP_MENU;
172   role_table [Accessibility_ROLE_PROGRESS_BAR] = SPI_ROLE_PROGRESS_BAR;
173   role_table [Accessibility_ROLE_PUSH_BUTTON] = SPI_ROLE_PUSH_BUTTON;
174   role_table [Accessibility_ROLE_RADIO_BUTTON] = SPI_ROLE_RADIO_BUTTON;
175   role_table [Accessibility_ROLE_RADIO_MENU_ITEM] = SPI_ROLE_RADIO_MENU_ITEM;
176   role_table [Accessibility_ROLE_ROOT_PANE] = SPI_ROLE_ROOT_PANE;
177   role_table [Accessibility_ROLE_ROW_HEADER] = SPI_ROLE_ROW_HEADER;
178   role_table [Accessibility_ROLE_SCROLL_BAR] = SPI_ROLE_SCROLL_BAR;
179   role_table [Accessibility_ROLE_SCROLL_PANE] = SPI_ROLE_SCROLL_PANE;
180   role_table [Accessibility_ROLE_SEPARATOR] = SPI_ROLE_SEPARATOR;
181   role_table [Accessibility_ROLE_SLIDER] = SPI_ROLE_SLIDER;
182   role_table [Accessibility_ROLE_SPIN_BUTTON] = SPI_ROLE_SPIN_BUTTON;
183   role_table [Accessibility_ROLE_SPLIT_PANE] = SPI_ROLE_SPLIT_PANE;
184   role_table [Accessibility_ROLE_STATUS_BAR] = SPI_ROLE_STATUS_BAR;
185   role_table [Accessibility_ROLE_TABLE] = SPI_ROLE_TABLE;
186   role_table [Accessibility_ROLE_TABLE_CELL] = SPI_ROLE_TABLE_CELL;
187   role_table[Accessibility_ROLE_TABLE_COLUMN_HEADER] = SPI_ROLE_TABLE_COLUMN_HEADER;
188   role_table[Accessibility_ROLE_TABLE_ROW_HEADER] = SPI_ROLE_TABLE_ROW_HEADER;
189   role_table [Accessibility_ROLE_TEAROFF_MENU_ITEM] = SPI_ROLE_TEAROFF_MENU_ITEM;
190   role_table[Accessibility_ROLE_TERMINAL] = SPI_ROLE_TERMINAL;
191   role_table [Accessibility_ROLE_TEXT] = SPI_ROLE_TEXT;
192   role_table [Accessibility_ROLE_TOGGLE_BUTTON] = SPI_ROLE_TOGGLE_BUTTON;
193   role_table [Accessibility_ROLE_TOOL_BAR] = SPI_ROLE_TOOL_BAR;
194   role_table [Accessibility_ROLE_TOOL_TIP] = SPI_ROLE_TOOL_TIP;
195   role_table [Accessibility_ROLE_TREE] = SPI_ROLE_TREE;
196   role_table [Accessibility_ROLE_TREE_TABLE] = SPI_ROLE_TREE_TABLE;
197   role_table [Accessibility_ROLE_VIEWPORT] = SPI_ROLE_VIEWPORT;
198   role_table [Accessibility_ROLE_WINDOW] = SPI_ROLE_WINDOW;
199   role_table [Accessibility_ROLE_EXTENDED] = SPI_ROLE_EXTENDED;
200   role_table [Accessibility_ROLE_HEADER] = SPI_ROLE_HEADER;
201   role_table [Accessibility_ROLE_FOOTER] = SPI_ROLE_FOOTER;
202   role_table [Accessibility_ROLE_PARAGRAPH] = SPI_ROLE_PARAGRAPH;
203   role_table [Accessibility_ROLE_RULER] = SPI_ROLE_RULER;
204   role_table [Accessibility_ROLE_APPLICATION] = SPI_ROLE_APPLICATION;
205   role_table [Accessibility_ROLE_AUTOCOMPLETE] = SPI_ROLE_AUTOCOMPLETE;
206   role_table [Accessibility_ROLE_EDITBAR] = SPI_ROLE_EDITBAR;
207   role_table [Accessibility_ROLE_EMBEDDED] = SPI_ROLE_EMBEDDED;
208   role_table [Accessibility_ROLE_ENTRY] = SPI_ROLE_ENTRY;
209   role_table [Accessibility_ROLE_CHART] = SPI_ROLE_CHART;
210   role_table [Accessibility_ROLE_CAPTION] = SPI_ROLE_CAPTION;
211   role_table [Accessibility_ROLE_DOCUMENT_FRAME] = SPI_ROLE_DOCUMENT_FRAME;
212   role_table [Accessibility_ROLE_HEADING] = SPI_ROLE_HEADING;
213   role_table [Accessibility_ROLE_PAGE] = SPI_ROLE_PAGE;
214   role_table [Accessibility_ROLE_SECTION] = SPI_ROLE_SECTION;
215   role_table [Accessibility_ROLE_FORM] = SPI_ROLE_FORM;
216   role_table [Accessibility_ROLE_REDUNDANT_OBJECT] = SPI_ROLE_REDUNDANT_OBJECT;
217   role_table [Accessibility_ROLE_LINK] = SPI_ROLE_LINK;
218   role_table [Accessibility_ROLE_INPUT_METHOD_WINDOW] = SPI_ROLE_INPUT_METHOD_WINDOW;
219
220   return TRUE;
221 }
222
223 AccessibleRole
224 cspi_role_from_spi_role (Accessibility_Role role)
225 {
226   /* array is sized according to IDL roles because IDL roles are the index */   
227   static AccessibleRole cspi_role_table [Accessibility_ROLE_LAST_DEFINED];
228   static SPIBoolean is_initialized = FALSE;
229   AccessibleRole cspi_role;
230   if (!is_initialized)
231     {
232       is_initialized = cspi_init_role_table (cspi_role_table);      
233     }
234   if (role >= 0 && role < Accessibility_ROLE_LAST_DEFINED)
235     {
236       cspi_role = cspi_role_table [role];           
237     }
238   else
239     {
240       cspi_role = SPI_ROLE_EXTENDED;
241     }
242   return cspi_role; 
243 }
244
245 AccessibleAttributeSet *
246 _cspi_attribute_set_from_sequence (const Accessibility_AttributeSet *seq)
247 {
248     AccessibleAttributeSet *set = g_new0 (AccessibleAttributeSet, 1);
249     int i;
250
251     set->len = seq->_length;
252     set->attributes = g_newa (char *, set->len);
253     for (i = 0; i < set->len; ++i)
254     {
255         set->attributes[i] = g_strdup (seq->_buffer [i]);
256     }
257     return set;
258 }
259
260 /**
261  * AccessibleRole_getName:
262  * @role: an #AccessibleRole object to query.
263  *
264  * Get a localizeable string that indicates the name of an #AccessibleRole.
265  * <em>DEPRECATED.</em>
266  *
267  * Returns: a localizable string name for an #AccessibleRole enumerated type.
268  **/
269 char *
270 AccessibleRole_getName (AccessibleRole role)
271 {
272   if (role < MAX_ROLES && role_names [(int) role])
273     {
274       return CORBA_string_dup (role_names [(int) role]);
275     }
276   else
277     {
278       return CORBA_string_dup ("");
279     }
280 }
281
282 /**
283  * Accessible_ref:
284  * @obj: a pointer to the #Accessible object on which to operate.
285  *
286  * Increment the reference count for an #Accessible object.
287  **/
288 void
289 Accessible_ref (Accessible *obj)
290 {
291   cspi_object_ref (obj);
292 }
293
294 /**
295  * Accessible_unref:
296  * @obj: a pointer to the #Accessible object on which to operate.
297  *
298  * Decrement the reference count for an #Accessible object.
299  **/
300 void
301 Accessible_unref (Accessible *obj)
302 {
303   cspi_object_unref (obj);
304 }
305
306 /**
307  * Accessible_getName:
308  * @obj: a pointer to the #Accessible object on which to operate.
309  *
310  * Get the name of an #Accessible object.
311  *
312  * Returns: a UTF-8 string indicating the name of the #Accessible object.
313  * or NULL on exception
314  **/
315 char *
316 Accessible_getName (Accessible *obj)
317 {
318   char *retval;
319
320   cspi_return_val_if_fail (obj != NULL, NULL);
321
322   retval = Accessibility_Accessible__get_name (CSPI_OBJREF (obj), cspi_ev ());
323
324   cspi_return_val_if_ev ("getName", NULL); 
325
326   return retval;
327 }
328
329 /**
330  * Accessible_getDescription:
331  * @obj: a pointer to the #Accessible object on which to operate.
332  *
333  * Get the description of an #Accessible object.
334  *
335  * Returns: a UTF-8 string describing the #Accessible object.
336  * or NULL on exception
337  **/
338 char *
339 Accessible_getDescription (Accessible *obj)
340 {
341   char *retval;
342
343   cspi_return_val_if_fail (obj != NULL, NULL);
344
345   retval = Accessibility_Accessible__get_description (CSPI_OBJREF (obj),
346                                                cspi_ev ());
347
348   cspi_return_val_if_ev ("getDescription", NULL); 
349
350   return retval;
351 }
352
353 /**
354  * Accessible_getParent:
355  * @obj: a pointer to the #Accessible object to query.
356  *
357  * Get an #Accessible object's parent container.
358  *
359  * Returns: a pointer tothe #Accessible object which contains the given
360  *          #Accessible instance, or NULL if the @obj has no parent container.
361  *
362  **/
363 Accessible *
364 Accessible_getParent (Accessible *obj)
365 {
366   Accessible *retval;
367
368   cspi_return_val_if_fail (obj != NULL, NULL);
369
370   retval = cspi_object_add (
371     Accessibility_Accessible__get_parent (CSPI_OBJREF (obj),
372                                           cspi_ev ()));
373
374   cspi_return_val_if_ev ("getParent", NULL); 
375
376   return retval;
377 }
378
379 /**
380  * Accessible_getChildCount:
381  * @obj: a pointer to the #Accessible object on which to operate.
382  *
383  * Get the number of children contained by an #Accessible object.
384  *
385  * Returns: a #long indicating the number of #Accessible children
386  *          contained by an #Accessible object. or -1 on exception
387  *
388  **/
389 long
390 Accessible_getChildCount (Accessible *obj)
391 {
392   long retval;
393
394   cspi_return_val_if_fail (obj != NULL, -1);
395
396   retval = Accessibility_Accessible__get_childCount (CSPI_OBJREF (obj),
397                                               cspi_ev ());
398
399   cspi_return_val_if_ev ("getChildCount", -1); 
400
401   return retval;
402 }
403
404 /**
405  * Accessible_getChildAtIndex:
406  * @obj: a pointer to the #Accessible object on which to operate.
407  * @childIndex: a #long indicating which child is specified.
408  *
409  * Get the #Accessible child of an #Accessible object at a given index.
410  *
411  * Returns: a pointer to the #Accessible child object at index
412  *          @childIndex. or NULL on exception
413  **/
414 Accessible *
415 Accessible_getChildAtIndex (Accessible *obj,
416                             long int    childIndex)
417 {
418   Accessible *retval;
419
420   cspi_return_val_if_fail (obj != NULL, NULL);
421
422   retval = cspi_object_add (
423     Accessibility_Accessible_getChildAtIndex (CSPI_OBJREF (obj),
424                                               childIndex, cspi_ev ()));
425
426   cspi_return_val_if_ev ("getChildAtIndex", NULL);
427   return retval;
428 }
429
430 /**
431  * Accessible_getIndexInParent:
432  * @obj: a pointer to the #Accessible object on which to operate.
433  *
434  * Get the index of an #Accessible object in its containing #Accessible.
435  *
436  * Returns: a #long indicating the index of the #Accessible object
437  *          in its parent (i.e. containing) #Accessible instance,
438  *          or -1 if @obj has no containing parent or on exception.
439  **/
440 long
441 Accessible_getIndexInParent (Accessible *obj)
442 {
443   long retval;
444
445   cspi_return_val_if_fail (obj != NULL, -1);
446
447   retval = Accessibility_Accessible_getIndexInParent (CSPI_OBJREF (obj), cspi_ev ());
448
449   cspi_return_val_if_ev ("getIndexInparent", -1); 
450   return retval;
451 }
452
453 /**
454  * Accessible_getRelationSet:
455  * @obj: a pointer to the #Accessible object on which to operate.
456  *
457  * Get the set of #AccessibleRelation objects which describe this #Accessible object's
458  *       relationships with other #Accessible objects.
459  *
460  * Returns: an array of #AccessibleRelation pointers. or NULL on exception
461  **/
462 AccessibleRelation **
463 Accessible_getRelationSet (Accessible *obj)
464 {
465   int i;
466   int n_relations;
467   AccessibleRelation **relations;
468   Accessibility_RelationSet *relation_set;
469
470   cspi_return_val_if_fail (obj != NULL, NULL);
471
472   g_assert (!cspi_exception ());
473
474   relation_set =
475     Accessibility_Accessible_getRelationSet (CSPI_OBJREF (obj), cspi_ev ());
476
477   cspi_return_val_if_ev ("getRelationSet", NULL); 
478   
479   n_relations = relation_set->_length;
480   relations = malloc (sizeof (AccessibleRelation *) * (n_relations + 1));
481   
482   for (i = 0; i < n_relations; ++i)
483     {
484       relations[i] = cspi_object_add (CORBA_Object_duplicate (
485               relation_set->_buffer[i], cspi_ev ()));
486     }
487   relations[i] = NULL;
488
489   CORBA_free (relation_set);
490
491   return relations;
492 }
493
494 /**
495  * Accessible_getRole:
496  * @obj: a pointer to the #Accessible object on which to operate.
497  *
498  * Get the UI role of an #Accessible object.
499  * A UTF-8 string describing this role can be obtained via Accessible_getRoleName ().
500  *
501  * Returns: the #AccessibleRole of the object.
502  *
503  **/
504 AccessibleRole
505 Accessible_getRole (Accessible *obj)
506 {
507   Accessibility_Role retval;
508
509   cspi_return_val_if_fail (obj != NULL, SPI_ROLE_INVALID);
510
511   retval = 
512     Accessibility_Accessible_getRole (CSPI_OBJREF (obj), cspi_ev ());
513
514   cspi_return_val_if_ev ("getRole", SPI_ROLE_INVALID); 
515
516   return cspi_role_from_spi_role (retval);
517 }
518
519 /**
520  * Accessible_getRoleName:
521  * @obj: a pointer to the #Accessible object on which to operate.
522  *
523  * Get a UTF-8 string describing the role this object plays in the UI.
524  * This method will return useful values for roles that fall outside the
525  * enumeration used in Accessible_getRole ().
526  *
527  * Returns: a UTF-8 string specifying the role of this #Accessible object.
528  *
529  **/
530 char *
531 Accessible_getRoleName (Accessible *obj)
532 {
533   char *retval;
534
535   cspi_return_val_if_fail (obj != NULL, CORBA_string_dup ("invalid"));
536
537   retval = 
538     Accessibility_Accessible_getRoleName (CSPI_OBJREF (obj), cspi_ev ());
539
540   cspi_return_val_if_ev ("getRoleName", CORBA_string_dup ("invalid")); 
541
542   return retval;
543 }
544
545 /**
546  * Accessible_getLocalizedRoleName:
547  * @obj: a pointer to the #Accessible object on which to operate.
548  *
549  * Get a UTF-8 string describing the (localized) role this object plays in the UI.
550  * This method will return useful values for roles that fall outside the
551  * enumeration used in Accessible_getRole ().
552  *
553  * @Since: AT-SPI 1.4
554  *
555  * Returns: a UTF-8 string specifying the role of this #Accessible object.
556  *
557  **/
558 char *
559 Accessible_getLocalizedRoleName (Accessible *obj)
560 {
561   char *retval;
562
563   cspi_return_val_if_fail (obj != NULL, CORBA_string_dup ("invalid"));
564
565   retval = 
566     Accessibility_Accessible_getLocalizedRoleName (CSPI_OBJREF (obj), cspi_ev ());
567
568   cspi_return_val_if_ev ("getLocalizedRoleName", CORBA_string_dup ("invalid")); 
569
570   return retval;
571 }
572
573 /**
574  * Accessible_getStateSet:
575  * @obj: a pointer to the #Accessible object on which to operate.
576  *
577  * Gets the current state of an object.
578  *
579  * Returns: a pointer to an #AccessibleStateSet representing the object's current state.
580  **/
581 AccessibleStateSet *
582 Accessible_getStateSet (Accessible *obj)
583 {
584   AccessibleStateSet *retval;
585   Accessibility_StateSet corba_stateset;
586   Accessibility_StateSeq *corba_seq;
587
588   cspi_return_val_if_fail (obj != NULL, NULL);
589
590   corba_stateset = Accessibility_Accessible_getState (
591           CSPI_OBJREF (obj), cspi_ev ());
592   cspi_return_val_if_ev ("getState", NULL);
593
594   cspi_return_val_if_fail (corba_stateset != CORBA_OBJECT_NIL, NULL);
595   cspi_return_val_if_fail (cspi_ping (corba_stateset), NULL);
596   corba_seq = Accessibility_StateSet_getStates (corba_stateset, cspi_ev ());
597   cspi_return_val_if_ev ("getState", NULL);
598
599   retval = spi_state_set_cache_new (corba_seq);
600
601   CORBA_free (corba_seq);
602   cspi_release_unref (corba_stateset);
603
604   return retval;
605 }
606
607 /**
608  * Accessible_getAttributes:
609  * @obj: The #Accessible being queried.
610  *
611  * Get the #AttributeSet representing any assigned 
612  * name-value pair attributes or annotations for this object.
613  * For typographic, textual, or textually-semantic attributes, see
614  * AccessibleText_getAttributes instead.
615  *
616  * Returns: The name-value-pair attributes assigned to this object.
617  */
618 AccessibleAttributeSet *
619 Accessible_getAttributes (Accessible *obj)
620 {
621     AccessibleAttributeSet *retval;
622     Accessibility_AttributeSet *corba_seq;
623
624     cspi_return_val_if_fail (obj != NULL, NULL);
625
626     corba_seq = Accessibility_Accessible_getAttributes (
627         CSPI_OBJREF (obj), cspi_ev ());
628     cspi_return_val_if_ev ("getAttributes", NULL);
629     
630     retval = _cspi_attribute_set_from_sequence (corba_seq);
631     CORBA_free (corba_seq);
632
633     return retval;
634 }
635
636 /**
637  * Accessible_getHostApplication:
638  * @obj: The #Accessible being queried.
639  *
640  * Get the containing #AccessibleApplication for an object.
641  *
642  * Returns: the containing AccessibleApplication instance for this object.
643  */
644 AccessibleApplication *
645 Accessible_getHostApplication (Accessible *obj)
646 {
647     AccessibleApplication *retval;
648
649     cspi_return_val_if_fail (obj != NULL, NULL);
650
651     retval = Accessible_getApplication (cspi_object_add (
652                                             Accessibility_Accessible_getApplication (CSPI_OBJREF (obj),
653                                                                                      cspi_ev ())));
654     cspi_return_val_if_ev ("getApplication", NULL);
655
656     return retval;
657 }
658
659 /* Interface query methods */
660
661 /**
662  * Accessible_isAction:
663  * @obj: a pointer to the #Accessible instance to query.
664  *
665  * Query whether the specified #Accessible implements #AccessibleAction.
666  *
667  * Returns: #TRUE if @obj implements the #AccessibleAction interface,
668  *          #FALSE otherwise.
669  **/
670 SPIBoolean
671 Accessible_isAction (Accessible *obj)
672 {
673   return cspi_accessible_is_a (obj,
674                               "IDL:Accessibility/Action:1.0");
675 }
676
677 /**
678  * Accessible_isApplication:
679  * @obj: a pointer to the #Accessible instance to query.
680  *
681  * Query whether the specified #Accessible implements #AccessibleApplication.
682  *
683  * Returns: #TRUE if @obj implements the #AccessibleApplication interface,
684  *          #FALSE otherwise.
685  **/
686 SPIBoolean
687 Accessible_isApplication (Accessible *obj)
688 {
689   return cspi_accessible_is_a (obj,
690                               "IDL:Accessibility/Application:1.0");
691 }
692
693 /**
694  * Accessible_isComponent:
695  * @obj: a pointer to the #Accessible instance to query.
696  *
697  * Query whether the specified #Accessible implements #AccessibleComponent.
698  *
699  * Returns: #TRUE if @obj implements the #AccessibleComponent interface,
700  *          #FALSE otherwise.
701  **/
702 SPIBoolean
703 Accessible_isComponent (Accessible *obj)
704 {
705   return cspi_accessible_is_a (obj,
706                               "IDL:Accessibility/Component:1.0");
707 }
708
709 /**
710  * Accessible_isDocument:
711  * @obj: a pointer to the #Accessible instance to query.
712  *
713  * Query whether the specified #Accessible implements #AccessibleDocument.
714  *
715  * Returns: #TRUE if @obj implements the #AccessibleDocument interface,
716  *          #FALSE otherwise.
717  **/
718 SPIBoolean
719 Accessible_isDocument (Accessible *obj)
720 {
721   return cspi_accessible_is_a (obj,
722                               "IDL:Accessibility/Document:1.0");
723 }
724
725 /**
726  * Accessible_isEditableText:
727  * @obj: a pointer to the #Accessible instance to query.
728  *
729  * Query whether the specified #Accessible implements #AccessibleEditableText.
730  *
731  * Returns: #TRUE if @obj implements the #AccessibleEditableText interface,
732  *          #FALSE otherwise.
733  **/
734 SPIBoolean
735 Accessible_isEditableText (Accessible *obj)
736 {
737   return cspi_accessible_is_a (obj,
738                               "IDL:Accessibility/EditableText:1.0");
739 }
740
741 /**
742  * Accessible_isHypertext:
743  * @obj: a pointer to the #Accessible instance to query.
744  *
745  * Query whether the specified #Accessible implements #AccessibleHypertext.
746  *
747  * Returns: #TRUE if @obj implements the #AccessibleHypertext interface,
748  *          #FALSE otherwise.
749  **/
750 SPIBoolean
751 Accessible_isHypertext (Accessible *obj)
752 {
753   return cspi_accessible_is_a (obj,
754                               "IDL:Accessibility/Hypertext:1.0");
755 }
756
757 /**
758  * Accessible_isImage:
759  * @obj: a pointer to the #Accessible instance to query.
760  *
761  * Query whether the specified #Accessible implements #AccessibleImage.
762  *
763  * Returns: #TRUE if @obj implements the #AccessibleImage interface,
764  *          #FALSE otherwise.
765 **/
766 SPIBoolean
767 Accessible_isImage (Accessible *obj)
768 {
769   return cspi_accessible_is_a (obj,
770                               "IDL:Accessibility/Image:1.0");
771 }
772
773 /**
774  * Accessible_isSelection:
775  * @obj: a pointer to the #Accessible instance to query.
776  *
777  * Query whether the specified #Accessible implements #AccessibleSelection.
778  *
779  * Returns: #TRUE if @obj implements the #AccessibleSelection interface,
780  *          #FALSE otherwise.
781 **/
782 SPIBoolean
783 Accessible_isSelection (Accessible *obj)
784 {
785   return cspi_accessible_is_a (obj,
786                               "IDL:Accessibility/Selection:1.0");
787 }
788
789 /**
790  * Accessible_isTable:
791  * @obj: a pointer to the #Accessible instance to query.
792  *
793  * Query whether the specified #Accessible implements #AccessibleTable.
794  *
795  * Returns: #TRUE if @obj implements the #AccessibleTable interface,
796  *          #FALSE otherwise.
797 **/
798 SPIBoolean
799 Accessible_isTable (Accessible *obj)
800 {
801   return cspi_accessible_is_a (obj,
802                               "IDL:Accessibility/Table:1.0");
803 }
804
805 /**
806  * Accessible_isStreamableContent:
807  * @obj: a pointer to the #Accessible instance to query.
808  *
809  * Query whether the specified #Accessible implements
810  *          #AccessibleStreamableContent.
811  *
812  * Returns: #TRUE if @obj implements the #AccessibleStreamableContent interface,
813  *          #FALSE otherwise.
814 **/
815 SPIBoolean
816 Accessible_isStreamableContent (Accessible *obj)
817 {
818   return cspi_accessible_is_a (obj,
819                               "IDL:Accessibility/StreamableContent:1.0");
820 }
821
822 /**
823  * Accessible_isText:
824  * @obj: a pointer to the #Accessible instance to query.
825  *
826  * Query whether the specified #Accessible implements #AccessibleText.
827  *
828  * Returns: #TRUE if @obj implements the #AccessibleText interface,
829  *          #FALSE otherwise.
830 **/
831 SPIBoolean
832 Accessible_isText (Accessible *obj)
833 {
834   return cspi_accessible_is_a (obj,
835                               "IDL:Accessibility/Text:1.0");
836 }
837
838 /**
839  * Accessible_isValue:
840  * @obj: a pointer to the #Accessible instance to query.
841  *
842  * Query whether the specified #Accessible implements #AccessibleValue.
843  *
844  * Returns: #TRUE if @obj implements the #AccessibleValue interface,
845  *          #FALSE otherwise.
846 **/
847 SPIBoolean
848 Accessible_isValue (Accessible *obj)
849 {
850   return cspi_accessible_is_a (obj,
851                               "IDL:Accessibility/Value:1.0");
852 }
853
854 /**
855  * Accessible_getApplication:
856  * @obj: a pointer to the #Accessible instance to query.
857  *
858  * Get the #AccessibleApplication interface for an #Accessible.
859  *
860  * Returns: a pointer to an #AccessibleApplication interface instance, or
861  *          NULL if @obj does not implement #AccessibleApplication.
862  **/
863 AccessibleApplication *
864 Accessible_getApplication (Accessible *obj)
865 {
866   return (AccessibleApplication *) Accessible_queryInterface (
867           obj, "IDL:Accessibility/Application:1.0");
868 }
869
870 /**
871  * Accessible_getAction:
872  * @obj: a pointer to the #Accessible instance to query.
873  *
874  * Get the #AccessibleAction interface for an #Accessible.
875  *
876  * Returns: a pointer to an #AccessibleAction interface instance, or
877  *          NULL if @obj does not implement #AccessibleAction.
878  **/
879 AccessibleAction *
880 Accessible_getAction (Accessible *obj)
881 {
882   return (AccessibleAction *) Accessible_queryInterface (
883           obj, "IDL:Accessibility/Action:1.0");
884 }
885
886 /**
887  * Accessible_getComponent:
888  * @obj: a pointer to the #Accessible instance to query.
889  *
890  * Get the #AccessibleComponent interface for an #Accessible.
891  *
892  * Returns: a pointer to an #AccessibleComponent interface instance, or
893  *          NULL if @obj does not implement #AccessibleComponent.
894  **/
895 AccessibleComponent *
896 Accessible_getComponent (Accessible *obj)
897 {
898   return (AccessibleComponent *) Accessible_queryInterface (
899           obj, "IDL:Accessibility/Component:1.0");
900 }
901 /**
902  * Accessible_getDocument:
903  * @obj: a pointer to the #Accessible instance to query.
904  *
905  * Get the #AccessibleDocument interface for an #Accessible.
906  *
907  * Returns: a pointer to an #AccessibleDocument interface instance, or
908  *          NULL if @obj does not implement #AccessibleDocument.
909  **/
910 AccessibleDocument *
911 Accessible_getDocument (Accessible *obj)
912 {
913   return (AccessibleDocument *) Accessible_queryInterface (
914           obj, "IDL:Accessibility/Document:1.0");
915 }
916
917 /**
918  * Accessible_getEditableText:
919  * @obj: a pointer to the #Accessible instance to query.
920  *
921  * Get the #AccessibleEditableText interface for an #Accessible.
922  *
923  * Returns: a pointer to an #AccessibleEditableText interface instance, or
924  *          NULL if @obj does not implement #AccessibleEditableText.
925  **/
926 AccessibleEditableText *
927 Accessible_getEditableText (Accessible *obj)
928 {
929   return (AccessibleEditableText *) Accessible_queryInterface (
930           obj, "IDL:Accessibility/EditableText:1.0");
931 }
932
933
934
935 /**
936  * Accessible_getHypertext:
937  * @obj: a pointer to the #Accessible instance to query.
938  *
939  * Get the #AccessibleHypertext interface for an #Accessible.
940  *
941  * Returns: a pointer to an #AccessibleHypertext interface instance, or
942  *          NULL if @obj does not implement #AccessibleHypertext.
943  **/
944 AccessibleHypertext *
945 Accessible_getHypertext (Accessible *obj)
946 {
947   return (AccessibleHypertext *) Accessible_queryInterface (
948           obj, "IDL:Accessibility/Hypertext:1.0");
949 }
950
951
952
953 /**
954  * Accessible_getImage:
955  * @obj: a pointer to the #Accessible instance to query.
956  *
957  * Get the #AccessibleImage interface for an #Accessible.
958  *
959  * Returns: a pointer to an #AccessibleImage interface instance, or
960  *          NULL if @obj does not implement #AccessibleImage.
961  **/
962 AccessibleImage *
963 Accessible_getImage (Accessible *obj)
964 {
965   return (AccessibleImage *) Accessible_queryInterface (
966           obj, "IDL:Accessibility/Image:1.0");
967 }
968
969
970
971 /**
972  * Accessible_getSelection:
973  * @obj: a pointer to the #Accessible instance to query.
974  *
975  * Get the #AccessibleSelection interface for an #Accessible.
976  *
977  * Returns: a pointer to an #AccessibleSelection interface instance, or
978  *          NULL if @obj does not implement #AccessibleSelection.
979  **/
980 AccessibleSelection *
981 Accessible_getSelection (Accessible *obj)
982 {
983   return (AccessibleSelection *) Accessible_queryInterface (
984           obj, "IDL:Accessibility/Selection:1.0");
985 }
986
987
988
989 /**
990  * Accessible_getStreamableContent:
991  * @obj: a pointer to the #Accessible instance to query.
992  *
993  * Get the #AccessibleStreamableContent interface for an #Accessible.
994  *
995  * Returns: a pointer to an #AccessibleStreamableContent interface instance, or
996  *          NULL if @obj does not implement #AccessibleStreamableContent.
997  **/
998 AccessibleStreamableContent *
999 Accessible_getStreamableContent (Accessible *obj)
1000 {
1001   return (AccessibleStreamableContent *) Accessible_queryInterface (
1002           obj, "IDL:Accessibility/StreamableContent:1.0");
1003 }
1004
1005 /**
1006  * Accessible_getTable:
1007  * @obj: a pointer to the #Accessible instance to query.
1008  *
1009  * Get the #AccessibleTable interface for an #Accessible.
1010  *
1011  * Returns: a pointer to an #AccessibleTable interface instance, or
1012  *          NULL if @obj does not implement #AccessibleTable.
1013  **/
1014 AccessibleTable *
1015 Accessible_getTable (Accessible *obj)
1016 {
1017   return (AccessibleTable *) Accessible_queryInterface (
1018           obj, "IDL:Accessibility/Table:1.0");
1019 }
1020
1021 /**
1022  * Accessible_getText:
1023  * @obj: a pointer to the #Accessible instance to query.
1024  *
1025  * Get the #AccessibleText interface for an #Accessible.
1026  *
1027  * Returns: a pointer to an #AccessibleText interface instance, or
1028  *          NULL if @obj does not implement #AccessibleText.
1029  **/
1030 AccessibleText *
1031 Accessible_getText (Accessible *obj)
1032 {
1033   return (AccessibleText *) Accessible_queryInterface (
1034           obj, "IDL:Accessibility/Text:1.0");
1035 }
1036
1037
1038
1039 /**
1040  * Accessible_getValue:
1041  * @obj: a pointer to the #Accessible instance to query.
1042  *
1043  * Get the #AccessibleValue interface for an #Accessible.
1044  *
1045  * Returns: a pointer to an #AccessibleValue interface instance, or
1046  *          NULL if @obj does not implement #AccessibleValue.
1047  **/
1048 AccessibleValue *
1049 Accessible_getValue (Accessible *obj)
1050 {
1051   return (AccessibleValue *) Accessible_queryInterface (
1052           obj, "IDL:Accessibility/Value:1.0");
1053 }
1054
1055
1056
1057 /**
1058  * Accessible_queryInterface:
1059  * @obj: a pointer to the #Accessible instance to query.
1060  * @interface_name: a UTF-8 character string specifiying the requested interface.
1061  *
1062  * Query an #Accessible object to for a named interface.
1063  *
1064  * Returns: an instance of the named interface object, if it is implemented
1065  *          by @obj, or NULL otherwise.
1066  *
1067  **/
1068 AccessibleUnknown *
1069 Accessible_queryInterface (Accessible *obj,
1070                            const char *interface_name)
1071 {
1072   Bonobo_Unknown iface;
1073   
1074   if (!obj)
1075     {
1076       return NULL;
1077     }
1078
1079   iface = Accessibility_Accessible_queryInterface (CSPI_OBJREF (obj),
1080                                                    interface_name,
1081                                                    cspi_ev ());
1082
1083
1084   cspi_return_val_if_ev ("queryInterface", NULL); 
1085
1086   /*
1087    * FIXME: we need to be fairly sure that references are going
1088    * to mach up if we are going to expose QueryInterface, ie. we
1089    * can't allow people to do:
1090    * b = a.qi ("b"); b.unref, b.unref to release a's reference.
1091    * this should be no real problem though for this level of API
1092    * user.
1093    */
1094
1095   return cspi_object_add (iface);
1096 }
1097
1098
1099 /**
1100  * AccessibleRelation_ref:
1101  * @obj: a pointer to the #AccessibleRelation object on which to operate.
1102  *
1103  * Increment the reference count for an #AccessibleRelation object.
1104  *
1105  **/
1106 void
1107 AccessibleRelation_ref (AccessibleRelation *obj)
1108 {
1109   cspi_object_ref (obj);
1110 }
1111
1112 /**
1113  * AccessibleRelation_unref:
1114  * @obj: a pointer to the #AccessibleRelation object on which to operate.
1115  *
1116  * Decrement the reference count for an #AccessibleRelation object.
1117  *
1118  **/
1119 void
1120 AccessibleRelation_unref (AccessibleRelation *obj)
1121 {
1122   cspi_object_unref (obj);
1123 }
1124
1125 static SPIBoolean
1126 cspi_init_relation_type_table (AccessibleRelationType *relation_type_table)
1127 {
1128   int i;
1129   for (i = 0; i < Accessibility_RELATION_LAST_DEFINED; ++i)
1130     {
1131       relation_type_table [i] = SPI_RELATION_NULL;
1132     }
1133   relation_type_table [Accessibility_RELATION_NULL] = SPI_RELATION_NULL;
1134   relation_type_table [Accessibility_RELATION_LABEL_FOR] = SPI_RELATION_LABEL_FOR;
1135   relation_type_table [Accessibility_RELATION_LABELLED_BY] = SPI_RELATION_LABELED_BY;
1136   relation_type_table [Accessibility_RELATION_CONTROLLER_FOR] = SPI_RELATION_CONTROLLER_FOR;
1137   relation_type_table [Accessibility_RELATION_CONTROLLED_BY] = SPI_RELATION_CONTROLLED_BY;
1138   relation_type_table [Accessibility_RELATION_MEMBER_OF] = SPI_RELATION_MEMBER_OF;
1139   relation_type_table [Accessibility_RELATION_TOOLTIP_FOR] = SPI_RELATION_NULL;
1140   relation_type_table [Accessibility_RELATION_NODE_CHILD_OF] = SPI_RELATION_NODE_CHILD_OF;
1141   relation_type_table [Accessibility_RELATION_EXTENDED] = SPI_RELATION_EXTENDED;
1142   relation_type_table [Accessibility_RELATION_FLOWS_TO] = SPI_RELATION_FLOWS_TO;
1143   relation_type_table [Accessibility_RELATION_FLOWS_FROM] = SPI_RELATION_FLOWS_FROM;
1144   relation_type_table [Accessibility_RELATION_SUBWINDOW_OF] = SPI_RELATION_SUBWINDOW_OF;
1145   relation_type_table [Accessibility_RELATION_EMBEDS] = SPI_RELATION_EMBEDS;
1146   relation_type_table [Accessibility_RELATION_EMBEDDED_BY] = SPI_RELATION_EMBEDDED_BY;
1147   relation_type_table [Accessibility_RELATION_POPUP_FOR] = SPI_RELATION_POPUP_FOR;
1148   relation_type_table [Accessibility_RELATION_PARENT_WINDOW_OF] = SPI_RELATION_PARENT_WINDOW_OF;
1149   relation_type_table [Accessibility_RELATION_DESCRIBED_BY] = SPI_RELATION_DESCRIBED_BY;
1150   relation_type_table [Accessibility_RELATION_DESCRIPTION_FOR] = SPI_RELATION_DESCRIPTION_FOR;
1151   return TRUE;
1152 }
1153
1154 static AccessibleRelationType
1155 cspi_relation_type_from_spi_relation_type (Accessibility_RelationType type)
1156 {
1157   /* array is sized according to IDL RelationType because IDL RelationTypes are the index */    
1158   static AccessibleRelationType cspi_relation_type_table [Accessibility_RELATION_LAST_DEFINED];
1159   static SPIBoolean is_initialized = FALSE;
1160   AccessibleRelationType cspi_type;
1161   if (!is_initialized)
1162     {
1163       is_initialized = cspi_init_relation_type_table (cspi_relation_type_table);            
1164     }
1165   if (type >= 0 && type < Accessibility_RELATION_LAST_DEFINED)
1166     {
1167       cspi_type = cspi_relation_type_table [type];          
1168     }
1169   else
1170     {
1171       cspi_type = SPI_RELATION_NULL;
1172     }
1173   return cspi_type; 
1174 }
1175 /**
1176  * AccessibleRelation_getRelationType:
1177  * @obj: a pointer to the #AccessibleRelation object to query.
1178  *
1179  * Get the type of relationship represented by an #AccessibleRelation.
1180  *
1181  * Returns: an #AccessibleRelationType indicating the type of relation
1182  *         encapsulated in this #AccessibleRelation object.
1183  *
1184  **/
1185 AccessibleRelationType
1186 AccessibleRelation_getRelationType (AccessibleRelation *obj)
1187 {
1188   Accessibility_RelationType retval;
1189   
1190   cspi_return_val_if_fail (obj, SPI_RELATION_NULL);
1191   retval =
1192     Accessibility_Relation_getRelationType (CSPI_OBJREF (obj), cspi_ev());
1193   cspi_return_val_if_ev ("getRelationType", SPI_RELATION_NULL);
1194   return cspi_relation_type_from_spi_relation_type (retval);
1195 }
1196
1197 /**
1198  * AccessibleRelation_getNTargets:
1199  * @obj: a pointer to the #AccessibleRelation object to query.
1200  *
1201  * Get the number of objects which this relationship has as its
1202  *       target objects (the subject is the #Accessible from which this
1203  *       #AccessibleRelation originated).
1204  *
1205  * Returns: a short integer indicating how many target objects which the
1206  *       originating #Accessible object has the #AccessibleRelation
1207  *       relationship with.
1208  **/
1209 int
1210 AccessibleRelation_getNTargets (AccessibleRelation *obj)
1211 {
1212   int retval;
1213   
1214   cspi_return_val_if_fail (obj, -1);
1215   retval = Accessibility_Relation_getNTargets (CSPI_OBJREF (obj), cspi_ev());
1216   cspi_return_val_if_ev ("getNTargets", -1);
1217   return retval;
1218 }
1219
1220 /**
1221  * AccessibleRelation_getTarget:
1222  * @obj: a pointer to the #AccessibleRelation object to query.
1223  * @i: a (zero-index) integer indicating which (of possibly several) target is requested.
1224  *
1225  * Get the @i-th target of a specified #AccessibleRelation relationship.
1226  *
1227  * Returns: an #Accessible which is the @i-th object with which the
1228  *      originating #Accessible has relationship specified in the
1229  *      #AccessibleRelation object.
1230  *
1231  **/
1232 Accessible *
1233 AccessibleRelation_getTarget (AccessibleRelation *obj, int i)
1234 {
1235   Accessible *retval;
1236
1237   cspi_return_val_if_fail (obj, NULL);
1238
1239   retval = cspi_object_add (
1240                          Accessibility_Relation_getTarget (CSPI_OBJREF(obj),
1241                                                            i, cspi_ev()));
1242   cspi_return_val_if_ev ("getTarget", NULL);
1243   return retval;
1244 }
1245
1246 /**
1247  * AccessibleStateSet_ref:
1248  * @obj: a pointer to the #AccessibleStateSet object on which to operate.
1249  *
1250  * Increment the reference count for an #AccessibleStateSet object.
1251  *
1252  **/
1253 void
1254 AccessibleStateSet_ref (AccessibleStateSet *obj)
1255 {
1256   spi_state_set_cache_ref (obj);
1257 }
1258
1259 /**
1260  * AccessibleStateSet_unref:
1261  * @obj: a pointer to the #AccessibleStateSet object on which to operate.
1262  *
1263  * Decrement the reference count for an #AccessibleStateSet object.
1264  *
1265  **/
1266 void
1267 AccessibleStateSet_unref (AccessibleStateSet *obj)
1268 {
1269   spi_state_set_cache_unref (obj);
1270 }
1271
1272 static Accessibility_StateType
1273 spi_state_to_corba (AccessibleState state)
1274 {
1275 #define MAP_STATE(a) \
1276   case SPI_STATE_##a: \
1277     return Accessibility_STATE_##a
1278
1279   switch (state)
1280     {
1281       MAP_STATE (INVALID);
1282       MAP_STATE (ACTIVE);
1283       MAP_STATE (ARMED);
1284       MAP_STATE (BUSY);
1285       MAP_STATE (CHECKED);
1286       MAP_STATE (DEFUNCT);
1287       MAP_STATE (EDITABLE);
1288       MAP_STATE (ENABLED);
1289       MAP_STATE (EXPANDABLE);
1290       MAP_STATE (EXPANDED);
1291       MAP_STATE (FOCUSABLE);
1292       MAP_STATE (FOCUSED);
1293       MAP_STATE (HORIZONTAL);
1294       MAP_STATE (ICONIFIED);
1295       MAP_STATE (MODAL);
1296       MAP_STATE (MULTI_LINE);
1297       MAP_STATE (MULTISELECTABLE);
1298       MAP_STATE (OPAQUE);
1299       MAP_STATE (PRESSED);
1300       MAP_STATE (RESIZABLE);
1301       MAP_STATE (SELECTABLE);
1302       MAP_STATE (SELECTED);
1303       MAP_STATE (SENSITIVE);
1304       MAP_STATE (SHOWING);
1305       MAP_STATE (SINGLE_LINE);
1306       MAP_STATE (STALE);
1307       MAP_STATE (TRANSIENT);
1308       MAP_STATE (VERTICAL);
1309       MAP_STATE (VISIBLE);
1310       MAP_STATE (MANAGES_DESCENDANTS);
1311       MAP_STATE (INDETERMINATE);
1312       MAP_STATE (TRUNCATED);
1313       MAP_STATE (REQUIRED);
1314       MAP_STATE (INVALID_ENTRY);
1315       MAP_STATE (SUPPORTS_AUTOCOMPLETION);
1316       MAP_STATE (SELECTABLE_TEXT);
1317       MAP_STATE (IS_DEFAULT);
1318       MAP_STATE (VISITED);
1319     default:
1320       return Accessibility_STATE_INVALID;
1321   }
1322 #undef MAP_STATE
1323 }             
1324
1325 /**
1326  * AccessibleStateSet_contains:
1327  * @obj: a pointer to the #AccessibleStateSet object on which to operate.
1328  * @state: an #AccessibleState for which the specified #AccessibleStateSet
1329  *       will be queried.
1330  *
1331  * Determine whether a given #AccessibleStateSet includes a given state; that is,
1332  *       whether @state is true for the stateset in question.
1333  *
1334  * Returns: #TRUE if @state is true/included in the given #AccessibleStateSet,
1335  *          otherwise #FALSE.
1336  *
1337  **/
1338 SPIBoolean
1339 AccessibleStateSet_contains (AccessibleStateSet *obj,
1340                              AccessibleState state)
1341 {
1342   return spi_state_set_cache_contains (obj, spi_state_to_corba (state));
1343 }
1344
1345 /**
1346  * AccessibleStateSet_add:
1347  * @obj: a pointer to the #AccessibleStateSet object on which to operate.
1348  * @state: an #AccessibleState to be added to the specified #AccessibleStateSet
1349  *
1350  * Add a particular #AccessibleState to an #AccessibleStateSet (i.e. set the
1351  *       given state to #TRUE in the stateset.
1352  *
1353  **/
1354 void
1355 AccessibleStateSet_add (AccessibleStateSet *obj,
1356                         AccessibleState state)
1357 {
1358   spi_state_set_cache_add (obj, spi_state_to_corba (state));
1359 }
1360
1361 /**
1362  * AccessibleStateSet_remove:
1363  * @obj: a pointer to the #AccessibleStateSet object on which to operate.
1364  * @state: an #AccessibleState to be removed from the specified #AccessibleStateSet
1365  *
1366  * Remove a particular #AccessibleState to an #AccessibleStateSet (i.e. set the
1367  *       given state to #FALSE in the stateset.)
1368  *
1369  **/
1370 void
1371 AccessibleStateSet_remove (AccessibleStateSet *obj,
1372                            AccessibleState state)
1373 {
1374   spi_state_set_cache_remove (obj, spi_state_to_corba (state));
1375 }
1376
1377 /**
1378  * AccessibleStateSet_equals:
1379  * @obj: a pointer to the first #AccessibleStateSet object on which to operate.
1380  * @obj2: a pointer to the second #AccessibleStateSet object on which to operate.
1381  *
1382  * Determine whether two instances of #AccessibleStateSet are equivalent (i.e.
1383  *         consist of the same #AccessibleStates).  Useful for checking multiple
1384  *         state variables at once; construct the target state then compare against it.
1385  *
1386  * @see AccessibleStateSet_compare().
1387  *
1388  * Returns: #TRUE if the two #AccessibleStateSets are equivalent,
1389  *          otherwise #FALSE.
1390  *
1391  **/
1392 SPIBoolean
1393 AccessibleStateSet_equals (AccessibleStateSet *obj,
1394                            AccessibleStateSet *obj2)
1395 {
1396   SPIBoolean   eq;
1397   AtkStateSet *cmp;
1398
1399   if (obj == obj2)
1400     {
1401       return TRUE;
1402     }
1403
1404   cmp = spi_state_set_cache_xor (obj, obj2);
1405   eq = spi_state_set_cache_is_empty (cmp);
1406   spi_state_set_cache_unref (cmp);
1407
1408   return eq;
1409 }
1410
1411 /**
1412  * AccessibleStateSet_compare:
1413  * @obj: a pointer to the first #AccessibleStateSet object on which to operate.
1414  * @obj2: a pointer to the second #AccessibleStateSet object on which to operate.
1415  *
1416  * Determine the differences between two instances of #AccessibleStateSet.
1417  * Not Yet Implemented.
1418  *.
1419  * @see AccessibleStateSet_equals().
1420  *
1421  * Returns: an #AccessibleStateSet object containing all states contained on one of
1422  *          the two sets but not the other.
1423  *
1424  **/
1425 AccessibleStateSet *
1426 AccessibleStateSet_compare (AccessibleStateSet *obj,
1427                             AccessibleStateSet *obj2)
1428 {
1429   return spi_state_set_cache_xor (obj, obj2);
1430 }
1431
1432 /**
1433  * AccessibleStateSet_isEmpty:
1434  * @obj: a pointer to the #AccessibleStateSet object on which to operate.
1435  *
1436  * Determine whether a given #AccessibleStateSet is the empty set.
1437  *
1438  * Returns: #TRUE if the given #AccessibleStateSet contains no (true) states,
1439  *          otherwise #FALSE.
1440  *
1441  **/
1442 SPIBoolean
1443 AccessibleStateSet_isEmpty (AccessibleStateSet *obj)
1444 {
1445   return spi_state_set_cache_is_empty (obj);
1446 }
1447
1448