2 * AT-SPI - Assistive Technology Service Provider Interface
3 * (Gnome Accessibility Project; http://developer.gnome.org/projects/gap)
5 * Copyright 2001, 2002 Sun Microsystems Inc.,
6 * Copyright 2001, 2002 Ximian, Inc.
7 * Copyright 2010, 2011 Novell, Inc.
9 * This library is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Library General Public
11 * License as published by the Free Software Foundation; either
12 * version 2 of the License, or (at your option) any later version.
14 * This library is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * Library General Public License for more details.
19 * You should have received a copy of the GNU Library General Public
20 * License along with this library; if not, write to the
21 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
22 * Boston, MA 02111-1307, USA.
25 #include "atspi-private.h"
26 #include "atspi-accessible-private.h"
29 static gboolean enable_caching = FALSE;
30 static guint quark_locale;
33 atspi_action_interface_init (AtspiAction *action)
38 atspi_collection_interface_init (AtspiCollection *component)
43 atspi_component_interface_init (AtspiComponent *component)
48 atspi_document_interface_init (AtspiDocument *document)
53 atspi_editable_text_interface_init (AtspiEditableText *editable_text)
58 atspi_hypertext_interface_init (AtspiHypertext *hypertext)
63 atspi_image_interface_init (AtspiImage *image)
68 atspi_selection_interface_init (AtspiSelection *selection)
73 atspi_table_interface_init (AtspiTable *table)
78 atspi_table_cell_interface_init (AtspiTableCell *cell)
83 atspi_text_interface_init (AtspiText *text)
88 atspi_value_interface_init (AtspiValue *value)
92 G_DEFINE_TYPE_WITH_CODE (AtspiAccessible, atspi_accessible, ATSPI_TYPE_OBJECT,
93 G_ADD_PRIVATE (AtspiAccessible)
94 G_IMPLEMENT_INTERFACE (ATSPI_TYPE_ACTION, atspi_action_interface_init)
95 G_IMPLEMENT_INTERFACE (ATSPI_TYPE_COLLECTION, atspi_collection_interface_init)
96 G_IMPLEMENT_INTERFACE (ATSPI_TYPE_COMPONENT, atspi_component_interface_init)
97 G_IMPLEMENT_INTERFACE (ATSPI_TYPE_DOCUMENT, atspi_document_interface_init)
98 G_IMPLEMENT_INTERFACE (ATSPI_TYPE_EDITABLE_TEXT, atspi_editable_text_interface_init)
99 G_IMPLEMENT_INTERFACE (ATSPI_TYPE_HYPERTEXT, atspi_hypertext_interface_init)
100 G_IMPLEMENT_INTERFACE (ATSPI_TYPE_IMAGE, atspi_image_interface_init)
101 G_IMPLEMENT_INTERFACE (ATSPI_TYPE_SELECTION, atspi_selection_interface_init)
102 G_IMPLEMENT_INTERFACE (ATSPI_TYPE_TABLE, atspi_table_interface_init)
103 G_IMPLEMENT_INTERFACE (ATSPI_TYPE_TABLE_CELL, atspi_table_cell_interface_init)
104 G_IMPLEMENT_INTERFACE (ATSPI_TYPE_TEXT, atspi_text_interface_init)
105 G_IMPLEMENT_INTERFACE (ATSPI_TYPE_VALUE, atspi_value_interface_init))
107 #ifdef DEBUG_REF_COUNTS
108 static gint accessible_count = 0;
112 atspi_accessible_init (AtspiAccessible *accessible)
114 #ifdef DEBUG_REF_COUNTS
116 g_hash_table_insert (_atspi_get_live_refs (), accessible, NULL);
117 g_print("at-spi: init: %d objects\n", accessible_count);
120 accessible->priv = atspi_accessible_get_instance_private (accessible);
124 atspi_accessible_dispose (GObject *object)
126 AtspiAccessible *accessible = ATSPI_ACCESSIBLE (object);
128 AtspiAccessible *parent;
132 /* TODO: Only fire if object not already marked defunct */
133 memset (&e, 0, sizeof (e));
134 e.type = "object:state-changed:defunct";
135 e.source = accessible;
138 _atspi_send_event (&e);
140 if (accessible->states)
142 g_object_unref (accessible->states);
143 accessible->states = NULL;
146 parent = accessible->accessible_parent;
147 if (parent && parent->children)
149 GList*ls = g_list_find (parent->children, accessible);
152 gboolean replace = (ls == parent->children);
153 ls = g_list_remove (ls, accessible);
155 parent->children = ls;
156 g_object_unref (object);
162 g_object_unref (parent);
163 accessible->accessible_parent = NULL;
166 children = accessible->children;
167 accessible->children = NULL;
168 for (l = children; l; l = l->next)
170 AtspiAccessible *child = l->data;
171 if (child && child->accessible_parent == accessible)
173 g_object_unref (accessible);
174 child->accessible_parent = NULL;
176 g_object_unref (child);
178 g_list_free (children);
180 G_OBJECT_CLASS (atspi_accessible_parent_class) ->dispose (object);
184 atspi_accessible_finalize (GObject *object)
186 AtspiAccessible *accessible = ATSPI_ACCESSIBLE (object);
188 g_free (accessible->description);
189 g_free (accessible->name);
190 if (accessible->attributes)
191 g_hash_table_unref (accessible->attributes);
193 if (accessible->priv->cache)
194 g_hash_table_destroy (accessible->priv->cache);
196 #ifdef DEBUG_REF_COUNTS
198 g_hash_table_remove (_atspi_get_live_refs (), accessible);
199 g_print ("at-spi: finalize: %d objects\n", accessible_count);
202 G_OBJECT_CLASS (atspi_accessible_parent_class)
207 atspi_accessible_class_init (AtspiAccessibleClass *klass)
209 GObjectClass *object_class = G_OBJECT_CLASS (klass);
211 object_class->dispose = atspi_accessible_dispose;
212 object_class->finalize = atspi_accessible_finalize;
214 quark_locale = g_quark_from_string ("accessible-locale");
218 * atspi_accessible_get_name:
219 * @obj: a pointer to the #AtspiAccessible object on which to operate.
221 * Gets the name of an #AtspiAccessible object.
223 * Returns: a UTF-8 string indicating the name of the #AtspiAccessible object
224 * or NULL on exception.
227 atspi_accessible_get_name (AtspiAccessible *obj, GError **error)
229 g_return_val_if_fail (obj != NULL, g_strdup (""));
230 if (!_atspi_accessible_test_cache (obj, ATSPI_CACHE_NAME))
232 if (!_atspi_dbus_get_property (obj, atspi_interface_accessible, "Name", error,
234 return g_strdup ("");
235 _atspi_accessible_add_cache (obj, ATSPI_CACHE_NAME);
237 return g_strdup (obj->name);
241 * atspi_accessible_get_path:
242 * @obj: a pointer to the #AtspiAccessible object on which to operate.
244 * Gets the path, uniquely identifying object.
246 * Returns: a UTF-8 string describing the #AtspiAccessible object
247 * or empty string on exception or NULL object passed.
250 atspi_accessible_get_path(AtspiAccessible *obj, GError **error)
252 static const char *prefix = "/org/a11y/atspi/accessible/";
253 static int prefix_len = 27;
257 AtspiObject *o = ATSPI_OBJECT (obj);
260 if (strncmp(o->path, prefix, prefix_len) == 0)
261 return g_strdup(o->path + prefix_len);
262 return g_strdup (o->path);
266 * atspi_accessible_get_description:
267 * @obj: a pointer to the #AtspiAccessible object on which to operate.
269 * Gets the description of an #AtspiAccessible object.
271 * Returns: a UTF-8 string describing the #AtspiAccessible object
272 * or NULL on exception.
275 atspi_accessible_get_description (AtspiAccessible *obj, GError **error)
277 g_return_val_if_fail (obj != NULL, g_strdup (""));
279 if (!_atspi_accessible_test_cache (obj, ATSPI_CACHE_DESCRIPTION))
281 if (!_atspi_dbus_get_property (obj, atspi_interface_accessible,
282 "Description", error, "s",
284 return g_strdup ("");
285 _atspi_accessible_add_cache (obj, ATSPI_CACHE_DESCRIPTION);
287 return g_strdup (obj->description);
290 const char *str_parent = "Parent";
293 * atspi_accessible_get_parent:
294 * @obj: a pointer to the #AtspiAccessible object to query.
296 * Gets an #AtspiAccessible object's parent container.
298 * Returns: (nullable) (transfer full): a pointer to the
299 * #AtspiAccessible object which contains the given
300 * #AtspiAccessible instance, or NULL if the @obj has no
305 atspi_accessible_get_parent (AtspiAccessible *obj, GError **error)
307 g_return_val_if_fail (obj != NULL, NULL);
309 if (obj->parent.app &&
310 !_atspi_accessible_test_cache (obj, ATSPI_CACHE_PARENT))
312 DBusMessage *message, *reply;
313 DBusMessageIter iter, iter_variant;
314 message = dbus_message_new_method_call (obj->parent.app->bus_name,
316 DBUS_INTERFACE_PROPERTIES, "Get");
319 dbus_message_append_args (message, DBUS_TYPE_STRING, &atspi_interface_accessible,
320 DBUS_TYPE_STRING, &str_parent,
322 reply = _atspi_dbus_send_with_reply_and_block (message, error);
325 if (strcmp (dbus_message_get_signature (reply), "v") != 0)
327 dbus_message_unref (reply);
330 dbus_message_iter_init (reply, &iter);
331 dbus_message_iter_recurse (&iter, &iter_variant);
332 obj->accessible_parent = _atspi_dbus_return_accessible_from_iter (&iter_variant);
333 dbus_message_unref (reply);
334 _atspi_accessible_add_cache (obj, ATSPI_CACHE_PARENT);
336 if (!obj->accessible_parent)
338 return g_object_ref (obj->accessible_parent);
342 * atspi_accessible_get_child_count:
343 * @obj: a pointer to the #AtspiAccessible object on which to operate.
345 * Gets the number of children contained by an #AtspiAccessible object.
347 * Returns: a #long indicating the number of #AtspiAccessible children
348 * contained by an #AtspiAccessible object or -1 on exception.
352 atspi_accessible_get_child_count (AtspiAccessible *obj, GError **error)
354 g_return_val_if_fail (obj != NULL, -1);
356 if (!_atspi_accessible_test_cache (obj, ATSPI_CACHE_CHILDREN))
359 if (!_atspi_dbus_get_property (obj, atspi_interface_accessible,
360 "ChildCount", error, "i", &ret))
365 return g_list_length (obj->children);
369 * atspi_accessible_get_child_at_index:
370 * @obj: a pointer to the #AtspiAccessible object on which to operate.
371 * @child_index: a #long indicating which child is specified.
373 * Gets the #AtspiAccessible child of an #AtspiAccessible object at a given index.
375 * Returns: (transfer full): a pointer to the #AtspiAccessible child object at
376 * index @child_index or NULL on exception.
379 atspi_accessible_get_child_at_index (AtspiAccessible *obj,
383 AtspiAccessible *child;
385 g_return_val_if_fail (obj != NULL, NULL);
387 if (!_atspi_accessible_test_cache (obj, ATSPI_CACHE_CHILDREN))
390 reply = _atspi_dbus_call_partial (obj, atspi_interface_accessible,
391 "GetChildAtIndex", error, "i",
393 return _atspi_dbus_return_accessible_from_message (reply);
396 child = g_list_nth_data (obj->children, child_index);
399 return g_object_ref (child);
403 * atspi_accessible_get_index_in_parent:
404 * @obj: a pointer to the #AtspiAccessible object on which to operate.
406 * Gets the index of an #AtspiAccessible object within its parent's
407 * #AtspiAccessible children list.
409 * Returns: a #glong indicating the index of the #AtspiAccessible object
411 * or -1 if @obj has no containing parent or on exception.
414 atspi_accessible_get_index_in_parent (AtspiAccessible *obj, GError **error)
419 g_return_val_if_fail (obj != NULL, -1);
420 if (_atspi_accessible_test_cache (obj, ATSPI_CACHE_PARENT) &&
421 !obj->accessible_parent)
423 if (!obj->accessible_parent ||
424 !_atspi_accessible_test_cache (obj->accessible_parent,
425 ATSPI_CACHE_CHILDREN))
427 dbus_int32_t ret = -1;
428 _atspi_dbus_call (obj, atspi_interface_accessible,
429 "GetIndexInParent", NULL, "=>i", &ret);
433 l = obj->accessible_parent->children;
436 if (l->data == obj) return i;
447 } Accessibility_Relation;
450 * atspi_accessible_get_relation_set:
451 * @obj: a pointer to the #AtspiAccessible object on which to operate.
453 * Gets the set of #AtspiRelation objects which describes this #AtspiAccessible object's
454 * relationships with other #AtspiAccessible objects.
456 * Returns: (element-type AtspiRelation*) (transfer full): a #GArray of
457 * #AtspiRelation pointers or NULL on exception.
460 atspi_accessible_get_relation_set (AtspiAccessible *obj, GError **error)
463 DBusMessageIter iter, iter_array;
466 g_return_val_if_fail (obj != NULL, NULL);
468 reply = _atspi_dbus_call_partial (obj, atspi_interface_accessible, "GetRelationSet", error, "");
471 _ATSPI_DBUS_CHECK_SIG (reply, "a(ua(so))", error, NULL);
473 ret = g_array_new (TRUE, TRUE, sizeof (AtspiRelation *));
474 dbus_message_iter_init (reply, &iter);
475 dbus_message_iter_recurse (&iter, &iter_array);
476 while (dbus_message_iter_get_arg_type (&iter_array) != DBUS_TYPE_INVALID)
478 AtspiRelation *relation;
479 relation = _atspi_relation_new_from_iter (&iter_array);
480 ret = g_array_append_val (ret, relation);
481 dbus_message_iter_next (&iter_array);
483 dbus_message_unref (reply);
488 * atspi_accessible_get_role:
489 * @obj: a pointer to the #AtspiAccessible object on which to operate.
491 * Gets the UI role played by an #AtspiAccessible object.
492 * This role's name can be obtained via atspi_accessible_get_role_name ().
494 * Returns: the #AtspiRole of an #AtspiAccessible object.
498 atspi_accessible_get_role (AtspiAccessible *obj, GError **error)
500 g_return_val_if_fail (obj != NULL, ATSPI_ROLE_INVALID);
502 if (!_atspi_accessible_test_cache (obj, ATSPI_CACHE_ROLE))
505 /* TODO: Make this a property */
506 if (_atspi_dbus_call (obj, atspi_interface_accessible, "GetRole", error, "=>u", &role))
509 _atspi_accessible_add_cache (obj, ATSPI_CACHE_ROLE);
516 * atspi_accessible_get_role_name:
517 * @obj: a pointer to the #AtspiAccessible object on which to operate.
519 * Gets a UTF-8 string corresponding to the name of the role played by an object.
520 * This method will return useful values for roles that fall outside the
521 * enumeration used in atspi_accessible_get_role ().
523 * Returns: a UTF-8 string specifying the type of UI role played by an
524 * #AtspiAccessible object.
528 atspi_accessible_get_role_name (AtspiAccessible *obj, GError **error)
530 gchar *retval = NULL;
533 g_return_val_if_fail (obj != NULL, NULL);
535 role = atspi_accessible_get_role (obj, error);
536 if (role >= 0 && role < ATSPI_ROLE_COUNT && role != ATSPI_ROLE_EXTENDED)
537 return atspi_role_get_name (role);
539 _atspi_dbus_call (obj, atspi_interface_accessible, "GetRoleName", error, "=>s", &retval);
542 retval = g_strdup ("");
548 * atspi_accessible_get_localized_role_name:
549 * @obj: a pointer to the #AtspiAccessible object on which to operate.
551 * Gets a UTF-8 string corresponding to the name of the role played by an
552 * object, translated to the current locale.
553 * This method will return useful values for roles that fall outside the
554 * enumeration used in atspi_accessible_getRole ().
556 * Returns: a localized, UTF-8 string specifying the type of UI role played
557 * by an #AtspiAccessible object.
561 atspi_accessible_get_localized_role_name (AtspiAccessible *obj, GError **error)
565 g_return_val_if_fail (obj != NULL, NULL);
567 _atspi_dbus_call (obj, atspi_interface_accessible, "GetLocalizedRoleName", error, "=>s", &retval);
570 return g_strdup ("");
575 static AtspiStateSet *
578 AtspiStateSet *set = atspi_state_set_new (NULL);
579 atspi_state_set_add (set, ATSPI_STATE_DEFUNCT);
584 * atspi_accessible_get_state_set:
585 * @obj: a pointer to the #AtspiAccessible object on which to operate.
587 * Gets the states currently held by an object.
589 * Returns: (transfer full): a pointer to an #AtspiStateSet representing an
590 * object's current state set.
593 atspi_accessible_get_state_set (AtspiAccessible *obj)
595 /* TODO: Should take a GError **, but would be an API break */
596 if (!obj->parent.app || !obj->parent.app->bus)
597 return defunct_set ();
599 if (!_atspi_accessible_test_cache (obj, ATSPI_CACHE_STATES))
602 DBusMessageIter iter;
603 reply = _atspi_dbus_call_partial (obj, atspi_interface_accessible,
604 "GetState", NULL, "");
605 _ATSPI_DBUS_CHECK_SIG (reply, "au", NULL, defunct_set ());
606 dbus_message_iter_init (reply, &iter);
607 _atspi_dbus_set_state (obj, &iter);
608 dbus_message_unref (reply);
609 _atspi_accessible_add_cache (obj, ATSPI_CACHE_STATES);
611 return g_object_ref (obj->states);
615 * atspi_accessible_get_attributes:
616 * @obj: The #AtspiAccessible being queried.
618 * Gets the #AttributeSet representing any assigned
619 * name-value pair attributes or annotations for this object.
620 * For typographic, textual, or textually-semantic attributes, see
621 * atspi_text_get_attributes instead.
623 * Returns: (element-type gchar* gchar*) (transfer full): The name-value-pair
624 * attributes assigned to this object.
627 atspi_accessible_get_attributes (AtspiAccessible *obj, GError **error)
629 DBusMessage *message;
631 g_return_val_if_fail (obj != NULL, NULL);
633 if (obj->priv->cache)
635 GValue *val = g_hash_table_lookup (obj->priv->cache, "Attributes");
637 return g_value_dup_boxed (val);
640 if (!_atspi_accessible_test_cache (obj, ATSPI_CACHE_ATTRIBUTES))
642 message = _atspi_dbus_call_partial (obj, atspi_interface_accessible,
643 "GetAttributes", error, "");
644 obj->attributes = _atspi_dbus_return_hash_from_message (message);
645 _atspi_accessible_add_cache (obj, ATSPI_CACHE_ATTRIBUTES);
648 if (!obj->attributes)
650 return g_hash_table_ref (obj->attributes);
654 add_to_attribute_array (gpointer key, gpointer value, gpointer data)
656 GArray **array = (GArray **)data;
657 gchar *str = g_strconcat (key, ":", value, NULL);
658 *array = g_array_append_val (*array, str);
662 * atspi_accessible_get_attributes_as_array:
663 * @obj: The #AtspiAccessible being queried.
665 * Gets a #GArray representing any assigned
666 * name-value pair attributes or annotations for this object.
667 * For typographic, textual, or textually-semantic attributes, see
668 * atspi_text_get_attributes_as_array instead.
670 * Returns: (element-type gchar*) (transfer full): The name-value-pair
671 * attributes assigned to this object.
674 atspi_accessible_get_attributes_as_array (AtspiAccessible *obj, GError **error)
676 DBusMessage *message;
678 g_return_val_if_fail (obj != NULL, NULL);
680 if (obj->priv->cache)
682 GValue *val = g_hash_table_lookup (obj->priv->cache, "Attributes");
685 GArray *array = g_array_new (TRUE, TRUE, sizeof (gchar *));
686 GHashTable *attributes = g_value_get_boxed (val);
687 g_hash_table_foreach (attributes, add_to_attribute_array, &array);
692 message = _atspi_dbus_call_partial (obj, atspi_interface_accessible, "GetAttributes", error, "");
693 return _atspi_dbus_return_attribute_array_from_message (message);
697 * atspi_accessible_get_application:
698 * @obj: The #AtspiAccessible being queried.
700 * Gets the containing #AtspiApplication for an object.
702 * Returns: (transfer full): the containing #AtspiApplication instance for
706 atspi_accessible_get_application (AtspiAccessible *obj, GError **error)
708 AtspiAccessible *parent;
713 parent = atspi_accessible_get_parent (obj, NULL);
714 if (!parent && obj->parent.app &&
715 atspi_accessible_get_role (obj, NULL) != ATSPI_ROLE_APPLICATION)
717 AtspiAccessible *root = g_object_ref (obj->parent.app->root);
720 g_object_unref (obj);
721 if (atspi_accessible_get_role (root, NULL) == ATSPI_ROLE_DESKTOP_FRAME)
723 g_object_unref (root);
729 if (!parent || parent == obj ||
730 atspi_accessible_get_role (parent, NULL) == ATSPI_ROLE_DESKTOP_FRAME)
733 g_object_unref (parent);
736 g_object_unref (obj);
741 /* Application-specific methods */
744 * atspi_accessible_get_toolkit_name:
745 * @obj: a pointer to the #AtspiAccessible object on which to operate.
747 * Gets the toolkit name for an #AtspiAccessible object.
748 * Only works on application root objects.
750 * Returns: a UTF-8 string indicating the toolkit name for the #AtspiAccessible object or NULL on exception.
753 atspi_accessible_get_toolkit_name (AtspiAccessible *obj, GError **error)
755 g_return_val_if_fail (obj != NULL, NULL);
757 if (!obj->parent.app)
760 if (!obj->parent.app->toolkit_name)
761 _atspi_dbus_get_property (obj, atspi_interface_application, "ToolkitName",
762 error, "s", &obj->parent.app->toolkit_name);
764 return g_strdup (obj->parent.app->toolkit_name);
768 * atspi_accessible_get_toolkit_version:
769 * @obj: a pointer to the #AtspiAccessible object on which to operate.
771 * Gets the toolkit version for an #AtspiAccessible object.
772 * Only works on application root objects.
774 * Returns: a UTF-8 string indicating the toolkit version for the #AtspiAccessible object or NULL on exception.
777 atspi_accessible_get_toolkit_version (AtspiAccessible *obj, GError **error)
779 g_return_val_if_fail (obj != NULL, NULL);
781 if (!obj->parent.app)
784 if (!obj->parent.app->toolkit_version)
785 _atspi_dbus_get_property (obj, atspi_interface_application, "Version",
786 error, "s", &obj->parent.app->toolkit_version);
788 return g_strdup (obj->parent.app->toolkit_version);
792 * atspi_accessible_get_atspi_version:
793 * @obj: a pointer to the #AtspiAccessible object on which to operate.
795 * Gets the AT-SPI IPC specification version supported by the application
796 * pointed to by the #AtspiAccessible object.
797 * Only works on application root objects.
799 * Returns: a UTF-8 string indicating the AT-SPI version for the #AtspiAccessible object or NULL on exception.
802 atspi_accessible_get_atspi_version (AtspiAccessible *obj, GError **error)
804 g_return_val_if_fail (obj != NULL, NULL);
806 if (!obj->parent.app)
809 if (!obj->parent.app->atspi_version)
810 _atspi_dbus_get_property (obj, atspi_interface_application, "AtspiVersion",
811 error, "s", &obj->parent.app->atspi_version);
813 return g_strdup (obj->parent.app->atspi_version);
817 * atspi_accessible_get_id:
818 * @obj: a pointer to the #AtspiAccessible object on which to operate.
820 * Gets the application id for a #AtspiAccessible object.
821 * Only works on application root objects.
823 * Returns: a positive #gint indicating the id for the #AtspiAccessible object
824 * or -1 on exception.
827 atspi_accessible_get_id (AtspiAccessible *obj, GError **error)
831 g_return_val_if_fail (obj != NULL, -1);
833 if (!_atspi_dbus_get_property (obj, atspi_interface_application, "Id", error, "i", &ret))
839 /* Interface query methods */
842 _atspi_accessible_is_a (AtspiAccessible *accessible,
843 const char *interface_name)
847 if (accessible == NULL)
852 if (!_atspi_accessible_test_cache (accessible, ATSPI_CACHE_INTERFACES))
855 DBusMessageIter iter;
856 reply = _atspi_dbus_call_partial (accessible, atspi_interface_accessible,
857 "GetInterfaces", NULL, "");
858 _ATSPI_DBUS_CHECK_SIG (reply, "as", NULL, FALSE);
859 dbus_message_iter_init (reply, &iter);
860 _atspi_dbus_set_interfaces (accessible, &iter);
861 dbus_message_unref (reply);
862 _atspi_accessible_add_cache (accessible, ATSPI_CACHE_INTERFACES);
865 n = _atspi_get_iface_num (interface_name);
866 if (n == -1) return FALSE;
867 return (gboolean) ((accessible->interfaces & (1 << n))? TRUE: FALSE);
871 * atspi_accessible_is_action:
872 * @obj: a pointer to the #AtspiAccessible instance to query.
874 * Query whether the specified #AtspiAccessible implements the
875 * #AtspiAction interface.
877 * Returns: #TRUE if @obj implements the #AtspiAction interface,
881 atspi_accessible_is_action (AtspiAccessible *obj)
883 return _atspi_accessible_is_a (obj,
884 atspi_interface_action);
888 * atspi_accessible_is_application:
889 * @obj: a pointer to the #AtspiAccessible instance to query.
891 * Query whether the specified #AtspiAccessible implements the
892 * #AtspiApplication interface.
894 * Returns: #TRUE if @obj implements the #AtspiApplication interface,
898 atspi_accessible_is_application (AtspiAccessible *obj)
900 return _atspi_accessible_is_a (obj,
901 atspi_interface_application);
905 * atspi_accessible_is_collection:
906 * @obj: a pointer to the #AtspiAccessible instance to query.
908 * Query whether the specified #AtspiAccessible implements the
909 * #AtspiCollection interface.
911 * Returns: #TRUE if @obj implements the #AtspiCollection interface,
915 atspi_accessible_is_collection (AtspiAccessible *obj)
917 return _atspi_accessible_is_a (obj,
918 atspi_interface_collection);
922 * atspi_accessible_is_component:
923 * @obj: a pointer to the #AtspiAccessible instance to query.
925 * Query whether the specified #AtspiAccessible implements #AtspiComponent.
927 * Returns: #TRUE if @obj implements the #AtspiComponent interface,
931 atspi_accessible_is_component (AtspiAccessible *obj)
933 return _atspi_accessible_is_a (obj,
934 atspi_interface_component);
938 * atspi_accessible_is_document:
939 * @obj: a pointer to the #AtspiAccessible instance to query.
941 * Query whether the specified #AtspiAccessible implements the
942 * #AtspiDocument interface.
944 * Returns: #TRUE if @obj implements the #AtspiDocument interface,
948 atspi_accessible_is_document (AtspiAccessible *obj)
950 return _atspi_accessible_is_a (obj,
951 atspi_interface_document);
955 * atspi_accessible_is_editable_text:
956 * @obj: a pointer to the #AtspiAccessible instance to query.
958 * Query whether the specified #AtspiAccessible implements the
959 * #AtspiEditableText interface.
961 * Returns: #TRUE if @obj implements the #AtspiEditableText interface,
965 atspi_accessible_is_editable_text (AtspiAccessible *obj)
967 return _atspi_accessible_is_a (obj,
968 atspi_interface_editable_text);
972 * atspi_accessible_is_hypertext:
973 * @obj: a pointer to the #AtspiAccessible instance to query.
975 * Query whether the specified #AtspiAccessible implements the
976 * #AtspiHypertext interface.
978 * Returns: #TRUE if @obj implements the #AtspiHypertext interface,
982 atspi_accessible_is_hypertext (AtspiAccessible *obj)
984 return _atspi_accessible_is_a (obj,
985 atspi_interface_hypertext);
989 * atspi_accessible_is_hyperlink:
990 * @obj: a pointer to the #AtspiAccessible instance to query.
992 * Query whether the specified #AtspiAccessible implements the
993 * #AtspiHyperlink interface.
995 * Returns: #TRUE if @obj implements the #AtspiHypertext interface,
999 atspi_accessible_is_hyperlink (AtspiAccessible *obj)
1001 return _atspi_accessible_is_a (obj,
1002 atspi_interface_hyperlink);
1006 * atspi_accessible_is_image:
1007 * @obj: a pointer to the #AtspiAccessible instance to query.
1009 * Query whether the specified #AtspiAccessible implements the
1010 * #AtspiImage interface.
1012 * Returns: #TRUE if @obj implements the #AtspiImage interface,
1016 atspi_accessible_is_image (AtspiAccessible *obj)
1018 return _atspi_accessible_is_a (obj,
1019 atspi_interface_image);
1023 * atspi_accessible_is_selection:
1024 * @obj: a pointer to the #AtspiAccessible instance to query.
1026 * Query whether the specified #AtspiAccessible implements the
1027 * #AtspiSelection interface.
1029 * Returns: #TRUE if @obj implements the #AtspiSelection interface,
1033 atspi_accessible_is_selection (AtspiAccessible *obj)
1035 return _atspi_accessible_is_a (obj,
1036 atspi_interface_selection);
1040 * atspi_accessible_is_table:
1041 * @obj: a pointer to the #AtspiAccessible instance to query.
1043 * Query whether the specified #AtspiAccessible implements the
1044 * #AtspiTable interface.
1046 * Returns: #TRUE if @obj implements the #AtspiTable interface,
1050 atspi_accessible_is_table (AtspiAccessible *obj)
1052 return _atspi_accessible_is_a (obj,
1053 atspi_interface_table);
1057 * atspi_accessible_is_table_cell:
1058 * @obj: a pointer to the #AtspiAccessible instance to query.
1060 * Query whether the specified #AtspiAccessible implements the
1061 * #AtspiTableCell interface.
1063 * Returns: #TRUE if @obj implements the #AtspiTable interface,
1067 atspi_accessible_is_table_cell (AtspiAccessible *obj)
1069 return _atspi_accessible_is_a (obj,
1070 atspi_interface_table_cell);
1074 * atspi_accessible_is_streamable_content:
1075 * @obj: a pointer to the #AtspiAccessible instance to query.
1077 * Query whether the specified #AtspiAccessible implements the
1078 * #AtspiStreamableContent interface.
1080 * Returns: #TRUE if @obj implements the #AtspiStreamableContent interface,
1084 atspi_accessible_is_streamable_content (AtspiAccessible *obj)
1087 return _atspi_accessible_is_a (obj,
1088 atspi_interface_streamable_content);
1090 g_warning ("Streamable content not implemented");
1096 * atspi_accessible_is_text:
1097 * @obj: a pointer to the #AtspiAccessible instance to query.
1099 * Query whether the specified #AtspiAccessible implements the
1100 * #AtspiText interface.
1102 * Returns: #TRUE if @obj implements the #AtspiText interface,
1106 atspi_accessible_is_text (AtspiAccessible *obj)
1108 return _atspi_accessible_is_a (obj,
1109 atspi_interface_text);
1113 * atspi_accessible_is_value:
1114 * @obj: a pointer to the #AtspiAccessible instance to query.
1116 * Query whether the specified #AtspiAccessible implements the
1117 * #AtspiValue interface.
1119 * Returns: #TRUE if @obj implements the #AtspiValue interface,
1123 atspi_accessible_is_value (AtspiAccessible *obj)
1125 return _atspi_accessible_is_a (obj,
1126 atspi_interface_value);
1130 * atspi_accessible_get_action: (rename-to atspi_accessible_get_action_iface)
1131 * @obj: a pointer to the #AtspiAccessible instance to query.
1133 * Gets the #AtspiAction interface for an #AtspiAccessible.
1135 * Returns: (transfer full): a pointer to an #AtspiAction interface
1136 * instance, or NULL if @obj does not implement #AtspiAction.
1138 * Deprecated: 2.10: Use atspi_accessible_get_action_iface instead.
1141 atspi_accessible_get_action (AtspiAccessible *accessible)
1143 return (_atspi_accessible_is_a (accessible, atspi_interface_action) ?
1144 g_object_ref (ATSPI_ACTION (accessible)) : NULL);
1148 * atspi_accessible_get_action_iface:
1149 * @obj: a pointer to the #AtspiAccessible instance to query.
1151 * Gets the #AtspiAction interface for an #AtspiAccessible.
1153 * Returns: (transfer full): a pointer to an #AtspiAction interface
1154 * instance, or NULL if @obj does not implement #AtspiAction.
1157 atspi_accessible_get_action_iface (AtspiAccessible *accessible)
1159 return (_atspi_accessible_is_a (accessible, atspi_interface_action) ?
1160 g_object_ref (ATSPI_ACTION (accessible)) : NULL);
1164 * atspi_accessible_get_collection: (rename-to atspi_accessible_get_collection_iface)
1165 * @obj: a pointer to the #AtspiAccessible instance to query.
1167 * Gets the #AtspiCollection interface for an #AtspiAccessible.
1169 * Returns: (transfer full): a pointer to an #AtspiCollection interface
1170 * instance, or NULL if @obj does not implement #AtspiCollection.
1172 * Deprecated: 2.10: Use atspi_accessible_get_collection_iface instead.
1175 atspi_accessible_get_collection (AtspiAccessible *accessible)
1177 return (_atspi_accessible_is_a (accessible, atspi_interface_collection) ?
1178 g_object_ref (ATSPI_COLLECTION (accessible)) : NULL);
1182 * atspi_accessible_get_collection_iface:
1183 * @obj: a pointer to the #AtspiAccessible instance to query.
1185 * Gets the #AtspiCollection interface for an #AtspiAccessible.
1187 * Returns: (transfer full): a pointer to an #AtspiCollection interface
1188 * instance, or NULL if @obj does not implement #AtspiCollection.
1191 atspi_accessible_get_collection_iface (AtspiAccessible *accessible)
1193 return (_atspi_accessible_is_a (accessible, atspi_interface_collection) ?
1194 g_object_ref (ATSPI_COLLECTION (accessible)) : NULL);
1198 * atspi_accessible_get_component: (rename-to atspi_accessible_get_component_iface)
1199 * @obj: a pointer to the #AtspiAccessible instance to query.
1201 * Gets the #AtspiComponent interface for an #AtspiAccessible.
1203 * Returns: (transfer full): a pointer to an #AtspiComponent interface
1204 * instance, or NULL if @obj does not implement #AtspiComponent.
1206 * Deprecated: 2.10: Use atspi_accessible_get_component_iface instead.
1209 atspi_accessible_get_component (AtspiAccessible *obj)
1211 return (_atspi_accessible_is_a (obj, atspi_interface_component) ?
1212 g_object_ref (ATSPI_COMPONENT (obj)) : NULL);
1216 * atspi_accessible_get_component_iface:
1217 * @obj: a pointer to the #AtspiAccessible instance to query.
1219 * Gets the #AtspiComponent interface for an #AtspiAccessible.
1221 * Returns: (transfer full): a pointer to an #AtspiComponent interface
1222 * instance, or NULL if @obj does not implement #AtspiComponent.
1225 atspi_accessible_get_component_iface (AtspiAccessible *obj)
1227 return (_atspi_accessible_is_a (obj, atspi_interface_component) ?
1228 g_object_ref (ATSPI_COMPONENT (obj)) : NULL);
1232 * atspi_accessible_get_document: (rename-to atspi_accessible_get_document_iface)
1233 * @obj: a pointer to the #AtspiAccessible instance to query.
1235 * Gets the #AtspiDocument interface for an #AtspiAccessible.
1237 * Returns: (transfer full): a pointer to an #AtspiDocument interface
1238 * instance, or NULL if @obj does not implement #AtspiDocument.
1240 * Deprecated: 2.10: Use atspi_accessible_get_document_iface instead.
1243 atspi_accessible_get_document (AtspiAccessible *accessible)
1245 return (_atspi_accessible_is_a (accessible, atspi_interface_document) ?
1246 g_object_ref (ATSPI_DOCUMENT (accessible)) : NULL);
1250 * atspi_accessible_get_document_iface:
1251 * @obj: a pointer to the #AtspiAccessible instance to query.
1253 * Gets the #AtspiDocument interface for an #AtspiAccessible.
1255 * Returns: (transfer full): a pointer to an #AtspiDocument interface
1256 * instance, or NULL if @obj does not implement #AtspiDocument.
1259 atspi_accessible_get_document_iface (AtspiAccessible *accessible)
1261 return (_atspi_accessible_is_a (accessible, atspi_interface_document) ?
1262 g_object_ref (ATSPI_DOCUMENT (accessible)) : NULL);
1266 * atspi_accessible_get_editable_text: (rename-to atspi_accessible_get_editable_text_iface)
1267 * @obj: a pointer to the #AtspiAccessible instance to query.
1269 * Gets the #AtspiEditableText interface for an #AtspiAccessible.
1271 * Returns: (transfer full): a pointer to an #AtspiEditableText interface
1272 * instance, or NULL if @obj does not implement #AtspiEditableText.
1274 * Deprecated: 2.10: Use atspi_accessible_get_editable_text_iface instead.
1277 atspi_accessible_get_editable_text (AtspiAccessible *accessible)
1279 return (_atspi_accessible_is_a (accessible, atspi_interface_editable_text) ?
1280 g_object_ref (ATSPI_EDITABLE_TEXT (accessible)) : NULL);
1284 * atspi_accessible_get_editable_text_iface:
1285 * @obj: a pointer to the #AtspiAccessible instance to query.
1287 * Gets the #AtspiEditableText interface for an #AtspiAccessible.
1289 * Returns: (transfer full): a pointer to an #AtspiEditableText interface
1290 * instance, or NULL if @obj does not implement #AtspiEditableText.
1293 atspi_accessible_get_editable_text_iface (AtspiAccessible *accessible)
1295 return (_atspi_accessible_is_a (accessible, atspi_interface_editable_text) ?
1296 g_object_ref (ATSPI_EDITABLE_TEXT (accessible)) : NULL);
1300 * atspi_accessible_get_hyperlink:
1301 * @obj: a pointer to the #AtspiAccessible object on which to operate.
1303 * Gets the #AtspiHyperlink interface for an #AtspiAccessible.
1305 * Returns: (transfer full): the #AtspiHyperlink object associated with
1306 * the given #AtspiAccessible, or NULL if not supported.
1309 atspi_accessible_get_hyperlink (AtspiAccessible *accessible)
1311 return (_atspi_accessible_is_a (accessible, atspi_interface_hyperlink) ?
1312 _atspi_hyperlink_new (accessible->parent.app, accessible->parent.path) : NULL);
1316 * atspi_accessible_get_hypertext: (rename-to atspi_accessible_get_hypertext_iface)
1317 * @obj: a pointer to the #AtspiAccessible instance to query.
1319 * Gets the #AtspiHypertext interface for an #AtspiAccessible.
1321 * Returns: (transfer full): a pointer to an #AtspiHypertext interface
1322 * instance, or NULL if @obj does not implement #AtspiHypertext.
1324 * Deprecated: 2.10: Use atspi_accessible_get_hypertext_iface instead.
1327 atspi_accessible_get_hypertext (AtspiAccessible *accessible)
1329 return (_atspi_accessible_is_a (accessible, atspi_interface_hypertext) ?
1330 g_object_ref (ATSPI_HYPERTEXT (accessible)) : NULL);
1334 * atspi_accessible_get_hypertext_iface:
1335 * @obj: a pointer to the #AtspiAccessible instance to query.
1337 * Gets the #AtspiHypertext interface for an #AtspiAccessible.
1339 * Returns: (transfer full): a pointer to an #AtspiHypertext interface
1340 * instance, or NULL if @obj does not implement #AtspiHypertext.
1343 atspi_accessible_get_hypertext_iface (AtspiAccessible *accessible)
1345 return (_atspi_accessible_is_a (accessible, atspi_interface_hypertext) ?
1346 g_object_ref (ATSPI_HYPERTEXT (accessible)) : NULL);
1350 * atspi_accessible_get_image: (rename-to atspi_accessible_get_image_iface)
1351 * @obj: a pointer to the #AtspiAccessible instance to query.
1353 * Gets the #AtspiImage interface for an #AtspiAccessible.
1355 * Returns: (transfer full): a pointer to an #AtspiImage interface instance, or
1356 * NULL if @obj does not implement #AtspiImage.
1358 * Deprecated: 2.10: Use atspi_accessible_get_image_iface instead.
1361 atspi_accessible_get_image (AtspiAccessible *accessible)
1363 return (_atspi_accessible_is_a (accessible, atspi_interface_image) ?
1364 g_object_ref (ATSPI_IMAGE (accessible)) : NULL);
1368 * atspi_accessible_get_image_iface:
1369 * @obj: a pointer to the #AtspiAccessible instance to query.
1371 * Gets the #AtspiImage interface for an #AtspiAccessible.
1373 * Returns: (transfer full): a pointer to an #AtspiImage interface instance, or
1374 * NULL if @obj does not implement #AtspiImage.
1377 atspi_accessible_get_image_iface (AtspiAccessible *accessible)
1379 return (_atspi_accessible_is_a (accessible, atspi_interface_image) ?
1380 g_object_ref (ATSPI_IMAGE (accessible)) : NULL);
1384 * atspi_accessible_get_selection: (rename-to atspi_accessible_get_selection_iface)
1385 * @obj: a pointer to the #AtspiAccessible instance to query.
1387 * Gets the #AtspiSelection interface for an #AtspiAccessible.
1389 * Returns: (transfer full): a pointer to an #AtspiSelection interface
1390 * instance, or NULL if @obj does not implement #AtspiSelection.
1392 * Deprecated: 2.10: Use atspi_accessible_get_selection_iface instead.
1395 atspi_accessible_get_selection (AtspiAccessible *accessible)
1397 return (_atspi_accessible_is_a (accessible, atspi_interface_selection) ?
1398 g_object_ref (ATSPI_SELECTION (accessible)) : NULL);
1402 * atspi_accessible_get_selection_iface:
1403 * @obj: a pointer to the #AtspiAccessible instance to query.
1405 * Gets the #AtspiSelection interface for an #AtspiAccessible.
1407 * Returns: (transfer full): a pointer to an #AtspiSelection interface
1408 * instance, or NULL if @obj does not implement #AtspiSelection.
1411 atspi_accessible_get_selection_iface (AtspiAccessible *accessible)
1413 return (_atspi_accessible_is_a (accessible, atspi_interface_selection) ?
1414 g_object_ref (ATSPI_SELECTION (accessible)) : NULL);
1419 * atspi_accessible_get_streamable_content:
1420 * @obj: a pointer to the #AtspiAccessible instance to query.
1422 * Gets the #AtspiStreamableContent interface for an #AtspiAccessible.
1424 * Returns: (transfer full): a pointer to an #AtspiStreamableContent interface
1425 * instance, or NULL if @obj does not implement #AtspiStreamableContent.
1427 AtspiStreamableContent *
1428 atspi_accessible_get_streamable_content (AtspiAccessible *accessible)
1430 return (_atspi_accessible_is_a (accessible, atspi_interface_streamable_content) ?
1436 * atspi_accessible_get_table: (rename-to atspi_accessible_get_table_iface)
1437 * @obj: a pointer to the #AtspiAccessible instance to query.
1439 * Gets the #AtspiTable interface for an #AtspiAccessible.
1441 * Returns: (transfer full): a pointer to an #AtspiTable interface instance, or
1442 * NULL if @obj does not implement #AtspiTable.
1444 * Deprecated: 2.10: Use atspi_accessible_get_table_iface instead.
1447 atspi_accessible_get_table (AtspiAccessible *obj)
1449 return (_atspi_accessible_is_a (obj, atspi_interface_table) ?
1450 g_object_ref (ATSPI_TABLE (obj)) : NULL);
1454 * atspi_accessible_get_table_iface:
1455 * @obj: a pointer to the #AtspiAccessible instance to query.
1457 * Gets the #AtspiTable interface for an #AtspiAccessible.
1459 * Returns: (transfer full): a pointer to an #AtspiTable interface instance, or
1460 * NULL if @obj does not implement #AtspiTable.
1463 atspi_accessible_get_table_iface (AtspiAccessible *obj)
1465 return (_atspi_accessible_is_a (obj, atspi_interface_table) ?
1466 g_object_ref (ATSPI_TABLE (obj)) : NULL);
1470 * atspi_accessible_get_table_cell:
1471 * @obj: a pointer to the #AtspiAccessible instance to query.
1473 * Gets the #AtspiTableCell interface for an #AtspiAccessible.
1475 * Returns: (transfer full): a pointer to an #AtspiTableCell interface instance,
1476 * or NULL if @obj does not implement #AtspiTable.
1479 atspi_accessible_get_table_cell (AtspiAccessible *obj)
1481 return (_atspi_accessible_is_a (obj, atspi_interface_table_cell) ?
1482 g_object_ref (ATSPI_TABLE_CELL (obj)) : NULL);
1486 * atspi_accessible_get_text: (rename-to atspi_accessible_get_text_iface)
1487 * @obj: a pointer to the #AtspiAccessible instance to query.
1489 * Gets the #AtspiTable interface for an #AtspiAccessible.
1491 * Returns: (transfer full): a pointer to an #AtspiText interface instance, or
1492 * NULL if @obj does not implement #AtspiText.
1494 * Deprecated: 2.10: Use atspi_accessible_get_text_iface instead.
1497 atspi_accessible_get_text (AtspiAccessible *obj)
1499 return (_atspi_accessible_is_a (obj, atspi_interface_text) ?
1500 g_object_ref (ATSPI_TEXT (obj)) : NULL);
1504 * atspi_accessible_get_text_iface:
1505 * @obj: a pointer to the #AtspiAccessible instance to query.
1507 * Gets the #AtspiTable interface for an #AtspiAccessible.
1509 * Returns: (transfer full): a pointer to an #AtspiText interface instance, or
1510 * NULL if @obj does not implement #AtspiText.
1513 atspi_accessible_get_text_iface (AtspiAccessible *obj)
1515 return (_atspi_accessible_is_a (obj, atspi_interface_text) ?
1516 g_object_ref (ATSPI_TEXT (obj)) : NULL);
1520 * atspi_accessible_get_value: (rename-to atspi_accessible_get_value_iface)
1521 * @obj: a pointer to the #AtspiAccessible instance to query.
1523 * Gets the #AtspiTable interface for an #AtspiAccessible.
1525 * Returns: (transfer full): a pointer to an #AtspiValue interface instance, or
1526 * NULL if @obj does not implement #AtspiValue.
1528 * Deprecated: 2.10: Use atspi_accessible_get_value_iface instead.
1531 atspi_accessible_get_value (AtspiAccessible *accessible)
1533 return (_atspi_accessible_is_a (accessible, atspi_interface_value) ?
1534 g_object_ref (ATSPI_VALUE (accessible)) : NULL);
1538 * atspi_accessible_get_value_iface:
1539 * @obj: a pointer to the #AtspiAccessible instance to query.
1541 * Gets the #AtspiTable interface for an #AtspiAccessible.
1543 * Returns: (transfer full): a pointer to an #AtspiValue interface instance, or
1544 * NULL if @obj does not implement #AtspiValue.
1547 atspi_accessible_get_value_iface (AtspiAccessible *accessible)
1549 return (_atspi_accessible_is_a (accessible, atspi_interface_value) ?
1550 g_object_ref (ATSPI_VALUE (accessible)) : NULL);
1554 append_const_val (GArray *array, const gchar *val)
1556 gchar *dup = g_strdup (val);
1559 g_array_append_val (array, dup);
1563 * atspi_accessible_get_interfaces:
1564 * @obj: The #AtspiAccessible to query.
1566 * A set of pointers to all interfaces supported by an #AtspiAccessible.
1568 * Returns: (element-type gchar*) (transfer full): A #GArray of strings
1569 * describing the interfaces supported by the object. Interfaces are
1570 * denoted in short-hand (i.e. "Component", "Text" etc.).
1573 atspi_accessible_get_interfaces (AtspiAccessible *obj)
1575 GArray *ret = g_array_new (TRUE, TRUE, sizeof (gchar *));
1577 g_return_val_if_fail (obj != NULL, NULL);
1579 append_const_val (ret, "Accessible");
1580 if (atspi_accessible_is_action (obj))
1581 append_const_val (ret, "Action");
1582 if (atspi_accessible_is_collection (obj))
1583 append_const_val (ret, "Collection");
1584 if (atspi_accessible_is_component (obj))
1585 append_const_val (ret, "Component");
1586 if (atspi_accessible_is_document (obj))
1587 append_const_val (ret, "Document");
1588 if (atspi_accessible_is_editable_text (obj))
1589 append_const_val (ret, "EditableText");
1590 if (atspi_accessible_is_hypertext (obj))
1591 append_const_val (ret, "Hypertext");
1592 if (atspi_accessible_is_hyperlink (obj))
1593 append_const_val (ret, "Hyperlink");
1594 if (atspi_accessible_is_image (obj))
1595 append_const_val (ret, "Image");
1596 if (atspi_accessible_is_selection (obj))
1597 append_const_val (ret, "Selection");
1598 if (atspi_accessible_is_table (obj))
1599 append_const_val (ret, "Table");
1600 if (atspi_accessible_is_table_cell (obj))
1601 append_const_val (ret, "TableCell");
1602 if (atspi_accessible_is_text (obj))
1603 append_const_val (ret, "Text");
1604 if (atspi_accessible_is_value (obj))
1605 append_const_val (ret, "Value");
1611 _atspi_accessible_new (AtspiApplication *app, const gchar *path)
1613 AtspiAccessible *accessible;
1615 accessible = g_object_new (ATSPI_TYPE_ACCESSIBLE, NULL);
1616 g_return_val_if_fail (accessible != NULL, NULL);
1618 accessible->parent.app = g_object_ref (app);
1619 accessible->parent.path = g_strdup (path);
1625 * atspi_accessible_set_cache_mask:
1626 * @accessible: The #AtspiAccessible to operate on. Must be the desktop or
1627 * the root of an application.
1628 * @mask: An #AtspiCache specifying a bit mask of the types of data to cache.
1630 * Sets the type of data to cache for accessibles.
1631 * If this is not set for an application or is reset to ATSPI_CACHE_UNDEFINED,
1632 * then the desktop's cache flag will be used.
1633 * If the desktop's cache flag is also undefined, then all possible data will
1635 * This function is intended to work around bugs in toolkits where the proper
1636 * events are not raised / to aid in testing for such bugs.
1639 atspi_accessible_set_cache_mask (AtspiAccessible *accessible, AtspiCache mask)
1641 g_return_if_fail (accessible != NULL);
1642 g_return_if_fail (accessible->parent.app != NULL);
1643 g_return_if_fail (accessible == accessible->parent.app->root);
1644 accessible->parent.app->cache = mask;
1645 enable_caching = TRUE;
1649 * atspi_accessible_clear_cache:
1650 * @accessible: The #AtspiAccessible whose cache to clear.
1652 * Clears the cached information for the given accessible and all of its
1656 atspi_accessible_clear_cache (AtspiAccessible *accessible)
1662 accessible->cached_properties = ATSPI_CACHE_NONE;
1663 for (l = accessible->children; l; l = l->next)
1664 atspi_accessible_clear_cache (l->data);
1669 * atspi_accessible_get_process_id:
1670 * @accessible: The #AtspiAccessible to query.
1671 * @error: a pointer to a %NULL #GError pointer
1673 * Returns the process id associated with the given accessible. Mainly
1674 * added for debugging; it is a shortcut to explicitly querying the
1675 * accessible's app->bus_name and then calling GetConnectionUnixProcessID.
1677 * Returns: The process ID or undetermined value if @error is set.
1680 atspi_accessible_get_process_id (AtspiAccessible *accessible, GError **error)
1682 DBusMessage *message, *reply;
1683 DBusConnection *bus = _atspi_bus ();
1684 dbus_uint32_t pid = -1;
1687 if (!accessible->parent.app || !accessible->parent.app->bus_name)
1689 g_set_error_literal(error, ATSPI_ERROR, ATSPI_ERROR_IPC, "Process is defunct");
1693 message = dbus_message_new_method_call ("org.freedesktop.DBus",
1694 "/org/freedesktop/DBus",
1695 "org.freedesktop.DBus",
1696 "GetConnectionUnixProcessID");
1697 dbus_message_append_args (message, DBUS_TYPE_STRING,
1698 &accessible->parent.app->bus_name,
1700 dbus_error_init (&d_error);
1701 reply = dbus_connection_send_with_reply_and_block (bus, message, -1, &d_error);
1702 dbus_message_unref (message);
1705 if (!strcmp (dbus_message_get_signature (reply), "u"))
1706 dbus_message_get_args (reply, NULL, DBUS_TYPE_UINT32, &pid, DBUS_TYPE_INVALID);
1707 dbus_message_unref (reply);
1709 if (dbus_error_is_set (&d_error))
1711 g_set_error_literal(error, ATSPI_ERROR, ATSPI_ERROR_IPC, "Process is defunct");
1712 dbus_error_free (&d_error);
1718 _atspi_accessible_get_cache_mask (AtspiAccessible *accessible)
1722 if (!accessible->parent.app)
1723 return ATSPI_CACHE_NONE;
1725 mask = accessible->parent.app->cache;
1726 if (mask == ATSPI_CACHE_UNDEFINED &&
1727 accessible->parent.app->root &&
1728 accessible->parent.app->root->accessible_parent)
1730 AtspiAccessible *desktop = atspi_get_desktop (0);
1731 mask = desktop->parent.app->cache;
1732 g_object_unref (desktop);
1735 if (mask == ATSPI_CACHE_UNDEFINED)
1736 mask = ATSPI_CACHE_DEFAULT;
1742 _atspi_accessible_test_cache (AtspiAccessible *accessible, AtspiCache flag)
1744 AtspiCache mask = _atspi_accessible_get_cache_mask (accessible);
1745 AtspiCache result = accessible->cached_properties & mask & flag;
1746 if (accessible->states && atspi_state_set_contains (accessible->states, ATSPI_STATE_TRANSIENT))
1748 return (result != 0 && (atspi_main_loop || enable_caching ||
1749 flag == ATSPI_CACHE_INTERFACES) &&
1754 _atspi_accessible_add_cache (AtspiAccessible *accessible, AtspiCache flag)
1756 AtspiCache mask = _atspi_accessible_get_cache_mask (accessible);
1758 accessible->cached_properties |= flag & mask;
1762 * atspi_accessible_get_locale:
1763 * @accessible: an #AtspiAccessible
1765 * Gets a UTF-8 string indicating the POSIX-style LC_MESSAGES locale
1770 * Returns: a UTF-8 string indicating the POSIX-style LC_MESSAGES
1771 * locale of @accessible.
1774 atspi_accessible_get_object_locale (AtspiAccessible *accessible, GError **error)
1778 g_return_val_if_fail (accessible != NULL, NULL);
1780 locale = g_object_get_qdata (G_OBJECT (accessible), quark_locale);
1783 if (!_atspi_dbus_get_property (accessible, atspi_interface_accessible,
1784 "Locale", error, "s", &locale))
1787 g_object_set_qdata_full (G_OBJECT (accessible), quark_locale, locale,
1794 free_value (gpointer data)
1796 GValue *value = data;
1798 g_value_unset (value);
1803 _atspi_accessible_ref_cache (AtspiAccessible *accessible)
1805 AtspiAccessiblePrivate *priv = accessible->priv;
1807 priv->cache_ref_count++;
1809 return g_hash_table_ref (priv->cache);
1810 priv->cache = g_hash_table_new_full (g_str_hash, g_str_equal, g_free,
1816 _atspi_accessible_unref_cache (AtspiAccessible *accessible)
1818 AtspiAccessiblePrivate *priv = accessible->priv;
1822 g_hash_table_unref (priv->cache);
1823 if (--priv->cache_ref_count == 0)