Started fixing IDL docs.
[platform/core/uifw/at-spi2-atk.git] / libspi / hyperlink.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 /* hyperlink.c : implements the Hyperlink interface */
24
25 #include <config.h>
26 #include <stdio.h>
27 #include <libspi/hyperlink.h>
28 #include <libspi/accessible.h>
29
30 /* Static function declarations */
31
32 static void
33 spi_hyperlink_class_init (SpiHyperlinkClass *klass);
34 static void
35 spi_hyperlink_init (SpiHyperlink *hyperlink);
36 static void
37 spi_hyperlink_finalize (GObject *obj);
38 static CORBA_string
39 impl_getURI (PortableServer_Servant _servant,
40              const CORBA_long i, CORBA_Environment * ev);
41 static CORBA_short
42 impl__get_n_anchors (PortableServer_Servant _servant,
43                      CORBA_Environment * ev);
44 static CORBA_long
45 impl__get_startIndex (PortableServer_Servant _servant,
46                       CORBA_Environment * ev);
47 static CORBA_long
48 impl__get_endIndex (PortableServer_Servant _servant,
49                     CORBA_Environment * ev);
50 static Accessibility_Accessible
51 impl_getObject (PortableServer_Servant _servant,
52                 const CORBA_long i,
53                 CORBA_Environment * ev);
54 static CORBA_boolean
55 impl_isValid (PortableServer_Servant _servant,
56               CORBA_Environment * ev);
57
58 static GObjectClass *parent_class;
59
60
61 BONOBO_TYPE_FUNC_FULL (SpiHyperlink,
62                        Accessibility_Hyperlink,
63                        BONOBO_TYPE_OBJECT,
64                        spi_hyperlink);
65
66 static void
67 spi_hyperlink_class_init (SpiHyperlinkClass *klass)
68 {
69   GObjectClass * object_class = (GObjectClass *) klass;
70   POA_Accessibility_Hyperlink__epv *epv = &klass->epv;
71   parent_class = g_type_class_peek_parent (klass);
72
73   object_class->finalize = spi_hyperlink_finalize;
74
75   /* Initialize epv table */
76
77   epv->_get_nAnchors = impl__get_n_anchors;
78   epv->getURI = impl_getURI;
79   epv->_get_startIndex = impl__get_startIndex;
80   epv->_get_endIndex = impl__get_endIndex;
81   epv->getObject = impl_getObject;
82   epv->isValid = impl_isValid;
83 }
84
85 static void
86 spi_hyperlink_init (SpiHyperlink *hyperlink)
87 {
88 }
89
90 static void
91 spi_hyperlink_finalize (GObject *obj)
92 {
93   SpiHyperlink *hyperlink = SPI_HYPERLINK(obj);
94   g_object_unref (hyperlink->hyperlink);
95   hyperlink->hyperlink = NULL;
96   parent_class->finalize (obj);
97 }
98
99 SpiHyperlink *
100 spi_hyperlink_new (AtkHyperlink *hyperlink)
101 {
102   SpiHyperlink *new_hyperlink = g_object_new (
103           SPI_HYPERLINK_TYPE, NULL);
104   g_object_ref (hyperlink);
105   new_hyperlink->hyperlink = hyperlink;
106   return new_hyperlink;
107 }
108
109
110
111 static CORBA_short
112 impl__get_n_anchors (PortableServer_Servant _servant,
113                      CORBA_Environment * ev)
114 {
115   SpiHyperlink *link = SPI_HYPERLINK(bonobo_object_from_servant(_servant));
116   return (CORBA_short) atk_hyperlink_get_n_anchors (ATK_HYPERLINK(link->hyperlink));
117 }
118
119
120
121 static CORBA_long
122 impl__get_startIndex (PortableServer_Servant _servant,
123                       CORBA_Environment * ev)
124 {
125   SpiHyperlink *link = SPI_HYPERLINK(bonobo_object_from_servant(_servant));
126   return (CORBA_long) atk_hyperlink_get_start_index (ATK_HYPERLINK(link->hyperlink));
127 }
128
129
130
131 static CORBA_long
132 impl__get_endIndex (PortableServer_Servant _servant,
133                     CORBA_Environment * ev)
134 {
135   SpiHyperlink *link = SPI_HYPERLINK(bonobo_object_from_servant(_servant));
136   return (CORBA_long) atk_hyperlink_get_end_index (ATK_HYPERLINK(link->hyperlink));
137 }
138
139
140
141 static CORBA_string
142 impl_getURI (PortableServer_Servant _servant,
143   const CORBA_long i, CORBA_Environment * ev)
144 {
145   SpiHyperlink *link = SPI_HYPERLINK(bonobo_object_from_servant(_servant));
146   gchar *uri;
147   CORBA_char *rv;
148   uri = atk_hyperlink_get_uri (ATK_HYPERLINK(link->hyperlink), (gint) i);
149   if (uri)
150     {
151       rv = CORBA_string_dup (uri);
152       g_free (uri);
153       }
154   else
155     rv = CORBA_string_dup ("");
156   return rv;
157
158
159
160
161 static Accessibility_Accessible
162 impl_getObject (PortableServer_Servant _servant,
163                 const CORBA_long i,
164                 CORBA_Environment * ev)
165 {
166   SpiHyperlink *link = SPI_HYPERLINK(bonobo_object_from_servant(_servant));
167   AtkObject *atk_object;
168   Accessibility_Accessible rv;
169   atk_object = atk_hyperlink_get_object (ATK_HYPERLINK(link->hyperlink), (gint) i);
170   rv = bonobo_object_corba_objref (BONOBO_OBJECT(spi_accessible_new(atk_object)));
171   return rv;
172 }
173
174
175
176 static CORBA_boolean
177 impl_isValid (PortableServer_Servant _servant,
178               CORBA_Environment * ev)
179 {
180   SpiHyperlink *link = SPI_HYPERLINK(bonobo_object_from_servant(_servant));
181   return (CORBA_boolean) atk_hyperlink_is_valid (ATK_HYPERLINK(link->hyperlink));
182 }