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_text_interface_init (AtspiText *text)
83 atspi_value_interface_init (AtspiValue *value)
87 G_DEFINE_TYPE_WITH_CODE (AtspiAccessible, atspi_accessible, ATSPI_TYPE_OBJECT,
88 G_ADD_PRIVATE (AtspiAccessible)
89 G_IMPLEMENT_INTERFACE (ATSPI_TYPE_ACTION, atspi_action_interface_init)
90 G_IMPLEMENT_INTERFACE (ATSPI_TYPE_COLLECTION, atspi_collection_interface_init)
91 G_IMPLEMENT_INTERFACE (ATSPI_TYPE_COMPONENT, atspi_component_interface_init)
92 G_IMPLEMENT_INTERFACE (ATSPI_TYPE_DOCUMENT, atspi_document_interface_init)
93 G_IMPLEMENT_INTERFACE (ATSPI_TYPE_EDITABLE_TEXT, atspi_editable_text_interface_init)
94 G_IMPLEMENT_INTERFACE (ATSPI_TYPE_HYPERTEXT, atspi_hypertext_interface_init)
95 G_IMPLEMENT_INTERFACE (ATSPI_TYPE_IMAGE, atspi_image_interface_init)
96 G_IMPLEMENT_INTERFACE (ATSPI_TYPE_SELECTION, atspi_selection_interface_init)
97 G_IMPLEMENT_INTERFACE (ATSPI_TYPE_TABLE, atspi_table_interface_init)
98 G_IMPLEMENT_INTERFACE (ATSPI_TYPE_TEXT, atspi_text_interface_init)
99 G_IMPLEMENT_INTERFACE (ATSPI_TYPE_VALUE, atspi_value_interface_init))
101 #ifdef DEBUG_REF_COUNTS
102 static gint accessible_count = 0;
106 atspi_accessible_init (AtspiAccessible *accessible)
108 #ifdef DEBUG_REF_COUNTS
110 g_hash_table_insert (_atspi_get_live_refs (), accessible, NULL);
111 g_print("at-spi: init: %d objects\n", accessible_count);
114 accessible->priv = atspi_accessible_get_instance_private (accessible);
118 atspi_accessible_dispose (GObject *object)
120 AtspiAccessible *accessible = ATSPI_ACCESSIBLE (object);
122 AtspiAccessible *parent;
126 /* TODO: Only fire if object not already marked defunct */
127 memset (&e, 0, sizeof (e));
128 e.type = "object:state-changed:defunct";
129 e.source = accessible;
132 _atspi_send_event (&e);
134 if (accessible->states)
136 g_object_unref (accessible->states);
137 accessible->states = NULL;
140 parent = accessible->accessible_parent;
141 if (parent && parent->children)
143 GList*ls = g_list_find (parent->children, accessible);
146 gboolean replace = (ls == parent->children);
147 ls = g_list_remove (ls, accessible);
149 parent->children = ls;
150 g_object_unref (object);
156 g_object_unref (parent);
157 accessible->accessible_parent = NULL;
160 children = accessible->children;
161 accessible->children = NULL;
162 for (l = children; l; l = l->next)
164 AtspiAccessible *child = l->data;
165 if (child && child->accessible_parent == accessible)
167 g_object_unref (accessible);
168 child->accessible_parent = NULL;
170 g_object_unref (child);
172 g_list_free (children);
174 G_OBJECT_CLASS (atspi_accessible_parent_class) ->dispose (object);
178 atspi_accessible_finalize (GObject *object)
180 AtspiAccessible *accessible = ATSPI_ACCESSIBLE (object);
182 g_free (accessible->description);
183 g_free (accessible->name);
184 if (accessible->attributes)
185 g_hash_table_unref (accessible->attributes);
187 #ifdef DEBUG_REF_COUNTS
189 g_hash_table_remove (_atspi_get_live_refs (), accessible);
190 g_print ("at-spi: finalize: %d objects\n", accessible_count);
193 G_OBJECT_CLASS (atspi_accessible_parent_class)
198 atspi_accessible_class_init (AtspiAccessibleClass *klass)
200 GObjectClass *object_class = G_OBJECT_CLASS (klass);
202 object_class->dispose = atspi_accessible_dispose;
203 object_class->finalize = atspi_accessible_finalize;
205 quark_locale = g_quark_from_string ("accessible-locale");
209 * atspi_accessible_get_name:
210 * @obj: a pointer to the #AtspiAccessible object on which to operate.
212 * Gets the name of an #AtspiAccessible object.
214 * Returns: a UTF-8 string indicating the name of the #AtspiAccessible object
215 * or NULL on exception.
218 atspi_accessible_get_name (AtspiAccessible *obj, GError **error)
220 g_return_val_if_fail (obj != NULL, g_strdup (""));
221 if (!_atspi_accessible_test_cache (obj, ATSPI_CACHE_NAME))
223 if (!_atspi_dbus_get_property (obj, atspi_interface_accessible, "Name", error,
225 return g_strdup ("");
226 _atspi_accessible_add_cache (obj, ATSPI_CACHE_NAME);
228 return g_strdup (obj->name);
232 * atspi_accessible_get_description:
233 * @obj: a pointer to the #AtspiAccessible object on which to operate.
235 * Gets the description of an #AtspiAccessible object.
237 * Returns: a UTF-8 string describing the #AtspiAccessible object
238 * or NULL on exception.
241 atspi_accessible_get_description (AtspiAccessible *obj, GError **error)
243 g_return_val_if_fail (obj != NULL, g_strdup (""));
245 if (!_atspi_accessible_test_cache (obj, ATSPI_CACHE_DESCRIPTION))
247 if (!_atspi_dbus_get_property (obj, atspi_interface_accessible,
248 "Description", error, "s",
250 return g_strdup ("");
251 _atspi_accessible_add_cache (obj, ATSPI_CACHE_DESCRIPTION);
253 return g_strdup (obj->description);
256 const char *str_parent = "Parent";
259 * atspi_accessible_get_parent:
260 * @obj: a pointer to the #AtspiAccessible object to query.
262 * Gets an #AtspiAccessible object's parent container.
264 * Returns: (transfer full): a pointer to the #AtspiAccessible object which
265 * contains the given #AtspiAccessible instance, or NULL if the @obj
266 * has no parent container.
270 atspi_accessible_get_parent (AtspiAccessible *obj, GError **error)
272 g_return_val_if_fail (obj != NULL, NULL);
274 if (obj->parent.app &&
275 !_atspi_accessible_test_cache (obj, ATSPI_CACHE_PARENT))
277 DBusMessage *message, *reply;
278 DBusMessageIter iter, iter_variant;
279 message = dbus_message_new_method_call (obj->parent.app->bus_name,
281 DBUS_INTERFACE_PROPERTIES, "Get");
284 dbus_message_append_args (message, DBUS_TYPE_STRING, &atspi_interface_accessible,
285 DBUS_TYPE_STRING, &str_parent,
287 reply = _atspi_dbus_send_with_reply_and_block (message, error);
290 if (strcmp (dbus_message_get_signature (reply), "v") != 0)
292 dbus_message_unref (reply);
295 dbus_message_iter_init (reply, &iter);
296 dbus_message_iter_recurse (&iter, &iter_variant);
297 obj->accessible_parent = _atspi_dbus_return_accessible_from_iter (&iter_variant);
298 dbus_message_unref (reply);
299 _atspi_accessible_add_cache (obj, ATSPI_CACHE_PARENT);
301 if (!obj->accessible_parent)
303 return g_object_ref (obj->accessible_parent);
307 * atspi_accessible_get_child_count:
308 * @obj: a pointer to the #AtspiAccessible object on which to operate.
310 * Gets the number of children contained by an #AtspiAccessible object.
312 * Returns: a #long indicating the number of #AtspiAccessible children
313 * contained by an #AtspiAccessible object or -1 on exception.
317 atspi_accessible_get_child_count (AtspiAccessible *obj, GError **error)
319 g_return_val_if_fail (obj != NULL, -1);
321 if (!_atspi_accessible_test_cache (obj, ATSPI_CACHE_CHILDREN))
324 if (!_atspi_dbus_get_property (obj, atspi_interface_accessible,
325 "ChildCount", error, "i", &ret))
330 return g_list_length (obj->children);
334 * atspi_accessible_get_child_at_index:
335 * @obj: a pointer to the #AtspiAccessible object on which to operate.
336 * @child_index: a #long indicating which child is specified.
338 * Gets the #AtspiAccessible child of an #AtspiAccessible object at a given index.
340 * Returns: (transfer full): a pointer to the #AtspiAccessible child object at
341 * index @child_index or NULL on exception.
344 atspi_accessible_get_child_at_index (AtspiAccessible *obj,
348 AtspiAccessible *child;
350 g_return_val_if_fail (obj != NULL, NULL);
352 if (!_atspi_accessible_test_cache (obj, ATSPI_CACHE_CHILDREN))
355 reply = _atspi_dbus_call_partial (obj, atspi_interface_accessible,
356 "GetChildAtIndex", error, "i",
358 return _atspi_dbus_return_accessible_from_message (reply);
361 child = g_list_nth_data (obj->children, child_index);
364 return g_object_ref (child);
368 * atspi_accessible_get_index_in_parent:
369 * @obj: a pointer to the #AtspiAccessible object on which to operate.
371 * Gets the index of an #AtspiAccessible object within its parent's
372 * #AtspiAccessible children list.
374 * Returns: a #glong indicating the index of the #AtspiAccessible object
376 * or -1 if @obj has no containing parent or on exception.
379 atspi_accessible_get_index_in_parent (AtspiAccessible *obj, GError **error)
384 g_return_val_if_fail (obj != NULL, -1);
385 if (_atspi_accessible_test_cache (obj, ATSPI_CACHE_PARENT) &&
386 !obj->accessible_parent)
388 if (!obj->accessible_parent ||
389 !_atspi_accessible_test_cache (obj->accessible_parent,
390 ATSPI_CACHE_CHILDREN))
392 dbus_int32_t ret = -1;
393 _atspi_dbus_call (obj, atspi_interface_accessible,
394 "GetIndexInParent", NULL, "=>i", &ret);
398 l = obj->accessible_parent->children;
401 if (l->data == obj) return i;
412 } Accessibility_Relation;
415 * atspi_accessible_get_relation_set:
416 * @obj: a pointer to the #AtspiAccessible object on which to operate.
418 * Gets the set of #AtspiRelation objects which describes this #AtspiAccessible object's
419 * relationships with other #AtspiAccessible objects.
421 * Returns: (element-type AtspiAccessible*) (transfer full): a #GArray of
422 * #AtspiRelation pointers or NULL on exception.
425 atspi_accessible_get_relation_set (AtspiAccessible *obj, GError **error)
428 DBusMessageIter iter, iter_array;
431 g_return_val_if_fail (obj != NULL, NULL);
433 reply = _atspi_dbus_call_partial (obj, atspi_interface_accessible, "GetRelationSet", error, "");
436 _ATSPI_DBUS_CHECK_SIG (reply, "a(ua(so))", error, NULL);
438 ret = g_array_new (TRUE, TRUE, sizeof (AtspiRelation *));
439 dbus_message_iter_init (reply, &iter);
440 dbus_message_iter_recurse (&iter, &iter_array);
441 while (dbus_message_iter_get_arg_type (&iter_array) != DBUS_TYPE_INVALID)
443 AtspiRelation *relation;
444 relation = _atspi_relation_new_from_iter (&iter_array);
445 ret = g_array_append_val (ret, relation);
446 dbus_message_iter_next (&iter_array);
448 dbus_message_unref (reply);
453 * atspi_accessible_get_role:
454 * @obj: a pointer to the #AtspiAccessible object on which to operate.
456 * Gets the UI role played by an #AtspiAccessible object.
457 * This role's name can be obtained via atspi_accessible_get_role_name ().
459 * Returns: the #AtspiRole of an #AtspiAccessible object.
463 atspi_accessible_get_role (AtspiAccessible *obj, GError **error)
465 g_return_val_if_fail (obj != NULL, ATSPI_ROLE_INVALID);
467 if (!_atspi_accessible_test_cache (obj, ATSPI_CACHE_ROLE))
470 /* TODO: Make this a property */
471 if (_atspi_dbus_call (obj, atspi_interface_accessible, "GetRole", error, "=>u", &role))
474 _atspi_accessible_add_cache (obj, ATSPI_CACHE_ROLE);
481 * atspi_accessible_get_role_name:
482 * @obj: a pointer to the #AtspiAccessible object on which to operate.
484 * Gets a UTF-8 string corresponding to the name of the role played by an object.
485 * This method will return useful values for roles that fall outside the
486 * enumeration used in atspi_accessible_get_role ().
488 * Returns: a UTF-8 string specifying the type of UI role played by an
489 * #AtspiAccessible object.
493 atspi_accessible_get_role_name (AtspiAccessible *obj, GError **error)
495 gchar *retval = NULL;
498 g_return_val_if_fail (obj != NULL, NULL);
500 role = atspi_accessible_get_role (obj, error);
501 if (role >= 0 && role < ATSPI_ROLE_COUNT && role != ATSPI_ROLE_EXTENDED)
502 return atspi_role_get_name (role);
504 _atspi_dbus_call (obj, atspi_interface_accessible, "GetRoleName", error, "=>s", &retval);
507 retval = g_strdup ("");
513 * atspi_accessible_get_localized_role_name:
514 * @obj: a pointer to the #AtspiAccessible object on which to operate.
516 * Gets a UTF-8 string corresponding to the name of the role played by an
517 * object, translated to the current locale.
518 * This method will return useful values for roles that fall outside the
519 * enumeration used in atspi_accessible_getRole ().
521 * Returns: a localized, UTF-8 string specifying the type of UI role played
522 * by an #AtspiAccessible object.
526 atspi_accessible_get_localized_role_name (AtspiAccessible *obj, GError **error)
530 g_return_val_if_fail (obj != NULL, NULL);
532 _atspi_dbus_call (obj, atspi_interface_accessible, "GetLocalizedRoleName", error, "=>s", &retval);
535 return g_strdup ("");
540 static AtspiStateSet *
543 AtspiStateSet *set = atspi_state_set_new (NULL);
544 atspi_state_set_add (set, ATSPI_STATE_DEFUNCT);
549 * atspi_accessible_get_state_set:
550 * @obj: a pointer to the #AtspiAccessible object on which to operate.
552 * Gets the states currently held by an object.
554 * Returns: (transfer full): a pointer to an #AtspiStateSet representing an
555 * object's current state set.
558 atspi_accessible_get_state_set (AtspiAccessible *obj)
560 /* TODO: Should take a GError **, but would be an API break */
561 if (!obj->parent.app || !obj->parent.app->bus)
562 return defunct_set ();
564 if (!_atspi_accessible_test_cache (obj, ATSPI_CACHE_STATES))
567 DBusMessageIter iter;
568 reply = _atspi_dbus_call_partial (obj, atspi_interface_accessible,
569 "GetState", NULL, "");
570 _ATSPI_DBUS_CHECK_SIG (reply, "au", NULL, defunct_set ());
571 dbus_message_iter_init (reply, &iter);
572 _atspi_dbus_set_state (obj, &iter);
573 dbus_message_unref (reply);
574 _atspi_accessible_add_cache (obj, ATSPI_CACHE_STATES);
577 return g_object_ref (obj->states);
581 * atspi_accessible_get_attributes:
582 * @obj: The #AtspiAccessible being queried.
584 * Gets the #AttributeSet representing any assigned
585 * name-value pair attributes or annotations for this object.
586 * For typographic, textual, or textually-semantic attributes, see
587 * atspi_text_get_attributes instead.
589 * Returns: (element-type gchar* gchar*) (transfer full): The name-value-pair
590 * attributes assigned to this object.
593 atspi_accessible_get_attributes (AtspiAccessible *obj, GError **error)
595 DBusMessage *message;
597 g_return_val_if_fail (obj != NULL, NULL);
599 if (obj->priv->cache)
601 GValue *val = g_hash_table_lookup (obj->priv->cache, "Attributes");
603 return g_value_dup_boxed (val);
606 if (!_atspi_accessible_test_cache (obj, ATSPI_CACHE_ATTRIBUTES))
608 message = _atspi_dbus_call_partial (obj, atspi_interface_accessible,
609 "GetAttributes", error, "");
610 obj->attributes = _atspi_dbus_return_hash_from_message (message);
611 _atspi_accessible_add_cache (obj, ATSPI_CACHE_ATTRIBUTES);
614 if (!obj->attributes)
616 return g_hash_table_ref (obj->attributes);
620 add_to_attribute_array (gpointer key, gpointer value, gpointer data)
622 GArray **array = (GArray **)data;
623 gchar *str = g_strconcat (key, ":", value, NULL);
624 *array = g_array_append_val (*array, str);
628 * atspi_accessible_get_attributes_as_array:
629 * @obj: The #AtspiAccessible being queried.
631 * Gets a #GArray representing any assigned
632 * name-value pair attributes or annotations for this object.
633 * For typographic, textual, or textually-semantic attributes, see
634 * atspi_text_get_attributes_as_array instead.
636 * Returns: (element-type gchar*) (transfer full): The name-value-pair
637 * attributes assigned to this object.
640 atspi_accessible_get_attributes_as_array (AtspiAccessible *obj, GError **error)
642 DBusMessage *message;
644 g_return_val_if_fail (obj != NULL, NULL);
646 if (obj->priv->cache)
648 GValue *val = g_hash_table_lookup (obj->priv->cache, "Attributes");
651 GArray *array = g_array_new (TRUE, TRUE, sizeof (gchar *));
652 GHashTable *attributes = g_value_get_boxed (val);
653 g_hash_table_foreach (attributes, add_to_attribute_array, &array);
658 message = _atspi_dbus_call_partial (obj, atspi_interface_accessible, "GetAttributes", error, "");
659 return _atspi_dbus_return_attribute_array_from_message (message);
663 * atspi_accessible_get_application:
664 * @obj: The #AtspiAccessible being queried.
666 * Gets the containing #AtspiApplication for an object.
668 * Returns: (transfer full): the containing #AtspiApplication instance for
672 atspi_accessible_get_application (AtspiAccessible *obj, GError **error)
674 AtspiAccessible *parent;
679 parent = atspi_accessible_get_parent (obj, NULL);
680 if (!parent && obj->parent.app &&
681 atspi_accessible_get_role (obj, NULL) != ATSPI_ROLE_APPLICATION)
683 AtspiAccessible *root = g_object_ref (obj->parent.app->root);
686 g_object_unref (obj);
687 if (atspi_accessible_get_role (root, NULL) == ATSPI_ROLE_DESKTOP_FRAME)
689 g_object_unref (root);
695 if (!parent || parent == obj ||
696 atspi_accessible_get_role (parent, NULL) == ATSPI_ROLE_DESKTOP_FRAME)
699 g_object_unref (parent);
702 g_object_unref (obj);
707 /* Application-specific methods */
710 * atspi_accessible_get_toolkit_name:
711 * @obj: a pointer to the #AtspiAccessible object on which to operate.
713 * Gets the toolkit name for an #AtspiAccessible object.
714 * Only works on application root objects.
716 * Returns: a UTF-8 string indicating the toolkit name for the #AtspiAccessible object or NULL on exception.
719 atspi_accessible_get_toolkit_name (AtspiAccessible *obj, GError **error)
721 g_return_val_if_fail (obj != NULL, NULL);
723 if (!obj->parent.app)
726 if (!obj->parent.app->toolkit_name)
727 _atspi_dbus_get_property (obj, atspi_interface_application, "ToolkitName",
728 error, "s", &obj->parent.app->toolkit_name);
730 return g_strdup (obj->parent.app->toolkit_name);
734 * atspi_accessible_get_toolkit_version:
735 * @obj: a pointer to the #AtspiAccessible object on which to operate.
737 * Gets the toolkit version for an #AtspiAccessible object.
738 * Only works on application root objects.
740 * Returns: a UTF-8 string indicating the toolkit version for the #AtspiAccessible object or NULL on exception.
743 atspi_accessible_get_toolkit_version (AtspiAccessible *obj, GError **error)
745 g_return_val_if_fail (obj != NULL, NULL);
747 if (!obj->parent.app)
750 if (!obj->parent.app->toolkit_version)
751 _atspi_dbus_get_property (obj, atspi_interface_application, "Version",
752 error, "s", &obj->parent.app->toolkit_version);
754 return g_strdup (obj->parent.app->toolkit_version);
758 * atspi_accessible_get_atspi_version:
759 * @obj: a pointer to the #AtspiAccessible object on which to operate.
761 * Gets the AT-SPI IPC specification version supported by the application
762 * pointed to by the #AtspiAccessible object.
763 * Only works on application root objects.
765 * Returns: a UTF-8 string indicating the AT-SPI version for the #AtspiAccessible object or NULL on exception.
768 atspi_accessible_get_atspi_version (AtspiAccessible *obj, GError **error)
770 g_return_val_if_fail (obj != NULL, NULL);
772 if (!obj->parent.app)
775 if (!obj->parent.app->atspi_version)
776 _atspi_dbus_get_property (obj, atspi_interface_application, "AtspiVersion",
777 error, "s", &obj->parent.app->atspi_version);
779 return g_strdup (obj->parent.app->atspi_version);
783 * atspi_accessible_get_id:
784 * @obj: a pointer to the #AtspiAccessible object on which to operate.
786 * Gets the application id for a #AtspiAccessible object.
787 * Only works on application root objects.
789 * Returns: a positive #gint indicating the id for the #AtspiAccessible object
790 * or -1 on exception.
793 atspi_accessible_get_id (AtspiAccessible *obj, GError **error)
797 g_return_val_if_fail (obj != NULL, -1);
799 if (!_atspi_dbus_get_property (obj, atspi_interface_application, "Id", error, "i", &ret))
805 /* Interface query methods */
808 _atspi_accessible_is_a (AtspiAccessible *accessible,
809 const char *interface_name)
813 if (accessible == NULL)
818 if (!_atspi_accessible_test_cache (accessible, ATSPI_CACHE_INTERFACES))
821 DBusMessageIter iter;
822 reply = _atspi_dbus_call_partial (accessible, atspi_interface_accessible,
823 "GetInterfaces", NULL, "");
824 _ATSPI_DBUS_CHECK_SIG (reply, "as", NULL, FALSE);
825 dbus_message_iter_init (reply, &iter);
826 _atspi_dbus_set_interfaces (accessible, &iter);
827 dbus_message_unref (reply);
828 _atspi_accessible_add_cache (accessible, ATSPI_CACHE_INTERFACES);
831 n = _atspi_get_iface_num (interface_name);
832 if (n == -1) return FALSE;
833 return (gboolean) ((accessible->interfaces & (1 << n))? TRUE: FALSE);
837 * atspi_accessible_is_action:
838 * @obj: a pointer to the #AtspiAccessible instance to query.
840 * Query whether the specified #AtspiAccessible implements the
841 * #AtspiAction interface.
843 * Returns: #TRUE if @obj implements the #AtspiAction interface,
847 atspi_accessible_is_action (AtspiAccessible *obj)
849 return _atspi_accessible_is_a (obj,
850 atspi_interface_action);
854 * atspi_accessible_is_application:
855 * @obj: a pointer to the #AtspiAccessible instance to query.
857 * Query whether the specified #AtspiAccessible implements the
858 * #AtspiApplication interface.
860 * Returns: #TRUE if @obj implements the #AtspiApplication interface,
864 atspi_accessible_is_application (AtspiAccessible *obj)
866 return _atspi_accessible_is_a (obj,
867 atspi_interface_application);
871 * atspi_accessible_is_collection:
872 * @obj: a pointer to the #AtspiAccessible instance to query.
874 * Query whether the specified #AtspiAccessible implements the
875 * #AtspiCollection interface.
877 * Returns: #TRUE if @obj implements the #AtspiCollection interface,
881 atspi_accessible_is_collection (AtspiAccessible *obj)
883 return _atspi_accessible_is_a (obj,
884 atspi_interface_collection);
888 * atspi_accessible_is_component:
889 * @obj: a pointer to the #AtspiAccessible instance to query.
891 * Query whether the specified #AtspiAccessible implements #AtspiComponent.
893 * Returns: #TRUE if @obj implements the #AtspiComponent interface,
897 atspi_accessible_is_component (AtspiAccessible *obj)
899 return _atspi_accessible_is_a (obj,
900 atspi_interface_component);
904 * atspi_accessible_is_document:
905 * @obj: a pointer to the #AtspiAccessible instance to query.
907 * Query whether the specified #AtspiAccessible implements the
908 * #AtspiDocument interface.
910 * Returns: #TRUE if @obj implements the #AtspiDocument interface,
914 atspi_accessible_is_document (AtspiAccessible *obj)
916 return _atspi_accessible_is_a (obj,
917 atspi_interface_document);
921 * atspi_accessible_is_editable_text:
922 * @obj: a pointer to the #AtspiAccessible instance to query.
924 * Query whether the specified #AtspiAccessible implements the
925 * #AtspiEditableText interface.
927 * Returns: #TRUE if @obj implements the #AtspiEditableText interface,
931 atspi_accessible_is_editable_text (AtspiAccessible *obj)
933 return _atspi_accessible_is_a (obj,
934 atspi_interface_editable_text);
938 * atspi_accessible_is_hypertext:
939 * @obj: a pointer to the #AtspiAccessible instance to query.
941 * Query whether the specified #AtspiAccessible implements the
942 * #AtspiHypertext interface.
944 * Returns: #TRUE if @obj implements the #AtspiHypertext interface,
948 atspi_accessible_is_hypertext (AtspiAccessible *obj)
950 return _atspi_accessible_is_a (obj,
951 atspi_interface_hypertext);
955 * atspi_accessible_is_hyperlink:
956 * @obj: a pointer to the #AtspiAccessible instance to query.
958 * Query whether the specified #AtspiAccessible implements the
959 * #AtspiHyperlink interface.
961 * Returns: #TRUE if @obj implements the #AtspiHypertext interface,
965 atspi_accessible_is_hyperlink (AtspiAccessible *obj)
967 return _atspi_accessible_is_a (obj,
968 atspi_interface_hyperlink);
972 * atspi_accessible_is_image:
973 * @obj: a pointer to the #AtspiAccessible instance to query.
975 * Query whether the specified #AtspiAccessible implements the
976 * #AtspiImage interface.
978 * Returns: #TRUE if @obj implements the #AtspiImage interface,
982 atspi_accessible_is_image (AtspiAccessible *obj)
984 return _atspi_accessible_is_a (obj,
985 atspi_interface_image);
989 * atspi_accessible_is_selection:
990 * @obj: a pointer to the #AtspiAccessible instance to query.
992 * Query whether the specified #AtspiAccessible implements the
993 * #AtspiSelection interface.
995 * Returns: #TRUE if @obj implements the #AtspiSelection interface,
999 atspi_accessible_is_selection (AtspiAccessible *obj)
1001 return _atspi_accessible_is_a (obj,
1002 atspi_interface_selection);
1006 * atspi_accessible_is_table:
1007 * @obj: a pointer to the #AtspiAccessible instance to query.
1009 * Query whether the specified #AtspiAccessible implements the
1010 * #AtspiTable interface.
1012 * Returns: #TRUE if @obj implements the #AtspiTable interface,
1016 atspi_accessible_is_table (AtspiAccessible *obj)
1018 return _atspi_accessible_is_a (obj,
1019 atspi_interface_table);
1023 * atspi_accessible_is_streamable_content:
1024 * @obj: a pointer to the #AtspiAccessible instance to query.
1026 * Query whether the specified #AtspiAccessible implements the
1027 * #AtspiStreamableContent interface.
1029 * Returns: #TRUE if @obj implements the #AtspiStreamableContent interface,
1033 atspi_accessible_is_streamable_content (AtspiAccessible *obj)
1036 return _atspi_accessible_is_a (obj,
1037 atspi_interface_streamable_content);
1039 g_warning ("Streamable content not implemented");
1045 * atspi_accessible_is_text:
1046 * @obj: a pointer to the #AtspiAccessible instance to query.
1048 * Query whether the specified #AtspiAccessible implements the
1049 * #AtspiText interface.
1051 * Returns: #TRUE if @obj implements the #AtspiText interface,
1055 atspi_accessible_is_text (AtspiAccessible *obj)
1057 return _atspi_accessible_is_a (obj,
1058 atspi_interface_text);
1062 * atspi_accessible_is_value:
1063 * @obj: a pointer to the #AtspiAccessible instance to query.
1065 * Query whether the specified #AtspiAccessible implements the
1066 * #AtspiValue interface.
1068 * Returns: #TRUE if @obj implements the #AtspiValue interface,
1072 atspi_accessible_is_value (AtspiAccessible *obj)
1074 return _atspi_accessible_is_a (obj,
1075 atspi_interface_value);
1079 * atspi_accessible_get_action:
1080 * @obj: a pointer to the #AtspiAccessible instance to query.
1082 * Gets the #AtspiAction interface for an #AtspiAccessible.
1084 * Returns: (transfer full): a pointer to an #AtspiAction interface
1085 * instance, or NULL if @obj does not implement #AtspiAction.
1087 * Deprecated: 2.10: Use atspi_accessible_get_action_iface instead.
1088 * Rename to: atspi_accessible_get_action_iface
1091 atspi_accessible_get_action (AtspiAccessible *accessible)
1093 return (_atspi_accessible_is_a (accessible, atspi_interface_action) ?
1094 g_object_ref (ATSPI_ACTION (accessible)) : NULL);
1098 * atspi_accessible_get_action_iface:
1099 * @obj: a pointer to the #AtspiAccessible instance to query.
1101 * Gets the #AtspiAction interface for an #AtspiAccessible.
1103 * Returns: (transfer full): a pointer to an #AtspiAction interface
1104 * instance, or NULL if @obj does not implement #AtspiAction.
1107 atspi_accessible_get_action_iface (AtspiAccessible *accessible)
1109 return (_atspi_accessible_is_a (accessible, atspi_interface_action) ?
1110 g_object_ref (ATSPI_ACTION (accessible)) : NULL);
1114 * atspi_accessible_get_collection:
1115 * @obj: a pointer to the #AtspiAccessible instance to query.
1117 * Gets the #AtspiCollection interface for an #AtspiAccessible.
1119 * Returns: (transfer full): a pointer to an #AtspiCollection interface
1120 * instance, or NULL if @obj does not implement #AtspiCollection.
1122 * Deprecated: 2.10: Use atspi_accessible_get_collection_iface instead.
1123 * Rename to: atspi_accessible_get_collection_iface
1126 atspi_accessible_get_collection (AtspiAccessible *accessible)
1128 return (_atspi_accessible_is_a (accessible, atspi_interface_collection) ?
1129 g_object_ref (ATSPI_COLLECTION (accessible)) : NULL);
1133 * atspi_accessible_get_collection_iface:
1134 * @obj: a pointer to the #AtspiAccessible instance to query.
1136 * Gets the #AtspiCollection interface for an #AtspiAccessible.
1138 * Returns: (transfer full): a pointer to an #AtspiCollection interface
1139 * instance, or NULL if @obj does not implement #AtspiCollection.
1142 atspi_accessible_get_collection_iface (AtspiAccessible *accessible)
1144 return (_atspi_accessible_is_a (accessible, atspi_interface_collection) ?
1145 g_object_ref (ATSPI_COLLECTION (accessible)) : NULL);
1149 * atspi_accessible_get_component:
1150 * @obj: a pointer to the #AtspiAccessible instance to query.
1152 * Gets the #AtspiComponent interface for an #AtspiAccessible.
1154 * Returns: (transfer full): a pointer to an #AtspiComponent interface
1155 * instance, or NULL if @obj does not implement #AtspiComponent.
1157 * Deprecated: 2.10: Use atspi_accessible_get_component_iface instead.
1158 * Rename to: atspi_accessible_get_component_iface
1161 atspi_accessible_get_component (AtspiAccessible *obj)
1163 return (_atspi_accessible_is_a (obj, atspi_interface_component) ?
1164 g_object_ref (ATSPI_COMPONENT (obj)) : NULL);
1168 * atspi_accessible_get_component_iface:
1169 * @obj: a pointer to the #AtspiAccessible instance to query.
1171 * Gets the #AtspiComponent interface for an #AtspiAccessible.
1173 * Returns: (transfer full): a pointer to an #AtspiComponent interface
1174 * instance, or NULL if @obj does not implement #AtspiComponent.
1177 atspi_accessible_get_component_iface (AtspiAccessible *obj)
1179 return (_atspi_accessible_is_a (obj, atspi_interface_component) ?
1180 g_object_ref (ATSPI_COMPONENT (obj)) : NULL);
1184 * atspi_accessible_get_document:
1185 * @obj: a pointer to the #AtspiAccessible instance to query.
1187 * Gets the #AtspiDocument interface for an #AtspiAccessible.
1189 * Returns: (transfer full): a pointer to an #AtspiDocument interface
1190 * instance, or NULL if @obj does not implement #AtspiDocument.
1192 * Deprecated: 2.10: Use atspi_accessible_get_document_iface instead.
1193 * Rename to: atspi_accessible_get_document_iface
1196 atspi_accessible_get_document (AtspiAccessible *accessible)
1198 return (_atspi_accessible_is_a (accessible, atspi_interface_document) ?
1199 g_object_ref (ATSPI_DOCUMENT (accessible)) : NULL);
1203 * atspi_accessible_get_document_iface:
1204 * @obj: a pointer to the #AtspiAccessible instance to query.
1206 * Gets the #AtspiDocument interface for an #AtspiAccessible.
1208 * Returns: (transfer full): a pointer to an #AtspiDocument interface
1209 * instance, or NULL if @obj does not implement #AtspiDocument.
1212 atspi_accessible_get_document_iface (AtspiAccessible *accessible)
1214 return (_atspi_accessible_is_a (accessible, atspi_interface_document) ?
1215 g_object_ref (ATSPI_DOCUMENT (accessible)) : NULL);
1219 * atspi_accessible_get_editable_text:
1220 * @obj: a pointer to the #AtspiAccessible instance to query.
1222 * Gets the #AtspiEditableText interface for an #AtspiAccessible.
1224 * Returns: (transfer full): a pointer to an #AtspiEditableText interface
1225 * instance, or NULL if @obj does not implement #AtspiEditableText.
1227 * Deprecated: 2.10: Use atspi_accessible_get_editable_text_iface instead.
1228 * Rename to: atspi_accessible_get_editable_text_iface
1231 atspi_accessible_get_editable_text (AtspiAccessible *accessible)
1233 return (_atspi_accessible_is_a (accessible, atspi_interface_editable_text) ?
1234 g_object_ref (ATSPI_EDITABLE_TEXT (accessible)) : NULL);
1238 * atspi_accessible_get_editable_text_iface:
1239 * @obj: a pointer to the #AtspiAccessible instance to query.
1241 * Gets the #AtspiEditableText interface for an #AtspiAccessible.
1243 * Returns: (transfer full): a pointer to an #AtspiEditableText interface
1244 * instance, or NULL if @obj does not implement #AtspiEditableText.
1247 atspi_accessible_get_editable_text_iface (AtspiAccessible *accessible)
1249 return (_atspi_accessible_is_a (accessible, atspi_interface_editable_text) ?
1250 g_object_ref (ATSPI_EDITABLE_TEXT (accessible)) : NULL);
1254 * atspi_accessible_get_hyperlink:
1255 * @obj: a pointer to the #AtspiAccessible object on which to operate.
1257 * Gets the #AtspiHyperlink interface for an #AtspiAccessible.
1259 * Returns: (transfer full): the #AtspiHyperlink object associated with
1260 * the given #AtspiAccessible, or NULL if not supported.
1263 atspi_accessible_get_hyperlink (AtspiAccessible *accessible)
1265 return (_atspi_accessible_is_a (accessible, atspi_interface_hyperlink) ?
1266 _atspi_hyperlink_new (accessible->parent.app, accessible->parent.path) : NULL);
1270 * atspi_accessible_get_hypertext:
1271 * @obj: a pointer to the #AtspiAccessible instance to query.
1273 * Gets the #AtspiHypertext interface for an #AtspiAccessible.
1275 * Returns: (transfer full): a pointer to an #AtspiHypertext interface
1276 * instance, or NULL if @obj does not implement #AtspiHypertext.
1278 * Deprecated: 2.10: Use atspi_accessible_get_hypertext_iface instead.
1279 * Rename to: atspi_accessible_get_hypertext_iface
1282 atspi_accessible_get_hypertext (AtspiAccessible *accessible)
1284 return (_atspi_accessible_is_a (accessible, atspi_interface_hypertext) ?
1285 g_object_ref (ATSPI_HYPERTEXT (accessible)) : NULL);
1289 * atspi_accessible_get_hypertext_iface:
1290 * @obj: a pointer to the #AtspiAccessible instance to query.
1292 * Gets the #AtspiHypertext interface for an #AtspiAccessible.
1294 * Returns: (transfer full): a pointer to an #AtspiHypertext interface
1295 * instance, or NULL if @obj does not implement #AtspiHypertext.
1298 atspi_accessible_get_hypertext_iface (AtspiAccessible *accessible)
1300 return (_atspi_accessible_is_a (accessible, atspi_interface_hypertext) ?
1301 g_object_ref (ATSPI_HYPERTEXT (accessible)) : NULL);
1305 * atspi_accessible_get_image:
1306 * @obj: a pointer to the #AtspiAccessible instance to query.
1308 * Gets the #AtspiImage interface for an #AtspiAccessible.
1310 * Returns: (transfer full): a pointer to an #AtspiImage interface instance, or
1311 * NULL if @obj does not implement #AtspiImage.
1313 * Deprecated: 2.10: Use atspi_accessible_get_image_iface instead.
1314 * Rename to: atspi_accessible_get_image_iface
1317 atspi_accessible_get_image (AtspiAccessible *accessible)
1319 return (_atspi_accessible_is_a (accessible, atspi_interface_image) ?
1320 g_object_ref (ATSPI_IMAGE (accessible)) : NULL);
1324 * atspi_accessible_get_image_iface:
1325 * @obj: a pointer to the #AtspiAccessible instance to query.
1327 * Gets the #AtspiImage interface for an #AtspiAccessible.
1329 * Returns: (transfer full): a pointer to an #AtspiImage interface instance, or
1330 * NULL if @obj does not implement #AtspiImage.
1333 atspi_accessible_get_image_iface (AtspiAccessible *accessible)
1335 return (_atspi_accessible_is_a (accessible, atspi_interface_image) ?
1336 g_object_ref (ATSPI_IMAGE (accessible)) : NULL);
1340 * atspi_accessible_get_selection:
1341 * @obj: a pointer to the #AtspiAccessible instance to query.
1343 * Gets the #AtspiSelection interface for an #AtspiAccessible.
1345 * Returns: (transfer full): a pointer to an #AtspiSelection interface
1346 * instance, or NULL if @obj does not implement #AtspiSelection.
1348 * Deprecated: 2.10: Use atspi_accessible_get_selection_iface instead.
1349 * Rename to: atspi_accessible_get_selection_iface
1352 atspi_accessible_get_selection (AtspiAccessible *accessible)
1354 return (_atspi_accessible_is_a (accessible, atspi_interface_selection) ?
1355 g_object_ref (ATSPI_SELECTION (accessible)) : NULL);
1359 * atspi_accessible_get_selection_iface:
1360 * @obj: a pointer to the #AtspiAccessible instance to query.
1362 * Gets the #AtspiSelection interface for an #AtspiAccessible.
1364 * Returns: (transfer full): a pointer to an #AtspiSelection interface
1365 * instance, or NULL if @obj does not implement #AtspiSelection.
1368 atspi_accessible_get_selection_iface (AtspiAccessible *accessible)
1370 return (_atspi_accessible_is_a (accessible, atspi_interface_selection) ?
1371 g_object_ref (ATSPI_SELECTION (accessible)) : NULL);
1376 * atspi_accessible_get_streamable_content:
1377 * @obj: a pointer to the #AtspiAccessible instance to query.
1379 * Gets the #AtspiStreamableContent interface for an #AtspiAccessible.
1381 * Returns: (transfer full): a pointer to an #AtspiStreamableContent interface
1382 * instance, or NULL if @obj does not implement #AtspiStreamableContent.
1384 AtspiStreamableContent *
1385 atspi_accessible_get_streamable_content (AtspiAccessible *accessible)
1387 return (_atspi_accessible_is_a (accessible, atspi_interface_streamable_content) ?
1393 * atspi_accessible_get_table:
1394 * @obj: a pointer to the #AtspiAccessible instance to query.
1396 * Gets the #AtspiTable interface for an #AtspiAccessible.
1398 * Returns: (transfer full): a pointer to an #AtspiTable interface instance, or
1399 * NULL if @obj does not implement #AtspiTable.
1401 * Deprecated: 2.10: Use atspi_accessible_get_table_iface instead.
1402 * Rename to: atspi_accessible_get_table_iface
1405 atspi_accessible_get_table (AtspiAccessible *obj)
1407 return (_atspi_accessible_is_a (obj, atspi_interface_table) ?
1408 g_object_ref (ATSPI_TABLE (obj)) : NULL);
1412 * atspi_accessible_get_table_iface:
1413 * @obj: a pointer to the #AtspiAccessible instance to query.
1415 * Gets the #AtspiTable interface for an #AtspiAccessible.
1417 * Returns: (transfer full): a pointer to an #AtspiTable interface instance, or
1418 * NULL if @obj does not implement #AtspiTable.
1421 atspi_accessible_get_table_iface (AtspiAccessible *obj)
1423 return (_atspi_accessible_is_a (obj, atspi_interface_table) ?
1424 g_object_ref (ATSPI_TABLE (obj)) : NULL);
1428 * atspi_accessible_get_text:
1429 * @obj: a pointer to the #AtspiAccessible instance to query.
1431 * Gets the #AtspiTable interface for an #AtspiAccessible.
1433 * Returns: (transfer full): a pointer to an #AtspiText interface instance, or
1434 * NULL if @obj does not implement #AtspiText.
1436 * Deprecated: 2.10: Use atspi_accessible_get_text_iface instead.
1437 * Rename to: atspi_accessible_get_text_iface
1440 atspi_accessible_get_text (AtspiAccessible *obj)
1442 return (_atspi_accessible_is_a (obj, atspi_interface_text) ?
1443 g_object_ref (ATSPI_TEXT (obj)) : NULL);
1447 * atspi_accessible_get_text_iface:
1448 * @obj: a pointer to the #AtspiAccessible instance to query.
1450 * Gets the #AtspiTable interface for an #AtspiAccessible.
1452 * Returns: (transfer full): a pointer to an #AtspiText interface instance, or
1453 * NULL if @obj does not implement #AtspiText.
1456 atspi_accessible_get_text_iface (AtspiAccessible *obj)
1458 return (_atspi_accessible_is_a (obj, atspi_interface_text) ?
1459 g_object_ref (ATSPI_TEXT (obj)) : NULL);
1463 * atspi_accessible_get_value:
1464 * @obj: a pointer to the #AtspiAccessible instance to query.
1466 * Gets the #AtspiTable interface for an #AtspiAccessible.
1468 * Returns: (transfer full): a pointer to an #AtspiValue interface instance, or
1469 * NULL if @obj does not implement #AtspiValue.
1471 * Deprecated: 2.10: Use atspi_accessible_get_value_iface instead.
1472 * Rename to: atspi_accessible_get_value_iface
1475 atspi_accessible_get_value (AtspiAccessible *accessible)
1477 return (_atspi_accessible_is_a (accessible, atspi_interface_value) ?
1478 g_object_ref (ATSPI_VALUE (accessible)) : NULL);
1482 * atspi_accessible_get_value_iface:
1483 * @obj: a pointer to the #AtspiAccessible instance to query.
1485 * Gets the #AtspiTable interface for an #AtspiAccessible.
1487 * Returns: (transfer full): a pointer to an #AtspiValue interface instance, or
1488 * NULL if @obj does not implement #AtspiValue.
1491 atspi_accessible_get_value_iface (AtspiAccessible *accessible)
1493 return (_atspi_accessible_is_a (accessible, atspi_interface_value) ?
1494 g_object_ref (ATSPI_VALUE (accessible)) : NULL);
1498 append_const_val (GArray *array, const gchar *val)
1500 gchar *dup = g_strdup (val);
1503 g_array_append_val (array, dup);
1507 * atspi_accessible_get_interfaces:
1508 * @obj: The #AtspiAccessible to query.
1510 * A set of pointers to all interfaces supported by an #AtspiAccessible.
1512 * Returns: (element-type gchar*) (transfer full): A #GArray of strings
1513 * describing the interfaces supported by the object. Interfaces are
1514 * denoted in short-hand (i.e. "Component", "Text" etc.).
1517 atspi_accessible_get_interfaces (AtspiAccessible *obj)
1519 GArray *ret = g_array_new (TRUE, TRUE, sizeof (gchar *));
1521 g_return_val_if_fail (obj != NULL, NULL);
1523 append_const_val (ret, "Accessible");
1524 if (atspi_accessible_is_action (obj))
1525 append_const_val (ret, "Action");
1526 if (atspi_accessible_is_collection (obj))
1527 append_const_val (ret, "Collection");
1528 if (atspi_accessible_is_component (obj))
1529 append_const_val (ret, "Component");
1530 if (atspi_accessible_is_document (obj))
1531 append_const_val (ret, "Document");
1532 if (atspi_accessible_is_editable_text (obj))
1533 append_const_val (ret, "EditableText");
1534 if (atspi_accessible_is_hypertext (obj))
1535 append_const_val (ret, "Hypertext");
1536 if (atspi_accessible_is_hyperlink (obj))
1537 append_const_val (ret, "Hyperlink");
1538 if (atspi_accessible_is_image (obj))
1539 append_const_val (ret, "Image");
1540 if (atspi_accessible_is_selection (obj))
1541 append_const_val (ret, "Selection");
1542 if (atspi_accessible_is_table (obj))
1543 append_const_val (ret, "Table");
1544 if (atspi_accessible_is_text (obj))
1545 append_const_val (ret, "Text");
1546 if (atspi_accessible_is_value (obj))
1547 append_const_val (ret, "Value");
1553 _atspi_accessible_new (AtspiApplication *app, const gchar *path)
1555 AtspiAccessible *accessible;
1557 accessible = g_object_new (ATSPI_TYPE_ACCESSIBLE, NULL);
1558 g_return_val_if_fail (accessible != NULL, NULL);
1560 accessible->parent.app = g_object_ref (app);
1561 accessible->parent.path = g_strdup (path);
1567 * atspi_accessible_set_cache_mask:
1568 * @accessible: The #AtspiAccessible to operate on. Must be the desktop or
1569 * the root of an application.
1570 * @mask: An #AtspiCache specifying a bit mask of the types of data to cache.
1572 * Sets the type of data to cache for accessibles.
1573 * If this is not set for an application or is reset to ATSPI_CACHE_UNDEFINED,
1574 * then the desktop's cache flag will be used.
1575 * If the desktop's cache flag is also undefined, then all possible data will
1577 * This function is intended to work around bugs in toolkits where the proper
1578 * events are not raised / to aid in testing for such bugs.
1581 atspi_accessible_set_cache_mask (AtspiAccessible *accessible, AtspiCache mask)
1583 g_return_if_fail (accessible != NULL);
1584 g_return_if_fail (accessible->parent.app != NULL);
1585 g_return_if_fail (accessible == accessible->parent.app->root);
1586 accessible->parent.app->cache = mask;
1587 enable_caching = TRUE;
1591 * atspi_accessible_clear_cache:
1592 * @accessible: The #AtspiAccessible whose cache to clear.
1594 * Clears the cached information for the given accessible and all of its
1598 atspi_accessible_clear_cache (AtspiAccessible *accessible)
1604 accessible->cached_properties = ATSPI_CACHE_NONE;
1605 for (l = accessible->children; l; l = l->next)
1606 atspi_accessible_clear_cache (l->data);
1611 * atspi_accessible_get_process_id:
1612 * @accessible: The #AtspiAccessible to query.
1614 * Returns the process id associated with the given accessible. Mainly
1615 * added for debugging; it is a shortcut to explicitly querying the
1616 * accessible's app->bus_name and then calling GetConnectionUnixProcessID.
1618 * Returns: The process ID, or -1 if defunct.
1621 atspi_accessible_get_process_id (AtspiAccessible *accessible, GError **error)
1623 DBusMessage *message, *reply;
1624 DBusConnection *bus = _atspi_bus ();
1625 dbus_uint32_t pid = -1;
1628 if (!accessible->parent.app || !accessible->parent.app->bus_name)
1631 message = dbus_message_new_method_call ("org.freedesktop.DBus",
1632 "/org/freedesktop/DBus",
1633 "org.freedesktop.DBus",
1634 "GetConnectionUnixProcessID");
1635 dbus_message_append_args (message, DBUS_TYPE_STRING,
1636 &accessible->parent.app->bus_name,
1638 dbus_error_init (&d_error);
1639 reply = dbus_connection_send_with_reply_and_block (bus, message, -1, &d_error);
1640 dbus_message_unref (message);
1643 if (!strcmp (dbus_message_get_signature (reply), "u"))
1644 dbus_message_get_args (reply, NULL, DBUS_TYPE_UINT32, &pid, DBUS_TYPE_INVALID);
1645 dbus_message_unref (reply);
1647 if (dbus_error_is_set (&d_error))
1649 g_warning ("GetConnectionUnixProcessID failed: %s", d_error.message);
1650 dbus_error_free (&d_error);
1656 _atspi_accessible_get_cache_mask (AtspiAccessible *accessible)
1660 if (!accessible->parent.app)
1661 return ATSPI_CACHE_NONE;
1663 mask = accessible->parent.app->cache;
1664 if (mask == ATSPI_CACHE_UNDEFINED &&
1665 accessible->parent.app->root &&
1666 accessible->parent.app->root->accessible_parent)
1668 AtspiAccessible *desktop = atspi_get_desktop (0);
1669 mask = desktop->parent.app->cache;
1670 g_object_unref (desktop);
1673 if (mask == ATSPI_CACHE_UNDEFINED)
1674 mask = ATSPI_CACHE_DEFAULT;
1680 _atspi_accessible_test_cache (AtspiAccessible *accessible, AtspiCache flag)
1682 AtspiCache mask = _atspi_accessible_get_cache_mask (accessible);
1683 AtspiCache result = accessible->cached_properties & mask & flag;
1684 if (accessible->states && atspi_state_set_contains (accessible->states, ATSPI_STATE_TRANSIENT))
1686 return (result != 0 && (atspi_main_loop || enable_caching ||
1687 flag == ATSPI_CACHE_INTERFACES) &&
1692 _atspi_accessible_add_cache (AtspiAccessible *accessible, AtspiCache flag)
1694 AtspiCache mask = _atspi_accessible_get_cache_mask (accessible);
1696 accessible->cached_properties |= flag & mask;
1700 * atspi_accessible_get_locale:
1701 * @accessible: an #AtspiAccessible
1703 * Gets a UTF-8 string indicating the POSIX-style LC_MESSAGES locale
1708 * Returns: a UTF-8 string indicating the POSIX-style LC_MESSAGES
1709 * locale of @accessible.
1712 atspi_accessible_get_object_locale (AtspiAccessible *accessible, GError **error)
1716 g_return_val_if_fail (accessible != NULL, NULL);
1718 locale = g_object_get_qdata (G_OBJECT (accessible), quark_locale);
1721 if (!_atspi_dbus_get_property (accessible, atspi_interface_accessible,
1722 "Locale", error, "s", &locale))
1725 g_object_set_qdata_full (G_OBJECT (accessible), quark_locale, locale,
1732 free_value (gpointer data)
1734 GValue *value = data;
1736 g_value_unset (value);
1741 _atspi_accessible_ref_cache (AtspiAccessible *accessible)
1743 AtspiAccessiblePrivate *priv = accessible->priv;
1745 priv->cache_ref_count++;
1747 return g_hash_table_ref (priv->cache);
1748 priv->cache = g_hash_table_new_full (g_str_hash, g_str_equal, g_free,
1754 _atspi_accessible_unref_cache (AtspiAccessible *accessible)
1756 AtspiAccessiblePrivate *priv = accessible->priv;
1760 g_hash_table_unref (priv->cache);
1761 if (--priv->cache_ref_count == 0)