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 (!_atspi_accessible_test_cache (obj, ATSPI_CACHE_PARENT))
273 DBusMessage *message, *reply;
274 DBusMessageIter iter, iter_variant;
275 if (!obj->parent.app)
277 message = dbus_message_new_method_call (obj->parent.app->bus_name,
279 DBUS_INTERFACE_PROPERTIES, "Get");
282 dbus_message_append_args (message, DBUS_TYPE_STRING, &atspi_interface_accessible,
283 DBUS_TYPE_STRING, &str_parent,
285 reply = _atspi_dbus_send_with_reply_and_block (message, error);
288 if (strcmp (dbus_message_get_signature (reply), "v") != 0)
290 dbus_message_unref (reply);
293 dbus_message_iter_init (reply, &iter);
294 dbus_message_iter_recurse (&iter, &iter_variant);
295 obj->accessible_parent = _atspi_dbus_return_accessible_from_iter (&iter_variant);
296 dbus_message_unref (reply);
297 _atspi_accessible_add_cache (obj, ATSPI_CACHE_PARENT);
299 if (!obj->accessible_parent)
301 return g_object_ref (obj->accessible_parent);
305 * atspi_accessible_get_child_count:
306 * @obj: a pointer to the #AtspiAccessible object on which to operate.
308 * Gets the number of children contained by an #AtspiAccessible object.
310 * Returns: a #long indicating the number of #AtspiAccessible children
311 * contained by an #AtspiAccessible object or -1 on exception.
315 atspi_accessible_get_child_count (AtspiAccessible *obj, GError **error)
317 g_return_val_if_fail (obj != NULL, -1);
319 if (!_atspi_accessible_test_cache (obj, ATSPI_CACHE_CHILDREN))
322 if (!_atspi_dbus_get_property (obj, atspi_interface_accessible,
323 "ChildCount", error, "i", &ret))
329 return 0; /* assume it's disposed */
331 return obj->children->len;
335 * atspi_accessible_get_child_at_index:
336 * @obj: a pointer to the #AtspiAccessible object on which to operate.
337 * @child_index: a #long indicating which child is specified.
339 * Gets the #AtspiAccessible child of an #AtspiAccessible object at a given index.
341 * Returns: (transfer full): a pointer to the #AtspiAccessible child object at
342 * index @child_index or NULL on exception.
345 atspi_accessible_get_child_at_index (AtspiAccessible *obj,
349 AtspiAccessible *child;
352 g_return_val_if_fail (obj != NULL, NULL);
354 if (_atspi_accessible_test_cache (obj, ATSPI_CACHE_CHILDREN))
357 return NULL; /* assume disposed */
359 child = g_ptr_array_index (obj->children, child_index);
361 return g_object_ref (child);
364 reply = _atspi_dbus_call_partial (obj, atspi_interface_accessible,
365 "GetChildAtIndex", error, "i", child_index);
366 child = _atspi_dbus_return_accessible_from_message (reply);
371 if (_atspi_accessible_test_cache (obj, ATSPI_CACHE_CHILDREN))
373 if (child_index >= obj->children->len)
374 g_ptr_array_set_size (obj->children, child_index + 1);
375 g_ptr_array_index (obj->children, child_index) = g_object_ref (child);
381 * atspi_accessible_get_index_in_parent:
382 * @obj: a pointer to the #AtspiAccessible object on which to operate.
384 * Gets the index of an #AtspiAccessible object within its parent's
385 * #AtspiAccessible children list.
387 * Returns: a #glong indicating the index of the #AtspiAccessible object
389 * or -1 if @obj has no containing parent or on exception.
392 atspi_accessible_get_index_in_parent (AtspiAccessible *obj, GError **error)
395 dbus_int32_t ret = -1;
397 g_return_val_if_fail (obj != NULL, -1);
398 if (_atspi_accessible_test_cache (obj, ATSPI_CACHE_PARENT))
400 if (!obj->accessible_parent)
403 if (!_atspi_accessible_test_cache (obj->accessible_parent, ATSPI_CACHE_CHILDREN) || !obj->accessible_parent->children)
406 for (i = 0; i < obj->accessible_parent->children->len; i++)
407 if (g_ptr_array_index (obj->accessible_parent->children, i) == obj)
412 _atspi_dbus_call (obj, atspi_interface_accessible,
413 "GetIndexInParent", NULL, "=>i", &ret);
421 } Accessibility_Relation;
424 * atspi_accessible_get_relation_set:
425 * @obj: a pointer to the #AtspiAccessible object on which to operate.
427 * Gets the set of #AtspiRelation objects which describes this #AtspiAccessible object's
428 * relationships with other #AtspiAccessible objects.
430 * Returns: (element-type AtspiRelation*) (transfer full): a #GArray of
431 * #AtspiRelation pointers or NULL on exception.
434 atspi_accessible_get_relation_set (AtspiAccessible *obj, GError **error)
437 DBusMessageIter iter, iter_array;
440 g_return_val_if_fail (obj != NULL, NULL);
442 reply = _atspi_dbus_call_partial (obj, atspi_interface_accessible, "GetRelationSet", error, "");
445 _ATSPI_DBUS_CHECK_SIG (reply, "a(ua(so))", error, NULL);
447 ret = g_array_new (TRUE, TRUE, sizeof (AtspiRelation *));
448 dbus_message_iter_init (reply, &iter);
449 dbus_message_iter_recurse (&iter, &iter_array);
450 while (dbus_message_iter_get_arg_type (&iter_array) != DBUS_TYPE_INVALID)
452 AtspiRelation *relation;
453 relation = _atspi_relation_new_from_iter (&iter_array);
454 ret = g_array_append_val (ret, relation);
455 dbus_message_iter_next (&iter_array);
457 dbus_message_unref (reply);
462 * atspi_accessible_get_role:
463 * @obj: a pointer to the #AtspiAccessible object on which to operate.
465 * Gets the UI role played by an #AtspiAccessible object.
466 * This role's name can be obtained via atspi_accessible_get_role_name ().
468 * Returns: the #AtspiRole of an #AtspiAccessible object.
472 atspi_accessible_get_role (AtspiAccessible *obj, GError **error)
474 g_return_val_if_fail (obj != NULL, ATSPI_ROLE_INVALID);
476 if (!_atspi_accessible_test_cache (obj, ATSPI_CACHE_ROLE))
479 /* TODO: Make this a property */
480 if (_atspi_dbus_call (obj, atspi_interface_accessible, "GetRole", error, "=>u", &role))
483 _atspi_accessible_add_cache (obj, ATSPI_CACHE_ROLE);
490 * atspi_accessible_get_role_name:
491 * @obj: a pointer to the #AtspiAccessible object on which to operate.
493 * Gets a UTF-8 string corresponding to the name of the role played by an object.
494 * This method will return useful values for roles that fall outside the
495 * enumeration used in atspi_accessible_get_role ().
497 * Returns: a UTF-8 string specifying the type of UI role played by an
498 * #AtspiAccessible object.
502 atspi_accessible_get_role_name (AtspiAccessible *obj, GError **error)
504 gchar *retval = NULL;
507 g_return_val_if_fail (obj != NULL, NULL);
509 role = atspi_accessible_get_role (obj, error);
510 if (role >= 0 && role < ATSPI_ROLE_COUNT && role != ATSPI_ROLE_EXTENDED)
511 return atspi_role_get_name (role);
513 _atspi_dbus_call (obj, atspi_interface_accessible, "GetRoleName", error, "=>s", &retval);
516 retval = g_strdup ("");
522 * atspi_accessible_get_localized_role_name:
523 * @obj: a pointer to the #AtspiAccessible object on which to operate.
525 * Gets a UTF-8 string corresponding to the name of the role played by an
526 * object, translated to the current locale.
527 * This method will return useful values for roles that fall outside the
528 * enumeration used in atspi_accessible_getRole ().
530 * Returns: a localized, UTF-8 string specifying the type of UI role played
531 * by an #AtspiAccessible object.
535 atspi_accessible_get_localized_role_name (AtspiAccessible *obj, GError **error)
539 g_return_val_if_fail (obj != NULL, NULL);
541 _atspi_dbus_call (obj, atspi_interface_accessible, "GetLocalizedRoleName", error, "=>s", &retval);
544 return g_strdup ("");
549 static AtspiStateSet *
552 AtspiStateSet *set = atspi_state_set_new (NULL);
553 atspi_state_set_add (set, ATSPI_STATE_DEFUNCT);
558 * atspi_accessible_get_state_set:
559 * @obj: a pointer to the #AtspiAccessible object on which to operate.
561 * Gets the states currently held by an object.
563 * Returns: (transfer full): a pointer to an #AtspiStateSet representing an
564 * object's current state set.
567 atspi_accessible_get_state_set (AtspiAccessible *obj)
569 /* TODO: Should take a GError **, but would be an API break */
570 if (!obj->parent.app || !obj->parent.app->bus)
571 return defunct_set ();
573 if (!_atspi_accessible_test_cache (obj, ATSPI_CACHE_STATES))
576 DBusMessageIter iter;
577 reply = _atspi_dbus_call_partial (obj, atspi_interface_accessible,
578 "GetState", NULL, "");
579 _ATSPI_DBUS_CHECK_SIG (reply, "au", NULL, defunct_set ());
580 dbus_message_iter_init (reply, &iter);
581 _atspi_dbus_set_state (obj, &iter);
582 dbus_message_unref (reply);
583 _atspi_accessible_add_cache (obj, ATSPI_CACHE_STATES);
586 return g_object_ref (obj->states);
590 * atspi_accessible_get_attributes:
591 * @obj: The #AtspiAccessible being queried.
593 * Gets the #AttributeSet representing any assigned
594 * name-value pair attributes or annotations for this object.
595 * For typographic, textual, or textually-semantic attributes, see
596 * atspi_text_get_attributes instead.
598 * Returns: (element-type gchar* gchar*) (transfer full): The name-value-pair
599 * attributes assigned to this object.
602 atspi_accessible_get_attributes (AtspiAccessible *obj, GError **error)
604 DBusMessage *message;
606 g_return_val_if_fail (obj != NULL, NULL);
608 if (obj->priv->cache)
610 GValue *val = g_hash_table_lookup (obj->priv->cache, "Attributes");
612 return g_value_dup_boxed (val);
615 if (!_atspi_accessible_test_cache (obj, ATSPI_CACHE_ATTRIBUTES))
617 message = _atspi_dbus_call_partial (obj, atspi_interface_accessible,
618 "GetAttributes", error, "");
619 obj->attributes = _atspi_dbus_return_hash_from_message (message);
620 _atspi_accessible_add_cache (obj, ATSPI_CACHE_ATTRIBUTES);
623 if (!obj->attributes)
625 return g_hash_table_ref (obj->attributes);
629 add_to_attribute_array (gpointer key, gpointer value, gpointer data)
631 GArray **array = (GArray **)data;
632 gchar *str = g_strconcat (key, ":", value, NULL);
633 *array = g_array_append_val (*array, str);
637 * atspi_accessible_get_attributes_as_array:
638 * @obj: The #AtspiAccessible being queried.
640 * Gets a #GArray representing any assigned
641 * name-value pair attributes or annotations for this object.
642 * For typographic, textual, or textually-semantic attributes, see
643 * atspi_text_get_attributes_as_array instead.
645 * Returns: (element-type gchar*) (transfer full): The name-value-pair
646 * attributes assigned to this object.
649 atspi_accessible_get_attributes_as_array (AtspiAccessible *obj, GError **error)
651 DBusMessage *message;
653 g_return_val_if_fail (obj != NULL, NULL);
655 if (obj->priv->cache)
657 GValue *val = g_hash_table_lookup (obj->priv->cache, "Attributes");
660 GArray *array = g_array_new (TRUE, TRUE, sizeof (gchar *));
661 GHashTable *attributes = g_value_get_boxed (val);
662 g_hash_table_foreach (attributes, add_to_attribute_array, &array);
667 message = _atspi_dbus_call_partial (obj, atspi_interface_accessible, "GetAttributes", error, "");
668 return _atspi_dbus_return_attribute_array_from_message (message);
672 * atspi_accessible_get_application:
673 * @obj: The #AtspiAccessible being queried.
675 * Gets the containing #AtspiApplication for an object.
677 * Returns: (transfer full): the containing #AtspiApplication instance for
681 atspi_accessible_get_application (AtspiAccessible *obj, GError **error)
683 AtspiAccessible *parent;
688 parent = atspi_accessible_get_parent (obj, NULL);
689 if (!parent && obj->parent.app &&
690 atspi_accessible_get_role (obj, NULL) != ATSPI_ROLE_APPLICATION)
692 AtspiAccessible *root = g_object_ref (obj->parent.app->root);
695 g_object_unref (obj);
696 if (atspi_accessible_get_role (root, NULL) == ATSPI_ROLE_DESKTOP_FRAME)
698 g_object_unref (root);
704 if (!parent || parent == obj ||
705 atspi_accessible_get_role (parent, NULL) == ATSPI_ROLE_DESKTOP_FRAME)
708 g_object_unref (parent);
711 g_object_unref (obj);
716 /* Application-specific methods */
719 * atspi_accessible_get_toolkit_name:
720 * @obj: a pointer to the #AtspiAccessible object on which to operate.
722 * Gets the toolkit name for an #AtspiAccessible object.
723 * Only works on application root objects.
725 * Returns: a UTF-8 string indicating the toolkit name for the #AtspiAccessible object or NULL on exception.
728 atspi_accessible_get_toolkit_name (AtspiAccessible *obj, GError **error)
730 g_return_val_if_fail (obj != NULL, NULL);
732 if (!obj->parent.app)
735 if (!obj->parent.app->toolkit_name)
736 _atspi_dbus_get_property (obj, atspi_interface_application, "ToolkitName",
737 error, "s", &obj->parent.app->toolkit_name);
739 return g_strdup (obj->parent.app->toolkit_name);
743 * atspi_accessible_get_toolkit_version:
744 * @obj: a pointer to the #AtspiAccessible object on which to operate.
746 * Gets the toolkit version for an #AtspiAccessible object.
747 * Only works on application root objects.
749 * Returns: a UTF-8 string indicating the toolkit version for the #AtspiAccessible object or NULL on exception.
752 atspi_accessible_get_toolkit_version (AtspiAccessible *obj, GError **error)
754 g_return_val_if_fail (obj != NULL, NULL);
756 if (!obj->parent.app)
759 if (!obj->parent.app->toolkit_version)
760 _atspi_dbus_get_property (obj, atspi_interface_application, "Version",
761 error, "s", &obj->parent.app->toolkit_version);
763 return g_strdup (obj->parent.app->toolkit_version);
767 * atspi_accessible_get_atspi_version:
768 * @obj: a pointer to the #AtspiAccessible object on which to operate.
770 * Gets the AT-SPI IPC specification version supported by the application
771 * pointed to by the #AtspiAccessible object.
772 * Only works on application root objects.
774 * Returns: a UTF-8 string indicating the AT-SPI version for the #AtspiAccessible object or NULL on exception.
777 atspi_accessible_get_atspi_version (AtspiAccessible *obj, GError **error)
779 g_return_val_if_fail (obj != NULL, NULL);
781 if (!obj->parent.app)
784 if (!obj->parent.app->atspi_version)
785 _atspi_dbus_get_property (obj, atspi_interface_application, "AtspiVersion",
786 error, "s", &obj->parent.app->atspi_version);
788 return g_strdup (obj->parent.app->atspi_version);
792 * atspi_accessible_get_id:
793 * @obj: a pointer to the #AtspiAccessible object on which to operate.
795 * Gets the application id for a #AtspiAccessible object.
796 * Only works on application root objects.
798 * Returns: a positive #gint indicating the id for the #AtspiAccessible object
799 * or -1 on exception.
802 atspi_accessible_get_id (AtspiAccessible *obj, GError **error)
806 g_return_val_if_fail (obj != NULL, -1);
808 if (!_atspi_dbus_get_property (obj, atspi_interface_application, "Id", error, "i", &ret))
814 /* Interface query methods */
817 _atspi_accessible_is_a (AtspiAccessible *accessible,
818 const char *interface_name)
822 if (accessible == NULL)
827 if (!_atspi_accessible_test_cache (accessible, ATSPI_CACHE_INTERFACES))
830 DBusMessageIter iter;
831 reply = _atspi_dbus_call_partial (accessible, atspi_interface_accessible,
832 "GetInterfaces", NULL, "");
833 _ATSPI_DBUS_CHECK_SIG (reply, "as", NULL, FALSE);
834 dbus_message_iter_init (reply, &iter);
835 _atspi_dbus_set_interfaces (accessible, &iter);
836 dbus_message_unref (reply);
837 _atspi_accessible_add_cache (accessible, ATSPI_CACHE_INTERFACES);
840 n = _atspi_get_iface_num (interface_name);
841 if (n == -1) return FALSE;
842 return (gboolean) ((accessible->interfaces & (1 << n))? TRUE: FALSE);
846 * atspi_accessible_is_action:
847 * @obj: a pointer to the #AtspiAccessible instance to query.
849 * Query whether the specified #AtspiAccessible implements the
850 * #AtspiAction interface.
852 * Returns: #TRUE if @obj implements the #AtspiAction interface,
856 atspi_accessible_is_action (AtspiAccessible *obj)
858 return _atspi_accessible_is_a (obj,
859 atspi_interface_action);
863 * atspi_accessible_is_application:
864 * @obj: a pointer to the #AtspiAccessible instance to query.
866 * Query whether the specified #AtspiAccessible implements the
867 * #AtspiApplication interface.
869 * Returns: #TRUE if @obj implements the #AtspiApplication interface,
873 atspi_accessible_is_application (AtspiAccessible *obj)
875 return _atspi_accessible_is_a (obj,
876 atspi_interface_application);
880 * atspi_accessible_is_collection:
881 * @obj: a pointer to the #AtspiAccessible instance to query.
883 * Query whether the specified #AtspiAccessible implements the
884 * #AtspiCollection interface.
886 * Returns: #TRUE if @obj implements the #AtspiCollection interface,
890 atspi_accessible_is_collection (AtspiAccessible *obj)
892 return _atspi_accessible_is_a (obj,
893 atspi_interface_collection);
897 * atspi_accessible_is_component:
898 * @obj: a pointer to the #AtspiAccessible instance to query.
900 * Query whether the specified #AtspiAccessible implements #AtspiComponent.
902 * Returns: #TRUE if @obj implements the #AtspiComponent interface,
906 atspi_accessible_is_component (AtspiAccessible *obj)
908 return _atspi_accessible_is_a (obj,
909 atspi_interface_component);
913 * atspi_accessible_is_document:
914 * @obj: a pointer to the #AtspiAccessible instance to query.
916 * Query whether the specified #AtspiAccessible implements the
917 * #AtspiDocument interface.
919 * Returns: #TRUE if @obj implements the #AtspiDocument interface,
923 atspi_accessible_is_document (AtspiAccessible *obj)
925 return _atspi_accessible_is_a (obj,
926 atspi_interface_document);
930 * atspi_accessible_is_editable_text:
931 * @obj: a pointer to the #AtspiAccessible instance to query.
933 * Query whether the specified #AtspiAccessible implements the
934 * #AtspiEditableText interface.
936 * Returns: #TRUE if @obj implements the #AtspiEditableText interface,
940 atspi_accessible_is_editable_text (AtspiAccessible *obj)
942 return _atspi_accessible_is_a (obj,
943 atspi_interface_editable_text);
947 * atspi_accessible_is_hypertext:
948 * @obj: a pointer to the #AtspiAccessible instance to query.
950 * Query whether the specified #AtspiAccessible implements the
951 * #AtspiHypertext interface.
953 * Returns: #TRUE if @obj implements the #AtspiHypertext interface,
957 atspi_accessible_is_hypertext (AtspiAccessible *obj)
959 return _atspi_accessible_is_a (obj,
960 atspi_interface_hypertext);
964 * atspi_accessible_is_hyperlink:
965 * @obj: a pointer to the #AtspiAccessible instance to query.
967 * Query whether the specified #AtspiAccessible implements the
968 * #AtspiHyperlink interface.
970 * Returns: #TRUE if @obj implements the #AtspiHypertext interface,
974 atspi_accessible_is_hyperlink (AtspiAccessible *obj)
976 return _atspi_accessible_is_a (obj,
977 atspi_interface_hyperlink);
981 * atspi_accessible_is_image:
982 * @obj: a pointer to the #AtspiAccessible instance to query.
984 * Query whether the specified #AtspiAccessible implements the
985 * #AtspiImage interface.
987 * Returns: #TRUE if @obj implements the #AtspiImage interface,
991 atspi_accessible_is_image (AtspiAccessible *obj)
993 return _atspi_accessible_is_a (obj,
994 atspi_interface_image);
998 * atspi_accessible_is_selection:
999 * @obj: a pointer to the #AtspiAccessible instance to query.
1001 * Query whether the specified #AtspiAccessible implements the
1002 * #AtspiSelection interface.
1004 * Returns: #TRUE if @obj implements the #AtspiSelection interface,
1008 atspi_accessible_is_selection (AtspiAccessible *obj)
1010 return _atspi_accessible_is_a (obj,
1011 atspi_interface_selection);
1015 * atspi_accessible_is_table:
1016 * @obj: a pointer to the #AtspiAccessible instance to query.
1018 * Query whether the specified #AtspiAccessible implements the
1019 * #AtspiTable interface.
1021 * Returns: #TRUE if @obj implements the #AtspiTable interface,
1025 atspi_accessible_is_table (AtspiAccessible *obj)
1027 return _atspi_accessible_is_a (obj,
1028 atspi_interface_table);
1032 * atspi_accessible_is_table_cell:
1033 * @obj: a pointer to the #AtspiAccessible instance to query.
1035 * Query whether the specified #AtspiAccessible implements the
1036 * #AtspiTableCell interface.
1038 * Returns: #TRUE if @obj implements the #AtspiTable interface,
1042 atspi_accessible_is_table_cell (AtspiAccessible *obj)
1044 return _atspi_accessible_is_a (obj,
1045 atspi_interface_table_cell);
1049 * atspi_accessible_is_streamable_content:
1050 * @obj: a pointer to the #AtspiAccessible instance to query.
1052 * Query whether the specified #AtspiAccessible implements the
1053 * #AtspiStreamableContent interface.
1055 * Returns: #TRUE if @obj implements the #AtspiStreamableContent interface,
1059 atspi_accessible_is_streamable_content (AtspiAccessible *obj)
1062 return _atspi_accessible_is_a (obj,
1063 atspi_interface_streamable_content);
1065 g_warning ("Streamable content not implemented");
1071 * atspi_accessible_is_text:
1072 * @obj: a pointer to the #AtspiAccessible instance to query.
1074 * Query whether the specified #AtspiAccessible implements the
1075 * #AtspiText interface.
1077 * Returns: #TRUE if @obj implements the #AtspiText interface,
1081 atspi_accessible_is_text (AtspiAccessible *obj)
1083 return _atspi_accessible_is_a (obj,
1084 atspi_interface_text);
1088 * atspi_accessible_is_value:
1089 * @obj: a pointer to the #AtspiAccessible instance to query.
1091 * Query whether the specified #AtspiAccessible implements the
1092 * #AtspiValue interface.
1094 * Returns: #TRUE if @obj implements the #AtspiValue interface,
1098 atspi_accessible_is_value (AtspiAccessible *obj)
1100 return _atspi_accessible_is_a (obj,
1101 atspi_interface_value);
1105 * atspi_accessible_get_action: (rename-to atspi_accessible_get_action_iface)
1106 * @obj: a pointer to the #AtspiAccessible instance to query.
1108 * Gets the #AtspiAction interface for an #AtspiAccessible.
1110 * Returns: (transfer full): a pointer to an #AtspiAction interface
1111 * instance, or NULL if @obj does not implement #AtspiAction.
1113 * Deprecated: 2.10: Use atspi_accessible_get_action_iface instead.
1116 atspi_accessible_get_action (AtspiAccessible *accessible)
1118 return (_atspi_accessible_is_a (accessible, atspi_interface_action) ?
1119 g_object_ref (ATSPI_ACTION (accessible)) : NULL);
1123 * atspi_accessible_get_action_iface:
1124 * @obj: a pointer to the #AtspiAccessible instance to query.
1126 * Gets the #AtspiAction interface for an #AtspiAccessible.
1128 * Returns: (transfer full): a pointer to an #AtspiAction interface
1129 * instance, or NULL if @obj does not implement #AtspiAction.
1132 atspi_accessible_get_action_iface (AtspiAccessible *accessible)
1134 return (_atspi_accessible_is_a (accessible, atspi_interface_action) ?
1135 g_object_ref (ATSPI_ACTION (accessible)) : NULL);
1139 * atspi_accessible_get_collection: (rename-to atspi_accessible_get_collection_iface)
1140 * @obj: a pointer to the #AtspiAccessible instance to query.
1142 * Gets the #AtspiCollection interface for an #AtspiAccessible.
1144 * Returns: (transfer full): a pointer to an #AtspiCollection interface
1145 * instance, or NULL if @obj does not implement #AtspiCollection.
1147 * Deprecated: 2.10: Use atspi_accessible_get_collection_iface instead.
1150 atspi_accessible_get_collection (AtspiAccessible *accessible)
1152 return (_atspi_accessible_is_a (accessible, atspi_interface_collection) ?
1153 g_object_ref (ATSPI_COLLECTION (accessible)) : NULL);
1157 * atspi_accessible_get_collection_iface:
1158 * @obj: a pointer to the #AtspiAccessible instance to query.
1160 * Gets the #AtspiCollection interface for an #AtspiAccessible.
1162 * Returns: (transfer full): a pointer to an #AtspiCollection interface
1163 * instance, or NULL if @obj does not implement #AtspiCollection.
1166 atspi_accessible_get_collection_iface (AtspiAccessible *accessible)
1168 return (_atspi_accessible_is_a (accessible, atspi_interface_collection) ?
1169 g_object_ref (ATSPI_COLLECTION (accessible)) : NULL);
1173 * atspi_accessible_get_component: (rename-to atspi_accessible_get_component_iface)
1174 * @obj: a pointer to the #AtspiAccessible instance to query.
1176 * Gets the #AtspiComponent interface for an #AtspiAccessible.
1178 * Returns: (transfer full): a pointer to an #AtspiComponent interface
1179 * instance, or NULL if @obj does not implement #AtspiComponent.
1181 * Deprecated: 2.10: Use atspi_accessible_get_component_iface instead.
1184 atspi_accessible_get_component (AtspiAccessible *obj)
1186 return (_atspi_accessible_is_a (obj, atspi_interface_component) ?
1187 g_object_ref (ATSPI_COMPONENT (obj)) : NULL);
1191 * atspi_accessible_get_component_iface:
1192 * @obj: a pointer to the #AtspiAccessible instance to query.
1194 * Gets the #AtspiComponent interface for an #AtspiAccessible.
1196 * Returns: (transfer full): a pointer to an #AtspiComponent interface
1197 * instance, or NULL if @obj does not implement #AtspiComponent.
1200 atspi_accessible_get_component_iface (AtspiAccessible *obj)
1202 return (_atspi_accessible_is_a (obj, atspi_interface_component) ?
1203 g_object_ref (ATSPI_COMPONENT (obj)) : NULL);
1207 * atspi_accessible_get_document: (rename-to atspi_accessible_get_document_iface)
1208 * @obj: a pointer to the #AtspiAccessible instance to query.
1210 * Gets the #AtspiDocument interface for an #AtspiAccessible.
1212 * Returns: (transfer full): a pointer to an #AtspiDocument interface
1213 * instance, or NULL if @obj does not implement #AtspiDocument.
1215 * Deprecated: 2.10: Use atspi_accessible_get_document_iface instead.
1218 atspi_accessible_get_document (AtspiAccessible *accessible)
1220 return (_atspi_accessible_is_a (accessible, atspi_interface_document) ?
1221 g_object_ref (ATSPI_DOCUMENT (accessible)) : NULL);
1225 * atspi_accessible_get_document_iface:
1226 * @obj: a pointer to the #AtspiAccessible instance to query.
1228 * Gets the #AtspiDocument interface for an #AtspiAccessible.
1230 * Returns: (transfer full): a pointer to an #AtspiDocument interface
1231 * instance, or NULL if @obj does not implement #AtspiDocument.
1234 atspi_accessible_get_document_iface (AtspiAccessible *accessible)
1236 return (_atspi_accessible_is_a (accessible, atspi_interface_document) ?
1237 g_object_ref (ATSPI_DOCUMENT (accessible)) : NULL);
1241 * atspi_accessible_get_editable_text: (rename-to atspi_accessible_get_editable_text_iface)
1242 * @obj: a pointer to the #AtspiAccessible instance to query.
1244 * Gets the #AtspiEditableText interface for an #AtspiAccessible.
1246 * Returns: (transfer full): a pointer to an #AtspiEditableText interface
1247 * instance, or NULL if @obj does not implement #AtspiEditableText.
1249 * Deprecated: 2.10: Use atspi_accessible_get_editable_text_iface instead.
1252 atspi_accessible_get_editable_text (AtspiAccessible *accessible)
1254 return (_atspi_accessible_is_a (accessible, atspi_interface_editable_text) ?
1255 g_object_ref (ATSPI_EDITABLE_TEXT (accessible)) : NULL);
1259 * atspi_accessible_get_editable_text_iface:
1260 * @obj: a pointer to the #AtspiAccessible instance to query.
1262 * Gets the #AtspiEditableText interface for an #AtspiAccessible.
1264 * Returns: (transfer full): a pointer to an #AtspiEditableText interface
1265 * instance, or NULL if @obj does not implement #AtspiEditableText.
1268 atspi_accessible_get_editable_text_iface (AtspiAccessible *accessible)
1270 return (_atspi_accessible_is_a (accessible, atspi_interface_editable_text) ?
1271 g_object_ref (ATSPI_EDITABLE_TEXT (accessible)) : NULL);
1275 * atspi_accessible_get_hyperlink:
1276 * @obj: a pointer to the #AtspiAccessible object on which to operate.
1278 * Gets the #AtspiHyperlink interface for an #AtspiAccessible.
1280 * Returns: (transfer full): the #AtspiHyperlink object associated with
1281 * the given #AtspiAccessible, or NULL if not supported.
1284 atspi_accessible_get_hyperlink (AtspiAccessible *accessible)
1286 return (_atspi_accessible_is_a (accessible, atspi_interface_hyperlink) ?
1287 _atspi_hyperlink_new (accessible->parent.app, accessible->parent.path) : NULL);
1291 * atspi_accessible_get_hypertext: (rename-to atspi_accessible_get_hypertext_iface)
1292 * @obj: a pointer to the #AtspiAccessible instance to query.
1294 * Gets the #AtspiHypertext interface for an #AtspiAccessible.
1296 * Returns: (transfer full): a pointer to an #AtspiHypertext interface
1297 * instance, or NULL if @obj does not implement #AtspiHypertext.
1299 * Deprecated: 2.10: Use atspi_accessible_get_hypertext_iface instead.
1302 atspi_accessible_get_hypertext (AtspiAccessible *accessible)
1304 return (_atspi_accessible_is_a (accessible, atspi_interface_hypertext) ?
1305 g_object_ref (ATSPI_HYPERTEXT (accessible)) : NULL);
1309 * atspi_accessible_get_hypertext_iface:
1310 * @obj: a pointer to the #AtspiAccessible instance to query.
1312 * Gets the #AtspiHypertext interface for an #AtspiAccessible.
1314 * Returns: (transfer full): a pointer to an #AtspiHypertext interface
1315 * instance, or NULL if @obj does not implement #AtspiHypertext.
1318 atspi_accessible_get_hypertext_iface (AtspiAccessible *accessible)
1320 return (_atspi_accessible_is_a (accessible, atspi_interface_hypertext) ?
1321 g_object_ref (ATSPI_HYPERTEXT (accessible)) : NULL);
1325 * atspi_accessible_get_image: (rename-to atspi_accessible_get_image_iface)
1326 * @obj: a pointer to the #AtspiAccessible instance to query.
1328 * Gets the #AtspiImage interface for an #AtspiAccessible.
1330 * Returns: (transfer full): a pointer to an #AtspiImage interface instance, or
1331 * NULL if @obj does not implement #AtspiImage.
1333 * Deprecated: 2.10: Use atspi_accessible_get_image_iface instead.
1336 atspi_accessible_get_image (AtspiAccessible *accessible)
1338 return (_atspi_accessible_is_a (accessible, atspi_interface_image) ?
1339 g_object_ref (ATSPI_IMAGE (accessible)) : NULL);
1343 * atspi_accessible_get_image_iface:
1344 * @obj: a pointer to the #AtspiAccessible instance to query.
1346 * Gets the #AtspiImage interface for an #AtspiAccessible.
1348 * Returns: (transfer full): a pointer to an #AtspiImage interface instance, or
1349 * NULL if @obj does not implement #AtspiImage.
1352 atspi_accessible_get_image_iface (AtspiAccessible *accessible)
1354 return (_atspi_accessible_is_a (accessible, atspi_interface_image) ?
1355 g_object_ref (ATSPI_IMAGE (accessible)) : NULL);
1359 * atspi_accessible_get_selection: (rename-to atspi_accessible_get_selection_iface)
1360 * @obj: a pointer to the #AtspiAccessible instance to query.
1362 * Gets the #AtspiSelection interface for an #AtspiAccessible.
1364 * Returns: (transfer full): a pointer to an #AtspiSelection interface
1365 * instance, or NULL if @obj does not implement #AtspiSelection.
1367 * Deprecated: 2.10: Use atspi_accessible_get_selection_iface instead.
1370 atspi_accessible_get_selection (AtspiAccessible *accessible)
1372 return (_atspi_accessible_is_a (accessible, atspi_interface_selection) ?
1373 g_object_ref (ATSPI_SELECTION (accessible)) : NULL);
1377 * atspi_accessible_get_selection_iface:
1378 * @obj: a pointer to the #AtspiAccessible instance to query.
1380 * Gets the #AtspiSelection interface for an #AtspiAccessible.
1382 * Returns: (transfer full): a pointer to an #AtspiSelection interface
1383 * instance, or NULL if @obj does not implement #AtspiSelection.
1386 atspi_accessible_get_selection_iface (AtspiAccessible *accessible)
1388 return (_atspi_accessible_is_a (accessible, atspi_interface_selection) ?
1389 g_object_ref (ATSPI_SELECTION (accessible)) : NULL);
1394 * atspi_accessible_get_streamable_content:
1395 * @obj: a pointer to the #AtspiAccessible instance to query.
1397 * Gets the #AtspiStreamableContent interface for an #AtspiAccessible.
1399 * Returns: (transfer full): a pointer to an #AtspiStreamableContent interface
1400 * instance, or NULL if @obj does not implement #AtspiStreamableContent.
1402 AtspiStreamableContent *
1403 atspi_accessible_get_streamable_content (AtspiAccessible *accessible)
1405 return (_atspi_accessible_is_a (accessible, atspi_interface_streamable_content) ?
1411 * atspi_accessible_get_table: (rename-to atspi_accessible_get_table_iface)
1412 * @obj: a pointer to the #AtspiAccessible instance to query.
1414 * Gets the #AtspiTable interface for an #AtspiAccessible.
1416 * Returns: (transfer full): a pointer to an #AtspiTable interface instance, or
1417 * NULL if @obj does not implement #AtspiTable.
1419 * Deprecated: 2.10: Use atspi_accessible_get_table_iface instead.
1422 atspi_accessible_get_table (AtspiAccessible *obj)
1424 return (_atspi_accessible_is_a (obj, atspi_interface_table) ?
1425 g_object_ref (ATSPI_TABLE (obj)) : NULL);
1429 * atspi_accessible_get_table_iface:
1430 * @obj: a pointer to the #AtspiAccessible instance to query.
1432 * Gets the #AtspiTable interface for an #AtspiAccessible.
1434 * Returns: (transfer full): a pointer to an #AtspiTable interface instance, or
1435 * NULL if @obj does not implement #AtspiTable.
1438 atspi_accessible_get_table_iface (AtspiAccessible *obj)
1440 return (_atspi_accessible_is_a (obj, atspi_interface_table) ?
1441 g_object_ref (ATSPI_TABLE (obj)) : NULL);
1445 * atspi_accessible_get_table_cell:
1446 * @obj: a pointer to the #AtspiAccessible instance to query.
1448 * Gets the #AtspiTableCell interface for an #AtspiAccessible.
1450 * Returns: (transfer full): a pointer to an #AtspiTableCell interface instance,
1451 * or NULL if @obj does not implement #AtspiTable.
1454 atspi_accessible_get_table_cell (AtspiAccessible *obj)
1456 return (_atspi_accessible_is_a (obj, atspi_interface_table_cell) ?
1457 g_object_ref (ATSPI_TABLE_CELL (obj)) : NULL);
1461 * atspi_accessible_get_text: (rename-to atspi_accessible_get_text_iface)
1462 * @obj: a pointer to the #AtspiAccessible instance to query.
1464 * Gets the #AtspiTable interface for an #AtspiAccessible.
1466 * Returns: (transfer full): a pointer to an #AtspiText interface instance, or
1467 * NULL if @obj does not implement #AtspiText.
1469 * Deprecated: 2.10: Use atspi_accessible_get_text_iface instead.
1472 atspi_accessible_get_text (AtspiAccessible *obj)
1474 return (_atspi_accessible_is_a (obj, atspi_interface_text) ?
1475 g_object_ref (ATSPI_TEXT (obj)) : NULL);
1479 * atspi_accessible_get_text_iface:
1480 * @obj: a pointer to the #AtspiAccessible instance to query.
1482 * Gets the #AtspiTable interface for an #AtspiAccessible.
1484 * Returns: (transfer full): a pointer to an #AtspiText interface instance, or
1485 * NULL if @obj does not implement #AtspiText.
1488 atspi_accessible_get_text_iface (AtspiAccessible *obj)
1490 return (_atspi_accessible_is_a (obj, atspi_interface_text) ?
1491 g_object_ref (ATSPI_TEXT (obj)) : NULL);
1495 * atspi_accessible_get_value: (rename-to atspi_accessible_get_value_iface)
1496 * @obj: a pointer to the #AtspiAccessible instance to query.
1498 * Gets the #AtspiTable interface for an #AtspiAccessible.
1500 * Returns: (transfer full): a pointer to an #AtspiValue interface instance, or
1501 * NULL if @obj does not implement #AtspiValue.
1503 * Deprecated: 2.10: Use atspi_accessible_get_value_iface instead.
1506 atspi_accessible_get_value (AtspiAccessible *accessible)
1508 return (_atspi_accessible_is_a (accessible, atspi_interface_value) ?
1509 g_object_ref (ATSPI_VALUE (accessible)) : NULL);
1513 * atspi_accessible_get_value_iface:
1514 * @obj: a pointer to the #AtspiAccessible instance to query.
1516 * Gets the #AtspiTable interface for an #AtspiAccessible.
1518 * Returns: (transfer full): a pointer to an #AtspiValue interface instance, or
1519 * NULL if @obj does not implement #AtspiValue.
1522 atspi_accessible_get_value_iface (AtspiAccessible *accessible)
1524 return (_atspi_accessible_is_a (accessible, atspi_interface_value) ?
1525 g_object_ref (ATSPI_VALUE (accessible)) : NULL);
1529 append_const_val (GArray *array, const gchar *val)
1531 gchar *dup = g_strdup (val);
1534 g_array_append_val (array, dup);
1538 * atspi_accessible_get_interfaces:
1539 * @obj: The #AtspiAccessible to query.
1541 * A set of pointers to all interfaces supported by an #AtspiAccessible.
1543 * Returns: (element-type gchar*) (transfer full): A #GArray of strings
1544 * describing the interfaces supported by the object. Interfaces are
1545 * denoted in short-hand (i.e. "Component", "Text" etc.).
1548 atspi_accessible_get_interfaces (AtspiAccessible *obj)
1550 GArray *ret = g_array_new (TRUE, TRUE, sizeof (gchar *));
1552 g_return_val_if_fail (obj != NULL, NULL);
1554 append_const_val (ret, "Accessible");
1555 if (atspi_accessible_is_action (obj))
1556 append_const_val (ret, "Action");
1557 if (atspi_accessible_is_collection (obj))
1558 append_const_val (ret, "Collection");
1559 if (atspi_accessible_is_component (obj))
1560 append_const_val (ret, "Component");
1561 if (atspi_accessible_is_document (obj))
1562 append_const_val (ret, "Document");
1563 if (atspi_accessible_is_editable_text (obj))
1564 append_const_val (ret, "EditableText");
1565 if (atspi_accessible_is_hypertext (obj))
1566 append_const_val (ret, "Hypertext");
1567 if (atspi_accessible_is_hyperlink (obj))
1568 append_const_val (ret, "Hyperlink");
1569 if (atspi_accessible_is_image (obj))
1570 append_const_val (ret, "Image");
1571 if (atspi_accessible_is_selection (obj))
1572 append_const_val (ret, "Selection");
1573 if (atspi_accessible_is_table (obj))
1574 append_const_val (ret, "Table");
1575 if (atspi_accessible_is_table_cell (obj))
1576 append_const_val (ret, "TableCell");
1577 if (atspi_accessible_is_text (obj))
1578 append_const_val (ret, "Text");
1579 if (atspi_accessible_is_value (obj))
1580 append_const_val (ret, "Value");
1586 _atspi_accessible_new (AtspiApplication *app, const gchar *path)
1588 AtspiAccessible *accessible;
1590 accessible = g_object_new (ATSPI_TYPE_ACCESSIBLE, NULL);
1591 g_return_val_if_fail (accessible != NULL, NULL);
1593 accessible->parent.app = g_object_ref (app);
1594 accessible->parent.path = g_strdup (path);
1600 * atspi_accessible_set_cache_mask:
1601 * @accessible: The #AtspiAccessible to operate on. Must be the desktop or
1602 * the root of an application.
1603 * @mask: An #AtspiCache specifying a bit mask of the types of data to cache.
1605 * Sets the type of data to cache for accessibles.
1606 * If this is not set for an application or is reset to ATSPI_CACHE_UNDEFINED,
1607 * then the desktop's cache flag will be used.
1608 * If the desktop's cache flag is also undefined, then all possible data will
1610 * This function is intended to work around bugs in toolkits where the proper
1611 * events are not raised / to aid in testing for such bugs.
1614 atspi_accessible_set_cache_mask (AtspiAccessible *accessible, AtspiCache mask)
1616 g_return_if_fail (accessible != NULL);
1617 g_return_if_fail (accessible->parent.app != NULL);
1618 g_return_if_fail (accessible == accessible->parent.app->root);
1619 accessible->parent.app->cache = mask;
1620 enable_caching = TRUE;
1624 * atspi_accessible_clear_cache:
1625 * @obj: The #AtspiAccessible whose cache to clear.
1627 * Clears the cached information for the given accessible and all of its
1631 atspi_accessible_clear_cache (AtspiAccessible *obj)
1637 obj->cached_properties = ATSPI_CACHE_NONE;
1639 for (i = 0; i < obj->children->len; i++)
1640 atspi_accessible_clear_cache (g_ptr_array_index (obj->children, i));
1645 * atspi_accessible_get_process_id:
1646 * @accessible: The #AtspiAccessible to query.
1647 * @error: a pointer to a %NULL #GError pointer
1649 * Returns the process id associated with the given accessible. Mainly
1650 * added for debugging; it is a shortcut to explicitly querying the
1651 * accessible's app->bus_name and then calling GetConnectionUnixProcessID.
1653 * Returns: The process ID or undetermined value if @error is set.
1656 atspi_accessible_get_process_id (AtspiAccessible *accessible, GError **error)
1658 DBusMessage *message, *reply;
1659 DBusConnection *bus = _atspi_bus ();
1660 dbus_uint32_t pid = -1;
1663 if (!accessible->parent.app || !accessible->parent.app->bus_name)
1665 g_set_error_literal(error, ATSPI_ERROR, ATSPI_ERROR_IPC, "Process is defunct");
1669 message = dbus_message_new_method_call ("org.freedesktop.DBus",
1670 "/org/freedesktop/DBus",
1671 "org.freedesktop.DBus",
1672 "GetConnectionUnixProcessID");
1673 dbus_message_append_args (message, DBUS_TYPE_STRING,
1674 &accessible->parent.app->bus_name,
1676 dbus_error_init (&d_error);
1677 reply = dbus_connection_send_with_reply_and_block (bus, message, -1, &d_error);
1678 dbus_message_unref (message);
1681 if (!strcmp (dbus_message_get_signature (reply), "u"))
1682 dbus_message_get_args (reply, NULL, DBUS_TYPE_UINT32, &pid, DBUS_TYPE_INVALID);
1683 dbus_message_unref (reply);
1685 if (dbus_error_is_set (&d_error))
1687 g_set_error_literal(error, ATSPI_ERROR, ATSPI_ERROR_IPC, "Process is defunct");
1688 dbus_error_free (&d_error);
1694 _atspi_accessible_get_cache_mask (AtspiAccessible *accessible)
1698 if (!accessible->parent.app)
1699 return ATSPI_CACHE_NONE;
1701 mask = accessible->parent.app->cache;
1702 if (mask == ATSPI_CACHE_UNDEFINED &&
1703 accessible->parent.app->root &&
1704 accessible->parent.app->root->accessible_parent)
1706 AtspiAccessible *desktop = atspi_get_desktop (0);
1707 mask = desktop->parent.app->cache;
1708 g_object_unref (desktop);
1711 if (mask == ATSPI_CACHE_UNDEFINED)
1712 mask = ATSPI_CACHE_DEFAULT;
1718 _atspi_accessible_test_cache (AtspiAccessible *accessible, AtspiCache flag)
1720 AtspiCache mask = _atspi_accessible_get_cache_mask (accessible);
1721 AtspiCache result = accessible->cached_properties & mask & flag;
1722 if (accessible->states && atspi_state_set_contains (accessible->states, ATSPI_STATE_TRANSIENT))
1724 return (result != 0 && (atspi_main_loop || enable_caching ||
1725 flag == ATSPI_CACHE_INTERFACES) &&
1730 _atspi_accessible_add_cache (AtspiAccessible *accessible, AtspiCache flag)
1732 AtspiCache mask = _atspi_accessible_get_cache_mask (accessible);
1734 accessible->cached_properties |= flag & mask;
1738 * atspi_accessible_get_locale:
1739 * @accessible: an #AtspiAccessible
1741 * Gets a UTF-8 string indicating the POSIX-style LC_MESSAGES locale
1746 * Returns: a UTF-8 string indicating the POSIX-style LC_MESSAGES
1747 * locale of @accessible.
1750 atspi_accessible_get_object_locale (AtspiAccessible *accessible, GError **error)
1754 g_return_val_if_fail (accessible != NULL, NULL);
1756 locale = g_object_get_qdata (G_OBJECT (accessible), quark_locale);
1759 if (!_atspi_dbus_get_property (accessible, atspi_interface_accessible,
1760 "Locale", error, "s", &locale))
1763 g_object_set_qdata_full (G_OBJECT (accessible), quark_locale, locale,
1770 free_value (gpointer data)
1772 GValue *value = data;
1774 g_value_unset (value);
1779 _atspi_accessible_ref_cache (AtspiAccessible *accessible)
1781 AtspiAccessiblePrivate *priv = accessible->priv;
1783 priv->cache_ref_count++;
1785 return g_hash_table_ref (priv->cache);
1786 priv->cache = g_hash_table_new_full (g_str_hash, g_str_equal, g_free,
1792 _atspi_accessible_unref_cache (AtspiAccessible *accessible)
1794 AtspiAccessiblePrivate *priv = accessible->priv;
1798 g_hash_table_unref (priv->cache);
1799 if (--priv->cache_ref_count == 0)