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>
25 #include "atkmarshal.h"
27 static gchar *role_names[ATK_ROLE_LAST_DEFINED] = {
84 "table_column_header",
101 PROP_0, /* gobject convention */
105 PROP_PARENT, /* ancestry has changed */
111 PROP_TABLE_COLUMN_DESCRIPTION,
112 PROP_TABLE_COLUMN_HEADER,
113 PROP_TABLE_ROW_DESCRIPTION,
114 PROP_TABLE_ROW_HEADER,
116 PROP_LAST /* gobject convention */
124 VISIBLE_DATA_CHANGED,
129 static void atk_object_class_init (AtkObjectClass *klass);
130 static void atk_object_init (AtkObject *accessible,
131 AtkObjectClass *klass);
132 static AtkRelationSet* atk_object_real_ref_relation_set
133 (AtkObject *accessible);
135 static void atk_object_real_set_property (GObject *object,
139 static void atk_object_real_get_property (GObject *object,
143 static void atk_object_finalize (GObject *object);
144 static G_CONST_RETURN gchar*
145 atk_object_real_get_name (AtkObject *object);
146 static G_CONST_RETURN gchar*
147 atk_object_real_get_description
149 static AtkObject* atk_object_real_get_parent (AtkObject *object);
150 static AtkRole atk_object_real_get_role (AtkObject *object);
151 static AtkLayer atk_object_real_get_layer (AtkObject *object);
152 static AtkStateSet* atk_object_real_ref_state_set
154 static void atk_object_real_set_name (AtkObject *object,
156 static void atk_object_real_set_description
158 const gchar *description);
159 static void atk_object_real_set_parent (AtkObject *object,
161 static void atk_object_real_set_role (AtkObject *object,
163 static guint atk_object_real_connect_property_change_handler
165 AtkPropertyChangeHandler
167 static void atk_object_real_remove_property_change_handler
170 static void atk_object_notify (GObject *obj,
174 static guint atk_object_signals[LAST_SIGNAL] = { 0, };
176 static gpointer parent_class = NULL;
178 static const gchar* atk_object_name_property_name = "accessible-name";
179 static const gchar* atk_object_name_property_description = "accessible-description";
180 static const gchar* atk_object_name_property_parent = "accessible-parent";
181 static const gchar* atk_object_name_property_value = "accessible-value";
182 static const gchar* atk_object_name_property_role = "accessible-role";
183 static const gchar* atk_object_name_property_component_layer = "accessible-component-layer";
184 static const gchar* atk_object_name_property_component_mdi_zorder = "accessible-component-mdi-zorder";
185 static const gchar* atk_object_name_property_table_caption = "accessible-table-caption";
186 static const gchar* atk_object_name_property_table_column_description = "accessible-table-column-description";
187 static const gchar* atk_object_name_property_table_column_header = "accessible-table-column-header";
188 static const gchar* atk_object_name_property_table_row_description = "accessible-table-row-description";
189 static const gchar* atk_object_name_property_table_row_header = "accessible-table-row-header";
190 static const gchar* atk_object_name_property_table_summary = "accessible-table-summary";
193 atk_object_get_type (void)
195 static GType type = 0;
199 static const GTypeInfo typeInfo =
201 sizeof (AtkObjectClass),
202 (GBaseInitFunc) NULL,
203 (GBaseFinalizeFunc) NULL,
204 (GClassInitFunc) atk_object_class_init,
205 (GClassFinalizeFunc) NULL,
209 (GInstanceInitFunc) atk_object_init,
211 type = g_type_register_static (G_TYPE_OBJECT, "AtkObject", &typeInfo, 0) ;
217 atk_object_class_init (AtkObjectClass *klass)
219 GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
221 parent_class = g_type_class_ref (G_TYPE_OBJECT);
223 gobject_class->set_property = atk_object_real_set_property;
224 gobject_class->get_property = atk_object_real_get_property;
225 gobject_class->finalize = atk_object_finalize;
226 gobject_class->notify = atk_object_notify;
228 klass->get_name = atk_object_real_get_name;
229 klass->get_description = atk_object_real_get_description;
230 klass->get_parent = atk_object_real_get_parent;
231 klass->get_n_children = NULL;
232 klass->ref_child = NULL;
233 klass->get_index_in_parent = NULL;
234 klass->ref_relation_set = atk_object_real_ref_relation_set;
235 klass->get_role = atk_object_real_get_role;
236 klass->get_layer = atk_object_real_get_layer;
237 klass->get_mdi_zorder = NULL;
238 klass->ref_state_set = atk_object_real_ref_state_set;
239 klass->set_name = atk_object_real_set_name;
240 klass->set_description = atk_object_real_set_description;
241 klass->set_parent = atk_object_real_set_parent;
242 klass->set_role = atk_object_real_set_role;
243 klass->connect_property_change_handler =
244 atk_object_real_connect_property_change_handler;
245 klass->remove_property_change_handler =
246 atk_object_real_remove_property_change_handler;
249 * We do not define default signal handlers here
251 klass->children_changed = NULL;
252 klass->focus_event = NULL;
253 klass->property_change = NULL;
254 klass->visible_data_changed = NULL;
256 g_object_class_install_property (gobject_class,
258 g_param_spec_string (atk_object_name_property_name,
260 "Object instance\'s name formatted for "
261 "assistive technology access",
264 g_object_class_install_property (gobject_class,
266 g_param_spec_string (atk_object_name_property_description,
267 "Accessible Description",
268 "Description of an object, formatted for "
269 "assistive technology access",
272 g_object_class_install_property (gobject_class,
274 g_param_spec_object (atk_object_name_property_parent,
276 "Is used to notify that the parent has changed ",
279 g_object_class_install_property (gobject_class,
281 g_param_spec_double (atk_object_name_property_value,
283 "Is used to notify that the value has changed ",
288 g_object_class_install_property (gobject_class,
290 g_param_spec_int (atk_object_name_property_role,
292 "The accessible role of this object ",
297 g_object_class_install_property (gobject_class,
299 g_param_spec_int (atk_object_name_property_component_layer,
301 "The accessible layer of this object ",
306 g_object_class_install_property (gobject_class,
308 g_param_spec_int (atk_object_name_property_component_mdi_zorder,
309 "Accessible MDI Value",
310 "The accessible MDI value of this object ",
315 g_object_class_install_property (gobject_class,
317 g_param_spec_string (atk_object_name_property_table_caption,
318 "Accessible Table Caption",
319 "Is used to notify that the table caption has changed ",
322 g_object_class_install_property (gobject_class,
323 PROP_TABLE_COLUMN_HEADER,
324 g_param_spec_object (atk_object_name_property_table_column_header,
325 "Accessible Table Column Header",
326 "Is used to notify that the table column header has changed ",
329 g_object_class_install_property (gobject_class,
330 PROP_TABLE_COLUMN_DESCRIPTION,
331 g_param_spec_string (atk_object_name_property_table_column_description,
332 "Accessible Table Column Description",
333 "Is used to notify that the table columnscription has changed ",
336 g_object_class_install_property (gobject_class,
337 PROP_TABLE_ROW_HEADER,
338 g_param_spec_object (atk_object_name_property_table_row_header,
339 "Accessible Table Row Header",
340 "Is used to notify that the table row header has changed ",
343 g_object_class_install_property (gobject_class,
344 PROP_TABLE_ROW_DESCRIPTION,
345 g_param_spec_string (atk_object_name_property_table_row_description,
346 "Accessible Table Row Description",
347 "Is used to notify that the table row description has changed ",
350 g_object_class_install_property (gobject_class,
352 g_param_spec_object (atk_object_name_property_table_summary,
353 "Accessible Table Summary",
354 "Is used to notify that the table summary has changed ",
358 * The signal "children_changed" supports two details:
361 atk_object_signals[CHILDREN_CHANGED] =
362 g_signal_new ("children_changed",
363 G_TYPE_FROM_CLASS (klass),
364 G_SIGNAL_RUN_LAST | G_SIGNAL_DETAILED,
365 G_STRUCT_OFFSET (AtkObjectClass, children_changed),
367 g_cclosure_marshal_VOID__UINT_POINTER,
369 2, G_TYPE_UINT, G_TYPE_POINTER);
370 atk_object_signals[FOCUS_EVENT] =
371 g_signal_new ("focus_event",
372 G_TYPE_FROM_CLASS (klass),
374 G_STRUCT_OFFSET (AtkObjectClass, focus_event),
376 g_cclosure_marshal_VOID__BOOLEAN,
379 atk_object_signals[PROPERTY_CHANGE] =
380 g_signal_new ("property_change",
381 G_TYPE_FROM_CLASS (klass),
382 G_SIGNAL_RUN_LAST | G_SIGNAL_DETAILED,
383 G_STRUCT_OFFSET (AtkObjectClass, property_change),
384 (GSignalAccumulator) NULL, NULL,
385 g_cclosure_marshal_VOID__POINTER,
389 * The "state_change" signal supports details, one for each accessible
393 atk_object_signals[STATE_CHANGE] =
394 g_signal_new ("state_change",
395 G_TYPE_FROM_CLASS (klass),
396 G_SIGNAL_RUN_LAST | G_SIGNAL_DETAILED,
397 G_STRUCT_OFFSET (AtkObjectClass, state_change),
398 (GSignalAccumulator) NULL, NULL,
399 atk_marshal_VOID__STRING_BOOLEAN,
403 atk_object_signals[VISIBLE_DATA_CHANGED] =
404 g_signal_new ("visible_data_changed",
405 G_TYPE_FROM_CLASS (klass),
407 G_STRUCT_OFFSET (AtkObjectClass, visible_data_changed),
408 (GSignalAccumulator) NULL, NULL,
409 g_cclosure_marshal_VOID__VOID,
414 atk_object_init (AtkObject *accessible,
415 AtkObjectClass *klass)
417 accessible->name = NULL;
418 accessible->description = NULL;
419 accessible->accessible_parent = NULL;
420 accessible->relation_set = atk_relation_set_new();
421 accessible->role = ATK_ROLE_UNKNOWN;
425 atk_implementor_get_type (void)
427 static GType type = 0;
431 static const GTypeInfo typeInfo =
433 sizeof (AtkImplementorIface),
434 (GBaseInitFunc) NULL,
435 (GBaseFinalizeFunc) NULL,
438 type = g_type_register_static (G_TYPE_INTERFACE, "AtkImplementorIface", &typeInfo, 0) ;
445 * atk_object_get_name:
446 * @accessible: an #AtkObject
448 * Gets the accessible name of the accessible.
450 * Returns: a character string representing the accessible name of the object.
452 G_CONST_RETURN gchar*
453 atk_object_get_name (AtkObject *accessible)
455 AtkObjectClass *klass;
457 g_return_val_if_fail (ATK_IS_OBJECT (accessible), NULL);
459 klass = ATK_OBJECT_GET_CLASS (accessible);
461 return (klass->get_name) (accessible);
467 * atk_object_get_description:
468 * @accessible: an #AtkObject
470 * Gets the accessible description of the accessible.
472 * Returns: a character string representing the accessible description
476 G_CONST_RETURN gchar*
477 atk_object_get_description (AtkObject *accessible)
479 AtkObjectClass *klass;
481 g_return_val_if_fail (ATK_IS_OBJECT (accessible), NULL);
483 klass = ATK_OBJECT_GET_CLASS (accessible);
484 if (klass->get_description)
485 return (klass->get_description) (accessible);
491 * atk_object_get_parent:
492 * @accessible: an #AtkObject
494 * Gets the accessible parent of the accessible.
496 * Returns: a #AtkObject representing the accessible parent of the accessible
499 atk_object_get_parent (AtkObject *accessible)
501 AtkObjectClass *klass;
503 g_return_val_if_fail (ATK_IS_OBJECT (accessible), NULL);
505 klass = ATK_OBJECT_GET_CLASS (accessible);
506 if (klass->get_parent)
507 return (klass->get_parent) (accessible);
513 * atk_object_get_n_accessible_children:
514 * @accessible: an #AtkObject
516 * Gets the number of accessible children of the accessible.
518 * Returns: an integer representing the number of accessible children
522 atk_object_get_n_accessible_children (AtkObject *accessible)
524 AtkObjectClass *klass;
526 g_return_val_if_fail (ATK_IS_OBJECT (accessible), 0);
528 klass = ATK_OBJECT_GET_CLASS (accessible);
529 if (klass->get_n_children)
530 return (klass->get_n_children) (accessible);
536 * atk_object_ref_accessible_child:
537 * @accessible: an #AtkObject
538 * @i: a gint representing the position of the child, starting from 0
540 * Gets a reference to the specified accessible child of the object.
541 * The accessible children are 0-based so the first accessible child is
542 * at index 0, the second at index 1 and so on.
544 * Returns: an #AtkObject representing the specified accessible child
548 atk_object_ref_accessible_child (AtkObject *accessible,
551 AtkObjectClass *klass;
553 g_return_val_if_fail (ATK_IS_OBJECT (accessible), NULL);
555 klass = ATK_OBJECT_GET_CLASS (accessible);
556 if (klass->ref_child)
557 return (klass->ref_child) (accessible, i);
563 * atk_object_ref_relation_set:
564 * @accessible: an #AtkObject
566 * Gets the #AtkRelationSet associated with the object.
568 * Returns: an #AtkRelationSet representing the relation set of the object.
571 atk_object_ref_relation_set (AtkObject *accessible)
573 AtkObjectClass *klass;
575 g_return_val_if_fail (ATK_IS_OBJECT (accessible), NULL);
577 klass = ATK_OBJECT_GET_CLASS (accessible);
578 if (klass->ref_relation_set)
579 return (klass->ref_relation_set) (accessible);
586 * @name: a character string describing the new role.
588 * Registers the role specified by @name.
590 * Returns: an #AtkRole for the new role.
593 atk_role_register (const gchar *name)
595 /* TODO: associate name with new type */
596 static guint type = ATK_ROLE_LAST_DEFINED;
601 * atk_object_get_role:
602 * @accessible: an #AtkObject
604 * Gets the role of the accessible.
606 * Returns: an #AtkRole which is the role of the accessible
609 atk_object_get_role (AtkObject *accessible)
611 AtkObjectClass *klass;
613 g_return_val_if_fail (ATK_IS_OBJECT (accessible), ATK_ROLE_UNKNOWN);
615 klass = ATK_OBJECT_GET_CLASS (accessible);
617 return (klass->get_role) (accessible);
619 return ATK_ROLE_UNKNOWN;
623 * atk_object_get_layer:
624 * @accessible: an #AtkObject
626 * Gets the layer of the accessible.
628 * Returns: an #AtkLayer which is the layer of the accessible
631 atk_object_get_layer (AtkObject *accessible)
633 AtkObjectClass *klass;
635 g_return_val_if_fail (ATK_IS_OBJECT (accessible), ATK_LAYER_INVALID);
637 klass = ATK_OBJECT_GET_CLASS (accessible);
638 if (klass->get_layer)
639 return (klass->get_layer) (accessible);
641 return ATK_LAYER_INVALID;
645 * atk_object_get_mdi_zorder:
646 * @accessible: an #AtkObject
648 * Gets the zorder of the accessible. The value G_MININT will be returned
649 * if the layer of the accessible is not ATK_LAYER_MDI.
651 * Returns: a gint which is the zorder of the accessible, i.e. the depth at
652 * which the component is shown in relation to other components in the same
656 atk_object_get_mdi_zorder (AtkObject *accessible)
658 AtkObjectClass *klass;
660 g_return_val_if_fail (ATK_IS_OBJECT (accessible), G_MININT);
662 klass = ATK_OBJECT_GET_CLASS (accessible);
663 if (klass->get_mdi_zorder)
664 return (klass->get_mdi_zorder) (accessible);
670 * atk_object_ref_state_set:
671 * @accessible: an #AtkObject
673 * Gets a reference to the state set of the accessible; the caller must
674 * unreference it when it is no longer needed.
676 * Returns: a reference to an #AtkStateSet which is the state
677 * set of the accessible
680 atk_object_ref_state_set (AtkObject *accessible)
682 AtkObjectClass *klass;
684 g_return_val_if_fail (ATK_IS_OBJECT (accessible), NULL);
686 klass = ATK_OBJECT_GET_CLASS (accessible);
687 if (klass->ref_state_set)
688 return (klass->ref_state_set) (accessible);
694 * atk_object_get_index_in_parent:
695 * @accessible: an #AtkObject
697 * Gets the 0-based index of this accessible in its parent; returns -1 if the
698 * accessible does not have an accessible parent.
700 * Returns: an integer which is the index of the accessible in its parent
703 atk_object_get_index_in_parent (AtkObject *accessible)
705 AtkObjectClass *klass;
707 g_return_val_if_fail (ATK_OBJECT (accessible), -1);
709 klass = ATK_OBJECT_GET_CLASS (accessible);
710 if (klass->get_index_in_parent)
711 return (klass->get_index_in_parent) (accessible);
717 * atk_object_set_name:
718 * @accessible: an #AtkObject
719 * @name: a character string to be set as the accessible name
721 * Sets the accessible name of the accessible.
724 atk_object_set_name (AtkObject *accessible,
727 AtkObjectClass *klass;
729 g_return_if_fail (ATK_IS_OBJECT (accessible));
730 g_return_if_fail (name != NULL);
732 klass = ATK_OBJECT_GET_CLASS (accessible);
735 (klass->set_name) (accessible, name);
736 g_object_notify (G_OBJECT (accessible), atk_object_name_property_name);
741 * atk_object_set_description:
742 * @accessible: an #AtkObject
743 * @description : a character string to be set as the accessible description
745 * Sets the accessible description of the accessible.
748 atk_object_set_description (AtkObject *accessible,
749 const gchar *description)
751 AtkObjectClass *klass;
753 g_return_if_fail (ATK_IS_OBJECT (accessible));
754 g_return_if_fail (description != NULL);
756 klass = ATK_OBJECT_GET_CLASS (accessible);
757 if (klass->set_description)
759 (klass->set_description) (accessible, description);
760 g_object_notify (G_OBJECT (accessible), atk_object_name_property_description);
765 * atk_object_set_parent:
766 * @accessible: an #AtkObject
767 * @parent : an #AtkObject to be set as the accessible parent
769 * Sets the accessible parent of the accessible.
772 atk_object_set_parent (AtkObject *accessible,
775 AtkObjectClass *klass;
777 g_return_if_fail (ATK_IS_OBJECT (accessible));
779 klass = ATK_OBJECT_GET_CLASS (accessible);
780 if (klass->set_parent)
782 (klass->set_parent) (accessible, parent);
783 g_object_notify (G_OBJECT (accessible), atk_object_name_property_parent);
788 * atk_object_set_role:
789 * @accessible: an #AtkObject
790 * @role : an #AtkRole to be set as the role
792 * Sets the role of the accessible.
795 atk_object_set_role (AtkObject *accessible,
798 AtkObjectClass *klass;
800 g_return_if_fail (ATK_IS_OBJECT (accessible));
802 klass = ATK_OBJECT_GET_CLASS (accessible);
805 (klass->set_role) (accessible, role);
806 g_object_notify (G_OBJECT (accessible), atk_object_name_property_role);
811 * atk_object_connect_property_change_handler:
812 * @accessible: an #AtkObject
813 * @handler : a function to be called when a property changes its value
815 * Specifies a function to be called when a property changes value.
817 * Returns: a #guint which is the handler id used in
818 * atk_object_remove_property_change_handler()
821 atk_object_connect_property_change_handler (AtkObject *accessible,
822 AtkPropertyChangeHandler *handler)
824 AtkObjectClass *klass;
826 g_return_val_if_fail (ATK_IS_OBJECT (accessible), 0);
827 g_return_val_if_fail ((handler != NULL), 0);
829 klass = ATK_OBJECT_GET_CLASS (accessible);
830 if (klass->connect_property_change_handler)
831 return (klass->connect_property_change_handler) (accessible, handler);
837 * atk_object_remove_property_change_handler:
838 * @accessible: an #AtkObject
839 * @handler_id : a guint which identifies the handler to be removed.
841 * Removes a property change handler.
844 atk_object_remove_property_change_handler (AtkObject *accessible,
847 AtkObjectClass *klass;
849 g_return_if_fail (ATK_IS_OBJECT (accessible));
851 klass = ATK_OBJECT_GET_CLASS (accessible);
852 if (klass->remove_property_change_handler)
853 (klass->remove_property_change_handler) (accessible, handler_id);
857 * atk_object_notify_state_change:
858 * @accessible: an #AtkObject
859 * @state: an #AtkState whose state is changed
860 * @value : a gboolean which indicates whether the state is being set on or off
862 * Emits a state-change signal for the specified state.
865 atk_object_notify_state_change (AtkObject *accessible,
869 G_CONST_RETURN gchar* name;
871 name = atk_state_type_get_name (state);
872 g_signal_emit (accessible, atk_object_signals[STATE_CHANGE],
873 g_quark_from_string (name),
878 * atk_implementor_ref_accessible:
879 * @implementor: The #GObject instance which should implement #AtkImplementorIface
880 * if a non-null return value is required.
882 * Gets a reference to an object's #AtkObject implementation, if
883 * the object implements #AtkObjectIface
885 * Returns: a reference to an object's #AtkObject implementation
888 atk_implementor_ref_accessible (AtkImplementor *object)
890 AtkImplementorIface *iface;
891 AtkObject *accessible = NULL;
893 g_return_val_if_fail (ATK_IS_IMPLEMENTOR (object), NULL);
895 iface = ATK_IMPLEMENTOR_GET_IFACE (object);
898 accessible = iface->ref_accessible (object);
900 g_return_val_if_fail ((accessible != NULL), NULL);
905 static AtkRelationSet*
906 atk_object_real_ref_relation_set (AtkObject *accessible)
908 g_return_val_if_fail (accessible->relation_set, NULL);
909 g_object_ref (accessible->relation_set);
911 return accessible->relation_set;
915 atk_object_real_set_property (GObject *object,
920 AtkObject *accessible;
922 accessible = ATK_OBJECT (object);
927 atk_object_set_name (accessible, g_value_get_string (value));
929 case PROP_DESCRIPTION:
930 atk_object_set_description (accessible, g_value_get_string (value));
933 atk_object_set_role (accessible, g_value_get_int (value));
936 atk_object_set_parent (accessible, g_value_get_object (value));
939 if (ATK_IS_VALUE (accessible))
940 atk_value_set_current_value (ATK_VALUE (accessible), value);
948 atk_object_real_get_property (GObject *object,
953 AtkObject *accessible;
955 accessible = ATK_OBJECT (object);
960 g_value_set_string (value, atk_object_get_name (accessible));
962 case PROP_DESCRIPTION:
963 g_value_set_string (value, atk_object_get_description (accessible));
966 g_value_set_int (value, atk_object_get_role (accessible));
969 g_value_set_int (value, atk_object_get_role (accessible));
971 case PROP_MDI_ZORDER:
972 g_value_set_int (value, atk_object_get_mdi_zorder (accessible));
975 g_value_set_object (value, atk_object_get_parent (accessible));
978 if (ATK_IS_VALUE (accessible))
979 atk_value_get_current_value (ATK_VALUE (accessible), value);
982 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
988 atk_object_finalize (GObject *object)
990 AtkObject *accessible;
992 g_return_if_fail (ATK_IS_OBJECT (object));
994 accessible = ATK_OBJECT (object);
996 g_free (accessible->name);
997 g_free (accessible->description);
1000 * Free memory allocated for relation set if it have been allocated.
1002 if (accessible->relation_set)
1003 g_object_unref (accessible->relation_set);
1005 if (accessible->accessible_parent)
1006 g_object_unref (accessible->accessible_parent);
1008 G_OBJECT_CLASS (parent_class)->finalize (object);
1011 static G_CONST_RETURN gchar*
1012 atk_object_real_get_name (AtkObject *object)
1014 return object->name;
1017 static G_CONST_RETURN gchar*
1018 atk_object_real_get_description (AtkObject *object)
1020 return object->description;
1024 atk_object_real_get_parent (AtkObject *object)
1026 return object->accessible_parent;
1030 atk_object_real_get_role (AtkObject *object)
1032 return object->role;
1036 atk_object_real_get_layer (AtkObject *object)
1038 return object->layer;
1042 atk_object_real_ref_state_set (AtkObject *accessible)
1044 AtkStateSet *state_set;
1047 state_set = atk_state_set_new ();
1049 ap = atk_object_get_parent (accessible);
1051 if (ATK_IS_SELECTION (ap))
1055 atk_state_set_add_state (state_set, ATK_STATE_SELECTABLE);
1057 i = atk_object_get_index_in_parent (accessible);
1059 if (atk_selection_is_child_selected(ATK_SELECTION (ap), i))
1060 atk_state_set_add_state (state_set, ATK_STATE_SELECTED);
1067 atk_object_real_set_name (AtkObject *object,
1070 g_free (object->name);
1071 object->name = g_strdup (name);
1075 atk_object_real_set_description (AtkObject *object,
1076 const gchar *description)
1078 g_free (object->description);
1079 object->description = g_strdup (description);
1083 atk_object_real_set_parent (AtkObject *object,
1086 if (object->accessible_parent)
1087 g_object_unref (object->accessible_parent);
1089 object->accessible_parent = parent;
1090 if (object->accessible_parent)
1091 g_object_ref (object->accessible_parent);
1095 atk_object_real_set_role (AtkObject *object,
1098 object->role = role;
1102 atk_object_real_connect_property_change_handler (AtkObject *obj,
1103 AtkPropertyChangeHandler *handler)
1105 return g_signal_connect_closure_by_id (obj,
1106 atk_object_signals[PROPERTY_CHANGE],
1109 G_CALLBACK (handler), NULL,
1110 (GClosureNotify) NULL),
1115 atk_object_real_remove_property_change_handler (AtkObject *obj,
1118 g_signal_handler_disconnect (obj, handler_id);
1122 * This function is a signal handler for notify signal which gets emitted
1123 * when a property changes value.
1125 * It constructs an AtkPropertyValues structure and emits a "property_changed"
1126 * signal which causes the user specified AtkPropertyChangeHandler
1130 atk_object_notify (GObject *obj,
1133 AtkPropertyValues values = { 0, };
1135 g_value_init (&values.new_value, pspec->value_type);
1136 g_object_get_property (obj, pspec->name, &values.new_value);
1137 values.property_name = pspec->name;
1138 g_signal_emit (obj, atk_object_signals[PROPERTY_CHANGE],
1139 g_quark_from_string (pspec->name),
1144 * atk_role_get_name:
1145 * @role: The #AtkRole whose name is required
1147 * Gets the description string describing the #Roleype @role.
1149 * Returns: the string describing the AtkRole
1151 G_CONST_RETURN gchar*
1152 atk_role_get_name (AtkRole role)
1158 if ((n >= 0) && (n < ATK_ROLE_LAST_DEFINED))
1159 return role_names[n];
1161 return role_names[ATK_ROLE_INVALID];
1165 * atk_role_for_name:
1166 * @name: a string which is the (non-localized) name of an ATK role.
1168 * Get the #AtkRole type corresponding to a rolew name.
1170 * Returns: the #AtkRole enumerated type corresponding to the specified
1172 * or #ATK_ROLE_INVALID if no matching role is found.
1175 atk_role_for_name (const gchar *name)
1179 g_return_val_if_fail (name, ATK_ROLE_INVALID);
1181 for (i = 0; i < ATK_ROLE_LAST_DEFINED; i++)
1183 if (strcmp (name, role_names[i]) == 0)
1186 return ATK_ROLE_INVALID;