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"
35 static gboolean enable_caching = FALSE;
36 static guint quark_locale;
38 static guint atspi_accessible_signals[LAST_SIGNAL] = { 0, };
41 screen_reader_signal_watcher (GSignalInvocationHint *signal_hint,
43 const GValue *param_values,
47 AtspiAccessible *accessible;
48 GSignalQuery signal_query;
51 DBusMessageIter iter, iter_struct, iter_variant, iter_array;
52 dbus_int32_t detail1 = 0, detail2 = 0;
53 const char *detail = "";
56 object = g_value_get_object (param_values + 0);
57 g_return_val_if_fail (ATSPI_IS_ACCESSIBLE(object), FALSE);
59 g_signal_query (signal_hint->signal_id, &signal_query);
60 name = signal_query.signal_name;
61 if (signal_hint->detail)
62 detail = g_quark_to_string (signal_hint->detail);
63 if (n_param_values > 1)
64 detail1 = g_value_get_int (param_values + 1);
65 if (n_param_values > 2 && G_VALUE_HOLDS_INT (param_values + 2))
66 detail2 = g_value_get_int (param_values + 2);
67 accessible = ATSPI_ACCESSIBLE (object);
69 dbus_name = _atspi_strdup_and_adjust_for_dbus (name);
70 signal = dbus_message_new_signal (ATSPI_DBUS_PATH_SCREEN_READER,
71 ATSPI_DBUS_INTERFACE_EVENT_SCREEN_READER,
74 dbus_message_iter_init_append (signal, &iter);
75 dbus_message_iter_append_basic (&iter, DBUS_TYPE_STRING, &detail);
76 dbus_message_iter_append_basic (&iter, DBUS_TYPE_INT32, &detail1);
77 dbus_message_iter_append_basic (&iter, DBUS_TYPE_INT32, &detail2);
78 dbus_message_iter_open_container (&iter, DBUS_TYPE_VARIANT, "(so)",
80 dbus_message_iter_open_container (&iter_variant, DBUS_TYPE_STRUCT, NULL,
82 dbus_message_iter_append_basic (&iter_struct, DBUS_TYPE_STRING, &accessible->parent.app->bus_name);
83 dbus_message_iter_append_basic (&iter_struct, DBUS_TYPE_OBJECT_PATH, &accessible->parent.path);
84 dbus_message_iter_close_container (&iter_variant, &iter_struct);
85 dbus_message_iter_close_container (&iter, &iter_variant);
86 dbus_message_iter_open_container (&iter, DBUS_TYPE_ARRAY, "{sv}",
88 dbus_message_iter_close_container (&iter, &iter_array);
89 dbus_connection_send (_atspi_bus (), signal, NULL);
90 dbus_message_unref (signal);
95 atspi_action_interface_init (AtspiAction *action)
100 atspi_collection_interface_init (AtspiCollection *component)
105 atspi_component_interface_init (AtspiComponent *component)
110 atspi_document_interface_init (AtspiDocument *document)
115 atspi_editable_text_interface_init (AtspiEditableText *editable_text)
120 atspi_hypertext_interface_init (AtspiHypertext *hypertext)
125 atspi_image_interface_init (AtspiImage *image)
130 atspi_selection_interface_init (AtspiSelection *selection)
135 atspi_table_interface_init (AtspiTable *table)
140 atspi_table_cell_interface_init (AtspiTableCell *cell)
145 atspi_text_interface_init (AtspiText *text)
150 atspi_value_interface_init (AtspiValue *value)
154 G_DEFINE_TYPE_WITH_CODE (AtspiAccessible, atspi_accessible, ATSPI_TYPE_OBJECT,
155 G_ADD_PRIVATE (AtspiAccessible)
156 G_IMPLEMENT_INTERFACE (ATSPI_TYPE_ACTION, atspi_action_interface_init)
157 G_IMPLEMENT_INTERFACE (ATSPI_TYPE_COLLECTION, atspi_collection_interface_init)
158 G_IMPLEMENT_INTERFACE (ATSPI_TYPE_COMPONENT, atspi_component_interface_init)
159 G_IMPLEMENT_INTERFACE (ATSPI_TYPE_DOCUMENT, atspi_document_interface_init)
160 G_IMPLEMENT_INTERFACE (ATSPI_TYPE_EDITABLE_TEXT, atspi_editable_text_interface_init)
161 G_IMPLEMENT_INTERFACE (ATSPI_TYPE_HYPERTEXT, atspi_hypertext_interface_init)
162 G_IMPLEMENT_INTERFACE (ATSPI_TYPE_IMAGE, atspi_image_interface_init)
163 G_IMPLEMENT_INTERFACE (ATSPI_TYPE_SELECTION, atspi_selection_interface_init)
164 G_IMPLEMENT_INTERFACE (ATSPI_TYPE_TABLE, atspi_table_interface_init)
165 G_IMPLEMENT_INTERFACE (ATSPI_TYPE_TABLE_CELL, atspi_table_cell_interface_init)
166 G_IMPLEMENT_INTERFACE (ATSPI_TYPE_TEXT, atspi_text_interface_init)
167 G_IMPLEMENT_INTERFACE (ATSPI_TYPE_VALUE, atspi_value_interface_init))
169 #ifdef DEBUG_REF_COUNTS
170 static gint accessible_count = 0;
174 atspi_accessible_unref (GObject *accessible)
176 if (accessible != NULL)
177 g_object_unref(accessible);
181 atspi_accessible_init (AtspiAccessible *accessible)
183 #ifdef DEBUG_REF_COUNTS
185 g_hash_table_insert (_atspi_get_live_refs (), accessible, NULL);
186 g_print("at-spi: init: %d objects\n", accessible_count);
189 accessible->priv = atspi_accessible_get_instance_private (accessible);
191 accessible->children = g_ptr_array_new_with_free_func ((GDestroyNotify) atspi_accessible_unref);
195 atspi_accessible_dispose (GObject *object)
197 AtspiAccessible *accessible = ATSPI_ACCESSIBLE (object);
199 AtspiAccessible *parent;
202 /* TODO: Only fire if object not already marked defunct */
203 memset (&e, 0, sizeof (e));
204 e.type = "object:state-changed:defunct";
205 e.source = accessible;
208 _atspi_send_event (&e);
210 g_clear_object (&accessible->states);
212 parent = accessible->accessible_parent;
215 accessible->accessible_parent = NULL;
216 if (parent->children)
217 g_ptr_array_remove (parent->children, accessible);
218 g_object_unref (parent);
221 if (accessible->children) for (i = accessible->children->len - 1; i >= 0; i--)
223 AtspiAccessible *child = g_ptr_array_index (accessible->children, i);
224 if (child && atspi_accessible_is_equal (child->accessible_parent, accessible))
226 child->accessible_parent = NULL;
227 g_object_unref (accessible);
231 if (accessible->children)
233 g_ptr_array_free (accessible->children, TRUE);
234 accessible->children = NULL;
237 G_OBJECT_CLASS (atspi_accessible_parent_class) ->dispose (object);
241 atspi_accessible_finalize (GObject *object)
243 AtspiAccessible *accessible = ATSPI_ACCESSIBLE (object);
245 g_free (accessible->description);
246 g_free (accessible->name);
248 if (accessible->attributes)
249 g_hash_table_unref (accessible->attributes);
251 if (accessible->priv->cache)
252 g_hash_table_destroy (accessible->priv->cache);
254 #ifdef DEBUG_REF_COUNTS
256 g_hash_table_remove (_atspi_get_live_refs (), accessible);
257 g_print ("at-spi: finalize: %d objects\n", accessible_count);
260 G_OBJECT_CLASS (atspi_accessible_parent_class)->finalize (object);
262 /* TODO: remove emission hook */
266 atspi_accessible_class_init (AtspiAccessibleClass *klass)
268 GObjectClass *object_class = G_OBJECT_CLASS (klass);
270 object_class->dispose = atspi_accessible_dispose;
271 object_class->finalize = atspi_accessible_finalize;
273 quark_locale = g_quark_from_string ("accessible-locale");
276 * AtspiAccessible::region-changed:
277 * @atspiaccessible: the object which received the signal
278 * @arg1: an integer specifying the current offset of the text being read,
279 * if the object is textual.
280 * @arg2: an integer specifying the ending offset of the text being read,
281 * if the object is textual.
283 * The signal "region-changed" is emitted by a screen reader to indicate
284 * that it is now reading or tracking a new object, or, a new piece of
285 * text within an object. This allows a magnifier to gain the information
286 * needed to highlight the object that the screen reader is reading.
288 atspi_accessible_signals[REGION_CHANGED] =
289 g_signal_new ("region_changed",
290 G_TYPE_FROM_CLASS (klass),
292 G_STRUCT_OFFSET (AtspiAccessibleClass, region_changed),
294 atspi_marshal_VOID__INT_INT,
296 2, G_TYPE_INT, G_TYPE_INT);
299 * AtspiAccessible::mode-changed:
300 * @atspiaccessible: the object which received the signal
301 * @arg1: a boolean specifying whether the mode is being toggled on or off.
302 * @why: an optional string explaining why the mode changed.
304 * The signal "mode-changed" is emitted by a screen reader to indicate
305 * that its mode has changed. This signal supports the following details:
312 atspi_accessible_signals[MODE_CHANGED] =
313 g_signal_new ("mode_changed",
314 G_TYPE_FROM_CLASS (klass),
315 G_SIGNAL_RUN_LAST | G_SIGNAL_DETAILED,
316 G_STRUCT_OFFSET (AtspiAccessibleClass, mode_changed),
318 atspi_marshal_VOID__INT_STRING,
320 2, G_TYPE_INT, G_TYPE_STRING);
322 g_signal_add_emission_hook (atspi_accessible_signals[REGION_CHANGED], 0,
323 screen_reader_signal_watcher, NULL,
324 (GDestroyNotify) NULL);
325 g_signal_add_emission_hook (atspi_accessible_signals[MODE_CHANGED], 0,
326 screen_reader_signal_watcher, NULL,
327 (GDestroyNotify) NULL);
331 * atspi_accessible_get_name:
332 * @obj: a pointer to the #AtspiAccessible object on which to operate.
334 * Gets the name of an #AtspiAccessible object.
336 * Returns: a UTF-8 string indicating the name of the #AtspiAccessible object
337 * or NULL on exception.
340 atspi_accessible_get_name (AtspiAccessible *obj, GError **error)
342 g_return_val_if_fail (obj != NULL, g_strdup (""));
344 if (!_atspi_accessible_test_cache (obj, ATSPI_CACHE_NAME))
348 if (!_atspi_dbus_get_property (obj, atspi_interface_accessible, "Name", error,
350 return g_strdup ("");
351 _atspi_accessible_add_cache (obj, ATSPI_CACHE_NAME);
353 return g_strdup (obj->name);
358 * atspi_accessible_get_unique_id:
359 * @obj: a pointer to the #AtspiAccessible object on which to operate.
361 * Gets the identificator, uniquely identifying object, or NULL if an error occured.
363 * Returns: a UTF-8 string describing the #AtspiAccessible object
364 * or NULL on exception or NULL object passed.
367 atspi_accessible_get_unique_id(AtspiAccessible *obj, GError **error)
370 g_set_error(error, ATSPI_ERROR, ATSPI_ERROR_IPC, "argument is null");
375 gchar *bus_name = atspi_accessible_get_bus_name(obj, error);
376 if (bus_name && bus_name[0]) {
377 gchar *path = atspi_accessible_get_path(obj, error);
379 id = g_strdup_printf("%s:%s", bus_name, path);
381 g_set_error(error, ATSPI_ERROR, ATSPI_ERROR_IPC, "failed to get path");
385 g_set_error(error, ATSPI_ERROR, ATSPI_ERROR_IPC, "failed to get bus name");
391 * atspi_accessible_get_bus_name:
392 * @obj: a pointer to the #AtspiAccessible object on which to operate.
394 * Gets the bus name, where object belongs.
396 * Returns: a UTF-8 string describing the #AtspiAccessible object's
397 * bus name or empty string on exception or NULL object passed.
400 atspi_accessible_get_bus_name(AtspiAccessible *obj, GError **error)
402 if (!obj || !obj->parent.app)
404 return g_strdup (obj->parent.app->bus_name);
408 * atspi_accessible_get_path:
409 * @obj: a pointer to the #AtspiAccessible object on which to operate.
411 * Gets the path, uniquely identifying object over its bus name.
413 * Returns: a UTF-8 string describing the #AtspiAccessible object
414 * or empty string on exception or NULL object passed.
417 atspi_accessible_get_path(AtspiAccessible *obj, GError **error)
419 static const char *prefix = "/org/a11y/atspi/accessible/";
420 static int prefix_len = 27;
424 AtspiObject *o = ATSPI_OBJECT (obj);
427 if (strncmp(o->path, prefix, prefix_len) == 0)
428 return g_strdup(o->path + prefix_len);
429 return g_strdup (o->path);
433 * atspi_accessible_get_navigable_at_point:
434 * @root: a pointer to the #AtspiAccessible to start search from.
435 * @x: a #gint specifying the x coordinate of the point in question.
436 * @y: a #gint specifying the y coordinate of the point in question.
437 * @ctype: the coordinate system of the point (@x, @y)
438 * (e.g. ATSPI_COORD_TYPE_WINDOW, ATSPI_COORD_TYPE_SCREEN).
440 * Finds the accessible element closest to user (highest in z-order), at a given coordinate within an #AtspiAccessible.
441 * This should be the element, that should be picked, when doing mouse click or finger tap at given coordinates.
443 * Returns: (nullable) (transfer full): a pointer to an
444 * #AtspiAccessible descendant (of any depth) of the specified component which
445 * contains the point (@x, @y), or NULL if no descendant contains
449 atspi_accessible_get_navigable_at_point (AtspiAccessible *root,
452 AtspiCoordType ctype, GError **error)
454 dbus_int32_t d_x = x, d_y = y;
455 dbus_uint32_t d_ctype = ctype;
457 AtspiAccessible *return_value = NULL;
458 unsigned char recurse = 0;
459 DBusMessageIter iter;
460 AtspiAccessible *deputy = NULL;
462 g_return_val_if_fail (root != NULL, NULL);
464 reply = _atspi_dbus_call_partial (root, atspi_interface_accessible, "GetNavigableAtPoint", error, "iiu", d_x, d_y, d_ctype);
465 // call failed, error is set, so we bail out
467 if (deputy) g_object_unref(deputy);
468 if (return_value) g_object_unref(return_value);
471 _ATSPI_DBUS_CHECK_SIG (reply, "(so)y(so)", NULL, NULL);
473 dbus_message_iter_init (reply, &iter);
474 AtspiAccessible *tmp = _atspi_dbus_return_accessible_from_iter (&iter);
476 unsigned char value = 0;
477 dbus_message_iter_get_basic (&iter, &value);
478 dbus_message_iter_next (&iter);
479 recurse = (value != 0);
481 /* keep deputy if tmp has deputy */
483 deputy = _atspi_dbus_return_accessible_from_iter (&iter);
485 dbus_message_unref(reply);
489 /* TODO: need to check deputy works for return value */
491 g_object_unref(return_value);
499 g_object_unref(return_value);
507 * atspi_accessible_get_reading_material:
508 * @obj: a pointer to the #AtspiAccessible object on which to operate.
510 * Gets reading material
512 * Returns: reading material to be used screen-reader side. This is not stable.
513 * You have to handle all alocated memory as below on screen-reader side.
515 * AtspiAccessibleReadingMaterial *rm
516 * g_object_unref(rm->parent);
517 * g_object_unref(rm->described_by_accessible);
518 * g_hash_table_unref(rm->attributes);
520 * free(rm->labeled_by_name);
521 * free(rm->text_interface_name);
522 * free(rm->localized_role_name);
523 * free(rm->description);
526 AtspiAccessibleReadingMaterial *
527 atspi_accessible_get_reading_material (AtspiAccessible *obj, GError **error)
529 AtspiAccessible *parent;
530 AtspiAccessibleReadingMaterial *reading_material = NULL;
532 double current_value;
536 DBusMessageIter iter;
537 DBusMessageIter iter_array;
539 dbus_uint32_t *states;
540 dbus_int32_t index_in_parent;
541 dbus_int32_t child_count;
542 dbus_bool_t is_selected;
544 g_return_val_if_fail (obj != NULL, NULL);
546 reply = _atspi_dbus_call_partial (obj, atspi_interface_accessible, "GetReadingMaterial", error, "");
548 _ATSPI_DBUS_CHECK_SIG (reply, "a{ss}sssuausiddddsibbii(so)auiui(so)", NULL, NULL);
550 reading_material = calloc(1, sizeof(AtspiAccessibleReadingMaterial));
551 if (!reading_material)
553 return reading_material;
556 dbus_message_iter_init (reply, &iter);
559 reading_material->attributes = _atspi_dbus_hash_from_iter (&iter);
560 dbus_message_iter_next (&iter);
563 dbus_message_iter_get_basic (&iter, &name);
564 reading_material->name = g_strdup (name);
565 dbus_message_iter_next (&iter);
567 /* get name of relation LABELED_BY */
568 dbus_message_iter_get_basic (&iter, &name);
569 reading_material->labeled_by_name = g_strdup (name);
570 dbus_message_iter_next (&iter);
572 /* get name of text interface */
573 dbus_message_iter_get_basic (&iter, &name);
574 reading_material->text_interface_name = g_strdup (name);
575 dbus_message_iter_next (&iter);
578 dbus_message_iter_get_basic (&iter, &role);
579 reading_material->role = role;
580 dbus_message_iter_next (&iter);
583 dbus_message_iter_recurse (&iter, &iter_array);
584 dbus_message_iter_get_fixed_array (&iter_array, &states, &count);
585 val = ((guint64)states [1]) << 32;
587 reading_material->states = val;
588 dbus_message_iter_next (&iter);
590 /* get localized role name */
591 dbus_message_iter_get_basic (&iter, &name);
592 reading_material->localized_role_name = g_strdup (name);
593 dbus_message_iter_next (&iter);
595 /* get child count */
596 dbus_message_iter_get_basic (&iter, &child_count);
597 reading_material->child_count = child_count;
598 dbus_message_iter_next (&iter);
600 /* get current value */
601 dbus_message_iter_get_basic (&iter, ¤t_value);
602 reading_material->value = current_value;
603 dbus_message_iter_next (&iter);
605 /* get minimum increment */
606 dbus_message_iter_get_basic (&iter, ¤t_value);
607 reading_material->increment = current_value;
608 dbus_message_iter_next (&iter);
610 /* get maximum value */
611 dbus_message_iter_get_basic (&iter, ¤t_value);
612 reading_material->upper = current_value;
613 dbus_message_iter_next (&iter);
615 /* get minimum value */
616 dbus_message_iter_get_basic (&iter, ¤t_value);
617 reading_material->lower = current_value;
618 dbus_message_iter_next (&iter);
620 /* get description */
621 dbus_message_iter_get_basic (&iter, &name);
622 reading_material->description = g_strdup (name);
623 dbus_message_iter_next (&iter);
625 /* get index in parent */
626 dbus_message_iter_get_basic (&iter, &index_in_parent);
627 reading_material->index_in_parent = index_in_parent;
628 dbus_message_iter_next (&iter);
630 /* get selected in parent */
631 dbus_message_iter_get_basic (&iter, &is_selected);
632 reading_material->is_selected_in_parent = is_selected;
633 dbus_message_iter_next (&iter);
635 /* get has checkbox child */
636 dbus_message_iter_get_basic (&iter, &is_selected);
637 reading_material->has_checkbox_child = is_selected;
638 dbus_message_iter_next (&iter);
640 /* get list children count */
641 dbus_message_iter_get_basic (&iter, &child_count);
642 reading_material->list_children_count = child_count;
643 dbus_message_iter_next (&iter);
645 /* get first selected child index */
646 dbus_message_iter_get_basic (&iter, &index_in_parent);
647 reading_material->first_selected_child_index = index_in_parent;
648 dbus_message_iter_next (&iter);
652 parent = _atspi_dbus_return_accessible_from_iter (&iter);
653 reading_material->parent = parent;
656 dbus_message_iter_recurse (&iter, &iter_array);
657 dbus_message_iter_get_fixed_array (&iter_array, &states, &count);
658 val = ((guint64)states [1]) << 32;
660 reading_material->parent_states = val;
661 dbus_message_iter_next (&iter);
663 /* get parent child count */
664 dbus_message_iter_get_basic (&iter, &child_count);
665 reading_material->parent_child_count = child_count;
666 dbus_message_iter_next (&iter);
668 /* get parent role */
669 dbus_message_iter_get_basic (&iter, &role);
670 reading_material->parent_role = role;
671 dbus_message_iter_next (&iter);
673 /* get parent selected child count */
674 dbus_message_iter_get_basic (&iter, &child_count);
675 reading_material->parent_selected_child_count = child_count;
676 dbus_message_iter_next (&iter);
678 ////////////////////////////////////////
679 /* get relation object - DESCRIBED_BY */
680 parent = _atspi_dbus_return_accessible_from_iter (&iter);
681 reading_material->described_by_accessible = parent;
683 dbus_message_unref(reply);
685 return reading_material;
689 * atspi_accessible_get_default_label_info:
690 * @obj: a pointer to the #AtspiAccessible object would be window.
692 * Gets default label information
694 * Returns: default label information to be used screen-reader side.
695 * This is not stable. And this depends on toolkit side UI definition.
696 * The candidate of default label object could be changed by UI definition.
697 * You have to handle all alocated memory as below on screen-reader side.
699 * AtspiAccessibleDefaultLabelInfo *dli
700 * g_hash_table_unref(dli->attributes);
702 * g_object_unref(dli->obj);
705 AtspiAccessibleDefaultLabelInfo *
706 atspi_accessible_get_default_label_info (AtspiAccessible *obj, GError **error)
708 AtspiAccessibleDefaultLabelInfo *default_label_info = NULL;
709 AtspiAccessible *default_label_object;
712 DBusMessageIter iter;
714 g_return_val_if_fail (obj != NULL, NULL);
716 reply = _atspi_dbus_call_partial (obj, atspi_interface_accessible, "GetDefaultLabelInfo", error, "");
718 _ATSPI_DBUS_CHECK_SIG (reply, "(so)ua{ss}", NULL, NULL);
720 default_label_info = calloc(1, sizeof(AtspiAccessibleDefaultLabelInfo));
721 if (!default_label_info)
723 dbus_message_unref(reply);
727 dbus_message_iter_init (reply, &iter);
729 default_label_object = _atspi_dbus_return_accessible_from_iter (&iter);
730 default_label_info->obj = default_label_object;
732 dbus_message_iter_get_basic (&iter, &role);
733 default_label_info->role = role;
734 dbus_message_iter_next (&iter);
736 default_label_info->attributes = _atspi_dbus_hash_from_iter (&iter);
737 dbus_message_iter_next (&iter);
739 dbus_message_unref(reply);
740 return default_label_info;
743 static unsigned char are_objects_on_the_same_bus(AtspiAccessible *obj1, AtspiAccessible *obj2)
745 const char *bus_name_1 = obj1->parent.app->bus_name;
746 const char *bus_name_2 = obj2->parent.app->bus_name;
747 return strcmp(bus_name_1, bus_name_2) == 0;
750 static unsigned char object_is_valid(AtspiAccessible *obj)
754 AtspiStateSet *ss = atspi_accessible_get_state_set(obj);
757 unsigned char valid = atspi_state_set_contains(ss, ATSPI_STATE_DEFUNCT) == 0;
763 NEIGHBOR_SEARCH_MODE_NORMAL = 0,
764 NEIGHBOR_SEARCH_MODE_RECURSE_FROM_ROOT = 1,
765 NEIGHBOR_SEARCH_MODE_CONTINUE_AFTER_FAILED_RECURSING = 2,
766 NEIGHBOR_SEARCH_MODE_RECURSE_TO_OUTSIDE = 3,
767 } GetNeighborSearchMode;
769 * atspi_accessible_get_neighbor:
770 * @root: a pointer to a #AtspiAccessible, which represents current root of subtree to search
771 * @start: a pointer to the #AtspiAccessible to start search from (can be null, which means start from root)
772 * @direction: direction, in which search (forward or backward)
774 * Calculates next (or previous) accessible element in logical order or null if none found.
776 * Returns: (nullable) (transfer full): a pointer to an
777 * #AtspiAccessible element, which is next (previous) in logical order or null if none found.
780 atspi_accessible_get_neighbor (AtspiAccessible *root,
781 AtspiAccessible *start,
782 AtspiNeighborSearchDirection direction,
785 g_return_val_if_fail (object_is_valid(root), NULL);
786 if (!object_is_valid(start))
788 const char *root_path = ATSPI_OBJECT(root)->path;
789 AtspiAccessible *return_value = NULL;
791 unsigned char recurse;
792 GetNeighborSearchMode search_mode = NEIGHBOR_SEARCH_MODE_NORMAL;
793 GQueue *children_root_stack = g_queue_new();
794 DBusMessageIter iter;
797 const char *path = are_objects_on_the_same_bus(root, start) ? root_path : "";
798 DBusMessage *reply = _atspi_dbus_call_partial (start, atspi_interface_accessible, "GetNeighbor", error, "sii", path, (int)direction, (int)search_mode);
799 // call failed, error is set, so we bail out
802 _ATSPI_DBUS_CHECK_SIG (reply, "(so)y", error, NULL);
803 dbus_message_iter_init (reply, &iter);
804 AtspiAccessible *ret = _atspi_dbus_return_accessible_from_iter (&iter);
806 unsigned char value = 0;
807 dbus_message_iter_get_basic (&iter, &value);
808 dbus_message_iter_next (&iter);
809 recurse = (value != 0);
811 dbus_message_unref(reply);
813 // got return value and request for recursive search, it means ret is on another bridge, than start
814 // thus we're recursing. should the recurse failed to find anything it will end with
815 if (ret && recurse) {
816 g_object_unref(G_OBJECT(start));
819 if (are_objects_on_the_same_bus(root, ret))
821 search_mode = NEIGHBOR_SEARCH_MODE_RECURSE_TO_OUTSIDE;
825 g_queue_push_tail(children_root_stack, ret);
826 search_mode = NEIGHBOR_SEARCH_MODE_RECURSE_FROM_ROOT;
830 // found the one we've been looking for
832 g_object_unref(G_OBJECT(start));
837 // we've stepped into different bridges previously and now we're going back to the last one
838 // and continuing search where we left
839 if (!g_queue_is_empty(children_root_stack)) {
840 g_object_unref(G_OBJECT(start));
841 start = g_queue_pop_tail(children_root_stack);
843 search_mode = NEIGHBOR_SEARCH_MODE_CONTINUE_AFTER_FAILED_RECURSING;
846 // there's no more bridges to check, but we might have started from one
847 // in that case there might be bridges "below" start, which we yet have to visit
848 if (!are_objects_on_the_same_bus(root, start)) {
849 unsigned char continue_loop = 1;
850 while(continue_loop) {
851 AtspiAccessible *parent = atspi_accessible_get_parent(start, NULL);
852 continue_loop = parent ? are_objects_on_the_same_bus(start, parent) : 0;
853 g_object_unref(G_OBJECT(start));
857 // going up thru parents put us in weird place (we didnt meet root on the way)
862 // start object now points to different bridge and must be treated as "resume after recursing"
863 search_mode = NEIGHBOR_SEARCH_MODE_CONTINUE_AFTER_FAILED_RECURSING;
868 g_object_unref(start);
871 while(!g_queue_is_empty(children_root_stack))
872 g_object_unref(g_queue_pop_tail(children_root_stack));
873 g_queue_free(children_root_stack);
879 * atspi_accessible_get_description:
880 * @obj: a pointer to the #AtspiAccessible object on which to operate.
882 * Gets the description of an #AtspiAccessible object.
884 * Returns: a UTF-8 string describing the #AtspiAccessible object
885 * or NULL on exception.
888 atspi_accessible_get_description (AtspiAccessible *obj, GError **error)
890 g_return_val_if_fail (obj != NULL, g_strdup (""));
892 if (!_atspi_accessible_test_cache (obj, ATSPI_CACHE_DESCRIPTION))
894 g_free (obj->description);
895 obj->description = NULL;
896 if (!_atspi_dbus_get_property (obj, atspi_interface_accessible,
897 "Description", error, "s",
899 return g_strdup ("");
900 _atspi_accessible_add_cache (obj, ATSPI_CACHE_DESCRIPTION);
902 return g_strdup (obj->description);
905 const char *str_parent = "Parent";
908 * atspi_accessible_get_parent:
909 * @obj: a pointer to the #AtspiAccessible object to query.
911 * Gets an #AtspiAccessible object's parent container.
913 * Returns: (nullable) (transfer full): a pointer to the
914 * #AtspiAccessible object which contains the given
915 * #AtspiAccessible instance, or NULL if the @obj has no
920 atspi_accessible_get_parent (AtspiAccessible *obj, GError **error)
922 g_return_val_if_fail (obj != NULL, NULL);
924 if (!_atspi_accessible_test_cache (obj, ATSPI_CACHE_PARENT))
926 DBusMessage *message, *reply;
927 DBusMessageIter iter, iter_variant;
928 if (!obj->parent.app)
930 message = dbus_message_new_method_call (obj->parent.app->bus_name,
932 DBUS_INTERFACE_PROPERTIES, "Get");
935 dbus_message_append_args (message, DBUS_TYPE_STRING, &atspi_interface_accessible,
936 DBUS_TYPE_STRING, &str_parent,
938 reply = _atspi_dbus_send_with_reply_and_block (message, error);
941 if (strcmp (dbus_message_get_signature (reply), "v") != 0)
943 dbus_message_unref (reply);
946 dbus_message_iter_init (reply, &iter);
947 dbus_message_iter_recurse (&iter, &iter_variant);
948 g_clear_object (&obj->accessible_parent);
949 obj->accessible_parent = _atspi_dbus_return_accessible_from_iter (&iter_variant);
950 dbus_message_unref (reply);
951 _atspi_accessible_add_cache (obj, ATSPI_CACHE_PARENT);
953 if (!obj->accessible_parent)
955 return g_object_ref (obj->accessible_parent);
959 * atspi_accessible_get_child_count:
960 * @obj: a pointer to the #AtspiAccessible object on which to operate.
962 * Gets the number of children contained by an #AtspiAccessible object.
964 * Returns: a #long indicating the number of #AtspiAccessible children
965 * contained by an #AtspiAccessible object or -1 on exception.
969 atspi_accessible_get_child_count (AtspiAccessible *obj, GError **error)
971 g_return_val_if_fail (obj != NULL, -1);
973 if (!_atspi_accessible_test_cache (obj, ATSPI_CACHE_CHILDREN))
976 if (!_atspi_dbus_get_property (obj, atspi_interface_accessible,
977 "ChildCount", error, "i", &ret))
983 return 0; /* assume it's disposed */
985 return obj->children->len;
989 * atspi_accessible_get_child_at_index:
990 * @obj: a pointer to the #AtspiAccessible object on which to operate.
991 * @child_index: a #long indicating which child is specified.
993 * Gets the #AtspiAccessible child of an #AtspiAccessible object at a given index.
995 * Returns: (transfer full): a pointer to the #AtspiAccessible child object at
996 * index @child_index or NULL on exception.
999 atspi_accessible_get_child_at_index (AtspiAccessible *obj,
1003 AtspiAccessible *child;
1006 g_return_val_if_fail (obj != NULL, NULL);
1008 if (_atspi_accessible_test_cache (obj, ATSPI_CACHE_CHILDREN))
1011 return NULL; /* assume disposed */
1013 child = g_ptr_array_index (obj->children, child_index);
1015 return g_object_ref (child);
1018 reply = _atspi_dbus_call_partial (obj, atspi_interface_accessible,
1019 "GetChildAtIndex", error, "i", child_index);
1020 child = _atspi_dbus_return_accessible_from_message (reply);
1025 if (_atspi_accessible_test_cache (obj, ATSPI_CACHE_CHILDREN))
1027 if (child_index >= obj->children->len)
1028 g_ptr_array_set_size (obj->children, child_index + 1);
1029 g_ptr_array_index (obj->children, child_index) = g_object_ref (child);
1035 * atspi_accessible_get_index_in_parent:
1036 * @obj: a pointer to the #AtspiAccessible object on which to operate.
1038 * Gets the index of an #AtspiAccessible object within its parent's
1039 * #AtspiAccessible children list.
1041 * Returns: a #glong indicating the index of the #AtspiAccessible object
1043 * or -1 if @obj has no containing parent or on exception.
1046 atspi_accessible_get_index_in_parent (AtspiAccessible *obj, GError **error)
1049 dbus_int32_t ret = -1;
1051 g_return_val_if_fail (obj != NULL, -1);
1052 if (_atspi_accessible_test_cache (obj, ATSPI_CACHE_PARENT))
1054 if (!obj->accessible_parent)
1057 if (!_atspi_accessible_test_cache (obj->accessible_parent, ATSPI_CACHE_CHILDREN) || !obj->accessible_parent->children)
1060 for (i = 0; i < obj->accessible_parent->children->len; i++)
1061 if (atspi_accessible_is_equal (g_ptr_array_index (obj->accessible_parent->children, i), obj))
1066 _atspi_dbus_call (obj, atspi_interface_accessible,
1067 "GetIndexInParent", NULL, "=>i", &ret);
1075 } Accessibility_Relation;
1078 * atspi_accessible_get_relation_set:
1079 * @obj: a pointer to the #AtspiAccessible object on which to operate.
1081 * Gets the set of #AtspiRelation objects which describes this #AtspiAccessible object's
1082 * relationships with other #AtspiAccessible objects.
1084 * Returns: (element-type AtspiRelation*) (transfer full): a #GArray of
1085 * #AtspiRelation pointers or NULL on exception.
1088 atspi_accessible_get_relation_set (AtspiAccessible *obj, GError **error)
1091 DBusMessageIter iter, iter_array;
1094 g_return_val_if_fail (obj != NULL, NULL);
1096 reply = _atspi_dbus_call_partial (obj, atspi_interface_accessible, "GetRelationSet", error, "");
1099 _ATSPI_DBUS_CHECK_SIG (reply, "a(ua(so))", error, NULL);
1101 ret = g_array_new (TRUE, TRUE, sizeof (AtspiRelation *));
1102 dbus_message_iter_init (reply, &iter);
1103 dbus_message_iter_recurse (&iter, &iter_array);
1104 while (dbus_message_iter_get_arg_type (&iter_array) != DBUS_TYPE_INVALID)
1106 AtspiRelation *relation;
1107 relation = _atspi_relation_new_from_iter (&iter_array);
1108 ret = g_array_append_val (ret, relation);
1109 dbus_message_iter_next (&iter_array);
1111 dbus_message_unref (reply);
1116 * atspi_accessible_get_role:
1117 * @obj: a pointer to the #AtspiAccessible object on which to operate.
1119 * Gets the UI role played by an #AtspiAccessible object.
1120 * This role's name can be obtained via atspi_accessible_get_role_name ().
1122 * Returns: the #AtspiRole of an #AtspiAccessible object.
1126 atspi_accessible_get_role (AtspiAccessible *obj, GError **error)
1128 g_return_val_if_fail (obj != NULL, ATSPI_ROLE_INVALID);
1130 if (!_atspi_accessible_test_cache (obj, ATSPI_CACHE_ROLE))
1133 /* TODO: Make this a property */
1134 if (_atspi_dbus_call (obj, atspi_interface_accessible, "GetRole", error, "=>u", &role))
1137 _atspi_accessible_add_cache (obj, ATSPI_CACHE_ROLE);
1144 * atspi_accessible_get_role_name:
1145 * @obj: a pointer to the #AtspiAccessible object on which to operate.
1147 * Gets a UTF-8 string corresponding to the name of the role played by an object.
1148 * This method will return useful values for roles that fall outside the
1149 * enumeration used in atspi_accessible_get_role ().
1151 * Returns: a UTF-8 string specifying the type of UI role played by an
1152 * #AtspiAccessible object.
1156 atspi_accessible_get_role_name (AtspiAccessible *obj, GError **error)
1158 gchar *retval = NULL;
1161 g_return_val_if_fail (obj != NULL, NULL);
1163 role = atspi_accessible_get_role (obj, error);
1164 if (role >= 0 && role < ATSPI_ROLE_COUNT && role != ATSPI_ROLE_EXTENDED)
1165 return atspi_role_get_name (role);
1167 _atspi_dbus_call (obj, atspi_interface_accessible, "GetRoleName", error, "=>s", &retval);
1170 retval = g_strdup ("");
1176 * atspi_accessible_get_localized_role_name:
1177 * @obj: a pointer to the #AtspiAccessible object on which to operate.
1179 * Gets a UTF-8 string corresponding to the name of the role played by an
1180 * object, translated to the current locale.
1181 * This method will return useful values for roles that fall outside the
1182 * enumeration used in atspi_accessible_getRole ().
1184 * Returns: a localized, UTF-8 string specifying the type of UI role played
1185 * by an #AtspiAccessible object.
1189 atspi_accessible_get_localized_role_name (AtspiAccessible *obj, GError **error)
1191 char *retval = NULL;
1193 g_return_val_if_fail (obj != NULL, NULL);
1195 _atspi_dbus_call (obj, atspi_interface_accessible, "GetLocalizedRoleName", error, "=>s", &retval);
1198 return g_strdup ("");
1203 static AtspiStateSet *
1206 AtspiStateSet *set = atspi_state_set_new (NULL);
1207 atspi_state_set_add (set, ATSPI_STATE_DEFUNCT);
1212 * atspi_accessible_get_state_set:
1213 * @obj: a pointer to the #AtspiAccessible object on which to operate.
1215 * Gets the states currently held by an object.
1217 * Returns: (transfer full): a pointer to an #AtspiStateSet representing an
1218 * object's current state set.
1221 atspi_accessible_get_state_set (AtspiAccessible *obj)
1223 /* TODO: Should take a GError **, but would be an API break */
1224 if (!obj->parent.app || !obj->parent.app->bus)
1225 return defunct_set ();
1227 if (!_atspi_accessible_test_cache (obj, ATSPI_CACHE_STATES))
1230 DBusMessageIter iter;
1231 reply = _atspi_dbus_call_partial (obj, atspi_interface_accessible,
1232 "GetState", NULL, "");
1233 _ATSPI_DBUS_CHECK_SIG (reply, "au", NULL, defunct_set ());
1234 dbus_message_iter_init (reply, &iter);
1235 _atspi_dbus_set_state (obj, &iter);
1236 dbus_message_unref (reply);
1237 _atspi_accessible_add_cache (obj, ATSPI_CACHE_STATES);
1239 return g_object_ref (obj->states);
1243 * atspi_accessible_get_attributes:
1244 * @obj: The #AtspiAccessible being queried.
1246 * Gets the #AttributeSet 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 instead.
1251 * Returns: (element-type gchar* gchar*) (transfer full): The name-value-pair
1252 * attributes assigned to this object.
1255 atspi_accessible_get_attributes (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");
1265 return g_value_dup_boxed (val);
1268 if (!_atspi_accessible_test_cache (obj, ATSPI_CACHE_ATTRIBUTES))
1270 message = _atspi_dbus_call_partial (obj, atspi_interface_accessible,
1271 "GetAttributes", error, "");
1272 g_clear_pointer (&(obj->attributes), g_hash_table_unref);
1274 obj->attributes = _atspi_dbus_return_hash_from_message (message);
1275 _atspi_accessible_add_cache (obj, ATSPI_CACHE_ATTRIBUTES);
1278 if (!obj->attributes)
1280 return g_hash_table_ref (obj->attributes);
1284 add_to_attribute_array (gpointer key, gpointer value, gpointer data)
1286 GArray **array = (GArray **)data;
1287 gchar *str = g_strconcat (key, ":", value, NULL);
1288 *array = g_array_append_val (*array, str);
1292 * atspi_accessible_get_attributes_as_array:
1293 * @obj: The #AtspiAccessible being queried.
1295 * Gets a #GArray representing any assigned
1296 * name-value pair attributes or annotations for this object.
1297 * For typographic, textual, or textually-semantic attributes, see
1298 * atspi_text_get_attributes_as_array instead.
1300 * Returns: (element-type gchar*) (transfer full): The name-value-pair
1301 * attributes assigned to this object.
1304 atspi_accessible_get_attributes_as_array (AtspiAccessible *obj, GError **error)
1306 DBusMessage *message;
1308 g_return_val_if_fail (obj != NULL, NULL);
1310 if (obj->priv->cache)
1312 GValue *val = g_hash_table_lookup (obj->priv->cache, "Attributes");
1315 GArray *array = g_array_new (TRUE, TRUE, sizeof (gchar *));
1316 GHashTable *attributes = g_value_get_boxed (val);
1317 g_hash_table_foreach (attributes, add_to_attribute_array, &array);
1322 message = _atspi_dbus_call_partial (obj, atspi_interface_accessible, "GetAttributes", error, "");
1323 return _atspi_dbus_return_attribute_array_from_message (message);
1327 * atspi_accessible_get_application:
1328 * @obj: The #AtspiAccessible being queried.
1330 * Gets the containing #AtspiApplication for an object.
1332 * Returns: (transfer full): the containing #AtspiApplication instance for
1336 atspi_accessible_get_application (AtspiAccessible *obj, GError **error)
1338 AtspiAccessible *parent;
1343 parent = atspi_accessible_get_parent (obj, NULL);
1344 if (!parent && obj->parent.app &&
1345 atspi_accessible_get_role (obj, NULL) != ATSPI_ROLE_APPLICATION)
1347 AtspiAccessible *root = g_object_ref (obj->parent.app->root);
1350 g_object_unref (obj);
1351 if (atspi_accessible_get_role (root, NULL) == ATSPI_ROLE_DESKTOP_FRAME)
1353 g_object_unref (root);
1359 if (!parent || atspi_accessible_is_equal (parent, obj) ||
1360 atspi_accessible_get_role (parent, NULL) == ATSPI_ROLE_DESKTOP_FRAME)
1363 g_object_unref (parent);
1366 g_object_unref (obj);
1371 /* Application-specific methods */
1374 * atspi_accessible_get_toolkit_name:
1375 * @obj: a pointer to the #AtspiAccessible object on which to operate.
1377 * Gets the toolkit name for an #AtspiAccessible object.
1378 * Only works on application root objects.
1380 * Returns: a UTF-8 string indicating the toolkit name for the #AtspiAccessible object or NULL on exception.
1383 atspi_accessible_get_toolkit_name (AtspiAccessible *obj, GError **error)
1385 g_return_val_if_fail (obj != NULL, NULL);
1387 if (!obj->parent.app)
1390 if (!obj->parent.app->toolkit_name)
1391 _atspi_dbus_get_property (obj, atspi_interface_application, "ToolkitName",
1392 error, "s", &obj->parent.app->toolkit_name);
1394 return g_strdup (obj->parent.app->toolkit_name);
1398 * atspi_accessible_get_toolkit_version:
1399 * @obj: a pointer to the #AtspiAccessible object on which to operate.
1401 * Gets the toolkit version for an #AtspiAccessible object.
1402 * Only works on application root objects.
1404 * Returns: a UTF-8 string indicating the toolkit version for the #AtspiAccessible object or NULL on exception.
1407 atspi_accessible_get_toolkit_version (AtspiAccessible *obj, GError **error)
1409 g_return_val_if_fail (obj != NULL, NULL);
1411 if (!obj->parent.app)
1414 if (!obj->parent.app->toolkit_version)
1415 _atspi_dbus_get_property (obj, atspi_interface_application, "Version",
1416 error, "s", &obj->parent.app->toolkit_version);
1418 return g_strdup (obj->parent.app->toolkit_version);
1422 * atspi_accessible_get_atspi_version:
1423 * @obj: a pointer to the #AtspiAccessible object on which to operate.
1425 * Gets the AT-SPI IPC specification version supported by the application
1426 * pointed to by the #AtspiAccessible object.
1427 * Only works on application root objects.
1429 * Returns: a UTF-8 string indicating the AT-SPI version for the #AtspiAccessible object or NULL on exception.
1432 atspi_accessible_get_atspi_version (AtspiAccessible *obj, GError **error)
1434 g_return_val_if_fail (obj != NULL, NULL);
1436 if (!obj->parent.app)
1439 if (!obj->parent.app->atspi_version)
1440 _atspi_dbus_get_property (obj, atspi_interface_application, "AtspiVersion",
1441 error, "s", &obj->parent.app->atspi_version);
1443 return g_strdup (obj->parent.app->atspi_version);
1447 * atspi_accessible_get_id:
1448 * @obj: a pointer to the #AtspiAccessible object on which to operate.
1450 * Gets the application id for a #AtspiAccessible object.
1451 * Only works on application root objects.
1453 * Returns: a positive #gint indicating the id for the #AtspiAccessible object
1454 * or -1 on exception.
1457 atspi_accessible_get_id (AtspiAccessible *obj, GError **error)
1461 g_return_val_if_fail (obj != NULL, -1);
1463 if (!_atspi_dbus_get_property (obj, atspi_interface_application, "Id", error, "i", &ret))
1468 //TIZEN_ONLY(20230307) Provide post render callback to client
1470 * atspi_accessible_set_listen_post_render:
1471 * @obj: a pointer to the #AtspiAccessible object on which to operate.
1472 * @enabled: a boolean true listen post render callback, false otherwise.
1474 * Asks the UI Toolkit listen for the post render callback.
1477 atspi_accessible_set_listen_post_render(AtspiAccessible *obj, gboolean enabled, GError **error)
1479 g_return_if_fail (obj != NULL);
1481 _atspi_dbus_call (obj, atspi_interface_accessible, "SetListenPostRender", error, "b", enabled, NULL);
1484 /* Interface query methods */
1487 _atspi_accessible_is_a (AtspiAccessible *accessible,
1488 const char *interface_name)
1492 if (accessible == NULL)
1497 if (!_atspi_accessible_test_cache (accessible, ATSPI_CACHE_INTERFACES))
1500 DBusMessageIter iter;
1501 reply = _atspi_dbus_call_partial (accessible, atspi_interface_accessible,
1502 "GetInterfaces", NULL, "");
1503 _ATSPI_DBUS_CHECK_SIG (reply, "as", NULL, FALSE);
1504 dbus_message_iter_init (reply, &iter);
1505 _atspi_dbus_set_interfaces (accessible, &iter);
1506 dbus_message_unref (reply);
1507 _atspi_accessible_add_cache (accessible, ATSPI_CACHE_INTERFACES);
1510 n = _atspi_get_iface_num (interface_name);
1511 if (n == -1) return FALSE;
1512 return (gboolean) ((accessible->interfaces & (1 << n))? TRUE: FALSE);
1516 * atspi_accessible_is_action:
1517 * @obj: a pointer to the #AtspiAccessible instance to query.
1519 * Query whether the specified #AtspiAccessible implements the
1520 * #AtspiAction interface.
1522 * Returns: #TRUE if @obj implements the #AtspiAction interface,
1526 atspi_accessible_is_action (AtspiAccessible *obj)
1528 return _atspi_accessible_is_a (obj,
1529 atspi_interface_action);
1533 * atspi_accessible_is_application:
1534 * @obj: a pointer to the #AtspiAccessible instance to query.
1536 * Query whether the specified #AtspiAccessible implements the
1537 * #AtspiApplication interface.
1539 * Returns: #TRUE if @obj implements the #AtspiApplication interface,
1543 atspi_accessible_is_application (AtspiAccessible *obj)
1545 return _atspi_accessible_is_a (obj,
1546 atspi_interface_application);
1550 * atspi_accessible_is_collection:
1551 * @obj: a pointer to the #AtspiAccessible instance to query.
1553 * Query whether the specified #AtspiAccessible implements the
1554 * #AtspiCollection interface.
1556 * Returns: #TRUE if @obj implements the #AtspiCollection interface,
1560 atspi_accessible_is_collection (AtspiAccessible *obj)
1562 return _atspi_accessible_is_a (obj,
1563 atspi_interface_collection);
1567 * atspi_accessible_is_component:
1568 * @obj: a pointer to the #AtspiAccessible instance to query.
1570 * Query whether the specified #AtspiAccessible implements #AtspiComponent.
1572 * Returns: #TRUE if @obj implements the #AtspiComponent interface,
1576 atspi_accessible_is_component (AtspiAccessible *obj)
1578 return _atspi_accessible_is_a (obj,
1579 atspi_interface_component);
1583 * atspi_accessible_is_document:
1584 * @obj: a pointer to the #AtspiAccessible instance to query.
1586 * Query whether the specified #AtspiAccessible implements the
1587 * #AtspiDocument interface.
1589 * Returns: #TRUE if @obj implements the #AtspiDocument interface,
1593 atspi_accessible_is_document (AtspiAccessible *obj)
1595 return _atspi_accessible_is_a (obj,
1596 atspi_interface_document);
1600 * atspi_accessible_is_editable_text:
1601 * @obj: a pointer to the #AtspiAccessible instance to query.
1603 * Query whether the specified #AtspiAccessible implements the
1604 * #AtspiEditableText interface.
1606 * Returns: #TRUE if @obj implements the #AtspiEditableText interface,
1610 atspi_accessible_is_editable_text (AtspiAccessible *obj)
1612 return _atspi_accessible_is_a (obj,
1613 atspi_interface_editable_text);
1617 * atspi_accessible_is_hypertext:
1618 * @obj: a pointer to the #AtspiAccessible instance to query.
1620 * Query whether the specified #AtspiAccessible implements the
1621 * #AtspiHypertext interface.
1623 * Returns: #TRUE if @obj implements the #AtspiHypertext interface,
1627 atspi_accessible_is_hypertext (AtspiAccessible *obj)
1629 return _atspi_accessible_is_a (obj,
1630 atspi_interface_hypertext);
1634 * atspi_accessible_is_hyperlink:
1635 * @obj: a pointer to the #AtspiAccessible instance to query.
1637 * Query whether the specified #AtspiAccessible implements the
1638 * #AtspiHyperlink interface.
1640 * Returns: #TRUE if @obj implements the #AtspiHypertext interface,
1644 atspi_accessible_is_hyperlink (AtspiAccessible *obj)
1646 return _atspi_accessible_is_a (obj,
1647 atspi_interface_hyperlink);
1651 * atspi_accessible_is_image:
1652 * @obj: a pointer to the #AtspiAccessible instance to query.
1654 * Query whether the specified #AtspiAccessible implements the
1655 * #AtspiImage interface.
1657 * Returns: #TRUE if @obj implements the #AtspiImage interface,
1661 atspi_accessible_is_image (AtspiAccessible *obj)
1663 return _atspi_accessible_is_a (obj,
1664 atspi_interface_image);
1668 * atspi_accessible_is_selection:
1669 * @obj: a pointer to the #AtspiAccessible instance to query.
1671 * Query whether the specified #AtspiAccessible implements the
1672 * #AtspiSelection interface.
1674 * Returns: #TRUE if @obj implements the #AtspiSelection interface,
1678 atspi_accessible_is_selection (AtspiAccessible *obj)
1680 return _atspi_accessible_is_a (obj,
1681 atspi_interface_selection);
1685 * atspi_accessible_is_table:
1686 * @obj: a pointer to the #AtspiAccessible instance to query.
1688 * Query whether the specified #AtspiAccessible implements the
1689 * #AtspiTable interface.
1691 * Returns: #TRUE if @obj implements the #AtspiTable interface,
1695 atspi_accessible_is_table (AtspiAccessible *obj)
1697 return _atspi_accessible_is_a (obj,
1698 atspi_interface_table);
1702 * atspi_accessible_is_table_cell:
1703 * @obj: a pointer to the #AtspiAccessible instance to query.
1705 * Query whether the specified #AtspiAccessible implements the
1706 * #AtspiTableCell interface.
1708 * Returns: #TRUE if @obj implements the #AtspiTable interface,
1712 atspi_accessible_is_table_cell (AtspiAccessible *obj)
1714 return _atspi_accessible_is_a (obj,
1715 atspi_interface_table_cell);
1719 * atspi_accessible_is_streamable_content:
1720 * @obj: a pointer to the #AtspiAccessible instance to query.
1722 * Query whether the specified #AtspiAccessible implements the
1723 * #AtspiStreamableContent interface.
1725 * Returns: #TRUE if @obj implements the #AtspiStreamableContent interface,
1729 atspi_accessible_is_streamable_content (AtspiAccessible *obj)
1732 return _atspi_accessible_is_a (obj,
1733 atspi_interface_streamable_content);
1735 g_warning ("Streamable content not implemented");
1741 * atspi_accessible_is_text:
1742 * @obj: a pointer to the #AtspiAccessible instance to query.
1744 * Query whether the specified #AtspiAccessible implements the
1745 * #AtspiText interface.
1747 * Returns: #TRUE if @obj implements the #AtspiText interface,
1751 atspi_accessible_is_text (AtspiAccessible *obj)
1753 return _atspi_accessible_is_a (obj,
1754 atspi_interface_text);
1758 * atspi_accessible_is_value:
1759 * @obj: a pointer to the #AtspiAccessible instance to query.
1761 * Query whether the specified #AtspiAccessible implements the
1762 * #AtspiValue interface.
1764 * Returns: #TRUE if @obj implements the #AtspiValue interface,
1768 atspi_accessible_is_value (AtspiAccessible *obj)
1770 return _atspi_accessible_is_a (obj,
1771 atspi_interface_value);
1775 * atspi_accessible_get_action: (rename-to atspi_accessible_get_action_iface)
1776 * @obj: a pointer to the #AtspiAccessible instance to query.
1778 * Gets the #AtspiAction interface for an #AtspiAccessible.
1780 * Returns: (transfer full): a pointer to an #AtspiAction interface
1781 * instance, or NULL if @obj does not implement #AtspiAction.
1783 * Deprecated: 2.10: Use atspi_accessible_get_action_iface instead.
1786 atspi_accessible_get_action (AtspiAccessible *accessible)
1788 return (_atspi_accessible_is_a (accessible, atspi_interface_action) ?
1789 g_object_ref (ATSPI_ACTION (accessible)) : NULL);
1793 * atspi_accessible_get_action_iface:
1794 * @obj: a pointer to the #AtspiAccessible instance to query.
1796 * Gets the #AtspiAction interface for an #AtspiAccessible.
1798 * Returns: (transfer full): a pointer to an #AtspiAction interface
1799 * instance, or NULL if @obj does not implement #AtspiAction.
1802 atspi_accessible_get_action_iface (AtspiAccessible *accessible)
1804 return (_atspi_accessible_is_a (accessible, atspi_interface_action) ?
1805 g_object_ref (ATSPI_ACTION (accessible)) : NULL);
1809 * atspi_accessible_get_collection: (rename-to atspi_accessible_get_collection_iface)
1810 * @obj: a pointer to the #AtspiAccessible instance to query.
1812 * Gets the #AtspiCollection interface for an #AtspiAccessible.
1814 * Returns: (transfer full): a pointer to an #AtspiCollection interface
1815 * instance, or NULL if @obj does not implement #AtspiCollection.
1817 * Deprecated: 2.10: Use atspi_accessible_get_collection_iface instead.
1820 atspi_accessible_get_collection (AtspiAccessible *accessible)
1822 return (_atspi_accessible_is_a (accessible, atspi_interface_collection) ?
1823 g_object_ref (ATSPI_COLLECTION (accessible)) : NULL);
1827 * atspi_accessible_get_collection_iface:
1828 * @obj: a pointer to the #AtspiAccessible instance to query.
1830 * Gets the #AtspiCollection interface for an #AtspiAccessible.
1832 * Returns: (transfer full): a pointer to an #AtspiCollection interface
1833 * instance, or NULL if @obj does not implement #AtspiCollection.
1836 atspi_accessible_get_collection_iface (AtspiAccessible *accessible)
1838 return (_atspi_accessible_is_a (accessible, atspi_interface_collection) ?
1839 g_object_ref (ATSPI_COLLECTION (accessible)) : NULL);
1843 * atspi_accessible_get_component: (rename-to atspi_accessible_get_component_iface)
1844 * @obj: a pointer to the #AtspiAccessible instance to query.
1846 * Gets the #AtspiComponent interface for an #AtspiAccessible.
1848 * Returns: (transfer full): a pointer to an #AtspiComponent interface
1849 * instance, or NULL if @obj does not implement #AtspiComponent.
1851 * Deprecated: 2.10: Use atspi_accessible_get_component_iface instead.
1854 atspi_accessible_get_component (AtspiAccessible *obj)
1856 return (_atspi_accessible_is_a (obj, atspi_interface_component) ?
1857 g_object_ref (ATSPI_COMPONENT (obj)) : NULL);
1861 * atspi_accessible_get_component_iface:
1862 * @obj: a pointer to the #AtspiAccessible instance to query.
1864 * Gets the #AtspiComponent interface for an #AtspiAccessible.
1866 * Returns: (transfer full): a pointer to an #AtspiComponent interface
1867 * instance, or NULL if @obj does not implement #AtspiComponent.
1870 atspi_accessible_get_component_iface (AtspiAccessible *obj)
1872 return (_atspi_accessible_is_a (obj, atspi_interface_component) ?
1873 g_object_ref (ATSPI_COMPONENT (obj)) : NULL);
1877 * atspi_accessible_get_document: (rename-to atspi_accessible_get_document_iface)
1878 * @obj: a pointer to the #AtspiAccessible instance to query.
1880 * Gets the #AtspiDocument interface for an #AtspiAccessible.
1882 * Returns: (transfer full): a pointer to an #AtspiDocument interface
1883 * instance, or NULL if @obj does not implement #AtspiDocument.
1885 * Deprecated: 2.10: Use atspi_accessible_get_document_iface instead.
1888 atspi_accessible_get_document (AtspiAccessible *accessible)
1890 return (_atspi_accessible_is_a (accessible, atspi_interface_document) ?
1891 g_object_ref (ATSPI_DOCUMENT (accessible)) : NULL);
1895 * atspi_accessible_get_document_iface:
1896 * @obj: a pointer to the #AtspiAccessible instance to query.
1898 * Gets the #AtspiDocument interface for an #AtspiAccessible.
1900 * Returns: (transfer full): a pointer to an #AtspiDocument interface
1901 * instance, or NULL if @obj does not implement #AtspiDocument.
1904 atspi_accessible_get_document_iface (AtspiAccessible *accessible)
1906 return (_atspi_accessible_is_a (accessible, atspi_interface_document) ?
1907 g_object_ref (ATSPI_DOCUMENT (accessible)) : NULL);
1911 * atspi_accessible_get_editable_text: (rename-to atspi_accessible_get_editable_text_iface)
1912 * @obj: a pointer to the #AtspiAccessible instance to query.
1914 * Gets the #AtspiEditableText interface for an #AtspiAccessible.
1916 * Returns: (transfer full): a pointer to an #AtspiEditableText interface
1917 * instance, or NULL if @obj does not implement #AtspiEditableText.
1919 * Deprecated: 2.10: Use atspi_accessible_get_editable_text_iface instead.
1922 atspi_accessible_get_editable_text (AtspiAccessible *accessible)
1924 return (_atspi_accessible_is_a (accessible, atspi_interface_editable_text) ?
1925 g_object_ref (ATSPI_EDITABLE_TEXT (accessible)) : NULL);
1929 * atspi_accessible_get_editable_text_iface:
1930 * @obj: a pointer to the #AtspiAccessible instance to query.
1932 * Gets the #AtspiEditableText interface for an #AtspiAccessible.
1934 * Returns: (transfer full): a pointer to an #AtspiEditableText interface
1935 * instance, or NULL if @obj does not implement #AtspiEditableText.
1938 atspi_accessible_get_editable_text_iface (AtspiAccessible *accessible)
1940 return (_atspi_accessible_is_a (accessible, atspi_interface_editable_text) ?
1941 g_object_ref (ATSPI_EDITABLE_TEXT (accessible)) : NULL);
1945 * atspi_accessible_get_hyperlink:
1946 * @obj: a pointer to the #AtspiAccessible object on which to operate.
1948 * Gets the #AtspiHyperlink interface for an #AtspiAccessible.
1950 * Returns: (transfer full): the #AtspiHyperlink object associated with
1951 * the given #AtspiAccessible, or NULL if not supported.
1954 atspi_accessible_get_hyperlink (AtspiAccessible *accessible)
1956 return (_atspi_accessible_is_a (accessible, atspi_interface_hyperlink) ?
1957 _atspi_hyperlink_new (accessible->parent.app, accessible->parent.path) : NULL);
1961 * atspi_accessible_get_hypertext: (rename-to atspi_accessible_get_hypertext_iface)
1962 * @obj: a pointer to the #AtspiAccessible instance to query.
1964 * Gets the #AtspiHypertext interface for an #AtspiAccessible.
1966 * Returns: (transfer full): a pointer to an #AtspiHypertext interface
1967 * instance, or NULL if @obj does not implement #AtspiHypertext.
1969 * Deprecated: 2.10: Use atspi_accessible_get_hypertext_iface instead.
1972 atspi_accessible_get_hypertext (AtspiAccessible *accessible)
1974 return (_atspi_accessible_is_a (accessible, atspi_interface_hypertext) ?
1975 g_object_ref (ATSPI_HYPERTEXT (accessible)) : NULL);
1979 * atspi_accessible_get_hypertext_iface:
1980 * @obj: a pointer to the #AtspiAccessible instance to query.
1982 * Gets the #AtspiHypertext interface for an #AtspiAccessible.
1984 * Returns: (transfer full): a pointer to an #AtspiHypertext interface
1985 * instance, or NULL if @obj does not implement #AtspiHypertext.
1988 atspi_accessible_get_hypertext_iface (AtspiAccessible *accessible)
1990 return (_atspi_accessible_is_a (accessible, atspi_interface_hypertext) ?
1991 g_object_ref (ATSPI_HYPERTEXT (accessible)) : NULL);
1995 * atspi_accessible_get_image: (rename-to atspi_accessible_get_image_iface)
1996 * @obj: a pointer to the #AtspiAccessible instance to query.
1998 * Gets the #AtspiImage interface for an #AtspiAccessible.
2000 * Returns: (transfer full): a pointer to an #AtspiImage interface instance, or
2001 * NULL if @obj does not implement #AtspiImage.
2003 * Deprecated: 2.10: Use atspi_accessible_get_image_iface instead.
2006 atspi_accessible_get_image (AtspiAccessible *accessible)
2008 return (_atspi_accessible_is_a (accessible, atspi_interface_image) ?
2009 g_object_ref (ATSPI_IMAGE (accessible)) : NULL);
2013 * atspi_accessible_get_image_iface:
2014 * @obj: a pointer to the #AtspiAccessible instance to query.
2016 * Gets the #AtspiImage interface for an #AtspiAccessible.
2018 * Returns: (transfer full): a pointer to an #AtspiImage interface instance, or
2019 * NULL if @obj does not implement #AtspiImage.
2022 atspi_accessible_get_image_iface (AtspiAccessible *accessible)
2024 return (_atspi_accessible_is_a (accessible, atspi_interface_image) ?
2025 g_object_ref (ATSPI_IMAGE (accessible)) : NULL);
2029 * atspi_accessible_get_selection: (rename-to atspi_accessible_get_selection_iface)
2030 * @obj: a pointer to the #AtspiAccessible instance to query.
2032 * Gets the #AtspiSelection interface for an #AtspiAccessible.
2034 * Returns: (transfer full): a pointer to an #AtspiSelection interface
2035 * instance, or NULL if @obj does not implement #AtspiSelection.
2037 * Deprecated: 2.10: Use atspi_accessible_get_selection_iface instead.
2040 atspi_accessible_get_selection (AtspiAccessible *accessible)
2042 return (_atspi_accessible_is_a (accessible, atspi_interface_selection) ?
2043 g_object_ref (ATSPI_SELECTION (accessible)) : NULL);
2047 * atspi_accessible_get_selection_iface:
2048 * @obj: a pointer to the #AtspiAccessible instance to query.
2050 * Gets the #AtspiSelection interface for an #AtspiAccessible.
2052 * Returns: (transfer full): a pointer to an #AtspiSelection interface
2053 * instance, or NULL if @obj does not implement #AtspiSelection.
2056 atspi_accessible_get_selection_iface (AtspiAccessible *accessible)
2058 return (_atspi_accessible_is_a (accessible, atspi_interface_selection) ?
2059 g_object_ref (ATSPI_SELECTION (accessible)) : NULL);
2064 * atspi_accessible_get_streamable_content:
2065 * @obj: a pointer to the #AtspiAccessible instance to query.
2067 * Gets the #AtspiStreamableContent interface for an #AtspiAccessible.
2069 * Returns: (transfer full): a pointer to an #AtspiStreamableContent interface
2070 * instance, or NULL if @obj does not implement #AtspiStreamableContent.
2072 AtspiStreamableContent *
2073 atspi_accessible_get_streamable_content (AtspiAccessible *accessible)
2075 return (_atspi_accessible_is_a (accessible, atspi_interface_streamable_content) ?
2081 * atspi_accessible_get_table: (rename-to atspi_accessible_get_table_iface)
2082 * @obj: a pointer to the #AtspiAccessible instance to query.
2084 * Gets the #AtspiTable interface for an #AtspiAccessible.
2086 * Returns: (transfer full): a pointer to an #AtspiTable interface instance, or
2087 * NULL if @obj does not implement #AtspiTable.
2089 * Deprecated: 2.10: Use atspi_accessible_get_table_iface instead.
2092 atspi_accessible_get_table (AtspiAccessible *obj)
2094 return (_atspi_accessible_is_a (obj, atspi_interface_table) ?
2095 g_object_ref (ATSPI_TABLE (obj)) : NULL);
2099 * atspi_accessible_get_table_iface:
2100 * @obj: a pointer to the #AtspiAccessible instance to query.
2102 * Gets the #AtspiTable interface for an #AtspiAccessible.
2104 * Returns: (transfer full): a pointer to an #AtspiTable interface instance, or
2105 * NULL if @obj does not implement #AtspiTable.
2108 atspi_accessible_get_table_iface (AtspiAccessible *obj)
2110 return (_atspi_accessible_is_a (obj, atspi_interface_table) ?
2111 g_object_ref (ATSPI_TABLE (obj)) : NULL);
2115 * atspi_accessible_get_table_cell:
2116 * @obj: a pointer to the #AtspiAccessible instance to query.
2118 * Gets the #AtspiTableCell interface for an #AtspiAccessible.
2120 * Returns: (transfer full): a pointer to an #AtspiTableCell interface instance,
2121 * or NULL if @obj does not implement #AtspiTable.
2124 atspi_accessible_get_table_cell (AtspiAccessible *obj)
2126 return (_atspi_accessible_is_a (obj, atspi_interface_table_cell) ?
2127 g_object_ref (ATSPI_TABLE_CELL (obj)) : NULL);
2131 * atspi_accessible_get_text: (rename-to atspi_accessible_get_text_iface)
2132 * @obj: a pointer to the #AtspiAccessible instance to query.
2134 * Gets the #AtspiTable interface for an #AtspiAccessible.
2136 * Returns: (transfer full): a pointer to an #AtspiText interface instance, or
2137 * NULL if @obj does not implement #AtspiText.
2139 * Deprecated: 2.10: Use atspi_accessible_get_text_iface instead.
2142 atspi_accessible_get_text (AtspiAccessible *obj)
2144 return (_atspi_accessible_is_a (obj, atspi_interface_text) ?
2145 g_object_ref (ATSPI_TEXT (obj)) : NULL);
2149 * atspi_accessible_get_text_iface:
2150 * @obj: a pointer to the #AtspiAccessible instance to query.
2152 * Gets the #AtspiTable interface for an #AtspiAccessible.
2154 * Returns: (transfer full): a pointer to an #AtspiText interface instance, or
2155 * NULL if @obj does not implement #AtspiText.
2158 atspi_accessible_get_text_iface (AtspiAccessible *obj)
2160 return (_atspi_accessible_is_a (obj, atspi_interface_text) ?
2161 g_object_ref (ATSPI_TEXT (obj)) : NULL);
2165 * atspi_accessible_get_value: (rename-to atspi_accessible_get_value_iface)
2166 * @obj: a pointer to the #AtspiAccessible instance to query.
2168 * Gets the #AtspiTable interface for an #AtspiAccessible.
2170 * Returns: (transfer full): a pointer to an #AtspiValue interface instance, or
2171 * NULL if @obj does not implement #AtspiValue.
2173 * Deprecated: 2.10: Use atspi_accessible_get_value_iface instead.
2176 atspi_accessible_get_value (AtspiAccessible *accessible)
2178 return (_atspi_accessible_is_a (accessible, atspi_interface_value) ?
2179 g_object_ref (ATSPI_VALUE (accessible)) : NULL);
2183 * atspi_accessible_get_value_iface:
2184 * @obj: a pointer to the #AtspiAccessible instance to query.
2186 * Gets the #AtspiTable interface for an #AtspiAccessible.
2188 * Returns: (transfer full): a pointer to an #AtspiValue interface instance, or
2189 * NULL if @obj does not implement #AtspiValue.
2192 atspi_accessible_get_value_iface (AtspiAccessible *accessible)
2194 return (_atspi_accessible_is_a (accessible, atspi_interface_value) ?
2195 g_object_ref (ATSPI_VALUE (accessible)) : NULL);
2199 append_const_val (GArray *array, const gchar *val)
2201 gchar *dup = g_strdup (val);
2204 g_array_append_val (array, dup);
2208 * atspi_accessible_get_interfaces:
2209 * @obj: The #AtspiAccessible to query.
2211 * A set of pointers to all interfaces supported by an #AtspiAccessible.
2213 * Returns: (element-type gchar*) (transfer full): A #GArray of strings
2214 * describing the interfaces supported by the object. Interfaces are
2215 * denoted in short-hand (i.e. "Component", "Text" etc.).
2218 atspi_accessible_get_interfaces (AtspiAccessible *obj)
2222 g_return_val_if_fail (obj != NULL, NULL);
2224 ret = g_array_new (TRUE, TRUE, sizeof (gchar *));
2226 append_const_val (ret, "Accessible");
2227 if (atspi_accessible_is_action (obj))
2228 append_const_val (ret, "Action");
2229 if (atspi_accessible_is_collection (obj))
2230 append_const_val (ret, "Collection");
2231 if (atspi_accessible_is_component (obj))
2232 append_const_val (ret, "Component");
2233 if (atspi_accessible_is_document (obj))
2234 append_const_val (ret, "Document");
2235 if (atspi_accessible_is_editable_text (obj))
2236 append_const_val (ret, "EditableText");
2237 if (atspi_accessible_is_hypertext (obj))
2238 append_const_val (ret, "Hypertext");
2239 if (atspi_accessible_is_hyperlink (obj))
2240 append_const_val (ret, "Hyperlink");
2241 if (atspi_accessible_is_image (obj))
2242 append_const_val (ret, "Image");
2243 if (atspi_accessible_is_selection (obj))
2244 append_const_val (ret, "Selection");
2245 if (atspi_accessible_is_table (obj))
2246 append_const_val (ret, "Table");
2247 if (atspi_accessible_is_table_cell (obj))
2248 append_const_val (ret, "TableCell");
2249 if (atspi_accessible_is_text (obj))
2250 append_const_val (ret, "Text");
2251 if (atspi_accessible_is_value (obj))
2252 append_const_val (ret, "Value");
2258 _atspi_accessible_new (AtspiApplication *app, const gchar *path)
2260 AtspiAccessible *accessible;
2262 accessible = g_object_new (ATSPI_TYPE_ACCESSIBLE, NULL);
2263 g_return_val_if_fail (accessible != NULL, NULL);
2265 accessible->parent.app = g_object_ref (app);
2266 accessible->parent.path = g_strdup (path);
2272 * atspi_accessible_set_cache_mask:
2273 * @accessible: The #AtspiAccessible to operate on. Must be the desktop or
2274 * the root of an application.
2275 * @mask: An #AtspiCache specifying a bit mask of the types of data to cache.
2277 * Sets the type of data to cache for accessibles.
2278 * If this is not set for an application or is reset to ATSPI_CACHE_UNDEFINED,
2279 * then the desktop's cache flag will be used.
2280 * If the desktop's cache flag is also undefined, then all possible data will
2282 * This function is intended to work around bugs in toolkits where the proper
2283 * events are not raised / to aid in testing for such bugs.
2286 atspi_accessible_set_cache_mask (AtspiAccessible *accessible, AtspiCache mask)
2288 g_return_if_fail (accessible != NULL);
2289 g_return_if_fail (accessible->parent.app != NULL);
2290 g_return_if_fail (atspi_accessible_is_equal (accessible, accessible->parent.app->root) || accessible->role == ATSPI_ROLE_APPLICATION);
2291 accessible->parent.app->cache = mask;
2292 enable_caching = TRUE;
2296 * atspi_accessible_clear_cache:
2297 * @obj: The #AtspiAccessible whose cache to clear.
2299 * Clears the cached information for the given accessible and all of its
2303 atspi_accessible_clear_cache (AtspiAccessible *obj)
2309 obj->cached_properties = ATSPI_CACHE_NONE;
2311 for (i = 0; i < obj->children->len; i++)
2312 atspi_accessible_clear_cache (g_ptr_array_index (obj->children, i));
2317 * atspi_accessible_get_process_id:
2318 * @accessible: The #AtspiAccessible to query.
2319 * @error: a pointer to a %NULL #GError pointer
2321 * Returns the process id associated with the given accessible. Mainly
2322 * added for debugging; it is a shortcut to explicitly querying the
2323 * accessible's app->bus_name and then calling GetConnectionUnixProcessID.
2325 * Returns: The process ID or undetermined value if @error is set.
2328 atspi_accessible_get_process_id (AtspiAccessible *accessible, GError **error)
2330 DBusMessage *message, *reply;
2331 DBusConnection *bus = _atspi_bus ();
2332 dbus_uint32_t pid = -1;
2335 if (!accessible->parent.app || !accessible->parent.app->bus_name)
2337 g_set_error_literal(error, ATSPI_ERROR, ATSPI_ERROR_IPC, "Process is defunct");
2341 message = dbus_message_new_method_call ("org.freedesktop.DBus",
2342 "/org/freedesktop/DBus",
2343 "org.freedesktop.DBus",
2344 "GetConnectionUnixProcessID");
2345 dbus_message_append_args (message, DBUS_TYPE_STRING,
2346 &accessible->parent.app->bus_name,
2348 dbus_error_init (&d_error);
2349 reply = dbus_connection_send_with_reply_and_block (bus, message, -1, &d_error);
2350 dbus_message_unref (message);
2353 if (!strcmp (dbus_message_get_signature (reply), "u"))
2354 dbus_message_get_args (reply, NULL, DBUS_TYPE_UINT32, &pid, DBUS_TYPE_INVALID);
2355 dbus_message_unref (reply);
2357 if (dbus_error_is_set (&d_error))
2359 g_set_error_literal(error, ATSPI_ERROR, ATSPI_ERROR_IPC, "Process is defunct");
2360 dbus_error_free (&d_error);
2366 _atspi_accessible_get_cache_mask (AtspiAccessible *accessible)
2370 if (!accessible->parent.app)
2371 return ATSPI_CACHE_NONE;
2373 mask = accessible->parent.app->cache;
2374 if (mask == ATSPI_CACHE_UNDEFINED &&
2375 accessible->parent.app->root &&
2376 accessible->parent.app->root->accessible_parent)
2378 AtspiAccessible *desktop = atspi_get_desktop (0);
2379 mask = desktop->parent.app->cache;
2380 g_object_unref (desktop);
2383 if (mask == ATSPI_CACHE_UNDEFINED)
2384 mask = ATSPI_CACHE_DEFAULT;
2390 _atspi_accessible_test_cache (AtspiAccessible *accessible, AtspiCache flag)
2392 AtspiCache mask = _atspi_accessible_get_cache_mask (accessible);
2393 AtspiCache result = accessible->cached_properties & mask & flag;
2394 if (accessible->states && atspi_state_set_contains (accessible->states, ATSPI_STATE_TRANSIENT))
2396 return (result != 0 && (atspi_main_loop || enable_caching ||
2397 flag == ATSPI_CACHE_INTERFACES) &&
2402 _atspi_accessible_add_cache (AtspiAccessible *accessible, AtspiCache flag)
2404 AtspiCache mask = _atspi_accessible_get_cache_mask (accessible);
2406 accessible->cached_properties |= flag & mask;
2410 * atspi_accessible_get_locale:
2411 * @accessible: an #AtspiAccessible
2413 * Gets a UTF-8 string indicating the POSIX-style LC_MESSAGES locale
2418 * Returns: a UTF-8 string indicating the POSIX-style LC_MESSAGES
2419 * locale of @accessible.
2422 atspi_accessible_get_object_locale (AtspiAccessible *accessible, GError **error)
2426 g_return_val_if_fail (accessible != NULL, NULL);
2428 locale = g_object_get_qdata (G_OBJECT (accessible), quark_locale);
2431 if (!_atspi_dbus_get_property (accessible, atspi_interface_accessible,
2432 "Locale", error, "s", &locale))
2435 g_object_set_qdata_full (G_OBJECT (accessible), quark_locale, locale,
2442 * atspi_accessible_get_accessible_id:
2443 * @obj: an #AtspiAccessible
2445 * Gets the accessible id of the accessible. This is not meant to be presented
2446 * to the user, but to be an id which is stable over application development.
2447 * Typically, this is the gtkbuilder id.
2451 * Returns: a character string representing the accessible id of the
2452 * #AtspiAccessible object or NULL on exception.
2455 atspi_accessible_get_accessible_id (AtspiAccessible *obj, GError **error)
2457 gchar *accessible_id;
2459 g_return_val_if_fail (obj != NULL, NULL);
2461 if (!_atspi_dbus_get_property (obj, atspi_interface_accessible,
2462 "AccessibleId", error, "s", &accessible_id))
2465 return accessible_id;
2469 atspi_accessible_is_equal (AtspiAccessible *obj, AtspiAccessible *other)
2471 static const char prefix[] = "/org/a11y/atspi/accessible/";
2472 static const size_t prefix_len = sizeof(prefix)/sizeof(char);
2480 * Is it possible to have 2 different objects representing
2481 * the same application? If not we should compare only pointers
2482 * (obj->parent.app and other->parent.app)
2485 /* One of them is null */
2486 if ((obj->parent.app != other->parent.app) && (!obj->parent.app || !other->parent.app))
2489 /* Both are not null */
2490 if ((obj->parent.app != other->parent.app) && g_strcmp0(obj->parent.app->bus_name, other->parent.app->bus_name))
2493 const AtspiObject *o1 = ATSPI_OBJECT (obj);
2494 const AtspiObject *o2 = ATSPI_OBJECT (other);
2496 const char *path1 = o1 ? o1->path : "";
2497 const char *path2 = o2 ? o2->path : "";
2499 if (!strncmp(path1, prefix, prefix_len))
2500 path1 += prefix_len;
2502 if (!strncmp(path2, prefix, prefix_len))
2503 path2 += prefix_len;
2505 return !g_strcmp0(path1, path2);
2509 free_value (gpointer data)
2511 GValue *value = data;
2513 g_value_unset (value);
2518 _atspi_accessible_ref_cache (AtspiAccessible *accessible)
2520 AtspiAccessiblePrivate *priv = accessible->priv;
2522 priv->cache_ref_count++;
2524 return g_hash_table_ref (priv->cache);
2525 priv->cache = g_hash_table_new_full (g_str_hash, g_str_equal, g_free,
2531 _atspi_accessible_unref_cache (AtspiAccessible *accessible)
2533 AtspiAccessiblePrivate *priv = accessible->priv;
2537 g_hash_table_unref (priv->cache);
2538 if (--priv->cache_ref_count == 0)