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_description:
318 * @obj: a pointer to the #AtspiAccessible object on which to operate.
320 * Gets the description of an #AtspiAccessible object.
322 * Returns: a UTF-8 string describing the #AtspiAccessible object
323 * or NULL on exception.
326 atspi_accessible_get_description (AtspiAccessible *obj, GError **error)
328 g_return_val_if_fail (obj != NULL, g_strdup (""));
330 if (!_atspi_accessible_test_cache (obj, ATSPI_CACHE_DESCRIPTION))
332 if (!_atspi_dbus_get_property (obj, atspi_interface_accessible,
333 "Description", error, "s",
335 return g_strdup ("");
336 _atspi_accessible_add_cache (obj, ATSPI_CACHE_DESCRIPTION);
338 return g_strdup (obj->description);
341 const char *str_parent = "Parent";
344 * atspi_accessible_get_parent:
345 * @obj: a pointer to the #AtspiAccessible object to query.
347 * Gets an #AtspiAccessible object's parent container.
349 * Returns: (nullable) (transfer full): a pointer to the
350 * #AtspiAccessible object which contains the given
351 * #AtspiAccessible instance, or NULL if the @obj has no
356 atspi_accessible_get_parent (AtspiAccessible *obj, GError **error)
358 g_return_val_if_fail (obj != NULL, NULL);
360 if (obj->parent.app &&
361 !_atspi_accessible_test_cache (obj, ATSPI_CACHE_PARENT))
363 DBusMessage *message, *reply;
364 DBusMessageIter iter, iter_variant;
365 message = dbus_message_new_method_call (obj->parent.app->bus_name,
367 DBUS_INTERFACE_PROPERTIES, "Get");
370 dbus_message_append_args (message, DBUS_TYPE_STRING, &atspi_interface_accessible,
371 DBUS_TYPE_STRING, &str_parent,
373 reply = _atspi_dbus_send_with_reply_and_block (message, error);
376 if (strcmp (dbus_message_get_signature (reply), "v") != 0)
378 dbus_message_unref (reply);
381 dbus_message_iter_init (reply, &iter);
382 dbus_message_iter_recurse (&iter, &iter_variant);
383 obj->accessible_parent = _atspi_dbus_return_accessible_from_iter (&iter_variant);
384 dbus_message_unref (reply);
385 _atspi_accessible_add_cache (obj, ATSPI_CACHE_PARENT);
387 if (!obj->accessible_parent)
389 return g_object_ref (obj->accessible_parent);
393 * atspi_accessible_get_child_count:
394 * @obj: a pointer to the #AtspiAccessible object on which to operate.
396 * Gets the number of children contained by an #AtspiAccessible object.
398 * Returns: a #long indicating the number of #AtspiAccessible children
399 * contained by an #AtspiAccessible object or -1 on exception.
403 atspi_accessible_get_child_count (AtspiAccessible *obj, GError **error)
405 g_return_val_if_fail (obj != NULL, -1);
407 if (!_atspi_accessible_test_cache (obj, ATSPI_CACHE_CHILDREN))
410 if (!_atspi_dbus_get_property (obj, atspi_interface_accessible,
411 "ChildCount", error, "i", &ret))
416 return g_list_length (obj->children);
420 * atspi_accessible_get_child_at_index:
421 * @obj: a pointer to the #AtspiAccessible object on which to operate.
422 * @child_index: a #long indicating which child is specified.
424 * Gets the #AtspiAccessible child of an #AtspiAccessible object at a given index.
426 * Returns: (transfer full): a pointer to the #AtspiAccessible child object at
427 * index @child_index or NULL on exception.
430 atspi_accessible_get_child_at_index (AtspiAccessible *obj,
434 AtspiAccessible *child;
436 g_return_val_if_fail (obj != NULL, NULL);
438 if (!_atspi_accessible_test_cache (obj, ATSPI_CACHE_CHILDREN))
441 reply = _atspi_dbus_call_partial (obj, atspi_interface_accessible,
442 "GetChildAtIndex", error, "i",
444 return _atspi_dbus_return_accessible_from_message (reply);
447 child = g_list_nth_data (obj->children, child_index);
450 return g_object_ref (child);
454 * atspi_accessible_get_index_in_parent:
455 * @obj: a pointer to the #AtspiAccessible object on which to operate.
457 * Gets the index of an #AtspiAccessible object within its parent's
458 * #AtspiAccessible children list.
460 * Returns: a #glong indicating the index of the #AtspiAccessible object
462 * or -1 if @obj has no containing parent or on exception.
465 atspi_accessible_get_index_in_parent (AtspiAccessible *obj, GError **error)
470 g_return_val_if_fail (obj != NULL, -1);
471 if (_atspi_accessible_test_cache (obj, ATSPI_CACHE_PARENT) &&
472 !obj->accessible_parent)
474 if (!obj->accessible_parent ||
475 !_atspi_accessible_test_cache (obj->accessible_parent,
476 ATSPI_CACHE_CHILDREN))
478 dbus_int32_t ret = -1;
479 _atspi_dbus_call (obj, atspi_interface_accessible,
480 "GetIndexInParent", NULL, "=>i", &ret);
484 l = obj->accessible_parent->children;
487 if (l->data == obj) return i;
498 } Accessibility_Relation;
501 * atspi_accessible_get_relation_set:
502 * @obj: a pointer to the #AtspiAccessible object on which to operate.
504 * Gets the set of #AtspiRelation objects which describes this #AtspiAccessible object's
505 * relationships with other #AtspiAccessible objects.
507 * Returns: (element-type AtspiRelation*) (transfer full): a #GArray of
508 * #AtspiRelation pointers or NULL on exception.
511 atspi_accessible_get_relation_set (AtspiAccessible *obj, GError **error)
514 DBusMessageIter iter, iter_array;
517 g_return_val_if_fail (obj != NULL, NULL);
519 reply = _atspi_dbus_call_partial (obj, atspi_interface_accessible, "GetRelationSet", error, "");
522 _ATSPI_DBUS_CHECK_SIG (reply, "a(ua(so))", error, NULL);
524 ret = g_array_new (TRUE, TRUE, sizeof (AtspiRelation *));
525 dbus_message_iter_init (reply, &iter);
526 dbus_message_iter_recurse (&iter, &iter_array);
527 while (dbus_message_iter_get_arg_type (&iter_array) != DBUS_TYPE_INVALID)
529 AtspiRelation *relation;
530 relation = _atspi_relation_new_from_iter (&iter_array);
531 ret = g_array_append_val (ret, relation);
532 dbus_message_iter_next (&iter_array);
534 dbus_message_unref (reply);
539 * atspi_accessible_get_role:
540 * @obj: a pointer to the #AtspiAccessible object on which to operate.
542 * Gets the UI role played by an #AtspiAccessible object.
543 * This role's name can be obtained via atspi_accessible_get_role_name ().
545 * Returns: the #AtspiRole of an #AtspiAccessible object.
549 atspi_accessible_get_role (AtspiAccessible *obj, GError **error)
551 g_return_val_if_fail (obj != NULL, ATSPI_ROLE_INVALID);
553 if (!_atspi_accessible_test_cache (obj, ATSPI_CACHE_ROLE))
556 /* TODO: Make this a property */
557 if (_atspi_dbus_call (obj, atspi_interface_accessible, "GetRole", error, "=>u", &role))
560 _atspi_accessible_add_cache (obj, ATSPI_CACHE_ROLE);
567 * atspi_accessible_get_role_name:
568 * @obj: a pointer to the #AtspiAccessible object on which to operate.
570 * Gets a UTF-8 string corresponding to the name of the role played by an object.
571 * This method will return useful values for roles that fall outside the
572 * enumeration used in atspi_accessible_get_role ().
574 * Returns: a UTF-8 string specifying the type of UI role played by an
575 * #AtspiAccessible object.
579 atspi_accessible_get_role_name (AtspiAccessible *obj, GError **error)
581 gchar *retval = NULL;
584 g_return_val_if_fail (obj != NULL, NULL);
586 role = atspi_accessible_get_role (obj, error);
587 if (role >= 0 && role < ATSPI_ROLE_COUNT && role != ATSPI_ROLE_EXTENDED)
588 return atspi_role_get_name (role);
590 _atspi_dbus_call (obj, atspi_interface_accessible, "GetRoleName", error, "=>s", &retval);
593 retval = g_strdup ("");
599 * atspi_accessible_get_localized_role_name:
600 * @obj: a pointer to the #AtspiAccessible object on which to operate.
602 * Gets a UTF-8 string corresponding to the name of the role played by an
603 * object, translated to the current locale.
604 * This method will return useful values for roles that fall outside the
605 * enumeration used in atspi_accessible_getRole ().
607 * Returns: a localized, UTF-8 string specifying the type of UI role played
608 * by an #AtspiAccessible object.
612 atspi_accessible_get_localized_role_name (AtspiAccessible *obj, GError **error)
616 g_return_val_if_fail (obj != NULL, NULL);
618 _atspi_dbus_call (obj, atspi_interface_accessible, "GetLocalizedRoleName", error, "=>s", &retval);
621 return g_strdup ("");
626 static AtspiStateSet *
629 AtspiStateSet *set = atspi_state_set_new (NULL);
630 atspi_state_set_add (set, ATSPI_STATE_DEFUNCT);
635 * atspi_accessible_get_state_set:
636 * @obj: a pointer to the #AtspiAccessible object on which to operate.
638 * Gets the states currently held by an object.
640 * Returns: (transfer full): a pointer to an #AtspiStateSet representing an
641 * object's current state set.
644 atspi_accessible_get_state_set (AtspiAccessible *obj)
646 /* TODO: Should take a GError **, but would be an API break */
647 if (!obj->parent.app || !obj->parent.app->bus)
648 return defunct_set ();
650 if (!_atspi_accessible_test_cache (obj, ATSPI_CACHE_STATES))
653 DBusMessageIter iter;
654 reply = _atspi_dbus_call_partial (obj, atspi_interface_accessible,
655 "GetState", NULL, "");
656 _ATSPI_DBUS_CHECK_SIG (reply, "au", NULL, defunct_set ());
657 dbus_message_iter_init (reply, &iter);
658 _atspi_dbus_set_state (obj, &iter);
659 dbus_message_unref (reply);
660 _atspi_accessible_add_cache (obj, ATSPI_CACHE_STATES);
662 return g_object_ref (obj->states);
666 * atspi_accessible_get_attributes:
667 * @obj: The #AtspiAccessible being queried.
669 * Gets the #AttributeSet representing any assigned
670 * name-value pair attributes or annotations for this object.
671 * For typographic, textual, or textually-semantic attributes, see
672 * atspi_text_get_attributes instead.
674 * Returns: (element-type gchar* gchar*) (transfer full): The name-value-pair
675 * attributes assigned to this object.
678 atspi_accessible_get_attributes (AtspiAccessible *obj, GError **error)
680 DBusMessage *message;
682 g_return_val_if_fail (obj != NULL, NULL);
684 if (obj->priv->cache)
686 GValue *val = g_hash_table_lookup (obj->priv->cache, "Attributes");
688 return g_value_dup_boxed (val);
691 if (!_atspi_accessible_test_cache (obj, ATSPI_CACHE_ATTRIBUTES))
693 message = _atspi_dbus_call_partial (obj, atspi_interface_accessible,
694 "GetAttributes", error, "");
695 obj->attributes = _atspi_dbus_return_hash_from_message (message);
696 _atspi_accessible_add_cache (obj, ATSPI_CACHE_ATTRIBUTES);
699 if (!obj->attributes)
701 return g_hash_table_ref (obj->attributes);
705 add_to_attribute_array (gpointer key, gpointer value, gpointer data)
707 GArray **array = (GArray **)data;
708 gchar *str = g_strconcat (key, ":", value, NULL);
709 *array = g_array_append_val (*array, str);
713 * atspi_accessible_get_attributes_as_array:
714 * @obj: The #AtspiAccessible being queried.
716 * Gets a #GArray representing any assigned
717 * name-value pair attributes or annotations for this object.
718 * For typographic, textual, or textually-semantic attributes, see
719 * atspi_text_get_attributes_as_array instead.
721 * Returns: (element-type gchar*) (transfer full): The name-value-pair
722 * attributes assigned to this object.
725 atspi_accessible_get_attributes_as_array (AtspiAccessible *obj, GError **error)
727 DBusMessage *message;
729 g_return_val_if_fail (obj != NULL, NULL);
731 if (obj->priv->cache)
733 GValue *val = g_hash_table_lookup (obj->priv->cache, "Attributes");
736 GArray *array = g_array_new (TRUE, TRUE, sizeof (gchar *));
737 GHashTable *attributes = g_value_get_boxed (val);
738 g_hash_table_foreach (attributes, add_to_attribute_array, &array);
743 message = _atspi_dbus_call_partial (obj, atspi_interface_accessible, "GetAttributes", error, "");
744 return _atspi_dbus_return_attribute_array_from_message (message);
748 * atspi_accessible_get_application:
749 * @obj: The #AtspiAccessible being queried.
751 * Gets the containing #AtspiApplication for an object.
753 * Returns: (transfer full): the containing #AtspiApplication instance for
757 atspi_accessible_get_application (AtspiAccessible *obj, GError **error)
759 AtspiAccessible *parent;
764 parent = atspi_accessible_get_parent (obj, NULL);
765 if (!parent && obj->parent.app &&
766 atspi_accessible_get_role (obj, NULL) != ATSPI_ROLE_APPLICATION)
768 AtspiAccessible *root = g_object_ref (obj->parent.app->root);
771 g_object_unref (obj);
772 if (atspi_accessible_get_role (root, NULL) == ATSPI_ROLE_DESKTOP_FRAME)
774 g_object_unref (root);
780 if (!parent || parent == obj ||
781 atspi_accessible_get_role (parent, NULL) == ATSPI_ROLE_DESKTOP_FRAME)
784 g_object_unref (parent);
787 g_object_unref (obj);
792 /* Application-specific methods */
795 * atspi_accessible_get_toolkit_name:
796 * @obj: a pointer to the #AtspiAccessible object on which to operate.
798 * Gets the toolkit name for an #AtspiAccessible object.
799 * Only works on application root objects.
801 * Returns: a UTF-8 string indicating the toolkit name for the #AtspiAccessible object or NULL on exception.
804 atspi_accessible_get_toolkit_name (AtspiAccessible *obj, GError **error)
806 g_return_val_if_fail (obj != NULL, NULL);
808 if (!obj->parent.app)
811 if (!obj->parent.app->toolkit_name)
812 _atspi_dbus_get_property (obj, atspi_interface_application, "ToolkitName",
813 error, "s", &obj->parent.app->toolkit_name);
815 return g_strdup (obj->parent.app->toolkit_name);
819 * atspi_accessible_get_toolkit_version:
820 * @obj: a pointer to the #AtspiAccessible object on which to operate.
822 * Gets the toolkit version for an #AtspiAccessible object.
823 * Only works on application root objects.
825 * Returns: a UTF-8 string indicating the toolkit version for the #AtspiAccessible object or NULL on exception.
828 atspi_accessible_get_toolkit_version (AtspiAccessible *obj, GError **error)
830 g_return_val_if_fail (obj != NULL, NULL);
832 if (!obj->parent.app)
835 if (!obj->parent.app->toolkit_version)
836 _atspi_dbus_get_property (obj, atspi_interface_application, "Version",
837 error, "s", &obj->parent.app->toolkit_version);
839 return g_strdup (obj->parent.app->toolkit_version);
843 * atspi_accessible_get_atspi_version:
844 * @obj: a pointer to the #AtspiAccessible object on which to operate.
846 * Gets the AT-SPI IPC specification version supported by the application
847 * pointed to by the #AtspiAccessible object.
848 * Only works on application root objects.
850 * Returns: a UTF-8 string indicating the AT-SPI version for the #AtspiAccessible object or NULL on exception.
853 atspi_accessible_get_atspi_version (AtspiAccessible *obj, GError **error)
855 g_return_val_if_fail (obj != NULL, NULL);
857 if (!obj->parent.app)
860 if (!obj->parent.app->atspi_version)
861 _atspi_dbus_get_property (obj, atspi_interface_application, "AtspiVersion",
862 error, "s", &obj->parent.app->atspi_version);
864 return g_strdup (obj->parent.app->atspi_version);
868 * atspi_accessible_get_id:
869 * @obj: a pointer to the #AtspiAccessible object on which to operate.
871 * Gets the application id for a #AtspiAccessible object.
872 * Only works on application root objects.
874 * Returns: a positive #gint indicating the id for the #AtspiAccessible object
875 * or -1 on exception.
878 atspi_accessible_get_id (AtspiAccessible *obj, GError **error)
882 g_return_val_if_fail (obj != NULL, -1);
884 if (!_atspi_dbus_get_property (obj, atspi_interface_application, "Id", error, "i", &ret))
890 /* Interface query methods */
893 _atspi_accessible_is_a (AtspiAccessible *accessible,
894 const char *interface_name)
898 if (accessible == NULL)
903 if (!_atspi_accessible_test_cache (accessible, ATSPI_CACHE_INTERFACES))
906 DBusMessageIter iter;
907 reply = _atspi_dbus_call_partial (accessible, atspi_interface_accessible,
908 "GetInterfaces", NULL, "");
909 _ATSPI_DBUS_CHECK_SIG (reply, "as", NULL, FALSE);
910 dbus_message_iter_init (reply, &iter);
911 _atspi_dbus_set_interfaces (accessible, &iter);
912 dbus_message_unref (reply);
913 _atspi_accessible_add_cache (accessible, ATSPI_CACHE_INTERFACES);
916 n = _atspi_get_iface_num (interface_name);
917 if (n == -1) return FALSE;
918 return (gboolean) ((accessible->interfaces & (1 << n))? TRUE: FALSE);
922 * atspi_accessible_is_action:
923 * @obj: a pointer to the #AtspiAccessible instance to query.
925 * Query whether the specified #AtspiAccessible implements the
926 * #AtspiAction interface.
928 * Returns: #TRUE if @obj implements the #AtspiAction interface,
932 atspi_accessible_is_action (AtspiAccessible *obj)
934 return _atspi_accessible_is_a (obj,
935 atspi_interface_action);
939 * atspi_accessible_is_application:
940 * @obj: a pointer to the #AtspiAccessible instance to query.
942 * Query whether the specified #AtspiAccessible implements the
943 * #AtspiApplication interface.
945 * Returns: #TRUE if @obj implements the #AtspiApplication interface,
949 atspi_accessible_is_application (AtspiAccessible *obj)
951 return _atspi_accessible_is_a (obj,
952 atspi_interface_application);
956 * atspi_accessible_is_collection:
957 * @obj: a pointer to the #AtspiAccessible instance to query.
959 * Query whether the specified #AtspiAccessible implements the
960 * #AtspiCollection interface.
962 * Returns: #TRUE if @obj implements the #AtspiCollection interface,
966 atspi_accessible_is_collection (AtspiAccessible *obj)
968 return _atspi_accessible_is_a (obj,
969 atspi_interface_collection);
973 * atspi_accessible_is_component:
974 * @obj: a pointer to the #AtspiAccessible instance to query.
976 * Query whether the specified #AtspiAccessible implements #AtspiComponent.
978 * Returns: #TRUE if @obj implements the #AtspiComponent interface,
982 atspi_accessible_is_component (AtspiAccessible *obj)
984 return _atspi_accessible_is_a (obj,
985 atspi_interface_component);
989 * atspi_accessible_is_document:
990 * @obj: a pointer to the #AtspiAccessible instance to query.
992 * Query whether the specified #AtspiAccessible implements the
993 * #AtspiDocument interface.
995 * Returns: #TRUE if @obj implements the #AtspiDocument interface,
999 atspi_accessible_is_document (AtspiAccessible *obj)
1001 return _atspi_accessible_is_a (obj,
1002 atspi_interface_document);
1006 * atspi_accessible_is_editable_text:
1007 * @obj: a pointer to the #AtspiAccessible instance to query.
1009 * Query whether the specified #AtspiAccessible implements the
1010 * #AtspiEditableText interface.
1012 * Returns: #TRUE if @obj implements the #AtspiEditableText interface,
1016 atspi_accessible_is_editable_text (AtspiAccessible *obj)
1018 return _atspi_accessible_is_a (obj,
1019 atspi_interface_editable_text);
1023 * atspi_accessible_is_hypertext:
1024 * @obj: a pointer to the #AtspiAccessible instance to query.
1026 * Query whether the specified #AtspiAccessible implements the
1027 * #AtspiHypertext interface.
1029 * Returns: #TRUE if @obj implements the #AtspiHypertext interface,
1033 atspi_accessible_is_hypertext (AtspiAccessible *obj)
1035 return _atspi_accessible_is_a (obj,
1036 atspi_interface_hypertext);
1040 * atspi_accessible_is_hyperlink:
1041 * @obj: a pointer to the #AtspiAccessible instance to query.
1043 * Query whether the specified #AtspiAccessible implements the
1044 * #AtspiHyperlink interface.
1046 * Returns: #TRUE if @obj implements the #AtspiHypertext interface,
1050 atspi_accessible_is_hyperlink (AtspiAccessible *obj)
1052 return _atspi_accessible_is_a (obj,
1053 atspi_interface_hyperlink);
1057 * atspi_accessible_is_image:
1058 * @obj: a pointer to the #AtspiAccessible instance to query.
1060 * Query whether the specified #AtspiAccessible implements the
1061 * #AtspiImage interface.
1063 * Returns: #TRUE if @obj implements the #AtspiImage interface,
1067 atspi_accessible_is_image (AtspiAccessible *obj)
1069 return _atspi_accessible_is_a (obj,
1070 atspi_interface_image);
1074 * atspi_accessible_is_selection:
1075 * @obj: a pointer to the #AtspiAccessible instance to query.
1077 * Query whether the specified #AtspiAccessible implements the
1078 * #AtspiSelection interface.
1080 * Returns: #TRUE if @obj implements the #AtspiSelection interface,
1084 atspi_accessible_is_selection (AtspiAccessible *obj)
1086 return _atspi_accessible_is_a (obj,
1087 atspi_interface_selection);
1091 * atspi_accessible_is_table:
1092 * @obj: a pointer to the #AtspiAccessible instance to query.
1094 * Query whether the specified #AtspiAccessible implements the
1095 * #AtspiTable interface.
1097 * Returns: #TRUE if @obj implements the #AtspiTable interface,
1101 atspi_accessible_is_table (AtspiAccessible *obj)
1103 return _atspi_accessible_is_a (obj,
1104 atspi_interface_table);
1108 * atspi_accessible_is_table_cell:
1109 * @obj: a pointer to the #AtspiAccessible instance to query.
1111 * Query whether the specified #AtspiAccessible implements the
1112 * #AtspiTableCell interface.
1114 * Returns: #TRUE if @obj implements the #AtspiTable interface,
1118 atspi_accessible_is_table_cell (AtspiAccessible *obj)
1120 return _atspi_accessible_is_a (obj,
1121 atspi_interface_table_cell);
1125 * atspi_accessible_is_streamable_content:
1126 * @obj: a pointer to the #AtspiAccessible instance to query.
1128 * Query whether the specified #AtspiAccessible implements the
1129 * #AtspiStreamableContent interface.
1131 * Returns: #TRUE if @obj implements the #AtspiStreamableContent interface,
1135 atspi_accessible_is_streamable_content (AtspiAccessible *obj)
1138 return _atspi_accessible_is_a (obj,
1139 atspi_interface_streamable_content);
1141 g_warning ("Streamable content not implemented");
1147 * atspi_accessible_is_text:
1148 * @obj: a pointer to the #AtspiAccessible instance to query.
1150 * Query whether the specified #AtspiAccessible implements the
1151 * #AtspiText interface.
1153 * Returns: #TRUE if @obj implements the #AtspiText interface,
1157 atspi_accessible_is_text (AtspiAccessible *obj)
1159 return _atspi_accessible_is_a (obj,
1160 atspi_interface_text);
1164 * atspi_accessible_is_value:
1165 * @obj: a pointer to the #AtspiAccessible instance to query.
1167 * Query whether the specified #AtspiAccessible implements the
1168 * #AtspiValue interface.
1170 * Returns: #TRUE if @obj implements the #AtspiValue interface,
1174 atspi_accessible_is_value (AtspiAccessible *obj)
1176 return _atspi_accessible_is_a (obj,
1177 atspi_interface_value);
1181 * atspi_accessible_get_action: (rename-to atspi_accessible_get_action_iface)
1182 * @obj: a pointer to the #AtspiAccessible instance to query.
1184 * Gets the #AtspiAction interface for an #AtspiAccessible.
1186 * Returns: (transfer full): a pointer to an #AtspiAction interface
1187 * instance, or NULL if @obj does not implement #AtspiAction.
1189 * Deprecated: 2.10: Use atspi_accessible_get_action_iface instead.
1192 atspi_accessible_get_action (AtspiAccessible *accessible)
1194 return (_atspi_accessible_is_a (accessible, atspi_interface_action) ?
1195 g_object_ref (ATSPI_ACTION (accessible)) : NULL);
1199 * atspi_accessible_get_action_iface:
1200 * @obj: a pointer to the #AtspiAccessible instance to query.
1202 * Gets the #AtspiAction interface for an #AtspiAccessible.
1204 * Returns: (transfer full): a pointer to an #AtspiAction interface
1205 * instance, or NULL if @obj does not implement #AtspiAction.
1208 atspi_accessible_get_action_iface (AtspiAccessible *accessible)
1210 return (_atspi_accessible_is_a (accessible, atspi_interface_action) ?
1211 g_object_ref (ATSPI_ACTION (accessible)) : NULL);
1215 * atspi_accessible_get_collection: (rename-to atspi_accessible_get_collection_iface)
1216 * @obj: a pointer to the #AtspiAccessible instance to query.
1218 * Gets the #AtspiCollection interface for an #AtspiAccessible.
1220 * Returns: (transfer full): a pointer to an #AtspiCollection interface
1221 * instance, or NULL if @obj does not implement #AtspiCollection.
1223 * Deprecated: 2.10: Use atspi_accessible_get_collection_iface instead.
1226 atspi_accessible_get_collection (AtspiAccessible *accessible)
1228 return (_atspi_accessible_is_a (accessible, atspi_interface_collection) ?
1229 g_object_ref (ATSPI_COLLECTION (accessible)) : NULL);
1233 * atspi_accessible_get_collection_iface:
1234 * @obj: a pointer to the #AtspiAccessible instance to query.
1236 * Gets the #AtspiCollection interface for an #AtspiAccessible.
1238 * Returns: (transfer full): a pointer to an #AtspiCollection interface
1239 * instance, or NULL if @obj does not implement #AtspiCollection.
1242 atspi_accessible_get_collection_iface (AtspiAccessible *accessible)
1244 return (_atspi_accessible_is_a (accessible, atspi_interface_collection) ?
1245 g_object_ref (ATSPI_COLLECTION (accessible)) : NULL);
1249 * atspi_accessible_get_component: (rename-to atspi_accessible_get_component_iface)
1250 * @obj: a pointer to the #AtspiAccessible instance to query.
1252 * Gets the #AtspiComponent interface for an #AtspiAccessible.
1254 * Returns: (transfer full): a pointer to an #AtspiComponent interface
1255 * instance, or NULL if @obj does not implement #AtspiComponent.
1257 * Deprecated: 2.10: Use atspi_accessible_get_component_iface instead.
1260 atspi_accessible_get_component (AtspiAccessible *obj)
1262 return (_atspi_accessible_is_a (obj, atspi_interface_component) ?
1263 g_object_ref (ATSPI_COMPONENT (obj)) : NULL);
1267 * atspi_accessible_get_component_iface:
1268 * @obj: a pointer to the #AtspiAccessible instance to query.
1270 * Gets the #AtspiComponent interface for an #AtspiAccessible.
1272 * Returns: (transfer full): a pointer to an #AtspiComponent interface
1273 * instance, or NULL if @obj does not implement #AtspiComponent.
1276 atspi_accessible_get_component_iface (AtspiAccessible *obj)
1278 return (_atspi_accessible_is_a (obj, atspi_interface_component) ?
1279 g_object_ref (ATSPI_COMPONENT (obj)) : NULL);
1283 * atspi_accessible_get_document: (rename-to atspi_accessible_get_document_iface)
1284 * @obj: a pointer to the #AtspiAccessible instance to query.
1286 * Gets the #AtspiDocument interface for an #AtspiAccessible.
1288 * Returns: (transfer full): a pointer to an #AtspiDocument interface
1289 * instance, or NULL if @obj does not implement #AtspiDocument.
1291 * Deprecated: 2.10: Use atspi_accessible_get_document_iface instead.
1294 atspi_accessible_get_document (AtspiAccessible *accessible)
1296 return (_atspi_accessible_is_a (accessible, atspi_interface_document) ?
1297 g_object_ref (ATSPI_DOCUMENT (accessible)) : NULL);
1301 * atspi_accessible_get_document_iface:
1302 * @obj: a pointer to the #AtspiAccessible instance to query.
1304 * Gets the #AtspiDocument interface for an #AtspiAccessible.
1306 * Returns: (transfer full): a pointer to an #AtspiDocument interface
1307 * instance, or NULL if @obj does not implement #AtspiDocument.
1310 atspi_accessible_get_document_iface (AtspiAccessible *accessible)
1312 return (_atspi_accessible_is_a (accessible, atspi_interface_document) ?
1313 g_object_ref (ATSPI_DOCUMENT (accessible)) : NULL);
1317 * atspi_accessible_get_editable_text: (rename-to atspi_accessible_get_editable_text_iface)
1318 * @obj: a pointer to the #AtspiAccessible instance to query.
1320 * Gets the #AtspiEditableText interface for an #AtspiAccessible.
1322 * Returns: (transfer full): a pointer to an #AtspiEditableText interface
1323 * instance, or NULL if @obj does not implement #AtspiEditableText.
1325 * Deprecated: 2.10: Use atspi_accessible_get_editable_text_iface instead.
1328 atspi_accessible_get_editable_text (AtspiAccessible *accessible)
1330 return (_atspi_accessible_is_a (accessible, atspi_interface_editable_text) ?
1331 g_object_ref (ATSPI_EDITABLE_TEXT (accessible)) : NULL);
1335 * atspi_accessible_get_editable_text_iface:
1336 * @obj: a pointer to the #AtspiAccessible instance to query.
1338 * Gets the #AtspiEditableText interface for an #AtspiAccessible.
1340 * Returns: (transfer full): a pointer to an #AtspiEditableText interface
1341 * instance, or NULL if @obj does not implement #AtspiEditableText.
1344 atspi_accessible_get_editable_text_iface (AtspiAccessible *accessible)
1346 return (_atspi_accessible_is_a (accessible, atspi_interface_editable_text) ?
1347 g_object_ref (ATSPI_EDITABLE_TEXT (accessible)) : NULL);
1351 * atspi_accessible_get_hyperlink:
1352 * @obj: a pointer to the #AtspiAccessible object on which to operate.
1354 * Gets the #AtspiHyperlink interface for an #AtspiAccessible.
1356 * Returns: (transfer full): the #AtspiHyperlink object associated with
1357 * the given #AtspiAccessible, or NULL if not supported.
1360 atspi_accessible_get_hyperlink (AtspiAccessible *accessible)
1362 return (_atspi_accessible_is_a (accessible, atspi_interface_hyperlink) ?
1363 _atspi_hyperlink_new (accessible->parent.app, accessible->parent.path) : NULL);
1367 * atspi_accessible_get_hypertext: (rename-to atspi_accessible_get_hypertext_iface)
1368 * @obj: a pointer to the #AtspiAccessible instance to query.
1370 * Gets the #AtspiHypertext interface for an #AtspiAccessible.
1372 * Returns: (transfer full): a pointer to an #AtspiHypertext interface
1373 * instance, or NULL if @obj does not implement #AtspiHypertext.
1375 * Deprecated: 2.10: Use atspi_accessible_get_hypertext_iface instead.
1378 atspi_accessible_get_hypertext (AtspiAccessible *accessible)
1380 return (_atspi_accessible_is_a (accessible, atspi_interface_hypertext) ?
1381 g_object_ref (ATSPI_HYPERTEXT (accessible)) : NULL);
1385 * atspi_accessible_get_hypertext_iface:
1386 * @obj: a pointer to the #AtspiAccessible instance to query.
1388 * Gets the #AtspiHypertext interface for an #AtspiAccessible.
1390 * Returns: (transfer full): a pointer to an #AtspiHypertext interface
1391 * instance, or NULL if @obj does not implement #AtspiHypertext.
1394 atspi_accessible_get_hypertext_iface (AtspiAccessible *accessible)
1396 return (_atspi_accessible_is_a (accessible, atspi_interface_hypertext) ?
1397 g_object_ref (ATSPI_HYPERTEXT (accessible)) : NULL);
1401 * atspi_accessible_get_image: (rename-to atspi_accessible_get_image_iface)
1402 * @obj: a pointer to the #AtspiAccessible instance to query.
1404 * Gets the #AtspiImage interface for an #AtspiAccessible.
1406 * Returns: (transfer full): a pointer to an #AtspiImage interface instance, or
1407 * NULL if @obj does not implement #AtspiImage.
1409 * Deprecated: 2.10: Use atspi_accessible_get_image_iface instead.
1412 atspi_accessible_get_image (AtspiAccessible *accessible)
1414 return (_atspi_accessible_is_a (accessible, atspi_interface_image) ?
1415 g_object_ref (ATSPI_IMAGE (accessible)) : NULL);
1419 * atspi_accessible_get_image_iface:
1420 * @obj: a pointer to the #AtspiAccessible instance to query.
1422 * Gets the #AtspiImage interface for an #AtspiAccessible.
1424 * Returns: (transfer full): a pointer to an #AtspiImage interface instance, or
1425 * NULL if @obj does not implement #AtspiImage.
1428 atspi_accessible_get_image_iface (AtspiAccessible *accessible)
1430 return (_atspi_accessible_is_a (accessible, atspi_interface_image) ?
1431 g_object_ref (ATSPI_IMAGE (accessible)) : NULL);
1435 * atspi_accessible_get_selection: (rename-to atspi_accessible_get_selection_iface)
1436 * @obj: a pointer to the #AtspiAccessible instance to query.
1438 * Gets the #AtspiSelection interface for an #AtspiAccessible.
1440 * Returns: (transfer full): a pointer to an #AtspiSelection interface
1441 * instance, or NULL if @obj does not implement #AtspiSelection.
1443 * Deprecated: 2.10: Use atspi_accessible_get_selection_iface instead.
1446 atspi_accessible_get_selection (AtspiAccessible *accessible)
1448 return (_atspi_accessible_is_a (accessible, atspi_interface_selection) ?
1449 g_object_ref (ATSPI_SELECTION (accessible)) : NULL);
1453 * atspi_accessible_get_selection_iface:
1454 * @obj: a pointer to the #AtspiAccessible instance to query.
1456 * Gets the #AtspiSelection interface for an #AtspiAccessible.
1458 * Returns: (transfer full): a pointer to an #AtspiSelection interface
1459 * instance, or NULL if @obj does not implement #AtspiSelection.
1462 atspi_accessible_get_selection_iface (AtspiAccessible *accessible)
1464 return (_atspi_accessible_is_a (accessible, atspi_interface_selection) ?
1465 g_object_ref (ATSPI_SELECTION (accessible)) : NULL);
1470 * atspi_accessible_get_streamable_content:
1471 * @obj: a pointer to the #AtspiAccessible instance to query.
1473 * Gets the #AtspiStreamableContent interface for an #AtspiAccessible.
1475 * Returns: (transfer full): a pointer to an #AtspiStreamableContent interface
1476 * instance, or NULL if @obj does not implement #AtspiStreamableContent.
1478 AtspiStreamableContent *
1479 atspi_accessible_get_streamable_content (AtspiAccessible *accessible)
1481 return (_atspi_accessible_is_a (accessible, atspi_interface_streamable_content) ?
1487 * atspi_accessible_get_table: (rename-to atspi_accessible_get_table_iface)
1488 * @obj: a pointer to the #AtspiAccessible instance to query.
1490 * Gets the #AtspiTable interface for an #AtspiAccessible.
1492 * Returns: (transfer full): a pointer to an #AtspiTable interface instance, or
1493 * NULL if @obj does not implement #AtspiTable.
1495 * Deprecated: 2.10: Use atspi_accessible_get_table_iface instead.
1498 atspi_accessible_get_table (AtspiAccessible *obj)
1500 return (_atspi_accessible_is_a (obj, atspi_interface_table) ?
1501 g_object_ref (ATSPI_TABLE (obj)) : NULL);
1505 * atspi_accessible_get_table_iface:
1506 * @obj: a pointer to the #AtspiAccessible instance to query.
1508 * Gets the #AtspiTable interface for an #AtspiAccessible.
1510 * Returns: (transfer full): a pointer to an #AtspiTable interface instance, or
1511 * NULL if @obj does not implement #AtspiTable.
1514 atspi_accessible_get_table_iface (AtspiAccessible *obj)
1516 return (_atspi_accessible_is_a (obj, atspi_interface_table) ?
1517 g_object_ref (ATSPI_TABLE (obj)) : NULL);
1521 * atspi_accessible_get_table_cell:
1522 * @obj: a pointer to the #AtspiAccessible instance to query.
1524 * Gets the #AtspiTableCell interface for an #AtspiAccessible.
1526 * Returns: (transfer full): a pointer to an #AtspiTableCell interface instance,
1527 * or NULL if @obj does not implement #AtspiTable.
1530 atspi_accessible_get_table_cell (AtspiAccessible *obj)
1532 return (_atspi_accessible_is_a (obj, atspi_interface_table_cell) ?
1533 g_object_ref (ATSPI_TABLE_CELL (obj)) : NULL);
1537 * atspi_accessible_get_text: (rename-to atspi_accessible_get_text_iface)
1538 * @obj: a pointer to the #AtspiAccessible instance to query.
1540 * Gets the #AtspiTable interface for an #AtspiAccessible.
1542 * Returns: (transfer full): a pointer to an #AtspiText interface instance, or
1543 * NULL if @obj does not implement #AtspiText.
1545 * Deprecated: 2.10: Use atspi_accessible_get_text_iface instead.
1548 atspi_accessible_get_text (AtspiAccessible *obj)
1550 return (_atspi_accessible_is_a (obj, atspi_interface_text) ?
1551 g_object_ref (ATSPI_TEXT (obj)) : NULL);
1555 * atspi_accessible_get_text_iface:
1556 * @obj: a pointer to the #AtspiAccessible instance to query.
1558 * Gets the #AtspiTable interface for an #AtspiAccessible.
1560 * Returns: (transfer full): a pointer to an #AtspiText interface instance, or
1561 * NULL if @obj does not implement #AtspiText.
1564 atspi_accessible_get_text_iface (AtspiAccessible *obj)
1566 return (_atspi_accessible_is_a (obj, atspi_interface_text) ?
1567 g_object_ref (ATSPI_TEXT (obj)) : NULL);
1571 * atspi_accessible_get_value: (rename-to atspi_accessible_get_value_iface)
1572 * @obj: a pointer to the #AtspiAccessible instance to query.
1574 * Gets the #AtspiTable interface for an #AtspiAccessible.
1576 * Returns: (transfer full): a pointer to an #AtspiValue interface instance, or
1577 * NULL if @obj does not implement #AtspiValue.
1579 * Deprecated: 2.10: Use atspi_accessible_get_value_iface instead.
1582 atspi_accessible_get_value (AtspiAccessible *accessible)
1584 return (_atspi_accessible_is_a (accessible, atspi_interface_value) ?
1585 g_object_ref (ATSPI_VALUE (accessible)) : NULL);
1589 * atspi_accessible_get_value_iface:
1590 * @obj: a pointer to the #AtspiAccessible instance to query.
1592 * Gets the #AtspiTable interface for an #AtspiAccessible.
1594 * Returns: (transfer full): a pointer to an #AtspiValue interface instance, or
1595 * NULL if @obj does not implement #AtspiValue.
1598 atspi_accessible_get_value_iface (AtspiAccessible *accessible)
1600 return (_atspi_accessible_is_a (accessible, atspi_interface_value) ?
1601 g_object_ref (ATSPI_VALUE (accessible)) : NULL);
1605 append_const_val (GArray *array, const gchar *val)
1607 gchar *dup = g_strdup (val);
1610 g_array_append_val (array, dup);
1614 * atspi_accessible_get_interfaces:
1615 * @obj: The #AtspiAccessible to query.
1617 * A set of pointers to all interfaces supported by an #AtspiAccessible.
1619 * Returns: (element-type gchar*) (transfer full): A #GArray of strings
1620 * describing the interfaces supported by the object. Interfaces are
1621 * denoted in short-hand (i.e. "Component", "Text" etc.).
1624 atspi_accessible_get_interfaces (AtspiAccessible *obj)
1626 GArray *ret = g_array_new (TRUE, TRUE, sizeof (gchar *));
1628 g_return_val_if_fail (obj != NULL, NULL);
1630 append_const_val (ret, "Accessible");
1631 if (atspi_accessible_is_action (obj))
1632 append_const_val (ret, "Action");
1633 if (atspi_accessible_is_collection (obj))
1634 append_const_val (ret, "Collection");
1635 if (atspi_accessible_is_component (obj))
1636 append_const_val (ret, "Component");
1637 if (atspi_accessible_is_document (obj))
1638 append_const_val (ret, "Document");
1639 if (atspi_accessible_is_editable_text (obj))
1640 append_const_val (ret, "EditableText");
1641 if (atspi_accessible_is_hypertext (obj))
1642 append_const_val (ret, "Hypertext");
1643 if (atspi_accessible_is_hyperlink (obj))
1644 append_const_val (ret, "Hyperlink");
1645 if (atspi_accessible_is_image (obj))
1646 append_const_val (ret, "Image");
1647 if (atspi_accessible_is_selection (obj))
1648 append_const_val (ret, "Selection");
1649 if (atspi_accessible_is_table (obj))
1650 append_const_val (ret, "Table");
1651 if (atspi_accessible_is_table_cell (obj))
1652 append_const_val (ret, "TableCell");
1653 if (atspi_accessible_is_text (obj))
1654 append_const_val (ret, "Text");
1655 if (atspi_accessible_is_value (obj))
1656 append_const_val (ret, "Value");
1662 _atspi_accessible_new (AtspiApplication *app, const gchar *path)
1664 AtspiAccessible *accessible;
1666 accessible = g_object_new (ATSPI_TYPE_ACCESSIBLE, NULL);
1667 g_return_val_if_fail (accessible != NULL, NULL);
1669 accessible->parent.app = g_object_ref (app);
1670 accessible->parent.path = g_strdup (path);
1676 * atspi_accessible_set_cache_mask:
1677 * @accessible: The #AtspiAccessible to operate on. Must be the desktop or
1678 * the root of an application.
1679 * @mask: An #AtspiCache specifying a bit mask of the types of data to cache.
1681 * Sets the type of data to cache for accessibles.
1682 * If this is not set for an application or is reset to ATSPI_CACHE_UNDEFINED,
1683 * then the desktop's cache flag will be used.
1684 * If the desktop's cache flag is also undefined, then all possible data will
1686 * This function is intended to work around bugs in toolkits where the proper
1687 * events are not raised / to aid in testing for such bugs.
1690 atspi_accessible_set_cache_mask (AtspiAccessible *accessible, AtspiCache mask)
1692 g_return_if_fail (accessible != NULL);
1693 g_return_if_fail (accessible->parent.app != NULL);
1694 g_return_if_fail (accessible == accessible->parent.app->root);
1695 accessible->parent.app->cache = mask;
1696 enable_caching = TRUE;
1700 * atspi_accessible_clear_cache:
1701 * @accessible: The #AtspiAccessible whose cache to clear.
1703 * Clears the cached information for the given accessible and all of its
1707 atspi_accessible_clear_cache (AtspiAccessible *accessible)
1713 accessible->cached_properties = ATSPI_CACHE_NONE;
1714 for (l = accessible->children; l; l = l->next)
1715 atspi_accessible_clear_cache (l->data);
1720 * atspi_accessible_get_process_id:
1721 * @accessible: The #AtspiAccessible to query.
1722 * @error: a pointer to a %NULL #GError pointer
1724 * Returns the process id associated with the given accessible. Mainly
1725 * added for debugging; it is a shortcut to explicitly querying the
1726 * accessible's app->bus_name and then calling GetConnectionUnixProcessID.
1728 * Returns: The process ID or undetermined value if @error is set.
1731 atspi_accessible_get_process_id (AtspiAccessible *accessible, GError **error)
1733 DBusMessage *message, *reply;
1734 DBusConnection *bus = _atspi_bus ();
1735 dbus_uint32_t pid = -1;
1738 if (!accessible->parent.app || !accessible->parent.app->bus_name)
1740 g_set_error_literal(error, ATSPI_ERROR, ATSPI_ERROR_IPC, "Process is defunct");
1744 message = dbus_message_new_method_call ("org.freedesktop.DBus",
1745 "/org/freedesktop/DBus",
1746 "org.freedesktop.DBus",
1747 "GetConnectionUnixProcessID");
1748 dbus_message_append_args (message, DBUS_TYPE_STRING,
1749 &accessible->parent.app->bus_name,
1751 dbus_error_init (&d_error);
1752 reply = dbus_connection_send_with_reply_and_block (bus, message, -1, &d_error);
1753 dbus_message_unref (message);
1756 if (!strcmp (dbus_message_get_signature (reply), "u"))
1757 dbus_message_get_args (reply, NULL, DBUS_TYPE_UINT32, &pid, DBUS_TYPE_INVALID);
1758 dbus_message_unref (reply);
1760 if (dbus_error_is_set (&d_error))
1762 g_set_error_literal(error, ATSPI_ERROR, ATSPI_ERROR_IPC, "Process is defunct");
1763 dbus_error_free (&d_error);
1769 _atspi_accessible_get_cache_mask (AtspiAccessible *accessible)
1773 if (!accessible->parent.app)
1774 return ATSPI_CACHE_NONE;
1776 mask = accessible->parent.app->cache;
1777 if (mask == ATSPI_CACHE_UNDEFINED &&
1778 accessible->parent.app->root &&
1779 accessible->parent.app->root->accessible_parent)
1781 AtspiAccessible *desktop = atspi_get_desktop (0);
1782 mask = desktop->parent.app->cache;
1783 g_object_unref (desktop);
1786 if (mask == ATSPI_CACHE_UNDEFINED)
1787 mask = ATSPI_CACHE_DEFAULT;
1793 _atspi_accessible_test_cache (AtspiAccessible *accessible, AtspiCache flag)
1795 AtspiCache mask = _atspi_accessible_get_cache_mask (accessible);
1796 AtspiCache result = accessible->cached_properties & mask & flag;
1797 if (accessible->states && atspi_state_set_contains (accessible->states, ATSPI_STATE_TRANSIENT))
1799 return (result != 0 && (atspi_main_loop || enable_caching ||
1800 flag == ATSPI_CACHE_INTERFACES) &&
1805 _atspi_accessible_add_cache (AtspiAccessible *accessible, AtspiCache flag)
1807 AtspiCache mask = _atspi_accessible_get_cache_mask (accessible);
1809 accessible->cached_properties |= flag & mask;
1813 * atspi_accessible_get_locale:
1814 * @accessible: an #AtspiAccessible
1816 * Gets a UTF-8 string indicating the POSIX-style LC_MESSAGES locale
1821 * Returns: a UTF-8 string indicating the POSIX-style LC_MESSAGES
1822 * locale of @accessible.
1825 atspi_accessible_get_object_locale (AtspiAccessible *accessible, GError **error)
1829 g_return_val_if_fail (accessible != NULL, NULL);
1831 locale = g_object_get_qdata (G_OBJECT (accessible), quark_locale);
1834 if (!_atspi_dbus_get_property (accessible, atspi_interface_accessible,
1835 "Locale", error, "s", &locale))
1838 g_object_set_qdata_full (G_OBJECT (accessible), quark_locale, locale,
1845 free_value (gpointer data)
1847 GValue *value = data;
1849 g_value_unset (value);
1854 _atspi_accessible_ref_cache (AtspiAccessible *accessible)
1856 AtspiAccessiblePrivate *priv = accessible->priv;
1858 priv->cache_ref_count++;
1860 return g_hash_table_ref (priv->cache);
1861 priv->cache = g_hash_table_new_full (g_str_hash, g_str_equal, g_free,
1867 _atspi_accessible_unref_cache (AtspiAccessible *accessible)
1869 AtspiAccessiblePrivate *priv = accessible->priv;
1873 g_hash_table_unref (priv->cache);
1874 if (--priv->cache_ref_count == 0)