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"
26 #include "atk-enum-types.h"
28 GPtrArray
*extra_roles
= NULL
;
32 PROP_0
, /* gobject convention */
36 PROP_PARENT
, /* ancestry has changed */
42 PROP_TABLE_COLUMN_DESCRIPTION
,
43 PROP_TABLE_COLUMN_HEADER
,
44 PROP_TABLE_ROW_DESCRIPTION
,
45 PROP_TABLE_ROW_HEADER
,
47 PROP_LAST
/* gobject convention */
60 static void atk_object_class_init (AtkObjectClass
*klass
);
61 static void atk_object_init (AtkObject
*accessible
,
62 AtkObjectClass
*klass
);
63 static AtkRelationSet
* atk_object_real_ref_relation_set
64 (AtkObject
*accessible
);
66 static void atk_object_real_set_property (GObject
*object
,
70 static void atk_object_real_get_property (GObject
*object
,
74 static void atk_object_finalize (GObject
*object
);
75 static G_CONST_RETURN gchar
*
76 atk_object_real_get_name (AtkObject
*object
);
77 static G_CONST_RETURN gchar
*
78 atk_object_real_get_description
80 static AtkObject
* atk_object_real_get_parent (AtkObject
*object
);
81 static AtkRole
atk_object_real_get_role (AtkObject
*object
);
82 static AtkLayer
atk_object_real_get_layer (AtkObject
*object
);
83 static AtkStateSet
* atk_object_real_ref_state_set
85 static void atk_object_real_set_name (AtkObject
*object
,
87 static void atk_object_real_set_description
89 const gchar
*description
);
90 static void atk_object_real_set_parent (AtkObject
*object
,
92 static void atk_object_real_set_role (AtkObject
*object
,
94 static guint atk_object_real_connect_property_change_handler
96 AtkPropertyChangeHandler
98 static void atk_object_real_remove_property_change_handler
101 static void atk_object_notify (GObject
*obj
,
105 static guint atk_object_signals
[LAST_SIGNAL
] = { 0, };
107 static gpointer parent_class
= NULL
;
109 static const gchar
* atk_object_name_property_name
= "accessible-name";
110 static const gchar
* atk_object_name_property_description
= "accessible-description";
111 static const gchar
* atk_object_name_property_parent
= "accessible-parent";
112 static const gchar
* atk_object_name_property_value
= "accessible-value";
113 static const gchar
* atk_object_name_property_role
= "accessible-role";
114 static const gchar
* atk_object_name_property_component_layer
= "accessible-component-layer";
115 static const gchar
* atk_object_name_property_component_mdi_zorder
= "accessible-component-mdi-zorder";
116 static const gchar
* atk_object_name_property_table_caption
= "accessible-table-caption";
117 static const gchar
* atk_object_name_property_table_column_description
= "accessible-table-column-description";
118 static const gchar
* atk_object_name_property_table_column_header
= "accessible-table-column-header";
119 static const gchar
* atk_object_name_property_table_row_description
= "accessible-table-row-description";
120 static const gchar
* atk_object_name_property_table_row_header
= "accessible-table-row-header";
121 static const gchar
* atk_object_name_property_table_summary
= "accessible-table-summary";
124 atk_object_get_type (void)
126 static GType type
= 0;
130 static const GTypeInfo typeInfo
=
132 sizeof (AtkObjectClass
),
133 (GBaseInitFunc
) NULL
,
134 (GBaseFinalizeFunc
) NULL
,
135 (GClassInitFunc
) atk_object_class_init
,
136 (GClassFinalizeFunc
) NULL
,
140 (GInstanceInitFunc
) atk_object_init
,
142 type
= g_type_register_static (G_TYPE_OBJECT
, "AtkObject", &typeInfo
, 0) ;
148 atk_object_class_init (AtkObjectClass
*klass
)
150 GObjectClass
*gobject_class
= G_OBJECT_CLASS (klass
);
152 parent_class
= g_type_class_ref (G_TYPE_OBJECT
);
154 gobject_class
->set_property
= atk_object_real_set_property
;
155 gobject_class
->get_property
= atk_object_real_get_property
;
156 gobject_class
->finalize
= atk_object_finalize
;
157 gobject_class
->notify
= atk_object_notify
;
159 klass
->get_name
= atk_object_real_get_name
;
160 klass
->get_description
= atk_object_real_get_description
;
161 klass
->get_parent
= atk_object_real_get_parent
;
162 klass
->get_n_children
= NULL
;
163 klass
->ref_child
= NULL
;
164 klass
->get_index_in_parent
= NULL
;
165 klass
->ref_relation_set
= atk_object_real_ref_relation_set
;
166 klass
->get_role
= atk_object_real_get_role
;
167 klass
->get_layer
= atk_object_real_get_layer
;
168 klass
->get_mdi_zorder
= NULL
;
169 klass
->ref_state_set
= atk_object_real_ref_state_set
;
170 klass
->set_name
= atk_object_real_set_name
;
171 klass
->set_description
= atk_object_real_set_description
;
172 klass
->set_parent
= atk_object_real_set_parent
;
173 klass
->set_role
= atk_object_real_set_role
;
174 klass
->connect_property_change_handler
=
175 atk_object_real_connect_property_change_handler
;
176 klass
->remove_property_change_handler
=
177 atk_object_real_remove_property_change_handler
;
180 * We do not define default signal handlers here
182 klass
->children_changed
= NULL
;
183 klass
->focus_event
= NULL
;
184 klass
->property_change
= NULL
;
185 klass
->visible_data_changed
= NULL
;
187 g_object_class_install_property (gobject_class
,
189 g_param_spec_string (atk_object_name_property_name
,
191 "Object instance\'s name formatted for "
192 "assistive technology access",
195 g_object_class_install_property (gobject_class
,
197 g_param_spec_string (atk_object_name_property_description
,
198 "Accessible Description",
199 "Description of an object, formatted for "
200 "assistive technology access",
203 g_object_class_install_property (gobject_class
,
205 g_param_spec_object (atk_object_name_property_parent
,
207 "Is used to notify that the parent has changed ",
210 g_object_class_install_property (gobject_class
,
212 g_param_spec_double (atk_object_name_property_value
,
214 "Is used to notify that the value has changed ",
219 g_object_class_install_property (gobject_class
,
221 g_param_spec_int (atk_object_name_property_role
,
223 "The accessible role of this object ",
228 g_object_class_install_property (gobject_class
,
230 g_param_spec_int (atk_object_name_property_component_layer
,
232 "The accessible layer of this object ",
237 g_object_class_install_property (gobject_class
,
239 g_param_spec_int (atk_object_name_property_component_mdi_zorder
,
240 "Accessible MDI Value",
241 "The accessible MDI value of this object ",
246 g_object_class_install_property (gobject_class
,
248 g_param_spec_string (atk_object_name_property_table_caption
,
249 "Accessible Table Caption",
250 "Is used to notify that the table caption has changed ",
253 g_object_class_install_property (gobject_class
,
254 PROP_TABLE_COLUMN_HEADER
,
255 g_param_spec_object (atk_object_name_property_table_column_header
,
256 "Accessible Table Column Header",
257 "Is used to notify that the table column header has changed ",
260 g_object_class_install_property (gobject_class
,
261 PROP_TABLE_COLUMN_DESCRIPTION
,
262 g_param_spec_string (atk_object_name_property_table_column_description
,
263 "Accessible Table Column Description",
264 "Is used to notify that the table columnscription has changed ",
267 g_object_class_install_property (gobject_class
,
268 PROP_TABLE_ROW_HEADER
,
269 g_param_spec_object (atk_object_name_property_table_row_header
,
270 "Accessible Table Row Header",
271 "Is used to notify that the table row header has changed ",
274 g_object_class_install_property (gobject_class
,
275 PROP_TABLE_ROW_DESCRIPTION
,
276 g_param_spec_string (atk_object_name_property_table_row_description
,
277 "Accessible Table Row Description",
278 "Is used to notify that the table row description has changed ",
281 g_object_class_install_property (gobject_class
,
283 g_param_spec_object (atk_object_name_property_table_summary
,
284 "Accessible Table Summary",
285 "Is used to notify that the table summary has changed ",
289 * The signal "children_changed" supports two details:
292 atk_object_signals
[CHILDREN_CHANGED
] =
293 g_signal_new ("children_changed",
294 G_TYPE_FROM_CLASS (klass
),
295 G_SIGNAL_RUN_LAST
| G_SIGNAL_DETAILED
,
296 G_STRUCT_OFFSET (AtkObjectClass
, children_changed
),
298 g_cclosure_marshal_VOID__UINT_POINTER
,
300 2, G_TYPE_UINT
, G_TYPE_POINTER
);
301 atk_object_signals
[FOCUS_EVENT
] =
302 g_signal_new ("focus_event",
303 G_TYPE_FROM_CLASS (klass
),
305 G_STRUCT_OFFSET (AtkObjectClass
, focus_event
),
307 g_cclosure_marshal_VOID__BOOLEAN
,
310 atk_object_signals
[PROPERTY_CHANGE
] =
311 g_signal_new ("property_change",
312 G_TYPE_FROM_CLASS (klass
),
313 G_SIGNAL_RUN_LAST
| G_SIGNAL_DETAILED
,
314 G_STRUCT_OFFSET (AtkObjectClass
, property_change
),
315 (GSignalAccumulator
) NULL
, NULL
,
316 g_cclosure_marshal_VOID__POINTER
,
320 * The "state_change" signal supports details, one for each accessible
324 atk_object_signals
[STATE_CHANGE
] =
325 g_signal_new ("state_change",
326 G_TYPE_FROM_CLASS (klass
),
327 G_SIGNAL_RUN_LAST
| G_SIGNAL_DETAILED
,
328 G_STRUCT_OFFSET (AtkObjectClass
, state_change
),
329 (GSignalAccumulator
) NULL
, NULL
,
330 atk_marshal_VOID__STRING_BOOLEAN
,
334 atk_object_signals
[VISIBLE_DATA_CHANGED
] =
335 g_signal_new ("visible_data_changed",
336 G_TYPE_FROM_CLASS (klass
),
338 G_STRUCT_OFFSET (AtkObjectClass
, visible_data_changed
),
339 (GSignalAccumulator
) NULL
, NULL
,
340 g_cclosure_marshal_VOID__VOID
,
345 atk_object_init (AtkObject
*accessible
,
346 AtkObjectClass
*klass
)
348 accessible
->name
= NULL
;
349 accessible
->description
= NULL
;
350 accessible
->accessible_parent
= NULL
;
351 accessible
->relation_set
= atk_relation_set_new();
352 accessible
->role
= ATK_ROLE_UNKNOWN
;
356 atk_implementor_get_type (void)
358 static GType type
= 0;
362 static const GTypeInfo typeInfo
=
364 sizeof (AtkImplementorIface
),
365 (GBaseInitFunc
) NULL
,
366 (GBaseFinalizeFunc
) NULL
,
369 type
= g_type_register_static (G_TYPE_INTERFACE
, "AtkImplementorIface", &typeInfo
, 0) ;
376 * atk_object_get_name:
377 * @accessible: an #AtkObject
379 * Gets the accessible name of the accessible.
381 * Returns: a character string representing the accessible name of the object.
383 G_CONST_RETURN gchar
*
384 atk_object_get_name (AtkObject
*accessible
)
386 AtkObjectClass
*klass
;
388 g_return_val_if_fail (ATK_IS_OBJECT (accessible
), NULL
);
390 klass
= ATK_OBJECT_GET_CLASS (accessible
);
392 return (klass
->get_name
) (accessible
);
398 * atk_object_get_description:
399 * @accessible: an #AtkObject
401 * Gets the accessible description of the accessible.
403 * Returns: a character string representing the accessible description
407 G_CONST_RETURN gchar
*
408 atk_object_get_description (AtkObject
*accessible
)
410 AtkObjectClass
*klass
;
412 g_return_val_if_fail (ATK_IS_OBJECT (accessible
), NULL
);
414 klass
= ATK_OBJECT_GET_CLASS (accessible
);
415 if (klass
->get_description
)
416 return (klass
->get_description
) (accessible
);
422 * atk_object_get_parent:
423 * @accessible: an #AtkObject
425 * Gets the accessible parent of the accessible.
427 * Returns: a #AtkObject representing the accessible parent of the accessible
430 atk_object_get_parent (AtkObject
*accessible
)
432 AtkObjectClass
*klass
;
434 g_return_val_if_fail (ATK_IS_OBJECT (accessible
), NULL
);
436 klass
= ATK_OBJECT_GET_CLASS (accessible
);
437 if (klass
->get_parent
)
438 return (klass
->get_parent
) (accessible
);
444 * atk_object_get_n_accessible_children:
445 * @accessible: an #AtkObject
447 * Gets the number of accessible children of the accessible.
449 * Returns: an integer representing the number of accessible children
453 atk_object_get_n_accessible_children (AtkObject
*accessible
)
455 AtkObjectClass
*klass
;
457 g_return_val_if_fail (ATK_IS_OBJECT (accessible
), 0);
459 klass
= ATK_OBJECT_GET_CLASS (accessible
);
460 if (klass
->get_n_children
)
461 return (klass
->get_n_children
) (accessible
);
467 * atk_object_ref_accessible_child:
468 * @accessible: an #AtkObject
469 * @i: a gint representing the position of the child, starting from 0
471 * Gets a reference to the specified accessible child of the object.
472 * The accessible children are 0-based so the first accessible child is
473 * at index 0, the second at index 1 and so on.
475 * Returns: an #AtkObject representing the specified accessible child
479 atk_object_ref_accessible_child (AtkObject
*accessible
,
482 AtkObjectClass
*klass
;
484 g_return_val_if_fail (ATK_IS_OBJECT (accessible
), NULL
);
486 klass
= ATK_OBJECT_GET_CLASS (accessible
);
487 if (klass
->ref_child
)
488 return (klass
->ref_child
) (accessible
, i
);
494 * atk_object_ref_relation_set:
495 * @accessible: an #AtkObject
497 * Gets the #AtkRelationSet associated with the object.
499 * Returns: an #AtkRelationSet representing the relation set of the object.
502 atk_object_ref_relation_set (AtkObject
*accessible
)
504 AtkObjectClass
*klass
;
506 g_return_val_if_fail (ATK_IS_OBJECT (accessible
), NULL
);
508 klass
= ATK_OBJECT_GET_CLASS (accessible
);
509 if (klass
->ref_relation_set
)
510 return (klass
->ref_relation_set
) (accessible
);
517 * @name: a character string describing the new role.
519 * Registers the role specified by @name.
521 * Returns: an #AtkRole for the new role.
524 atk_role_register (const gchar
*name
)
527 extra_roles
= g_ptr_array_new ();
529 g_ptr_array_add (extra_roles
, g_strdup (name
));
530 return extra_roles
->len
+ ATK_ROLE_LAST_DEFINED
;
534 * atk_object_get_role:
535 * @accessible: an #AtkObject
537 * Gets the role of the accessible.
539 * Returns: an #AtkRole which is the role of the accessible
542 atk_object_get_role (AtkObject
*accessible
)
544 AtkObjectClass
*klass
;
546 g_return_val_if_fail (ATK_IS_OBJECT (accessible
), ATK_ROLE_UNKNOWN
);
548 klass
= ATK_OBJECT_GET_CLASS (accessible
);
550 return (klass
->get_role
) (accessible
);
552 return ATK_ROLE_UNKNOWN
;
556 * atk_object_get_layer:
557 * @accessible: an #AtkObject
559 * Gets the layer of the accessible.
560 * DEPRECATED: use atk_component_get_layer instead!
562 * Returns: an #AtkLayer which is the layer of the accessible
565 atk_object_get_layer (AtkObject
*accessible
)
567 AtkObjectClass
*klass
;
569 g_return_val_if_fail (ATK_IS_OBJECT (accessible
), ATK_LAYER_INVALID
);
571 klass
= ATK_OBJECT_GET_CLASS (accessible
);
572 if (klass
->get_layer
)
573 return (klass
->get_layer
) (accessible
);
575 return ATK_LAYER_INVALID
;
579 * atk_object_get_mdi_zorder:
580 * @accessible: an #AtkObject
582 * Gets the zorder of the accessible. The value G_MININT will be returned
583 * if the layer of the accessible is not ATK_LAYER_MDI.
584 * DEPRECATED: use atk_component_get_mdi_zorder instead!
586 * Returns: a gint which is the zorder of the accessible, i.e. the depth at
587 * which the component is shown in relation to other components in the same
591 atk_object_get_mdi_zorder (AtkObject
*accessible
)
593 AtkObjectClass
*klass
;
595 g_return_val_if_fail (ATK_IS_OBJECT (accessible
), G_MININT
);
597 klass
= ATK_OBJECT_GET_CLASS (accessible
);
598 if (klass
->get_mdi_zorder
)
599 return (klass
->get_mdi_zorder
) (accessible
);
605 * atk_object_ref_state_set:
606 * @accessible: an #AtkObject
608 * Gets a reference to the state set of the accessible; the caller must
609 * unreference it when it is no longer needed.
611 * Returns: a reference to an #AtkStateSet which is the state
612 * set of the accessible
615 atk_object_ref_state_set (AtkObject
*accessible
)
617 AtkObjectClass
*klass
;
619 g_return_val_if_fail (ATK_IS_OBJECT (accessible
), NULL
);
621 klass
= ATK_OBJECT_GET_CLASS (accessible
);
622 if (klass
->ref_state_set
)
623 return (klass
->ref_state_set
) (accessible
);
629 * atk_object_get_index_in_parent:
630 * @accessible: an #AtkObject
632 * Gets the 0-based index of this accessible in its parent; returns -1 if the
633 * accessible does not have an accessible parent.
635 * Returns: an integer which is the index of the accessible in its parent
638 atk_object_get_index_in_parent (AtkObject
*accessible
)
640 AtkObjectClass
*klass
;
642 g_return_val_if_fail (ATK_OBJECT (accessible
), -1);
644 klass
= ATK_OBJECT_GET_CLASS (accessible
);
645 if (klass
->get_index_in_parent
)
646 return (klass
->get_index_in_parent
) (accessible
);
652 * atk_object_set_name:
653 * @accessible: an #AtkObject
654 * @name: a character string to be set as the accessible name
656 * Sets the accessible name of the accessible.
659 atk_object_set_name (AtkObject
*accessible
,
662 AtkObjectClass
*klass
;
664 g_return_if_fail (ATK_IS_OBJECT (accessible
));
665 g_return_if_fail (name
!= NULL
);
667 klass
= ATK_OBJECT_GET_CLASS (accessible
);
670 (klass
->set_name
) (accessible
, name
);
671 g_object_notify (G_OBJECT (accessible
), atk_object_name_property_name
);
676 * atk_object_set_description:
677 * @accessible: an #AtkObject
678 * @description : a character string to be set as the accessible description
680 * Sets the accessible description of the accessible.
683 atk_object_set_description (AtkObject
*accessible
,
684 const gchar
*description
)
686 AtkObjectClass
*klass
;
688 g_return_if_fail (ATK_IS_OBJECT (accessible
));
689 g_return_if_fail (description
!= NULL
);
691 klass
= ATK_OBJECT_GET_CLASS (accessible
);
692 if (klass
->set_description
)
694 (klass
->set_description
) (accessible
, description
);
695 g_object_notify (G_OBJECT (accessible
), atk_object_name_property_description
);
700 * atk_object_set_parent:
701 * @accessible: an #AtkObject
702 * @parent : an #AtkObject to be set as the accessible parent
704 * Sets the accessible parent of the accessible.
707 atk_object_set_parent (AtkObject
*accessible
,
710 AtkObjectClass
*klass
;
712 g_return_if_fail (ATK_IS_OBJECT (accessible
));
714 klass
= ATK_OBJECT_GET_CLASS (accessible
);
715 if (klass
->set_parent
)
717 (klass
->set_parent
) (accessible
, parent
);
718 g_object_notify (G_OBJECT (accessible
), atk_object_name_property_parent
);
723 * atk_object_set_role:
724 * @accessible: an #AtkObject
725 * @role : an #AtkRole to be set as the role
727 * Sets the role of the accessible.
730 atk_object_set_role (AtkObject
*accessible
,
733 AtkObjectClass
*klass
;
735 g_return_if_fail (ATK_IS_OBJECT (accessible
));
737 klass
= ATK_OBJECT_GET_CLASS (accessible
);
740 (klass
->set_role
) (accessible
, role
);
741 g_object_notify (G_OBJECT (accessible
), atk_object_name_property_role
);
746 * atk_object_connect_property_change_handler:
747 * @accessible: an #AtkObject
748 * @handler : a function to be called when a property changes its value
750 * Specifies a function to be called when a property changes value.
752 * Returns: a #guint which is the handler id used in
753 * atk_object_remove_property_change_handler()
756 atk_object_connect_property_change_handler (AtkObject
*accessible
,
757 AtkPropertyChangeHandler
*handler
)
759 AtkObjectClass
*klass
;
761 g_return_val_if_fail (ATK_IS_OBJECT (accessible
), 0);
762 g_return_val_if_fail ((handler
!= NULL
), 0);
764 klass
= ATK_OBJECT_GET_CLASS (accessible
);
765 if (klass
->connect_property_change_handler
)
766 return (klass
->connect_property_change_handler
) (accessible
, handler
);
772 * atk_object_remove_property_change_handler:
773 * @accessible: an #AtkObject
774 * @handler_id : a guint which identifies the handler to be removed.
776 * Removes a property change handler.
779 atk_object_remove_property_change_handler (AtkObject
*accessible
,
782 AtkObjectClass
*klass
;
784 g_return_if_fail (ATK_IS_OBJECT (accessible
));
786 klass
= ATK_OBJECT_GET_CLASS (accessible
);
787 if (klass
->remove_property_change_handler
)
788 (klass
->remove_property_change_handler
) (accessible
, handler_id
);
792 * atk_object_notify_state_change:
793 * @accessible: an #AtkObject
794 * @state: an #AtkState whose state is changed
795 * @value : a gboolean which indicates whether the state is being set on or off
797 * Emits a state-change signal for the specified state.
800 atk_object_notify_state_change (AtkObject
*accessible
,
804 G_CONST_RETURN gchar
* name
;
806 name
= atk_state_type_get_name (state
);
807 g_signal_emit (accessible
, atk_object_signals
[STATE_CHANGE
],
808 g_quark_from_string (name
),
813 * atk_implementor_ref_accessible:
814 * @implementor: The #GObject instance which should implement #AtkImplementorIface
815 * if a non-null return value is required.
817 * Gets a reference to an object's #AtkObject implementation, if
818 * the object implements #AtkObjectIface
820 * Returns: a reference to an object's #AtkObject implementation
823 atk_implementor_ref_accessible (AtkImplementor
*object
)
825 AtkImplementorIface
*iface
;
826 AtkObject
*accessible
= NULL
;
828 g_return_val_if_fail (ATK_IS_IMPLEMENTOR (object
), NULL
);
830 iface
= ATK_IMPLEMENTOR_GET_IFACE (object
);
833 accessible
= iface
->ref_accessible (object
);
835 g_return_val_if_fail ((accessible
!= NULL
), NULL
);
840 static AtkRelationSet
*
841 atk_object_real_ref_relation_set (AtkObject
*accessible
)
843 g_return_val_if_fail (accessible
->relation_set
, NULL
);
844 g_object_ref (accessible
->relation_set
);
846 return accessible
->relation_set
;
850 atk_object_real_set_property (GObject
*object
,
855 AtkObject
*accessible
;
857 accessible
= ATK_OBJECT (object
);
862 atk_object_set_name (accessible
, g_value_get_string (value
));
864 case PROP_DESCRIPTION
:
865 atk_object_set_description (accessible
, g_value_get_string (value
));
868 atk_object_set_role (accessible
, g_value_get_int (value
));
871 atk_object_set_parent (accessible
, g_value_get_object (value
));
874 if (ATK_IS_VALUE (accessible
))
875 atk_value_set_current_value (ATK_VALUE (accessible
), value
);
883 atk_object_real_get_property (GObject
*object
,
888 AtkObject
*accessible
;
890 accessible
= ATK_OBJECT (object
);
895 g_value_set_string (value
, atk_object_get_name (accessible
));
897 case PROP_DESCRIPTION
:
898 g_value_set_string (value
, atk_object_get_description (accessible
));
901 g_value_set_int (value
, atk_object_get_role (accessible
));
904 if (ATK_IS_COMPONENT (accessible
))
905 g_value_set_int (value
, atk_component_get_layer (ATK_COMPONENT (accessible
)));
907 case PROP_MDI_ZORDER
:
908 if (ATK_IS_COMPONENT (accessible
))
909 g_value_set_int (value
, atk_component_get_mdi_zorder (ATK_COMPONENT (accessible
)));
912 g_value_set_object (value
, atk_object_get_parent (accessible
));
915 if (ATK_IS_VALUE (accessible
))
916 atk_value_get_current_value (ATK_VALUE (accessible
), value
);
919 G_OBJECT_WARN_INVALID_PROPERTY_ID (object
, prop_id
, pspec
);
925 atk_object_finalize (GObject
*object
)
927 AtkObject
*accessible
;
929 g_return_if_fail (ATK_IS_OBJECT (object
));
931 accessible
= ATK_OBJECT (object
);
933 g_free (accessible
->name
);
934 g_free (accessible
->description
);
937 * Free memory allocated for relation set if it have been allocated.
939 if (accessible
->relation_set
)
940 g_object_unref (accessible
->relation_set
);
942 if (accessible
->accessible_parent
)
943 g_object_unref (accessible
->accessible_parent
);
945 G_OBJECT_CLASS (parent_class
)->finalize (object
);
948 static G_CONST_RETURN gchar
*
949 atk_object_real_get_name (AtkObject
*object
)
954 static G_CONST_RETURN gchar
*
955 atk_object_real_get_description (AtkObject
*object
)
957 return object
->description
;
961 atk_object_real_get_parent (AtkObject
*object
)
963 return object
->accessible_parent
;
967 atk_object_real_get_role (AtkObject
*object
)
973 atk_object_real_get_layer (AtkObject
*object
)
975 return object
->layer
;
979 atk_object_real_ref_state_set (AtkObject
*accessible
)
981 AtkStateSet
*state_set
;
984 state_set
= atk_state_set_new ();
986 ap
= atk_object_get_parent (accessible
);
988 if (ATK_IS_SELECTION (ap
))
992 atk_state_set_add_state (state_set
, ATK_STATE_SELECTABLE
);
994 i
= atk_object_get_index_in_parent (accessible
);
996 if (atk_selection_is_child_selected(ATK_SELECTION (ap
), i
))
997 atk_state_set_add_state (state_set
, ATK_STATE_SELECTED
);
1004 atk_object_real_set_name (AtkObject
*object
,
1007 g_free (object
->name
);
1008 object
->name
= g_strdup (name
);
1012 atk_object_real_set_description (AtkObject
*object
,
1013 const gchar
*description
)
1015 g_free (object
->description
);
1016 object
->description
= g_strdup (description
);
1020 atk_object_real_set_parent (AtkObject
*object
,
1023 if (object
->accessible_parent
)
1024 g_object_unref (object
->accessible_parent
);
1026 object
->accessible_parent
= parent
;
1027 if (object
->accessible_parent
)
1028 g_object_ref (object
->accessible_parent
);
1032 atk_object_real_set_role (AtkObject
*object
,
1035 object
->role
= role
;
1039 atk_object_real_connect_property_change_handler (AtkObject
*obj
,
1040 AtkPropertyChangeHandler
*handler
)
1042 return g_signal_connect_closure_by_id (obj
,
1043 atk_object_signals
[PROPERTY_CHANGE
],
1046 G_CALLBACK (handler
), NULL
,
1047 (GClosureNotify
) NULL
),
1052 atk_object_real_remove_property_change_handler (AtkObject
*obj
,
1055 g_signal_handler_disconnect (obj
, handler_id
);
1059 * atk_object_initialize:
1060 * @accessible: a #AtkObject
1061 * @data: a #gpointer which identifies the object for which the AtkObject was created.
1063 * This function is called when implementing subclasses of #AtkObject.
1064 * It does initialization required for the new object. It is intended
1065 * that this function should called only in the ..._new() functions used
1066 * to create an instance of a subclass of #AtkObject
1069 atk_object_initialize (AtkObject
*accessible
,
1072 AtkObjectClass
*klass
;
1074 g_return_if_fail (ATK_IS_OBJECT (accessible
));
1076 klass
= ATK_OBJECT_GET_CLASS (accessible
);
1077 if (klass
->initialize
)
1078 klass
->initialize (accessible
, data
);
1082 * This function is a signal handler for notify signal which gets emitted
1083 * when a property changes value.
1085 * It constructs an AtkPropertyValues structure and emits a "property_changed"
1086 * signal which causes the user specified AtkPropertyChangeHandler
1090 atk_object_notify (GObject
*obj
,
1093 AtkPropertyValues values
= { 0, };
1095 g_value_init (&values
.new_value
, pspec
->value_type
);
1096 g_object_get_property (obj
, pspec
->name
, &values
.new_value
);
1097 values
.property_name
= pspec
->name
;
1098 g_signal_emit (obj
, atk_object_signals
[PROPERTY_CHANGE
],
1099 g_quark_from_string (pspec
->name
),
1104 * atk_role_get_name:
1105 * @role: The #AtkRole whose name is required
1107 * Gets the description string describing the #Roleype @role.
1109 * Returns: the string describing the AtkRole
1111 G_CONST_RETURN gchar
*
1112 atk_role_get_name (AtkRole role
)
1114 GTypeClass
*type_class
;
1118 type_class
= g_type_class_ref (ATK_TYPE_ROLE
);
1119 g_return_val_if_fail (G_IS_ENUM_CLASS (type_class
), NULL
);
1121 value
= g_enum_get_value (G_ENUM_CLASS (type_class
), role
);
1125 name
= value
->value_nick
;
1133 n
-= ATK_ROLE_LAST_DEFINED
+ 1;
1135 if (n
< extra_roles
->len
)
1136 name
= g_ptr_array_index (extra_roles
, n
);
1139 g_type_class_unref (type_class
);
1144 * atk_role_for_name:
1145 * @name: a string which is the (non-localized) name of an ATK role.
1147 * Get the #AtkRole type corresponding to a rolew name.
1149 * Returns: the #AtkRole enumerated type corresponding to the specified
1151 * or #ATK_ROLE_INVALID if no matching role is found.
1154 atk_role_for_name (const gchar
*name
)
1156 GTypeClass
*type_class
;
1158 AtkRole role
= ATK_ROLE_INVALID
;
1160 g_return_val_if_fail (name
, ATK_ROLE_INVALID
);
1162 type_class
= g_type_class_ref (ATK_TYPE_ROLE
);
1163 g_return_val_if_fail (G_IS_ENUM_CLASS (type_class
), ATK_ROLE_INVALID
);
1165 value
= g_enum_get_value_by_nick (G_ENUM_CLASS (type_class
), name
);
1169 role
= value
->value
;
1177 for (i
= 0; i
< extra_roles
->len
; i
++)
1179 gchar
*extra_role
= (gchar
*)g_ptr_array_index (extra_roles
, i
);
1181 g_return_val_if_fail (extra_role
, ATK_ROLE_INVALID
);
1183 if (strcmp (name
, extra_role
) == 0)
1185 role
= i
+ 1 + ATK_ROLE_LAST_DEFINED
;
1191 g_type_class_unref (type_class
);