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 "atspi-private.h"
26 G_DEFINE_TYPE (AtspiAccessible, atspi_accessible, G_TYPE_OBJECT)
29 atspi_accessible_init (AtspiAccessible *accessible)
34 atspi_accessible_class_init (AtspiAccessibleClass *klass)
37 /* TODO: Generate following from spec? */
38 static const char *role_names [] =
96 "table-column-header",
128 "input method window"
131 #define MAX_ROLES (sizeof (role_names) / sizeof (char *))
134 * atspi_role_get_name
135 * @role: an #AtspiAccessibleRole object to query.
137 * Get a localizeable string that indicates the name of an #AtspiAccessibleRole.
138 * <em>DEPRECATED.</em>
140 * Returns: a localizable string name for an #AtspiAccessibleRole enumerated type.
143 atspi_role_get_name (AtspiRole role)
145 if (role < MAX_ROLES && role_names [(int) role])
147 return g_strdup (role_names [(int) role]);
151 return g_strdup ("");
156 * atspi_accessible_get_name:
157 * @obj: a pointer to the #AtspiAccessible object on which to operate.
159 * Get the name of an #AtspiAccessible object.
161 * Returns: a UTF-8 string indicating the name of the #AtspiAccessible object.
162 * or NULL on exception
165 atspi_accessible_get_name (AtspiAccessible *obj, GError **error)
167 g_return_val_if_fail (obj != NULL, NULL);
168 return g_strdup (obj->name);
172 * atspi_accessible_get_description:
173 * @obj: a pointer to the #AtspiAccessible object on which to operate.
175 * Get the description of an #AtspiAccessible object.
177 * Returns: a UTF-8 string describing the #AtspiAccessible object.
178 * or NULL on exception
181 atspi_accessible_get_description (AtspiAccessible *obj, GError **error)
183 g_return_val_if_fail (obj != NULL, NULL);
185 return g_strdup (obj->description);
189 * atspi_accessible_get_parent:
190 * @obj: a pointer to the #AtspiAccessible object to query.
192 * Get an #AtspiAccessible object's parent container.
194 * Returns: a pointer tothe #AtspiAccessible object which contains the given
195 * #AtspiAccessible instance, or NULL if the @obj has no parent container.
199 atspi_accessible_get_parent (AtspiAccessible *obj, GError **error)
201 g_return_val_if_fail (obj != NULL, NULL);
203 return g_object_ref (obj->accessible_parent);
207 * atspi_accessible_get_child_count:
208 * @obj: a pointer to the #AtspiAccessible object on which to operate.
210 * Get the number of children contained by an #AtspiAccessible object.
212 * Returns: a #long indicating the number of #AtspiAccessible children
213 * contained by an #AtspiAccessible object. or -1 on exception
217 atspi_accessible_get_child_count (AtspiAccessible *obj, GError *error)
219 g_return_val_if_fail (obj != NULL, -1);
221 /* TODO: MANAGES_DESCENDANTS */
222 return g_list_length (obj->children);
226 * atspi_accessible_get_child_at_index:
227 * @obj: a pointer to the #AtspiAccessible object on which to operate.
228 * @child_index: a #long indicating which child is specified.
230 * Get the #AtspiAccessible child of an #AtspiAccessible object at a given index.
232 * Returns: a pointer to the #AtspiAccessible child object at index
233 * @child_index. or NULL on exception
236 atspi_accessible_get_child_at_index (AtspiAccessible *obj,
240 AtspiAccessible *child;
242 g_return_val_if_fail (obj != NULL, NULL);
244 /* TODO: ManagesDescendants */
245 child = g_list_nth_data (obj->children, child_index);
246 return g_object_ref (child);
250 * atspi_accessible_get_index_in_parent
251 * @obj: a pointer to the #AtspiAccessible object on which to operate.
253 * Get the index of an #AtspiAccessible object in its containing #AtspiAccessible.
255 * Returns: a #glong indicating the index of the #AtspiAccessible object
256 * in its parent (i.e. containing) #AtspiAccessible instance,
257 * or -1 if @obj has no containing parent or on exception.
260 atspi_accessible_get_index_in_parent (AtspiAccessible *obj, GError **error)
265 g_return_val_if_fail (obj != NULL, -1);
266 if (!obj->accessible_parent) return -1;
267 l = obj->accessible_parent->children;
270 if (l->data == obj) return i;
281 } Accessibility_Relation;
284 * atspi_accessible_get_relation_set:
285 * @obj: a pointer to the #AtspiAccessible object on which to operate.
287 * Get the set of #AtspiRelation objects which describe this #AtspiAccessible object's
288 * relationships with other #AtspiAccessible objects.
290 * Returns: an array of #AtspiAccessibleRelation pointers. or NULL on exception
291 * TODO:: Annotate array type
294 atspi_accessible_get_relation_set (AtspiAccessible *obj, GError **error)
298 GArray *relation_set;
300 g_return_val_if_fail (obj != NULL, NULL);
302 if (!_atspi_dbus_call (obj, atspi_interface_accessible, "GetRelationSet", error, "=>a(uao)", &relation_set))
309 * atspi_accessible_get_role:
310 * @obj: a pointer to the #AtspiAccessible object on which to operate.
312 * Get the UI role of an #AtspiAccessible object.
313 * A UTF-8 string describing this role can be obtained via atspi_accessible_getRoleName ().
315 * Returns: the #AtspiRole of the object.
319 atspi_accessible_get_role (AtspiAccessible *obj, GError **error)
321 g_return_val_if_fail (obj != NULL, ATSPI_ROLE_INVALID);
327 * atspi_accessible_get_role_name:
328 * @obj: a pointer to the #AtspiAccessible object on which to operate.
330 * Get a UTF-8 string describing the role this object plays in the UI.
331 * This method will return useful values for roles that fall outside the
332 * enumeration used in atspi_accessible_getRole ().
334 * Returns: a UTF-8 string specifying the role of this #AtspiAccessible object.
338 atspi_accessible_get_role_name (AtspiAccessible *obj, GError **error)
342 g_return_val_if_fail (obj != NULL, g_strdup ("invalid"));
344 _atspi_dbus_call (obj, atspi_interface_accessible, "GetRoleName", error, "=>s", &retval);
350 * atspi_accessible_get_localized_role_name:
351 * @obj: a pointer to the #AtspiAccessible object on which to operate.
353 * Get a UTF-8 string describing the (localized) role this object plays in the UI.
354 * This method will return useful values for roles that fall outside the
355 * enumeration used in atspi_accessible_getRole ().
357 * Returns: a UTF-8 string specifying the role of this #AtspiAccessible object.
361 atspi_accessible_get_localized_role_name (AtspiAccessible *obj, GError **error)
365 g_return_val_if_fail (obj != NULL, g_strdup ("invalid"));
367 _atspi_dbus_call (obj, atspi_interface_accessible, "GetLocalizedRoleName", error, "=>s", &retval);
373 * atspi_accessible_get_state_set:
374 * @obj: a pointer to the #AtspiAccessible object on which to operate.
376 * Gets the current state of an object.
378 * Returns: a pointer to an #AtspiStateSet representing the object's current state.
381 atspi_accessible_get_state_set (AtspiAccessible *obj)
387 * atspi_accessible_get_attributes:
388 * @obj: The #AtspiAccessible being queried.
390 * Get the #AttributeSet representing any assigned
391 * name-value pair attributes or annotations for this object.
392 * For typographic, textual, or textually-semantic attributes, see
393 * atspi_text_get_attributes instead.
395 * Returns: The name-value-pair attributes assigned to this object.
398 atspi_accessible_get_attributes (AtspiAccessible *obj, GError **error)
400 DBusMessage *message;
403 g_return_val_if_fail (obj != NULL, NULL);
405 message = _atspi_dbus_call_partial (obj, atspi_interface_accessible, "GetAttributes", error, "");
406 ret = _atspi_dbus_hash_from_message (message);
407 dbus_message_unref (message);
412 * atspi_accessible_get_host_application:
413 * @obj: The #AtspiAccessible being queried.
415 * Get the containing #AtspiApplication for an object.
417 * Returns: the containing AtspiApplication instance for this object.
420 atspi_accessible_get_host_application (AtspiAccessible *obj, GError **error)
422 while (obj->accessible_parent) obj = obj->accessible_parent;
423 g_warning ("atspi: TODO: Application interface");
424 //return atspi_accessible_get_application (obj);
427 #if 0 // TODO: interfaces */
428 /* Interface query methods */
431 * atspi_accessible_is_action:
432 * @obj: a pointer to the #AtspiAccessible instance to query.
434 * Query whether the specified #AtspiAccessible implements #AtspiAction.
436 * Returns: #TRUE if @obj implements the #AtspiAction interface,
440 atspi_accessible_is_action (AtspiAccessible *obj)
442 return _atspi_accessible_is_a (obj,
443 atspi_interface_action);
447 * atspi_accessible_is_application:
448 * @obj: a pointer to the #AtspiAccessible instance to query.
450 * Query whether the specified #AtspiAccessible implements #AtspiApplication.
452 * Returns: #TRUE if @obj implements the #AtspiApplication interface,
456 atspi_accessible_is_application (AtspiAccessible *obj)
458 return _atspi_accessible_is_a (obj,
459 atspi_interface_application);
463 * atspi_accessible_is_collection: * @obj: a pointer to the #AtspiAccessible instance to query.
465 * Query whether the specified #AtspiAccessible implements #AtspiCollection.
466 * Returns: #TRUE if @obj implements the #AtspiCollection interface,
470 atspi_accessible_is_collection (AtspiAccessible *obj)
473 g_warning ("Collections not implemented");
474 return _atspi_accessible_is_a (obj,
475 atspi_interface_collection);
482 * atspi_accessible_is_component:
483 * @obj: a pointer to the #AtspiAccessible instance to query.
485 * Query whether the specified #AtspiAccessible implements #AtspiComponent.
487 * Returns: #TRUE if @obj implements the #AtspiComponent interface,
491 atspi_accessible_is_component (AtspiAccessible *obj)
493 return _atspi_accessible_is_a (obj,
494 atspi_interface_component);
498 * atspi_accessible_is_document:
499 * @obj: a pointer to the #AtspiAccessible instance to query.
501 * Query whether the specified #AtspiAccessible implements #AtspiDocument.
503 * Returns: #TRUE if @obj implements the #AtspiDocument interface,
507 atspi_accessible_is_document (AtspiAccessible *obj)
509 return _atspi_accessible_is_a (obj,
510 atspi_interface_document);
514 * atspi_accessible_is_editable_text:
515 * @obj: a pointer to the #AtspiAccessible instance to query.
517 * Query whether the specified #AtspiAccessible implements #AtspiEditableText.
519 * Returns: #TRUE if @obj implements the #AtspiEditableText interface,
523 atspi_accessible_is_editable_text (AtspiAccessible *obj)
525 return _atspi_accessible_is_a (obj,
526 atspi_interface_editable_text);
530 * atspi_accessible_is_hypertext:
531 * @obj: a pointer to the #AtspiAccessible instance to query.
533 * Query whether the specified #AtspiAccessible implements #AtspiHypertext.
535 * Returns: #TRUE if @obj implements the #AtspiHypertext interface,
539 atspi_accessible_is_hypertext (AtspiAccessible *obj)
541 return _atspi_accessible_is_a (obj,
542 atspi_interface_hypertext);
546 * atspi_accessible_is_image:
547 * @obj: a pointer to the #AtspiAccessible instance to query.
549 * Query whether the specified #AtspiAccessible implements #AtspiImage.
551 * Returns: #TRUE if @obj implements the #AtspiImage interface,
555 atspi_accessible_is_image (AtspiAccessible *obj)
557 return _atspi_accessible_is_a (obj,
558 atspi_interface_image);
562 * atspi_accessible_is_selection:
563 * @obj: a pointer to the #AtspiAccessible instance to query.
565 * Query whether the specified #AtspiAccessible implements #AtspiSelection.
567 * Returns: #TRUE if @obj implements the #AtspiSelection interface,
571 atspi_accessible_is_selection (AtspiAccessible *obj)
573 return _atspi_accessible_is_a (obj,
574 atspi_interface_selection);
578 * atspi_accessible_is_table:
579 * @obj: a pointer to the #AtspiAccessible instance to query.
581 * Query whether the specified #AtspiAccessible implements #AtspiTable.
583 * Returns: #TRUE if @obj implements the #AtspiTable interface,
587 atspi_accessible_is_table (AtspiAccessible *obj)
589 return _atspi_accessible_is_a (obj,
590 atspi_interface_table);
594 * atspi_accessible_is_streamable_content:
595 * @obj: a pointer to the #AtspiAccessible instance to query.
597 * Query whether the specified #AtspiAccessible implements
598 * #AtspiStreamableContent.
600 * Returns: #TRUE if @obj implements the #AtspiStreamableContent interface,
604 atspi_accessible_is_streamable_content (AtspiAccessible *obj)
607 return _atspi_accessible_is_a (obj,
608 atspi_interface_streamable_content);
610 g_warning ("Streamable content not implemented");
616 * atspi_accessible_is_text:
617 * @obj: a pointer to the #AtspiAccessible instance to query.
619 * Query whether the specified #AtspiAccessible implements #AtspiText.
621 * Returns: #TRUE if @obj implements the #AtspiText interface,
625 atspi_accessible_is_text (AtspiAccessible *obj)
627 return _atspi_accessible_is_a (obj,
628 atspi_interface_text);
632 * atspi_accessible_is_value:
633 * @obj: a pointer to the #AtspiAccessible instance to query.
635 * Query whether the specified #AtspiAccessible implements #AtspiValue.
637 * Returns: #TRUE if @obj implements the #AtspiValue interface,
641 atspi_accessible_is_value (AtspiAccessible *obj)
643 return _atspi_accessible_is_a (obj,
644 atspi_interface_value);
648 * atspi_accessible_get_application:
649 * @obj: a pointer to the #AtspiAccessible instance to query.
651 * Get the #AtspiApplication interface for an #AtspiAccessible.
653 * Returns: a pointer to an #AtspiApplication interface instance, or
654 * NULL if @obj does not implement #AtspiApplication.
657 atspi_accessible_get_application (AtspiAccessible *obj)
659 return (_atspi_accessible_is_a (accessible, atspi_interface_application) ?
660 ATSPI_APPLICATION (accessible) : NULL);
664 * atspi_accessible_get_action:
665 * @obj: a pointer to the #AtspiAccessible instance to query.
667 * Get the #AtspiAction interface for an #AtspiAccessible.
669 * Returns: a pointer to an #AtspiAction interface instance, or
670 * NULL if @obj does not implement #AtspiAction.
673 atspi_accessible_get_action (AtspiAccessible *obj)
675 return (_atspi_accessible_is_a (accessible, atspi_interface_action) ?
676 ATSPI_APPLICATION (accessible) : NULL);
680 * atspi_accessible_get_collection:
681 * @obj: a pointer to the #AtspiAccessible instance to query.
683 * Get the #AtspiCollection interface for an #AtspiAccessible.
685 * Returns: a pointer to an #AtspiCollection interface instance, or
686 * NULL if @obj does not implement #AtspiCollection.
689 atspi_accessible_get_collection (AtspiAccessible *obj)
691 return (_atspi_accessible_is_a (accessible, atspi_interface_collection) ?
692 ATSPI_APPLICATION (accessible) : NULL);
696 * atspi_accessible_get_component:
697 * @obj: a pointer to the #AtspiAccessible instance to query.
699 * Get the #AtspiComponent interface for an #AtspiAccessible.
701 * Returns: a pointer to an #AtspiComponent interface instance, or
702 * NULL if @obj does not implement #AtspiComponent.
705 atspi_accessible_get_component (AtspiAccessible *obj)
707 return (_atspi_accessible_is_a (accessible, atspi_interface_component) ?
708 ATSPI_APPLICATION (accessible) : NULL);
712 * atspi_accessible_get_document:
713 * @obj: a pointer to the #AtspiAccessible instance to query.
715 * Get the #AtspiDocument interface for an #AtspiAccessible.
717 * Returns: a pointer to an #AtspiDocument interface instance, or
718 * NULL if @obj does not implement #AtspiDocument.
721 atspi_accessible_get_document (AtspiAccessible *obj)
723 return (_atspi_accessible_is_a (accessible, atspi_interface_document) ?
724 ATSPI_APPLICATION (accessible) : NULL);
728 * atspi_accessible_get_editable_text:
729 * @obj: a pointer to the #AtspiAccessible instance to query.
731 * Get the #AtspiEditableText interface for an #AtspiAccessible.
733 * Returns: a pointer to an #AtspiEditableText interface instance, or
734 * NULL if @obj does not implement #AtspiEditableText.
737 atspi_accessible_get_editable_text (AtspiAccessible *obj)
739 return (_atspi_accessible_is_a (accessible, atspi_interface_editable_text) ?
740 ATSPI_APPLICATION (accessible) : NULL);
744 * atspi_accessible_get_hypertext:
745 * @obj: a pointer to the #AtspiAccessible instance to query.
747 * Get the #AtspiHypertext interface for an #AtspiAccessible.
749 * Returns: a pointer to an #AtspiHypertext interface instance, or
750 * NULL if @obj does not implement #AtspiHypertext.
753 atspi_accessible_get_hypertext (AtspiAccessible *obj)
755 return (_atspi_accessible_is_a (accessible, atspi_interface_hypertext) ?
756 ATSPI_APPLICATION (accessible) : NULL);
760 * atspi_accessible_get_image:
761 * @obj: a pointer to the #AtspiAccessible instance to query.
763 * Get the #AtspiImage interface for an #AtspiAccessible.
765 * Returns: a pointer to an #AtspiImage interface instance, or
766 * NULL if @obj does not implement #AtspiImage.
769 atspi_accessible_get_image (AtspiAccessible *obj)
771 return (_atspi_accessible_is_a (accessible, atspi_interface_image) ?
772 ATSPI_APPLICATION (accessible) : NULL);
776 * atspi_accessible_get_selection:
777 * @obj: a pointer to the #AtspiAccessible instance to query.
779 * Get the #AtspiSelection interface for an #AtspiAccessible.
781 * Returns: a pointer to an #AtspiSelection interface instance, or
782 * NULL if @obj does not implement #AtspiSelection.
785 atspi_accessible_get_selection (AtspiAccessible *obj)
787 return (_atspi_accessible_is_a (accessible, atspi_interface_selection) ?
788 ATSPI_APPLICATION (accessible) : NULL);
792 * atspi_accessible_get_streamable_content:
793 * @obj: a pointer to the #AtspiAccessible instance to query.
795 * Get the #AtspiStreamableContent interface for an #AtspiAccessible.
797 * Returns: a pointer to an #AtspiStreamableContent interface instance, or
798 * NULL if @obj does not implement #AtspiStreamableContent.
800 AtspiStreamableContent *
801 atspi_accessible_get_streamable_content (AtspiAccessible *obj)
803 return (_atspi_accessible_is_a (accessible, atspi_interface_streamable_content) ?
804 ATSPI_APPLICATION (accessible) : NULL);
808 * atspi_accessible_get_table:
809 * @obj: a pointer to the #AtspiAccessible instance to query.
811 * Get the #AtspiTable interface for an #AtspiAccessible.
813 * Returns: a pointer to an #AtspiTable interface instance, or
814 * NULL if @obj does not implement #AtspiTable.
817 atspi_accessible_get_table (AtspiAccessible *obj)
819 return (_atspi_accessible_is_a (accessible, atspi_interface_table) ?
820 ATSPI_APPLICATION (accessible) : NULL);
824 * atspi_accessible_get_text:
825 * @obj: a pointer to the #AtspiAccessible instance to query.
827 * Get the #AtspiTable interface for an #AtspiAccessible.
829 * Returns: a pointer to an #AtspiTable interface instance, or
830 * NULL if @obj does not implement #AtspiTable.
833 atspi_accessible_get_text (AtspiAccessible *obj)
835 return (_atspi_accessible_is_a (accessible, atspi_interface_text) ?
836 ATSPI_APPLICATION (accessible) : NULL);
840 * atspi_accessible_get_value:
841 * @obj: a pointer to the #AtspiAccessible instance to query.
843 * Get the #AtspiTable interface for an #AtspiAccessible.
845 * Returns: a pointer to an #AtspiTable interface instance, or
846 * NULL if @obj does not implement #AtspiTable.
849 atspi_accessible_get_value (AtspiAccessible *obj)
851 return (_atspi_accessible_is_a (accessible, atspi_interface_value) ?
852 ATSPI_APPLICATION (accessible) : NULL);
856 cspi_init_relation_type_table (AccessibleRelationType *relation_type_table)
859 for (i = 0; i < Accessibility_RELATION_LAST_DEFINED; ++i)
861 relation_type_table [i] = SPI_RELATION_NULL;
863 relation_type_table [Accessibility_RELATION_NULL] = SPI_RELATION_NULL;
864 relation_type_table [Accessibility_RELATION_LABEL_FOR] = SPI_RELATION_LABEL_FOR;
865 relation_type_table [Accessibility_RELATION_LABELLED_BY] = SPI_RELATION_LABELED_BY;
866 relation_type_table [Accessibility_RELATION_CONTROLLER_FOR] = SPI_RELATION_CONTROLLER_FOR;
867 relation_type_table [Accessibility_RELATION_CONTROLLED_BY] = SPI_RELATION_CONTROLLED_BY;
868 relation_type_table [Accessibility_RELATION_MEMBER_OF] = SPI_RELATION_MEMBER_OF;
869 relation_type_table [Accessibility_RELATION_TOOLTIP_FOR] = SPI_RELATION_NULL;
870 relation_type_table [Accessibility_RELATION_NODE_CHILD_OF] = SPI_RELATION_NODE_CHILD_OF;
871 relation_type_table [Accessibility_RELATION_EXTENDED] = SPI_RELATION_EXTENDED;
872 relation_type_table [Accessibility_RELATION_FLOWS_TO] = SPI_RELATION_FLOWS_TO;
873 relation_type_table [Accessibility_RELATION_FLOWS_FROM] = SPI_RELATION_FLOWS_FROM;
874 relation_type_table [Accessibility_RELATION_SUBWINDOW_OF] = SPI_RELATION_SUBWINDOW_OF;
875 relation_type_table [Accessibility_RELATION_EMBEDS] = SPI_RELATION_EMBEDS;
876 relation_type_table [Accessibility_RELATION_EMBEDDED_BY] = SPI_RELATION_EMBEDDED_BY;
877 relation_type_table [Accessibility_RELATION_POPUP_FOR] = SPI_RELATION_POPUP_FOR;
878 relation_type_table [Accessibility_RELATION_PARENT_WINDOW_OF] = SPI_RELATION_PARENT_WINDOW_OF;
879 relation_type_table [Accessibility_RELATION_DESCRIBED_BY] = SPI_RELATION_DESCRIBED_BY;
880 relation_type_table [Accessibility_RELATION_DESCRIPTION_FOR] = SPI_RELATION_DESCRIPTION_FOR;
884 static AccessibleRelationType
885 cspi_relation_type_from_spi_relation_type (Accessibility_RelationType type)
887 /* array is sized according to IDL RelationType because IDL RelationTypes are the index */
888 static AccessibleRelationType cspi_relation_type_table [Accessibility_RELATION_LAST_DEFINED];
889 static gboolean is_initialized = FALSE;
890 AccessibleRelationType cspi_type;
893 is_initialized = cspi_init_relation_type_table (cspi_relation_type_table);
895 if (type >= 0 && type < Accessibility_RELATION_LAST_DEFINED)
897 cspi_type = cspi_relation_type_table [type];
901 cspi_type = SPI_RELATION_NULL;
906 * AccessibleRelation_getRelationType:
907 * @obj: a pointer to the #AtspiAccessibleRelation object to query.
909 * Get the type of relationship represented by an #AtspiAccessibleRelation.
911 * Returns: an #AtspiAccessibleRelationType indicating the type of relation
912 * encapsulated in this #AtspiAccessibleRelation object.
915 AccessibleRelationType
916 AccessibleRelation_getRelationType (AccessibleRelation *obj)
918 cspi_return_val_if_fail (obj, SPI_RELATION_NULL);
919 return cspi_relation_type_from_spi_relation_type (obj->type);
923 * AccessibleRelation_getNTargets:
924 * @obj: a pointer to the #AtspiAccessibleRelation object to query.
926 * Get the number of objects which this relationship has as its
927 * target objects (the subject is the #AtspiAccessible from which this
928 * #AtspiAccessibleRelation originated).
930 * Returns: a short integer indicating how many target objects which the
931 * originating #AtspiAccessible object has the #AtspiAccessibleRelation
935 AccessibleRelation_getNTargets (AccessibleRelation *obj)
937 cspi_return_val_if_fail (obj, -1);
938 return obj->targets->len;
942 * AccessibleRelation_getTarget:
943 * @obj: a pointer to the #AtspiAccessibleRelation object to query.
944 * @i: a (zero-index) integer indicating which (of possibly several) target is requested.
946 * Get the @i-th target of a specified #AtspiAccessibleRelation relationship.
948 * Returns: an #AtspiAccessible which is the @i-th object with which the
949 * originating #AtspiAccessible has relationship specified in the
950 * #AtspiAccessibleRelation object.
954 AccessibleRelation_getTarget (AccessibleRelation *obj, int i)
956 cspi_return_val_if_fail (obj, NULL);
958 if (i < 0 || i >= obj->targets->len) return NULL;
959 return cspi_object_add (
960 g_array_index (obj->targets, Accessible *, i));
964 * AccessibleStateSet_ref:
965 * @obj: a pointer to the #AtspiAccessibleStateSet object on which to operate.
967 * Increment the reference count for an #AtspiAccessibleStateSet object.
971 AccessibleStateSet_ref (AccessibleStateSet *obj)
973 spi_state_set_cache_ref (obj);
977 * AccessibleStateSet_unref:
978 * @obj: a pointer to the #AtspiAccessibleStateSet object on which to operate.
980 * Decrement the reference count for an #AtspiAccessibleStateSet object.
984 AccessibleStateSet_unref (AccessibleStateSet *obj)
986 spi_state_set_cache_unref (obj);
989 static Accessibility_StateType
990 spi_state_to_dbus (AccessibleState state)
992 #define MAP_STATE(a) \
993 case SPI_STATE_##a: \
994 return Accessibility_STATE_##a
1002 MAP_STATE (CHECKED);
1003 MAP_STATE (DEFUNCT);
1004 MAP_STATE (EDITABLE);
1005 MAP_STATE (ENABLED);
1006 MAP_STATE (EXPANDABLE);
1007 MAP_STATE (EXPANDED);
1008 MAP_STATE (FOCUSABLE);
1009 MAP_STATE (FOCUSED);
1010 MAP_STATE (HORIZONTAL);
1011 MAP_STATE (ICONIFIED);
1013 MAP_STATE (MULTI_LINE);
1014 MAP_STATE (MULTISELECTABLE);
1016 MAP_STATE (PRESSED);
1017 MAP_STATE (RESIZABLE);
1018 MAP_STATE (SELECTABLE);
1019 MAP_STATE (SELECTED);
1020 MAP_STATE (SENSITIVE);
1021 MAP_STATE (SHOWING);
1022 MAP_STATE (SINGLE_LINE);
1024 MAP_STATE (TRANSIENT);
1025 MAP_STATE (VERTICAL);
1026 MAP_STATE (VISIBLE);
1027 MAP_STATE (MANAGES_DESCENDANTS);
1028 MAP_STATE (INDETERMINATE);
1029 MAP_STATE (TRUNCATED);
1030 MAP_STATE (REQUIRED);
1031 MAP_STATE (INVALID_ENTRY);
1032 MAP_STATE (SUPPORTS_AUTOCOMPLETION);
1033 MAP_STATE (SELECTABLE_TEXT);
1034 MAP_STATE (IS_DEFAULT);
1035 MAP_STATE (VISITED);
1037 return Accessibility_STATE_INVALID;
1043 * AccessibleStateSet_contains:
1044 * @obj: a pointer to the #AtspiAccessibleStateSet object on which to operate.
1045 * @state: an #AtspiAccessibleState for which the specified #AtspiAccessibleStateSet
1048 * Determine whether a given #AtspiAccessibleStateSet includes a given state; that is,
1049 * whether @state is true for the stateset in question.
1051 * Returns: #TRUE if @state is true/included in the given #AtspiAccessibleStateSet,
1056 AccessibleStateSet_contains (AccessibleStateSet *obj,
1057 AccessibleState state)
1059 return spi_state_set_cache_contains (obj, spi_state_to_dbus (state));
1063 * AccessibleStateSet_add:
1064 * @obj: a pointer to the #AtspiAccessibleStateSet object on which to operate.
1065 * @state: an #AtspiAccessibleState to be added to the specified #AtspiAccessibleStateSet
1067 * Add a particular #AtspiAccessibleState to an #AtspiAccessibleStateSet (i.e. set the
1068 * given state to #TRUE in the stateset.
1072 AccessibleStateSet_add (AccessibleStateSet *obj,
1073 AccessibleState state)
1075 spi_state_set_cache_add (obj, spi_state_to_dbus (state));
1079 * AccessibleStateSet_remove:
1080 * @obj: a pointer to the #AtspiAccessibleStateSet object on which to operate.
1081 * @state: an #AtspiAccessibleState to be removed from the specified #AtspiAccessibleStateSet
1083 * Remove a particular #AtspiAccessibleState to an #AtspiAccessibleStateSet (i.e. set the
1084 * given state to #FALSE in the stateset.)
1088 AccessibleStateSet_remove (AccessibleStateSet *obj,
1089 AccessibleState state)
1091 spi_state_set_cache_remove (obj, spi_state_to_dbus (state));
1095 * AccessibleStateSet_equals:
1096 * @obj: a pointer to the first #AtspiAccessibleStateSet object on which to operate.
1097 * @obj2: a pointer to the second #AtspiAccessibleStateSet object on which to operate.
1099 * Determine whether two instances of #AtspiAccessibleStateSet are equivalent (i.e.
1100 * consist of the same #AtspiAccessibleStates). Useful for checking multiple
1101 * state variables at once; construct the target state then compare against it.
1103 * @see AccessibleStateSet_compare().
1105 * Returns: #TRUE if the two #AtspiAccessibleStateSets are equivalent,
1110 AccessibleStateSet_equals (AccessibleStateSet *obj,
1111 AccessibleStateSet *obj2)
1121 cmp = spi_state_set_cache_xor (obj, obj2);
1122 eq = spi_state_set_cache_is_empty (cmp);
1123 spi_state_set_cache_unref (cmp);
1129 * AccessibleStateSet_compare:
1130 * @obj: a pointer to the first #AtspiAccessibleStateSet object on which to operate.
1131 * @obj2: a pointer to the second #AtspiAccessibleStateSet object on which to operate.
1133 * Determine the differences between two instances of #AtspiAccessibleStateSet.
1134 * Not Yet Implemented.
1136 * @see AccessibleStateSet_equals().
1138 * Returns: an #AtspiAccessibleStateSet object containing all states contained on one of
1139 * the two sets but not the other.
1142 AccessibleStateSet *
1143 AccessibleStateSet_compare (AccessibleStateSet *obj,
1144 AccessibleStateSet *obj2)
1146 return spi_state_set_cache_xor (obj, obj2);
1150 * AccessibleStateSet_isEmpty:
1151 * @obj: a pointer to the #AtspiAccessibleStateSet object on which to operate.
1153 * Determine whether a given #AtspiAccessibleStateSet is the empty set.
1155 * Returns: #TRUE if the given #AtspiAccessibleStateSet contains no (true) states,
1160 AccessibleStateSet_isEmpty (AccessibleStateSet *obj)
1162 return spi_state_set_cache_is_empty (obj);
1166 _atspi_accessible_is_a (AtspiAccessible *accessible,
1167 const char *interface_name)
1171 if (accessible == NULL)
1176 n = get_iface_num (interface_name);
1177 if (n == -1) return FALSE;
1178 return (gbooleanean)((accessible->interfaces & (1 << n))? TRUE: FALSE);
1182 /* TODO: Move to a finalizer */
1184 cspi_object_destroyed (AtspiAccessible *accessible)
1189 /* TODO: Only fire if object not already marked defunct */
1190 memset (&e, 0, sizeof(e));
1191 e.type = "object:state-change:defunct";
1192 e.source = accessible;
1194 atspi_dispatch_event (&e);
1196 g_free (accessible->path);
1198 if (accessible->states)
1199 g_object_unref (accessible->states);
1200 g_free (accessible->description);
1201 g_free (accessible->name);
1205 atspi_accessible_new ()
1207 AtspiAccessible *accessible;
1209 accessible = g_object_new (ATSPI_TYPE_ACCESSIBLE, NULL);
1210 g_return_val_if_fail (accessible != NULL, NULL);