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);
77 static void atk_object_real_set_property (GObject *object,
81 static void atk_object_real_get_property (GObject *object,
85 static void atk_object_finalize (GObject *object);
86 static G_CONST_RETURN gchar*
87 atk_object_real_get_name (AtkObject *object);
88 static G_CONST_RETURN gchar*
89 atk_object_real_get_description
91 static AtkObject* atk_object_real_get_parent (AtkObject *object);
92 static AtkRole atk_object_real_get_role (AtkObject *object);
93 static AtkLayer atk_object_real_get_layer (AtkObject *object);
94 static AtkStateSet* atk_object_real_ref_state_set
96 static void atk_object_real_set_name (AtkObject *object,
98 static void atk_object_real_set_description
100 const gchar *description);
101 static void atk_object_real_set_parent (AtkObject *object,
103 static void atk_object_real_set_role (AtkObject *object,
105 static guint atk_object_real_connect_property_change_handler
107 AtkPropertyChangeHandler
109 static void atk_object_real_remove_property_change_handler
112 static void atk_object_notify (GObject *obj,
116 static guint atk_object_signals[LAST_SIGNAL] = { 0, };
118 static gpointer parent_class = NULL;
120 static const gchar* atk_object_name_property_name = "accessible-name";
121 static const gchar* atk_object_name_property_description = "accessible-description";
122 static const gchar* atk_object_name_property_parent = "accessible-parent";
123 static const gchar* atk_object_name_property_value = "accessible-value";
124 static const gchar* atk_object_name_property_role = "accessible-role";
125 static const gchar* atk_object_name_property_component_layer = "accessible-component-layer";
126 static const gchar* atk_object_name_property_component_mdi_zorder = "accessible-component-mdi-zorder";
127 static const gchar* atk_object_name_property_table_caption = "accessible-table-caption";
128 static const gchar* atk_object_name_property_table_column_description = "accessible-table-column-description";
129 static const gchar* atk_object_name_property_table_column_header = "accessible-table-column-header";
130 static const gchar* atk_object_name_property_table_row_description = "accessible-table-row-description";
131 static const gchar* atk_object_name_property_table_row_header = "accessible-table-row-header";
132 static const gchar* atk_object_name_property_table_summary = "accessible-table-summary";
133 static const gchar* atk_object_name_property_table_caption_object = "accessible-table-caption-object";
136 atk_object_get_type (void)
138 static GType type = 0;
142 static const GTypeInfo typeInfo =
144 sizeof (AtkObjectClass),
145 (GBaseInitFunc) NULL,
146 (GBaseFinalizeFunc) NULL,
147 (GClassInitFunc) atk_object_class_init,
148 (GClassFinalizeFunc) NULL,
152 (GInstanceInitFunc) atk_object_init,
154 type = g_type_register_static (G_TYPE_OBJECT, "AtkObject", &typeInfo, 0) ;
160 atk_object_class_init (AtkObjectClass *klass)
162 GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
164 parent_class = g_type_class_peek_parent (klass);
166 gobject_class->set_property = atk_object_real_set_property;
167 gobject_class->get_property = atk_object_real_get_property;
168 gobject_class->finalize = atk_object_finalize;
169 gobject_class->notify = atk_object_notify;
171 klass->get_name = atk_object_real_get_name;
172 klass->get_description = atk_object_real_get_description;
173 klass->get_parent = atk_object_real_get_parent;
174 klass->get_n_children = NULL;
175 klass->ref_child = NULL;
176 klass->get_index_in_parent = NULL;
177 klass->ref_relation_set = atk_object_real_ref_relation_set;
178 klass->get_role = atk_object_real_get_role;
179 klass->get_layer = atk_object_real_get_layer;
180 klass->get_mdi_zorder = NULL;
181 klass->ref_state_set = atk_object_real_ref_state_set;
182 klass->set_name = atk_object_real_set_name;
183 klass->set_description = atk_object_real_set_description;
184 klass->set_parent = atk_object_real_set_parent;
185 klass->set_role = atk_object_real_set_role;
186 klass->connect_property_change_handler =
187 atk_object_real_connect_property_change_handler;
188 klass->remove_property_change_handler =
189 atk_object_real_remove_property_change_handler;
192 * We do not define default signal handlers here
194 klass->children_changed = NULL;
195 klass->focus_event = NULL;
196 klass->property_change = NULL;
197 klass->visible_data_changed = NULL;
198 klass->active_descendant_changed = NULL;
200 g_object_class_install_property (gobject_class,
202 g_param_spec_string (atk_object_name_property_name,
204 "Object instance\'s name formatted for "
205 "assistive technology access",
208 g_object_class_install_property (gobject_class,
210 g_param_spec_string (atk_object_name_property_description,
211 "Accessible Description",
212 "Description of an object, formatted for "
213 "assistive technology access",
216 g_object_class_install_property (gobject_class,
218 g_param_spec_object (atk_object_name_property_parent,
220 "Is used to notify that the parent has changed ",
223 g_object_class_install_property (gobject_class,
225 g_param_spec_double (atk_object_name_property_value,
227 "Is used to notify that the value has changed ",
232 g_object_class_install_property (gobject_class,
234 g_param_spec_int (atk_object_name_property_role,
236 "The accessible role of this object ",
241 g_object_class_install_property (gobject_class,
243 g_param_spec_int (atk_object_name_property_component_layer,
245 "The accessible layer of this object ",
250 g_object_class_install_property (gobject_class,
252 g_param_spec_int (atk_object_name_property_component_mdi_zorder,
253 "Accessible MDI Value",
254 "The accessible MDI value of this object ",
259 g_object_class_install_property (gobject_class,
261 g_param_spec_string (atk_object_name_property_table_caption,
262 "Accessible Table Caption",
263 "Is used to notify that the table caption has changed; this property should not be used. accessible-table-caption-object should be used instead",
266 g_object_class_install_property (gobject_class,
267 PROP_TABLE_COLUMN_HEADER,
268 g_param_spec_object (atk_object_name_property_table_column_header,
269 "Accessible Table Column Header",
270 "Is used to notify that the table column header has changed ",
273 g_object_class_install_property (gobject_class,
274 PROP_TABLE_COLUMN_DESCRIPTION,
275 g_param_spec_string (atk_object_name_property_table_column_description,
276 "Accessible Table Column Description",
277 "Is used to notify that the table columnscription has changed ",
280 g_object_class_install_property (gobject_class,
281 PROP_TABLE_ROW_HEADER,
282 g_param_spec_object (atk_object_name_property_table_row_header,
283 "Accessible Table Row Header",
284 "Is used to notify that the table row header has changed ",
287 g_object_class_install_property (gobject_class,
288 PROP_TABLE_ROW_DESCRIPTION,
289 g_param_spec_string (atk_object_name_property_table_row_description,
290 "Accessible Table Row Description",
291 "Is used to notify that the table row description has changed ",
294 g_object_class_install_property (gobject_class,
296 g_param_spec_object (atk_object_name_property_table_summary,
297 "Accessible Table Summary",
298 "Is used to notify that the table summary has changed ",
301 g_object_class_install_property (gobject_class,
302 PROP_TABLE_CAPTION_OBJECT,
303 g_param_spec_object (atk_object_name_property_table_caption_object,
304 "Accessible Table Caption Object",
305 "Is used to notify that the table caption has changed ",
309 * The signal "children_changed" supports two details:
312 atk_object_signals[CHILDREN_CHANGED] =
313 g_signal_new ("children_changed",
314 G_TYPE_FROM_CLASS (klass),
315 G_SIGNAL_RUN_LAST | G_SIGNAL_DETAILED,
316 G_STRUCT_OFFSET (AtkObjectClass, children_changed),
318 g_cclosure_marshal_VOID__UINT_POINTER,
320 2, G_TYPE_UINT, G_TYPE_POINTER);
321 atk_object_signals[FOCUS_EVENT] =
322 g_signal_new ("focus_event",
323 G_TYPE_FROM_CLASS (klass),
325 G_STRUCT_OFFSET (AtkObjectClass, focus_event),
327 g_cclosure_marshal_VOID__BOOLEAN,
330 atk_object_signals[PROPERTY_CHANGE] =
331 g_signal_new ("property_change",
332 G_TYPE_FROM_CLASS (klass),
333 G_SIGNAL_RUN_LAST | G_SIGNAL_DETAILED,
334 G_STRUCT_OFFSET (AtkObjectClass, property_change),
335 (GSignalAccumulator) NULL, NULL,
336 g_cclosure_marshal_VOID__POINTER,
340 * The "state_change" signal supports details, one for each accessible
344 atk_object_signals[STATE_CHANGE] =
345 g_signal_new ("state_change",
346 G_TYPE_FROM_CLASS (klass),
347 G_SIGNAL_RUN_LAST | G_SIGNAL_DETAILED,
348 G_STRUCT_OFFSET (AtkObjectClass, state_change),
349 (GSignalAccumulator) NULL, NULL,
350 atk_marshal_VOID__STRING_BOOLEAN,
354 atk_object_signals[VISIBLE_DATA_CHANGED] =
355 g_signal_new ("visible_data_changed",
356 G_TYPE_FROM_CLASS (klass),
358 G_STRUCT_OFFSET (AtkObjectClass, visible_data_changed),
359 (GSignalAccumulator) NULL, NULL,
360 g_cclosure_marshal_VOID__VOID,
362 atk_object_signals[ACTIVE_DESCENDANT_CHANGED] =
363 g_signal_new ("active_descendant_changed",
364 G_TYPE_FROM_CLASS (klass),
365 G_SIGNAL_RUN_LAST | G_SIGNAL_DETAILED,
366 G_STRUCT_OFFSET (AtkObjectClass, active_descendant_changed),
368 g_cclosure_marshal_VOID__POINTER,
374 atk_object_init (AtkObject *accessible,
375 AtkObjectClass *klass)
377 accessible->name = NULL;
378 accessible->description = NULL;
379 accessible->accessible_parent = NULL;
380 accessible->relation_set = atk_relation_set_new();
381 accessible->role = ATK_ROLE_UNKNOWN;
385 atk_implementor_get_type (void)
387 static GType type = 0;
391 static const GTypeInfo typeInfo =
393 sizeof (AtkImplementorIface),
394 (GBaseInitFunc) NULL,
395 (GBaseFinalizeFunc) NULL,
398 type = g_type_register_static (G_TYPE_INTERFACE, "AtkImplementorIface", &typeInfo, 0) ;
405 * atk_object_get_name:
406 * @accessible: an #AtkObject
408 * Gets the accessible name of the accessible.
410 * Returns: a character string representing the accessible name of the object.
412 G_CONST_RETURN gchar*
413 atk_object_get_name (AtkObject *accessible)
415 AtkObjectClass *klass;
417 g_return_val_if_fail (ATK_IS_OBJECT (accessible), NULL);
419 klass = ATK_OBJECT_GET_CLASS (accessible);
421 return (klass->get_name) (accessible);
427 * atk_object_get_description:
428 * @accessible: an #AtkObject
430 * Gets the accessible description of the accessible.
432 * Returns: a character string representing the accessible description
436 G_CONST_RETURN gchar*
437 atk_object_get_description (AtkObject *accessible)
439 AtkObjectClass *klass;
441 g_return_val_if_fail (ATK_IS_OBJECT (accessible), NULL);
443 klass = ATK_OBJECT_GET_CLASS (accessible);
444 if (klass->get_description)
445 return (klass->get_description) (accessible);
451 * atk_object_get_parent:
452 * @accessible: an #AtkObject
454 * Gets the accessible parent of the accessible.
456 * Returns: a #AtkObject representing the accessible parent of the accessible
459 atk_object_get_parent (AtkObject *accessible)
461 AtkObjectClass *klass;
463 g_return_val_if_fail (ATK_IS_OBJECT (accessible), NULL);
465 klass = ATK_OBJECT_GET_CLASS (accessible);
466 if (klass->get_parent)
467 return (klass->get_parent) (accessible);
473 * atk_object_get_n_accessible_children:
474 * @accessible: an #AtkObject
476 * Gets the number of accessible children of the accessible.
478 * Returns: an integer representing the number of accessible children
482 atk_object_get_n_accessible_children (AtkObject *accessible)
484 AtkObjectClass *klass;
486 g_return_val_if_fail (ATK_IS_OBJECT (accessible), 0);
488 klass = ATK_OBJECT_GET_CLASS (accessible);
489 if (klass->get_n_children)
490 return (klass->get_n_children) (accessible);
496 * atk_object_ref_accessible_child:
497 * @accessible: an #AtkObject
498 * @i: a gint representing the position of the child, starting from 0
500 * Gets a reference to the specified accessible child of the object.
501 * The accessible children are 0-based so the first accessible child is
502 * at index 0, the second at index 1 and so on.
504 * Returns: an #AtkObject representing the specified accessible child
508 atk_object_ref_accessible_child (AtkObject *accessible,
511 AtkObjectClass *klass;
513 g_return_val_if_fail (ATK_IS_OBJECT (accessible), NULL);
515 klass = ATK_OBJECT_GET_CLASS (accessible);
516 if (klass->ref_child)
517 return (klass->ref_child) (accessible, i);
523 * atk_object_ref_relation_set:
524 * @accessible: an #AtkObject
526 * Gets the #AtkRelationSet associated with the object.
528 * Returns: an #AtkRelationSet representing the relation set of the object.
531 atk_object_ref_relation_set (AtkObject *accessible)
533 AtkObjectClass *klass;
535 g_return_val_if_fail (ATK_IS_OBJECT (accessible), NULL);
537 klass = ATK_OBJECT_GET_CLASS (accessible);
538 if (klass->ref_relation_set)
539 return (klass->ref_relation_set) (accessible);
546 * @name: a character string describing the new role.
548 * Registers the role specified by @name.
550 * Returns: an #AtkRole for the new role.
553 atk_role_register (const gchar *name)
556 extra_roles = g_ptr_array_new ();
558 g_ptr_array_add (extra_roles, g_strdup (name));
559 return extra_roles->len + ATK_ROLE_LAST_DEFINED;
563 * atk_object_get_role:
564 * @accessible: an #AtkObject
566 * Gets the role of the accessible.
568 * Returns: an #AtkRole which is the role of the accessible
571 atk_object_get_role (AtkObject *accessible)
573 AtkObjectClass *klass;
575 g_return_val_if_fail (ATK_IS_OBJECT (accessible), ATK_ROLE_UNKNOWN);
577 klass = ATK_OBJECT_GET_CLASS (accessible);
579 return (klass->get_role) (accessible);
581 return ATK_ROLE_UNKNOWN;
585 * atk_object_get_layer:
586 * @accessible: an #AtkObject
588 * Gets the layer of the accessible.
589 * DEPRECATED: use atk_component_get_layer instead!
591 * Returns: an #AtkLayer which is the layer of the accessible
594 atk_object_get_layer (AtkObject *accessible)
596 AtkObjectClass *klass;
598 g_return_val_if_fail (ATK_IS_OBJECT (accessible), ATK_LAYER_INVALID);
600 klass = ATK_OBJECT_GET_CLASS (accessible);
601 if (klass->get_layer)
602 return (klass->get_layer) (accessible);
604 return ATK_LAYER_INVALID;
608 * atk_object_get_mdi_zorder:
609 * @accessible: an #AtkObject
611 * Gets the zorder of the accessible. The value G_MININT will be returned
612 * if the layer of the accessible is not ATK_LAYER_MDI.
613 * DEPRECATED: use atk_component_get_mdi_zorder instead!
615 * Returns: a gint which is the zorder of the accessible, i.e. the depth at
616 * which the component is shown in relation to other components in the same
620 atk_object_get_mdi_zorder (AtkObject *accessible)
622 AtkObjectClass *klass;
624 g_return_val_if_fail (ATK_IS_OBJECT (accessible), G_MININT);
626 klass = ATK_OBJECT_GET_CLASS (accessible);
627 if (klass->get_mdi_zorder)
628 return (klass->get_mdi_zorder) (accessible);
634 * atk_object_ref_state_set:
635 * @accessible: an #AtkObject
637 * Gets a reference to the state set of the accessible; the caller must
638 * unreference it when it is no longer needed.
640 * Returns: a reference to an #AtkStateSet which is the state
641 * set of the accessible
644 atk_object_ref_state_set (AtkObject *accessible)
646 AtkObjectClass *klass;
648 g_return_val_if_fail (ATK_IS_OBJECT (accessible), NULL);
650 klass = ATK_OBJECT_GET_CLASS (accessible);
651 if (klass->ref_state_set)
652 return (klass->ref_state_set) (accessible);
658 * atk_object_get_index_in_parent:
659 * @accessible: an #AtkObject
661 * Gets the 0-based index of this accessible in its parent; returns -1 if the
662 * accessible does not have an accessible parent.
664 * Returns: an integer which is the index of the accessible in its parent
667 atk_object_get_index_in_parent (AtkObject *accessible)
669 AtkObjectClass *klass;
671 g_return_val_if_fail (ATK_OBJECT (accessible), -1);
673 klass = ATK_OBJECT_GET_CLASS (accessible);
674 if (klass->get_index_in_parent)
675 return (klass->get_index_in_parent) (accessible);
681 * atk_object_set_name:
682 * @accessible: an #AtkObject
683 * @name: a character string to be set as the accessible name
685 * Sets the accessible name of the accessible.
688 atk_object_set_name (AtkObject *accessible,
691 AtkObjectClass *klass;
693 g_return_if_fail (ATK_IS_OBJECT (accessible));
694 g_return_if_fail (name != NULL);
696 klass = ATK_OBJECT_GET_CLASS (accessible);
699 (klass->set_name) (accessible, name);
700 g_object_notify (G_OBJECT (accessible), atk_object_name_property_name);
705 * atk_object_set_description:
706 * @accessible: an #AtkObject
707 * @description : a character string to be set as the accessible description
709 * Sets the accessible description of the accessible.
712 atk_object_set_description (AtkObject *accessible,
713 const gchar *description)
715 AtkObjectClass *klass;
717 g_return_if_fail (ATK_IS_OBJECT (accessible));
718 g_return_if_fail (description != NULL);
720 klass = ATK_OBJECT_GET_CLASS (accessible);
721 if (klass->set_description)
723 (klass->set_description) (accessible, description);
724 g_object_notify (G_OBJECT (accessible), atk_object_name_property_description);
729 * atk_object_set_parent:
730 * @accessible: an #AtkObject
731 * @parent : an #AtkObject to be set as the accessible parent
733 * Sets the accessible parent of the accessible.
736 atk_object_set_parent (AtkObject *accessible,
739 AtkObjectClass *klass;
741 g_return_if_fail (ATK_IS_OBJECT (accessible));
743 klass = ATK_OBJECT_GET_CLASS (accessible);
744 if (klass->set_parent)
746 (klass->set_parent) (accessible, parent);
747 g_object_notify (G_OBJECT (accessible), atk_object_name_property_parent);
752 * atk_object_set_role:
753 * @accessible: an #AtkObject
754 * @role : an #AtkRole to be set as the role
756 * Sets the role of the accessible.
759 atk_object_set_role (AtkObject *accessible,
762 AtkObjectClass *klass;
764 g_return_if_fail (ATK_IS_OBJECT (accessible));
766 klass = ATK_OBJECT_GET_CLASS (accessible);
769 (klass->set_role) (accessible, role);
770 g_object_notify (G_OBJECT (accessible), atk_object_name_property_role);
775 * atk_object_connect_property_change_handler:
776 * @accessible: an #AtkObject
777 * @handler : a function to be called when a property changes its value
779 * Specifies a function to be called when a property changes value.
781 * Returns: a #guint which is the handler id used in
782 * atk_object_remove_property_change_handler()
785 atk_object_connect_property_change_handler (AtkObject *accessible,
786 AtkPropertyChangeHandler *handler)
788 AtkObjectClass *klass;
790 g_return_val_if_fail (ATK_IS_OBJECT (accessible), 0);
791 g_return_val_if_fail ((handler != NULL), 0);
793 klass = ATK_OBJECT_GET_CLASS (accessible);
794 if (klass->connect_property_change_handler)
795 return (klass->connect_property_change_handler) (accessible, handler);
801 * atk_object_remove_property_change_handler:
802 * @accessible: an #AtkObject
803 * @handler_id : a guint which identifies the handler to be removed.
805 * Removes a property change handler.
808 atk_object_remove_property_change_handler (AtkObject *accessible,
811 AtkObjectClass *klass;
813 g_return_if_fail (ATK_IS_OBJECT (accessible));
815 klass = ATK_OBJECT_GET_CLASS (accessible);
816 if (klass->remove_property_change_handler)
817 (klass->remove_property_change_handler) (accessible, handler_id);
821 * atk_object_notify_state_change:
822 * @accessible: an #AtkObject
823 * @state: an #AtkState whose state is changed
824 * @value : a gboolean which indicates whether the state is being set on or off
826 * Emits a state-change signal for the specified state.
829 atk_object_notify_state_change (AtkObject *accessible,
833 G_CONST_RETURN gchar* name;
835 name = atk_state_type_get_name (state);
836 g_signal_emit (accessible, atk_object_signals[STATE_CHANGE],
837 g_quark_from_string (name),
842 * atk_implementor_ref_accessible:
843 * @implementor: The #GObject instance which should implement #AtkImplementorIface
844 * if a non-null return value is required.
846 * Gets a reference to an object's #AtkObject implementation, if
847 * the object implements #AtkObjectIface
849 * Returns: a reference to an object's #AtkObject implementation
852 atk_implementor_ref_accessible (AtkImplementor *object)
854 AtkImplementorIface *iface;
855 AtkObject *accessible = NULL;
857 g_return_val_if_fail (ATK_IS_IMPLEMENTOR (object), NULL);
859 iface = ATK_IMPLEMENTOR_GET_IFACE (object);
862 accessible = iface->ref_accessible (object);
864 g_return_val_if_fail ((accessible != NULL), NULL);
869 static AtkRelationSet*
870 atk_object_real_ref_relation_set (AtkObject *accessible)
872 g_return_val_if_fail (accessible->relation_set, NULL);
873 g_object_ref (accessible->relation_set);
875 return accessible->relation_set;
879 atk_object_real_set_property (GObject *object,
884 AtkObject *accessible;
886 accessible = ATK_OBJECT (object);
891 atk_object_set_name (accessible, g_value_get_string (value));
893 case PROP_DESCRIPTION:
894 atk_object_set_description (accessible, g_value_get_string (value));
897 atk_object_set_role (accessible, g_value_get_int (value));
900 atk_object_set_parent (accessible, g_value_get_object (value));
903 if (ATK_IS_VALUE (accessible))
904 atk_value_set_current_value (ATK_VALUE (accessible), value);
906 case PROP_TABLE_SUMMARY:
907 if (ATK_IS_TABLE (accessible))
908 atk_table_set_summary (ATK_TABLE (accessible), g_value_get_object (value));
910 case PROP_TABLE_CAPTION_OBJECT:
911 if (ATK_IS_TABLE (accessible))
912 atk_table_set_caption (ATK_TABLE (accessible), g_value_get_object (value));
920 atk_object_real_get_property (GObject *object,
925 AtkObject *accessible;
927 accessible = ATK_OBJECT (object);
932 g_value_set_string (value, atk_object_get_name (accessible));
934 case PROP_DESCRIPTION:
935 g_value_set_string (value, atk_object_get_description (accessible));
938 g_value_set_int (value, atk_object_get_role (accessible));
941 if (ATK_IS_COMPONENT (accessible))
942 g_value_set_int (value, atk_component_get_layer (ATK_COMPONENT (accessible)));
944 case PROP_MDI_ZORDER:
945 if (ATK_IS_COMPONENT (accessible))
946 g_value_set_int (value, atk_component_get_mdi_zorder (ATK_COMPONENT (accessible)));
949 g_value_set_object (value, atk_object_get_parent (accessible));
952 if (ATK_IS_VALUE (accessible))
953 atk_value_get_current_value (ATK_VALUE (accessible), value);
955 case PROP_TABLE_SUMMARY:
956 if (ATK_IS_TABLE (accessible))
957 g_value_set_object (value, atk_table_get_summary (ATK_TABLE (accessible)));
959 case PROP_TABLE_CAPTION_OBJECT:
960 if (ATK_IS_TABLE (accessible))
961 g_value_set_object (value, atk_table_get_caption (ATK_TABLE (accessible)));
964 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
970 atk_object_finalize (GObject *object)
972 AtkObject *accessible;
974 g_return_if_fail (ATK_IS_OBJECT (object));
976 accessible = ATK_OBJECT (object);
978 g_free (accessible->name);
979 g_free (accessible->description);
982 * Free memory allocated for relation set if it have been allocated.
984 if (accessible->relation_set)
985 g_object_unref (accessible->relation_set);
987 if (accessible->accessible_parent)
988 g_object_unref (accessible->accessible_parent);
990 G_OBJECT_CLASS (parent_class)->finalize (object);
993 static G_CONST_RETURN gchar*
994 atk_object_real_get_name (AtkObject *object)
999 static G_CONST_RETURN gchar*
1000 atk_object_real_get_description (AtkObject *object)
1002 return object->description;
1006 atk_object_real_get_parent (AtkObject *object)
1008 return object->accessible_parent;
1012 atk_object_real_get_role (AtkObject *object)
1014 return object->role;
1018 atk_object_real_get_layer (AtkObject *object)
1020 return object->layer;
1024 atk_object_real_ref_state_set (AtkObject *accessible)
1026 AtkStateSet *state_set;
1029 state_set = atk_state_set_new ();
1031 ap = atk_object_get_parent (accessible);
1033 if (ATK_IS_SELECTION (ap))
1037 atk_state_set_add_state (state_set, ATK_STATE_SELECTABLE);
1039 i = atk_object_get_index_in_parent (accessible);
1041 if (atk_selection_is_child_selected(ATK_SELECTION (ap), i))
1042 atk_state_set_add_state (state_set, ATK_STATE_SELECTED);
1049 atk_object_real_set_name (AtkObject *object,
1052 g_free (object->name);
1053 object->name = g_strdup (name);
1057 atk_object_real_set_description (AtkObject *object,
1058 const gchar *description)
1060 g_free (object->description);
1061 object->description = g_strdup (description);
1065 atk_object_real_set_parent (AtkObject *object,
1068 if (object->accessible_parent)
1069 g_object_unref (object->accessible_parent);
1071 object->accessible_parent = parent;
1072 if (object->accessible_parent)
1073 g_object_ref (object->accessible_parent);
1077 atk_object_real_set_role (AtkObject *object,
1080 object->role = role;
1084 atk_object_real_connect_property_change_handler (AtkObject *obj,
1085 AtkPropertyChangeHandler *handler)
1087 return g_signal_connect_closure_by_id (obj,
1088 atk_object_signals[PROPERTY_CHANGE],
1091 G_CALLBACK (handler), NULL,
1092 (GClosureNotify) NULL),
1097 atk_object_real_remove_property_change_handler (AtkObject *obj,
1100 g_signal_handler_disconnect (obj, handler_id);
1104 * atk_object_initialize:
1105 * @accessible: a #AtkObject
1106 * @data: a #gpointer which identifies the object for which the AtkObject was created.
1108 * This function is called when implementing subclasses of #AtkObject.
1109 * It does initialization required for the new object. It is intended
1110 * that this function should called only in the ..._new() functions used
1111 * to create an instance of a subclass of #AtkObject
1114 atk_object_initialize (AtkObject *accessible,
1117 AtkObjectClass *klass;
1119 g_return_if_fail (ATK_IS_OBJECT (accessible));
1121 klass = ATK_OBJECT_GET_CLASS (accessible);
1122 if (klass->initialize)
1123 klass->initialize (accessible, data);
1127 * This function is a signal handler for notify signal which gets emitted
1128 * when a property changes value.
1130 * It constructs an AtkPropertyValues structure and emits a "property_changed"
1131 * signal which causes the user specified AtkPropertyChangeHandler
1135 atk_object_notify (GObject *obj,
1138 AtkPropertyValues values = { 0, };
1140 g_value_init (&values.new_value, pspec->value_type);
1141 g_object_get_property (obj, pspec->name, &values.new_value);
1142 values.property_name = pspec->name;
1143 g_signal_emit (obj, atk_object_signals[PROPERTY_CHANGE],
1144 g_quark_from_string (pspec->name),
1146 g_value_unset (&values.new_value);
1150 * atk_role_get_name:
1151 * @role: The #AtkRole whose name is required
1153 * Gets the description string describing the #AtkRole @role.
1155 * Returns: the string describing the AtkRole
1157 G_CONST_RETURN gchar*
1158 atk_role_get_name (AtkRole role)
1160 GTypeClass *type_class;
1164 type_class = g_type_class_ref (ATK_TYPE_ROLE);
1165 g_return_val_if_fail (G_IS_ENUM_CLASS (type_class), NULL);
1167 value = g_enum_get_value (G_ENUM_CLASS (type_class), role);
1171 name = value->value_nick;
1179 n -= ATK_ROLE_LAST_DEFINED + 1;
1181 if (n < extra_roles->len)
1182 name = g_ptr_array_index (extra_roles, n);
1185 g_type_class_unref (type_class);
1193 #define ATKLOCALEDIR get_atk_locale_dir()
1195 G_WIN32_DLLMAIN_FOR_DLL_NAME(static, dll_name)
1198 get_atk_locale_dir (void)
1200 return g_win32_get_package_installation_subdirectory
1201 (GETTEXT_PACKAGE, dll_name, "lib/locale");
1207 * atk_role_get_localized_name:
1208 * @role: The #AtkRole whose localized name is required
1210 * Gets the localized description string describing the #AtkRole @role.
1212 * Returns: the localized string describing the AtkRole
1214 G_CONST_RETURN gchar*
1215 atk_role_get_localized_name (AtkRole role)
1217 G_CONST_RETURN gchar *name;
1218 gboolean gettext_initialized = FALSE;
1221 if (!gettext_initialized)
1223 bindtextdomain (GETTEXT_PACKAGE, ATKLOCALEDIR);
1224 #ifdef HAVE_BIND_TEXTDOMAIN_CODESET
1225 bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
1232 case ATK_ROLE_INVALID:
1233 name = _("invalid");
1235 case ATK_ROLE_ACCEL_LABEL:
1236 name = _("accel-label");
1238 case ATK_ROLE_ALERT:
1241 case ATK_ROLE_ANIMATION:
1242 name = _("animation");
1244 case ATK_ROLE_ARROW:
1247 case ATK_ROLE_CALENDAR:
1248 name = _("calendar");
1250 case ATK_ROLE_CANVAS:
1253 case ATK_ROLE_CHECK_BOX:
1254 name = _("check-box");
1256 case ATK_ROLE_CHECK_MENU_ITEM:
1257 name = _("check-menu-item");
1259 case ATK_ROLE_COLOR_CHOOSER:
1260 name = _("color-chooser");
1262 case ATK_ROLE_COLUMN_HEADER:
1263 name = _("column-header");
1265 case ATK_ROLE_COMBO_BOX:
1266 name = _("combo-box");
1268 case ATK_ROLE_DATE_EDITOR:
1269 name = _("date-editor");
1271 case ATK_ROLE_DESKTOP_ICON:
1272 name = _("desktop-icon");
1274 case ATK_ROLE_DESKTOP_FRAME:
1275 name = _("desktop-frame");
1280 case ATK_ROLE_DIALOG:
1283 case ATK_ROLE_DIRECTORY_PANE:
1284 name = _("directory-pane");
1286 case ATK_ROLE_DRAWING_AREA:
1287 name = _("drawing-area");
1289 case ATK_ROLE_FILE_CHOOSER:
1290 name = _("file-chooser");
1292 case ATK_ROLE_FILLER:
1295 case ATK_ROLE_FONT_CHOOSER:
1296 name = _("font-chooser");
1298 case ATK_ROLE_FRAME:
1301 case ATK_ROLE_GLASS_PANE:
1302 name = _("glass-pane");
1304 case ATK_ROLE_HTML_CONTAINER:
1305 name = _("html-container");
1310 case ATK_ROLE_IMAGE:
1313 case ATK_ROLE_INTERNAL_FRAME:
1314 name = _("internal-frame");
1316 case ATK_ROLE_LABEL:
1319 case ATK_ROLE_LAYERED_PANE:
1320 name = _("layered-pane");
1325 case ATK_ROLE_LIST_ITEM:
1326 name = _("list-item");
1331 case ATK_ROLE_MENU_BAR:
1332 name = _("menu-bar");
1334 case ATK_ROLE_MENU_ITEM:
1335 name = _("menu-item");
1337 case ATK_ROLE_OPTION_PANE:
1338 name = _("option-pane");
1340 case ATK_ROLE_PAGE_TAB:
1341 name = _("page-tab");
1343 case ATK_ROLE_PAGE_TAB_LIST:
1344 name = _("page-tab-list");
1346 case ATK_ROLE_PANEL:
1349 case ATK_ROLE_PASSWORD_TEXT:
1350 name = _("password-text");
1352 case ATK_ROLE_POPUP_MENU:
1353 name = _("popup-menu");
1355 case ATK_ROLE_PROGRESS_BAR:
1356 name = _("progress-bar");
1358 case ATK_ROLE_PUSH_BUTTON:
1359 name = _("push-button");
1361 case ATK_ROLE_RADIO_BUTTON:
1362 name = _("radio-button");
1364 case ATK_ROLE_RADIO_MENU_ITEM:
1365 name = _("radio-menu-item");
1367 case ATK_ROLE_ROOT_PANE:
1368 name = _("root-pane");
1370 case ATK_ROLE_ROW_HEADER:
1371 name = _("row-header");
1373 case ATK_ROLE_SCROLL_BAR:
1374 name = _("scroll-bar");
1376 case ATK_ROLE_SCROLL_PANE:
1377 name = _("scroll-pane");
1379 case ATK_ROLE_SEPARATOR:
1380 name = _("separator");
1382 case ATK_ROLE_SLIDER:
1385 case ATK_ROLE_SPLIT_PANE:
1386 name = _("split-pane");
1388 case ATK_ROLE_SPIN_BUTTON:
1389 name = _("spin-button");
1391 case ATK_ROLE_STATUSBAR:
1392 name = _("statusbar");
1394 case ATK_ROLE_TABLE:
1397 case ATK_ROLE_TABLE_CELL:
1398 name = _("table-cell");
1400 case ATK_ROLE_TABLE_COLUMN_HEADER:
1401 name = _("table-column-header");
1403 case ATK_ROLE_TABLE_ROW_HEADER:
1404 name = _("table-row-header");
1406 case ATK_ROLE_TEAR_OFF_MENU_ITEM:
1407 name = _("tear-off-menu-item");
1409 case ATK_ROLE_TERMINAL:
1410 name = _("terminal");
1415 case ATK_ROLE_TOGGLE_BUTTON:
1416 name = _("toggle-button");
1418 case ATK_ROLE_TOOL_BAR:
1419 name = _("tool-bar");
1421 case ATK_ROLE_TOOL_TIP:
1422 name = _("tool-tip");
1427 case ATK_ROLE_TREE_TABLE:
1428 name = _("tree-table");
1430 case ATK_ROLE_UNKNOWN:
1431 name = _("unknown");
1433 case ATK_ROLE_VIEWPORT:
1434 name = _("viewport");
1436 case ATK_ROLE_WINDOW:
1439 case ATK_ROLE_HEADER:
1442 case ATK_ROLE_FOOTER:
1445 case ATK_ROLE_PARAGRAPH:
1446 name = _("paragraph");
1448 case ATK_ROLE_RULER:
1451 case ATK_ROLE_APPLICATION:
1452 name = _("application");
1455 name = atk_role_get_name (role);
1462 * atk_role_for_name:
1463 * @name: a string which is the (non-localized) name of an ATK role.
1465 * Get the #AtkRole type corresponding to a rolew name.
1467 * Returns: the #AtkRole enumerated type corresponding to the specified
1469 * or #ATK_ROLE_INVALID if no matching role is found.
1472 atk_role_for_name (const gchar *name)
1474 GTypeClass *type_class;
1476 AtkRole role = ATK_ROLE_INVALID;
1478 g_return_val_if_fail (name, ATK_ROLE_INVALID);
1480 type_class = g_type_class_ref (ATK_TYPE_ROLE);
1481 g_return_val_if_fail (G_IS_ENUM_CLASS (type_class), ATK_ROLE_INVALID);
1483 value = g_enum_get_value_by_nick (G_ENUM_CLASS (type_class), name);
1487 role = value->value;
1495 for (i = 0; i < extra_roles->len; i++)
1497 gchar *extra_role = (gchar *)g_ptr_array_index (extra_roles, i);
1499 g_return_val_if_fail (extra_role, ATK_ROLE_INVALID);
1501 if (strcmp (name, extra_role) == 0)
1503 role = i + 1 + ATK_ROLE_LAST_DEFINED;
1509 g_type_class_unref (type_class);
1515 * atk_object_add_relationship:
1516 * @object: The #AtkObject to which an AtkRelation is to be added.
1517 * @relationship: The #AtkRelationType of the relation
1518 * @target: The #AtkObject which is to be the target of the relation.
1520 * Adds a relationship of the specified type with the specified target.
1522 * Returns TRUE if the relationship is added.
1525 atk_object_add_relationship (AtkObject *object,
1526 AtkRelationType relationship,
1529 AtkObject *array[1];
1530 AtkRelation *relation;
1532 g_return_val_if_fail (ATK_IS_OBJECT (object), FALSE);
1533 g_return_val_if_fail (ATK_IS_OBJECT (target), FALSE);
1536 relation = atk_relation_new (array, 1, relationship);
1537 atk_relation_set_add (object->relation_set, relation);
1538 g_object_unref (relation);
1544 * atk_object_remove_relationship:
1545 * @object: The #AtkObject from which an AtkRelation is to be removed.
1546 * @relationship: The #AtkRelationType of the relation
1547 * @target: The #AtkObject which is the target of the relation to be removed.
1549 * Removes a relationship of the specified type with the specified target.
1551 * Returns TRUE if the relationship is removed.
1554 atk_object_remove_relationship (AtkObject *object,
1555 AtkRelationType relationship,
1558 gint n_relations, i;
1559 gboolean ret = FALSE;
1560 AtkRelation *relation;
1562 g_return_val_if_fail (ATK_IS_OBJECT (object), FALSE);
1563 g_return_val_if_fail (ATK_IS_OBJECT (target), FALSE);
1565 n_relations = atk_relation_set_get_n_relations (object->relation_set);
1566 for (i = 0; i < n_relations; i++)
1568 relation = atk_relation_set_get_relation (object->relation_set, i);
1569 if (atk_relation_get_relation_type (relation) == relationship)
1573 array = atk_relation_get_target (relation);
1575 if (g_ptr_array_index (array, 0) == target)
1577 atk_relation_set_remove (object->relation_set, relation);