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_finalize (AtspiAccessible *accessible)
37 g_object_unref (accessible->app);
39 g_free (accessible->path);
43 atspi_accessible_class_init (AtspiAccessibleClass *klass)
45 GObjectClass *object_class = G_OBJECT_CLASS (klass);
47 object_class->finalize = atspi_accessible_finalize;
49 /* TODO: Generate following from spec? */
50 static const char *role_names [] =
108 "table-column-header",
110 "tear-off-menu-item",
140 "input method window"
143 #define MAX_ROLES (sizeof (role_names) / sizeof (char *))
146 * atspi_role_get_name
147 * @role: an #AtspiAccessibleRole object to query.
149 * Get a localizeable string that indicates the name of an #AtspiAccessibleRole.
150 * <em>DEPRECATED.</em>
152 * Returns: a localizable string name for an #AtspiAccessibleRole enumerated type.
155 atspi_role_get_name (AtspiRole role)
157 if (role < MAX_ROLES && role_names [(int) role])
159 return g_strdup (role_names [(int) role]);
163 return g_strdup ("");
168 * atspi_accessible_get_name:
169 * @obj: a pointer to the #AtspiAccessible object on which to operate.
171 * Get the name of an #AtspiAccessible object.
173 * Returns: a UTF-8 string indicating the name of the #AtspiAccessible object.
174 * or NULL on exception
177 atspi_accessible_get_name (AtspiAccessible *obj, GError **error)
179 g_return_val_if_fail (obj != NULL, NULL);
180 return g_strdup (obj->name);
184 * atspi_accessible_get_description:
185 * @obj: a pointer to the #AtspiAccessible object on which to operate.
187 * Get the description of an #AtspiAccessible object.
189 * Returns: a UTF-8 string describing the #AtspiAccessible object.
190 * or NULL on exception
193 atspi_accessible_get_description (AtspiAccessible *obj, GError **error)
195 g_return_val_if_fail (obj != NULL, NULL);
197 return g_strdup (obj->description);
201 * atspi_accessible_get_parent:
202 * @obj: a pointer to the #AtspiAccessible object to query.
204 * Get an #AtspiAccessible object's parent container.
206 * Returns: a pointer tothe #AtspiAccessible object which contains the given
207 * #AtspiAccessible instance, or NULL if the @obj has no parent container.
211 atspi_accessible_get_parent (AtspiAccessible *obj, GError **error)
213 g_return_val_if_fail (obj != NULL, NULL);
215 return g_object_ref (obj->accessible_parent);
219 * atspi_accessible_get_child_count:
220 * @obj: a pointer to the #AtspiAccessible object on which to operate.
222 * Get the number of children contained by an #AtspiAccessible object.
224 * Returns: a #long indicating the number of #AtspiAccessible children
225 * contained by an #AtspiAccessible object. or -1 on exception
229 atspi_accessible_get_child_count (AtspiAccessible *obj, GError *error)
231 g_return_val_if_fail (obj != NULL, -1);
233 /* TODO: MANAGES_DESCENDANTS */
234 return g_list_length (obj->children);
238 * atspi_accessible_get_child_at_index:
239 * @obj: a pointer to the #AtspiAccessible object on which to operate.
240 * @child_index: a #long indicating which child is specified.
242 * Get the #AtspiAccessible child of an #AtspiAccessible object at a given index.
244 * Returns: (transfer full): a pointer to the #AtspiAccessible child object at
245 * index @child_index. or NULL on exception
248 atspi_accessible_get_child_at_index (AtspiAccessible *obj,
252 AtspiAccessible *child;
254 g_return_val_if_fail (obj != NULL, NULL);
256 /* TODO: ManagesDescendants */
257 child = g_list_nth_data (obj->children, child_index);
258 return g_object_ref (child);
262 * atspi_accessible_get_index_in_parent
263 * @obj: a pointer to the #AtspiAccessible object on which to operate.
265 * Get the index of an #AtspiAccessible object in its containing #AtspiAccessible.
267 * Returns: a #glong indicating the index of the #AtspiAccessible object
268 * in its parent (i.e. containing) #AtspiAccessible instance,
269 * or -1 if @obj has no containing parent or on exception.
272 atspi_accessible_get_index_in_parent (AtspiAccessible *obj, GError **error)
277 g_return_val_if_fail (obj != NULL, -1);
278 if (!obj->accessible_parent) return -1;
279 l = obj->accessible_parent->children;
282 if (l->data == obj) return i;
293 } Accessibility_Relation;
296 * atspi_accessible_get_relation_set:
297 * @obj: a pointer to the #AtspiAccessible object on which to operate.
299 * Get the set of #AtspiRelation objects which describe this #AtspiAccessible object's
300 * relationships with other #AtspiAccessible objects.
302 * Returns: an array of #AtspiAccessibleRelation pointers. or NULL on exception
303 * TODO:: Annotate array type
306 atspi_accessible_get_relation_set (AtspiAccessible *obj, GError **error)
310 GArray *relation_set;
312 g_return_val_if_fail (obj != NULL, NULL);
314 if (!_atspi_dbus_call (obj, atspi_interface_accessible, "GetRelationSet", error, "=>a(uao)", &relation_set))
321 * atspi_accessible_get_role:
322 * @obj: a pointer to the #AtspiAccessible object on which to operate.
324 * Get the UI role of an #AtspiAccessible object.
325 * A UTF-8 string describing this role can be obtained via atspi_accessible_getRoleName ().
327 * Returns: the #AtspiRole of the object.
331 atspi_accessible_get_role (AtspiAccessible *obj, GError **error)
333 g_return_val_if_fail (obj != NULL, ATSPI_ROLE_INVALID);
339 * atspi_accessible_get_role_name:
340 * @obj: a pointer to the #AtspiAccessible object on which to operate.
342 * Get a UTF-8 string describing the role this object plays in the UI.
343 * This method will return useful values for roles that fall outside the
344 * enumeration used in atspi_accessible_getRole ().
346 * Returns: a UTF-8 string specifying the role of this #AtspiAccessible object.
350 atspi_accessible_get_role_name (AtspiAccessible *obj, GError **error)
354 g_return_val_if_fail (obj != NULL, g_strdup ("invalid"));
356 _atspi_dbus_call (obj, atspi_interface_accessible, "GetRoleName", error, "=>s", &retval);
362 * atspi_accessible_get_localized_role_name:
363 * @obj: a pointer to the #AtspiAccessible object on which to operate.
365 * Get a UTF-8 string describing the (localized) role this object plays in the UI.
366 * This method will return useful values for roles that fall outside the
367 * enumeration used in atspi_accessible_getRole ().
369 * Returns: a UTF-8 string specifying the role of this #AtspiAccessible object.
373 atspi_accessible_get_localized_role_name (AtspiAccessible *obj, GError **error)
377 g_return_val_if_fail (obj != NULL, g_strdup ("invalid"));
379 _atspi_dbus_call (obj, atspi_interface_accessible, "GetLocalizedRoleName", error, "=>s", &retval);
385 * atspi_accessible_get_state_set:
386 * @obj: a pointer to the #AtspiAccessible object on which to operate.
388 * Gets the current state of an object.
390 * Returns: a pointer to an #AtspiStateSet representing the object's current state.
393 atspi_accessible_get_state_set (AtspiAccessible *obj)
399 * atspi_accessible_get_attributes:
400 * @obj: The #AtspiAccessible being queried.
402 * Get the #AttributeSet representing any assigned
403 * name-value pair attributes or annotations for this object.
404 * For typographic, textual, or textually-semantic attributes, see
405 * atspi_text_get_attributes instead.
407 * Returns: (transfer full): The name-value-pair attributes assigned to this
411 atspi_accessible_get_attributes (AtspiAccessible *obj, GError **error)
413 DBusMessage *message;
416 g_return_val_if_fail (obj != NULL, NULL);
418 message = _atspi_dbus_call_partial (obj, atspi_interface_accessible, "GetAttributes", error, "");
419 ret = _atspi_dbus_hash_from_message (message);
420 dbus_message_unref (message);
425 * atspi_accessible_get_host_application:
426 * @obj: The #AtspiAccessible being queried.
428 * Get the containing #AtspiApplication for an object.
430 * Returns: the containing AtspiApplication instance for this object.
433 atspi_accessible_get_host_application (AtspiAccessible *obj, GError **error)
435 while (obj->accessible_parent) obj = obj->accessible_parent;
436 g_warning ("atspi: TODO: Application interface");
437 //return atspi_accessible_get_application (obj);
440 #if 0 // TODO: interfaces */
441 /* Interface query methods */
444 * atspi_accessible_is_action:
445 * @obj: a pointer to the #AtspiAccessible instance to query.
447 * Query whether the specified #AtspiAccessible implements #AtspiAction.
449 * Returns: #TRUE if @obj implements the #AtspiAction interface,
453 atspi_accessible_is_action (AtspiAccessible *obj)
455 return _atspi_accessible_is_a (obj,
456 atspi_interface_action);
460 * atspi_accessible_is_application:
461 * @obj: a pointer to the #AtspiAccessible instance to query.
463 * Query whether the specified #AtspiAccessible implements #AtspiApplication.
465 * Returns: #TRUE if @obj implements the #AtspiApplication interface,
469 atspi_accessible_is_application (AtspiAccessible *obj)
471 return _atspi_accessible_is_a (obj,
472 atspi_interface_application);
476 * atspi_accessible_is_collection: * @obj: a pointer to the #AtspiAccessible instance to query.
478 * Query whether the specified #AtspiAccessible implements #AtspiCollection.
479 * Returns: #TRUE if @obj implements the #AtspiCollection interface,
483 atspi_accessible_is_collection (AtspiAccessible *obj)
486 g_warning ("Collections not implemented");
487 return _atspi_accessible_is_a (obj,
488 atspi_interface_collection);
495 * atspi_accessible_is_component:
496 * @obj: a pointer to the #AtspiAccessible instance to query.
498 * Query whether the specified #AtspiAccessible implements #AtspiComponent.
500 * Returns: #TRUE if @obj implements the #AtspiComponent interface,
504 atspi_accessible_is_component (AtspiAccessible *obj)
506 return _atspi_accessible_is_a (obj,
507 atspi_interface_component);
511 * atspi_accessible_is_document:
512 * @obj: a pointer to the #AtspiAccessible instance to query.
514 * Query whether the specified #AtspiAccessible implements #AtspiDocument.
516 * Returns: #TRUE if @obj implements the #AtspiDocument interface,
520 atspi_accessible_is_document (AtspiAccessible *obj)
522 return _atspi_accessible_is_a (obj,
523 atspi_interface_document);
527 * atspi_accessible_is_editable_text:
528 * @obj: a pointer to the #AtspiAccessible instance to query.
530 * Query whether the specified #AtspiAccessible implements #AtspiEditableText.
532 * Returns: #TRUE if @obj implements the #AtspiEditableText interface,
536 atspi_accessible_is_editable_text (AtspiAccessible *obj)
538 return _atspi_accessible_is_a (obj,
539 atspi_interface_editable_text);
543 * atspi_accessible_is_hypertext:
544 * @obj: a pointer to the #AtspiAccessible instance to query.
546 * Query whether the specified #AtspiAccessible implements #AtspiHypertext.
548 * Returns: #TRUE if @obj implements the #AtspiHypertext interface,
552 atspi_accessible_is_hypertext (AtspiAccessible *obj)
554 return _atspi_accessible_is_a (obj,
555 atspi_interface_hypertext);
559 * atspi_accessible_is_image:
560 * @obj: a pointer to the #AtspiAccessible instance to query.
562 * Query whether the specified #AtspiAccessible implements #AtspiImage.
564 * Returns: #TRUE if @obj implements the #AtspiImage interface,
568 atspi_accessible_is_image (AtspiAccessible *obj)
570 return _atspi_accessible_is_a (obj,
571 atspi_interface_image);
575 * atspi_accessible_is_selection:
576 * @obj: a pointer to the #AtspiAccessible instance to query.
578 * Query whether the specified #AtspiAccessible implements #AtspiSelection.
580 * Returns: #TRUE if @obj implements the #AtspiSelection interface,
584 atspi_accessible_is_selection (AtspiAccessible *obj)
586 return _atspi_accessible_is_a (obj,
587 atspi_interface_selection);
591 * atspi_accessible_is_table:
592 * @obj: a pointer to the #AtspiAccessible instance to query.
594 * Query whether the specified #AtspiAccessible implements #AtspiTable.
596 * Returns: #TRUE if @obj implements the #AtspiTable interface,
600 atspi_accessible_is_table (AtspiAccessible *obj)
602 return _atspi_accessible_is_a (obj,
603 atspi_interface_table);
607 * atspi_accessible_is_streamable_content:
608 * @obj: a pointer to the #AtspiAccessible instance to query.
610 * Query whether the specified #AtspiAccessible implements
611 * #AtspiStreamableContent.
613 * Returns: #TRUE if @obj implements the #AtspiStreamableContent interface,
617 atspi_accessible_is_streamable_content (AtspiAccessible *obj)
620 return _atspi_accessible_is_a (obj,
621 atspi_interface_streamable_content);
623 g_warning ("Streamable content not implemented");
629 * atspi_accessible_is_text:
630 * @obj: a pointer to the #AtspiAccessible instance to query.
632 * Query whether the specified #AtspiAccessible implements #AtspiText.
634 * Returns: #TRUE if @obj implements the #AtspiText interface,
638 atspi_accessible_is_text (AtspiAccessible *obj)
640 return _atspi_accessible_is_a (obj,
641 atspi_interface_text);
645 * atspi_accessible_is_value:
646 * @obj: a pointer to the #AtspiAccessible instance to query.
648 * Query whether the specified #AtspiAccessible implements #AtspiValue.
650 * Returns: #TRUE if @obj implements the #AtspiValue interface,
654 atspi_accessible_is_value (AtspiAccessible *obj)
656 return _atspi_accessible_is_a (obj,
657 atspi_interface_value);
661 * atspi_accessible_get_application:
662 * @obj: a pointer to the #AtspiAccessible instance to query.
664 * Get the #AtspiApplication interface for an #AtspiAccessible.
666 * Returns: a pointer to an #AtspiApplication interface instance, or
667 * NULL if @obj does not implement #AtspiApplication.
670 atspi_accessible_get_application (AtspiAccessible *obj)
672 return (_atspi_accessible_is_a (accessible, atspi_interface_application) ?
673 ATSPI_APPLICATION (accessible) : NULL);
677 * atspi_accessible_get_action:
678 * @obj: a pointer to the #AtspiAccessible instance to query.
680 * Get the #AtspiAction interface for an #AtspiAccessible.
682 * Returns: a pointer to an #AtspiAction interface instance, or
683 * NULL if @obj does not implement #AtspiAction.
686 atspi_accessible_get_action (AtspiAccessible *obj)
688 return (_atspi_accessible_is_a (accessible, atspi_interface_action) ?
689 ATSPI_APPLICATION (accessible) : NULL);
693 * atspi_accessible_get_collection:
694 * @obj: a pointer to the #AtspiAccessible instance to query.
696 * Get the #AtspiCollection interface for an #AtspiAccessible.
698 * Returns: a pointer to an #AtspiCollection interface instance, or
699 * NULL if @obj does not implement #AtspiCollection.
702 atspi_accessible_get_collection (AtspiAccessible *obj)
704 return (_atspi_accessible_is_a (accessible, atspi_interface_collection) ?
705 ATSPI_APPLICATION (accessible) : NULL);
709 * atspi_accessible_get_component:
710 * @obj: a pointer to the #AtspiAccessible instance to query.
712 * Get the #AtspiComponent interface for an #AtspiAccessible.
714 * Returns: a pointer to an #AtspiComponent interface instance, or
715 * NULL if @obj does not implement #AtspiComponent.
718 atspi_accessible_get_component (AtspiAccessible *obj)
720 return (_atspi_accessible_is_a (accessible, atspi_interface_component) ?
721 ATSPI_APPLICATION (accessible) : NULL);
725 * atspi_accessible_get_document:
726 * @obj: a pointer to the #AtspiAccessible instance to query.
728 * Get the #AtspiDocument interface for an #AtspiAccessible.
730 * Returns: a pointer to an #AtspiDocument interface instance, or
731 * NULL if @obj does not implement #AtspiDocument.
734 atspi_accessible_get_document (AtspiAccessible *obj)
736 return (_atspi_accessible_is_a (accessible, atspi_interface_document) ?
737 ATSPI_APPLICATION (accessible) : NULL);
741 * atspi_accessible_get_editable_text:
742 * @obj: a pointer to the #AtspiAccessible instance to query.
744 * Get the #AtspiEditableText interface for an #AtspiAccessible.
746 * Returns: a pointer to an #AtspiEditableText interface instance, or
747 * NULL if @obj does not implement #AtspiEditableText.
750 atspi_accessible_get_editable_text (AtspiAccessible *obj)
752 return (_atspi_accessible_is_a (accessible, atspi_interface_editable_text) ?
753 ATSPI_APPLICATION (accessible) : NULL);
757 * atspi_accessible_get_hypertext:
758 * @obj: a pointer to the #AtspiAccessible instance to query.
760 * Get the #AtspiHypertext interface for an #AtspiAccessible.
762 * Returns: a pointer to an #AtspiHypertext interface instance, or
763 * NULL if @obj does not implement #AtspiHypertext.
766 atspi_accessible_get_hypertext (AtspiAccessible *obj)
768 return (_atspi_accessible_is_a (accessible, atspi_interface_hypertext) ?
769 ATSPI_APPLICATION (accessible) : NULL);
773 * atspi_accessible_get_image:
774 * @obj: a pointer to the #AtspiAccessible instance to query.
776 * Get the #AtspiImage interface for an #AtspiAccessible.
778 * Returns: a pointer to an #AtspiImage interface instance, or
779 * NULL if @obj does not implement #AtspiImage.
782 atspi_accessible_get_image (AtspiAccessible *obj)
784 return (_atspi_accessible_is_a (accessible, atspi_interface_image) ?
785 ATSPI_APPLICATION (accessible) : NULL);
789 * atspi_accessible_get_selection:
790 * @obj: a pointer to the #AtspiAccessible instance to query.
792 * Get the #AtspiSelection interface for an #AtspiAccessible.
794 * Returns: a pointer to an #AtspiSelection interface instance, or
795 * NULL if @obj does not implement #AtspiSelection.
798 atspi_accessible_get_selection (AtspiAccessible *obj)
800 return (_atspi_accessible_is_a (accessible, atspi_interface_selection) ?
801 ATSPI_APPLICATION (accessible) : NULL);
805 * atspi_accessible_get_streamable_content:
806 * @obj: a pointer to the #AtspiAccessible instance to query.
808 * Get the #AtspiStreamableContent interface for an #AtspiAccessible.
810 * Returns: a pointer to an #AtspiStreamableContent interface instance, or
811 * NULL if @obj does not implement #AtspiStreamableContent.
813 AtspiStreamableContent *
814 atspi_accessible_get_streamable_content (AtspiAccessible *obj)
816 return (_atspi_accessible_is_a (accessible, atspi_interface_streamable_content) ?
817 ATSPI_APPLICATION (accessible) : NULL);
821 * atspi_accessible_get_table:
822 * @obj: a pointer to the #AtspiAccessible instance to query.
824 * Get the #AtspiTable interface for an #AtspiAccessible.
826 * Returns: a pointer to an #AtspiTable interface instance, or
827 * NULL if @obj does not implement #AtspiTable.
830 atspi_accessible_get_table (AtspiAccessible *obj)
832 return (_atspi_accessible_is_a (accessible, atspi_interface_table) ?
833 ATSPI_APPLICATION (accessible) : NULL);
837 * atspi_accessible_get_text:
838 * @obj: a pointer to the #AtspiAccessible instance to query.
840 * Get the #AtspiTable interface for an #AtspiAccessible.
842 * Returns: a pointer to an #AtspiTable interface instance, or
843 * NULL if @obj does not implement #AtspiTable.
846 atspi_accessible_get_text (AtspiAccessible *obj)
848 return (_atspi_accessible_is_a (accessible, atspi_interface_text) ?
849 ATSPI_APPLICATION (accessible) : NULL);
853 * atspi_accessible_get_value:
854 * @obj: a pointer to the #AtspiAccessible instance to query.
856 * Get the #AtspiTable interface for an #AtspiAccessible.
858 * Returns: a pointer to an #AtspiTable interface instance, or
859 * NULL if @obj does not implement #AtspiTable.
862 atspi_accessible_get_value (AtspiAccessible *obj)
864 return (_atspi_accessible_is_a (accessible, atspi_interface_value) ?
865 ATSPI_APPLICATION (accessible) : NULL);
869 cspi_init_relation_type_table (AccessibleRelationType *relation_type_table)
872 for (i = 0; i < Accessibility_RELATION_LAST_DEFINED; ++i)
874 relation_type_table [i] = SPI_RELATION_NULL;
876 relation_type_table [Accessibility_RELATION_NULL] = SPI_RELATION_NULL;
877 relation_type_table [Accessibility_RELATION_LABEL_FOR] = SPI_RELATION_LABEL_FOR;
878 relation_type_table [Accessibility_RELATION_LABELLED_BY] = SPI_RELATION_LABELED_BY;
879 relation_type_table [Accessibility_RELATION_CONTROLLER_FOR] = SPI_RELATION_CONTROLLER_FOR;
880 relation_type_table [Accessibility_RELATION_CONTROLLED_BY] = SPI_RELATION_CONTROLLED_BY;
881 relation_type_table [Accessibility_RELATION_MEMBER_OF] = SPI_RELATION_MEMBER_OF;
882 relation_type_table [Accessibility_RELATION_TOOLTIP_FOR] = SPI_RELATION_NULL;
883 relation_type_table [Accessibility_RELATION_NODE_CHILD_OF] = SPI_RELATION_NODE_CHILD_OF;
884 relation_type_table [Accessibility_RELATION_EXTENDED] = SPI_RELATION_EXTENDED;
885 relation_type_table [Accessibility_RELATION_FLOWS_TO] = SPI_RELATION_FLOWS_TO;
886 relation_type_table [Accessibility_RELATION_FLOWS_FROM] = SPI_RELATION_FLOWS_FROM;
887 relation_type_table [Accessibility_RELATION_SUBWINDOW_OF] = SPI_RELATION_SUBWINDOW_OF;
888 relation_type_table [Accessibility_RELATION_EMBEDS] = SPI_RELATION_EMBEDS;
889 relation_type_table [Accessibility_RELATION_EMBEDDED_BY] = SPI_RELATION_EMBEDDED_BY;
890 relation_type_table [Accessibility_RELATION_POPUP_FOR] = SPI_RELATION_POPUP_FOR;
891 relation_type_table [Accessibility_RELATION_PARENT_WINDOW_OF] = SPI_RELATION_PARENT_WINDOW_OF;
892 relation_type_table [Accessibility_RELATION_DESCRIBED_BY] = SPI_RELATION_DESCRIBED_BY;
893 relation_type_table [Accessibility_RELATION_DESCRIPTION_FOR] = SPI_RELATION_DESCRIPTION_FOR;
897 static AccessibleRelationType
898 cspi_relation_type_from_spi_relation_type (Accessibility_RelationType type)
900 /* array is sized according to IDL RelationType because IDL RelationTypes are the index */
901 static AccessibleRelationType cspi_relation_type_table [Accessibility_RELATION_LAST_DEFINED];
902 static gboolean is_initialized = FALSE;
903 AccessibleRelationType cspi_type;
906 is_initialized = cspi_init_relation_type_table (cspi_relation_type_table);
908 if (type >= 0 && type < Accessibility_RELATION_LAST_DEFINED)
910 cspi_type = cspi_relation_type_table [type];
914 cspi_type = SPI_RELATION_NULL;
919 * AccessibleRelation_getRelationType:
920 * @obj: a pointer to the #AtspiAccessibleRelation object to query.
922 * Get the type of relationship represented by an #AtspiAccessibleRelation.
924 * Returns: an #AtspiAccessibleRelationType indicating the type of relation
925 * encapsulated in this #AtspiAccessibleRelation object.
928 AccessibleRelationType
929 AccessibleRelation_getRelationType (AccessibleRelation *obj)
931 cspi_return_val_if_fail (obj, SPI_RELATION_NULL);
932 return cspi_relation_type_from_spi_relation_type (obj->type);
936 * AccessibleRelation_getNTargets:
937 * @obj: a pointer to the #AtspiAccessibleRelation object to query.
939 * Get the number of objects which this relationship has as its
940 * target objects (the subject is the #AtspiAccessible from which this
941 * #AtspiAccessibleRelation originated).
943 * Returns: a short integer indicating how many target objects which the
944 * originating #AtspiAccessible object has the #AtspiAccessibleRelation
948 AccessibleRelation_getNTargets (AccessibleRelation *obj)
950 cspi_return_val_if_fail (obj, -1);
951 return obj->targets->len;
955 * AccessibleRelation_getTarget:
956 * @obj: a pointer to the #AtspiAccessibleRelation object to query.
957 * @i: a (zero-index) integer indicating which (of possibly several) target is requested.
959 * Get the @i-th target of a specified #AtspiAccessibleRelation relationship.
961 * Returns: an #AtspiAccessible which is the @i-th object with which the
962 * originating #AtspiAccessible has relationship specified in the
963 * #AtspiAccessibleRelation object.
967 AccessibleRelation_getTarget (AccessibleRelation *obj, int i)
969 cspi_return_val_if_fail (obj, NULL);
971 if (i < 0 || i >= obj->targets->len) return NULL;
972 return cspi_object_add (
973 g_array_index (obj->targets, Accessible *, i));
977 * AccessibleStateSet_ref:
978 * @obj: a pointer to the #AtspiAccessibleStateSet object on which to operate.
980 * Increment the reference count for an #AtspiAccessibleStateSet object.
984 AccessibleStateSet_ref (AccessibleStateSet *obj)
986 spi_state_set_cache_ref (obj);
990 * AccessibleStateSet_unref:
991 * @obj: a pointer to the #AtspiAccessibleStateSet object on which to operate.
993 * Decrement the reference count for an #AtspiAccessibleStateSet object.
997 AccessibleStateSet_unref (AccessibleStateSet *obj)
999 spi_state_set_cache_unref (obj);
1002 static Accessibility_StateType
1003 spi_state_to_dbus (AccessibleState state)
1005 #define MAP_STATE(a) \
1006 case SPI_STATE_##a: \
1007 return Accessibility_STATE_##a
1011 MAP_STATE (INVALID);
1015 MAP_STATE (CHECKED);
1016 MAP_STATE (DEFUNCT);
1017 MAP_STATE (EDITABLE);
1018 MAP_STATE (ENABLED);
1019 MAP_STATE (EXPANDABLE);
1020 MAP_STATE (EXPANDED);
1021 MAP_STATE (FOCUSABLE);
1022 MAP_STATE (FOCUSED);
1023 MAP_STATE (HORIZONTAL);
1024 MAP_STATE (ICONIFIED);
1026 MAP_STATE (MULTI_LINE);
1027 MAP_STATE (MULTISELECTABLE);
1029 MAP_STATE (PRESSED);
1030 MAP_STATE (RESIZABLE);
1031 MAP_STATE (SELECTABLE);
1032 MAP_STATE (SELECTED);
1033 MAP_STATE (SENSITIVE);
1034 MAP_STATE (SHOWING);
1035 MAP_STATE (SINGLE_LINE);
1037 MAP_STATE (TRANSIENT);
1038 MAP_STATE (VERTICAL);
1039 MAP_STATE (VISIBLE);
1040 MAP_STATE (MANAGES_DESCENDANTS);
1041 MAP_STATE (INDETERMINATE);
1042 MAP_STATE (TRUNCATED);
1043 MAP_STATE (REQUIRED);
1044 MAP_STATE (INVALID_ENTRY);
1045 MAP_STATE (SUPPORTS_AUTOCOMPLETION);
1046 MAP_STATE (SELECTABLE_TEXT);
1047 MAP_STATE (IS_DEFAULT);
1048 MAP_STATE (VISITED);
1050 return Accessibility_STATE_INVALID;
1056 * AccessibleStateSet_contains:
1057 * @obj: a pointer to the #AtspiAccessibleStateSet object on which to operate.
1058 * @state: an #AtspiAccessibleState for which the specified #AtspiAccessibleStateSet
1061 * Determine whether a given #AtspiAccessibleStateSet includes a given state; that is,
1062 * whether @state is true for the stateset in question.
1064 * Returns: #TRUE if @state is true/included in the given #AtspiAccessibleStateSet,
1069 AccessibleStateSet_contains (AccessibleStateSet *obj,
1070 AccessibleState state)
1072 return spi_state_set_cache_contains (obj, spi_state_to_dbus (state));
1076 * AccessibleStateSet_add:
1077 * @obj: a pointer to the #AtspiAccessibleStateSet object on which to operate.
1078 * @state: an #AtspiAccessibleState to be added to the specified #AtspiAccessibleStateSet
1080 * Add a particular #AtspiAccessibleState to an #AtspiAccessibleStateSet (i.e. set the
1081 * given state to #TRUE in the stateset.
1085 AccessibleStateSet_add (AccessibleStateSet *obj,
1086 AccessibleState state)
1088 spi_state_set_cache_add (obj, spi_state_to_dbus (state));
1092 * AccessibleStateSet_remove:
1093 * @obj: a pointer to the #AtspiAccessibleStateSet object on which to operate.
1094 * @state: an #AtspiAccessibleState to be removed from the specified #AtspiAccessibleStateSet
1096 * Remove a particular #AtspiAccessibleState to an #AtspiAccessibleStateSet (i.e. set the
1097 * given state to #FALSE in the stateset.)
1101 AccessibleStateSet_remove (AccessibleStateSet *obj,
1102 AccessibleState state)
1104 spi_state_set_cache_remove (obj, spi_state_to_dbus (state));
1108 * AccessibleStateSet_equals:
1109 * @obj: a pointer to the first #AtspiAccessibleStateSet object on which to operate.
1110 * @obj2: a pointer to the second #AtspiAccessibleStateSet object on which to operate.
1112 * Determine whether two instances of #AtspiAccessibleStateSet are equivalent (i.e.
1113 * consist of the same #AtspiAccessibleStates). Useful for checking multiple
1114 * state variables at once; construct the target state then compare against it.
1116 * @see AccessibleStateSet_compare().
1118 * Returns: #TRUE if the two #AtspiAccessibleStateSets are equivalent,
1123 AccessibleStateSet_equals (AccessibleStateSet *obj,
1124 AccessibleStateSet *obj2)
1134 cmp = spi_state_set_cache_xor (obj, obj2);
1135 eq = spi_state_set_cache_is_empty (cmp);
1136 spi_state_set_cache_unref (cmp);
1142 * AccessibleStateSet_compare:
1143 * @obj: a pointer to the first #AtspiAccessibleStateSet object on which to operate.
1144 * @obj2: a pointer to the second #AtspiAccessibleStateSet object on which to operate.
1146 * Determine the differences between two instances of #AtspiAccessibleStateSet.
1147 * Not Yet Implemented.
1149 * @see AccessibleStateSet_equals().
1151 * Returns: an #AtspiAccessibleStateSet object containing all states contained on one of
1152 * the two sets but not the other.
1155 AccessibleStateSet *
1156 AccessibleStateSet_compare (AccessibleStateSet *obj,
1157 AccessibleStateSet *obj2)
1159 return spi_state_set_cache_xor (obj, obj2);
1163 * AccessibleStateSet_isEmpty:
1164 * @obj: a pointer to the #AtspiAccessibleStateSet object on which to operate.
1166 * Determine whether a given #AtspiAccessibleStateSet is the empty set.
1168 * Returns: #TRUE if the given #AtspiAccessibleStateSet contains no (true) states,
1173 AccessibleStateSet_isEmpty (AccessibleStateSet *obj)
1175 return spi_state_set_cache_is_empty (obj);
1179 _atspi_accessible_is_a (AtspiAccessible *accessible,
1180 const char *interface_name)
1184 if (accessible == NULL)
1189 n = get_iface_num (interface_name);
1190 if (n == -1) return FALSE;
1191 return (gbooleanean)((accessible->interfaces & (1 << n))? TRUE: FALSE);
1195 /* TODO: Move to a finalizer */
1197 cspi_object_destroyed (AtspiAccessible *accessible)
1202 /* TODO: Only fire if object not already marked defunct */
1203 memset (&e, 0, sizeof(e));
1204 e.type = "object:state-change:defunct";
1205 e.source = accessible;
1208 g_warning ("atspi: TODO: Finish events");
1209 atspi_dispatch_event (&e);
1212 g_free (accessible->path);
1214 if (accessible->states)
1215 g_object_unref (accessible->states);
1216 g_free (accessible->description);
1217 g_free (accessible->name);
1221 atspi_accessible_new (AtspiApplication *app, const gchar *path)
1223 AtspiAccessible *accessible;
1225 accessible = g_object_new (ATSPI_TYPE_ACCESSIBLE, NULL);
1226 g_return_val_if_fail (accessible != NULL, NULL);
1228 accessible->app = g_object_ref (app);
1229 accessible->path = g_strdup (path);