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 static void atk_object_class_init (AtkObjectClass *klass);
72 static void atk_object_init (AtkObject *accessible,
73 AtkObjectClass *klass);
74 static AtkRelationSet* atk_object_real_ref_relation_set
75 (AtkObject *accessible);
76 static void atk_object_real_initialize (AtkObject *accessible,
78 static void atk_object_real_set_property (GObject *object,
82 static void atk_object_real_get_property (GObject *object,
86 static void atk_object_finalize (GObject *object);
87 static G_CONST_RETURN gchar*
88 atk_object_real_get_name (AtkObject *object);
89 static G_CONST_RETURN gchar*
90 atk_object_real_get_description
92 static AtkObject* atk_object_real_get_parent (AtkObject *object);
93 static AtkRole atk_object_real_get_role (AtkObject *object);
94 static AtkLayer atk_object_real_get_layer (AtkObject *object);
95 static AtkStateSet* atk_object_real_ref_state_set
97 static void atk_object_real_set_name (AtkObject *object,
99 static void atk_object_real_set_description
101 const gchar *description);
102 static void atk_object_real_set_parent (AtkObject *object,
104 static void atk_object_real_set_role (AtkObject *object,
106 static guint atk_object_real_connect_property_change_handler
108 AtkPropertyChangeHandler
110 static void atk_object_real_remove_property_change_handler
113 static void atk_object_notify (GObject *obj,
117 static guint atk_object_signals[LAST_SIGNAL] = { 0, };
119 static gpointer parent_class = NULL;
121 static const gchar* atk_object_name_property_name = "accessible-name";
122 static const gchar* atk_object_name_property_description = "accessible-description";
123 static const gchar* atk_object_name_property_parent = "accessible-parent";
124 static const gchar* atk_object_name_property_value = "accessible-value";
125 static const gchar* atk_object_name_property_role = "accessible-role";
126 static const gchar* atk_object_name_property_component_layer = "accessible-component-layer";
127 static const gchar* atk_object_name_property_component_mdi_zorder = "accessible-component-mdi-zorder";
128 static const gchar* atk_object_name_property_table_caption = "accessible-table-caption";
129 static const gchar* atk_object_name_property_table_column_description = "accessible-table-column-description";
130 static const gchar* atk_object_name_property_table_column_header = "accessible-table-column-header";
131 static const gchar* atk_object_name_property_table_row_description = "accessible-table-row-description";
132 static const gchar* atk_object_name_property_table_row_header = "accessible-table-row-header";
133 static const gchar* atk_object_name_property_table_summary = "accessible-table-summary";
134 static const gchar* atk_object_name_property_table_caption_object = "accessible-table-caption-object";
137 atk_object_get_type (void)
139 static GType type = 0;
143 static const GTypeInfo typeInfo =
145 sizeof (AtkObjectClass),
146 (GBaseInitFunc) NULL,
147 (GBaseFinalizeFunc) NULL,
148 (GClassInitFunc) atk_object_class_init,
149 (GClassFinalizeFunc) NULL,
153 (GInstanceInitFunc) atk_object_init,
155 type = g_type_register_static (G_TYPE_OBJECT, "AtkObject", &typeInfo, 0) ;
161 atk_object_class_init (AtkObjectClass *klass)
163 GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
165 parent_class = g_type_class_peek_parent (klass);
167 gobject_class->set_property = atk_object_real_set_property;
168 gobject_class->get_property = atk_object_real_get_property;
169 gobject_class->finalize = atk_object_finalize;
170 gobject_class->notify = atk_object_notify;
172 klass->get_name = atk_object_real_get_name;
173 klass->get_description = atk_object_real_get_description;
174 klass->get_parent = atk_object_real_get_parent;
175 klass->get_n_children = NULL;
176 klass->ref_child = NULL;
177 klass->get_index_in_parent = NULL;
178 klass->ref_relation_set = atk_object_real_ref_relation_set;
179 klass->get_role = atk_object_real_get_role;
180 klass->get_layer = atk_object_real_get_layer;
181 klass->get_mdi_zorder = NULL;
182 klass->initialize = atk_object_real_initialize;
183 klass->ref_state_set = atk_object_real_ref_state_set;
184 klass->set_name = atk_object_real_set_name;
185 klass->set_description = atk_object_real_set_description;
186 klass->set_parent = atk_object_real_set_parent;
187 klass->set_role = atk_object_real_set_role;
188 klass->connect_property_change_handler =
189 atk_object_real_connect_property_change_handler;
190 klass->remove_property_change_handler =
191 atk_object_real_remove_property_change_handler;
194 * We do not define default signal handlers here
196 klass->children_changed = NULL;
197 klass->focus_event = NULL;
198 klass->property_change = NULL;
199 klass->visible_data_changed = NULL;
200 klass->active_descendant_changed = NULL;
202 g_object_class_install_property (gobject_class,
204 g_param_spec_string (atk_object_name_property_name,
206 "Object instance\'s name formatted for "
207 "assistive technology access",
210 g_object_class_install_property (gobject_class,
212 g_param_spec_string (atk_object_name_property_description,
213 "Accessible Description",
214 "Description of an object, formatted for "
215 "assistive technology access",
218 g_object_class_install_property (gobject_class,
220 g_param_spec_object (atk_object_name_property_parent,
222 "Is used to notify that the parent has changed ",
225 g_object_class_install_property (gobject_class,
227 g_param_spec_double (atk_object_name_property_value,
229 "Is used to notify that the value has changed ",
234 g_object_class_install_property (gobject_class,
236 g_param_spec_int (atk_object_name_property_role,
238 "The accessible role of this object ",
243 g_object_class_install_property (gobject_class,
245 g_param_spec_int (atk_object_name_property_component_layer,
247 "The accessible layer of this object ",
252 g_object_class_install_property (gobject_class,
254 g_param_spec_int (atk_object_name_property_component_mdi_zorder,
255 "Accessible MDI Value",
256 "The accessible MDI value of this object ",
261 g_object_class_install_property (gobject_class,
263 g_param_spec_string (atk_object_name_property_table_caption,
264 "Accessible Table Caption",
265 "Is used to notify that the table caption has changed; this property should not be used. accessible-table-caption-object should be used instead",
268 g_object_class_install_property (gobject_class,
269 PROP_TABLE_COLUMN_HEADER,
270 g_param_spec_object (atk_object_name_property_table_column_header,
271 "Accessible Table Column Header",
272 "Is used to notify that the table column header has changed ",
275 g_object_class_install_property (gobject_class,
276 PROP_TABLE_COLUMN_DESCRIPTION,
277 g_param_spec_string (atk_object_name_property_table_column_description,
278 "Accessible Table Column Description",
279 "Is used to notify that the table columnscription has changed ",
282 g_object_class_install_property (gobject_class,
283 PROP_TABLE_ROW_HEADER,
284 g_param_spec_object (atk_object_name_property_table_row_header,
285 "Accessible Table Row Header",
286 "Is used to notify that the table row header has changed ",
289 g_object_class_install_property (gobject_class,
290 PROP_TABLE_ROW_DESCRIPTION,
291 g_param_spec_string (atk_object_name_property_table_row_description,
292 "Accessible Table Row Description",
293 "Is used to notify that the table row description has changed ",
296 g_object_class_install_property (gobject_class,
298 g_param_spec_object (atk_object_name_property_table_summary,
299 "Accessible Table Summary",
300 "Is used to notify that the table summary has changed ",
303 g_object_class_install_property (gobject_class,
304 PROP_TABLE_CAPTION_OBJECT,
305 g_param_spec_object (atk_object_name_property_table_caption_object,
306 "Accessible Table Caption Object",
307 "Is used to notify that the table caption has changed ",
311 * The signal "children_changed" supports two details:
314 atk_object_signals[CHILDREN_CHANGED] =
315 g_signal_new ("children_changed",
316 G_TYPE_FROM_CLASS (klass),
317 G_SIGNAL_RUN_LAST | G_SIGNAL_DETAILED,
318 G_STRUCT_OFFSET (AtkObjectClass, children_changed),
320 g_cclosure_marshal_VOID__UINT_POINTER,
322 2, G_TYPE_UINT, G_TYPE_POINTER);
323 atk_object_signals[FOCUS_EVENT] =
324 g_signal_new ("focus_event",
325 G_TYPE_FROM_CLASS (klass),
327 G_STRUCT_OFFSET (AtkObjectClass, focus_event),
329 g_cclosure_marshal_VOID__BOOLEAN,
332 atk_object_signals[PROPERTY_CHANGE] =
333 g_signal_new ("property_change",
334 G_TYPE_FROM_CLASS (klass),
335 G_SIGNAL_RUN_LAST | G_SIGNAL_DETAILED,
336 G_STRUCT_OFFSET (AtkObjectClass, property_change),
337 (GSignalAccumulator) NULL, NULL,
338 g_cclosure_marshal_VOID__POINTER,
342 * The "state_change" signal supports details, one for each accessible
346 atk_object_signals[STATE_CHANGE] =
347 g_signal_new ("state_change",
348 G_TYPE_FROM_CLASS (klass),
349 G_SIGNAL_RUN_LAST | G_SIGNAL_DETAILED,
350 G_STRUCT_OFFSET (AtkObjectClass, state_change),
351 (GSignalAccumulator) NULL, NULL,
352 atk_marshal_VOID__STRING_BOOLEAN,
356 atk_object_signals[VISIBLE_DATA_CHANGED] =
357 g_signal_new ("visible_data_changed",
358 G_TYPE_FROM_CLASS (klass),
360 G_STRUCT_OFFSET (AtkObjectClass, visible_data_changed),
361 (GSignalAccumulator) NULL, NULL,
362 g_cclosure_marshal_VOID__VOID,
364 atk_object_signals[ACTIVE_DESCENDANT_CHANGED] =
365 g_signal_new ("active_descendant_changed",
366 G_TYPE_FROM_CLASS (klass),
367 G_SIGNAL_RUN_LAST | G_SIGNAL_DETAILED,
368 G_STRUCT_OFFSET (AtkObjectClass, active_descendant_changed),
370 g_cclosure_marshal_VOID__POINTER,
376 atk_object_init (AtkObject *accessible,
377 AtkObjectClass *klass)
379 accessible->name = NULL;
380 accessible->description = NULL;
381 accessible->accessible_parent = NULL;
382 accessible->relation_set = atk_relation_set_new();
383 accessible->role = ATK_ROLE_UNKNOWN;
387 atk_implementor_get_type (void)
389 static GType type = 0;
393 static const GTypeInfo typeInfo =
395 sizeof (AtkImplementorIface),
396 (GBaseInitFunc) NULL,
397 (GBaseFinalizeFunc) NULL,
400 type = g_type_register_static (G_TYPE_INTERFACE, "AtkImplementorIface", &typeInfo, 0) ;
407 * atk_object_get_name:
408 * @accessible: an #AtkObject
410 * Gets the accessible name of the accessible.
412 * Returns: a character string representing the accessible name of the object.
414 G_CONST_RETURN gchar*
415 atk_object_get_name (AtkObject *accessible)
417 AtkObjectClass *klass;
419 g_return_val_if_fail (ATK_IS_OBJECT (accessible), NULL);
421 klass = ATK_OBJECT_GET_CLASS (accessible);
423 return (klass->get_name) (accessible);
429 * atk_object_get_description:
430 * @accessible: an #AtkObject
432 * Gets the accessible description of the accessible.
434 * Returns: a character string representing the accessible description
438 G_CONST_RETURN gchar*
439 atk_object_get_description (AtkObject *accessible)
441 AtkObjectClass *klass;
443 g_return_val_if_fail (ATK_IS_OBJECT (accessible), NULL);
445 klass = ATK_OBJECT_GET_CLASS (accessible);
446 if (klass->get_description)
447 return (klass->get_description) (accessible);
453 * atk_object_get_parent:
454 * @accessible: an #AtkObject
456 * Gets the accessible parent of the accessible.
458 * Returns: a #AtkObject representing the accessible parent of the accessible
461 atk_object_get_parent (AtkObject *accessible)
463 AtkObjectClass *klass;
465 g_return_val_if_fail (ATK_IS_OBJECT (accessible), NULL);
467 klass = ATK_OBJECT_GET_CLASS (accessible);
468 if (klass->get_parent)
469 return (klass->get_parent) (accessible);
475 * atk_object_get_n_accessible_children:
476 * @accessible: an #AtkObject
478 * Gets the number of accessible children of the accessible.
480 * Returns: an integer representing the number of accessible children
484 atk_object_get_n_accessible_children (AtkObject *accessible)
486 AtkObjectClass *klass;
488 g_return_val_if_fail (ATK_IS_OBJECT (accessible), 0);
490 klass = ATK_OBJECT_GET_CLASS (accessible);
491 if (klass->get_n_children)
492 return (klass->get_n_children) (accessible);
498 * atk_object_ref_accessible_child:
499 * @accessible: an #AtkObject
500 * @i: a gint representing the position of the child, starting from 0
502 * Gets a reference to the specified accessible child of the object.
503 * The accessible children are 0-based so the first accessible child is
504 * at index 0, the second at index 1 and so on.
506 * Returns: an #AtkObject representing the specified accessible child
510 atk_object_ref_accessible_child (AtkObject *accessible,
513 AtkObjectClass *klass;
515 g_return_val_if_fail (ATK_IS_OBJECT (accessible), NULL);
517 klass = ATK_OBJECT_GET_CLASS (accessible);
518 if (klass->ref_child)
519 return (klass->ref_child) (accessible, i);
525 * atk_object_ref_relation_set:
526 * @accessible: an #AtkObject
528 * Gets the #AtkRelationSet associated with the object.
530 * Returns: an #AtkRelationSet representing the relation set of the object.
533 atk_object_ref_relation_set (AtkObject *accessible)
535 AtkObjectClass *klass;
537 g_return_val_if_fail (ATK_IS_OBJECT (accessible), NULL);
539 klass = ATK_OBJECT_GET_CLASS (accessible);
540 if (klass->ref_relation_set)
541 return (klass->ref_relation_set) (accessible);
548 * @name: a character string describing the new role.
550 * Registers the role specified by @name.
552 * Returns: an #AtkRole for the new role.
555 atk_role_register (const gchar *name)
558 extra_roles = g_ptr_array_new ();
560 g_ptr_array_add (extra_roles, g_strdup (name));
561 return extra_roles->len + ATK_ROLE_LAST_DEFINED;
565 * atk_object_get_role:
566 * @accessible: an #AtkObject
568 * Gets the role of the accessible.
570 * Returns: an #AtkRole which is the role of the accessible
573 atk_object_get_role (AtkObject *accessible)
575 AtkObjectClass *klass;
577 g_return_val_if_fail (ATK_IS_OBJECT (accessible), ATK_ROLE_UNKNOWN);
579 klass = ATK_OBJECT_GET_CLASS (accessible);
581 return (klass->get_role) (accessible);
583 return ATK_ROLE_UNKNOWN;
587 * atk_object_get_layer:
588 * @accessible: an #AtkObject
590 * Gets the layer of the accessible.
591 * DEPRECATED: use atk_component_get_layer instead!
593 * Returns: an #AtkLayer which is the layer of the accessible
596 atk_object_get_layer (AtkObject *accessible)
598 AtkObjectClass *klass;
600 g_return_val_if_fail (ATK_IS_OBJECT (accessible), ATK_LAYER_INVALID);
602 klass = ATK_OBJECT_GET_CLASS (accessible);
603 if (klass->get_layer)
604 return (klass->get_layer) (accessible);
606 return ATK_LAYER_INVALID;
610 * atk_object_get_mdi_zorder:
611 * @accessible: an #AtkObject
613 * Gets the zorder of the accessible. The value G_MININT will be returned
614 * if the layer of the accessible is not ATK_LAYER_MDI.
615 * DEPRECATED: use atk_component_get_mdi_zorder instead!
617 * Returns: a gint which is the zorder of the accessible, i.e. the depth at
618 * which the component is shown in relation to other components in the same
622 atk_object_get_mdi_zorder (AtkObject *accessible)
624 AtkObjectClass *klass;
626 g_return_val_if_fail (ATK_IS_OBJECT (accessible), G_MININT);
628 klass = ATK_OBJECT_GET_CLASS (accessible);
629 if (klass->get_mdi_zorder)
630 return (klass->get_mdi_zorder) (accessible);
636 * atk_object_ref_state_set:
637 * @accessible: an #AtkObject
639 * Gets a reference to the state set of the accessible; the caller must
640 * unreference it when it is no longer needed.
642 * Returns: a reference to an #AtkStateSet which is the state
643 * set of the accessible
646 atk_object_ref_state_set (AtkObject *accessible)
648 AtkObjectClass *klass;
650 g_return_val_if_fail (ATK_IS_OBJECT (accessible), NULL);
652 klass = ATK_OBJECT_GET_CLASS (accessible);
653 if (klass->ref_state_set)
654 return (klass->ref_state_set) (accessible);
660 * atk_object_get_index_in_parent:
661 * @accessible: an #AtkObject
663 * Gets the 0-based index of this accessible in its parent; returns -1 if the
664 * accessible does not have an accessible parent.
666 * Returns: an integer which is the index of the accessible in its parent
669 atk_object_get_index_in_parent (AtkObject *accessible)
671 AtkObjectClass *klass;
673 g_return_val_if_fail (ATK_OBJECT (accessible), -1);
675 klass = ATK_OBJECT_GET_CLASS (accessible);
676 if (klass->get_index_in_parent)
677 return (klass->get_index_in_parent) (accessible);
683 * atk_object_set_name:
684 * @accessible: an #AtkObject
685 * @name: a character string to be set as the accessible name
687 * Sets the accessible name of the accessible.
690 atk_object_set_name (AtkObject *accessible,
693 AtkObjectClass *klass;
695 g_return_if_fail (ATK_IS_OBJECT (accessible));
696 g_return_if_fail (name != NULL);
698 klass = ATK_OBJECT_GET_CLASS (accessible);
701 (klass->set_name) (accessible, name);
702 g_object_notify (G_OBJECT (accessible), atk_object_name_property_name);
707 * atk_object_set_description:
708 * @accessible: an #AtkObject
709 * @description : a character string to be set as the accessible description
711 * Sets the accessible description of the accessible.
714 atk_object_set_description (AtkObject *accessible,
715 const gchar *description)
717 AtkObjectClass *klass;
719 g_return_if_fail (ATK_IS_OBJECT (accessible));
720 g_return_if_fail (description != NULL);
722 klass = ATK_OBJECT_GET_CLASS (accessible);
723 if (klass->set_description)
725 (klass->set_description) (accessible, description);
726 g_object_notify (G_OBJECT (accessible), atk_object_name_property_description);
731 * atk_object_set_parent:
732 * @accessible: an #AtkObject
733 * @parent : an #AtkObject to be set as the accessible parent
735 * Sets the accessible parent of the accessible.
738 atk_object_set_parent (AtkObject *accessible,
741 AtkObjectClass *klass;
743 g_return_if_fail (ATK_IS_OBJECT (accessible));
745 klass = ATK_OBJECT_GET_CLASS (accessible);
746 if (klass->set_parent)
748 (klass->set_parent) (accessible, parent);
749 g_object_notify (G_OBJECT (accessible), atk_object_name_property_parent);
754 * atk_object_set_role:
755 * @accessible: an #AtkObject
756 * @role : an #AtkRole to be set as the role
758 * Sets the role of the accessible.
761 atk_object_set_role (AtkObject *accessible,
764 AtkObjectClass *klass;
766 g_return_if_fail (ATK_IS_OBJECT (accessible));
768 klass = ATK_OBJECT_GET_CLASS (accessible);
771 (klass->set_role) (accessible, role);
772 g_object_notify (G_OBJECT (accessible), atk_object_name_property_role);
777 * atk_object_connect_property_change_handler:
778 * @accessible: an #AtkObject
779 * @handler : a function to be called when a property changes its value
781 * Specifies a function to be called when a property changes value.
783 * Returns: a #guint which is the handler id used in
784 * atk_object_remove_property_change_handler()
787 atk_object_connect_property_change_handler (AtkObject *accessible,
788 AtkPropertyChangeHandler *handler)
790 AtkObjectClass *klass;
792 g_return_val_if_fail (ATK_IS_OBJECT (accessible), 0);
793 g_return_val_if_fail ((handler != NULL), 0);
795 klass = ATK_OBJECT_GET_CLASS (accessible);
796 if (klass->connect_property_change_handler)
797 return (klass->connect_property_change_handler) (accessible, handler);
803 * atk_object_remove_property_change_handler:
804 * @accessible: an #AtkObject
805 * @handler_id : a guint which identifies the handler to be removed.
807 * Removes a property change handler.
810 atk_object_remove_property_change_handler (AtkObject *accessible,
813 AtkObjectClass *klass;
815 g_return_if_fail (ATK_IS_OBJECT (accessible));
817 klass = ATK_OBJECT_GET_CLASS (accessible);
818 if (klass->remove_property_change_handler)
819 (klass->remove_property_change_handler) (accessible, handler_id);
823 * atk_object_notify_state_change:
824 * @accessible: an #AtkObject
825 * @state: an #AtkState whose state is changed
826 * @value : a gboolean which indicates whether the state is being set on or off
828 * Emits a state-change signal for the specified state.
831 atk_object_notify_state_change (AtkObject *accessible,
835 G_CONST_RETURN gchar* name;
837 name = atk_state_type_get_name (state);
838 g_signal_emit (accessible, atk_object_signals[STATE_CHANGE],
839 g_quark_from_string (name),
844 * atk_implementor_ref_accessible:
845 * @implementor: The #GObject instance which should implement #AtkImplementorIface
846 * if a non-null return value is required.
848 * Gets a reference to an object's #AtkObject implementation, if
849 * the object implements #AtkObjectIface
851 * Returns: a reference to an object's #AtkObject implementation
854 atk_implementor_ref_accessible (AtkImplementor *object)
856 AtkImplementorIface *iface;
857 AtkObject *accessible = NULL;
859 g_return_val_if_fail (ATK_IS_IMPLEMENTOR (object), NULL);
861 iface = ATK_IMPLEMENTOR_GET_IFACE (object);
864 accessible = iface->ref_accessible (object);
866 g_return_val_if_fail ((accessible != NULL), NULL);
871 static AtkRelationSet*
872 atk_object_real_ref_relation_set (AtkObject *accessible)
874 g_return_val_if_fail (accessible->relation_set, NULL);
875 g_object_ref (accessible->relation_set);
877 return accessible->relation_set;
881 atk_object_real_set_property (GObject *object,
886 AtkObject *accessible;
888 accessible = ATK_OBJECT (object);
893 atk_object_set_name (accessible, g_value_get_string (value));
895 case PROP_DESCRIPTION:
896 atk_object_set_description (accessible, g_value_get_string (value));
899 atk_object_set_role (accessible, g_value_get_int (value));
902 atk_object_set_parent (accessible, g_value_get_object (value));
905 if (ATK_IS_VALUE (accessible))
906 atk_value_set_current_value (ATK_VALUE (accessible), value);
908 case PROP_TABLE_SUMMARY:
909 if (ATK_IS_TABLE (accessible))
910 atk_table_set_summary (ATK_TABLE (accessible), g_value_get_object (value));
912 case PROP_TABLE_CAPTION_OBJECT:
913 if (ATK_IS_TABLE (accessible))
914 atk_table_set_caption (ATK_TABLE (accessible), g_value_get_object (value));
922 atk_object_real_get_property (GObject *object,
927 AtkObject *accessible;
929 accessible = ATK_OBJECT (object);
934 g_value_set_string (value, atk_object_get_name (accessible));
936 case PROP_DESCRIPTION:
937 g_value_set_string (value, atk_object_get_description (accessible));
940 g_value_set_int (value, atk_object_get_role (accessible));
943 if (ATK_IS_COMPONENT (accessible))
944 g_value_set_int (value, atk_component_get_layer (ATK_COMPONENT (accessible)));
946 case PROP_MDI_ZORDER:
947 if (ATK_IS_COMPONENT (accessible))
948 g_value_set_int (value, atk_component_get_mdi_zorder (ATK_COMPONENT (accessible)));
951 g_value_set_object (value, atk_object_get_parent (accessible));
954 if (ATK_IS_VALUE (accessible))
955 atk_value_get_current_value (ATK_VALUE (accessible), value);
957 case PROP_TABLE_SUMMARY:
958 if (ATK_IS_TABLE (accessible))
959 g_value_set_object (value, atk_table_get_summary (ATK_TABLE (accessible)));
961 case PROP_TABLE_CAPTION_OBJECT:
962 if (ATK_IS_TABLE (accessible))
963 g_value_set_object (value, atk_table_get_caption (ATK_TABLE (accessible)));
966 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
972 atk_object_finalize (GObject *object)
974 AtkObject *accessible;
976 g_return_if_fail (ATK_IS_OBJECT (object));
978 accessible = ATK_OBJECT (object);
980 g_free (accessible->name);
981 g_free (accessible->description);
984 * Free memory allocated for relation set if it have been allocated.
986 if (accessible->relation_set)
987 g_object_unref (accessible->relation_set);
989 if (accessible->accessible_parent)
990 g_object_unref (accessible->accessible_parent);
992 G_OBJECT_CLASS (parent_class)->finalize (object);
995 static G_CONST_RETURN gchar*
996 atk_object_real_get_name (AtkObject *object)
1001 static G_CONST_RETURN gchar*
1002 atk_object_real_get_description (AtkObject *object)
1004 return object->description;
1008 atk_object_real_get_parent (AtkObject *object)
1010 return object->accessible_parent;
1014 atk_object_real_get_role (AtkObject *object)
1016 return object->role;
1020 atk_object_real_get_layer (AtkObject *object)
1022 return object->layer;
1026 atk_object_real_ref_state_set (AtkObject *accessible)
1028 AtkStateSet *state_set;
1031 state_set = atk_state_set_new ();
1033 ap = atk_object_get_parent (accessible);
1035 if (ATK_IS_SELECTION (ap))
1039 atk_state_set_add_state (state_set, ATK_STATE_SELECTABLE);
1041 i = atk_object_get_index_in_parent (accessible);
1043 if (atk_selection_is_child_selected(ATK_SELECTION (ap), i))
1044 atk_state_set_add_state (state_set, ATK_STATE_SELECTED);
1051 atk_object_real_set_name (AtkObject *object,
1054 g_free (object->name);
1055 object->name = g_strdup (name);
1059 atk_object_real_set_description (AtkObject *object,
1060 const gchar *description)
1062 g_free (object->description);
1063 object->description = g_strdup (description);
1067 atk_object_real_set_parent (AtkObject *object,
1070 if (object->accessible_parent)
1071 g_object_unref (object->accessible_parent);
1073 object->accessible_parent = parent;
1074 if (object->accessible_parent)
1075 g_object_ref (object->accessible_parent);
1079 atk_object_real_set_role (AtkObject *object,
1082 object->role = role;
1086 atk_object_real_connect_property_change_handler (AtkObject *obj,
1087 AtkPropertyChangeHandler *handler)
1089 return g_signal_connect_closure_by_id (obj,
1090 atk_object_signals[PROPERTY_CHANGE],
1093 G_CALLBACK (handler), NULL,
1094 (GClosureNotify) NULL),
1099 atk_object_real_remove_property_change_handler (AtkObject *obj,
1102 g_signal_handler_disconnect (obj, handler_id);
1106 * atk_object_initialize:
1107 * @accessible: a #AtkObject
1108 * @data: a #gpointer which identifies the object for which the AtkObject was created.
1110 * This function is called when implementing subclasses of #AtkObject.
1111 * It does initialization required for the new object. It is intended
1112 * that this function should called only in the ..._new() functions used
1113 * to create an instance of a subclass of #AtkObject
1116 atk_object_initialize (AtkObject *accessible,
1119 AtkObjectClass *klass;
1121 g_return_if_fail (ATK_IS_OBJECT (accessible));
1123 klass = ATK_OBJECT_GET_CLASS (accessible);
1124 if (klass->initialize)
1125 klass->initialize (accessible, data);
1129 * This function is a signal handler for notify signal which gets emitted
1130 * when a property changes value.
1132 * It constructs an AtkPropertyValues structure and emits a "property_changed"
1133 * signal which causes the user specified AtkPropertyChangeHandler
1137 atk_object_notify (GObject *obj,
1140 AtkPropertyValues values = { 0, };
1142 g_value_init (&values.new_value, pspec->value_type);
1143 g_object_get_property (obj, pspec->name, &values.new_value);
1144 values.property_name = pspec->name;
1145 g_signal_emit (obj, atk_object_signals[PROPERTY_CHANGE],
1146 g_quark_from_string (pspec->name),
1148 g_value_unset (&values.new_value);
1152 * atk_role_get_name:
1153 * @role: The #AtkRole whose name is required
1155 * Gets the description string describing the #AtkRole @role.
1157 * Returns: the string describing the AtkRole
1159 G_CONST_RETURN gchar*
1160 atk_role_get_name (AtkRole role)
1162 GTypeClass *type_class;
1166 type_class = g_type_class_ref (ATK_TYPE_ROLE);
1167 g_return_val_if_fail (G_IS_ENUM_CLASS (type_class), NULL);
1169 value = g_enum_get_value (G_ENUM_CLASS (type_class), role);
1173 name = value->value_nick;
1181 n -= ATK_ROLE_LAST_DEFINED + 1;
1183 if (n < extra_roles->len)
1184 name = g_ptr_array_index (extra_roles, n);
1187 g_type_class_unref (type_class);
1195 #define ATKLOCALEDIR get_atk_locale_dir()
1197 G_WIN32_DLLMAIN_FOR_DLL_NAME(static, dll_name)
1200 get_atk_locale_dir (void)
1202 return g_win32_get_package_installation_subdirectory
1203 (GETTEXT_PACKAGE, dll_name, "lib/locale");
1209 * atk_role_get_localized_name:
1210 * @role: The #AtkRole whose localized name is required
1212 * Gets the localized description string describing the #AtkRole @role.
1214 * Returns: the localized string describing the AtkRole
1216 G_CONST_RETURN gchar*
1217 atk_role_get_localized_name (AtkRole role)
1219 G_CONST_RETURN gchar *name;
1220 gboolean gettext_initialized = FALSE;
1223 if (!gettext_initialized)
1225 bindtextdomain (GETTEXT_PACKAGE, ATKLOCALEDIR);
1226 #ifdef HAVE_BIND_TEXTDOMAIN_CODESET
1227 bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
1234 case ATK_ROLE_INVALID:
1235 name = _("invalid");
1237 case ATK_ROLE_ACCEL_LABEL:
1238 name = _("accel-label");
1240 case ATK_ROLE_ALERT:
1243 case ATK_ROLE_ANIMATION:
1244 name = _("animation");
1246 case ATK_ROLE_ARROW:
1249 case ATK_ROLE_CALENDAR:
1250 name = _("calendar");
1252 case ATK_ROLE_CANVAS:
1255 case ATK_ROLE_CHECK_BOX:
1256 name = _("check-box");
1258 case ATK_ROLE_CHECK_MENU_ITEM:
1259 name = _("check-menu-item");
1261 case ATK_ROLE_COLOR_CHOOSER:
1262 name = _("color-chooser");
1264 case ATK_ROLE_COLUMN_HEADER:
1265 name = _("column-header");
1267 case ATK_ROLE_COMBO_BOX:
1268 name = _("combo-box");
1270 case ATK_ROLE_DATE_EDITOR:
1271 name = _("date-editor");
1273 case ATK_ROLE_DESKTOP_ICON:
1274 name = _("desktop-icon");
1276 case ATK_ROLE_DESKTOP_FRAME:
1277 name = _("desktop-frame");
1282 case ATK_ROLE_DIALOG:
1285 case ATK_ROLE_DIRECTORY_PANE:
1286 name = _("directory-pane");
1288 case ATK_ROLE_DRAWING_AREA:
1289 name = _("drawing-area");
1291 case ATK_ROLE_FILE_CHOOSER:
1292 name = _("file-chooser");
1294 case ATK_ROLE_FILLER:
1297 case ATK_ROLE_FONT_CHOOSER:
1298 name = _("font-chooser");
1300 case ATK_ROLE_FRAME:
1303 case ATK_ROLE_GLASS_PANE:
1304 name = _("glass-pane");
1306 case ATK_ROLE_HTML_CONTAINER:
1307 name = _("html-container");
1312 case ATK_ROLE_IMAGE:
1315 case ATK_ROLE_INTERNAL_FRAME:
1316 name = _("internal-frame");
1318 case ATK_ROLE_LABEL:
1321 case ATK_ROLE_LAYERED_PANE:
1322 name = _("layered-pane");
1327 case ATK_ROLE_LIST_ITEM:
1328 name = _("list-item");
1333 case ATK_ROLE_MENU_BAR:
1334 name = _("menu-bar");
1336 case ATK_ROLE_MENU_ITEM:
1337 name = _("menu-item");
1339 case ATK_ROLE_OPTION_PANE:
1340 name = _("option-pane");
1342 case ATK_ROLE_PAGE_TAB:
1343 name = _("page-tab");
1345 case ATK_ROLE_PAGE_TAB_LIST:
1346 name = _("page-tab-list");
1348 case ATK_ROLE_PANEL:
1351 case ATK_ROLE_PASSWORD_TEXT:
1352 name = _("password-text");
1354 case ATK_ROLE_POPUP_MENU:
1355 name = _("popup-menu");
1357 case ATK_ROLE_PROGRESS_BAR:
1358 name = _("progress-bar");
1360 case ATK_ROLE_PUSH_BUTTON:
1361 name = _("push-button");
1363 case ATK_ROLE_RADIO_BUTTON:
1364 name = _("radio-button");
1366 case ATK_ROLE_RADIO_MENU_ITEM:
1367 name = _("radio-menu-item");
1369 case ATK_ROLE_ROOT_PANE:
1370 name = _("root-pane");
1372 case ATK_ROLE_ROW_HEADER:
1373 name = _("row-header");
1375 case ATK_ROLE_SCROLL_BAR:
1376 name = _("scroll-bar");
1378 case ATK_ROLE_SCROLL_PANE:
1379 name = _("scroll-pane");
1381 case ATK_ROLE_SEPARATOR:
1382 name = _("separator");
1384 case ATK_ROLE_SLIDER:
1387 case ATK_ROLE_SPLIT_PANE:
1388 name = _("split-pane");
1390 case ATK_ROLE_SPIN_BUTTON:
1391 name = _("spin-button");
1393 case ATK_ROLE_STATUSBAR:
1394 name = _("statusbar");
1396 case ATK_ROLE_TABLE:
1399 case ATK_ROLE_TABLE_CELL:
1400 name = _("table-cell");
1402 case ATK_ROLE_TABLE_COLUMN_HEADER:
1403 name = _("table-column-header");
1405 case ATK_ROLE_TABLE_ROW_HEADER:
1406 name = _("table-row-header");
1408 case ATK_ROLE_TEAR_OFF_MENU_ITEM:
1409 name = _("tear-off-menu-item");
1411 case ATK_ROLE_TERMINAL:
1412 name = _("terminal");
1417 case ATK_ROLE_TOGGLE_BUTTON:
1418 name = _("toggle-button");
1420 case ATK_ROLE_TOOL_BAR:
1421 name = _("tool-bar");
1423 case ATK_ROLE_TOOL_TIP:
1424 name = _("tool-tip");
1429 case ATK_ROLE_TREE_TABLE:
1430 name = _("tree-table");
1432 case ATK_ROLE_UNKNOWN:
1433 name = _("unknown");
1435 case ATK_ROLE_VIEWPORT:
1436 name = _("viewport");
1438 case ATK_ROLE_WINDOW:
1441 case ATK_ROLE_HEADER:
1444 case ATK_ROLE_FOOTER:
1447 case ATK_ROLE_PARAGRAPH:
1448 name = _("paragraph");
1450 case ATK_ROLE_RULER:
1453 case ATK_ROLE_APPLICATION:
1454 name = _("application");
1457 name = atk_role_get_name (role);
1464 * atk_role_for_name:
1465 * @name: a string which is the (non-localized) name of an ATK role.
1467 * Get the #AtkRole type corresponding to a rolew name.
1469 * Returns: the #AtkRole enumerated type corresponding to the specified
1471 * or #ATK_ROLE_INVALID if no matching role is found.
1474 atk_role_for_name (const gchar *name)
1476 GTypeClass *type_class;
1478 AtkRole role = ATK_ROLE_INVALID;
1480 g_return_val_if_fail (name, ATK_ROLE_INVALID);
1482 type_class = g_type_class_ref (ATK_TYPE_ROLE);
1483 g_return_val_if_fail (G_IS_ENUM_CLASS (type_class), ATK_ROLE_INVALID);
1485 value = g_enum_get_value_by_nick (G_ENUM_CLASS (type_class), name);
1489 role = value->value;
1497 for (i = 0; i < extra_roles->len; i++)
1499 gchar *extra_role = (gchar *)g_ptr_array_index (extra_roles, i);
1501 g_return_val_if_fail (extra_role, ATK_ROLE_INVALID);
1503 if (strcmp (name, extra_role) == 0)
1505 role = i + 1 + ATK_ROLE_LAST_DEFINED;
1511 g_type_class_unref (type_class);
1517 * atk_object_add_relationship:
1518 * @object: The #AtkObject to which an AtkRelation is to be added.
1519 * @relationship: The #AtkRelationType of the relation
1520 * @target: The #AtkObject which is to be the target of the relation.
1522 * Adds a relationship of the specified type with the specified target.
1524 * Returns TRUE if the relationship is added.
1527 atk_object_add_relationship (AtkObject *object,
1528 AtkRelationType relationship,
1531 AtkObject *array[1];
1532 AtkRelation *relation;
1534 g_return_val_if_fail (ATK_IS_OBJECT (object), FALSE);
1535 g_return_val_if_fail (ATK_IS_OBJECT (target), FALSE);
1538 relation = atk_relation_new (array, 1, relationship);
1539 atk_relation_set_add (object->relation_set, relation);
1540 g_object_unref (relation);
1546 * atk_object_remove_relationship:
1547 * @object: The #AtkObject from which an AtkRelation is to be removed.
1548 * @relationship: The #AtkRelationType of the relation
1549 * @target: The #AtkObject which is the target of the relation to be removed.
1551 * Removes a relationship of the specified type with the specified target.
1553 * Returns TRUE if the relationship is removed.
1556 atk_object_remove_relationship (AtkObject *object,
1557 AtkRelationType relationship,
1560 gint n_relations, i;
1561 gboolean ret = FALSE;
1562 AtkRelation *relation;
1564 g_return_val_if_fail (ATK_IS_OBJECT (object), FALSE);
1565 g_return_val_if_fail (ATK_IS_OBJECT (target), FALSE);
1567 n_relations = atk_relation_set_get_n_relations (object->relation_set);
1568 for (i = 0; i < n_relations; i++)
1570 relation = atk_relation_set_get_relation (object->relation_set, i);
1571 if (atk_relation_get_relation_type (relation) == relationship)
1575 array = atk_relation_get_target (relation);
1577 if (g_ptr_array_index (array, 0) == target)
1579 atk_relation_set_remove (object->relation_set, relation);
1590 atk_object_real_initialize (AtkObject *accessible,