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 "spi-common/spi-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 GArray *seq)
248 AccessibleAttributeSet *set = g_new0 (AccessibleAttributeSet, 1);
252 set->attributes = g_new0 (char *, set->len);
253 for (i = 0; i < set->len; ++i)
255 set->attributes[i] = g_array_index (seq, char *, i);
258 g_array_free (seq, TRUE);
263 * AccessibleRole_getName:
264 * @role: an #AccessibleRole object to query.
266 * Get a localizeable string that indicates the name of an #AccessibleRole.
267 * <em>DEPRECATED.</em>
269 * Returns: a localizable string name for an #AccessibleRole enumerated type.
272 AccessibleRole_getName (AccessibleRole role)
274 if (role < MAX_ROLES && role_names [(int) role])
276 return g_strdup (role_names [(int) role]);
280 return g_strdup ("");
286 * @obj: a pointer to the #Accessible object on which to operate.
288 * Increment the reference count for an #Accessible object.
291 Accessible_ref (Accessible *obj)
293 cspi_object_ref (obj);
298 * @obj: a pointer to the #Accessible object on which to operate.
300 * Decrement the reference count for an #Accessible object.
303 Accessible_unref (Accessible *obj)
305 cspi_object_unref (obj);
309 * Accessible_getName:
310 * @obj: a pointer to the #Accessible object on which to operate.
312 * Get the name of an #Accessible object.
314 * Returns: a UTF-8 string indicating the name of the #Accessible object.
315 * or NULL on exception
318 Accessible_getName (Accessible *obj)
320 cspi_return_val_if_fail (obj != NULL, NULL);
321 return g_strdup (obj->name);
325 * Accessible_getDescription:
326 * @obj: a pointer to the #Accessible object on which to operate.
328 * Get the description of an #Accessible object.
330 * Returns: a UTF-8 string describing the #Accessible object.
331 * or NULL on exception
334 Accessible_getDescription (Accessible *obj)
336 cspi_return_val_if_fail (obj != NULL, NULL);
338 return g_strdup (obj->description);
342 * Accessible_getParent:
343 * @obj: a pointer to the #Accessible object to query.
345 * Get an #Accessible object's parent container.
347 * Returns: a pointer tothe #Accessible object which contains the given
348 * #Accessible instance, or NULL if the @obj has no parent container.
352 Accessible_getParent (Accessible *obj)
354 cspi_return_val_if_fail (obj != NULL, NULL);
356 return cspi_object_add (obj->parent);
360 * Accessible_getChildCount:
361 * @obj: a pointer to the #Accessible object on which to operate.
363 * Get the number of children contained by an #Accessible object.
365 * Returns: a #long indicating the number of #Accessible children
366 * contained by an #Accessible object. or -1 on exception
370 Accessible_getChildCount (Accessible *obj)
372 cspi_return_val_if_fail (obj != NULL, -1);
374 return g_list_length (obj->children);
378 * Accessible_getChildAtIndex:
379 * @obj: a pointer to the #Accessible object on which to operate.
380 * @childIndex: a #long indicating which child is specified.
382 * Get the #Accessible child of an #Accessible object at a given index.
384 * Returns: a pointer to the #Accessible child object at index
385 * @childIndex. or NULL on exception
388 Accessible_getChildAtIndex (Accessible *obj,
393 cspi_return_val_if_fail (obj != NULL, NULL);
395 child = g_list_nth_data (obj->children, childIndex);
396 return cspi_object_add(child);
400 * Accessible_getIndexInParent:
401 * @obj: a pointer to the #Accessible object on which to operate.
403 * Get the index of an #Accessible object in its containing #Accessible.
405 * Returns: a #long indicating the index of the #Accessible object
406 * in its parent (i.e. containing) #Accessible instance,
407 * or -1 if @obj has no containing parent or on exception.
410 Accessible_getIndexInParent (Accessible *obj)
415 cspi_return_val_if_fail (obj != NULL, -1);
416 if (!obj->parent) return -1;
417 l = obj->parent->children;
420 if (l->data == obj) return i;
431 } Accessibility_Relation;
434 * Accessible_getRelationSet:
435 * @obj: a pointer to the #Accessible object on which to operate.
437 * Get the set of #AccessibleRelation objects which describe this #Accessible object's
438 * relationships with other #Accessible objects.
440 * Returns: an array of #AccessibleRelation pointers. or NULL on exception
442 AccessibleRelation **
443 Accessible_getRelationSet (Accessible *obj)
447 AccessibleRelation **relations;
448 GArray *relation_set;
451 cspi_return_val_if_fail (obj != NULL, NULL);
453 g_assert (!cspi_exception ());
455 dbus_error_init (&error);
456 cspi_dbus_call (obj, spi_interface_accessible, "getAttributes", &error, "=>a(uao)", &relation_set);
458 cspi_return_val_if_ev ("getRelationSet", NULL);
460 n_relations = relation_set->len;
461 relations = malloc (sizeof (AccessibleRelation *) * (n_relations + 1));
463 for (i = 0; i < n_relations; ++i)
465 Accessibility_Relation *r = g_array_index (relation_set, Accessibility_Relation *, i);
466 relations[i] = g_new (AccessibleRelation, 1);
467 if (!relations[i]) continue;
468 relations[i]->ref_count = 1;
469 relations[i]->type = r->type;
470 relations[i]->targets = r->targets;
474 g_array_free (relation_set, TRUE);
480 * Accessible_getRole:
481 * @obj: a pointer to the #Accessible object on which to operate.
483 * Get the UI role of an #Accessible object.
484 * A UTF-8 string describing this role can be obtained via Accessible_getRoleName ().
486 * Returns: the #AccessibleRole of the object.
490 Accessible_getRole (Accessible *obj)
492 cspi_return_val_if_fail (obj != NULL, SPI_ROLE_INVALID);
498 * Accessible_getRoleName:
499 * @obj: a pointer to the #Accessible object on which to operate.
501 * Get a UTF-8 string describing the role this object plays in the UI.
502 * This method will return useful values for roles that fall outside the
503 * enumeration used in Accessible_getRole ().
505 * Returns: a UTF-8 string specifying the role of this #Accessible object.
509 Accessible_getRoleName (Accessible *obj)
513 cspi_return_val_if_fail (obj != NULL, g_strdup ("invalid"));
515 cspi_dbus_call (obj, spi_interface_accessible, "getRoleName", NULL, "=>s", &retval);
517 cspi_return_val_if_ev ("getRoleName", g_strdup ("invalid"));
523 * Accessible_getLocalizedRoleName:
524 * @obj: a pointer to the #Accessible object on which to operate.
526 * Get a UTF-8 string describing the (localized) role this object plays in the UI.
527 * This method will return useful values for roles that fall outside the
528 * enumeration used in Accessible_getRole ().
532 * Returns: a UTF-8 string specifying the role of this #Accessible object.
536 Accessible_getLocalizedRoleName (Accessible *obj)
540 cspi_return_val_if_fail (obj != NULL, g_strdup ("invalid"));
542 cspi_dbus_call (obj, spi_interface_accessible, "getLocalizedRoleName", NULL, "=>s", &retval);
544 cspi_return_val_if_ev ("getLocalizedRoleName", g_strdup ("invalid"));
550 * Accessible_getStateSet:
551 * @obj: a pointer to the #Accessible object on which to operate.
553 * Gets the current state of an object.
555 * Returns: a pointer to an #AccessibleStateSet representing the object's current state.
558 Accessible_getStateSet (Accessible *obj)
564 * Accessible_getAttributes:
565 * @obj: The #Accessible being queried.
567 * Get the #AttributeSet representing any assigned
568 * name-value pair attributes or annotations for this object.
569 * For typographic, textual, or textually-semantic attributes, see
570 * AccessibleText_getAttributes instead.
572 * Returns: The name-value-pair attributes assigned to this object.
574 AccessibleAttributeSet *
575 Accessible_getAttributes (Accessible *obj)
577 AccessibleAttributeSet *retval;
580 cspi_return_val_if_fail (obj != NULL, NULL);
582 cspi_dbus_call (obj, spi_interface_accessible, "getAttributes", NULL, "=>as", &dbus_seq);
584 cspi_return_val_if_ev ("getAttributes", NULL);
586 retval = _cspi_attribute_set_from_sequence (dbus_seq);
592 * Accessible_getHostApplication:
593 * @obj: The #Accessible being queried.
595 * Get the containing #AccessibleApplication for an object.
597 * Returns: the containing AccessibleApplication instance for this object.
599 AccessibleApplication *
600 Accessible_getHostApplication (Accessible *obj)
602 while (obj->parent) obj = obj->parent;
606 /* Interface query methods */
609 * Accessible_isAction:
610 * @obj: a pointer to the #Accessible instance to query.
612 * Query whether the specified #Accessible implements #AccessibleAction.
614 * Returns: #TRUE if @obj implements the #AccessibleAction interface,
618 Accessible_isAction (Accessible *obj)
620 return cspi_accessible_is_a (obj,
621 spi_interface_action);
625 * Accessible_isApplication:
626 * @obj: a pointer to the #Accessible instance to query.
628 * Query whether the specified #Accessible implements #AccessibleApplication.
630 * Returns: #TRUE if @obj implements the #AccessibleApplication interface,
634 Accessible_isApplication (Accessible *obj)
636 return cspi_accessible_is_a (obj,
637 spi_interface_application);
641 * Accessible_isCollection: * @obj: a pointer to the #Accessible instance to query.
643 * Query whether the specified #Accessible implements #AccessibleCollection.
644 * Returns: #TRUE if @obj implements the #AccessibleCollection interface,
649 Accessible_isCollection (Accessible *obj)
652 g_warning ("Collections not implemented");
653 return cspi_accessible_is_a (obj,
654 spi_interface_collection);
661 * Accessible_isComponent:
662 * @obj: a pointer to the #Accessible instance to query.
664 * Query whether the specified #Accessible implements #AccessibleComponent.
666 * Returns: #TRUE if @obj implements the #AccessibleComponent interface,
670 Accessible_isComponent (Accessible *obj)
672 return cspi_accessible_is_a (obj,
673 spi_interface_component);
677 * Accessible_isDocument:
678 * @obj: a pointer to the #Accessible instance to query.
680 * Query whether the specified #Accessible implements #AccessibleDocument.
682 * Returns: #TRUE if @obj implements the #AccessibleDocument interface,
686 Accessible_isDocument (Accessible *obj)
688 return cspi_accessible_is_a (obj,
689 spi_interface_document);
693 * Accessible_isEditableText:
694 * @obj: a pointer to the #Accessible instance to query.
696 * Query whether the specified #Accessible implements #AccessibleEditableText.
698 * Returns: #TRUE if @obj implements the #AccessibleEditableText interface,
702 Accessible_isEditableText (Accessible *obj)
704 return cspi_accessible_is_a (obj,
705 spi_interface_editable_text);
709 * Accessible_isMatchRule:
710 * @obj: a pointer to the #Accessible instance to query.
712 * Query whether the specified #Accessible implements #AccessibleMatchRule.
714 * Returns: #TRUE if @obj implements the #AccessibleMatchRule interface,
718 Accessible_isMatchRule (Accessible *obj)
721 return cspi_accessible_is_a (obj,
722 spi_interface_match_rule);
724 g_warning ("Match rules not implemented");
730 * Accessible_isHypertext:
731 * @obj: a pointer to the #Accessible instance to query.
733 * Query whether the specified #Accessible implements #AccessibleHypertext.
735 * Returns: #TRUE if @obj implements the #AccessibleHypertext interface,
739 Accessible_isHypertext (Accessible *obj)
741 return cspi_accessible_is_a (obj,
742 spi_interface_hypertext);
746 * Accessible_isImage:
747 * @obj: a pointer to the #Accessible instance to query.
749 * Query whether the specified #Accessible implements #AccessibleImage.
751 * Returns: #TRUE if @obj implements the #AccessibleImage interface,
755 Accessible_isImage (Accessible *obj)
757 return cspi_accessible_is_a (obj,
758 spi_interface_image);
762 * Accessible_isSelection:
763 * @obj: a pointer to the #Accessible instance to query.
765 * Query whether the specified #Accessible implements #AccessibleSelection.
767 * Returns: #TRUE if @obj implements the #AccessibleSelection interface,
771 Accessible_isSelection (Accessible *obj)
773 return cspi_accessible_is_a (obj,
774 spi_interface_selection);
778 * Accessible_isTable:
779 * @obj: a pointer to the #Accessible instance to query.
781 * Query whether the specified #Accessible implements #AccessibleTable.
783 * Returns: #TRUE if @obj implements the #AccessibleTable interface,
787 Accessible_isTable (Accessible *obj)
789 return cspi_accessible_is_a (obj,
790 spi_interface_table);
794 * Accessible_isStreamableContent:
795 * @obj: a pointer to the #Accessible instance to query.
797 * Query whether the specified #Accessible implements
798 * #AccessibleStreamableContent.
800 * Returns: #TRUE if @obj implements the #AccessibleStreamableContent interface,
804 Accessible_isStreamableContent (Accessible *obj)
807 return cspi_accessible_is_a (obj,
808 spi_interface_streamable_content);
810 g_warning ("Streamable content not implemented");
817 * @obj: a pointer to the #Accessible instance to query.
819 * Query whether the specified #Accessible implements #AccessibleText.
821 * Returns: #TRUE if @obj implements the #AccessibleText interface,
825 Accessible_isText (Accessible *obj)
827 return cspi_accessible_is_a (obj,
832 * Accessible_isValue:
833 * @obj: a pointer to the #Accessible instance to query.
835 * Query whether the specified #Accessible implements #AccessibleValue.
837 * Returns: #TRUE if @obj implements the #AccessibleValue interface,
841 Accessible_isValue (Accessible *obj)
843 return cspi_accessible_is_a (obj,
844 spi_interface_value);
848 * Accessible_getApplication:
849 * @obj: a pointer to the #Accessible instance to query.
851 * Get the #AccessibleApplication interface for an #Accessible.
853 * Returns: a pointer to an #AccessibleApplication interface instance, or
854 * NULL if @obj does not implement #AccessibleApplication.
856 AccessibleApplication *
857 Accessible_getApplication (Accessible *obj)
859 return (AccessibleApplication *) Accessible_queryInterface (
860 obj, spi_interface_application);
864 * Accessible_getAction:
865 * @obj: a pointer to the #Accessible instance to query.
867 * Get the #AccessibleAction interface for an #Accessible.
869 * Returns: a pointer to an #AccessibleAction interface instance, or
870 * NULL if @obj does not implement #AccessibleAction.
873 Accessible_getAction (Accessible *obj)
875 return (AccessibleAction *) Accessible_queryInterface (
876 obj, spi_interface_action);
881 * Accessible_getCollection:
882 * @obj: a pointer to the #Accessible instance to query.
884 * Get the #AccessibleCollection interface for an #Accessible.
886 * Returns: a pointer to an #AccessibleCollection interface instance, or
887 * NULL if @obj does not implement #AccessibleCollection.
889 AccessibleCollection *
890 Accessible_getCollection (Accessible *obj)
893 return (AccessibleCollection *) Accessible_queryInterface (
894 obj, spi_interface_collection);
896 g_warning ("Collections not implemented");
902 * Accessible_getComponent:
903 * @obj: a pointer to the #Accessible instance to query.
905 * Get the #AccessibleComponent interface for an #Accessible.
907 * Returns: a pointer to an #AccessibleComponent interface instance, or
908 * NULL if @obj does not implement #AccessibleComponent.
910 AccessibleComponent *
911 Accessible_getComponent (Accessible *obj)
913 return (AccessibleComponent *) Accessible_queryInterface (
914 obj, spi_interface_component);
918 * Accessible_getDocument:
919 * @obj: a pointer to the #Accessible instance to query.
921 * Get the #AccessibleDocument interface for an #Accessible.
923 * Returns: a pointer to an #AccessibleDocument interface instance, or
924 * NULL if @obj does not implement #AccessibleDocument.
927 Accessible_getDocument (Accessible *obj)
929 return (AccessibleDocument *) Accessible_queryInterface (
930 obj, spi_interface_document);
934 * Accessible_getEditableText:
935 * @obj: a pointer to the #Accessible instance to query.
937 * Get the #AccessibleEditableText interface for an #Accessible.
939 * Returns: a pointer to an #AccessibleEditableText interface instance, or
940 * NULL if @obj does not implement #AccessibleEditableText.
942 AccessibleEditableText *
943 Accessible_getEditableText (Accessible *obj)
945 return (AccessibleEditableText *) Accessible_queryInterface (
946 obj, spi_interface_editable_text);
951 * Accessible_getHypertext:
952 * @obj: a pointer to the #Accessible instance to query.
954 * Get the #AccessibleHypertext interface for an #Accessible.
956 * Returns: a pointer to an #AccessibleHypertext interface instance, or
957 * NULL if @obj does not implement #AccessibleHypertext.
959 AccessibleHypertext *
960 Accessible_getHypertext (Accessible *obj)
962 return (AccessibleHypertext *) Accessible_queryInterface (
963 obj, spi_interface_hypertext);
969 * Accessible_getImage:
970 * @obj: a pointer to the #Accessible instance to query.
972 * Get the #AccessibleImage interface for an #Accessible.
974 * Returns: a pointer to an #AccessibleImage interface instance, or
975 * NULL if @obj does not implement #AccessibleImage.
978 Accessible_getImage (Accessible *obj)
980 return (AccessibleImage *) Accessible_queryInterface (
981 obj, spi_interface_image);
985 * Accessible_getMatchRule:
986 * @obj: a pointer to the #Accessible instance to query.
988 * Get the #AccessibleMatchRule interface for an #Accessible.
990 * Returns: a pointer to an #AccessibleMatchRule interface instance, or
991 * NULL if @obj does not implement #AccessibleMatchRule.
993 AccessibleMatchRule *
994 Accessible_getMatchRule (Accessible *obj)
997 return (AccessibleMatchRule *) Accessible_queryInterface (
998 obj, spi_interface_match_rule);
1000 g_warning ("Match rules not supported");
1006 * Accessible_getSelection:
1007 * @obj: a pointer to the #Accessible instance to query.
1009 * Get the #AccessibleSelection interface for an #Accessible.
1011 * Returns: a pointer to an #AccessibleSelection interface instance, or
1012 * NULL if @obj does not implement #AccessibleSelection.
1014 AccessibleSelection *
1015 Accessible_getSelection (Accessible *obj)
1017 return (AccessibleSelection *) Accessible_queryInterface (
1018 obj, spi_interface_selection);
1024 * Accessible_getStreamableContent:
1025 * @obj: a pointer to the #Accessible instance to query.
1027 * Get the #AccessibleStreamableContent interface for an #Accessible.
1029 * Returns: a pointer to an #AccessibleStreamableContent interface instance, or
1030 * NULL if @obj does not implement #AccessibleStreamableContent.
1032 AccessibleStreamableContent *
1033 Accessible_getStreamableContent (Accessible *obj)
1036 return (AccessibleStreamableContent *) Accessible_queryInterface (
1037 obj, spi_interface_streamable_content);
1039 g_warning ("Streamable content not supported");
1045 * Accessible_getTable:
1046 * @obj: a pointer to the #Accessible instance to query.
1048 * Get the #AccessibleTable interface for an #Accessible.
1050 * Returns: a pointer to an #AccessibleTable interface instance, or
1051 * NULL if @obj does not implement #AccessibleTable.
1054 Accessible_getTable (Accessible *obj)
1056 return (AccessibleTable *) Accessible_queryInterface (
1057 obj, spi_interface_table);
1061 * Accessible_getText:
1062 * @obj: a pointer to the #Accessible instance to query.
1064 * Get the #AccessibleText interface for an #Accessible.
1066 * Returns: a pointer to an #AccessibleText interface instance, or
1067 * NULL if @obj does not implement #AccessibleText.
1070 Accessible_getText (Accessible *obj)
1072 return (AccessibleText *) Accessible_queryInterface (
1073 obj, spi_interface_text);
1079 * Accessible_getValue:
1080 * @obj: a pointer to the #Accessible instance to query.
1082 * Get the #AccessibleValue interface for an #Accessible.
1084 * Returns: a pointer to an #AccessibleValue interface instance, or
1085 * NULL if @obj does not implement #AccessibleValue.
1088 Accessible_getValue (Accessible *obj)
1090 return (AccessibleValue *) Accessible_queryInterface (
1091 obj, spi_interface_value);
1097 * Accessible_queryInterface:
1098 * @obj: a pointer to the #Accessible instance to query.
1099 * @interface_name: a UTF-8 character string specifiying the requested interface.
1101 * Query an #Accessible object to for a named interface.
1103 * Returns: an instance of the named interface object, if it is implemented
1104 * by @obj, or NULL otherwise.
1108 Accessible_queryInterface (Accessible *obj,
1109 const char *interface_name)
1111 if (cspi_accessible_is_a (obj, interface_name))
1113 /* The original code called cspi_object_add(obj) instead, but gok and
1114 * simple-at don't treat interfaces as references, so I'm confused
1115 * and not going to replicate this bit of code */
1123 * AccessibleRelation_ref:
1124 * @obj: a pointer to the #AccessibleRelation object on which to operate.
1126 * Increment the reference count for an #AccessibleRelation object.
1130 AccessibleRelation_ref (AccessibleRelation *obj)
1136 * AccessibleRelation_unref:
1137 * @obj: a pointer to the #AccessibleRelation object on which to operate.
1139 * Decrement the reference count for an #AccessibleRelation object.
1143 AccessibleRelation_unref (AccessibleRelation *obj)
1146 if (obj->ref_count <= 0)
1148 g_array_free (obj->targets, TRUE);
1154 cspi_init_relation_type_table (AccessibleRelationType *relation_type_table)
1157 for (i = 0; i < Accessibility_RELATION_LAST_DEFINED; ++i)
1159 relation_type_table [i] = SPI_RELATION_NULL;
1161 relation_type_table [Accessibility_RELATION_NULL] = SPI_RELATION_NULL;
1162 relation_type_table [Accessibility_RELATION_LABEL_FOR] = SPI_RELATION_LABEL_FOR;
1163 relation_type_table [Accessibility_RELATION_LABELLED_BY] = SPI_RELATION_LABELED_BY;
1164 relation_type_table [Accessibility_RELATION_CONTROLLER_FOR] = SPI_RELATION_CONTROLLER_FOR;
1165 relation_type_table [Accessibility_RELATION_CONTROLLED_BY] = SPI_RELATION_CONTROLLED_BY;
1166 relation_type_table [Accessibility_RELATION_MEMBER_OF] = SPI_RELATION_MEMBER_OF;
1167 relation_type_table [Accessibility_RELATION_TOOLTIP_FOR] = SPI_RELATION_NULL;
1168 relation_type_table [Accessibility_RELATION_NODE_CHILD_OF] = SPI_RELATION_NODE_CHILD_OF;
1169 relation_type_table [Accessibility_RELATION_EXTENDED] = SPI_RELATION_EXTENDED;
1170 relation_type_table [Accessibility_RELATION_FLOWS_TO] = SPI_RELATION_FLOWS_TO;
1171 relation_type_table [Accessibility_RELATION_FLOWS_FROM] = SPI_RELATION_FLOWS_FROM;
1172 relation_type_table [Accessibility_RELATION_SUBWINDOW_OF] = SPI_RELATION_SUBWINDOW_OF;
1173 relation_type_table [Accessibility_RELATION_EMBEDS] = SPI_RELATION_EMBEDS;
1174 relation_type_table [Accessibility_RELATION_EMBEDDED_BY] = SPI_RELATION_EMBEDDED_BY;
1175 relation_type_table [Accessibility_RELATION_POPUP_FOR] = SPI_RELATION_POPUP_FOR;
1176 relation_type_table [Accessibility_RELATION_PARENT_WINDOW_OF] = SPI_RELATION_PARENT_WINDOW_OF;
1177 relation_type_table [Accessibility_RELATION_DESCRIBED_BY] = SPI_RELATION_DESCRIBED_BY;
1178 relation_type_table [Accessibility_RELATION_DESCRIPTION_FOR] = SPI_RELATION_DESCRIPTION_FOR;
1182 static AccessibleRelationType
1183 cspi_relation_type_from_spi_relation_type (Accessibility_RelationType type)
1185 /* array is sized according to IDL RelationType because IDL RelationTypes are the index */
1186 static AccessibleRelationType cspi_relation_type_table [Accessibility_RELATION_LAST_DEFINED];
1187 static SPIBoolean is_initialized = FALSE;
1188 AccessibleRelationType cspi_type;
1189 if (!is_initialized)
1191 is_initialized = cspi_init_relation_type_table (cspi_relation_type_table);
1193 if (type >= 0 && type < Accessibility_RELATION_LAST_DEFINED)
1195 cspi_type = cspi_relation_type_table [type];
1199 cspi_type = SPI_RELATION_NULL;
1204 * AccessibleRelation_getRelationType:
1205 * @obj: a pointer to the #AccessibleRelation object to query.
1207 * Get the type of relationship represented by an #AccessibleRelation.
1209 * Returns: an #AccessibleRelationType indicating the type of relation
1210 * encapsulated in this #AccessibleRelation object.
1213 AccessibleRelationType
1214 AccessibleRelation_getRelationType (AccessibleRelation *obj)
1216 cspi_return_val_if_fail (obj, SPI_RELATION_NULL);
1217 return cspi_relation_type_from_spi_relation_type (obj->type);
1221 * AccessibleRelation_getNTargets:
1222 * @obj: a pointer to the #AccessibleRelation object to query.
1224 * Get the number of objects which this relationship has as its
1225 * target objects (the subject is the #Accessible from which this
1226 * #AccessibleRelation originated).
1228 * Returns: a short integer indicating how many target objects which the
1229 * originating #Accessible object has the #AccessibleRelation
1230 * relationship with.
1233 AccessibleRelation_getNTargets (AccessibleRelation *obj)
1235 cspi_return_val_if_fail (obj, -1);
1236 return obj->targets->len;
1240 * AccessibleRelation_getTarget:
1241 * @obj: a pointer to the #AccessibleRelation object to query.
1242 * @i: a (zero-index) integer indicating which (of possibly several) target is requested.
1244 * Get the @i-th target of a specified #AccessibleRelation relationship.
1246 * Returns: an #Accessible which is the @i-th object with which the
1247 * originating #Accessible has relationship specified in the
1248 * #AccessibleRelation object.
1252 AccessibleRelation_getTarget (AccessibleRelation *obj, int i)
1254 cspi_return_val_if_fail (obj, NULL);
1256 if (i < 0 || i >= obj->targets->len) return NULL;
1257 return cspi_object_add (
1258 g_array_index (obj->targets, Accessible *, i));
1262 * AccessibleStateSet_ref:
1263 * @obj: a pointer to the #AccessibleStateSet object on which to operate.
1265 * Increment the reference count for an #AccessibleStateSet object.
1269 AccessibleStateSet_ref (AccessibleStateSet *obj)
1271 spi_state_set_cache_ref (obj);
1275 * AccessibleStateSet_unref:
1276 * @obj: a pointer to the #AccessibleStateSet object on which to operate.
1278 * Decrement the reference count for an #AccessibleStateSet object.
1282 AccessibleStateSet_unref (AccessibleStateSet *obj)
1284 spi_state_set_cache_unref (obj);
1287 static Accessibility_StateType
1288 spi_state_to_dbus (AccessibleState state)
1290 #define MAP_STATE(a) \
1291 case SPI_STATE_##a: \
1292 return Accessibility_STATE_##a
1296 MAP_STATE (INVALID);
1300 MAP_STATE (CHECKED);
1301 MAP_STATE (DEFUNCT);
1302 MAP_STATE (EDITABLE);
1303 MAP_STATE (ENABLED);
1304 MAP_STATE (EXPANDABLE);
1305 MAP_STATE (EXPANDED);
1306 MAP_STATE (FOCUSABLE);
1307 MAP_STATE (FOCUSED);
1308 MAP_STATE (HORIZONTAL);
1309 MAP_STATE (ICONIFIED);
1311 MAP_STATE (MULTI_LINE);
1312 MAP_STATE (MULTISELECTABLE);
1314 MAP_STATE (PRESSED);
1315 MAP_STATE (RESIZABLE);
1316 MAP_STATE (SELECTABLE);
1317 MAP_STATE (SELECTED);
1318 MAP_STATE (SENSITIVE);
1319 MAP_STATE (SHOWING);
1320 MAP_STATE (SINGLE_LINE);
1322 MAP_STATE (TRANSIENT);
1323 MAP_STATE (VERTICAL);
1324 MAP_STATE (VISIBLE);
1325 MAP_STATE (MANAGES_DESCENDANTS);
1326 MAP_STATE (INDETERMINATE);
1327 MAP_STATE (TRUNCATED);
1328 MAP_STATE (REQUIRED);
1329 MAP_STATE (INVALID_ENTRY);
1330 MAP_STATE (SUPPORTS_AUTOCOMPLETION);
1331 MAP_STATE (SELECTABLE_TEXT);
1332 MAP_STATE (IS_DEFAULT);
1333 MAP_STATE (VISITED);
1335 return Accessibility_STATE_INVALID;
1341 * AccessibleStateSet_contains:
1342 * @obj: a pointer to the #AccessibleStateSet object on which to operate.
1343 * @state: an #AccessibleState for which the specified #AccessibleStateSet
1346 * Determine whether a given #AccessibleStateSet includes a given state; that is,
1347 * whether @state is true for the stateset in question.
1349 * Returns: #TRUE if @state is true/included in the given #AccessibleStateSet,
1354 AccessibleStateSet_contains (AccessibleStateSet *obj,
1355 AccessibleState state)
1357 return spi_state_set_cache_contains (obj, spi_state_to_dbus (state));
1361 * AccessibleStateSet_add:
1362 * @obj: a pointer to the #AccessibleStateSet object on which to operate.
1363 * @state: an #AccessibleState to be added to the specified #AccessibleStateSet
1365 * Add a particular #AccessibleState to an #AccessibleStateSet (i.e. set the
1366 * given state to #TRUE in the stateset.
1370 AccessibleStateSet_add (AccessibleStateSet *obj,
1371 AccessibleState state)
1373 spi_state_set_cache_add (obj, spi_state_to_dbus (state));
1377 * AccessibleStateSet_remove:
1378 * @obj: a pointer to the #AccessibleStateSet object on which to operate.
1379 * @state: an #AccessibleState to be removed from the specified #AccessibleStateSet
1381 * Remove a particular #AccessibleState to an #AccessibleStateSet (i.e. set the
1382 * given state to #FALSE in the stateset.)
1386 AccessibleStateSet_remove (AccessibleStateSet *obj,
1387 AccessibleState state)
1389 spi_state_set_cache_remove (obj, spi_state_to_dbus (state));
1393 * AccessibleStateSet_equals:
1394 * @obj: a pointer to the first #AccessibleStateSet object on which to operate.
1395 * @obj2: a pointer to the second #AccessibleStateSet object on which to operate.
1397 * Determine whether two instances of #AccessibleStateSet are equivalent (i.e.
1398 * consist of the same #AccessibleStates). Useful for checking multiple
1399 * state variables at once; construct the target state then compare against it.
1401 * @see AccessibleStateSet_compare().
1403 * Returns: #TRUE if the two #AccessibleStateSets are equivalent,
1408 AccessibleStateSet_equals (AccessibleStateSet *obj,
1409 AccessibleStateSet *obj2)
1419 cmp = spi_state_set_cache_xor (obj, obj2);
1420 eq = spi_state_set_cache_is_empty (cmp);
1421 spi_state_set_cache_unref (cmp);
1427 * AccessibleStateSet_compare:
1428 * @obj: a pointer to the first #AccessibleStateSet object on which to operate.
1429 * @obj2: a pointer to the second #AccessibleStateSet object on which to operate.
1431 * Determine the differences between two instances of #AccessibleStateSet.
1432 * Not Yet Implemented.
1434 * @see AccessibleStateSet_equals().
1436 * Returns: an #AccessibleStateSet object containing all states contained on one of
1437 * the two sets but not the other.
1440 AccessibleStateSet *
1441 AccessibleStateSet_compare (AccessibleStateSet *obj,
1442 AccessibleStateSet *obj2)
1444 return spi_state_set_cache_xor (obj, obj2);
1448 * AccessibleStateSet_isEmpty:
1449 * @obj: a pointer to the #AccessibleStateSet object on which to operate.
1451 * Determine whether a given #AccessibleStateSet is the empty set.
1453 * Returns: #TRUE if the given #AccessibleStateSet contains no (true) states,
1458 AccessibleStateSet_isEmpty (AccessibleStateSet *obj)
1460 return spi_state_set_cache_is_empty (obj);