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.
22 #include <glib-object.h>
28 #undef FOCUS_EVENT /* <windows.h> pollutes the namespace
29 * like a six hundred pound gorilla */
33 #include "atkmarshal.h"
34 #include "atk-enum-types.h"
37 static GPtrArray *extra_roles = NULL;
41 PROP_0, /* gobject convention */
45 PROP_PARENT, /* ancestry has changed */
51 PROP_TABLE_COLUMN_DESCRIPTION,
52 PROP_TABLE_COLUMN_HEADER,
53 PROP_TABLE_ROW_DESCRIPTION,
54 PROP_TABLE_ROW_HEADER,
56 PROP_TABLE_CAPTION_OBJECT,
57 PROP_HYPERTEXT_NUM_LINKS,
58 PROP_LAST /* gobject convention */
67 ACTIVE_DESCENDANT_CHANGED,
72 typedef struct _AtkRoleItem AtkRoleItem;
80 static const AtkRoleItem role_items [] =
82 { ATK_ROLE_INVALID, N_("invalid")},
83 { ATK_ROLE_ACCEL_LABEL, N_("accelerator label")},
84 { ATK_ROLE_ALERT, N_("alert")},
85 { ATK_ROLE_ANIMATION, N_("animation")},
86 { ATK_ROLE_ARROW, N_("arrow")},
87 { ATK_ROLE_CALENDAR, N_("calendar")},
88 { ATK_ROLE_CANVAS, N_("canvas")},
89 { ATK_ROLE_CHECK_BOX, N_("check box")},
90 { ATK_ROLE_CHECK_MENU_ITEM, N_("check menu item")},
91 { ATK_ROLE_COLOR_CHOOSER, N_("color chooser")},
92 { ATK_ROLE_COLUMN_HEADER, N_("column header")},
93 { ATK_ROLE_COMBO_BOX, N_("combo box")},
94 { ATK_ROLE_DATE_EDITOR, N_("dateeditor")},
95 { ATK_ROLE_DESKTOP_ICON, N_("desktop icon")},
96 { ATK_ROLE_DESKTOP_FRAME, N_("desktop frame")},
97 { ATK_ROLE_DIAL, N_("dial")},
98 { ATK_ROLE_DIALOG, N_("dialog")},
99 { ATK_ROLE_DIRECTORY_PANE, N_("directory pane")},
100 { ATK_ROLE_DRAWING_AREA, N_("drawing area")},
101 { ATK_ROLE_FILE_CHOOSER, N_("file chooser")},
102 { ATK_ROLE_FILLER, N_("filler")},
103 /* I know it looks wrong but that is what Java returns */
104 { ATK_ROLE_FONT_CHOOSER, N_("fontchooser")},
105 { ATK_ROLE_FRAME, N_("frame")},
106 { ATK_ROLE_GLASS_PANE, N_("glass pane")},
107 { ATK_ROLE_HTML_CONTAINER, N_("html container")},
108 { ATK_ROLE_ICON, N_("icon")},
109 { ATK_ROLE_IMAGE, N_("image")},
110 { ATK_ROLE_INTERNAL_FRAME, N_("internal frame")},
111 { ATK_ROLE_LABEL, N_("label")},
112 { ATK_ROLE_LAYERED_PANE, N_("layered pane")},
113 { ATK_ROLE_LIST, N_("list")},
114 { ATK_ROLE_LIST_ITEM, N_("list item")},
115 { ATK_ROLE_MENU, N_("menu")},
116 { ATK_ROLE_MENU_BAR, N_("menu bar")},
117 { ATK_ROLE_MENU_ITEM, N_("menu item")},
118 { ATK_ROLE_OPTION_PANE, N_("option pane")},
119 { ATK_ROLE_PAGE_TAB, N_("page tab")},
120 { ATK_ROLE_PAGE_TAB_LIST, N_("page tab list")},
121 { ATK_ROLE_PANEL, N_("panel")},
122 { ATK_ROLE_PASSWORD_TEXT, N_("password text")},
123 { ATK_ROLE_POPUP_MENU, N_("popup menu")},
124 { ATK_ROLE_PROGRESS_BAR, N_("progress bar")},
125 { ATK_ROLE_PUSH_BUTTON, N_("push button")},
126 { ATK_ROLE_RADIO_BUTTON, N_("radio button")},
127 { ATK_ROLE_RADIO_MENU_ITEM, N_("radio menu item")},
128 { ATK_ROLE_ROOT_PANE, N_("root pane")},
129 { ATK_ROLE_ROW_HEADER, N_("row header")},
130 { ATK_ROLE_SCROLL_BAR, N_("scroll bar")},
131 { ATK_ROLE_SCROLL_PANE, N_("scroll pane")},
132 { ATK_ROLE_SEPARATOR, N_("separator")},
133 { ATK_ROLE_SLIDER, N_("slider")},
134 { ATK_ROLE_SPLIT_PANE, N_("split pane")},
135 { ATK_ROLE_SPIN_BUTTON, N_("spin button")},
136 { ATK_ROLE_STATUSBAR, N_("statusbar")},
137 { ATK_ROLE_TABLE, N_("table")},
138 { ATK_ROLE_TABLE_CELL, N_("table cell")},
139 { ATK_ROLE_TABLE_COLUMN_HEADER, N_("table column header")},
140 { ATK_ROLE_TABLE_ROW_HEADER, N_("table row header")},
141 { ATK_ROLE_TEAR_OFF_MENU_ITEM, N_("tear off menu item")},
142 { ATK_ROLE_TERMINAL, N_("terminal")},
143 { ATK_ROLE_TEXT, N_("text")},
144 { ATK_ROLE_TOGGLE_BUTTON, N_("toggle button")},
145 { ATK_ROLE_TOOL_BAR, N_("tool bar")},
146 { ATK_ROLE_TOOL_TIP, N_("tool tip")},
147 { ATK_ROLE_TREE, N_("tree")},
148 { ATK_ROLE_TREE_TABLE, N_("tree table")},
149 { ATK_ROLE_UNKNOWN, N_("unknown")},
150 { ATK_ROLE_VIEWPORT, N_("viewport")},
151 { ATK_ROLE_WINDOW, N_("window")},
152 { ATK_ROLE_HEADER, N_("header")},
153 { ATK_ROLE_FOOTER, N_("footer")},
154 { ATK_ROLE_PARAGRAPH, N_("paragraph")},
155 { ATK_ROLE_APPLICATION, N_("application")},
156 { ATK_ROLE_AUTOCOMPLETE, N_("autocomplete")},
157 { ATK_ROLE_EDITBAR, N_("edit bar")},
158 { ATK_ROLE_EMBEDDED, N_("embedded component")},
159 { ATK_ROLE_ENTRY, N_("entry")},
160 { ATK_ROLE_CHART, N_("chart")},
161 { ATK_ROLE_CAPTION, N_("caption")},
162 { ATK_ROLE_DOCUMENT_FRAME, N_("document frame")},
163 { ATK_ROLE_HEADING, N_("heading")},
164 { ATK_ROLE_PAGE, N_("page")},
165 { ATK_ROLE_SECTION, N_("section")},
166 { ATK_ROLE_REDUNDANT_OBJECT, N_("redundant object")}
169 static void atk_object_class_init (AtkObjectClass *klass);
170 static void atk_object_init (AtkObject *accessible,
171 AtkObjectClass *klass);
172 static AtkRelationSet* atk_object_real_ref_relation_set
173 (AtkObject *accessible);
174 static void atk_object_real_initialize (AtkObject *accessible,
176 static void atk_object_real_set_property (GObject *object,
180 static void atk_object_real_get_property (GObject *object,
184 static void atk_object_finalize (GObject *object);
185 static G_CONST_RETURN gchar*
186 atk_object_real_get_name (AtkObject *object);
187 static G_CONST_RETURN gchar*
188 atk_object_real_get_description
190 static AtkObject* atk_object_real_get_parent (AtkObject *object);
191 static AtkRole atk_object_real_get_role (AtkObject *object);
192 static AtkLayer atk_object_real_get_layer (AtkObject *object);
193 static AtkStateSet* atk_object_real_ref_state_set
195 static void atk_object_real_set_name (AtkObject *object,
197 static void atk_object_real_set_description
199 const gchar *description);
200 static void atk_object_real_set_parent (AtkObject *object,
202 static void atk_object_real_set_role (AtkObject *object,
204 static guint atk_object_real_connect_property_change_handler
206 AtkPropertyChangeHandler
208 static void atk_object_real_remove_property_change_handler
211 static void atk_object_notify (GObject *obj,
215 static guint atk_object_signals[LAST_SIGNAL] = { 0, };
217 static gpointer parent_class = NULL;
219 static const gchar* const atk_object_name_property_name = "accessible-name";
220 static const gchar* const atk_object_name_property_description = "accessible-description";
221 static const gchar* const atk_object_name_property_parent = "accessible-parent";
222 static const gchar* const atk_object_name_property_value = "accessible-value";
223 static const gchar* const atk_object_name_property_role = "accessible-role";
224 static const gchar* const atk_object_name_property_component_layer = "accessible-component-layer";
225 static const gchar* const atk_object_name_property_component_mdi_zorder = "accessible-component-mdi-zorder";
226 static const gchar* const atk_object_name_property_table_caption = "accessible-table-caption";
227 static const gchar* const atk_object_name_property_table_column_description = "accessible-table-column-description";
228 static const gchar* const atk_object_name_property_table_column_header = "accessible-table-column-header";
229 static const gchar* const atk_object_name_property_table_row_description = "accessible-table-row-description";
230 static const gchar* const atk_object_name_property_table_row_header = "accessible-table-row-header";
231 static const gchar* const atk_object_name_property_table_summary = "accessible-table-summary";
232 static const gchar* const atk_object_name_property_table_caption_object = "accessible-table-caption-object";
233 static const gchar* const atk_object_name_property_hypertext_num_links = "accessible-hypertext-nlinks";
239 #define ATK_LOCALEDIR get_atk_locale_dir()
241 G_WIN32_DLLMAIN_FOR_DLL_NAME(static, dll_name)
244 get_atk_locale_dir (void)
246 static gchar *atk_localedir = NULL;
252 temp = g_win32_get_package_installation_subdirectory
253 (GETTEXT_PACKAGE, dll_name, "lib\\locale");
254 atk_localedir = g_win32_locale_filename_from_utf8 (temp);
257 return atk_localedir;
263 gettext_initialization (void)
266 static gboolean gettext_initialized = FALSE;
268 if (!gettext_initialized)
270 const char *dir = g_getenv ("ATK_ALT_LOCALEDIR");
272 gettext_initialized = TRUE;
276 bindtextdomain (GETTEXT_PACKAGE, dir);
277 #ifdef HAVE_BIND_TEXTDOMAIN_CODESET
278 bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
285 atk_object_get_type (void)
287 static GType type = 0;
291 static const GTypeInfo typeInfo =
293 sizeof (AtkObjectClass),
294 (GBaseInitFunc) NULL,
295 (GBaseFinalizeFunc) NULL,
296 (GClassInitFunc) atk_object_class_init,
297 (GClassFinalizeFunc) NULL,
301 (GInstanceInitFunc) atk_object_init,
303 type = g_type_register_static (G_TYPE_OBJECT, "AtkObject", &typeInfo, 0) ;
309 atk_object_class_init (AtkObjectClass *klass)
311 GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
313 parent_class = g_type_class_peek_parent (klass);
315 gobject_class->set_property = atk_object_real_set_property;
316 gobject_class->get_property = atk_object_real_get_property;
317 gobject_class->finalize = atk_object_finalize;
318 gobject_class->notify = atk_object_notify;
320 klass->get_name = atk_object_real_get_name;
321 klass->get_description = atk_object_real_get_description;
322 klass->get_parent = atk_object_real_get_parent;
323 klass->get_n_children = NULL;
324 klass->ref_child = NULL;
325 klass->get_index_in_parent = NULL;
326 klass->ref_relation_set = atk_object_real_ref_relation_set;
327 klass->get_role = atk_object_real_get_role;
328 klass->get_layer = atk_object_real_get_layer;
329 klass->get_mdi_zorder = NULL;
330 klass->initialize = atk_object_real_initialize;
331 klass->ref_state_set = atk_object_real_ref_state_set;
332 klass->set_name = atk_object_real_set_name;
333 klass->set_description = atk_object_real_set_description;
334 klass->set_parent = atk_object_real_set_parent;
335 klass->set_role = atk_object_real_set_role;
336 klass->connect_property_change_handler =
337 atk_object_real_connect_property_change_handler;
338 klass->remove_property_change_handler =
339 atk_object_real_remove_property_change_handler;
342 * We do not define default signal handlers here
344 klass->children_changed = NULL;
345 klass->focus_event = NULL;
346 klass->property_change = NULL;
347 klass->visible_data_changed = NULL;
348 klass->active_descendant_changed = NULL;
350 gettext_initialization ();
352 g_object_class_install_property (gobject_class,
354 g_param_spec_string (atk_object_name_property_name,
355 _("Accessible Name"),
356 _("Object instance\'s name formatted for assistive technology access"),
359 g_object_class_install_property (gobject_class,
361 g_param_spec_string (atk_object_name_property_description,
362 _("Accessible Description"),
363 _("Description of an object, formatted for assistive technology access"),
366 g_object_class_install_property (gobject_class,
368 g_param_spec_object (atk_object_name_property_parent,
369 _("Accessible Parent"),
370 _("Is used to notify that the parent has changed"),
373 g_object_class_install_property (gobject_class,
375 g_param_spec_double (atk_object_name_property_value,
376 _("Accessible Value"),
377 _("Is used to notify that the value has changed"),
382 g_object_class_install_property (gobject_class,
384 g_param_spec_int (atk_object_name_property_role,
385 _("Accessible Role"),
386 _("The accessible role of this object"),
391 g_object_class_install_property (gobject_class,
393 g_param_spec_int (atk_object_name_property_component_layer,
394 _("Accessible Layer"),
395 _("The accessible layer of this object"),
400 g_object_class_install_property (gobject_class,
402 g_param_spec_int (atk_object_name_property_component_mdi_zorder,
403 _("Accessible MDI Value"),
404 _("The accessible MDI value of this object"),
409 g_object_class_install_property (gobject_class,
411 g_param_spec_string (atk_object_name_property_table_caption,
412 _("Accessible Table Caption"),
413 _("Is used to notify that the table caption has changed; this property should not be used. accessible-table-caption-object should be used instead"),
416 g_object_class_install_property (gobject_class,
417 PROP_TABLE_COLUMN_HEADER,
418 g_param_spec_object (atk_object_name_property_table_column_header,
419 _("Accessible Table Column Header"),
420 _("Is used to notify that the table column header has changed"),
423 g_object_class_install_property (gobject_class,
424 PROP_TABLE_COLUMN_DESCRIPTION,
425 g_param_spec_string (atk_object_name_property_table_column_description,
426 _("Accessible Table Column Description"),
427 _("Is used to notify that the table column description has changed"),
430 g_object_class_install_property (gobject_class,
431 PROP_TABLE_ROW_HEADER,
432 g_param_spec_object (atk_object_name_property_table_row_header,
433 _("Accessible Table Row Header"),
434 _("Is used to notify that the table row header has changed"),
437 g_object_class_install_property (gobject_class,
438 PROP_TABLE_ROW_DESCRIPTION,
439 g_param_spec_string (atk_object_name_property_table_row_description,
440 _("Accessible Table Row Description"),
441 _("Is used to notify that the table row description has changed"),
444 g_object_class_install_property (gobject_class,
446 g_param_spec_object (atk_object_name_property_table_summary,
447 _("Accessible Table Summary"),
448 _("Is used to notify that the table summary has changed"),
451 g_object_class_install_property (gobject_class,
452 PROP_TABLE_CAPTION_OBJECT,
453 g_param_spec_object (atk_object_name_property_table_caption_object,
454 _("Accessible Table Caption Object"),
455 _("Is used to notify that the table caption has changed"),
458 g_object_class_install_property (gobject_class,
459 PROP_HYPERTEXT_NUM_LINKS,
460 g_param_spec_int (atk_object_name_property_hypertext_num_links,
461 _("Number of Accessible Hypertext Links"),
462 _("The number of links which the current AtkHypertext has"),
467 atk_object_signals[CHILDREN_CHANGED] =
468 g_signal_new ("children_changed",
469 G_TYPE_FROM_CLASS (klass),
470 G_SIGNAL_RUN_LAST | G_SIGNAL_DETAILED,
471 G_STRUCT_OFFSET (AtkObjectClass, children_changed),
473 g_cclosure_marshal_VOID__UINT_POINTER,
475 2, G_TYPE_UINT, G_TYPE_POINTER);
476 atk_object_signals[FOCUS_EVENT] =
477 g_signal_new ("focus_event",
478 G_TYPE_FROM_CLASS (klass),
480 G_STRUCT_OFFSET (AtkObjectClass, focus_event),
482 g_cclosure_marshal_VOID__BOOLEAN,
485 atk_object_signals[PROPERTY_CHANGE] =
486 g_signal_new ("property_change",
487 G_TYPE_FROM_CLASS (klass),
488 G_SIGNAL_RUN_LAST | G_SIGNAL_DETAILED,
489 G_STRUCT_OFFSET (AtkObjectClass, property_change),
490 (GSignalAccumulator) NULL, NULL,
491 g_cclosure_marshal_VOID__POINTER,
494 atk_object_signals[STATE_CHANGE] =
495 g_signal_new ("state_change",
496 G_TYPE_FROM_CLASS (klass),
497 G_SIGNAL_RUN_LAST | G_SIGNAL_DETAILED,
498 G_STRUCT_OFFSET (AtkObjectClass, state_change),
499 (GSignalAccumulator) NULL, NULL,
500 atk_marshal_VOID__STRING_BOOLEAN,
504 atk_object_signals[VISIBLE_DATA_CHANGED] =
505 g_signal_new ("visible_data_changed",
506 G_TYPE_FROM_CLASS (klass),
508 G_STRUCT_OFFSET (AtkObjectClass, visible_data_changed),
509 (GSignalAccumulator) NULL, NULL,
510 g_cclosure_marshal_VOID__VOID,
512 atk_object_signals[ACTIVE_DESCENDANT_CHANGED] =
513 g_signal_new ("active_descendant_changed",
514 G_TYPE_FROM_CLASS (klass),
515 G_SIGNAL_RUN_LAST | G_SIGNAL_DETAILED,
516 G_STRUCT_OFFSET (AtkObjectClass, active_descendant_changed),
518 g_cclosure_marshal_VOID__POINTER,
524 atk_object_init (AtkObject *accessible,
525 AtkObjectClass *klass)
527 accessible->name = NULL;
528 accessible->description = NULL;
529 accessible->accessible_parent = NULL;
530 accessible->relation_set = atk_relation_set_new();
531 accessible->role = ATK_ROLE_UNKNOWN;
535 atk_implementor_get_type (void)
537 static GType type = 0;
541 static const GTypeInfo typeInfo =
543 sizeof (AtkImplementorIface),
544 (GBaseInitFunc) NULL,
545 (GBaseFinalizeFunc) NULL,
548 type = g_type_register_static (G_TYPE_INTERFACE, "AtkImplementorIface", &typeInfo, 0) ;
555 * atk_object_get_name:
556 * @accessible: an #AtkObject
558 * Gets the accessible name of the accessible.
560 * Returns: a character string representing the accessible name of the object.
562 G_CONST_RETURN gchar*
563 atk_object_get_name (AtkObject *accessible)
565 AtkObjectClass *klass;
567 g_return_val_if_fail (ATK_IS_OBJECT (accessible), NULL);
569 klass = ATK_OBJECT_GET_CLASS (accessible);
571 return (klass->get_name) (accessible);
577 * atk_object_get_description:
578 * @accessible: an #AtkObject
580 * Gets the accessible description of the accessible.
582 * Returns: a character string representing the accessible description
586 G_CONST_RETURN gchar*
587 atk_object_get_description (AtkObject *accessible)
589 AtkObjectClass *klass;
591 g_return_val_if_fail (ATK_IS_OBJECT (accessible), NULL);
593 klass = ATK_OBJECT_GET_CLASS (accessible);
594 if (klass->get_description)
595 return (klass->get_description) (accessible);
601 * atk_object_get_parent:
602 * @accessible: an #AtkObject
604 * Gets the accessible parent of the accessible.
606 * Returns: a #AtkObject representing the accessible parent of the accessible
609 atk_object_get_parent (AtkObject *accessible)
611 AtkObjectClass *klass;
613 g_return_val_if_fail (ATK_IS_OBJECT (accessible), NULL);
615 klass = ATK_OBJECT_GET_CLASS (accessible);
616 if (klass->get_parent)
617 return (klass->get_parent) (accessible);
623 * atk_object_get_n_accessible_children:
624 * @accessible: an #AtkObject
626 * Gets the number of accessible children of the accessible.
628 * Returns: an integer representing the number of accessible children
632 atk_object_get_n_accessible_children (AtkObject *accessible)
634 AtkObjectClass *klass;
636 g_return_val_if_fail (ATK_IS_OBJECT (accessible), 0);
638 klass = ATK_OBJECT_GET_CLASS (accessible);
639 if (klass->get_n_children)
640 return (klass->get_n_children) (accessible);
646 * atk_object_ref_accessible_child:
647 * @accessible: an #AtkObject
648 * @i: a gint representing the position of the child, starting from 0
650 * Gets a reference to the specified accessible child of the object.
651 * The accessible children are 0-based so the first accessible child is
652 * at index 0, the second at index 1 and so on.
654 * Returns: an #AtkObject representing the specified accessible child
658 atk_object_ref_accessible_child (AtkObject *accessible,
661 AtkObjectClass *klass;
663 g_return_val_if_fail (ATK_IS_OBJECT (accessible), NULL);
665 klass = ATK_OBJECT_GET_CLASS (accessible);
666 if (klass->ref_child)
667 return (klass->ref_child) (accessible, i);
673 * atk_object_ref_relation_set:
674 * @accessible: an #AtkObject
676 * Gets the #AtkRelationSet associated with the object.
678 * Returns: an #AtkRelationSet representing the relation set of the object.
681 atk_object_ref_relation_set (AtkObject *accessible)
683 AtkObjectClass *klass;
685 g_return_val_if_fail (ATK_IS_OBJECT (accessible), NULL);
687 klass = ATK_OBJECT_GET_CLASS (accessible);
688 if (klass->ref_relation_set)
689 return (klass->ref_relation_set) (accessible);
696 * @name: a character string describing the new role.
698 * Registers the role specified by @name.
700 * Returns: an #AtkRole for the new role.
703 atk_role_register (const gchar *name)
706 extra_roles = g_ptr_array_new ();
708 g_ptr_array_add (extra_roles, g_strdup (name));
709 return extra_roles->len + ATK_ROLE_LAST_DEFINED;
713 * atk_object_get_role:
714 * @accessible: an #AtkObject
716 * Gets the role of the accessible.
718 * Returns: an #AtkRole which is the role of the accessible
721 atk_object_get_role (AtkObject *accessible)
723 AtkObjectClass *klass;
725 g_return_val_if_fail (ATK_IS_OBJECT (accessible), ATK_ROLE_UNKNOWN);
727 klass = ATK_OBJECT_GET_CLASS (accessible);
729 return (klass->get_role) (accessible);
731 return ATK_ROLE_UNKNOWN;
735 * atk_object_get_layer:
736 * @accessible: an #AtkObject
738 * Gets the layer of the accessible.
740 * Returns: an #AtkLayer which is the layer of the accessible
742 * @Deprecated: Use atk_component_get_layer instead.
745 atk_object_get_layer (AtkObject *accessible)
747 AtkObjectClass *klass;
749 g_return_val_if_fail (ATK_IS_OBJECT (accessible), ATK_LAYER_INVALID);
751 klass = ATK_OBJECT_GET_CLASS (accessible);
752 if (klass->get_layer)
753 return (klass->get_layer) (accessible);
755 return ATK_LAYER_INVALID;
759 * atk_object_get_mdi_zorder:
760 * @accessible: an #AtkObject
762 * Gets the zorder of the accessible. The value G_MININT will be returned
763 * if the layer of the accessible is not ATK_LAYER_MDI.
765 * Returns: a gint which is the zorder of the accessible, i.e. the depth at
766 * which the component is shown in relation to other components in the same
769 * @Deprecated: Use atk_component_get_mdi_zorder instead.
772 atk_object_get_mdi_zorder (AtkObject *accessible)
774 AtkObjectClass *klass;
776 g_return_val_if_fail (ATK_IS_OBJECT (accessible), G_MININT);
778 klass = ATK_OBJECT_GET_CLASS (accessible);
779 if (klass->get_mdi_zorder)
780 return (klass->get_mdi_zorder) (accessible);
786 * atk_object_ref_state_set:
787 * @accessible: an #AtkObject
789 * Gets a reference to the state set of the accessible; the caller must
790 * unreference it when it is no longer needed.
792 * Returns: a reference to an #AtkStateSet which is the state
793 * set of the accessible
796 atk_object_ref_state_set (AtkObject *accessible)
798 AtkObjectClass *klass;
800 g_return_val_if_fail (ATK_IS_OBJECT (accessible), NULL);
802 klass = ATK_OBJECT_GET_CLASS (accessible);
803 if (klass->ref_state_set)
804 return (klass->ref_state_set) (accessible);
810 * atk_object_get_index_in_parent:
811 * @accessible: an #AtkObject
813 * Gets the 0-based index of this accessible in its parent; returns -1 if the
814 * accessible does not have an accessible parent.
816 * Returns: an integer which is the index of the accessible in its parent
819 atk_object_get_index_in_parent (AtkObject *accessible)
821 AtkObjectClass *klass;
823 g_return_val_if_fail (ATK_OBJECT (accessible), -1);
825 klass = ATK_OBJECT_GET_CLASS (accessible);
826 if (klass->get_index_in_parent)
827 return (klass->get_index_in_parent) (accessible);
833 * atk_object_set_name:
834 * @accessible: an #AtkObject
835 * @name: a character string to be set as the accessible name
837 * Sets the accessible name of the accessible.
840 atk_object_set_name (AtkObject *accessible,
843 AtkObjectClass *klass;
845 g_return_if_fail (ATK_IS_OBJECT (accessible));
846 g_return_if_fail (name != NULL);
848 klass = ATK_OBJECT_GET_CLASS (accessible);
851 (klass->set_name) (accessible, name);
852 g_object_notify (G_OBJECT (accessible), atk_object_name_property_name);
857 * atk_object_set_description:
858 * @accessible: an #AtkObject
859 * @description : a character string to be set as the accessible description
861 * Sets the accessible description of the accessible.
864 atk_object_set_description (AtkObject *accessible,
865 const gchar *description)
867 AtkObjectClass *klass;
869 g_return_if_fail (ATK_IS_OBJECT (accessible));
870 g_return_if_fail (description != NULL);
872 klass = ATK_OBJECT_GET_CLASS (accessible);
873 if (klass->set_description)
875 (klass->set_description) (accessible, description);
876 g_object_notify (G_OBJECT (accessible), atk_object_name_property_description);
881 * atk_object_set_parent:
882 * @accessible: an #AtkObject
883 * @parent : an #AtkObject to be set as the accessible parent
885 * Sets the accessible parent of the accessible.
888 atk_object_set_parent (AtkObject *accessible,
891 AtkObjectClass *klass;
893 g_return_if_fail (ATK_IS_OBJECT (accessible));
895 klass = ATK_OBJECT_GET_CLASS (accessible);
896 if (klass->set_parent)
898 (klass->set_parent) (accessible, parent);
899 g_object_notify (G_OBJECT (accessible), atk_object_name_property_parent);
904 * atk_object_set_role:
905 * @accessible: an #AtkObject
906 * @role : an #AtkRole to be set as the role
908 * Sets the role of the accessible.
911 atk_object_set_role (AtkObject *accessible,
914 AtkObjectClass *klass;
917 g_return_if_fail (ATK_IS_OBJECT (accessible));
919 klass = ATK_OBJECT_GET_CLASS (accessible);
922 old_role = atk_object_get_role (accessible);
923 if (old_role != role)
925 (klass->set_role) (accessible, role);
926 if (old_role != ATK_ROLE_UNKNOWN)
927 /* Do not notify for initial role setting */
928 g_object_notify (G_OBJECT (accessible), atk_object_name_property_role);
934 * atk_object_connect_property_change_handler:
935 * @accessible: an #AtkObject
936 * @handler : a function to be called when a property changes its value
938 * Specifies a function to be called when a property changes value.
940 * Returns: a #guint which is the handler id used in
941 * atk_object_remove_property_change_handler()
944 atk_object_connect_property_change_handler (AtkObject *accessible,
945 AtkPropertyChangeHandler *handler)
947 AtkObjectClass *klass;
949 g_return_val_if_fail (ATK_IS_OBJECT (accessible), 0);
950 g_return_val_if_fail ((handler != NULL), 0);
952 klass = ATK_OBJECT_GET_CLASS (accessible);
953 if (klass->connect_property_change_handler)
954 return (klass->connect_property_change_handler) (accessible, handler);
960 * atk_object_remove_property_change_handler:
961 * @accessible: an #AtkObject
962 * @handler_id : a guint which identifies the handler to be removed.
964 * Removes a property change handler.
967 atk_object_remove_property_change_handler (AtkObject *accessible,
970 AtkObjectClass *klass;
972 g_return_if_fail (ATK_IS_OBJECT (accessible));
974 klass = ATK_OBJECT_GET_CLASS (accessible);
975 if (klass->remove_property_change_handler)
976 (klass->remove_property_change_handler) (accessible, handler_id);
980 * atk_object_notify_state_change:
981 * @accessible: an #AtkObject
982 * @state: an #AtkState whose state is changed
983 * @value : a gboolean which indicates whether the state is being set on or off
985 * Emits a state-change signal for the specified state.
988 atk_object_notify_state_change (AtkObject *accessible,
992 G_CONST_RETURN gchar* name;
994 name = atk_state_type_get_name (state);
995 g_signal_emit (accessible, atk_object_signals[STATE_CHANGE],
996 g_quark_from_string (name),
1001 * atk_implementor_ref_accessible:
1002 * @implementor: The #GObject instance which should implement #AtkImplementorIface
1003 * if a non-null return value is required.
1005 * Gets a reference to an object's #AtkObject implementation, if
1006 * the object implements #AtkObjectIface
1008 * Returns: a reference to an object's #AtkObject implementation
1011 atk_implementor_ref_accessible (AtkImplementor *object)
1013 AtkImplementorIface *iface;
1014 AtkObject *accessible = NULL;
1016 g_return_val_if_fail (ATK_IS_IMPLEMENTOR (object), NULL);
1018 iface = ATK_IMPLEMENTOR_GET_IFACE (object);
1021 accessible = iface->ref_accessible (object);
1023 g_return_val_if_fail ((accessible != NULL), NULL);
1030 * Get a list of properties applied to this object as a whole, as an #AtkAttributeSet consisting of
1031 * name-value pairs. As such these attributes may be considered weakly-typed properties or annotations,
1032 * as distinct from strongly-typed object data available via other get/set methods.
1033 * Not all objects have explicit "name-value pair" #AtkAttributeSet properties.
1037 atk_object_get_attributes (AtkObject *accessible)
1039 AtkObjectClass *klass;
1041 g_return_val_if_fail (ATK_IS_OBJECT (accessible), NULL);
1043 klass = ATK_OBJECT_GET_CLASS (accessible);
1044 if (klass->get_attributes)
1045 return (klass->get_attributes) (accessible);
1051 static AtkRelationSet*
1052 atk_object_real_ref_relation_set (AtkObject *accessible)
1054 g_return_val_if_fail (accessible->relation_set, NULL);
1055 g_object_ref (accessible->relation_set);
1057 return accessible->relation_set;
1061 atk_object_real_set_property (GObject *object,
1063 const GValue *value,
1066 AtkObject *accessible;
1068 accessible = ATK_OBJECT (object);
1073 atk_object_set_name (accessible, g_value_get_string (value));
1075 case PROP_DESCRIPTION:
1076 atk_object_set_description (accessible, g_value_get_string (value));
1079 atk_object_set_role (accessible, g_value_get_int (value));
1082 atk_object_set_parent (accessible, g_value_get_object (value));
1085 if (ATK_IS_VALUE (accessible))
1086 atk_value_set_current_value (ATK_VALUE (accessible), value);
1088 case PROP_TABLE_SUMMARY:
1089 if (ATK_IS_TABLE (accessible))
1090 atk_table_set_summary (ATK_TABLE (accessible), g_value_get_object (value));
1092 case PROP_TABLE_CAPTION_OBJECT:
1093 if (ATK_IS_TABLE (accessible))
1094 atk_table_set_caption (ATK_TABLE (accessible), g_value_get_object (value));
1102 atk_object_real_get_property (GObject *object,
1107 AtkObject *accessible;
1109 accessible = ATK_OBJECT (object);
1114 g_value_set_string (value, atk_object_get_name (accessible));
1116 case PROP_DESCRIPTION:
1117 g_value_set_string (value, atk_object_get_description (accessible));
1120 g_value_set_int (value, atk_object_get_role (accessible));
1123 if (ATK_IS_COMPONENT (accessible))
1124 g_value_set_int (value, atk_component_get_layer (ATK_COMPONENT (accessible)));
1126 case PROP_MDI_ZORDER:
1127 if (ATK_IS_COMPONENT (accessible))
1128 g_value_set_int (value, atk_component_get_mdi_zorder (ATK_COMPONENT (accessible)));
1131 g_value_set_object (value, atk_object_get_parent (accessible));
1134 if (ATK_IS_VALUE (accessible))
1135 atk_value_get_current_value (ATK_VALUE (accessible), value);
1137 case PROP_TABLE_SUMMARY:
1138 if (ATK_IS_TABLE (accessible))
1139 g_value_set_object (value, atk_table_get_summary (ATK_TABLE (accessible)));
1141 case PROP_TABLE_CAPTION_OBJECT:
1142 if (ATK_IS_TABLE (accessible))
1143 g_value_set_object (value, atk_table_get_caption (ATK_TABLE (accessible)));
1145 case PROP_HYPERTEXT_NUM_LINKS:
1146 if (ATK_IS_HYPERTEXT (accessible))
1147 g_value_set_int (value, atk_hypertext_get_n_links (ATK_HYPERTEXT (accessible)));
1150 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
1156 atk_object_finalize (GObject *object)
1158 AtkObject *accessible;
1160 g_return_if_fail (ATK_IS_OBJECT (object));
1162 accessible = ATK_OBJECT (object);
1164 g_free (accessible->name);
1165 g_free (accessible->description);
1168 * Free memory allocated for relation set if it have been allocated.
1170 if (accessible->relation_set)
1171 g_object_unref (accessible->relation_set);
1173 if (accessible->accessible_parent)
1174 g_object_unref (accessible->accessible_parent);
1176 G_OBJECT_CLASS (parent_class)->finalize (object);
1179 static G_CONST_RETURN gchar*
1180 atk_object_real_get_name (AtkObject *object)
1182 return object->name;
1185 static G_CONST_RETURN gchar*
1186 atk_object_real_get_description (AtkObject *object)
1188 return object->description;
1192 atk_object_real_get_parent (AtkObject *object)
1194 return object->accessible_parent;
1198 atk_object_real_get_role (AtkObject *object)
1200 return object->role;
1204 atk_object_real_get_layer (AtkObject *object)
1206 return object->layer;
1210 atk_object_real_ref_state_set (AtkObject *accessible)
1212 AtkStateSet *state_set;
1214 AtkObject *focus_object;
1216 state_set = atk_state_set_new ();
1218 ap = atk_object_get_parent (accessible);
1220 if (ATK_IS_SELECTION (ap))
1224 atk_state_set_add_state (state_set, ATK_STATE_SELECTABLE);
1226 i = atk_object_get_index_in_parent (accessible);
1228 if (atk_selection_is_child_selected(ATK_SELECTION (ap), i))
1229 atk_state_set_add_state (state_set, ATK_STATE_SELECTED);
1231 focus_object = atk_get_focus_object ();
1232 if (focus_object == accessible)
1233 atk_state_set_add_state (state_set, ATK_STATE_FOCUSED);
1239 atk_object_real_set_name (AtkObject *object,
1242 g_free (object->name);
1243 object->name = g_strdup (name);
1247 atk_object_real_set_description (AtkObject *object,
1248 const gchar *description)
1250 g_free (object->description);
1251 object->description = g_strdup (description);
1255 atk_object_real_set_parent (AtkObject *object,
1258 if (object->accessible_parent)
1259 g_object_unref (object->accessible_parent);
1261 object->accessible_parent = parent;
1262 if (object->accessible_parent)
1263 g_object_ref (object->accessible_parent);
1267 atk_object_real_set_role (AtkObject *object,
1270 object->role = role;
1274 atk_object_real_connect_property_change_handler (AtkObject *obj,
1275 AtkPropertyChangeHandler *handler)
1277 return g_signal_connect_closure_by_id (obj,
1278 atk_object_signals[PROPERTY_CHANGE],
1281 G_CALLBACK (handler), NULL,
1282 (GClosureNotify) NULL),
1287 atk_object_real_remove_property_change_handler (AtkObject *obj,
1290 g_signal_handler_disconnect (obj, handler_id);
1294 * atk_object_initialize:
1295 * @accessible: a #AtkObject
1296 * @data: a #gpointer which identifies the object for which the AtkObject was created.
1298 * This function is called when implementing subclasses of #AtkObject.
1299 * It does initialization required for the new object. It is intended
1300 * that this function should called only in the ..._new() functions used
1301 * to create an instance of a subclass of #AtkObject
1304 atk_object_initialize (AtkObject *accessible,
1307 AtkObjectClass *klass;
1309 g_return_if_fail (ATK_IS_OBJECT (accessible));
1311 klass = ATK_OBJECT_GET_CLASS (accessible);
1312 if (klass->initialize)
1313 klass->initialize (accessible, data);
1317 * This function is a signal handler for notify signal which gets emitted
1318 * when a property changes value.
1320 * It constructs an AtkPropertyValues structure and emits a "property_changed"
1321 * signal which causes the user specified AtkPropertyChangeHandler
1325 atk_object_notify (GObject *obj,
1328 AtkPropertyValues values = { NULL, };
1330 g_value_init (&values.new_value, pspec->value_type);
1331 g_object_get_property (obj, pspec->name, &values.new_value);
1332 values.property_name = pspec->name;
1333 g_signal_emit (obj, atk_object_signals[PROPERTY_CHANGE],
1334 g_quark_from_string (pspec->name),
1336 g_value_unset (&values.new_value);
1340 * atk_role_get_name:
1341 * @role: The #AtkRole whose name is required
1343 * Gets the description string describing the #AtkRole @role.
1345 * Returns: the string describing the AtkRole
1347 G_CONST_RETURN gchar*
1348 atk_role_get_name (AtkRole role)
1353 for (i = 0; i < G_N_ELEMENTS (role_items); i++)
1355 if (role == role_items[i].role)
1356 return role_items[i].name;
1363 n -= ATK_ROLE_LAST_DEFINED + 1;
1365 if (n < extra_roles->len)
1366 name = g_ptr_array_index (extra_roles, n);
1372 * atk_role_get_localized_name:
1373 * @role: The #AtkRole whose localized name is required
1375 * Gets the localized description string describing the #AtkRole @role.
1377 * Returns: the localized string describing the AtkRole
1379 G_CONST_RETURN gchar*
1380 atk_role_get_localized_name (AtkRole role)
1382 G_CONST_RETURN gchar *name;
1385 gettext_initialization ();
1387 for (i = 0; i < G_N_ELEMENTS (role_items); i++)
1389 if (role == role_items[i].role)
1390 return dgettext (GETTEXT_PACKAGE, role_items[i].name);
1392 name = atk_role_get_name (role);
1398 * atk_role_for_name:
1399 * @name: a string which is the (non-localized) name of an ATK role.
1401 * Get the #AtkRole type corresponding to a rolew name.
1403 * Returns: the #AtkRole enumerated type corresponding to the specified
1405 * or #ATK_ROLE_INVALID if no matching role is found.
1408 atk_role_for_name (const gchar *name)
1410 AtkRole role = ATK_ROLE_INVALID;
1413 g_return_val_if_fail (name, ATK_ROLE_INVALID);
1415 for (i = 0; i < G_N_ELEMENTS (role_items); i++)
1417 if (strcmp (name, role_items[i].name) == 0)
1418 return role_items[i].role;
1423 for (i = 0; i < extra_roles->len; i++)
1425 gchar *extra_role = (gchar *)g_ptr_array_index (extra_roles, i);
1427 g_return_val_if_fail (extra_role, ATK_ROLE_INVALID);
1429 if (strcmp (name, extra_role) == 0)
1431 role = i + 1 + ATK_ROLE_LAST_DEFINED;
1441 * atk_object_add_relationship:
1442 * @object: The #AtkObject to which an AtkRelation is to be added.
1443 * @relationship: The #AtkRelationType of the relation
1444 * @target: The #AtkObject which is to be the target of the relation.
1446 * Adds a relationship of the specified type with the specified target.
1448 * Returns TRUE if the relationship is added.
1451 atk_object_add_relationship (AtkObject *object,
1452 AtkRelationType relationship,
1455 AtkObject *array[1];
1456 AtkRelation *relation;
1458 g_return_val_if_fail (ATK_IS_OBJECT (object), FALSE);
1459 g_return_val_if_fail (ATK_IS_OBJECT (target), FALSE);
1462 relation = atk_relation_new (array, 1, relationship);
1463 atk_relation_set_add (object->relation_set, relation);
1464 g_object_unref (relation);
1470 * atk_object_remove_relationship:
1471 * @object: The #AtkObject from which an AtkRelation is to be removed.
1472 * @relationship: The #AtkRelationType of the relation
1473 * @target: The #AtkObject which is the target of the relation to be removed.
1475 * Removes a relationship of the specified type with the specified target.
1477 * Returns TRUE if the relationship is removed.
1480 atk_object_remove_relationship (AtkObject *object,
1481 AtkRelationType relationship,
1484 gint n_relations, i;
1485 gboolean ret = FALSE;
1486 AtkRelation *relation;
1488 g_return_val_if_fail (ATK_IS_OBJECT (object), FALSE);
1489 g_return_val_if_fail (ATK_IS_OBJECT (target), FALSE);
1491 n_relations = atk_relation_set_get_n_relations (object->relation_set);
1492 for (i = 0; i < n_relations; i++)
1494 relation = atk_relation_set_get_relation (object->relation_set, i);
1495 if (atk_relation_get_relation_type (relation) == relationship)
1499 array = atk_relation_get_target (relation);
1501 if (g_ptr_array_index (array, 0) == target)
1503 atk_relation_set_remove (object->relation_set, relation);
1514 atk_object_real_initialize (AtkObject *accessible,