doc: Improve AtkObject::children-changed documentation
[atk.git] / atk / atkobject.c
blob320472c9ada791b261eb00c76511901648a0798f
1 /* ATK - Accessibility Toolkit
2 * Copyright 2001 Sun Microsystems Inc.
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the
16 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17 * Boston, MA 02111-1307, USA.
20 #include <string.h>
21 #include <locale.h>
23 #include <glib-object.h>
25 #ifdef G_OS_WIN32
26 #define STRICT
27 #include <windows.h>
28 #undef STRICT
29 #undef FOCUS_EVENT /* <windows.h> pollutes the namespace
30 * like a six hundred pound gorilla */
31 #endif
33 #include "atk.h"
34 #include "atkmarshal.h"
35 #include "atk-enum-types.h"
36 #include "atkintl.h"
38 /**
39 * SECTION:atkobject
40 * @Short_description: The base object class for the Accessibility Toolkit API.
41 * @Title:AtkObject
43 * This class is the primary class for accessibility support via the
44 * Accessibility ToolKit (ATK). Objects which are instances of
45 * #AtkObject (or instances of AtkObject-derived types) are queried
46 * for properties which relate basic (and generic) properties of a UI
47 * component such as name and description. Instances of #AtkObject
48 * may also be queried as to whether they implement other ATK
49 * interfaces (e.g. #AtkAction, #AtkComponent, etc.), as appropriate
50 * to the role which a given UI component plays in a user interface.
52 * All UI components in an application which provide useful
53 * information or services to the user must provide corresponding
54 * #AtkObject instances on request (in GTK+, for instance, usually on
55 * a call to #gtk_widget_get_accessible ()), either via ATK support
56 * built into the toolkit for the widget class or ancestor class, or
57 * in the case of custom widgets, if the inherited #AtkObject
58 * implementation is insufficient, via instances of a new #AtkObject
59 * subclass.
61 * See also: #AtkObjectFactory, #AtkRegistry. (GTK+ users see also
62 * #GtkAccessible).
66 static GPtrArray *role_names = NULL;
68 enum
70 PROP_0, /* gobject convention */
72 PROP_NAME,
73 PROP_DESCRIPTION,
74 PROP_PARENT, /* ancestry has changed */
75 PROP_VALUE,
76 PROP_ROLE,
77 PROP_LAYER,
78 PROP_MDI_ZORDER,
79 PROP_TABLE_CAPTION,
80 PROP_TABLE_COLUMN_DESCRIPTION,
81 PROP_TABLE_COLUMN_HEADER,
82 PROP_TABLE_ROW_DESCRIPTION,
83 PROP_TABLE_ROW_HEADER,
84 PROP_TABLE_SUMMARY,
85 PROP_TABLE_CAPTION_OBJECT,
86 PROP_HYPERTEXT_NUM_LINKS,
87 PROP_LAST /* gobject convention */
90 enum {
91 CHILDREN_CHANGED,
92 FOCUS_EVENT,
93 PROPERTY_CHANGE,
94 STATE_CHANGE,
95 VISIBLE_DATA_CHANGED,
96 ACTIVE_DESCENDANT_CHANGED,
98 LAST_SIGNAL
101 /* These are listed here for extraction by intltool */
102 #if 0
103 N_("invalid")
104 N_("accelerator label")
105 N_("alert")
106 N_("animation")
107 N_("arrow")
108 N_("calendar")
109 N_("canvas")
110 N_("check box")
111 N_("check menu item")
112 N_("color chooser")
113 N_("column header")
114 N_("combo box")
115 N_("dateeditor")
116 N_("desktop icon")
117 N_("desktop frame")
118 N_("dial")
119 N_("dialog")
120 N_("directory pane")
121 N_("drawing area")
122 N_("file chooser")
123 N_("filler")
124 /* I know it looks wrong but that is what Java returns */
125 N_("fontchooser")
126 N_("frame")
127 N_("glass pane")
128 N_("html container")
129 N_("icon")
130 N_("image")
131 N_("internal frame")
132 N_("label")
133 N_("layered pane")
134 N_("list")
135 N_("list item")
136 N_("menu")
137 N_("menu bar")
138 N_("menu item")
139 N_("option pane")
140 N_("page tab")
141 N_("page tab list")
142 N_("panel")
143 N_("password text")
144 N_("popup menu")
145 N_("progress bar")
146 N_("push button")
147 N_("radio button")
148 N_("radio menu item")
149 N_("root pane")
150 N_("row header")
151 N_("scroll bar")
152 N_("scroll pane")
153 N_("separator")
154 N_("slider")
155 N_("split pane")
156 N_("spin button")
157 N_("statusbar")
158 N_("table")
159 N_("table cell")
160 N_("table column header")
161 N_("table row header")
162 N_("tear off menu item")
163 N_("terminal")
164 N_("text")
165 N_("toggle button")
166 N_("tool bar")
167 N_("tool tip")
168 N_("tree")
169 N_("tree table")
170 N_("unknown")
171 N_("viewport")
172 N_("window")
173 N_("header")
174 N_("footer")
175 N_("paragraph")
176 N_("ruler")
177 N_("application")
178 N_("autocomplete")
179 N_("edit bar")
180 N_("embedded component")
181 N_("entry")
182 N_("chart")
183 N_("caption")
184 N_("document frame")
185 N_("heading")
186 N_("page")
187 N_("section")
188 N_("redundant object")
189 N_("form")
190 N_("link")
191 N_("input method window")
192 N_("table row")
193 N_("tree item")
194 N_("document spreadsheet")
195 N_("document presentation")
196 N_("document text")
197 N_("document web")
198 N_("document email")
199 N_("comment")
200 N_("list box")
201 N_("grouping")
202 N_("image map")
203 N_("notification")
204 N_("info bar")
205 N_("level bar")
206 N_("title bar")
207 N_("block quote")
208 #endif /* 0 */
210 static void atk_object_class_init (AtkObjectClass *klass);
211 static void atk_object_init (AtkObject *accessible,
212 AtkObjectClass *klass);
213 static AtkRelationSet* atk_object_real_ref_relation_set
214 (AtkObject *accessible);
215 static void atk_object_real_initialize (AtkObject *accessible,
216 gpointer data);
217 static void atk_object_real_set_property (GObject *object,
218 guint prop_id,
219 const GValue *value,
220 GParamSpec *pspec);
221 static void atk_object_real_get_property (GObject *object,
222 guint prop_id,
223 GValue *value,
224 GParamSpec *pspec);
225 static void atk_object_finalize (GObject *object);
226 static const gchar* atk_object_real_get_name (AtkObject *object);
227 static const gchar* atk_object_real_get_description
228 (AtkObject *object);
229 static AtkObject* atk_object_real_get_parent (AtkObject *object);
230 static AtkRole atk_object_real_get_role (AtkObject *object);
231 static AtkLayer atk_object_real_get_layer (AtkObject *object);
232 static AtkStateSet* atk_object_real_ref_state_set
233 (AtkObject *object);
234 static void atk_object_real_set_name (AtkObject *object,
235 const gchar *name);
236 static void atk_object_real_set_description
237 (AtkObject *object,
238 const gchar *description);
239 static void atk_object_real_set_parent (AtkObject *object,
240 AtkObject *parent);
241 static void atk_object_real_set_role (AtkObject *object,
242 AtkRole role);
243 static guint atk_object_real_connect_property_change_handler
244 (AtkObject *obj,
245 AtkPropertyChangeHandler
246 *handler);
247 static void atk_object_real_remove_property_change_handler
248 (AtkObject *obj,
249 guint handler_id);
250 static void atk_object_notify (GObject *obj,
251 GParamSpec *pspec);
252 static const gchar* atk_object_real_get_object_locale
253 (AtkObject *object);
255 static guint atk_object_signals[LAST_SIGNAL] = { 0, };
257 static gpointer parent_class = NULL;
259 static const gchar* const atk_object_name_property_name = "accessible-name";
260 static const gchar* const atk_object_name_property_description = "accessible-description";
261 static const gchar* const atk_object_name_property_parent = "accessible-parent";
262 static const gchar* const atk_object_name_property_value = "accessible-value";
263 static const gchar* const atk_object_name_property_role = "accessible-role";
264 static const gchar* const atk_object_name_property_component_layer = "accessible-component-layer";
265 static const gchar* const atk_object_name_property_component_mdi_zorder = "accessible-component-mdi-zorder";
266 static const gchar* const atk_object_name_property_table_caption = "accessible-table-caption";
267 static const gchar* const atk_object_name_property_table_column_description = "accessible-table-column-description";
268 static const gchar* const atk_object_name_property_table_column_header = "accessible-table-column-header";
269 static const gchar* const atk_object_name_property_table_row_description = "accessible-table-row-description";
270 static const gchar* const atk_object_name_property_table_row_header = "accessible-table-row-header";
271 static const gchar* const atk_object_name_property_table_summary = "accessible-table-summary";
272 static const gchar* const atk_object_name_property_table_caption_object = "accessible-table-caption-object";
273 static const gchar* const atk_object_name_property_hypertext_num_links = "accessible-hypertext-nlinks";
275 #ifdef G_OS_WIN32
277 static HMODULE atk_dll;
279 BOOL WINAPI
280 DllMain (HINSTANCE hinstDLL,
281 DWORD fdwReason,
282 LPVOID lpvReserved)
284 switch (fdwReason)
286 case DLL_PROCESS_ATTACH:
287 atk_dll = (HMODULE) hinstDLL;
288 break;
291 return TRUE;
294 static const char *
295 get_atk_locale_dir (void)
297 static gchar *atk_localedir = NULL;
299 if (!atk_localedir)
301 const gchar *p;
302 gchar *root, *temp;
304 /* ATK_LOCALEDIR might end in either /lib/locale or
305 * /share/locale. Scan for that slash.
307 p = ATK_LOCALEDIR + strlen (ATK_LOCALEDIR);
308 while (*--p != '/')
310 while (*--p != '/')
313 root = g_win32_get_package_installation_directory_of_module (atk_dll);
314 temp = g_build_filename (root, p, NULL);
315 g_free (root);
317 /* atk_localedir is passed to bindtextdomain() which isn't
318 * UTF-8-aware.
320 atk_localedir = g_win32_locale_filename_from_utf8 (temp);
321 g_free (temp);
323 return atk_localedir;
326 #undef ATK_LOCALEDIR
328 #define ATK_LOCALEDIR get_atk_locale_dir()
330 #endif
332 static void
333 gettext_initialization (void)
335 #ifdef ENABLE_NLS
336 static gboolean gettext_initialized = FALSE;
338 if (!gettext_initialized)
340 const char *dir = g_getenv ("ATK_ALT_LOCALEDIR");
342 gettext_initialized = TRUE;
343 if (dir == NULL)
344 dir = ATK_LOCALEDIR;
346 bindtextdomain (GETTEXT_PACKAGE, dir);
347 #ifdef HAVE_BIND_TEXTDOMAIN_CODESET
348 bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
349 #endif
351 #endif
354 static void
355 compact_role_name (gchar *role_name)
357 gchar *p = role_name;
359 while (*p)
361 if (*p == '-')
362 *p = ' ';
363 p++;
367 static void
368 initialize_role_names ()
370 GTypeClass *enum_class;
371 GEnumValue *enum_value;
372 int i;
373 gchar *role_name = NULL;
375 if (role_names)
376 return;
378 role_names = g_ptr_array_new ();
379 enum_class = g_type_class_ref (ATK_TYPE_ROLE);
380 if (!G_IS_ENUM_CLASS(enum_class))
381 return;
383 for (i = 0; i < ATK_ROLE_LAST_DEFINED; i++)
385 enum_value = g_enum_get_value (G_ENUM_CLASS (enum_class), i);
386 role_name = g_strdup (enum_value->value_nick);
387 // We want the role names to be in the format "check button" and not "check-button"
388 compact_role_name (role_name);
389 g_ptr_array_add (role_names, role_name);
392 g_type_class_unref (enum_class);
396 GType
397 atk_object_get_type (void)
399 static GType type = 0;
401 if (!type)
403 static const GTypeInfo typeInfo =
405 sizeof (AtkObjectClass),
406 (GBaseInitFunc) NULL,
407 (GBaseFinalizeFunc) NULL,
408 (GClassInitFunc) atk_object_class_init,
409 (GClassFinalizeFunc) NULL,
410 NULL,
411 sizeof (AtkObject),
413 (GInstanceInitFunc) atk_object_init,
415 type = g_type_register_static (G_TYPE_OBJECT, "AtkObject", &typeInfo, 0) ;
417 return type;
420 static void
421 atk_object_class_init (AtkObjectClass *klass)
423 GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
425 parent_class = g_type_class_peek_parent (klass);
427 gobject_class->set_property = atk_object_real_set_property;
428 gobject_class->get_property = atk_object_real_get_property;
429 gobject_class->finalize = atk_object_finalize;
430 gobject_class->notify = atk_object_notify;
432 klass->get_name = atk_object_real_get_name;
433 klass->get_description = atk_object_real_get_description;
434 klass->get_parent = atk_object_real_get_parent;
435 klass->get_n_children = NULL;
436 klass->ref_child = NULL;
437 klass->get_index_in_parent = NULL;
438 klass->ref_relation_set = atk_object_real_ref_relation_set;
439 klass->get_role = atk_object_real_get_role;
440 klass->get_layer = atk_object_real_get_layer;
441 klass->get_mdi_zorder = NULL;
442 klass->initialize = atk_object_real_initialize;
443 klass->ref_state_set = atk_object_real_ref_state_set;
444 klass->set_name = atk_object_real_set_name;
445 klass->set_description = atk_object_real_set_description;
446 klass->set_parent = atk_object_real_set_parent;
447 klass->set_role = atk_object_real_set_role;
448 klass->connect_property_change_handler =
449 atk_object_real_connect_property_change_handler;
450 klass->remove_property_change_handler =
451 atk_object_real_remove_property_change_handler;
452 klass->get_object_locale = atk_object_real_get_object_locale;
455 * We do not define default signal handlers here
457 klass->children_changed = NULL;
458 klass->focus_event = NULL;
459 klass->property_change = NULL;
460 klass->visible_data_changed = NULL;
461 klass->active_descendant_changed = NULL;
463 gettext_initialization ();
465 g_object_class_install_property (gobject_class,
466 PROP_NAME,
467 g_param_spec_string (atk_object_name_property_name,
468 _("Accessible Name"),
469 _("Object instance\'s name formatted for assistive technology access"),
470 NULL,
471 G_PARAM_READWRITE));
472 g_object_class_install_property (gobject_class,
473 PROP_DESCRIPTION,
474 g_param_spec_string (atk_object_name_property_description,
475 _("Accessible Description"),
476 _("Description of an object, formatted for assistive technology access"),
477 NULL,
478 G_PARAM_READWRITE));
479 g_object_class_install_property (gobject_class,
480 PROP_PARENT,
481 g_param_spec_object (atk_object_name_property_parent,
482 _("Accessible Parent"),
483 _("Is used to notify that the parent has changed"),
484 ATK_TYPE_OBJECT,
485 G_PARAM_READWRITE));
486 g_object_class_install_property (gobject_class,
487 PROP_VALUE,
488 g_param_spec_double (atk_object_name_property_value,
489 _("Accessible Value"),
490 _("Is used to notify that the value has changed"),
491 0.0,
492 G_MAXDOUBLE,
493 0.0,
494 G_PARAM_READWRITE));
495 g_object_class_install_property (gobject_class,
496 PROP_ROLE,
497 g_param_spec_int (atk_object_name_property_role,
498 _("Accessible Role"),
499 _("The accessible role of this object"),
501 G_MAXINT,
502 ATK_ROLE_UNKNOWN,
503 G_PARAM_READWRITE));
504 g_object_class_install_property (gobject_class,
505 PROP_LAYER,
506 g_param_spec_int (atk_object_name_property_component_layer,
507 _("Accessible Layer"),
508 _("The accessible layer of this object"),
510 G_MAXINT,
512 G_PARAM_READABLE));
513 g_object_class_install_property (gobject_class,
514 PROP_MDI_ZORDER,
515 g_param_spec_int (atk_object_name_property_component_mdi_zorder,
516 _("Accessible MDI Value"),
517 _("The accessible MDI value of this object"),
518 G_MININT,
519 G_MAXINT,
520 G_MININT,
521 G_PARAM_READABLE));
522 g_object_class_install_property (gobject_class,
523 PROP_TABLE_CAPTION,
524 g_param_spec_string (atk_object_name_property_table_caption,
525 _("Accessible Table Caption"),
526 _("Is used to notify that the table caption has changed; this property should not be used. accessible-table-caption-object should be used instead"),
527 NULL,
528 G_PARAM_READWRITE));
529 g_object_class_install_property (gobject_class,
530 PROP_TABLE_COLUMN_HEADER,
531 g_param_spec_object (atk_object_name_property_table_column_header,
532 _("Accessible Table Column Header"),
533 _("Is used to notify that the table column header has changed"),
534 ATK_TYPE_OBJECT,
535 G_PARAM_READWRITE));
536 g_object_class_install_property (gobject_class,
537 PROP_TABLE_COLUMN_DESCRIPTION,
538 g_param_spec_string (atk_object_name_property_table_column_description,
539 _("Accessible Table Column Description"),
540 _("Is used to notify that the table column description has changed"),
541 NULL,
542 G_PARAM_READWRITE));
543 g_object_class_install_property (gobject_class,
544 PROP_TABLE_ROW_HEADER,
545 g_param_spec_object (atk_object_name_property_table_row_header,
546 _("Accessible Table Row Header"),
547 _("Is used to notify that the table row header has changed"),
548 ATK_TYPE_OBJECT,
549 G_PARAM_READWRITE));
550 g_object_class_install_property (gobject_class,
551 PROP_TABLE_ROW_DESCRIPTION,
552 g_param_spec_string (atk_object_name_property_table_row_description,
553 _("Accessible Table Row Description"),
554 _("Is used to notify that the table row description has changed"),
555 NULL,
556 G_PARAM_READWRITE));
557 g_object_class_install_property (gobject_class,
558 PROP_TABLE_SUMMARY,
559 g_param_spec_object (atk_object_name_property_table_summary,
560 _("Accessible Table Summary"),
561 _("Is used to notify that the table summary has changed"),
562 ATK_TYPE_OBJECT,
563 G_PARAM_READWRITE));
564 g_object_class_install_property (gobject_class,
565 PROP_TABLE_CAPTION_OBJECT,
566 g_param_spec_object (atk_object_name_property_table_caption_object,
567 _("Accessible Table Caption Object"),
568 _("Is used to notify that the table caption has changed"),
569 ATK_TYPE_OBJECT,
570 G_PARAM_READWRITE));
571 g_object_class_install_property (gobject_class,
572 PROP_HYPERTEXT_NUM_LINKS,
573 g_param_spec_int (atk_object_name_property_hypertext_num_links,
574 _("Number of Accessible Hypertext Links"),
575 _("The number of links which the current AtkHypertext has"),
577 G_MAXINT,
579 G_PARAM_READABLE));
582 * AtkObject::children-changed:
583 * @atkobject: the object which received the signal.
584 * @arg1: The index of the added or removed child. The value can be
585 * -1. This is used if the value is not known by the implementor
586 * when the child is added/removed or irrelevant.
587 * @arg2: A gpointer to the child AtkObject which was added or
588 * removed. If the child was removed, it is possible that it is not
589 * available for the implementor. In that case this pointer can be
590 * NULL.
592 * The signal "children-changed" is emitted when a child is added or
593 * removed form an object. It supports two details: "add" and
594 * "remove"
596 atk_object_signals[CHILDREN_CHANGED] =
597 g_signal_new ("children_changed",
598 G_TYPE_FROM_CLASS (klass),
599 G_SIGNAL_RUN_LAST | G_SIGNAL_DETAILED,
600 G_STRUCT_OFFSET (AtkObjectClass, children_changed),
601 NULL, NULL,
602 g_cclosure_marshal_VOID__UINT_POINTER,
603 G_TYPE_NONE,
604 2, G_TYPE_UINT, G_TYPE_POINTER);
607 * AtkObject::focus-event:
608 * @atkobject: the object which received the signal
609 * @arg1: a boolean value which indicates whether the object gained
610 * or lost focus.
612 * The signal "focus-event" is emitted when an object gained or lost
613 * focus.
615 * Deprecated: Since 2.9.4. Use #AtkObject::state-change signal instead.
617 atk_object_signals[FOCUS_EVENT] =
618 g_signal_new ("focus_event",
619 G_TYPE_FROM_CLASS (klass),
620 G_SIGNAL_RUN_LAST,
621 G_STRUCT_OFFSET (AtkObjectClass, focus_event),
622 NULL, NULL,
623 g_cclosure_marshal_VOID__BOOLEAN,
624 G_TYPE_NONE,
625 1, G_TYPE_BOOLEAN);
627 * AtkObject::property-change:
628 * @atkobject: the object which received the signal.
629 * @arg1: The new value of the property which changed.
631 * The signal "property-change" is emitted when an object's property
632 * value changes. The detail identifies the name of the property
633 * whose value has changed.
635 atk_object_signals[PROPERTY_CHANGE] =
636 g_signal_new ("property_change",
637 G_TYPE_FROM_CLASS (klass),
638 G_SIGNAL_RUN_LAST | G_SIGNAL_DETAILED,
639 G_STRUCT_OFFSET (AtkObjectClass, property_change),
640 (GSignalAccumulator) NULL, NULL,
641 g_cclosure_marshal_VOID__POINTER,
642 G_TYPE_NONE, 1,
643 G_TYPE_POINTER);
646 * AtkObject::state-change:
647 * @atkobject: the object which received the signal.
648 * @arg1: The name of the state which has changed
649 * @arg2: A boolean which indicates whether the state has been set or unset.
651 * The "state-change" signal is emitted when an object's state
652 * changes. The detail value identifies the state type which has
653 * changed.
655 atk_object_signals[STATE_CHANGE] =
656 g_signal_new ("state_change",
657 G_TYPE_FROM_CLASS (klass),
658 G_SIGNAL_RUN_LAST | G_SIGNAL_DETAILED,
659 G_STRUCT_OFFSET (AtkObjectClass, state_change),
660 (GSignalAccumulator) NULL, NULL,
661 atk_marshal_VOID__STRING_BOOLEAN,
662 G_TYPE_NONE, 2,
663 G_TYPE_STRING,
664 G_TYPE_BOOLEAN);
667 * AtkObject::visible-data-changed:
668 * @atkobject: the object which received the signal.
670 * The "visible-data-changed" signal is emitted when the visual
671 * appearance of the object changed.
673 atk_object_signals[VISIBLE_DATA_CHANGED] =
674 g_signal_new ("visible_data_changed",
675 G_TYPE_FROM_CLASS (klass),
676 G_SIGNAL_RUN_LAST,
677 G_STRUCT_OFFSET (AtkObjectClass, visible_data_changed),
678 (GSignalAccumulator) NULL, NULL,
679 g_cclosure_marshal_VOID__VOID,
680 G_TYPE_NONE, 0);
683 * AtkObject::active-descendant-changed:
684 * @atkobject: the object which received the signal.
685 * @arg1: the newly focused object.
687 * The "active-descendant-changed" signal is emitted by an object
688 * which has the state ATK_STATE_MANAGES_DESCENDANTS when the focus
689 * object in the object changes. For instance, a table will emit the
690 * signal when the cell in the table which has focus changes.
692 atk_object_signals[ACTIVE_DESCENDANT_CHANGED] =
693 g_signal_new ("active_descendant_changed",
694 G_TYPE_FROM_CLASS (klass),
695 G_SIGNAL_RUN_LAST | G_SIGNAL_DETAILED,
696 G_STRUCT_OFFSET (AtkObjectClass, active_descendant_changed),
697 NULL, NULL,
698 g_cclosure_marshal_VOID__POINTER,
699 G_TYPE_NONE,
700 1, G_TYPE_POINTER);
703 static void
704 atk_object_init (AtkObject *accessible,
705 AtkObjectClass *klass)
707 accessible->name = NULL;
708 accessible->description = NULL;
709 accessible->accessible_parent = NULL;
710 accessible->relation_set = atk_relation_set_new();
711 accessible->role = ATK_ROLE_UNKNOWN;
714 GType
715 atk_implementor_get_type (void)
717 static GType type = 0;
719 if (!type)
721 static const GTypeInfo typeInfo =
723 sizeof (AtkImplementorIface),
724 (GBaseInitFunc) NULL,
725 (GBaseFinalizeFunc) NULL,
728 type = g_type_register_static (G_TYPE_INTERFACE, "AtkImplementorIface", &typeInfo, 0) ;
731 return type;
735 * atk_object_get_name:
736 * @accessible: an #AtkObject
738 * Gets the accessible name of the accessible.
740 * Returns: a character string representing the accessible name of the object.
742 const gchar*
743 atk_object_get_name (AtkObject *accessible)
745 AtkObjectClass *klass;
747 g_return_val_if_fail (ATK_IS_OBJECT (accessible), NULL);
749 klass = ATK_OBJECT_GET_CLASS (accessible);
750 if (klass->get_name)
751 return (klass->get_name) (accessible);
752 else
753 return NULL;
757 * atk_object_get_description:
758 * @accessible: an #AtkObject
760 * Gets the accessible description of the accessible.
762 * Returns: a character string representing the accessible description
763 * of the accessible.
766 const gchar*
767 atk_object_get_description (AtkObject *accessible)
769 AtkObjectClass *klass;
771 g_return_val_if_fail (ATK_IS_OBJECT (accessible), NULL);
773 klass = ATK_OBJECT_GET_CLASS (accessible);
774 if (klass->get_description)
775 return (klass->get_description) (accessible);
776 else
777 return NULL;
781 * atk_object_get_parent:
782 * @accessible: an #AtkObject
784 * Gets the accessible parent of the accessible.
786 * Returns: (transfer none): a #AtkObject representing the accessible parent
787 * of the accessible
789 AtkObject*
790 atk_object_get_parent (AtkObject *accessible)
792 AtkObjectClass *klass;
794 g_return_val_if_fail (ATK_IS_OBJECT (accessible), NULL);
796 klass = ATK_OBJECT_GET_CLASS (accessible);
797 if (klass->get_parent)
798 return (klass->get_parent) (accessible);
799 else
800 return NULL;
804 * atk_object_get_n_accessible_children:
805 * @accessible: an #AtkObject
807 * Gets the number of accessible children of the accessible.
809 * Returns: an integer representing the number of accessible children
810 * of the accessible.
812 gint
813 atk_object_get_n_accessible_children (AtkObject *accessible)
815 AtkObjectClass *klass;
817 g_return_val_if_fail (ATK_IS_OBJECT (accessible), 0);
819 klass = ATK_OBJECT_GET_CLASS (accessible);
820 if (klass->get_n_children)
821 return (klass->get_n_children) (accessible);
822 else
823 return 0;
827 * atk_object_ref_accessible_child:
828 * @accessible: an #AtkObject
829 * @i: a gint representing the position of the child, starting from 0
831 * Gets a reference to the specified accessible child of the object.
832 * The accessible children are 0-based so the first accessible child is
833 * at index 0, the second at index 1 and so on.
835 * Returns: (transfer full): an #AtkObject representing the specified
836 * accessible child of the accessible.
838 AtkObject*
839 atk_object_ref_accessible_child (AtkObject *accessible,
840 gint i)
842 AtkObjectClass *klass;
844 g_return_val_if_fail (ATK_IS_OBJECT (accessible), NULL);
846 klass = ATK_OBJECT_GET_CLASS (accessible);
847 if (klass->ref_child)
848 return (klass->ref_child) (accessible, i);
849 else
850 return NULL;
854 * atk_object_ref_relation_set:
855 * @accessible: an #AtkObject
857 * Gets the #AtkRelationSet associated with the object.
859 * Returns: (transfer full): an #AtkRelationSet representing the relation set
860 * of the object.
862 AtkRelationSet*
863 atk_object_ref_relation_set (AtkObject *accessible)
865 AtkObjectClass *klass;
867 g_return_val_if_fail (ATK_IS_OBJECT (accessible), NULL);
869 klass = ATK_OBJECT_GET_CLASS (accessible);
870 if (klass->ref_relation_set)
871 return (klass->ref_relation_set) (accessible);
872 else
873 return NULL;
877 * atk_role_register:
878 * @name: a character string describing the new role.
880 * Registers the role specified by @name.
882 * Returns: an #AtkRole for the new role.
884 AtkRole
885 atk_role_register (const gchar *name)
887 if (!role_names)
888 initialize_role_names ();
890 g_ptr_array_add (role_names, g_strdup (name));
891 return role_names->len - 1;
895 * atk_object_get_role:
896 * @accessible: an #AtkObject
898 * Gets the role of the accessible.
900 * Returns: an #AtkRole which is the role of the accessible
902 AtkRole
903 atk_object_get_role (AtkObject *accessible)
905 AtkObjectClass *klass;
907 g_return_val_if_fail (ATK_IS_OBJECT (accessible), ATK_ROLE_UNKNOWN);
909 klass = ATK_OBJECT_GET_CLASS (accessible);
910 if (klass->get_role)
911 return (klass->get_role) (accessible);
912 else
913 return ATK_ROLE_UNKNOWN;
917 * atk_object_get_layer:
918 * @accessible: an #AtkObject
920 * Gets the layer of the accessible.
922 * Deprecated: Use atk_component_get_layer instead.
924 * Returns: an #AtkLayer which is the layer of the accessible
926 AtkLayer
927 atk_object_get_layer (AtkObject *accessible)
929 AtkObjectClass *klass;
931 g_return_val_if_fail (ATK_IS_OBJECT (accessible), ATK_LAYER_INVALID);
933 klass = ATK_OBJECT_GET_CLASS (accessible);
934 if (klass->get_layer)
935 return (klass->get_layer) (accessible);
936 else
937 return ATK_LAYER_INVALID;
941 * atk_object_get_mdi_zorder:
942 * @accessible: an #AtkObject
944 * Gets the zorder of the accessible. The value G_MININT will be returned
945 * if the layer of the accessible is not ATK_LAYER_MDI.
947 * Deprecated: Use atk_component_get_mdi_zorder instead.
949 * Returns: a gint which is the zorder of the accessible, i.e. the depth at
950 * which the component is shown in relation to other components in the same
951 * container.
954 gint
955 atk_object_get_mdi_zorder (AtkObject *accessible)
957 AtkObjectClass *klass;
959 g_return_val_if_fail (ATK_IS_OBJECT (accessible), G_MININT);
961 klass = ATK_OBJECT_GET_CLASS (accessible);
962 if (klass->get_mdi_zorder)
963 return (klass->get_mdi_zorder) (accessible);
964 else
965 return G_MININT;
969 * atk_object_ref_state_set:
970 * @accessible: an #AtkObject
972 * Gets a reference to the state set of the accessible; the caller must
973 * unreference it when it is no longer needed.
975 * Returns: (transfer full): a reference to an #AtkStateSet which is the state
976 * set of the accessible
978 AtkStateSet*
979 atk_object_ref_state_set (AtkObject *accessible)
981 AtkObjectClass *klass;
983 g_return_val_if_fail (ATK_IS_OBJECT (accessible), NULL);
985 klass = ATK_OBJECT_GET_CLASS (accessible);
986 if (klass->ref_state_set)
987 return (klass->ref_state_set) (accessible);
988 else
989 return NULL;
993 * atk_object_get_index_in_parent:
994 * @accessible: an #AtkObject
996 * Gets the 0-based index of this accessible in its parent; returns -1 if the
997 * accessible does not have an accessible parent.
999 * Returns: an integer which is the index of the accessible in its parent
1001 gint
1002 atk_object_get_index_in_parent (AtkObject *accessible)
1004 AtkObjectClass *klass;
1006 g_return_val_if_fail (ATK_OBJECT (accessible), -1);
1008 klass = ATK_OBJECT_GET_CLASS (accessible);
1009 if (klass->get_index_in_parent)
1010 return (klass->get_index_in_parent) (accessible);
1011 else
1012 return -1;
1016 * atk_object_set_name:
1017 * @accessible: an #AtkObject
1018 * @name: a character string to be set as the accessible name
1020 * Sets the accessible name of the accessible. You can't set the name
1021 * to NULL. This is reserved for the initial value. In this aspect
1022 * NULL is similar to ATK_ROLE_UNKNOWN. If you want to set the name to
1023 * a empty value you can use "".
1025 void
1026 atk_object_set_name (AtkObject *accessible,
1027 const gchar *name)
1029 AtkObjectClass *klass;
1030 gboolean notify = FALSE;
1032 g_return_if_fail (ATK_IS_OBJECT (accessible));
1033 g_return_if_fail (name != NULL);
1035 klass = ATK_OBJECT_GET_CLASS (accessible);
1036 if (klass->set_name)
1038 /* Do not notify for initial name setting. See bug 665870 */
1039 notify = (accessible->name != NULL);
1041 (klass->set_name) (accessible, name);
1042 if (notify)
1043 g_object_notify (G_OBJECT (accessible), atk_object_name_property_name);
1048 * atk_object_set_description:
1049 * @accessible: an #AtkObject
1050 * @description: a character string to be set as the accessible description
1052 * Sets the accessible description of the accessible. You can't set
1053 * the description to NULL. This is reserved for the initial value. In
1054 * this aspect NULL is similar to ATK_ROLE_UNKNOWN. If you want to set
1055 * the name to a empty value you can use "".
1057 void
1058 atk_object_set_description (AtkObject *accessible,
1059 const gchar *description)
1061 AtkObjectClass *klass;
1062 gboolean notify = FALSE;
1064 g_return_if_fail (ATK_IS_OBJECT (accessible));
1065 g_return_if_fail (description != NULL);
1067 klass = ATK_OBJECT_GET_CLASS (accessible);
1068 if (klass->set_description)
1070 /* Do not notify for initial name setting. See bug 665870 */
1071 notify = (accessible->description != NULL);
1073 (klass->set_description) (accessible, description);
1074 if (notify)
1075 g_object_notify (G_OBJECT (accessible),
1076 atk_object_name_property_description);
1081 * atk_object_set_parent:
1082 * @accessible: an #AtkObject
1083 * @parent: an #AtkObject to be set as the accessible parent
1085 * Sets the accessible parent of the accessible.
1087 void
1088 atk_object_set_parent (AtkObject *accessible,
1089 AtkObject *parent)
1091 AtkObjectClass *klass;
1093 g_return_if_fail (ATK_IS_OBJECT (accessible));
1095 klass = ATK_OBJECT_GET_CLASS (accessible);
1096 if (klass->set_parent)
1098 (klass->set_parent) (accessible, parent);
1099 g_object_notify (G_OBJECT (accessible), atk_object_name_property_parent);
1104 * atk_object_set_role:
1105 * @accessible: an #AtkObject
1106 * @role: an #AtkRole to be set as the role
1108 * Sets the role of the accessible.
1110 void
1111 atk_object_set_role (AtkObject *accessible,
1112 AtkRole role)
1114 AtkObjectClass *klass;
1115 AtkRole old_role;
1117 g_return_if_fail (ATK_IS_OBJECT (accessible));
1119 klass = ATK_OBJECT_GET_CLASS (accessible);
1120 if (klass->set_role)
1122 old_role = atk_object_get_role (accessible);
1123 if (old_role != role)
1125 (klass->set_role) (accessible, role);
1126 if (old_role != ATK_ROLE_UNKNOWN)
1127 /* Do not notify for initial role setting */
1128 g_object_notify (G_OBJECT (accessible), atk_object_name_property_role);
1134 * atk_object_connect_property_change_handler:
1135 * @accessible: an #AtkObject
1136 * @handler: a function to be called when a property changes its value
1138 * Specifies a function to be called when a property changes value.
1140 * Returns: a #guint which is the handler id used in
1141 * atk_object_remove_property_change_handler()
1143 guint
1144 atk_object_connect_property_change_handler (AtkObject *accessible,
1145 AtkPropertyChangeHandler *handler)
1147 AtkObjectClass *klass;
1149 g_return_val_if_fail (ATK_IS_OBJECT (accessible), 0);
1150 g_return_val_if_fail ((handler != NULL), 0);
1152 klass = ATK_OBJECT_GET_CLASS (accessible);
1153 if (klass->connect_property_change_handler)
1154 return (klass->connect_property_change_handler) (accessible, handler);
1155 else
1156 return 0;
1160 * atk_object_remove_property_change_handler:
1161 * @accessible: an #AtkObject
1162 * @handler_id: a guint which identifies the handler to be removed.
1164 * Removes a property change handler.
1166 void
1167 atk_object_remove_property_change_handler (AtkObject *accessible,
1168 guint handler_id)
1170 AtkObjectClass *klass;
1172 g_return_if_fail (ATK_IS_OBJECT (accessible));
1174 klass = ATK_OBJECT_GET_CLASS (accessible);
1175 if (klass->remove_property_change_handler)
1176 (klass->remove_property_change_handler) (accessible, handler_id);
1180 * atk_object_notify_state_change:
1181 * @accessible: an #AtkObject
1182 * @state: an #AtkState whose state is changed
1183 * @value: a gboolean which indicates whether the state is being set on or off
1185 * Emits a state-change signal for the specified state.
1187 void
1188 atk_object_notify_state_change (AtkObject *accessible,
1189 AtkState state,
1190 gboolean value)
1192 const gchar* name;
1194 g_return_if_fail (ATK_IS_OBJECT (accessible));
1196 name = atk_state_type_get_name (state);
1197 g_signal_emit (accessible, atk_object_signals[STATE_CHANGE],
1198 g_quark_from_string (name),
1199 name, value, NULL);
1203 * atk_implementor_ref_accessible:
1204 * @implementor: The #GObject instance which should implement #AtkImplementorIface
1205 * if a non-null return value is required.
1207 * Gets a reference to an object's #AtkObject implementation, if
1208 * the object implements #AtkObjectIface
1210 * Returns: (transfer full): a reference to an object's #AtkObject
1211 * implementation
1213 AtkObject *
1214 atk_implementor_ref_accessible (AtkImplementor *implementor)
1216 AtkImplementorIface *iface;
1217 AtkObject *accessible = NULL;
1219 g_return_val_if_fail (ATK_IS_IMPLEMENTOR (implementor), NULL);
1221 iface = ATK_IMPLEMENTOR_GET_IFACE (implementor);
1223 if (iface != NULL)
1224 accessible = iface->ref_accessible (implementor);
1226 g_return_val_if_fail ((accessible != NULL), NULL);
1228 return accessible;
1233 * atk_object_get_attributes:
1234 * @accessible: An #AtkObject.
1236 * Get a list of properties applied to this object as a whole, as an #AtkAttributeSet consisting of
1237 * name-value pairs. As such these attributes may be considered weakly-typed properties or annotations,
1238 * as distinct from strongly-typed object data available via other get/set methods.
1239 * Not all objects have explicit "name-value pair" #AtkAttributeSet properties.
1241 * Since: 1.12
1243 * Returns: (transfer full): an #AtkAttributeSet consisting of all
1244 * explicit properties/annotations applied to the object, or an empty
1245 * set if the object has no name-value pair attributes assigned to
1246 * it. This #atkattributeset should be freed by a call to
1247 * atk_attribute_set_free().
1249 AtkAttributeSet *
1250 atk_object_get_attributes (AtkObject *accessible)
1252 AtkObjectClass *klass;
1254 g_return_val_if_fail (ATK_IS_OBJECT (accessible), NULL);
1256 klass = ATK_OBJECT_GET_CLASS (accessible);
1257 if (klass->get_attributes)
1258 return (klass->get_attributes) (accessible);
1259 else
1260 return NULL;
1264 static AtkRelationSet*
1265 atk_object_real_ref_relation_set (AtkObject *accessible)
1267 g_return_val_if_fail (accessible->relation_set, NULL);
1268 g_object_ref (accessible->relation_set);
1270 return accessible->relation_set;
1273 static void
1274 atk_object_real_set_property (GObject *object,
1275 guint prop_id,
1276 const GValue *value,
1277 GParamSpec *pspec)
1279 AtkObject *accessible;
1281 accessible = ATK_OBJECT (object);
1283 switch (prop_id)
1285 case PROP_NAME:
1286 atk_object_set_name (accessible, g_value_get_string (value));
1287 break;
1288 case PROP_DESCRIPTION:
1289 atk_object_set_description (accessible, g_value_get_string (value));
1290 break;
1291 case PROP_ROLE:
1292 atk_object_set_role (accessible, g_value_get_int (value));
1293 break;
1294 case PROP_PARENT:
1295 atk_object_set_parent (accessible, g_value_get_object (value));
1296 break;
1297 case PROP_VALUE:
1298 if (ATK_IS_VALUE (accessible))
1299 atk_value_set_current_value (ATK_VALUE (accessible), value);
1300 break;
1301 case PROP_TABLE_SUMMARY:
1302 if (ATK_IS_TABLE (accessible))
1303 atk_table_set_summary (ATK_TABLE (accessible), g_value_get_object (value));
1304 break;
1305 case PROP_TABLE_CAPTION_OBJECT:
1306 if (ATK_IS_TABLE (accessible))
1307 atk_table_set_caption (ATK_TABLE (accessible), g_value_get_object (value));
1308 break;
1309 default:
1310 break;
1314 static void
1315 atk_object_real_get_property (GObject *object,
1316 guint prop_id,
1317 GValue *value,
1318 GParamSpec *pspec)
1320 AtkObject *accessible;
1322 accessible = ATK_OBJECT (object);
1324 switch (prop_id)
1326 case PROP_NAME:
1327 g_value_set_string (value, atk_object_get_name (accessible));
1328 break;
1329 case PROP_DESCRIPTION:
1330 g_value_set_string (value, atk_object_get_description (accessible));
1331 break;
1332 case PROP_ROLE:
1333 g_value_set_int (value, atk_object_get_role (accessible));
1334 break;
1335 case PROP_LAYER:
1336 if (ATK_IS_COMPONENT (accessible))
1337 g_value_set_int (value, atk_component_get_layer (ATK_COMPONENT (accessible)));
1338 break;
1339 case PROP_MDI_ZORDER:
1340 if (ATK_IS_COMPONENT (accessible))
1341 g_value_set_int (value, atk_component_get_mdi_zorder (ATK_COMPONENT (accessible)));
1342 break;
1343 case PROP_PARENT:
1344 g_value_set_object (value, atk_object_get_parent (accessible));
1345 break;
1346 case PROP_VALUE:
1347 if (ATK_IS_VALUE (accessible))
1348 atk_value_get_current_value (ATK_VALUE (accessible), value);
1349 break;
1350 case PROP_TABLE_SUMMARY:
1351 if (ATK_IS_TABLE (accessible))
1352 g_value_set_object (value, atk_table_get_summary (ATK_TABLE (accessible)));
1353 break;
1354 case PROP_TABLE_CAPTION_OBJECT:
1355 if (ATK_IS_TABLE (accessible))
1356 g_value_set_object (value, atk_table_get_caption (ATK_TABLE (accessible)));
1357 break;
1358 case PROP_HYPERTEXT_NUM_LINKS:
1359 if (ATK_IS_HYPERTEXT (accessible))
1360 g_value_set_int (value, atk_hypertext_get_n_links (ATK_HYPERTEXT (accessible)));
1361 break;
1362 default:
1363 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
1364 break;
1368 static void
1369 atk_object_finalize (GObject *object)
1371 AtkObject *accessible;
1373 g_return_if_fail (ATK_IS_OBJECT (object));
1375 accessible = ATK_OBJECT (object);
1377 g_free (accessible->name);
1378 g_free (accessible->description);
1381 * Free memory allocated for relation set if it have been allocated.
1383 if (accessible->relation_set)
1384 g_object_unref (accessible->relation_set);
1386 if (accessible->accessible_parent)
1387 g_object_unref (accessible->accessible_parent);
1389 G_OBJECT_CLASS (parent_class)->finalize (object);
1392 static const gchar*
1393 atk_object_real_get_name (AtkObject *object)
1395 return object->name;
1398 static const gchar*
1399 atk_object_real_get_description (AtkObject *object)
1401 return object->description;
1404 static AtkObject*
1405 atk_object_real_get_parent (AtkObject *object)
1407 return object->accessible_parent;
1410 static AtkRole
1411 atk_object_real_get_role (AtkObject *object)
1413 return object->role;
1416 static AtkLayer
1417 atk_object_real_get_layer (AtkObject *object)
1419 return object->layer;
1422 static AtkStateSet*
1423 atk_object_real_ref_state_set (AtkObject *accessible)
1425 AtkStateSet *state_set;
1426 AtkObject *focus_object;
1428 state_set = atk_state_set_new ();
1430 focus_object = atk_get_focus_object ();
1431 if (focus_object == accessible)
1432 atk_state_set_add_state (state_set, ATK_STATE_FOCUSED);
1434 return state_set;
1437 static void
1438 atk_object_real_set_name (AtkObject *object,
1439 const gchar *name)
1441 g_free (object->name);
1442 object->name = g_strdup (name);
1445 static void
1446 atk_object_real_set_description (AtkObject *object,
1447 const gchar *description)
1449 g_free (object->description);
1450 object->description = g_strdup (description);
1453 static void
1454 atk_object_real_set_parent (AtkObject *object,
1455 AtkObject *parent)
1457 if (object->accessible_parent)
1458 g_object_unref (object->accessible_parent);
1460 object->accessible_parent = parent;
1461 if (object->accessible_parent)
1462 g_object_ref (object->accessible_parent);
1465 static void
1466 atk_object_real_set_role (AtkObject *object,
1467 AtkRole role)
1469 object->role = role;
1472 static guint
1473 atk_object_real_connect_property_change_handler (AtkObject *obj,
1474 AtkPropertyChangeHandler *handler)
1476 return g_signal_connect_closure_by_id (obj,
1477 atk_object_signals[PROPERTY_CHANGE],
1479 g_cclosure_new (
1480 G_CALLBACK (handler), NULL,
1481 (GClosureNotify) NULL),
1482 FALSE);
1485 static void
1486 atk_object_real_remove_property_change_handler (AtkObject *obj,
1487 guint handler_id)
1489 g_signal_handler_disconnect (obj, handler_id);
1493 * atk_object_initialize:
1494 * @accessible: a #AtkObject
1495 * @data: a #gpointer which identifies the object for which the AtkObject was created.
1497 * This function is called when implementing subclasses of #AtkObject.
1498 * It does initialization required for the new object. It is intended
1499 * that this function should called only in the ..._new() functions used
1500 * to create an instance of a subclass of #AtkObject
1502 void
1503 atk_object_initialize (AtkObject *accessible,
1504 gpointer data)
1506 AtkObjectClass *klass;
1508 g_return_if_fail (ATK_IS_OBJECT (accessible));
1510 klass = ATK_OBJECT_GET_CLASS (accessible);
1511 if (klass->initialize)
1512 klass->initialize (accessible, data);
1516 * This function is a signal handler for notify signal which gets emitted
1517 * when a property changes value.
1519 * It constructs an AtkPropertyValues structure and emits a "property_changed"
1520 * signal which causes the user specified AtkPropertyChangeHandler
1521 * to be called.
1523 static void
1524 atk_object_notify (GObject *obj,
1525 GParamSpec *pspec)
1527 AtkPropertyValues values = { NULL, };
1529 g_value_init (&values.new_value, pspec->value_type);
1530 g_object_get_property (obj, pspec->name, &values.new_value);
1531 values.property_name = pspec->name;
1532 g_signal_emit (obj, atk_object_signals[PROPERTY_CHANGE],
1533 g_quark_from_string (pspec->name),
1534 &values, NULL);
1535 g_value_unset (&values.new_value);
1539 * atk_role_get_name:
1540 * @role: The #AtkRole whose name is required
1542 * Gets the description string describing the #AtkRole @role.
1544 * Returns: the string describing the AtkRole
1546 const gchar*
1547 atk_role_get_name (AtkRole role)
1549 g_return_val_if_fail (role >= 0, NULL);
1551 if (!role_names)
1552 initialize_role_names ();
1554 if (role < role_names->len)
1555 return g_ptr_array_index (role_names, role);
1557 return NULL;
1561 * atk_role_get_localized_name:
1562 * @role: The #AtkRole whose localized name is required
1564 * Gets the localized description string describing the #AtkRole @role.
1566 * Returns: the localized string describing the AtkRole
1568 const gchar*
1569 atk_role_get_localized_name (AtkRole role)
1571 gettext_initialization ();
1573 return dgettext (GETTEXT_PACKAGE, atk_role_get_name (role));
1576 static const gchar*
1577 atk_object_real_get_object_locale (AtkObject *object)
1579 return setlocale (LC_MESSAGES, NULL);
1583 * atk_object_get_object_locale:
1584 * @accessible: an #AtkObject
1586 * Gets a UTF-8 string indicating the POSIX-style LC_MESSAGES locale
1587 * of @accessible.
1589 * Since: 2.7.90
1591 * Returns: a UTF-8 string indicating the POSIX-style LC_MESSAGES
1592 * locale of @accessible.
1594 const gchar*
1595 atk_object_get_object_locale (AtkObject *accessible)
1597 AtkObjectClass *klass;
1599 g_return_val_if_fail (ATK_IS_OBJECT (accessible), NULL);
1601 klass = ATK_OBJECT_GET_CLASS (accessible);
1602 if (klass->get_object_locale)
1603 return (klass->get_object_locale) (accessible);
1604 else
1605 return NULL;
1610 * atk_role_for_name:
1611 * @name: a string which is the (non-localized) name of an ATK role.
1613 * Get the #AtkRole type corresponding to a rolew name.
1615 * Returns: the #AtkRole enumerated type corresponding to the specified name,
1616 * or #ATK_ROLE_INVALID if no matching role is found.
1618 AtkRole
1619 atk_role_for_name (const gchar *name)
1621 AtkRole role = ATK_ROLE_INVALID;
1622 gint i;
1624 g_return_val_if_fail (name, ATK_ROLE_INVALID);
1626 if (!role_names)
1627 initialize_role_names ();
1629 for (i = 0; i < role_names->len; i++)
1631 gchar *role_name = (gchar *)g_ptr_array_index (role_names, i);
1633 g_return_val_if_fail (role_name, ATK_ROLE_INVALID);
1635 if (strcmp (name, role_name) == 0)
1637 role = i;
1638 break;
1642 return role;
1646 * atk_object_add_relationship:
1647 * @object: The #AtkObject to which an AtkRelation is to be added.
1648 * @relationship: The #AtkRelationType of the relation
1649 * @target: The #AtkObject which is to be the target of the relation.
1651 * Adds a relationship of the specified type with the specified target.
1653 * Returns: TRUE if the relationship is added.
1655 gboolean
1656 atk_object_add_relationship (AtkObject *object,
1657 AtkRelationType relationship,
1658 AtkObject *target)
1660 AtkObject *array[1];
1661 AtkRelation *relation;
1663 g_return_val_if_fail (ATK_IS_OBJECT (object), FALSE);
1664 g_return_val_if_fail (ATK_IS_OBJECT (target), FALSE);
1666 if (atk_relation_set_contains_target (object->relation_set,
1667 relationship, target))
1668 return FALSE;
1670 array[0] = target;
1671 relation = atk_relation_new (array, 1, relationship);
1672 atk_relation_set_add (object->relation_set, relation);
1673 g_object_unref (relation);
1675 return TRUE;
1679 * atk_object_remove_relationship:
1680 * @object: The #AtkObject from which an AtkRelation is to be removed.
1681 * @relationship: The #AtkRelationType of the relation
1682 * @target: The #AtkObject which is the target of the relation to be removed.
1684 * Removes a relationship of the specified type with the specified target.
1686 * Returns: TRUE if the relationship is removed.
1688 gboolean
1689 atk_object_remove_relationship (AtkObject *object,
1690 AtkRelationType relationship,
1691 AtkObject *target)
1693 gboolean ret = FALSE;
1694 AtkRelation *relation;
1695 GPtrArray *array;
1697 g_return_val_if_fail (ATK_IS_OBJECT (object), FALSE);
1698 g_return_val_if_fail (ATK_IS_OBJECT (target), FALSE);
1700 relation = atk_relation_set_get_relation_by_type (object->relation_set, relationship);
1702 if (relation)
1704 ret = atk_relation_remove_target (relation, target);
1705 array = atk_relation_get_target (relation);
1706 if (!array || array->len == 0)
1707 atk_relation_set_remove (object->relation_set, relation);
1709 return ret;
1712 static void
1713 atk_object_real_initialize (AtkObject *accessible,
1714 gpointer data)
1716 return;