d3877efb49b2abfa403f4438188d084200cf6259
[platform/core/uifw/at-spi2-atk.git] / libspi / relation.c
1 /*
2  * AT-SPI - Assistive Technology Service Provider Interface
3  * (Gnome Accessibility Project; http://developer.gnome.org/projects/gap)
4  *
5  * Copyright 2001 Sun Microsystems 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 /*
24  * relation.c : bonobo wrapper for accessible relation implementation
25  *
26  */
27 #include <config.h>
28 #include <bonobo/Bonobo.h>
29
30 #include <stdio.h>
31
32 /*
33  * This pulls the CORBA definitions for the "Accessibility::Accessible" server
34  */
35 #include <libspi/Accessibility.h>
36
37 /*
38  * This pulls the definition of the relation bonobo object
39  */
40 #include "relation.h"
41
42 /*
43  * Static function declarations
44  */
45
46 static void
47 spi_relation_class_init (SpiRelationClass *klass);
48 static void
49 spi_relation_init (SpiRelation *relation);
50 static void
51 spi_relation_finalize (GObject *obj);
52 static CORBA_string
53 impl_getURI (PortableServer_Servant _servant,
54              const CORBA_long i, CORBA_Environment * ev);
55 static CORBA_short
56 impl__get_n_anchors (PortableServer_Servant _servant,
57                      CORBA_Environment * ev);
58 static CORBA_long
59 impl__get_startIndex (PortableServer_Servant _servant,
60                       CORBA_Environment * ev);
61 static CORBA_long
62 impl__get_endIndex (PortableServer_Servant _servant,
63                     CORBA_Environment * ev);
64 static Accessibility_Accessible
65 impl_getObject (PortableServer_Servant _servant,
66                 const CORBA_long i,
67                 CORBA_Environment * ev);
68 static CORBA_boolean
69 impl_isValid (PortableServer_Servant _servant,
70               CORBA_Environment * ev);
71
72 static GObjectClass *parent_class;
73
74 GType
75 spi_relation_get_type (void)
76 {
77   static GType type = 0;
78
79   if (!type) {
80     static const GTypeInfo tinfo = {
81       sizeof (SpiRelationClass),
82       (GBaseInitFunc) NULL,
83       (GBaseFinalizeFunc) NULL,
84       (GClassInitFunc) spi_relation_class_init,
85       (GClassFinalizeFunc) NULL,
86       NULL, /* class data */
87       sizeof (SpiRelation),
88       0, /* n preallocs */
89       (GInstanceInitFunc) spi_relation_init,
90                         NULL /* value table */
91     };
92
93     /*
94      * Bonobo_type_unique auto-generates a load of
95      * CORBA structures for us. All derived types must
96      * use bonobo_type_unique.
97      */
98     type = bonobo_type_unique (
99                                BONOBO_OBJECT_TYPE,
100                                POA_Accessibility_Relation__init,
101                                NULL,
102                                G_STRUCT_OFFSET (SpiRelationClass, epv),
103                                &tinfo,
104                                "SpiAccessibleRelation");
105   }
106
107   return type;
108 }
109
110 static void
111 spi_relation_class_init (SpiRelationClass *klass)
112 {
113   GObjectClass * object_class = (GObjectClass *) klass;
114   POA_Accessibility_Relation__epv *epv = &klass->epv;
115   parent_class = g_type_class_peek_parent (klass);
116
117   object_class->finalize = spi_relation_finalize;
118
119   epv->getRelationType  = NULL; /* TODO: finish me! */
120   epv->getNTargets      = NULL;
121   epv->getTarget        = NULL;
122 }
123
124 static void
125 spi_relation_init (SpiRelation *relation)
126 {
127 }
128
129 static void
130 spi_relation_finalize (GObject *obj)
131 {
132   SpiRelation *relation = SPI_RELATION(obj);
133   g_object_unref (relation->relation);
134   relation->relation = NULL;
135   parent_class->finalize (obj);
136 }
137
138 SpiRelation *
139 spi_relation_new (AtkRelation *obj)
140 {
141   SpiRelation *new_relation = 
142     SPI_RELATION (g_object_new (SPI_RELATION_TYPE, NULL));
143   new_relation->relation = obj;
144   g_object_ref (obj);
145   return new_relation;
146 }
147