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 #ifdef DEBUG_REF_COUNTS
195 g_hash_table_remove (_atspi_get_live_refs (), accessible);
196 g_print ("at-spi: finalize: %d objects\n", accessible_count);
199 G_OBJECT_CLASS (atspi_accessible_parent_class)
204 atspi_accessible_class_init (AtspiAccessibleClass *klass)
206 GObjectClass *object_class = G_OBJECT_CLASS (klass);
208 object_class->dispose = atspi_accessible_dispose;
209 object_class->finalize = atspi_accessible_finalize;
211 quark_locale = g_quark_from_string ("accessible-locale");
215 * atspi_accessible_get_name:
216 * @obj: a pointer to the #AtspiAccessible object on which to operate.
218 * Gets the name of an #AtspiAccessible object.
220 * Returns: a UTF-8 string indicating the name of the #AtspiAccessible object
221 * or NULL on exception.
224 atspi_accessible_get_name (AtspiAccessible *obj, GError **error)
226 g_return_val_if_fail (obj != NULL, g_strdup (""));
227 if (!_atspi_accessible_test_cache (obj, ATSPI_CACHE_NAME))
229 if (!_atspi_dbus_get_property (obj, atspi_interface_accessible, "Name", error,
231 return g_strdup ("");
232 _atspi_accessible_add_cache (obj, ATSPI_CACHE_NAME);
234 return g_strdup (obj->name);
238 * atspi_accessible_get_description:
239 * @obj: a pointer to the #AtspiAccessible object on which to operate.
241 * Gets the description of an #AtspiAccessible object.
243 * Returns: a UTF-8 string describing the #AtspiAccessible object
244 * or NULL on exception.
247 atspi_accessible_get_description (AtspiAccessible *obj, GError **error)
249 g_return_val_if_fail (obj != NULL, g_strdup (""));
251 if (!_atspi_accessible_test_cache (obj, ATSPI_CACHE_DESCRIPTION))
253 if (!_atspi_dbus_get_property (obj, atspi_interface_accessible,
254 "Description", error, "s",
256 return g_strdup ("");
257 _atspi_accessible_add_cache (obj, ATSPI_CACHE_DESCRIPTION);
259 return g_strdup (obj->description);
262 const char *str_parent = "Parent";
265 * atspi_accessible_get_parent:
266 * @obj: a pointer to the #AtspiAccessible object to query.
268 * Gets an #AtspiAccessible object's parent container.
270 * Returns: (nullable) (transfer full): a pointer to the
271 * #AtspiAccessible object which contains the given
272 * #AtspiAccessible instance, or NULL if the @obj has no
277 atspi_accessible_get_parent (AtspiAccessible *obj, GError **error)
279 g_return_val_if_fail (obj != NULL, NULL);
281 if (obj->parent.app &&
282 !_atspi_accessible_test_cache (obj, ATSPI_CACHE_PARENT))
284 DBusMessage *message, *reply;
285 DBusMessageIter iter, iter_variant;
286 message = dbus_message_new_method_call (obj->parent.app->bus_name,
288 DBUS_INTERFACE_PROPERTIES, "Get");
291 dbus_message_append_args (message, DBUS_TYPE_STRING, &atspi_interface_accessible,
292 DBUS_TYPE_STRING, &str_parent,
294 reply = _atspi_dbus_send_with_reply_and_block (message, error);
297 if (strcmp (dbus_message_get_signature (reply), "v") != 0)
299 dbus_message_unref (reply);
302 dbus_message_iter_init (reply, &iter);
303 dbus_message_iter_recurse (&iter, &iter_variant);
304 obj->accessible_parent = _atspi_dbus_return_accessible_from_iter (&iter_variant);
305 dbus_message_unref (reply);
306 _atspi_accessible_add_cache (obj, ATSPI_CACHE_PARENT);
308 if (!obj->accessible_parent)
310 return g_object_ref (obj->accessible_parent);
314 * atspi_accessible_get_child_count:
315 * @obj: a pointer to the #AtspiAccessible object on which to operate.
317 * Gets the number of children contained by an #AtspiAccessible object.
319 * Returns: a #long indicating the number of #AtspiAccessible children
320 * contained by an #AtspiAccessible object or -1 on exception.
324 atspi_accessible_get_child_count (AtspiAccessible *obj, GError **error)
326 g_return_val_if_fail (obj != NULL, -1);
328 if (!_atspi_accessible_test_cache (obj, ATSPI_CACHE_CHILDREN))
331 if (!_atspi_dbus_get_property (obj, atspi_interface_accessible,
332 "ChildCount", error, "i", &ret))
337 return g_list_length (obj->children);
341 * atspi_accessible_get_child_at_index:
342 * @obj: a pointer to the #AtspiAccessible object on which to operate.
343 * @child_index: a #long indicating which child is specified.
345 * Gets the #AtspiAccessible child of an #AtspiAccessible object at a given index.
347 * Returns: (transfer full): a pointer to the #AtspiAccessible child object at
348 * index @child_index or NULL on exception.
351 atspi_accessible_get_child_at_index (AtspiAccessible *obj,
355 AtspiAccessible *child;
357 g_return_val_if_fail (obj != NULL, NULL);
359 if (!_atspi_accessible_test_cache (obj, ATSPI_CACHE_CHILDREN))
362 reply = _atspi_dbus_call_partial (obj, atspi_interface_accessible,
363 "GetChildAtIndex", error, "i",
365 return _atspi_dbus_return_accessible_from_message (reply);
368 child = g_list_nth_data (obj->children, child_index);
371 return g_object_ref (child);
375 * atspi_accessible_get_index_in_parent:
376 * @obj: a pointer to the #AtspiAccessible object on which to operate.
378 * Gets the index of an #AtspiAccessible object within its parent's
379 * #AtspiAccessible children list.
381 * Returns: a #glong indicating the index of the #AtspiAccessible object
383 * or -1 if @obj has no containing parent or on exception.
386 atspi_accessible_get_index_in_parent (AtspiAccessible *obj, GError **error)
391 g_return_val_if_fail (obj != NULL, -1);
392 if (_atspi_accessible_test_cache (obj, ATSPI_CACHE_PARENT) &&
393 !obj->accessible_parent)
395 if (!obj->accessible_parent ||
396 !_atspi_accessible_test_cache (obj->accessible_parent,
397 ATSPI_CACHE_CHILDREN))
399 dbus_int32_t ret = -1;
400 _atspi_dbus_call (obj, atspi_interface_accessible,
401 "GetIndexInParent", NULL, "=>i", &ret);
405 l = obj->accessible_parent->children;
408 if (l->data == obj) return i;
419 } Accessibility_Relation;
422 * atspi_accessible_get_relation_set:
423 * @obj: a pointer to the #AtspiAccessible object on which to operate.
425 * Gets the set of #AtspiRelation objects which describes this #AtspiAccessible object's
426 * relationships with other #AtspiAccessible objects.
428 * Returns: (element-type AtspiAccessible*) (transfer full): a #GArray of
429 * #AtspiRelation pointers or NULL on exception.
432 atspi_accessible_get_relation_set (AtspiAccessible *obj, GError **error)
435 DBusMessageIter iter, iter_array;
438 g_return_val_if_fail (obj != NULL, NULL);
440 reply = _atspi_dbus_call_partial (obj, atspi_interface_accessible, "GetRelationSet", error, "");
443 _ATSPI_DBUS_CHECK_SIG (reply, "a(ua(so))", error, NULL);
445 ret = g_array_new (TRUE, TRUE, sizeof (AtspiRelation *));
446 dbus_message_iter_init (reply, &iter);
447 dbus_message_iter_recurse (&iter, &iter_array);
448 while (dbus_message_iter_get_arg_type (&iter_array) != DBUS_TYPE_INVALID)
450 AtspiRelation *relation;
451 relation = _atspi_relation_new_from_iter (&iter_array);
452 ret = g_array_append_val (ret, relation);
453 dbus_message_iter_next (&iter_array);
455 dbus_message_unref (reply);
460 * atspi_accessible_get_role:
461 * @obj: a pointer to the #AtspiAccessible object on which to operate.
463 * Gets the UI role played by an #AtspiAccessible object.
464 * This role's name can be obtained via atspi_accessible_get_role_name ().
466 * Returns: the #AtspiRole of an #AtspiAccessible object.
470 atspi_accessible_get_role (AtspiAccessible *obj, GError **error)
472 g_return_val_if_fail (obj != NULL, ATSPI_ROLE_INVALID);
474 if (!_atspi_accessible_test_cache (obj, ATSPI_CACHE_ROLE))
477 /* TODO: Make this a property */
478 if (_atspi_dbus_call (obj, atspi_interface_accessible, "GetRole", error, "=>u", &role))
481 _atspi_accessible_add_cache (obj, ATSPI_CACHE_ROLE);
488 * atspi_accessible_get_role_name:
489 * @obj: a pointer to the #AtspiAccessible object on which to operate.
491 * Gets a UTF-8 string corresponding to the name of the role played by an object.
492 * This method will return useful values for roles that fall outside the
493 * enumeration used in atspi_accessible_get_role ().
495 * Returns: a UTF-8 string specifying the type of UI role played by an
496 * #AtspiAccessible object.
500 atspi_accessible_get_role_name (AtspiAccessible *obj, GError **error)
502 gchar *retval = NULL;
505 g_return_val_if_fail (obj != NULL, NULL);
507 role = atspi_accessible_get_role (obj, error);
508 if (role >= 0 && role < ATSPI_ROLE_COUNT && role != ATSPI_ROLE_EXTENDED)
509 return atspi_role_get_name (role);
511 _atspi_dbus_call (obj, atspi_interface_accessible, "GetRoleName", error, "=>s", &retval);
514 retval = g_strdup ("");
520 * atspi_accessible_get_localized_role_name:
521 * @obj: a pointer to the #AtspiAccessible object on which to operate.
523 * Gets a UTF-8 string corresponding to the name of the role played by an
524 * object, translated to the current locale.
525 * This method will return useful values for roles that fall outside the
526 * enumeration used in atspi_accessible_getRole ().
528 * Returns: a localized, UTF-8 string specifying the type of UI role played
529 * by an #AtspiAccessible object.
533 atspi_accessible_get_localized_role_name (AtspiAccessible *obj, GError **error)
537 g_return_val_if_fail (obj != NULL, NULL);
539 _atspi_dbus_call (obj, atspi_interface_accessible, "GetLocalizedRoleName", error, "=>s", &retval);
542 return g_strdup ("");
547 static AtspiStateSet *
550 AtspiStateSet *set = atspi_state_set_new (NULL);
551 atspi_state_set_add (set, ATSPI_STATE_DEFUNCT);
556 * atspi_accessible_get_state_set:
557 * @obj: a pointer to the #AtspiAccessible object on which to operate.
559 * Gets the states currently held by an object.
561 * Returns: (transfer full): a pointer to an #AtspiStateSet representing an
562 * object's current state set.
565 atspi_accessible_get_state_set (AtspiAccessible *obj)
567 /* TODO: Should take a GError **, but would be an API break */
568 if (!obj->parent.app || !obj->parent.app->bus)
569 return defunct_set ();
571 if (!_atspi_accessible_test_cache (obj, ATSPI_CACHE_STATES))
574 DBusMessageIter iter;
575 reply = _atspi_dbus_call_partial (obj, atspi_interface_accessible,
576 "GetState", NULL, "");
577 _ATSPI_DBUS_CHECK_SIG (reply, "au", NULL, defunct_set ());
578 dbus_message_iter_init (reply, &iter);
579 _atspi_dbus_set_state (obj, &iter);
580 dbus_message_unref (reply);
581 _atspi_accessible_add_cache (obj, ATSPI_CACHE_STATES);
584 return g_object_ref (obj->states);
588 * atspi_accessible_get_attributes:
589 * @obj: The #AtspiAccessible being queried.
591 * Gets the #AttributeSet representing any assigned
592 * name-value pair attributes or annotations for this object.
593 * For typographic, textual, or textually-semantic attributes, see
594 * atspi_text_get_attributes instead.
596 * Returns: (element-type gchar* gchar*) (transfer full): The name-value-pair
597 * attributes assigned to this object.
600 atspi_accessible_get_attributes (AtspiAccessible *obj, GError **error)
602 DBusMessage *message;
604 g_return_val_if_fail (obj != NULL, NULL);
606 if (obj->priv->cache)
608 GValue *val = g_hash_table_lookup (obj->priv->cache, "Attributes");
610 return g_value_dup_boxed (val);
613 if (!_atspi_accessible_test_cache (obj, ATSPI_CACHE_ATTRIBUTES))
615 message = _atspi_dbus_call_partial (obj, atspi_interface_accessible,
616 "GetAttributes", error, "");
617 obj->attributes = _atspi_dbus_return_hash_from_message (message);
618 _atspi_accessible_add_cache (obj, ATSPI_CACHE_ATTRIBUTES);
621 if (!obj->attributes)
623 return g_hash_table_ref (obj->attributes);
627 add_to_attribute_array (gpointer key, gpointer value, gpointer data)
629 GArray **array = (GArray **)data;
630 gchar *str = g_strconcat (key, ":", value, NULL);
631 *array = g_array_append_val (*array, str);
635 * atspi_accessible_get_attributes_as_array:
636 * @obj: The #AtspiAccessible being queried.
638 * Gets a #GArray representing any assigned
639 * name-value pair attributes or annotations for this object.
640 * For typographic, textual, or textually-semantic attributes, see
641 * atspi_text_get_attributes_as_array instead.
643 * Returns: (element-type gchar*) (transfer full): The name-value-pair
644 * attributes assigned to this object.
647 atspi_accessible_get_attributes_as_array (AtspiAccessible *obj, GError **error)
649 DBusMessage *message;
651 g_return_val_if_fail (obj != NULL, NULL);
653 if (obj->priv->cache)
655 GValue *val = g_hash_table_lookup (obj->priv->cache, "Attributes");
658 GArray *array = g_array_new (TRUE, TRUE, sizeof (gchar *));
659 GHashTable *attributes = g_value_get_boxed (val);
660 g_hash_table_foreach (attributes, add_to_attribute_array, &array);
665 message = _atspi_dbus_call_partial (obj, atspi_interface_accessible, "GetAttributes", error, "");
666 return _atspi_dbus_return_attribute_array_from_message (message);
670 * atspi_accessible_get_application:
671 * @obj: The #AtspiAccessible being queried.
673 * Gets the containing #AtspiApplication for an object.
675 * Returns: (transfer full): the containing #AtspiApplication instance for
679 atspi_accessible_get_application (AtspiAccessible *obj, GError **error)
681 AtspiAccessible *parent;
686 parent = atspi_accessible_get_parent (obj, NULL);
687 if (!parent && obj->parent.app &&
688 atspi_accessible_get_role (obj, NULL) != ATSPI_ROLE_APPLICATION)
690 AtspiAccessible *root = g_object_ref (obj->parent.app->root);
693 g_object_unref (obj);
694 if (atspi_accessible_get_role (root, NULL) == ATSPI_ROLE_DESKTOP_FRAME)
696 g_object_unref (root);
702 if (!parent || parent == obj ||
703 atspi_accessible_get_role (parent, NULL) == ATSPI_ROLE_DESKTOP_FRAME)
706 g_object_unref (parent);
709 g_object_unref (obj);
714 /* Application-specific methods */
717 * atspi_accessible_get_toolkit_name:
718 * @obj: a pointer to the #AtspiAccessible object on which to operate.
720 * Gets the toolkit name for an #AtspiAccessible object.
721 * Only works on application root objects.
723 * Returns: a UTF-8 string indicating the toolkit name for the #AtspiAccessible object or NULL on exception.
726 atspi_accessible_get_toolkit_name (AtspiAccessible *obj, GError **error)
728 g_return_val_if_fail (obj != NULL, NULL);
730 if (!obj->parent.app)
733 if (!obj->parent.app->toolkit_name)
734 _atspi_dbus_get_property (obj, atspi_interface_application, "ToolkitName",
735 error, "s", &obj->parent.app->toolkit_name);
737 return g_strdup (obj->parent.app->toolkit_name);
741 * atspi_accessible_get_toolkit_version:
742 * @obj: a pointer to the #AtspiAccessible object on which to operate.
744 * Gets the toolkit version for an #AtspiAccessible object.
745 * Only works on application root objects.
747 * Returns: a UTF-8 string indicating the toolkit version for the #AtspiAccessible object or NULL on exception.
750 atspi_accessible_get_toolkit_version (AtspiAccessible *obj, GError **error)
752 g_return_val_if_fail (obj != NULL, NULL);
754 if (!obj->parent.app)
757 if (!obj->parent.app->toolkit_version)
758 _atspi_dbus_get_property (obj, atspi_interface_application, "Version",
759 error, "s", &obj->parent.app->toolkit_version);
761 return g_strdup (obj->parent.app->toolkit_version);
765 * atspi_accessible_get_atspi_version:
766 * @obj: a pointer to the #AtspiAccessible object on which to operate.
768 * Gets the AT-SPI IPC specification version supported by the application
769 * pointed to by the #AtspiAccessible object.
770 * Only works on application root objects.
772 * Returns: a UTF-8 string indicating the AT-SPI version for the #AtspiAccessible object or NULL on exception.
775 atspi_accessible_get_atspi_version (AtspiAccessible *obj, GError **error)
777 g_return_val_if_fail (obj != NULL, NULL);
779 if (!obj->parent.app)
782 if (!obj->parent.app->atspi_version)
783 _atspi_dbus_get_property (obj, atspi_interface_application, "AtspiVersion",
784 error, "s", &obj->parent.app->atspi_version);
786 return g_strdup (obj->parent.app->atspi_version);
790 * atspi_accessible_get_id:
791 * @obj: a pointer to the #AtspiAccessible object on which to operate.
793 * Gets the application id for a #AtspiAccessible object.
794 * Only works on application root objects.
796 * Returns: a positive #gint indicating the id for the #AtspiAccessible object
797 * or -1 on exception.
800 atspi_accessible_get_id (AtspiAccessible *obj, GError **error)
804 g_return_val_if_fail (obj != NULL, -1);
806 if (!_atspi_dbus_get_property (obj, atspi_interface_application, "Id", error, "i", &ret))
812 /* Interface query methods */
815 _atspi_accessible_is_a (AtspiAccessible *accessible,
816 const char *interface_name)
820 if (accessible == NULL)
825 if (!_atspi_accessible_test_cache (accessible, ATSPI_CACHE_INTERFACES))
828 DBusMessageIter iter;
829 reply = _atspi_dbus_call_partial (accessible, atspi_interface_accessible,
830 "GetInterfaces", NULL, "");
831 _ATSPI_DBUS_CHECK_SIG (reply, "as", NULL, FALSE);
832 dbus_message_iter_init (reply, &iter);
833 _atspi_dbus_set_interfaces (accessible, &iter);
834 dbus_message_unref (reply);
835 _atspi_accessible_add_cache (accessible, ATSPI_CACHE_INTERFACES);
838 n = _atspi_get_iface_num (interface_name);
839 if (n == -1) return FALSE;
840 return (gboolean) ((accessible->interfaces & (1 << n))? TRUE: FALSE);
844 * atspi_accessible_is_action:
845 * @obj: a pointer to the #AtspiAccessible instance to query.
847 * Query whether the specified #AtspiAccessible implements the
848 * #AtspiAction interface.
850 * Returns: #TRUE if @obj implements the #AtspiAction interface,
854 atspi_accessible_is_action (AtspiAccessible *obj)
856 return _atspi_accessible_is_a (obj,
857 atspi_interface_action);
861 * atspi_accessible_is_application:
862 * @obj: a pointer to the #AtspiAccessible instance to query.
864 * Query whether the specified #AtspiAccessible implements the
865 * #AtspiApplication interface.
867 * Returns: #TRUE if @obj implements the #AtspiApplication interface,
871 atspi_accessible_is_application (AtspiAccessible *obj)
873 return _atspi_accessible_is_a (obj,
874 atspi_interface_application);
878 * atspi_accessible_is_collection:
879 * @obj: a pointer to the #AtspiAccessible instance to query.
881 * Query whether the specified #AtspiAccessible implements the
882 * #AtspiCollection interface.
884 * Returns: #TRUE if @obj implements the #AtspiCollection interface,
888 atspi_accessible_is_collection (AtspiAccessible *obj)
890 return _atspi_accessible_is_a (obj,
891 atspi_interface_collection);
895 * atspi_accessible_is_component:
896 * @obj: a pointer to the #AtspiAccessible instance to query.
898 * Query whether the specified #AtspiAccessible implements #AtspiComponent.
900 * Returns: #TRUE if @obj implements the #AtspiComponent interface,
904 atspi_accessible_is_component (AtspiAccessible *obj)
906 return _atspi_accessible_is_a (obj,
907 atspi_interface_component);
911 * atspi_accessible_is_document:
912 * @obj: a pointer to the #AtspiAccessible instance to query.
914 * Query whether the specified #AtspiAccessible implements the
915 * #AtspiDocument interface.
917 * Returns: #TRUE if @obj implements the #AtspiDocument interface,
921 atspi_accessible_is_document (AtspiAccessible *obj)
923 return _atspi_accessible_is_a (obj,
924 atspi_interface_document);
928 * atspi_accessible_is_editable_text:
929 * @obj: a pointer to the #AtspiAccessible instance to query.
931 * Query whether the specified #AtspiAccessible implements the
932 * #AtspiEditableText interface.
934 * Returns: #TRUE if @obj implements the #AtspiEditableText interface,
938 atspi_accessible_is_editable_text (AtspiAccessible *obj)
940 return _atspi_accessible_is_a (obj,
941 atspi_interface_editable_text);
945 * atspi_accessible_is_hypertext:
946 * @obj: a pointer to the #AtspiAccessible instance to query.
948 * Query whether the specified #AtspiAccessible implements the
949 * #AtspiHypertext interface.
951 * Returns: #TRUE if @obj implements the #AtspiHypertext interface,
955 atspi_accessible_is_hypertext (AtspiAccessible *obj)
957 return _atspi_accessible_is_a (obj,
958 atspi_interface_hypertext);
962 * atspi_accessible_is_hyperlink:
963 * @obj: a pointer to the #AtspiAccessible instance to query.
965 * Query whether the specified #AtspiAccessible implements the
966 * #AtspiHyperlink interface.
968 * Returns: #TRUE if @obj implements the #AtspiHypertext interface,
972 atspi_accessible_is_hyperlink (AtspiAccessible *obj)
974 return _atspi_accessible_is_a (obj,
975 atspi_interface_hyperlink);
979 * atspi_accessible_is_image:
980 * @obj: a pointer to the #AtspiAccessible instance to query.
982 * Query whether the specified #AtspiAccessible implements the
983 * #AtspiImage interface.
985 * Returns: #TRUE if @obj implements the #AtspiImage interface,
989 atspi_accessible_is_image (AtspiAccessible *obj)
991 return _atspi_accessible_is_a (obj,
992 atspi_interface_image);
996 * atspi_accessible_is_selection:
997 * @obj: a pointer to the #AtspiAccessible instance to query.
999 * Query whether the specified #AtspiAccessible implements the
1000 * #AtspiSelection interface.
1002 * Returns: #TRUE if @obj implements the #AtspiSelection interface,
1006 atspi_accessible_is_selection (AtspiAccessible *obj)
1008 return _atspi_accessible_is_a (obj,
1009 atspi_interface_selection);
1013 * atspi_accessible_is_table:
1014 * @obj: a pointer to the #AtspiAccessible instance to query.
1016 * Query whether the specified #AtspiAccessible implements the
1017 * #AtspiTable interface.
1019 * Returns: #TRUE if @obj implements the #AtspiTable interface,
1023 atspi_accessible_is_table (AtspiAccessible *obj)
1025 return _atspi_accessible_is_a (obj,
1026 atspi_interface_table);
1030 * atspi_accessible_is_table_cell:
1031 * @obj: a pointer to the #AtspiAccessible instance to query.
1033 * Query whether the specified #AtspiAccessible implements the
1034 * #AtspiTableCell interface.
1036 * Returns: #TRUE if @obj implements the #AtspiTable interface,
1040 atspi_accessible_is_table_cell (AtspiAccessible *obj)
1042 return _atspi_accessible_is_a (obj,
1043 atspi_interface_table_cell);
1047 * atspi_accessible_is_streamable_content:
1048 * @obj: a pointer to the #AtspiAccessible instance to query.
1050 * Query whether the specified #AtspiAccessible implements the
1051 * #AtspiStreamableContent interface.
1053 * Returns: #TRUE if @obj implements the #AtspiStreamableContent interface,
1057 atspi_accessible_is_streamable_content (AtspiAccessible *obj)
1060 return _atspi_accessible_is_a (obj,
1061 atspi_interface_streamable_content);
1063 g_warning ("Streamable content not implemented");
1069 * atspi_accessible_is_text:
1070 * @obj: a pointer to the #AtspiAccessible instance to query.
1072 * Query whether the specified #AtspiAccessible implements the
1073 * #AtspiText interface.
1075 * Returns: #TRUE if @obj implements the #AtspiText interface,
1079 atspi_accessible_is_text (AtspiAccessible *obj)
1081 return _atspi_accessible_is_a (obj,
1082 atspi_interface_text);
1086 * atspi_accessible_is_value:
1087 * @obj: a pointer to the #AtspiAccessible instance to query.
1089 * Query whether the specified #AtspiAccessible implements the
1090 * #AtspiValue interface.
1092 * Returns: #TRUE if @obj implements the #AtspiValue interface,
1096 atspi_accessible_is_value (AtspiAccessible *obj)
1098 return _atspi_accessible_is_a (obj,
1099 atspi_interface_value);
1103 * atspi_accessible_get_action:
1104 * @obj: a pointer to the #AtspiAccessible instance to query.
1106 * Gets the #AtspiAction interface for an #AtspiAccessible.
1108 * Returns: (transfer full): a pointer to an #AtspiAction interface
1109 * instance, or NULL if @obj does not implement #AtspiAction.
1111 * Deprecated: 2.10: Use atspi_accessible_get_action_iface instead.
1112 * Rename to: atspi_accessible_get_action_iface
1115 atspi_accessible_get_action (AtspiAccessible *accessible)
1117 return (_atspi_accessible_is_a (accessible, atspi_interface_action) ?
1118 g_object_ref (ATSPI_ACTION (accessible)) : NULL);
1122 * atspi_accessible_get_action_iface:
1123 * @obj: a pointer to the #AtspiAccessible instance to query.
1125 * Gets the #AtspiAction interface for an #AtspiAccessible.
1127 * Returns: (transfer full): a pointer to an #AtspiAction interface
1128 * instance, or NULL if @obj does not implement #AtspiAction.
1131 atspi_accessible_get_action_iface (AtspiAccessible *accessible)
1133 return (_atspi_accessible_is_a (accessible, atspi_interface_action) ?
1134 g_object_ref (ATSPI_ACTION (accessible)) : NULL);
1138 * atspi_accessible_get_collection:
1139 * @obj: a pointer to the #AtspiAccessible instance to query.
1141 * Gets the #AtspiCollection interface for an #AtspiAccessible.
1143 * Returns: (transfer full): a pointer to an #AtspiCollection interface
1144 * instance, or NULL if @obj does not implement #AtspiCollection.
1146 * Deprecated: 2.10: Use atspi_accessible_get_collection_iface instead.
1147 * Rename to: atspi_accessible_get_collection_iface
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:
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.
1182 * Rename to: atspi_accessible_get_component_iface
1185 atspi_accessible_get_component (AtspiAccessible *obj)
1187 return (_atspi_accessible_is_a (obj, atspi_interface_component) ?
1188 g_object_ref (ATSPI_COMPONENT (obj)) : NULL);
1192 * atspi_accessible_get_component_iface:
1193 * @obj: a pointer to the #AtspiAccessible instance to query.
1195 * Gets the #AtspiComponent interface for an #AtspiAccessible.
1197 * Returns: (transfer full): a pointer to an #AtspiComponent interface
1198 * instance, or NULL if @obj does not implement #AtspiComponent.
1201 atspi_accessible_get_component_iface (AtspiAccessible *obj)
1203 return (_atspi_accessible_is_a (obj, atspi_interface_component) ?
1204 g_object_ref (ATSPI_COMPONENT (obj)) : NULL);
1208 * atspi_accessible_get_document:
1209 * @obj: a pointer to the #AtspiAccessible instance to query.
1211 * Gets the #AtspiDocument interface for an #AtspiAccessible.
1213 * Returns: (transfer full): a pointer to an #AtspiDocument interface
1214 * instance, or NULL if @obj does not implement #AtspiDocument.
1216 * Deprecated: 2.10: Use atspi_accessible_get_document_iface instead.
1217 * Rename to: atspi_accessible_get_document_iface
1220 atspi_accessible_get_document (AtspiAccessible *accessible)
1222 return (_atspi_accessible_is_a (accessible, atspi_interface_document) ?
1223 g_object_ref (ATSPI_DOCUMENT (accessible)) : NULL);
1227 * atspi_accessible_get_document_iface:
1228 * @obj: a pointer to the #AtspiAccessible instance to query.
1230 * Gets the #AtspiDocument interface for an #AtspiAccessible.
1232 * Returns: (transfer full): a pointer to an #AtspiDocument interface
1233 * instance, or NULL if @obj does not implement #AtspiDocument.
1236 atspi_accessible_get_document_iface (AtspiAccessible *accessible)
1238 return (_atspi_accessible_is_a (accessible, atspi_interface_document) ?
1239 g_object_ref (ATSPI_DOCUMENT (accessible)) : NULL);
1243 * atspi_accessible_get_editable_text:
1244 * @obj: a pointer to the #AtspiAccessible instance to query.
1246 * Gets the #AtspiEditableText interface for an #AtspiAccessible.
1248 * Returns: (transfer full): a pointer to an #AtspiEditableText interface
1249 * instance, or NULL if @obj does not implement #AtspiEditableText.
1251 * Deprecated: 2.10: Use atspi_accessible_get_editable_text_iface instead.
1252 * Rename to: atspi_accessible_get_editable_text_iface
1255 atspi_accessible_get_editable_text (AtspiAccessible *accessible)
1257 return (_atspi_accessible_is_a (accessible, atspi_interface_editable_text) ?
1258 g_object_ref (ATSPI_EDITABLE_TEXT (accessible)) : NULL);
1262 * atspi_accessible_get_editable_text_iface:
1263 * @obj: a pointer to the #AtspiAccessible instance to query.
1265 * Gets the #AtspiEditableText interface for an #AtspiAccessible.
1267 * Returns: (transfer full): a pointer to an #AtspiEditableText interface
1268 * instance, or NULL if @obj does not implement #AtspiEditableText.
1271 atspi_accessible_get_editable_text_iface (AtspiAccessible *accessible)
1273 return (_atspi_accessible_is_a (accessible, atspi_interface_editable_text) ?
1274 g_object_ref (ATSPI_EDITABLE_TEXT (accessible)) : NULL);
1278 * atspi_accessible_get_hyperlink:
1279 * @obj: a pointer to the #AtspiAccessible object on which to operate.
1281 * Gets the #AtspiHyperlink interface for an #AtspiAccessible.
1283 * Returns: (transfer full): the #AtspiHyperlink object associated with
1284 * the given #AtspiAccessible, or NULL if not supported.
1287 atspi_accessible_get_hyperlink (AtspiAccessible *accessible)
1289 return (_atspi_accessible_is_a (accessible, atspi_interface_hyperlink) ?
1290 _atspi_hyperlink_new (accessible->parent.app, accessible->parent.path) : NULL);
1294 * atspi_accessible_get_hypertext:
1295 * @obj: a pointer to the #AtspiAccessible instance to query.
1297 * Gets the #AtspiHypertext interface for an #AtspiAccessible.
1299 * Returns: (transfer full): a pointer to an #AtspiHypertext interface
1300 * instance, or NULL if @obj does not implement #AtspiHypertext.
1302 * Deprecated: 2.10: Use atspi_accessible_get_hypertext_iface instead.
1303 * Rename to: atspi_accessible_get_hypertext_iface
1306 atspi_accessible_get_hypertext (AtspiAccessible *accessible)
1308 return (_atspi_accessible_is_a (accessible, atspi_interface_hypertext) ?
1309 g_object_ref (ATSPI_HYPERTEXT (accessible)) : NULL);
1313 * atspi_accessible_get_hypertext_iface:
1314 * @obj: a pointer to the #AtspiAccessible instance to query.
1316 * Gets the #AtspiHypertext interface for an #AtspiAccessible.
1318 * Returns: (transfer full): a pointer to an #AtspiHypertext interface
1319 * instance, or NULL if @obj does not implement #AtspiHypertext.
1322 atspi_accessible_get_hypertext_iface (AtspiAccessible *accessible)
1324 return (_atspi_accessible_is_a (accessible, atspi_interface_hypertext) ?
1325 g_object_ref (ATSPI_HYPERTEXT (accessible)) : NULL);
1329 * atspi_accessible_get_image:
1330 * @obj: a pointer to the #AtspiAccessible instance to query.
1332 * Gets the #AtspiImage interface for an #AtspiAccessible.
1334 * Returns: (transfer full): a pointer to an #AtspiImage interface instance, or
1335 * NULL if @obj does not implement #AtspiImage.
1337 * Deprecated: 2.10: Use atspi_accessible_get_image_iface instead.
1338 * Rename to: atspi_accessible_get_image_iface
1341 atspi_accessible_get_image (AtspiAccessible *accessible)
1343 return (_atspi_accessible_is_a (accessible, atspi_interface_image) ?
1344 g_object_ref (ATSPI_IMAGE (accessible)) : NULL);
1348 * atspi_accessible_get_image_iface:
1349 * @obj: a pointer to the #AtspiAccessible instance to query.
1351 * Gets the #AtspiImage interface for an #AtspiAccessible.
1353 * Returns: (transfer full): a pointer to an #AtspiImage interface instance, or
1354 * NULL if @obj does not implement #AtspiImage.
1357 atspi_accessible_get_image_iface (AtspiAccessible *accessible)
1359 return (_atspi_accessible_is_a (accessible, atspi_interface_image) ?
1360 g_object_ref (ATSPI_IMAGE (accessible)) : NULL);
1364 * atspi_accessible_get_selection:
1365 * @obj: a pointer to the #AtspiAccessible instance to query.
1367 * Gets the #AtspiSelection interface for an #AtspiAccessible.
1369 * Returns: (transfer full): a pointer to an #AtspiSelection interface
1370 * instance, or NULL if @obj does not implement #AtspiSelection.
1372 * Deprecated: 2.10: Use atspi_accessible_get_selection_iface instead.
1373 * Rename to: atspi_accessible_get_selection_iface
1376 atspi_accessible_get_selection (AtspiAccessible *accessible)
1378 return (_atspi_accessible_is_a (accessible, atspi_interface_selection) ?
1379 g_object_ref (ATSPI_SELECTION (accessible)) : NULL);
1383 * atspi_accessible_get_selection_iface:
1384 * @obj: a pointer to the #AtspiAccessible instance to query.
1386 * Gets the #AtspiSelection interface for an #AtspiAccessible.
1388 * Returns: (transfer full): a pointer to an #AtspiSelection interface
1389 * instance, or NULL if @obj does not implement #AtspiSelection.
1392 atspi_accessible_get_selection_iface (AtspiAccessible *accessible)
1394 return (_atspi_accessible_is_a (accessible, atspi_interface_selection) ?
1395 g_object_ref (ATSPI_SELECTION (accessible)) : NULL);
1400 * atspi_accessible_get_streamable_content:
1401 * @obj: a pointer to the #AtspiAccessible instance to query.
1403 * Gets the #AtspiStreamableContent interface for an #AtspiAccessible.
1405 * Returns: (transfer full): a pointer to an #AtspiStreamableContent interface
1406 * instance, or NULL if @obj does not implement #AtspiStreamableContent.
1408 AtspiStreamableContent *
1409 atspi_accessible_get_streamable_content (AtspiAccessible *accessible)
1411 return (_atspi_accessible_is_a (accessible, atspi_interface_streamable_content) ?
1417 * atspi_accessible_get_table:
1418 * @obj: a pointer to the #AtspiAccessible instance to query.
1420 * Gets the #AtspiTable interface for an #AtspiAccessible.
1422 * Returns: (transfer full): a pointer to an #AtspiTable interface instance, or
1423 * NULL if @obj does not implement #AtspiTable.
1425 * Deprecated: 2.10: Use atspi_accessible_get_table_iface instead.
1426 * Rename to: atspi_accessible_get_table_iface
1429 atspi_accessible_get_table (AtspiAccessible *obj)
1431 return (_atspi_accessible_is_a (obj, atspi_interface_table) ?
1432 g_object_ref (ATSPI_TABLE (obj)) : NULL);
1436 * 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.
1445 atspi_accessible_get_table_iface (AtspiAccessible *obj)
1447 return (_atspi_accessible_is_a (obj, atspi_interface_table) ?
1448 g_object_ref (ATSPI_TABLE (obj)) : NULL);
1452 * atspi_accessible_get_table_cell:
1453 * @obj: a pointer to the #AtspiAccessible instance to query.
1455 * Gets the #AtspiTableCell interface for an #AtspiAccessible.
1457 * Returns: (transfer full): a pointer to an #AtspiTableCell interface instance,
1458 * or NULL if @obj does not implement #AtspiTable.
1461 atspi_accessible_get_table_cell (AtspiAccessible *obj)
1463 return (_atspi_accessible_is_a (obj, atspi_interface_table_cell) ?
1464 g_object_ref (ATSPI_TABLE_CELL (obj)) : NULL);
1468 * atspi_accessible_get_text:
1469 * @obj: a pointer to the #AtspiAccessible instance to query.
1471 * Gets the #AtspiTable interface for an #AtspiAccessible.
1473 * Returns: (transfer full): a pointer to an #AtspiText interface instance, or
1474 * NULL if @obj does not implement #AtspiText.
1476 * Deprecated: 2.10: Use atspi_accessible_get_text_iface instead.
1477 * Rename to: atspi_accessible_get_text_iface
1480 atspi_accessible_get_text (AtspiAccessible *obj)
1482 return (_atspi_accessible_is_a (obj, atspi_interface_text) ?
1483 g_object_ref (ATSPI_TEXT (obj)) : NULL);
1487 * atspi_accessible_get_text_iface:
1488 * @obj: a pointer to the #AtspiAccessible instance to query.
1490 * Gets the #AtspiTable interface for an #AtspiAccessible.
1492 * Returns: (transfer full): a pointer to an #AtspiText interface instance, or
1493 * NULL if @obj does not implement #AtspiText.
1496 atspi_accessible_get_text_iface (AtspiAccessible *obj)
1498 return (_atspi_accessible_is_a (obj, atspi_interface_text) ?
1499 g_object_ref (ATSPI_TEXT (obj)) : NULL);
1503 * atspi_accessible_get_value:
1504 * @obj: a pointer to the #AtspiAccessible instance to query.
1506 * Gets the #AtspiTable interface for an #AtspiAccessible.
1508 * Returns: (transfer full): a pointer to an #AtspiValue interface instance, or
1509 * NULL if @obj does not implement #AtspiValue.
1511 * Deprecated: 2.10: Use atspi_accessible_get_value_iface instead.
1512 * Rename to: atspi_accessible_get_value_iface
1515 atspi_accessible_get_value (AtspiAccessible *accessible)
1517 return (_atspi_accessible_is_a (accessible, atspi_interface_value) ?
1518 g_object_ref (ATSPI_VALUE (accessible)) : NULL);
1522 * atspi_accessible_get_value_iface:
1523 * @obj: a pointer to the #AtspiAccessible instance to query.
1525 * Gets the #AtspiTable interface for an #AtspiAccessible.
1527 * Returns: (transfer full): a pointer to an #AtspiValue interface instance, or
1528 * NULL if @obj does not implement #AtspiValue.
1531 atspi_accessible_get_value_iface (AtspiAccessible *accessible)
1533 return (_atspi_accessible_is_a (accessible, atspi_interface_value) ?
1534 g_object_ref (ATSPI_VALUE (accessible)) : NULL);
1538 append_const_val (GArray *array, const gchar *val)
1540 gchar *dup = g_strdup (val);
1543 g_array_append_val (array, dup);
1547 * atspi_accessible_get_interfaces:
1548 * @obj: The #AtspiAccessible to query.
1550 * A set of pointers to all interfaces supported by an #AtspiAccessible.
1552 * Returns: (element-type gchar*) (transfer full): A #GArray of strings
1553 * describing the interfaces supported by the object. Interfaces are
1554 * denoted in short-hand (i.e. "Component", "Text" etc.).
1557 atspi_accessible_get_interfaces (AtspiAccessible *obj)
1559 GArray *ret = g_array_new (TRUE, TRUE, sizeof (gchar *));
1561 g_return_val_if_fail (obj != NULL, NULL);
1563 append_const_val (ret, "Accessible");
1564 if (atspi_accessible_is_action (obj))
1565 append_const_val (ret, "Action");
1566 if (atspi_accessible_is_collection (obj))
1567 append_const_val (ret, "Collection");
1568 if (atspi_accessible_is_component (obj))
1569 append_const_val (ret, "Component");
1570 if (atspi_accessible_is_document (obj))
1571 append_const_val (ret, "Document");
1572 if (atspi_accessible_is_editable_text (obj))
1573 append_const_val (ret, "EditableText");
1574 if (atspi_accessible_is_hypertext (obj))
1575 append_const_val (ret, "Hypertext");
1576 if (atspi_accessible_is_hyperlink (obj))
1577 append_const_val (ret, "Hyperlink");
1578 if (atspi_accessible_is_image (obj))
1579 append_const_val (ret, "Image");
1580 if (atspi_accessible_is_selection (obj))
1581 append_const_val (ret, "Selection");
1582 if (atspi_accessible_is_table (obj))
1583 append_const_val (ret, "Table");
1584 if (atspi_accessible_is_table_cell (obj))
1585 append_const_val (ret, "TableCell");
1586 if (atspi_accessible_is_text (obj))
1587 append_const_val (ret, "Text");
1588 if (atspi_accessible_is_value (obj))
1589 append_const_val (ret, "Value");
1595 _atspi_accessible_new (AtspiApplication *app, const gchar *path)
1597 AtspiAccessible *accessible;
1599 accessible = g_object_new (ATSPI_TYPE_ACCESSIBLE, NULL);
1600 g_return_val_if_fail (accessible != NULL, NULL);
1602 accessible->parent.app = g_object_ref (app);
1603 accessible->parent.path = g_strdup (path);
1609 * atspi_accessible_set_cache_mask:
1610 * @accessible: The #AtspiAccessible to operate on. Must be the desktop or
1611 * the root of an application.
1612 * @mask: An #AtspiCache specifying a bit mask of the types of data to cache.
1614 * Sets the type of data to cache for accessibles.
1615 * If this is not set for an application or is reset to ATSPI_CACHE_UNDEFINED,
1616 * then the desktop's cache flag will be used.
1617 * If the desktop's cache flag is also undefined, then all possible data will
1619 * This function is intended to work around bugs in toolkits where the proper
1620 * events are not raised / to aid in testing for such bugs.
1623 atspi_accessible_set_cache_mask (AtspiAccessible *accessible, AtspiCache mask)
1625 g_return_if_fail (accessible != NULL);
1626 g_return_if_fail (accessible->parent.app != NULL);
1627 g_return_if_fail (accessible == accessible->parent.app->root);
1628 accessible->parent.app->cache = mask;
1629 enable_caching = TRUE;
1633 * atspi_accessible_clear_cache:
1634 * @accessible: The #AtspiAccessible whose cache to clear.
1636 * Clears the cached information for the given accessible and all of its
1640 atspi_accessible_clear_cache (AtspiAccessible *accessible)
1646 accessible->cached_properties = ATSPI_CACHE_NONE;
1647 for (l = accessible->children; l; l = l->next)
1648 atspi_accessible_clear_cache (l->data);
1653 * atspi_accessible_get_process_id:
1654 * @accessible: The #AtspiAccessible to query.
1655 * @error: a pointer to a %NULL #GError pointer
1657 * Returns the process id associated with the given accessible. Mainly
1658 * added for debugging; it is a shortcut to explicitly querying the
1659 * accessible's app->bus_name and then calling GetConnectionUnixProcessID.
1661 * Returns: The process ID or undetermined value if @error is set.
1664 atspi_accessible_get_process_id (AtspiAccessible *accessible, GError **error)
1666 DBusMessage *message, *reply;
1667 DBusConnection *bus = _atspi_bus ();
1668 dbus_uint32_t pid = -1;
1671 if (!accessible->parent.app || !accessible->parent.app->bus_name)
1673 g_set_error_literal(error, ATSPI_ERROR, ATSPI_ERROR_IPC, "Process is defunct");
1677 message = dbus_message_new_method_call ("org.freedesktop.DBus",
1678 "/org/freedesktop/DBus",
1679 "org.freedesktop.DBus",
1680 "GetConnectionUnixProcessID");
1681 dbus_message_append_args (message, DBUS_TYPE_STRING,
1682 &accessible->parent.app->bus_name,
1684 dbus_error_init (&d_error);
1685 reply = dbus_connection_send_with_reply_and_block (bus, message, -1, &d_error);
1686 dbus_message_unref (message);
1689 if (!strcmp (dbus_message_get_signature (reply), "u"))
1690 dbus_message_get_args (reply, NULL, DBUS_TYPE_UINT32, &pid, DBUS_TYPE_INVALID);
1691 dbus_message_unref (reply);
1693 if (dbus_error_is_set (&d_error))
1695 g_set_error_literal(error, ATSPI_ERROR, ATSPI_ERROR_IPC, "Process is defunct");
1696 dbus_error_free (&d_error);
1702 _atspi_accessible_get_cache_mask (AtspiAccessible *accessible)
1706 if (!accessible->parent.app)
1707 return ATSPI_CACHE_NONE;
1709 mask = accessible->parent.app->cache;
1710 if (mask == ATSPI_CACHE_UNDEFINED &&
1711 accessible->parent.app->root &&
1712 accessible->parent.app->root->accessible_parent)
1714 AtspiAccessible *desktop = atspi_get_desktop (0);
1715 mask = desktop->parent.app->cache;
1716 g_object_unref (desktop);
1719 if (mask == ATSPI_CACHE_UNDEFINED)
1720 mask = ATSPI_CACHE_DEFAULT;
1726 _atspi_accessible_test_cache (AtspiAccessible *accessible, AtspiCache flag)
1728 AtspiCache mask = _atspi_accessible_get_cache_mask (accessible);
1729 AtspiCache result = accessible->cached_properties & mask & flag;
1730 if (accessible->states && atspi_state_set_contains (accessible->states, ATSPI_STATE_TRANSIENT))
1732 return (result != 0 && (atspi_main_loop || enable_caching ||
1733 flag == ATSPI_CACHE_INTERFACES) &&
1738 _atspi_accessible_add_cache (AtspiAccessible *accessible, AtspiCache flag)
1740 AtspiCache mask = _atspi_accessible_get_cache_mask (accessible);
1742 accessible->cached_properties |= flag & mask;
1746 * atspi_accessible_get_locale:
1747 * @accessible: an #AtspiAccessible
1749 * Gets a UTF-8 string indicating the POSIX-style LC_MESSAGES locale
1754 * Returns: a UTF-8 string indicating the POSIX-style LC_MESSAGES
1755 * locale of @accessible.
1758 atspi_accessible_get_object_locale (AtspiAccessible *accessible, GError **error)
1762 g_return_val_if_fail (accessible != NULL, NULL);
1764 locale = g_object_get_qdata (G_OBJECT (accessible), quark_locale);
1767 if (!_atspi_dbus_get_property (accessible, atspi_interface_accessible,
1768 "Locale", error, "s", &locale))
1771 g_object_set_qdata_full (G_OBJECT (accessible), quark_locale, locale,
1778 free_value (gpointer data)
1780 GValue *value = data;
1782 g_value_unset (value);
1787 _atspi_accessible_ref_cache (AtspiAccessible *accessible)
1789 AtspiAccessiblePrivate *priv = accessible->priv;
1791 priv->cache_ref_count++;
1793 return g_hash_table_ref (priv->cache);
1794 priv->cache = g_hash_table_new_full (g_str_hash, g_str_equal, g_free,
1800 _atspi_accessible_unref_cache (AtspiAccessible *accessible)
1802 AtspiAccessiblePrivate *priv = accessible->priv;
1806 g_hash_table_unref (priv->cache);
1807 if (--priv->cache_ref_count == 0)