Cleaned up docs.
[platform/upstream/atk.git] / atk / atkobject.c
1 /* ATK -  Accessibility Toolkit
2  * Copyright 2001 Sun Microsystems Inc.
3  *
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.
8  *
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.
13  *
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.
18  */
19
20 #include <string.h>
21
22 #include <glib-object.h>
23
24 #include "atk.h"
25
26 /* New GObject properties registered by AtkObject */
27 enum
28 {
29   PROP_0,  /* gobject convention */
30
31   PROP_NAME,
32   PROP_DESCRIPTION,
33   PROP_PARENT,      /* ancestry has changed */
34   PROP_CHILD,       /* a child has been added or removed */
35   PROP_STATE,       /* AtkStateSet for the object has changed */
36   PROP_TEXT,        /* Used only by AtkText implementors */
37   PROP_CARET,       /* Used only by AtkText implementors */
38   PROP_SELECTION,
39   PROP_VALUE,
40   PROP_VISIBLE_DATA,
41   PROP_ROLE,
42   PROP_TABLE_CAPTION,
43   PROP_TABLE_COLUMN_DESCRIPTION,
44   PROP_TABLE_COLUMN_HEADER,
45   PROP_TABLE_ROW_DESCRIPTION,
46   PROP_TABLE_ROW_HEADER,
47   PROP_TABLE_SUMMARY,
48   PROP_MODEL,
49   PROP_LAST         /* gobject convention */
50 };
51
52 enum {
53   CHILDREN_CHANGED,
54   FOCUS_EVENT,
55   LAST_SIGNAL
56 };
57
58 static void            atk_object_class_init       (AtkObjectClass  *klass);
59 static void            atk_object_init             (AtkObject       *accessible,
60                                                     AtkObjectClass  *klass);
61 static AtkRelationSet* atk_object_real_ref_relation_set (AtkObject *accessible);
62
63 static void            atk_object_real_set_property(GObject         *object,
64                                                     guint            prop_id,
65                                                     const GValue    *value,
66                                                     GParamSpec      *pspec);
67 static void            atk_object_real_get_property(GObject         *object,
68                                                     guint            prop_id,
69                                                     GValue          *value,
70                                                     GParamSpec      *pspec);
71 static void            atk_object_finalize         (GObject         *object);
72 static void            atk_object_real_set_role    (AtkObject       *object,
73                                                     AtkRole         role);
74
75 static guint atk_object_signals[LAST_SIGNAL] = { 0, };
76
77 static gpointer parent_class = NULL;
78
79 static const gchar* atk_object_name_property_name = "accessible-name";
80 static const gchar* atk_object_name_property_state = "accessible-state";
81 static const gchar* atk_object_name_property_description = "accessible-description";
82 static const gchar* atk_object_name_property_child = "accessible-child";
83 static const gchar* atk_object_name_property_parent = "accessible-parent";
84 static const gchar* atk_object_name_property_text = "accessible-text";
85 static const gchar* atk_object_name_property_caret = "accessible-caret";
86 static const gchar* atk_object_name_property_selection = "accessible-selection";
87 static const gchar* atk_object_name_property_value = "accessible-value";
88 static const gchar* atk_object_name_property_visible = "accessible-visible-data";
89 static const gchar* atk_object_name_property_role = "accessible-role";
90 static const gchar* atk_object_name_property_table_caption = "accessible-table-caption";
91 static const gchar* atk_object_name_property_table_column_description = "accessible-table-column-description";
92 static const gchar* atk_object_name_property_table_column_header = "accessible-table-column-header";
93 static const gchar* atk_object_name_property_table_row_description = "accessible-table-row-description";
94 static const gchar* atk_object_name_property_table_row_header = "accessible-table-row-header";
95 static const gchar* atk_object_name_property_table_summary = "accessible-table-summary";
96 static const gchar* atk_object_name_property_model = "accessible-model";
97
98 GType
99 atk_object_get_type (void)
100 {
101   static GType type = 0;
102
103   if (!type)
104     {
105       static const GTypeInfo typeInfo =
106       {
107         sizeof (AtkObjectClass),
108         (GBaseInitFunc) NULL,
109         (GBaseFinalizeFunc) NULL,
110         (GClassInitFunc) atk_object_class_init,
111         (GClassFinalizeFunc) NULL,
112         NULL,
113         sizeof (AtkObject),
114         0,
115         (GInstanceInitFunc) atk_object_init,
116       } ;
117       type = g_type_register_static (G_TYPE_OBJECT, "AtkObject", &typeInfo, 0) ;
118     }
119   return type;
120 }
121
122 static void
123 atk_object_class_init (AtkObjectClass *klass)
124 {
125   GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
126
127   parent_class = g_type_class_ref (G_TYPE_OBJECT);
128
129   gobject_class->set_property = atk_object_real_set_property;
130   gobject_class->get_property = atk_object_real_get_property;
131   gobject_class->finalize = atk_object_finalize;
132
133   klass->ref_relation_set = atk_object_real_ref_relation_set;
134   klass->set_role = atk_object_real_set_role;
135
136   /*
137    * We do not define default signal handlers here
138    */
139   klass->focus_event = NULL;
140   klass->children_changed = NULL;
141
142   g_object_class_install_property (gobject_class,
143                                    PROP_NAME,
144                                    g_param_spec_string (atk_object_name_property_name,
145                                                         "Accessible Name",
146                                                         "Object instance\'s name formatted for "
147                                                            "assistive technology access",
148                                                         NULL,
149                                                         G_PARAM_READWRITE));
150   g_object_class_install_property (gobject_class,
151                                    PROP_DESCRIPTION,
152                                    g_param_spec_string (atk_object_name_property_description,
153                                                         "Accessible Description",
154                                                         "Description of an object, formatted for "
155                                                         "assistive technology access",
156                                                         NULL,
157                                                         G_PARAM_READWRITE));
158   g_object_class_install_property (gobject_class,
159                                    PROP_STATE,
160                                    g_param_spec_int    (atk_object_name_property_state,
161                                                         "Accessible State Set",
162                                                         "The accessible state set of this object "
163                                                         "or its UI component",
164                                                         0,
165                                                         G_MAXINT,
166                                                         0,
167                                                         G_PARAM_READWRITE));
168   g_object_class_install_property (gobject_class,
169                                    PROP_CHILD,
170                                    g_param_spec_object (atk_object_name_property_child,
171                                                         "Accessible Child",
172                                                         "Is used to notify that a child has been added or removed ",
173                                                         ATK_TYPE_OBJECT,
174                                                         G_PARAM_READWRITE));
175   g_object_class_install_property (gobject_class,
176                                    PROP_PARENT,
177                                    g_param_spec_object (atk_object_name_property_parent,
178                                                         "Accessible Parent",
179                                                         "Is used to notify that the parent has changed ",
180                                                         ATK_TYPE_OBJECT,
181                                                         G_PARAM_READWRITE));
182   g_object_class_install_property (gobject_class,
183                                    PROP_TEXT,
184                                    g_param_spec_object (atk_object_name_property_text,
185                                                         "Accessible Text",
186                                                         "Is used to notify that the text has changed ",
187                                                         ATK_TYPE_OBJECT,
188                                                         G_PARAM_READWRITE));
189   g_object_class_install_property (gobject_class,
190                                    PROP_CARET,
191                                    g_param_spec_int    (atk_object_name_property_caret,
192                                                         "Accessible Caret",
193                                                         "Is used to notify that the caret position has changed ",
194                                                         0,
195                                                         G_MAXINT,
196                                                         0,
197                                                         G_PARAM_READWRITE));
198   g_object_class_install_property (gobject_class,
199                                    PROP_SELECTION,
200                                    g_param_spec_object (atk_object_name_property_selection,
201                                                         "Accessible Selection",
202                                                         "Is used to notify that the selection has changed ",
203                                                         ATK_TYPE_OBJECT,
204                                                         G_PARAM_READWRITE));
205   g_object_class_install_property (gobject_class,
206                                    PROP_VALUE,
207                                    g_param_spec_double (atk_object_name_property_value,
208                                                         "Accessible Value",
209                                                         "Is used to notify that the value has changed ",
210                                                         0.0,
211                                                         G_MAXDOUBLE,
212                                                         0.0,
213                                                         G_PARAM_READWRITE));
214   g_object_class_install_property (gobject_class,
215                                    PROP_VISIBLE_DATA,
216                                    g_param_spec_object (atk_object_name_property_visible,
217                                                         "Accessible Visible Data",
218                                                         "Is used to notify that the visual appearance of the object has changed ",
219                                                         ATK_TYPE_OBJECT,
220                                                         G_PARAM_READWRITE));
221   g_object_class_install_property (gobject_class,
222                                    PROP_ROLE,
223                                    g_param_spec_int    (atk_object_name_property_role,
224                                                         "Accessible Role",
225                                                         "The accessible role this object ",
226                                                         0,
227                                                         G_MAXINT,
228                                                         0,
229                                                         G_PARAM_READWRITE));
230   g_object_class_install_property (gobject_class,
231                                    PROP_TABLE_CAPTION,
232                                    g_param_spec_object (atk_object_name_property_table_caption,
233                                                         "Accessible Table Caption",
234                                                         "Is used to notify that the table caption has changed ",
235                                                         ATK_TYPE_OBJECT,
236                                                         G_PARAM_READWRITE));
237   g_object_class_install_property (gobject_class,
238                                    PROP_TABLE_COLUMN_HEADER,
239                                    g_param_spec_object (atk_object_name_property_table_column_header,
240                                                         "Accessible Table Column Header",
241                                                         "Is used to notify that the table column header has changed ",
242                                                         ATK_TYPE_OBJECT,
243                                                         G_PARAM_READWRITE));
244   g_object_class_install_property (gobject_class,
245                                    PROP_TABLE_COLUMN_DESCRIPTION,
246                                    g_param_spec_int    (atk_object_name_property_table_column_description,
247                                                         "Accessible Table Column Description",
248                                                         "Is used to notify that the table columnscription has changed ",
249                                                         0,
250                                                         G_MAXINT,
251                                                         0,
252                                                         G_PARAM_READWRITE));
253   g_object_class_install_property (gobject_class,
254                                    PROP_TABLE_ROW_HEADER,
255                                    g_param_spec_object (atk_object_name_property_table_row_header,
256                                                         "Accessible Table Row Header",
257                                                         "Is used to notify that the table row header has changed ",
258                                                         ATK_TYPE_OBJECT,
259                                                         G_PARAM_READWRITE));
260   g_object_class_install_property (gobject_class,
261                                    PROP_TABLE_ROW_DESCRIPTION,
262                                    g_param_spec_int    (atk_object_name_property_table_row_description,
263                                                         "Accessible Table Row Description",
264                                                         "Is used to notify that the table row description has changed ",
265                                                         0,
266                                                         G_MAXINT,
267                                                         0,
268                                                         G_PARAM_READWRITE));
269   g_object_class_install_property (gobject_class,
270                                    PROP_TABLE_SUMMARY,
271                                    g_param_spec_object (atk_object_name_property_table_summary,
272                                                         "Accessible Table Summary",
273                                                         "Is used to notify that the table summary has changed ",
274                                                         ATK_TYPE_OBJECT,
275                                                         G_PARAM_READWRITE));
276   g_object_class_install_property (gobject_class,
277                                    PROP_MODEL,
278                                    g_param_spec_object (atk_object_name_property_model,
279                                                         "Accessible Model",
280                                                         "Is used to notify that the model for Table or Tree has changed ",
281                                                         ATK_TYPE_OBJECT,
282                                                         G_PARAM_READWRITE));
283   /*
284    * The signal "children_changed" supports two details:
285    * "add" and "remove"
286    */
287   atk_object_signals[CHILDREN_CHANGED] =
288     g_signal_newc ("children_changed",
289                    G_TYPE_FROM_CLASS (klass),
290                    G_SIGNAL_RUN_LAST | G_SIGNAL_DETAILED,
291                    G_STRUCT_OFFSET (AtkObjectClass, children_changed),
292                    NULL, NULL,
293                    g_cclosure_marshal_VOID__UINT_POINTER,
294                    G_TYPE_NONE,
295                    2, G_TYPE_UINT, ATK_TYPE_OBJECT);
296   atk_object_signals[FOCUS_EVENT] =
297     g_signal_newc ("focus_event",
298                    G_TYPE_FROM_CLASS (klass),
299                    G_SIGNAL_RUN_LAST,
300                    G_STRUCT_OFFSET (AtkObjectClass, focus_event), 
301                    NULL, NULL,
302                    g_cclosure_marshal_VOID__BOOLEAN,
303                    G_TYPE_NONE,
304                    1, G_TYPE_BOOLEAN);
305 }
306
307 static void
308 atk_object_init  (AtkObject        *accessible,
309                   AtkObjectClass   *klass)
310 {
311 }
312
313 GType
314 atk_implementor_get_type (void)
315 {
316   static GType type = 0;
317
318   if (!type)
319     {
320       static const GTypeInfo typeInfo =
321       {
322         sizeof (AtkImplementorIface),
323         (GBaseInitFunc) NULL,
324         (GBaseFinalizeFunc) NULL,
325       } ;
326
327       type = g_type_register_static (G_TYPE_INTERFACE, "AtkImplementorIface", &typeInfo, 0) ;
328     }
329
330   return type;
331 }
332
333 /**
334  * atk_object_get_name:
335  * @accessible: an #AtkObject
336  *
337  * Gets the accessible name of the accessible.
338  *
339  * Returns: a character string representing the accessible name of the object.
340  **/
341 G_CONST_RETURN gchar*
342 atk_object_get_name (AtkObject *accessible)
343 {
344   AtkObjectClass *klass;
345
346   g_return_val_if_fail (accessible != NULL, NULL);
347   g_return_val_if_fail (ATK_IS_OBJECT (accessible), NULL);
348
349   klass = ATK_OBJECT_GET_CLASS (accessible);
350   if (klass->get_name)
351     return (klass->get_name) (accessible);
352   else
353     return NULL;
354 }
355
356 /**
357  * atk_object_get_description:
358  * @accessible: an #AtkObject
359  *
360  * Gets the accessible description of the accessible.
361  *
362  * Returns: a character string representing the accessible description
363  * of the accessible.
364  *
365  **/
366 G_CONST_RETURN gchar*
367 atk_object_get_description (AtkObject *accessible)
368 {
369   AtkObjectClass *klass;
370
371   g_return_val_if_fail (accessible != NULL, NULL);
372   g_return_val_if_fail (ATK_IS_OBJECT (accessible), NULL);
373
374   klass = ATK_OBJECT_GET_CLASS (accessible);
375   if (klass->get_description)
376     return (klass->get_description) (accessible);
377   else
378     return NULL;
379 }
380
381 /**
382  * atk_object_get_parent:
383  * @accessible: an #AtkObject
384  *
385  * Gets the accessible parent of the accessible.
386  *
387  * Returns: a #AtkObject representing the accessible parent of the accessible
388  **/
389 AtkObject*
390 atk_object_get_parent (AtkObject *accessible)
391 {
392   AtkObjectClass *klass;
393
394   g_return_val_if_fail (accessible != NULL, NULL);
395   g_return_val_if_fail (ATK_IS_OBJECT (accessible), NULL);
396
397   klass = ATK_OBJECT_GET_CLASS (accessible);
398   if (klass->get_parent)
399     return (klass->get_parent) (accessible);
400   else
401     return NULL;
402 }
403
404 /**
405  * atk_object_get_n_accessible_children:
406  * @accessible: an #AtkObject
407  *
408  * Gets the number of accessible children of the accessible.
409  *
410  * Returns: an integer representing the number of accessible children
411  * of the accessible.
412  **/
413 gint
414 atk_object_get_n_accessible_children (AtkObject *accessible)
415 {
416   AtkObjectClass *klass;
417
418   g_return_val_if_fail (accessible != NULL, 0);
419   g_return_val_if_fail (ATK_IS_OBJECT (accessible), 0);
420
421   klass = ATK_OBJECT_GET_CLASS (accessible);
422   if (klass->get_n_children)
423     return (klass->get_n_children) (accessible);
424   else
425     return 0;
426 }
427
428 /**
429  * atk_object_ref_accessible_child:
430  * @accessible: an #AtkObject
431  * @i: a gint representing the position of the child, starting from 0
432  *
433  * Gets a reference to the specified accessible child of the object.
434  * The accessible children are 0-based so the first accessible child is
435  * at index 0, the second at index 1 and so on.
436  *
437  * Returns: an #AtkObject representing the specified accessible child
438  * of the accessible.
439  **/
440 AtkObject*
441 atk_object_ref_accessible_child (AtkObject   *accessible,
442                                  gint        i)
443 {
444   AtkObjectClass *klass;
445
446   g_return_val_if_fail (accessible != NULL, NULL);
447   g_return_val_if_fail (ATK_IS_OBJECT (accessible), NULL);
448
449   klass = ATK_OBJECT_GET_CLASS (accessible);
450   if (klass->ref_child)
451     return (klass->ref_child) (accessible, i);
452   else
453     return NULL;
454 }
455
456 /**
457  * atk_object_ref_relation_set:
458  * @accessible: an #AtkObject
459  *
460  * Gets the #AtkRelationSet associated with the object.
461  *
462  * Returns: an #AtkRelationSet representing the relation set of the object.
463  **/
464 AtkRelationSet*
465 atk_object_ref_relation_set (AtkObject *accessible)
466 {
467   AtkObjectClass *klass;
468
469   g_return_val_if_fail (accessible != NULL, NULL);
470   g_return_val_if_fail (ATK_IS_OBJECT (accessible), NULL);
471
472   klass = ATK_OBJECT_GET_CLASS (accessible);
473   if (klass->ref_relation_set)
474     return (klass->ref_relation_set) (accessible);
475   else
476     return NULL;
477 }
478
479 /**
480  * atk_role_register:
481  * @name: a character string describing the new role.
482  *
483  * Registers the role specified by @name.
484  *
485  * Returns: an #AtkRole for the new role.
486  **/
487 AtkRole
488 atk_role_register (const gchar *name)
489 {
490   /* TODO: associate name with new type */
491   static guint type = ATK_ROLE_LAST_DEFINED;
492   return (++type);
493 }
494
495 /**
496  * atk_object_get_role:
497  * @accessible: an #AtkObject
498  *
499  * Gets the role of the accessible.
500  *
501  * Returns: an #AtkRole which is the role of the accessible
502  **/
503 AtkRole
504 atk_object_get_role (AtkObject *accessible) {
505   AtkObjectClass *klass;
506
507   g_return_val_if_fail (accessible != NULL, ATK_ROLE_UNKNOWN);
508   g_return_val_if_fail (ATK_IS_OBJECT (accessible), ATK_ROLE_UNKNOWN);
509
510   klass = ATK_OBJECT_GET_CLASS (accessible);
511   if (klass->get_role)
512     return (klass->get_role) (accessible);
513   else
514     return ATK_ROLE_UNKNOWN;
515 }
516
517 /**
518  * atk_object_ref_state_set:
519  * @accessible: an #AtkObject
520  *
521  * Gets a reference to the state set of the accessible; the caller must
522  * unreference it when it is no longer needed.
523  *
524  * Returns: a reference to an #AtkStateSet which is the state
525  * set of the accessible
526  **/
527 AtkStateSet*
528 atk_object_ref_state_set (AtkObject *accessible) {
529   AtkObjectClass *klass;
530
531   g_return_val_if_fail (accessible != NULL, NULL);
532   g_return_val_if_fail (ATK_IS_OBJECT (accessible), NULL);
533
534   klass = ATK_OBJECT_GET_CLASS (accessible);
535   if (klass->ref_state_set)
536     return (klass->ref_state_set) (accessible);
537   else
538     return NULL;
539 }
540
541 /**
542  * atk_object_get_index_in_parent:
543  * @accessible: an #AtkObject
544  *
545  * Gets the 0-based index of this accessible in its parent; returns -1 if the
546  * accessible does not have an accessible parent.
547  *
548  * Returns: an integer which is the index of the accessible in its parent
549  **/
550 gint
551 atk_object_get_index_in_parent (AtkObject *accessible)
552 {
553   AtkObjectClass *klass;
554
555   g_return_val_if_fail (accessible != NULL, -1);
556   g_return_val_if_fail (ATK_OBJECT (accessible), -1);
557
558   klass = ATK_OBJECT_GET_CLASS (accessible);
559   if (klass->get_index_in_parent)
560     return (klass->get_index_in_parent) (accessible);
561   else
562     return -1;
563 }
564
565 /**
566  * atk_object_set_name:
567  * @accessible: an #AtkObject
568  * @name: a character string to be set as the accessible name
569  *
570  * Sets the accessible name of the accessible.
571  **/
572 void
573 atk_object_set_name (AtkObject    *accessible,
574                      const gchar  *name)
575 {
576   AtkObjectClass *klass;
577
578   g_return_if_fail (accessible != NULL);
579   g_return_if_fail (ATK_IS_OBJECT (accessible));
580   g_return_if_fail (name != NULL);
581
582   klass = ATK_OBJECT_GET_CLASS (accessible);
583   if (klass->set_name)
584   {
585     (klass->set_name) (accessible, name);
586     g_object_notify (G_OBJECT (accessible), atk_object_name_property_name);
587   }
588 }
589
590 /**
591  * atk_object_set_description:
592  * @accessible: an #AtkObject
593  * @description : a character string to be set as the accessible description
594  *
595  * Sets the accessible description of the accessible.
596  **/
597 void
598 atk_object_set_description (AtkObject   *accessible,
599                             const gchar *description)
600 {
601   AtkObjectClass *klass;
602
603   g_return_if_fail (accessible != NULL);
604   g_return_if_fail (ATK_IS_OBJECT (accessible));
605   g_return_if_fail (description != NULL);
606
607   klass = ATK_OBJECT_GET_CLASS (accessible);
608   if (klass->set_description)
609   {
610     (klass->set_description) (accessible, description);
611     g_object_notify (G_OBJECT (accessible), atk_object_name_property_description);
612   }
613 }
614
615 /**
616  * atk_object_set_parent:
617  * @accessible: an #AtkObject
618  * @parent : an #AtkObject to be set as the accessible parent
619  *
620  * Sets the accessible parent of the accessible.
621  **/
622 void
623 atk_object_set_parent (AtkObject *accessible,
624                        AtkObject *parent)
625 {
626   AtkObjectClass *klass;
627
628   g_return_if_fail (accessible != NULL);
629   g_return_if_fail (ATK_IS_OBJECT (accessible));
630
631   klass = ATK_OBJECT_GET_CLASS (accessible);
632   if (klass->set_parent)
633     (klass->set_parent) (accessible, parent);
634 }
635
636 /**
637  * atk_object_set_role:
638  * @accessible: an #AtkObject
639  * @role : an #AtkRole to be set as the role
640  *
641  * Sets the role of the accessible.
642  **/
643 void
644 atk_object_set_role (AtkObject *accessible, 
645                      AtkRole   role)
646 {
647   AtkObjectClass *klass;
648
649   g_return_if_fail (accessible != NULL);
650   g_return_if_fail (ATK_IS_OBJECT (accessible));
651
652   klass = ATK_OBJECT_GET_CLASS (accessible);
653   if (klass->set_role)
654     (klass->set_role) (accessible, role);
655 }
656
657 /**
658  * atk_object_connect_property_change_handler:
659  * @accessible: an #AtkObject
660  * @handler : a function to be called when a property changes its value
661  *
662  * Specifies a function to be called when a property changes value.
663  *
664  * Returns: a #guint which is the handler id used in 
665  * atk_object_remove_property_change_handler()
666  **/
667 guint
668 atk_object_connect_property_change_handler (AtkObject *accessible,
669                                             AtkPropertyChangeHandler *handler)
670 {
671   AtkObjectClass *klass;
672
673   g_return_val_if_fail (accessible != NULL, 0);
674   g_return_val_if_fail (ATK_IS_OBJECT (accessible), 0);
675   g_return_val_if_fail ((handler != NULL), 0);
676
677   klass = ATK_OBJECT_GET_CLASS (accessible);
678   if (klass->connect_property_change_handler)
679     return (klass->connect_property_change_handler) (accessible, handler);
680   else
681     return 0;
682 }
683
684 /**
685  * atk_object_remove_property_change_handler:
686  * @accessible: an #AtkObject
687  * @handler_id : a guint which identifies the handler to be removed.
688  * 
689  * Removes a property change handler.
690  **/
691 void
692 atk_object_remove_property_change_handler  (AtkObject *accessible,
693                                             guint      handler_id)
694 {
695   AtkObjectClass *klass;
696
697   g_return_if_fail (accessible != NULL);
698   g_return_if_fail (ATK_IS_OBJECT (accessible));
699
700   klass = ATK_OBJECT_GET_CLASS (accessible);
701   if (klass->remove_property_change_handler)
702     (klass->remove_property_change_handler) (accessible, handler_id);
703 }
704
705 /**
706  * atk_implementor_ref_accessible:
707  * @implementor: The #GObject instance which should implement #AtkImplementorIface
708  * if a non-null return value is required.
709  * 
710  * Gets a reference to an object's #AtkObject implementation, if
711  * the object implements #AtkObjectIface
712  *
713  * Returns: a reference to an object's #AtkObject implementation
714  */
715 AtkObject *
716 atk_implementor_ref_accessible (AtkImplementor *object)
717 {
718   AtkImplementorIface *iface;
719   AtkObject           *accessible = NULL;
720
721   g_return_val_if_fail (object != NULL, NULL);
722   g_return_val_if_fail (ATK_IS_IMPLEMENTOR (object), NULL);
723
724   iface = ATK_IMPLEMENTOR_GET_IFACE (object);
725
726   if (iface != NULL) 
727     accessible =  iface->ref_accessible (object);
728
729   g_return_val_if_fail ((accessible != NULL), NULL);
730
731   return accessible;
732 }
733
734 static AtkRelationSet*
735 atk_object_real_ref_relation_set (AtkObject *accessible)
736 {
737   if (accessible->relation_set)
738     g_object_ref (accessible->relation_set); 
739
740   return accessible->relation_set;
741 }
742
743 static void
744 atk_object_real_set_property (GObject      *object,
745                               guint         prop_id,
746                               const GValue *value,
747                               GParamSpec   *pspec)
748 {
749   AtkObject *accessible;
750
751   accessible = ATK_OBJECT (object);
752
753   switch (prop_id)
754   {
755     case PROP_NAME:
756       atk_object_set_name (accessible, g_value_get_string (value));
757       break;
758     case PROP_DESCRIPTION:
759       atk_object_set_description (accessible, g_value_get_string (value));
760       break;
761     case PROP_STATE:
762       g_print ("This interface does not support setting the state set of an accessible object\n");
763       break;
764     case PROP_VALUE:
765       if (ATK_IS_VALUE (accessible))
766         atk_value_set_current_value (ATK_VALUE (accessible), value);
767       break;
768     default:
769       break;
770   }
771 }
772
773 static void
774 atk_object_real_get_property (GObject      *object,
775                               guint         prop_id,
776                               GValue       *value,
777                               GParamSpec   *pspec)
778 {
779   AtkObject *accessible;
780
781   accessible = ATK_OBJECT (object);
782
783   switch (prop_id)
784   {
785     case PROP_NAME:
786       g_value_set_string (value, atk_object_get_name (accessible));
787       break;
788     case PROP_DESCRIPTION:
789       g_value_set_string (value, atk_object_get_description (accessible));
790       break;
791     case PROP_VALUE:
792       if (ATK_IS_VALUE (accessible))
793         atk_value_get_current_value (ATK_VALUE (accessible), value);
794       break;
795     default:
796       break;
797   }
798 }
799
800 static void
801 atk_object_finalize (GObject *object)
802 {
803   AtkObject        *accessible;
804
805   g_return_if_fail (ATK_IS_OBJECT (object));
806
807   accessible = ATK_OBJECT (object);
808
809   g_free (accessible->name);
810   g_free (accessible->description);
811
812   /*
813    * Free memory allocated for relation set if it have been allocated.
814    */
815   if (accessible->relation_set)
816   {
817     g_object_unref (accessible->relation_set);
818   }
819
820   G_OBJECT_CLASS (parent_class)->finalize (object);
821 }
822
823 static void
824 atk_object_real_set_role (AtkObject *object,
825                           AtkRole   role)
826 {
827   object->role = role;
828 }