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 _atspi_accessible_unref_cache (accessible);
195 #ifdef DEBUG_REF_COUNTS
197 g_hash_table_remove (_atspi_get_live_refs (), accessible);
198 g_print ("at-spi: finalize: %d objects\n", accessible_count);
201 G_OBJECT_CLASS (atspi_accessible_parent_class)
206 atspi_accessible_class_init (AtspiAccessibleClass *klass)
208 GObjectClass *object_class = G_OBJECT_CLASS (klass);
210 object_class->dispose = atspi_accessible_dispose;
211 object_class->finalize = atspi_accessible_finalize;
213 quark_locale = g_quark_from_string ("accessible-locale");
217 * atspi_accessible_get_name:
218 * @obj: a pointer to the #AtspiAccessible object on which to operate.
220 * Gets the name of an #AtspiAccessible object.
222 * Returns: a UTF-8 string indicating the name of the #AtspiAccessible object
223 * or NULL on exception.
226 atspi_accessible_get_name (AtspiAccessible *obj, GError **error)
228 g_return_val_if_fail (obj != NULL, g_strdup (""));
229 if (!_atspi_accessible_test_cache (obj, ATSPI_CACHE_NAME))
231 if (!_atspi_dbus_get_property (obj, atspi_interface_accessible, "Name", error,
233 return g_strdup ("");
234 _atspi_accessible_add_cache (obj, ATSPI_CACHE_NAME);
236 return g_strdup (obj->name);
240 * atspi_accessible_get_description:
241 * @obj: a pointer to the #AtspiAccessible object on which to operate.
243 * Gets the description of an #AtspiAccessible object.
245 * Returns: a UTF-8 string describing the #AtspiAccessible object
246 * or NULL on exception.
249 atspi_accessible_get_description (AtspiAccessible *obj, GError **error)
251 g_return_val_if_fail (obj != NULL, g_strdup (""));
253 if (!_atspi_accessible_test_cache (obj, ATSPI_CACHE_DESCRIPTION))
255 if (!_atspi_dbus_get_property (obj, atspi_interface_accessible,
256 "Description", error, "s",
258 return g_strdup ("");
259 _atspi_accessible_add_cache (obj, ATSPI_CACHE_DESCRIPTION);
261 return g_strdup (obj->description);
264 const char *str_parent = "Parent";
267 * atspi_accessible_get_parent:
268 * @obj: a pointer to the #AtspiAccessible object to query.
270 * Gets an #AtspiAccessible object's parent container.
272 * Returns: (nullable) (transfer full): a pointer to the
273 * #AtspiAccessible object which contains the given
274 * #AtspiAccessible instance, or NULL if the @obj has no
279 atspi_accessible_get_parent (AtspiAccessible *obj, GError **error)
281 g_return_val_if_fail (obj != NULL, NULL);
283 if (obj->parent.app &&
284 !_atspi_accessible_test_cache (obj, ATSPI_CACHE_PARENT))
286 DBusMessage *message, *reply;
287 DBusMessageIter iter, iter_variant;
288 message = dbus_message_new_method_call (obj->parent.app->bus_name,
290 DBUS_INTERFACE_PROPERTIES, "Get");
293 dbus_message_append_args (message, DBUS_TYPE_STRING, &atspi_interface_accessible,
294 DBUS_TYPE_STRING, &str_parent,
296 reply = _atspi_dbus_send_with_reply_and_block (message, error);
299 if (strcmp (dbus_message_get_signature (reply), "v") != 0)
301 dbus_message_unref (reply);
304 dbus_message_iter_init (reply, &iter);
305 dbus_message_iter_recurse (&iter, &iter_variant);
306 obj->accessible_parent = _atspi_dbus_return_accessible_from_iter (&iter_variant);
307 dbus_message_unref (reply);
308 _atspi_accessible_add_cache (obj, ATSPI_CACHE_PARENT);
310 if (!obj->accessible_parent)
312 return g_object_ref (obj->accessible_parent);
316 * atspi_accessible_get_child_count:
317 * @obj: a pointer to the #AtspiAccessible object on which to operate.
319 * Gets the number of children contained by an #AtspiAccessible object.
321 * Returns: a #long indicating the number of #AtspiAccessible children
322 * contained by an #AtspiAccessible object or -1 on exception.
326 atspi_accessible_get_child_count (AtspiAccessible *obj, GError **error)
328 g_return_val_if_fail (obj != NULL, -1);
330 if (!_atspi_accessible_test_cache (obj, ATSPI_CACHE_CHILDREN))
333 if (!_atspi_dbus_get_property (obj, atspi_interface_accessible,
334 "ChildCount", error, "i", &ret))
339 return g_list_length (obj->children);
343 * atspi_accessible_get_child_at_index:
344 * @obj: a pointer to the #AtspiAccessible object on which to operate.
345 * @child_index: a #long indicating which child is specified.
347 * Gets the #AtspiAccessible child of an #AtspiAccessible object at a given index.
349 * Returns: (transfer full): a pointer to the #AtspiAccessible child object at
350 * index @child_index or NULL on exception.
353 atspi_accessible_get_child_at_index (AtspiAccessible *obj,
357 AtspiAccessible *child;
359 g_return_val_if_fail (obj != NULL, NULL);
361 if (!_atspi_accessible_test_cache (obj, ATSPI_CACHE_CHILDREN))
364 reply = _atspi_dbus_call_partial (obj, atspi_interface_accessible,
365 "GetChildAtIndex", error, "i",
367 return _atspi_dbus_return_accessible_from_message (reply);
370 child = g_list_nth_data (obj->children, child_index);
373 return g_object_ref (child);
377 * atspi_accessible_get_index_in_parent:
378 * @obj: a pointer to the #AtspiAccessible object on which to operate.
380 * Gets the index of an #AtspiAccessible object within its parent's
381 * #AtspiAccessible children list.
383 * Returns: a #glong indicating the index of the #AtspiAccessible object
385 * or -1 if @obj has no containing parent or on exception.
388 atspi_accessible_get_index_in_parent (AtspiAccessible *obj, GError **error)
393 g_return_val_if_fail (obj != NULL, -1);
394 if (_atspi_accessible_test_cache (obj, ATSPI_CACHE_PARENT) &&
395 !obj->accessible_parent)
397 if (!obj->accessible_parent ||
398 !_atspi_accessible_test_cache (obj->accessible_parent,
399 ATSPI_CACHE_CHILDREN))
401 dbus_int32_t ret = -1;
402 _atspi_dbus_call (obj, atspi_interface_accessible,
403 "GetIndexInParent", NULL, "=>i", &ret);
407 l = obj->accessible_parent->children;
410 if (l->data == obj) return i;
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 AtspiAccessible*) (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:
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.
1114 * Rename to: atspi_accessible_get_action_iface
1117 atspi_accessible_get_action (AtspiAccessible *accessible)
1119 return (_atspi_accessible_is_a (accessible, atspi_interface_action) ?
1120 g_object_ref (ATSPI_ACTION (accessible)) : NULL);
1124 * atspi_accessible_get_action_iface:
1125 * @obj: a pointer to the #AtspiAccessible instance to query.
1127 * Gets the #AtspiAction interface for an #AtspiAccessible.
1129 * Returns: (transfer full): a pointer to an #AtspiAction interface
1130 * instance, or NULL if @obj does not implement #AtspiAction.
1133 atspi_accessible_get_action_iface (AtspiAccessible *accessible)
1135 return (_atspi_accessible_is_a (accessible, atspi_interface_action) ?
1136 g_object_ref (ATSPI_ACTION (accessible)) : NULL);
1140 * atspi_accessible_get_collection:
1141 * @obj: a pointer to the #AtspiAccessible instance to query.
1143 * Gets the #AtspiCollection interface for an #AtspiAccessible.
1145 * Returns: (transfer full): a pointer to an #AtspiCollection interface
1146 * instance, or NULL if @obj does not implement #AtspiCollection.
1148 * Deprecated: 2.10: Use atspi_accessible_get_collection_iface instead.
1149 * Rename to: atspi_accessible_get_collection_iface
1152 atspi_accessible_get_collection (AtspiAccessible *accessible)
1154 return (_atspi_accessible_is_a (accessible, atspi_interface_collection) ?
1155 g_object_ref (ATSPI_COLLECTION (accessible)) : NULL);
1159 * atspi_accessible_get_collection_iface:
1160 * @obj: a pointer to the #AtspiAccessible instance to query.
1162 * Gets the #AtspiCollection interface for an #AtspiAccessible.
1164 * Returns: (transfer full): a pointer to an #AtspiCollection interface
1165 * instance, or NULL if @obj does not implement #AtspiCollection.
1168 atspi_accessible_get_collection_iface (AtspiAccessible *accessible)
1170 return (_atspi_accessible_is_a (accessible, atspi_interface_collection) ?
1171 g_object_ref (ATSPI_COLLECTION (accessible)) : NULL);
1175 * atspi_accessible_get_component:
1176 * @obj: a pointer to the #AtspiAccessible instance to query.
1178 * Gets the #AtspiComponent interface for an #AtspiAccessible.
1180 * Returns: (transfer full): a pointer to an #AtspiComponent interface
1181 * instance, or NULL if @obj does not implement #AtspiComponent.
1183 * Deprecated: 2.10: Use atspi_accessible_get_component_iface instead.
1184 * Rename to: atspi_accessible_get_component_iface
1187 atspi_accessible_get_component (AtspiAccessible *obj)
1189 return (_atspi_accessible_is_a (obj, atspi_interface_component) ?
1190 g_object_ref (ATSPI_COMPONENT (obj)) : NULL);
1194 * atspi_accessible_get_component_iface:
1195 * @obj: a pointer to the #AtspiAccessible instance to query.
1197 * Gets the #AtspiComponent interface for an #AtspiAccessible.
1199 * Returns: (transfer full): a pointer to an #AtspiComponent interface
1200 * instance, or NULL if @obj does not implement #AtspiComponent.
1203 atspi_accessible_get_component_iface (AtspiAccessible *obj)
1205 return (_atspi_accessible_is_a (obj, atspi_interface_component) ?
1206 g_object_ref (ATSPI_COMPONENT (obj)) : NULL);
1210 * atspi_accessible_get_document:
1211 * @obj: a pointer to the #AtspiAccessible instance to query.
1213 * Gets the #AtspiDocument interface for an #AtspiAccessible.
1215 * Returns: (transfer full): a pointer to an #AtspiDocument interface
1216 * instance, or NULL if @obj does not implement #AtspiDocument.
1218 * Deprecated: 2.10: Use atspi_accessible_get_document_iface instead.
1219 * Rename to: atspi_accessible_get_document_iface
1222 atspi_accessible_get_document (AtspiAccessible *accessible)
1224 return (_atspi_accessible_is_a (accessible, atspi_interface_document) ?
1225 g_object_ref (ATSPI_DOCUMENT (accessible)) : NULL);
1229 * atspi_accessible_get_document_iface:
1230 * @obj: a pointer to the #AtspiAccessible instance to query.
1232 * Gets the #AtspiDocument interface for an #AtspiAccessible.
1234 * Returns: (transfer full): a pointer to an #AtspiDocument interface
1235 * instance, or NULL if @obj does not implement #AtspiDocument.
1238 atspi_accessible_get_document_iface (AtspiAccessible *accessible)
1240 return (_atspi_accessible_is_a (accessible, atspi_interface_document) ?
1241 g_object_ref (ATSPI_DOCUMENT (accessible)) : NULL);
1245 * atspi_accessible_get_editable_text:
1246 * @obj: a pointer to the #AtspiAccessible instance to query.
1248 * Gets the #AtspiEditableText interface for an #AtspiAccessible.
1250 * Returns: (transfer full): a pointer to an #AtspiEditableText interface
1251 * instance, or NULL if @obj does not implement #AtspiEditableText.
1253 * Deprecated: 2.10: Use atspi_accessible_get_editable_text_iface instead.
1254 * Rename to: atspi_accessible_get_editable_text_iface
1257 atspi_accessible_get_editable_text (AtspiAccessible *accessible)
1259 return (_atspi_accessible_is_a (accessible, atspi_interface_editable_text) ?
1260 g_object_ref (ATSPI_EDITABLE_TEXT (accessible)) : NULL);
1264 * atspi_accessible_get_editable_text_iface:
1265 * @obj: a pointer to the #AtspiAccessible instance to query.
1267 * Gets the #AtspiEditableText interface for an #AtspiAccessible.
1269 * Returns: (transfer full): a pointer to an #AtspiEditableText interface
1270 * instance, or NULL if @obj does not implement #AtspiEditableText.
1273 atspi_accessible_get_editable_text_iface (AtspiAccessible *accessible)
1275 return (_atspi_accessible_is_a (accessible, atspi_interface_editable_text) ?
1276 g_object_ref (ATSPI_EDITABLE_TEXT (accessible)) : NULL);
1280 * atspi_accessible_get_hyperlink:
1281 * @obj: a pointer to the #AtspiAccessible object on which to operate.
1283 * Gets the #AtspiHyperlink interface for an #AtspiAccessible.
1285 * Returns: (transfer full): the #AtspiHyperlink object associated with
1286 * the given #AtspiAccessible, or NULL if not supported.
1289 atspi_accessible_get_hyperlink (AtspiAccessible *accessible)
1291 return (_atspi_accessible_is_a (accessible, atspi_interface_hyperlink) ?
1292 _atspi_hyperlink_new (accessible->parent.app, accessible->parent.path) : NULL);
1296 * atspi_accessible_get_hypertext:
1297 * @obj: a pointer to the #AtspiAccessible instance to query.
1299 * Gets the #AtspiHypertext interface for an #AtspiAccessible.
1301 * Returns: (transfer full): a pointer to an #AtspiHypertext interface
1302 * instance, or NULL if @obj does not implement #AtspiHypertext.
1304 * Deprecated: 2.10: Use atspi_accessible_get_hypertext_iface instead.
1305 * Rename to: atspi_accessible_get_hypertext_iface
1308 atspi_accessible_get_hypertext (AtspiAccessible *accessible)
1310 return (_atspi_accessible_is_a (accessible, atspi_interface_hypertext) ?
1311 g_object_ref (ATSPI_HYPERTEXT (accessible)) : NULL);
1315 * atspi_accessible_get_hypertext_iface:
1316 * @obj: a pointer to the #AtspiAccessible instance to query.
1318 * Gets the #AtspiHypertext interface for an #AtspiAccessible.
1320 * Returns: (transfer full): a pointer to an #AtspiHypertext interface
1321 * instance, or NULL if @obj does not implement #AtspiHypertext.
1324 atspi_accessible_get_hypertext_iface (AtspiAccessible *accessible)
1326 return (_atspi_accessible_is_a (accessible, atspi_interface_hypertext) ?
1327 g_object_ref (ATSPI_HYPERTEXT (accessible)) : NULL);
1331 * atspi_accessible_get_image:
1332 * @obj: a pointer to the #AtspiAccessible instance to query.
1334 * Gets the #AtspiImage interface for an #AtspiAccessible.
1336 * Returns: (transfer full): a pointer to an #AtspiImage interface instance, or
1337 * NULL if @obj does not implement #AtspiImage.
1339 * Deprecated: 2.10: Use atspi_accessible_get_image_iface instead.
1340 * Rename to: atspi_accessible_get_image_iface
1343 atspi_accessible_get_image (AtspiAccessible *accessible)
1345 return (_atspi_accessible_is_a (accessible, atspi_interface_image) ?
1346 g_object_ref (ATSPI_IMAGE (accessible)) : NULL);
1350 * atspi_accessible_get_image_iface:
1351 * @obj: a pointer to the #AtspiAccessible instance to query.
1353 * Gets the #AtspiImage interface for an #AtspiAccessible.
1355 * Returns: (transfer full): a pointer to an #AtspiImage interface instance, or
1356 * NULL if @obj does not implement #AtspiImage.
1359 atspi_accessible_get_image_iface (AtspiAccessible *accessible)
1361 return (_atspi_accessible_is_a (accessible, atspi_interface_image) ?
1362 g_object_ref (ATSPI_IMAGE (accessible)) : NULL);
1366 * atspi_accessible_get_selection:
1367 * @obj: a pointer to the #AtspiAccessible instance to query.
1369 * Gets the #AtspiSelection interface for an #AtspiAccessible.
1371 * Returns: (transfer full): a pointer to an #AtspiSelection interface
1372 * instance, or NULL if @obj does not implement #AtspiSelection.
1374 * Deprecated: 2.10: Use atspi_accessible_get_selection_iface instead.
1375 * Rename to: atspi_accessible_get_selection_iface
1378 atspi_accessible_get_selection (AtspiAccessible *accessible)
1380 return (_atspi_accessible_is_a (accessible, atspi_interface_selection) ?
1381 g_object_ref (ATSPI_SELECTION (accessible)) : NULL);
1385 * atspi_accessible_get_selection_iface:
1386 * @obj: a pointer to the #AtspiAccessible instance to query.
1388 * Gets the #AtspiSelection interface for an #AtspiAccessible.
1390 * Returns: (transfer full): a pointer to an #AtspiSelection interface
1391 * instance, or NULL if @obj does not implement #AtspiSelection.
1394 atspi_accessible_get_selection_iface (AtspiAccessible *accessible)
1396 return (_atspi_accessible_is_a (accessible, atspi_interface_selection) ?
1397 g_object_ref (ATSPI_SELECTION (accessible)) : NULL);
1402 * atspi_accessible_get_streamable_content:
1403 * @obj: a pointer to the #AtspiAccessible instance to query.
1405 * Gets the #AtspiStreamableContent interface for an #AtspiAccessible.
1407 * Returns: (transfer full): a pointer to an #AtspiStreamableContent interface
1408 * instance, or NULL if @obj does not implement #AtspiStreamableContent.
1410 AtspiStreamableContent *
1411 atspi_accessible_get_streamable_content (AtspiAccessible *accessible)
1413 return (_atspi_accessible_is_a (accessible, atspi_interface_streamable_content) ?
1419 * atspi_accessible_get_table:
1420 * @obj: a pointer to the #AtspiAccessible instance to query.
1422 * Gets the #AtspiTable interface for an #AtspiAccessible.
1424 * Returns: (transfer full): a pointer to an #AtspiTable interface instance, or
1425 * NULL if @obj does not implement #AtspiTable.
1427 * Deprecated: 2.10: Use atspi_accessible_get_table_iface instead.
1428 * Rename to: atspi_accessible_get_table_iface
1431 atspi_accessible_get_table (AtspiAccessible *obj)
1433 return (_atspi_accessible_is_a (obj, atspi_interface_table) ?
1434 g_object_ref (ATSPI_TABLE (obj)) : NULL);
1438 * atspi_accessible_get_table_iface:
1439 * @obj: a pointer to the #AtspiAccessible instance to query.
1441 * Gets the #AtspiTable interface for an #AtspiAccessible.
1443 * Returns: (transfer full): a pointer to an #AtspiTable interface instance, or
1444 * NULL if @obj does not implement #AtspiTable.
1447 atspi_accessible_get_table_iface (AtspiAccessible *obj)
1449 return (_atspi_accessible_is_a (obj, atspi_interface_table) ?
1450 g_object_ref (ATSPI_TABLE (obj)) : NULL);
1454 * atspi_accessible_get_table_cell:
1455 * @obj: a pointer to the #AtspiAccessible instance to query.
1457 * Gets the #AtspiTableCell interface for an #AtspiAccessible.
1459 * Returns: (transfer full): a pointer to an #AtspiTableCell interface instance,
1460 * or NULL if @obj does not implement #AtspiTable.
1463 atspi_accessible_get_table_cell (AtspiAccessible *obj)
1465 return (_atspi_accessible_is_a (obj, atspi_interface_table_cell) ?
1466 g_object_ref (ATSPI_TABLE_CELL (obj)) : NULL);
1470 * atspi_accessible_get_text:
1471 * @obj: a pointer to the #AtspiAccessible instance to query.
1473 * Gets the #AtspiTable interface for an #AtspiAccessible.
1475 * Returns: (transfer full): a pointer to an #AtspiText interface instance, or
1476 * NULL if @obj does not implement #AtspiText.
1478 * Deprecated: 2.10: Use atspi_accessible_get_text_iface instead.
1479 * Rename to: atspi_accessible_get_text_iface
1482 atspi_accessible_get_text (AtspiAccessible *obj)
1484 return (_atspi_accessible_is_a (obj, atspi_interface_text) ?
1485 g_object_ref (ATSPI_TEXT (obj)) : NULL);
1489 * atspi_accessible_get_text_iface:
1490 * @obj: a pointer to the #AtspiAccessible instance to query.
1492 * Gets the #AtspiTable interface for an #AtspiAccessible.
1494 * Returns: (transfer full): a pointer to an #AtspiText interface instance, or
1495 * NULL if @obj does not implement #AtspiText.
1498 atspi_accessible_get_text_iface (AtspiAccessible *obj)
1500 return (_atspi_accessible_is_a (obj, atspi_interface_text) ?
1501 g_object_ref (ATSPI_TEXT (obj)) : NULL);
1505 * atspi_accessible_get_value:
1506 * @obj: a pointer to the #AtspiAccessible instance to query.
1508 * Gets the #AtspiTable interface for an #AtspiAccessible.
1510 * Returns: (transfer full): a pointer to an #AtspiValue interface instance, or
1511 * NULL if @obj does not implement #AtspiValue.
1513 * Deprecated: 2.10: Use atspi_accessible_get_value_iface instead.
1514 * Rename to: atspi_accessible_get_value_iface
1517 atspi_accessible_get_value (AtspiAccessible *accessible)
1519 return (_atspi_accessible_is_a (accessible, atspi_interface_value) ?
1520 g_object_ref (ATSPI_VALUE (accessible)) : NULL);
1524 * atspi_accessible_get_value_iface:
1525 * @obj: a pointer to the #AtspiAccessible instance to query.
1527 * Gets the #AtspiTable interface for an #AtspiAccessible.
1529 * Returns: (transfer full): a pointer to an #AtspiValue interface instance, or
1530 * NULL if @obj does not implement #AtspiValue.
1533 atspi_accessible_get_value_iface (AtspiAccessible *accessible)
1535 return (_atspi_accessible_is_a (accessible, atspi_interface_value) ?
1536 g_object_ref (ATSPI_VALUE (accessible)) : NULL);
1540 append_const_val (GArray *array, const gchar *val)
1542 gchar *dup = g_strdup (val);
1545 g_array_append_val (array, dup);
1549 * atspi_accessible_get_interfaces:
1550 * @obj: The #AtspiAccessible to query.
1552 * A set of pointers to all interfaces supported by an #AtspiAccessible.
1554 * Returns: (element-type gchar*) (transfer full): A #GArray of strings
1555 * describing the interfaces supported by the object. Interfaces are
1556 * denoted in short-hand (i.e. "Component", "Text" etc.).
1559 atspi_accessible_get_interfaces (AtspiAccessible *obj)
1561 GArray *ret = g_array_new (TRUE, TRUE, sizeof (gchar *));
1563 g_return_val_if_fail (obj != NULL, NULL);
1565 append_const_val (ret, "Accessible");
1566 if (atspi_accessible_is_action (obj))
1567 append_const_val (ret, "Action");
1568 if (atspi_accessible_is_collection (obj))
1569 append_const_val (ret, "Collection");
1570 if (atspi_accessible_is_component (obj))
1571 append_const_val (ret, "Component");
1572 if (atspi_accessible_is_document (obj))
1573 append_const_val (ret, "Document");
1574 if (atspi_accessible_is_editable_text (obj))
1575 append_const_val (ret, "EditableText");
1576 if (atspi_accessible_is_hypertext (obj))
1577 append_const_val (ret, "Hypertext");
1578 if (atspi_accessible_is_hyperlink (obj))
1579 append_const_val (ret, "Hyperlink");
1580 if (atspi_accessible_is_image (obj))
1581 append_const_val (ret, "Image");
1582 if (atspi_accessible_is_selection (obj))
1583 append_const_val (ret, "Selection");
1584 if (atspi_accessible_is_table (obj))
1585 append_const_val (ret, "Table");
1586 if (atspi_accessible_is_table_cell (obj))
1587 append_const_val (ret, "TableCell");
1588 if (atspi_accessible_is_text (obj))
1589 append_const_val (ret, "Text");
1590 if (atspi_accessible_is_value (obj))
1591 append_const_val (ret, "Value");
1597 _atspi_accessible_new (AtspiApplication *app, const gchar *path)
1599 AtspiAccessible *accessible;
1601 accessible = g_object_new (ATSPI_TYPE_ACCESSIBLE, NULL);
1602 g_return_val_if_fail (accessible != NULL, NULL);
1604 accessible->parent.app = g_object_ref (app);
1605 accessible->parent.path = g_strdup (path);
1611 * atspi_accessible_set_cache_mask:
1612 * @accessible: The #AtspiAccessible to operate on. Must be the desktop or
1613 * the root of an application.
1614 * @mask: An #AtspiCache specifying a bit mask of the types of data to cache.
1616 * Sets the type of data to cache for accessibles.
1617 * If this is not set for an application or is reset to ATSPI_CACHE_UNDEFINED,
1618 * then the desktop's cache flag will be used.
1619 * If the desktop's cache flag is also undefined, then all possible data will
1621 * This function is intended to work around bugs in toolkits where the proper
1622 * events are not raised / to aid in testing for such bugs.
1625 atspi_accessible_set_cache_mask (AtspiAccessible *accessible, AtspiCache mask)
1627 g_return_if_fail (accessible != NULL);
1628 g_return_if_fail (accessible->parent.app != NULL);
1629 g_return_if_fail (accessible == accessible->parent.app->root);
1630 accessible->parent.app->cache = mask;
1631 enable_caching = TRUE;
1635 * atspi_accessible_clear_cache:
1636 * @accessible: The #AtspiAccessible whose cache to clear.
1638 * Clears the cached information for the given accessible and all of its
1642 atspi_accessible_clear_cache (AtspiAccessible *accessible)
1648 accessible->cached_properties = ATSPI_CACHE_NONE;
1649 for (l = accessible->children; l; l = l->next)
1650 atspi_accessible_clear_cache (l->data);
1655 * atspi_accessible_get_process_id:
1656 * @accessible: The #AtspiAccessible to query.
1657 * @error: a pointer to a %NULL #GError pointer
1659 * Returns the process id associated with the given accessible. Mainly
1660 * added for debugging; it is a shortcut to explicitly querying the
1661 * accessible's app->bus_name and then calling GetConnectionUnixProcessID.
1663 * Returns: The process ID or undetermined value if @error is set.
1666 atspi_accessible_get_process_id (AtspiAccessible *accessible, GError **error)
1668 DBusMessage *message, *reply;
1669 DBusConnection *bus = _atspi_bus ();
1670 dbus_uint32_t pid = -1;
1673 if (!accessible->parent.app || !accessible->parent.app->bus_name)
1675 g_set_error_literal(error, ATSPI_ERROR, ATSPI_ERROR_IPC, "Process is defunct");
1679 message = dbus_message_new_method_call ("org.freedesktop.DBus",
1680 "/org/freedesktop/DBus",
1681 "org.freedesktop.DBus",
1682 "GetConnectionUnixProcessID");
1683 dbus_message_append_args (message, DBUS_TYPE_STRING,
1684 &accessible->parent.app->bus_name,
1686 dbus_error_init (&d_error);
1687 reply = dbus_connection_send_with_reply_and_block (bus, message, -1, &d_error);
1688 dbus_message_unref (message);
1691 if (!strcmp (dbus_message_get_signature (reply), "u"))
1692 dbus_message_get_args (reply, NULL, DBUS_TYPE_UINT32, &pid, DBUS_TYPE_INVALID);
1693 dbus_message_unref (reply);
1695 if (dbus_error_is_set (&d_error))
1697 g_set_error_literal(error, ATSPI_ERROR, ATSPI_ERROR_IPC, "Process is defunct");
1698 dbus_error_free (&d_error);
1704 _atspi_accessible_get_cache_mask (AtspiAccessible *accessible)
1708 if (!accessible->parent.app)
1709 return ATSPI_CACHE_NONE;
1711 mask = accessible->parent.app->cache;
1712 if (mask == ATSPI_CACHE_UNDEFINED &&
1713 accessible->parent.app->root &&
1714 accessible->parent.app->root->accessible_parent)
1716 AtspiAccessible *desktop = atspi_get_desktop (0);
1717 mask = desktop->parent.app->cache;
1718 g_object_unref (desktop);
1721 if (mask == ATSPI_CACHE_UNDEFINED)
1722 mask = ATSPI_CACHE_DEFAULT;
1728 _atspi_accessible_test_cache (AtspiAccessible *accessible, AtspiCache flag)
1730 AtspiCache mask = _atspi_accessible_get_cache_mask (accessible);
1731 AtspiCache result = accessible->cached_properties & mask & flag;
1732 if (accessible->states && atspi_state_set_contains (accessible->states, ATSPI_STATE_TRANSIENT))
1734 return (result != 0 && (atspi_main_loop || enable_caching ||
1735 flag == ATSPI_CACHE_INTERFACES) &&
1740 _atspi_accessible_add_cache (AtspiAccessible *accessible, AtspiCache flag)
1742 AtspiCache mask = _atspi_accessible_get_cache_mask (accessible);
1744 accessible->cached_properties |= flag & mask;
1748 * atspi_accessible_get_locale:
1749 * @accessible: an #AtspiAccessible
1751 * Gets a UTF-8 string indicating the POSIX-style LC_MESSAGES locale
1756 * Returns: a UTF-8 string indicating the POSIX-style LC_MESSAGES
1757 * locale of @accessible.
1760 atspi_accessible_get_object_locale (AtspiAccessible *accessible, GError **error)
1764 g_return_val_if_fail (accessible != NULL, NULL);
1766 locale = g_object_get_qdata (G_OBJECT (accessible), quark_locale);
1769 if (!_atspi_dbus_get_property (accessible, atspi_interface_accessible,
1770 "Locale", error, "s", &locale))
1773 g_object_set_qdata_full (G_OBJECT (accessible), quark_locale, locale,
1780 free_value (gpointer data)
1782 GValue *value = data;
1784 g_value_unset (value);
1789 _atspi_accessible_ref_cache (AtspiAccessible *accessible)
1791 AtspiAccessiblePrivate *priv = accessible->priv;
1793 priv->cache_ref_count++;
1795 return g_hash_table_ref (priv->cache);
1796 priv->cache = g_hash_table_new_full (g_str_hash, g_str_equal, g_free,
1802 _atspi_accessible_unref_cache (AtspiAccessible *accessible)
1804 AtspiAccessiblePrivate *priv = accessible->priv;
1808 g_hash_table_unref (priv->cache);
1809 if (--priv->cache_ref_count == 0)