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.
7 * Copyright 2010, 2011 Novell, Inc.
9 * This library is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Library General Public
11 * License as published by the Free Software Foundation; either
12 * version 2 of the License, or (at your option) any later version.
14 * This library is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * Library General Public License for more details.
19 * You should have received a copy of the GNU Library General Public
20 * License along with this library; if not, write to the
21 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
22 * Boston, MA 02111-1307, USA.
25 #include "atspi-private.h"
29 atspi_action_interface_init (AtspiAction *action)
34 atspi_collection_interface_init (AtspiCollection *component)
39 atspi_component_interface_init (AtspiComponent *component)
44 atspi_document_interface_init (AtspiDocument *document)
49 atspi_editable_text_interface_init (AtspiEditableText *editable_text)
54 atspi_hypertext_interface_init (AtspiHypertext *hypertext)
59 atspi_image_interface_init (AtspiImage *image)
64 atspi_selection_interface_init (AtspiSelection *selection)
69 atspi_table_interface_init (AtspiTable *table)
74 atspi_text_interface_init (AtspiText *text)
79 atspi_value_interface_init (AtspiValue *value)
83 G_DEFINE_TYPE_WITH_CODE (AtspiAccessible, atspi_accessible, ATSPI_TYPE_OBJECT,
84 G_IMPLEMENT_INTERFACE (ATSPI_TYPE_ACTION, atspi_action_interface_init)
85 G_IMPLEMENT_INTERFACE (ATSPI_TYPE_COLLECTION, atspi_collection_interface_init)
86 G_IMPLEMENT_INTERFACE (ATSPI_TYPE_COMPONENT, atspi_component_interface_init)
87 G_IMPLEMENT_INTERFACE (ATSPI_TYPE_DOCUMENT, atspi_document_interface_init)
88 G_IMPLEMENT_INTERFACE (ATSPI_TYPE_EDITABLE_TEXT, atspi_editable_text_interface_init)
89 G_IMPLEMENT_INTERFACE (ATSPI_TYPE_HYPERTEXT, atspi_hypertext_interface_init)
90 G_IMPLEMENT_INTERFACE (ATSPI_TYPE_IMAGE, atspi_image_interface_init)
91 G_IMPLEMENT_INTERFACE (ATSPI_TYPE_SELECTION, atspi_selection_interface_init)
92 G_IMPLEMENT_INTERFACE (ATSPI_TYPE_TABLE, atspi_table_interface_init)
93 G_IMPLEMENT_INTERFACE (ATSPI_TYPE_TEXT, atspi_text_interface_init)
94 G_IMPLEMENT_INTERFACE (ATSPI_TYPE_VALUE, atspi_value_interface_init))
96 #ifdef DEBUG_REF_COUNTS
97 static gint accessible_count = 0;
101 atspi_accessible_init (AtspiAccessible *accessible)
103 #ifdef DEBUG_REF_COUNTS
105 printf("at-spi: init: %d objects\n", accessible_count);
110 atspi_accessible_dispose (GObject *object)
112 AtspiAccessible *accessible = ATSPI_ACCESSIBLE (object);
114 AtspiAccessible *parent;
116 /* TODO: Only fire if object not already marked defunct */
117 memset (&e, 0, sizeof (e));
118 e.type = "object:state-change:defunct";
119 e.source = accessible;
122 _atspi_send_event (&e);
124 if (accessible->states)
126 g_object_unref (accessible->states);
127 accessible->states = NULL;
130 parent = accessible->accessible_parent;
131 if (parent && parent->children)
133 GList*ls = g_list_find (parent->children, accessible);
136 gboolean replace = (ls == parent->children);
137 ls = g_list_remove (ls, accessible);
139 parent->children = ls;
140 g_object_unref (object);
146 g_object_unref (parent);
147 accessible->accessible_parent = NULL;
150 G_OBJECT_CLASS (atspi_accessible_parent_class) ->dispose (object);
154 atspi_accessible_finalize (GObject *object)
156 AtspiAccessible *accessible = ATSPI_ACCESSIBLE (object);
158 g_free (accessible->description);
159 g_free (accessible->name);
161 #ifdef DEBUG_REF_COUNTS
163 printf("at-spi: finalize: %d objects\n", accessible_count);
166 G_OBJECT_CLASS (atspi_accessible_parent_class)
171 atspi_accessible_class_init (AtspiAccessibleClass *klass)
173 GObjectClass *object_class = G_OBJECT_CLASS (klass);
175 object_class->dispose = atspi_accessible_dispose;
176 object_class->finalize = atspi_accessible_finalize;
179 /* TODO: Generate following from spec? */
180 static const char *role_names [] =
238 "table-column-header",
240 "tear-off-menu-item",
270 "input method window"
273 #define MAX_ROLES (sizeof (role_names) / sizeof (char *))
276 * atspi_role_get_name
277 * @role: an #AtspiAccessibleRole object to query.
279 * Get a localizeable string that indicates the name of an #AtspiAccessibleRole.
280 * <em>DEPRECATED.</em>
282 * Returns: a localizable string name for an #AtspiAccessibleRole enumerated type.
285 atspi_role_get_name (AtspiRole role)
287 if (role < MAX_ROLES && role_names [(int) role])
289 return g_strdup (role_names [(int) role]);
293 return g_strdup ("");
298 * atspi_accessible_get_name:
299 * @obj: a pointer to the #AtspiAccessible object on which to operate.
301 * Get the name of an #AtspiAccessible object.
303 * Returns: a UTF-8 string indicating the name of the #AtspiAccessible object.
304 * or NULL on exception
307 atspi_accessible_get_name (AtspiAccessible *obj, GError **error)
309 g_return_val_if_fail (obj != NULL, g_strdup (""));
310 if (!(obj->cached_properties & ATSPI_CACHE_NAME))
312 if (!_atspi_dbus_get_property (obj, atspi_interface_accessible, "Name", error,
314 return g_strdup ("");
315 _atspi_accessible_add_cache (obj, ATSPI_CACHE_NAME);
317 return g_strdup (obj->name);
321 * atspi_accessible_get_description:
322 * @obj: a pointer to the #AtspiAccessible object on which to operate.
324 * Get the description of an #AtspiAccessible object.
326 * Returns: a UTF-8 string describing the #AtspiAccessible object.
327 * or NULL on exception
330 atspi_accessible_get_description (AtspiAccessible *obj, GError **error)
332 g_return_val_if_fail (obj != NULL, g_strdup (""));
334 if (!(obj->cached_properties & ATSPI_CACHE_DESCRIPTION))
336 if (!_atspi_dbus_get_property (obj, atspi_interface_accessible,
337 "Description", error, "s",
339 return g_strdup ("");
340 _atspi_accessible_add_cache (obj, ATSPI_CACHE_DESCRIPTION);
342 return g_strdup (obj->description);
345 const char *str_parent = "Parent";
348 * atspi_accessible_get_parent:
349 * @obj: a pointer to the #AtspiAccessible object to query.
351 * Get an #AtspiAccessible object's parent container.
353 * Returns: (transfer full): a pointer to the #AtspiAccessible object which
354 * contains the given #AtspiAccessible instance, or NULL if the @obj
355 * has no parent container.
359 atspi_accessible_get_parent (AtspiAccessible *obj, GError **error)
361 g_return_val_if_fail (obj != NULL, NULL);
363 if (obj->parent.app && !(obj->cached_properties & ATSPI_CACHE_PARENT))
365 DBusMessage *message, *reply;
366 DBusMessageIter iter, iter_variant;
367 message = dbus_message_new_method_call (obj->parent.app->bus_name,
369 DBUS_INTERFACE_PROPERTIES, "Get");
372 dbus_message_append_args (message, DBUS_TYPE_STRING, &atspi_interface_accessible,
373 DBUS_TYPE_STRING, &str_parent,
375 reply = _atspi_dbus_send_with_reply_and_block (message, error);
378 if (strcmp (dbus_message_get_signature (reply), "v") != 0)
380 dbus_message_unref (reply);
383 dbus_message_iter_init (reply, &iter);
384 dbus_message_iter_recurse (&iter, &iter_variant);
385 obj->accessible_parent = _atspi_dbus_return_accessible_from_iter (&iter_variant);
386 dbus_message_unref (reply);
387 _atspi_accessible_add_cache (obj, ATSPI_CACHE_PARENT);
389 if (!obj->accessible_parent)
391 return g_object_ref (obj->accessible_parent);
395 * atspi_accessible_get_child_count:
396 * @obj: a pointer to the #AtspiAccessible object on which to operate.
398 * Get the number of children contained by an #AtspiAccessible object.
400 * Returns: a #long indicating the number of #AtspiAccessible children
401 * contained by an #AtspiAccessible object. or -1 on exception
405 atspi_accessible_get_child_count (AtspiAccessible *obj, GError **error)
407 g_return_val_if_fail (obj != NULL, -1);
409 if (!(obj->cached_properties & ATSPI_CACHE_CHILDREN))
412 if (!_atspi_dbus_get_property (obj, atspi_interface_accessible,
413 "ChildCount", error, "i", &ret))
418 return g_list_length (obj->children);
422 * atspi_accessible_get_child_at_index:
423 * @obj: a pointer to the #AtspiAccessible object on which to operate.
424 * @child_index: a #long indicating which child is specified.
426 * Get the #AtspiAccessible child of an #AtspiAccessible object at a given index.
428 * Returns: (transfer full): a pointer to the #AtspiAccessible child object at
429 * index @child_index. or NULL on exception
432 atspi_accessible_get_child_at_index (AtspiAccessible *obj,
436 AtspiAccessible *child;
438 g_return_val_if_fail (obj != NULL, NULL);
440 if (!(obj->cached_properties & ATSPI_CACHE_CHILDREN))
443 reply = _atspi_dbus_call_partial (obj, atspi_interface_accessible,
444 "GetChildAtIndex", error, "i",
446 return _atspi_dbus_return_accessible_from_message (reply);
449 child = g_list_nth_data (obj->children, child_index);
452 return g_object_ref (child);
456 * atspi_accessible_get_index_in_parent
457 * @obj: a pointer to the #AtspiAccessible object on which to operate.
459 * Get the index of an #AtspiAccessible object in its containing #AtspiAccessible.
461 * Returns: a #glong indicating the index of the #AtspiAccessible object
462 * in its parent (i.e. containing) #AtspiAccessible instance,
463 * or -1 if @obj has no containing parent or on exception.
466 atspi_accessible_get_index_in_parent (AtspiAccessible *obj, GError **error)
471 g_return_val_if_fail (obj != NULL, -1);
472 if (!obj->accessible_parent) return -1;
473 if (!(obj->accessible_parent->cached_properties & ATSPI_CACHE_CHILDREN))
475 dbus_uint32_t ret = -1;
476 _atspi_dbus_call (obj, atspi_interface_accessible,
477 "GetIndexInParent", NULL, "=>u", &ret);
481 l = obj->accessible_parent->children;
484 if (l->data == obj) return i;
495 } Accessibility_Relation;
498 * atspi_accessible_get_relation_set:
499 * @obj: a pointer to the #AtspiAccessible object on which to operate.
501 * Get the set of #AtspiRelation objects which describe this #AtspiAccessible object's
502 * relationships with other #AtspiAccessible objects.
504 * Returns: (element-type AtspiAccessible*) (transfer full): an array of
505 * #AtspiAccessibleRelation pointers. or NULL on exception
508 atspi_accessible_get_relation_set (AtspiAccessible *obj, GError **error)
511 DBusMessageIter iter, iter_array;
514 g_return_val_if_fail (obj != NULL, NULL);
516 reply = _atspi_dbus_call_partial (obj, atspi_interface_accessible, "GetRelationSet", error, "");
519 _ATSPI_DBUS_CHECK_SIG (reply, "a(ua(so))", error, NULL);
521 ret = g_array_new (TRUE, TRUE, sizeof (AtspiRelation *));
522 dbus_message_iter_init (reply, &iter);
523 dbus_message_iter_recurse (&iter, &iter_array);
524 while (dbus_message_iter_get_arg_type (&iter_array) != DBUS_TYPE_INVALID)
527 AtspiRelation *relation;
528 relation = _atspi_relation_new_from_iter (&iter_array);
529 new_array = g_array_append_val (ret, relation);
532 dbus_message_iter_next (&iter_array);
534 dbus_message_unref (reply);
539 * atspi_accessible_get_role:
540 * @obj: a pointer to the #AtspiAccessible object on which to operate.
542 * Get the UI role of an #AtspiAccessible object.
543 * A UTF-8 string describing this role can be obtained via atspi_accessible_getRoleName ().
545 * Returns: the #AtspiRole of the object.
549 atspi_accessible_get_role (AtspiAccessible *obj, GError **error)
551 g_return_val_if_fail (obj != NULL, ATSPI_ROLE_INVALID);
553 if (!(obj->cached_properties & ATSPI_CACHE_ROLE))
556 /* TODO: Make this a property */
557 if (_atspi_dbus_call (obj, atspi_interface_accessible, "GetRole", error, "=>u", &role))
560 _atspi_accessible_add_cache (obj, ATSPI_CACHE_ROLE);
567 * atspi_accessible_get_role_name:
568 * @obj: a pointer to the #AtspiAccessible object on which to operate.
570 * Get a UTF-8 string describing the role this object plays in the UI.
571 * This method will return useful values for roles that fall outside the
572 * enumeration used in atspi_accessible_getRole ().
574 * Returns: a UTF-8 string specifying the role of this #AtspiAccessible object.
578 atspi_accessible_get_role_name (AtspiAccessible *obj, GError **error)
582 g_return_val_if_fail (obj != NULL, NULL);
584 _atspi_dbus_call (obj, atspi_interface_accessible, "GetRoleName", error, "=>s", &retval);
587 retval = g_strdup ("");
593 * atspi_accessible_get_localized_role_name:
594 * @obj: a pointer to the #AtspiAccessible object on which to operate.
596 * Get a UTF-8 string describing the (localized) role this object plays in the UI.
597 * This method will return useful values for roles that fall outside the
598 * enumeration used in atspi_accessible_getRole ().
600 * Returns: a UTF-8 string specifying the role of this #AtspiAccessible object.
604 atspi_accessible_get_localized_role_name (AtspiAccessible *obj, GError **error)
608 g_return_val_if_fail (obj != NULL, NULL);
610 _atspi_dbus_call (obj, atspi_interface_accessible, "GetLocalizedRoleName", error, "=>s", &retval);
613 return g_strdup ("");
618 static AtspiStateSet *
621 AtspiStateSet *set = atspi_state_set_new (NULL);
622 atspi_state_set_add (set, ATSPI_STATE_DEFUNCT);
627 * atspi_accessible_get_state_set:
628 * @obj: a pointer to the #AtspiAccessible object on which to operate.
630 * Gets the current state of an object.
632 * Returns: (transfer full): a pointer to an #AtspiStateSet representing the
633 * object's current state.
636 atspi_accessible_get_state_set (AtspiAccessible *obj)
638 if (!obj->parent.app || !obj->parent.app->bus)
639 return defunct_set ();
642 if (!(obj->cached_properties & ATSPI_CACHE_STATES))
645 DBusMessageIter iter;
646 reply = _atspi_dbus_call_partial (obj, atspi_interface_accessible,
647 "GetState", NULL, "");
648 _ATSPI_DBUS_CHECK_SIG (reply, "au", NULL, defunct_set ());
649 dbus_message_iter_init (reply, &iter);
650 _atspi_dbus_set_state (obj, &iter);
651 dbus_message_unref (reply);
652 _atspi_accessible_add_cache (obj, ATSPI_CACHE_STATES);
655 return g_object_ref (obj->states);
659 * atspi_accessible_get_attributes:
660 * @obj: The #AtspiAccessible being queried.
662 * Get the #AttributeSet representing any assigned
663 * name-value pair attributes or annotations for this object.
664 * For typographic, textual, or textually-semantic attributes, see
665 * atspi_text_get_attributes instead.
667 * Returns: (element-type gchar* gchar*) (transfer full): The name-value-pair
668 * attributes assigned to this object.
671 atspi_accessible_get_attributes (AtspiAccessible *obj, GError **error)
673 DBusMessage *message;
675 g_return_val_if_fail (obj != NULL, NULL);
677 message = _atspi_dbus_call_partial (obj, atspi_interface_accessible, "GetAttributes", error, "");
678 return _atspi_dbus_return_hash_from_message (message);
682 * atspi_accessible_get_attributes_as_array:
683 * @obj: The #AtspiAccessible being queried.
685 * Get the #AttributeSet representing any assigned
686 * name-value pair attributes or annotations for this object.
687 * For typographic, textual, or textually-semantic attributes, see
688 * atspi_text_get_attributes_as_array instead.
690 * Returns: (element-type gchar*) (transfer full): The name-value-pair
691 * attributes assigned to this object.
694 atspi_accessible_get_attributes_as_array (AtspiAccessible *obj, GError **error)
696 DBusMessage *message;
698 g_return_val_if_fail (obj != NULL, NULL);
700 message = _atspi_dbus_call_partial (obj, atspi_interface_accessible, "GetAttributes", error, "");
701 return _atspi_dbus_return_attribute_array_from_message (message);
705 * atspi_accessible_get_application:
706 * @obj: The #AtspiAccessible being queried.
708 * Get the containing #AtspiApplication for an object.
710 * Returns: (transfer full): the containing AtspiApplication instance for
714 atspi_accessible_get_application (AtspiAccessible *obj, GError **error)
716 AtspiAccessible *parent;
721 parent = atspi_accessible_get_parent (obj, NULL);
722 if (!parent && obj->parent.app &&
723 atspi_accessible_get_role (obj, NULL) != ATSPI_ROLE_APPLICATION)
725 AtspiAccessible *root = g_object_ref (obj->parent.app->root);
728 g_object_unref (obj);
732 if (!parent || parent == obj ||
733 atspi_accessible_get_role (parent, NULL) == ATSPI_ROLE_DESKTOP_FRAME)
735 g_object_unref (obj);
740 /* Application-specific methods */
743 * atspi_accessible_get_toolkit_name:
744 * @obj: a pointer to the #AtspiAccessible object on which to operate.
746 * Get the toolkit for a #AtspiAccessible object.
747 * Only works on application root objects.
749 * Returns: a UTF-8 string indicating the toolkit name for the #AtspiAccessible object.
750 * or NULL on exception
753 atspi_accessible_get_toolkit_name (AtspiAccessible *obj, GError **error)
757 g_return_val_if_fail (obj != NULL, NULL);
759 if (!_atspi_dbus_get_property (obj, atspi_interface_application, "ToolkitName", error, "s", &ret))
761 return g_strdup (ret);
765 * atspi_accessible_get_toolkit_version:
766 * @obj: a pointer to the #AtspiAccessible object on which to operate.
768 * Get the toolkit version for a #AtspiAccessible object.
769 * Only works on application root objects.
771 * Returns: a UTF-8 string indicating the toolkit ersion for the #AtspiAccessible object.
772 * or NULL on exception
775 atspi_accessible_get_toolkit_version (AtspiAccessible *obj, GError **error)
779 g_return_val_if_fail (obj != NULL, NULL);
781 if (!_atspi_dbus_get_property (obj, atspi_interface_application, "ToolkitVersion", error, "s", &ret))
783 return g_strdup (ret);
785 /* Interface query methods */
788 _atspi_accessible_is_a (AtspiAccessible *accessible,
789 const char *interface_name)
793 if (accessible == NULL)
798 if (!(accessible->cached_properties & ATSPI_CACHE_INTERFACES))
801 DBusMessageIter iter;
802 reply = _atspi_dbus_call_partial (accessible, atspi_interface_accessible,
803 "GetInterfaces", NULL, "");
804 _ATSPI_DBUS_CHECK_SIG (reply, "as", NULL, FALSE);
805 dbus_message_iter_init (reply, &iter);
806 _atspi_dbus_set_interfaces (accessible, &iter);
807 dbus_message_unref (reply);
808 _atspi_accessible_add_cache (accessible, ATSPI_CACHE_INTERFACES);
811 n = _atspi_get_iface_num (interface_name);
812 if (n == -1) return FALSE;
813 return (gboolean) ((accessible->interfaces & (1 << n))? TRUE: FALSE);
817 * atspi_accessible_is_action:
818 * @obj: a pointer to the #AtspiAccessible instance to query.
820 * Query whether the specified #AtspiAccessible implements #AtspiAction.
822 * Returns: #TRUE if @obj implements the #AtspiAction interface,
826 atspi_accessible_is_action (AtspiAccessible *obj)
828 return _atspi_accessible_is_a (obj,
829 atspi_interface_action);
833 * atspi_accessible_is_application:
834 * @obj: a pointer to the #AtspiAccessible instance to query.
836 * Query whether the specified #AtspiAccessible implements #AtspiApplication.
838 * Returns: #TRUE if @obj implements the #AtspiApplication interface,
842 atspi_accessible_is_application (AtspiAccessible *obj)
844 return _atspi_accessible_is_a (obj,
845 atspi_interface_application);
849 * atspi_accessible_is_collection: * @obj: a pointer to the #AtspiAccessible instance to query.
851 * Query whether the specified #AtspiAccessible implements #AtspiCollection.
852 * Returns: #TRUE if @obj implements the #AtspiCollection interface,
856 atspi_accessible_is_collection (AtspiAccessible *obj)
858 return _atspi_accessible_is_a (obj,
859 atspi_interface_collection);
863 * atspi_accessible_is_component:
864 * @obj: a pointer to the #AtspiAccessible instance to query.
866 * Query whether the specified #AtspiAccessible implements #AtspiComponent.
868 * Returns: #TRUE if @obj implements the #AtspiComponent interface,
872 atspi_accessible_is_component (AtspiAccessible *obj)
874 return _atspi_accessible_is_a (obj,
875 atspi_interface_component);
879 * atspi_accessible_is_document:
880 * @obj: a pointer to the #AtspiAccessible instance to query.
882 * Query whether the specified #AtspiAccessible implements #AtspiDocument.
884 * Returns: #TRUE if @obj implements the #AtspiDocument interface,
888 atspi_accessible_is_document (AtspiAccessible *obj)
890 return _atspi_accessible_is_a (obj,
891 atspi_interface_document);
895 * atspi_accessible_is_editable_text:
896 * @obj: a pointer to the #AtspiAccessible instance to query.
898 * Query whether the specified #AtspiAccessible implements #AtspiEditableText.
900 * Returns: #TRUE if @obj implements the #AtspiEditableText interface,
904 atspi_accessible_is_editable_text (AtspiAccessible *obj)
906 return _atspi_accessible_is_a (obj,
907 atspi_interface_editable_text);
911 * atspi_accessible_is_hypertext:
912 * @obj: a pointer to the #AtspiAccessible instance to query.
914 * Query whether the specified #AtspiAccessible implements #AtspiHypertext.
916 * Returns: #TRUE if @obj implements the #AtspiHypertext interface,
920 atspi_accessible_is_hypertext (AtspiAccessible *obj)
922 return _atspi_accessible_is_a (obj,
923 atspi_interface_hypertext);
927 * atspi_accessible_is_hyperlink:
928 * @obj: a pointer to the #AtspiAccessible instance to query.
930 * Query whether the specified #AtspiAccessible implements #AtspiHyperlink.
932 * Returns: #TRUE if @obj implements the #AtspiHypertext interface,
936 atspi_accessible_is_hyperlink (AtspiAccessible *obj)
938 return _atspi_accessible_is_a (obj,
939 atspi_interface_hyperlink);
943 * atspi_accessible_is_image:
944 * @obj: a pointer to the #AtspiAccessible instance to query.
946 * Query whether the specified #AtspiAccessible implements #AtspiImage.
948 * Returns: #TRUE if @obj implements the #AtspiImage interface,
952 atspi_accessible_is_image (AtspiAccessible *obj)
954 return _atspi_accessible_is_a (obj,
955 atspi_interface_image);
959 * atspi_accessible_is_selection:
960 * @obj: a pointer to the #AtspiAccessible instance to query.
962 * Query whether the specified #AtspiAccessible implements #AtspiSelection.
964 * Returns: #TRUE if @obj implements the #AtspiSelection interface,
968 atspi_accessible_is_selection (AtspiAccessible *obj)
970 return _atspi_accessible_is_a (obj,
971 atspi_interface_selection);
975 * atspi_accessible_is_table:
976 * @obj: a pointer to the #AtspiAccessible instance to query.
978 * Query whether the specified #AtspiAccessible implements #AtspiTable.
980 * Returns: #TRUE if @obj implements the #AtspiTable interface,
984 atspi_accessible_is_table (AtspiAccessible *obj)
986 return _atspi_accessible_is_a (obj,
987 atspi_interface_table);
991 * atspi_accessible_is_streamable_content:
992 * @obj: a pointer to the #AtspiAccessible instance to query.
994 * Query whether the specified #AtspiAccessible implements
995 * #AtspiStreamableContent.
997 * Returns: #TRUE if @obj implements the #AtspiStreamableContent interface,
1001 atspi_accessible_is_streamable_content (AtspiAccessible *obj)
1004 return _atspi_accessible_is_a (obj,
1005 atspi_interface_streamable_content);
1007 g_warning (_("Streamable content not implemented"));
1013 * atspi_accessible_is_text:
1014 * @obj: a pointer to the #AtspiAccessible instance to query.
1016 * Query whether the specified #AtspiAccessible implements #AtspiText.
1018 * Returns: #TRUE if @obj implements the #AtspiText interface,
1022 atspi_accessible_is_text (AtspiAccessible *obj)
1024 return _atspi_accessible_is_a (obj,
1025 atspi_interface_text);
1029 * atspi_accessible_is_value:
1030 * @obj: a pointer to the #AtspiAccessible instance to query.
1032 * Query whether the specified #AtspiAccessible implements #AtspiValue.
1034 * Returns: #TRUE if @obj implements the #AtspiValue interface,
1038 atspi_accessible_is_value (AtspiAccessible *obj)
1040 return _atspi_accessible_is_a (obj,
1041 atspi_interface_value);
1045 * atspi_accessible_get_action:
1046 * @obj: a pointer to the #AtspiAccessible instance to query.
1048 * Get the #AtspiAction interface for an #AtspiAccessible.
1050 * Returns: (transfer full): a pointer to an #AtspiAction interface
1051 * instance, or NULL if @obj does not implement #AtspiAction.
1054 atspi_accessible_get_action (AtspiAccessible *accessible)
1056 return (_atspi_accessible_is_a (accessible, atspi_interface_action) ?
1057 g_object_ref (ATSPI_ACTION (accessible)) : NULL);
1061 * atspi_accessible_get_collection:
1062 * @obj: a pointer to the #AtspiAccessible instance to query.
1064 * Get the #AtspiCollection interface for an #AtspiAccessible.
1066 * Returns: (transfer full): a pointer to an #AtspiCollection interface
1067 * instance, or NULL if @obj does not implement #AtspiCollection.
1070 atspi_accessible_get_collection (AtspiAccessible *accessible)
1072 return (_atspi_accessible_is_a (accessible, atspi_interface_collection) ?
1073 g_object_ref (ATSPI_COLLECTION (accessible)) : NULL);
1077 * atspi_accessible_get_component:
1078 * @obj: a pointer to the #AtspiAccessible instance to query.
1080 * Get the #AtspiComponent interface for an #AtspiAccessible.
1082 * Returns: (transfer full): a pointer to an #AtspiComponent interface
1083 * instance, or NULL if @obj does not implement #AtspiComponent.
1086 atspi_accessible_get_component (AtspiAccessible *obj)
1088 return (_atspi_accessible_is_a (obj, atspi_interface_component) ?
1089 g_object_ref (ATSPI_COMPONENT (obj)) : NULL);
1093 * atspi_accessible_get_document:
1094 * @obj: a pointer to the #AtspiAccessible instance to query.
1096 * Get the #AtspiDocument interface for an #AtspiAccessible.
1098 * Returns: (transfer full): a pointer to an #AtspiDocument interface
1099 * instance, or NULL if @obj does not implement #AtspiDocument.
1102 atspi_accessible_get_document (AtspiAccessible *accessible)
1104 return (_atspi_accessible_is_a (accessible, atspi_interface_document) ?
1105 g_object_ref (ATSPI_DOCUMENT (accessible)) : NULL);
1109 * atspi_accessible_get_editable_text:
1110 * @obj: a pointer to the #AtspiAccessible instance to query.
1112 * Get the #AtspiEditableText interface for an #AtspiAccessible.
1114 * Returns: (transfer full): a pointer to an #AtspiEditableText interface
1115 * instance, or NULL if @obj does not implement #AtspiEditableText.
1118 atspi_accessible_get_editable_text (AtspiAccessible *accessible)
1120 return (_atspi_accessible_is_a (accessible, atspi_interface_editable_text) ?
1121 g_object_ref (ATSPI_EDITABLE_TEXT (accessible)) : NULL);
1125 * atspi_accessible_get_hyperlink:
1126 * @obj: a pointer to the #AtspiAccessible object on which to operate.
1128 * Get the #AtspiHyperlink associated with the given #AtspiAccessible, if
1131 * Returns: (transfer full): the #AtspiHyperlink object associated with
1132 * the given #AtspiAccessible, or NULL if not supported.
1135 atspi_accessible_get_hyperlink (AtspiAccessible *accessible)
1137 return (_atspi_accessible_is_a (accessible, atspi_interface_hyperlink) ?
1138 atspi_hyperlink_new (accessible->parent.app, accessible->parent.path) : NULL);
1142 * atspi_accessible_get_hypertext:
1143 * @obj: a pointer to the #AtspiAccessible instance to query.
1145 * Get the #AtspiHypertext interface for an #AtspiAccessible.
1147 * Returns: (transfer full): a pointer to an #AtspiHypertext interface
1148 * instance, or NULL if @obj does not implement #AtspiHypertext.
1151 atspi_accessible_get_hypertext (AtspiAccessible *accessible)
1153 return (_atspi_accessible_is_a (accessible, atspi_interface_hypertext) ?
1154 g_object_ref (ATSPI_HYPERTEXT (accessible)) : NULL);
1158 * atspi_accessible_get_image:
1159 * @obj: a pointer to the #AtspiAccessible instance to query.
1161 * Get the #AtspiImage interface for an #AtspiAccessible.
1163 * Returns: (transfer full): a pointer to an #AtspiImage interface instance, or
1164 * NULL if @obj does not implement #AtspiImage.
1167 atspi_accessible_get_image (AtspiAccessible *accessible)
1169 return (_atspi_accessible_is_a (accessible, atspi_interface_image) ?
1170 g_object_ref (ATSPI_IMAGE (accessible)) : NULL);
1174 * atspi_accessible_get_selection:
1175 * @obj: a pointer to the #AtspiAccessible instance to query.
1177 * Get the #AtspiSelection interface for an #AtspiAccessible.
1179 * Returns: (transfer full): a pointer to an #AtspiSelection interface
1180 * instance, or NULL if @obj does not implement #AtspiSelection.
1183 atspi_accessible_get_selection (AtspiAccessible *accessible)
1185 return (_atspi_accessible_is_a (accessible, atspi_interface_selection) ?
1186 g_object_ref (ATSPI_SELECTION (accessible)) : NULL);
1191 * atspi_accessible_get_streamable_content:
1192 * @obj: a pointer to the #AtspiAccessible instance to query.
1194 * Get the #AtspiStreamableContent interface for an #AtspiAccessible.
1196 * Returns: (transfer full): a pointer to an #AtspiStreamableContent interface
1197 * instance, or NULL if @obj does not implement #AtspiStreamableContent.
1199 AtspiStreamableContent *
1200 atspi_accessible_get_streamable_content (AtspiAccessible *accessible)
1202 return (_atspi_accessible_is_a (accessible, atspi_interface_streamable_content) ?
1208 * atspi_accessible_get_table:
1209 * @obj: a pointer to the #AtspiAccessible instance to query.
1211 * Get the #AtspiTable interface for an #AtspiAccessible.
1213 * Returns: (transfer full): a pointer to an #AtspiTable interface instance, or
1214 * NULL if @obj does not implement #AtspiTable.
1217 atspi_accessible_get_table (AtspiAccessible *obj)
1219 return (_atspi_accessible_is_a (obj, atspi_interface_table) ?
1220 g_object_ref (ATSPI_TABLE (obj)) : NULL);
1224 * atspi_accessible_get_text:
1225 * @obj: a pointer to the #AtspiAccessible instance to query.
1227 * Get the #AtspiTable interface for an #AtspiAccessible.
1229 * Returns: (transfer full): a pointer to an #AtspiText interface instance, or
1230 * NULL if @obj does not implement #AtspiText.
1233 atspi_accessible_get_text (AtspiAccessible *obj)
1235 return (_atspi_accessible_is_a (obj, atspi_interface_text) ?
1236 g_object_ref (ATSPI_TEXT (obj)) : NULL);
1240 * atspi_accessible_get_value:
1241 * @obj: a pointer to the #AtspiAccessible instance to query.
1243 * Get the #AtspiTable interface for an #AtspiAccessible.
1245 * Returns: (transfer full): a pointer to an #AtspiValue interface instance, or
1246 * NULL if @obj does not implement #AtspiValue.
1249 atspi_accessible_get_value (AtspiAccessible *accessible)
1251 return (_atspi_accessible_is_a (accessible, atspi_interface_value) ?
1252 g_object_ref (ATSPI_VALUE (accessible)) : NULL);
1256 append_const_val (GArray *array, const gchar *val)
1258 gchar *dup = g_strdup (val);
1261 g_array_append_val (array, dup);
1265 * atspi_accessible_get_interfaces:
1267 * #obj: The #AtspiAccessible to query.
1269 * Returns: (element-type gchar*) (transfer full): A #GArray of strings
1270 * describing the interfaces supported by the object. Interfaces are
1271 * denoted in short-hand (ie, "Component", "Text", etc.)
1274 atspi_accessible_get_interfaces (AtspiAccessible *obj)
1276 GArray *ret = g_array_new (TRUE, TRUE, sizeof (gchar *));
1281 g_return_val_if_fail (obj != NULL, NULL);
1283 append_const_val (ret, "Accessible");
1284 if (atspi_accessible_is_action (obj))
1285 append_const_val (ret, "Action");
1286 if (atspi_accessible_is_collection (obj))
1287 append_const_val (ret, "Collection");
1288 if (atspi_accessible_is_component (obj))
1289 append_const_val (ret, "Component");
1290 if (atspi_accessible_is_document (obj))
1291 append_const_val (ret, "Document");
1292 if (atspi_accessible_is_editable_text (obj))
1293 append_const_val (ret, "EditableText");
1294 if (atspi_accessible_is_hypertext (obj))
1295 append_const_val (ret, "Hypertext");
1296 if (atspi_accessible_is_hyperlink (obj))
1297 append_const_val (ret, "Hyperlink");
1298 if (atspi_accessible_is_image (obj))
1299 append_const_val (ret, "Image");
1300 if (atspi_accessible_is_selection (obj))
1301 append_const_val (ret, "Selection");
1302 if (atspi_accessible_is_table (obj))
1303 append_const_val (ret, "Table");
1304 if (atspi_accessible_is_text (obj))
1305 append_const_val (ret, "Text");
1306 if (atspi_accessible_is_value (obj))
1307 append_const_val (ret, "Value");
1313 atspi_accessible_new (AtspiApplication *app, const gchar *path)
1315 AtspiAccessible *accessible;
1317 accessible = g_object_new (ATSPI_TYPE_ACCESSIBLE, NULL);
1318 g_return_val_if_fail (accessible != NULL, NULL);
1320 accessible->parent.app = g_object_ref (app);
1321 accessible->parent.path = g_strdup (path);
1327 * atspi_accessible_set_cache_mask:
1329 * @accessible: The #AtspiAccessible to operate on. Must be the desktop or
1330 * the root of an application.
1331 * @mask: An #AtspiCache specifying a bit mask of the types of data to cache.
1333 * Sets the type of data to cache for accessibles.
1334 * If this is not set for an application or is reset to ATSPI_CACHE_UNDEFINED,
1335 * then the desktop's cache flag will be used.
1336 * If the desktop's cache flag is also undefined, then all possible data will
1338 * This function is intended to work around bugs in toolkits where the proper
1339 * events are not raised / to aid in testing for such bugs.
1341 * Note: This function has no effect on data that has already been cached.
1344 atspi_accessible_set_cache_mask (AtspiAccessible *accessible, AtspiCache mask)
1346 g_return_if_fail (accessible != NULL);
1347 g_return_if_fail (accessible->parent.app != NULL);
1348 g_return_if_fail (accessible == accessible->parent.app->root);
1349 accessible->parent.app->cache = mask;
1353 _atspi_accessible_add_cache (AtspiAccessible *accessible, AtspiCache flag)
1355 AtspiCache mask = accessible->parent.app->cache;
1357 if (mask == ATSPI_CACHE_UNDEFINED &&
1358 accessible->parent.app->root &&
1359 accessible->parent.app->root->accessible_parent)
1361 AtspiAccessible *desktop = atspi_get_desktop (0);
1362 mask = desktop->parent.app->cache;
1363 g_object_unref (desktop);
1366 if (mask == ATSPI_CACHE_UNDEFINED)
1367 mask = ATSPI_CACHE_ALL;
1369 accessible->cached_properties |= flag & mask;