2 * AT-SPI - Assistive Technology Service Provider Interface
3 * (Gnome Accessibility Project; http://developer.gnome.org/projects/gap)
5 * Copyright 2001, 2002 Sun Microsystems Inc.,
6 * Copyright 2001, 2002 Ximian, Inc.
7 * Copyright 2010, 2011 Novell, Inc.
9 * This library is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Library General Public
11 * License as published by the Free Software Foundation; either
12 * version 2 of the License, or (at your option) any later version.
14 * This library is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * Library General Public License for more details.
19 * You should have received a copy of the GNU Library General Public
20 * License along with this library; if not, write to the
21 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
22 * Boston, MA 02111-1307, USA.
25 #include "atspi-private.h"
26 #include "atspi-accessible-private.h"
29 static gboolean enable_caching = FALSE;
30 static guint quark_locale;
33 atspi_action_interface_init (AtspiAction *action)
38 atspi_collection_interface_init (AtspiCollection *component)
43 atspi_component_interface_init (AtspiComponent *component)
48 atspi_document_interface_init (AtspiDocument *document)
53 atspi_editable_text_interface_init (AtspiEditableText *editable_text)
58 atspi_hypertext_interface_init (AtspiHypertext *hypertext)
63 atspi_image_interface_init (AtspiImage *image)
68 atspi_selection_interface_init (AtspiSelection *selection)
73 atspi_table_interface_init (AtspiTable *table)
78 atspi_table_cell_interface_init (AtspiTableCell *cell)
83 atspi_text_interface_init (AtspiText *text)
88 atspi_value_interface_init (AtspiValue *value)
92 G_DEFINE_TYPE_WITH_CODE (AtspiAccessible, atspi_accessible, ATSPI_TYPE_OBJECT,
93 G_ADD_PRIVATE (AtspiAccessible)
94 G_IMPLEMENT_INTERFACE (ATSPI_TYPE_ACTION, atspi_action_interface_init)
95 G_IMPLEMENT_INTERFACE (ATSPI_TYPE_COLLECTION, atspi_collection_interface_init)
96 G_IMPLEMENT_INTERFACE (ATSPI_TYPE_COMPONENT, atspi_component_interface_init)
97 G_IMPLEMENT_INTERFACE (ATSPI_TYPE_DOCUMENT, atspi_document_interface_init)
98 G_IMPLEMENT_INTERFACE (ATSPI_TYPE_EDITABLE_TEXT, atspi_editable_text_interface_init)
99 G_IMPLEMENT_INTERFACE (ATSPI_TYPE_HYPERTEXT, atspi_hypertext_interface_init)
100 G_IMPLEMENT_INTERFACE (ATSPI_TYPE_IMAGE, atspi_image_interface_init)
101 G_IMPLEMENT_INTERFACE (ATSPI_TYPE_SELECTION, atspi_selection_interface_init)
102 G_IMPLEMENT_INTERFACE (ATSPI_TYPE_TABLE, atspi_table_interface_init)
103 G_IMPLEMENT_INTERFACE (ATSPI_TYPE_TABLE_CELL, atspi_table_cell_interface_init)
104 G_IMPLEMENT_INTERFACE (ATSPI_TYPE_TEXT, atspi_text_interface_init)
105 G_IMPLEMENT_INTERFACE (ATSPI_TYPE_VALUE, atspi_value_interface_init))
107 #ifdef DEBUG_REF_COUNTS
108 static gint accessible_count = 0;
112 atspi_accessible_init (AtspiAccessible *accessible)
114 #ifdef DEBUG_REF_COUNTS
116 g_hash_table_insert (_atspi_get_live_refs (), accessible, NULL);
117 g_print("at-spi: init: %d objects\n", accessible_count);
120 accessible->priv = atspi_accessible_get_instance_private (accessible);
124 atspi_accessible_dispose (GObject *object)
126 AtspiAccessible *accessible = ATSPI_ACCESSIBLE (object);
128 AtspiAccessible *parent;
132 /* TODO: Only fire if object not already marked defunct */
133 memset (&e, 0, sizeof (e));
134 e.type = "object:state-changed:defunct";
135 e.source = accessible;
138 _atspi_send_event (&e);
140 if (accessible->states)
142 g_object_unref (accessible->states);
143 accessible->states = NULL;
146 parent = accessible->accessible_parent;
147 if (parent && parent->children)
149 GList*ls = g_list_find (parent->children, accessible);
152 gboolean replace = (ls == parent->children);
153 ls = g_list_remove (ls, accessible);
155 parent->children = ls;
156 g_object_unref (object);
162 g_object_unref (parent);
163 accessible->accessible_parent = NULL;
166 children = accessible->children;
167 accessible->children = NULL;
168 for (l = children; l; l = l->next)
170 AtspiAccessible *child = l->data;
171 if (child && child->accessible_parent == accessible)
173 g_object_unref (accessible);
174 child->accessible_parent = NULL;
176 g_object_unref (child);
178 g_list_free (children);
180 G_OBJECT_CLASS (atspi_accessible_parent_class) ->dispose (object);
184 atspi_accessible_finalize (GObject *object)
186 AtspiAccessible *accessible = ATSPI_ACCESSIBLE (object);
188 g_free (accessible->description);
189 g_free (accessible->name);
190 if (accessible->attributes)
191 g_hash_table_unref (accessible->attributes);
193 if (accessible->priv->cache)
194 g_hash_table_destroy (accessible->priv->cache);
196 #ifdef DEBUG_REF_COUNTS
198 g_hash_table_remove (_atspi_get_live_refs (), accessible);
199 g_print ("at-spi: finalize: %d objects\n", accessible_count);
202 G_OBJECT_CLASS (atspi_accessible_parent_class)
207 atspi_accessible_class_init (AtspiAccessibleClass *klass)
209 GObjectClass *object_class = G_OBJECT_CLASS (klass);
211 object_class->dispose = atspi_accessible_dispose;
212 object_class->finalize = atspi_accessible_finalize;
214 quark_locale = g_quark_from_string ("accessible-locale");
218 * atspi_accessible_get_name:
219 * @obj: a pointer to the #AtspiAccessible object on which to operate.
221 * Gets the name of an #AtspiAccessible object.
223 * Returns: a UTF-8 string indicating the name of the #AtspiAccessible object
224 * or NULL on exception.
227 atspi_accessible_get_name (AtspiAccessible *obj, GError **error)
229 g_return_val_if_fail (obj != NULL, g_strdup (""));
230 if (!_atspi_accessible_test_cache (obj, ATSPI_CACHE_NAME))
232 if (!_atspi_dbus_get_property (obj, atspi_interface_accessible, "Name", error,
234 return g_strdup ("");
235 _atspi_accessible_add_cache (obj, ATSPI_CACHE_NAME);
237 return g_strdup (obj->name);
241 * atspi_accessible_get_description:
242 * @obj: a pointer to the #AtspiAccessible object on which to operate.
244 * Gets the description of an #AtspiAccessible object.
246 * Returns: a UTF-8 string describing the #AtspiAccessible object
247 * or NULL on exception.
250 atspi_accessible_get_description (AtspiAccessible *obj, GError **error)
252 g_return_val_if_fail (obj != NULL, g_strdup (""));
254 if (!_atspi_accessible_test_cache (obj, ATSPI_CACHE_DESCRIPTION))
256 if (!_atspi_dbus_get_property (obj, atspi_interface_accessible,
257 "Description", error, "s",
259 return g_strdup ("");
260 _atspi_accessible_add_cache (obj, ATSPI_CACHE_DESCRIPTION);
262 return g_strdup (obj->description);
265 const char *str_parent = "Parent";
268 * atspi_accessible_get_parent:
269 * @obj: a pointer to the #AtspiAccessible object to query.
271 * Gets an #AtspiAccessible object's parent container.
273 * Returns: (nullable) (transfer full): a pointer to the
274 * #AtspiAccessible object which contains the given
275 * #AtspiAccessible instance, or NULL if the @obj has no
280 atspi_accessible_get_parent (AtspiAccessible *obj, GError **error)
282 g_return_val_if_fail (obj != NULL, NULL);
284 if (obj->parent.app &&
285 !_atspi_accessible_test_cache (obj, ATSPI_CACHE_PARENT))
287 DBusMessage *message, *reply;
288 DBusMessageIter iter, iter_variant;
289 message = dbus_message_new_method_call (obj->parent.app->bus_name,
291 DBUS_INTERFACE_PROPERTIES, "Get");
294 dbus_message_append_args (message, DBUS_TYPE_STRING, &atspi_interface_accessible,
295 DBUS_TYPE_STRING, &str_parent,
297 reply = _atspi_dbus_send_with_reply_and_block (message, error);
300 if (strcmp (dbus_message_get_signature (reply), "v") != 0)
302 dbus_message_unref (reply);
305 dbus_message_iter_init (reply, &iter);
306 dbus_message_iter_recurse (&iter, &iter_variant);
307 obj->accessible_parent = _atspi_dbus_return_accessible_from_iter (&iter_variant);
308 dbus_message_unref (reply);
309 _atspi_accessible_add_cache (obj, ATSPI_CACHE_PARENT);
311 if (!obj->accessible_parent)
313 return g_object_ref (obj->accessible_parent);
317 * atspi_accessible_get_child_count:
318 * @obj: a pointer to the #AtspiAccessible object on which to operate.
320 * Gets the number of children contained by an #AtspiAccessible object.
322 * Returns: a #long indicating the number of #AtspiAccessible children
323 * contained by an #AtspiAccessible object or -1 on exception.
327 atspi_accessible_get_child_count (AtspiAccessible *obj, GError **error)
329 g_return_val_if_fail (obj != NULL, -1);
331 if (!_atspi_accessible_test_cache (obj, ATSPI_CACHE_CHILDREN))
334 if (!_atspi_dbus_get_property (obj, atspi_interface_accessible,
335 "ChildCount", error, "i", &ret))
340 return g_list_length (obj->children);
344 * atspi_accessible_get_child_at_index:
345 * @obj: a pointer to the #AtspiAccessible object on which to operate.
346 * @child_index: a #long indicating which child is specified.
348 * Gets the #AtspiAccessible child of an #AtspiAccessible object at a given index.
350 * Returns: (transfer full): a pointer to the #AtspiAccessible child object at
351 * index @child_index or NULL on exception.
354 atspi_accessible_get_child_at_index (AtspiAccessible *obj,
358 AtspiAccessible *child;
360 g_return_val_if_fail (obj != NULL, NULL);
362 if (!_atspi_accessible_test_cache (obj, ATSPI_CACHE_CHILDREN))
365 reply = _atspi_dbus_call_partial (obj, atspi_interface_accessible,
366 "GetChildAtIndex", error, "i",
368 return _atspi_dbus_return_accessible_from_message (reply);
371 child = g_list_nth_data (obj->children, child_index);
374 return g_object_ref (child);
378 * atspi_accessible_get_index_in_parent:
379 * @obj: a pointer to the #AtspiAccessible object on which to operate.
381 * Gets the index of an #AtspiAccessible object within its parent's
382 * #AtspiAccessible children list.
384 * Returns: a #glong indicating the index of the #AtspiAccessible object
386 * or -1 if @obj has no containing parent or on exception.
389 atspi_accessible_get_index_in_parent (AtspiAccessible *obj, GError **error)
394 g_return_val_if_fail (obj != NULL, -1);
395 if (_atspi_accessible_test_cache (obj, ATSPI_CACHE_PARENT) &&
396 !obj->accessible_parent)
398 if (!obj->accessible_parent ||
399 !_atspi_accessible_test_cache (obj->accessible_parent,
400 ATSPI_CACHE_CHILDREN))
402 dbus_int32_t ret = -1;
403 _atspi_dbus_call (obj, atspi_interface_accessible,
404 "GetIndexInParent", NULL, "=>i", &ret);
408 l = obj->accessible_parent->children;
411 if (l->data == obj) return i;
422 } Accessibility_Relation;
425 * atspi_accessible_get_relation_set:
426 * @obj: a pointer to the #AtspiAccessible object on which to operate.
428 * Gets the set of #AtspiRelation objects which describes this #AtspiAccessible object's
429 * relationships with other #AtspiAccessible objects.
431 * Returns: (element-type AtspiRelation*) (transfer full): a #GArray of
432 * #AtspiRelation pointers or NULL on exception.
435 atspi_accessible_get_relation_set (AtspiAccessible *obj, GError **error)
438 DBusMessageIter iter, iter_array;
441 g_return_val_if_fail (obj != NULL, NULL);
443 reply = _atspi_dbus_call_partial (obj, atspi_interface_accessible, "GetRelationSet", error, "");
446 _ATSPI_DBUS_CHECK_SIG (reply, "a(ua(so))", error, NULL);
448 ret = g_array_new (TRUE, TRUE, sizeof (AtspiRelation *));
449 dbus_message_iter_init (reply, &iter);
450 dbus_message_iter_recurse (&iter, &iter_array);
451 while (dbus_message_iter_get_arg_type (&iter_array) != DBUS_TYPE_INVALID)
453 AtspiRelation *relation;
454 relation = _atspi_relation_new_from_iter (&iter_array);
455 ret = g_array_append_val (ret, relation);
456 dbus_message_iter_next (&iter_array);
458 dbus_message_unref (reply);
463 * atspi_accessible_get_role:
464 * @obj: a pointer to the #AtspiAccessible object on which to operate.
466 * Gets the UI role played by an #AtspiAccessible object.
467 * This role's name can be obtained via atspi_accessible_get_role_name ().
469 * Returns: the #AtspiRole of an #AtspiAccessible object.
473 atspi_accessible_get_role (AtspiAccessible *obj, GError **error)
475 g_return_val_if_fail (obj != NULL, ATSPI_ROLE_INVALID);
477 if (!_atspi_accessible_test_cache (obj, ATSPI_CACHE_ROLE))
480 /* TODO: Make this a property */
481 if (_atspi_dbus_call (obj, atspi_interface_accessible, "GetRole", error, "=>u", &role))
484 _atspi_accessible_add_cache (obj, ATSPI_CACHE_ROLE);
491 * atspi_accessible_get_role_name:
492 * @obj: a pointer to the #AtspiAccessible object on which to operate.
494 * Gets a UTF-8 string corresponding to the name of the role played by an object.
495 * This method will return useful values for roles that fall outside the
496 * enumeration used in atspi_accessible_get_role ().
498 * Returns: a UTF-8 string specifying the type of UI role played by an
499 * #AtspiAccessible object.
503 atspi_accessible_get_role_name (AtspiAccessible *obj, GError **error)
505 gchar *retval = NULL;
508 g_return_val_if_fail (obj != NULL, NULL);
510 role = atspi_accessible_get_role (obj, error);
511 if (role >= 0 && role < ATSPI_ROLE_COUNT && role != ATSPI_ROLE_EXTENDED)
512 return atspi_role_get_name (role);
514 _atspi_dbus_call (obj, atspi_interface_accessible, "GetRoleName", error, "=>s", &retval);
517 retval = g_strdup ("");
523 * atspi_accessible_get_localized_role_name:
524 * @obj: a pointer to the #AtspiAccessible object on which to operate.
526 * Gets a UTF-8 string corresponding to the name of the role played by an
527 * object, translated to the current locale.
528 * This method will return useful values for roles that fall outside the
529 * enumeration used in atspi_accessible_getRole ().
531 * Returns: a localized, UTF-8 string specifying the type of UI role played
532 * by an #AtspiAccessible object.
536 atspi_accessible_get_localized_role_name (AtspiAccessible *obj, GError **error)
540 g_return_val_if_fail (obj != NULL, NULL);
542 _atspi_dbus_call (obj, atspi_interface_accessible, "GetLocalizedRoleName", error, "=>s", &retval);
545 return g_strdup ("");
550 static AtspiStateSet *
553 AtspiStateSet *set = atspi_state_set_new (NULL);
554 atspi_state_set_add (set, ATSPI_STATE_DEFUNCT);
559 * atspi_accessible_get_state_set:
560 * @obj: a pointer to the #AtspiAccessible object on which to operate.
562 * Gets the states currently held by an object.
564 * Returns: (transfer full): a pointer to an #AtspiStateSet representing an
565 * object's current state set.
568 atspi_accessible_get_state_set (AtspiAccessible *obj)
570 /* TODO: Should take a GError **, but would be an API break */
571 if (!obj->parent.app || !obj->parent.app->bus)
572 return defunct_set ();
574 if (!_atspi_accessible_test_cache (obj, ATSPI_CACHE_STATES))
577 DBusMessageIter iter;
578 reply = _atspi_dbus_call_partial (obj, atspi_interface_accessible,
579 "GetState", NULL, "");
580 _ATSPI_DBUS_CHECK_SIG (reply, "au", NULL, defunct_set ());
581 dbus_message_iter_init (reply, &iter);
582 _atspi_dbus_set_state (obj, &iter);
583 dbus_message_unref (reply);
584 _atspi_accessible_add_cache (obj, ATSPI_CACHE_STATES);
587 return g_object_ref (obj->states);
591 * atspi_accessible_get_attributes:
592 * @obj: The #AtspiAccessible being queried.
594 * Gets the #AttributeSet representing any assigned
595 * name-value pair attributes or annotations for this object.
596 * For typographic, textual, or textually-semantic attributes, see
597 * atspi_text_get_attributes instead.
599 * Returns: (element-type gchar* gchar*) (transfer full): The name-value-pair
600 * attributes assigned to this object.
603 atspi_accessible_get_attributes (AtspiAccessible *obj, GError **error)
605 DBusMessage *message;
607 g_return_val_if_fail (obj != NULL, NULL);
609 if (obj->priv->cache)
611 GValue *val = g_hash_table_lookup (obj->priv->cache, "Attributes");
613 return g_value_dup_boxed (val);
616 if (!_atspi_accessible_test_cache (obj, ATSPI_CACHE_ATTRIBUTES))
618 message = _atspi_dbus_call_partial (obj, atspi_interface_accessible,
619 "GetAttributes", error, "");
620 obj->attributes = _atspi_dbus_return_hash_from_message (message);
621 _atspi_accessible_add_cache (obj, ATSPI_CACHE_ATTRIBUTES);
624 if (!obj->attributes)
626 return g_hash_table_ref (obj->attributes);
630 add_to_attribute_array (gpointer key, gpointer value, gpointer data)
632 GArray **array = (GArray **)data;
633 gchar *str = g_strconcat (key, ":", value, NULL);
634 *array = g_array_append_val (*array, str);
638 * atspi_accessible_get_attributes_as_array:
639 * @obj: The #AtspiAccessible being queried.
641 * Gets a #GArray representing any assigned
642 * name-value pair attributes or annotations for this object.
643 * For typographic, textual, or textually-semantic attributes, see
644 * atspi_text_get_attributes_as_array instead.
646 * Returns: (element-type gchar*) (transfer full): The name-value-pair
647 * attributes assigned to this object.
650 atspi_accessible_get_attributes_as_array (AtspiAccessible *obj, GError **error)
652 DBusMessage *message;
654 g_return_val_if_fail (obj != NULL, NULL);
656 if (obj->priv->cache)
658 GValue *val = g_hash_table_lookup (obj->priv->cache, "Attributes");
661 GArray *array = g_array_new (TRUE, TRUE, sizeof (gchar *));
662 GHashTable *attributes = g_value_get_boxed (val);
663 g_hash_table_foreach (attributes, add_to_attribute_array, &array);
668 message = _atspi_dbus_call_partial (obj, atspi_interface_accessible, "GetAttributes", error, "");
669 return _atspi_dbus_return_attribute_array_from_message (message);
673 * atspi_accessible_get_application:
674 * @obj: The #AtspiAccessible being queried.
676 * Gets the containing #AtspiApplication for an object.
678 * Returns: (transfer full): the containing #AtspiApplication instance for
682 atspi_accessible_get_application (AtspiAccessible *obj, GError **error)
684 AtspiAccessible *parent;
689 parent = atspi_accessible_get_parent (obj, NULL);
690 if (!parent && obj->parent.app &&
691 atspi_accessible_get_role (obj, NULL) != ATSPI_ROLE_APPLICATION)
693 AtspiAccessible *root = g_object_ref (obj->parent.app->root);
696 g_object_unref (obj);
697 if (atspi_accessible_get_role (root, NULL) == ATSPI_ROLE_DESKTOP_FRAME)
699 g_object_unref (root);
705 if (!parent || parent == obj ||
706 atspi_accessible_get_role (parent, NULL) == ATSPI_ROLE_DESKTOP_FRAME)
709 g_object_unref (parent);
712 g_object_unref (obj);
717 /* Application-specific methods */
720 * atspi_accessible_get_toolkit_name:
721 * @obj: a pointer to the #AtspiAccessible object on which to operate.
723 * Gets the toolkit name for an #AtspiAccessible object.
724 * Only works on application root objects.
726 * Returns: a UTF-8 string indicating the toolkit name for the #AtspiAccessible object or NULL on exception.
729 atspi_accessible_get_toolkit_name (AtspiAccessible *obj, GError **error)
731 g_return_val_if_fail (obj != NULL, NULL);
733 if (!obj->parent.app)
736 if (!obj->parent.app->toolkit_name)
737 _atspi_dbus_get_property (obj, atspi_interface_application, "ToolkitName",
738 error, "s", &obj->parent.app->toolkit_name);
740 return g_strdup (obj->parent.app->toolkit_name);
744 * atspi_accessible_get_toolkit_version:
745 * @obj: a pointer to the #AtspiAccessible object on which to operate.
747 * Gets the toolkit version for an #AtspiAccessible object.
748 * Only works on application root objects.
750 * Returns: a UTF-8 string indicating the toolkit version for the #AtspiAccessible object or NULL on exception.
753 atspi_accessible_get_toolkit_version (AtspiAccessible *obj, GError **error)
755 g_return_val_if_fail (obj != NULL, NULL);
757 if (!obj->parent.app)
760 if (!obj->parent.app->toolkit_version)
761 _atspi_dbus_get_property (obj, atspi_interface_application, "Version",
762 error, "s", &obj->parent.app->toolkit_version);
764 return g_strdup (obj->parent.app->toolkit_version);
768 * atspi_accessible_get_atspi_version:
769 * @obj: a pointer to the #AtspiAccessible object on which to operate.
771 * Gets the AT-SPI IPC specification version supported by the application
772 * pointed to by the #AtspiAccessible object.
773 * Only works on application root objects.
775 * Returns: a UTF-8 string indicating the AT-SPI version for the #AtspiAccessible object or NULL on exception.
778 atspi_accessible_get_atspi_version (AtspiAccessible *obj, GError **error)
780 g_return_val_if_fail (obj != NULL, NULL);
782 if (!obj->parent.app)
785 if (!obj->parent.app->atspi_version)
786 _atspi_dbus_get_property (obj, atspi_interface_application, "AtspiVersion",
787 error, "s", &obj->parent.app->atspi_version);
789 return g_strdup (obj->parent.app->atspi_version);
793 * atspi_accessible_get_id:
794 * @obj: a pointer to the #AtspiAccessible object on which to operate.
796 * Gets the application id for a #AtspiAccessible object.
797 * Only works on application root objects.
799 * Returns: a positive #gint indicating the id for the #AtspiAccessible object
800 * or -1 on exception.
803 atspi_accessible_get_id (AtspiAccessible *obj, GError **error)
807 g_return_val_if_fail (obj != NULL, -1);
809 if (!_atspi_dbus_get_property (obj, atspi_interface_application, "Id", error, "i", &ret))
815 /* Interface query methods */
818 _atspi_accessible_is_a (AtspiAccessible *accessible,
819 const char *interface_name)
823 if (accessible == NULL)
828 if (!_atspi_accessible_test_cache (accessible, ATSPI_CACHE_INTERFACES))
831 DBusMessageIter iter;
832 reply = _atspi_dbus_call_partial (accessible, atspi_interface_accessible,
833 "GetInterfaces", NULL, "");
834 _ATSPI_DBUS_CHECK_SIG (reply, "as", NULL, FALSE);
835 dbus_message_iter_init (reply, &iter);
836 _atspi_dbus_set_interfaces (accessible, &iter);
837 dbus_message_unref (reply);
838 _atspi_accessible_add_cache (accessible, ATSPI_CACHE_INTERFACES);
841 n = _atspi_get_iface_num (interface_name);
842 if (n == -1) return FALSE;
843 return (gboolean) ((accessible->interfaces & (1 << n))? TRUE: FALSE);
847 * atspi_accessible_is_action:
848 * @obj: a pointer to the #AtspiAccessible instance to query.
850 * Query whether the specified #AtspiAccessible implements the
851 * #AtspiAction interface.
853 * Returns: #TRUE if @obj implements the #AtspiAction interface,
857 atspi_accessible_is_action (AtspiAccessible *obj)
859 return _atspi_accessible_is_a (obj,
860 atspi_interface_action);
864 * atspi_accessible_is_application:
865 * @obj: a pointer to the #AtspiAccessible instance to query.
867 * Query whether the specified #AtspiAccessible implements the
868 * #AtspiApplication interface.
870 * Returns: #TRUE if @obj implements the #AtspiApplication interface,
874 atspi_accessible_is_application (AtspiAccessible *obj)
876 return _atspi_accessible_is_a (obj,
877 atspi_interface_application);
881 * atspi_accessible_is_collection:
882 * @obj: a pointer to the #AtspiAccessible instance to query.
884 * Query whether the specified #AtspiAccessible implements the
885 * #AtspiCollection interface.
887 * Returns: #TRUE if @obj implements the #AtspiCollection interface,
891 atspi_accessible_is_collection (AtspiAccessible *obj)
893 return _atspi_accessible_is_a (obj,
894 atspi_interface_collection);
898 * atspi_accessible_is_component:
899 * @obj: a pointer to the #AtspiAccessible instance to query.
901 * Query whether the specified #AtspiAccessible implements #AtspiComponent.
903 * Returns: #TRUE if @obj implements the #AtspiComponent interface,
907 atspi_accessible_is_component (AtspiAccessible *obj)
909 return _atspi_accessible_is_a (obj,
910 atspi_interface_component);
914 * atspi_accessible_is_document:
915 * @obj: a pointer to the #AtspiAccessible instance to query.
917 * Query whether the specified #AtspiAccessible implements the
918 * #AtspiDocument interface.
920 * Returns: #TRUE if @obj implements the #AtspiDocument interface,
924 atspi_accessible_is_document (AtspiAccessible *obj)
926 return _atspi_accessible_is_a (obj,
927 atspi_interface_document);
931 * atspi_accessible_is_editable_text:
932 * @obj: a pointer to the #AtspiAccessible instance to query.
934 * Query whether the specified #AtspiAccessible implements the
935 * #AtspiEditableText interface.
937 * Returns: #TRUE if @obj implements the #AtspiEditableText interface,
941 atspi_accessible_is_editable_text (AtspiAccessible *obj)
943 return _atspi_accessible_is_a (obj,
944 atspi_interface_editable_text);
948 * atspi_accessible_is_hypertext:
949 * @obj: a pointer to the #AtspiAccessible instance to query.
951 * Query whether the specified #AtspiAccessible implements the
952 * #AtspiHypertext interface.
954 * Returns: #TRUE if @obj implements the #AtspiHypertext interface,
958 atspi_accessible_is_hypertext (AtspiAccessible *obj)
960 return _atspi_accessible_is_a (obj,
961 atspi_interface_hypertext);
965 * atspi_accessible_is_hyperlink:
966 * @obj: a pointer to the #AtspiAccessible instance to query.
968 * Query whether the specified #AtspiAccessible implements the
969 * #AtspiHyperlink interface.
971 * Returns: #TRUE if @obj implements the #AtspiHypertext interface,
975 atspi_accessible_is_hyperlink (AtspiAccessible *obj)
977 return _atspi_accessible_is_a (obj,
978 atspi_interface_hyperlink);
982 * atspi_accessible_is_image:
983 * @obj: a pointer to the #AtspiAccessible instance to query.
985 * Query whether the specified #AtspiAccessible implements the
986 * #AtspiImage interface.
988 * Returns: #TRUE if @obj implements the #AtspiImage interface,
992 atspi_accessible_is_image (AtspiAccessible *obj)
994 return _atspi_accessible_is_a (obj,
995 atspi_interface_image);
999 * atspi_accessible_is_selection:
1000 * @obj: a pointer to the #AtspiAccessible instance to query.
1002 * Query whether the specified #AtspiAccessible implements the
1003 * #AtspiSelection interface.
1005 * Returns: #TRUE if @obj implements the #AtspiSelection interface,
1009 atspi_accessible_is_selection (AtspiAccessible *obj)
1011 return _atspi_accessible_is_a (obj,
1012 atspi_interface_selection);
1016 * atspi_accessible_is_table:
1017 * @obj: a pointer to the #AtspiAccessible instance to query.
1019 * Query whether the specified #AtspiAccessible implements the
1020 * #AtspiTable interface.
1022 * Returns: #TRUE if @obj implements the #AtspiTable interface,
1026 atspi_accessible_is_table (AtspiAccessible *obj)
1028 return _atspi_accessible_is_a (obj,
1029 atspi_interface_table);
1033 * atspi_accessible_is_table_cell:
1034 * @obj: a pointer to the #AtspiAccessible instance to query.
1036 * Query whether the specified #AtspiAccessible implements the
1037 * #AtspiTableCell interface.
1039 * Returns: #TRUE if @obj implements the #AtspiTable interface,
1043 atspi_accessible_is_table_cell (AtspiAccessible *obj)
1045 return _atspi_accessible_is_a (obj,
1046 atspi_interface_table_cell);
1050 * atspi_accessible_is_streamable_content:
1051 * @obj: a pointer to the #AtspiAccessible instance to query.
1053 * Query whether the specified #AtspiAccessible implements the
1054 * #AtspiStreamableContent interface.
1056 * Returns: #TRUE if @obj implements the #AtspiStreamableContent interface,
1060 atspi_accessible_is_streamable_content (AtspiAccessible *obj)
1063 return _atspi_accessible_is_a (obj,
1064 atspi_interface_streamable_content);
1066 g_warning ("Streamable content not implemented");
1072 * atspi_accessible_is_text:
1073 * @obj: a pointer to the #AtspiAccessible instance to query.
1075 * Query whether the specified #AtspiAccessible implements the
1076 * #AtspiText interface.
1078 * Returns: #TRUE if @obj implements the #AtspiText interface,
1082 atspi_accessible_is_text (AtspiAccessible *obj)
1084 return _atspi_accessible_is_a (obj,
1085 atspi_interface_text);
1089 * atspi_accessible_is_value:
1090 * @obj: a pointer to the #AtspiAccessible instance to query.
1092 * Query whether the specified #AtspiAccessible implements the
1093 * #AtspiValue interface.
1095 * Returns: #TRUE if @obj implements the #AtspiValue interface,
1099 atspi_accessible_is_value (AtspiAccessible *obj)
1101 return _atspi_accessible_is_a (obj,
1102 atspi_interface_value);
1106 * atspi_accessible_get_action:
1107 * @obj: a pointer to the #AtspiAccessible instance to query.
1109 * Gets the #AtspiAction interface for an #AtspiAccessible.
1111 * Returns: (transfer full): a pointer to an #AtspiAction interface
1112 * instance, or NULL if @obj does not implement #AtspiAction.
1114 * Deprecated: 2.10: Use atspi_accessible_get_action_iface instead.
1115 * Rename to: atspi_accessible_get_action_iface
1118 atspi_accessible_get_action (AtspiAccessible *accessible)
1120 return (_atspi_accessible_is_a (accessible, atspi_interface_action) ?
1121 g_object_ref (ATSPI_ACTION (accessible)) : NULL);
1125 * atspi_accessible_get_action_iface:
1126 * @obj: a pointer to the #AtspiAccessible instance to query.
1128 * Gets the #AtspiAction interface for an #AtspiAccessible.
1130 * Returns: (transfer full): a pointer to an #AtspiAction interface
1131 * instance, or NULL if @obj does not implement #AtspiAction.
1134 atspi_accessible_get_action_iface (AtspiAccessible *accessible)
1136 return (_atspi_accessible_is_a (accessible, atspi_interface_action) ?
1137 g_object_ref (ATSPI_ACTION (accessible)) : NULL);
1141 * atspi_accessible_get_collection:
1142 * @obj: a pointer to the #AtspiAccessible instance to query.
1144 * Gets the #AtspiCollection interface for an #AtspiAccessible.
1146 * Returns: (transfer full): a pointer to an #AtspiCollection interface
1147 * instance, or NULL if @obj does not implement #AtspiCollection.
1149 * Deprecated: 2.10: Use atspi_accessible_get_collection_iface instead.
1150 * Rename to: atspi_accessible_get_collection_iface
1153 atspi_accessible_get_collection (AtspiAccessible *accessible)
1155 return (_atspi_accessible_is_a (accessible, atspi_interface_collection) ?
1156 g_object_ref (ATSPI_COLLECTION (accessible)) : NULL);
1160 * atspi_accessible_get_collection_iface:
1161 * @obj: a pointer to the #AtspiAccessible instance to query.
1163 * Gets the #AtspiCollection interface for an #AtspiAccessible.
1165 * Returns: (transfer full): a pointer to an #AtspiCollection interface
1166 * instance, or NULL if @obj does not implement #AtspiCollection.
1169 atspi_accessible_get_collection_iface (AtspiAccessible *accessible)
1171 return (_atspi_accessible_is_a (accessible, atspi_interface_collection) ?
1172 g_object_ref (ATSPI_COLLECTION (accessible)) : NULL);
1176 * atspi_accessible_get_component:
1177 * @obj: a pointer to the #AtspiAccessible instance to query.
1179 * Gets the #AtspiComponent interface for an #AtspiAccessible.
1181 * Returns: (transfer full): a pointer to an #AtspiComponent interface
1182 * instance, or NULL if @obj does not implement #AtspiComponent.
1184 * Deprecated: 2.10: Use atspi_accessible_get_component_iface instead.
1185 * Rename to: atspi_accessible_get_component_iface
1188 atspi_accessible_get_component (AtspiAccessible *obj)
1190 return (_atspi_accessible_is_a (obj, atspi_interface_component) ?
1191 g_object_ref (ATSPI_COMPONENT (obj)) : NULL);
1195 * atspi_accessible_get_component_iface:
1196 * @obj: a pointer to the #AtspiAccessible instance to query.
1198 * Gets the #AtspiComponent interface for an #AtspiAccessible.
1200 * Returns: (transfer full): a pointer to an #AtspiComponent interface
1201 * instance, or NULL if @obj does not implement #AtspiComponent.
1204 atspi_accessible_get_component_iface (AtspiAccessible *obj)
1206 return (_atspi_accessible_is_a (obj, atspi_interface_component) ?
1207 g_object_ref (ATSPI_COMPONENT (obj)) : NULL);
1211 * atspi_accessible_get_document:
1212 * @obj: a pointer to the #AtspiAccessible instance to query.
1214 * Gets the #AtspiDocument interface for an #AtspiAccessible.
1216 * Returns: (transfer full): a pointer to an #AtspiDocument interface
1217 * instance, or NULL if @obj does not implement #AtspiDocument.
1219 * Deprecated: 2.10: Use atspi_accessible_get_document_iface instead.
1220 * Rename to: atspi_accessible_get_document_iface
1223 atspi_accessible_get_document (AtspiAccessible *accessible)
1225 return (_atspi_accessible_is_a (accessible, atspi_interface_document) ?
1226 g_object_ref (ATSPI_DOCUMENT (accessible)) : NULL);
1230 * atspi_accessible_get_document_iface:
1231 * @obj: a pointer to the #AtspiAccessible instance to query.
1233 * Gets the #AtspiDocument interface for an #AtspiAccessible.
1235 * Returns: (transfer full): a pointer to an #AtspiDocument interface
1236 * instance, or NULL if @obj does not implement #AtspiDocument.
1239 atspi_accessible_get_document_iface (AtspiAccessible *accessible)
1241 return (_atspi_accessible_is_a (accessible, atspi_interface_document) ?
1242 g_object_ref (ATSPI_DOCUMENT (accessible)) : NULL);
1246 * atspi_accessible_get_editable_text:
1247 * @obj: a pointer to the #AtspiAccessible instance to query.
1249 * Gets the #AtspiEditableText interface for an #AtspiAccessible.
1251 * Returns: (transfer full): a pointer to an #AtspiEditableText interface
1252 * instance, or NULL if @obj does not implement #AtspiEditableText.
1254 * Deprecated: 2.10: Use atspi_accessible_get_editable_text_iface instead.
1255 * Rename to: atspi_accessible_get_editable_text_iface
1258 atspi_accessible_get_editable_text (AtspiAccessible *accessible)
1260 return (_atspi_accessible_is_a (accessible, atspi_interface_editable_text) ?
1261 g_object_ref (ATSPI_EDITABLE_TEXT (accessible)) : NULL);
1265 * atspi_accessible_get_editable_text_iface:
1266 * @obj: a pointer to the #AtspiAccessible instance to query.
1268 * Gets the #AtspiEditableText interface for an #AtspiAccessible.
1270 * Returns: (transfer full): a pointer to an #AtspiEditableText interface
1271 * instance, or NULL if @obj does not implement #AtspiEditableText.
1274 atspi_accessible_get_editable_text_iface (AtspiAccessible *accessible)
1276 return (_atspi_accessible_is_a (accessible, atspi_interface_editable_text) ?
1277 g_object_ref (ATSPI_EDITABLE_TEXT (accessible)) : NULL);
1281 * atspi_accessible_get_hyperlink:
1282 * @obj: a pointer to the #AtspiAccessible object on which to operate.
1284 * Gets the #AtspiHyperlink interface for an #AtspiAccessible.
1286 * Returns: (transfer full): the #AtspiHyperlink object associated with
1287 * the given #AtspiAccessible, or NULL if not supported.
1290 atspi_accessible_get_hyperlink (AtspiAccessible *accessible)
1292 return (_atspi_accessible_is_a (accessible, atspi_interface_hyperlink) ?
1293 _atspi_hyperlink_new (accessible->parent.app, accessible->parent.path) : NULL);
1297 * atspi_accessible_get_hypertext:
1298 * @obj: a pointer to the #AtspiAccessible instance to query.
1300 * Gets the #AtspiHypertext interface for an #AtspiAccessible.
1302 * Returns: (transfer full): a pointer to an #AtspiHypertext interface
1303 * instance, or NULL if @obj does not implement #AtspiHypertext.
1305 * Deprecated: 2.10: Use atspi_accessible_get_hypertext_iface instead.
1306 * Rename to: atspi_accessible_get_hypertext_iface
1309 atspi_accessible_get_hypertext (AtspiAccessible *accessible)
1311 return (_atspi_accessible_is_a (accessible, atspi_interface_hypertext) ?
1312 g_object_ref (ATSPI_HYPERTEXT (accessible)) : NULL);
1316 * atspi_accessible_get_hypertext_iface:
1317 * @obj: a pointer to the #AtspiAccessible instance to query.
1319 * Gets the #AtspiHypertext interface for an #AtspiAccessible.
1321 * Returns: (transfer full): a pointer to an #AtspiHypertext interface
1322 * instance, or NULL if @obj does not implement #AtspiHypertext.
1325 atspi_accessible_get_hypertext_iface (AtspiAccessible *accessible)
1327 return (_atspi_accessible_is_a (accessible, atspi_interface_hypertext) ?
1328 g_object_ref (ATSPI_HYPERTEXT (accessible)) : NULL);
1332 * atspi_accessible_get_image:
1333 * @obj: a pointer to the #AtspiAccessible instance to query.
1335 * Gets the #AtspiImage interface for an #AtspiAccessible.
1337 * Returns: (transfer full): a pointer to an #AtspiImage interface instance, or
1338 * NULL if @obj does not implement #AtspiImage.
1340 * Deprecated: 2.10: Use atspi_accessible_get_image_iface instead.
1341 * Rename to: atspi_accessible_get_image_iface
1344 atspi_accessible_get_image (AtspiAccessible *accessible)
1346 return (_atspi_accessible_is_a (accessible, atspi_interface_image) ?
1347 g_object_ref (ATSPI_IMAGE (accessible)) : NULL);
1351 * atspi_accessible_get_image_iface:
1352 * @obj: a pointer to the #AtspiAccessible instance to query.
1354 * Gets the #AtspiImage interface for an #AtspiAccessible.
1356 * Returns: (transfer full): a pointer to an #AtspiImage interface instance, or
1357 * NULL if @obj does not implement #AtspiImage.
1360 atspi_accessible_get_image_iface (AtspiAccessible *accessible)
1362 return (_atspi_accessible_is_a (accessible, atspi_interface_image) ?
1363 g_object_ref (ATSPI_IMAGE (accessible)) : NULL);
1367 * atspi_accessible_get_selection:
1368 * @obj: a pointer to the #AtspiAccessible instance to query.
1370 * Gets the #AtspiSelection interface for an #AtspiAccessible.
1372 * Returns: (transfer full): a pointer to an #AtspiSelection interface
1373 * instance, or NULL if @obj does not implement #AtspiSelection.
1375 * Deprecated: 2.10: Use atspi_accessible_get_selection_iface instead.
1376 * Rename to: atspi_accessible_get_selection_iface
1379 atspi_accessible_get_selection (AtspiAccessible *accessible)
1381 return (_atspi_accessible_is_a (accessible, atspi_interface_selection) ?
1382 g_object_ref (ATSPI_SELECTION (accessible)) : NULL);
1386 * atspi_accessible_get_selection_iface:
1387 * @obj: a pointer to the #AtspiAccessible instance to query.
1389 * Gets the #AtspiSelection interface for an #AtspiAccessible.
1391 * Returns: (transfer full): a pointer to an #AtspiSelection interface
1392 * instance, or NULL if @obj does not implement #AtspiSelection.
1395 atspi_accessible_get_selection_iface (AtspiAccessible *accessible)
1397 return (_atspi_accessible_is_a (accessible, atspi_interface_selection) ?
1398 g_object_ref (ATSPI_SELECTION (accessible)) : NULL);
1403 * atspi_accessible_get_streamable_content:
1404 * @obj: a pointer to the #AtspiAccessible instance to query.
1406 * Gets the #AtspiStreamableContent interface for an #AtspiAccessible.
1408 * Returns: (transfer full): a pointer to an #AtspiStreamableContent interface
1409 * instance, or NULL if @obj does not implement #AtspiStreamableContent.
1411 AtspiStreamableContent *
1412 atspi_accessible_get_streamable_content (AtspiAccessible *accessible)
1414 return (_atspi_accessible_is_a (accessible, atspi_interface_streamable_content) ?
1420 * atspi_accessible_get_table:
1421 * @obj: a pointer to the #AtspiAccessible instance to query.
1423 * Gets the #AtspiTable interface for an #AtspiAccessible.
1425 * Returns: (transfer full): a pointer to an #AtspiTable interface instance, or
1426 * NULL if @obj does not implement #AtspiTable.
1428 * Deprecated: 2.10: Use atspi_accessible_get_table_iface instead.
1429 * Rename to: atspi_accessible_get_table_iface
1432 atspi_accessible_get_table (AtspiAccessible *obj)
1434 return (_atspi_accessible_is_a (obj, atspi_interface_table) ?
1435 g_object_ref (ATSPI_TABLE (obj)) : NULL);
1439 * atspi_accessible_get_table_iface:
1440 * @obj: a pointer to the #AtspiAccessible instance to query.
1442 * Gets the #AtspiTable interface for an #AtspiAccessible.
1444 * Returns: (transfer full): a pointer to an #AtspiTable interface instance, or
1445 * NULL if @obj does not implement #AtspiTable.
1448 atspi_accessible_get_table_iface (AtspiAccessible *obj)
1450 return (_atspi_accessible_is_a (obj, atspi_interface_table) ?
1451 g_object_ref (ATSPI_TABLE (obj)) : NULL);
1455 * atspi_accessible_get_table_cell:
1456 * @obj: a pointer to the #AtspiAccessible instance to query.
1458 * Gets the #AtspiTableCell interface for an #AtspiAccessible.
1460 * Returns: (transfer full): a pointer to an #AtspiTableCell interface instance,
1461 * or NULL if @obj does not implement #AtspiTable.
1464 atspi_accessible_get_table_cell (AtspiAccessible *obj)
1466 return (_atspi_accessible_is_a (obj, atspi_interface_table_cell) ?
1467 g_object_ref (ATSPI_TABLE_CELL (obj)) : NULL);
1471 * atspi_accessible_get_text:
1472 * @obj: a pointer to the #AtspiAccessible instance to query.
1474 * Gets the #AtspiTable interface for an #AtspiAccessible.
1476 * Returns: (transfer full): a pointer to an #AtspiText interface instance, or
1477 * NULL if @obj does not implement #AtspiText.
1479 * Deprecated: 2.10: Use atspi_accessible_get_text_iface instead.
1480 * Rename to: atspi_accessible_get_text_iface
1483 atspi_accessible_get_text (AtspiAccessible *obj)
1485 return (_atspi_accessible_is_a (obj, atspi_interface_text) ?
1486 g_object_ref (ATSPI_TEXT (obj)) : NULL);
1490 * atspi_accessible_get_text_iface:
1491 * @obj: a pointer to the #AtspiAccessible instance to query.
1493 * Gets the #AtspiTable interface for an #AtspiAccessible.
1495 * Returns: (transfer full): a pointer to an #AtspiText interface instance, or
1496 * NULL if @obj does not implement #AtspiText.
1499 atspi_accessible_get_text_iface (AtspiAccessible *obj)
1501 return (_atspi_accessible_is_a (obj, atspi_interface_text) ?
1502 g_object_ref (ATSPI_TEXT (obj)) : NULL);
1506 * atspi_accessible_get_value:
1507 * @obj: a pointer to the #AtspiAccessible instance to query.
1509 * Gets the #AtspiTable interface for an #AtspiAccessible.
1511 * Returns: (transfer full): a pointer to an #AtspiValue interface instance, or
1512 * NULL if @obj does not implement #AtspiValue.
1514 * Deprecated: 2.10: Use atspi_accessible_get_value_iface instead.
1515 * Rename to: atspi_accessible_get_value_iface
1518 atspi_accessible_get_value (AtspiAccessible *accessible)
1520 return (_atspi_accessible_is_a (accessible, atspi_interface_value) ?
1521 g_object_ref (ATSPI_VALUE (accessible)) : NULL);
1525 * atspi_accessible_get_value_iface:
1526 * @obj: a pointer to the #AtspiAccessible instance to query.
1528 * Gets the #AtspiTable interface for an #AtspiAccessible.
1530 * Returns: (transfer full): a pointer to an #AtspiValue interface instance, or
1531 * NULL if @obj does not implement #AtspiValue.
1534 atspi_accessible_get_value_iface (AtspiAccessible *accessible)
1536 return (_atspi_accessible_is_a (accessible, atspi_interface_value) ?
1537 g_object_ref (ATSPI_VALUE (accessible)) : NULL);
1541 append_const_val (GArray *array, const gchar *val)
1543 gchar *dup = g_strdup (val);
1546 g_array_append_val (array, dup);
1550 * atspi_accessible_get_interfaces:
1551 * @obj: The #AtspiAccessible to query.
1553 * A set of pointers to all interfaces supported by an #AtspiAccessible.
1555 * Returns: (element-type gchar*) (transfer full): A #GArray of strings
1556 * describing the interfaces supported by the object. Interfaces are
1557 * denoted in short-hand (i.e. "Component", "Text" etc.).
1560 atspi_accessible_get_interfaces (AtspiAccessible *obj)
1562 GArray *ret = g_array_new (TRUE, TRUE, sizeof (gchar *));
1564 g_return_val_if_fail (obj != NULL, NULL);
1566 append_const_val (ret, "Accessible");
1567 if (atspi_accessible_is_action (obj))
1568 append_const_val (ret, "Action");
1569 if (atspi_accessible_is_collection (obj))
1570 append_const_val (ret, "Collection");
1571 if (atspi_accessible_is_component (obj))
1572 append_const_val (ret, "Component");
1573 if (atspi_accessible_is_document (obj))
1574 append_const_val (ret, "Document");
1575 if (atspi_accessible_is_editable_text (obj))
1576 append_const_val (ret, "EditableText");
1577 if (atspi_accessible_is_hypertext (obj))
1578 append_const_val (ret, "Hypertext");
1579 if (atspi_accessible_is_hyperlink (obj))
1580 append_const_val (ret, "Hyperlink");
1581 if (atspi_accessible_is_image (obj))
1582 append_const_val (ret, "Image");
1583 if (atspi_accessible_is_selection (obj))
1584 append_const_val (ret, "Selection");
1585 if (atspi_accessible_is_table (obj))
1586 append_const_val (ret, "Table");
1587 if (atspi_accessible_is_table_cell (obj))
1588 append_const_val (ret, "TableCell");
1589 if (atspi_accessible_is_text (obj))
1590 append_const_val (ret, "Text");
1591 if (atspi_accessible_is_value (obj))
1592 append_const_val (ret, "Value");
1598 _atspi_accessible_new (AtspiApplication *app, const gchar *path)
1600 AtspiAccessible *accessible;
1602 accessible = g_object_new (ATSPI_TYPE_ACCESSIBLE, NULL);
1603 g_return_val_if_fail (accessible != NULL, NULL);
1605 accessible->parent.app = g_object_ref (app);
1606 accessible->parent.path = g_strdup (path);
1612 * atspi_accessible_set_cache_mask:
1613 * @accessible: The #AtspiAccessible to operate on. Must be the desktop or
1614 * the root of an application.
1615 * @mask: An #AtspiCache specifying a bit mask of the types of data to cache.
1617 * Sets the type of data to cache for accessibles.
1618 * If this is not set for an application or is reset to ATSPI_CACHE_UNDEFINED,
1619 * then the desktop's cache flag will be used.
1620 * If the desktop's cache flag is also undefined, then all possible data will
1622 * This function is intended to work around bugs in toolkits where the proper
1623 * events are not raised / to aid in testing for such bugs.
1626 atspi_accessible_set_cache_mask (AtspiAccessible *accessible, AtspiCache mask)
1628 g_return_if_fail (accessible != NULL);
1629 g_return_if_fail (accessible->parent.app != NULL);
1630 g_return_if_fail (accessible == accessible->parent.app->root);
1631 accessible->parent.app->cache = mask;
1632 enable_caching = TRUE;
1636 * atspi_accessible_clear_cache:
1637 * @accessible: The #AtspiAccessible whose cache to clear.
1639 * Clears the cached information for the given accessible and all of its
1643 atspi_accessible_clear_cache (AtspiAccessible *accessible)
1649 accessible->cached_properties = ATSPI_CACHE_NONE;
1650 for (l = accessible->children; l; l = l->next)
1651 atspi_accessible_clear_cache (l->data);
1656 * atspi_accessible_get_process_id:
1657 * @accessible: The #AtspiAccessible to query.
1658 * @error: a pointer to a %NULL #GError pointer
1660 * Returns the process id associated with the given accessible. Mainly
1661 * added for debugging; it is a shortcut to explicitly querying the
1662 * accessible's app->bus_name and then calling GetConnectionUnixProcessID.
1664 * Returns: The process ID or undetermined value if @error is set.
1667 atspi_accessible_get_process_id (AtspiAccessible *accessible, GError **error)
1669 DBusMessage *message, *reply;
1670 DBusConnection *bus = _atspi_bus ();
1671 dbus_uint32_t pid = -1;
1674 if (!accessible->parent.app || !accessible->parent.app->bus_name)
1676 g_set_error_literal(error, ATSPI_ERROR, ATSPI_ERROR_IPC, "Process is defunct");
1680 message = dbus_message_new_method_call ("org.freedesktop.DBus",
1681 "/org/freedesktop/DBus",
1682 "org.freedesktop.DBus",
1683 "GetConnectionUnixProcessID");
1684 dbus_message_append_args (message, DBUS_TYPE_STRING,
1685 &accessible->parent.app->bus_name,
1687 dbus_error_init (&d_error);
1688 reply = dbus_connection_send_with_reply_and_block (bus, message, -1, &d_error);
1689 dbus_message_unref (message);
1692 if (!strcmp (dbus_message_get_signature (reply), "u"))
1693 dbus_message_get_args (reply, NULL, DBUS_TYPE_UINT32, &pid, DBUS_TYPE_INVALID);
1694 dbus_message_unref (reply);
1696 if (dbus_error_is_set (&d_error))
1698 g_set_error_literal(error, ATSPI_ERROR, ATSPI_ERROR_IPC, "Process is defunct");
1699 dbus_error_free (&d_error);
1705 _atspi_accessible_get_cache_mask (AtspiAccessible *accessible)
1709 if (!accessible->parent.app)
1710 return ATSPI_CACHE_NONE;
1712 mask = accessible->parent.app->cache;
1713 if (mask == ATSPI_CACHE_UNDEFINED &&
1714 accessible->parent.app->root &&
1715 accessible->parent.app->root->accessible_parent)
1717 AtspiAccessible *desktop = atspi_get_desktop (0);
1718 mask = desktop->parent.app->cache;
1719 g_object_unref (desktop);
1722 if (mask == ATSPI_CACHE_UNDEFINED)
1723 mask = ATSPI_CACHE_DEFAULT;
1729 _atspi_accessible_test_cache (AtspiAccessible *accessible, AtspiCache flag)
1731 AtspiCache mask = _atspi_accessible_get_cache_mask (accessible);
1732 AtspiCache result = accessible->cached_properties & mask & flag;
1733 if (accessible->states && atspi_state_set_contains (accessible->states, ATSPI_STATE_TRANSIENT))
1735 return (result != 0 && (atspi_main_loop || enable_caching ||
1736 flag == ATSPI_CACHE_INTERFACES) &&
1741 _atspi_accessible_add_cache (AtspiAccessible *accessible, AtspiCache flag)
1743 AtspiCache mask = _atspi_accessible_get_cache_mask (accessible);
1745 accessible->cached_properties |= flag & mask;
1749 * atspi_accessible_get_locale:
1750 * @accessible: an #AtspiAccessible
1752 * Gets a UTF-8 string indicating the POSIX-style LC_MESSAGES locale
1757 * Returns: a UTF-8 string indicating the POSIX-style LC_MESSAGES
1758 * locale of @accessible.
1761 atspi_accessible_get_object_locale (AtspiAccessible *accessible, GError **error)
1765 g_return_val_if_fail (accessible != NULL, NULL);
1767 locale = g_object_get_qdata (G_OBJECT (accessible), quark_locale);
1770 if (!_atspi_dbus_get_property (accessible, atspi_interface_accessible,
1771 "Locale", error, "s", &locale))
1774 g_object_set_qdata_full (G_OBJECT (accessible), quark_locale, locale,
1781 free_value (gpointer data)
1783 GValue *value = data;
1785 g_value_unset (value);
1790 _atspi_accessible_ref_cache (AtspiAccessible *accessible)
1792 AtspiAccessiblePrivate *priv = accessible->priv;
1794 priv->cache_ref_count++;
1796 return g_hash_table_ref (priv->cache);
1797 priv->cache = g_hash_table_new_full (g_str_hash, g_str_equal, g_free,
1803 _atspi_accessible_unref_cache (AtspiAccessible *accessible)
1805 AtspiAccessiblePrivate *priv = accessible->priv;
1809 g_hash_table_unref (priv->cache);
1810 if (--priv->cache_ref_count == 0)