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 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* atk_object_name_property_name = "accessible-name";
220 static const gchar* atk_object_name_property_description = "accessible-description";
221 static const gchar* atk_object_name_property_parent = "accessible-parent";
222 static const gchar* atk_object_name_property_value = "accessible-value";
223 static const gchar* atk_object_name_property_role = "accessible-role";
224 static const gchar* atk_object_name_property_component_layer = "accessible-component-layer";
225 static const gchar* atk_object_name_property_component_mdi_zorder = "accessible-component-mdi-zorder";
226 static const gchar* atk_object_name_property_table_caption = "accessible-table-caption";
227 static const gchar* atk_object_name_property_table_column_description = "accessible-table-column-description";
228 static const gchar* atk_object_name_property_table_column_header = "accessible-table-column-header";
229 static const gchar* atk_object_name_property_table_row_description = "accessible-table-row-description";
230 static const gchar* atk_object_name_property_table_row_header = "accessible-table-row-header";
231 static const gchar* atk_object_name_property_table_summary = "accessible-table-summary";
232 static const gchar* atk_object_name_property_table_caption_object = "accessible-table-caption-object";
233 static const gchar* 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 return g_win32_get_package_installation_subdirectory
247 (GETTEXT_PACKAGE, dll_name, "lib/locale");
253 gettext_initialization (void)
256 static gboolean gettext_initialized = FALSE;
258 if (!gettext_initialized)
260 const char *dir = g_getenv ("ATK_ALT_LOCALEDIR");
262 gettext_initialized = TRUE;
266 bindtextdomain (GETTEXT_PACKAGE, dir);
267 #ifdef HAVE_BIND_TEXTDOMAIN_CODESET
268 bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
275 atk_object_get_type (void)
277 static GType type = 0;
281 static const GTypeInfo typeInfo =
283 sizeof (AtkObjectClass),
284 (GBaseInitFunc) NULL,
285 (GBaseFinalizeFunc) NULL,
286 (GClassInitFunc) atk_object_class_init,
287 (GClassFinalizeFunc) NULL,
291 (GInstanceInitFunc) atk_object_init,
293 type = g_type_register_static (G_TYPE_OBJECT, "AtkObject", &typeInfo, 0) ;
299 atk_object_class_init (AtkObjectClass *klass)
301 GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
303 parent_class = g_type_class_peek_parent (klass);
305 gobject_class->set_property = atk_object_real_set_property;
306 gobject_class->get_property = atk_object_real_get_property;
307 gobject_class->finalize = atk_object_finalize;
308 gobject_class->notify = atk_object_notify;
310 klass->get_name = atk_object_real_get_name;
311 klass->get_description = atk_object_real_get_description;
312 klass->get_parent = atk_object_real_get_parent;
313 klass->get_n_children = NULL;
314 klass->ref_child = NULL;
315 klass->get_index_in_parent = NULL;
316 klass->ref_relation_set = atk_object_real_ref_relation_set;
317 klass->get_role = atk_object_real_get_role;
318 klass->get_layer = atk_object_real_get_layer;
319 klass->get_mdi_zorder = NULL;
320 klass->initialize = atk_object_real_initialize;
321 klass->ref_state_set = atk_object_real_ref_state_set;
322 klass->set_name = atk_object_real_set_name;
323 klass->set_description = atk_object_real_set_description;
324 klass->set_parent = atk_object_real_set_parent;
325 klass->set_role = atk_object_real_set_role;
326 klass->connect_property_change_handler =
327 atk_object_real_connect_property_change_handler;
328 klass->remove_property_change_handler =
329 atk_object_real_remove_property_change_handler;
332 * We do not define default signal handlers here
334 klass->children_changed = NULL;
335 klass->focus_event = NULL;
336 klass->property_change = NULL;
337 klass->visible_data_changed = NULL;
338 klass->active_descendant_changed = NULL;
340 gettext_initialization ();
342 g_object_class_install_property (gobject_class,
344 g_param_spec_string (atk_object_name_property_name,
345 _("Accessible Name"),
346 _("Object instance\'s name formatted for assistive technology access"),
349 g_object_class_install_property (gobject_class,
351 g_param_spec_string (atk_object_name_property_description,
352 _("Accessible Description"),
353 _("Description of an object, formatted for assistive technology access"),
356 g_object_class_install_property (gobject_class,
358 g_param_spec_object (atk_object_name_property_parent,
359 _("Accessible Parent"),
360 _("Is used to notify that the parent has changed"),
363 g_object_class_install_property (gobject_class,
365 g_param_spec_double (atk_object_name_property_value,
366 _("Accessible Value"),
367 _("Is used to notify that the value has changed"),
372 g_object_class_install_property (gobject_class,
374 g_param_spec_int (atk_object_name_property_role,
375 _("Accessible Role"),
376 _("The accessible role of this object"),
381 g_object_class_install_property (gobject_class,
383 g_param_spec_int (atk_object_name_property_component_layer,
384 _("Accessible Layer"),
385 _("The accessible layer of this object"),
390 g_object_class_install_property (gobject_class,
392 g_param_spec_int (atk_object_name_property_component_mdi_zorder,
393 _("Accessible MDI Value"),
394 _("The accessible MDI value of this object"),
399 g_object_class_install_property (gobject_class,
401 g_param_spec_string (atk_object_name_property_table_caption,
402 _("Accessible Table Caption"),
403 _("Is used to notify that the table caption has changed; this property should not be used. accessible-table-caption-object should be used instead"),
406 g_object_class_install_property (gobject_class,
407 PROP_TABLE_COLUMN_HEADER,
408 g_param_spec_object (atk_object_name_property_table_column_header,
409 _("Accessible Table Column Header"),
410 _("Is used to notify that the table column header has changed"),
413 g_object_class_install_property (gobject_class,
414 PROP_TABLE_COLUMN_DESCRIPTION,
415 g_param_spec_string (atk_object_name_property_table_column_description,
416 _("Accessible Table Column Description"),
417 _("Is used to notify that the table column description has changed"),
420 g_object_class_install_property (gobject_class,
421 PROP_TABLE_ROW_HEADER,
422 g_param_spec_object (atk_object_name_property_table_row_header,
423 _("Accessible Table Row Header"),
424 _("Is used to notify that the table row header has changed"),
427 g_object_class_install_property (gobject_class,
428 PROP_TABLE_ROW_DESCRIPTION,
429 g_param_spec_string (atk_object_name_property_table_row_description,
430 _("Accessible Table Row Description"),
431 _("Is used to notify that the table row description has changed"),
434 g_object_class_install_property (gobject_class,
436 g_param_spec_object (atk_object_name_property_table_summary,
437 _("Accessible Table Summary"),
438 _("Is used to notify that the table summary has changed"),
441 g_object_class_install_property (gobject_class,
442 PROP_TABLE_CAPTION_OBJECT,
443 g_param_spec_object (atk_object_name_property_table_caption_object,
444 _("Accessible Table Caption Object"),
445 _("Is used to notify that the table caption has changed"),
448 g_object_class_install_property (gobject_class,
449 PROP_HYPERTEXT_NUM_LINKS,
450 g_param_spec_int (atk_object_name_property_hypertext_num_links,
451 _("Number of Accessible Hypertext Links"),
452 _("The number of links which the current AtkHypertext has"),
457 atk_object_signals[CHILDREN_CHANGED] =
458 g_signal_new ("children_changed",
459 G_TYPE_FROM_CLASS (klass),
460 G_SIGNAL_RUN_LAST | G_SIGNAL_DETAILED,
461 G_STRUCT_OFFSET (AtkObjectClass, children_changed),
463 g_cclosure_marshal_VOID__UINT_POINTER,
465 2, G_TYPE_UINT, G_TYPE_POINTER);
466 atk_object_signals[FOCUS_EVENT] =
467 g_signal_new ("focus_event",
468 G_TYPE_FROM_CLASS (klass),
470 G_STRUCT_OFFSET (AtkObjectClass, focus_event),
472 g_cclosure_marshal_VOID__BOOLEAN,
475 atk_object_signals[PROPERTY_CHANGE] =
476 g_signal_new ("property_change",
477 G_TYPE_FROM_CLASS (klass),
478 G_SIGNAL_RUN_LAST | G_SIGNAL_DETAILED,
479 G_STRUCT_OFFSET (AtkObjectClass, property_change),
480 (GSignalAccumulator) NULL, NULL,
481 g_cclosure_marshal_VOID__POINTER,
484 atk_object_signals[STATE_CHANGE] =
485 g_signal_new ("state_change",
486 G_TYPE_FROM_CLASS (klass),
487 G_SIGNAL_RUN_LAST | G_SIGNAL_DETAILED,
488 G_STRUCT_OFFSET (AtkObjectClass, state_change),
489 (GSignalAccumulator) NULL, NULL,
490 atk_marshal_VOID__STRING_BOOLEAN,
494 atk_object_signals[VISIBLE_DATA_CHANGED] =
495 g_signal_new ("visible_data_changed",
496 G_TYPE_FROM_CLASS (klass),
498 G_STRUCT_OFFSET (AtkObjectClass, visible_data_changed),
499 (GSignalAccumulator) NULL, NULL,
500 g_cclosure_marshal_VOID__VOID,
502 atk_object_signals[ACTIVE_DESCENDANT_CHANGED] =
503 g_signal_new ("active_descendant_changed",
504 G_TYPE_FROM_CLASS (klass),
505 G_SIGNAL_RUN_LAST | G_SIGNAL_DETAILED,
506 G_STRUCT_OFFSET (AtkObjectClass, active_descendant_changed),
508 g_cclosure_marshal_VOID__POINTER,
514 atk_object_init (AtkObject *accessible,
515 AtkObjectClass *klass)
517 accessible->name = NULL;
518 accessible->description = NULL;
519 accessible->accessible_parent = NULL;
520 accessible->relation_set = atk_relation_set_new();
521 accessible->role = ATK_ROLE_UNKNOWN;
525 atk_implementor_get_type (void)
527 static GType type = 0;
531 static const GTypeInfo typeInfo =
533 sizeof (AtkImplementorIface),
534 (GBaseInitFunc) NULL,
535 (GBaseFinalizeFunc) NULL,
538 type = g_type_register_static (G_TYPE_INTERFACE, "AtkImplementorIface", &typeInfo, 0) ;
545 * atk_object_get_name:
546 * @accessible: an #AtkObject
548 * Gets the accessible name of the accessible.
550 * Returns: a character string representing the accessible name of the object.
552 G_CONST_RETURN gchar*
553 atk_object_get_name (AtkObject *accessible)
555 AtkObjectClass *klass;
557 g_return_val_if_fail (ATK_IS_OBJECT (accessible), NULL);
559 klass = ATK_OBJECT_GET_CLASS (accessible);
561 return (klass->get_name) (accessible);
567 * atk_object_get_description:
568 * @accessible: an #AtkObject
570 * Gets the accessible description of the accessible.
572 * Returns: a character string representing the accessible description
576 G_CONST_RETURN gchar*
577 atk_object_get_description (AtkObject *accessible)
579 AtkObjectClass *klass;
581 g_return_val_if_fail (ATK_IS_OBJECT (accessible), NULL);
583 klass = ATK_OBJECT_GET_CLASS (accessible);
584 if (klass->get_description)
585 return (klass->get_description) (accessible);
591 * atk_object_get_parent:
592 * @accessible: an #AtkObject
594 * Gets the accessible parent of the accessible.
596 * Returns: a #AtkObject representing the accessible parent of the accessible
599 atk_object_get_parent (AtkObject *accessible)
601 AtkObjectClass *klass;
603 g_return_val_if_fail (ATK_IS_OBJECT (accessible), NULL);
605 klass = ATK_OBJECT_GET_CLASS (accessible);
606 if (klass->get_parent)
607 return (klass->get_parent) (accessible);
613 * atk_object_get_n_accessible_children:
614 * @accessible: an #AtkObject
616 * Gets the number of accessible children of the accessible.
618 * Returns: an integer representing the number of accessible children
622 atk_object_get_n_accessible_children (AtkObject *accessible)
624 AtkObjectClass *klass;
626 g_return_val_if_fail (ATK_IS_OBJECT (accessible), 0);
628 klass = ATK_OBJECT_GET_CLASS (accessible);
629 if (klass->get_n_children)
630 return (klass->get_n_children) (accessible);
636 * atk_object_ref_accessible_child:
637 * @accessible: an #AtkObject
638 * @i: a gint representing the position of the child, starting from 0
640 * Gets a reference to the specified accessible child of the object.
641 * The accessible children are 0-based so the first accessible child is
642 * at index 0, the second at index 1 and so on.
644 * Returns: an #AtkObject representing the specified accessible child
648 atk_object_ref_accessible_child (AtkObject *accessible,
651 AtkObjectClass *klass;
653 g_return_val_if_fail (ATK_IS_OBJECT (accessible), NULL);
655 klass = ATK_OBJECT_GET_CLASS (accessible);
656 if (klass->ref_child)
657 return (klass->ref_child) (accessible, i);
663 * atk_object_ref_relation_set:
664 * @accessible: an #AtkObject
666 * Gets the #AtkRelationSet associated with the object.
668 * Returns: an #AtkRelationSet representing the relation set of the object.
671 atk_object_ref_relation_set (AtkObject *accessible)
673 AtkObjectClass *klass;
675 g_return_val_if_fail (ATK_IS_OBJECT (accessible), NULL);
677 klass = ATK_OBJECT_GET_CLASS (accessible);
678 if (klass->ref_relation_set)
679 return (klass->ref_relation_set) (accessible);
686 * @name: a character string describing the new role.
688 * Registers the role specified by @name.
690 * Returns: an #AtkRole for the new role.
693 atk_role_register (const gchar *name)
696 extra_roles = g_ptr_array_new ();
698 g_ptr_array_add (extra_roles, g_strdup (name));
699 return extra_roles->len + ATK_ROLE_LAST_DEFINED;
703 * atk_object_get_role:
704 * @accessible: an #AtkObject
706 * Gets the role of the accessible.
708 * Returns: an #AtkRole which is the role of the accessible
711 atk_object_get_role (AtkObject *accessible)
713 AtkObjectClass *klass;
715 g_return_val_if_fail (ATK_IS_OBJECT (accessible), ATK_ROLE_UNKNOWN);
717 klass = ATK_OBJECT_GET_CLASS (accessible);
719 return (klass->get_role) (accessible);
721 return ATK_ROLE_UNKNOWN;
725 * atk_object_get_layer:
726 * @accessible: an #AtkObject
728 * Gets the layer of the accessible.
730 * Returns: an #AtkLayer which is the layer of the accessible
732 * @Deprecated: Use atk_component_get_layer instead.
735 atk_object_get_layer (AtkObject *accessible)
737 AtkObjectClass *klass;
739 g_return_val_if_fail (ATK_IS_OBJECT (accessible), ATK_LAYER_INVALID);
741 klass = ATK_OBJECT_GET_CLASS (accessible);
742 if (klass->get_layer)
743 return (klass->get_layer) (accessible);
745 return ATK_LAYER_INVALID;
749 * atk_object_get_mdi_zorder:
750 * @accessible: an #AtkObject
752 * Gets the zorder of the accessible. The value G_MININT will be returned
753 * if the layer of the accessible is not ATK_LAYER_MDI.
755 * Returns: a gint which is the zorder of the accessible, i.e. the depth at
756 * which the component is shown in relation to other components in the same
759 * @Deprecated: Use atk_component_get_mdi_zorder instead.
762 atk_object_get_mdi_zorder (AtkObject *accessible)
764 AtkObjectClass *klass;
766 g_return_val_if_fail (ATK_IS_OBJECT (accessible), G_MININT);
768 klass = ATK_OBJECT_GET_CLASS (accessible);
769 if (klass->get_mdi_zorder)
770 return (klass->get_mdi_zorder) (accessible);
776 * atk_object_ref_state_set:
777 * @accessible: an #AtkObject
779 * Gets a reference to the state set of the accessible; the caller must
780 * unreference it when it is no longer needed.
782 * Returns: a reference to an #AtkStateSet which is the state
783 * set of the accessible
786 atk_object_ref_state_set (AtkObject *accessible)
788 AtkObjectClass *klass;
790 g_return_val_if_fail (ATK_IS_OBJECT (accessible), NULL);
792 klass = ATK_OBJECT_GET_CLASS (accessible);
793 if (klass->ref_state_set)
794 return (klass->ref_state_set) (accessible);
800 * atk_object_get_index_in_parent:
801 * @accessible: an #AtkObject
803 * Gets the 0-based index of this accessible in its parent; returns -1 if the
804 * accessible does not have an accessible parent.
806 * Returns: an integer which is the index of the accessible in its parent
809 atk_object_get_index_in_parent (AtkObject *accessible)
811 AtkObjectClass *klass;
813 g_return_val_if_fail (ATK_OBJECT (accessible), -1);
815 klass = ATK_OBJECT_GET_CLASS (accessible);
816 if (klass->get_index_in_parent)
817 return (klass->get_index_in_parent) (accessible);
823 * atk_object_set_name:
824 * @accessible: an #AtkObject
825 * @name: a character string to be set as the accessible name
827 * Sets the accessible name of the accessible.
830 atk_object_set_name (AtkObject *accessible,
833 AtkObjectClass *klass;
835 g_return_if_fail (ATK_IS_OBJECT (accessible));
836 g_return_if_fail (name != NULL);
838 klass = ATK_OBJECT_GET_CLASS (accessible);
841 (klass->set_name) (accessible, name);
842 g_object_notify (G_OBJECT (accessible), atk_object_name_property_name);
847 * atk_object_set_description:
848 * @accessible: an #AtkObject
849 * @description : a character string to be set as the accessible description
851 * Sets the accessible description of the accessible.
854 atk_object_set_description (AtkObject *accessible,
855 const gchar *description)
857 AtkObjectClass *klass;
859 g_return_if_fail (ATK_IS_OBJECT (accessible));
860 g_return_if_fail (description != NULL);
862 klass = ATK_OBJECT_GET_CLASS (accessible);
863 if (klass->set_description)
865 (klass->set_description) (accessible, description);
866 g_object_notify (G_OBJECT (accessible), atk_object_name_property_description);
871 * atk_object_set_parent:
872 * @accessible: an #AtkObject
873 * @parent : an #AtkObject to be set as the accessible parent
875 * Sets the accessible parent of the accessible.
878 atk_object_set_parent (AtkObject *accessible,
881 AtkObjectClass *klass;
883 g_return_if_fail (ATK_IS_OBJECT (accessible));
885 klass = ATK_OBJECT_GET_CLASS (accessible);
886 if (klass->set_parent)
888 (klass->set_parent) (accessible, parent);
889 g_object_notify (G_OBJECT (accessible), atk_object_name_property_parent);
894 * atk_object_set_role:
895 * @accessible: an #AtkObject
896 * @role : an #AtkRole to be set as the role
898 * Sets the role of the accessible.
901 atk_object_set_role (AtkObject *accessible,
904 AtkObjectClass *klass;
907 g_return_if_fail (ATK_IS_OBJECT (accessible));
909 klass = ATK_OBJECT_GET_CLASS (accessible);
912 old_role = atk_object_get_role (accessible);
913 if (old_role != role)
915 (klass->set_role) (accessible, role);
916 if (old_role != ATK_ROLE_UNKNOWN)
917 /* Do not notify for initial role setting */
918 g_object_notify (G_OBJECT (accessible), atk_object_name_property_role);
924 * atk_object_connect_property_change_handler:
925 * @accessible: an #AtkObject
926 * @handler : a function to be called when a property changes its value
928 * Specifies a function to be called when a property changes value.
930 * Returns: a #guint which is the handler id used in
931 * atk_object_remove_property_change_handler()
934 atk_object_connect_property_change_handler (AtkObject *accessible,
935 AtkPropertyChangeHandler *handler)
937 AtkObjectClass *klass;
939 g_return_val_if_fail (ATK_IS_OBJECT (accessible), 0);
940 g_return_val_if_fail ((handler != NULL), 0);
942 klass = ATK_OBJECT_GET_CLASS (accessible);
943 if (klass->connect_property_change_handler)
944 return (klass->connect_property_change_handler) (accessible, handler);
950 * atk_object_remove_property_change_handler:
951 * @accessible: an #AtkObject
952 * @handler_id : a guint which identifies the handler to be removed.
954 * Removes a property change handler.
957 atk_object_remove_property_change_handler (AtkObject *accessible,
960 AtkObjectClass *klass;
962 g_return_if_fail (ATK_IS_OBJECT (accessible));
964 klass = ATK_OBJECT_GET_CLASS (accessible);
965 if (klass->remove_property_change_handler)
966 (klass->remove_property_change_handler) (accessible, handler_id);
970 * atk_object_notify_state_change:
971 * @accessible: an #AtkObject
972 * @state: an #AtkState whose state is changed
973 * @value : a gboolean which indicates whether the state is being set on or off
975 * Emits a state-change signal for the specified state.
978 atk_object_notify_state_change (AtkObject *accessible,
982 G_CONST_RETURN gchar* name;
984 name = atk_state_type_get_name (state);
985 g_signal_emit (accessible, atk_object_signals[STATE_CHANGE],
986 g_quark_from_string (name),
991 * atk_implementor_ref_accessible:
992 * @implementor: The #GObject instance which should implement #AtkImplementorIface
993 * if a non-null return value is required.
995 * Gets a reference to an object's #AtkObject implementation, if
996 * the object implements #AtkObjectIface
998 * Returns: a reference to an object's #AtkObject implementation
1001 atk_implementor_ref_accessible (AtkImplementor *object)
1003 AtkImplementorIface *iface;
1004 AtkObject *accessible = NULL;
1006 g_return_val_if_fail (ATK_IS_IMPLEMENTOR (object), NULL);
1008 iface = ATK_IMPLEMENTOR_GET_IFACE (object);
1011 accessible = iface->ref_accessible (object);
1013 g_return_val_if_fail ((accessible != NULL), NULL);
1020 * Get a list of properties applied to this object as a whole, as an #AtkAttributeSet consisting of
1021 * name-value pairs. As such these attributes may be considered weakly-typed properties or annotations,
1022 * as distinct from strongly-typed object data available via other get/set methods.
1023 * Not all objects have explicit "name-value pair" #AtkAttributeSet properties.
1027 atk_object_get_attributes (AtkObject *accessible)
1029 AtkObjectClass *klass;
1031 g_return_val_if_fail (ATK_IS_OBJECT (accessible), NULL);
1033 klass = ATK_OBJECT_GET_CLASS (accessible);
1034 if (klass->get_attributes)
1035 return (klass->get_attributes) (accessible);
1041 static AtkRelationSet*
1042 atk_object_real_ref_relation_set (AtkObject *accessible)
1044 g_return_val_if_fail (accessible->relation_set, NULL);
1045 g_object_ref (accessible->relation_set);
1047 return accessible->relation_set;
1051 atk_object_real_set_property (GObject *object,
1053 const GValue *value,
1056 AtkObject *accessible;
1058 accessible = ATK_OBJECT (object);
1063 atk_object_set_name (accessible, g_value_get_string (value));
1065 case PROP_DESCRIPTION:
1066 atk_object_set_description (accessible, g_value_get_string (value));
1069 atk_object_set_role (accessible, g_value_get_int (value));
1072 atk_object_set_parent (accessible, g_value_get_object (value));
1075 if (ATK_IS_VALUE (accessible))
1076 atk_value_set_current_value (ATK_VALUE (accessible), value);
1078 case PROP_TABLE_SUMMARY:
1079 if (ATK_IS_TABLE (accessible))
1080 atk_table_set_summary (ATK_TABLE (accessible), g_value_get_object (value));
1082 case PROP_TABLE_CAPTION_OBJECT:
1083 if (ATK_IS_TABLE (accessible))
1084 atk_table_set_caption (ATK_TABLE (accessible), g_value_get_object (value));
1092 atk_object_real_get_property (GObject *object,
1097 AtkObject *accessible;
1099 accessible = ATK_OBJECT (object);
1104 g_value_set_string (value, atk_object_get_name (accessible));
1106 case PROP_DESCRIPTION:
1107 g_value_set_string (value, atk_object_get_description (accessible));
1110 g_value_set_int (value, atk_object_get_role (accessible));
1113 if (ATK_IS_COMPONENT (accessible))
1114 g_value_set_int (value, atk_component_get_layer (ATK_COMPONENT (accessible)));
1116 case PROP_MDI_ZORDER:
1117 if (ATK_IS_COMPONENT (accessible))
1118 g_value_set_int (value, atk_component_get_mdi_zorder (ATK_COMPONENT (accessible)));
1121 g_value_set_object (value, atk_object_get_parent (accessible));
1124 if (ATK_IS_VALUE (accessible))
1125 atk_value_get_current_value (ATK_VALUE (accessible), value);
1127 case PROP_TABLE_SUMMARY:
1128 if (ATK_IS_TABLE (accessible))
1129 g_value_set_object (value, atk_table_get_summary (ATK_TABLE (accessible)));
1131 case PROP_TABLE_CAPTION_OBJECT:
1132 if (ATK_IS_TABLE (accessible))
1133 g_value_set_object (value, atk_table_get_caption (ATK_TABLE (accessible)));
1135 case PROP_HYPERTEXT_NUM_LINKS:
1136 if (ATK_IS_HYPERTEXT (accessible))
1137 g_value_set_int (value, atk_hypertext_get_n_links (ATK_HYPERTEXT (accessible)));
1140 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
1146 atk_object_finalize (GObject *object)
1148 AtkObject *accessible;
1150 g_return_if_fail (ATK_IS_OBJECT (object));
1152 accessible = ATK_OBJECT (object);
1154 g_free (accessible->name);
1155 g_free (accessible->description);
1158 * Free memory allocated for relation set if it have been allocated.
1160 if (accessible->relation_set)
1161 g_object_unref (accessible->relation_set);
1163 if (accessible->accessible_parent)
1164 g_object_unref (accessible->accessible_parent);
1166 G_OBJECT_CLASS (parent_class)->finalize (object);
1169 static G_CONST_RETURN gchar*
1170 atk_object_real_get_name (AtkObject *object)
1172 return object->name;
1175 static G_CONST_RETURN gchar*
1176 atk_object_real_get_description (AtkObject *object)
1178 return object->description;
1182 atk_object_real_get_parent (AtkObject *object)
1184 return object->accessible_parent;
1188 atk_object_real_get_role (AtkObject *object)
1190 return object->role;
1194 atk_object_real_get_layer (AtkObject *object)
1196 return object->layer;
1200 atk_object_real_ref_state_set (AtkObject *accessible)
1202 AtkStateSet *state_set;
1204 AtkObject *focus_object;
1206 state_set = atk_state_set_new ();
1208 ap = atk_object_get_parent (accessible);
1210 if (ATK_IS_SELECTION (ap))
1214 atk_state_set_add_state (state_set, ATK_STATE_SELECTABLE);
1216 i = atk_object_get_index_in_parent (accessible);
1218 if (atk_selection_is_child_selected(ATK_SELECTION (ap), i))
1219 atk_state_set_add_state (state_set, ATK_STATE_SELECTED);
1221 focus_object = atk_get_focus_object ();
1222 if (focus_object == accessible)
1223 atk_state_set_add_state (state_set, ATK_STATE_FOCUSED);
1229 atk_object_real_set_name (AtkObject *object,
1232 g_free (object->name);
1233 object->name = g_strdup (name);
1237 atk_object_real_set_description (AtkObject *object,
1238 const gchar *description)
1240 g_free (object->description);
1241 object->description = g_strdup (description);
1245 atk_object_real_set_parent (AtkObject *object,
1248 if (object->accessible_parent)
1249 g_object_unref (object->accessible_parent);
1251 object->accessible_parent = parent;
1252 if (object->accessible_parent)
1253 g_object_ref (object->accessible_parent);
1257 atk_object_real_set_role (AtkObject *object,
1260 object->role = role;
1264 atk_object_real_connect_property_change_handler (AtkObject *obj,
1265 AtkPropertyChangeHandler *handler)
1267 return g_signal_connect_closure_by_id (obj,
1268 atk_object_signals[PROPERTY_CHANGE],
1271 G_CALLBACK (handler), NULL,
1272 (GClosureNotify) NULL),
1277 atk_object_real_remove_property_change_handler (AtkObject *obj,
1280 g_signal_handler_disconnect (obj, handler_id);
1284 * atk_object_initialize:
1285 * @accessible: a #AtkObject
1286 * @data: a #gpointer which identifies the object for which the AtkObject was created.
1288 * This function is called when implementing subclasses of #AtkObject.
1289 * It does initialization required for the new object. It is intended
1290 * that this function should called only in the ..._new() functions used
1291 * to create an instance of a subclass of #AtkObject
1294 atk_object_initialize (AtkObject *accessible,
1297 AtkObjectClass *klass;
1299 g_return_if_fail (ATK_IS_OBJECT (accessible));
1301 klass = ATK_OBJECT_GET_CLASS (accessible);
1302 if (klass->initialize)
1303 klass->initialize (accessible, data);
1307 * This function is a signal handler for notify signal which gets emitted
1308 * when a property changes value.
1310 * It constructs an AtkPropertyValues structure and emits a "property_changed"
1311 * signal which causes the user specified AtkPropertyChangeHandler
1315 atk_object_notify (GObject *obj,
1318 AtkPropertyValues values = { NULL, };
1320 g_value_init (&values.new_value, pspec->value_type);
1321 g_object_get_property (obj, pspec->name, &values.new_value);
1322 values.property_name = pspec->name;
1323 g_signal_emit (obj, atk_object_signals[PROPERTY_CHANGE],
1324 g_quark_from_string (pspec->name),
1326 g_value_unset (&values.new_value);
1330 * atk_role_get_name:
1331 * @role: The #AtkRole whose name is required
1333 * Gets the description string describing the #AtkRole @role.
1335 * Returns: the string describing the AtkRole
1337 G_CONST_RETURN gchar*
1338 atk_role_get_name (AtkRole role)
1343 for (i = 0; i < G_N_ELEMENTS (role_items); i++)
1345 if (role == role_items[i].role)
1346 return role_items[i].name;
1353 n -= ATK_ROLE_LAST_DEFINED + 1;
1355 if (n < extra_roles->len)
1356 name = g_ptr_array_index (extra_roles, n);
1362 * atk_role_get_localized_name:
1363 * @role: The #AtkRole whose localized name is required
1365 * Gets the localized description string describing the #AtkRole @role.
1367 * Returns: the localized string describing the AtkRole
1369 G_CONST_RETURN gchar*
1370 atk_role_get_localized_name (AtkRole role)
1372 G_CONST_RETURN gchar *name;
1375 gettext_initialization ();
1377 for (i = 0; i < G_N_ELEMENTS (role_items); i++)
1379 if (role == role_items[i].role)
1380 return dgettext (GETTEXT_PACKAGE, role_items[i].name);
1382 name = atk_role_get_name (role);
1388 * atk_role_for_name:
1389 * @name: a string which is the (non-localized) name of an ATK role.
1391 * Get the #AtkRole type corresponding to a rolew name.
1393 * Returns: the #AtkRole enumerated type corresponding to the specified
1395 * or #ATK_ROLE_INVALID if no matching role is found.
1398 atk_role_for_name (const gchar *name)
1400 AtkRole role = ATK_ROLE_INVALID;
1403 g_return_val_if_fail (name, ATK_ROLE_INVALID);
1405 for (i = 0; i < G_N_ELEMENTS (role_items); i++)
1407 if (strcmp (name, role_items[i].name) == 0)
1408 return role_items[i].role;
1413 for (i = 0; i < extra_roles->len; i++)
1415 gchar *extra_role = (gchar *)g_ptr_array_index (extra_roles, i);
1417 g_return_val_if_fail (extra_role, ATK_ROLE_INVALID);
1419 if (strcmp (name, extra_role) == 0)
1421 role = i + 1 + ATK_ROLE_LAST_DEFINED;
1431 * atk_object_add_relationship:
1432 * @object: The #AtkObject to which an AtkRelation is to be added.
1433 * @relationship: The #AtkRelationType of the relation
1434 * @target: The #AtkObject which is to be the target of the relation.
1436 * Adds a relationship of the specified type with the specified target.
1438 * Returns TRUE if the relationship is added.
1441 atk_object_add_relationship (AtkObject *object,
1442 AtkRelationType relationship,
1445 AtkObject *array[1];
1446 AtkRelation *relation;
1448 g_return_val_if_fail (ATK_IS_OBJECT (object), FALSE);
1449 g_return_val_if_fail (ATK_IS_OBJECT (target), FALSE);
1452 relation = atk_relation_new (array, 1, relationship);
1453 atk_relation_set_add (object->relation_set, relation);
1454 g_object_unref (relation);
1460 * atk_object_remove_relationship:
1461 * @object: The #AtkObject from which an AtkRelation is to be removed.
1462 * @relationship: The #AtkRelationType of the relation
1463 * @target: The #AtkObject which is the target of the relation to be removed.
1465 * Removes a relationship of the specified type with the specified target.
1467 * Returns TRUE if the relationship is removed.
1470 atk_object_remove_relationship (AtkObject *object,
1471 AtkRelationType relationship,
1474 gint n_relations, i;
1475 gboolean ret = FALSE;
1476 AtkRelation *relation;
1478 g_return_val_if_fail (ATK_IS_OBJECT (object), FALSE);
1479 g_return_val_if_fail (ATK_IS_OBJECT (target), FALSE);
1481 n_relations = atk_relation_set_get_n_relations (object->relation_set);
1482 for (i = 0; i < n_relations; i++)
1484 relation = atk_relation_set_get_relation (object->relation_set, i);
1485 if (atk_relation_get_relation_type (relation) == relationship)
1489 array = atk_relation_get_target (relation);
1491 if (g_ptr_array_index (array, 0) == target)
1493 atk_relation_set_remove (object->relation_set, relation);
1504 atk_object_real_initialize (AtkObject *accessible,