2 * AT-SPI - Assistive Technology Service Provider Interface
3 * (Gnome Accessibility Project; http://developer.gnome.org/projects/gap)
5 * Copyright 2001, 2002 Sun Microsystems Inc.,
6 * Copyright 2001, 2002 Ximian, Inc.
7 * Copyright 2010, 2011 Novell, Inc.
9 * This library is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Library General Public
11 * License as published by the Free Software Foundation; either
12 * version 2 of the License, or (at your option) any later version.
14 * This library is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * Library General Public License for more details.
19 * You should have received a copy of the GNU Library General Public
20 * License along with this library; if not, write to the
21 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
22 * Boston, MA 02111-1307, USA.
25 #include "atspi-private.h"
26 #include "atspi-accessible-private.h"
29 static gboolean enable_caching = FALSE;
30 static guint quark_locale;
33 atspi_action_interface_init (AtspiAction *action)
38 atspi_collection_interface_init (AtspiCollection *component)
43 atspi_component_interface_init (AtspiComponent *component)
48 atspi_document_interface_init (AtspiDocument *document)
53 atspi_editable_text_interface_init (AtspiEditableText *editable_text)
58 atspi_hypertext_interface_init (AtspiHypertext *hypertext)
63 atspi_image_interface_init (AtspiImage *image)
68 atspi_selection_interface_init (AtspiSelection *selection)
73 atspi_table_interface_init (AtspiTable *table)
78 atspi_table_cell_interface_init (AtspiTableCell *cell)
83 atspi_text_interface_init (AtspiText *text)
88 atspi_value_interface_init (AtspiValue *value)
92 G_DEFINE_TYPE_WITH_CODE (AtspiAccessible, atspi_accessible, ATSPI_TYPE_OBJECT,
93 G_ADD_PRIVATE (AtspiAccessible)
94 G_IMPLEMENT_INTERFACE (ATSPI_TYPE_ACTION, atspi_action_interface_init)
95 G_IMPLEMENT_INTERFACE (ATSPI_TYPE_COLLECTION, atspi_collection_interface_init)
96 G_IMPLEMENT_INTERFACE (ATSPI_TYPE_COMPONENT, atspi_component_interface_init)
97 G_IMPLEMENT_INTERFACE (ATSPI_TYPE_DOCUMENT, atspi_document_interface_init)
98 G_IMPLEMENT_INTERFACE (ATSPI_TYPE_EDITABLE_TEXT, atspi_editable_text_interface_init)
99 G_IMPLEMENT_INTERFACE (ATSPI_TYPE_HYPERTEXT, atspi_hypertext_interface_init)
100 G_IMPLEMENT_INTERFACE (ATSPI_TYPE_IMAGE, atspi_image_interface_init)
101 G_IMPLEMENT_INTERFACE (ATSPI_TYPE_SELECTION, atspi_selection_interface_init)
102 G_IMPLEMENT_INTERFACE (ATSPI_TYPE_TABLE, atspi_table_interface_init)
103 G_IMPLEMENT_INTERFACE (ATSPI_TYPE_TABLE_CELL, atspi_table_cell_interface_init)
104 G_IMPLEMENT_INTERFACE (ATSPI_TYPE_TEXT, atspi_text_interface_init)
105 G_IMPLEMENT_INTERFACE (ATSPI_TYPE_VALUE, atspi_value_interface_init))
107 #ifdef DEBUG_REF_COUNTS
108 static gint accessible_count = 0;
112 atspi_accessible_init (AtspiAccessible *accessible)
114 #ifdef DEBUG_REF_COUNTS
116 g_hash_table_insert (_atspi_get_live_refs (), accessible, NULL);
117 g_print("at-spi: init: %d objects\n", accessible_count);
120 accessible->priv = atspi_accessible_get_instance_private (accessible);
124 atspi_accessible_dispose (GObject *object)
126 AtspiAccessible *accessible = ATSPI_ACCESSIBLE (object);
128 AtspiAccessible *parent;
132 /* TODO: Only fire if object not already marked defunct */
133 memset (&e, 0, sizeof (e));
134 e.type = "object:state-changed:defunct";
135 e.source = accessible;
138 _atspi_send_event (&e);
140 if (accessible->states)
142 g_object_unref (accessible->states);
143 accessible->states = NULL;
146 parent = accessible->accessible_parent;
147 if (parent && parent->children)
149 GList*ls = g_list_find (parent->children, accessible);
152 gboolean replace = (ls == parent->children);
153 ls = g_list_remove (ls, accessible);
155 parent->children = ls;
156 g_object_unref (object);
162 g_object_unref (parent);
163 accessible->accessible_parent = NULL;
166 children = accessible->children;
167 accessible->children = NULL;
168 for (l = children; l; l = l->next)
170 AtspiAccessible *child = l->data;
171 if (child && child->accessible_parent == accessible)
173 g_object_unref (accessible);
174 child->accessible_parent = NULL;
176 g_object_unref (child);
178 g_list_free (children);
180 G_OBJECT_CLASS (atspi_accessible_parent_class) ->dispose (object);
184 atspi_accessible_finalize (GObject *object)
186 AtspiAccessible *accessible = ATSPI_ACCESSIBLE (object);
188 g_free (accessible->description);
189 g_free (accessible->name);
190 if (accessible->attributes)
191 g_hash_table_unref (accessible->attributes);
193 if (accessible->priv->cache)
194 g_hash_table_destroy (accessible->priv->cache);
196 #ifdef DEBUG_REF_COUNTS
198 g_hash_table_remove (_atspi_get_live_refs (), accessible);
199 g_print ("at-spi: finalize: %d objects\n", accessible_count);
202 G_OBJECT_CLASS (atspi_accessible_parent_class)
207 atspi_accessible_class_init (AtspiAccessibleClass *klass)
209 GObjectClass *object_class = G_OBJECT_CLASS (klass);
211 object_class->dispose = atspi_accessible_dispose;
212 object_class->finalize = atspi_accessible_finalize;
214 quark_locale = g_quark_from_string ("accessible-locale");
218 * atspi_accessible_get_name:
219 * @obj: a pointer to the #AtspiAccessible object on which to operate.
221 * Gets the name of an #AtspiAccessible object.
223 * Returns: a UTF-8 string indicating the name of the #AtspiAccessible object
224 * or NULL on exception.
227 atspi_accessible_get_name (AtspiAccessible *obj, GError **error)
229 g_return_val_if_fail (obj != NULL, g_strdup (""));
230 if (!_atspi_accessible_test_cache (obj, ATSPI_CACHE_NAME))
232 if (!_atspi_dbus_get_property (obj, atspi_interface_accessible, "Name", error,
234 return g_strdup ("");
235 _atspi_accessible_add_cache (obj, ATSPI_CACHE_NAME);
237 return g_strdup (obj->name);
242 * atspi_accessible_get_unique_id:
243 * @obj: a pointer to the #AtspiAccessible object on which to operate.
245 * Gets the identificator, uniquely identifying object, or NULL if an error occured.
247 * Returns: a UTF-8 string describing the #AtspiAccessible object
248 * or NULL on exception or NULL object passed.
251 atspi_accessible_get_unique_id(AtspiAccessible *obj, GError **error)
254 g_set_error(error, ATSPI_ERROR, ATSPI_ERROR_IPC, "argument is null");
259 gchar *bus_name = atspi_accessible_get_bus_name(obj, error);
260 if (bus_name && bus_name[0]) {
261 gchar *path = atspi_accessible_get_path(obj, error);
263 id = g_strdup_printf("%s:%s", bus_name, path);
265 g_set_error(error, ATSPI_ERROR, ATSPI_ERROR_IPC, "failed to get path");
269 g_set_error(error, ATSPI_ERROR, ATSPI_ERROR_IPC, "failed to get bus name");
275 * atspi_accessible_get_bus_name:
276 * @obj: a pointer to the #AtspiAccessible object on which to operate.
278 * Gets the bus name, where object belongs.
280 * Returns: a UTF-8 string describing the #AtspiAccessible object's
281 * bus name or empty string on exception or NULL object passed.
284 atspi_accessible_get_bus_name(AtspiAccessible *obj, GError **error)
286 if (!obj || !obj->parent.app)
288 return g_strdup (obj->parent.app->bus_name);
292 * atspi_accessible_get_path:
293 * @obj: a pointer to the #AtspiAccessible object on which to operate.
295 * Gets the path, uniquely identifying object over its bus name.
297 * Returns: a UTF-8 string describing the #AtspiAccessible object
298 * or empty string on exception or NULL object passed.
301 atspi_accessible_get_path(AtspiAccessible *obj, GError **error)
303 static const char *prefix = "/org/a11y/atspi/accessible/";
304 static int prefix_len = 27;
308 AtspiObject *o = ATSPI_OBJECT (obj);
311 if (strncmp(o->path, prefix, prefix_len) == 0)
312 return g_strdup(o->path + prefix_len);
313 return g_strdup (o->path);
317 * atspi_accessible_get_navigable_at_point:
318 * @root: a pointer to the #AtspiAccessible to start search from.
319 * @x: a #gint specifying the x coordinate of the point in question.
320 * @y: a #gint specifying the y coordinate of the point in question.
321 * @ctype: the coordinate system of the point (@x, @y)
322 * (e.g. ATSPI_COORD_TYPE_WINDOW, ATSPI_COORD_TYPE_SCREEN).
324 * Finds the accessible element closest to user (highest in z-order), at a given coordinate within an #AtspiAccessible.
325 * This should be the element, that should be picked, when doing mouse click or finger tap at given coordinates.
327 * Returns: (nullable) (transfer full): a pointer to an
328 * #AtspiAccessible descendant (of any depth) of the specified component which
329 * contains the point (@x, @y), or NULL if no descendant contains
333 atspi_accessible_get_navigable_at_point (AtspiAccessible *root,
336 AtspiCoordType ctype, GError **error)
338 dbus_int32_t d_x = x, d_y = y;
339 dbus_uint32_t d_ctype = ctype;
341 AtspiAccessible *return_value = NULL;
342 unsigned char recurse = 0;
344 g_return_val_if_fail (root != NULL, FALSE);
346 reply = _atspi_dbus_call_partial (root, atspi_interface_accessible, "GetNavigableAtPoint", error, "iiu", d_x, d_y, d_ctype);
348 AtspiAccessible *tmp = _atspi_dbus_return_accessible_and_recurse_info_from_message (reply, &recurse);
351 g_object_unref(return_value);
352 return_value = root = tmp;
358 * atspi_accessible_get_description:
359 * @obj: a pointer to the #AtspiAccessible object on which to operate.
361 * Gets the description of an #AtspiAccessible object.
363 * Returns: a UTF-8 string describing the #AtspiAccessible object
364 * or NULL on exception.
367 atspi_accessible_get_description (AtspiAccessible *obj, GError **error)
369 g_return_val_if_fail (obj != NULL, g_strdup (""));
371 if (!_atspi_accessible_test_cache (obj, ATSPI_CACHE_DESCRIPTION))
373 if (!_atspi_dbus_get_property (obj, atspi_interface_accessible,
374 "Description", error, "s",
376 return g_strdup ("");
377 _atspi_accessible_add_cache (obj, ATSPI_CACHE_DESCRIPTION);
379 return g_strdup (obj->description);
382 const char *str_parent = "Parent";
385 * atspi_accessible_get_parent:
386 * @obj: a pointer to the #AtspiAccessible object to query.
388 * Gets an #AtspiAccessible object's parent container.
390 * Returns: (nullable) (transfer full): a pointer to the
391 * #AtspiAccessible object which contains the given
392 * #AtspiAccessible instance, or NULL if the @obj has no
397 atspi_accessible_get_parent (AtspiAccessible *obj, GError **error)
399 g_return_val_if_fail (obj != NULL, NULL);
401 if (obj->parent.app &&
402 !_atspi_accessible_test_cache (obj, ATSPI_CACHE_PARENT))
404 DBusMessage *message, *reply;
405 DBusMessageIter iter, iter_variant;
406 message = dbus_message_new_method_call (obj->parent.app->bus_name,
408 DBUS_INTERFACE_PROPERTIES, "Get");
411 dbus_message_append_args (message, DBUS_TYPE_STRING, &atspi_interface_accessible,
412 DBUS_TYPE_STRING, &str_parent,
414 reply = _atspi_dbus_send_with_reply_and_block (message, error);
417 if (strcmp (dbus_message_get_signature (reply), "v") != 0)
419 dbus_message_unref (reply);
422 dbus_message_iter_init (reply, &iter);
423 dbus_message_iter_recurse (&iter, &iter_variant);
424 obj->accessible_parent = _atspi_dbus_return_accessible_from_iter (&iter_variant);
425 dbus_message_unref (reply);
426 _atspi_accessible_add_cache (obj, ATSPI_CACHE_PARENT);
428 if (!obj->accessible_parent)
430 return g_object_ref (obj->accessible_parent);
434 * atspi_accessible_get_child_count:
435 * @obj: a pointer to the #AtspiAccessible object on which to operate.
437 * Gets the number of children contained by an #AtspiAccessible object.
439 * Returns: a #long indicating the number of #AtspiAccessible children
440 * contained by an #AtspiAccessible object or -1 on exception.
444 atspi_accessible_get_child_count (AtspiAccessible *obj, GError **error)
446 g_return_val_if_fail (obj != NULL, -1);
448 if (!_atspi_accessible_test_cache (obj, ATSPI_CACHE_CHILDREN))
451 if (!_atspi_dbus_get_property (obj, atspi_interface_accessible,
452 "ChildCount", error, "i", &ret))
457 return g_list_length (obj->children);
461 * atspi_accessible_get_child_at_index:
462 * @obj: a pointer to the #AtspiAccessible object on which to operate.
463 * @child_index: a #long indicating which child is specified.
465 * Gets the #AtspiAccessible child of an #AtspiAccessible object at a given index.
467 * Returns: (transfer full): a pointer to the #AtspiAccessible child object at
468 * index @child_index or NULL on exception.
471 atspi_accessible_get_child_at_index (AtspiAccessible *obj,
475 AtspiAccessible *child;
477 g_return_val_if_fail (obj != NULL, NULL);
479 if (!_atspi_accessible_test_cache (obj, ATSPI_CACHE_CHILDREN))
482 reply = _atspi_dbus_call_partial (obj, atspi_interface_accessible,
483 "GetChildAtIndex", error, "i",
485 return _atspi_dbus_return_accessible_from_message (reply);
488 child = g_list_nth_data (obj->children, child_index);
491 return g_object_ref (child);
495 * atspi_accessible_get_index_in_parent:
496 * @obj: a pointer to the #AtspiAccessible object on which to operate.
498 * Gets the index of an #AtspiAccessible object within its parent's
499 * #AtspiAccessible children list.
501 * Returns: a #glong indicating the index of the #AtspiAccessible object
503 * or -1 if @obj has no containing parent or on exception.
506 atspi_accessible_get_index_in_parent (AtspiAccessible *obj, GError **error)
511 g_return_val_if_fail (obj != NULL, -1);
512 if (_atspi_accessible_test_cache (obj, ATSPI_CACHE_PARENT) &&
513 !obj->accessible_parent)
515 if (!obj->accessible_parent ||
516 !_atspi_accessible_test_cache (obj->accessible_parent,
517 ATSPI_CACHE_CHILDREN))
519 dbus_int32_t ret = -1;
520 _atspi_dbus_call (obj, atspi_interface_accessible,
521 "GetIndexInParent", NULL, "=>i", &ret);
525 l = obj->accessible_parent->children;
528 if (l->data == obj) return i;
539 } Accessibility_Relation;
542 * atspi_accessible_get_relation_set:
543 * @obj: a pointer to the #AtspiAccessible object on which to operate.
545 * Gets the set of #AtspiRelation objects which describes this #AtspiAccessible object's
546 * relationships with other #AtspiAccessible objects.
548 * Returns: (element-type AtspiRelation*) (transfer full): a #GArray of
549 * #AtspiRelation pointers or NULL on exception.
552 atspi_accessible_get_relation_set (AtspiAccessible *obj, GError **error)
555 DBusMessageIter iter, iter_array;
558 g_return_val_if_fail (obj != NULL, NULL);
560 reply = _atspi_dbus_call_partial (obj, atspi_interface_accessible, "GetRelationSet", error, "");
563 _ATSPI_DBUS_CHECK_SIG (reply, "a(ua(so))", error, NULL);
565 ret = g_array_new (TRUE, TRUE, sizeof (AtspiRelation *));
566 dbus_message_iter_init (reply, &iter);
567 dbus_message_iter_recurse (&iter, &iter_array);
568 while (dbus_message_iter_get_arg_type (&iter_array) != DBUS_TYPE_INVALID)
570 AtspiRelation *relation;
571 relation = _atspi_relation_new_from_iter (&iter_array);
572 ret = g_array_append_val (ret, relation);
573 dbus_message_iter_next (&iter_array);
575 dbus_message_unref (reply);
580 * atspi_accessible_get_role:
581 * @obj: a pointer to the #AtspiAccessible object on which to operate.
583 * Gets the UI role played by an #AtspiAccessible object.
584 * This role's name can be obtained via atspi_accessible_get_role_name ().
586 * Returns: the #AtspiRole of an #AtspiAccessible object.
590 atspi_accessible_get_role (AtspiAccessible *obj, GError **error)
592 g_return_val_if_fail (obj != NULL, ATSPI_ROLE_INVALID);
594 if (!_atspi_accessible_test_cache (obj, ATSPI_CACHE_ROLE))
597 /* TODO: Make this a property */
598 if (_atspi_dbus_call (obj, atspi_interface_accessible, "GetRole", error, "=>u", &role))
601 _atspi_accessible_add_cache (obj, ATSPI_CACHE_ROLE);
608 * atspi_accessible_get_role_name:
609 * @obj: a pointer to the #AtspiAccessible object on which to operate.
611 * Gets a UTF-8 string corresponding to the name of the role played by an object.
612 * This method will return useful values for roles that fall outside the
613 * enumeration used in atspi_accessible_get_role ().
615 * Returns: a UTF-8 string specifying the type of UI role played by an
616 * #AtspiAccessible object.
620 atspi_accessible_get_role_name (AtspiAccessible *obj, GError **error)
622 gchar *retval = NULL;
625 g_return_val_if_fail (obj != NULL, NULL);
627 role = atspi_accessible_get_role (obj, error);
628 if (role >= 0 && role < ATSPI_ROLE_COUNT && role != ATSPI_ROLE_EXTENDED)
629 return atspi_role_get_name (role);
631 _atspi_dbus_call (obj, atspi_interface_accessible, "GetRoleName", error, "=>s", &retval);
634 retval = g_strdup ("");
640 * atspi_accessible_get_localized_role_name:
641 * @obj: a pointer to the #AtspiAccessible object on which to operate.
643 * Gets a UTF-8 string corresponding to the name of the role played by an
644 * object, translated to the current locale.
645 * This method will return useful values for roles that fall outside the
646 * enumeration used in atspi_accessible_getRole ().
648 * Returns: a localized, UTF-8 string specifying the type of UI role played
649 * by an #AtspiAccessible object.
653 atspi_accessible_get_localized_role_name (AtspiAccessible *obj, GError **error)
657 g_return_val_if_fail (obj != NULL, NULL);
659 _atspi_dbus_call (obj, atspi_interface_accessible, "GetLocalizedRoleName", error, "=>s", &retval);
662 return g_strdup ("");
667 static AtspiStateSet *
670 AtspiStateSet *set = atspi_state_set_new (NULL);
671 atspi_state_set_add (set, ATSPI_STATE_DEFUNCT);
676 * atspi_accessible_get_state_set:
677 * @obj: a pointer to the #AtspiAccessible object on which to operate.
679 * Gets the states currently held by an object.
681 * Returns: (transfer full): a pointer to an #AtspiStateSet representing an
682 * object's current state set.
685 atspi_accessible_get_state_set (AtspiAccessible *obj)
687 /* TODO: Should take a GError **, but would be an API break */
688 if (!obj->parent.app || !obj->parent.app->bus)
689 return defunct_set ();
691 if (!_atspi_accessible_test_cache (obj, ATSPI_CACHE_STATES))
694 DBusMessageIter iter;
695 reply = _atspi_dbus_call_partial (obj, atspi_interface_accessible,
696 "GetState", NULL, "");
697 _ATSPI_DBUS_CHECK_SIG (reply, "au", NULL, defunct_set ());
698 dbus_message_iter_init (reply, &iter);
699 _atspi_dbus_set_state (obj, &iter);
700 dbus_message_unref (reply);
701 _atspi_accessible_add_cache (obj, ATSPI_CACHE_STATES);
703 return g_object_ref (obj->states);
707 * atspi_accessible_get_attributes:
708 * @obj: The #AtspiAccessible being queried.
710 * Gets the #AttributeSet representing any assigned
711 * name-value pair attributes or annotations for this object.
712 * For typographic, textual, or textually-semantic attributes, see
713 * atspi_text_get_attributes instead.
715 * Returns: (element-type gchar* gchar*) (transfer full): The name-value-pair
716 * attributes assigned to this object.
719 atspi_accessible_get_attributes (AtspiAccessible *obj, GError **error)
721 DBusMessage *message;
723 g_return_val_if_fail (obj != NULL, NULL);
725 if (obj->priv->cache)
727 GValue *val = g_hash_table_lookup (obj->priv->cache, "Attributes");
729 return g_value_dup_boxed (val);
732 if (!_atspi_accessible_test_cache (obj, ATSPI_CACHE_ATTRIBUTES))
734 message = _atspi_dbus_call_partial (obj, atspi_interface_accessible,
735 "GetAttributes", error, "");
736 obj->attributes = _atspi_dbus_return_hash_from_message (message);
737 _atspi_accessible_add_cache (obj, ATSPI_CACHE_ATTRIBUTES);
740 if (!obj->attributes)
742 return g_hash_table_ref (obj->attributes);
746 add_to_attribute_array (gpointer key, gpointer value, gpointer data)
748 GArray **array = (GArray **)data;
749 gchar *str = g_strconcat (key, ":", value, NULL);
750 *array = g_array_append_val (*array, str);
754 * atspi_accessible_get_attributes_as_array:
755 * @obj: The #AtspiAccessible being queried.
757 * Gets a #GArray representing any assigned
758 * name-value pair attributes or annotations for this object.
759 * For typographic, textual, or textually-semantic attributes, see
760 * atspi_text_get_attributes_as_array instead.
762 * Returns: (element-type gchar*) (transfer full): The name-value-pair
763 * attributes assigned to this object.
766 atspi_accessible_get_attributes_as_array (AtspiAccessible *obj, GError **error)
768 DBusMessage *message;
770 g_return_val_if_fail (obj != NULL, NULL);
772 if (obj->priv->cache)
774 GValue *val = g_hash_table_lookup (obj->priv->cache, "Attributes");
777 GArray *array = g_array_new (TRUE, TRUE, sizeof (gchar *));
778 GHashTable *attributes = g_value_get_boxed (val);
779 g_hash_table_foreach (attributes, add_to_attribute_array, &array);
784 message = _atspi_dbus_call_partial (obj, atspi_interface_accessible, "GetAttributes", error, "");
785 return _atspi_dbus_return_attribute_array_from_message (message);
789 * atspi_accessible_get_application:
790 * @obj: The #AtspiAccessible being queried.
792 * Gets the containing #AtspiApplication for an object.
794 * Returns: (transfer full): the containing #AtspiApplication instance for
798 atspi_accessible_get_application (AtspiAccessible *obj, GError **error)
800 AtspiAccessible *parent;
805 parent = atspi_accessible_get_parent (obj, NULL);
806 if (!parent && obj->parent.app &&
807 atspi_accessible_get_role (obj, NULL) != ATSPI_ROLE_APPLICATION)
809 AtspiAccessible *root = g_object_ref (obj->parent.app->root);
812 g_object_unref (obj);
813 if (atspi_accessible_get_role (root, NULL) == ATSPI_ROLE_DESKTOP_FRAME)
815 g_object_unref (root);
821 if (!parent || parent == obj ||
822 atspi_accessible_get_role (parent, NULL) == ATSPI_ROLE_DESKTOP_FRAME)
825 g_object_unref (parent);
828 g_object_unref (obj);
833 /* Application-specific methods */
836 * atspi_accessible_get_toolkit_name:
837 * @obj: a pointer to the #AtspiAccessible object on which to operate.
839 * Gets the toolkit name for an #AtspiAccessible object.
840 * Only works on application root objects.
842 * Returns: a UTF-8 string indicating the toolkit name for the #AtspiAccessible object or NULL on exception.
845 atspi_accessible_get_toolkit_name (AtspiAccessible *obj, GError **error)
847 g_return_val_if_fail (obj != NULL, NULL);
849 if (!obj->parent.app)
852 if (!obj->parent.app->toolkit_name)
853 _atspi_dbus_get_property (obj, atspi_interface_application, "ToolkitName",
854 error, "s", &obj->parent.app->toolkit_name);
856 return g_strdup (obj->parent.app->toolkit_name);
860 * atspi_accessible_get_toolkit_version:
861 * @obj: a pointer to the #AtspiAccessible object on which to operate.
863 * Gets the toolkit version for an #AtspiAccessible object.
864 * Only works on application root objects.
866 * Returns: a UTF-8 string indicating the toolkit version for the #AtspiAccessible object or NULL on exception.
869 atspi_accessible_get_toolkit_version (AtspiAccessible *obj, GError **error)
871 g_return_val_if_fail (obj != NULL, NULL);
873 if (!obj->parent.app)
876 if (!obj->parent.app->toolkit_version)
877 _atspi_dbus_get_property (obj, atspi_interface_application, "Version",
878 error, "s", &obj->parent.app->toolkit_version);
880 return g_strdup (obj->parent.app->toolkit_version);
884 * atspi_accessible_get_atspi_version:
885 * @obj: a pointer to the #AtspiAccessible object on which to operate.
887 * Gets the AT-SPI IPC specification version supported by the application
888 * pointed to by the #AtspiAccessible object.
889 * Only works on application root objects.
891 * Returns: a UTF-8 string indicating the AT-SPI version for the #AtspiAccessible object or NULL on exception.
894 atspi_accessible_get_atspi_version (AtspiAccessible *obj, GError **error)
896 g_return_val_if_fail (obj != NULL, NULL);
898 if (!obj->parent.app)
901 if (!obj->parent.app->atspi_version)
902 _atspi_dbus_get_property (obj, atspi_interface_application, "AtspiVersion",
903 error, "s", &obj->parent.app->atspi_version);
905 return g_strdup (obj->parent.app->atspi_version);
909 * atspi_accessible_get_id:
910 * @obj: a pointer to the #AtspiAccessible object on which to operate.
912 * Gets the application id for a #AtspiAccessible object.
913 * Only works on application root objects.
915 * Returns: a positive #gint indicating the id for the #AtspiAccessible object
916 * or -1 on exception.
919 atspi_accessible_get_id (AtspiAccessible *obj, GError **error)
923 g_return_val_if_fail (obj != NULL, -1);
925 if (!_atspi_dbus_get_property (obj, atspi_interface_application, "Id", error, "i", &ret))
931 /* Interface query methods */
934 _atspi_accessible_is_a (AtspiAccessible *accessible,
935 const char *interface_name)
939 if (accessible == NULL)
944 if (!_atspi_accessible_test_cache (accessible, ATSPI_CACHE_INTERFACES))
947 DBusMessageIter iter;
948 reply = _atspi_dbus_call_partial (accessible, atspi_interface_accessible,
949 "GetInterfaces", NULL, "");
950 _ATSPI_DBUS_CHECK_SIG (reply, "as", NULL, FALSE);
951 dbus_message_iter_init (reply, &iter);
952 _atspi_dbus_set_interfaces (accessible, &iter);
953 dbus_message_unref (reply);
954 _atspi_accessible_add_cache (accessible, ATSPI_CACHE_INTERFACES);
957 n = _atspi_get_iface_num (interface_name);
958 if (n == -1) return FALSE;
959 return (gboolean) ((accessible->interfaces & (1 << n))? TRUE: FALSE);
963 * atspi_accessible_is_action:
964 * @obj: a pointer to the #AtspiAccessible instance to query.
966 * Query whether the specified #AtspiAccessible implements the
967 * #AtspiAction interface.
969 * Returns: #TRUE if @obj implements the #AtspiAction interface,
973 atspi_accessible_is_action (AtspiAccessible *obj)
975 return _atspi_accessible_is_a (obj,
976 atspi_interface_action);
980 * atspi_accessible_is_application:
981 * @obj: a pointer to the #AtspiAccessible instance to query.
983 * Query whether the specified #AtspiAccessible implements the
984 * #AtspiApplication interface.
986 * Returns: #TRUE if @obj implements the #AtspiApplication interface,
990 atspi_accessible_is_application (AtspiAccessible *obj)
992 return _atspi_accessible_is_a (obj,
993 atspi_interface_application);
997 * atspi_accessible_is_collection:
998 * @obj: a pointer to the #AtspiAccessible instance to query.
1000 * Query whether the specified #AtspiAccessible implements the
1001 * #AtspiCollection interface.
1003 * Returns: #TRUE if @obj implements the #AtspiCollection interface,
1007 atspi_accessible_is_collection (AtspiAccessible *obj)
1009 return _atspi_accessible_is_a (obj,
1010 atspi_interface_collection);
1014 * atspi_accessible_is_component:
1015 * @obj: a pointer to the #AtspiAccessible instance to query.
1017 * Query whether the specified #AtspiAccessible implements #AtspiComponent.
1019 * Returns: #TRUE if @obj implements the #AtspiComponent interface,
1023 atspi_accessible_is_component (AtspiAccessible *obj)
1025 return _atspi_accessible_is_a (obj,
1026 atspi_interface_component);
1030 * atspi_accessible_is_document:
1031 * @obj: a pointer to the #AtspiAccessible instance to query.
1033 * Query whether the specified #AtspiAccessible implements the
1034 * #AtspiDocument interface.
1036 * Returns: #TRUE if @obj implements the #AtspiDocument interface,
1040 atspi_accessible_is_document (AtspiAccessible *obj)
1042 return _atspi_accessible_is_a (obj,
1043 atspi_interface_document);
1047 * atspi_accessible_is_editable_text:
1048 * @obj: a pointer to the #AtspiAccessible instance to query.
1050 * Query whether the specified #AtspiAccessible implements the
1051 * #AtspiEditableText interface.
1053 * Returns: #TRUE if @obj implements the #AtspiEditableText interface,
1057 atspi_accessible_is_editable_text (AtspiAccessible *obj)
1059 return _atspi_accessible_is_a (obj,
1060 atspi_interface_editable_text);
1064 * atspi_accessible_is_hypertext:
1065 * @obj: a pointer to the #AtspiAccessible instance to query.
1067 * Query whether the specified #AtspiAccessible implements the
1068 * #AtspiHypertext interface.
1070 * Returns: #TRUE if @obj implements the #AtspiHypertext interface,
1074 atspi_accessible_is_hypertext (AtspiAccessible *obj)
1076 return _atspi_accessible_is_a (obj,
1077 atspi_interface_hypertext);
1081 * atspi_accessible_is_hyperlink:
1082 * @obj: a pointer to the #AtspiAccessible instance to query.
1084 * Query whether the specified #AtspiAccessible implements the
1085 * #AtspiHyperlink interface.
1087 * Returns: #TRUE if @obj implements the #AtspiHypertext interface,
1091 atspi_accessible_is_hyperlink (AtspiAccessible *obj)
1093 return _atspi_accessible_is_a (obj,
1094 atspi_interface_hyperlink);
1098 * atspi_accessible_is_image:
1099 * @obj: a pointer to the #AtspiAccessible instance to query.
1101 * Query whether the specified #AtspiAccessible implements the
1102 * #AtspiImage interface.
1104 * Returns: #TRUE if @obj implements the #AtspiImage interface,
1108 atspi_accessible_is_image (AtspiAccessible *obj)
1110 return _atspi_accessible_is_a (obj,
1111 atspi_interface_image);
1115 * atspi_accessible_is_selection:
1116 * @obj: a pointer to the #AtspiAccessible instance to query.
1118 * Query whether the specified #AtspiAccessible implements the
1119 * #AtspiSelection interface.
1121 * Returns: #TRUE if @obj implements the #AtspiSelection interface,
1125 atspi_accessible_is_selection (AtspiAccessible *obj)
1127 return _atspi_accessible_is_a (obj,
1128 atspi_interface_selection);
1132 * atspi_accessible_is_table:
1133 * @obj: a pointer to the #AtspiAccessible instance to query.
1135 * Query whether the specified #AtspiAccessible implements the
1136 * #AtspiTable interface.
1138 * Returns: #TRUE if @obj implements the #AtspiTable interface,
1142 atspi_accessible_is_table (AtspiAccessible *obj)
1144 return _atspi_accessible_is_a (obj,
1145 atspi_interface_table);
1149 * atspi_accessible_is_table_cell:
1150 * @obj: a pointer to the #AtspiAccessible instance to query.
1152 * Query whether the specified #AtspiAccessible implements the
1153 * #AtspiTableCell interface.
1155 * Returns: #TRUE if @obj implements the #AtspiTable interface,
1159 atspi_accessible_is_table_cell (AtspiAccessible *obj)
1161 return _atspi_accessible_is_a (obj,
1162 atspi_interface_table_cell);
1166 * atspi_accessible_is_streamable_content:
1167 * @obj: a pointer to the #AtspiAccessible instance to query.
1169 * Query whether the specified #AtspiAccessible implements the
1170 * #AtspiStreamableContent interface.
1172 * Returns: #TRUE if @obj implements the #AtspiStreamableContent interface,
1176 atspi_accessible_is_streamable_content (AtspiAccessible *obj)
1179 return _atspi_accessible_is_a (obj,
1180 atspi_interface_streamable_content);
1182 g_warning ("Streamable content not implemented");
1188 * atspi_accessible_is_text:
1189 * @obj: a pointer to the #AtspiAccessible instance to query.
1191 * Query whether the specified #AtspiAccessible implements the
1192 * #AtspiText interface.
1194 * Returns: #TRUE if @obj implements the #AtspiText interface,
1198 atspi_accessible_is_text (AtspiAccessible *obj)
1200 return _atspi_accessible_is_a (obj,
1201 atspi_interface_text);
1205 * atspi_accessible_is_value:
1206 * @obj: a pointer to the #AtspiAccessible instance to query.
1208 * Query whether the specified #AtspiAccessible implements the
1209 * #AtspiValue interface.
1211 * Returns: #TRUE if @obj implements the #AtspiValue interface,
1215 atspi_accessible_is_value (AtspiAccessible *obj)
1217 return _atspi_accessible_is_a (obj,
1218 atspi_interface_value);
1222 * atspi_accessible_get_action: (rename-to atspi_accessible_get_action_iface)
1223 * @obj: a pointer to the #AtspiAccessible instance to query.
1225 * Gets the #AtspiAction interface for an #AtspiAccessible.
1227 * Returns: (transfer full): a pointer to an #AtspiAction interface
1228 * instance, or NULL if @obj does not implement #AtspiAction.
1230 * Deprecated: 2.10: Use atspi_accessible_get_action_iface instead.
1233 atspi_accessible_get_action (AtspiAccessible *accessible)
1235 return (_atspi_accessible_is_a (accessible, atspi_interface_action) ?
1236 g_object_ref (ATSPI_ACTION (accessible)) : NULL);
1240 * atspi_accessible_get_action_iface:
1241 * @obj: a pointer to the #AtspiAccessible instance to query.
1243 * Gets the #AtspiAction interface for an #AtspiAccessible.
1245 * Returns: (transfer full): a pointer to an #AtspiAction interface
1246 * instance, or NULL if @obj does not implement #AtspiAction.
1249 atspi_accessible_get_action_iface (AtspiAccessible *accessible)
1251 return (_atspi_accessible_is_a (accessible, atspi_interface_action) ?
1252 g_object_ref (ATSPI_ACTION (accessible)) : NULL);
1256 * atspi_accessible_get_collection: (rename-to atspi_accessible_get_collection_iface)
1257 * @obj: a pointer to the #AtspiAccessible instance to query.
1259 * Gets the #AtspiCollection interface for an #AtspiAccessible.
1261 * Returns: (transfer full): a pointer to an #AtspiCollection interface
1262 * instance, or NULL if @obj does not implement #AtspiCollection.
1264 * Deprecated: 2.10: Use atspi_accessible_get_collection_iface instead.
1267 atspi_accessible_get_collection (AtspiAccessible *accessible)
1269 return (_atspi_accessible_is_a (accessible, atspi_interface_collection) ?
1270 g_object_ref (ATSPI_COLLECTION (accessible)) : NULL);
1274 * atspi_accessible_get_collection_iface:
1275 * @obj: a pointer to the #AtspiAccessible instance to query.
1277 * Gets the #AtspiCollection interface for an #AtspiAccessible.
1279 * Returns: (transfer full): a pointer to an #AtspiCollection interface
1280 * instance, or NULL if @obj does not implement #AtspiCollection.
1283 atspi_accessible_get_collection_iface (AtspiAccessible *accessible)
1285 return (_atspi_accessible_is_a (accessible, atspi_interface_collection) ?
1286 g_object_ref (ATSPI_COLLECTION (accessible)) : NULL);
1290 * atspi_accessible_get_component: (rename-to atspi_accessible_get_component_iface)
1291 * @obj: a pointer to the #AtspiAccessible instance to query.
1293 * Gets the #AtspiComponent interface for an #AtspiAccessible.
1295 * Returns: (transfer full): a pointer to an #AtspiComponent interface
1296 * instance, or NULL if @obj does not implement #AtspiComponent.
1298 * Deprecated: 2.10: Use atspi_accessible_get_component_iface instead.
1301 atspi_accessible_get_component (AtspiAccessible *obj)
1303 return (_atspi_accessible_is_a (obj, atspi_interface_component) ?
1304 g_object_ref (ATSPI_COMPONENT (obj)) : NULL);
1308 * atspi_accessible_get_component_iface:
1309 * @obj: a pointer to the #AtspiAccessible instance to query.
1311 * Gets the #AtspiComponent interface for an #AtspiAccessible.
1313 * Returns: (transfer full): a pointer to an #AtspiComponent interface
1314 * instance, or NULL if @obj does not implement #AtspiComponent.
1317 atspi_accessible_get_component_iface (AtspiAccessible *obj)
1319 return (_atspi_accessible_is_a (obj, atspi_interface_component) ?
1320 g_object_ref (ATSPI_COMPONENT (obj)) : NULL);
1324 * atspi_accessible_get_document: (rename-to atspi_accessible_get_document_iface)
1325 * @obj: a pointer to the #AtspiAccessible instance to query.
1327 * Gets the #AtspiDocument interface for an #AtspiAccessible.
1329 * Returns: (transfer full): a pointer to an #AtspiDocument interface
1330 * instance, or NULL if @obj does not implement #AtspiDocument.
1332 * Deprecated: 2.10: Use atspi_accessible_get_document_iface instead.
1335 atspi_accessible_get_document (AtspiAccessible *accessible)
1337 return (_atspi_accessible_is_a (accessible, atspi_interface_document) ?
1338 g_object_ref (ATSPI_DOCUMENT (accessible)) : NULL);
1342 * atspi_accessible_get_document_iface:
1343 * @obj: a pointer to the #AtspiAccessible instance to query.
1345 * Gets the #AtspiDocument interface for an #AtspiAccessible.
1347 * Returns: (transfer full): a pointer to an #AtspiDocument interface
1348 * instance, or NULL if @obj does not implement #AtspiDocument.
1351 atspi_accessible_get_document_iface (AtspiAccessible *accessible)
1353 return (_atspi_accessible_is_a (accessible, atspi_interface_document) ?
1354 g_object_ref (ATSPI_DOCUMENT (accessible)) : NULL);
1358 * atspi_accessible_get_editable_text: (rename-to atspi_accessible_get_editable_text_iface)
1359 * @obj: a pointer to the #AtspiAccessible instance to query.
1361 * Gets the #AtspiEditableText interface for an #AtspiAccessible.
1363 * Returns: (transfer full): a pointer to an #AtspiEditableText interface
1364 * instance, or NULL if @obj does not implement #AtspiEditableText.
1366 * Deprecated: 2.10: Use atspi_accessible_get_editable_text_iface instead.
1369 atspi_accessible_get_editable_text (AtspiAccessible *accessible)
1371 return (_atspi_accessible_is_a (accessible, atspi_interface_editable_text) ?
1372 g_object_ref (ATSPI_EDITABLE_TEXT (accessible)) : NULL);
1376 * atspi_accessible_get_editable_text_iface:
1377 * @obj: a pointer to the #AtspiAccessible instance to query.
1379 * Gets the #AtspiEditableText interface for an #AtspiAccessible.
1381 * Returns: (transfer full): a pointer to an #AtspiEditableText interface
1382 * instance, or NULL if @obj does not implement #AtspiEditableText.
1385 atspi_accessible_get_editable_text_iface (AtspiAccessible *accessible)
1387 return (_atspi_accessible_is_a (accessible, atspi_interface_editable_text) ?
1388 g_object_ref (ATSPI_EDITABLE_TEXT (accessible)) : NULL);
1392 * atspi_accessible_get_hyperlink:
1393 * @obj: a pointer to the #AtspiAccessible object on which to operate.
1395 * Gets the #AtspiHyperlink interface for an #AtspiAccessible.
1397 * Returns: (transfer full): the #AtspiHyperlink object associated with
1398 * the given #AtspiAccessible, or NULL if not supported.
1401 atspi_accessible_get_hyperlink (AtspiAccessible *accessible)
1403 return (_atspi_accessible_is_a (accessible, atspi_interface_hyperlink) ?
1404 _atspi_hyperlink_new (accessible->parent.app, accessible->parent.path) : NULL);
1408 * atspi_accessible_get_hypertext: (rename-to atspi_accessible_get_hypertext_iface)
1409 * @obj: a pointer to the #AtspiAccessible instance to query.
1411 * Gets the #AtspiHypertext interface for an #AtspiAccessible.
1413 * Returns: (transfer full): a pointer to an #AtspiHypertext interface
1414 * instance, or NULL if @obj does not implement #AtspiHypertext.
1416 * Deprecated: 2.10: Use atspi_accessible_get_hypertext_iface instead.
1419 atspi_accessible_get_hypertext (AtspiAccessible *accessible)
1421 return (_atspi_accessible_is_a (accessible, atspi_interface_hypertext) ?
1422 g_object_ref (ATSPI_HYPERTEXT (accessible)) : NULL);
1426 * atspi_accessible_get_hypertext_iface:
1427 * @obj: a pointer to the #AtspiAccessible instance to query.
1429 * Gets the #AtspiHypertext interface for an #AtspiAccessible.
1431 * Returns: (transfer full): a pointer to an #AtspiHypertext interface
1432 * instance, or NULL if @obj does not implement #AtspiHypertext.
1435 atspi_accessible_get_hypertext_iface (AtspiAccessible *accessible)
1437 return (_atspi_accessible_is_a (accessible, atspi_interface_hypertext) ?
1438 g_object_ref (ATSPI_HYPERTEXT (accessible)) : NULL);
1442 * atspi_accessible_get_image: (rename-to atspi_accessible_get_image_iface)
1443 * @obj: a pointer to the #AtspiAccessible instance to query.
1445 * Gets the #AtspiImage interface for an #AtspiAccessible.
1447 * Returns: (transfer full): a pointer to an #AtspiImage interface instance, or
1448 * NULL if @obj does not implement #AtspiImage.
1450 * Deprecated: 2.10: Use atspi_accessible_get_image_iface instead.
1453 atspi_accessible_get_image (AtspiAccessible *accessible)
1455 return (_atspi_accessible_is_a (accessible, atspi_interface_image) ?
1456 g_object_ref (ATSPI_IMAGE (accessible)) : NULL);
1460 * atspi_accessible_get_image_iface:
1461 * @obj: a pointer to the #AtspiAccessible instance to query.
1463 * Gets the #AtspiImage interface for an #AtspiAccessible.
1465 * Returns: (transfer full): a pointer to an #AtspiImage interface instance, or
1466 * NULL if @obj does not implement #AtspiImage.
1469 atspi_accessible_get_image_iface (AtspiAccessible *accessible)
1471 return (_atspi_accessible_is_a (accessible, atspi_interface_image) ?
1472 g_object_ref (ATSPI_IMAGE (accessible)) : NULL);
1476 * atspi_accessible_get_selection: (rename-to atspi_accessible_get_selection_iface)
1477 * @obj: a pointer to the #AtspiAccessible instance to query.
1479 * Gets the #AtspiSelection interface for an #AtspiAccessible.
1481 * Returns: (transfer full): a pointer to an #AtspiSelection interface
1482 * instance, or NULL if @obj does not implement #AtspiSelection.
1484 * Deprecated: 2.10: Use atspi_accessible_get_selection_iface instead.
1487 atspi_accessible_get_selection (AtspiAccessible *accessible)
1489 return (_atspi_accessible_is_a (accessible, atspi_interface_selection) ?
1490 g_object_ref (ATSPI_SELECTION (accessible)) : NULL);
1494 * atspi_accessible_get_selection_iface:
1495 * @obj: a pointer to the #AtspiAccessible instance to query.
1497 * Gets the #AtspiSelection interface for an #AtspiAccessible.
1499 * Returns: (transfer full): a pointer to an #AtspiSelection interface
1500 * instance, or NULL if @obj does not implement #AtspiSelection.
1503 atspi_accessible_get_selection_iface (AtspiAccessible *accessible)
1505 return (_atspi_accessible_is_a (accessible, atspi_interface_selection) ?
1506 g_object_ref (ATSPI_SELECTION (accessible)) : NULL);
1511 * atspi_accessible_get_streamable_content:
1512 * @obj: a pointer to the #AtspiAccessible instance to query.
1514 * Gets the #AtspiStreamableContent interface for an #AtspiAccessible.
1516 * Returns: (transfer full): a pointer to an #AtspiStreamableContent interface
1517 * instance, or NULL if @obj does not implement #AtspiStreamableContent.
1519 AtspiStreamableContent *
1520 atspi_accessible_get_streamable_content (AtspiAccessible *accessible)
1522 return (_atspi_accessible_is_a (accessible, atspi_interface_streamable_content) ?
1528 * atspi_accessible_get_table: (rename-to atspi_accessible_get_table_iface)
1529 * @obj: a pointer to the #AtspiAccessible instance to query.
1531 * Gets the #AtspiTable interface for an #AtspiAccessible.
1533 * Returns: (transfer full): a pointer to an #AtspiTable interface instance, or
1534 * NULL if @obj does not implement #AtspiTable.
1536 * Deprecated: 2.10: Use atspi_accessible_get_table_iface instead.
1539 atspi_accessible_get_table (AtspiAccessible *obj)
1541 return (_atspi_accessible_is_a (obj, atspi_interface_table) ?
1542 g_object_ref (ATSPI_TABLE (obj)) : NULL);
1546 * atspi_accessible_get_table_iface:
1547 * @obj: a pointer to the #AtspiAccessible instance to query.
1549 * Gets the #AtspiTable interface for an #AtspiAccessible.
1551 * Returns: (transfer full): a pointer to an #AtspiTable interface instance, or
1552 * NULL if @obj does not implement #AtspiTable.
1555 atspi_accessible_get_table_iface (AtspiAccessible *obj)
1557 return (_atspi_accessible_is_a (obj, atspi_interface_table) ?
1558 g_object_ref (ATSPI_TABLE (obj)) : NULL);
1562 * atspi_accessible_get_table_cell:
1563 * @obj: a pointer to the #AtspiAccessible instance to query.
1565 * Gets the #AtspiTableCell interface for an #AtspiAccessible.
1567 * Returns: (transfer full): a pointer to an #AtspiTableCell interface instance,
1568 * or NULL if @obj does not implement #AtspiTable.
1571 atspi_accessible_get_table_cell (AtspiAccessible *obj)
1573 return (_atspi_accessible_is_a (obj, atspi_interface_table_cell) ?
1574 g_object_ref (ATSPI_TABLE_CELL (obj)) : NULL);
1578 * atspi_accessible_get_text: (rename-to atspi_accessible_get_text_iface)
1579 * @obj: a pointer to the #AtspiAccessible instance to query.
1581 * Gets the #AtspiTable interface for an #AtspiAccessible.
1583 * Returns: (transfer full): a pointer to an #AtspiText interface instance, or
1584 * NULL if @obj does not implement #AtspiText.
1586 * Deprecated: 2.10: Use atspi_accessible_get_text_iface instead.
1589 atspi_accessible_get_text (AtspiAccessible *obj)
1591 return (_atspi_accessible_is_a (obj, atspi_interface_text) ?
1592 g_object_ref (ATSPI_TEXT (obj)) : NULL);
1596 * atspi_accessible_get_text_iface:
1597 * @obj: a pointer to the #AtspiAccessible instance to query.
1599 * Gets the #AtspiTable interface for an #AtspiAccessible.
1601 * Returns: (transfer full): a pointer to an #AtspiText interface instance, or
1602 * NULL if @obj does not implement #AtspiText.
1605 atspi_accessible_get_text_iface (AtspiAccessible *obj)
1607 return (_atspi_accessible_is_a (obj, atspi_interface_text) ?
1608 g_object_ref (ATSPI_TEXT (obj)) : NULL);
1612 * atspi_accessible_get_value: (rename-to atspi_accessible_get_value_iface)
1613 * @obj: a pointer to the #AtspiAccessible instance to query.
1615 * Gets the #AtspiTable interface for an #AtspiAccessible.
1617 * Returns: (transfer full): a pointer to an #AtspiValue interface instance, or
1618 * NULL if @obj does not implement #AtspiValue.
1620 * Deprecated: 2.10: Use atspi_accessible_get_value_iface instead.
1623 atspi_accessible_get_value (AtspiAccessible *accessible)
1625 return (_atspi_accessible_is_a (accessible, atspi_interface_value) ?
1626 g_object_ref (ATSPI_VALUE (accessible)) : NULL);
1630 * atspi_accessible_get_value_iface:
1631 * @obj: a pointer to the #AtspiAccessible instance to query.
1633 * Gets the #AtspiTable interface for an #AtspiAccessible.
1635 * Returns: (transfer full): a pointer to an #AtspiValue interface instance, or
1636 * NULL if @obj does not implement #AtspiValue.
1639 atspi_accessible_get_value_iface (AtspiAccessible *accessible)
1641 return (_atspi_accessible_is_a (accessible, atspi_interface_value) ?
1642 g_object_ref (ATSPI_VALUE (accessible)) : NULL);
1646 append_const_val (GArray *array, const gchar *val)
1648 gchar *dup = g_strdup (val);
1651 g_array_append_val (array, dup);
1655 * atspi_accessible_get_interfaces:
1656 * @obj: The #AtspiAccessible to query.
1658 * A set of pointers to all interfaces supported by an #AtspiAccessible.
1660 * Returns: (element-type gchar*) (transfer full): A #GArray of strings
1661 * describing the interfaces supported by the object. Interfaces are
1662 * denoted in short-hand (i.e. "Component", "Text" etc.).
1665 atspi_accessible_get_interfaces (AtspiAccessible *obj)
1667 GArray *ret = g_array_new (TRUE, TRUE, sizeof (gchar *));
1669 g_return_val_if_fail (obj != NULL, NULL);
1671 append_const_val (ret, "Accessible");
1672 if (atspi_accessible_is_action (obj))
1673 append_const_val (ret, "Action");
1674 if (atspi_accessible_is_collection (obj))
1675 append_const_val (ret, "Collection");
1676 if (atspi_accessible_is_component (obj))
1677 append_const_val (ret, "Component");
1678 if (atspi_accessible_is_document (obj))
1679 append_const_val (ret, "Document");
1680 if (atspi_accessible_is_editable_text (obj))
1681 append_const_val (ret, "EditableText");
1682 if (atspi_accessible_is_hypertext (obj))
1683 append_const_val (ret, "Hypertext");
1684 if (atspi_accessible_is_hyperlink (obj))
1685 append_const_val (ret, "Hyperlink");
1686 if (atspi_accessible_is_image (obj))
1687 append_const_val (ret, "Image");
1688 if (atspi_accessible_is_selection (obj))
1689 append_const_val (ret, "Selection");
1690 if (atspi_accessible_is_table (obj))
1691 append_const_val (ret, "Table");
1692 if (atspi_accessible_is_table_cell (obj))
1693 append_const_val (ret, "TableCell");
1694 if (atspi_accessible_is_text (obj))
1695 append_const_val (ret, "Text");
1696 if (atspi_accessible_is_value (obj))
1697 append_const_val (ret, "Value");
1703 _atspi_accessible_new (AtspiApplication *app, const gchar *path)
1705 AtspiAccessible *accessible;
1707 accessible = g_object_new (ATSPI_TYPE_ACCESSIBLE, NULL);
1708 g_return_val_if_fail (accessible != NULL, NULL);
1710 accessible->parent.app = g_object_ref (app);
1711 accessible->parent.path = g_strdup (path);
1717 * atspi_accessible_set_cache_mask:
1718 * @accessible: The #AtspiAccessible to operate on. Must be the desktop or
1719 * the root of an application.
1720 * @mask: An #AtspiCache specifying a bit mask of the types of data to cache.
1722 * Sets the type of data to cache for accessibles.
1723 * If this is not set for an application or is reset to ATSPI_CACHE_UNDEFINED,
1724 * then the desktop's cache flag will be used.
1725 * If the desktop's cache flag is also undefined, then all possible data will
1727 * This function is intended to work around bugs in toolkits where the proper
1728 * events are not raised / to aid in testing for such bugs.
1731 atspi_accessible_set_cache_mask (AtspiAccessible *accessible, AtspiCache mask)
1733 g_return_if_fail (accessible != NULL);
1734 g_return_if_fail (accessible->parent.app != NULL);
1735 g_return_if_fail (accessible == accessible->parent.app->root);
1736 accessible->parent.app->cache = mask;
1737 enable_caching = TRUE;
1741 * atspi_accessible_clear_cache:
1742 * @accessible: The #AtspiAccessible whose cache to clear.
1744 * Clears the cached information for the given accessible and all of its
1748 atspi_accessible_clear_cache (AtspiAccessible *accessible)
1754 accessible->cached_properties = ATSPI_CACHE_NONE;
1755 for (l = accessible->children; l; l = l->next)
1756 atspi_accessible_clear_cache (l->data);
1761 * atspi_accessible_get_process_id:
1762 * @accessible: The #AtspiAccessible to query.
1763 * @error: a pointer to a %NULL #GError pointer
1765 * Returns the process id associated with the given accessible. Mainly
1766 * added for debugging; it is a shortcut to explicitly querying the
1767 * accessible's app->bus_name and then calling GetConnectionUnixProcessID.
1769 * Returns: The process ID or undetermined value if @error is set.
1772 atspi_accessible_get_process_id (AtspiAccessible *accessible, GError **error)
1774 DBusMessage *message, *reply;
1775 DBusConnection *bus = _atspi_bus ();
1776 dbus_uint32_t pid = -1;
1779 if (!accessible->parent.app || !accessible->parent.app->bus_name)
1781 g_set_error_literal(error, ATSPI_ERROR, ATSPI_ERROR_IPC, "Process is defunct");
1785 message = dbus_message_new_method_call ("org.freedesktop.DBus",
1786 "/org/freedesktop/DBus",
1787 "org.freedesktop.DBus",
1788 "GetConnectionUnixProcessID");
1789 dbus_message_append_args (message, DBUS_TYPE_STRING,
1790 &accessible->parent.app->bus_name,
1792 dbus_error_init (&d_error);
1793 reply = dbus_connection_send_with_reply_and_block (bus, message, -1, &d_error);
1794 dbus_message_unref (message);
1797 if (!strcmp (dbus_message_get_signature (reply), "u"))
1798 dbus_message_get_args (reply, NULL, DBUS_TYPE_UINT32, &pid, DBUS_TYPE_INVALID);
1799 dbus_message_unref (reply);
1801 if (dbus_error_is_set (&d_error))
1803 g_set_error_literal(error, ATSPI_ERROR, ATSPI_ERROR_IPC, "Process is defunct");
1804 dbus_error_free (&d_error);
1810 _atspi_accessible_get_cache_mask (AtspiAccessible *accessible)
1814 if (!accessible->parent.app)
1815 return ATSPI_CACHE_NONE;
1817 mask = accessible->parent.app->cache;
1818 if (mask == ATSPI_CACHE_UNDEFINED &&
1819 accessible->parent.app->root &&
1820 accessible->parent.app->root->accessible_parent)
1822 AtspiAccessible *desktop = atspi_get_desktop (0);
1823 mask = desktop->parent.app->cache;
1824 g_object_unref (desktop);
1827 if (mask == ATSPI_CACHE_UNDEFINED)
1828 mask = ATSPI_CACHE_DEFAULT;
1834 _atspi_accessible_test_cache (AtspiAccessible *accessible, AtspiCache flag)
1836 AtspiCache mask = _atspi_accessible_get_cache_mask (accessible);
1837 AtspiCache result = accessible->cached_properties & mask & flag;
1838 if (accessible->states && atspi_state_set_contains (accessible->states, ATSPI_STATE_TRANSIENT))
1840 return (result != 0 && (atspi_main_loop || enable_caching ||
1841 flag == ATSPI_CACHE_INTERFACES) &&
1846 _atspi_accessible_add_cache (AtspiAccessible *accessible, AtspiCache flag)
1848 AtspiCache mask = _atspi_accessible_get_cache_mask (accessible);
1850 accessible->cached_properties |= flag & mask;
1854 * atspi_accessible_get_locale:
1855 * @accessible: an #AtspiAccessible
1857 * Gets a UTF-8 string indicating the POSIX-style LC_MESSAGES locale
1862 * Returns: a UTF-8 string indicating the POSIX-style LC_MESSAGES
1863 * locale of @accessible.
1866 atspi_accessible_get_object_locale (AtspiAccessible *accessible, GError **error)
1870 g_return_val_if_fail (accessible != NULL, NULL);
1872 locale = g_object_get_qdata (G_OBJECT (accessible), quark_locale);
1875 if (!_atspi_dbus_get_property (accessible, atspi_interface_accessible,
1876 "Locale", error, "s", &locale))
1879 g_object_set_qdata_full (G_OBJECT (accessible), quark_locale, locale,
1886 free_value (gpointer data)
1888 GValue *value = data;
1890 g_value_unset (value);
1895 _atspi_accessible_ref_cache (AtspiAccessible *accessible)
1897 AtspiAccessiblePrivate *priv = accessible->priv;
1899 priv->cache_ref_count++;
1901 return g_hash_table_ref (priv->cache);
1902 priv->cache = g_hash_table_new_full (g_str_hash, g_str_equal, g_free,
1908 _atspi_accessible_unref_cache (AtspiAccessible *accessible)
1910 AtspiAccessiblePrivate *priv = accessible->priv;
1914 g_hash_table_unref (priv->cache);
1915 if (--priv->cache_ref_count == 0)