2 * AT-SPI - Assistive Technology Service Provider Interface
3 * (Gnome Accessibility Project; http://developer.gnome.org/projects/gap)
5 * Copyright 2001, 2002 Sun Microsystems Inc.,
6 * Copyright 2001, 2002 Ximian, Inc.
7 * Copyright 2010, 2011 Novell, Inc.
9 * This library is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Lesser General Public
11 * License as published by the Free Software Foundation; either
12 * version 2.1 of the License, or (at your option) any later version.
14 * This library is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * Lesser General Public License for more details.
19 * You should have received a copy of the GNU Lesser General Public
20 * License along with this library; if not, write to the
21 * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
22 * Boston, MA 02110-1301, USA.
25 #include "atspi-private.h"
26 #include "atspi-accessible-private.h"
34 static gboolean enable_caching = FALSE;
35 static guint quark_locale;
37 static guint atspi_accessible_signals[LAST_SIGNAL] = { 0, };
40 screen_reader_signal_watcher (GSignalInvocationHint *signal_hint,
42 const GValue *param_values,
46 AtspiAccessible *accessible;
47 GSignalQuery signal_query;
50 DBusMessageIter iter, iter_struct, iter_variant, iter_array;
51 dbus_int32_t detail1, detail2;
52 const char *detail = "";
54 object = g_value_get_object (param_values + 0);
55 g_return_val_if_fail (ATSPI_IS_ACCESSIBLE(object), FALSE);
57 g_signal_query (signal_hint->signal_id, &signal_query);
58 name = signal_query.signal_name;
59 detail1 = g_value_get_int (param_values + 1);
60 detail2 = g_value_get_int (param_values + 2);
61 accessible = ATSPI_ACCESSIBLE (object);
63 signal = dbus_message_new_signal (ATSPI_DBUS_PATH_SCREEN_READER,
64 ATSPI_DBUS_INTERFACE_EVENT_SCREEN_READER,
66 dbus_message_iter_init_append (signal, &iter);
67 dbus_message_iter_append_basic (&iter, DBUS_TYPE_STRING, &detail);
68 dbus_message_iter_append_basic (&iter, DBUS_TYPE_INT32, &detail1);
69 dbus_message_iter_append_basic (&iter, DBUS_TYPE_INT32, &detail2);
70 dbus_message_iter_open_container (&iter, DBUS_TYPE_VARIANT, "(so)",
72 dbus_message_iter_open_container (&iter_variant, DBUS_TYPE_STRUCT, NULL,
74 dbus_message_iter_append_basic (&iter_struct, DBUS_TYPE_STRING, &accessible->parent.app->bus_name);
75 dbus_message_iter_append_basic (&iter_struct, DBUS_TYPE_OBJECT_PATH, &accessible->parent.path);
76 dbus_message_iter_close_container (&iter_variant, &iter_struct);
77 dbus_message_iter_close_container (&iter, &iter_variant);
78 dbus_message_iter_open_container (&iter, DBUS_TYPE_ARRAY, "{sv}",
80 dbus_message_iter_close_container (&iter, &iter_array);
81 dbus_connection_send (_atspi_bus (), signal, NULL);
82 dbus_message_unref (signal);
87 atspi_action_interface_init (AtspiAction *action)
92 atspi_collection_interface_init (AtspiCollection *component)
97 atspi_component_interface_init (AtspiComponent *component)
102 atspi_document_interface_init (AtspiDocument *document)
107 atspi_editable_text_interface_init (AtspiEditableText *editable_text)
112 atspi_hypertext_interface_init (AtspiHypertext *hypertext)
117 atspi_image_interface_init (AtspiImage *image)
122 atspi_selection_interface_init (AtspiSelection *selection)
127 atspi_table_interface_init (AtspiTable *table)
132 atspi_table_cell_interface_init (AtspiTableCell *cell)
137 atspi_text_interface_init (AtspiText *text)
142 atspi_value_interface_init (AtspiValue *value)
146 G_DEFINE_TYPE_WITH_CODE (AtspiAccessible, atspi_accessible, ATSPI_TYPE_OBJECT,
147 G_ADD_PRIVATE (AtspiAccessible)
148 G_IMPLEMENT_INTERFACE (ATSPI_TYPE_ACTION, atspi_action_interface_init)
149 G_IMPLEMENT_INTERFACE (ATSPI_TYPE_COLLECTION, atspi_collection_interface_init)
150 G_IMPLEMENT_INTERFACE (ATSPI_TYPE_COMPONENT, atspi_component_interface_init)
151 G_IMPLEMENT_INTERFACE (ATSPI_TYPE_DOCUMENT, atspi_document_interface_init)
152 G_IMPLEMENT_INTERFACE (ATSPI_TYPE_EDITABLE_TEXT, atspi_editable_text_interface_init)
153 G_IMPLEMENT_INTERFACE (ATSPI_TYPE_HYPERTEXT, atspi_hypertext_interface_init)
154 G_IMPLEMENT_INTERFACE (ATSPI_TYPE_IMAGE, atspi_image_interface_init)
155 G_IMPLEMENT_INTERFACE (ATSPI_TYPE_SELECTION, atspi_selection_interface_init)
156 G_IMPLEMENT_INTERFACE (ATSPI_TYPE_TABLE, atspi_table_interface_init)
157 G_IMPLEMENT_INTERFACE (ATSPI_TYPE_TABLE_CELL, atspi_table_cell_interface_init)
158 G_IMPLEMENT_INTERFACE (ATSPI_TYPE_TEXT, atspi_text_interface_init)
159 G_IMPLEMENT_INTERFACE (ATSPI_TYPE_VALUE, atspi_value_interface_init))
161 #ifdef DEBUG_REF_COUNTS
162 static gint accessible_count = 0;
166 atspi_accessible_unref (GObject *accessible)
168 if (accessible != NULL)
169 g_object_unref(accessible);
173 atspi_accessible_init (AtspiAccessible *accessible)
175 #ifdef DEBUG_REF_COUNTS
177 g_hash_table_insert (_atspi_get_live_refs (), accessible, NULL);
178 g_print("at-spi: init: %d objects\n", accessible_count);
181 accessible->priv = atspi_accessible_get_instance_private (accessible);
183 accessible->children = g_ptr_array_new_with_free_func (atspi_accessible_unref);
187 atspi_accessible_dispose (GObject *object)
189 AtspiAccessible *accessible = ATSPI_ACCESSIBLE (object);
191 AtspiAccessible *parent;
194 /* TODO: Only fire if object not already marked defunct */
195 memset (&e, 0, sizeof (e));
196 e.type = "object:state-changed:defunct";
197 e.source = accessible;
200 _atspi_send_event (&e);
202 g_clear_object (&accessible->states);
204 parent = accessible->accessible_parent;
207 accessible->accessible_parent = NULL;
208 if (parent->children)
209 g_ptr_array_remove (parent->children, accessible);
210 g_object_unref (parent);
213 if (accessible->children) for (i = accessible->children->len - 1; i >= 0; i--)
215 AtspiAccessible *child = g_ptr_array_index (accessible->children, i);
216 if (child && child->accessible_parent == accessible)
218 child->accessible_parent = NULL;
219 g_object_unref (accessible);
223 if (accessible->children)
225 g_ptr_array_free (accessible->children, TRUE);
226 accessible->children = NULL;
229 G_OBJECT_CLASS (atspi_accessible_parent_class) ->dispose (object);
233 atspi_accessible_finalize (GObject *object)
235 AtspiAccessible *accessible = ATSPI_ACCESSIBLE (object);
237 g_free (accessible->description);
238 g_free (accessible->name);
240 if (accessible->attributes)
241 g_hash_table_unref (accessible->attributes);
243 if (accessible->priv->cache)
244 g_hash_table_destroy (accessible->priv->cache);
246 #ifdef DEBUG_REF_COUNTS
248 g_hash_table_remove (_atspi_get_live_refs (), accessible);
249 g_print ("at-spi: finalize: %d objects\n", accessible_count);
252 G_OBJECT_CLASS (atspi_accessible_parent_class)->finalize (object);
254 /* TODO: remove emission hook */
258 atspi_accessible_class_init (AtspiAccessibleClass *klass)
260 GObjectClass *object_class = G_OBJECT_CLASS (klass);
262 object_class->dispose = atspi_accessible_dispose;
263 object_class->finalize = atspi_accessible_finalize;
265 quark_locale = g_quark_from_string ("accessible-locale");
268 * AtspiAccessible::region-changed:
269 * @atspiaccessible: the object which received the signal
270 * @arg1: an integer specifying the current offset of the text being read,
271 * if the object is textual.
272 * @arg2: an integer specifying the ending offset of the text being read,
273 * if the object is textual.
275 * The signal "region-changed" is emitted by a screen reader to indicate
276 * that it is now reading or tracking a new object, or, a new piece of
277 * text within an object. This allows a magnifier to gain the information
278 * needed to highlight the object that the screen reader is reading.
280 atspi_accessible_signals[REGION_CHANGED] =
281 g_signal_new ("region_changed",
282 G_TYPE_FROM_CLASS (klass),
284 G_STRUCT_OFFSET (AtspiAccessibleClass, region_changed),
286 atspi_marshal_VOID__INT_INT,
288 2, G_TYPE_INT, G_TYPE_INT);
290 g_signal_add_emission_hook (atspi_accessible_signals[REGION_CHANGED], 0,
291 screen_reader_signal_watcher, NULL,
292 (GDestroyNotify) NULL);
296 * atspi_accessible_get_name:
297 * @obj: a pointer to the #AtspiAccessible object on which to operate.
299 * Gets the name of an #AtspiAccessible object.
301 * Returns: a UTF-8 string indicating the name of the #AtspiAccessible object
302 * or NULL on exception.
305 atspi_accessible_get_name (AtspiAccessible *obj, GError **error)
307 g_return_val_if_fail (obj != NULL, g_strdup (""));
308 if (!_atspi_accessible_test_cache (obj, ATSPI_CACHE_NAME))
310 if (!_atspi_dbus_get_property (obj, atspi_interface_accessible, "Name", error,
312 return g_strdup ("");
313 _atspi_accessible_add_cache (obj, ATSPI_CACHE_NAME);
315 return g_strdup (obj->name);
320 * atspi_accessible_get_unique_id:
321 * @obj: a pointer to the #AtspiAccessible object on which to operate.
323 * Gets the identificator, uniquely identifying object, or NULL if an error occured.
325 * Returns: a UTF-8 string describing the #AtspiAccessible object
326 * or NULL on exception or NULL object passed.
329 atspi_accessible_get_unique_id(AtspiAccessible *obj, GError **error)
332 g_set_error(error, ATSPI_ERROR, ATSPI_ERROR_IPC, "argument is null");
337 gchar *bus_name = atspi_accessible_get_bus_name(obj, error);
338 if (bus_name && bus_name[0]) {
339 gchar *path = atspi_accessible_get_path(obj, error);
341 id = g_strdup_printf("%s:%s", bus_name, path);
343 g_set_error(error, ATSPI_ERROR, ATSPI_ERROR_IPC, "failed to get path");
347 g_set_error(error, ATSPI_ERROR, ATSPI_ERROR_IPC, "failed to get bus name");
353 * atspi_accessible_get_bus_name:
354 * @obj: a pointer to the #AtspiAccessible object on which to operate.
356 * Gets the bus name, where object belongs.
358 * Returns: a UTF-8 string describing the #AtspiAccessible object's
359 * bus name or empty string on exception or NULL object passed.
362 atspi_accessible_get_bus_name(AtspiAccessible *obj, GError **error)
364 if (!obj || !obj->parent.app)
366 return g_strdup (obj->parent.app->bus_name);
370 * atspi_accessible_get_path:
371 * @obj: a pointer to the #AtspiAccessible object on which to operate.
373 * Gets the path, uniquely identifying object over its bus name.
375 * Returns: a UTF-8 string describing the #AtspiAccessible object
376 * or empty string on exception or NULL object passed.
379 atspi_accessible_get_path(AtspiAccessible *obj, GError **error)
381 static const char *prefix = "/org/a11y/atspi/accessible/";
382 static int prefix_len = 27;
386 AtspiObject *o = ATSPI_OBJECT (obj);
389 if (strncmp(o->path, prefix, prefix_len) == 0)
390 return g_strdup(o->path + prefix_len);
391 return g_strdup (o->path);
395 * atspi_accessible_get_navigable_at_point:
396 * @root: a pointer to the #AtspiAccessible to start search from.
397 * @x: a #gint specifying the x coordinate of the point in question.
398 * @y: a #gint specifying the y coordinate of the point in question.
399 * @ctype: the coordinate system of the point (@x, @y)
400 * (e.g. ATSPI_COORD_TYPE_WINDOW, ATSPI_COORD_TYPE_SCREEN).
402 * Finds the accessible element closest to user (highest in z-order), at a given coordinate within an #AtspiAccessible.
403 * This should be the element, that should be picked, when doing mouse click or finger tap at given coordinates.
405 * Returns: (nullable) (transfer full): a pointer to an
406 * #AtspiAccessible descendant (of any depth) of the specified component which
407 * contains the point (@x, @y), or NULL if no descendant contains
411 atspi_accessible_get_navigable_at_point (AtspiAccessible *root,
414 AtspiCoordType ctype, GError **error)
416 dbus_int32_t d_x = x, d_y = y;
417 dbus_uint32_t d_ctype = ctype;
419 AtspiAccessible *return_value = NULL;
420 unsigned char recurse = 0;
421 DBusMessageIter iter;
422 AtspiAccessible *deputy = NULL;
424 g_return_val_if_fail (root != NULL, NULL);
426 reply = _atspi_dbus_call_partial (root, atspi_interface_accessible, "GetNavigableAtPoint", error, "iiu", d_x, d_y, d_ctype);
427 // call failed, error is set, so we bail out
429 if (deputy) g_object_unref(deputy);
430 if (return_value) g_object_unref(return_value);
433 _ATSPI_DBUS_CHECK_SIG (reply, "(so)y(so)", NULL, NULL);
435 dbus_message_iter_init (reply, &iter);
436 AtspiAccessible *tmp = _atspi_dbus_return_accessible_from_iter (&iter);
438 unsigned char value = 0;
439 dbus_message_iter_get_basic (&iter, &value);
440 dbus_message_iter_next (&iter);
441 recurse = (value != 0);
443 /* keep deputy if tmp has deputy */
445 deputy = _atspi_dbus_return_accessible_from_iter (&iter);
447 dbus_message_unref(reply);
451 /* TODO: need to check deputy works for return value */
453 g_object_unref(return_value);
460 g_object_unref(return_value);
461 return_value = root = tmp;
467 * atspi_accessible_get_reading_material:
468 * @obj: a pointer to the #AtspiAccessible object on which to operate.
470 * Gets reading material
472 * Returns: reading material to be used screen-reader side. This is not stable.
473 * You have to handle all alocated memory as below on screen-reader side.
475 * AtspiAccessibleReadingMaterial *rm
476 * g_object_unref(rm->parent);
477 * g_object_unref(rm->described_by_accessible);
478 * g_hash_table_unref(rm->attributes);
480 * free(rm->labeled_by_name);
481 * free(rm->text_interface_name);
482 * free(rm->localized_role_name);
483 * free(rm->description);
486 AtspiAccessibleReadingMaterial *
487 atspi_accessible_get_reading_material (AtspiAccessible *obj, GError **error)
489 AtspiAccessible *parent;
490 AtspiAccessibleReadingMaterial *reading_material = NULL;
492 double current_value;
496 DBusMessageIter iter;
497 DBusMessageIter iter_array;
499 dbus_uint32_t *states;
500 dbus_int32_t index_in_parent;
501 dbus_int32_t child_count;
502 dbus_bool_t is_selected;
504 g_return_val_if_fail (obj != NULL, NULL);
506 reply = _atspi_dbus_call_partial (obj, atspi_interface_accessible, "GetReadingMaterial", error, "");
508 _ATSPI_DBUS_CHECK_SIG (reply, "a{ss}sssuausiddddsibbii(so)auiui(so)", NULL, NULL);
510 reading_material = calloc(1, sizeof(AtspiAccessibleReadingMaterial));
511 if (!reading_material)
513 return reading_material;
516 dbus_message_iter_init (reply, &iter);
519 reading_material->attributes = _atspi_dbus_hash_from_iter (&iter);
520 dbus_message_iter_next (&iter);
523 dbus_message_iter_get_basic (&iter, &name);
524 reading_material->name = g_strdup (name);
525 dbus_message_iter_next (&iter);
527 /* get name of relation LABELED_BY */
528 dbus_message_iter_get_basic (&iter, &name);
529 reading_material->labeled_by_name = g_strdup (name);
530 dbus_message_iter_next (&iter);
532 /* get name of text interface */
533 dbus_message_iter_get_basic (&iter, &name);
534 reading_material->text_interface_name = g_strdup (name);
535 dbus_message_iter_next (&iter);
538 dbus_message_iter_get_basic (&iter, &role);
539 reading_material->role = role;
540 dbus_message_iter_next (&iter);
543 dbus_message_iter_recurse (&iter, &iter_array);
544 dbus_message_iter_get_fixed_array (&iter_array, &states, &count);
545 val = ((guint64)states [1]) << 32;
547 reading_material->states = val;
548 dbus_message_iter_next (&iter);
550 /* get localized role name */
551 dbus_message_iter_get_basic (&iter, &name);
552 reading_material->localized_role_name = g_strdup (name);
553 dbus_message_iter_next (&iter);
555 /* get child count */
556 dbus_message_iter_get_basic (&iter, &child_count);
557 reading_material->child_count = child_count;
558 dbus_message_iter_next (&iter);
560 /* get current value */
561 dbus_message_iter_get_basic (&iter, ¤t_value);
562 reading_material->value = current_value;
563 dbus_message_iter_next (&iter);
565 /* get minimum increment */
566 dbus_message_iter_get_basic (&iter, ¤t_value);
567 reading_material->increment = current_value;
568 dbus_message_iter_next (&iter);
570 /* get maximum value */
571 dbus_message_iter_get_basic (&iter, ¤t_value);
572 reading_material->upper = current_value;
573 dbus_message_iter_next (&iter);
575 /* get minimum value */
576 dbus_message_iter_get_basic (&iter, ¤t_value);
577 reading_material->lower = current_value;
578 dbus_message_iter_next (&iter);
580 /* get description */
581 dbus_message_iter_get_basic (&iter, &name);
582 reading_material->description = g_strdup (name);
583 dbus_message_iter_next (&iter);
585 /* get index in parent */
586 dbus_message_iter_get_basic (&iter, &index_in_parent);
587 reading_material->index_in_parent = index_in_parent;
588 dbus_message_iter_next (&iter);
590 /* get selected in parent */
591 dbus_message_iter_get_basic (&iter, &is_selected);
592 reading_material->is_selected_in_parent = is_selected;
593 dbus_message_iter_next (&iter);
595 /* get has checkbox child */
596 dbus_message_iter_get_basic (&iter, &is_selected);
597 reading_material->has_checkbox_child = is_selected;
598 dbus_message_iter_next (&iter);
600 /* get list children count */
601 dbus_message_iter_get_basic (&iter, &child_count);
602 reading_material->list_children_count = child_count;
603 dbus_message_iter_next (&iter);
605 /* get first selected child index */
606 dbus_message_iter_get_basic (&iter, &index_in_parent);
607 reading_material->first_selected_child_index = index_in_parent;
608 dbus_message_iter_next (&iter);
612 parent = _atspi_dbus_return_accessible_from_iter (&iter);
613 reading_material->parent = parent;
616 dbus_message_iter_recurse (&iter, &iter_array);
617 dbus_message_iter_get_fixed_array (&iter_array, &states, &count);
618 val = ((guint64)states [1]) << 32;
620 reading_material->parent_states = val;
621 dbus_message_iter_next (&iter);
623 /* get parent child count */
624 dbus_message_iter_get_basic (&iter, &child_count);
625 reading_material->parent_child_count = child_count;
626 dbus_message_iter_next (&iter);
628 /* get parent role */
629 dbus_message_iter_get_basic (&iter, &role);
630 reading_material->parent_role = role;
631 dbus_message_iter_next (&iter);
633 /* get parent selected child count */
634 dbus_message_iter_get_basic (&iter, &child_count);
635 reading_material->parent_selected_child_count = child_count;
636 dbus_message_iter_next (&iter);
638 ////////////////////////////////////////
639 /* get relation object - DESCRIBED_BY */
640 parent = _atspi_dbus_return_accessible_from_iter (&iter);
641 reading_material->described_by_accessible = parent;
643 return reading_material;
647 * atspi_accessible_get_default_label_info:
648 * @obj: a pointer to the #AtspiAccessible object would be window.
650 * Gets default label information
652 * Returns: default label information to be used screen-reader side.
653 * This is not stable. And this depends on toolkit side UI definition.
654 * The candidate of default label object could be changed by UI definition.
655 * You have to handle all alocated memory as below on screen-reader side.
657 * AtspiAccessibleDefaultLabelInfo *dli
658 * g_hash_table_unref(dli->attributes);
660 * g_object_unref(dli->obj);
663 AtspiAccessibleDefaultLabelInfo *
664 atspi_accessible_get_default_label_info (AtspiAccessible *obj, GError **error)
666 AtspiAccessibleDefaultLabelInfo *default_label_info = NULL;
667 AtspiAccessible *default_label_object;
670 DBusMessageIter iter;
672 g_return_val_if_fail (obj != NULL, NULL);
674 reply = _atspi_dbus_call_partial (obj, atspi_interface_accessible, "GetDefaultLabelInfo", error, "");
676 _ATSPI_DBUS_CHECK_SIG (reply, "(so)ua{ss}", NULL, NULL);
678 default_label_info = calloc(1, sizeof(AtspiAccessibleDefaultLabelInfo));
679 if (!default_label_info)
681 return default_label_info;
684 dbus_message_iter_init (reply, &iter);
686 default_label_object = _atspi_dbus_return_accessible_from_iter (&iter);
687 default_label_info->obj = default_label_object;
689 dbus_message_iter_get_basic (&iter, &role);
690 default_label_info->role = role;
691 dbus_message_iter_next (&iter);
693 default_label_info->attributes = _atspi_dbus_hash_from_iter (&iter);
694 dbus_message_iter_next (&iter);
696 return default_label_info;
699 static unsigned char are_objects_on_the_same_bus(AtspiAccessible *obj1, AtspiAccessible *obj2)
701 const char *bus_name_1 = obj1->parent.app->bus_name;
702 const char *bus_name_2 = obj2->parent.app->bus_name;
703 return strcmp(bus_name_1, bus_name_2) == 0;
706 static unsigned char object_is_valid(AtspiAccessible *obj)
710 AtspiStateSet *ss = atspi_accessible_get_state_set(obj);
713 unsigned char valid = atspi_state_set_contains(ss, ATSPI_STATE_DEFUNCT) == 0;
719 NEIGHBOR_SEARCH_MODE_NORMAL = 0,
720 NEIGHBOR_SEARCH_MODE_RECURSE_FROM_ROOT = 1,
721 NEIGHBOR_SEARCH_MODE_CONTINUE_AFTER_FAILED_RECURSING = 2,
722 NEIGHBOR_SEARCH_MODE_RECURSE_TO_OUTSIDE = 3,
723 } GetNeighborSearchMode;
725 * atspi_accessible_get_neighbor:
726 * @root: a pointer to a #AtspiAccessible, which represents current root of subtree to search
727 * @start: a pointer to the #AtspiAccessible to start search from (can be null, which means start from root)
728 * @direction: direction, in which search (forward or backward)
730 * Calculates next (or previous) accessible element in logical order or null if none found.
732 * Returns: (nullable) (transfer full): a pointer to an
733 * #AtspiAccessible element, which is next (previous) in logical order or null if none found.
736 atspi_accessible_get_neighbor (AtspiAccessible *root,
737 AtspiAccessible *start,
738 AtspiNeighborSearchDirection direction,
741 g_return_val_if_fail (object_is_valid(root), NULL);
742 if (!object_is_valid(start))
744 const char *root_path = ATSPI_OBJECT(root)->path;
745 AtspiAccessible *return_value = NULL;
747 unsigned char recurse;
748 GetNeighborSearchMode search_mode = NEIGHBOR_SEARCH_MODE_NORMAL;
749 GQueue *children_root_stack = g_queue_new();
750 DBusMessageIter iter;
753 const char *path = are_objects_on_the_same_bus(root, start) ? root_path : "";
754 DBusMessage *reply = _atspi_dbus_call_partial (start, atspi_interface_accessible, "GetNeighbor", error, "sii", path, (int)direction, (int)search_mode);
755 // call failed, error is set, so we bail out
758 _ATSPI_DBUS_CHECK_SIG (reply, "(so)y", error, NULL);
759 dbus_message_iter_init (reply, &iter);
760 AtspiAccessible *ret = _atspi_dbus_return_accessible_from_iter (&iter);
762 unsigned char value = 0;
763 dbus_message_iter_get_basic (&iter, &value);
764 dbus_message_iter_next (&iter);
765 recurse = (value != 0);
767 dbus_message_unref(reply);
769 // got return value and request for recursive search, it means ret is on another bridge, than start
770 // thus we're recursing. should the recurse failed to find anything it will end with
771 if (ret && recurse) {
772 g_object_unref(G_OBJECT(start));
775 if (are_objects_on_the_same_bus(root, ret))
777 search_mode = NEIGHBOR_SEARCH_MODE_RECURSE_TO_OUTSIDE;
781 g_queue_push_tail(children_root_stack, ret);
782 search_mode = NEIGHBOR_SEARCH_MODE_RECURSE_FROM_ROOT;
786 // found the one we've been looking for
788 g_object_unref(G_OBJECT(start));
793 // we've stepped into different bridges previously and now we're going back to the last one
794 // and continuing search where we left
795 if (!g_queue_is_empty(children_root_stack)) {
796 g_object_unref(G_OBJECT(start));
797 start = g_queue_pop_tail(children_root_stack);
799 search_mode = NEIGHBOR_SEARCH_MODE_CONTINUE_AFTER_FAILED_RECURSING;
802 // there's no more bridges to check, but we might have started from one
803 // in that case there might be bridges "below" start, which we yet have to visit
804 if (!are_objects_on_the_same_bus(root, start)) {
805 unsigned char continue_loop = 1;
806 while(continue_loop) {
807 AtspiAccessible *parent = atspi_accessible_get_parent(start, NULL);
808 continue_loop = parent ? are_objects_on_the_same_bus(start, parent) : 0;
809 g_object_unref(G_OBJECT(start));
813 // going up thru parents put us in weird place (we didnt meet root on the way)
818 // start object now points to different bridge and must be treated as "resume after recursing"
819 search_mode = NEIGHBOR_SEARCH_MODE_CONTINUE_AFTER_FAILED_RECURSING;
824 g_object_unref(start);
827 while(!g_queue_is_empty(children_root_stack))
828 g_object_unref(g_queue_pop_tail(children_root_stack));
829 g_queue_free(children_root_stack);
835 * atspi_accessible_get_description:
836 * @obj: a pointer to the #AtspiAccessible object on which to operate.
838 * Gets the description of an #AtspiAccessible object.
840 * Returns: a UTF-8 string describing the #AtspiAccessible object
841 * or NULL on exception.
844 atspi_accessible_get_description (AtspiAccessible *obj, GError **error)
846 g_return_val_if_fail (obj != NULL, g_strdup (""));
848 if (!_atspi_accessible_test_cache (obj, ATSPI_CACHE_DESCRIPTION))
850 if (!_atspi_dbus_get_property (obj, atspi_interface_accessible,
851 "Description", error, "s",
853 return g_strdup ("");
854 _atspi_accessible_add_cache (obj, ATSPI_CACHE_DESCRIPTION);
856 return g_strdup (obj->description);
859 const char *str_parent = "Parent";
862 * atspi_accessible_get_parent:
863 * @obj: a pointer to the #AtspiAccessible object to query.
865 * Gets an #AtspiAccessible object's parent container.
867 * Returns: (nullable) (transfer full): a pointer to the
868 * #AtspiAccessible object which contains the given
869 * #AtspiAccessible instance, or NULL if the @obj has no
874 atspi_accessible_get_parent (AtspiAccessible *obj, GError **error)
876 g_return_val_if_fail (obj != NULL, NULL);
878 if (!_atspi_accessible_test_cache (obj, ATSPI_CACHE_PARENT))
880 DBusMessage *message, *reply;
881 DBusMessageIter iter, iter_variant;
882 if (!obj->parent.app)
884 message = dbus_message_new_method_call (obj->parent.app->bus_name,
886 DBUS_INTERFACE_PROPERTIES, "Get");
889 dbus_message_append_args (message, DBUS_TYPE_STRING, &atspi_interface_accessible,
890 DBUS_TYPE_STRING, &str_parent,
892 reply = _atspi_dbus_send_with_reply_and_block (message, error);
895 if (strcmp (dbus_message_get_signature (reply), "v") != 0)
897 dbus_message_unref (reply);
900 dbus_message_iter_init (reply, &iter);
901 dbus_message_iter_recurse (&iter, &iter_variant);
902 obj->accessible_parent = _atspi_dbus_return_accessible_from_iter (&iter_variant);
903 dbus_message_unref (reply);
904 _atspi_accessible_add_cache (obj, ATSPI_CACHE_PARENT);
906 if (!obj->accessible_parent)
908 return g_object_ref (obj->accessible_parent);
912 * atspi_accessible_get_child_count:
913 * @obj: a pointer to the #AtspiAccessible object on which to operate.
915 * Gets the number of children contained by an #AtspiAccessible object.
917 * Returns: a #long indicating the number of #AtspiAccessible children
918 * contained by an #AtspiAccessible object or -1 on exception.
922 atspi_accessible_get_child_count (AtspiAccessible *obj, GError **error)
924 g_return_val_if_fail (obj != NULL, -1);
926 if (!_atspi_accessible_test_cache (obj, ATSPI_CACHE_CHILDREN))
929 if (!_atspi_dbus_get_property (obj, atspi_interface_accessible,
930 "ChildCount", error, "i", &ret))
936 return 0; /* assume it's disposed */
938 return obj->children->len;
942 * atspi_accessible_get_child_at_index:
943 * @obj: a pointer to the #AtspiAccessible object on which to operate.
944 * @child_index: a #long indicating which child is specified.
946 * Gets the #AtspiAccessible child of an #AtspiAccessible object at a given index.
948 * Returns: (transfer full): a pointer to the #AtspiAccessible child object at
949 * index @child_index or NULL on exception.
952 atspi_accessible_get_child_at_index (AtspiAccessible *obj,
956 AtspiAccessible *child;
959 g_return_val_if_fail (obj != NULL, NULL);
961 if (_atspi_accessible_test_cache (obj, ATSPI_CACHE_CHILDREN))
964 return NULL; /* assume disposed */
966 child = g_ptr_array_index (obj->children, child_index);
968 return g_object_ref (child);
971 reply = _atspi_dbus_call_partial (obj, atspi_interface_accessible,
972 "GetChildAtIndex", error, "i", child_index);
973 child = _atspi_dbus_return_accessible_from_message (reply);
978 if (_atspi_accessible_test_cache (obj, ATSPI_CACHE_CHILDREN))
980 if (child_index >= obj->children->len)
981 g_ptr_array_set_size (obj->children, child_index + 1);
982 g_ptr_array_index (obj->children, child_index) = g_object_ref (child);
988 * atspi_accessible_get_index_in_parent:
989 * @obj: a pointer to the #AtspiAccessible object on which to operate.
991 * Gets the index of an #AtspiAccessible object within its parent's
992 * #AtspiAccessible children list.
994 * Returns: a #glong indicating the index of the #AtspiAccessible object
996 * or -1 if @obj has no containing parent or on exception.
999 atspi_accessible_get_index_in_parent (AtspiAccessible *obj, GError **error)
1002 dbus_int32_t ret = -1;
1004 g_return_val_if_fail (obj != NULL, -1);
1005 if (_atspi_accessible_test_cache (obj, ATSPI_CACHE_PARENT))
1007 if (!obj->accessible_parent)
1010 if (!_atspi_accessible_test_cache (obj->accessible_parent, ATSPI_CACHE_CHILDREN) || !obj->accessible_parent->children)
1013 for (i = 0; i < obj->accessible_parent->children->len; i++)
1014 if (g_ptr_array_index (obj->accessible_parent->children, i) == obj)
1019 _atspi_dbus_call (obj, atspi_interface_accessible,
1020 "GetIndexInParent", NULL, "=>i", &ret);
1028 } Accessibility_Relation;
1031 * atspi_accessible_get_relation_set:
1032 * @obj: a pointer to the #AtspiAccessible object on which to operate.
1034 * Gets the set of #AtspiRelation objects which describes this #AtspiAccessible object's
1035 * relationships with other #AtspiAccessible objects.
1037 * Returns: (element-type AtspiRelation*) (transfer full): a #GArray of
1038 * #AtspiRelation pointers or NULL on exception.
1041 atspi_accessible_get_relation_set (AtspiAccessible *obj, GError **error)
1044 DBusMessageIter iter, iter_array;
1047 g_return_val_if_fail (obj != NULL, NULL);
1049 reply = _atspi_dbus_call_partial (obj, atspi_interface_accessible, "GetRelationSet", error, "");
1052 _ATSPI_DBUS_CHECK_SIG (reply, "a(ua(so))", error, NULL);
1054 ret = g_array_new (TRUE, TRUE, sizeof (AtspiRelation *));
1055 dbus_message_iter_init (reply, &iter);
1056 dbus_message_iter_recurse (&iter, &iter_array);
1057 while (dbus_message_iter_get_arg_type (&iter_array) != DBUS_TYPE_INVALID)
1059 AtspiRelation *relation;
1060 relation = _atspi_relation_new_from_iter (&iter_array);
1061 ret = g_array_append_val (ret, relation);
1062 dbus_message_iter_next (&iter_array);
1064 dbus_message_unref (reply);
1069 * atspi_accessible_get_role:
1070 * @obj: a pointer to the #AtspiAccessible object on which to operate.
1072 * Gets the UI role played by an #AtspiAccessible object.
1073 * This role's name can be obtained via atspi_accessible_get_role_name ().
1075 * Returns: the #AtspiRole of an #AtspiAccessible object.
1079 atspi_accessible_get_role (AtspiAccessible *obj, GError **error)
1081 g_return_val_if_fail (obj != NULL, ATSPI_ROLE_INVALID);
1083 if (!_atspi_accessible_test_cache (obj, ATSPI_CACHE_ROLE))
1086 /* TODO: Make this a property */
1087 if (_atspi_dbus_call (obj, atspi_interface_accessible, "GetRole", error, "=>u", &role))
1090 _atspi_accessible_add_cache (obj, ATSPI_CACHE_ROLE);
1097 * atspi_accessible_get_role_name:
1098 * @obj: a pointer to the #AtspiAccessible object on which to operate.
1100 * Gets a UTF-8 string corresponding to the name of the role played by an object.
1101 * This method will return useful values for roles that fall outside the
1102 * enumeration used in atspi_accessible_get_role ().
1104 * Returns: a UTF-8 string specifying the type of UI role played by an
1105 * #AtspiAccessible object.
1109 atspi_accessible_get_role_name (AtspiAccessible *obj, GError **error)
1111 gchar *retval = NULL;
1114 g_return_val_if_fail (obj != NULL, NULL);
1116 role = atspi_accessible_get_role (obj, error);
1117 if (role >= 0 && role < ATSPI_ROLE_COUNT && role != ATSPI_ROLE_EXTENDED)
1118 return atspi_role_get_name (role);
1120 _atspi_dbus_call (obj, atspi_interface_accessible, "GetRoleName", error, "=>s", &retval);
1123 retval = g_strdup ("");
1129 * atspi_accessible_get_localized_role_name:
1130 * @obj: a pointer to the #AtspiAccessible object on which to operate.
1132 * Gets a UTF-8 string corresponding to the name of the role played by an
1133 * object, translated to the current locale.
1134 * This method will return useful values for roles that fall outside the
1135 * enumeration used in atspi_accessible_getRole ().
1137 * Returns: a localized, UTF-8 string specifying the type of UI role played
1138 * by an #AtspiAccessible object.
1142 atspi_accessible_get_localized_role_name (AtspiAccessible *obj, GError **error)
1144 char *retval = NULL;
1146 g_return_val_if_fail (obj != NULL, NULL);
1148 _atspi_dbus_call (obj, atspi_interface_accessible, "GetLocalizedRoleName", error, "=>s", &retval);
1151 return g_strdup ("");
1156 static AtspiStateSet *
1159 AtspiStateSet *set = atspi_state_set_new (NULL);
1160 atspi_state_set_add (set, ATSPI_STATE_DEFUNCT);
1165 * atspi_accessible_get_state_set:
1166 * @obj: a pointer to the #AtspiAccessible object on which to operate.
1168 * Gets the states currently held by an object.
1170 * Returns: (transfer full): a pointer to an #AtspiStateSet representing an
1171 * object's current state set.
1174 atspi_accessible_get_state_set (AtspiAccessible *obj)
1176 /* TODO: Should take a GError **, but would be an API break */
1177 if (!obj->parent.app || !obj->parent.app->bus)
1178 return defunct_set ();
1180 if (!_atspi_accessible_test_cache (obj, ATSPI_CACHE_STATES))
1183 DBusMessageIter iter;
1184 reply = _atspi_dbus_call_partial (obj, atspi_interface_accessible,
1185 "GetState", NULL, "");
1186 _ATSPI_DBUS_CHECK_SIG (reply, "au", NULL, defunct_set ());
1187 dbus_message_iter_init (reply, &iter);
1188 _atspi_dbus_set_state (obj, &iter);
1189 dbus_message_unref (reply);
1190 _atspi_accessible_add_cache (obj, ATSPI_CACHE_STATES);
1192 return g_object_ref (obj->states);
1196 * atspi_accessible_get_attributes:
1197 * @obj: The #AtspiAccessible being queried.
1199 * Gets the #AttributeSet representing any assigned
1200 * name-value pair attributes or annotations for this object.
1201 * For typographic, textual, or textually-semantic attributes, see
1202 * atspi_text_get_attributes instead.
1204 * Returns: (element-type gchar* gchar*) (transfer full): The name-value-pair
1205 * attributes assigned to this object.
1208 atspi_accessible_get_attributes (AtspiAccessible *obj, GError **error)
1210 DBusMessage *message;
1212 g_return_val_if_fail (obj != NULL, NULL);
1214 if (obj->priv->cache)
1216 GValue *val = g_hash_table_lookup (obj->priv->cache, "Attributes");
1218 return g_value_dup_boxed (val);
1221 if (!_atspi_accessible_test_cache (obj, ATSPI_CACHE_ATTRIBUTES))
1223 message = _atspi_dbus_call_partial (obj, atspi_interface_accessible,
1224 "GetAttributes", error, "");
1225 obj->attributes = _atspi_dbus_return_hash_from_message (message);
1226 _atspi_accessible_add_cache (obj, ATSPI_CACHE_ATTRIBUTES);
1229 if (!obj->attributes)
1231 return g_hash_table_ref (obj->attributes);
1235 add_to_attribute_array (gpointer key, gpointer value, gpointer data)
1237 GArray **array = (GArray **)data;
1238 gchar *str = g_strconcat (key, ":", value, NULL);
1239 *array = g_array_append_val (*array, str);
1243 * atspi_accessible_get_attributes_as_array:
1244 * @obj: The #AtspiAccessible being queried.
1246 * Gets a #GArray representing any assigned
1247 * name-value pair attributes or annotations for this object.
1248 * For typographic, textual, or textually-semantic attributes, see
1249 * atspi_text_get_attributes_as_array instead.
1251 * Returns: (element-type gchar*) (transfer full): The name-value-pair
1252 * attributes assigned to this object.
1255 atspi_accessible_get_attributes_as_array (AtspiAccessible *obj, GError **error)
1257 DBusMessage *message;
1259 g_return_val_if_fail (obj != NULL, NULL);
1261 if (obj->priv->cache)
1263 GValue *val = g_hash_table_lookup (obj->priv->cache, "Attributes");
1266 GArray *array = g_array_new (TRUE, TRUE, sizeof (gchar *));
1267 GHashTable *attributes = g_value_get_boxed (val);
1268 g_hash_table_foreach (attributes, add_to_attribute_array, &array);
1273 message = _atspi_dbus_call_partial (obj, atspi_interface_accessible, "GetAttributes", error, "");
1274 return _atspi_dbus_return_attribute_array_from_message (message);
1278 * atspi_accessible_get_application:
1279 * @obj: The #AtspiAccessible being queried.
1281 * Gets the containing #AtspiApplication for an object.
1283 * Returns: (transfer full): the containing #AtspiApplication instance for
1287 atspi_accessible_get_application (AtspiAccessible *obj, GError **error)
1289 AtspiAccessible *parent;
1294 parent = atspi_accessible_get_parent (obj, NULL);
1295 if (!parent && obj->parent.app &&
1296 atspi_accessible_get_role (obj, NULL) != ATSPI_ROLE_APPLICATION)
1298 AtspiAccessible *root = g_object_ref (obj->parent.app->root);
1301 g_object_unref (obj);
1302 if (atspi_accessible_get_role (root, NULL) == ATSPI_ROLE_DESKTOP_FRAME)
1304 g_object_unref (root);
1310 if (!parent || parent == obj ||
1311 atspi_accessible_get_role (parent, NULL) == ATSPI_ROLE_DESKTOP_FRAME)
1314 g_object_unref (parent);
1317 g_object_unref (obj);
1322 /* Application-specific methods */
1325 * atspi_accessible_get_toolkit_name:
1326 * @obj: a pointer to the #AtspiAccessible object on which to operate.
1328 * Gets the toolkit name for an #AtspiAccessible object.
1329 * Only works on application root objects.
1331 * Returns: a UTF-8 string indicating the toolkit name for the #AtspiAccessible object or NULL on exception.
1334 atspi_accessible_get_toolkit_name (AtspiAccessible *obj, GError **error)
1336 g_return_val_if_fail (obj != NULL, NULL);
1338 if (!obj->parent.app)
1341 if (!obj->parent.app->toolkit_name)
1342 _atspi_dbus_get_property (obj, atspi_interface_application, "ToolkitName",
1343 error, "s", &obj->parent.app->toolkit_name);
1345 return g_strdup (obj->parent.app->toolkit_name);
1349 * atspi_accessible_get_toolkit_version:
1350 * @obj: a pointer to the #AtspiAccessible object on which to operate.
1352 * Gets the toolkit version for an #AtspiAccessible object.
1353 * Only works on application root objects.
1355 * Returns: a UTF-8 string indicating the toolkit version for the #AtspiAccessible object or NULL on exception.
1358 atspi_accessible_get_toolkit_version (AtspiAccessible *obj, GError **error)
1360 g_return_val_if_fail (obj != NULL, NULL);
1362 if (!obj->parent.app)
1365 if (!obj->parent.app->toolkit_version)
1366 _atspi_dbus_get_property (obj, atspi_interface_application, "Version",
1367 error, "s", &obj->parent.app->toolkit_version);
1369 return g_strdup (obj->parent.app->toolkit_version);
1373 * atspi_accessible_get_atspi_version:
1374 * @obj: a pointer to the #AtspiAccessible object on which to operate.
1376 * Gets the AT-SPI IPC specification version supported by the application
1377 * pointed to by the #AtspiAccessible object.
1378 * Only works on application root objects.
1380 * Returns: a UTF-8 string indicating the AT-SPI version for the #AtspiAccessible object or NULL on exception.
1383 atspi_accessible_get_atspi_version (AtspiAccessible *obj, GError **error)
1385 g_return_val_if_fail (obj != NULL, NULL);
1387 if (!obj->parent.app)
1390 if (!obj->parent.app->atspi_version)
1391 _atspi_dbus_get_property (obj, atspi_interface_application, "AtspiVersion",
1392 error, "s", &obj->parent.app->atspi_version);
1394 return g_strdup (obj->parent.app->atspi_version);
1398 * atspi_accessible_get_id:
1399 * @obj: a pointer to the #AtspiAccessible object on which to operate.
1401 * Gets the application id for a #AtspiAccessible object.
1402 * Only works on application root objects.
1404 * Returns: a positive #gint indicating the id for the #AtspiAccessible object
1405 * or -1 on exception.
1408 atspi_accessible_get_id (AtspiAccessible *obj, GError **error)
1412 g_return_val_if_fail (obj != NULL, -1);
1414 if (!_atspi_dbus_get_property (obj, atspi_interface_application, "Id", error, "i", &ret))
1420 /* Interface query methods */
1423 _atspi_accessible_is_a (AtspiAccessible *accessible,
1424 const char *interface_name)
1428 if (accessible == NULL)
1433 if (!_atspi_accessible_test_cache (accessible, ATSPI_CACHE_INTERFACES))
1436 DBusMessageIter iter;
1437 reply = _atspi_dbus_call_partial (accessible, atspi_interface_accessible,
1438 "GetInterfaces", NULL, "");
1439 _ATSPI_DBUS_CHECK_SIG (reply, "as", NULL, FALSE);
1440 dbus_message_iter_init (reply, &iter);
1441 _atspi_dbus_set_interfaces (accessible, &iter);
1442 dbus_message_unref (reply);
1443 _atspi_accessible_add_cache (accessible, ATSPI_CACHE_INTERFACES);
1446 n = _atspi_get_iface_num (interface_name);
1447 if (n == -1) return FALSE;
1448 return (gboolean) ((accessible->interfaces & (1 << n))? TRUE: FALSE);
1452 * atspi_accessible_is_action:
1453 * @obj: a pointer to the #AtspiAccessible instance to query.
1455 * Query whether the specified #AtspiAccessible implements the
1456 * #AtspiAction interface.
1458 * Returns: #TRUE if @obj implements the #AtspiAction interface,
1462 atspi_accessible_is_action (AtspiAccessible *obj)
1464 return _atspi_accessible_is_a (obj,
1465 atspi_interface_action);
1469 * atspi_accessible_is_application:
1470 * @obj: a pointer to the #AtspiAccessible instance to query.
1472 * Query whether the specified #AtspiAccessible implements the
1473 * #AtspiApplication interface.
1475 * Returns: #TRUE if @obj implements the #AtspiApplication interface,
1479 atspi_accessible_is_application (AtspiAccessible *obj)
1481 return _atspi_accessible_is_a (obj,
1482 atspi_interface_application);
1486 * atspi_accessible_is_collection:
1487 * @obj: a pointer to the #AtspiAccessible instance to query.
1489 * Query whether the specified #AtspiAccessible implements the
1490 * #AtspiCollection interface.
1492 * Returns: #TRUE if @obj implements the #AtspiCollection interface,
1496 atspi_accessible_is_collection (AtspiAccessible *obj)
1498 return _atspi_accessible_is_a (obj,
1499 atspi_interface_collection);
1503 * atspi_accessible_is_component:
1504 * @obj: a pointer to the #AtspiAccessible instance to query.
1506 * Query whether the specified #AtspiAccessible implements #AtspiComponent.
1508 * Returns: #TRUE if @obj implements the #AtspiComponent interface,
1512 atspi_accessible_is_component (AtspiAccessible *obj)
1514 return _atspi_accessible_is_a (obj,
1515 atspi_interface_component);
1519 * atspi_accessible_is_document:
1520 * @obj: a pointer to the #AtspiAccessible instance to query.
1522 * Query whether the specified #AtspiAccessible implements the
1523 * #AtspiDocument interface.
1525 * Returns: #TRUE if @obj implements the #AtspiDocument interface,
1529 atspi_accessible_is_document (AtspiAccessible *obj)
1531 return _atspi_accessible_is_a (obj,
1532 atspi_interface_document);
1536 * atspi_accessible_is_editable_text:
1537 * @obj: a pointer to the #AtspiAccessible instance to query.
1539 * Query whether the specified #AtspiAccessible implements the
1540 * #AtspiEditableText interface.
1542 * Returns: #TRUE if @obj implements the #AtspiEditableText interface,
1546 atspi_accessible_is_editable_text (AtspiAccessible *obj)
1548 return _atspi_accessible_is_a (obj,
1549 atspi_interface_editable_text);
1553 * atspi_accessible_is_hypertext:
1554 * @obj: a pointer to the #AtspiAccessible instance to query.
1556 * Query whether the specified #AtspiAccessible implements the
1557 * #AtspiHypertext interface.
1559 * Returns: #TRUE if @obj implements the #AtspiHypertext interface,
1563 atspi_accessible_is_hypertext (AtspiAccessible *obj)
1565 return _atspi_accessible_is_a (obj,
1566 atspi_interface_hypertext);
1570 * atspi_accessible_is_hyperlink:
1571 * @obj: a pointer to the #AtspiAccessible instance to query.
1573 * Query whether the specified #AtspiAccessible implements the
1574 * #AtspiHyperlink interface.
1576 * Returns: #TRUE if @obj implements the #AtspiHypertext interface,
1580 atspi_accessible_is_hyperlink (AtspiAccessible *obj)
1582 return _atspi_accessible_is_a (obj,
1583 atspi_interface_hyperlink);
1587 * atspi_accessible_is_image:
1588 * @obj: a pointer to the #AtspiAccessible instance to query.
1590 * Query whether the specified #AtspiAccessible implements the
1591 * #AtspiImage interface.
1593 * Returns: #TRUE if @obj implements the #AtspiImage interface,
1597 atspi_accessible_is_image (AtspiAccessible *obj)
1599 return _atspi_accessible_is_a (obj,
1600 atspi_interface_image);
1604 * atspi_accessible_is_selection:
1605 * @obj: a pointer to the #AtspiAccessible instance to query.
1607 * Query whether the specified #AtspiAccessible implements the
1608 * #AtspiSelection interface.
1610 * Returns: #TRUE if @obj implements the #AtspiSelection interface,
1614 atspi_accessible_is_selection (AtspiAccessible *obj)
1616 return _atspi_accessible_is_a (obj,
1617 atspi_interface_selection);
1621 * atspi_accessible_is_table:
1622 * @obj: a pointer to the #AtspiAccessible instance to query.
1624 * Query whether the specified #AtspiAccessible implements the
1625 * #AtspiTable interface.
1627 * Returns: #TRUE if @obj implements the #AtspiTable interface,
1631 atspi_accessible_is_table (AtspiAccessible *obj)
1633 return _atspi_accessible_is_a (obj,
1634 atspi_interface_table);
1638 * atspi_accessible_is_table_cell:
1639 * @obj: a pointer to the #AtspiAccessible instance to query.
1641 * Query whether the specified #AtspiAccessible implements the
1642 * #AtspiTableCell interface.
1644 * Returns: #TRUE if @obj implements the #AtspiTable interface,
1648 atspi_accessible_is_table_cell (AtspiAccessible *obj)
1650 return _atspi_accessible_is_a (obj,
1651 atspi_interface_table_cell);
1655 * atspi_accessible_is_streamable_content:
1656 * @obj: a pointer to the #AtspiAccessible instance to query.
1658 * Query whether the specified #AtspiAccessible implements the
1659 * #AtspiStreamableContent interface.
1661 * Returns: #TRUE if @obj implements the #AtspiStreamableContent interface,
1665 atspi_accessible_is_streamable_content (AtspiAccessible *obj)
1668 return _atspi_accessible_is_a (obj,
1669 atspi_interface_streamable_content);
1671 g_warning ("Streamable content not implemented");
1677 * atspi_accessible_is_text:
1678 * @obj: a pointer to the #AtspiAccessible instance to query.
1680 * Query whether the specified #AtspiAccessible implements the
1681 * #AtspiText interface.
1683 * Returns: #TRUE if @obj implements the #AtspiText interface,
1687 atspi_accessible_is_text (AtspiAccessible *obj)
1689 return _atspi_accessible_is_a (obj,
1690 atspi_interface_text);
1694 * atspi_accessible_is_value:
1695 * @obj: a pointer to the #AtspiAccessible instance to query.
1697 * Query whether the specified #AtspiAccessible implements the
1698 * #AtspiValue interface.
1700 * Returns: #TRUE if @obj implements the #AtspiValue interface,
1704 atspi_accessible_is_value (AtspiAccessible *obj)
1706 return _atspi_accessible_is_a (obj,
1707 atspi_interface_value);
1711 * atspi_accessible_get_action: (rename-to atspi_accessible_get_action_iface)
1712 * @obj: a pointer to the #AtspiAccessible instance to query.
1714 * Gets the #AtspiAction interface for an #AtspiAccessible.
1716 * Returns: (transfer full): a pointer to an #AtspiAction interface
1717 * instance, or NULL if @obj does not implement #AtspiAction.
1719 * Deprecated: 2.10: Use atspi_accessible_get_action_iface instead.
1722 atspi_accessible_get_action (AtspiAccessible *accessible)
1724 return (_atspi_accessible_is_a (accessible, atspi_interface_action) ?
1725 g_object_ref (ATSPI_ACTION (accessible)) : NULL);
1729 * atspi_accessible_get_action_iface:
1730 * @obj: a pointer to the #AtspiAccessible instance to query.
1732 * Gets the #AtspiAction interface for an #AtspiAccessible.
1734 * Returns: (transfer full): a pointer to an #AtspiAction interface
1735 * instance, or NULL if @obj does not implement #AtspiAction.
1738 atspi_accessible_get_action_iface (AtspiAccessible *accessible)
1740 return (_atspi_accessible_is_a (accessible, atspi_interface_action) ?
1741 g_object_ref (ATSPI_ACTION (accessible)) : NULL);
1745 * atspi_accessible_get_collection: (rename-to atspi_accessible_get_collection_iface)
1746 * @obj: a pointer to the #AtspiAccessible instance to query.
1748 * Gets the #AtspiCollection interface for an #AtspiAccessible.
1750 * Returns: (transfer full): a pointer to an #AtspiCollection interface
1751 * instance, or NULL if @obj does not implement #AtspiCollection.
1753 * Deprecated: 2.10: Use atspi_accessible_get_collection_iface instead.
1756 atspi_accessible_get_collection (AtspiAccessible *accessible)
1758 return (_atspi_accessible_is_a (accessible, atspi_interface_collection) ?
1759 g_object_ref (ATSPI_COLLECTION (accessible)) : NULL);
1763 * atspi_accessible_get_collection_iface:
1764 * @obj: a pointer to the #AtspiAccessible instance to query.
1766 * Gets the #AtspiCollection interface for an #AtspiAccessible.
1768 * Returns: (transfer full): a pointer to an #AtspiCollection interface
1769 * instance, or NULL if @obj does not implement #AtspiCollection.
1772 atspi_accessible_get_collection_iface (AtspiAccessible *accessible)
1774 return (_atspi_accessible_is_a (accessible, atspi_interface_collection) ?
1775 g_object_ref (ATSPI_COLLECTION (accessible)) : NULL);
1779 * atspi_accessible_get_component: (rename-to atspi_accessible_get_component_iface)
1780 * @obj: a pointer to the #AtspiAccessible instance to query.
1782 * Gets the #AtspiComponent interface for an #AtspiAccessible.
1784 * Returns: (transfer full): a pointer to an #AtspiComponent interface
1785 * instance, or NULL if @obj does not implement #AtspiComponent.
1787 * Deprecated: 2.10: Use atspi_accessible_get_component_iface instead.
1790 atspi_accessible_get_component (AtspiAccessible *obj)
1792 return (_atspi_accessible_is_a (obj, atspi_interface_component) ?
1793 g_object_ref (ATSPI_COMPONENT (obj)) : NULL);
1797 * atspi_accessible_get_component_iface:
1798 * @obj: a pointer to the #AtspiAccessible instance to query.
1800 * Gets the #AtspiComponent interface for an #AtspiAccessible.
1802 * Returns: (transfer full): a pointer to an #AtspiComponent interface
1803 * instance, or NULL if @obj does not implement #AtspiComponent.
1806 atspi_accessible_get_component_iface (AtspiAccessible *obj)
1808 return (_atspi_accessible_is_a (obj, atspi_interface_component) ?
1809 g_object_ref (ATSPI_COMPONENT (obj)) : NULL);
1813 * atspi_accessible_get_document: (rename-to atspi_accessible_get_document_iface)
1814 * @obj: a pointer to the #AtspiAccessible instance to query.
1816 * Gets the #AtspiDocument interface for an #AtspiAccessible.
1818 * Returns: (transfer full): a pointer to an #AtspiDocument interface
1819 * instance, or NULL if @obj does not implement #AtspiDocument.
1821 * Deprecated: 2.10: Use atspi_accessible_get_document_iface instead.
1824 atspi_accessible_get_document (AtspiAccessible *accessible)
1826 return (_atspi_accessible_is_a (accessible, atspi_interface_document) ?
1827 g_object_ref (ATSPI_DOCUMENT (accessible)) : NULL);
1831 * atspi_accessible_get_document_iface:
1832 * @obj: a pointer to the #AtspiAccessible instance to query.
1834 * Gets the #AtspiDocument interface for an #AtspiAccessible.
1836 * Returns: (transfer full): a pointer to an #AtspiDocument interface
1837 * instance, or NULL if @obj does not implement #AtspiDocument.
1840 atspi_accessible_get_document_iface (AtspiAccessible *accessible)
1842 return (_atspi_accessible_is_a (accessible, atspi_interface_document) ?
1843 g_object_ref (ATSPI_DOCUMENT (accessible)) : NULL);
1847 * atspi_accessible_get_editable_text: (rename-to atspi_accessible_get_editable_text_iface)
1848 * @obj: a pointer to the #AtspiAccessible instance to query.
1850 * Gets the #AtspiEditableText interface for an #AtspiAccessible.
1852 * Returns: (transfer full): a pointer to an #AtspiEditableText interface
1853 * instance, or NULL if @obj does not implement #AtspiEditableText.
1855 * Deprecated: 2.10: Use atspi_accessible_get_editable_text_iface instead.
1858 atspi_accessible_get_editable_text (AtspiAccessible *accessible)
1860 return (_atspi_accessible_is_a (accessible, atspi_interface_editable_text) ?
1861 g_object_ref (ATSPI_EDITABLE_TEXT (accessible)) : NULL);
1865 * atspi_accessible_get_editable_text_iface:
1866 * @obj: a pointer to the #AtspiAccessible instance to query.
1868 * Gets the #AtspiEditableText interface for an #AtspiAccessible.
1870 * Returns: (transfer full): a pointer to an #AtspiEditableText interface
1871 * instance, or NULL if @obj does not implement #AtspiEditableText.
1874 atspi_accessible_get_editable_text_iface (AtspiAccessible *accessible)
1876 return (_atspi_accessible_is_a (accessible, atspi_interface_editable_text) ?
1877 g_object_ref (ATSPI_EDITABLE_TEXT (accessible)) : NULL);
1881 * atspi_accessible_get_hyperlink:
1882 * @obj: a pointer to the #AtspiAccessible object on which to operate.
1884 * Gets the #AtspiHyperlink interface for an #AtspiAccessible.
1886 * Returns: (transfer full): the #AtspiHyperlink object associated with
1887 * the given #AtspiAccessible, or NULL if not supported.
1890 atspi_accessible_get_hyperlink (AtspiAccessible *accessible)
1892 return (_atspi_accessible_is_a (accessible, atspi_interface_hyperlink) ?
1893 _atspi_hyperlink_new (accessible->parent.app, accessible->parent.path) : NULL);
1897 * atspi_accessible_get_hypertext: (rename-to atspi_accessible_get_hypertext_iface)
1898 * @obj: a pointer to the #AtspiAccessible instance to query.
1900 * Gets the #AtspiHypertext interface for an #AtspiAccessible.
1902 * Returns: (transfer full): a pointer to an #AtspiHypertext interface
1903 * instance, or NULL if @obj does not implement #AtspiHypertext.
1905 * Deprecated: 2.10: Use atspi_accessible_get_hypertext_iface instead.
1908 atspi_accessible_get_hypertext (AtspiAccessible *accessible)
1910 return (_atspi_accessible_is_a (accessible, atspi_interface_hypertext) ?
1911 g_object_ref (ATSPI_HYPERTEXT (accessible)) : NULL);
1915 * atspi_accessible_get_hypertext_iface:
1916 * @obj: a pointer to the #AtspiAccessible instance to query.
1918 * Gets the #AtspiHypertext interface for an #AtspiAccessible.
1920 * Returns: (transfer full): a pointer to an #AtspiHypertext interface
1921 * instance, or NULL if @obj does not implement #AtspiHypertext.
1924 atspi_accessible_get_hypertext_iface (AtspiAccessible *accessible)
1926 return (_atspi_accessible_is_a (accessible, atspi_interface_hypertext) ?
1927 g_object_ref (ATSPI_HYPERTEXT (accessible)) : NULL);
1931 * atspi_accessible_get_image: (rename-to atspi_accessible_get_image_iface)
1932 * @obj: a pointer to the #AtspiAccessible instance to query.
1934 * Gets the #AtspiImage interface for an #AtspiAccessible.
1936 * Returns: (transfer full): a pointer to an #AtspiImage interface instance, or
1937 * NULL if @obj does not implement #AtspiImage.
1939 * Deprecated: 2.10: Use atspi_accessible_get_image_iface instead.
1942 atspi_accessible_get_image (AtspiAccessible *accessible)
1944 return (_atspi_accessible_is_a (accessible, atspi_interface_image) ?
1945 g_object_ref (ATSPI_IMAGE (accessible)) : NULL);
1949 * atspi_accessible_get_image_iface:
1950 * @obj: a pointer to the #AtspiAccessible instance to query.
1952 * Gets the #AtspiImage interface for an #AtspiAccessible.
1954 * Returns: (transfer full): a pointer to an #AtspiImage interface instance, or
1955 * NULL if @obj does not implement #AtspiImage.
1958 atspi_accessible_get_image_iface (AtspiAccessible *accessible)
1960 return (_atspi_accessible_is_a (accessible, atspi_interface_image) ?
1961 g_object_ref (ATSPI_IMAGE (accessible)) : NULL);
1965 * atspi_accessible_get_selection: (rename-to atspi_accessible_get_selection_iface)
1966 * @obj: a pointer to the #AtspiAccessible instance to query.
1968 * Gets the #AtspiSelection interface for an #AtspiAccessible.
1970 * Returns: (transfer full): a pointer to an #AtspiSelection interface
1971 * instance, or NULL if @obj does not implement #AtspiSelection.
1973 * Deprecated: 2.10: Use atspi_accessible_get_selection_iface instead.
1976 atspi_accessible_get_selection (AtspiAccessible *accessible)
1978 return (_atspi_accessible_is_a (accessible, atspi_interface_selection) ?
1979 g_object_ref (ATSPI_SELECTION (accessible)) : NULL);
1983 * atspi_accessible_get_selection_iface:
1984 * @obj: a pointer to the #AtspiAccessible instance to query.
1986 * Gets the #AtspiSelection interface for an #AtspiAccessible.
1988 * Returns: (transfer full): a pointer to an #AtspiSelection interface
1989 * instance, or NULL if @obj does not implement #AtspiSelection.
1992 atspi_accessible_get_selection_iface (AtspiAccessible *accessible)
1994 return (_atspi_accessible_is_a (accessible, atspi_interface_selection) ?
1995 g_object_ref (ATSPI_SELECTION (accessible)) : NULL);
2000 * atspi_accessible_get_streamable_content:
2001 * @obj: a pointer to the #AtspiAccessible instance to query.
2003 * Gets the #AtspiStreamableContent interface for an #AtspiAccessible.
2005 * Returns: (transfer full): a pointer to an #AtspiStreamableContent interface
2006 * instance, or NULL if @obj does not implement #AtspiStreamableContent.
2008 AtspiStreamableContent *
2009 atspi_accessible_get_streamable_content (AtspiAccessible *accessible)
2011 return (_atspi_accessible_is_a (accessible, atspi_interface_streamable_content) ?
2017 * atspi_accessible_get_table: (rename-to atspi_accessible_get_table_iface)
2018 * @obj: a pointer to the #AtspiAccessible instance to query.
2020 * Gets the #AtspiTable interface for an #AtspiAccessible.
2022 * Returns: (transfer full): a pointer to an #AtspiTable interface instance, or
2023 * NULL if @obj does not implement #AtspiTable.
2025 * Deprecated: 2.10: Use atspi_accessible_get_table_iface instead.
2028 atspi_accessible_get_table (AtspiAccessible *obj)
2030 return (_atspi_accessible_is_a (obj, atspi_interface_table) ?
2031 g_object_ref (ATSPI_TABLE (obj)) : NULL);
2035 * atspi_accessible_get_table_iface:
2036 * @obj: a pointer to the #AtspiAccessible instance to query.
2038 * Gets the #AtspiTable interface for an #AtspiAccessible.
2040 * Returns: (transfer full): a pointer to an #AtspiTable interface instance, or
2041 * NULL if @obj does not implement #AtspiTable.
2044 atspi_accessible_get_table_iface (AtspiAccessible *obj)
2046 return (_atspi_accessible_is_a (obj, atspi_interface_table) ?
2047 g_object_ref (ATSPI_TABLE (obj)) : NULL);
2051 * atspi_accessible_get_table_cell:
2052 * @obj: a pointer to the #AtspiAccessible instance to query.
2054 * Gets the #AtspiTableCell interface for an #AtspiAccessible.
2056 * Returns: (transfer full): a pointer to an #AtspiTableCell interface instance,
2057 * or NULL if @obj does not implement #AtspiTable.
2060 atspi_accessible_get_table_cell (AtspiAccessible *obj)
2062 return (_atspi_accessible_is_a (obj, atspi_interface_table_cell) ?
2063 g_object_ref (ATSPI_TABLE_CELL (obj)) : NULL);
2067 * atspi_accessible_get_text: (rename-to atspi_accessible_get_text_iface)
2068 * @obj: a pointer to the #AtspiAccessible instance to query.
2070 * Gets the #AtspiTable interface for an #AtspiAccessible.
2072 * Returns: (transfer full): a pointer to an #AtspiText interface instance, or
2073 * NULL if @obj does not implement #AtspiText.
2075 * Deprecated: 2.10: Use atspi_accessible_get_text_iface instead.
2078 atspi_accessible_get_text (AtspiAccessible *obj)
2080 return (_atspi_accessible_is_a (obj, atspi_interface_text) ?
2081 g_object_ref (ATSPI_TEXT (obj)) : NULL);
2085 * atspi_accessible_get_text_iface:
2086 * @obj: a pointer to the #AtspiAccessible instance to query.
2088 * Gets the #AtspiTable interface for an #AtspiAccessible.
2090 * Returns: (transfer full): a pointer to an #AtspiText interface instance, or
2091 * NULL if @obj does not implement #AtspiText.
2094 atspi_accessible_get_text_iface (AtspiAccessible *obj)
2096 return (_atspi_accessible_is_a (obj, atspi_interface_text) ?
2097 g_object_ref (ATSPI_TEXT (obj)) : NULL);
2101 * atspi_accessible_get_value: (rename-to atspi_accessible_get_value_iface)
2102 * @obj: a pointer to the #AtspiAccessible instance to query.
2104 * Gets the #AtspiTable interface for an #AtspiAccessible.
2106 * Returns: (transfer full): a pointer to an #AtspiValue interface instance, or
2107 * NULL if @obj does not implement #AtspiValue.
2109 * Deprecated: 2.10: Use atspi_accessible_get_value_iface instead.
2112 atspi_accessible_get_value (AtspiAccessible *accessible)
2114 return (_atspi_accessible_is_a (accessible, atspi_interface_value) ?
2115 g_object_ref (ATSPI_VALUE (accessible)) : NULL);
2119 * atspi_accessible_get_value_iface:
2120 * @obj: a pointer to the #AtspiAccessible instance to query.
2122 * Gets the #AtspiTable interface for an #AtspiAccessible.
2124 * Returns: (transfer full): a pointer to an #AtspiValue interface instance, or
2125 * NULL if @obj does not implement #AtspiValue.
2128 atspi_accessible_get_value_iface (AtspiAccessible *accessible)
2130 return (_atspi_accessible_is_a (accessible, atspi_interface_value) ?
2131 g_object_ref (ATSPI_VALUE (accessible)) : NULL);
2135 append_const_val (GArray *array, const gchar *val)
2137 gchar *dup = g_strdup (val);
2140 g_array_append_val (array, dup);
2144 * atspi_accessible_get_interfaces:
2145 * @obj: The #AtspiAccessible to query.
2147 * A set of pointers to all interfaces supported by an #AtspiAccessible.
2149 * Returns: (element-type gchar*) (transfer full): A #GArray of strings
2150 * describing the interfaces supported by the object. Interfaces are
2151 * denoted in short-hand (i.e. "Component", "Text" etc.).
2154 atspi_accessible_get_interfaces (AtspiAccessible *obj)
2158 g_return_val_if_fail (obj != NULL, NULL);
2160 ret = g_array_new (TRUE, TRUE, sizeof (gchar *));
2162 append_const_val (ret, "Accessible");
2163 if (atspi_accessible_is_action (obj))
2164 append_const_val (ret, "Action");
2165 if (atspi_accessible_is_collection (obj))
2166 append_const_val (ret, "Collection");
2167 if (atspi_accessible_is_component (obj))
2168 append_const_val (ret, "Component");
2169 if (atspi_accessible_is_document (obj))
2170 append_const_val (ret, "Document");
2171 if (atspi_accessible_is_editable_text (obj))
2172 append_const_val (ret, "EditableText");
2173 if (atspi_accessible_is_hypertext (obj))
2174 append_const_val (ret, "Hypertext");
2175 if (atspi_accessible_is_hyperlink (obj))
2176 append_const_val (ret, "Hyperlink");
2177 if (atspi_accessible_is_image (obj))
2178 append_const_val (ret, "Image");
2179 if (atspi_accessible_is_selection (obj))
2180 append_const_val (ret, "Selection");
2181 if (atspi_accessible_is_table (obj))
2182 append_const_val (ret, "Table");
2183 if (atspi_accessible_is_table_cell (obj))
2184 append_const_val (ret, "TableCell");
2185 if (atspi_accessible_is_text (obj))
2186 append_const_val (ret, "Text");
2187 if (atspi_accessible_is_value (obj))
2188 append_const_val (ret, "Value");
2194 _atspi_accessible_new (AtspiApplication *app, const gchar *path)
2196 AtspiAccessible *accessible;
2198 accessible = g_object_new (ATSPI_TYPE_ACCESSIBLE, NULL);
2199 g_return_val_if_fail (accessible != NULL, NULL);
2201 accessible->parent.app = g_object_ref (app);
2202 accessible->parent.path = g_strdup (path);
2208 * atspi_accessible_set_cache_mask:
2209 * @accessible: The #AtspiAccessible to operate on. Must be the desktop or
2210 * the root of an application.
2211 * @mask: An #AtspiCache specifying a bit mask of the types of data to cache.
2213 * Sets the type of data to cache for accessibles.
2214 * If this is not set for an application or is reset to ATSPI_CACHE_UNDEFINED,
2215 * then the desktop's cache flag will be used.
2216 * If the desktop's cache flag is also undefined, then all possible data will
2218 * This function is intended to work around bugs in toolkits where the proper
2219 * events are not raised / to aid in testing for such bugs.
2222 atspi_accessible_set_cache_mask (AtspiAccessible *accessible, AtspiCache mask)
2224 g_return_if_fail (accessible != NULL);
2225 g_return_if_fail (accessible->parent.app != NULL);
2226 g_return_if_fail (accessible == accessible->parent.app->root);
2227 accessible->parent.app->cache = mask;
2228 enable_caching = TRUE;
2232 * atspi_accessible_clear_cache:
2233 * @obj: The #AtspiAccessible whose cache to clear.
2235 * Clears the cached information for the given accessible and all of its
2239 atspi_accessible_clear_cache (AtspiAccessible *obj)
2245 obj->cached_properties = ATSPI_CACHE_NONE;
2247 for (i = 0; i < obj->children->len; i++)
2248 atspi_accessible_clear_cache (g_ptr_array_index (obj->children, i));
2253 * atspi_accessible_get_process_id:
2254 * @accessible: The #AtspiAccessible to query.
2255 * @error: a pointer to a %NULL #GError pointer
2257 * Returns the process id associated with the given accessible. Mainly
2258 * added for debugging; it is a shortcut to explicitly querying the
2259 * accessible's app->bus_name and then calling GetConnectionUnixProcessID.
2261 * Returns: The process ID or undetermined value if @error is set.
2264 atspi_accessible_get_process_id (AtspiAccessible *accessible, GError **error)
2266 DBusMessage *message, *reply;
2267 DBusConnection *bus = _atspi_bus ();
2268 dbus_uint32_t pid = -1;
2271 if (!accessible->parent.app || !accessible->parent.app->bus_name)
2273 g_set_error_literal(error, ATSPI_ERROR, ATSPI_ERROR_IPC, "Process is defunct");
2277 message = dbus_message_new_method_call ("org.freedesktop.DBus",
2278 "/org/freedesktop/DBus",
2279 "org.freedesktop.DBus",
2280 "GetConnectionUnixProcessID");
2281 dbus_message_append_args (message, DBUS_TYPE_STRING,
2282 &accessible->parent.app->bus_name,
2284 dbus_error_init (&d_error);
2285 reply = dbus_connection_send_with_reply_and_block (bus, message, -1, &d_error);
2286 dbus_message_unref (message);
2289 if (!strcmp (dbus_message_get_signature (reply), "u"))
2290 dbus_message_get_args (reply, NULL, DBUS_TYPE_UINT32, &pid, DBUS_TYPE_INVALID);
2291 dbus_message_unref (reply);
2293 if (dbus_error_is_set (&d_error))
2295 g_set_error_literal(error, ATSPI_ERROR, ATSPI_ERROR_IPC, "Process is defunct");
2296 dbus_error_free (&d_error);
2302 _atspi_accessible_get_cache_mask (AtspiAccessible *accessible)
2306 if (!accessible->parent.app)
2307 return ATSPI_CACHE_NONE;
2309 mask = accessible->parent.app->cache;
2310 if (mask == ATSPI_CACHE_UNDEFINED &&
2311 accessible->parent.app->root &&
2312 accessible->parent.app->root->accessible_parent)
2314 AtspiAccessible *desktop = atspi_get_desktop (0);
2315 mask = desktop->parent.app->cache;
2316 g_object_unref (desktop);
2319 if (mask == ATSPI_CACHE_UNDEFINED)
2320 mask = ATSPI_CACHE_DEFAULT;
2326 _atspi_accessible_test_cache (AtspiAccessible *accessible, AtspiCache flag)
2328 AtspiCache mask = _atspi_accessible_get_cache_mask (accessible);
2329 AtspiCache result = accessible->cached_properties & mask & flag;
2330 if (accessible->states && atspi_state_set_contains (accessible->states, ATSPI_STATE_TRANSIENT))
2332 return (result != 0 && (atspi_main_loop || enable_caching ||
2333 flag == ATSPI_CACHE_INTERFACES) &&
2338 _atspi_accessible_add_cache (AtspiAccessible *accessible, AtspiCache flag)
2340 AtspiCache mask = _atspi_accessible_get_cache_mask (accessible);
2342 accessible->cached_properties |= flag & mask;
2346 * atspi_accessible_get_locale:
2347 * @accessible: an #AtspiAccessible
2349 * Gets a UTF-8 string indicating the POSIX-style LC_MESSAGES locale
2354 * Returns: a UTF-8 string indicating the POSIX-style LC_MESSAGES
2355 * locale of @accessible.
2358 atspi_accessible_get_object_locale (AtspiAccessible *accessible, GError **error)
2362 g_return_val_if_fail (accessible != NULL, NULL);
2364 locale = g_object_get_qdata (G_OBJECT (accessible), quark_locale);
2367 if (!_atspi_dbus_get_property (accessible, atspi_interface_accessible,
2368 "Locale", error, "s", &locale))
2371 g_object_set_qdata_full (G_OBJECT (accessible), quark_locale, locale,
2378 * atspi_accessible_get_accessible_id:
2379 * @obj: an #AtspiAccessible
2381 * Gets the accessible id of the accessible. This is not meant to be presented
2382 * to the user, but to be an id which is stable over application development.
2383 * Typically, this is the gtkbuilder id.
2387 * Returns: a character string representing the accessible id of the
2388 * #AtspiAccessible object or NULL on exception.
2391 atspi_accessible_get_accessible_id (AtspiAccessible *obj, GError **error)
2393 gchar *accessible_id;
2395 g_return_val_if_fail (obj != NULL, NULL);
2397 if (!_atspi_dbus_get_property (obj, atspi_interface_accessible,
2398 "AccessibleId", error, "s", &accessible_id))
2401 return accessible_id;
2405 free_value (gpointer data)
2407 GValue *value = data;
2409 g_value_unset (value);
2414 _atspi_accessible_ref_cache (AtspiAccessible *accessible)
2416 AtspiAccessiblePrivate *priv = accessible->priv;
2418 priv->cache_ref_count++;
2420 return g_hash_table_ref (priv->cache);
2421 priv->cache = g_hash_table_new_full (g_str_hash, g_str_equal, g_free,
2427 _atspi_accessible_unref_cache (AtspiAccessible *accessible)
2429 AtspiAccessiblePrivate *priv = accessible->priv;
2433 g_hash_table_unref (priv->cache);
2434 if (--priv->cache_ref_count == 0)