2001-12-10 Michael Meeks <michael@ximian.com>
[platform/core/uifw/at-spi2-atk.git] / libspi / base.c
1 /*
2  * AT-SPI - Assistive Technology Service Provider Interface
3  * (Gnome Accessibility Project; http://developer.gnome.org/projects/gap)
4  *
5  * Copyright 2001 Ximian Inc.
6  *
7  * This library is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Library General Public
9  * License as published by the Free Software Foundation; either
10  * version 2 of the License, or (at your option) any later version.
11  *
12  * This library is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15  * Library General Public License for more details.
16  *
17  * You should have received a copy of the GNU Library General Public
18  * License along with this library; if not, write to the
19  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
20  * Boston, MA 02111-1307, USA.
21  */
22
23 /* base.c: the base object managing an AtkObject proxy */
24
25 #include <config.h>
26 #include <stdio.h>
27 #include <libspi/libspi.h>
28
29 /* Our parent Gtk object type  */
30 #define PARENT_TYPE BONOBO_TYPE_OBJECT
31
32 /* A pointer to our parent object class */
33 static GObjectClass *spi_base_parent_class;
34
35 /*
36  * Implemented GObject::dispose
37  */
38 static void
39 spi_base_object_dispose (GObject *gobject)
40 {
41   SpiBase *object = SPI_BASE (gobject);
42
43   if (object->atko)
44     {
45       g_assert (ATK_IS_OBJECT (object->atko));
46       g_object_unref (G_OBJECT (object->atko));
47       object->atko = NULL;
48     }
49
50   spi_base_parent_class->dispose (gobject);
51 }
52
53 static void
54 spi_base_class_init (SpiBaseClass *klass)
55 {
56         GObjectClass * object_class = (GObjectClass *) klass;
57
58         spi_base_parent_class = g_type_class_peek_parent (klass);
59
60         object_class->dispose = spi_base_object_dispose;
61 }
62
63 static void
64 spi_base_init (SpiBase *object)
65 {
66 }
67
68 BONOBO_TYPE_FUNC (SpiBase, PARENT_TYPE, spi_base);
69
70 void
71 spi_base_construct (SpiBase *object, AtkObject *aobject)
72 {
73   object->atko = g_object_ref (G_OBJECT (aobject));
74 }
75
76 void
77 spi_base_construct_default (SpiBase *object)
78 {
79   object->atko = g_object_new (ATK_TYPE_OBJECT, NULL);
80 }
81
82 AtkObject *
83 spi_base_get_atkobject (SpiBase *object)
84 {
85   g_return_val_if_fail (ATK_IS_OBJECT (object), NULL);
86
87   return object->atko;
88 }