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"
26 #include "atspi-accessible-private.h"
29 static gboolean enable_caching = FALSE;
30 static guint quark_locale;
33 atspi_action_interface_init (AtspiAction *action)
38 atspi_collection_interface_init (AtspiCollection *component)
43 atspi_component_interface_init (AtspiComponent *component)
48 atspi_document_interface_init (AtspiDocument *document)
53 atspi_editable_text_interface_init (AtspiEditableText *editable_text)
58 atspi_hypertext_interface_init (AtspiHypertext *hypertext)
63 atspi_image_interface_init (AtspiImage *image)
68 atspi_selection_interface_init (AtspiSelection *selection)
73 atspi_table_interface_init (AtspiTable *table)
78 atspi_table_cell_interface_init (AtspiTableCell *cell)
83 atspi_text_interface_init (AtspiText *text)
88 atspi_value_interface_init (AtspiValue *value)
92 G_DEFINE_TYPE_WITH_CODE (AtspiAccessible, atspi_accessible, ATSPI_TYPE_OBJECT,
93 G_ADD_PRIVATE (AtspiAccessible)
94 G_IMPLEMENT_INTERFACE (ATSPI_TYPE_ACTION, atspi_action_interface_init)
95 G_IMPLEMENT_INTERFACE (ATSPI_TYPE_COLLECTION, atspi_collection_interface_init)
96 G_IMPLEMENT_INTERFACE (ATSPI_TYPE_COMPONENT, atspi_component_interface_init)
97 G_IMPLEMENT_INTERFACE (ATSPI_TYPE_DOCUMENT, atspi_document_interface_init)
98 G_IMPLEMENT_INTERFACE (ATSPI_TYPE_EDITABLE_TEXT, atspi_editable_text_interface_init)
99 G_IMPLEMENT_INTERFACE (ATSPI_TYPE_HYPERTEXT, atspi_hypertext_interface_init)
100 G_IMPLEMENT_INTERFACE (ATSPI_TYPE_IMAGE, atspi_image_interface_init)
101 G_IMPLEMENT_INTERFACE (ATSPI_TYPE_SELECTION, atspi_selection_interface_init)
102 G_IMPLEMENT_INTERFACE (ATSPI_TYPE_TABLE, atspi_table_interface_init)
103 G_IMPLEMENT_INTERFACE (ATSPI_TYPE_TABLE_CELL, atspi_table_cell_interface_init)
104 G_IMPLEMENT_INTERFACE (ATSPI_TYPE_TEXT, atspi_text_interface_init)
105 G_IMPLEMENT_INTERFACE (ATSPI_TYPE_VALUE, atspi_value_interface_init))
107 #ifdef DEBUG_REF_COUNTS
108 static gint accessible_count = 0;
112 atspi_accessible_init (AtspiAccessible *accessible)
114 #ifdef DEBUG_REF_COUNTS
116 g_hash_table_insert (_atspi_get_live_refs (), accessible, NULL);
117 g_print("at-spi: init: %d objects\n", accessible_count);
120 accessible->priv = atspi_accessible_get_instance_private (accessible);
124 atspi_accessible_dispose (GObject *object)
126 AtspiAccessible *accessible = ATSPI_ACCESSIBLE (object);
128 AtspiAccessible *parent;
132 /* TODO: Only fire if object not already marked defunct */
133 memset (&e, 0, sizeof (e));
134 e.type = "object:state-changed:defunct";
135 e.source = accessible;
138 _atspi_send_event (&e);
140 if (accessible->states)
142 g_object_unref (accessible->states);
143 accessible->states = NULL;
146 parent = accessible->accessible_parent;
147 if (parent && parent->children)
149 GList*ls = g_list_find (parent->children, accessible);
152 gboolean replace = (ls == parent->children);
153 ls = g_list_remove (ls, accessible);
155 parent->children = ls;
156 g_object_unref (object);
162 g_object_unref (parent);
163 accessible->accessible_parent = NULL;
166 children = accessible->children;
167 accessible->children = NULL;
168 for (l = children; l; l = l->next)
170 AtspiAccessible *child = l->data;
171 if (child && child->accessible_parent == accessible)
173 g_object_unref (accessible);
174 child->accessible_parent = NULL;
176 g_object_unref (child);
178 g_list_free (children);
180 G_OBJECT_CLASS (atspi_accessible_parent_class) ->dispose (object);
184 atspi_accessible_finalize (GObject *object)
186 AtspiAccessible *accessible = ATSPI_ACCESSIBLE (object);
188 g_free (accessible->description);
189 g_free (accessible->name);
190 if (accessible->attributes)
191 g_hash_table_unref (accessible->attributes);
193 if (accessible->priv->cache)
194 g_hash_table_destroy (accessible->priv->cache);
196 #ifdef DEBUG_REF_COUNTS
198 g_hash_table_remove (_atspi_get_live_refs (), accessible);
199 g_print ("at-spi: finalize: %d objects\n", accessible_count);
202 G_OBJECT_CLASS (atspi_accessible_parent_class)
207 atspi_accessible_class_init (AtspiAccessibleClass *klass)
209 GObjectClass *object_class = G_OBJECT_CLASS (klass);
211 object_class->dispose = atspi_accessible_dispose;
212 object_class->finalize = atspi_accessible_finalize;
214 quark_locale = g_quark_from_string ("accessible-locale");
218 * atspi_accessible_get_name:
219 * @obj: a pointer to the #AtspiAccessible object on which to operate.
221 * Gets the name of an #AtspiAccessible object.
223 * Returns: a UTF-8 string indicating the name of the #AtspiAccessible object
224 * or NULL on exception.
227 atspi_accessible_get_name (AtspiAccessible *obj, GError **error)
229 g_return_val_if_fail (obj != NULL, g_strdup (""));
230 if (!_atspi_accessible_test_cache (obj, ATSPI_CACHE_NAME))
232 if (!_atspi_dbus_get_property (obj, atspi_interface_accessible, "Name", error,
234 return g_strdup ("");
235 _atspi_accessible_add_cache (obj, ATSPI_CACHE_NAME);
237 return g_strdup (obj->name);
241 * atspi_accessible_get_description:
242 * @obj: a pointer to the #AtspiAccessible object on which to operate.
244 * Gets the description of an #AtspiAccessible object.
246 * Returns: a UTF-8 string describing the #AtspiAccessible object
247 * or NULL on exception.
250 atspi_accessible_get_description (AtspiAccessible *obj, GError **error)
252 g_return_val_if_fail (obj != NULL, g_strdup (""));
254 if (!_atspi_accessible_test_cache (obj, ATSPI_CACHE_DESCRIPTION))
256 if (!_atspi_dbus_get_property (obj, atspi_interface_accessible,
257 "Description", error, "s",
259 return g_strdup ("");
260 _atspi_accessible_add_cache (obj, ATSPI_CACHE_DESCRIPTION);
262 return g_strdup (obj->description);
265 const char *str_parent = "Parent";
268 * atspi_accessible_get_parent:
269 * @obj: a pointer to the #AtspiAccessible object to query.
271 * Gets an #AtspiAccessible object's parent container.
273 * Returns: (nullable) (transfer full): a pointer to the
274 * #AtspiAccessible object which contains the given
275 * #AtspiAccessible instance, or NULL if the @obj has no
280 atspi_accessible_get_parent (AtspiAccessible *obj, GError **error)
282 g_return_val_if_fail (obj != NULL, NULL);
284 if (obj->parent.app &&
285 !_atspi_accessible_test_cache (obj, ATSPI_CACHE_PARENT))
287 DBusMessage *message, *reply;
288 DBusMessageIter iter, iter_variant;
289 message = dbus_message_new_method_call (obj->parent.app->bus_name,
291 DBUS_INTERFACE_PROPERTIES, "Get");
294 dbus_message_append_args (message, DBUS_TYPE_STRING, &atspi_interface_accessible,
295 DBUS_TYPE_STRING, &str_parent,
297 reply = _atspi_dbus_send_with_reply_and_block (message, error);
300 if (strcmp (dbus_message_get_signature (reply), "v") != 0)
302 dbus_message_unref (reply);
305 dbus_message_iter_init (reply, &iter);
306 dbus_message_iter_recurse (&iter, &iter_variant);
307 obj->accessible_parent = _atspi_dbus_return_accessible_from_iter (&iter_variant);
308 dbus_message_unref (reply);
309 _atspi_accessible_add_cache (obj, ATSPI_CACHE_PARENT);
311 if (!obj->accessible_parent)
313 return g_object_ref (obj->accessible_parent);
317 * atspi_accessible_get_child_count:
318 * @obj: a pointer to the #AtspiAccessible object on which to operate.
320 * Gets the number of children contained by an #AtspiAccessible object.
322 * Returns: a #long indicating the number of #AtspiAccessible children
323 * contained by an #AtspiAccessible object or -1 on exception.
327 atspi_accessible_get_child_count (AtspiAccessible *obj, GError **error)
329 g_return_val_if_fail (obj != NULL, -1);
331 if (!_atspi_accessible_test_cache (obj, ATSPI_CACHE_CHILDREN))
334 if (!_atspi_dbus_get_property (obj, atspi_interface_accessible,
335 "ChildCount", error, "i", &ret))
340 return g_list_length (obj->children);
344 * atspi_accessible_get_child_at_index:
345 * @obj: a pointer to the #AtspiAccessible object on which to operate.
346 * @child_index: a #long indicating which child is specified.
348 * Gets the #AtspiAccessible child of an #AtspiAccessible object at a given index.
350 * Returns: (transfer full): a pointer to the #AtspiAccessible child object at
351 * index @child_index or NULL on exception.
354 atspi_accessible_get_child_at_index (AtspiAccessible *obj,
358 AtspiAccessible *child;
360 g_return_val_if_fail (obj != NULL, NULL);
362 if (!_atspi_accessible_test_cache (obj, ATSPI_CACHE_CHILDREN))
365 reply = _atspi_dbus_call_partial (obj, atspi_interface_accessible,
366 "GetChildAtIndex", error, "i",
368 return _atspi_dbus_return_accessible_from_message (reply);
371 child = g_list_nth_data (obj->children, child_index);
374 return g_object_ref (child);
378 * atspi_accessible_get_index_in_parent:
379 * @obj: a pointer to the #AtspiAccessible object on which to operate.
381 * Gets the index of an #AtspiAccessible object within its parent's
382 * #AtspiAccessible children list.
384 * Returns: a #glong indicating the index of the #AtspiAccessible object
386 * or -1 if @obj has no containing parent or on exception.
389 atspi_accessible_get_index_in_parent (AtspiAccessible *obj, GError **error)
394 g_return_val_if_fail (obj != NULL, -1);
395 if (_atspi_accessible_test_cache (obj, ATSPI_CACHE_PARENT) &&
396 !obj->accessible_parent)
398 if (!obj->accessible_parent ||
399 !_atspi_accessible_test_cache (obj->accessible_parent,
400 ATSPI_CACHE_CHILDREN))
402 dbus_int32_t ret = -1;
403 _atspi_dbus_call (obj, atspi_interface_accessible,
404 "GetIndexInParent", NULL, "=>i", &ret);
408 l = obj->accessible_parent->children;
411 if (l->data == obj) return i;
422 } Accessibility_Relation;
425 * atspi_accessible_get_relation_set:
426 * @obj: a pointer to the #AtspiAccessible object on which to operate.
428 * Gets the set of #AtspiRelation objects which describes this #AtspiAccessible object's
429 * relationships with other #AtspiAccessible objects.
431 * Returns: (element-type AtspiRelation*) (transfer full): a #GArray of
432 * #AtspiRelation pointers or NULL on exception.
435 atspi_accessible_get_relation_set (AtspiAccessible *obj, GError **error)
438 DBusMessageIter iter, iter_array;
441 g_return_val_if_fail (obj != NULL, NULL);
443 reply = _atspi_dbus_call_partial (obj, atspi_interface_accessible, "GetRelationSet", error, "");
446 _ATSPI_DBUS_CHECK_SIG (reply, "a(ua(so))", error, NULL);
448 ret = g_array_new (TRUE, TRUE, sizeof (AtspiRelation *));
449 dbus_message_iter_init (reply, &iter);
450 dbus_message_iter_recurse (&iter, &iter_array);
451 while (dbus_message_iter_get_arg_type (&iter_array) != DBUS_TYPE_INVALID)
453 AtspiRelation *relation;
454 relation = _atspi_relation_new_from_iter (&iter_array);
455 ret = g_array_append_val (ret, relation);
456 dbus_message_iter_next (&iter_array);
458 dbus_message_unref (reply);
463 * atspi_accessible_get_role:
464 * @obj: a pointer to the #AtspiAccessible object on which to operate.
466 * Gets the UI role played by an #AtspiAccessible object.
467 * This role's name can be obtained via atspi_accessible_get_role_name ().
469 * Returns: the #AtspiRole of an #AtspiAccessible object.
473 atspi_accessible_get_role (AtspiAccessible *obj, GError **error)
475 g_return_val_if_fail (obj != NULL, ATSPI_ROLE_INVALID);
477 if (!_atspi_accessible_test_cache (obj, ATSPI_CACHE_ROLE))
480 /* TODO: Make this a property */
481 if (_atspi_dbus_call (obj, atspi_interface_accessible, "GetRole", error, "=>u", &role))
484 _atspi_accessible_add_cache (obj, ATSPI_CACHE_ROLE);
491 * atspi_accessible_get_role_name:
492 * @obj: a pointer to the #AtspiAccessible object on which to operate.
494 * Gets a UTF-8 string corresponding to the name of the role played by an object.
495 * This method will return useful values for roles that fall outside the
496 * enumeration used in atspi_accessible_get_role ().
498 * Returns: a UTF-8 string specifying the type of UI role played by an
499 * #AtspiAccessible object.
503 atspi_accessible_get_role_name (AtspiAccessible *obj, GError **error)
505 gchar *retval = NULL;
508 g_return_val_if_fail (obj != NULL, NULL);
510 role = atspi_accessible_get_role (obj, error);
511 if (role >= 0 && role < ATSPI_ROLE_COUNT && role != ATSPI_ROLE_EXTENDED)
512 return atspi_role_get_name (role);
514 _atspi_dbus_call (obj, atspi_interface_accessible, "GetRoleName", error, "=>s", &retval);
517 retval = g_strdup ("");
523 * atspi_accessible_get_localized_role_name:
524 * @obj: a pointer to the #AtspiAccessible object on which to operate.
526 * Gets a UTF-8 string corresponding to the name of the role played by an
527 * object, translated to the current locale.
528 * This method will return useful values for roles that fall outside the
529 * enumeration used in atspi_accessible_getRole ().
531 * Returns: a localized, UTF-8 string specifying the type of UI role played
532 * by an #AtspiAccessible object.
536 atspi_accessible_get_localized_role_name (AtspiAccessible *obj, GError **error)
540 g_return_val_if_fail (obj != NULL, NULL);
542 _atspi_dbus_call (obj, atspi_interface_accessible, "GetLocalizedRoleName", error, "=>s", &retval);
545 return g_strdup ("");
550 static AtspiStateSet *
553 AtspiStateSet *set = atspi_state_set_new (NULL);
554 atspi_state_set_add (set, ATSPI_STATE_DEFUNCT);
559 * atspi_accessible_get_state_set:
560 * @obj: a pointer to the #AtspiAccessible object on which to operate.
562 * Gets the states currently held by an object.
564 * Returns: (transfer full): a pointer to an #AtspiStateSet representing an
565 * object's current state set.
568 atspi_accessible_get_state_set (AtspiAccessible *obj)
570 /* TODO: Should take a GError **, but would be an API break */
571 if (!obj->parent.app || !obj->parent.app->bus)
572 return defunct_set ();
574 if (!_atspi_accessible_test_cache (obj, ATSPI_CACHE_STATES))
577 DBusMessageIter iter;
578 reply = _atspi_dbus_call_partial (obj, atspi_interface_accessible,
579 "GetState", NULL, "");
580 _ATSPI_DBUS_CHECK_SIG (reply, "au", NULL, defunct_set ());
581 dbus_message_iter_init (reply, &iter);
582 _atspi_dbus_set_state (obj, &iter);
583 dbus_message_unref (reply);
584 _atspi_accessible_add_cache (obj, ATSPI_CACHE_STATES);
587 return g_object_ref (obj->states);
591 * atspi_accessible_get_attributes:
592 * @obj: The #AtspiAccessible being queried.
594 * Gets the #AttributeSet representing any assigned
595 * name-value pair attributes or annotations for this object.
596 * For typographic, textual, or textually-semantic attributes, see
597 * atspi_text_get_attributes instead.
599 * Returns: (element-type gchar* gchar*) (transfer full): The name-value-pair
600 * attributes assigned to this object.
603 atspi_accessible_get_attributes (AtspiAccessible *obj, GError **error)
605 DBusMessage *message;
607 g_return_val_if_fail (obj != NULL, NULL);
609 if (obj->priv->cache)
611 GValue *val = g_hash_table_lookup (obj->priv->cache, "Attributes");
613 return g_value_dup_boxed (val);
616 if (!_atspi_accessible_test_cache (obj, ATSPI_CACHE_ATTRIBUTES))
618 message = _atspi_dbus_call_partial (obj, atspi_interface_accessible,
619 "GetAttributes", error, "");
620 obj->attributes = _atspi_dbus_return_hash_from_message (message);
621 _atspi_accessible_add_cache (obj, ATSPI_CACHE_ATTRIBUTES);
624 if (!obj->attributes)
626 return g_hash_table_ref (obj->attributes);
630 add_to_attribute_array (gpointer key, gpointer value, gpointer data)
632 GArray **array = (GArray **)data;
633 gchar *str = g_strconcat (key, ":", value, NULL);
634 *array = g_array_append_val (*array, str);
638 * atspi_accessible_get_attributes_as_array:
639 * @obj: The #AtspiAccessible being queried.
641 * Gets a #GArray representing any assigned
642 * name-value pair attributes or annotations for this object.
643 * For typographic, textual, or textually-semantic attributes, see
644 * atspi_text_get_attributes_as_array instead.
646 * Returns: (element-type gchar*) (transfer full): The name-value-pair
647 * attributes assigned to this object.
650 atspi_accessible_get_attributes_as_array (AtspiAccessible *obj, GError **error)
652 DBusMessage *message;
654 g_return_val_if_fail (obj != NULL, NULL);
656 if (obj->priv->cache)
658 GValue *val = g_hash_table_lookup (obj->priv->cache, "Attributes");
661 GArray *array = g_array_new (TRUE, TRUE, sizeof (gchar *));
662 GHashTable *attributes = g_value_get_boxed (val);
663 g_hash_table_foreach (attributes, add_to_attribute_array, &array);
668 message = _atspi_dbus_call_partial (obj, atspi_interface_accessible, "GetAttributes", error, "");
669 return _atspi_dbus_return_attribute_array_from_message (message);
673 * atspi_accessible_get_application:
674 * @obj: The #AtspiAccessible being queried.
676 * Gets the containing #AtspiApplication for an object.
678 * Returns: (transfer full): the containing #AtspiApplication instance for
682 atspi_accessible_get_application (AtspiAccessible *obj, GError **error)
684 AtspiAccessible *parent;
689 parent = atspi_accessible_get_parent (obj, NULL);
690 if (!parent && obj->parent.app &&
691 atspi_accessible_get_role (obj, NULL) != ATSPI_ROLE_APPLICATION)
693 AtspiAccessible *root = g_object_ref (obj->parent.app->root);
696 g_object_unref (obj);
697 if (atspi_accessible_get_role (root, NULL) == ATSPI_ROLE_DESKTOP_FRAME)
699 g_object_unref (root);
705 if (!parent || parent == obj ||
706 atspi_accessible_get_role (parent, NULL) == ATSPI_ROLE_DESKTOP_FRAME)
709 g_object_unref (parent);
712 g_object_unref (obj);
717 /* Application-specific methods */
720 * atspi_accessible_get_toolkit_name:
721 * @obj: a pointer to the #AtspiAccessible object on which to operate.
723 * Gets the toolkit name for an #AtspiAccessible object.
724 * Only works on application root objects.
726 * Returns: a UTF-8 string indicating the toolkit name for the #AtspiAccessible object or NULL on exception.
729 atspi_accessible_get_toolkit_name (AtspiAccessible *obj, GError **error)
731 g_return_val_if_fail (obj != NULL, NULL);
733 if (!obj->parent.app)
736 if (!obj->parent.app->toolkit_name)
737 _atspi_dbus_get_property (obj, atspi_interface_application, "ToolkitName",
738 error, "s", &obj->parent.app->toolkit_name);
740 return g_strdup (obj->parent.app->toolkit_name);
744 * atspi_accessible_get_toolkit_version:
745 * @obj: a pointer to the #AtspiAccessible object on which to operate.
747 * Gets the toolkit version for an #AtspiAccessible object.
748 * Only works on application root objects.
750 * Returns: a UTF-8 string indicating the toolkit version for the #AtspiAccessible object or NULL on exception.
753 atspi_accessible_get_toolkit_version (AtspiAccessible *obj, GError **error)
755 g_return_val_if_fail (obj != NULL, NULL);
757 if (!obj->parent.app)
760 if (!obj->parent.app->toolkit_version)
761 _atspi_dbus_get_property (obj, atspi_interface_application, "Version",
762 error, "s", &obj->parent.app->toolkit_version);
764 return g_strdup (obj->parent.app->toolkit_version);
768 * atspi_accessible_get_atspi_version:
769 * @obj: a pointer to the #AtspiAccessible object on which to operate.
771 * Gets the AT-SPI IPC specification version supported by the application
772 * pointed to by the #AtspiAccessible object.
773 * Only works on application root objects.
775 * Returns: a UTF-8 string indicating the AT-SPI version for the #AtspiAccessible object or NULL on exception.
778 atspi_accessible_get_atspi_version (AtspiAccessible *obj, GError **error)
780 g_return_val_if_fail (obj != NULL, NULL);
782 if (!obj->parent.app)
785 if (!obj->parent.app->atspi_version)
786 _atspi_dbus_get_property (obj, atspi_interface_application, "AtspiVersion",
787 error, "s", &obj->parent.app->atspi_version);
789 return g_strdup (obj->parent.app->atspi_version);
793 * atspi_accessible_get_id:
794 * @obj: a pointer to the #AtspiAccessible object on which to operate.
796 * Gets the application id for a #AtspiAccessible object.
797 * Only works on application root objects.
799 * Returns: a positive #gint indicating the id for the #AtspiAccessible object
800 * or -1 on exception.
803 atspi_accessible_get_id (AtspiAccessible *obj, GError **error)
807 g_return_val_if_fail (obj != NULL, -1);
809 if (!_atspi_dbus_get_property (obj, atspi_interface_application, "Id", error, "i", &ret))
815 /* Interface query methods */
818 _atspi_accessible_is_a (AtspiAccessible *accessible,
819 const char *interface_name)
823 if (accessible == NULL)
828 if (!_atspi_accessible_test_cache (accessible, ATSPI_CACHE_INTERFACES))
831 DBusMessageIter iter;
832 reply = _atspi_dbus_call_partial (accessible, atspi_interface_accessible,
833 "GetInterfaces", NULL, "");
834 _ATSPI_DBUS_CHECK_SIG (reply, "as", NULL, FALSE);
835 dbus_message_iter_init (reply, &iter);
836 _atspi_dbus_set_interfaces (accessible, &iter);
837 dbus_message_unref (reply);
838 _atspi_accessible_add_cache (accessible, ATSPI_CACHE_INTERFACES);
841 n = _atspi_get_iface_num (interface_name);
842 if (n == -1) return FALSE;
843 return (gboolean) ((accessible->interfaces & (1 << n))? TRUE: FALSE);
847 * atspi_accessible_is_action:
848 * @obj: a pointer to the #AtspiAccessible instance to query.
850 * Query whether the specified #AtspiAccessible implements the
851 * #AtspiAction interface.
853 * Returns: #TRUE if @obj implements the #AtspiAction interface,
857 atspi_accessible_is_action (AtspiAccessible *obj)
859 return _atspi_accessible_is_a (obj,
860 atspi_interface_action);
864 * atspi_accessible_is_application:
865 * @obj: a pointer to the #AtspiAccessible instance to query.
867 * Query whether the specified #AtspiAccessible implements the
868 * #AtspiApplication interface.
870 * Returns: #TRUE if @obj implements the #AtspiApplication interface,
874 atspi_accessible_is_application (AtspiAccessible *obj)
876 return _atspi_accessible_is_a (obj,
877 atspi_interface_application);
881 * atspi_accessible_is_collection:
882 * @obj: a pointer to the #AtspiAccessible instance to query.
884 * Query whether the specified #AtspiAccessible implements the
885 * #AtspiCollection interface.
887 * Returns: #TRUE if @obj implements the #AtspiCollection interface,
891 atspi_accessible_is_collection (AtspiAccessible *obj)
893 return _atspi_accessible_is_a (obj,
894 atspi_interface_collection);
898 * atspi_accessible_is_component:
899 * @obj: a pointer to the #AtspiAccessible instance to query.
901 * Query whether the specified #AtspiAccessible implements #AtspiComponent.
903 * Returns: #TRUE if @obj implements the #AtspiComponent interface,
907 atspi_accessible_is_component (AtspiAccessible *obj)
909 return _atspi_accessible_is_a (obj,
910 atspi_interface_component);
914 * atspi_accessible_is_document:
915 * @obj: a pointer to the #AtspiAccessible instance to query.
917 * Query whether the specified #AtspiAccessible implements the
918 * #AtspiDocument interface.
920 * Returns: #TRUE if @obj implements the #AtspiDocument interface,
924 atspi_accessible_is_document (AtspiAccessible *obj)
926 return _atspi_accessible_is_a (obj,
927 atspi_interface_document);
931 * atspi_accessible_is_editable_text:
932 * @obj: a pointer to the #AtspiAccessible instance to query.
934 * Query whether the specified #AtspiAccessible implements the
935 * #AtspiEditableText interface.
937 * Returns: #TRUE if @obj implements the #AtspiEditableText interface,
941 atspi_accessible_is_editable_text (AtspiAccessible *obj)
943 return _atspi_accessible_is_a (obj,
944 atspi_interface_editable_text);
948 * atspi_accessible_is_hypertext:
949 * @obj: a pointer to the #AtspiAccessible instance to query.
951 * Query whether the specified #AtspiAccessible implements the
952 * #AtspiHypertext interface.
954 * Returns: #TRUE if @obj implements the #AtspiHypertext interface,
958 atspi_accessible_is_hypertext (AtspiAccessible *obj)
960 return _atspi_accessible_is_a (obj,
961 atspi_interface_hypertext);
965 * atspi_accessible_is_hyperlink:
966 * @obj: a pointer to the #AtspiAccessible instance to query.
968 * Query whether the specified #AtspiAccessible implements the
969 * #AtspiHyperlink interface.
971 * Returns: #TRUE if @obj implements the #AtspiHypertext interface,
975 atspi_accessible_is_hyperlink (AtspiAccessible *obj)
977 return _atspi_accessible_is_a (obj,
978 atspi_interface_hyperlink);
982 * atspi_accessible_is_image:
983 * @obj: a pointer to the #AtspiAccessible instance to query.
985 * Query whether the specified #AtspiAccessible implements the
986 * #AtspiImage interface.
988 * Returns: #TRUE if @obj implements the #AtspiImage interface,
992 atspi_accessible_is_image (AtspiAccessible *obj)
994 return _atspi_accessible_is_a (obj,
995 atspi_interface_image);
999 * atspi_accessible_is_selection:
1000 * @obj: a pointer to the #AtspiAccessible instance to query.
1002 * Query whether the specified #AtspiAccessible implements the
1003 * #AtspiSelection interface.
1005 * Returns: #TRUE if @obj implements the #AtspiSelection interface,
1009 atspi_accessible_is_selection (AtspiAccessible *obj)
1011 return _atspi_accessible_is_a (obj,
1012 atspi_interface_selection);
1016 * atspi_accessible_is_table:
1017 * @obj: a pointer to the #AtspiAccessible instance to query.
1019 * Query whether the specified #AtspiAccessible implements the
1020 * #AtspiTable interface.
1022 * Returns: #TRUE if @obj implements the #AtspiTable interface,
1026 atspi_accessible_is_table (AtspiAccessible *obj)
1028 return _atspi_accessible_is_a (obj,
1029 atspi_interface_table);
1033 * atspi_accessible_is_table_cell:
1034 * @obj: a pointer to the #AtspiAccessible instance to query.
1036 * Query whether the specified #AtspiAccessible implements the
1037 * #AtspiTableCell interface.
1039 * Returns: #TRUE if @obj implements the #AtspiTable interface,
1043 atspi_accessible_is_table_cell (AtspiAccessible *obj)
1045 return _atspi_accessible_is_a (obj,
1046 atspi_interface_table_cell);
1050 * atspi_accessible_is_streamable_content:
1051 * @obj: a pointer to the #AtspiAccessible instance to query.
1053 * Query whether the specified #AtspiAccessible implements the
1054 * #AtspiStreamableContent interface.
1056 * Returns: #TRUE if @obj implements the #AtspiStreamableContent interface,
1060 atspi_accessible_is_streamable_content (AtspiAccessible *obj)
1063 return _atspi_accessible_is_a (obj,
1064 atspi_interface_streamable_content);
1066 g_warning ("Streamable content not implemented");
1072 * atspi_accessible_is_text:
1073 * @obj: a pointer to the #AtspiAccessible instance to query.
1075 * Query whether the specified #AtspiAccessible implements the
1076 * #AtspiText interface.
1078 * Returns: #TRUE if @obj implements the #AtspiText interface,
1082 atspi_accessible_is_text (AtspiAccessible *obj)
1084 return _atspi_accessible_is_a (obj,
1085 atspi_interface_text);
1089 * atspi_accessible_is_value:
1090 * @obj: a pointer to the #AtspiAccessible instance to query.
1092 * Query whether the specified #AtspiAccessible implements the
1093 * #AtspiValue interface.
1095 * Returns: #TRUE if @obj implements the #AtspiValue interface,
1099 atspi_accessible_is_value (AtspiAccessible *obj)
1101 return _atspi_accessible_is_a (obj,
1102 atspi_interface_value);
1106 * atspi_accessible_get_action: (rename-to atspi_accessible_get_action_iface)
1107 * @obj: a pointer to the #AtspiAccessible instance to query.
1109 * Gets the #AtspiAction interface for an #AtspiAccessible.
1111 * Returns: (transfer full): a pointer to an #AtspiAction interface
1112 * instance, or NULL if @obj does not implement #AtspiAction.
1114 * Deprecated: 2.10: Use atspi_accessible_get_action_iface instead.
1117 atspi_accessible_get_action (AtspiAccessible *accessible)
1119 return (_atspi_accessible_is_a (accessible, atspi_interface_action) ?
1120 g_object_ref (ATSPI_ACTION (accessible)) : NULL);
1124 * atspi_accessible_get_action_iface:
1125 * @obj: a pointer to the #AtspiAccessible instance to query.
1127 * Gets the #AtspiAction interface for an #AtspiAccessible.
1129 * Returns: (transfer full): a pointer to an #AtspiAction interface
1130 * instance, or NULL if @obj does not implement #AtspiAction.
1133 atspi_accessible_get_action_iface (AtspiAccessible *accessible)
1135 return (_atspi_accessible_is_a (accessible, atspi_interface_action) ?
1136 g_object_ref (ATSPI_ACTION (accessible)) : NULL);
1140 * atspi_accessible_get_collection: (rename-to atspi_accessible_get_collection_iface)
1141 * @obj: a pointer to the #AtspiAccessible instance to query.
1143 * Gets the #AtspiCollection interface for an #AtspiAccessible.
1145 * Returns: (transfer full): a pointer to an #AtspiCollection interface
1146 * instance, or NULL if @obj does not implement #AtspiCollection.
1148 * Deprecated: 2.10: Use atspi_accessible_get_collection_iface instead.
1151 atspi_accessible_get_collection (AtspiAccessible *accessible)
1153 return (_atspi_accessible_is_a (accessible, atspi_interface_collection) ?
1154 g_object_ref (ATSPI_COLLECTION (accessible)) : NULL);
1158 * atspi_accessible_get_collection_iface:
1159 * @obj: a pointer to the #AtspiAccessible instance to query.
1161 * Gets the #AtspiCollection interface for an #AtspiAccessible.
1163 * Returns: (transfer full): a pointer to an #AtspiCollection interface
1164 * instance, or NULL if @obj does not implement #AtspiCollection.
1167 atspi_accessible_get_collection_iface (AtspiAccessible *accessible)
1169 return (_atspi_accessible_is_a (accessible, atspi_interface_collection) ?
1170 g_object_ref (ATSPI_COLLECTION (accessible)) : NULL);
1174 * atspi_accessible_get_component: (rename-to atspi_accessible_get_component_iface)
1175 * @obj: a pointer to the #AtspiAccessible instance to query.
1177 * Gets the #AtspiComponent interface for an #AtspiAccessible.
1179 * Returns: (transfer full): a pointer to an #AtspiComponent interface
1180 * instance, or NULL if @obj does not implement #AtspiComponent.
1182 * Deprecated: 2.10: Use atspi_accessible_get_component_iface instead.
1185 atspi_accessible_get_component (AtspiAccessible *obj)
1187 return (_atspi_accessible_is_a (obj, atspi_interface_component) ?
1188 g_object_ref (ATSPI_COMPONENT (obj)) : NULL);
1192 * atspi_accessible_get_component_iface:
1193 * @obj: a pointer to the #AtspiAccessible instance to query.
1195 * Gets the #AtspiComponent interface for an #AtspiAccessible.
1197 * Returns: (transfer full): a pointer to an #AtspiComponent interface
1198 * instance, or NULL if @obj does not implement #AtspiComponent.
1201 atspi_accessible_get_component_iface (AtspiAccessible *obj)
1203 return (_atspi_accessible_is_a (obj, atspi_interface_component) ?
1204 g_object_ref (ATSPI_COMPONENT (obj)) : NULL);
1208 * atspi_accessible_get_document: (rename-to atspi_accessible_get_document_iface)
1209 * @obj: a pointer to the #AtspiAccessible instance to query.
1211 * Gets the #AtspiDocument interface for an #AtspiAccessible.
1213 * Returns: (transfer full): a pointer to an #AtspiDocument interface
1214 * instance, or NULL if @obj does not implement #AtspiDocument.
1216 * Deprecated: 2.10: Use atspi_accessible_get_document_iface instead.
1219 atspi_accessible_get_document (AtspiAccessible *accessible)
1221 return (_atspi_accessible_is_a (accessible, atspi_interface_document) ?
1222 g_object_ref (ATSPI_DOCUMENT (accessible)) : NULL);
1226 * atspi_accessible_get_document_iface:
1227 * @obj: a pointer to the #AtspiAccessible instance to query.
1229 * Gets the #AtspiDocument interface for an #AtspiAccessible.
1231 * Returns: (transfer full): a pointer to an #AtspiDocument interface
1232 * instance, or NULL if @obj does not implement #AtspiDocument.
1235 atspi_accessible_get_document_iface (AtspiAccessible *accessible)
1237 return (_atspi_accessible_is_a (accessible, atspi_interface_document) ?
1238 g_object_ref (ATSPI_DOCUMENT (accessible)) : NULL);
1242 * atspi_accessible_get_editable_text: (rename-to atspi_accessible_get_editable_text_iface)
1243 * @obj: a pointer to the #AtspiAccessible instance to query.
1245 * Gets the #AtspiEditableText interface for an #AtspiAccessible.
1247 * Returns: (transfer full): a pointer to an #AtspiEditableText interface
1248 * instance, or NULL if @obj does not implement #AtspiEditableText.
1250 * Deprecated: 2.10: Use atspi_accessible_get_editable_text_iface instead.
1253 atspi_accessible_get_editable_text (AtspiAccessible *accessible)
1255 return (_atspi_accessible_is_a (accessible, atspi_interface_editable_text) ?
1256 g_object_ref (ATSPI_EDITABLE_TEXT (accessible)) : NULL);
1260 * atspi_accessible_get_editable_text_iface:
1261 * @obj: a pointer to the #AtspiAccessible instance to query.
1263 * Gets the #AtspiEditableText interface for an #AtspiAccessible.
1265 * Returns: (transfer full): a pointer to an #AtspiEditableText interface
1266 * instance, or NULL if @obj does not implement #AtspiEditableText.
1269 atspi_accessible_get_editable_text_iface (AtspiAccessible *accessible)
1271 return (_atspi_accessible_is_a (accessible, atspi_interface_editable_text) ?
1272 g_object_ref (ATSPI_EDITABLE_TEXT (accessible)) : NULL);
1276 * atspi_accessible_get_hyperlink:
1277 * @obj: a pointer to the #AtspiAccessible object on which to operate.
1279 * Gets the #AtspiHyperlink interface for an #AtspiAccessible.
1281 * Returns: (transfer full): the #AtspiHyperlink object associated with
1282 * the given #AtspiAccessible, or NULL if not supported.
1285 atspi_accessible_get_hyperlink (AtspiAccessible *accessible)
1287 return (_atspi_accessible_is_a (accessible, atspi_interface_hyperlink) ?
1288 _atspi_hyperlink_new (accessible->parent.app, accessible->parent.path) : NULL);
1292 * atspi_accessible_get_hypertext: (rename-to atspi_accessible_get_hypertext_iface)
1293 * @obj: a pointer to the #AtspiAccessible instance to query.
1295 * Gets the #AtspiHypertext interface for an #AtspiAccessible.
1297 * Returns: (transfer full): a pointer to an #AtspiHypertext interface
1298 * instance, or NULL if @obj does not implement #AtspiHypertext.
1300 * Deprecated: 2.10: Use atspi_accessible_get_hypertext_iface instead.
1303 atspi_accessible_get_hypertext (AtspiAccessible *accessible)
1305 return (_atspi_accessible_is_a (accessible, atspi_interface_hypertext) ?
1306 g_object_ref (ATSPI_HYPERTEXT (accessible)) : NULL);
1310 * atspi_accessible_get_hypertext_iface:
1311 * @obj: a pointer to the #AtspiAccessible instance to query.
1313 * Gets the #AtspiHypertext interface for an #AtspiAccessible.
1315 * Returns: (transfer full): a pointer to an #AtspiHypertext interface
1316 * instance, or NULL if @obj does not implement #AtspiHypertext.
1319 atspi_accessible_get_hypertext_iface (AtspiAccessible *accessible)
1321 return (_atspi_accessible_is_a (accessible, atspi_interface_hypertext) ?
1322 g_object_ref (ATSPI_HYPERTEXT (accessible)) : NULL);
1326 * atspi_accessible_get_image: (rename-to atspi_accessible_get_image_iface)
1327 * @obj: a pointer to the #AtspiAccessible instance to query.
1329 * Gets the #AtspiImage interface for an #AtspiAccessible.
1331 * Returns: (transfer full): a pointer to an #AtspiImage interface instance, or
1332 * NULL if @obj does not implement #AtspiImage.
1334 * Deprecated: 2.10: Use atspi_accessible_get_image_iface instead.
1337 atspi_accessible_get_image (AtspiAccessible *accessible)
1339 return (_atspi_accessible_is_a (accessible, atspi_interface_image) ?
1340 g_object_ref (ATSPI_IMAGE (accessible)) : NULL);
1344 * atspi_accessible_get_image_iface:
1345 * @obj: a pointer to the #AtspiAccessible instance to query.
1347 * Gets the #AtspiImage interface for an #AtspiAccessible.
1349 * Returns: (transfer full): a pointer to an #AtspiImage interface instance, or
1350 * NULL if @obj does not implement #AtspiImage.
1353 atspi_accessible_get_image_iface (AtspiAccessible *accessible)
1355 return (_atspi_accessible_is_a (accessible, atspi_interface_image) ?
1356 g_object_ref (ATSPI_IMAGE (accessible)) : NULL);
1360 * atspi_accessible_get_selection: (rename-to atspi_accessible_get_selection_iface)
1361 * @obj: a pointer to the #AtspiAccessible instance to query.
1363 * Gets the #AtspiSelection interface for an #AtspiAccessible.
1365 * Returns: (transfer full): a pointer to an #AtspiSelection interface
1366 * instance, or NULL if @obj does not implement #AtspiSelection.
1368 * Deprecated: 2.10: Use atspi_accessible_get_selection_iface instead.
1371 atspi_accessible_get_selection (AtspiAccessible *accessible)
1373 return (_atspi_accessible_is_a (accessible, atspi_interface_selection) ?
1374 g_object_ref (ATSPI_SELECTION (accessible)) : NULL);
1378 * atspi_accessible_get_selection_iface:
1379 * @obj: a pointer to the #AtspiAccessible instance to query.
1381 * Gets the #AtspiSelection interface for an #AtspiAccessible.
1383 * Returns: (transfer full): a pointer to an #AtspiSelection interface
1384 * instance, or NULL if @obj does not implement #AtspiSelection.
1387 atspi_accessible_get_selection_iface (AtspiAccessible *accessible)
1389 return (_atspi_accessible_is_a (accessible, atspi_interface_selection) ?
1390 g_object_ref (ATSPI_SELECTION (accessible)) : NULL);
1395 * atspi_accessible_get_streamable_content:
1396 * @obj: a pointer to the #AtspiAccessible instance to query.
1398 * Gets the #AtspiStreamableContent interface for an #AtspiAccessible.
1400 * Returns: (transfer full): a pointer to an #AtspiStreamableContent interface
1401 * instance, or NULL if @obj does not implement #AtspiStreamableContent.
1403 AtspiStreamableContent *
1404 atspi_accessible_get_streamable_content (AtspiAccessible *accessible)
1406 return (_atspi_accessible_is_a (accessible, atspi_interface_streamable_content) ?
1412 * atspi_accessible_get_table: (rename-to atspi_accessible_get_table_iface)
1413 * @obj: a pointer to the #AtspiAccessible instance to query.
1415 * Gets the #AtspiTable interface for an #AtspiAccessible.
1417 * Returns: (transfer full): a pointer to an #AtspiTable interface instance, or
1418 * NULL if @obj does not implement #AtspiTable.
1420 * Deprecated: 2.10: Use atspi_accessible_get_table_iface instead.
1423 atspi_accessible_get_table (AtspiAccessible *obj)
1425 return (_atspi_accessible_is_a (obj, atspi_interface_table) ?
1426 g_object_ref (ATSPI_TABLE (obj)) : NULL);
1430 * atspi_accessible_get_table_iface:
1431 * @obj: a pointer to the #AtspiAccessible instance to query.
1433 * Gets the #AtspiTable interface for an #AtspiAccessible.
1435 * Returns: (transfer full): a pointer to an #AtspiTable interface instance, or
1436 * NULL if @obj does not implement #AtspiTable.
1439 atspi_accessible_get_table_iface (AtspiAccessible *obj)
1441 return (_atspi_accessible_is_a (obj, atspi_interface_table) ?
1442 g_object_ref (ATSPI_TABLE (obj)) : NULL);
1446 * atspi_accessible_get_table_cell:
1447 * @obj: a pointer to the #AtspiAccessible instance to query.
1449 * Gets the #AtspiTableCell interface for an #AtspiAccessible.
1451 * Returns: (transfer full): a pointer to an #AtspiTableCell interface instance,
1452 * or NULL if @obj does not implement #AtspiTable.
1455 atspi_accessible_get_table_cell (AtspiAccessible *obj)
1457 return (_atspi_accessible_is_a (obj, atspi_interface_table_cell) ?
1458 g_object_ref (ATSPI_TABLE_CELL (obj)) : NULL);
1462 * atspi_accessible_get_text: (rename-to atspi_accessible_get_text_iface)
1463 * @obj: a pointer to the #AtspiAccessible instance to query.
1465 * Gets the #AtspiTable interface for an #AtspiAccessible.
1467 * Returns: (transfer full): a pointer to an #AtspiText interface instance, or
1468 * NULL if @obj does not implement #AtspiText.
1470 * Deprecated: 2.10: Use atspi_accessible_get_text_iface instead.
1473 atspi_accessible_get_text (AtspiAccessible *obj)
1475 return (_atspi_accessible_is_a (obj, atspi_interface_text) ?
1476 g_object_ref (ATSPI_TEXT (obj)) : NULL);
1480 * atspi_accessible_get_text_iface:
1481 * @obj: a pointer to the #AtspiAccessible instance to query.
1483 * Gets the #AtspiTable interface for an #AtspiAccessible.
1485 * Returns: (transfer full): a pointer to an #AtspiText interface instance, or
1486 * NULL if @obj does not implement #AtspiText.
1489 atspi_accessible_get_text_iface (AtspiAccessible *obj)
1491 return (_atspi_accessible_is_a (obj, atspi_interface_text) ?
1492 g_object_ref (ATSPI_TEXT (obj)) : NULL);
1496 * atspi_accessible_get_value: (rename-to atspi_accessible_get_value_iface)
1497 * @obj: a pointer to the #AtspiAccessible instance to query.
1499 * Gets the #AtspiTable interface for an #AtspiAccessible.
1501 * Returns: (transfer full): a pointer to an #AtspiValue interface instance, or
1502 * NULL if @obj does not implement #AtspiValue.
1504 * Deprecated: 2.10: Use atspi_accessible_get_value_iface instead.
1507 atspi_accessible_get_value (AtspiAccessible *accessible)
1509 return (_atspi_accessible_is_a (accessible, atspi_interface_value) ?
1510 g_object_ref (ATSPI_VALUE (accessible)) : NULL);
1514 * atspi_accessible_get_value_iface:
1515 * @obj: a pointer to the #AtspiAccessible instance to query.
1517 * Gets the #AtspiTable interface for an #AtspiAccessible.
1519 * Returns: (transfer full): a pointer to an #AtspiValue interface instance, or
1520 * NULL if @obj does not implement #AtspiValue.
1523 atspi_accessible_get_value_iface (AtspiAccessible *accessible)
1525 return (_atspi_accessible_is_a (accessible, atspi_interface_value) ?
1526 g_object_ref (ATSPI_VALUE (accessible)) : NULL);
1530 append_const_val (GArray *array, const gchar *val)
1532 gchar *dup = g_strdup (val);
1535 g_array_append_val (array, dup);
1539 * atspi_accessible_get_interfaces:
1540 * @obj: The #AtspiAccessible to query.
1542 * A set of pointers to all interfaces supported by an #AtspiAccessible.
1544 * Returns: (element-type gchar*) (transfer full): A #GArray of strings
1545 * describing the interfaces supported by the object. Interfaces are
1546 * denoted in short-hand (i.e. "Component", "Text" etc.).
1549 atspi_accessible_get_interfaces (AtspiAccessible *obj)
1551 GArray *ret = g_array_new (TRUE, TRUE, sizeof (gchar *));
1553 g_return_val_if_fail (obj != NULL, NULL);
1555 append_const_val (ret, "Accessible");
1556 if (atspi_accessible_is_action (obj))
1557 append_const_val (ret, "Action");
1558 if (atspi_accessible_is_collection (obj))
1559 append_const_val (ret, "Collection");
1560 if (atspi_accessible_is_component (obj))
1561 append_const_val (ret, "Component");
1562 if (atspi_accessible_is_document (obj))
1563 append_const_val (ret, "Document");
1564 if (atspi_accessible_is_editable_text (obj))
1565 append_const_val (ret, "EditableText");
1566 if (atspi_accessible_is_hypertext (obj))
1567 append_const_val (ret, "Hypertext");
1568 if (atspi_accessible_is_hyperlink (obj))
1569 append_const_val (ret, "Hyperlink");
1570 if (atspi_accessible_is_image (obj))
1571 append_const_val (ret, "Image");
1572 if (atspi_accessible_is_selection (obj))
1573 append_const_val (ret, "Selection");
1574 if (atspi_accessible_is_table (obj))
1575 append_const_val (ret, "Table");
1576 if (atspi_accessible_is_table_cell (obj))
1577 append_const_val (ret, "TableCell");
1578 if (atspi_accessible_is_text (obj))
1579 append_const_val (ret, "Text");
1580 if (atspi_accessible_is_value (obj))
1581 append_const_val (ret, "Value");
1587 _atspi_accessible_new (AtspiApplication *app, const gchar *path)
1589 AtspiAccessible *accessible;
1591 accessible = g_object_new (ATSPI_TYPE_ACCESSIBLE, NULL);
1592 g_return_val_if_fail (accessible != NULL, NULL);
1594 accessible->parent.app = g_object_ref (app);
1595 accessible->parent.path = g_strdup (path);
1601 * atspi_accessible_set_cache_mask:
1602 * @accessible: The #AtspiAccessible to operate on. Must be the desktop or
1603 * the root of an application.
1604 * @mask: An #AtspiCache specifying a bit mask of the types of data to cache.
1606 * Sets the type of data to cache for accessibles.
1607 * If this is not set for an application or is reset to ATSPI_CACHE_UNDEFINED,
1608 * then the desktop's cache flag will be used.
1609 * If the desktop's cache flag is also undefined, then all possible data will
1611 * This function is intended to work around bugs in toolkits where the proper
1612 * events are not raised / to aid in testing for such bugs.
1615 atspi_accessible_set_cache_mask (AtspiAccessible *accessible, AtspiCache mask)
1617 g_return_if_fail (accessible != NULL);
1618 g_return_if_fail (accessible->parent.app != NULL);
1619 g_return_if_fail (accessible == accessible->parent.app->root);
1620 accessible->parent.app->cache = mask;
1621 enable_caching = TRUE;
1625 * atspi_accessible_clear_cache:
1626 * @accessible: The #AtspiAccessible whose cache to clear.
1628 * Clears the cached information for the given accessible and all of its
1632 atspi_accessible_clear_cache (AtspiAccessible *accessible)
1638 accessible->cached_properties = ATSPI_CACHE_NONE;
1639 for (l = accessible->children; l; l = l->next)
1640 atspi_accessible_clear_cache (l->data);
1645 * atspi_accessible_get_process_id:
1646 * @accessible: The #AtspiAccessible to query.
1647 * @error: a pointer to a %NULL #GError pointer
1649 * Returns the process id associated with the given accessible. Mainly
1650 * added for debugging; it is a shortcut to explicitly querying the
1651 * accessible's app->bus_name and then calling GetConnectionUnixProcessID.
1653 * Returns: The process ID or undetermined value if @error is set.
1656 atspi_accessible_get_process_id (AtspiAccessible *accessible, GError **error)
1658 DBusMessage *message, *reply;
1659 DBusConnection *bus = _atspi_bus ();
1660 dbus_uint32_t pid = -1;
1663 if (!accessible->parent.app || !accessible->parent.app->bus_name)
1665 g_set_error_literal(error, ATSPI_ERROR, ATSPI_ERROR_IPC, "Process is defunct");
1669 message = dbus_message_new_method_call ("org.freedesktop.DBus",
1670 "/org/freedesktop/DBus",
1671 "org.freedesktop.DBus",
1672 "GetConnectionUnixProcessID");
1673 dbus_message_append_args (message, DBUS_TYPE_STRING,
1674 &accessible->parent.app->bus_name,
1676 dbus_error_init (&d_error);
1677 reply = dbus_connection_send_with_reply_and_block (bus, message, -1, &d_error);
1678 dbus_message_unref (message);
1681 if (!strcmp (dbus_message_get_signature (reply), "u"))
1682 dbus_message_get_args (reply, NULL, DBUS_TYPE_UINT32, &pid, DBUS_TYPE_INVALID);
1683 dbus_message_unref (reply);
1685 if (dbus_error_is_set (&d_error))
1687 g_set_error_literal(error, ATSPI_ERROR, ATSPI_ERROR_IPC, "Process is defunct");
1688 dbus_error_free (&d_error);
1694 _atspi_accessible_get_cache_mask (AtspiAccessible *accessible)
1698 if (!accessible->parent.app)
1699 return ATSPI_CACHE_NONE;
1701 mask = accessible->parent.app->cache;
1702 if (mask == ATSPI_CACHE_UNDEFINED &&
1703 accessible->parent.app->root &&
1704 accessible->parent.app->root->accessible_parent)
1706 AtspiAccessible *desktop = atspi_get_desktop (0);
1707 mask = desktop->parent.app->cache;
1708 g_object_unref (desktop);
1711 if (mask == ATSPI_CACHE_UNDEFINED)
1712 mask = ATSPI_CACHE_DEFAULT;
1718 _atspi_accessible_test_cache (AtspiAccessible *accessible, AtspiCache flag)
1720 AtspiCache mask = _atspi_accessible_get_cache_mask (accessible);
1721 AtspiCache result = accessible->cached_properties & mask & flag;
1722 if (accessible->states && atspi_state_set_contains (accessible->states, ATSPI_STATE_TRANSIENT))
1724 return (result != 0 && (atspi_main_loop || enable_caching ||
1725 flag == ATSPI_CACHE_INTERFACES) &&
1730 _atspi_accessible_add_cache (AtspiAccessible *accessible, AtspiCache flag)
1732 AtspiCache mask = _atspi_accessible_get_cache_mask (accessible);
1734 accessible->cached_properties |= flag & mask;
1738 * atspi_accessible_get_locale:
1739 * @accessible: an #AtspiAccessible
1741 * Gets a UTF-8 string indicating the POSIX-style LC_MESSAGES locale
1746 * Returns: a UTF-8 string indicating the POSIX-style LC_MESSAGES
1747 * locale of @accessible.
1750 atspi_accessible_get_object_locale (AtspiAccessible *accessible, GError **error)
1754 g_return_val_if_fail (accessible != NULL, NULL);
1756 locale = g_object_get_qdata (G_OBJECT (accessible), quark_locale);
1759 if (!_atspi_dbus_get_property (accessible, atspi_interface_accessible,
1760 "Locale", error, "s", &locale))
1763 g_object_set_qdata_full (G_OBJECT (accessible), quark_locale, locale,
1770 free_value (gpointer data)
1772 GValue *value = data;
1774 g_value_unset (value);
1779 _atspi_accessible_ref_cache (AtspiAccessible *accessible)
1781 AtspiAccessiblePrivate *priv = accessible->priv;
1783 priv->cache_ref_count++;
1785 return g_hash_table_ref (priv->cache);
1786 priv->cache = g_hash_table_new_full (g_str_hash, g_str_equal, g_free,
1792 _atspi_accessible_unref_cache (AtspiAccessible *accessible)
1794 AtspiAccessiblePrivate *priv = accessible->priv;
1798 g_hash_table_unref (priv->cache);
1799 if (--priv->cache_ref_count == 0)