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 /* hyperlink.c : implements the Hyperlink interface */
27 #include <libspi/hyperlink.h>
28 #include <libspi/accessible.h>
30 /* Static function declarations */
33 spi_hyperlink_class_init (SpiHyperlinkClass *klass);
35 spi_hyperlink_init (SpiHyperlink *hyperlink);
37 impl_getURI (PortableServer_Servant _servant,
38 const CORBA_long i, CORBA_Environment * ev);
40 impl__get_n_anchors (PortableServer_Servant _servant,
41 CORBA_Environment * ev);
43 impl__get_startIndex (PortableServer_Servant _servant,
44 CORBA_Environment * ev);
46 impl__get_endIndex (PortableServer_Servant _servant,
47 CORBA_Environment * ev);
48 static Accessibility_Accessible
49 impl_getObject (PortableServer_Servant _servant,
51 CORBA_Environment * ev);
53 impl_isValid (PortableServer_Servant _servant,
54 CORBA_Environment * ev);
57 BONOBO_TYPE_FUNC_FULL (SpiHyperlink,
58 Accessibility_Hyperlink,
64 spi_hyperlink_class_init (SpiHyperlinkClass *klass)
66 POA_Accessibility_Hyperlink__epv *epv = &klass->epv;
68 /* Initialize epv table */
70 epv->_get_nAnchors = impl__get_n_anchors;
71 epv->getURI = impl_getURI;
72 epv->_get_startIndex = impl__get_startIndex;
73 epv->_get_endIndex = impl__get_endIndex;
74 epv->getObject = impl_getObject;
75 epv->isValid = impl_isValid;
80 spi_hyperlink_init (SpiHyperlink *hyperlink)
86 spi_hyperlink_new (AtkObject *object)
88 SpiHyperlink *new_hyperlink = g_object_new (
89 SPI_HYPERLINK_TYPE, NULL);
91 spi_base_construct (SPI_BASE (new_hyperlink), G_OBJECT(object));
98 get_hyperlink_from_servant (PortableServer_Servant servant)
100 SpiBase *object = SPI_BASE (bonobo_object_from_servant (servant));
102 g_return_val_if_fail (object != NULL, NULL);
103 g_return_val_if_fail (ATK_IS_OBJECT(object->gobj), NULL);
104 return ATK_HYPERLINK (object->gobj);
109 impl__get_n_anchors (PortableServer_Servant servant,
110 CORBA_Environment *ev)
112 AtkHyperlink *link = get_hyperlink_from_servant (servant);
114 g_return_val_if_fail (link != NULL, 0);
116 return (CORBA_short) atk_hyperlink_get_n_anchors (link);
121 impl__get_startIndex (PortableServer_Servant servant,
122 CORBA_Environment *ev)
124 AtkHyperlink *link = get_hyperlink_from_servant (servant);
126 g_return_val_if_fail (link != NULL, -1);
128 return (CORBA_long) atk_hyperlink_get_start_index (link);
133 impl__get_endIndex (PortableServer_Servant servant,
134 CORBA_Environment *ev)
136 AtkHyperlink *link = get_hyperlink_from_servant (servant);
138 g_return_val_if_fail (link != NULL, -1);
140 return (CORBA_long) atk_hyperlink_get_end_index (link);
145 impl_getURI (PortableServer_Servant servant,
146 const CORBA_long i, CORBA_Environment *ev)
150 AtkHyperlink *link = get_hyperlink_from_servant (servant);
152 g_return_val_if_fail (link != NULL, CORBA_string_dup (""));
154 uri = atk_hyperlink_get_uri (link, (gint) i);
157 rv = CORBA_string_dup (uri);
161 rv = CORBA_string_dup ("");
167 static Accessibility_Accessible
168 impl_getObject (PortableServer_Servant servant,
170 CORBA_Environment *ev)
172 AtkObject *atk_object;
173 AtkHyperlink *link = get_hyperlink_from_servant (servant);
175 g_return_val_if_fail (link != NULL, CORBA_OBJECT_NIL);
177 atk_object = atk_hyperlink_get_object (link, (gint) i);
179 return spi_accessible_new_return (atk_object, FALSE, ev);
184 impl_isValid (PortableServer_Servant servant,
185 CORBA_Environment *ev)
187 AtkHyperlink *link = get_hyperlink_from_servant (servant);
189 g_return_val_if_fail (link != NULL, TRUE);
191 return (CORBA_boolean) atk_hyperlink_is_valid (link);