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")},
167 { ATK_ROLE_FORM, N_("form")}
170 static void atk_object_class_init (AtkObjectClass *klass);
171 static void atk_object_init (AtkObject *accessible,
172 AtkObjectClass *klass);
173 static AtkRelationSet* atk_object_real_ref_relation_set
174 (AtkObject *accessible);
175 static void atk_object_real_initialize (AtkObject *accessible,
177 static void atk_object_real_set_property (GObject *object,
181 static void atk_object_real_get_property (GObject *object,
185 static void atk_object_finalize (GObject *object);
186 static G_CONST_RETURN gchar*
187 atk_object_real_get_name (AtkObject *object);
188 static G_CONST_RETURN gchar*
189 atk_object_real_get_description
191 static AtkObject* atk_object_real_get_parent (AtkObject *object);
192 static AtkRole atk_object_real_get_role (AtkObject *object);
193 static AtkLayer atk_object_real_get_layer (AtkObject *object);
194 static AtkStateSet* atk_object_real_ref_state_set
196 static void atk_object_real_set_name (AtkObject *object,
198 static void atk_object_real_set_description
200 const gchar *description);
201 static void atk_object_real_set_parent (AtkObject *object,
203 static void atk_object_real_set_role (AtkObject *object,
205 static guint atk_object_real_connect_property_change_handler
207 AtkPropertyChangeHandler
209 static void atk_object_real_remove_property_change_handler
212 static void atk_object_notify (GObject *obj,
216 static guint atk_object_signals[LAST_SIGNAL] = { 0, };
218 static gpointer parent_class = NULL;
220 static const gchar* const atk_object_name_property_name = "accessible-name";
221 static const gchar* const atk_object_name_property_description = "accessible-description";
222 static const gchar* const atk_object_name_property_parent = "accessible-parent";
223 static const gchar* const atk_object_name_property_value = "accessible-value";
224 static const gchar* const atk_object_name_property_role = "accessible-role";
225 static const gchar* const atk_object_name_property_component_layer = "accessible-component-layer";
226 static const gchar* const atk_object_name_property_component_mdi_zorder = "accessible-component-mdi-zorder";
227 static const gchar* const atk_object_name_property_table_caption = "accessible-table-caption";
228 static const gchar* const atk_object_name_property_table_column_description = "accessible-table-column-description";
229 static const gchar* const atk_object_name_property_table_column_header = "accessible-table-column-header";
230 static const gchar* const atk_object_name_property_table_row_description = "accessible-table-row-description";
231 static const gchar* const atk_object_name_property_table_row_header = "accessible-table-row-header";
232 static const gchar* const atk_object_name_property_table_summary = "accessible-table-summary";
233 static const gchar* const atk_object_name_property_table_caption_object = "accessible-table-caption-object";
234 static const gchar* const atk_object_name_property_hypertext_num_links = "accessible-hypertext-nlinks";
238 static HMODULE atk_dll;
241 DllMain (HINSTANCE hinstDLL,
247 case DLL_PROCESS_ATTACH:
248 atk_dll = (HMODULE) hinstDLL;
256 get_atk_locale_dir (void)
258 static gchar *atk_localedir = NULL;
265 /* ATK_LOCALEDIR might end in either /lib/locale or
266 * /share/locale. Scan for that slash.
268 p = ATK_LOCALEDIR + strlen (ATK_LOCALEDIR);
274 root = g_win32_get_package_installation_directory_of_module (atk_dll);
275 temp = g_build_filename (root, p, NULL);
278 /* atk_localedir is passed to bindtextdomain() which isn't
281 atk_localedir = g_win32_locale_filename_from_utf8 (temp);
284 return atk_localedir;
289 #define ATK_LOCALEDIR get_atk_locale_dir()
294 gettext_initialization (void)
297 static gboolean gettext_initialized = FALSE;
299 if (!gettext_initialized)
301 const char *dir = g_getenv ("ATK_ALT_LOCALEDIR");
303 gettext_initialized = TRUE;
307 bindtextdomain (GETTEXT_PACKAGE, dir);
308 #ifdef HAVE_BIND_TEXTDOMAIN_CODESET
309 bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
316 atk_object_get_type (void)
318 static GType type = 0;
322 static const GTypeInfo typeInfo =
324 sizeof (AtkObjectClass),
325 (GBaseInitFunc) NULL,
326 (GBaseFinalizeFunc) NULL,
327 (GClassInitFunc) atk_object_class_init,
328 (GClassFinalizeFunc) NULL,
332 (GInstanceInitFunc) atk_object_init,
334 type = g_type_register_static (G_TYPE_OBJECT, "AtkObject", &typeInfo, 0) ;
340 atk_object_class_init (AtkObjectClass *klass)
342 GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
344 parent_class = g_type_class_peek_parent (klass);
346 gobject_class->set_property = atk_object_real_set_property;
347 gobject_class->get_property = atk_object_real_get_property;
348 gobject_class->finalize = atk_object_finalize;
349 gobject_class->notify = atk_object_notify;
351 klass->get_name = atk_object_real_get_name;
352 klass->get_description = atk_object_real_get_description;
353 klass->get_parent = atk_object_real_get_parent;
354 klass->get_n_children = NULL;
355 klass->ref_child = NULL;
356 klass->get_index_in_parent = NULL;
357 klass->ref_relation_set = atk_object_real_ref_relation_set;
358 klass->get_role = atk_object_real_get_role;
359 klass->get_layer = atk_object_real_get_layer;
360 klass->get_mdi_zorder = NULL;
361 klass->initialize = atk_object_real_initialize;
362 klass->ref_state_set = atk_object_real_ref_state_set;
363 klass->set_name = atk_object_real_set_name;
364 klass->set_description = atk_object_real_set_description;
365 klass->set_parent = atk_object_real_set_parent;
366 klass->set_role = atk_object_real_set_role;
367 klass->connect_property_change_handler =
368 atk_object_real_connect_property_change_handler;
369 klass->remove_property_change_handler =
370 atk_object_real_remove_property_change_handler;
373 * We do not define default signal handlers here
375 klass->children_changed = NULL;
376 klass->focus_event = NULL;
377 klass->property_change = NULL;
378 klass->visible_data_changed = NULL;
379 klass->active_descendant_changed = NULL;
381 gettext_initialization ();
383 g_object_class_install_property (gobject_class,
385 g_param_spec_string (atk_object_name_property_name,
386 _("Accessible Name"),
387 _("Object instance\'s name formatted for assistive technology access"),
390 g_object_class_install_property (gobject_class,
392 g_param_spec_string (atk_object_name_property_description,
393 _("Accessible Description"),
394 _("Description of an object, formatted for assistive technology access"),
397 g_object_class_install_property (gobject_class,
399 g_param_spec_object (atk_object_name_property_parent,
400 _("Accessible Parent"),
401 _("Is used to notify that the parent has changed"),
404 g_object_class_install_property (gobject_class,
406 g_param_spec_double (atk_object_name_property_value,
407 _("Accessible Value"),
408 _("Is used to notify that the value has changed"),
413 g_object_class_install_property (gobject_class,
415 g_param_spec_int (atk_object_name_property_role,
416 _("Accessible Role"),
417 _("The accessible role of this object"),
422 g_object_class_install_property (gobject_class,
424 g_param_spec_int (atk_object_name_property_component_layer,
425 _("Accessible Layer"),
426 _("The accessible layer of this object"),
431 g_object_class_install_property (gobject_class,
433 g_param_spec_int (atk_object_name_property_component_mdi_zorder,
434 _("Accessible MDI Value"),
435 _("The accessible MDI value of this object"),
440 g_object_class_install_property (gobject_class,
442 g_param_spec_string (atk_object_name_property_table_caption,
443 _("Accessible Table Caption"),
444 _("Is used to notify that the table caption has changed; this property should not be used. accessible-table-caption-object should be used instead"),
447 g_object_class_install_property (gobject_class,
448 PROP_TABLE_COLUMN_HEADER,
449 g_param_spec_object (atk_object_name_property_table_column_header,
450 _("Accessible Table Column Header"),
451 _("Is used to notify that the table column header has changed"),
454 g_object_class_install_property (gobject_class,
455 PROP_TABLE_COLUMN_DESCRIPTION,
456 g_param_spec_string (atk_object_name_property_table_column_description,
457 _("Accessible Table Column Description"),
458 _("Is used to notify that the table column description has changed"),
461 g_object_class_install_property (gobject_class,
462 PROP_TABLE_ROW_HEADER,
463 g_param_spec_object (atk_object_name_property_table_row_header,
464 _("Accessible Table Row Header"),
465 _("Is used to notify that the table row header has changed"),
468 g_object_class_install_property (gobject_class,
469 PROP_TABLE_ROW_DESCRIPTION,
470 g_param_spec_string (atk_object_name_property_table_row_description,
471 _("Accessible Table Row Description"),
472 _("Is used to notify that the table row description has changed"),
475 g_object_class_install_property (gobject_class,
477 g_param_spec_object (atk_object_name_property_table_summary,
478 _("Accessible Table Summary"),
479 _("Is used to notify that the table summary has changed"),
482 g_object_class_install_property (gobject_class,
483 PROP_TABLE_CAPTION_OBJECT,
484 g_param_spec_object (atk_object_name_property_table_caption_object,
485 _("Accessible Table Caption Object"),
486 _("Is used to notify that the table caption has changed"),
489 g_object_class_install_property (gobject_class,
490 PROP_HYPERTEXT_NUM_LINKS,
491 g_param_spec_int (atk_object_name_property_hypertext_num_links,
492 _("Number of Accessible Hypertext Links"),
493 _("The number of links which the current AtkHypertext has"),
498 atk_object_signals[CHILDREN_CHANGED] =
499 g_signal_new ("children_changed",
500 G_TYPE_FROM_CLASS (klass),
501 G_SIGNAL_RUN_LAST | G_SIGNAL_DETAILED,
502 G_STRUCT_OFFSET (AtkObjectClass, children_changed),
504 g_cclosure_marshal_VOID__UINT_POINTER,
506 2, G_TYPE_UINT, G_TYPE_POINTER);
507 atk_object_signals[FOCUS_EVENT] =
508 g_signal_new ("focus_event",
509 G_TYPE_FROM_CLASS (klass),
511 G_STRUCT_OFFSET (AtkObjectClass, focus_event),
513 g_cclosure_marshal_VOID__BOOLEAN,
516 atk_object_signals[PROPERTY_CHANGE] =
517 g_signal_new ("property_change",
518 G_TYPE_FROM_CLASS (klass),
519 G_SIGNAL_RUN_LAST | G_SIGNAL_DETAILED,
520 G_STRUCT_OFFSET (AtkObjectClass, property_change),
521 (GSignalAccumulator) NULL, NULL,
522 g_cclosure_marshal_VOID__POINTER,
525 atk_object_signals[STATE_CHANGE] =
526 g_signal_new ("state_change",
527 G_TYPE_FROM_CLASS (klass),
528 G_SIGNAL_RUN_LAST | G_SIGNAL_DETAILED,
529 G_STRUCT_OFFSET (AtkObjectClass, state_change),
530 (GSignalAccumulator) NULL, NULL,
531 atk_marshal_VOID__STRING_BOOLEAN,
535 atk_object_signals[VISIBLE_DATA_CHANGED] =
536 g_signal_new ("visible_data_changed",
537 G_TYPE_FROM_CLASS (klass),
539 G_STRUCT_OFFSET (AtkObjectClass, visible_data_changed),
540 (GSignalAccumulator) NULL, NULL,
541 g_cclosure_marshal_VOID__VOID,
543 atk_object_signals[ACTIVE_DESCENDANT_CHANGED] =
544 g_signal_new ("active_descendant_changed",
545 G_TYPE_FROM_CLASS (klass),
546 G_SIGNAL_RUN_LAST | G_SIGNAL_DETAILED,
547 G_STRUCT_OFFSET (AtkObjectClass, active_descendant_changed),
549 g_cclosure_marshal_VOID__POINTER,
555 atk_object_init (AtkObject *accessible,
556 AtkObjectClass *klass)
558 accessible->name = NULL;
559 accessible->description = NULL;
560 accessible->accessible_parent = NULL;
561 accessible->relation_set = atk_relation_set_new();
562 accessible->role = ATK_ROLE_UNKNOWN;
566 atk_implementor_get_type (void)
568 static GType type = 0;
572 static const GTypeInfo typeInfo =
574 sizeof (AtkImplementorIface),
575 (GBaseInitFunc) NULL,
576 (GBaseFinalizeFunc) NULL,
579 type = g_type_register_static (G_TYPE_INTERFACE, "AtkImplementorIface", &typeInfo, 0) ;
586 * atk_object_get_name:
587 * @accessible: an #AtkObject
589 * Gets the accessible name of the accessible.
591 * Returns: a character string representing the accessible name of the object.
593 G_CONST_RETURN gchar*
594 atk_object_get_name (AtkObject *accessible)
596 AtkObjectClass *klass;
598 g_return_val_if_fail (ATK_IS_OBJECT (accessible), NULL);
600 klass = ATK_OBJECT_GET_CLASS (accessible);
602 return (klass->get_name) (accessible);
608 * atk_object_get_description:
609 * @accessible: an #AtkObject
611 * Gets the accessible description of the accessible.
613 * Returns: a character string representing the accessible description
617 G_CONST_RETURN gchar*
618 atk_object_get_description (AtkObject *accessible)
620 AtkObjectClass *klass;
622 g_return_val_if_fail (ATK_IS_OBJECT (accessible), NULL);
624 klass = ATK_OBJECT_GET_CLASS (accessible);
625 if (klass->get_description)
626 return (klass->get_description) (accessible);
632 * atk_object_get_parent:
633 * @accessible: an #AtkObject
635 * Gets the accessible parent of the accessible.
637 * Returns: a #AtkObject representing the accessible parent of the accessible
640 atk_object_get_parent (AtkObject *accessible)
642 AtkObjectClass *klass;
644 g_return_val_if_fail (ATK_IS_OBJECT (accessible), NULL);
646 klass = ATK_OBJECT_GET_CLASS (accessible);
647 if (klass->get_parent)
648 return (klass->get_parent) (accessible);
654 * atk_object_get_n_accessible_children:
655 * @accessible: an #AtkObject
657 * Gets the number of accessible children of the accessible.
659 * Returns: an integer representing the number of accessible children
663 atk_object_get_n_accessible_children (AtkObject *accessible)
665 AtkObjectClass *klass;
667 g_return_val_if_fail (ATK_IS_OBJECT (accessible), 0);
669 klass = ATK_OBJECT_GET_CLASS (accessible);
670 if (klass->get_n_children)
671 return (klass->get_n_children) (accessible);
677 * atk_object_ref_accessible_child:
678 * @accessible: an #AtkObject
679 * @i: a gint representing the position of the child, starting from 0
681 * Gets a reference to the specified accessible child of the object.
682 * The accessible children are 0-based so the first accessible child is
683 * at index 0, the second at index 1 and so on.
685 * Returns: an #AtkObject representing the specified accessible child
689 atk_object_ref_accessible_child (AtkObject *accessible,
692 AtkObjectClass *klass;
694 g_return_val_if_fail (ATK_IS_OBJECT (accessible), NULL);
696 klass = ATK_OBJECT_GET_CLASS (accessible);
697 if (klass->ref_child)
698 return (klass->ref_child) (accessible, i);
704 * atk_object_ref_relation_set:
705 * @accessible: an #AtkObject
707 * Gets the #AtkRelationSet associated with the object.
709 * Returns: an #AtkRelationSet representing the relation set of the object.
712 atk_object_ref_relation_set (AtkObject *accessible)
714 AtkObjectClass *klass;
716 g_return_val_if_fail (ATK_IS_OBJECT (accessible), NULL);
718 klass = ATK_OBJECT_GET_CLASS (accessible);
719 if (klass->ref_relation_set)
720 return (klass->ref_relation_set) (accessible);
727 * @name: a character string describing the new role.
729 * Registers the role specified by @name.
731 * Returns: an #AtkRole for the new role.
734 atk_role_register (const gchar *name)
737 extra_roles = g_ptr_array_new ();
739 g_ptr_array_add (extra_roles, g_strdup (name));
740 return extra_roles->len + ATK_ROLE_LAST_DEFINED;
744 * atk_object_get_role:
745 * @accessible: an #AtkObject
747 * Gets the role of the accessible.
749 * Returns: an #AtkRole which is the role of the accessible
752 atk_object_get_role (AtkObject *accessible)
754 AtkObjectClass *klass;
756 g_return_val_if_fail (ATK_IS_OBJECT (accessible), ATK_ROLE_UNKNOWN);
758 klass = ATK_OBJECT_GET_CLASS (accessible);
760 return (klass->get_role) (accessible);
762 return ATK_ROLE_UNKNOWN;
766 * atk_object_get_layer:
767 * @accessible: an #AtkObject
769 * Gets the layer of the accessible.
771 * Deprecated: Use atk_component_get_layer instead.
773 * Returns: an #AtkLayer which is the layer of the accessible
776 atk_object_get_layer (AtkObject *accessible)
778 AtkObjectClass *klass;
780 g_return_val_if_fail (ATK_IS_OBJECT (accessible), ATK_LAYER_INVALID);
782 klass = ATK_OBJECT_GET_CLASS (accessible);
783 if (klass->get_layer)
784 return (klass->get_layer) (accessible);
786 return ATK_LAYER_INVALID;
790 * atk_object_get_mdi_zorder:
791 * @accessible: an #AtkObject
793 * Gets the zorder of the accessible. The value G_MININT will be returned
794 * if the layer of the accessible is not ATK_LAYER_MDI.
796 * Deprecated: Use atk_component_get_mdi_zorder instead.
798 * Returns: a gint which is the zorder of the accessible, i.e. the depth at
799 * which the component is shown in relation to other components in the same
804 atk_object_get_mdi_zorder (AtkObject *accessible)
806 AtkObjectClass *klass;
808 g_return_val_if_fail (ATK_IS_OBJECT (accessible), G_MININT);
810 klass = ATK_OBJECT_GET_CLASS (accessible);
811 if (klass->get_mdi_zorder)
812 return (klass->get_mdi_zorder) (accessible);
818 * atk_object_ref_state_set:
819 * @accessible: an #AtkObject
821 * Gets a reference to the state set of the accessible; the caller must
822 * unreference it when it is no longer needed.
824 * Returns: a reference to an #AtkStateSet which is the state
825 * set of the accessible
828 atk_object_ref_state_set (AtkObject *accessible)
830 AtkObjectClass *klass;
832 g_return_val_if_fail (ATK_IS_OBJECT (accessible), NULL);
834 klass = ATK_OBJECT_GET_CLASS (accessible);
835 if (klass->ref_state_set)
836 return (klass->ref_state_set) (accessible);
842 * atk_object_get_index_in_parent:
843 * @accessible: an #AtkObject
845 * Gets the 0-based index of this accessible in its parent; returns -1 if the
846 * accessible does not have an accessible parent.
848 * Returns: an integer which is the index of the accessible in its parent
851 atk_object_get_index_in_parent (AtkObject *accessible)
853 AtkObjectClass *klass;
855 g_return_val_if_fail (ATK_OBJECT (accessible), -1);
857 klass = ATK_OBJECT_GET_CLASS (accessible);
858 if (klass->get_index_in_parent)
859 return (klass->get_index_in_parent) (accessible);
865 * atk_object_set_name:
866 * @accessible: an #AtkObject
867 * @name: a character string to be set as the accessible name
869 * Sets the accessible name of the accessible.
872 atk_object_set_name (AtkObject *accessible,
875 AtkObjectClass *klass;
877 g_return_if_fail (ATK_IS_OBJECT (accessible));
878 g_return_if_fail (name != NULL);
880 klass = ATK_OBJECT_GET_CLASS (accessible);
883 (klass->set_name) (accessible, name);
884 g_object_notify (G_OBJECT (accessible), atk_object_name_property_name);
889 * atk_object_set_description:
890 * @accessible: an #AtkObject
891 * @description : a character string to be set as the accessible description
893 * Sets the accessible description of the accessible.
896 atk_object_set_description (AtkObject *accessible,
897 const gchar *description)
899 AtkObjectClass *klass;
901 g_return_if_fail (ATK_IS_OBJECT (accessible));
902 g_return_if_fail (description != NULL);
904 klass = ATK_OBJECT_GET_CLASS (accessible);
905 if (klass->set_description)
907 (klass->set_description) (accessible, description);
908 g_object_notify (G_OBJECT (accessible), atk_object_name_property_description);
913 * atk_object_set_parent:
914 * @accessible: an #AtkObject
915 * @parent : an #AtkObject to be set as the accessible parent
917 * Sets the accessible parent of the accessible.
920 atk_object_set_parent (AtkObject *accessible,
923 AtkObjectClass *klass;
925 g_return_if_fail (ATK_IS_OBJECT (accessible));
927 klass = ATK_OBJECT_GET_CLASS (accessible);
928 if (klass->set_parent)
930 (klass->set_parent) (accessible, parent);
931 g_object_notify (G_OBJECT (accessible), atk_object_name_property_parent);
936 * atk_object_set_role:
937 * @accessible: an #AtkObject
938 * @role : an #AtkRole to be set as the role
940 * Sets the role of the accessible.
943 atk_object_set_role (AtkObject *accessible,
946 AtkObjectClass *klass;
949 g_return_if_fail (ATK_IS_OBJECT (accessible));
951 klass = ATK_OBJECT_GET_CLASS (accessible);
954 old_role = atk_object_get_role (accessible);
955 if (old_role != role)
957 (klass->set_role) (accessible, role);
958 if (old_role != ATK_ROLE_UNKNOWN)
959 /* Do not notify for initial role setting */
960 g_object_notify (G_OBJECT (accessible), atk_object_name_property_role);
966 * atk_object_connect_property_change_handler:
967 * @accessible: an #AtkObject
968 * @handler : a function to be called when a property changes its value
970 * Specifies a function to be called when a property changes value.
972 * Returns: a #guint which is the handler id used in
973 * atk_object_remove_property_change_handler()
976 atk_object_connect_property_change_handler (AtkObject *accessible,
977 AtkPropertyChangeHandler *handler)
979 AtkObjectClass *klass;
981 g_return_val_if_fail (ATK_IS_OBJECT (accessible), 0);
982 g_return_val_if_fail ((handler != NULL), 0);
984 klass = ATK_OBJECT_GET_CLASS (accessible);
985 if (klass->connect_property_change_handler)
986 return (klass->connect_property_change_handler) (accessible, handler);
992 * atk_object_remove_property_change_handler:
993 * @accessible: an #AtkObject
994 * @handler_id : a guint which identifies the handler to be removed.
996 * Removes a property change handler.
999 atk_object_remove_property_change_handler (AtkObject *accessible,
1002 AtkObjectClass *klass;
1004 g_return_if_fail (ATK_IS_OBJECT (accessible));
1006 klass = ATK_OBJECT_GET_CLASS (accessible);
1007 if (klass->remove_property_change_handler)
1008 (klass->remove_property_change_handler) (accessible, handler_id);
1012 * atk_object_notify_state_change:
1013 * @accessible: an #AtkObject
1014 * @state: an #AtkState whose state is changed
1015 * @value : a gboolean which indicates whether the state is being set on or off
1017 * Emits a state-change signal for the specified state.
1020 atk_object_notify_state_change (AtkObject *accessible,
1024 G_CONST_RETURN gchar* name;
1026 g_return_if_fail (ATK_IS_OBJECT (accessible));
1028 name = atk_state_type_get_name (state);
1029 g_signal_emit (accessible, atk_object_signals[STATE_CHANGE],
1030 g_quark_from_string (name),
1035 * atk_implementor_ref_accessible:
1036 * @implementor: The #GObject instance which should implement #AtkImplementorIface
1037 * if a non-null return value is required.
1039 * Gets a reference to an object's #AtkObject implementation, if
1040 * the object implements #AtkObjectIface
1042 * Returns: a reference to an object's #AtkObject implementation
1045 atk_implementor_ref_accessible (AtkImplementor *implementor)
1047 AtkImplementorIface *iface;
1048 AtkObject *accessible = NULL;
1050 g_return_val_if_fail (ATK_IS_IMPLEMENTOR (implementor), NULL);
1052 iface = ATK_IMPLEMENTOR_GET_IFACE (implementor);
1055 accessible = iface->ref_accessible (implementor);
1057 g_return_val_if_fail ((accessible != NULL), NULL);
1064 * atk_object_get_attributes:
1065 * @accessible: An #AtkObject.
1067 * Get a list of properties applied to this object as a whole, as an #AtkAttributeSet consisting of
1068 * name-value pairs. As such these attributes may be considered weakly-typed properties or annotations,
1069 * as distinct from strongly-typed object data available via other get/set methods.
1070 * Not all objects have explicit "name-value pair" #AtkAttributeSet properties.
1074 * Returns: an #AtkAttributeSet consisting of all explicit properties/annotations applied to
1075 * the object, or an empty set if the object has no name-value pair attributes assigned to it.
1078 atk_object_get_attributes (AtkObject *accessible)
1080 AtkObjectClass *klass;
1082 g_return_val_if_fail (ATK_IS_OBJECT (accessible), NULL);
1084 klass = ATK_OBJECT_GET_CLASS (accessible);
1085 if (klass->get_attributes)
1086 return (klass->get_attributes) (accessible);
1092 static AtkRelationSet*
1093 atk_object_real_ref_relation_set (AtkObject *accessible)
1095 g_return_val_if_fail (accessible->relation_set, NULL);
1096 g_object_ref (accessible->relation_set);
1098 return accessible->relation_set;
1102 atk_object_real_set_property (GObject *object,
1104 const GValue *value,
1107 AtkObject *accessible;
1109 accessible = ATK_OBJECT (object);
1114 atk_object_set_name (accessible, g_value_get_string (value));
1116 case PROP_DESCRIPTION:
1117 atk_object_set_description (accessible, g_value_get_string (value));
1120 atk_object_set_role (accessible, g_value_get_int (value));
1123 atk_object_set_parent (accessible, g_value_get_object (value));
1126 if (ATK_IS_VALUE (accessible))
1127 atk_value_set_current_value (ATK_VALUE (accessible), value);
1129 case PROP_TABLE_SUMMARY:
1130 if (ATK_IS_TABLE (accessible))
1131 atk_table_set_summary (ATK_TABLE (accessible), g_value_get_object (value));
1133 case PROP_TABLE_CAPTION_OBJECT:
1134 if (ATK_IS_TABLE (accessible))
1135 atk_table_set_caption (ATK_TABLE (accessible), g_value_get_object (value));
1143 atk_object_real_get_property (GObject *object,
1148 AtkObject *accessible;
1150 accessible = ATK_OBJECT (object);
1155 g_value_set_string (value, atk_object_get_name (accessible));
1157 case PROP_DESCRIPTION:
1158 g_value_set_string (value, atk_object_get_description (accessible));
1161 g_value_set_int (value, atk_object_get_role (accessible));
1164 if (ATK_IS_COMPONENT (accessible))
1165 g_value_set_int (value, atk_component_get_layer (ATK_COMPONENT (accessible)));
1167 case PROP_MDI_ZORDER:
1168 if (ATK_IS_COMPONENT (accessible))
1169 g_value_set_int (value, atk_component_get_mdi_zorder (ATK_COMPONENT (accessible)));
1172 g_value_set_object (value, atk_object_get_parent (accessible));
1175 if (ATK_IS_VALUE (accessible))
1176 atk_value_get_current_value (ATK_VALUE (accessible), value);
1178 case PROP_TABLE_SUMMARY:
1179 if (ATK_IS_TABLE (accessible))
1180 g_value_set_object (value, atk_table_get_summary (ATK_TABLE (accessible)));
1182 case PROP_TABLE_CAPTION_OBJECT:
1183 if (ATK_IS_TABLE (accessible))
1184 g_value_set_object (value, atk_table_get_caption (ATK_TABLE (accessible)));
1186 case PROP_HYPERTEXT_NUM_LINKS:
1187 if (ATK_IS_HYPERTEXT (accessible))
1188 g_value_set_int (value, atk_hypertext_get_n_links (ATK_HYPERTEXT (accessible)));
1191 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
1197 atk_object_finalize (GObject *object)
1199 AtkObject *accessible;
1201 g_return_if_fail (ATK_IS_OBJECT (object));
1203 accessible = ATK_OBJECT (object);
1205 g_free (accessible->name);
1206 g_free (accessible->description);
1209 * Free memory allocated for relation set if it have been allocated.
1211 if (accessible->relation_set)
1212 g_object_unref (accessible->relation_set);
1214 if (accessible->accessible_parent)
1215 g_object_unref (accessible->accessible_parent);
1217 G_OBJECT_CLASS (parent_class)->finalize (object);
1220 static G_CONST_RETURN gchar*
1221 atk_object_real_get_name (AtkObject *object)
1223 return object->name;
1226 static G_CONST_RETURN gchar*
1227 atk_object_real_get_description (AtkObject *object)
1229 return object->description;
1233 atk_object_real_get_parent (AtkObject *object)
1235 return object->accessible_parent;
1239 atk_object_real_get_role (AtkObject *object)
1241 return object->role;
1245 atk_object_real_get_layer (AtkObject *object)
1247 return object->layer;
1251 atk_object_real_ref_state_set (AtkObject *accessible)
1253 AtkStateSet *state_set;
1255 AtkObject *focus_object;
1257 state_set = atk_state_set_new ();
1259 ap = atk_object_get_parent (accessible);
1261 if (ATK_IS_SELECTION (ap))
1265 atk_state_set_add_state (state_set, ATK_STATE_SELECTABLE);
1267 i = atk_object_get_index_in_parent (accessible);
1269 if (atk_selection_is_child_selected(ATK_SELECTION (ap), i))
1270 atk_state_set_add_state (state_set, ATK_STATE_SELECTED);
1272 focus_object = atk_get_focus_object ();
1273 if (focus_object == accessible)
1274 atk_state_set_add_state (state_set, ATK_STATE_FOCUSED);
1280 atk_object_real_set_name (AtkObject *object,
1283 g_free (object->name);
1284 object->name = g_strdup (name);
1288 atk_object_real_set_description (AtkObject *object,
1289 const gchar *description)
1291 g_free (object->description);
1292 object->description = g_strdup (description);
1296 atk_object_real_set_parent (AtkObject *object,
1299 if (object->accessible_parent)
1300 g_object_unref (object->accessible_parent);
1302 object->accessible_parent = parent;
1303 if (object->accessible_parent)
1304 g_object_ref (object->accessible_parent);
1308 atk_object_real_set_role (AtkObject *object,
1311 object->role = role;
1315 atk_object_real_connect_property_change_handler (AtkObject *obj,
1316 AtkPropertyChangeHandler *handler)
1318 return g_signal_connect_closure_by_id (obj,
1319 atk_object_signals[PROPERTY_CHANGE],
1322 G_CALLBACK (handler), NULL,
1323 (GClosureNotify) NULL),
1328 atk_object_real_remove_property_change_handler (AtkObject *obj,
1331 g_signal_handler_disconnect (obj, handler_id);
1335 * atk_object_initialize:
1336 * @accessible: a #AtkObject
1337 * @data: a #gpointer which identifies the object for which the AtkObject was created.
1339 * This function is called when implementing subclasses of #AtkObject.
1340 * It does initialization required for the new object. It is intended
1341 * that this function should called only in the ..._new() functions used
1342 * to create an instance of a subclass of #AtkObject
1345 atk_object_initialize (AtkObject *accessible,
1348 AtkObjectClass *klass;
1350 g_return_if_fail (ATK_IS_OBJECT (accessible));
1352 klass = ATK_OBJECT_GET_CLASS (accessible);
1353 if (klass->initialize)
1354 klass->initialize (accessible, data);
1358 * This function is a signal handler for notify signal which gets emitted
1359 * when a property changes value.
1361 * It constructs an AtkPropertyValues structure and emits a "property_changed"
1362 * signal which causes the user specified AtkPropertyChangeHandler
1366 atk_object_notify (GObject *obj,
1369 AtkPropertyValues values = { NULL, };
1371 g_value_init (&values.new_value, pspec->value_type);
1372 g_object_get_property (obj, pspec->name, &values.new_value);
1373 values.property_name = pspec->name;
1374 g_signal_emit (obj, atk_object_signals[PROPERTY_CHANGE],
1375 g_quark_from_string (pspec->name),
1377 g_value_unset (&values.new_value);
1381 * atk_role_get_name:
1382 * @role: The #AtkRole whose name is required
1384 * Gets the description string describing the #AtkRole @role.
1386 * Returns: the string describing the AtkRole
1388 G_CONST_RETURN gchar*
1389 atk_role_get_name (AtkRole role)
1394 for (i = 0; i < G_N_ELEMENTS (role_items); i++)
1396 if (role == role_items[i].role)
1397 return role_items[i].name;
1404 n -= ATK_ROLE_LAST_DEFINED + 1;
1406 if (n < extra_roles->len)
1407 name = g_ptr_array_index (extra_roles, n);
1413 * atk_role_get_localized_name:
1414 * @role: The #AtkRole whose localized name is required
1416 * Gets the localized description string describing the #AtkRole @role.
1418 * Returns: the localized string describing the AtkRole
1420 G_CONST_RETURN gchar*
1421 atk_role_get_localized_name (AtkRole role)
1423 G_CONST_RETURN gchar *name;
1426 gettext_initialization ();
1428 for (i = 0; i < G_N_ELEMENTS (role_items); i++)
1430 if (role == role_items[i].role)
1431 return dgettext (GETTEXT_PACKAGE, role_items[i].name);
1433 name = atk_role_get_name (role);
1439 * atk_role_for_name:
1440 * @name: a string which is the (non-localized) name of an ATK role.
1442 * Get the #AtkRole type corresponding to a rolew name.
1444 * Returns: the #AtkRole enumerated type corresponding to the specified
1446 * or #ATK_ROLE_INVALID if no matching role is found.
1449 atk_role_for_name (const gchar *name)
1451 AtkRole role = ATK_ROLE_INVALID;
1454 g_return_val_if_fail (name, ATK_ROLE_INVALID);
1456 for (i = 0; i < G_N_ELEMENTS (role_items); i++)
1458 if (strcmp (name, role_items[i].name) == 0)
1459 return role_items[i].role;
1464 for (i = 0; i < extra_roles->len; i++)
1466 gchar *extra_role = (gchar *)g_ptr_array_index (extra_roles, i);
1468 g_return_val_if_fail (extra_role, ATK_ROLE_INVALID);
1470 if (strcmp (name, extra_role) == 0)
1472 role = i + 1 + ATK_ROLE_LAST_DEFINED;
1482 * atk_object_add_relationship:
1483 * @object: The #AtkObject to which an AtkRelation is to be added.
1484 * @relationship: The #AtkRelationType of the relation
1485 * @target: The #AtkObject which is to be the target of the relation.
1487 * Adds a relationship of the specified type with the specified target.
1489 * Returns TRUE if the relationship is added.
1492 atk_object_add_relationship (AtkObject *object,
1493 AtkRelationType relationship,
1496 AtkObject *array[1];
1497 AtkRelation *relation;
1499 g_return_val_if_fail (ATK_IS_OBJECT (object), FALSE);
1500 g_return_val_if_fail (ATK_IS_OBJECT (target), FALSE);
1503 relation = atk_relation_new (array, 1, relationship);
1504 atk_relation_set_add (object->relation_set, relation);
1505 g_object_unref (relation);
1511 * atk_object_remove_relationship:
1512 * @object: The #AtkObject from which an AtkRelation is to be removed.
1513 * @relationship: The #AtkRelationType of the relation
1514 * @target: The #AtkObject which is the target of the relation to be removed.
1516 * Removes a relationship of the specified type with the specified target.
1518 * Returns TRUE if the relationship is removed.
1521 atk_object_remove_relationship (AtkObject *object,
1522 AtkRelationType relationship,
1525 gint n_relations, i;
1526 gboolean ret = FALSE;
1527 AtkRelation *relation;
1529 g_return_val_if_fail (ATK_IS_OBJECT (object), FALSE);
1530 g_return_val_if_fail (ATK_IS_OBJECT (target), FALSE);
1532 n_relations = atk_relation_set_get_n_relations (object->relation_set);
1533 for (i = 0; i < n_relations; i++)
1535 relation = atk_relation_set_get_relation (object->relation_set, i);
1536 if (atk_relation_get_relation_type (relation) == relationship)
1540 array = atk_relation_get_target (relation);
1542 if (g_ptr_array_index (array, 0) == target)
1544 atk_relation_set_remove (object->relation_set, relation);
1555 atk_object_real_initialize (AtkObject *accessible,