2 * AT-SPI - Assistive Technology Service Provider Interface
3 * (Gnome Accessibility Project; http://developer.gnome.org/projects/gap)
5 * Copyright 2001, 2002 Sun Microsystems Inc.,
6 * Copyright 2001, 2002 Ximian, Inc.
7 * Copyright 2010, 2011 Novell, Inc.
9 * This library is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Library General Public
11 * License as published by the Free Software Foundation; either
12 * version 2 of the License, or (at your option) any later version.
14 * This library is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * Library General Public License for more details.
19 * You should have received a copy of the GNU Library General Public
20 * License along with this library; if not, write to the
21 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
22 * Boston, MA 02111-1307, USA.
25 #include "atspi-private.h"
26 #include "atspi-accessible-private.h"
29 static gboolean enable_caching = FALSE;
30 static guint quark_locale;
33 atspi_action_interface_init (AtspiAction *action)
38 atspi_collection_interface_init (AtspiCollection *component)
43 atspi_component_interface_init (AtspiComponent *component)
48 atspi_document_interface_init (AtspiDocument *document)
53 atspi_editable_text_interface_init (AtspiEditableText *editable_text)
58 atspi_hypertext_interface_init (AtspiHypertext *hypertext)
63 atspi_image_interface_init (AtspiImage *image)
68 atspi_selection_interface_init (AtspiSelection *selection)
73 atspi_table_interface_init (AtspiTable *table)
78 atspi_table_cell_interface_init (AtspiTableCell *cell)
83 atspi_text_interface_init (AtspiText *text)
88 atspi_value_interface_init (AtspiValue *value)
92 G_DEFINE_TYPE_WITH_CODE (AtspiAccessible, atspi_accessible, ATSPI_TYPE_OBJECT,
93 G_ADD_PRIVATE (AtspiAccessible)
94 G_IMPLEMENT_INTERFACE (ATSPI_TYPE_ACTION, atspi_action_interface_init)
95 G_IMPLEMENT_INTERFACE (ATSPI_TYPE_COLLECTION, atspi_collection_interface_init)
96 G_IMPLEMENT_INTERFACE (ATSPI_TYPE_COMPONENT, atspi_component_interface_init)
97 G_IMPLEMENT_INTERFACE (ATSPI_TYPE_DOCUMENT, atspi_document_interface_init)
98 G_IMPLEMENT_INTERFACE (ATSPI_TYPE_EDITABLE_TEXT, atspi_editable_text_interface_init)
99 G_IMPLEMENT_INTERFACE (ATSPI_TYPE_HYPERTEXT, atspi_hypertext_interface_init)
100 G_IMPLEMENT_INTERFACE (ATSPI_TYPE_IMAGE, atspi_image_interface_init)
101 G_IMPLEMENT_INTERFACE (ATSPI_TYPE_SELECTION, atspi_selection_interface_init)
102 G_IMPLEMENT_INTERFACE (ATSPI_TYPE_TABLE, atspi_table_interface_init)
103 G_IMPLEMENT_INTERFACE (ATSPI_TYPE_TABLE_CELL, atspi_table_cell_interface_init)
104 G_IMPLEMENT_INTERFACE (ATSPI_TYPE_TEXT, atspi_text_interface_init)
105 G_IMPLEMENT_INTERFACE (ATSPI_TYPE_VALUE, atspi_value_interface_init))
107 #ifdef DEBUG_REF_COUNTS
108 static gint accessible_count = 0;
112 atspi_accessible_init (AtspiAccessible *accessible)
114 #ifdef DEBUG_REF_COUNTS
116 g_hash_table_insert (_atspi_get_live_refs (), accessible, NULL);
117 g_print("at-spi: init: %d objects\n", accessible_count);
120 accessible->priv = atspi_accessible_get_instance_private (accessible);
124 atspi_accessible_dispose (GObject *object)
126 AtspiAccessible *accessible = ATSPI_ACCESSIBLE (object);
128 AtspiAccessible *parent;
132 /* TODO: Only fire if object not already marked defunct */
133 memset (&e, 0, sizeof (e));
134 e.type = "object:state-changed:defunct";
135 e.source = accessible;
138 _atspi_send_event (&e);
140 if (accessible->states)
142 g_object_unref (accessible->states);
143 accessible->states = NULL;
146 parent = accessible->accessible_parent;
147 if (parent && parent->children)
149 GList*ls = g_list_find (parent->children, accessible);
152 gboolean replace = (ls == parent->children);
153 ls = g_list_remove (ls, accessible);
155 parent->children = ls;
156 g_object_unref (object);
162 g_object_unref (parent);
163 accessible->accessible_parent = NULL;
166 children = accessible->children;
167 accessible->children = NULL;
168 for (l = children; l; l = l->next)
170 AtspiAccessible *child = l->data;
171 if (child && child->accessible_parent == accessible)
173 g_object_unref (accessible);
174 child->accessible_parent = NULL;
176 g_object_unref (child);
178 g_list_free (children);
180 G_OBJECT_CLASS (atspi_accessible_parent_class) ->dispose (object);
184 atspi_accessible_finalize (GObject *object)
186 AtspiAccessible *accessible = ATSPI_ACCESSIBLE (object);
188 g_free (accessible->description);
189 g_free (accessible->name);
190 if (accessible->attributes)
191 g_hash_table_unref (accessible->attributes);
193 #ifdef DEBUG_REF_COUNTS
195 g_hash_table_remove (_atspi_get_live_refs (), accessible);
196 g_print ("at-spi: finalize: %d objects\n", accessible_count);
199 G_OBJECT_CLASS (atspi_accessible_parent_class)
204 atspi_accessible_class_init (AtspiAccessibleClass *klass)
206 GObjectClass *object_class = G_OBJECT_CLASS (klass);
208 object_class->dispose = atspi_accessible_dispose;
209 object_class->finalize = atspi_accessible_finalize;
211 quark_locale = g_quark_from_string ("accessible-locale");
215 * atspi_accessible_get_name:
216 * @obj: a pointer to the #AtspiAccessible object on which to operate.
218 * Gets the name of an #AtspiAccessible object.
220 * Returns: a UTF-8 string indicating the name of the #AtspiAccessible object
221 * or NULL on exception.
224 atspi_accessible_get_name (AtspiAccessible *obj, GError **error)
226 g_return_val_if_fail (obj != NULL, g_strdup (""));
227 if (!_atspi_accessible_test_cache (obj, ATSPI_CACHE_NAME))
229 if (!_atspi_dbus_get_property (obj, atspi_interface_accessible, "Name", error,
231 return g_strdup ("");
232 _atspi_accessible_add_cache (obj, ATSPI_CACHE_NAME);
234 return g_strdup (obj->name);
238 * atspi_accessible_get_description:
239 * @obj: a pointer to the #AtspiAccessible object on which to operate.
241 * Gets the description of an #AtspiAccessible object.
243 * Returns: a UTF-8 string describing the #AtspiAccessible object
244 * or NULL on exception.
247 atspi_accessible_get_description (AtspiAccessible *obj, GError **error)
249 g_return_val_if_fail (obj != NULL, g_strdup (""));
251 if (!_atspi_accessible_test_cache (obj, ATSPI_CACHE_DESCRIPTION))
253 if (!_atspi_dbus_get_property (obj, atspi_interface_accessible,
254 "Description", error, "s",
256 return g_strdup ("");
257 _atspi_accessible_add_cache (obj, ATSPI_CACHE_DESCRIPTION);
259 return g_strdup (obj->description);
262 const char *str_parent = "Parent";
265 * atspi_accessible_get_parent:
266 * @obj: a pointer to the #AtspiAccessible object to query.
268 * Gets an #AtspiAccessible object's parent container.
270 * Returns: (transfer full): a pointer to the #AtspiAccessible object which
271 * contains the given #AtspiAccessible instance, or NULL if the @obj
272 * has no parent container.
276 atspi_accessible_get_parent (AtspiAccessible *obj, GError **error)
278 g_return_val_if_fail (obj != NULL, NULL);
280 if (obj->parent.app &&
281 !_atspi_accessible_test_cache (obj, ATSPI_CACHE_PARENT))
283 DBusMessage *message, *reply;
284 DBusMessageIter iter, iter_variant;
285 message = dbus_message_new_method_call (obj->parent.app->bus_name,
287 DBUS_INTERFACE_PROPERTIES, "Get");
290 dbus_message_append_args (message, DBUS_TYPE_STRING, &atspi_interface_accessible,
291 DBUS_TYPE_STRING, &str_parent,
293 reply = _atspi_dbus_send_with_reply_and_block (message, error);
296 if (strcmp (dbus_message_get_signature (reply), "v") != 0)
298 dbus_message_unref (reply);
301 dbus_message_iter_init (reply, &iter);
302 dbus_message_iter_recurse (&iter, &iter_variant);
303 obj->accessible_parent = _atspi_dbus_return_accessible_from_iter (&iter_variant);
304 dbus_message_unref (reply);
305 _atspi_accessible_add_cache (obj, ATSPI_CACHE_PARENT);
307 if (!obj->accessible_parent)
309 return g_object_ref (obj->accessible_parent);
313 * atspi_accessible_get_child_count:
314 * @obj: a pointer to the #AtspiAccessible object on which to operate.
316 * Gets the number of children contained by an #AtspiAccessible object.
318 * Returns: a #long indicating the number of #AtspiAccessible children
319 * contained by an #AtspiAccessible object or -1 on exception.
323 atspi_accessible_get_child_count (AtspiAccessible *obj, GError **error)
325 g_return_val_if_fail (obj != NULL, -1);
327 if (!_atspi_accessible_test_cache (obj, ATSPI_CACHE_CHILDREN))
330 if (!_atspi_dbus_get_property (obj, atspi_interface_accessible,
331 "ChildCount", error, "i", &ret))
336 return g_list_length (obj->children);
340 * atspi_accessible_get_child_at_index:
341 * @obj: a pointer to the #AtspiAccessible object on which to operate.
342 * @child_index: a #long indicating which child is specified.
344 * Gets the #AtspiAccessible child of an #AtspiAccessible object at a given index.
346 * Returns: (transfer full): a pointer to the #AtspiAccessible child object at
347 * index @child_index or NULL on exception.
350 atspi_accessible_get_child_at_index (AtspiAccessible *obj,
354 AtspiAccessible *child;
356 g_return_val_if_fail (obj != NULL, NULL);
358 if (!_atspi_accessible_test_cache (obj, ATSPI_CACHE_CHILDREN))
361 reply = _atspi_dbus_call_partial (obj, atspi_interface_accessible,
362 "GetChildAtIndex", error, "i",
364 return _atspi_dbus_return_accessible_from_message (reply);
367 child = g_list_nth_data (obj->children, child_index);
370 return g_object_ref (child);
374 * atspi_accessible_get_index_in_parent:
375 * @obj: a pointer to the #AtspiAccessible object on which to operate.
377 * Gets the index of an #AtspiAccessible object within its parent's
378 * #AtspiAccessible children list.
380 * Returns: a #glong indicating the index of the #AtspiAccessible object
382 * or -1 if @obj has no containing parent or on exception.
385 atspi_accessible_get_index_in_parent (AtspiAccessible *obj, GError **error)
390 g_return_val_if_fail (obj != NULL, -1);
391 if (_atspi_accessible_test_cache (obj, ATSPI_CACHE_PARENT) &&
392 !obj->accessible_parent)
394 if (!obj->accessible_parent ||
395 !_atspi_accessible_test_cache (obj->accessible_parent,
396 ATSPI_CACHE_CHILDREN))
398 dbus_int32_t ret = -1;
399 _atspi_dbus_call (obj, atspi_interface_accessible,
400 "GetIndexInParent", NULL, "=>i", &ret);
404 l = obj->accessible_parent->children;
407 if (l->data == obj) return i;
418 } Accessibility_Relation;
421 * atspi_accessible_get_relation_set:
422 * @obj: a pointer to the #AtspiAccessible object on which to operate.
424 * Gets the set of #AtspiRelation objects which describes this #AtspiAccessible object's
425 * relationships with other #AtspiAccessible objects.
427 * Returns: (element-type AtspiAccessible*) (transfer full): a #GArray of
428 * #AtspiRelation pointers or NULL on exception.
431 atspi_accessible_get_relation_set (AtspiAccessible *obj, GError **error)
434 DBusMessageIter iter, iter_array;
437 g_return_val_if_fail (obj != NULL, NULL);
439 reply = _atspi_dbus_call_partial (obj, atspi_interface_accessible, "GetRelationSet", error, "");
442 _ATSPI_DBUS_CHECK_SIG (reply, "a(ua(so))", error, NULL);
444 ret = g_array_new (TRUE, TRUE, sizeof (AtspiRelation *));
445 dbus_message_iter_init (reply, &iter);
446 dbus_message_iter_recurse (&iter, &iter_array);
447 while (dbus_message_iter_get_arg_type (&iter_array) != DBUS_TYPE_INVALID)
449 AtspiRelation *relation;
450 relation = _atspi_relation_new_from_iter (&iter_array);
451 ret = g_array_append_val (ret, relation);
452 dbus_message_iter_next (&iter_array);
454 dbus_message_unref (reply);
459 * atspi_accessible_get_role:
460 * @obj: a pointer to the #AtspiAccessible object on which to operate.
462 * Gets the UI role played by an #AtspiAccessible object.
463 * This role's name can be obtained via atspi_accessible_get_role_name ().
465 * Returns: the #AtspiRole of an #AtspiAccessible object.
469 atspi_accessible_get_role (AtspiAccessible *obj, GError **error)
471 g_return_val_if_fail (obj != NULL, ATSPI_ROLE_INVALID);
473 if (!_atspi_accessible_test_cache (obj, ATSPI_CACHE_ROLE))
476 /* TODO: Make this a property */
477 if (_atspi_dbus_call (obj, atspi_interface_accessible, "GetRole", error, "=>u", &role))
480 _atspi_accessible_add_cache (obj, ATSPI_CACHE_ROLE);
487 * atspi_accessible_get_role_name:
488 * @obj: a pointer to the #AtspiAccessible object on which to operate.
490 * Gets a UTF-8 string corresponding to the name of the role played by an object.
491 * This method will return useful values for roles that fall outside the
492 * enumeration used in atspi_accessible_get_role ().
494 * Returns: a UTF-8 string specifying the type of UI role played by an
495 * #AtspiAccessible object.
499 atspi_accessible_get_role_name (AtspiAccessible *obj, GError **error)
501 gchar *retval = NULL;
504 g_return_val_if_fail (obj != NULL, NULL);
506 role = atspi_accessible_get_role (obj, error);
507 if (role >= 0 && role < ATSPI_ROLE_COUNT && role != ATSPI_ROLE_EXTENDED)
508 return atspi_role_get_name (role);
510 _atspi_dbus_call (obj, atspi_interface_accessible, "GetRoleName", error, "=>s", &retval);
513 retval = g_strdup ("");
519 * atspi_accessible_get_localized_role_name:
520 * @obj: a pointer to the #AtspiAccessible object on which to operate.
522 * Gets a UTF-8 string corresponding to the name of the role played by an
523 * object, translated to the current locale.
524 * This method will return useful values for roles that fall outside the
525 * enumeration used in atspi_accessible_getRole ().
527 * Returns: a localized, UTF-8 string specifying the type of UI role played
528 * by an #AtspiAccessible object.
532 atspi_accessible_get_localized_role_name (AtspiAccessible *obj, GError **error)
536 g_return_val_if_fail (obj != NULL, NULL);
538 _atspi_dbus_call (obj, atspi_interface_accessible, "GetLocalizedRoleName", error, "=>s", &retval);
541 return g_strdup ("");
546 static AtspiStateSet *
549 AtspiStateSet *set = atspi_state_set_new (NULL);
550 atspi_state_set_add (set, ATSPI_STATE_DEFUNCT);
555 * atspi_accessible_get_state_set:
556 * @obj: a pointer to the #AtspiAccessible object on which to operate.
558 * Gets the states currently held by an object.
560 * Returns: (transfer full): a pointer to an #AtspiStateSet representing an
561 * object's current state set.
564 atspi_accessible_get_state_set (AtspiAccessible *obj)
566 /* TODO: Should take a GError **, but would be an API break */
567 if (!obj->parent.app || !obj->parent.app->bus)
568 return defunct_set ();
570 if (!_atspi_accessible_test_cache (obj, ATSPI_CACHE_STATES))
573 DBusMessageIter iter;
574 reply = _atspi_dbus_call_partial (obj, atspi_interface_accessible,
575 "GetState", NULL, "");
576 _ATSPI_DBUS_CHECK_SIG (reply, "au", NULL, defunct_set ());
577 dbus_message_iter_init (reply, &iter);
578 _atspi_dbus_set_state (obj, &iter);
579 dbus_message_unref (reply);
580 _atspi_accessible_add_cache (obj, ATSPI_CACHE_STATES);
583 return g_object_ref (obj->states);
587 * atspi_accessible_get_attributes:
588 * @obj: The #AtspiAccessible being queried.
590 * Gets the #AttributeSet representing any assigned
591 * name-value pair attributes or annotations for this object.
592 * For typographic, textual, or textually-semantic attributes, see
593 * atspi_text_get_attributes instead.
595 * Returns: (element-type gchar* gchar*) (transfer full): The name-value-pair
596 * attributes assigned to this object.
599 atspi_accessible_get_attributes (AtspiAccessible *obj, GError **error)
601 DBusMessage *message;
603 g_return_val_if_fail (obj != NULL, NULL);
605 if (obj->priv->cache)
607 GValue *val = g_hash_table_lookup (obj->priv->cache, "Attributes");
609 return g_value_dup_boxed (val);
612 if (!_atspi_accessible_test_cache (obj, ATSPI_CACHE_ATTRIBUTES))
614 message = _atspi_dbus_call_partial (obj, atspi_interface_accessible,
615 "GetAttributes", error, "");
616 obj->attributes = _atspi_dbus_return_hash_from_message (message);
617 _atspi_accessible_add_cache (obj, ATSPI_CACHE_ATTRIBUTES);
620 if (!obj->attributes)
622 return g_hash_table_ref (obj->attributes);
626 add_to_attribute_array (gpointer key, gpointer value, gpointer data)
628 GArray **array = (GArray **)data;
629 gchar *str = g_strconcat (key, ":", value, NULL);
630 *array = g_array_append_val (*array, str);
634 * atspi_accessible_get_attributes_as_array:
635 * @obj: The #AtspiAccessible being queried.
637 * Gets a #GArray representing any assigned
638 * name-value pair attributes or annotations for this object.
639 * For typographic, textual, or textually-semantic attributes, see
640 * atspi_text_get_attributes_as_array instead.
642 * Returns: (element-type gchar*) (transfer full): The name-value-pair
643 * attributes assigned to this object.
646 atspi_accessible_get_attributes_as_array (AtspiAccessible *obj, GError **error)
648 DBusMessage *message;
650 g_return_val_if_fail (obj != NULL, NULL);
652 if (obj->priv->cache)
654 GValue *val = g_hash_table_lookup (obj->priv->cache, "Attributes");
657 GArray *array = g_array_new (TRUE, TRUE, sizeof (gchar *));
658 GHashTable *attributes = g_value_get_boxed (val);
659 g_hash_table_foreach (attributes, add_to_attribute_array, &array);
664 message = _atspi_dbus_call_partial (obj, atspi_interface_accessible, "GetAttributes", error, "");
665 return _atspi_dbus_return_attribute_array_from_message (message);
669 * atspi_accessible_get_application:
670 * @obj: The #AtspiAccessible being queried.
672 * Gets the containing #AtspiApplication for an object.
674 * Returns: (transfer full): the containing #AtspiApplication instance for
678 atspi_accessible_get_application (AtspiAccessible *obj, GError **error)
680 AtspiAccessible *parent;
685 parent = atspi_accessible_get_parent (obj, NULL);
686 if (!parent && obj->parent.app &&
687 atspi_accessible_get_role (obj, NULL) != ATSPI_ROLE_APPLICATION)
689 AtspiAccessible *root = g_object_ref (obj->parent.app->root);
692 g_object_unref (obj);
693 if (atspi_accessible_get_role (root, NULL) == ATSPI_ROLE_DESKTOP_FRAME)
695 g_object_unref (root);
701 if (!parent || parent == obj ||
702 atspi_accessible_get_role (parent, NULL) == ATSPI_ROLE_DESKTOP_FRAME)
705 g_object_unref (parent);
708 g_object_unref (obj);
713 /* Application-specific methods */
716 * atspi_accessible_get_toolkit_name:
717 * @obj: a pointer to the #AtspiAccessible object on which to operate.
719 * Gets the toolkit name for an #AtspiAccessible object.
720 * Only works on application root objects.
722 * Returns: a UTF-8 string indicating the toolkit name for the #AtspiAccessible object or NULL on exception.
725 atspi_accessible_get_toolkit_name (AtspiAccessible *obj, GError **error)
727 g_return_val_if_fail (obj != NULL, NULL);
729 if (!obj->parent.app)
732 if (!obj->parent.app->toolkit_name)
733 _atspi_dbus_get_property (obj, atspi_interface_application, "ToolkitName",
734 error, "s", &obj->parent.app->toolkit_name);
736 return g_strdup (obj->parent.app->toolkit_name);
740 * atspi_accessible_get_toolkit_version:
741 * @obj: a pointer to the #AtspiAccessible object on which to operate.
743 * Gets the toolkit version for an #AtspiAccessible object.
744 * Only works on application root objects.
746 * Returns: a UTF-8 string indicating the toolkit version for the #AtspiAccessible object or NULL on exception.
749 atspi_accessible_get_toolkit_version (AtspiAccessible *obj, GError **error)
751 g_return_val_if_fail (obj != NULL, NULL);
753 if (!obj->parent.app)
756 if (!obj->parent.app->toolkit_version)
757 _atspi_dbus_get_property (obj, atspi_interface_application, "Version",
758 error, "s", &obj->parent.app->toolkit_version);
760 return g_strdup (obj->parent.app->toolkit_version);
764 * atspi_accessible_get_atspi_version:
765 * @obj: a pointer to the #AtspiAccessible object on which to operate.
767 * Gets the AT-SPI IPC specification version supported by the application
768 * pointed to by the #AtspiAccessible object.
769 * Only works on application root objects.
771 * Returns: a UTF-8 string indicating the AT-SPI version for the #AtspiAccessible object or NULL on exception.
774 atspi_accessible_get_atspi_version (AtspiAccessible *obj, GError **error)
776 g_return_val_if_fail (obj != NULL, NULL);
778 if (!obj->parent.app)
781 if (!obj->parent.app->atspi_version)
782 _atspi_dbus_get_property (obj, atspi_interface_application, "AtspiVersion",
783 error, "s", &obj->parent.app->atspi_version);
785 return g_strdup (obj->parent.app->atspi_version);
789 * atspi_accessible_get_id:
790 * @obj: a pointer to the #AtspiAccessible object on which to operate.
792 * Gets the application id for a #AtspiAccessible object.
793 * Only works on application root objects.
795 * Returns: a positive #gint indicating the id for the #AtspiAccessible object
796 * or -1 on exception.
799 atspi_accessible_get_id (AtspiAccessible *obj, GError **error)
803 g_return_val_if_fail (obj != NULL, -1);
805 if (!_atspi_dbus_get_property (obj, atspi_interface_application, "Id", error, "i", &ret))
811 /* Interface query methods */
814 _atspi_accessible_is_a (AtspiAccessible *accessible,
815 const char *interface_name)
819 if (accessible == NULL)
824 if (!_atspi_accessible_test_cache (accessible, ATSPI_CACHE_INTERFACES))
827 DBusMessageIter iter;
828 reply = _atspi_dbus_call_partial (accessible, atspi_interface_accessible,
829 "GetInterfaces", NULL, "");
830 _ATSPI_DBUS_CHECK_SIG (reply, "as", NULL, FALSE);
831 dbus_message_iter_init (reply, &iter);
832 _atspi_dbus_set_interfaces (accessible, &iter);
833 dbus_message_unref (reply);
834 _atspi_accessible_add_cache (accessible, ATSPI_CACHE_INTERFACES);
837 n = _atspi_get_iface_num (interface_name);
838 if (n == -1) return FALSE;
839 return (gboolean) ((accessible->interfaces & (1 << n))? TRUE: FALSE);
843 * atspi_accessible_is_action:
844 * @obj: a pointer to the #AtspiAccessible instance to query.
846 * Query whether the specified #AtspiAccessible implements the
847 * #AtspiAction interface.
849 * Returns: #TRUE if @obj implements the #AtspiAction interface,
853 atspi_accessible_is_action (AtspiAccessible *obj)
855 return _atspi_accessible_is_a (obj,
856 atspi_interface_action);
860 * atspi_accessible_is_application:
861 * @obj: a pointer to the #AtspiAccessible instance to query.
863 * Query whether the specified #AtspiAccessible implements the
864 * #AtspiApplication interface.
866 * Returns: #TRUE if @obj implements the #AtspiApplication interface,
870 atspi_accessible_is_application (AtspiAccessible *obj)
872 return _atspi_accessible_is_a (obj,
873 atspi_interface_application);
877 * atspi_accessible_is_collection:
878 * @obj: a pointer to the #AtspiAccessible instance to query.
880 * Query whether the specified #AtspiAccessible implements the
881 * #AtspiCollection interface.
883 * Returns: #TRUE if @obj implements the #AtspiCollection interface,
887 atspi_accessible_is_collection (AtspiAccessible *obj)
889 return _atspi_accessible_is_a (obj,
890 atspi_interface_collection);
894 * atspi_accessible_is_component:
895 * @obj: a pointer to the #AtspiAccessible instance to query.
897 * Query whether the specified #AtspiAccessible implements #AtspiComponent.
899 * Returns: #TRUE if @obj implements the #AtspiComponent interface,
903 atspi_accessible_is_component (AtspiAccessible *obj)
905 return _atspi_accessible_is_a (obj,
906 atspi_interface_component);
910 * atspi_accessible_is_document:
911 * @obj: a pointer to the #AtspiAccessible instance to query.
913 * Query whether the specified #AtspiAccessible implements the
914 * #AtspiDocument interface.
916 * Returns: #TRUE if @obj implements the #AtspiDocument interface,
920 atspi_accessible_is_document (AtspiAccessible *obj)
922 return _atspi_accessible_is_a (obj,
923 atspi_interface_document);
927 * atspi_accessible_is_editable_text:
928 * @obj: a pointer to the #AtspiAccessible instance to query.
930 * Query whether the specified #AtspiAccessible implements the
931 * #AtspiEditableText interface.
933 * Returns: #TRUE if @obj implements the #AtspiEditableText interface,
937 atspi_accessible_is_editable_text (AtspiAccessible *obj)
939 return _atspi_accessible_is_a (obj,
940 atspi_interface_editable_text);
944 * atspi_accessible_is_hypertext:
945 * @obj: a pointer to the #AtspiAccessible instance to query.
947 * Query whether the specified #AtspiAccessible implements the
948 * #AtspiHypertext interface.
950 * Returns: #TRUE if @obj implements the #AtspiHypertext interface,
954 atspi_accessible_is_hypertext (AtspiAccessible *obj)
956 return _atspi_accessible_is_a (obj,
957 atspi_interface_hypertext);
961 * atspi_accessible_is_hyperlink:
962 * @obj: a pointer to the #AtspiAccessible instance to query.
964 * Query whether the specified #AtspiAccessible implements the
965 * #AtspiHyperlink interface.
967 * Returns: #TRUE if @obj implements the #AtspiHypertext interface,
971 atspi_accessible_is_hyperlink (AtspiAccessible *obj)
973 return _atspi_accessible_is_a (obj,
974 atspi_interface_hyperlink);
978 * atspi_accessible_is_image:
979 * @obj: a pointer to the #AtspiAccessible instance to query.
981 * Query whether the specified #AtspiAccessible implements the
982 * #AtspiImage interface.
984 * Returns: #TRUE if @obj implements the #AtspiImage interface,
988 atspi_accessible_is_image (AtspiAccessible *obj)
990 return _atspi_accessible_is_a (obj,
991 atspi_interface_image);
995 * atspi_accessible_is_selection:
996 * @obj: a pointer to the #AtspiAccessible instance to query.
998 * Query whether the specified #AtspiAccessible implements the
999 * #AtspiSelection interface.
1001 * Returns: #TRUE if @obj implements the #AtspiSelection interface,
1005 atspi_accessible_is_selection (AtspiAccessible *obj)
1007 return _atspi_accessible_is_a (obj,
1008 atspi_interface_selection);
1012 * atspi_accessible_is_table:
1013 * @obj: a pointer to the #AtspiAccessible instance to query.
1015 * Query whether the specified #AtspiAccessible implements the
1016 * #AtspiTable interface.
1018 * Returns: #TRUE if @obj implements the #AtspiTable interface,
1022 atspi_accessible_is_table (AtspiAccessible *obj)
1024 return _atspi_accessible_is_a (obj,
1025 atspi_interface_table);
1029 * atspi_accessible_is_table_cell:
1030 * @obj: a pointer to the #AtspiAccessible instance to query.
1032 * Query whether the specified #AtspiAccessible implements the
1033 * #AtspiTableCell interface.
1035 * Returns: #TRUE if @obj implements the #AtspiTable interface,
1039 atspi_accessible_is_table_cell (AtspiAccessible *obj)
1041 return _atspi_accessible_is_a (obj,
1042 atspi_interface_table_cell);
1046 * atspi_accessible_is_streamable_content:
1047 * @obj: a pointer to the #AtspiAccessible instance to query.
1049 * Query whether the specified #AtspiAccessible implements the
1050 * #AtspiStreamableContent interface.
1052 * Returns: #TRUE if @obj implements the #AtspiStreamableContent interface,
1056 atspi_accessible_is_streamable_content (AtspiAccessible *obj)
1059 return _atspi_accessible_is_a (obj,
1060 atspi_interface_streamable_content);
1062 g_warning ("Streamable content not implemented");
1068 * atspi_accessible_is_text:
1069 * @obj: a pointer to the #AtspiAccessible instance to query.
1071 * Query whether the specified #AtspiAccessible implements the
1072 * #AtspiText interface.
1074 * Returns: #TRUE if @obj implements the #AtspiText interface,
1078 atspi_accessible_is_text (AtspiAccessible *obj)
1080 return _atspi_accessible_is_a (obj,
1081 atspi_interface_text);
1085 * atspi_accessible_is_value:
1086 * @obj: a pointer to the #AtspiAccessible instance to query.
1088 * Query whether the specified #AtspiAccessible implements the
1089 * #AtspiValue interface.
1091 * Returns: #TRUE if @obj implements the #AtspiValue interface,
1095 atspi_accessible_is_value (AtspiAccessible *obj)
1097 return _atspi_accessible_is_a (obj,
1098 atspi_interface_value);
1102 * atspi_accessible_get_action:
1103 * @obj: a pointer to the #AtspiAccessible instance to query.
1105 * Gets the #AtspiAction interface for an #AtspiAccessible.
1107 * Returns: (transfer full): a pointer to an #AtspiAction interface
1108 * instance, or NULL if @obj does not implement #AtspiAction.
1110 * Deprecated: 2.10: Use atspi_accessible_get_action_iface instead.
1111 * Rename to: atspi_accessible_get_action_iface
1114 atspi_accessible_get_action (AtspiAccessible *accessible)
1116 return (_atspi_accessible_is_a (accessible, atspi_interface_action) ?
1117 g_object_ref (ATSPI_ACTION (accessible)) : NULL);
1121 * atspi_accessible_get_action_iface:
1122 * @obj: a pointer to the #AtspiAccessible instance to query.
1124 * Gets the #AtspiAction interface for an #AtspiAccessible.
1126 * Returns: (transfer full): a pointer to an #AtspiAction interface
1127 * instance, or NULL if @obj does not implement #AtspiAction.
1130 atspi_accessible_get_action_iface (AtspiAccessible *accessible)
1132 return (_atspi_accessible_is_a (accessible, atspi_interface_action) ?
1133 g_object_ref (ATSPI_ACTION (accessible)) : NULL);
1137 * atspi_accessible_get_collection:
1138 * @obj: a pointer to the #AtspiAccessible instance to query.
1140 * Gets the #AtspiCollection interface for an #AtspiAccessible.
1142 * Returns: (transfer full): a pointer to an #AtspiCollection interface
1143 * instance, or NULL if @obj does not implement #AtspiCollection.
1145 * Deprecated: 2.10: Use atspi_accessible_get_collection_iface instead.
1146 * Rename to: atspi_accessible_get_collection_iface
1149 atspi_accessible_get_collection (AtspiAccessible *accessible)
1151 return (_atspi_accessible_is_a (accessible, atspi_interface_collection) ?
1152 g_object_ref (ATSPI_COLLECTION (accessible)) : NULL);
1156 * atspi_accessible_get_collection_iface:
1157 * @obj: a pointer to the #AtspiAccessible instance to query.
1159 * Gets the #AtspiCollection interface for an #AtspiAccessible.
1161 * Returns: (transfer full): a pointer to an #AtspiCollection interface
1162 * instance, or NULL if @obj does not implement #AtspiCollection.
1165 atspi_accessible_get_collection_iface (AtspiAccessible *accessible)
1167 return (_atspi_accessible_is_a (accessible, atspi_interface_collection) ?
1168 g_object_ref (ATSPI_COLLECTION (accessible)) : NULL);
1172 * atspi_accessible_get_component:
1173 * @obj: a pointer to the #AtspiAccessible instance to query.
1175 * Gets the #AtspiComponent interface for an #AtspiAccessible.
1177 * Returns: (transfer full): a pointer to an #AtspiComponent interface
1178 * instance, or NULL if @obj does not implement #AtspiComponent.
1180 * Deprecated: 2.10: Use atspi_accessible_get_component_iface instead.
1181 * Rename to: atspi_accessible_get_component_iface
1184 atspi_accessible_get_component (AtspiAccessible *obj)
1186 return (_atspi_accessible_is_a (obj, atspi_interface_component) ?
1187 g_object_ref (ATSPI_COMPONENT (obj)) : NULL);
1191 * atspi_accessible_get_component_iface:
1192 * @obj: a pointer to the #AtspiAccessible instance to query.
1194 * Gets the #AtspiComponent interface for an #AtspiAccessible.
1196 * Returns: (transfer full): a pointer to an #AtspiComponent interface
1197 * instance, or NULL if @obj does not implement #AtspiComponent.
1200 atspi_accessible_get_component_iface (AtspiAccessible *obj)
1202 return (_atspi_accessible_is_a (obj, atspi_interface_component) ?
1203 g_object_ref (ATSPI_COMPONENT (obj)) : NULL);
1207 * atspi_accessible_get_document:
1208 * @obj: a pointer to the #AtspiAccessible instance to query.
1210 * Gets the #AtspiDocument interface for an #AtspiAccessible.
1212 * Returns: (transfer full): a pointer to an #AtspiDocument interface
1213 * instance, or NULL if @obj does not implement #AtspiDocument.
1215 * Deprecated: 2.10: Use atspi_accessible_get_document_iface instead.
1216 * Rename to: atspi_accessible_get_document_iface
1219 atspi_accessible_get_document (AtspiAccessible *accessible)
1221 return (_atspi_accessible_is_a (accessible, atspi_interface_document) ?
1222 g_object_ref (ATSPI_DOCUMENT (accessible)) : NULL);
1226 * atspi_accessible_get_document_iface:
1227 * @obj: a pointer to the #AtspiAccessible instance to query.
1229 * Gets the #AtspiDocument interface for an #AtspiAccessible.
1231 * Returns: (transfer full): a pointer to an #AtspiDocument interface
1232 * instance, or NULL if @obj does not implement #AtspiDocument.
1235 atspi_accessible_get_document_iface (AtspiAccessible *accessible)
1237 return (_atspi_accessible_is_a (accessible, atspi_interface_document) ?
1238 g_object_ref (ATSPI_DOCUMENT (accessible)) : NULL);
1242 * atspi_accessible_get_editable_text:
1243 * @obj: a pointer to the #AtspiAccessible instance to query.
1245 * Gets the #AtspiEditableText interface for an #AtspiAccessible.
1247 * Returns: (transfer full): a pointer to an #AtspiEditableText interface
1248 * instance, or NULL if @obj does not implement #AtspiEditableText.
1250 * Deprecated: 2.10: Use atspi_accessible_get_editable_text_iface instead.
1251 * Rename to: atspi_accessible_get_editable_text_iface
1254 atspi_accessible_get_editable_text (AtspiAccessible *accessible)
1256 return (_atspi_accessible_is_a (accessible, atspi_interface_editable_text) ?
1257 g_object_ref (ATSPI_EDITABLE_TEXT (accessible)) : NULL);
1261 * atspi_accessible_get_editable_text_iface:
1262 * @obj: a pointer to the #AtspiAccessible instance to query.
1264 * Gets the #AtspiEditableText interface for an #AtspiAccessible.
1266 * Returns: (transfer full): a pointer to an #AtspiEditableText interface
1267 * instance, or NULL if @obj does not implement #AtspiEditableText.
1270 atspi_accessible_get_editable_text_iface (AtspiAccessible *accessible)
1272 return (_atspi_accessible_is_a (accessible, atspi_interface_editable_text) ?
1273 g_object_ref (ATSPI_EDITABLE_TEXT (accessible)) : NULL);
1277 * atspi_accessible_get_hyperlink:
1278 * @obj: a pointer to the #AtspiAccessible object on which to operate.
1280 * Gets the #AtspiHyperlink interface for an #AtspiAccessible.
1282 * Returns: (transfer full): the #AtspiHyperlink object associated with
1283 * the given #AtspiAccessible, or NULL if not supported.
1286 atspi_accessible_get_hyperlink (AtspiAccessible *accessible)
1288 return (_atspi_accessible_is_a (accessible, atspi_interface_hyperlink) ?
1289 _atspi_hyperlink_new (accessible->parent.app, accessible->parent.path) : NULL);
1293 * atspi_accessible_get_hypertext:
1294 * @obj: a pointer to the #AtspiAccessible instance to query.
1296 * Gets the #AtspiHypertext interface for an #AtspiAccessible.
1298 * Returns: (transfer full): a pointer to an #AtspiHypertext interface
1299 * instance, or NULL if @obj does not implement #AtspiHypertext.
1301 * Deprecated: 2.10: Use atspi_accessible_get_hypertext_iface instead.
1302 * Rename to: atspi_accessible_get_hypertext_iface
1305 atspi_accessible_get_hypertext (AtspiAccessible *accessible)
1307 return (_atspi_accessible_is_a (accessible, atspi_interface_hypertext) ?
1308 g_object_ref (ATSPI_HYPERTEXT (accessible)) : NULL);
1312 * atspi_accessible_get_hypertext_iface:
1313 * @obj: a pointer to the #AtspiAccessible instance to query.
1315 * Gets the #AtspiHypertext interface for an #AtspiAccessible.
1317 * Returns: (transfer full): a pointer to an #AtspiHypertext interface
1318 * instance, or NULL if @obj does not implement #AtspiHypertext.
1321 atspi_accessible_get_hypertext_iface (AtspiAccessible *accessible)
1323 return (_atspi_accessible_is_a (accessible, atspi_interface_hypertext) ?
1324 g_object_ref (ATSPI_HYPERTEXT (accessible)) : NULL);
1328 * atspi_accessible_get_image:
1329 * @obj: a pointer to the #AtspiAccessible instance to query.
1331 * Gets the #AtspiImage interface for an #AtspiAccessible.
1333 * Returns: (transfer full): a pointer to an #AtspiImage interface instance, or
1334 * NULL if @obj does not implement #AtspiImage.
1336 * Deprecated: 2.10: Use atspi_accessible_get_image_iface instead.
1337 * Rename to: atspi_accessible_get_image_iface
1340 atspi_accessible_get_image (AtspiAccessible *accessible)
1342 return (_atspi_accessible_is_a (accessible, atspi_interface_image) ?
1343 g_object_ref (ATSPI_IMAGE (accessible)) : NULL);
1347 * atspi_accessible_get_image_iface:
1348 * @obj: a pointer to the #AtspiAccessible instance to query.
1350 * Gets the #AtspiImage interface for an #AtspiAccessible.
1352 * Returns: (transfer full): a pointer to an #AtspiImage interface instance, or
1353 * NULL if @obj does not implement #AtspiImage.
1356 atspi_accessible_get_image_iface (AtspiAccessible *accessible)
1358 return (_atspi_accessible_is_a (accessible, atspi_interface_image) ?
1359 g_object_ref (ATSPI_IMAGE (accessible)) : NULL);
1363 * atspi_accessible_get_selection:
1364 * @obj: a pointer to the #AtspiAccessible instance to query.
1366 * Gets the #AtspiSelection interface for an #AtspiAccessible.
1368 * Returns: (transfer full): a pointer to an #AtspiSelection interface
1369 * instance, or NULL if @obj does not implement #AtspiSelection.
1371 * Deprecated: 2.10: Use atspi_accessible_get_selection_iface instead.
1372 * Rename to: atspi_accessible_get_selection_iface
1375 atspi_accessible_get_selection (AtspiAccessible *accessible)
1377 return (_atspi_accessible_is_a (accessible, atspi_interface_selection) ?
1378 g_object_ref (ATSPI_SELECTION (accessible)) : NULL);
1382 * atspi_accessible_get_selection_iface:
1383 * @obj: a pointer to the #AtspiAccessible instance to query.
1385 * Gets the #AtspiSelection interface for an #AtspiAccessible.
1387 * Returns: (transfer full): a pointer to an #AtspiSelection interface
1388 * instance, or NULL if @obj does not implement #AtspiSelection.
1391 atspi_accessible_get_selection_iface (AtspiAccessible *accessible)
1393 return (_atspi_accessible_is_a (accessible, atspi_interface_selection) ?
1394 g_object_ref (ATSPI_SELECTION (accessible)) : NULL);
1399 * atspi_accessible_get_streamable_content:
1400 * @obj: a pointer to the #AtspiAccessible instance to query.
1402 * Gets the #AtspiStreamableContent interface for an #AtspiAccessible.
1404 * Returns: (transfer full): a pointer to an #AtspiStreamableContent interface
1405 * instance, or NULL if @obj does not implement #AtspiStreamableContent.
1407 AtspiStreamableContent *
1408 atspi_accessible_get_streamable_content (AtspiAccessible *accessible)
1410 return (_atspi_accessible_is_a (accessible, atspi_interface_streamable_content) ?
1416 * atspi_accessible_get_table:
1417 * @obj: a pointer to the #AtspiAccessible instance to query.
1419 * Gets the #AtspiTable interface for an #AtspiAccessible.
1421 * Returns: (transfer full): a pointer to an #AtspiTable interface instance, or
1422 * NULL if @obj does not implement #AtspiTable.
1424 * Deprecated: 2.10: Use atspi_accessible_get_table_iface instead.
1425 * Rename to: atspi_accessible_get_table_iface
1428 atspi_accessible_get_table (AtspiAccessible *obj)
1430 return (_atspi_accessible_is_a (obj, atspi_interface_table) ?
1431 g_object_ref (ATSPI_TABLE (obj)) : NULL);
1435 * atspi_accessible_get_table_iface:
1436 * @obj: a pointer to the #AtspiAccessible instance to query.
1438 * Gets the #AtspiTable interface for an #AtspiAccessible.
1440 * Returns: (transfer full): a pointer to an #AtspiTable interface instance, or
1441 * NULL if @obj does not implement #AtspiTable.
1444 atspi_accessible_get_table_iface (AtspiAccessible *obj)
1446 return (_atspi_accessible_is_a (obj, atspi_interface_table) ?
1447 g_object_ref (ATSPI_TABLE (obj)) : NULL);
1451 * atspi_accessible_get_table_cell:
1452 * @obj: a pointer to the #AtspiAccessible instance to query.
1454 * Gets the #AtspiTableCell interface for an #AtspiAccessible.
1456 * Returns: (transfer full): a pointer to an #AtspiTableCell interface instance,
1457 * or NULL if @obj does not implement #AtspiTable.
1460 atspi_accessible_get_table_cell (AtspiAccessible *obj)
1462 return (_atspi_accessible_is_a (obj, atspi_interface_table_cell) ?
1463 g_object_ref (ATSPI_TABLE_CELL (obj)) : NULL);
1467 * atspi_accessible_get_text:
1468 * @obj: a pointer to the #AtspiAccessible instance to query.
1470 * Gets the #AtspiTable interface for an #AtspiAccessible.
1472 * Returns: (transfer full): a pointer to an #AtspiText interface instance, or
1473 * NULL if @obj does not implement #AtspiText.
1475 * Deprecated: 2.10: Use atspi_accessible_get_text_iface instead.
1476 * Rename to: atspi_accessible_get_text_iface
1479 atspi_accessible_get_text (AtspiAccessible *obj)
1481 return (_atspi_accessible_is_a (obj, atspi_interface_text) ?
1482 g_object_ref (ATSPI_TEXT (obj)) : NULL);
1486 * atspi_accessible_get_text_iface:
1487 * @obj: a pointer to the #AtspiAccessible instance to query.
1489 * Gets the #AtspiTable interface for an #AtspiAccessible.
1491 * Returns: (transfer full): a pointer to an #AtspiText interface instance, or
1492 * NULL if @obj does not implement #AtspiText.
1495 atspi_accessible_get_text_iface (AtspiAccessible *obj)
1497 return (_atspi_accessible_is_a (obj, atspi_interface_text) ?
1498 g_object_ref (ATSPI_TEXT (obj)) : NULL);
1502 * atspi_accessible_get_value:
1503 * @obj: a pointer to the #AtspiAccessible instance to query.
1505 * Gets the #AtspiTable interface for an #AtspiAccessible.
1507 * Returns: (transfer full): a pointer to an #AtspiValue interface instance, or
1508 * NULL if @obj does not implement #AtspiValue.
1510 * Deprecated: 2.10: Use atspi_accessible_get_value_iface instead.
1511 * Rename to: atspi_accessible_get_value_iface
1514 atspi_accessible_get_value (AtspiAccessible *accessible)
1516 return (_atspi_accessible_is_a (accessible, atspi_interface_value) ?
1517 g_object_ref (ATSPI_VALUE (accessible)) : NULL);
1521 * atspi_accessible_get_value_iface:
1522 * @obj: a pointer to the #AtspiAccessible instance to query.
1524 * Gets the #AtspiTable interface for an #AtspiAccessible.
1526 * Returns: (transfer full): a pointer to an #AtspiValue interface instance, or
1527 * NULL if @obj does not implement #AtspiValue.
1530 atspi_accessible_get_value_iface (AtspiAccessible *accessible)
1532 return (_atspi_accessible_is_a (accessible, atspi_interface_value) ?
1533 g_object_ref (ATSPI_VALUE (accessible)) : NULL);
1537 append_const_val (GArray *array, const gchar *val)
1539 gchar *dup = g_strdup (val);
1542 g_array_append_val (array, dup);
1546 * atspi_accessible_get_interfaces:
1547 * @obj: The #AtspiAccessible to query.
1549 * A set of pointers to all interfaces supported by an #AtspiAccessible.
1551 * Returns: (element-type gchar*) (transfer full): A #GArray of strings
1552 * describing the interfaces supported by the object. Interfaces are
1553 * denoted in short-hand (i.e. "Component", "Text" etc.).
1556 atspi_accessible_get_interfaces (AtspiAccessible *obj)
1558 GArray *ret = g_array_new (TRUE, TRUE, sizeof (gchar *));
1560 g_return_val_if_fail (obj != NULL, NULL);
1562 append_const_val (ret, "Accessible");
1563 if (atspi_accessible_is_action (obj))
1564 append_const_val (ret, "Action");
1565 if (atspi_accessible_is_collection (obj))
1566 append_const_val (ret, "Collection");
1567 if (atspi_accessible_is_component (obj))
1568 append_const_val (ret, "Component");
1569 if (atspi_accessible_is_document (obj))
1570 append_const_val (ret, "Document");
1571 if (atspi_accessible_is_editable_text (obj))
1572 append_const_val (ret, "EditableText");
1573 if (atspi_accessible_is_hypertext (obj))
1574 append_const_val (ret, "Hypertext");
1575 if (atspi_accessible_is_hyperlink (obj))
1576 append_const_val (ret, "Hyperlink");
1577 if (atspi_accessible_is_image (obj))
1578 append_const_val (ret, "Image");
1579 if (atspi_accessible_is_selection (obj))
1580 append_const_val (ret, "Selection");
1581 if (atspi_accessible_is_table (obj))
1582 append_const_val (ret, "Table");
1583 if (atspi_accessible_is_table_cell (obj))
1584 append_const_val (ret, "TableCell");
1585 if (atspi_accessible_is_text (obj))
1586 append_const_val (ret, "Text");
1587 if (atspi_accessible_is_value (obj))
1588 append_const_val (ret, "Value");
1594 _atspi_accessible_new (AtspiApplication *app, const gchar *path)
1596 AtspiAccessible *accessible;
1598 accessible = g_object_new (ATSPI_TYPE_ACCESSIBLE, NULL);
1599 g_return_val_if_fail (accessible != NULL, NULL);
1601 accessible->parent.app = g_object_ref (app);
1602 accessible->parent.path = g_strdup (path);
1608 * atspi_accessible_set_cache_mask:
1609 * @accessible: The #AtspiAccessible to operate on. Must be the desktop or
1610 * the root of an application.
1611 * @mask: An #AtspiCache specifying a bit mask of the types of data to cache.
1613 * Sets the type of data to cache for accessibles.
1614 * If this is not set for an application or is reset to ATSPI_CACHE_UNDEFINED,
1615 * then the desktop's cache flag will be used.
1616 * If the desktop's cache flag is also undefined, then all possible data will
1618 * This function is intended to work around bugs in toolkits where the proper
1619 * events are not raised / to aid in testing for such bugs.
1622 atspi_accessible_set_cache_mask (AtspiAccessible *accessible, AtspiCache mask)
1624 g_return_if_fail (accessible != NULL);
1625 g_return_if_fail (accessible->parent.app != NULL);
1626 g_return_if_fail (accessible == accessible->parent.app->root);
1627 accessible->parent.app->cache = mask;
1628 enable_caching = TRUE;
1632 * atspi_accessible_clear_cache:
1633 * @accessible: The #AtspiAccessible whose cache to clear.
1635 * Clears the cached information for the given accessible and all of its
1639 atspi_accessible_clear_cache (AtspiAccessible *accessible)
1645 accessible->cached_properties = ATSPI_CACHE_NONE;
1646 for (l = accessible->children; l; l = l->next)
1647 atspi_accessible_clear_cache (l->data);
1652 * atspi_accessible_get_process_id:
1653 * @accessible: The #AtspiAccessible to query.
1654 * @error: a pointer to a %NULL #GError pointer
1656 * Returns the process id associated with the given accessible. Mainly
1657 * added for debugging; it is a shortcut to explicitly querying the
1658 * accessible's app->bus_name and then calling GetConnectionUnixProcessID.
1660 * Returns: The process ID or undetermined value if @error is set.
1663 atspi_accessible_get_process_id (AtspiAccessible *accessible, GError **error)
1665 DBusMessage *message, *reply;
1666 DBusConnection *bus = _atspi_bus ();
1667 dbus_uint32_t pid = -1;
1670 if (!accessible->parent.app || !accessible->parent.app->bus_name)
1672 g_set_error_literal(error, ATSPI_ERROR, ATSPI_ERROR_IPC, "Process is defunct");
1676 message = dbus_message_new_method_call ("org.freedesktop.DBus",
1677 "/org/freedesktop/DBus",
1678 "org.freedesktop.DBus",
1679 "GetConnectionUnixProcessID");
1680 dbus_message_append_args (message, DBUS_TYPE_STRING,
1681 &accessible->parent.app->bus_name,
1683 dbus_error_init (&d_error);
1684 reply = dbus_connection_send_with_reply_and_block (bus, message, -1, &d_error);
1685 dbus_message_unref (message);
1688 if (!strcmp (dbus_message_get_signature (reply), "u"))
1689 dbus_message_get_args (reply, NULL, DBUS_TYPE_UINT32, &pid, DBUS_TYPE_INVALID);
1690 dbus_message_unref (reply);
1692 if (dbus_error_is_set (&d_error))
1694 g_set_error_literal(error, ATSPI_ERROR, ATSPI_ERROR_IPC, "Process is defunct");
1695 dbus_error_free (&d_error);
1701 _atspi_accessible_get_cache_mask (AtspiAccessible *accessible)
1705 if (!accessible->parent.app)
1706 return ATSPI_CACHE_NONE;
1708 mask = accessible->parent.app->cache;
1709 if (mask == ATSPI_CACHE_UNDEFINED &&
1710 accessible->parent.app->root &&
1711 accessible->parent.app->root->accessible_parent)
1713 AtspiAccessible *desktop = atspi_get_desktop (0);
1714 mask = desktop->parent.app->cache;
1715 g_object_unref (desktop);
1718 if (mask == ATSPI_CACHE_UNDEFINED)
1719 mask = ATSPI_CACHE_DEFAULT;
1725 _atspi_accessible_test_cache (AtspiAccessible *accessible, AtspiCache flag)
1727 AtspiCache mask = _atspi_accessible_get_cache_mask (accessible);
1728 AtspiCache result = accessible->cached_properties & mask & flag;
1729 if (accessible->states && atspi_state_set_contains (accessible->states, ATSPI_STATE_TRANSIENT))
1731 return (result != 0 && (atspi_main_loop || enable_caching ||
1732 flag == ATSPI_CACHE_INTERFACES) &&
1737 _atspi_accessible_add_cache (AtspiAccessible *accessible, AtspiCache flag)
1739 AtspiCache mask = _atspi_accessible_get_cache_mask (accessible);
1741 accessible->cached_properties |= flag & mask;
1745 * atspi_accessible_get_locale:
1746 * @accessible: an #AtspiAccessible
1748 * Gets a UTF-8 string indicating the POSIX-style LC_MESSAGES locale
1753 * Returns: a UTF-8 string indicating the POSIX-style LC_MESSAGES
1754 * locale of @accessible.
1757 atspi_accessible_get_object_locale (AtspiAccessible *accessible, GError **error)
1761 g_return_val_if_fail (accessible != NULL, NULL);
1763 locale = g_object_get_qdata (G_OBJECT (accessible), quark_locale);
1766 if (!_atspi_dbus_get_property (accessible, atspi_interface_accessible,
1767 "Locale", error, "s", &locale))
1770 g_object_set_qdata_full (G_OBJECT (accessible), quark_locale, locale,
1777 free_value (gpointer data)
1779 GValue *value = data;
1781 g_value_unset (value);
1786 _atspi_accessible_ref_cache (AtspiAccessible *accessible)
1788 AtspiAccessiblePrivate *priv = accessible->priv;
1790 priv->cache_ref_count++;
1792 return g_hash_table_ref (priv->cache);
1793 priv->cache = g_hash_table_new_full (g_str_hash, g_str_equal, g_free,
1799 _atspi_accessible_unref_cache (AtspiAccessible *accessible)
1801 AtspiAccessiblePrivate *priv = accessible->priv;
1805 g_hash_table_unref (priv->cache);
1806 if (--priv->cache_ref_count == 0)