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