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 Lesser General Public
11 * License as published by the Free Software Foundation; either
12 * version 2.1 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 * Lesser General Public License for more details.
19 * You should have received a copy of the GNU Lesser General Public
20 * License along with this library; if not, write to the
21 * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
22 * Boston, MA 02110-1301, USA.
25 #include "atspi-private.h"
26 #include "atspi-accessible-private.h"
34 static gboolean enable_caching = FALSE;
35 static guint quark_locale;
37 static guint atspi_accessible_signals[LAST_SIGNAL] = { 0, };
40 screen_reader_signal_watcher (GSignalInvocationHint *signal_hint,
42 const GValue *param_values,
46 AtspiAccessible *accessible;
47 GSignalQuery signal_query;
50 DBusMessageIter iter, iter_struct, iter_variant, iter_array;
51 dbus_int32_t detail1, detail2;
52 const char *detail = "";
54 object = g_value_get_object (param_values + 0);
55 g_return_val_if_fail (ATSPI_IS_ACCESSIBLE(object), FALSE);
57 g_signal_query (signal_hint->signal_id, &signal_query);
58 name = signal_query.signal_name;
59 detail1 = g_value_get_int (param_values + 1);
60 detail2 = g_value_get_int (param_values + 2);
61 accessible = ATSPI_ACCESSIBLE (object);
63 signal = dbus_message_new_signal (ATSPI_DBUS_PATH_SCREEN_READER,
64 ATSPI_DBUS_INTERFACE_EVENT_SCREEN_READER,
66 dbus_message_iter_init_append (signal, &iter);
67 dbus_message_iter_append_basic (&iter, DBUS_TYPE_STRING, &detail);
68 dbus_message_iter_append_basic (&iter, DBUS_TYPE_INT32, &detail1);
69 dbus_message_iter_append_basic (&iter, DBUS_TYPE_INT32, &detail2);
70 dbus_message_iter_open_container (&iter, DBUS_TYPE_VARIANT, "(so)",
72 dbus_message_iter_open_container (&iter_variant, DBUS_TYPE_STRUCT, NULL,
74 dbus_message_iter_append_basic (&iter_struct, DBUS_TYPE_STRING, &accessible->parent.app->bus_name);
75 dbus_message_iter_append_basic (&iter_struct, DBUS_TYPE_OBJECT_PATH, &accessible->parent.path);
76 dbus_message_iter_close_container (&iter_variant, &iter_struct);
77 dbus_message_iter_close_container (&iter, &iter_variant);
78 dbus_message_iter_open_container (&iter, DBUS_TYPE_ARRAY, "{sv}",
80 dbus_message_iter_close_container (&iter, &iter_array);
81 dbus_connection_send (_atspi_bus (), signal, NULL);
82 dbus_message_unref (signal);
87 atspi_action_interface_init (AtspiAction *action)
92 atspi_collection_interface_init (AtspiCollection *component)
97 atspi_component_interface_init (AtspiComponent *component)
102 atspi_document_interface_init (AtspiDocument *document)
107 atspi_editable_text_interface_init (AtspiEditableText *editable_text)
112 atspi_hypertext_interface_init (AtspiHypertext *hypertext)
117 atspi_image_interface_init (AtspiImage *image)
122 atspi_selection_interface_init (AtspiSelection *selection)
127 atspi_table_interface_init (AtspiTable *table)
132 atspi_table_cell_interface_init (AtspiTableCell *cell)
137 atspi_text_interface_init (AtspiText *text)
142 atspi_value_interface_init (AtspiValue *value)
146 G_DEFINE_TYPE_WITH_CODE (AtspiAccessible, atspi_accessible, ATSPI_TYPE_OBJECT,
147 G_ADD_PRIVATE (AtspiAccessible)
148 G_IMPLEMENT_INTERFACE (ATSPI_TYPE_ACTION, atspi_action_interface_init)
149 G_IMPLEMENT_INTERFACE (ATSPI_TYPE_COLLECTION, atspi_collection_interface_init)
150 G_IMPLEMENT_INTERFACE (ATSPI_TYPE_COMPONENT, atspi_component_interface_init)
151 G_IMPLEMENT_INTERFACE (ATSPI_TYPE_DOCUMENT, atspi_document_interface_init)
152 G_IMPLEMENT_INTERFACE (ATSPI_TYPE_EDITABLE_TEXT, atspi_editable_text_interface_init)
153 G_IMPLEMENT_INTERFACE (ATSPI_TYPE_HYPERTEXT, atspi_hypertext_interface_init)
154 G_IMPLEMENT_INTERFACE (ATSPI_TYPE_IMAGE, atspi_image_interface_init)
155 G_IMPLEMENT_INTERFACE (ATSPI_TYPE_SELECTION, atspi_selection_interface_init)
156 G_IMPLEMENT_INTERFACE (ATSPI_TYPE_TABLE, atspi_table_interface_init)
157 G_IMPLEMENT_INTERFACE (ATSPI_TYPE_TABLE_CELL, atspi_table_cell_interface_init)
158 G_IMPLEMENT_INTERFACE (ATSPI_TYPE_TEXT, atspi_text_interface_init)
159 G_IMPLEMENT_INTERFACE (ATSPI_TYPE_VALUE, atspi_value_interface_init))
161 #ifdef DEBUG_REF_COUNTS
162 static gint accessible_count = 0;
166 atspi_accessible_unref (GObject *accessible)
168 if (accessible != NULL)
169 g_object_unref(accessible);
173 atspi_accessible_init (AtspiAccessible *accessible)
175 #ifdef DEBUG_REF_COUNTS
177 g_hash_table_insert (_atspi_get_live_refs (), accessible, NULL);
178 g_print("at-spi: init: %d objects\n", accessible_count);
181 accessible->priv = atspi_accessible_get_instance_private (accessible);
183 accessible->children = g_ptr_array_new_with_free_func (atspi_accessible_unref);
187 atspi_accessible_dispose (GObject *object)
189 AtspiAccessible *accessible = ATSPI_ACCESSIBLE (object);
191 AtspiAccessible *parent;
194 /* TODO: Only fire if object not already marked defunct */
195 memset (&e, 0, sizeof (e));
196 e.type = "object:state-changed:defunct";
197 e.source = accessible;
200 _atspi_send_event (&e);
202 g_clear_object (&accessible->states);
204 parent = accessible->accessible_parent;
207 accessible->accessible_parent = NULL;
208 if (parent->children)
209 g_ptr_array_remove (parent->children, accessible);
210 g_object_unref (parent);
213 if (accessible->children) for (i = accessible->children->len - 1; i >= 0; i--)
215 AtspiAccessible *child = g_ptr_array_index (accessible->children, i);
216 if (child && child->accessible_parent == accessible)
218 child->accessible_parent = NULL;
219 g_object_unref (accessible);
223 if (accessible->children)
225 g_ptr_array_free (accessible->children, TRUE);
226 accessible->children = NULL;
229 G_OBJECT_CLASS (atspi_accessible_parent_class) ->dispose (object);
233 atspi_accessible_finalize (GObject *object)
235 AtspiAccessible *accessible = ATSPI_ACCESSIBLE (object);
237 g_free (accessible->description);
238 g_free (accessible->name);
240 if (accessible->attributes)
241 g_hash_table_unref (accessible->attributes);
243 if (accessible->priv->cache)
244 g_hash_table_destroy (accessible->priv->cache);
246 #ifdef DEBUG_REF_COUNTS
248 g_hash_table_remove (_atspi_get_live_refs (), accessible);
249 g_print ("at-spi: finalize: %d objects\n", accessible_count);
252 G_OBJECT_CLASS (atspi_accessible_parent_class)->finalize (object);
254 /* TODO: remove emission hook */
258 atspi_accessible_class_init (AtspiAccessibleClass *klass)
260 GObjectClass *object_class = G_OBJECT_CLASS (klass);
262 object_class->dispose = atspi_accessible_dispose;
263 object_class->finalize = atspi_accessible_finalize;
265 quark_locale = g_quark_from_string ("accessible-locale");
268 * AtspiAccessible::region-changed:
269 * @atspiaccessible: the object which received the signal
270 * @arg1: an integer specifying the current offset of the text being read,
271 * if the object is textual.
272 * @arg2: an integer specifying the ending offset of the text being read,
273 * if the object is textual.
275 * The signal "region-changed" is emitted by a screen reader to indicate
276 * that it is now reading or tracking a new object, or, a new piece of
277 * text within an object. This allows a magnifier to gain the information
278 * needed to highlight the object that the screen reader is reading.
280 atspi_accessible_signals[REGION_CHANGED] =
281 g_signal_new ("region_changed",
282 G_TYPE_FROM_CLASS (klass),
284 G_STRUCT_OFFSET (AtspiAccessibleClass, region_changed),
286 atspi_marshal_VOID__INT_INT,
288 2, G_TYPE_INT, G_TYPE_INT);
290 g_signal_add_emission_hook (atspi_accessible_signals[REGION_CHANGED], 0,
291 screen_reader_signal_watcher, NULL,
292 (GDestroyNotify) NULL);
296 * atspi_accessible_get_name:
297 * @obj: a pointer to the #AtspiAccessible object on which to operate.
299 * Gets the name of an #AtspiAccessible object.
301 * Returns: a UTF-8 string indicating the name of the #AtspiAccessible object
302 * or NULL on exception.
305 atspi_accessible_get_name (AtspiAccessible *obj, GError **error)
307 g_return_val_if_fail (obj != NULL, g_strdup (""));
308 if (!_atspi_accessible_test_cache (obj, ATSPI_CACHE_NAME))
310 if (!_atspi_dbus_get_property (obj, atspi_interface_accessible, "Name", error,
312 return g_strdup ("");
313 _atspi_accessible_add_cache (obj, ATSPI_CACHE_NAME);
315 return g_strdup (obj->name);
319 * atspi_accessible_get_description:
320 * @obj: a pointer to the #AtspiAccessible object on which to operate.
322 * Gets the description of an #AtspiAccessible object.
324 * Returns: a UTF-8 string describing the #AtspiAccessible object
325 * or NULL on exception.
328 atspi_accessible_get_description (AtspiAccessible *obj, GError **error)
330 g_return_val_if_fail (obj != NULL, g_strdup (""));
332 if (!_atspi_accessible_test_cache (obj, ATSPI_CACHE_DESCRIPTION))
334 if (!_atspi_dbus_get_property (obj, atspi_interface_accessible,
335 "Description", error, "s",
337 return g_strdup ("");
338 _atspi_accessible_add_cache (obj, ATSPI_CACHE_DESCRIPTION);
340 return g_strdup (obj->description);
343 const char *str_parent = "Parent";
346 * atspi_accessible_get_parent:
347 * @obj: a pointer to the #AtspiAccessible object to query.
349 * Gets an #AtspiAccessible object's parent container.
351 * Returns: (nullable) (transfer full): a pointer to the
352 * #AtspiAccessible object which contains the given
353 * #AtspiAccessible instance, or NULL if the @obj has no
358 atspi_accessible_get_parent (AtspiAccessible *obj, GError **error)
360 g_return_val_if_fail (obj != NULL, NULL);
362 if (!_atspi_accessible_test_cache (obj, ATSPI_CACHE_PARENT))
364 DBusMessage *message, *reply;
365 DBusMessageIter iter, iter_variant;
366 if (!obj->parent.app)
368 message = dbus_message_new_method_call (obj->parent.app->bus_name,
370 DBUS_INTERFACE_PROPERTIES, "Get");
373 dbus_message_append_args (message, DBUS_TYPE_STRING, &atspi_interface_accessible,
374 DBUS_TYPE_STRING, &str_parent,
376 reply = _atspi_dbus_send_with_reply_and_block (message, error);
379 if (strcmp (dbus_message_get_signature (reply), "v") != 0)
381 dbus_message_unref (reply);
384 dbus_message_iter_init (reply, &iter);
385 dbus_message_iter_recurse (&iter, &iter_variant);
386 obj->accessible_parent = _atspi_dbus_return_accessible_from_iter (&iter_variant);
387 dbus_message_unref (reply);
388 _atspi_accessible_add_cache (obj, ATSPI_CACHE_PARENT);
390 if (!obj->accessible_parent)
392 return g_object_ref (obj->accessible_parent);
396 * atspi_accessible_get_child_count:
397 * @obj: a pointer to the #AtspiAccessible object on which to operate.
399 * Gets the number of children contained by an #AtspiAccessible object.
401 * Returns: a #long indicating the number of #AtspiAccessible children
402 * contained by an #AtspiAccessible object or -1 on exception.
406 atspi_accessible_get_child_count (AtspiAccessible *obj, GError **error)
408 g_return_val_if_fail (obj != NULL, -1);
410 if (!_atspi_accessible_test_cache (obj, ATSPI_CACHE_CHILDREN))
413 if (!_atspi_dbus_get_property (obj, atspi_interface_accessible,
414 "ChildCount", error, "i", &ret))
420 return 0; /* assume it's disposed */
422 return obj->children->len;
426 * atspi_accessible_get_child_at_index:
427 * @obj: a pointer to the #AtspiAccessible object on which to operate.
428 * @child_index: a #long indicating which child is specified.
430 * Gets the #AtspiAccessible child of an #AtspiAccessible object at a given index.
432 * Returns: (transfer full): a pointer to the #AtspiAccessible child object at
433 * index @child_index or NULL on exception.
436 atspi_accessible_get_child_at_index (AtspiAccessible *obj,
440 AtspiAccessible *child;
443 g_return_val_if_fail (obj != NULL, NULL);
445 if (_atspi_accessible_test_cache (obj, ATSPI_CACHE_CHILDREN))
448 return NULL; /* assume disposed */
450 child = g_ptr_array_index (obj->children, child_index);
452 return g_object_ref (child);
455 reply = _atspi_dbus_call_partial (obj, atspi_interface_accessible,
456 "GetChildAtIndex", error, "i", child_index);
457 child = _atspi_dbus_return_accessible_from_message (reply);
462 if (_atspi_accessible_test_cache (obj, ATSPI_CACHE_CHILDREN))
464 if (child_index >= obj->children->len)
465 g_ptr_array_set_size (obj->children, child_index + 1);
466 g_ptr_array_index (obj->children, child_index) = g_object_ref (child);
472 * atspi_accessible_get_index_in_parent:
473 * @obj: a pointer to the #AtspiAccessible object on which to operate.
475 * Gets the index of an #AtspiAccessible object within its parent's
476 * #AtspiAccessible children list.
478 * Returns: a #glong indicating the index of the #AtspiAccessible object
480 * or -1 if @obj has no containing parent or on exception.
483 atspi_accessible_get_index_in_parent (AtspiAccessible *obj, GError **error)
486 dbus_int32_t ret = -1;
488 g_return_val_if_fail (obj != NULL, -1);
489 if (_atspi_accessible_test_cache (obj, ATSPI_CACHE_PARENT))
491 if (!obj->accessible_parent)
494 if (!_atspi_accessible_test_cache (obj->accessible_parent, ATSPI_CACHE_CHILDREN) || !obj->accessible_parent->children)
497 for (i = 0; i < obj->accessible_parent->children->len; i++)
498 if (g_ptr_array_index (obj->accessible_parent->children, i) == obj)
503 _atspi_dbus_call (obj, atspi_interface_accessible,
504 "GetIndexInParent", NULL, "=>i", &ret);
512 } Accessibility_Relation;
515 * atspi_accessible_get_relation_set:
516 * @obj: a pointer to the #AtspiAccessible object on which to operate.
518 * Gets the set of #AtspiRelation objects which describes this #AtspiAccessible object's
519 * relationships with other #AtspiAccessible objects.
521 * Returns: (element-type AtspiRelation*) (transfer full): a #GArray of
522 * #AtspiRelation pointers or NULL on exception.
525 atspi_accessible_get_relation_set (AtspiAccessible *obj, GError **error)
528 DBusMessageIter iter, iter_array;
531 g_return_val_if_fail (obj != NULL, NULL);
533 reply = _atspi_dbus_call_partial (obj, atspi_interface_accessible, "GetRelationSet", error, "");
536 _ATSPI_DBUS_CHECK_SIG (reply, "a(ua(so))", error, NULL);
538 ret = g_array_new (TRUE, TRUE, sizeof (AtspiRelation *));
539 dbus_message_iter_init (reply, &iter);
540 dbus_message_iter_recurse (&iter, &iter_array);
541 while (dbus_message_iter_get_arg_type (&iter_array) != DBUS_TYPE_INVALID)
543 AtspiRelation *relation;
544 relation = _atspi_relation_new_from_iter (&iter_array);
545 ret = g_array_append_val (ret, relation);
546 dbus_message_iter_next (&iter_array);
548 dbus_message_unref (reply);
553 * atspi_accessible_get_role:
554 * @obj: a pointer to the #AtspiAccessible object on which to operate.
556 * Gets the UI role played by an #AtspiAccessible object.
557 * This role's name can be obtained via atspi_accessible_get_role_name ().
559 * Returns: the #AtspiRole of an #AtspiAccessible object.
563 atspi_accessible_get_role (AtspiAccessible *obj, GError **error)
565 g_return_val_if_fail (obj != NULL, ATSPI_ROLE_INVALID);
567 if (!_atspi_accessible_test_cache (obj, ATSPI_CACHE_ROLE))
570 /* TODO: Make this a property */
571 if (_atspi_dbus_call (obj, atspi_interface_accessible, "GetRole", error, "=>u", &role))
574 _atspi_accessible_add_cache (obj, ATSPI_CACHE_ROLE);
581 * atspi_accessible_get_role_name:
582 * @obj: a pointer to the #AtspiAccessible object on which to operate.
584 * Gets a UTF-8 string corresponding to the name of the role played by an object.
585 * This method will return useful values for roles that fall outside the
586 * enumeration used in atspi_accessible_get_role ().
588 * Returns: a UTF-8 string specifying the type of UI role played by an
589 * #AtspiAccessible object.
593 atspi_accessible_get_role_name (AtspiAccessible *obj, GError **error)
595 gchar *retval = NULL;
598 g_return_val_if_fail (obj != NULL, NULL);
600 role = atspi_accessible_get_role (obj, error);
601 if (role >= 0 && role < ATSPI_ROLE_COUNT && role != ATSPI_ROLE_EXTENDED)
602 return atspi_role_get_name (role);
604 _atspi_dbus_call (obj, atspi_interface_accessible, "GetRoleName", error, "=>s", &retval);
607 retval = g_strdup ("");
613 * atspi_accessible_get_localized_role_name:
614 * @obj: a pointer to the #AtspiAccessible object on which to operate.
616 * Gets a UTF-8 string corresponding to the name of the role played by an
617 * object, translated to the current locale.
618 * This method will return useful values for roles that fall outside the
619 * enumeration used in atspi_accessible_getRole ().
621 * Returns: a localized, UTF-8 string specifying the type of UI role played
622 * by an #AtspiAccessible object.
626 atspi_accessible_get_localized_role_name (AtspiAccessible *obj, GError **error)
630 g_return_val_if_fail (obj != NULL, NULL);
632 _atspi_dbus_call (obj, atspi_interface_accessible, "GetLocalizedRoleName", error, "=>s", &retval);
635 return g_strdup ("");
640 static AtspiStateSet *
643 AtspiStateSet *set = atspi_state_set_new (NULL);
644 atspi_state_set_add (set, ATSPI_STATE_DEFUNCT);
649 * atspi_accessible_get_state_set:
650 * @obj: a pointer to the #AtspiAccessible object on which to operate.
652 * Gets the states currently held by an object.
654 * Returns: (transfer full): a pointer to an #AtspiStateSet representing an
655 * object's current state set.
658 atspi_accessible_get_state_set (AtspiAccessible *obj)
660 /* TODO: Should take a GError **, but would be an API break */
661 if (!obj->parent.app || !obj->parent.app->bus)
662 return defunct_set ();
664 if (!_atspi_accessible_test_cache (obj, ATSPI_CACHE_STATES))
667 DBusMessageIter iter;
668 reply = _atspi_dbus_call_partial (obj, atspi_interface_accessible,
669 "GetState", NULL, "");
670 _ATSPI_DBUS_CHECK_SIG (reply, "au", NULL, defunct_set ());
671 dbus_message_iter_init (reply, &iter);
672 _atspi_dbus_set_state (obj, &iter);
673 dbus_message_unref (reply);
674 _atspi_accessible_add_cache (obj, ATSPI_CACHE_STATES);
677 return g_object_ref (obj->states);
681 * atspi_accessible_get_attributes:
682 * @obj: The #AtspiAccessible being queried.
684 * Gets the #AttributeSet representing any assigned
685 * name-value pair attributes or annotations for this object.
686 * For typographic, textual, or textually-semantic attributes, see
687 * atspi_text_get_attributes instead.
689 * Returns: (element-type gchar* gchar*) (transfer full): The name-value-pair
690 * attributes assigned to this object.
693 atspi_accessible_get_attributes (AtspiAccessible *obj, GError **error)
695 DBusMessage *message;
697 g_return_val_if_fail (obj != NULL, NULL);
699 if (obj->priv->cache)
701 GValue *val = g_hash_table_lookup (obj->priv->cache, "Attributes");
703 return g_value_dup_boxed (val);
706 if (!_atspi_accessible_test_cache (obj, ATSPI_CACHE_ATTRIBUTES))
708 message = _atspi_dbus_call_partial (obj, atspi_interface_accessible,
709 "GetAttributes", error, "");
710 obj->attributes = _atspi_dbus_return_hash_from_message (message);
711 _atspi_accessible_add_cache (obj, ATSPI_CACHE_ATTRIBUTES);
714 if (!obj->attributes)
716 return g_hash_table_ref (obj->attributes);
720 add_to_attribute_array (gpointer key, gpointer value, gpointer data)
722 GArray **array = (GArray **)data;
723 gchar *str = g_strconcat (key, ":", value, NULL);
724 *array = g_array_append_val (*array, str);
728 * atspi_accessible_get_attributes_as_array:
729 * @obj: The #AtspiAccessible being queried.
731 * Gets a #GArray representing any assigned
732 * name-value pair attributes or annotations for this object.
733 * For typographic, textual, or textually-semantic attributes, see
734 * atspi_text_get_attributes_as_array instead.
736 * Returns: (element-type gchar*) (transfer full): The name-value-pair
737 * attributes assigned to this object.
740 atspi_accessible_get_attributes_as_array (AtspiAccessible *obj, GError **error)
742 DBusMessage *message;
744 g_return_val_if_fail (obj != NULL, NULL);
746 if (obj->priv->cache)
748 GValue *val = g_hash_table_lookup (obj->priv->cache, "Attributes");
751 GArray *array = g_array_new (TRUE, TRUE, sizeof (gchar *));
752 GHashTable *attributes = g_value_get_boxed (val);
753 g_hash_table_foreach (attributes, add_to_attribute_array, &array);
758 message = _atspi_dbus_call_partial (obj, atspi_interface_accessible, "GetAttributes", error, "");
759 return _atspi_dbus_return_attribute_array_from_message (message);
763 * atspi_accessible_get_application:
764 * @obj: The #AtspiAccessible being queried.
766 * Gets the containing #AtspiApplication for an object.
768 * Returns: (transfer full): the containing #AtspiApplication instance for
772 atspi_accessible_get_application (AtspiAccessible *obj, GError **error)
774 AtspiAccessible *parent;
779 parent = atspi_accessible_get_parent (obj, NULL);
780 if (!parent && obj->parent.app &&
781 atspi_accessible_get_role (obj, NULL) != ATSPI_ROLE_APPLICATION)
783 AtspiAccessible *root = g_object_ref (obj->parent.app->root);
786 g_object_unref (obj);
787 if (atspi_accessible_get_role (root, NULL) == ATSPI_ROLE_DESKTOP_FRAME)
789 g_object_unref (root);
795 if (!parent || parent == obj ||
796 atspi_accessible_get_role (parent, NULL) == ATSPI_ROLE_DESKTOP_FRAME)
799 g_object_unref (parent);
802 g_object_unref (obj);
807 /* Application-specific methods */
810 * atspi_accessible_get_toolkit_name:
811 * @obj: a pointer to the #AtspiAccessible object on which to operate.
813 * Gets the toolkit name for an #AtspiAccessible object.
814 * Only works on application root objects.
816 * Returns: a UTF-8 string indicating the toolkit name for the #AtspiAccessible object or NULL on exception.
819 atspi_accessible_get_toolkit_name (AtspiAccessible *obj, GError **error)
821 g_return_val_if_fail (obj != NULL, NULL);
823 if (!obj->parent.app)
826 if (!obj->parent.app->toolkit_name)
827 _atspi_dbus_get_property (obj, atspi_interface_application, "ToolkitName",
828 error, "s", &obj->parent.app->toolkit_name);
830 return g_strdup (obj->parent.app->toolkit_name);
834 * atspi_accessible_get_toolkit_version:
835 * @obj: a pointer to the #AtspiAccessible object on which to operate.
837 * Gets the toolkit version for an #AtspiAccessible object.
838 * Only works on application root objects.
840 * Returns: a UTF-8 string indicating the toolkit version for the #AtspiAccessible object or NULL on exception.
843 atspi_accessible_get_toolkit_version (AtspiAccessible *obj, GError **error)
845 g_return_val_if_fail (obj != NULL, NULL);
847 if (!obj->parent.app)
850 if (!obj->parent.app->toolkit_version)
851 _atspi_dbus_get_property (obj, atspi_interface_application, "Version",
852 error, "s", &obj->parent.app->toolkit_version);
854 return g_strdup (obj->parent.app->toolkit_version);
858 * atspi_accessible_get_atspi_version:
859 * @obj: a pointer to the #AtspiAccessible object on which to operate.
861 * Gets the AT-SPI IPC specification version supported by the application
862 * pointed to by the #AtspiAccessible object.
863 * Only works on application root objects.
865 * Returns: a UTF-8 string indicating the AT-SPI version for the #AtspiAccessible object or NULL on exception.
868 atspi_accessible_get_atspi_version (AtspiAccessible *obj, GError **error)
870 g_return_val_if_fail (obj != NULL, NULL);
872 if (!obj->parent.app)
875 if (!obj->parent.app->atspi_version)
876 _atspi_dbus_get_property (obj, atspi_interface_application, "AtspiVersion",
877 error, "s", &obj->parent.app->atspi_version);
879 return g_strdup (obj->parent.app->atspi_version);
883 * atspi_accessible_get_id:
884 * @obj: a pointer to the #AtspiAccessible object on which to operate.
886 * Gets the application id for a #AtspiAccessible object.
887 * Only works on application root objects.
889 * Returns: a positive #gint indicating the id for the #AtspiAccessible object
890 * or -1 on exception.
893 atspi_accessible_get_id (AtspiAccessible *obj, GError **error)
897 g_return_val_if_fail (obj != NULL, -1);
899 if (!_atspi_dbus_get_property (obj, atspi_interface_application, "Id", error, "i", &ret))
905 /* Interface query methods */
908 _atspi_accessible_is_a (AtspiAccessible *accessible,
909 const char *interface_name)
913 if (accessible == NULL)
918 if (!_atspi_accessible_test_cache (accessible, ATSPI_CACHE_INTERFACES))
921 DBusMessageIter iter;
922 reply = _atspi_dbus_call_partial (accessible, atspi_interface_accessible,
923 "GetInterfaces", NULL, "");
924 _ATSPI_DBUS_CHECK_SIG (reply, "as", NULL, FALSE);
925 dbus_message_iter_init (reply, &iter);
926 _atspi_dbus_set_interfaces (accessible, &iter);
927 dbus_message_unref (reply);
928 _atspi_accessible_add_cache (accessible, ATSPI_CACHE_INTERFACES);
931 n = _atspi_get_iface_num (interface_name);
932 if (n == -1) return FALSE;
933 return (gboolean) ((accessible->interfaces & (1 << n))? TRUE: FALSE);
937 * atspi_accessible_is_action:
938 * @obj: a pointer to the #AtspiAccessible instance to query.
940 * Query whether the specified #AtspiAccessible implements the
941 * #AtspiAction interface.
943 * Returns: #TRUE if @obj implements the #AtspiAction interface,
947 atspi_accessible_is_action (AtspiAccessible *obj)
949 return _atspi_accessible_is_a (obj,
950 atspi_interface_action);
954 * atspi_accessible_is_application:
955 * @obj: a pointer to the #AtspiAccessible instance to query.
957 * Query whether the specified #AtspiAccessible implements the
958 * #AtspiApplication interface.
960 * Returns: #TRUE if @obj implements the #AtspiApplication interface,
964 atspi_accessible_is_application (AtspiAccessible *obj)
966 return _atspi_accessible_is_a (obj,
967 atspi_interface_application);
971 * atspi_accessible_is_collection:
972 * @obj: a pointer to the #AtspiAccessible instance to query.
974 * Query whether the specified #AtspiAccessible implements the
975 * #AtspiCollection interface.
977 * Returns: #TRUE if @obj implements the #AtspiCollection interface,
981 atspi_accessible_is_collection (AtspiAccessible *obj)
983 return _atspi_accessible_is_a (obj,
984 atspi_interface_collection);
988 * atspi_accessible_is_component:
989 * @obj: a pointer to the #AtspiAccessible instance to query.
991 * Query whether the specified #AtspiAccessible implements #AtspiComponent.
993 * Returns: #TRUE if @obj implements the #AtspiComponent interface,
997 atspi_accessible_is_component (AtspiAccessible *obj)
999 return _atspi_accessible_is_a (obj,
1000 atspi_interface_component);
1004 * atspi_accessible_is_document:
1005 * @obj: a pointer to the #AtspiAccessible instance to query.
1007 * Query whether the specified #AtspiAccessible implements the
1008 * #AtspiDocument interface.
1010 * Returns: #TRUE if @obj implements the #AtspiDocument interface,
1014 atspi_accessible_is_document (AtspiAccessible *obj)
1016 return _atspi_accessible_is_a (obj,
1017 atspi_interface_document);
1021 * atspi_accessible_is_editable_text:
1022 * @obj: a pointer to the #AtspiAccessible instance to query.
1024 * Query whether the specified #AtspiAccessible implements the
1025 * #AtspiEditableText interface.
1027 * Returns: #TRUE if @obj implements the #AtspiEditableText interface,
1031 atspi_accessible_is_editable_text (AtspiAccessible *obj)
1033 return _atspi_accessible_is_a (obj,
1034 atspi_interface_editable_text);
1038 * atspi_accessible_is_hypertext:
1039 * @obj: a pointer to the #AtspiAccessible instance to query.
1041 * Query whether the specified #AtspiAccessible implements the
1042 * #AtspiHypertext interface.
1044 * Returns: #TRUE if @obj implements the #AtspiHypertext interface,
1048 atspi_accessible_is_hypertext (AtspiAccessible *obj)
1050 return _atspi_accessible_is_a (obj,
1051 atspi_interface_hypertext);
1055 * atspi_accessible_is_hyperlink:
1056 * @obj: a pointer to the #AtspiAccessible instance to query.
1058 * Query whether the specified #AtspiAccessible implements the
1059 * #AtspiHyperlink interface.
1061 * Returns: #TRUE if @obj implements the #AtspiHypertext interface,
1065 atspi_accessible_is_hyperlink (AtspiAccessible *obj)
1067 return _atspi_accessible_is_a (obj,
1068 atspi_interface_hyperlink);
1072 * atspi_accessible_is_image:
1073 * @obj: a pointer to the #AtspiAccessible instance to query.
1075 * Query whether the specified #AtspiAccessible implements the
1076 * #AtspiImage interface.
1078 * Returns: #TRUE if @obj implements the #AtspiImage interface,
1082 atspi_accessible_is_image (AtspiAccessible *obj)
1084 return _atspi_accessible_is_a (obj,
1085 atspi_interface_image);
1089 * atspi_accessible_is_selection:
1090 * @obj: a pointer to the #AtspiAccessible instance to query.
1092 * Query whether the specified #AtspiAccessible implements the
1093 * #AtspiSelection interface.
1095 * Returns: #TRUE if @obj implements the #AtspiSelection interface,
1099 atspi_accessible_is_selection (AtspiAccessible *obj)
1101 return _atspi_accessible_is_a (obj,
1102 atspi_interface_selection);
1106 * atspi_accessible_is_table:
1107 * @obj: a pointer to the #AtspiAccessible instance to query.
1109 * Query whether the specified #AtspiAccessible implements the
1110 * #AtspiTable interface.
1112 * Returns: #TRUE if @obj implements the #AtspiTable interface,
1116 atspi_accessible_is_table (AtspiAccessible *obj)
1118 return _atspi_accessible_is_a (obj,
1119 atspi_interface_table);
1123 * atspi_accessible_is_table_cell:
1124 * @obj: a pointer to the #AtspiAccessible instance to query.
1126 * Query whether the specified #AtspiAccessible implements the
1127 * #AtspiTableCell interface.
1129 * Returns: #TRUE if @obj implements the #AtspiTable interface,
1133 atspi_accessible_is_table_cell (AtspiAccessible *obj)
1135 return _atspi_accessible_is_a (obj,
1136 atspi_interface_table_cell);
1140 * atspi_accessible_is_streamable_content:
1141 * @obj: a pointer to the #AtspiAccessible instance to query.
1143 * Query whether the specified #AtspiAccessible implements the
1144 * #AtspiStreamableContent interface.
1146 * Returns: #TRUE if @obj implements the #AtspiStreamableContent interface,
1150 atspi_accessible_is_streamable_content (AtspiAccessible *obj)
1153 return _atspi_accessible_is_a (obj,
1154 atspi_interface_streamable_content);
1156 g_warning ("Streamable content not implemented");
1162 * atspi_accessible_is_text:
1163 * @obj: a pointer to the #AtspiAccessible instance to query.
1165 * Query whether the specified #AtspiAccessible implements the
1166 * #AtspiText interface.
1168 * Returns: #TRUE if @obj implements the #AtspiText interface,
1172 atspi_accessible_is_text (AtspiAccessible *obj)
1174 return _atspi_accessible_is_a (obj,
1175 atspi_interface_text);
1179 * atspi_accessible_is_value:
1180 * @obj: a pointer to the #AtspiAccessible instance to query.
1182 * Query whether the specified #AtspiAccessible implements the
1183 * #AtspiValue interface.
1185 * Returns: #TRUE if @obj implements the #AtspiValue interface,
1189 atspi_accessible_is_value (AtspiAccessible *obj)
1191 return _atspi_accessible_is_a (obj,
1192 atspi_interface_value);
1196 * atspi_accessible_get_action: (rename-to atspi_accessible_get_action_iface)
1197 * @obj: a pointer to the #AtspiAccessible instance to query.
1199 * Gets the #AtspiAction interface for an #AtspiAccessible.
1201 * Returns: (transfer full): a pointer to an #AtspiAction interface
1202 * instance, or NULL if @obj does not implement #AtspiAction.
1204 * Deprecated: 2.10: Use atspi_accessible_get_action_iface instead.
1207 atspi_accessible_get_action (AtspiAccessible *accessible)
1209 return (_atspi_accessible_is_a (accessible, atspi_interface_action) ?
1210 g_object_ref (ATSPI_ACTION (accessible)) : NULL);
1214 * atspi_accessible_get_action_iface:
1215 * @obj: a pointer to the #AtspiAccessible instance to query.
1217 * Gets the #AtspiAction interface for an #AtspiAccessible.
1219 * Returns: (transfer full): a pointer to an #AtspiAction interface
1220 * instance, or NULL if @obj does not implement #AtspiAction.
1223 atspi_accessible_get_action_iface (AtspiAccessible *accessible)
1225 return (_atspi_accessible_is_a (accessible, atspi_interface_action) ?
1226 g_object_ref (ATSPI_ACTION (accessible)) : NULL);
1230 * atspi_accessible_get_collection: (rename-to atspi_accessible_get_collection_iface)
1231 * @obj: a pointer to the #AtspiAccessible instance to query.
1233 * Gets the #AtspiCollection interface for an #AtspiAccessible.
1235 * Returns: (transfer full): a pointer to an #AtspiCollection interface
1236 * instance, or NULL if @obj does not implement #AtspiCollection.
1238 * Deprecated: 2.10: Use atspi_accessible_get_collection_iface instead.
1241 atspi_accessible_get_collection (AtspiAccessible *accessible)
1243 return (_atspi_accessible_is_a (accessible, atspi_interface_collection) ?
1244 g_object_ref (ATSPI_COLLECTION (accessible)) : NULL);
1248 * atspi_accessible_get_collection_iface:
1249 * @obj: a pointer to the #AtspiAccessible instance to query.
1251 * Gets the #AtspiCollection interface for an #AtspiAccessible.
1253 * Returns: (transfer full): a pointer to an #AtspiCollection interface
1254 * instance, or NULL if @obj does not implement #AtspiCollection.
1257 atspi_accessible_get_collection_iface (AtspiAccessible *accessible)
1259 return (_atspi_accessible_is_a (accessible, atspi_interface_collection) ?
1260 g_object_ref (ATSPI_COLLECTION (accessible)) : NULL);
1264 * atspi_accessible_get_component: (rename-to atspi_accessible_get_component_iface)
1265 * @obj: a pointer to the #AtspiAccessible instance to query.
1267 * Gets the #AtspiComponent interface for an #AtspiAccessible.
1269 * Returns: (transfer full): a pointer to an #AtspiComponent interface
1270 * instance, or NULL if @obj does not implement #AtspiComponent.
1272 * Deprecated: 2.10: Use atspi_accessible_get_component_iface instead.
1275 atspi_accessible_get_component (AtspiAccessible *obj)
1277 return (_atspi_accessible_is_a (obj, atspi_interface_component) ?
1278 g_object_ref (ATSPI_COMPONENT (obj)) : NULL);
1282 * atspi_accessible_get_component_iface:
1283 * @obj: a pointer to the #AtspiAccessible instance to query.
1285 * Gets the #AtspiComponent interface for an #AtspiAccessible.
1287 * Returns: (transfer full): a pointer to an #AtspiComponent interface
1288 * instance, or NULL if @obj does not implement #AtspiComponent.
1291 atspi_accessible_get_component_iface (AtspiAccessible *obj)
1293 return (_atspi_accessible_is_a (obj, atspi_interface_component) ?
1294 g_object_ref (ATSPI_COMPONENT (obj)) : NULL);
1298 * atspi_accessible_get_document: (rename-to atspi_accessible_get_document_iface)
1299 * @obj: a pointer to the #AtspiAccessible instance to query.
1301 * Gets the #AtspiDocument interface for an #AtspiAccessible.
1303 * Returns: (transfer full): a pointer to an #AtspiDocument interface
1304 * instance, or NULL if @obj does not implement #AtspiDocument.
1306 * Deprecated: 2.10: Use atspi_accessible_get_document_iface instead.
1309 atspi_accessible_get_document (AtspiAccessible *accessible)
1311 return (_atspi_accessible_is_a (accessible, atspi_interface_document) ?
1312 g_object_ref (ATSPI_DOCUMENT (accessible)) : NULL);
1316 * atspi_accessible_get_document_iface:
1317 * @obj: a pointer to the #AtspiAccessible instance to query.
1319 * Gets the #AtspiDocument interface for an #AtspiAccessible.
1321 * Returns: (transfer full): a pointer to an #AtspiDocument interface
1322 * instance, or NULL if @obj does not implement #AtspiDocument.
1325 atspi_accessible_get_document_iface (AtspiAccessible *accessible)
1327 return (_atspi_accessible_is_a (accessible, atspi_interface_document) ?
1328 g_object_ref (ATSPI_DOCUMENT (accessible)) : NULL);
1332 * atspi_accessible_get_editable_text: (rename-to atspi_accessible_get_editable_text_iface)
1333 * @obj: a pointer to the #AtspiAccessible instance to query.
1335 * Gets the #AtspiEditableText interface for an #AtspiAccessible.
1337 * Returns: (transfer full): a pointer to an #AtspiEditableText interface
1338 * instance, or NULL if @obj does not implement #AtspiEditableText.
1340 * Deprecated: 2.10: Use atspi_accessible_get_editable_text_iface instead.
1343 atspi_accessible_get_editable_text (AtspiAccessible *accessible)
1345 return (_atspi_accessible_is_a (accessible, atspi_interface_editable_text) ?
1346 g_object_ref (ATSPI_EDITABLE_TEXT (accessible)) : NULL);
1350 * atspi_accessible_get_editable_text_iface:
1351 * @obj: a pointer to the #AtspiAccessible instance to query.
1353 * Gets the #AtspiEditableText interface for an #AtspiAccessible.
1355 * Returns: (transfer full): a pointer to an #AtspiEditableText interface
1356 * instance, or NULL if @obj does not implement #AtspiEditableText.
1359 atspi_accessible_get_editable_text_iface (AtspiAccessible *accessible)
1361 return (_atspi_accessible_is_a (accessible, atspi_interface_editable_text) ?
1362 g_object_ref (ATSPI_EDITABLE_TEXT (accessible)) : NULL);
1366 * atspi_accessible_get_hyperlink:
1367 * @obj: a pointer to the #AtspiAccessible object on which to operate.
1369 * Gets the #AtspiHyperlink interface for an #AtspiAccessible.
1371 * Returns: (transfer full): the #AtspiHyperlink object associated with
1372 * the given #AtspiAccessible, or NULL if not supported.
1375 atspi_accessible_get_hyperlink (AtspiAccessible *accessible)
1377 return (_atspi_accessible_is_a (accessible, atspi_interface_hyperlink) ?
1378 _atspi_hyperlink_new (accessible->parent.app, accessible->parent.path) : NULL);
1382 * atspi_accessible_get_hypertext: (rename-to atspi_accessible_get_hypertext_iface)
1383 * @obj: a pointer to the #AtspiAccessible instance to query.
1385 * Gets the #AtspiHypertext interface for an #AtspiAccessible.
1387 * Returns: (transfer full): a pointer to an #AtspiHypertext interface
1388 * instance, or NULL if @obj does not implement #AtspiHypertext.
1390 * Deprecated: 2.10: Use atspi_accessible_get_hypertext_iface instead.
1393 atspi_accessible_get_hypertext (AtspiAccessible *accessible)
1395 return (_atspi_accessible_is_a (accessible, atspi_interface_hypertext) ?
1396 g_object_ref (ATSPI_HYPERTEXT (accessible)) : NULL);
1400 * atspi_accessible_get_hypertext_iface:
1401 * @obj: a pointer to the #AtspiAccessible instance to query.
1403 * Gets the #AtspiHypertext interface for an #AtspiAccessible.
1405 * Returns: (transfer full): a pointer to an #AtspiHypertext interface
1406 * instance, or NULL if @obj does not implement #AtspiHypertext.
1409 atspi_accessible_get_hypertext_iface (AtspiAccessible *accessible)
1411 return (_atspi_accessible_is_a (accessible, atspi_interface_hypertext) ?
1412 g_object_ref (ATSPI_HYPERTEXT (accessible)) : NULL);
1416 * atspi_accessible_get_image: (rename-to atspi_accessible_get_image_iface)
1417 * @obj: a pointer to the #AtspiAccessible instance to query.
1419 * Gets the #AtspiImage interface for an #AtspiAccessible.
1421 * Returns: (transfer full): a pointer to an #AtspiImage interface instance, or
1422 * NULL if @obj does not implement #AtspiImage.
1424 * Deprecated: 2.10: Use atspi_accessible_get_image_iface instead.
1427 atspi_accessible_get_image (AtspiAccessible *accessible)
1429 return (_atspi_accessible_is_a (accessible, atspi_interface_image) ?
1430 g_object_ref (ATSPI_IMAGE (accessible)) : NULL);
1434 * atspi_accessible_get_image_iface:
1435 * @obj: a pointer to the #AtspiAccessible instance to query.
1437 * Gets the #AtspiImage interface for an #AtspiAccessible.
1439 * Returns: (transfer full): a pointer to an #AtspiImage interface instance, or
1440 * NULL if @obj does not implement #AtspiImage.
1443 atspi_accessible_get_image_iface (AtspiAccessible *accessible)
1445 return (_atspi_accessible_is_a (accessible, atspi_interface_image) ?
1446 g_object_ref (ATSPI_IMAGE (accessible)) : NULL);
1450 * atspi_accessible_get_selection: (rename-to atspi_accessible_get_selection_iface)
1451 * @obj: a pointer to the #AtspiAccessible instance to query.
1453 * Gets the #AtspiSelection interface for an #AtspiAccessible.
1455 * Returns: (transfer full): a pointer to an #AtspiSelection interface
1456 * instance, or NULL if @obj does not implement #AtspiSelection.
1458 * Deprecated: 2.10: Use atspi_accessible_get_selection_iface instead.
1461 atspi_accessible_get_selection (AtspiAccessible *accessible)
1463 return (_atspi_accessible_is_a (accessible, atspi_interface_selection) ?
1464 g_object_ref (ATSPI_SELECTION (accessible)) : NULL);
1468 * atspi_accessible_get_selection_iface:
1469 * @obj: a pointer to the #AtspiAccessible instance to query.
1471 * Gets the #AtspiSelection interface for an #AtspiAccessible.
1473 * Returns: (transfer full): a pointer to an #AtspiSelection interface
1474 * instance, or NULL if @obj does not implement #AtspiSelection.
1477 atspi_accessible_get_selection_iface (AtspiAccessible *accessible)
1479 return (_atspi_accessible_is_a (accessible, atspi_interface_selection) ?
1480 g_object_ref (ATSPI_SELECTION (accessible)) : NULL);
1485 * atspi_accessible_get_streamable_content:
1486 * @obj: a pointer to the #AtspiAccessible instance to query.
1488 * Gets the #AtspiStreamableContent interface for an #AtspiAccessible.
1490 * Returns: (transfer full): a pointer to an #AtspiStreamableContent interface
1491 * instance, or NULL if @obj does not implement #AtspiStreamableContent.
1493 AtspiStreamableContent *
1494 atspi_accessible_get_streamable_content (AtspiAccessible *accessible)
1496 return (_atspi_accessible_is_a (accessible, atspi_interface_streamable_content) ?
1502 * atspi_accessible_get_table: (rename-to atspi_accessible_get_table_iface)
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 #AtspiTable interface instance, or
1508 * NULL if @obj does not implement #AtspiTable.
1510 * Deprecated: 2.10: Use atspi_accessible_get_table_iface instead.
1513 atspi_accessible_get_table (AtspiAccessible *obj)
1515 return (_atspi_accessible_is_a (obj, atspi_interface_table) ?
1516 g_object_ref (ATSPI_TABLE (obj)) : NULL);
1520 * atspi_accessible_get_table_iface:
1521 * @obj: a pointer to the #AtspiAccessible instance to query.
1523 * Gets the #AtspiTable interface for an #AtspiAccessible.
1525 * Returns: (transfer full): a pointer to an #AtspiTable interface instance, or
1526 * NULL if @obj does not implement #AtspiTable.
1529 atspi_accessible_get_table_iface (AtspiAccessible *obj)
1531 return (_atspi_accessible_is_a (obj, atspi_interface_table) ?
1532 g_object_ref (ATSPI_TABLE (obj)) : NULL);
1536 * atspi_accessible_get_table_cell:
1537 * @obj: a pointer to the #AtspiAccessible instance to query.
1539 * Gets the #AtspiTableCell interface for an #AtspiAccessible.
1541 * Returns: (transfer full): a pointer to an #AtspiTableCell interface instance,
1542 * or NULL if @obj does not implement #AtspiTable.
1545 atspi_accessible_get_table_cell (AtspiAccessible *obj)
1547 return (_atspi_accessible_is_a (obj, atspi_interface_table_cell) ?
1548 g_object_ref (ATSPI_TABLE_CELL (obj)) : NULL);
1552 * atspi_accessible_get_text: (rename-to atspi_accessible_get_text_iface)
1553 * @obj: a pointer to the #AtspiAccessible instance to query.
1555 * Gets the #AtspiTable interface for an #AtspiAccessible.
1557 * Returns: (transfer full): a pointer to an #AtspiText interface instance, or
1558 * NULL if @obj does not implement #AtspiText.
1560 * Deprecated: 2.10: Use atspi_accessible_get_text_iface instead.
1563 atspi_accessible_get_text (AtspiAccessible *obj)
1565 return (_atspi_accessible_is_a (obj, atspi_interface_text) ?
1566 g_object_ref (ATSPI_TEXT (obj)) : NULL);
1570 * atspi_accessible_get_text_iface:
1571 * @obj: a pointer to the #AtspiAccessible instance to query.
1573 * Gets the #AtspiTable interface for an #AtspiAccessible.
1575 * Returns: (transfer full): a pointer to an #AtspiText interface instance, or
1576 * NULL if @obj does not implement #AtspiText.
1579 atspi_accessible_get_text_iface (AtspiAccessible *obj)
1581 return (_atspi_accessible_is_a (obj, atspi_interface_text) ?
1582 g_object_ref (ATSPI_TEXT (obj)) : NULL);
1586 * atspi_accessible_get_value: (rename-to atspi_accessible_get_value_iface)
1587 * @obj: a pointer to the #AtspiAccessible instance to query.
1589 * Gets the #AtspiTable interface for an #AtspiAccessible.
1591 * Returns: (transfer full): a pointer to an #AtspiValue interface instance, or
1592 * NULL if @obj does not implement #AtspiValue.
1594 * Deprecated: 2.10: Use atspi_accessible_get_value_iface instead.
1597 atspi_accessible_get_value (AtspiAccessible *accessible)
1599 return (_atspi_accessible_is_a (accessible, atspi_interface_value) ?
1600 g_object_ref (ATSPI_VALUE (accessible)) : NULL);
1604 * atspi_accessible_get_value_iface:
1605 * @obj: a pointer to the #AtspiAccessible instance to query.
1607 * Gets the #AtspiTable interface for an #AtspiAccessible.
1609 * Returns: (transfer full): a pointer to an #AtspiValue interface instance, or
1610 * NULL if @obj does not implement #AtspiValue.
1613 atspi_accessible_get_value_iface (AtspiAccessible *accessible)
1615 return (_atspi_accessible_is_a (accessible, atspi_interface_value) ?
1616 g_object_ref (ATSPI_VALUE (accessible)) : NULL);
1620 append_const_val (GArray *array, const gchar *val)
1622 gchar *dup = g_strdup (val);
1625 g_array_append_val (array, dup);
1629 * atspi_accessible_get_interfaces:
1630 * @obj: The #AtspiAccessible to query.
1632 * A set of pointers to all interfaces supported by an #AtspiAccessible.
1634 * Returns: (element-type gchar*) (transfer full): A #GArray of strings
1635 * describing the interfaces supported by the object. Interfaces are
1636 * denoted in short-hand (i.e. "Component", "Text" etc.).
1639 atspi_accessible_get_interfaces (AtspiAccessible *obj)
1641 GArray *ret = g_array_new (TRUE, TRUE, sizeof (gchar *));
1643 g_return_val_if_fail (obj != NULL, NULL);
1645 append_const_val (ret, "Accessible");
1646 if (atspi_accessible_is_action (obj))
1647 append_const_val (ret, "Action");
1648 if (atspi_accessible_is_collection (obj))
1649 append_const_val (ret, "Collection");
1650 if (atspi_accessible_is_component (obj))
1651 append_const_val (ret, "Component");
1652 if (atspi_accessible_is_document (obj))
1653 append_const_val (ret, "Document");
1654 if (atspi_accessible_is_editable_text (obj))
1655 append_const_val (ret, "EditableText");
1656 if (atspi_accessible_is_hypertext (obj))
1657 append_const_val (ret, "Hypertext");
1658 if (atspi_accessible_is_hyperlink (obj))
1659 append_const_val (ret, "Hyperlink");
1660 if (atspi_accessible_is_image (obj))
1661 append_const_val (ret, "Image");
1662 if (atspi_accessible_is_selection (obj))
1663 append_const_val (ret, "Selection");
1664 if (atspi_accessible_is_table (obj))
1665 append_const_val (ret, "Table");
1666 if (atspi_accessible_is_table_cell (obj))
1667 append_const_val (ret, "TableCell");
1668 if (atspi_accessible_is_text (obj))
1669 append_const_val (ret, "Text");
1670 if (atspi_accessible_is_value (obj))
1671 append_const_val (ret, "Value");
1677 _atspi_accessible_new (AtspiApplication *app, const gchar *path)
1679 AtspiAccessible *accessible;
1681 accessible = g_object_new (ATSPI_TYPE_ACCESSIBLE, NULL);
1682 g_return_val_if_fail (accessible != NULL, NULL);
1684 accessible->parent.app = g_object_ref (app);
1685 accessible->parent.path = g_strdup (path);
1691 * atspi_accessible_set_cache_mask:
1692 * @accessible: The #AtspiAccessible to operate on. Must be the desktop or
1693 * the root of an application.
1694 * @mask: An #AtspiCache specifying a bit mask of the types of data to cache.
1696 * Sets the type of data to cache for accessibles.
1697 * If this is not set for an application or is reset to ATSPI_CACHE_UNDEFINED,
1698 * then the desktop's cache flag will be used.
1699 * If the desktop's cache flag is also undefined, then all possible data will
1701 * This function is intended to work around bugs in toolkits where the proper
1702 * events are not raised / to aid in testing for such bugs.
1705 atspi_accessible_set_cache_mask (AtspiAccessible *accessible, AtspiCache mask)
1707 g_return_if_fail (accessible != NULL);
1708 g_return_if_fail (accessible->parent.app != NULL);
1709 g_return_if_fail (accessible == accessible->parent.app->root);
1710 accessible->parent.app->cache = mask;
1711 enable_caching = TRUE;
1715 * atspi_accessible_clear_cache:
1716 * @obj: The #AtspiAccessible whose cache to clear.
1718 * Clears the cached information for the given accessible and all of its
1722 atspi_accessible_clear_cache (AtspiAccessible *obj)
1728 obj->cached_properties = ATSPI_CACHE_NONE;
1730 for (i = 0; i < obj->children->len; i++)
1731 atspi_accessible_clear_cache (g_ptr_array_index (obj->children, i));
1736 * atspi_accessible_get_process_id:
1737 * @accessible: The #AtspiAccessible to query.
1738 * @error: a pointer to a %NULL #GError pointer
1740 * Returns the process id associated with the given accessible. Mainly
1741 * added for debugging; it is a shortcut to explicitly querying the
1742 * accessible's app->bus_name and then calling GetConnectionUnixProcessID.
1744 * Returns: The process ID or undetermined value if @error is set.
1747 atspi_accessible_get_process_id (AtspiAccessible *accessible, GError **error)
1749 DBusMessage *message, *reply;
1750 DBusConnection *bus = _atspi_bus ();
1751 dbus_uint32_t pid = -1;
1754 if (!accessible->parent.app || !accessible->parent.app->bus_name)
1756 g_set_error_literal(error, ATSPI_ERROR, ATSPI_ERROR_IPC, "Process is defunct");
1760 message = dbus_message_new_method_call ("org.freedesktop.DBus",
1761 "/org/freedesktop/DBus",
1762 "org.freedesktop.DBus",
1763 "GetConnectionUnixProcessID");
1764 dbus_message_append_args (message, DBUS_TYPE_STRING,
1765 &accessible->parent.app->bus_name,
1767 dbus_error_init (&d_error);
1768 reply = dbus_connection_send_with_reply_and_block (bus, message, -1, &d_error);
1769 dbus_message_unref (message);
1772 if (!strcmp (dbus_message_get_signature (reply), "u"))
1773 dbus_message_get_args (reply, NULL, DBUS_TYPE_UINT32, &pid, DBUS_TYPE_INVALID);
1774 dbus_message_unref (reply);
1776 if (dbus_error_is_set (&d_error))
1778 g_set_error_literal(error, ATSPI_ERROR, ATSPI_ERROR_IPC, "Process is defunct");
1779 dbus_error_free (&d_error);
1785 _atspi_accessible_get_cache_mask (AtspiAccessible *accessible)
1789 if (!accessible->parent.app)
1790 return ATSPI_CACHE_NONE;
1792 mask = accessible->parent.app->cache;
1793 if (mask == ATSPI_CACHE_UNDEFINED &&
1794 accessible->parent.app->root &&
1795 accessible->parent.app->root->accessible_parent)
1797 AtspiAccessible *desktop = atspi_get_desktop (0);
1798 mask = desktop->parent.app->cache;
1799 g_object_unref (desktop);
1802 if (mask == ATSPI_CACHE_UNDEFINED)
1803 mask = ATSPI_CACHE_DEFAULT;
1809 _atspi_accessible_test_cache (AtspiAccessible *accessible, AtspiCache flag)
1811 AtspiCache mask = _atspi_accessible_get_cache_mask (accessible);
1812 AtspiCache result = accessible->cached_properties & mask & flag;
1813 if (accessible->states && atspi_state_set_contains (accessible->states, ATSPI_STATE_TRANSIENT))
1815 return (result != 0 && (atspi_main_loop || enable_caching ||
1816 flag == ATSPI_CACHE_INTERFACES) &&
1821 _atspi_accessible_add_cache (AtspiAccessible *accessible, AtspiCache flag)
1823 AtspiCache mask = _atspi_accessible_get_cache_mask (accessible);
1825 accessible->cached_properties |= flag & mask;
1829 * atspi_accessible_get_locale:
1830 * @accessible: an #AtspiAccessible
1832 * Gets a UTF-8 string indicating the POSIX-style LC_MESSAGES locale
1837 * Returns: a UTF-8 string indicating the POSIX-style LC_MESSAGES
1838 * locale of @accessible.
1841 atspi_accessible_get_object_locale (AtspiAccessible *accessible, GError **error)
1845 g_return_val_if_fail (accessible != NULL, NULL);
1847 locale = g_object_get_qdata (G_OBJECT (accessible), quark_locale);
1850 if (!_atspi_dbus_get_property (accessible, atspi_interface_accessible,
1851 "Locale", error, "s", &locale))
1854 g_object_set_qdata_full (G_OBJECT (accessible), quark_locale, locale,
1861 * atspi_accessible_get_accessible_id:
1862 * @obj: an #AtspiAccessible
1864 * Gets the accessible id of the accessible. This is not meant to be presented
1865 * to the user, but to be an id which is stable over application development.
1866 * Typically, this is the gtkbuilder id.
1870 * Returns: a character string representing the accessible id of the
1871 * #AtspiAccessible object or NULL on exception.
1874 atspi_accessible_get_accessible_id (AtspiAccessible *obj, GError **error)
1876 gchar *accessible_id;
1878 g_return_val_if_fail (obj != NULL, NULL);
1880 if (!_atspi_dbus_get_property (obj, atspi_interface_accessible,
1881 "AccessibleId", error, "s", &accessible_id))
1884 return accessible_id;
1888 free_value (gpointer data)
1890 GValue *value = data;
1892 g_value_unset (value);
1897 _atspi_accessible_ref_cache (AtspiAccessible *accessible)
1899 AtspiAccessiblePrivate *priv = accessible->priv;
1901 priv->cache_ref_count++;
1903 return g_hash_table_ref (priv->cache);
1904 priv->cache = g_hash_table_new_full (g_str_hash, g_str_equal, g_free,
1910 _atspi_accessible_unref_cache (AtspiAccessible *accessible)
1912 AtspiAccessiblePrivate *priv = accessible->priv;
1916 g_hash_table_unref (priv->cache);
1917 if (--priv->cache_ref_count == 0)