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 if (!_atspi_accessible_test_cache (obj->accessible_parent, ATSPI_CACHE_CHILDREN) || !obj->accessible_parent->children)
405 for (i = 0; i < obj->accessible_parent->children->len; i++)
406 if (g_ptr_array_index (obj->accessible_parent->children, i) == obj)
411 _atspi_dbus_call (obj, atspi_interface_accessible,
412 "GetIndexInParent", NULL, "=>i", &ret);
420 } Accessibility_Relation;
423 * atspi_accessible_get_relation_set:
424 * @obj: a pointer to the #AtspiAccessible object on which to operate.
426 * Gets the set of #AtspiRelation objects which describes this #AtspiAccessible object's
427 * relationships with other #AtspiAccessible objects.
429 * Returns: (element-type AtspiRelation*) (transfer full): a #GArray of
430 * #AtspiRelation pointers or NULL on exception.
433 atspi_accessible_get_relation_set (AtspiAccessible *obj, GError **error)
436 DBusMessageIter iter, iter_array;
439 g_return_val_if_fail (obj != NULL, NULL);
441 reply = _atspi_dbus_call_partial (obj, atspi_interface_accessible, "GetRelationSet", error, "");
444 _ATSPI_DBUS_CHECK_SIG (reply, "a(ua(so))", error, NULL);
446 ret = g_array_new (TRUE, TRUE, sizeof (AtspiRelation *));
447 dbus_message_iter_init (reply, &iter);
448 dbus_message_iter_recurse (&iter, &iter_array);
449 while (dbus_message_iter_get_arg_type (&iter_array) != DBUS_TYPE_INVALID)
451 AtspiRelation *relation;
452 relation = _atspi_relation_new_from_iter (&iter_array);
453 ret = g_array_append_val (ret, relation);
454 dbus_message_iter_next (&iter_array);
456 dbus_message_unref (reply);
461 * atspi_accessible_get_role:
462 * @obj: a pointer to the #AtspiAccessible object on which to operate.
464 * Gets the UI role played by an #AtspiAccessible object.
465 * This role's name can be obtained via atspi_accessible_get_role_name ().
467 * Returns: the #AtspiRole of an #AtspiAccessible object.
471 atspi_accessible_get_role (AtspiAccessible *obj, GError **error)
473 g_return_val_if_fail (obj != NULL, ATSPI_ROLE_INVALID);
475 if (!_atspi_accessible_test_cache (obj, ATSPI_CACHE_ROLE))
478 /* TODO: Make this a property */
479 if (_atspi_dbus_call (obj, atspi_interface_accessible, "GetRole", error, "=>u", &role))
482 _atspi_accessible_add_cache (obj, ATSPI_CACHE_ROLE);
489 * atspi_accessible_get_role_name:
490 * @obj: a pointer to the #AtspiAccessible object on which to operate.
492 * Gets a UTF-8 string corresponding to the name of the role played by an object.
493 * This method will return useful values for roles that fall outside the
494 * enumeration used in atspi_accessible_get_role ().
496 * Returns: a UTF-8 string specifying the type of UI role played by an
497 * #AtspiAccessible object.
501 atspi_accessible_get_role_name (AtspiAccessible *obj, GError **error)
503 gchar *retval = NULL;
506 g_return_val_if_fail (obj != NULL, NULL);
508 role = atspi_accessible_get_role (obj, error);
509 if (role >= 0 && role < ATSPI_ROLE_COUNT && role != ATSPI_ROLE_EXTENDED)
510 return atspi_role_get_name (role);
512 _atspi_dbus_call (obj, atspi_interface_accessible, "GetRoleName", error, "=>s", &retval);
515 retval = g_strdup ("");
521 * atspi_accessible_get_localized_role_name:
522 * @obj: a pointer to the #AtspiAccessible object on which to operate.
524 * Gets a UTF-8 string corresponding to the name of the role played by an
525 * object, translated to the current locale.
526 * This method will return useful values for roles that fall outside the
527 * enumeration used in atspi_accessible_getRole ().
529 * Returns: a localized, UTF-8 string specifying the type of UI role played
530 * by an #AtspiAccessible object.
534 atspi_accessible_get_localized_role_name (AtspiAccessible *obj, GError **error)
538 g_return_val_if_fail (obj != NULL, NULL);
540 _atspi_dbus_call (obj, atspi_interface_accessible, "GetLocalizedRoleName", error, "=>s", &retval);
543 return g_strdup ("");
548 static AtspiStateSet *
551 AtspiStateSet *set = atspi_state_set_new (NULL);
552 atspi_state_set_add (set, ATSPI_STATE_DEFUNCT);
557 * atspi_accessible_get_state_set:
558 * @obj: a pointer to the #AtspiAccessible object on which to operate.
560 * Gets the states currently held by an object.
562 * Returns: (transfer full): a pointer to an #AtspiStateSet representing an
563 * object's current state set.
566 atspi_accessible_get_state_set (AtspiAccessible *obj)
568 /* TODO: Should take a GError **, but would be an API break */
569 if (!obj->parent.app || !obj->parent.app->bus)
570 return defunct_set ();
572 if (!_atspi_accessible_test_cache (obj, ATSPI_CACHE_STATES))
575 DBusMessageIter iter;
576 reply = _atspi_dbus_call_partial (obj, atspi_interface_accessible,
577 "GetState", NULL, "");
578 _ATSPI_DBUS_CHECK_SIG (reply, "au", NULL, defunct_set ());
579 dbus_message_iter_init (reply, &iter);
580 _atspi_dbus_set_state (obj, &iter);
581 dbus_message_unref (reply);
582 _atspi_accessible_add_cache (obj, ATSPI_CACHE_STATES);
585 return g_object_ref (obj->states);
589 * atspi_accessible_get_attributes:
590 * @obj: The #AtspiAccessible being queried.
592 * Gets the #AttributeSet representing any assigned
593 * name-value pair attributes or annotations for this object.
594 * For typographic, textual, or textually-semantic attributes, see
595 * atspi_text_get_attributes instead.
597 * Returns: (element-type gchar* gchar*) (transfer full): The name-value-pair
598 * attributes assigned to this object.
601 atspi_accessible_get_attributes (AtspiAccessible *obj, GError **error)
603 DBusMessage *message;
605 g_return_val_if_fail (obj != NULL, NULL);
607 if (obj->priv->cache)
609 GValue *val = g_hash_table_lookup (obj->priv->cache, "Attributes");
611 return g_value_dup_boxed (val);
614 if (!_atspi_accessible_test_cache (obj, ATSPI_CACHE_ATTRIBUTES))
616 message = _atspi_dbus_call_partial (obj, atspi_interface_accessible,
617 "GetAttributes", error, "");
618 obj->attributes = _atspi_dbus_return_hash_from_message (message);
619 _atspi_accessible_add_cache (obj, ATSPI_CACHE_ATTRIBUTES);
622 if (!obj->attributes)
624 return g_hash_table_ref (obj->attributes);
628 add_to_attribute_array (gpointer key, gpointer value, gpointer data)
630 GArray **array = (GArray **)data;
631 gchar *str = g_strconcat (key, ":", value, NULL);
632 *array = g_array_append_val (*array, str);
636 * atspi_accessible_get_attributes_as_array:
637 * @obj: The #AtspiAccessible being queried.
639 * Gets a #GArray representing any assigned
640 * name-value pair attributes or annotations for this object.
641 * For typographic, textual, or textually-semantic attributes, see
642 * atspi_text_get_attributes_as_array instead.
644 * Returns: (element-type gchar*) (transfer full): The name-value-pair
645 * attributes assigned to this object.
648 atspi_accessible_get_attributes_as_array (AtspiAccessible *obj, GError **error)
650 DBusMessage *message;
652 g_return_val_if_fail (obj != NULL, NULL);
654 if (obj->priv->cache)
656 GValue *val = g_hash_table_lookup (obj->priv->cache, "Attributes");
659 GArray *array = g_array_new (TRUE, TRUE, sizeof (gchar *));
660 GHashTable *attributes = g_value_get_boxed (val);
661 g_hash_table_foreach (attributes, add_to_attribute_array, &array);
666 message = _atspi_dbus_call_partial (obj, atspi_interface_accessible, "GetAttributes", error, "");
667 return _atspi_dbus_return_attribute_array_from_message (message);
671 * atspi_accessible_get_application:
672 * @obj: The #AtspiAccessible being queried.
674 * Gets the containing #AtspiApplication for an object.
676 * Returns: (transfer full): the containing #AtspiApplication instance for
680 atspi_accessible_get_application (AtspiAccessible *obj, GError **error)
682 AtspiAccessible *parent;
687 parent = atspi_accessible_get_parent (obj, NULL);
688 if (!parent && obj->parent.app &&
689 atspi_accessible_get_role (obj, NULL) != ATSPI_ROLE_APPLICATION)
691 AtspiAccessible *root = g_object_ref (obj->parent.app->root);
694 g_object_unref (obj);
695 if (atspi_accessible_get_role (root, NULL) == ATSPI_ROLE_DESKTOP_FRAME)
697 g_object_unref (root);
703 if (!parent || parent == obj ||
704 atspi_accessible_get_role (parent, NULL) == ATSPI_ROLE_DESKTOP_FRAME)
707 g_object_unref (parent);
710 g_object_unref (obj);
715 /* Application-specific methods */
718 * atspi_accessible_get_toolkit_name:
719 * @obj: a pointer to the #AtspiAccessible object on which to operate.
721 * Gets the toolkit name for an #AtspiAccessible object.
722 * Only works on application root objects.
724 * Returns: a UTF-8 string indicating the toolkit name for the #AtspiAccessible object or NULL on exception.
727 atspi_accessible_get_toolkit_name (AtspiAccessible *obj, GError **error)
729 g_return_val_if_fail (obj != NULL, NULL);
731 if (!obj->parent.app)
734 if (!obj->parent.app->toolkit_name)
735 _atspi_dbus_get_property (obj, atspi_interface_application, "ToolkitName",
736 error, "s", &obj->parent.app->toolkit_name);
738 return g_strdup (obj->parent.app->toolkit_name);
742 * atspi_accessible_get_toolkit_version:
743 * @obj: a pointer to the #AtspiAccessible object on which to operate.
745 * Gets the toolkit version for an #AtspiAccessible object.
746 * Only works on application root objects.
748 * Returns: a UTF-8 string indicating the toolkit version for the #AtspiAccessible object or NULL on exception.
751 atspi_accessible_get_toolkit_version (AtspiAccessible *obj, GError **error)
753 g_return_val_if_fail (obj != NULL, NULL);
755 if (!obj->parent.app)
758 if (!obj->parent.app->toolkit_version)
759 _atspi_dbus_get_property (obj, atspi_interface_application, "Version",
760 error, "s", &obj->parent.app->toolkit_version);
762 return g_strdup (obj->parent.app->toolkit_version);
766 * atspi_accessible_get_atspi_version:
767 * @obj: a pointer to the #AtspiAccessible object on which to operate.
769 * Gets the AT-SPI IPC specification version supported by the application
770 * pointed to by the #AtspiAccessible object.
771 * Only works on application root objects.
773 * Returns: a UTF-8 string indicating the AT-SPI version for the #AtspiAccessible object or NULL on exception.
776 atspi_accessible_get_atspi_version (AtspiAccessible *obj, GError **error)
778 g_return_val_if_fail (obj != NULL, NULL);
780 if (!obj->parent.app)
783 if (!obj->parent.app->atspi_version)
784 _atspi_dbus_get_property (obj, atspi_interface_application, "AtspiVersion",
785 error, "s", &obj->parent.app->atspi_version);
787 return g_strdup (obj->parent.app->atspi_version);
791 * atspi_accessible_get_id:
792 * @obj: a pointer to the #AtspiAccessible object on which to operate.
794 * Gets the application id for a #AtspiAccessible object.
795 * Only works on application root objects.
797 * Returns: a positive #gint indicating the id for the #AtspiAccessible object
798 * or -1 on exception.
801 atspi_accessible_get_id (AtspiAccessible *obj, GError **error)
805 g_return_val_if_fail (obj != NULL, -1);
807 if (!_atspi_dbus_get_property (obj, atspi_interface_application, "Id", error, "i", &ret))
813 /* Interface query methods */
816 _atspi_accessible_is_a (AtspiAccessible *accessible,
817 const char *interface_name)
821 if (accessible == NULL)
826 if (!_atspi_accessible_test_cache (accessible, ATSPI_CACHE_INTERFACES))
829 DBusMessageIter iter;
830 reply = _atspi_dbus_call_partial (accessible, atspi_interface_accessible,
831 "GetInterfaces", NULL, "");
832 _ATSPI_DBUS_CHECK_SIG (reply, "as", NULL, FALSE);
833 dbus_message_iter_init (reply, &iter);
834 _atspi_dbus_set_interfaces (accessible, &iter);
835 dbus_message_unref (reply);
836 _atspi_accessible_add_cache (accessible, ATSPI_CACHE_INTERFACES);
839 n = _atspi_get_iface_num (interface_name);
840 if (n == -1) return FALSE;
841 return (gboolean) ((accessible->interfaces & (1 << n))? TRUE: FALSE);
845 * atspi_accessible_is_action:
846 * @obj: a pointer to the #AtspiAccessible instance to query.
848 * Query whether the specified #AtspiAccessible implements the
849 * #AtspiAction interface.
851 * Returns: #TRUE if @obj implements the #AtspiAction interface,
855 atspi_accessible_is_action (AtspiAccessible *obj)
857 return _atspi_accessible_is_a (obj,
858 atspi_interface_action);
862 * atspi_accessible_is_application:
863 * @obj: a pointer to the #AtspiAccessible instance to query.
865 * Query whether the specified #AtspiAccessible implements the
866 * #AtspiApplication interface.
868 * Returns: #TRUE if @obj implements the #AtspiApplication interface,
872 atspi_accessible_is_application (AtspiAccessible *obj)
874 return _atspi_accessible_is_a (obj,
875 atspi_interface_application);
879 * atspi_accessible_is_collection:
880 * @obj: a pointer to the #AtspiAccessible instance to query.
882 * Query whether the specified #AtspiAccessible implements the
883 * #AtspiCollection interface.
885 * Returns: #TRUE if @obj implements the #AtspiCollection interface,
889 atspi_accessible_is_collection (AtspiAccessible *obj)
891 return _atspi_accessible_is_a (obj,
892 atspi_interface_collection);
896 * atspi_accessible_is_component:
897 * @obj: a pointer to the #AtspiAccessible instance to query.
899 * Query whether the specified #AtspiAccessible implements #AtspiComponent.
901 * Returns: #TRUE if @obj implements the #AtspiComponent interface,
905 atspi_accessible_is_component (AtspiAccessible *obj)
907 return _atspi_accessible_is_a (obj,
908 atspi_interface_component);
912 * atspi_accessible_is_document:
913 * @obj: a pointer to the #AtspiAccessible instance to query.
915 * Query whether the specified #AtspiAccessible implements the
916 * #AtspiDocument interface.
918 * Returns: #TRUE if @obj implements the #AtspiDocument interface,
922 atspi_accessible_is_document (AtspiAccessible *obj)
924 return _atspi_accessible_is_a (obj,
925 atspi_interface_document);
929 * atspi_accessible_is_editable_text:
930 * @obj: a pointer to the #AtspiAccessible instance to query.
932 * Query whether the specified #AtspiAccessible implements the
933 * #AtspiEditableText interface.
935 * Returns: #TRUE if @obj implements the #AtspiEditableText interface,
939 atspi_accessible_is_editable_text (AtspiAccessible *obj)
941 return _atspi_accessible_is_a (obj,
942 atspi_interface_editable_text);
946 * atspi_accessible_is_hypertext:
947 * @obj: a pointer to the #AtspiAccessible instance to query.
949 * Query whether the specified #AtspiAccessible implements the
950 * #AtspiHypertext interface.
952 * Returns: #TRUE if @obj implements the #AtspiHypertext interface,
956 atspi_accessible_is_hypertext (AtspiAccessible *obj)
958 return _atspi_accessible_is_a (obj,
959 atspi_interface_hypertext);
963 * atspi_accessible_is_hyperlink:
964 * @obj: a pointer to the #AtspiAccessible instance to query.
966 * Query whether the specified #AtspiAccessible implements the
967 * #AtspiHyperlink interface.
969 * Returns: #TRUE if @obj implements the #AtspiHypertext interface,
973 atspi_accessible_is_hyperlink (AtspiAccessible *obj)
975 return _atspi_accessible_is_a (obj,
976 atspi_interface_hyperlink);
980 * atspi_accessible_is_image:
981 * @obj: a pointer to the #AtspiAccessible instance to query.
983 * Query whether the specified #AtspiAccessible implements the
984 * #AtspiImage interface.
986 * Returns: #TRUE if @obj implements the #AtspiImage interface,
990 atspi_accessible_is_image (AtspiAccessible *obj)
992 return _atspi_accessible_is_a (obj,
993 atspi_interface_image);
997 * atspi_accessible_is_selection:
998 * @obj: a pointer to the #AtspiAccessible instance to query.
1000 * Query whether the specified #AtspiAccessible implements the
1001 * #AtspiSelection interface.
1003 * Returns: #TRUE if @obj implements the #AtspiSelection interface,
1007 atspi_accessible_is_selection (AtspiAccessible *obj)
1009 return _atspi_accessible_is_a (obj,
1010 atspi_interface_selection);
1014 * atspi_accessible_is_table:
1015 * @obj: a pointer to the #AtspiAccessible instance to query.
1017 * Query whether the specified #AtspiAccessible implements the
1018 * #AtspiTable interface.
1020 * Returns: #TRUE if @obj implements the #AtspiTable interface,
1024 atspi_accessible_is_table (AtspiAccessible *obj)
1026 return _atspi_accessible_is_a (obj,
1027 atspi_interface_table);
1031 * atspi_accessible_is_table_cell:
1032 * @obj: a pointer to the #AtspiAccessible instance to query.
1034 * Query whether the specified #AtspiAccessible implements the
1035 * #AtspiTableCell interface.
1037 * Returns: #TRUE if @obj implements the #AtspiTable interface,
1041 atspi_accessible_is_table_cell (AtspiAccessible *obj)
1043 return _atspi_accessible_is_a (obj,
1044 atspi_interface_table_cell);
1048 * atspi_accessible_is_streamable_content:
1049 * @obj: a pointer to the #AtspiAccessible instance to query.
1051 * Query whether the specified #AtspiAccessible implements the
1052 * #AtspiStreamableContent interface.
1054 * Returns: #TRUE if @obj implements the #AtspiStreamableContent interface,
1058 atspi_accessible_is_streamable_content (AtspiAccessible *obj)
1061 return _atspi_accessible_is_a (obj,
1062 atspi_interface_streamable_content);
1064 g_warning ("Streamable content not implemented");
1070 * atspi_accessible_is_text:
1071 * @obj: a pointer to the #AtspiAccessible instance to query.
1073 * Query whether the specified #AtspiAccessible implements the
1074 * #AtspiText interface.
1076 * Returns: #TRUE if @obj implements the #AtspiText interface,
1080 atspi_accessible_is_text (AtspiAccessible *obj)
1082 return _atspi_accessible_is_a (obj,
1083 atspi_interface_text);
1087 * atspi_accessible_is_value:
1088 * @obj: a pointer to the #AtspiAccessible instance to query.
1090 * Query whether the specified #AtspiAccessible implements the
1091 * #AtspiValue interface.
1093 * Returns: #TRUE if @obj implements the #AtspiValue interface,
1097 atspi_accessible_is_value (AtspiAccessible *obj)
1099 return _atspi_accessible_is_a (obj,
1100 atspi_interface_value);
1104 * atspi_accessible_get_action: (rename-to atspi_accessible_get_action_iface)
1105 * @obj: a pointer to the #AtspiAccessible instance to query.
1107 * Gets the #AtspiAction interface for an #AtspiAccessible.
1109 * Returns: (transfer full): a pointer to an #AtspiAction interface
1110 * instance, or NULL if @obj does not implement #AtspiAction.
1112 * Deprecated: 2.10: Use atspi_accessible_get_action_iface instead.
1115 atspi_accessible_get_action (AtspiAccessible *accessible)
1117 return (_atspi_accessible_is_a (accessible, atspi_interface_action) ?
1118 g_object_ref (ATSPI_ACTION (accessible)) : NULL);
1122 * atspi_accessible_get_action_iface:
1123 * @obj: a pointer to the #AtspiAccessible instance to query.
1125 * Gets the #AtspiAction interface for an #AtspiAccessible.
1127 * Returns: (transfer full): a pointer to an #AtspiAction interface
1128 * instance, or NULL if @obj does not implement #AtspiAction.
1131 atspi_accessible_get_action_iface (AtspiAccessible *accessible)
1133 return (_atspi_accessible_is_a (accessible, atspi_interface_action) ?
1134 g_object_ref (ATSPI_ACTION (accessible)) : NULL);
1138 * atspi_accessible_get_collection: (rename-to atspi_accessible_get_collection_iface)
1139 * @obj: a pointer to the #AtspiAccessible instance to query.
1141 * Gets the #AtspiCollection interface for an #AtspiAccessible.
1143 * Returns: (transfer full): a pointer to an #AtspiCollection interface
1144 * instance, or NULL if @obj does not implement #AtspiCollection.
1146 * Deprecated: 2.10: Use atspi_accessible_get_collection_iface instead.
1149 atspi_accessible_get_collection (AtspiAccessible *accessible)
1151 return (_atspi_accessible_is_a (accessible, atspi_interface_collection) ?
1152 g_object_ref (ATSPI_COLLECTION (accessible)) : NULL);
1156 * atspi_accessible_get_collection_iface:
1157 * @obj: a pointer to the #AtspiAccessible instance to query.
1159 * Gets the #AtspiCollection interface for an #AtspiAccessible.
1161 * Returns: (transfer full): a pointer to an #AtspiCollection interface
1162 * instance, or NULL if @obj does not implement #AtspiCollection.
1165 atspi_accessible_get_collection_iface (AtspiAccessible *accessible)
1167 return (_atspi_accessible_is_a (accessible, atspi_interface_collection) ?
1168 g_object_ref (ATSPI_COLLECTION (accessible)) : NULL);
1172 * atspi_accessible_get_component: (rename-to atspi_accessible_get_component_iface)
1173 * @obj: a pointer to the #AtspiAccessible instance to query.
1175 * Gets the #AtspiComponent interface for an #AtspiAccessible.
1177 * Returns: (transfer full): a pointer to an #AtspiComponent interface
1178 * instance, or NULL if @obj does not implement #AtspiComponent.
1180 * Deprecated: 2.10: Use atspi_accessible_get_component_iface instead.
1183 atspi_accessible_get_component (AtspiAccessible *obj)
1185 return (_atspi_accessible_is_a (obj, atspi_interface_component) ?
1186 g_object_ref (ATSPI_COMPONENT (obj)) : NULL);
1190 * atspi_accessible_get_component_iface:
1191 * @obj: a pointer to the #AtspiAccessible instance to query.
1193 * Gets the #AtspiComponent interface for an #AtspiAccessible.
1195 * Returns: (transfer full): a pointer to an #AtspiComponent interface
1196 * instance, or NULL if @obj does not implement #AtspiComponent.
1199 atspi_accessible_get_component_iface (AtspiAccessible *obj)
1201 return (_atspi_accessible_is_a (obj, atspi_interface_component) ?
1202 g_object_ref (ATSPI_COMPONENT (obj)) : NULL);
1206 * atspi_accessible_get_document: (rename-to atspi_accessible_get_document_iface)
1207 * @obj: a pointer to the #AtspiAccessible instance to query.
1209 * Gets the #AtspiDocument interface for an #AtspiAccessible.
1211 * Returns: (transfer full): a pointer to an #AtspiDocument interface
1212 * instance, or NULL if @obj does not implement #AtspiDocument.
1214 * Deprecated: 2.10: Use atspi_accessible_get_document_iface instead.
1217 atspi_accessible_get_document (AtspiAccessible *accessible)
1219 return (_atspi_accessible_is_a (accessible, atspi_interface_document) ?
1220 g_object_ref (ATSPI_DOCUMENT (accessible)) : NULL);
1224 * atspi_accessible_get_document_iface:
1225 * @obj: a pointer to the #AtspiAccessible instance to query.
1227 * Gets the #AtspiDocument interface for an #AtspiAccessible.
1229 * Returns: (transfer full): a pointer to an #AtspiDocument interface
1230 * instance, or NULL if @obj does not implement #AtspiDocument.
1233 atspi_accessible_get_document_iface (AtspiAccessible *accessible)
1235 return (_atspi_accessible_is_a (accessible, atspi_interface_document) ?
1236 g_object_ref (ATSPI_DOCUMENT (accessible)) : NULL);
1240 * atspi_accessible_get_editable_text: (rename-to atspi_accessible_get_editable_text_iface)
1241 * @obj: a pointer to the #AtspiAccessible instance to query.
1243 * Gets the #AtspiEditableText interface for an #AtspiAccessible.
1245 * Returns: (transfer full): a pointer to an #AtspiEditableText interface
1246 * instance, or NULL if @obj does not implement #AtspiEditableText.
1248 * Deprecated: 2.10: Use atspi_accessible_get_editable_text_iface instead.
1251 atspi_accessible_get_editable_text (AtspiAccessible *accessible)
1253 return (_atspi_accessible_is_a (accessible, atspi_interface_editable_text) ?
1254 g_object_ref (ATSPI_EDITABLE_TEXT (accessible)) : NULL);
1258 * atspi_accessible_get_editable_text_iface:
1259 * @obj: a pointer to the #AtspiAccessible instance to query.
1261 * Gets the #AtspiEditableText interface for an #AtspiAccessible.
1263 * Returns: (transfer full): a pointer to an #AtspiEditableText interface
1264 * instance, or NULL if @obj does not implement #AtspiEditableText.
1267 atspi_accessible_get_editable_text_iface (AtspiAccessible *accessible)
1269 return (_atspi_accessible_is_a (accessible, atspi_interface_editable_text) ?
1270 g_object_ref (ATSPI_EDITABLE_TEXT (accessible)) : NULL);
1274 * atspi_accessible_get_hyperlink:
1275 * @obj: a pointer to the #AtspiAccessible object on which to operate.
1277 * Gets the #AtspiHyperlink interface for an #AtspiAccessible.
1279 * Returns: (transfer full): the #AtspiHyperlink object associated with
1280 * the given #AtspiAccessible, or NULL if not supported.
1283 atspi_accessible_get_hyperlink (AtspiAccessible *accessible)
1285 return (_atspi_accessible_is_a (accessible, atspi_interface_hyperlink) ?
1286 _atspi_hyperlink_new (accessible->parent.app, accessible->parent.path) : NULL);
1290 * atspi_accessible_get_hypertext: (rename-to atspi_accessible_get_hypertext_iface)
1291 * @obj: a pointer to the #AtspiAccessible instance to query.
1293 * Gets the #AtspiHypertext interface for an #AtspiAccessible.
1295 * Returns: (transfer full): a pointer to an #AtspiHypertext interface
1296 * instance, or NULL if @obj does not implement #AtspiHypertext.
1298 * Deprecated: 2.10: Use atspi_accessible_get_hypertext_iface instead.
1301 atspi_accessible_get_hypertext (AtspiAccessible *accessible)
1303 return (_atspi_accessible_is_a (accessible, atspi_interface_hypertext) ?
1304 g_object_ref (ATSPI_HYPERTEXT (accessible)) : NULL);
1308 * atspi_accessible_get_hypertext_iface:
1309 * @obj: a pointer to the #AtspiAccessible instance to query.
1311 * Gets the #AtspiHypertext interface for an #AtspiAccessible.
1313 * Returns: (transfer full): a pointer to an #AtspiHypertext interface
1314 * instance, or NULL if @obj does not implement #AtspiHypertext.
1317 atspi_accessible_get_hypertext_iface (AtspiAccessible *accessible)
1319 return (_atspi_accessible_is_a (accessible, atspi_interface_hypertext) ?
1320 g_object_ref (ATSPI_HYPERTEXT (accessible)) : NULL);
1324 * atspi_accessible_get_image: (rename-to atspi_accessible_get_image_iface)
1325 * @obj: a pointer to the #AtspiAccessible instance to query.
1327 * Gets the #AtspiImage interface for an #AtspiAccessible.
1329 * Returns: (transfer full): a pointer to an #AtspiImage interface instance, or
1330 * NULL if @obj does not implement #AtspiImage.
1332 * Deprecated: 2.10: Use atspi_accessible_get_image_iface instead.
1335 atspi_accessible_get_image (AtspiAccessible *accessible)
1337 return (_atspi_accessible_is_a (accessible, atspi_interface_image) ?
1338 g_object_ref (ATSPI_IMAGE (accessible)) : NULL);
1342 * atspi_accessible_get_image_iface:
1343 * @obj: a pointer to the #AtspiAccessible instance to query.
1345 * Gets the #AtspiImage interface for an #AtspiAccessible.
1347 * Returns: (transfer full): a pointer to an #AtspiImage interface instance, or
1348 * NULL if @obj does not implement #AtspiImage.
1351 atspi_accessible_get_image_iface (AtspiAccessible *accessible)
1353 return (_atspi_accessible_is_a (accessible, atspi_interface_image) ?
1354 g_object_ref (ATSPI_IMAGE (accessible)) : NULL);
1358 * atspi_accessible_get_selection: (rename-to atspi_accessible_get_selection_iface)
1359 * @obj: a pointer to the #AtspiAccessible instance to query.
1361 * Gets the #AtspiSelection interface for an #AtspiAccessible.
1363 * Returns: (transfer full): a pointer to an #AtspiSelection interface
1364 * instance, or NULL if @obj does not implement #AtspiSelection.
1366 * Deprecated: 2.10: Use atspi_accessible_get_selection_iface instead.
1369 atspi_accessible_get_selection (AtspiAccessible *accessible)
1371 return (_atspi_accessible_is_a (accessible, atspi_interface_selection) ?
1372 g_object_ref (ATSPI_SELECTION (accessible)) : NULL);
1376 * atspi_accessible_get_selection_iface:
1377 * @obj: a pointer to the #AtspiAccessible instance to query.
1379 * Gets the #AtspiSelection interface for an #AtspiAccessible.
1381 * Returns: (transfer full): a pointer to an #AtspiSelection interface
1382 * instance, or NULL if @obj does not implement #AtspiSelection.
1385 atspi_accessible_get_selection_iface (AtspiAccessible *accessible)
1387 return (_atspi_accessible_is_a (accessible, atspi_interface_selection) ?
1388 g_object_ref (ATSPI_SELECTION (accessible)) : NULL);
1393 * atspi_accessible_get_streamable_content:
1394 * @obj: a pointer to the #AtspiAccessible instance to query.
1396 * Gets the #AtspiStreamableContent interface for an #AtspiAccessible.
1398 * Returns: (transfer full): a pointer to an #AtspiStreamableContent interface
1399 * instance, or NULL if @obj does not implement #AtspiStreamableContent.
1401 AtspiStreamableContent *
1402 atspi_accessible_get_streamable_content (AtspiAccessible *accessible)
1404 return (_atspi_accessible_is_a (accessible, atspi_interface_streamable_content) ?
1410 * atspi_accessible_get_table: (rename-to atspi_accessible_get_table_iface)
1411 * @obj: a pointer to the #AtspiAccessible instance to query.
1413 * Gets the #AtspiTable interface for an #AtspiAccessible.
1415 * Returns: (transfer full): a pointer to an #AtspiTable interface instance, or
1416 * NULL if @obj does not implement #AtspiTable.
1418 * Deprecated: 2.10: Use atspi_accessible_get_table_iface instead.
1421 atspi_accessible_get_table (AtspiAccessible *obj)
1423 return (_atspi_accessible_is_a (obj, atspi_interface_table) ?
1424 g_object_ref (ATSPI_TABLE (obj)) : NULL);
1428 * atspi_accessible_get_table_iface:
1429 * @obj: a pointer to the #AtspiAccessible instance to query.
1431 * Gets the #AtspiTable interface for an #AtspiAccessible.
1433 * Returns: (transfer full): a pointer to an #AtspiTable interface instance, or
1434 * NULL if @obj does not implement #AtspiTable.
1437 atspi_accessible_get_table_iface (AtspiAccessible *obj)
1439 return (_atspi_accessible_is_a (obj, atspi_interface_table) ?
1440 g_object_ref (ATSPI_TABLE (obj)) : NULL);
1444 * atspi_accessible_get_table_cell:
1445 * @obj: a pointer to the #AtspiAccessible instance to query.
1447 * Gets the #AtspiTableCell interface for an #AtspiAccessible.
1449 * Returns: (transfer full): a pointer to an #AtspiTableCell interface instance,
1450 * or NULL if @obj does not implement #AtspiTable.
1453 atspi_accessible_get_table_cell (AtspiAccessible *obj)
1455 return (_atspi_accessible_is_a (obj, atspi_interface_table_cell) ?
1456 g_object_ref (ATSPI_TABLE_CELL (obj)) : NULL);
1460 * atspi_accessible_get_text: (rename-to atspi_accessible_get_text_iface)
1461 * @obj: a pointer to the #AtspiAccessible instance to query.
1463 * Gets the #AtspiTable interface for an #AtspiAccessible.
1465 * Returns: (transfer full): a pointer to an #AtspiText interface instance, or
1466 * NULL if @obj does not implement #AtspiText.
1468 * Deprecated: 2.10: Use atspi_accessible_get_text_iface instead.
1471 atspi_accessible_get_text (AtspiAccessible *obj)
1473 return (_atspi_accessible_is_a (obj, atspi_interface_text) ?
1474 g_object_ref (ATSPI_TEXT (obj)) : NULL);
1478 * atspi_accessible_get_text_iface:
1479 * @obj: a pointer to the #AtspiAccessible instance to query.
1481 * Gets the #AtspiTable interface for an #AtspiAccessible.
1483 * Returns: (transfer full): a pointer to an #AtspiText interface instance, or
1484 * NULL if @obj does not implement #AtspiText.
1487 atspi_accessible_get_text_iface (AtspiAccessible *obj)
1489 return (_atspi_accessible_is_a (obj, atspi_interface_text) ?
1490 g_object_ref (ATSPI_TEXT (obj)) : NULL);
1494 * atspi_accessible_get_value: (rename-to atspi_accessible_get_value_iface)
1495 * @obj: a pointer to the #AtspiAccessible instance to query.
1497 * Gets the #AtspiTable interface for an #AtspiAccessible.
1499 * Returns: (transfer full): a pointer to an #AtspiValue interface instance, or
1500 * NULL if @obj does not implement #AtspiValue.
1502 * Deprecated: 2.10: Use atspi_accessible_get_value_iface instead.
1505 atspi_accessible_get_value (AtspiAccessible *accessible)
1507 return (_atspi_accessible_is_a (accessible, atspi_interface_value) ?
1508 g_object_ref (ATSPI_VALUE (accessible)) : NULL);
1512 * atspi_accessible_get_value_iface:
1513 * @obj: a pointer to the #AtspiAccessible instance to query.
1515 * Gets the #AtspiTable interface for an #AtspiAccessible.
1517 * Returns: (transfer full): a pointer to an #AtspiValue interface instance, or
1518 * NULL if @obj does not implement #AtspiValue.
1521 atspi_accessible_get_value_iface (AtspiAccessible *accessible)
1523 return (_atspi_accessible_is_a (accessible, atspi_interface_value) ?
1524 g_object_ref (ATSPI_VALUE (accessible)) : NULL);
1528 append_const_val (GArray *array, const gchar *val)
1530 gchar *dup = g_strdup (val);
1533 g_array_append_val (array, dup);
1537 * atspi_accessible_get_interfaces:
1538 * @obj: The #AtspiAccessible to query.
1540 * A set of pointers to all interfaces supported by an #AtspiAccessible.
1542 * Returns: (element-type gchar*) (transfer full): A #GArray of strings
1543 * describing the interfaces supported by the object. Interfaces are
1544 * denoted in short-hand (i.e. "Component", "Text" etc.).
1547 atspi_accessible_get_interfaces (AtspiAccessible *obj)
1549 GArray *ret = g_array_new (TRUE, TRUE, sizeof (gchar *));
1551 g_return_val_if_fail (obj != NULL, NULL);
1553 append_const_val (ret, "Accessible");
1554 if (atspi_accessible_is_action (obj))
1555 append_const_val (ret, "Action");
1556 if (atspi_accessible_is_collection (obj))
1557 append_const_val (ret, "Collection");
1558 if (atspi_accessible_is_component (obj))
1559 append_const_val (ret, "Component");
1560 if (atspi_accessible_is_document (obj))
1561 append_const_val (ret, "Document");
1562 if (atspi_accessible_is_editable_text (obj))
1563 append_const_val (ret, "EditableText");
1564 if (atspi_accessible_is_hypertext (obj))
1565 append_const_val (ret, "Hypertext");
1566 if (atspi_accessible_is_hyperlink (obj))
1567 append_const_val (ret, "Hyperlink");
1568 if (atspi_accessible_is_image (obj))
1569 append_const_val (ret, "Image");
1570 if (atspi_accessible_is_selection (obj))
1571 append_const_val (ret, "Selection");
1572 if (atspi_accessible_is_table (obj))
1573 append_const_val (ret, "Table");
1574 if (atspi_accessible_is_table_cell (obj))
1575 append_const_val (ret, "TableCell");
1576 if (atspi_accessible_is_text (obj))
1577 append_const_val (ret, "Text");
1578 if (atspi_accessible_is_value (obj))
1579 append_const_val (ret, "Value");
1585 _atspi_accessible_new (AtspiApplication *app, const gchar *path)
1587 AtspiAccessible *accessible;
1589 accessible = g_object_new (ATSPI_TYPE_ACCESSIBLE, NULL);
1590 g_return_val_if_fail (accessible != NULL, NULL);
1592 accessible->parent.app = g_object_ref (app);
1593 accessible->parent.path = g_strdup (path);
1599 * atspi_accessible_set_cache_mask:
1600 * @accessible: The #AtspiAccessible to operate on. Must be the desktop or
1601 * the root of an application.
1602 * @mask: An #AtspiCache specifying a bit mask of the types of data to cache.
1604 * Sets the type of data to cache for accessibles.
1605 * If this is not set for an application or is reset to ATSPI_CACHE_UNDEFINED,
1606 * then the desktop's cache flag will be used.
1607 * If the desktop's cache flag is also undefined, then all possible data will
1609 * This function is intended to work around bugs in toolkits where the proper
1610 * events are not raised / to aid in testing for such bugs.
1613 atspi_accessible_set_cache_mask (AtspiAccessible *accessible, AtspiCache mask)
1615 g_return_if_fail (accessible != NULL);
1616 g_return_if_fail (accessible->parent.app != NULL);
1617 g_return_if_fail (accessible == accessible->parent.app->root);
1618 accessible->parent.app->cache = mask;
1619 enable_caching = TRUE;
1623 * atspi_accessible_clear_cache:
1624 * @obj: The #AtspiAccessible whose cache to clear.
1626 * Clears the cached information for the given accessible and all of its
1630 atspi_accessible_clear_cache (AtspiAccessible *obj)
1636 obj->cached_properties = ATSPI_CACHE_NONE;
1637 for (i = 0; i < obj->children->len; i++)
1638 atspi_accessible_clear_cache (g_ptr_array_index (obj->children, i));
1643 * atspi_accessible_get_process_id:
1644 * @accessible: The #AtspiAccessible to query.
1645 * @error: a pointer to a %NULL #GError pointer
1647 * Returns the process id associated with the given accessible. Mainly
1648 * added for debugging; it is a shortcut to explicitly querying the
1649 * accessible's app->bus_name and then calling GetConnectionUnixProcessID.
1651 * Returns: The process ID or undetermined value if @error is set.
1654 atspi_accessible_get_process_id (AtspiAccessible *accessible, GError **error)
1656 DBusMessage *message, *reply;
1657 DBusConnection *bus = _atspi_bus ();
1658 dbus_uint32_t pid = -1;
1661 if (!accessible->parent.app || !accessible->parent.app->bus_name)
1663 g_set_error_literal(error, ATSPI_ERROR, ATSPI_ERROR_IPC, "Process is defunct");
1667 message = dbus_message_new_method_call ("org.freedesktop.DBus",
1668 "/org/freedesktop/DBus",
1669 "org.freedesktop.DBus",
1670 "GetConnectionUnixProcessID");
1671 dbus_message_append_args (message, DBUS_TYPE_STRING,
1672 &accessible->parent.app->bus_name,
1674 dbus_error_init (&d_error);
1675 reply = dbus_connection_send_with_reply_and_block (bus, message, -1, &d_error);
1676 dbus_message_unref (message);
1679 if (!strcmp (dbus_message_get_signature (reply), "u"))
1680 dbus_message_get_args (reply, NULL, DBUS_TYPE_UINT32, &pid, DBUS_TYPE_INVALID);
1681 dbus_message_unref (reply);
1683 if (dbus_error_is_set (&d_error))
1685 g_set_error_literal(error, ATSPI_ERROR, ATSPI_ERROR_IPC, "Process is defunct");
1686 dbus_error_free (&d_error);
1692 _atspi_accessible_get_cache_mask (AtspiAccessible *accessible)
1696 if (!accessible->parent.app)
1697 return ATSPI_CACHE_NONE;
1699 mask = accessible->parent.app->cache;
1700 if (mask == ATSPI_CACHE_UNDEFINED &&
1701 accessible->parent.app->root &&
1702 accessible->parent.app->root->accessible_parent)
1704 AtspiAccessible *desktop = atspi_get_desktop (0);
1705 mask = desktop->parent.app->cache;
1706 g_object_unref (desktop);
1709 if (mask == ATSPI_CACHE_UNDEFINED)
1710 mask = ATSPI_CACHE_DEFAULT;
1716 _atspi_accessible_test_cache (AtspiAccessible *accessible, AtspiCache flag)
1718 AtspiCache mask = _atspi_accessible_get_cache_mask (accessible);
1719 AtspiCache result = accessible->cached_properties & mask & flag;
1720 if (accessible->states && atspi_state_set_contains (accessible->states, ATSPI_STATE_TRANSIENT))
1722 return (result != 0 && (atspi_main_loop || enable_caching ||
1723 flag == ATSPI_CACHE_INTERFACES) &&
1728 _atspi_accessible_add_cache (AtspiAccessible *accessible, AtspiCache flag)
1730 AtspiCache mask = _atspi_accessible_get_cache_mask (accessible);
1732 accessible->cached_properties |= flag & mask;
1736 * atspi_accessible_get_locale:
1737 * @accessible: an #AtspiAccessible
1739 * Gets a UTF-8 string indicating the POSIX-style LC_MESSAGES locale
1744 * Returns: a UTF-8 string indicating the POSIX-style LC_MESSAGES
1745 * locale of @accessible.
1748 atspi_accessible_get_object_locale (AtspiAccessible *accessible, GError **error)
1752 g_return_val_if_fail (accessible != NULL, NULL);
1754 locale = g_object_get_qdata (G_OBJECT (accessible), quark_locale);
1757 if (!_atspi_dbus_get_property (accessible, atspi_interface_accessible,
1758 "Locale", error, "s", &locale))
1761 g_object_set_qdata_full (G_OBJECT (accessible), quark_locale, locale,
1768 free_value (gpointer data)
1770 GValue *value = data;
1772 g_value_unset (value);
1777 _atspi_accessible_ref_cache (AtspiAccessible *accessible)
1779 AtspiAccessiblePrivate *priv = accessible->priv;
1781 priv->cache_ref_count++;
1783 return g_hash_table_ref (priv->cache);
1784 priv->cache = g_hash_table_new_full (g_str_hash, g_str_equal, g_free,
1790 _atspi_accessible_unref_cache (AtspiAccessible *accessible)
1792 AtspiAccessiblePrivate *priv = accessible->priv;
1796 g_hash_table_unref (priv->cache);
1797 if (--priv->cache_ref_count == 0)