2 * AT-SPI - Assistive Technology Service Provider Interface
3 * (Gnome Accessibility Project; http://developer.gnome.org/projects/gap)
5 * Copyright 2001 Sun Microsystems Inc.
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.
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.
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.
23 /* hypertext.c : implements the HyperText interface */
27 #include <libspi/hyperlink.h>
28 #include <libspi/hypertext.h>
30 /* Static function declarations */
33 spi_hypertext_class_init (SpiHypertextClass *klass);
35 spi_hypertext_init (SpiHypertext *hypertext);
37 spi_hypertext_finalize (GObject *obj);
39 impl__get_n_anchors (PortableServer_Servant _servant,
40 CORBA_Environment * ev);
42 impl__get_uri (PortableServer_Servant _servant,
43 CORBA_Environment * ev);
45 impl__get_startIndex (PortableServer_Servant _servant,
46 CORBA_Environment * ev);
48 impl__get_endIndex (PortableServer_Servant _servant,
49 CORBA_Environment * ev);
50 static Accessibility_Accessible
51 impl_getAnchor (PortableServer_Servant _servant,
53 CORBA_Environment * ev);
54 static Accessibility_Accessible
55 impl_getObject (PortableServer_Servant _servant,
57 CORBA_Environment * ev);
59 impl_getNLinks (PortableServer_Servant _servant,
60 CORBA_Environment * ev);
61 static Accessibility_Hyperlink
62 impl_getLink (PortableServer_Servant _servant,
63 const CORBA_long linkIndex,
64 CORBA_Environment * ev);
66 impl_getLinkIndex (PortableServer_Servant _servant,
67 const CORBA_long characterIndex,
68 CORBA_Environment * ev);
70 static GObjectClass *parent_class;
73 spi_hypertext_get_type (void)
75 static GType type = 0;
78 static const GTypeInfo tinfo = {
79 sizeof (SpiHypertextClass),
81 (GBaseFinalizeFunc) NULL,
82 (GClassInitFunc) spi_hypertext_class_init,
83 (GClassFinalizeFunc) NULL,
84 NULL, /* class data */
85 sizeof (SpiHypertext),
87 (GInstanceInitFunc) spi_hypertext_init,
88 NULL /* value table */
92 * Bonobo_type_unique auto-generates a load of
93 * CORBA structures for us. All derived types must
94 * use bonobo_type_unique.
96 type = bonobo_type_unique (
98 POA_Accessibility_Hypertext__init,
100 G_STRUCT_OFFSET (SpiHypertextClass, epv),
102 "SpiAccessibleHypertext");
109 spi_hypertext_class_init (SpiHypertextClass *klass)
111 GObjectClass * object_class = (GObjectClass *) klass;
112 POA_Accessibility_Hypertext__epv *epv = &klass->epv;
113 parent_class = g_type_class_peek_parent (klass);
115 object_class->finalize = spi_hypertext_finalize;
117 /* Initialize epv table */
119 epv->getNLinks = impl_getNLinks;
120 epv->getLink = impl_getLink;
121 epv->getLinkIndex = impl_getLinkIndex;
125 spi_hypertext_init (SpiHypertext *hypertext)
130 spi_hypertext_finalize (GObject *obj)
132 SpiHypertext *hypertext = SPI_HYPERTEXT(obj);
133 g_object_unref (hypertext->atko);
134 hypertext->atko = NULL;
135 parent_class->finalize (obj);
139 spi_hypertext_interface_new (AtkObject *obj)
141 SpiHypertext *new_hypertext =
142 SPI_HYPERTEXT(g_object_new (SPI_HYPERTEXT_TYPE, NULL));
143 new_hypertext->atko = obj;
145 return new_hypertext;
151 impl_getNLinks (PortableServer_Servant _servant,
152 CORBA_Environment * ev)
154 SpiHypertext *hypertext = SPI_HYPERTEXT(bonobo_object_from_servant(_servant));
156 atk_hypertext_get_n_links (ATK_HYPERTEXT(hypertext->atko));
161 static Accessibility_Hyperlink
162 impl_getLink (PortableServer_Servant servant,
163 const CORBA_long linkIndex,
164 CORBA_Environment *ev)
167 SpiHypertext *hypertext;
168 Accessibility_Hyperlink rv;
170 hypertext = SPI_HYPERTEXT (bonobo_object_from_servant (servant));
172 link = atk_hypertext_get_link (
173 ATK_HYPERTEXT (hypertext->atko), linkIndex);
175 rv = bonobo_object_corba_objref (BONOBO_OBJECT (
176 spi_hyperlink_new (ATK_OBJECT (link))));
184 impl_getLinkIndex (PortableServer_Servant _servant,
185 const CORBA_long characterIndex,
186 CORBA_Environment * ev)
188 SpiHypertext *hypertext = SPI_HYPERTEXT(bonobo_object_from_servant(_servant));
190 atk_hypertext_get_link_index (ATK_HYPERTEXT(hypertext->atko),
191 (gint) characterIndex);