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 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_LAST /* gobject convention */
66 ACTIVE_DESCENDANT_CHANGED,
71 typedef struct _AtkRoleItem AtkRoleItem;
79 static AtkRoleItem role_items [] =
81 { ATK_ROLE_INVALID, N_("invalid")},
82 { ATK_ROLE_ACCEL_LABEL, N_("accel label")},
83 { ATK_ROLE_ALERT, N_("alert")},
84 { ATK_ROLE_ANIMATION, N_("animation")},
85 { ATK_ROLE_ARROW, N_("arrow")},
86 { ATK_ROLE_CALENDAR, N_("calendar")},
87 { ATK_ROLE_CANVAS, N_("canvas")},
88 { ATK_ROLE_CHECK_BOX, N_("check box")},
89 { ATK_ROLE_CHECK_MENU_ITEM, N_("check menu item")},
90 { ATK_ROLE_COLOR_CHOOSER, N_("color chooser")},
91 { ATK_ROLE_COLUMN_HEADER, N_("column header")},
92 { ATK_ROLE_COMBO_BOX, N_("combo box")},
93 { ATK_ROLE_DATE_EDITOR, N_("dateeditor")},
94 { ATK_ROLE_DESKTOP_ICON, N_("desktop icon")},
95 { ATK_ROLE_DESKTOP_FRAME, N_("desktop frame")},
96 { ATK_ROLE_DIAL, N_("dial")},
97 { ATK_ROLE_DIALOG, N_("dialog")},
98 { ATK_ROLE_DIRECTORY_PANE, N_("directory pane")},
99 { ATK_ROLE_DRAWING_AREA, N_("drawing area")},
100 { ATK_ROLE_FILE_CHOOSER, N_("file chooser")},
101 { ATK_ROLE_FILLER, N_("filler")},
102 /* I know it looks wrong but that is what Java returns */
103 { ATK_ROLE_FONT_CHOOSER, N_("fontchooser")},
104 { ATK_ROLE_FRAME, N_("frame")},
105 { ATK_ROLE_GLASS_PANE, N_("glass pane")},
106 { ATK_ROLE_HTML_CONTAINER, N_("html container")},
107 { ATK_ROLE_ICON, N_("icon")},
108 { ATK_ROLE_IMAGE, N_("image")},
109 { ATK_ROLE_INTERNAL_FRAME, N_("internal frame")},
110 { ATK_ROLE_LABEL, N_("label")},
111 { ATK_ROLE_LAYERED_PANE, N_("layered pane")},
112 { ATK_ROLE_LIST, N_("list")},
113 { ATK_ROLE_LIST_ITEM, N_("list item")},
114 { ATK_ROLE_MENU, N_("menu")},
115 { ATK_ROLE_MENU_BAR, N_("menu bar")},
116 { ATK_ROLE_MENU_ITEM, N_("menu item")},
117 { ATK_ROLE_OPTION_PANE, N_("option pane")},
118 { ATK_ROLE_PAGE_TAB, N_("page tab")},
119 { ATK_ROLE_PAGE_TAB_LIST, N_("page tab list")},
120 { ATK_ROLE_PANEL, N_("panel")},
121 { ATK_ROLE_PASSWORD_TEXT, N_("password text")},
122 { ATK_ROLE_POPUP_MENU, N_("popup menu")},
123 { ATK_ROLE_PROGRESS_BAR, N_("progress bar")},
124 { ATK_ROLE_PUSH_BUTTON, N_("push button")},
125 { ATK_ROLE_RADIO_BUTTON, N_("radio button")},
126 { ATK_ROLE_RADIO_MENU_ITEM, N_("radio menu item")},
127 { ATK_ROLE_ROOT_PANE, N_("root pane")},
128 { ATK_ROLE_ROW_HEADER, N_("row header")},
129 { ATK_ROLE_SCROLL_BAR, N_("scroll bar")},
130 { ATK_ROLE_SCROLL_PANE, N_("scroll pane")},
131 { ATK_ROLE_SEPARATOR, N_("separator")},
132 { ATK_ROLE_SLIDER, N_("slider")},
133 { ATK_ROLE_SPLIT_PANE, N_("split pane")},
134 { ATK_ROLE_SPIN_BUTTON, N_("spin button")},
135 { ATK_ROLE_STATUSBAR, N_("statusbar")},
136 { ATK_ROLE_TABLE, N_("table")},
137 { ATK_ROLE_TABLE_CELL, N_("table cell")},
138 { ATK_ROLE_TABLE_COLUMN_HEADER, N_("table column header")},
139 { ATK_ROLE_TABLE_ROW_HEADER, N_("table row header")},
140 { ATK_ROLE_TEAR_OFF_MENU_ITEM, N_("tear off menu item")},
141 { ATK_ROLE_TERMINAL, N_("terminal")},
142 { ATK_ROLE_TEXT, N_("text")},
143 { ATK_ROLE_TOGGLE_BUTTON, N_("toggle button")},
144 { ATK_ROLE_TOOL_BAR, N_("tool bar")},
145 { ATK_ROLE_TOOL_TIP, N_("tool tip")},
146 { ATK_ROLE_TREE, N_("tree")},
147 { ATK_ROLE_TREE_TABLE, N_("tree table")},
148 { ATK_ROLE_UNKNOWN, N_("unknown")},
149 { ATK_ROLE_VIEWPORT, N_("viewport")},
150 { ATK_ROLE_WINDOW, N_("window")},
151 { ATK_ROLE_HEADER, N_("header")},
152 { ATK_ROLE_FOOTER, N_("footer")},
153 { ATK_ROLE_PARAGRAPH, N_("paragraph")},
154 { ATK_ROLE_APPLICATION, N_("application")},
155 { ATK_ROLE_AUTOCOMPLETE, N_("autocomplete")}
158 static void atk_object_class_init (AtkObjectClass *klass);
159 static void atk_object_init (AtkObject *accessible,
160 AtkObjectClass *klass);
161 static AtkRelationSet* atk_object_real_ref_relation_set
162 (AtkObject *accessible);
163 static void atk_object_real_initialize (AtkObject *accessible,
165 static void atk_object_real_set_property (GObject *object,
169 static void atk_object_real_get_property (GObject *object,
173 static void atk_object_finalize (GObject *object);
174 static G_CONST_RETURN gchar*
175 atk_object_real_get_name (AtkObject *object);
176 static G_CONST_RETURN gchar*
177 atk_object_real_get_description
179 static AtkObject* atk_object_real_get_parent (AtkObject *object);
180 static AtkRole atk_object_real_get_role (AtkObject *object);
181 static AtkLayer atk_object_real_get_layer (AtkObject *object);
182 static AtkStateSet* atk_object_real_ref_state_set
184 static void atk_object_real_set_name (AtkObject *object,
186 static void atk_object_real_set_description
188 const gchar *description);
189 static void atk_object_real_set_parent (AtkObject *object,
191 static void atk_object_real_set_role (AtkObject *object,
193 static guint atk_object_real_connect_property_change_handler
195 AtkPropertyChangeHandler
197 static void atk_object_real_remove_property_change_handler
200 static void atk_object_notify (GObject *obj,
204 static guint atk_object_signals[LAST_SIGNAL] = { 0, };
206 static gpointer parent_class = NULL;
208 static const gchar* atk_object_name_property_name = "accessible-name";
209 static const gchar* atk_object_name_property_description = "accessible-description";
210 static const gchar* atk_object_name_property_parent = "accessible-parent";
211 static const gchar* atk_object_name_property_value = "accessible-value";
212 static const gchar* atk_object_name_property_role = "accessible-role";
213 static const gchar* atk_object_name_property_component_layer = "accessible-component-layer";
214 static const gchar* atk_object_name_property_component_mdi_zorder = "accessible-component-mdi-zorder";
215 static const gchar* atk_object_name_property_table_caption = "accessible-table-caption";
216 static const gchar* atk_object_name_property_table_column_description = "accessible-table-column-description";
217 static const gchar* atk_object_name_property_table_column_header = "accessible-table-column-header";
218 static const gchar* atk_object_name_property_table_row_description = "accessible-table-row-description";
219 static const gchar* atk_object_name_property_table_row_header = "accessible-table-row-header";
220 static const gchar* atk_object_name_property_table_summary = "accessible-table-summary";
221 static const gchar* atk_object_name_property_table_caption_object = "accessible-table-caption-object";
224 atk_object_get_type (void)
226 static GType type = 0;
230 static const GTypeInfo typeInfo =
232 sizeof (AtkObjectClass),
233 (GBaseInitFunc) NULL,
234 (GBaseFinalizeFunc) NULL,
235 (GClassInitFunc) atk_object_class_init,
236 (GClassFinalizeFunc) NULL,
240 (GInstanceInitFunc) atk_object_init,
242 type = g_type_register_static (G_TYPE_OBJECT, "AtkObject", &typeInfo, 0) ;
248 atk_object_class_init (AtkObjectClass *klass)
250 GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
252 parent_class = g_type_class_peek_parent (klass);
254 gobject_class->set_property = atk_object_real_set_property;
255 gobject_class->get_property = atk_object_real_get_property;
256 gobject_class->finalize = atk_object_finalize;
257 gobject_class->notify = atk_object_notify;
259 klass->get_name = atk_object_real_get_name;
260 klass->get_description = atk_object_real_get_description;
261 klass->get_parent = atk_object_real_get_parent;
262 klass->get_n_children = NULL;
263 klass->ref_child = NULL;
264 klass->get_index_in_parent = NULL;
265 klass->ref_relation_set = atk_object_real_ref_relation_set;
266 klass->get_role = atk_object_real_get_role;
267 klass->get_layer = atk_object_real_get_layer;
268 klass->get_mdi_zorder = NULL;
269 klass->initialize = atk_object_real_initialize;
270 klass->ref_state_set = atk_object_real_ref_state_set;
271 klass->set_name = atk_object_real_set_name;
272 klass->set_description = atk_object_real_set_description;
273 klass->set_parent = atk_object_real_set_parent;
274 klass->set_role = atk_object_real_set_role;
275 klass->connect_property_change_handler =
276 atk_object_real_connect_property_change_handler;
277 klass->remove_property_change_handler =
278 atk_object_real_remove_property_change_handler;
281 * We do not define default signal handlers here
283 klass->children_changed = NULL;
284 klass->focus_event = NULL;
285 klass->property_change = NULL;
286 klass->visible_data_changed = NULL;
287 klass->active_descendant_changed = NULL;
289 g_object_class_install_property (gobject_class,
291 g_param_spec_string (atk_object_name_property_name,
293 "Object instance\'s name formatted for "
294 "assistive technology access",
297 g_object_class_install_property (gobject_class,
299 g_param_spec_string (atk_object_name_property_description,
300 "Accessible Description",
301 "Description of an object, formatted for "
302 "assistive technology access",
305 g_object_class_install_property (gobject_class,
307 g_param_spec_object (atk_object_name_property_parent,
309 "Is used to notify that the parent has changed ",
312 g_object_class_install_property (gobject_class,
314 g_param_spec_double (atk_object_name_property_value,
316 "Is used to notify that the value has changed ",
321 g_object_class_install_property (gobject_class,
323 g_param_spec_int (atk_object_name_property_role,
325 "The accessible role of this object ",
330 g_object_class_install_property (gobject_class,
332 g_param_spec_int (atk_object_name_property_component_layer,
334 "The accessible layer of this object ",
339 g_object_class_install_property (gobject_class,
341 g_param_spec_int (atk_object_name_property_component_mdi_zorder,
342 "Accessible MDI Value",
343 "The accessible MDI value of this object ",
348 g_object_class_install_property (gobject_class,
350 g_param_spec_string (atk_object_name_property_table_caption,
351 "Accessible Table Caption",
352 "Is used to notify that the table caption has changed; this property should not be used. accessible-table-caption-object should be used instead",
355 g_object_class_install_property (gobject_class,
356 PROP_TABLE_COLUMN_HEADER,
357 g_param_spec_object (atk_object_name_property_table_column_header,
358 "Accessible Table Column Header",
359 "Is used to notify that the table column header has changed ",
362 g_object_class_install_property (gobject_class,
363 PROP_TABLE_COLUMN_DESCRIPTION,
364 g_param_spec_string (atk_object_name_property_table_column_description,
365 "Accessible Table Column Description",
366 "Is used to notify that the table columnscription has changed ",
369 g_object_class_install_property (gobject_class,
370 PROP_TABLE_ROW_HEADER,
371 g_param_spec_object (atk_object_name_property_table_row_header,
372 "Accessible Table Row Header",
373 "Is used to notify that the table row header has changed ",
376 g_object_class_install_property (gobject_class,
377 PROP_TABLE_ROW_DESCRIPTION,
378 g_param_spec_string (atk_object_name_property_table_row_description,
379 "Accessible Table Row Description",
380 "Is used to notify that the table row description has changed ",
383 g_object_class_install_property (gobject_class,
385 g_param_spec_object (atk_object_name_property_table_summary,
386 "Accessible Table Summary",
387 "Is used to notify that the table summary has changed ",
390 g_object_class_install_property (gobject_class,
391 PROP_TABLE_CAPTION_OBJECT,
392 g_param_spec_object (atk_object_name_property_table_caption_object,
393 "Accessible Table Caption Object",
394 "Is used to notify that the table caption has changed ",
397 atk_object_signals[CHILDREN_CHANGED] =
398 g_signal_new ("children_changed",
399 G_TYPE_FROM_CLASS (klass),
400 G_SIGNAL_RUN_LAST | G_SIGNAL_DETAILED,
401 G_STRUCT_OFFSET (AtkObjectClass, children_changed),
403 g_cclosure_marshal_VOID__UINT_POINTER,
405 2, G_TYPE_UINT, G_TYPE_POINTER);
406 atk_object_signals[FOCUS_EVENT] =
407 g_signal_new ("focus_event",
408 G_TYPE_FROM_CLASS (klass),
410 G_STRUCT_OFFSET (AtkObjectClass, focus_event),
412 g_cclosure_marshal_VOID__BOOLEAN,
415 atk_object_signals[PROPERTY_CHANGE] =
416 g_signal_new ("property_change",
417 G_TYPE_FROM_CLASS (klass),
418 G_SIGNAL_RUN_LAST | G_SIGNAL_DETAILED,
419 G_STRUCT_OFFSET (AtkObjectClass, property_change),
420 (GSignalAccumulator) NULL, NULL,
421 g_cclosure_marshal_VOID__POINTER,
424 atk_object_signals[STATE_CHANGE] =
425 g_signal_new ("state_change",
426 G_TYPE_FROM_CLASS (klass),
427 G_SIGNAL_RUN_LAST | G_SIGNAL_DETAILED,
428 G_STRUCT_OFFSET (AtkObjectClass, state_change),
429 (GSignalAccumulator) NULL, NULL,
430 atk_marshal_VOID__STRING_BOOLEAN,
434 atk_object_signals[VISIBLE_DATA_CHANGED] =
435 g_signal_new ("visible_data_changed",
436 G_TYPE_FROM_CLASS (klass),
438 G_STRUCT_OFFSET (AtkObjectClass, visible_data_changed),
439 (GSignalAccumulator) NULL, NULL,
440 g_cclosure_marshal_VOID__VOID,
442 atk_object_signals[ACTIVE_DESCENDANT_CHANGED] =
443 g_signal_new ("active_descendant_changed",
444 G_TYPE_FROM_CLASS (klass),
445 G_SIGNAL_RUN_LAST | G_SIGNAL_DETAILED,
446 G_STRUCT_OFFSET (AtkObjectClass, active_descendant_changed),
448 g_cclosure_marshal_VOID__POINTER,
454 atk_object_init (AtkObject *accessible,
455 AtkObjectClass *klass)
457 accessible->name = NULL;
458 accessible->description = NULL;
459 accessible->accessible_parent = NULL;
460 accessible->relation_set = atk_relation_set_new();
461 accessible->role = ATK_ROLE_UNKNOWN;
465 atk_implementor_get_type (void)
467 static GType type = 0;
471 static const GTypeInfo typeInfo =
473 sizeof (AtkImplementorIface),
474 (GBaseInitFunc) NULL,
475 (GBaseFinalizeFunc) NULL,
478 type = g_type_register_static (G_TYPE_INTERFACE, "AtkImplementorIface", &typeInfo, 0) ;
485 * atk_object_get_name:
486 * @accessible: an #AtkObject
488 * Gets the accessible name of the accessible.
490 * Returns: a character string representing the accessible name of the object.
492 G_CONST_RETURN gchar*
493 atk_object_get_name (AtkObject *accessible)
495 AtkObjectClass *klass;
497 g_return_val_if_fail (ATK_IS_OBJECT (accessible), NULL);
499 klass = ATK_OBJECT_GET_CLASS (accessible);
501 return (klass->get_name) (accessible);
507 * atk_object_get_description:
508 * @accessible: an #AtkObject
510 * Gets the accessible description of the accessible.
512 * Returns: a character string representing the accessible description
516 G_CONST_RETURN gchar*
517 atk_object_get_description (AtkObject *accessible)
519 AtkObjectClass *klass;
521 g_return_val_if_fail (ATK_IS_OBJECT (accessible), NULL);
523 klass = ATK_OBJECT_GET_CLASS (accessible);
524 if (klass->get_description)
525 return (klass->get_description) (accessible);
531 * atk_object_get_parent:
532 * @accessible: an #AtkObject
534 * Gets the accessible parent of the accessible.
536 * Returns: a #AtkObject representing the accessible parent of the accessible
539 atk_object_get_parent (AtkObject *accessible)
541 AtkObjectClass *klass;
543 g_return_val_if_fail (ATK_IS_OBJECT (accessible), NULL);
545 klass = ATK_OBJECT_GET_CLASS (accessible);
546 if (klass->get_parent)
547 return (klass->get_parent) (accessible);
553 * atk_object_get_n_accessible_children:
554 * @accessible: an #AtkObject
556 * Gets the number of accessible children of the accessible.
558 * Returns: an integer representing the number of accessible children
562 atk_object_get_n_accessible_children (AtkObject *accessible)
564 AtkObjectClass *klass;
566 g_return_val_if_fail (ATK_IS_OBJECT (accessible), 0);
568 klass = ATK_OBJECT_GET_CLASS (accessible);
569 if (klass->get_n_children)
570 return (klass->get_n_children) (accessible);
576 * atk_object_ref_accessible_child:
577 * @accessible: an #AtkObject
578 * @i: a gint representing the position of the child, starting from 0
580 * Gets a reference to the specified accessible child of the object.
581 * The accessible children are 0-based so the first accessible child is
582 * at index 0, the second at index 1 and so on.
584 * Returns: an #AtkObject representing the specified accessible child
588 atk_object_ref_accessible_child (AtkObject *accessible,
591 AtkObjectClass *klass;
593 g_return_val_if_fail (ATK_IS_OBJECT (accessible), NULL);
595 klass = ATK_OBJECT_GET_CLASS (accessible);
596 if (klass->ref_child)
597 return (klass->ref_child) (accessible, i);
603 * atk_object_ref_relation_set:
604 * @accessible: an #AtkObject
606 * Gets the #AtkRelationSet associated with the object.
608 * Returns: an #AtkRelationSet representing the relation set of the object.
611 atk_object_ref_relation_set (AtkObject *accessible)
613 AtkObjectClass *klass;
615 g_return_val_if_fail (ATK_IS_OBJECT (accessible), NULL);
617 klass = ATK_OBJECT_GET_CLASS (accessible);
618 if (klass->ref_relation_set)
619 return (klass->ref_relation_set) (accessible);
626 * @name: a character string describing the new role.
628 * Registers the role specified by @name.
630 * Returns: an #AtkRole for the new role.
633 atk_role_register (const gchar *name)
636 extra_roles = g_ptr_array_new ();
638 g_ptr_array_add (extra_roles, g_strdup (name));
639 return extra_roles->len + ATK_ROLE_LAST_DEFINED;
643 * atk_object_get_role:
644 * @accessible: an #AtkObject
646 * Gets the role of the accessible.
648 * Returns: an #AtkRole which is the role of the accessible
651 atk_object_get_role (AtkObject *accessible)
653 AtkObjectClass *klass;
655 g_return_val_if_fail (ATK_IS_OBJECT (accessible), ATK_ROLE_UNKNOWN);
657 klass = ATK_OBJECT_GET_CLASS (accessible);
659 return (klass->get_role) (accessible);
661 return ATK_ROLE_UNKNOWN;
665 * atk_object_get_layer:
666 * @accessible: an #AtkObject
668 * Gets the layer of the accessible.
669 * DEPRECATED: use atk_component_get_layer instead!
671 * Returns: an #AtkLayer which is the layer of the accessible
674 atk_object_get_layer (AtkObject *accessible)
676 AtkObjectClass *klass;
678 g_return_val_if_fail (ATK_IS_OBJECT (accessible), ATK_LAYER_INVALID);
680 klass = ATK_OBJECT_GET_CLASS (accessible);
681 if (klass->get_layer)
682 return (klass->get_layer) (accessible);
684 return ATK_LAYER_INVALID;
688 * atk_object_get_mdi_zorder:
689 * @accessible: an #AtkObject
691 * Gets the zorder of the accessible. The value G_MININT will be returned
692 * if the layer of the accessible is not ATK_LAYER_MDI.
693 * DEPRECATED: use atk_component_get_mdi_zorder instead!
695 * Returns: a gint which is the zorder of the accessible, i.e. the depth at
696 * which the component is shown in relation to other components in the same
700 atk_object_get_mdi_zorder (AtkObject *accessible)
702 AtkObjectClass *klass;
704 g_return_val_if_fail (ATK_IS_OBJECT (accessible), G_MININT);
706 klass = ATK_OBJECT_GET_CLASS (accessible);
707 if (klass->get_mdi_zorder)
708 return (klass->get_mdi_zorder) (accessible);
714 * atk_object_ref_state_set:
715 * @accessible: an #AtkObject
717 * Gets a reference to the state set of the accessible; the caller must
718 * unreference it when it is no longer needed.
720 * Returns: a reference to an #AtkStateSet which is the state
721 * set of the accessible
724 atk_object_ref_state_set (AtkObject *accessible)
726 AtkObjectClass *klass;
728 g_return_val_if_fail (ATK_IS_OBJECT (accessible), NULL);
730 klass = ATK_OBJECT_GET_CLASS (accessible);
731 if (klass->ref_state_set)
732 return (klass->ref_state_set) (accessible);
738 * atk_object_get_index_in_parent:
739 * @accessible: an #AtkObject
741 * Gets the 0-based index of this accessible in its parent; returns -1 if the
742 * accessible does not have an accessible parent.
744 * Returns: an integer which is the index of the accessible in its parent
747 atk_object_get_index_in_parent (AtkObject *accessible)
749 AtkObjectClass *klass;
751 g_return_val_if_fail (ATK_OBJECT (accessible), -1);
753 klass = ATK_OBJECT_GET_CLASS (accessible);
754 if (klass->get_index_in_parent)
755 return (klass->get_index_in_parent) (accessible);
761 * atk_object_set_name:
762 * @accessible: an #AtkObject
763 * @name: a character string to be set as the accessible name
765 * Sets the accessible name of the accessible.
768 atk_object_set_name (AtkObject *accessible,
771 AtkObjectClass *klass;
773 g_return_if_fail (ATK_IS_OBJECT (accessible));
774 g_return_if_fail (name != NULL);
776 klass = ATK_OBJECT_GET_CLASS (accessible);
779 (klass->set_name) (accessible, name);
780 g_object_notify (G_OBJECT (accessible), atk_object_name_property_name);
785 * atk_object_set_description:
786 * @accessible: an #AtkObject
787 * @description : a character string to be set as the accessible description
789 * Sets the accessible description of the accessible.
792 atk_object_set_description (AtkObject *accessible,
793 const gchar *description)
795 AtkObjectClass *klass;
797 g_return_if_fail (ATK_IS_OBJECT (accessible));
798 g_return_if_fail (description != NULL);
800 klass = ATK_OBJECT_GET_CLASS (accessible);
801 if (klass->set_description)
803 (klass->set_description) (accessible, description);
804 g_object_notify (G_OBJECT (accessible), atk_object_name_property_description);
809 * atk_object_set_parent:
810 * @accessible: an #AtkObject
811 * @parent : an #AtkObject to be set as the accessible parent
813 * Sets the accessible parent of the accessible.
816 atk_object_set_parent (AtkObject *accessible,
819 AtkObjectClass *klass;
821 g_return_if_fail (ATK_IS_OBJECT (accessible));
823 klass = ATK_OBJECT_GET_CLASS (accessible);
824 if (klass->set_parent)
826 (klass->set_parent) (accessible, parent);
827 g_object_notify (G_OBJECT (accessible), atk_object_name_property_parent);
832 * atk_object_set_role:
833 * @accessible: an #AtkObject
834 * @role : an #AtkRole to be set as the role
836 * Sets the role of the accessible.
839 atk_object_set_role (AtkObject *accessible,
842 AtkObjectClass *klass;
845 g_return_if_fail (ATK_IS_OBJECT (accessible));
847 klass = ATK_OBJECT_GET_CLASS (accessible);
850 old_role = atk_object_get_role (accessible);
851 if (old_role != role)
853 (klass->set_role) (accessible, role);
854 if (old_role != ATK_ROLE_UNKNOWN)
855 /* Do not notify for initial role setting */
856 g_object_notify (G_OBJECT (accessible), atk_object_name_property_role);
862 * atk_object_connect_property_change_handler:
863 * @accessible: an #AtkObject
864 * @handler : a function to be called when a property changes its value
866 * Specifies a function to be called when a property changes value.
868 * Returns: a #guint which is the handler id used in
869 * atk_object_remove_property_change_handler()
872 atk_object_connect_property_change_handler (AtkObject *accessible,
873 AtkPropertyChangeHandler *handler)
875 AtkObjectClass *klass;
877 g_return_val_if_fail (ATK_IS_OBJECT (accessible), 0);
878 g_return_val_if_fail ((handler != NULL), 0);
880 klass = ATK_OBJECT_GET_CLASS (accessible);
881 if (klass->connect_property_change_handler)
882 return (klass->connect_property_change_handler) (accessible, handler);
888 * atk_object_remove_property_change_handler:
889 * @accessible: an #AtkObject
890 * @handler_id : a guint which identifies the handler to be removed.
892 * Removes a property change handler.
895 atk_object_remove_property_change_handler (AtkObject *accessible,
898 AtkObjectClass *klass;
900 g_return_if_fail (ATK_IS_OBJECT (accessible));
902 klass = ATK_OBJECT_GET_CLASS (accessible);
903 if (klass->remove_property_change_handler)
904 (klass->remove_property_change_handler) (accessible, handler_id);
908 * atk_object_notify_state_change:
909 * @accessible: an #AtkObject
910 * @state: an #AtkState whose state is changed
911 * @value : a gboolean which indicates whether the state is being set on or off
913 * Emits a state-change signal for the specified state.
916 atk_object_notify_state_change (AtkObject *accessible,
920 G_CONST_RETURN gchar* name;
922 name = atk_state_type_get_name (state);
923 g_signal_emit (accessible, atk_object_signals[STATE_CHANGE],
924 g_quark_from_string (name),
929 * atk_implementor_ref_accessible:
930 * @implementor: The #GObject instance which should implement #AtkImplementorIface
931 * if a non-null return value is required.
933 * Gets a reference to an object's #AtkObject implementation, if
934 * the object implements #AtkObjectIface
936 * Returns: a reference to an object's #AtkObject implementation
939 atk_implementor_ref_accessible (AtkImplementor *object)
941 AtkImplementorIface *iface;
942 AtkObject *accessible = NULL;
944 g_return_val_if_fail (ATK_IS_IMPLEMENTOR (object), NULL);
946 iface = ATK_IMPLEMENTOR_GET_IFACE (object);
949 accessible = iface->ref_accessible (object);
951 g_return_val_if_fail ((accessible != NULL), NULL);
956 static AtkRelationSet*
957 atk_object_real_ref_relation_set (AtkObject *accessible)
959 g_return_val_if_fail (accessible->relation_set, NULL);
960 g_object_ref (accessible->relation_set);
962 return accessible->relation_set;
966 atk_object_real_set_property (GObject *object,
971 AtkObject *accessible;
973 accessible = ATK_OBJECT (object);
978 atk_object_set_name (accessible, g_value_get_string (value));
980 case PROP_DESCRIPTION:
981 atk_object_set_description (accessible, g_value_get_string (value));
984 atk_object_set_role (accessible, g_value_get_int (value));
987 atk_object_set_parent (accessible, g_value_get_object (value));
990 if (ATK_IS_VALUE (accessible))
991 atk_value_set_current_value (ATK_VALUE (accessible), value);
993 case PROP_TABLE_SUMMARY:
994 if (ATK_IS_TABLE (accessible))
995 atk_table_set_summary (ATK_TABLE (accessible), g_value_get_object (value));
997 case PROP_TABLE_CAPTION_OBJECT:
998 if (ATK_IS_TABLE (accessible))
999 atk_table_set_caption (ATK_TABLE (accessible), g_value_get_object (value));
1007 atk_object_real_get_property (GObject *object,
1012 AtkObject *accessible;
1014 accessible = ATK_OBJECT (object);
1019 g_value_set_string (value, atk_object_get_name (accessible));
1021 case PROP_DESCRIPTION:
1022 g_value_set_string (value, atk_object_get_description (accessible));
1025 g_value_set_int (value, atk_object_get_role (accessible));
1028 if (ATK_IS_COMPONENT (accessible))
1029 g_value_set_int (value, atk_component_get_layer (ATK_COMPONENT (accessible)));
1031 case PROP_MDI_ZORDER:
1032 if (ATK_IS_COMPONENT (accessible))
1033 g_value_set_int (value, atk_component_get_mdi_zorder (ATK_COMPONENT (accessible)));
1036 g_value_set_object (value, atk_object_get_parent (accessible));
1039 if (ATK_IS_VALUE (accessible))
1040 atk_value_get_current_value (ATK_VALUE (accessible), value);
1042 case PROP_TABLE_SUMMARY:
1043 if (ATK_IS_TABLE (accessible))
1044 g_value_set_object (value, atk_table_get_summary (ATK_TABLE (accessible)));
1046 case PROP_TABLE_CAPTION_OBJECT:
1047 if (ATK_IS_TABLE (accessible))
1048 g_value_set_object (value, atk_table_get_caption (ATK_TABLE (accessible)));
1051 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
1057 atk_object_finalize (GObject *object)
1059 AtkObject *accessible;
1061 g_return_if_fail (ATK_IS_OBJECT (object));
1063 accessible = ATK_OBJECT (object);
1065 g_free (accessible->name);
1066 g_free (accessible->description);
1069 * Free memory allocated for relation set if it have been allocated.
1071 if (accessible->relation_set)
1072 g_object_unref (accessible->relation_set);
1074 if (accessible->accessible_parent)
1075 g_object_unref (accessible->accessible_parent);
1077 G_OBJECT_CLASS (parent_class)->finalize (object);
1080 static G_CONST_RETURN gchar*
1081 atk_object_real_get_name (AtkObject *object)
1083 return object->name;
1086 static G_CONST_RETURN gchar*
1087 atk_object_real_get_description (AtkObject *object)
1089 return object->description;
1093 atk_object_real_get_parent (AtkObject *object)
1095 return object->accessible_parent;
1099 atk_object_real_get_role (AtkObject *object)
1101 return object->role;
1105 atk_object_real_get_layer (AtkObject *object)
1107 return object->layer;
1111 atk_object_real_ref_state_set (AtkObject *accessible)
1113 AtkStateSet *state_set;
1116 state_set = atk_state_set_new ();
1118 ap = atk_object_get_parent (accessible);
1120 if (ATK_IS_SELECTION (ap))
1124 atk_state_set_add_state (state_set, ATK_STATE_SELECTABLE);
1126 i = atk_object_get_index_in_parent (accessible);
1128 if (atk_selection_is_child_selected(ATK_SELECTION (ap), i))
1129 atk_state_set_add_state (state_set, ATK_STATE_SELECTED);
1136 atk_object_real_set_name (AtkObject *object,
1139 g_free (object->name);
1140 object->name = g_strdup (name);
1144 atk_object_real_set_description (AtkObject *object,
1145 const gchar *description)
1147 g_free (object->description);
1148 object->description = g_strdup (description);
1152 atk_object_real_set_parent (AtkObject *object,
1155 if (object->accessible_parent)
1156 g_object_unref (object->accessible_parent);
1158 object->accessible_parent = parent;
1159 if (object->accessible_parent)
1160 g_object_ref (object->accessible_parent);
1164 atk_object_real_set_role (AtkObject *object,
1167 object->role = role;
1171 atk_object_real_connect_property_change_handler (AtkObject *obj,
1172 AtkPropertyChangeHandler *handler)
1174 return g_signal_connect_closure_by_id (obj,
1175 atk_object_signals[PROPERTY_CHANGE],
1178 G_CALLBACK (handler), NULL,
1179 (GClosureNotify) NULL),
1184 atk_object_real_remove_property_change_handler (AtkObject *obj,
1187 g_signal_handler_disconnect (obj, handler_id);
1191 * atk_object_initialize:
1192 * @accessible: a #AtkObject
1193 * @data: a #gpointer which identifies the object for which the AtkObject was created.
1195 * This function is called when implementing subclasses of #AtkObject.
1196 * It does initialization required for the new object. It is intended
1197 * that this function should called only in the ..._new() functions used
1198 * to create an instance of a subclass of #AtkObject
1201 atk_object_initialize (AtkObject *accessible,
1204 AtkObjectClass *klass;
1206 g_return_if_fail (ATK_IS_OBJECT (accessible));
1208 klass = ATK_OBJECT_GET_CLASS (accessible);
1209 if (klass->initialize)
1210 klass->initialize (accessible, data);
1214 * This function is a signal handler for notify signal which gets emitted
1215 * when a property changes value.
1217 * It constructs an AtkPropertyValues structure and emits a "property_changed"
1218 * signal which causes the user specified AtkPropertyChangeHandler
1222 atk_object_notify (GObject *obj,
1225 AtkPropertyValues values = { 0, };
1227 g_value_init (&values.new_value, pspec->value_type);
1228 g_object_get_property (obj, pspec->name, &values.new_value);
1229 values.property_name = pspec->name;
1230 g_signal_emit (obj, atk_object_signals[PROPERTY_CHANGE],
1231 g_quark_from_string (pspec->name),
1233 g_value_unset (&values.new_value);
1237 * atk_role_get_name:
1238 * @role: The #AtkRole whose name is required
1240 * Gets the description string describing the #AtkRole @role.
1242 * Returns: the string describing the AtkRole
1244 G_CONST_RETURN gchar*
1245 atk_role_get_name (AtkRole role)
1250 for (i = 0; i < G_N_ELEMENTS (role_items); i++)
1252 if (role == role_items[i].role)
1253 return role_items[i].name;
1260 n -= ATK_ROLE_LAST_DEFINED + 1;
1262 if (n < extra_roles->len)
1263 name = g_ptr_array_index (extra_roles, n);
1272 #define ATKLOCALEDIR get_atk_locale_dir()
1274 G_WIN32_DLLMAIN_FOR_DLL_NAME(static, dll_name)
1277 get_atk_locale_dir (void)
1279 return g_win32_get_package_installation_subdirectory
1280 (GETTEXT_PACKAGE, dll_name, "lib/locale");
1286 * atk_role_get_localized_name:
1287 * @role: The #AtkRole whose localized name is required
1289 * Gets the localized description string describing the #AtkRole @role.
1291 * Returns: the localized string describing the AtkRole
1293 G_CONST_RETURN gchar*
1294 atk_role_get_localized_name (AtkRole role)
1296 G_CONST_RETURN gchar *name;
1298 static gboolean gettext_initialized = FALSE;
1301 if (!gettext_initialized)
1303 gettext_initialized = TRUE;
1305 bindtextdomain (GETTEXT_PACKAGE, ATKLOCALEDIR);
1306 #ifdef HAVE_BIND_TEXTDOMAIN_CODESET
1307 bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
1312 for (i = 0; i < G_N_ELEMENTS (role_items); i++)
1314 if (role == role_items[i].role)
1315 return dgettext (GETTEXT_PACKAGE, role_items[i].name);
1317 name = atk_role_get_name (role);
1323 * atk_role_for_name:
1324 * @name: a string which is the (non-localized) name of an ATK role.
1326 * Get the #AtkRole type corresponding to a rolew name.
1328 * Returns: the #AtkRole enumerated type corresponding to the specified
1330 * or #ATK_ROLE_INVALID if no matching role is found.
1333 atk_role_for_name (const gchar *name)
1335 AtkRole role = ATK_ROLE_INVALID;
1338 g_return_val_if_fail (name, ATK_ROLE_INVALID);
1340 for (i = 0; i < G_N_ELEMENTS (role_items); i++)
1342 if (strcmp (name, role_items[i].name) == 0)
1343 return role_items[i].role;
1348 for (i = 0; i < extra_roles->len; i++)
1350 gchar *extra_role = (gchar *)g_ptr_array_index (extra_roles, i);
1352 g_return_val_if_fail (extra_role, ATK_ROLE_INVALID);
1354 if (strcmp (name, extra_role) == 0)
1356 role = i + 1 + ATK_ROLE_LAST_DEFINED;
1366 * atk_object_add_relationship:
1367 * @object: The #AtkObject to which an AtkRelation is to be added.
1368 * @relationship: The #AtkRelationType of the relation
1369 * @target: The #AtkObject which is to be the target of the relation.
1371 * Adds a relationship of the specified type with the specified target.
1373 * Returns TRUE if the relationship is added.
1376 atk_object_add_relationship (AtkObject *object,
1377 AtkRelationType relationship,
1380 AtkObject *array[1];
1381 AtkRelation *relation;
1383 g_return_val_if_fail (ATK_IS_OBJECT (object), FALSE);
1384 g_return_val_if_fail (ATK_IS_OBJECT (target), FALSE);
1387 relation = atk_relation_new (array, 1, relationship);
1388 atk_relation_set_add (object->relation_set, relation);
1389 g_object_unref (relation);
1395 * atk_object_remove_relationship:
1396 * @object: The #AtkObject from which an AtkRelation is to be removed.
1397 * @relationship: The #AtkRelationType of the relation
1398 * @target: The #AtkObject which is the target of the relation to be removed.
1400 * Removes a relationship of the specified type with the specified target.
1402 * Returns TRUE if the relationship is removed.
1405 atk_object_remove_relationship (AtkObject *object,
1406 AtkRelationType relationship,
1409 gint n_relations, i;
1410 gboolean ret = FALSE;
1411 AtkRelation *relation;
1413 g_return_val_if_fail (ATK_IS_OBJECT (object), FALSE);
1414 g_return_val_if_fail (ATK_IS_OBJECT (target), FALSE);
1416 n_relations = atk_relation_set_get_n_relations (object->relation_set);
1417 for (i = 0; i < n_relations; i++)
1419 relation = atk_relation_set_get_relation (object->relation_set, i);
1420 if (atk_relation_get_relation_type (relation) == relationship)
1424 array = atk_relation_get_target (relation);
1426 if (g_ptr_array_index (array, 0) == target)
1428 atk_relation_set_remove (object->relation_set, relation);
1439 atk_object_real_initialize (AtkObject *accessible,