2 * AT-SPI - Assistive Technology Service Provider Interface
3 * (Gnome Accessibility Project; http://developer.gnome.org/projects/gap)
5 * Copyright 2001, 2002 Sun Microsystems Inc.,
6 * Copyright 2001, 2002 Ximian, Inc.
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.
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.
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.
24 #include <stdlib.h> /* for malloc */
25 #include <libspi/stateset.h>
26 #include <cspi/spi-private.h>
28 static const char *role_names [] =
86 "table-column-header",
107 #define MAX_ROLES (sizeof (role_names) / sizeof (char *))
110 cspi_init_role_table (AccessibleRole *role_table)
113 for (i = 0; i < Accessibility_ROLE_LAST_DEFINED; ++i)
115 role_table [i] = SPI_ROLE_UNKNOWN;
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;
196 static AccessibleRole
197 cspi_role_from_spi_role (Accessibility_Role role)
199 /* array is sized according to IDL roles because IDL roles are the index */
200 static AccessibleRole cspi_role_table [Accessibility_ROLE_LAST_DEFINED];
201 static SPIBoolean is_initialized = FALSE;
202 AccessibleRole cspi_role;
205 is_initialized = cspi_init_role_table (cspi_role_table);
207 if (role >= 0 && role < Accessibility_ROLE_LAST_DEFINED)
209 cspi_role = cspi_role_table [role];
213 cspi_role = SPI_ROLE_EXTENDED;
219 * AccessibleRole_getName:
220 * @role: an #AccessibleRole object to query.
222 * Get a localizeable string that indicates the name of an #AccessibleRole.
223 * <em>DEPRECATED.</em>
225 * Returns: a localizable string name for an #AccessibleRole enumerated type.
228 AccessibleRole_getName (AccessibleRole role)
230 if (role < MAX_ROLES && role_names [(int) role])
232 return CORBA_string_dup (role_names [(int) role]);
236 return CORBA_string_dup ("");
242 * @obj: a pointer to the #Accessible object on which to operate.
244 * Increment the reference count for an #Accessible object.
247 Accessible_ref (Accessible *obj)
249 cspi_object_ref (obj);
254 * @obj: a pointer to the #Accessible object on which to operate.
256 * Decrement the reference count for an #Accessible object.
259 Accessible_unref (Accessible *obj)
261 cspi_object_unref (obj);
265 * Accessible_getName:
266 * @obj: a pointer to the #Accessible object on which to operate.
268 * Get the name of an #Accessible object.
270 * Returns: a UTF-8 string indicating the name of the #Accessible object.
271 * or NULL on exception
274 Accessible_getName (Accessible *obj)
278 cspi_return_val_if_fail (obj != NULL, NULL);
280 retval = Accessibility_Accessible__get_name (CSPI_OBJREF (obj), cspi_ev ());
282 cspi_return_val_if_ev ("getName", NULL);
288 * Accessible_getDescription:
289 * @obj: a pointer to the #Accessible object on which to operate.
291 * Get the description of an #Accessible object.
293 * Returns: a UTF-8 string describing the #Accessible object.
294 * or NULL on exception
297 Accessible_getDescription (Accessible *obj)
301 cspi_return_val_if_fail (obj != NULL, NULL);
303 retval = Accessibility_Accessible__get_description (CSPI_OBJREF (obj),
306 cspi_return_val_if_ev ("getDescription", NULL);
312 * Accessible_getParent:
313 * @obj: a pointer to the #Accessible object to query.
315 * Get an #Accessible object's parent container.
317 * Returns: a pointer tothe #Accessible object which contains the given
318 * #Accessible instance, or NULL if the @obj has no parent container.
322 Accessible_getParent (Accessible *obj)
326 cspi_return_val_if_fail (obj != NULL, NULL);
328 retval = cspi_object_add (
329 Accessibility_Accessible__get_parent (CSPI_OBJREF (obj),
332 cspi_return_val_if_ev ("getParent", NULL);
338 * Accessible_getChildCount:
339 * @obj: a pointer to the #Accessible object on which to operate.
341 * Get the number of children contained by an #Accessible object.
343 * Returns: a #long indicating the number of #Accessible children
344 * contained by an #Accessible object. or -1 on exception
348 Accessible_getChildCount (Accessible *obj)
352 cspi_return_val_if_fail (obj != NULL, -1);
354 retval = Accessibility_Accessible__get_childCount (CSPI_OBJREF (obj),
357 cspi_return_val_if_ev ("getChildCount", -1);
363 * Accessible_getChildAtIndex:
364 * @obj: a pointer to the #Accessible object on which to operate.
365 * @childIndex: a #long indicating which child is specified.
367 * Get the #Accessible child of an #Accessible object at a given index.
369 * Returns: a pointer to the #Accessible child object at index
370 * @childIndex. or NULL on exception
373 Accessible_getChildAtIndex (Accessible *obj,
378 cspi_return_val_if_fail (obj != NULL, NULL);
380 retval = cspi_object_add (
381 Accessibility_Accessible_getChildAtIndex (CSPI_OBJREF (obj),
382 childIndex, cspi_ev ()));
384 cspi_return_val_if_ev ("getChildAtIndex", NULL);
389 * Accessible_getIndexInParent:
390 * @obj: a pointer to the #Accessible object on which to operate.
392 * Get the index of an #Accessible object in its containing #Accessible.
394 * Returns: a #long indicating the index of the #Accessible object
395 * in its parent (i.e. containing) #Accessible instance,
396 * or -1 if @obj has no containing parent or on exception.
399 Accessible_getIndexInParent (Accessible *obj)
403 cspi_return_val_if_fail (obj != NULL, -1);
405 retval = Accessibility_Accessible_getIndexInParent (CSPI_OBJREF (obj), cspi_ev ());
407 cspi_return_val_if_ev ("getIndexInparent", -1);
412 * Accessible_getRelationSet:
413 * @obj: a pointer to the #Accessible object on which to operate.
415 * Get the set of #AccessibleRelation objects which describe this #Accessible object's
416 * relationships with other #Accessible objects.
418 * Returns: an array of #AccessibleRelation pointers. or NULL on exception
420 AccessibleRelation **
421 Accessible_getRelationSet (Accessible *obj)
425 AccessibleRelation **relations;
426 Accessibility_RelationSet *relation_set;
428 cspi_return_val_if_fail (obj != NULL, NULL);
431 Accessibility_Accessible_getRelationSet (CSPI_OBJREF (obj), cspi_ev ());
433 cspi_return_val_if_ev ("getRelationSet", NULL);
435 n_relations = relation_set->_length;
436 relations = malloc (sizeof (AccessibleRelation *) * (n_relations + 1));
438 for (i = 0; i < n_relations; ++i)
440 relations[i] = cspi_object_add (CORBA_Object_duplicate (
441 relation_set->_buffer[i], cspi_ev ()));
445 CORBA_free (relation_set);
451 * Accessible_getRole:
452 * @obj: a pointer to the #Accessible object on which to operate.
454 * Get the UI role of an #Accessible object.
455 * A UTF-8 string describing this role can be obtained via Accessible_getRoleName ().
457 * Returns: the #AccessibleRole of the object.
461 Accessible_getRole (Accessible *obj)
463 Accessibility_Role retval;
465 cspi_return_val_if_fail (obj != NULL, SPI_ROLE_INVALID);
468 Accessibility_Accessible_getRole (CSPI_OBJREF (obj), cspi_ev ());
470 cspi_return_val_if_ev ("getRole", SPI_ROLE_INVALID);
472 return cspi_role_from_spi_role (retval);
476 * Accessible_getRoleName:
477 * @obj: a pointer to the #Accessible object on which to operate.
479 * Get a UTF-8 string describing the role this object plays in the UI.
480 * This method will return useful values for roles that fall outside the
481 * enumeration used in Accessible_getRole ().
483 * Returns: a UTF-8 string specifying the role of this #Accessible object.
487 Accessible_getRoleName (Accessible *obj)
491 cspi_return_val_if_fail (obj != NULL, CORBA_string_dup ("invalid"));
494 Accessibility_Accessible_getRoleName (CSPI_OBJREF (obj), cspi_ev ());
496 cspi_return_val_if_ev ("getRoleName", CORBA_string_dup ("invalid"));
502 * Accessible_getStateSet:
503 * @obj: a pointer to the #Accessible object on which to operate.
505 * Returns: a pointer to an #AccessibleStateSet representing the object's current state.
508 Accessible_getStateSet (Accessible *obj)
510 AccessibleStateSet *retval;
511 Accessibility_StateSet corba_stateset;
512 Accessibility_StateSeq *corba_seq;
514 cspi_return_val_if_fail (obj != NULL, NULL);
516 corba_stateset = Accessibility_Accessible_getState (
517 CSPI_OBJREF (obj), cspi_ev ());
518 cspi_return_val_if_ev ("getState", NULL);
520 cspi_return_val_if_fail (corba_stateset != CORBA_OBJECT_NIL, NULL);
521 cspi_return_val_if_fail (cspi_ping (corba_stateset), NULL);
522 corba_seq = Accessibility_StateSet_getStates (corba_stateset, cspi_ev ());
523 cspi_return_val_if_ev ("getState", NULL);
525 retval = spi_state_set_cache_new (corba_seq);
527 CORBA_free (corba_seq);
528 cspi_release_unref (corba_stateset);
533 /* Interface query methods */
536 * Accessible_isAction:
537 * @obj: a pointer to the #Accessible instance to query.
539 * Query whether the specified #Accessible implements #AccessibleAction.
541 * Returns: #TRUE if @obj implements the #AccessibleAction interface,
545 Accessible_isAction (Accessible *obj)
547 return cspi_accessible_is_a (obj,
548 "IDL:Accessibility/Action:1.0");
552 * Accessible_isApplication:
553 * @obj: a pointer to the #Accessible instance to query.
555 * Query whether the specified #Accessible implements #AccessibleApplication.
557 * Returns: #TRUE if @obj implements the #AccessibleApplication interface,
561 Accessible_isApplication (Accessible *obj)
563 return cspi_accessible_is_a (obj,
564 "IDL:Accessibility/Application:1.0");
568 * Accessible_isComponent:
569 * @obj: a pointer to the #Accessible instance to query.
571 * Query whether the specified #Accessible implements #AccessibleComponent.
573 * Returns: #TRUE if @obj implements the #AccessibleComponent interface,
577 Accessible_isComponent (Accessible *obj)
579 return cspi_accessible_is_a (obj,
580 "IDL:Accessibility/Component:1.0");
584 * Accessible_isEditableText:
585 * @obj: a pointer to the #Accessible instance to query.
587 * Query whether the specified #Accessible implements #AccessibleEditableText.
589 * Returns: #TRUE if @obj implements the #AccessibleEditableText interface,
593 Accessible_isEditableText (Accessible *obj)
595 return cspi_accessible_is_a (obj,
596 "IDL:Accessibility/EditableText:1.0");
600 * Accessible_isHypertext:
601 * @obj: a pointer to the #Accessible instance to query.
603 * Query whether the specified #Accessible implements #AccessibleHypertext.
605 * Returns: #TRUE if @obj implements the #AccessibleHypertext interface,
609 Accessible_isHypertext (Accessible *obj)
611 return cspi_accessible_is_a (obj,
612 "IDL:Accessibility/Hypertext:1.0");
616 * Accessible_isImage:
617 * @obj: a pointer to the #Accessible instance to query.
619 * Query whether the specified #Accessible implements #AccessibleImage.
621 * Returns: #TRUE if @obj implements the #AccessibleImage interface,
625 Accessible_isImage (Accessible *obj)
627 return cspi_accessible_is_a (obj,
628 "IDL:Accessibility/Image:1.0");
632 * Accessible_isSelection:
633 * @obj: a pointer to the #Accessible instance to query.
635 * Query whether the specified #Accessible implements #AccessibleSelection.
637 * Returns: #TRUE if @obj implements the #AccessibleSelection interface,
641 Accessible_isSelection (Accessible *obj)
643 return cspi_accessible_is_a (obj,
644 "IDL:Accessibility/Selection:1.0");
648 * Accessible_isTable:
649 * @obj: a pointer to the #Accessible instance to query.
651 * Query whether the specified #Accessible implements #AccessibleTable.
653 * Returns: #TRUE if @obj implements the #AccessibleTable interface,
657 Accessible_isTable (Accessible *obj)
659 return cspi_accessible_is_a (obj,
660 "IDL:Accessibility/Table:1.0");
664 * Accessible_isStreamableContent:
665 * @obj: a pointer to the #Accessible instance to query.
667 * Query whether the specified #Accessible implements
668 * #AccessibleStreamableContent.
670 * Returns: #TRUE if @obj implements the #AccessibleStreamableContent interface,
674 Accessible_isStreamableContent (Accessible *obj)
676 return cspi_accessible_is_a (obj,
677 "IDL:Accessibility/StreamableContent:1.0");
682 * @obj: a pointer to the #Accessible instance to query.
684 * Query whether the specified #Accessible implements #AccessibleText.
686 * Returns: #TRUE if @obj implements the #AccessibleText interface,
690 Accessible_isText (Accessible *obj)
692 return cspi_accessible_is_a (obj,
693 "IDL:Accessibility/Text:1.0");
697 * Accessible_isValue:
698 * @obj: a pointer to the #Accessible instance to query.
700 * Query whether the specified #Accessible implements #AccessibleValue.
702 * Returns: #TRUE if @obj implements the #AccessibleValue interface,
706 Accessible_isValue (Accessible *obj)
708 return cspi_accessible_is_a (obj,
709 "IDL:Accessibility/Value:1.0");
713 * Accessible_getApplication:
714 * @obj: a pointer to the #Accessible instance to query.
716 * Get the #AccessibleApplication interface for an #Accessible.
718 * Returns: a pointer to an #AccessibleApplication interface instance, or
719 * NULL if @obj does not implement #AccessibleApplication.
721 AccessibleApplication *
722 Accessible_getApplication (Accessible *obj)
724 return (AccessibleApplication *) Accessible_queryInterface (
725 obj, "IDL:Accessibility/Application:1.0");
729 * Accessible_getAction:
730 * @obj: a pointer to the #Accessible instance to query.
732 * Get the #AccessibleAction interface for an #Accessible.
734 * Returns: a pointer to an #AccessibleAction interface instance, or
735 * NULL if @obj does not implement #AccessibleAction.
738 Accessible_getAction (Accessible *obj)
740 return (AccessibleAction *) Accessible_queryInterface (
741 obj, "IDL:Accessibility/Action:1.0");
745 * Accessible_getComponent:
746 * @obj: a pointer to the #Accessible instance to query.
748 * Get the #AccessibleComponent interface for an #Accessible.
750 * Returns: a pointer to an #AccessibleComponent interface instance, or
751 * NULL if @obj does not implement #AccessibleComponent.
753 AccessibleComponent *
754 Accessible_getComponent (Accessible *obj)
756 return (AccessibleComponent *) Accessible_queryInterface (
757 obj, "IDL:Accessibility/Component:1.0");
761 * Accessible_getEditableText:
762 * @obj: a pointer to the #Accessible instance to query.
764 * Get the #AccessibleEditableText interface for an #Accessible.
766 * Returns: a pointer to an #AccessibleEditableText interface instance, or
767 * NULL if @obj does not implement #AccessibleEditableText.
769 AccessibleEditableText *
770 Accessible_getEditableText (Accessible *obj)
772 return (AccessibleEditableText *) Accessible_queryInterface (
773 obj, "IDL:Accessibility/EditableText:1.0");
779 * Accessible_getHypertext:
780 * @obj: a pointer to the #Accessible instance to query.
782 * Get the #AccessibleHypertext interface for an #Accessible.
784 * Returns: a pointer to an #AccessibleHypertext interface instance, or
785 * NULL if @obj does not implement #AccessibleHypertext.
787 AccessibleHypertext *
788 Accessible_getHypertext (Accessible *obj)
790 return (AccessibleHypertext *) Accessible_queryInterface (
791 obj, "IDL:Accessibility/Hypertext:1.0");
797 * Accessible_getImage:
798 * @obj: a pointer to the #Accessible instance to query.
800 * Get the #AccessibleImage interface for an #Accessible.
802 * Returns: a pointer to an #AccessibleImage interface instance, or
803 * NULL if @obj does not implement #AccessibleImage.
806 Accessible_getImage (Accessible *obj)
808 return (AccessibleImage *) Accessible_queryInterface (
809 obj, "IDL:Accessibility/Image:1.0");
815 * Accessible_getSelection:
816 * @obj: a pointer to the #Accessible instance to query.
818 * Get the #AccessibleSelection interface for an #Accessible.
820 * Returns: a pointer to an #AccessibleSelection interface instance, or
821 * NULL if @obj does not implement #AccessibleSelection.
823 AccessibleSelection *
824 Accessible_getSelection (Accessible *obj)
826 return (AccessibleSelection *) Accessible_queryInterface (
827 obj, "IDL:Accessibility/Selection:1.0");
833 * Accessible_getStreamableContent:
834 * @obj: a pointer to the #Accessible instance to query.
836 * Get the #AccessibleStreamableContent interface for an #Accessible.
838 * Returns: a pointer to an #AccessibleStreamableContent interface instance, or
839 * NULL if @obj does not implement #AccessibleStreamableContent.
841 AccessibleStreamableContent *
842 Accessible_getStreamableContent (Accessible *obj)
844 return (AccessibleStreamableContent *) Accessible_queryInterface (
845 obj, "IDL:Accessibility/StreamableContent:1.0");
849 * Accessible_getTable:
850 * @obj: a pointer to the #Accessible instance to query.
852 * Get the #AccessibleTable interface for an #Accessible.
854 * Returns: a pointer to an #AccessibleTable interface instance, or
855 * NULL if @obj does not implement #AccessibleTable.
858 Accessible_getTable (Accessible *obj)
860 return (AccessibleTable *) Accessible_queryInterface (
861 obj, "IDL:Accessibility/Table:1.0");
865 * Accessible_getText:
866 * @obj: a pointer to the #Accessible instance to query.
868 * Get the #AccessibleText interface for an #Accessible.
870 * Returns: a pointer to an #AccessibleText interface instance, or
871 * NULL if @obj does not implement #AccessibleText.
874 Accessible_getText (Accessible *obj)
876 return (AccessibleText *) Accessible_queryInterface (
877 obj, "IDL:Accessibility/Text:1.0");
883 * Accessible_getValue:
884 * @obj: a pointer to the #Accessible instance to query.
886 * Get the #AccessibleValue interface for an #Accessible.
888 * Returns: a pointer to an #AccessibleValue interface instance, or
889 * NULL if @obj does not implement #AccessibleValue.
892 Accessible_getValue (Accessible *obj)
894 return (AccessibleValue *) Accessible_queryInterface (
895 obj, "IDL:Accessibility/Value:1.0");
901 * Accessible_queryInterface:
902 * @obj: a pointer to the #Accessible instance to query.
903 * @interface_name: a UTF-8 character string specifiying the requested interface.
905 * Query an #Accessible object to for a named interface.
907 * Returns: an instance of the named interface object, if it is implemented
908 * by @obj, or NULL otherwise.
912 Accessible_queryInterface (Accessible *obj,
913 const char *interface_name)
915 Bonobo_Unknown iface;
922 iface = Accessibility_Accessible_queryInterface (CSPI_OBJREF (obj),
927 cspi_return_val_if_ev ("queryInterface", NULL);
930 * FIXME: we need to be fairly sure that references are going
931 * to mach up if we are going to expose QueryInterface, ie. we
932 * can't allow people to do:
933 * b = a.qi ("b"); b.unref, b.unref to release a's reference.
934 * this should be no real problem though for this level of API
938 return cspi_object_add (iface);
943 * AccessibleRelation_ref:
944 * @obj: a pointer to the #AccessibleRelation object on which to operate.
946 * Increment the reference count for an #AccessibleRelation object.
950 AccessibleRelation_ref (AccessibleRelation *obj)
952 cspi_object_ref (obj);
956 * AccessibleRelation_unref:
957 * @obj: a pointer to the #AccessibleRelation object on which to operate.
959 * Decrement the reference count for an #AccessibleRelation object.
963 AccessibleRelation_unref (AccessibleRelation *obj)
965 cspi_object_unref (obj);
969 cspi_init_relation_type_table (AccessibleRelationType *relation_type_table)
972 for (i = 0; i < Accessibility_RELATION_LAST_DEFINED; ++i)
974 relation_type_table [i] = SPI_RELATION_NULL;
976 relation_type_table [Accessibility_RELATION_NULL] = SPI_RELATION_NULL;
977 relation_type_table [Accessibility_RELATION_LABEL_FOR] = SPI_RELATION_LABEL_FOR;
978 relation_type_table [Accessibility_RELATION_LABELLED_BY] = SPI_RELATION_LABELED_BY;
979 relation_type_table [Accessibility_RELATION_CONTROLLER_FOR] = SPI_RELATION_CONTROLLER_FOR;
980 relation_type_table [Accessibility_RELATION_CONTROLLED_BY] = SPI_RELATION_CONTROLLED_BY;
981 relation_type_table [Accessibility_RELATION_MEMBER_OF] = SPI_RELATION_MEMBER_OF;
982 relation_type_table [Accessibility_RELATION_TOOLTIP_FOR] = SPI_RELATION_NULL;
983 relation_type_table [Accessibility_RELATION_NODE_CHILD_OF] = SPI_RELATION_NODE_CHILD_OF;
984 relation_type_table [Accessibility_RELATION_EXTENDED] = SPI_RELATION_EXTENDED;
985 relation_type_table [Accessibility_RELATION_FLOWS_TO] = SPI_RELATION_FLOWS_TO;
986 relation_type_table [Accessibility_RELATION_FLOWS_FROM] = SPI_RELATION_FLOWS_FROM;
987 relation_type_table [Accessibility_RELATION_SUBWINDOW_OF] = SPI_RELATION_SUBWINDOW_OF;
988 relation_type_table [Accessibility_RELATION_EMBEDS] = SPI_RELATION_EMBEDS;
989 relation_type_table [Accessibility_RELATION_EMBEDDED_BY] = SPI_RELATION_EMBEDDED_BY;
990 relation_type_table [Accessibility_RELATION_POPUP_FOR] = SPI_RELATION_POPUP_FOR;
994 static AccessibleRelationType
995 cspi_relation_type_from_spi_relation_type (Accessibility_RelationType type)
997 /* array is sized according to IDL RelationType because IDL RelationTypes are the index */
998 static AccessibleRelationType cspi_relation_type_table [Accessibility_RELATION_LAST_DEFINED];
999 static SPIBoolean is_initialized = FALSE;
1000 AccessibleRelationType cspi_type;
1001 if (!is_initialized)
1003 is_initialized = cspi_init_relation_type_table (cspi_relation_type_table);
1005 if (type >= 0 && type < Accessibility_RELATION_LAST_DEFINED)
1007 cspi_type = cspi_relation_type_table [type];
1011 cspi_type = SPI_RELATION_NULL;
1016 * AccessibleRelation_getRelationType:
1017 * @obj: a pointer to the #AccessibleRelation object to query.
1019 * Get the type of relationship represented by an #AccessibleRelation.
1021 * Returns: an #AccessibleRelationType indicating the type of relation
1022 * encapsulated in this #AccessibleRelation object.
1025 AccessibleRelationType
1026 AccessibleRelation_getRelationType (AccessibleRelation *obj)
1028 Accessibility_RelationType retval;
1030 cspi_return_val_if_fail (obj, SPI_RELATION_NULL);
1032 Accessibility_Relation_getRelationType (CSPI_OBJREF (obj), cspi_ev());
1033 cspi_return_val_if_ev ("getRelationType", SPI_RELATION_NULL);
1034 return cspi_relation_type_from_spi_relation_type (retval);
1038 * AccessibleRelation_getNTargets:
1039 * @obj: a pointer to the #AccessibleRelation object to query.
1041 * Get the number of objects which this relationship has as its
1042 * target objects (the subject is the #Accessible from which this
1043 * #AccessibleRelation originated).
1045 * Returns: a short integer indicating how many target objects which the
1046 * originating #Accessible object has the #AccessibleRelation
1047 * relationship with.
1050 AccessibleRelation_getNTargets (AccessibleRelation *obj)
1054 cspi_return_val_if_fail (obj, -1);
1055 retval = Accessibility_Relation_getNTargets (CSPI_OBJREF (obj), cspi_ev());
1056 cspi_return_val_if_ev ("getNTargets", -1);
1061 * AccessibleRelation_getTarget:
1062 * @obj: a pointer to the #AccessibleRelation object to query.
1063 * @i: a (zero-index) integer indicating which (of possibly several) target is requested.
1065 * Get the @i-th target of a specified #AccessibleRelation relationship.
1067 * Returns: an #Accessible which is the @i-th object with which the
1068 * originating #Accessible has relationship specified in the
1069 * #AccessibleRelation object.
1073 AccessibleRelation_getTarget (AccessibleRelation *obj, int i)
1077 cspi_return_val_if_fail (obj, NULL);
1079 retval = cspi_object_add (
1080 Accessibility_Relation_getTarget (CSPI_OBJREF(obj),
1082 cspi_return_val_if_ev ("getTarget", NULL);
1087 * AccessibleStateSet_ref:
1088 * @obj: a pointer to the #AccessibleStateSet object on which to operate.
1090 * Increment the reference count for an #AccessibleStateSet object.
1094 AccessibleStateSet_ref (AccessibleStateSet *obj)
1096 spi_state_set_cache_ref (obj);
1100 * AccessibleStateSet_unref:
1101 * @obj: a pointer to the #AccessibleStateSet object on which to operate.
1103 * Decrement the reference count for an #AccessibleStateSet object.
1107 AccessibleStateSet_unref (AccessibleStateSet *obj)
1109 spi_state_set_cache_unref (obj);
1112 static Accessibility_StateType
1113 spi_state_to_corba (AccessibleState state)
1115 #define MAP_STATE(a) \
1116 case SPI_STATE_##a: \
1117 return Accessibility_STATE_##a
1121 MAP_STATE (INVALID);
1125 MAP_STATE (CHECKED);
1126 MAP_STATE (DEFUNCT);
1127 MAP_STATE (EDITABLE);
1128 MAP_STATE (ENABLED);
1129 MAP_STATE (EXPANDABLE);
1130 MAP_STATE (EXPANDED);
1131 MAP_STATE (FOCUSABLE);
1132 MAP_STATE (FOCUSED);
1133 MAP_STATE (HORIZONTAL);
1134 MAP_STATE (ICONIFIED);
1136 MAP_STATE (MULTI_LINE);
1137 MAP_STATE (MULTISELECTABLE);
1139 MAP_STATE (PRESSED);
1140 MAP_STATE (RESIZABLE);
1141 MAP_STATE (SELECTABLE);
1142 MAP_STATE (SELECTED);
1143 MAP_STATE (SENSITIVE);
1144 MAP_STATE (SHOWING);
1145 MAP_STATE (SINGLE_LINE);
1147 MAP_STATE (TRANSIENT);
1148 MAP_STATE (VERTICAL);
1149 MAP_STATE (VISIBLE);
1150 MAP_STATE (MANAGES_DESCENDANTS);
1151 MAP_STATE (INDETERMINATE);
1153 return Accessibility_STATE_INVALID;
1159 * AccessibleStateSet_contains:
1160 * @obj: a pointer to the #AccessibleStateSet object on which to operate.
1161 * @state: an #AccessibleState for which the specified #AccessibleStateSet
1164 * Determine whether a given #AccessibleStateSet includes a given state; that is,
1165 * whether @state is true for the stateset in question.
1167 * Returns: #TRUE if @state is true/included in the given #AccessibleStateSet,
1172 AccessibleStateSet_contains (AccessibleStateSet *obj,
1173 AccessibleState state)
1175 return spi_state_set_cache_contains (obj, spi_state_to_corba (state));
1179 * AccessibleStateSet_add:
1180 * @obj: a pointer to the #AccessibleStateSet object on which to operate.
1181 * @state: an #AccessibleState to be added to the specified #AccessibleStateSet
1183 * Add a particular #AccessibleState to an #AccessibleStateSet (i.e. set the
1184 * given state to #TRUE in the stateset.
1188 AccessibleStateSet_add (AccessibleStateSet *obj,
1189 AccessibleState state)
1191 spi_state_set_cache_add (obj, spi_state_to_corba (state));
1195 * AccessibleStateSet_remove:
1196 * @obj: a pointer to the #AccessibleStateSet object on which to operate.
1197 * @state: an #AccessibleState to be removed from the specified #AccessibleStateSet
1199 * Remove a particular #AccessibleState to an #AccessibleStateSet (i.e. set the
1200 * given state to #FALSE in the stateset.)
1204 AccessibleStateSet_remove (AccessibleStateSet *obj,
1205 AccessibleState state)
1207 spi_state_set_cache_remove (obj, spi_state_to_corba (state));
1211 * AccessibleStateSet_equals:
1212 * @obj: a pointer to the first #AccessibleStateSet object on which to operate.
1213 * @obj2: a pointer to the second #AccessibleStateSet object on which to operate.
1215 * Determine whether two instances of #AccessibleStateSet are equivalent (i.e.
1216 * consist of the same #AccessibleStates). Useful for checking multiple
1217 * state variables at once; construct the target state then compare against it.
1219 * @see AccessibleStateSet_compare().
1221 * Returns: #TRUE if the two #AccessibleStateSets are equivalent,
1226 AccessibleStateSet_equals (AccessibleStateSet *obj,
1227 AccessibleStateSet *obj2)
1237 cmp = spi_state_set_cache_xor (obj, obj2);
1238 eq = spi_state_set_cache_is_empty (cmp);
1239 spi_state_set_cache_unref (cmp);
1245 * AccessibleStateSet_compare:
1246 * @obj: a pointer to the first #AccessibleStateSet object on which to operate.
1247 * @obj2: a pointer to the second #AccessibleStateSet object on which to operate.
1249 * Determine the differences between two instances of #AccessibleStateSet.
1250 * Not Yet Implemented.
1252 * @see AccessibleStateSet_equals().
1254 * Returns: an #AccessibleStateSet object containing all states contained on one of
1255 * the two sets but not the other.
1258 AccessibleStateSet *
1259 AccessibleStateSet_compare (AccessibleStateSet *obj,
1260 AccessibleStateSet *obj2)
1262 return spi_state_set_cache_xor (obj, obj2);
1266 * AccessibleStateSet_isEmpty:
1267 * @obj: a pointer to the #AccessibleStateSet object on which to operate.
1269 * Determine whether a given #AccessibleStateSet is the empty set.
1271 * Returns: #TRUE if the given #AccessibleStateSet contains no (true) states,
1276 AccessibleStateSet_isEmpty (AccessibleStateSet *obj)
1278 return spi_state_set_cache_is_empty (obj);