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);
122 accessible->children = g_ptr_array_new_with_free_func (g_object_unref);
126 atspi_accessible_dispose (GObject *object)
128 AtspiAccessible *accessible = ATSPI_ACCESSIBLE (object);
130 AtspiAccessible *parent;
133 /* TODO: Only fire if object not already marked defunct */
134 memset (&e, 0, sizeof (e));
135 e.type = "object:state-changed:defunct";
136 e.source = accessible;
139 _atspi_send_event (&e);
141 g_clear_object (&accessible->states);
143 parent = accessible->accessible_parent;
146 accessible->accessible_parent = NULL;
147 if (parent->children)
148 g_ptr_array_remove (parent->children, accessible);
149 g_object_unref (parent);
152 if (accessible->children) for (i = accessible->children->len - 1; i >= 0; i--)
154 AtspiAccessible *child = g_ptr_array_index (accessible->children, i);
155 if (child && child->accessible_parent == accessible)
157 child->accessible_parent = NULL;
158 g_object_unref (accessible);
162 if (accessible->children)
164 g_ptr_array_free (accessible->children, TRUE);
165 accessible->children = NULL;
168 G_OBJECT_CLASS (atspi_accessible_parent_class) ->dispose (object);
172 atspi_accessible_finalize (GObject *object)
174 AtspiAccessible *accessible = ATSPI_ACCESSIBLE (object);
176 g_free (accessible->description);
177 g_free (accessible->name);
178 if (accessible->attributes)
179 g_hash_table_unref (accessible->attributes);
181 if (accessible->priv->cache)
182 g_hash_table_destroy (accessible->priv->cache);
184 #ifdef DEBUG_REF_COUNTS
186 g_hash_table_remove (_atspi_get_live_refs (), accessible);
187 g_print ("at-spi: finalize: %d objects\n", accessible_count);
190 G_OBJECT_CLASS (atspi_accessible_parent_class)->finalize (object);
194 atspi_accessible_class_init (AtspiAccessibleClass *klass)
196 GObjectClass *object_class = G_OBJECT_CLASS (klass);
198 object_class->dispose = atspi_accessible_dispose;
199 object_class->finalize = atspi_accessible_finalize;
201 quark_locale = g_quark_from_string ("accessible-locale");
205 * atspi_accessible_get_name:
206 * @obj: a pointer to the #AtspiAccessible object on which to operate.
208 * Gets the name of an #AtspiAccessible object.
210 * Returns: a UTF-8 string indicating the name of the #AtspiAccessible object
211 * or NULL on exception.
214 atspi_accessible_get_name (AtspiAccessible *obj, GError **error)
216 g_return_val_if_fail (obj != NULL, g_strdup (""));
217 if (!_atspi_accessible_test_cache (obj, ATSPI_CACHE_NAME))
219 if (!_atspi_dbus_get_property (obj, atspi_interface_accessible, "Name", error,
221 return g_strdup ("");
222 _atspi_accessible_add_cache (obj, ATSPI_CACHE_NAME);
224 return g_strdup (obj->name);
228 * atspi_accessible_get_description:
229 * @obj: a pointer to the #AtspiAccessible object on which to operate.
231 * Gets the description of an #AtspiAccessible object.
233 * Returns: a UTF-8 string describing the #AtspiAccessible object
234 * or NULL on exception.
237 atspi_accessible_get_description (AtspiAccessible *obj, GError **error)
239 g_return_val_if_fail (obj != NULL, g_strdup (""));
241 if (!_atspi_accessible_test_cache (obj, ATSPI_CACHE_DESCRIPTION))
243 if (!_atspi_dbus_get_property (obj, atspi_interface_accessible,
244 "Description", error, "s",
246 return g_strdup ("");
247 _atspi_accessible_add_cache (obj, ATSPI_CACHE_DESCRIPTION);
249 return g_strdup (obj->description);
252 const char *str_parent = "Parent";
255 * atspi_accessible_get_parent:
256 * @obj: a pointer to the #AtspiAccessible object to query.
258 * Gets an #AtspiAccessible object's parent container.
260 * Returns: (nullable) (transfer full): a pointer to the
261 * #AtspiAccessible object which contains the given
262 * #AtspiAccessible instance, or NULL if the @obj has no
267 atspi_accessible_get_parent (AtspiAccessible *obj, GError **error)
269 g_return_val_if_fail (obj != NULL, NULL);
271 if (obj->parent.app &&
272 !_atspi_accessible_test_cache (obj, ATSPI_CACHE_PARENT))
274 DBusMessage *message, *reply;
275 DBusMessageIter iter, iter_variant;
276 message = dbus_message_new_method_call (obj->parent.app->bus_name,
278 DBUS_INTERFACE_PROPERTIES, "Get");
281 dbus_message_append_args (message, DBUS_TYPE_STRING, &atspi_interface_accessible,
282 DBUS_TYPE_STRING, &str_parent,
284 reply = _atspi_dbus_send_with_reply_and_block (message, error);
287 if (strcmp (dbus_message_get_signature (reply), "v") != 0)
289 dbus_message_unref (reply);
292 dbus_message_iter_init (reply, &iter);
293 dbus_message_iter_recurse (&iter, &iter_variant);
294 obj->accessible_parent = _atspi_dbus_return_accessible_from_iter (&iter_variant);
295 dbus_message_unref (reply);
296 _atspi_accessible_add_cache (obj, ATSPI_CACHE_PARENT);
298 if (!obj->accessible_parent)
300 return g_object_ref (obj->accessible_parent);
304 * atspi_accessible_get_child_count:
305 * @obj: a pointer to the #AtspiAccessible object on which to operate.
307 * Gets the number of children contained by an #AtspiAccessible object.
309 * Returns: a #long indicating the number of #AtspiAccessible children
310 * contained by an #AtspiAccessible object or -1 on exception.
314 atspi_accessible_get_child_count (AtspiAccessible *obj, GError **error)
316 g_return_val_if_fail (obj != NULL, -1);
318 if (!_atspi_accessible_test_cache (obj, ATSPI_CACHE_CHILDREN))
321 if (!_atspi_dbus_get_property (obj, atspi_interface_accessible,
322 "ChildCount", error, "i", &ret))
328 return 0; /* assume it's disposed */
330 return obj->children->len;
334 * atspi_accessible_get_child_at_index:
335 * @obj: a pointer to the #AtspiAccessible object on which to operate.
336 * @child_index: a #long indicating which child is specified.
338 * Gets the #AtspiAccessible child of an #AtspiAccessible object at a given index.
340 * Returns: (transfer full): a pointer to the #AtspiAccessible child object at
341 * index @child_index or NULL on exception.
344 atspi_accessible_get_child_at_index (AtspiAccessible *obj,
348 AtspiAccessible *child;
351 g_return_val_if_fail (obj != NULL, NULL);
353 if (_atspi_accessible_test_cache (obj, ATSPI_CACHE_CHILDREN))
356 return NULL; /* assume disposed */
358 child = g_ptr_array_index (obj->children, child_index);
360 return g_object_ref (child);
363 reply = _atspi_dbus_call_partial (obj, atspi_interface_accessible,
364 "GetChildAtIndex", error, "i", child_index);
365 child = _atspi_dbus_return_accessible_from_message (reply);
370 if (_atspi_accessible_test_cache (obj, ATSPI_CACHE_CHILDREN))
372 if (child_index >= obj->children->len)
373 g_ptr_array_set_size (obj->children, child_index + 1);
374 g_ptr_array_index (obj->children, child_index) = g_object_ref (child);
380 * atspi_accessible_get_index_in_parent:
381 * @obj: a pointer to the #AtspiAccessible object on which to operate.
383 * Gets the index of an #AtspiAccessible object within its parent's
384 * #AtspiAccessible children list.
386 * Returns: a #glong indicating the index of the #AtspiAccessible object
388 * or -1 if @obj has no containing parent or on exception.
391 atspi_accessible_get_index_in_parent (AtspiAccessible *obj, GError **error)
394 dbus_int32_t ret = -1;
396 g_return_val_if_fail (obj != NULL, -1);
397 if (_atspi_accessible_test_cache (obj, ATSPI_CACHE_PARENT))
399 if (!obj->accessible_parent)
402 for (i = 0; i < obj->accessible_parent->children->len; i++)
403 if (g_ptr_array_index (obj->accessible_parent->children, i) == obj)
407 _atspi_dbus_call (obj, atspi_interface_accessible,
408 "GetIndexInParent", NULL, "=>i", &ret);
416 } Accessibility_Relation;
419 * atspi_accessible_get_relation_set:
420 * @obj: a pointer to the #AtspiAccessible object on which to operate.
422 * Gets the set of #AtspiRelation objects which describes this #AtspiAccessible object's
423 * relationships with other #AtspiAccessible objects.
425 * Returns: (element-type AtspiRelation*) (transfer full): a #GArray of
426 * #AtspiRelation pointers or NULL on exception.
429 atspi_accessible_get_relation_set (AtspiAccessible *obj, GError **error)
432 DBusMessageIter iter, iter_array;
435 g_return_val_if_fail (obj != NULL, NULL);
437 reply = _atspi_dbus_call_partial (obj, atspi_interface_accessible, "GetRelationSet", error, "");
440 _ATSPI_DBUS_CHECK_SIG (reply, "a(ua(so))", error, NULL);
442 ret = g_array_new (TRUE, TRUE, sizeof (AtspiRelation *));
443 dbus_message_iter_init (reply, &iter);
444 dbus_message_iter_recurse (&iter, &iter_array);
445 while (dbus_message_iter_get_arg_type (&iter_array) != DBUS_TYPE_INVALID)
447 AtspiRelation *relation;
448 relation = _atspi_relation_new_from_iter (&iter_array);
449 ret = g_array_append_val (ret, relation);
450 dbus_message_iter_next (&iter_array);
452 dbus_message_unref (reply);
457 * atspi_accessible_get_role:
458 * @obj: a pointer to the #AtspiAccessible object on which to operate.
460 * Gets the UI role played by an #AtspiAccessible object.
461 * This role's name can be obtained via atspi_accessible_get_role_name ().
463 * Returns: the #AtspiRole of an #AtspiAccessible object.
467 atspi_accessible_get_role (AtspiAccessible *obj, GError **error)
469 g_return_val_if_fail (obj != NULL, ATSPI_ROLE_INVALID);
471 if (!_atspi_accessible_test_cache (obj, ATSPI_CACHE_ROLE))
474 /* TODO: Make this a property */
475 if (_atspi_dbus_call (obj, atspi_interface_accessible, "GetRole", error, "=>u", &role))
478 _atspi_accessible_add_cache (obj, ATSPI_CACHE_ROLE);
485 * atspi_accessible_get_role_name:
486 * @obj: a pointer to the #AtspiAccessible object on which to operate.
488 * Gets a UTF-8 string corresponding to the name of the role played by an object.
489 * This method will return useful values for roles that fall outside the
490 * enumeration used in atspi_accessible_get_role ().
492 * Returns: a UTF-8 string specifying the type of UI role played by an
493 * #AtspiAccessible object.
497 atspi_accessible_get_role_name (AtspiAccessible *obj, GError **error)
499 gchar *retval = NULL;
502 g_return_val_if_fail (obj != NULL, NULL);
504 role = atspi_accessible_get_role (obj, error);
505 if (role >= 0 && role < ATSPI_ROLE_COUNT && role != ATSPI_ROLE_EXTENDED)
506 return atspi_role_get_name (role);
508 _atspi_dbus_call (obj, atspi_interface_accessible, "GetRoleName", error, "=>s", &retval);
511 retval = g_strdup ("");
517 * atspi_accessible_get_localized_role_name:
518 * @obj: a pointer to the #AtspiAccessible object on which to operate.
520 * Gets a UTF-8 string corresponding to the name of the role played by an
521 * object, translated to the current locale.
522 * This method will return useful values for roles that fall outside the
523 * enumeration used in atspi_accessible_getRole ().
525 * Returns: a localized, UTF-8 string specifying the type of UI role played
526 * by an #AtspiAccessible object.
530 atspi_accessible_get_localized_role_name (AtspiAccessible *obj, GError **error)
534 g_return_val_if_fail (obj != NULL, NULL);
536 _atspi_dbus_call (obj, atspi_interface_accessible, "GetLocalizedRoleName", error, "=>s", &retval);
539 return g_strdup ("");
544 static AtspiStateSet *
547 AtspiStateSet *set = atspi_state_set_new (NULL);
548 atspi_state_set_add (set, ATSPI_STATE_DEFUNCT);
553 * atspi_accessible_get_state_set:
554 * @obj: a pointer to the #AtspiAccessible object on which to operate.
556 * Gets the states currently held by an object.
558 * Returns: (transfer full): a pointer to an #AtspiStateSet representing an
559 * object's current state set.
562 atspi_accessible_get_state_set (AtspiAccessible *obj)
564 /* TODO: Should take a GError **, but would be an API break */
565 if (!obj->parent.app || !obj->parent.app->bus)
566 return defunct_set ();
568 if (!_atspi_accessible_test_cache (obj, ATSPI_CACHE_STATES))
571 DBusMessageIter iter;
572 reply = _atspi_dbus_call_partial (obj, atspi_interface_accessible,
573 "GetState", NULL, "");
574 _ATSPI_DBUS_CHECK_SIG (reply, "au", NULL, defunct_set ());
575 dbus_message_iter_init (reply, &iter);
576 _atspi_dbus_set_state (obj, &iter);
577 dbus_message_unref (reply);
578 _atspi_accessible_add_cache (obj, ATSPI_CACHE_STATES);
581 return g_object_ref (obj->states);
585 * atspi_accessible_get_attributes:
586 * @obj: The #AtspiAccessible being queried.
588 * Gets the #AttributeSet representing any assigned
589 * name-value pair attributes or annotations for this object.
590 * For typographic, textual, or textually-semantic attributes, see
591 * atspi_text_get_attributes instead.
593 * Returns: (element-type gchar* gchar*) (transfer full): The name-value-pair
594 * attributes assigned to this object.
597 atspi_accessible_get_attributes (AtspiAccessible *obj, GError **error)
599 DBusMessage *message;
601 g_return_val_if_fail (obj != NULL, NULL);
603 if (obj->priv->cache)
605 GValue *val = g_hash_table_lookup (obj->priv->cache, "Attributes");
607 return g_value_dup_boxed (val);
610 if (!_atspi_accessible_test_cache (obj, ATSPI_CACHE_ATTRIBUTES))
612 message = _atspi_dbus_call_partial (obj, atspi_interface_accessible,
613 "GetAttributes", error, "");
614 obj->attributes = _atspi_dbus_return_hash_from_message (message);
615 _atspi_accessible_add_cache (obj, ATSPI_CACHE_ATTRIBUTES);
618 if (!obj->attributes)
620 return g_hash_table_ref (obj->attributes);
624 add_to_attribute_array (gpointer key, gpointer value, gpointer data)
626 GArray **array = (GArray **)data;
627 gchar *str = g_strconcat (key, ":", value, NULL);
628 *array = g_array_append_val (*array, str);
632 * atspi_accessible_get_attributes_as_array:
633 * @obj: The #AtspiAccessible being queried.
635 * Gets a #GArray representing any assigned
636 * name-value pair attributes or annotations for this object.
637 * For typographic, textual, or textually-semantic attributes, see
638 * atspi_text_get_attributes_as_array instead.
640 * Returns: (element-type gchar*) (transfer full): The name-value-pair
641 * attributes assigned to this object.
644 atspi_accessible_get_attributes_as_array (AtspiAccessible *obj, GError **error)
646 DBusMessage *message;
648 g_return_val_if_fail (obj != NULL, NULL);
650 if (obj->priv->cache)
652 GValue *val = g_hash_table_lookup (obj->priv->cache, "Attributes");
655 GArray *array = g_array_new (TRUE, TRUE, sizeof (gchar *));
656 GHashTable *attributes = g_value_get_boxed (val);
657 g_hash_table_foreach (attributes, add_to_attribute_array, &array);
662 message = _atspi_dbus_call_partial (obj, atspi_interface_accessible, "GetAttributes", error, "");
663 return _atspi_dbus_return_attribute_array_from_message (message);
667 * atspi_accessible_get_application:
668 * @obj: The #AtspiAccessible being queried.
670 * Gets the containing #AtspiApplication for an object.
672 * Returns: (transfer full): the containing #AtspiApplication instance for
676 atspi_accessible_get_application (AtspiAccessible *obj, GError **error)
678 AtspiAccessible *parent;
683 parent = atspi_accessible_get_parent (obj, NULL);
684 if (!parent && obj->parent.app &&
685 atspi_accessible_get_role (obj, NULL) != ATSPI_ROLE_APPLICATION)
687 AtspiAccessible *root = g_object_ref (obj->parent.app->root);
690 g_object_unref (obj);
691 if (atspi_accessible_get_role (root, NULL) == ATSPI_ROLE_DESKTOP_FRAME)
693 g_object_unref (root);
699 if (!parent || parent == obj ||
700 atspi_accessible_get_role (parent, NULL) == ATSPI_ROLE_DESKTOP_FRAME)
703 g_object_unref (parent);
706 g_object_unref (obj);
711 /* Application-specific methods */
714 * atspi_accessible_get_toolkit_name:
715 * @obj: a pointer to the #AtspiAccessible object on which to operate.
717 * Gets the toolkit name for an #AtspiAccessible object.
718 * Only works on application root objects.
720 * Returns: a UTF-8 string indicating the toolkit name for the #AtspiAccessible object or NULL on exception.
723 atspi_accessible_get_toolkit_name (AtspiAccessible *obj, GError **error)
725 g_return_val_if_fail (obj != NULL, NULL);
727 if (!obj->parent.app)
730 if (!obj->parent.app->toolkit_name)
731 _atspi_dbus_get_property (obj, atspi_interface_application, "ToolkitName",
732 error, "s", &obj->parent.app->toolkit_name);
734 return g_strdup (obj->parent.app->toolkit_name);
738 * atspi_accessible_get_toolkit_version:
739 * @obj: a pointer to the #AtspiAccessible object on which to operate.
741 * Gets the toolkit version for an #AtspiAccessible object.
742 * Only works on application root objects.
744 * Returns: a UTF-8 string indicating the toolkit version for the #AtspiAccessible object or NULL on exception.
747 atspi_accessible_get_toolkit_version (AtspiAccessible *obj, GError **error)
749 g_return_val_if_fail (obj != NULL, NULL);
751 if (!obj->parent.app)
754 if (!obj->parent.app->toolkit_version)
755 _atspi_dbus_get_property (obj, atspi_interface_application, "Version",
756 error, "s", &obj->parent.app->toolkit_version);
758 return g_strdup (obj->parent.app->toolkit_version);
762 * atspi_accessible_get_atspi_version:
763 * @obj: a pointer to the #AtspiAccessible object on which to operate.
765 * Gets the AT-SPI IPC specification version supported by the application
766 * pointed to by the #AtspiAccessible object.
767 * Only works on application root objects.
769 * Returns: a UTF-8 string indicating the AT-SPI version for the #AtspiAccessible object or NULL on exception.
772 atspi_accessible_get_atspi_version (AtspiAccessible *obj, GError **error)
774 g_return_val_if_fail (obj != NULL, NULL);
776 if (!obj->parent.app)
779 if (!obj->parent.app->atspi_version)
780 _atspi_dbus_get_property (obj, atspi_interface_application, "AtspiVersion",
781 error, "s", &obj->parent.app->atspi_version);
783 return g_strdup (obj->parent.app->atspi_version);
787 * atspi_accessible_get_id:
788 * @obj: a pointer to the #AtspiAccessible object on which to operate.
790 * Gets the application id for a #AtspiAccessible object.
791 * Only works on application root objects.
793 * Returns: a positive #gint indicating the id for the #AtspiAccessible object
794 * or -1 on exception.
797 atspi_accessible_get_id (AtspiAccessible *obj, GError **error)
801 g_return_val_if_fail (obj != NULL, -1);
803 if (!_atspi_dbus_get_property (obj, atspi_interface_application, "Id", error, "i", &ret))
809 /* Interface query methods */
812 _atspi_accessible_is_a (AtspiAccessible *accessible,
813 const char *interface_name)
817 if (accessible == NULL)
822 if (!_atspi_accessible_test_cache (accessible, ATSPI_CACHE_INTERFACES))
825 DBusMessageIter iter;
826 reply = _atspi_dbus_call_partial (accessible, atspi_interface_accessible,
827 "GetInterfaces", NULL, "");
828 _ATSPI_DBUS_CHECK_SIG (reply, "as", NULL, FALSE);
829 dbus_message_iter_init (reply, &iter);
830 _atspi_dbus_set_interfaces (accessible, &iter);
831 dbus_message_unref (reply);
832 _atspi_accessible_add_cache (accessible, ATSPI_CACHE_INTERFACES);
835 n = _atspi_get_iface_num (interface_name);
836 if (n == -1) return FALSE;
837 return (gboolean) ((accessible->interfaces & (1 << n))? TRUE: FALSE);
841 * atspi_accessible_is_action:
842 * @obj: a pointer to the #AtspiAccessible instance to query.
844 * Query whether the specified #AtspiAccessible implements the
845 * #AtspiAction interface.
847 * Returns: #TRUE if @obj implements the #AtspiAction interface,
851 atspi_accessible_is_action (AtspiAccessible *obj)
853 return _atspi_accessible_is_a (obj,
854 atspi_interface_action);
858 * atspi_accessible_is_application:
859 * @obj: a pointer to the #AtspiAccessible instance to query.
861 * Query whether the specified #AtspiAccessible implements the
862 * #AtspiApplication interface.
864 * Returns: #TRUE if @obj implements the #AtspiApplication interface,
868 atspi_accessible_is_application (AtspiAccessible *obj)
870 return _atspi_accessible_is_a (obj,
871 atspi_interface_application);
875 * atspi_accessible_is_collection:
876 * @obj: a pointer to the #AtspiAccessible instance to query.
878 * Query whether the specified #AtspiAccessible implements the
879 * #AtspiCollection interface.
881 * Returns: #TRUE if @obj implements the #AtspiCollection interface,
885 atspi_accessible_is_collection (AtspiAccessible *obj)
887 return _atspi_accessible_is_a (obj,
888 atspi_interface_collection);
892 * atspi_accessible_is_component:
893 * @obj: a pointer to the #AtspiAccessible instance to query.
895 * Query whether the specified #AtspiAccessible implements #AtspiComponent.
897 * Returns: #TRUE if @obj implements the #AtspiComponent interface,
901 atspi_accessible_is_component (AtspiAccessible *obj)
903 return _atspi_accessible_is_a (obj,
904 atspi_interface_component);
908 * atspi_accessible_is_document:
909 * @obj: a pointer to the #AtspiAccessible instance to query.
911 * Query whether the specified #AtspiAccessible implements the
912 * #AtspiDocument interface.
914 * Returns: #TRUE if @obj implements the #AtspiDocument interface,
918 atspi_accessible_is_document (AtspiAccessible *obj)
920 return _atspi_accessible_is_a (obj,
921 atspi_interface_document);
925 * atspi_accessible_is_editable_text:
926 * @obj: a pointer to the #AtspiAccessible instance to query.
928 * Query whether the specified #AtspiAccessible implements the
929 * #AtspiEditableText interface.
931 * Returns: #TRUE if @obj implements the #AtspiEditableText interface,
935 atspi_accessible_is_editable_text (AtspiAccessible *obj)
937 return _atspi_accessible_is_a (obj,
938 atspi_interface_editable_text);
942 * atspi_accessible_is_hypertext:
943 * @obj: a pointer to the #AtspiAccessible instance to query.
945 * Query whether the specified #AtspiAccessible implements the
946 * #AtspiHypertext interface.
948 * Returns: #TRUE if @obj implements the #AtspiHypertext interface,
952 atspi_accessible_is_hypertext (AtspiAccessible *obj)
954 return _atspi_accessible_is_a (obj,
955 atspi_interface_hypertext);
959 * atspi_accessible_is_hyperlink:
960 * @obj: a pointer to the #AtspiAccessible instance to query.
962 * Query whether the specified #AtspiAccessible implements the
963 * #AtspiHyperlink interface.
965 * Returns: #TRUE if @obj implements the #AtspiHypertext interface,
969 atspi_accessible_is_hyperlink (AtspiAccessible *obj)
971 return _atspi_accessible_is_a (obj,
972 atspi_interface_hyperlink);
976 * atspi_accessible_is_image:
977 * @obj: a pointer to the #AtspiAccessible instance to query.
979 * Query whether the specified #AtspiAccessible implements the
980 * #AtspiImage interface.
982 * Returns: #TRUE if @obj implements the #AtspiImage interface,
986 atspi_accessible_is_image (AtspiAccessible *obj)
988 return _atspi_accessible_is_a (obj,
989 atspi_interface_image);
993 * atspi_accessible_is_selection:
994 * @obj: a pointer to the #AtspiAccessible instance to query.
996 * Query whether the specified #AtspiAccessible implements the
997 * #AtspiSelection interface.
999 * Returns: #TRUE if @obj implements the #AtspiSelection interface,
1003 atspi_accessible_is_selection (AtspiAccessible *obj)
1005 return _atspi_accessible_is_a (obj,
1006 atspi_interface_selection);
1010 * atspi_accessible_is_table:
1011 * @obj: a pointer to the #AtspiAccessible instance to query.
1013 * Query whether the specified #AtspiAccessible implements the
1014 * #AtspiTable interface.
1016 * Returns: #TRUE if @obj implements the #AtspiTable interface,
1020 atspi_accessible_is_table (AtspiAccessible *obj)
1022 return _atspi_accessible_is_a (obj,
1023 atspi_interface_table);
1027 * atspi_accessible_is_table_cell:
1028 * @obj: a pointer to the #AtspiAccessible instance to query.
1030 * Query whether the specified #AtspiAccessible implements the
1031 * #AtspiTableCell interface.
1033 * Returns: #TRUE if @obj implements the #AtspiTable interface,
1037 atspi_accessible_is_table_cell (AtspiAccessible *obj)
1039 return _atspi_accessible_is_a (obj,
1040 atspi_interface_table_cell);
1044 * atspi_accessible_is_streamable_content:
1045 * @obj: a pointer to the #AtspiAccessible instance to query.
1047 * Query whether the specified #AtspiAccessible implements the
1048 * #AtspiStreamableContent interface.
1050 * Returns: #TRUE if @obj implements the #AtspiStreamableContent interface,
1054 atspi_accessible_is_streamable_content (AtspiAccessible *obj)
1057 return _atspi_accessible_is_a (obj,
1058 atspi_interface_streamable_content);
1060 g_warning ("Streamable content not implemented");
1066 * atspi_accessible_is_text:
1067 * @obj: a pointer to the #AtspiAccessible instance to query.
1069 * Query whether the specified #AtspiAccessible implements the
1070 * #AtspiText interface.
1072 * Returns: #TRUE if @obj implements the #AtspiText interface,
1076 atspi_accessible_is_text (AtspiAccessible *obj)
1078 return _atspi_accessible_is_a (obj,
1079 atspi_interface_text);
1083 * atspi_accessible_is_value:
1084 * @obj: a pointer to the #AtspiAccessible instance to query.
1086 * Query whether the specified #AtspiAccessible implements the
1087 * #AtspiValue interface.
1089 * Returns: #TRUE if @obj implements the #AtspiValue interface,
1093 atspi_accessible_is_value (AtspiAccessible *obj)
1095 return _atspi_accessible_is_a (obj,
1096 atspi_interface_value);
1100 * atspi_accessible_get_action: (rename-to atspi_accessible_get_action_iface)
1101 * @obj: a pointer to the #AtspiAccessible instance to query.
1103 * Gets the #AtspiAction interface for an #AtspiAccessible.
1105 * Returns: (transfer full): a pointer to an #AtspiAction interface
1106 * instance, or NULL if @obj does not implement #AtspiAction.
1108 * Deprecated: 2.10: Use atspi_accessible_get_action_iface instead.
1111 atspi_accessible_get_action (AtspiAccessible *accessible)
1113 return (_atspi_accessible_is_a (accessible, atspi_interface_action) ?
1114 g_object_ref (ATSPI_ACTION (accessible)) : NULL);
1118 * atspi_accessible_get_action_iface:
1119 * @obj: a pointer to the #AtspiAccessible instance to query.
1121 * Gets the #AtspiAction interface for an #AtspiAccessible.
1123 * Returns: (transfer full): a pointer to an #AtspiAction interface
1124 * instance, or NULL if @obj does not implement #AtspiAction.
1127 atspi_accessible_get_action_iface (AtspiAccessible *accessible)
1129 return (_atspi_accessible_is_a (accessible, atspi_interface_action) ?
1130 g_object_ref (ATSPI_ACTION (accessible)) : NULL);
1134 * atspi_accessible_get_collection: (rename-to atspi_accessible_get_collection_iface)
1135 * @obj: a pointer to the #AtspiAccessible instance to query.
1137 * Gets the #AtspiCollection interface for an #AtspiAccessible.
1139 * Returns: (transfer full): a pointer to an #AtspiCollection interface
1140 * instance, or NULL if @obj does not implement #AtspiCollection.
1142 * Deprecated: 2.10: Use atspi_accessible_get_collection_iface instead.
1145 atspi_accessible_get_collection (AtspiAccessible *accessible)
1147 return (_atspi_accessible_is_a (accessible, atspi_interface_collection) ?
1148 g_object_ref (ATSPI_COLLECTION (accessible)) : NULL);
1152 * atspi_accessible_get_collection_iface:
1153 * @obj: a pointer to the #AtspiAccessible instance to query.
1155 * Gets the #AtspiCollection interface for an #AtspiAccessible.
1157 * Returns: (transfer full): a pointer to an #AtspiCollection interface
1158 * instance, or NULL if @obj does not implement #AtspiCollection.
1161 atspi_accessible_get_collection_iface (AtspiAccessible *accessible)
1163 return (_atspi_accessible_is_a (accessible, atspi_interface_collection) ?
1164 g_object_ref (ATSPI_COLLECTION (accessible)) : NULL);
1168 * atspi_accessible_get_component: (rename-to atspi_accessible_get_component_iface)
1169 * @obj: a pointer to the #AtspiAccessible instance to query.
1171 * Gets the #AtspiComponent interface for an #AtspiAccessible.
1173 * Returns: (transfer full): a pointer to an #AtspiComponent interface
1174 * instance, or NULL if @obj does not implement #AtspiComponent.
1176 * Deprecated: 2.10: Use atspi_accessible_get_component_iface instead.
1179 atspi_accessible_get_component (AtspiAccessible *obj)
1181 return (_atspi_accessible_is_a (obj, atspi_interface_component) ?
1182 g_object_ref (ATSPI_COMPONENT (obj)) : NULL);
1186 * atspi_accessible_get_component_iface:
1187 * @obj: a pointer to the #AtspiAccessible instance to query.
1189 * Gets the #AtspiComponent interface for an #AtspiAccessible.
1191 * Returns: (transfer full): a pointer to an #AtspiComponent interface
1192 * instance, or NULL if @obj does not implement #AtspiComponent.
1195 atspi_accessible_get_component_iface (AtspiAccessible *obj)
1197 return (_atspi_accessible_is_a (obj, atspi_interface_component) ?
1198 g_object_ref (ATSPI_COMPONENT (obj)) : NULL);
1202 * atspi_accessible_get_document: (rename-to atspi_accessible_get_document_iface)
1203 * @obj: a pointer to the #AtspiAccessible instance to query.
1205 * Gets the #AtspiDocument interface for an #AtspiAccessible.
1207 * Returns: (transfer full): a pointer to an #AtspiDocument interface
1208 * instance, or NULL if @obj does not implement #AtspiDocument.
1210 * Deprecated: 2.10: Use atspi_accessible_get_document_iface instead.
1213 atspi_accessible_get_document (AtspiAccessible *accessible)
1215 return (_atspi_accessible_is_a (accessible, atspi_interface_document) ?
1216 g_object_ref (ATSPI_DOCUMENT (accessible)) : NULL);
1220 * atspi_accessible_get_document_iface:
1221 * @obj: a pointer to the #AtspiAccessible instance to query.
1223 * Gets the #AtspiDocument interface for an #AtspiAccessible.
1225 * Returns: (transfer full): a pointer to an #AtspiDocument interface
1226 * instance, or NULL if @obj does not implement #AtspiDocument.
1229 atspi_accessible_get_document_iface (AtspiAccessible *accessible)
1231 return (_atspi_accessible_is_a (accessible, atspi_interface_document) ?
1232 g_object_ref (ATSPI_DOCUMENT (accessible)) : NULL);
1236 * atspi_accessible_get_editable_text: (rename-to atspi_accessible_get_editable_text_iface)
1237 * @obj: a pointer to the #AtspiAccessible instance to query.
1239 * Gets the #AtspiEditableText interface for an #AtspiAccessible.
1241 * Returns: (transfer full): a pointer to an #AtspiEditableText interface
1242 * instance, or NULL if @obj does not implement #AtspiEditableText.
1244 * Deprecated: 2.10: Use atspi_accessible_get_editable_text_iface instead.
1247 atspi_accessible_get_editable_text (AtspiAccessible *accessible)
1249 return (_atspi_accessible_is_a (accessible, atspi_interface_editable_text) ?
1250 g_object_ref (ATSPI_EDITABLE_TEXT (accessible)) : NULL);
1254 * atspi_accessible_get_editable_text_iface:
1255 * @obj: a pointer to the #AtspiAccessible instance to query.
1257 * Gets the #AtspiEditableText interface for an #AtspiAccessible.
1259 * Returns: (transfer full): a pointer to an #AtspiEditableText interface
1260 * instance, or NULL if @obj does not implement #AtspiEditableText.
1263 atspi_accessible_get_editable_text_iface (AtspiAccessible *accessible)
1265 return (_atspi_accessible_is_a (accessible, atspi_interface_editable_text) ?
1266 g_object_ref (ATSPI_EDITABLE_TEXT (accessible)) : NULL);
1270 * atspi_accessible_get_hyperlink:
1271 * @obj: a pointer to the #AtspiAccessible object on which to operate.
1273 * Gets the #AtspiHyperlink interface for an #AtspiAccessible.
1275 * Returns: (transfer full): the #AtspiHyperlink object associated with
1276 * the given #AtspiAccessible, or NULL if not supported.
1279 atspi_accessible_get_hyperlink (AtspiAccessible *accessible)
1281 return (_atspi_accessible_is_a (accessible, atspi_interface_hyperlink) ?
1282 _atspi_hyperlink_new (accessible->parent.app, accessible->parent.path) : NULL);
1286 * atspi_accessible_get_hypertext: (rename-to atspi_accessible_get_hypertext_iface)
1287 * @obj: a pointer to the #AtspiAccessible instance to query.
1289 * Gets the #AtspiHypertext interface for an #AtspiAccessible.
1291 * Returns: (transfer full): a pointer to an #AtspiHypertext interface
1292 * instance, or NULL if @obj does not implement #AtspiHypertext.
1294 * Deprecated: 2.10: Use atspi_accessible_get_hypertext_iface instead.
1297 atspi_accessible_get_hypertext (AtspiAccessible *accessible)
1299 return (_atspi_accessible_is_a (accessible, atspi_interface_hypertext) ?
1300 g_object_ref (ATSPI_HYPERTEXT (accessible)) : NULL);
1304 * atspi_accessible_get_hypertext_iface:
1305 * @obj: a pointer to the #AtspiAccessible instance to query.
1307 * Gets the #AtspiHypertext interface for an #AtspiAccessible.
1309 * Returns: (transfer full): a pointer to an #AtspiHypertext interface
1310 * instance, or NULL if @obj does not implement #AtspiHypertext.
1313 atspi_accessible_get_hypertext_iface (AtspiAccessible *accessible)
1315 return (_atspi_accessible_is_a (accessible, atspi_interface_hypertext) ?
1316 g_object_ref (ATSPI_HYPERTEXT (accessible)) : NULL);
1320 * atspi_accessible_get_image: (rename-to atspi_accessible_get_image_iface)
1321 * @obj: a pointer to the #AtspiAccessible instance to query.
1323 * Gets the #AtspiImage interface for an #AtspiAccessible.
1325 * Returns: (transfer full): a pointer to an #AtspiImage interface instance, or
1326 * NULL if @obj does not implement #AtspiImage.
1328 * Deprecated: 2.10: Use atspi_accessible_get_image_iface instead.
1331 atspi_accessible_get_image (AtspiAccessible *accessible)
1333 return (_atspi_accessible_is_a (accessible, atspi_interface_image) ?
1334 g_object_ref (ATSPI_IMAGE (accessible)) : NULL);
1338 * atspi_accessible_get_image_iface:
1339 * @obj: a pointer to the #AtspiAccessible instance to query.
1341 * Gets the #AtspiImage interface for an #AtspiAccessible.
1343 * Returns: (transfer full): a pointer to an #AtspiImage interface instance, or
1344 * NULL if @obj does not implement #AtspiImage.
1347 atspi_accessible_get_image_iface (AtspiAccessible *accessible)
1349 return (_atspi_accessible_is_a (accessible, atspi_interface_image) ?
1350 g_object_ref (ATSPI_IMAGE (accessible)) : NULL);
1354 * atspi_accessible_get_selection: (rename-to atspi_accessible_get_selection_iface)
1355 * @obj: a pointer to the #AtspiAccessible instance to query.
1357 * Gets the #AtspiSelection interface for an #AtspiAccessible.
1359 * Returns: (transfer full): a pointer to an #AtspiSelection interface
1360 * instance, or NULL if @obj does not implement #AtspiSelection.
1362 * Deprecated: 2.10: Use atspi_accessible_get_selection_iface instead.
1365 atspi_accessible_get_selection (AtspiAccessible *accessible)
1367 return (_atspi_accessible_is_a (accessible, atspi_interface_selection) ?
1368 g_object_ref (ATSPI_SELECTION (accessible)) : NULL);
1372 * atspi_accessible_get_selection_iface:
1373 * @obj: a pointer to the #AtspiAccessible instance to query.
1375 * Gets the #AtspiSelection interface for an #AtspiAccessible.
1377 * Returns: (transfer full): a pointer to an #AtspiSelection interface
1378 * instance, or NULL if @obj does not implement #AtspiSelection.
1381 atspi_accessible_get_selection_iface (AtspiAccessible *accessible)
1383 return (_atspi_accessible_is_a (accessible, atspi_interface_selection) ?
1384 g_object_ref (ATSPI_SELECTION (accessible)) : NULL);
1389 * atspi_accessible_get_streamable_content:
1390 * @obj: a pointer to the #AtspiAccessible instance to query.
1392 * Gets the #AtspiStreamableContent interface for an #AtspiAccessible.
1394 * Returns: (transfer full): a pointer to an #AtspiStreamableContent interface
1395 * instance, or NULL if @obj does not implement #AtspiStreamableContent.
1397 AtspiStreamableContent *
1398 atspi_accessible_get_streamable_content (AtspiAccessible *accessible)
1400 return (_atspi_accessible_is_a (accessible, atspi_interface_streamable_content) ?
1406 * atspi_accessible_get_table: (rename-to atspi_accessible_get_table_iface)
1407 * @obj: a pointer to the #AtspiAccessible instance to query.
1409 * Gets the #AtspiTable interface for an #AtspiAccessible.
1411 * Returns: (transfer full): a pointer to an #AtspiTable interface instance, or
1412 * NULL if @obj does not implement #AtspiTable.
1414 * Deprecated: 2.10: Use atspi_accessible_get_table_iface instead.
1417 atspi_accessible_get_table (AtspiAccessible *obj)
1419 return (_atspi_accessible_is_a (obj, atspi_interface_table) ?
1420 g_object_ref (ATSPI_TABLE (obj)) : NULL);
1424 * atspi_accessible_get_table_iface:
1425 * @obj: a pointer to the #AtspiAccessible instance to query.
1427 * Gets the #AtspiTable interface for an #AtspiAccessible.
1429 * Returns: (transfer full): a pointer to an #AtspiTable interface instance, or
1430 * NULL if @obj does not implement #AtspiTable.
1433 atspi_accessible_get_table_iface (AtspiAccessible *obj)
1435 return (_atspi_accessible_is_a (obj, atspi_interface_table) ?
1436 g_object_ref (ATSPI_TABLE (obj)) : NULL);
1440 * atspi_accessible_get_table_cell:
1441 * @obj: a pointer to the #AtspiAccessible instance to query.
1443 * Gets the #AtspiTableCell interface for an #AtspiAccessible.
1445 * Returns: (transfer full): a pointer to an #AtspiTableCell interface instance,
1446 * or NULL if @obj does not implement #AtspiTable.
1449 atspi_accessible_get_table_cell (AtspiAccessible *obj)
1451 return (_atspi_accessible_is_a (obj, atspi_interface_table_cell) ?
1452 g_object_ref (ATSPI_TABLE_CELL (obj)) : NULL);
1456 * atspi_accessible_get_text: (rename-to atspi_accessible_get_text_iface)
1457 * @obj: a pointer to the #AtspiAccessible instance to query.
1459 * Gets the #AtspiTable interface for an #AtspiAccessible.
1461 * Returns: (transfer full): a pointer to an #AtspiText interface instance, or
1462 * NULL if @obj does not implement #AtspiText.
1464 * Deprecated: 2.10: Use atspi_accessible_get_text_iface instead.
1467 atspi_accessible_get_text (AtspiAccessible *obj)
1469 return (_atspi_accessible_is_a (obj, atspi_interface_text) ?
1470 g_object_ref (ATSPI_TEXT (obj)) : NULL);
1474 * atspi_accessible_get_text_iface:
1475 * @obj: a pointer to the #AtspiAccessible instance to query.
1477 * Gets the #AtspiTable interface for an #AtspiAccessible.
1479 * Returns: (transfer full): a pointer to an #AtspiText interface instance, or
1480 * NULL if @obj does not implement #AtspiText.
1483 atspi_accessible_get_text_iface (AtspiAccessible *obj)
1485 return (_atspi_accessible_is_a (obj, atspi_interface_text) ?
1486 g_object_ref (ATSPI_TEXT (obj)) : NULL);
1490 * atspi_accessible_get_value: (rename-to atspi_accessible_get_value_iface)
1491 * @obj: a pointer to the #AtspiAccessible instance to query.
1493 * Gets the #AtspiTable interface for an #AtspiAccessible.
1495 * Returns: (transfer full): a pointer to an #AtspiValue interface instance, or
1496 * NULL if @obj does not implement #AtspiValue.
1498 * Deprecated: 2.10: Use atspi_accessible_get_value_iface instead.
1501 atspi_accessible_get_value (AtspiAccessible *accessible)
1503 return (_atspi_accessible_is_a (accessible, atspi_interface_value) ?
1504 g_object_ref (ATSPI_VALUE (accessible)) : NULL);
1508 * atspi_accessible_get_value_iface:
1509 * @obj: a pointer to the #AtspiAccessible instance to query.
1511 * Gets the #AtspiTable interface for an #AtspiAccessible.
1513 * Returns: (transfer full): a pointer to an #AtspiValue interface instance, or
1514 * NULL if @obj does not implement #AtspiValue.
1517 atspi_accessible_get_value_iface (AtspiAccessible *accessible)
1519 return (_atspi_accessible_is_a (accessible, atspi_interface_value) ?
1520 g_object_ref (ATSPI_VALUE (accessible)) : NULL);
1524 append_const_val (GArray *array, const gchar *val)
1526 gchar *dup = g_strdup (val);
1529 g_array_append_val (array, dup);
1533 * atspi_accessible_get_interfaces:
1534 * @obj: The #AtspiAccessible to query.
1536 * A set of pointers to all interfaces supported by an #AtspiAccessible.
1538 * Returns: (element-type gchar*) (transfer full): A #GArray of strings
1539 * describing the interfaces supported by the object. Interfaces are
1540 * denoted in short-hand (i.e. "Component", "Text" etc.).
1543 atspi_accessible_get_interfaces (AtspiAccessible *obj)
1545 GArray *ret = g_array_new (TRUE, TRUE, sizeof (gchar *));
1547 g_return_val_if_fail (obj != NULL, NULL);
1549 append_const_val (ret, "Accessible");
1550 if (atspi_accessible_is_action (obj))
1551 append_const_val (ret, "Action");
1552 if (atspi_accessible_is_collection (obj))
1553 append_const_val (ret, "Collection");
1554 if (atspi_accessible_is_component (obj))
1555 append_const_val (ret, "Component");
1556 if (atspi_accessible_is_document (obj))
1557 append_const_val (ret, "Document");
1558 if (atspi_accessible_is_editable_text (obj))
1559 append_const_val (ret, "EditableText");
1560 if (atspi_accessible_is_hypertext (obj))
1561 append_const_val (ret, "Hypertext");
1562 if (atspi_accessible_is_hyperlink (obj))
1563 append_const_val (ret, "Hyperlink");
1564 if (atspi_accessible_is_image (obj))
1565 append_const_val (ret, "Image");
1566 if (atspi_accessible_is_selection (obj))
1567 append_const_val (ret, "Selection");
1568 if (atspi_accessible_is_table (obj))
1569 append_const_val (ret, "Table");
1570 if (atspi_accessible_is_table_cell (obj))
1571 append_const_val (ret, "TableCell");
1572 if (atspi_accessible_is_text (obj))
1573 append_const_val (ret, "Text");
1574 if (atspi_accessible_is_value (obj))
1575 append_const_val (ret, "Value");
1581 _atspi_accessible_new (AtspiApplication *app, const gchar *path)
1583 AtspiAccessible *accessible;
1585 accessible = g_object_new (ATSPI_TYPE_ACCESSIBLE, NULL);
1586 g_return_val_if_fail (accessible != NULL, NULL);
1588 accessible->parent.app = g_object_ref (app);
1589 accessible->parent.path = g_strdup (path);
1595 * atspi_accessible_set_cache_mask:
1596 * @accessible: The #AtspiAccessible to operate on. Must be the desktop or
1597 * the root of an application.
1598 * @mask: An #AtspiCache specifying a bit mask of the types of data to cache.
1600 * Sets the type of data to cache for accessibles.
1601 * If this is not set for an application or is reset to ATSPI_CACHE_UNDEFINED,
1602 * then the desktop's cache flag will be used.
1603 * If the desktop's cache flag is also undefined, then all possible data will
1605 * This function is intended to work around bugs in toolkits where the proper
1606 * events are not raised / to aid in testing for such bugs.
1609 atspi_accessible_set_cache_mask (AtspiAccessible *accessible, AtspiCache mask)
1611 g_return_if_fail (accessible != NULL);
1612 g_return_if_fail (accessible->parent.app != NULL);
1613 g_return_if_fail (accessible == accessible->parent.app->root);
1614 accessible->parent.app->cache = mask;
1615 enable_caching = TRUE;
1619 * atspi_accessible_clear_cache:
1620 * @obj: The #AtspiAccessible whose cache to clear.
1622 * Clears the cached information for the given accessible and all of its
1626 atspi_accessible_clear_cache (AtspiAccessible *obj)
1632 obj->cached_properties = ATSPI_CACHE_NONE;
1633 for (i = 0; i < obj->children->len; i++)
1634 atspi_accessible_clear_cache (g_ptr_array_index (obj->children, i));
1639 * atspi_accessible_get_process_id:
1640 * @accessible: The #AtspiAccessible to query.
1641 * @error: a pointer to a %NULL #GError pointer
1643 * Returns the process id associated with the given accessible. Mainly
1644 * added for debugging; it is a shortcut to explicitly querying the
1645 * accessible's app->bus_name and then calling GetConnectionUnixProcessID.
1647 * Returns: The process ID or undetermined value if @error is set.
1650 atspi_accessible_get_process_id (AtspiAccessible *accessible, GError **error)
1652 DBusMessage *message, *reply;
1653 DBusConnection *bus = _atspi_bus ();
1654 dbus_uint32_t pid = -1;
1657 if (!accessible->parent.app || !accessible->parent.app->bus_name)
1659 g_set_error_literal(error, ATSPI_ERROR, ATSPI_ERROR_IPC, "Process is defunct");
1663 message = dbus_message_new_method_call ("org.freedesktop.DBus",
1664 "/org/freedesktop/DBus",
1665 "org.freedesktop.DBus",
1666 "GetConnectionUnixProcessID");
1667 dbus_message_append_args (message, DBUS_TYPE_STRING,
1668 &accessible->parent.app->bus_name,
1670 dbus_error_init (&d_error);
1671 reply = dbus_connection_send_with_reply_and_block (bus, message, -1, &d_error);
1672 dbus_message_unref (message);
1675 if (!strcmp (dbus_message_get_signature (reply), "u"))
1676 dbus_message_get_args (reply, NULL, DBUS_TYPE_UINT32, &pid, DBUS_TYPE_INVALID);
1677 dbus_message_unref (reply);
1679 if (dbus_error_is_set (&d_error))
1681 g_set_error_literal(error, ATSPI_ERROR, ATSPI_ERROR_IPC, "Process is defunct");
1682 dbus_error_free (&d_error);
1688 _atspi_accessible_get_cache_mask (AtspiAccessible *accessible)
1692 if (!accessible->parent.app)
1693 return ATSPI_CACHE_NONE;
1695 mask = accessible->parent.app->cache;
1696 if (mask == ATSPI_CACHE_UNDEFINED &&
1697 accessible->parent.app->root &&
1698 accessible->parent.app->root->accessible_parent)
1700 AtspiAccessible *desktop = atspi_get_desktop (0);
1701 mask = desktop->parent.app->cache;
1702 g_object_unref (desktop);
1705 if (mask == ATSPI_CACHE_UNDEFINED)
1706 mask = ATSPI_CACHE_DEFAULT;
1712 _atspi_accessible_test_cache (AtspiAccessible *accessible, AtspiCache flag)
1714 AtspiCache mask = _atspi_accessible_get_cache_mask (accessible);
1715 AtspiCache result = accessible->cached_properties & mask & flag;
1716 if (accessible->states && atspi_state_set_contains (accessible->states, ATSPI_STATE_TRANSIENT))
1718 return (result != 0 && (atspi_main_loop || enable_caching ||
1719 flag == ATSPI_CACHE_INTERFACES) &&
1724 _atspi_accessible_add_cache (AtspiAccessible *accessible, AtspiCache flag)
1726 AtspiCache mask = _atspi_accessible_get_cache_mask (accessible);
1728 accessible->cached_properties |= flag & mask;
1732 * atspi_accessible_get_locale:
1733 * @accessible: an #AtspiAccessible
1735 * Gets a UTF-8 string indicating the POSIX-style LC_MESSAGES locale
1740 * Returns: a UTF-8 string indicating the POSIX-style LC_MESSAGES
1741 * locale of @accessible.
1744 atspi_accessible_get_object_locale (AtspiAccessible *accessible, GError **error)
1748 g_return_val_if_fail (accessible != NULL, NULL);
1750 locale = g_object_get_qdata (G_OBJECT (accessible), quark_locale);
1753 if (!_atspi_dbus_get_property (accessible, atspi_interface_accessible,
1754 "Locale", error, "s", &locale))
1757 g_object_set_qdata_full (G_OBJECT (accessible), quark_locale, locale,
1764 free_value (gpointer data)
1766 GValue *value = data;
1768 g_value_unset (value);
1773 _atspi_accessible_ref_cache (AtspiAccessible *accessible)
1775 AtspiAccessiblePrivate *priv = accessible->priv;
1777 priv->cache_ref_count++;
1779 return g_hash_table_ref (priv->cache);
1780 priv->cache = g_hash_table_new_full (g_str_hash, g_str_equal, g_free,
1786 _atspi_accessible_unref_cache (AtspiAccessible *accessible)
1788 AtspiAccessiblePrivate *priv = accessible->priv;
1792 g_hash_table_unref (priv->cache);
1793 if (--priv->cache_ref_count == 0)