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",
118 "input method window"
121 #define MAX_ROLES (sizeof (role_names) / sizeof (char *))
124 cspi_init_role_table (AccessibleRole *role_table)
127 for (i = 0; i < Accessibility_ROLE_LAST_DEFINED; ++i)
129 role_table [i] = SPI_ROLE_UNKNOWN;
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;
224 cspi_role_from_spi_role (Accessibility_Role role)
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;
232 is_initialized = cspi_init_role_table (cspi_role_table);
234 if (role >= 0 && role < Accessibility_ROLE_LAST_DEFINED)
236 cspi_role = cspi_role_table [role];
240 cspi_role = SPI_ROLE_EXTENDED;
245 AccessibleAttributeSet *
246 _cspi_attribute_set_from_sequence (const Accessibility_AttributeSet *seq)
248 AccessibleAttributeSet *set = g_new0 (AccessibleAttributeSet, 1);
251 set->len = seq->_length;
252 set->attributes = g_new0 (char *, set->len);
253 for (i = 0; i < set->len; ++i)
255 set->attributes[i] = g_strdup (seq->_buffer [i]);
261 * AccessibleRole_getName:
262 * @role: an #AccessibleRole object to query.
264 * Get a localizeable string that indicates the name of an #AccessibleRole.
265 * <em>DEPRECATED.</em>
267 * Returns: a localizable string name for an #AccessibleRole enumerated type.
270 AccessibleRole_getName (AccessibleRole role)
272 if (role < MAX_ROLES && role_names [(int) role])
274 return CORBA_string_dup (role_names [(int) role]);
278 return CORBA_string_dup ("");
284 * @obj: a pointer to the #Accessible object on which to operate.
286 * Increment the reference count for an #Accessible object.
289 Accessible_ref (Accessible *obj)
291 cspi_object_ref (obj);
296 * @obj: a pointer to the #Accessible object on which to operate.
298 * Decrement the reference count for an #Accessible object.
301 Accessible_unref (Accessible *obj)
303 cspi_object_unref (obj);
307 * Accessible_getName:
308 * @obj: a pointer to the #Accessible object on which to operate.
310 * Get the name of an #Accessible object.
312 * Returns: a UTF-8 string indicating the name of the #Accessible object.
313 * or NULL on exception
316 Accessible_getName (Accessible *obj)
320 cspi_return_val_if_fail (obj != NULL, NULL);
322 retval = Accessibility_Accessible__get_name (CSPI_OBJREF (obj), cspi_ev ());
324 cspi_return_val_if_ev ("getName", NULL);
330 * Accessible_getDescription:
331 * @obj: a pointer to the #Accessible object on which to operate.
333 * Get the description of an #Accessible object.
335 * Returns: a UTF-8 string describing the #Accessible object.
336 * or NULL on exception
339 Accessible_getDescription (Accessible *obj)
343 cspi_return_val_if_fail (obj != NULL, NULL);
345 retval = Accessibility_Accessible__get_description (CSPI_OBJREF (obj),
348 cspi_return_val_if_ev ("getDescription", NULL);
354 * Accessible_getParent:
355 * @obj: a pointer to the #Accessible object to query.
357 * Get an #Accessible object's parent container.
359 * Returns: a pointer tothe #Accessible object which contains the given
360 * #Accessible instance, or NULL if the @obj has no parent container.
364 Accessible_getParent (Accessible *obj)
368 cspi_return_val_if_fail (obj != NULL, NULL);
370 retval = cspi_object_add (
371 Accessibility_Accessible__get_parent (CSPI_OBJREF (obj),
374 cspi_return_val_if_ev ("getParent", NULL);
380 * Accessible_getChildCount:
381 * @obj: a pointer to the #Accessible object on which to operate.
383 * Get the number of children contained by an #Accessible object.
385 * Returns: a #long indicating the number of #Accessible children
386 * contained by an #Accessible object. or -1 on exception
390 Accessible_getChildCount (Accessible *obj)
394 cspi_return_val_if_fail (obj != NULL, -1);
396 retval = Accessibility_Accessible__get_childCount (CSPI_OBJREF (obj),
399 cspi_return_val_if_ev ("getChildCount", -1);
405 * Accessible_getChildAtIndex:
406 * @obj: a pointer to the #Accessible object on which to operate.
407 * @childIndex: a #long indicating which child is specified.
409 * Get the #Accessible child of an #Accessible object at a given index.
411 * Returns: a pointer to the #Accessible child object at index
412 * @childIndex. or NULL on exception
415 Accessible_getChildAtIndex (Accessible *obj,
420 cspi_return_val_if_fail (obj != NULL, NULL);
422 retval = cspi_object_add (
423 Accessibility_Accessible_getChildAtIndex (CSPI_OBJREF (obj),
424 childIndex, cspi_ev ()));
426 cspi_return_val_if_ev ("getChildAtIndex", NULL);
431 * Accessible_getIndexInParent:
432 * @obj: a pointer to the #Accessible object on which to operate.
434 * Get the index of an #Accessible object in its containing #Accessible.
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.
441 Accessible_getIndexInParent (Accessible *obj)
445 cspi_return_val_if_fail (obj != NULL, -1);
447 retval = Accessibility_Accessible_getIndexInParent (CSPI_OBJREF (obj), cspi_ev ());
449 cspi_return_val_if_ev ("getIndexInparent", -1);
454 * Accessible_getRelationSet:
455 * @obj: a pointer to the #Accessible object on which to operate.
457 * Get the set of #AccessibleRelation objects which describe this #Accessible object's
458 * relationships with other #Accessible objects.
460 * Returns: an array of #AccessibleRelation pointers. or NULL on exception
462 AccessibleRelation **
463 Accessible_getRelationSet (Accessible *obj)
467 AccessibleRelation **relations;
468 Accessibility_RelationSet *relation_set;
470 cspi_return_val_if_fail (obj != NULL, NULL);
472 g_assert (!cspi_exception ());
475 Accessibility_Accessible_getRelationSet (CSPI_OBJREF (obj), cspi_ev ());
477 cspi_return_val_if_ev ("getRelationSet", NULL);
479 n_relations = relation_set->_length;
480 relations = malloc (sizeof (AccessibleRelation *) * (n_relations + 1));
482 for (i = 0; i < n_relations; ++i)
484 relations[i] = cspi_object_add (CORBA_Object_duplicate (
485 relation_set->_buffer[i], cspi_ev ()));
489 CORBA_free (relation_set);
495 * Accessible_getRole:
496 * @obj: a pointer to the #Accessible object on which to operate.
498 * Get the UI role of an #Accessible object.
499 * A UTF-8 string describing this role can be obtained via Accessible_getRoleName ().
501 * Returns: the #AccessibleRole of the object.
505 Accessible_getRole (Accessible *obj)
507 Accessibility_Role retval;
509 cspi_return_val_if_fail (obj != NULL, SPI_ROLE_INVALID);
512 Accessibility_Accessible_getRole (CSPI_OBJREF (obj), cspi_ev ());
514 cspi_return_val_if_ev ("getRole", SPI_ROLE_INVALID);
516 return cspi_role_from_spi_role (retval);
520 * Accessible_getRoleName:
521 * @obj: a pointer to the #Accessible object on which to operate.
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 ().
527 * Returns: a UTF-8 string specifying the role of this #Accessible object.
531 Accessible_getRoleName (Accessible *obj)
535 cspi_return_val_if_fail (obj != NULL, CORBA_string_dup ("invalid"));
538 Accessibility_Accessible_getRoleName (CSPI_OBJREF (obj), cspi_ev ());
540 cspi_return_val_if_ev ("getRoleName", CORBA_string_dup ("invalid"));
546 * Accessible_getLocalizedRoleName:
547 * @obj: a pointer to the #Accessible object on which to operate.
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 ().
555 * Returns: a UTF-8 string specifying the role of this #Accessible object.
559 Accessible_getLocalizedRoleName (Accessible *obj)
563 cspi_return_val_if_fail (obj != NULL, CORBA_string_dup ("invalid"));
566 Accessibility_Accessible_getLocalizedRoleName (CSPI_OBJREF (obj), cspi_ev ());
568 cspi_return_val_if_ev ("getLocalizedRoleName", CORBA_string_dup ("invalid"));
574 * Accessible_getStateSet:
575 * @obj: a pointer to the #Accessible object on which to operate.
577 * Gets the current state of an object.
579 * Returns: a pointer to an #AccessibleStateSet representing the object's current state.
582 Accessible_getStateSet (Accessible *obj)
584 AccessibleStateSet *retval;
585 Accessibility_StateSet corba_stateset;
586 Accessibility_StateSeq *corba_seq;
588 cspi_return_val_if_fail (obj != NULL, NULL);
590 corba_stateset = Accessibility_Accessible_getState (
591 CSPI_OBJREF (obj), cspi_ev ());
592 cspi_return_val_if_ev ("getState", NULL);
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);
599 retval = spi_state_set_cache_new (corba_seq);
601 CORBA_free (corba_seq);
602 cspi_release_unref (corba_stateset);
608 * Accessible_getAttributes:
609 * @obj: The #Accessible being queried.
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.
616 * Returns: The name-value-pair attributes assigned to this object.
618 AccessibleAttributeSet *
619 Accessible_getAttributes (Accessible *obj)
621 AccessibleAttributeSet *retval;
622 Accessibility_AttributeSet *corba_seq;
624 cspi_return_val_if_fail (obj != NULL, NULL);
626 corba_seq = Accessibility_Accessible_getAttributes (
627 CSPI_OBJREF (obj), cspi_ev ());
628 cspi_return_val_if_ev ("getAttributes", NULL);
630 retval = _cspi_attribute_set_from_sequence (corba_seq);
631 CORBA_free (corba_seq);
637 * Accessible_getHostApplication:
638 * @obj: The #Accessible being queried.
640 * Get the containing #AccessibleApplication for an object.
642 * Returns: the containing AccessibleApplication instance for this object.
644 AccessibleApplication *
645 Accessible_getHostApplication (Accessible *obj)
647 AccessibleApplication *retval;
649 cspi_return_val_if_fail (obj != NULL, NULL);
651 retval = Accessible_getApplication (cspi_object_add (
652 Accessibility_Accessible_getApplication (CSPI_OBJREF (obj),
654 cspi_return_val_if_ev ("getApplication", NULL);
659 /* Interface query methods */
662 * Accessible_isAction:
663 * @obj: a pointer to the #Accessible instance to query.
665 * Query whether the specified #Accessible implements #AccessibleAction.
667 * Returns: #TRUE if @obj implements the #AccessibleAction interface,
671 Accessible_isAction (Accessible *obj)
673 return cspi_accessible_is_a (obj,
674 "IDL:Accessibility/Action:1.0");
678 * Accessible_isApplication:
679 * @obj: a pointer to the #Accessible instance to query.
681 * Query whether the specified #Accessible implements #AccessibleApplication.
683 * Returns: #TRUE if @obj implements the #AccessibleApplication interface,
687 Accessible_isApplication (Accessible *obj)
689 return cspi_accessible_is_a (obj,
690 "IDL:Accessibility/Application:1.0");
694 * Accessible_isCollection: * @obj: a pointer to the #Accessible instance to query.
696 * Query whether the specified #Accessible implements #AccessibleCollection.
697 * Returns: #TRUE if @obj implements the #AccessibleCollection interface,
702 Accessible_isCollection (Accessible *obj)
704 return cspi_accessible_is_a (obj,
705 "IDL:Accessibility/Collection:1.0");
709 * Accessible_isComponent:
710 * @obj: a pointer to the #Accessible instance to query.
712 * Query whether the specified #Accessible implements #AccessibleComponent.
714 * Returns: #TRUE if @obj implements the #AccessibleComponent interface,
718 Accessible_isComponent (Accessible *obj)
720 return cspi_accessible_is_a (obj,
721 "IDL:Accessibility/Component:1.0");
725 * Accessible_isDocument:
726 * @obj: a pointer to the #Accessible instance to query.
728 * Query whether the specified #Accessible implements #AccessibleDocument.
730 * Returns: #TRUE if @obj implements the #AccessibleDocument interface,
734 Accessible_isDocument (Accessible *obj)
736 return cspi_accessible_is_a (obj,
737 "IDL:Accessibility/Document:1.0");
741 * Accessible_isEditableText:
742 * @obj: a pointer to the #Accessible instance to query.
744 * Query whether the specified #Accessible implements #AccessibleEditableText.
746 * Returns: #TRUE if @obj implements the #AccessibleEditableText interface,
750 Accessible_isEditableText (Accessible *obj)
752 return cspi_accessible_is_a (obj,
753 "IDL:Accessibility/EditableText:1.0");
757 * Accessible_isMatchRule:
758 * @obj: a pointer to the #Accessible instance to query.
760 * Query whether the specified #Accessible implements #AccessibleMatchRule.
762 * Returns: #TRUE if @obj implements the #AccessibleMatchRule interface,
766 Accessible_isMatchRule (Accessible *obj)
768 return cspi_accessible_is_a (obj,
769 "IDL:Accessibility/MatchRule:1.0");
773 * Accessible_isHypertext:
774 * @obj: a pointer to the #Accessible instance to query.
776 * Query whether the specified #Accessible implements #AccessibleHypertext.
778 * Returns: #TRUE if @obj implements the #AccessibleHypertext interface,
782 Accessible_isHypertext (Accessible *obj)
784 return cspi_accessible_is_a (obj,
785 "IDL:Accessibility/Hypertext:1.0");
789 * Accessible_isImage:
790 * @obj: a pointer to the #Accessible instance to query.
792 * Query whether the specified #Accessible implements #AccessibleImage.
794 * Returns: #TRUE if @obj implements the #AccessibleImage interface,
798 Accessible_isImage (Accessible *obj)
800 return cspi_accessible_is_a (obj,
801 "IDL:Accessibility/Image:1.0");
805 * Accessible_isSelection:
806 * @obj: a pointer to the #Accessible instance to query.
808 * Query whether the specified #Accessible implements #AccessibleSelection.
810 * Returns: #TRUE if @obj implements the #AccessibleSelection interface,
814 Accessible_isSelection (Accessible *obj)
816 return cspi_accessible_is_a (obj,
817 "IDL:Accessibility/Selection:1.0");
821 * Accessible_isTable:
822 * @obj: a pointer to the #Accessible instance to query.
824 * Query whether the specified #Accessible implements #AccessibleTable.
826 * Returns: #TRUE if @obj implements the #AccessibleTable interface,
830 Accessible_isTable (Accessible *obj)
832 return cspi_accessible_is_a (obj,
833 "IDL:Accessibility/Table:1.0");
837 * Accessible_isStreamableContent:
838 * @obj: a pointer to the #Accessible instance to query.
840 * Query whether the specified #Accessible implements
841 * #AccessibleStreamableContent.
843 * Returns: #TRUE if @obj implements the #AccessibleStreamableContent interface,
847 Accessible_isStreamableContent (Accessible *obj)
849 return cspi_accessible_is_a (obj,
850 "IDL:Accessibility/StreamableContent:1.0");
855 * @obj: a pointer to the #Accessible instance to query.
857 * Query whether the specified #Accessible implements #AccessibleText.
859 * Returns: #TRUE if @obj implements the #AccessibleText interface,
863 Accessible_isText (Accessible *obj)
865 return cspi_accessible_is_a (obj,
866 "IDL:Accessibility/Text:1.0");
870 * Accessible_isValue:
871 * @obj: a pointer to the #Accessible instance to query.
873 * Query whether the specified #Accessible implements #AccessibleValue.
875 * Returns: #TRUE if @obj implements the #AccessibleValue interface,
879 Accessible_isValue (Accessible *obj)
881 return cspi_accessible_is_a (obj,
882 "IDL:Accessibility/Value:1.0");
886 * Accessible_getApplication:
887 * @obj: a pointer to the #Accessible instance to query.
889 * Get the #AccessibleApplication interface for an #Accessible.
891 * Returns: a pointer to an #AccessibleApplication interface instance, or
892 * NULL if @obj does not implement #AccessibleApplication.
894 AccessibleApplication *
895 Accessible_getApplication (Accessible *obj)
897 return (AccessibleApplication *) Accessible_queryInterface (
898 obj, "IDL:Accessibility/Application:1.0");
902 * Accessible_getAction:
903 * @obj: a pointer to the #Accessible instance to query.
905 * Get the #AccessibleAction interface for an #Accessible.
907 * Returns: a pointer to an #AccessibleAction interface instance, or
908 * NULL if @obj does not implement #AccessibleAction.
911 Accessible_getAction (Accessible *obj)
913 return (AccessibleAction *) Accessible_queryInterface (
914 obj, "IDL:Accessibility/Action:1.0");
919 * Accessible_getCollection:
920 * @obj: a pointer to the #Accessible instance to query.
922 * Get the #AccessibleCollection interface for an #Accessible.
924 * Returns: a pointer to an #AccessibleCollection interface instance, or
925 * NULL if @obj does not implement #AccessibleCollection.
927 AccessibleCollection *
928 Accessible_getCollection (Accessible *obj)
930 return (AccessibleCollection *) Accessible_queryInterface (
931 obj, "IDL:Accessibility/Collection:1.0");
935 * Accessible_getComponent:
936 * @obj: a pointer to the #Accessible instance to query.
938 * Get the #AccessibleComponent interface for an #Accessible.
940 * Returns: a pointer to an #AccessibleComponent interface instance, or
941 * NULL if @obj does not implement #AccessibleComponent.
943 AccessibleComponent *
944 Accessible_getComponent (Accessible *obj)
946 return (AccessibleComponent *) Accessible_queryInterface (
947 obj, "IDL:Accessibility/Component:1.0");
950 * Accessible_getDocument:
951 * @obj: a pointer to the #Accessible instance to query.
953 * Get the #AccessibleDocument interface for an #Accessible.
955 * Returns: a pointer to an #AccessibleDocument interface instance, or
956 * NULL if @obj does not implement #AccessibleDocument.
959 Accessible_getDocument (Accessible *obj)
961 return (AccessibleDocument *) Accessible_queryInterface (
962 obj, "IDL:Accessibility/Document:1.0");
966 * Accessible_getEditableText:
967 * @obj: a pointer to the #Accessible instance to query.
969 * Get the #AccessibleEditableText interface for an #Accessible.
971 * Returns: a pointer to an #AccessibleEditableText interface instance, or
972 * NULL if @obj does not implement #AccessibleEditableText.
974 AccessibleEditableText *
975 Accessible_getEditableText (Accessible *obj)
977 return (AccessibleEditableText *) Accessible_queryInterface (
978 obj, "IDL:Accessibility/EditableText:1.0");
984 * Accessible_getHypertext:
985 * @obj: a pointer to the #Accessible instance to query.
987 * Get the #AccessibleHypertext interface for an #Accessible.
989 * Returns: a pointer to an #AccessibleHypertext interface instance, or
990 * NULL if @obj does not implement #AccessibleHypertext.
992 AccessibleHypertext *
993 Accessible_getHypertext (Accessible *obj)
995 return (AccessibleHypertext *) Accessible_queryInterface (
996 obj, "IDL:Accessibility/Hypertext:1.0");
1002 * Accessible_getImage:
1003 * @obj: a pointer to the #Accessible instance to query.
1005 * Get the #AccessibleImage interface for an #Accessible.
1007 * Returns: a pointer to an #AccessibleImage interface instance, or
1008 * NULL if @obj does not implement #AccessibleImage.
1011 Accessible_getImage (Accessible *obj)
1013 return (AccessibleImage *) Accessible_queryInterface (
1014 obj, "IDL:Accessibility/Image:1.0");
1018 * Accessible_getMatchRule:
1019 * @obj: a pointer to the #Accessible instance to query.
1021 * Get the #AccessibleMatchRule interface for an #Accessible.
1023 * Returns: a pointer to an #AccessibleMatchRule interface instance, or
1024 * NULL if @obj does not implement #AccessibleMatchRule.
1026 AccessibleMatchRule *
1027 Accessible_getMatchRule (Accessible *obj)
1029 return (AccessibleMatchRule *) Accessible_queryInterface (
1030 obj, "IDL:Accessibility/MatchRule:1.0");
1034 * Accessible_getSelection:
1035 * @obj: a pointer to the #Accessible instance to query.
1037 * Get the #AccessibleSelection interface for an #Accessible.
1039 * Returns: a pointer to an #AccessibleSelection interface instance, or
1040 * NULL if @obj does not implement #AccessibleSelection.
1042 AccessibleSelection *
1043 Accessible_getSelection (Accessible *obj)
1045 return (AccessibleSelection *) Accessible_queryInterface (
1046 obj, "IDL:Accessibility/Selection:1.0");
1052 * Accessible_getStreamableContent:
1053 * @obj: a pointer to the #Accessible instance to query.
1055 * Get the #AccessibleStreamableContent interface for an #Accessible.
1057 * Returns: a pointer to an #AccessibleStreamableContent interface instance, or
1058 * NULL if @obj does not implement #AccessibleStreamableContent.
1060 AccessibleStreamableContent *
1061 Accessible_getStreamableContent (Accessible *obj)
1063 return (AccessibleStreamableContent *) Accessible_queryInterface (
1064 obj, "IDL:Accessibility/StreamableContent:1.0");
1068 * Accessible_getTable:
1069 * @obj: a pointer to the #Accessible instance to query.
1071 * Get the #AccessibleTable interface for an #Accessible.
1073 * Returns: a pointer to an #AccessibleTable interface instance, or
1074 * NULL if @obj does not implement #AccessibleTable.
1077 Accessible_getTable (Accessible *obj)
1079 return (AccessibleTable *) Accessible_queryInterface (
1080 obj, "IDL:Accessibility/Table:1.0");
1084 * Accessible_getText:
1085 * @obj: a pointer to the #Accessible instance to query.
1087 * Get the #AccessibleText interface for an #Accessible.
1089 * Returns: a pointer to an #AccessibleText interface instance, or
1090 * NULL if @obj does not implement #AccessibleText.
1093 Accessible_getText (Accessible *obj)
1095 return (AccessibleText *) Accessible_queryInterface (
1096 obj, "IDL:Accessibility/Text:1.0");
1102 * Accessible_getValue:
1103 * @obj: a pointer to the #Accessible instance to query.
1105 * Get the #AccessibleValue interface for an #Accessible.
1107 * Returns: a pointer to an #AccessibleValue interface instance, or
1108 * NULL if @obj does not implement #AccessibleValue.
1111 Accessible_getValue (Accessible *obj)
1113 return (AccessibleValue *) Accessible_queryInterface (
1114 obj, "IDL:Accessibility/Value:1.0");
1120 * Accessible_queryInterface:
1121 * @obj: a pointer to the #Accessible instance to query.
1122 * @interface_name: a UTF-8 character string specifiying the requested interface.
1124 * Query an #Accessible object to for a named interface.
1126 * Returns: an instance of the named interface object, if it is implemented
1127 * by @obj, or NULL otherwise.
1131 Accessible_queryInterface (Accessible *obj,
1132 const char *interface_name)
1134 Bonobo_Unknown iface;
1141 iface = Accessibility_Accessible_queryInterface (CSPI_OBJREF (obj),
1146 cspi_return_val_if_ev ("queryInterface", NULL);
1149 * FIXME: we need to be fairly sure that references are going
1150 * to mach up if we are going to expose QueryInterface, ie. we
1151 * can't allow people to do:
1152 * b = a.qi ("b"); b.unref, b.unref to release a's reference.
1153 * this should be no real problem though for this level of API
1157 return cspi_object_add (iface);
1162 * AccessibleRelation_ref:
1163 * @obj: a pointer to the #AccessibleRelation object on which to operate.
1165 * Increment the reference count for an #AccessibleRelation object.
1169 AccessibleRelation_ref (AccessibleRelation *obj)
1171 cspi_object_ref (obj);
1175 * AccessibleRelation_unref:
1176 * @obj: a pointer to the #AccessibleRelation object on which to operate.
1178 * Decrement the reference count for an #AccessibleRelation object.
1182 AccessibleRelation_unref (AccessibleRelation *obj)
1184 cspi_object_unref (obj);
1188 cspi_init_relation_type_table (AccessibleRelationType *relation_type_table)
1191 for (i = 0; i < Accessibility_RELATION_LAST_DEFINED; ++i)
1193 relation_type_table [i] = SPI_RELATION_NULL;
1195 relation_type_table [Accessibility_RELATION_NULL] = SPI_RELATION_NULL;
1196 relation_type_table [Accessibility_RELATION_LABEL_FOR] = SPI_RELATION_LABEL_FOR;
1197 relation_type_table [Accessibility_RELATION_LABELLED_BY] = SPI_RELATION_LABELED_BY;
1198 relation_type_table [Accessibility_RELATION_CONTROLLER_FOR] = SPI_RELATION_CONTROLLER_FOR;
1199 relation_type_table [Accessibility_RELATION_CONTROLLED_BY] = SPI_RELATION_CONTROLLED_BY;
1200 relation_type_table [Accessibility_RELATION_MEMBER_OF] = SPI_RELATION_MEMBER_OF;
1201 relation_type_table [Accessibility_RELATION_TOOLTIP_FOR] = SPI_RELATION_NULL;
1202 relation_type_table [Accessibility_RELATION_NODE_CHILD_OF] = SPI_RELATION_NODE_CHILD_OF;
1203 relation_type_table [Accessibility_RELATION_EXTENDED] = SPI_RELATION_EXTENDED;
1204 relation_type_table [Accessibility_RELATION_FLOWS_TO] = SPI_RELATION_FLOWS_TO;
1205 relation_type_table [Accessibility_RELATION_FLOWS_FROM] = SPI_RELATION_FLOWS_FROM;
1206 relation_type_table [Accessibility_RELATION_SUBWINDOW_OF] = SPI_RELATION_SUBWINDOW_OF;
1207 relation_type_table [Accessibility_RELATION_EMBEDS] = SPI_RELATION_EMBEDS;
1208 relation_type_table [Accessibility_RELATION_EMBEDDED_BY] = SPI_RELATION_EMBEDDED_BY;
1209 relation_type_table [Accessibility_RELATION_POPUP_FOR] = SPI_RELATION_POPUP_FOR;
1210 relation_type_table [Accessibility_RELATION_PARENT_WINDOW_OF] = SPI_RELATION_PARENT_WINDOW_OF;
1211 relation_type_table [Accessibility_RELATION_DESCRIBED_BY] = SPI_RELATION_DESCRIBED_BY;
1212 relation_type_table [Accessibility_RELATION_DESCRIPTION_FOR] = SPI_RELATION_DESCRIPTION_FOR;
1216 static AccessibleRelationType
1217 cspi_relation_type_from_spi_relation_type (Accessibility_RelationType type)
1219 /* array is sized according to IDL RelationType because IDL RelationTypes are the index */
1220 static AccessibleRelationType cspi_relation_type_table [Accessibility_RELATION_LAST_DEFINED];
1221 static SPIBoolean is_initialized = FALSE;
1222 AccessibleRelationType cspi_type;
1223 if (!is_initialized)
1225 is_initialized = cspi_init_relation_type_table (cspi_relation_type_table);
1227 if (type >= 0 && type < Accessibility_RELATION_LAST_DEFINED)
1229 cspi_type = cspi_relation_type_table [type];
1233 cspi_type = SPI_RELATION_NULL;
1238 * AccessibleRelation_getRelationType:
1239 * @obj: a pointer to the #AccessibleRelation object to query.
1241 * Get the type of relationship represented by an #AccessibleRelation.
1243 * Returns: an #AccessibleRelationType indicating the type of relation
1244 * encapsulated in this #AccessibleRelation object.
1247 AccessibleRelationType
1248 AccessibleRelation_getRelationType (AccessibleRelation *obj)
1250 Accessibility_RelationType retval;
1252 cspi_return_val_if_fail (obj, SPI_RELATION_NULL);
1254 Accessibility_Relation_getRelationType (CSPI_OBJREF (obj), cspi_ev());
1255 cspi_return_val_if_ev ("getRelationType", SPI_RELATION_NULL);
1256 return cspi_relation_type_from_spi_relation_type (retval);
1260 * AccessibleRelation_getNTargets:
1261 * @obj: a pointer to the #AccessibleRelation object to query.
1263 * Get the number of objects which this relationship has as its
1264 * target objects (the subject is the #Accessible from which this
1265 * #AccessibleRelation originated).
1267 * Returns: a short integer indicating how many target objects which the
1268 * originating #Accessible object has the #AccessibleRelation
1269 * relationship with.
1272 AccessibleRelation_getNTargets (AccessibleRelation *obj)
1276 cspi_return_val_if_fail (obj, -1);
1277 retval = Accessibility_Relation_getNTargets (CSPI_OBJREF (obj), cspi_ev());
1278 cspi_return_val_if_ev ("getNTargets", -1);
1283 * AccessibleRelation_getTarget:
1284 * @obj: a pointer to the #AccessibleRelation object to query.
1285 * @i: a (zero-index) integer indicating which (of possibly several) target is requested.
1287 * Get the @i-th target of a specified #AccessibleRelation relationship.
1289 * Returns: an #Accessible which is the @i-th object with which the
1290 * originating #Accessible has relationship specified in the
1291 * #AccessibleRelation object.
1295 AccessibleRelation_getTarget (AccessibleRelation *obj, int i)
1299 cspi_return_val_if_fail (obj, NULL);
1301 retval = cspi_object_add (
1302 Accessibility_Relation_getTarget (CSPI_OBJREF(obj),
1304 cspi_return_val_if_ev ("getTarget", NULL);
1309 * AccessibleStateSet_ref:
1310 * @obj: a pointer to the #AccessibleStateSet object on which to operate.
1312 * Increment the reference count for an #AccessibleStateSet object.
1316 AccessibleStateSet_ref (AccessibleStateSet *obj)
1318 spi_state_set_cache_ref (obj);
1322 * AccessibleStateSet_unref:
1323 * @obj: a pointer to the #AccessibleStateSet object on which to operate.
1325 * Decrement the reference count for an #AccessibleStateSet object.
1329 AccessibleStateSet_unref (AccessibleStateSet *obj)
1331 spi_state_set_cache_unref (obj);
1334 static Accessibility_StateType
1335 spi_state_to_corba (AccessibleState state)
1337 #define MAP_STATE(a) \
1338 case SPI_STATE_##a: \
1339 return Accessibility_STATE_##a
1343 MAP_STATE (INVALID);
1347 MAP_STATE (CHECKED);
1348 MAP_STATE (DEFUNCT);
1349 MAP_STATE (EDITABLE);
1350 MAP_STATE (ENABLED);
1351 MAP_STATE (EXPANDABLE);
1352 MAP_STATE (EXPANDED);
1353 MAP_STATE (FOCUSABLE);
1354 MAP_STATE (FOCUSED);
1355 MAP_STATE (HORIZONTAL);
1356 MAP_STATE (ICONIFIED);
1358 MAP_STATE (MULTI_LINE);
1359 MAP_STATE (MULTISELECTABLE);
1361 MAP_STATE (PRESSED);
1362 MAP_STATE (RESIZABLE);
1363 MAP_STATE (SELECTABLE);
1364 MAP_STATE (SELECTED);
1365 MAP_STATE (SENSITIVE);
1366 MAP_STATE (SHOWING);
1367 MAP_STATE (SINGLE_LINE);
1369 MAP_STATE (TRANSIENT);
1370 MAP_STATE (VERTICAL);
1371 MAP_STATE (VISIBLE);
1372 MAP_STATE (MANAGES_DESCENDANTS);
1373 MAP_STATE (INDETERMINATE);
1374 MAP_STATE (TRUNCATED);
1375 MAP_STATE (REQUIRED);
1376 MAP_STATE (INVALID_ENTRY);
1377 MAP_STATE (SUPPORTS_AUTOCOMPLETION);
1378 MAP_STATE (SELECTABLE_TEXT);
1379 MAP_STATE (IS_DEFAULT);
1380 MAP_STATE (VISITED);
1382 return Accessibility_STATE_INVALID;
1388 * AccessibleStateSet_contains:
1389 * @obj: a pointer to the #AccessibleStateSet object on which to operate.
1390 * @state: an #AccessibleState for which the specified #AccessibleStateSet
1393 * Determine whether a given #AccessibleStateSet includes a given state; that is,
1394 * whether @state is true for the stateset in question.
1396 * Returns: #TRUE if @state is true/included in the given #AccessibleStateSet,
1401 AccessibleStateSet_contains (AccessibleStateSet *obj,
1402 AccessibleState state)
1404 return spi_state_set_cache_contains (obj, spi_state_to_corba (state));
1408 * AccessibleStateSet_add:
1409 * @obj: a pointer to the #AccessibleStateSet object on which to operate.
1410 * @state: an #AccessibleState to be added to the specified #AccessibleStateSet
1412 * Add a particular #AccessibleState to an #AccessibleStateSet (i.e. set the
1413 * given state to #TRUE in the stateset.
1417 AccessibleStateSet_add (AccessibleStateSet *obj,
1418 AccessibleState state)
1420 spi_state_set_cache_add (obj, spi_state_to_corba (state));
1424 * AccessibleStateSet_remove:
1425 * @obj: a pointer to the #AccessibleStateSet object on which to operate.
1426 * @state: an #AccessibleState to be removed from the specified #AccessibleStateSet
1428 * Remove a particular #AccessibleState to an #AccessibleStateSet (i.e. set the
1429 * given state to #FALSE in the stateset.)
1433 AccessibleStateSet_remove (AccessibleStateSet *obj,
1434 AccessibleState state)
1436 spi_state_set_cache_remove (obj, spi_state_to_corba (state));
1440 * AccessibleStateSet_equals:
1441 * @obj: a pointer to the first #AccessibleStateSet object on which to operate.
1442 * @obj2: a pointer to the second #AccessibleStateSet object on which to operate.
1444 * Determine whether two instances of #AccessibleStateSet are equivalent (i.e.
1445 * consist of the same #AccessibleStates). Useful for checking multiple
1446 * state variables at once; construct the target state then compare against it.
1448 * @see AccessibleStateSet_compare().
1450 * Returns: #TRUE if the two #AccessibleStateSets are equivalent,
1455 AccessibleStateSet_equals (AccessibleStateSet *obj,
1456 AccessibleStateSet *obj2)
1466 cmp = spi_state_set_cache_xor (obj, obj2);
1467 eq = spi_state_set_cache_is_empty (cmp);
1468 spi_state_set_cache_unref (cmp);
1474 * AccessibleStateSet_compare:
1475 * @obj: a pointer to the first #AccessibleStateSet object on which to operate.
1476 * @obj2: a pointer to the second #AccessibleStateSet object on which to operate.
1478 * Determine the differences between two instances of #AccessibleStateSet.
1479 * Not Yet Implemented.
1481 * @see AccessibleStateSet_equals().
1483 * Returns: an #AccessibleStateSet object containing all states contained on one of
1484 * the two sets but not the other.
1487 AccessibleStateSet *
1488 AccessibleStateSet_compare (AccessibleStateSet *obj,
1489 AccessibleStateSet *obj2)
1491 return spi_state_set_cache_xor (obj, obj2);
1495 * AccessibleStateSet_isEmpty:
1496 * @obj: a pointer to the #AccessibleStateSet object on which to operate.
1498 * Determine whether a given #AccessibleStateSet is the empty set.
1500 * Returns: #TRUE if the given #AccessibleStateSet contains no (true) states,
1505 AccessibleStateSet_isEmpty (AccessibleStateSet *obj)
1507 return spi_state_set_cache_is_empty (obj);