2 * AT-SPI - Assistive Technology Service Provider Interface
3 * (Gnome Accessibility Project; http://developer.gnome.org/projects/gap)
5 * Copyright 2001, 2002 Sun Microsystems Inc.,
6 * Copyright 2001, 2002 Ximian, Inc.
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Library General Public
10 * License as published by the Free Software Foundation; either
11 * version 2 of the License, or (at your option) any later version.
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Library General Public License for more details.
18 * You should have received a copy of the GNU Library General Public
19 * License along with this library; if not, write to the
20 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
21 * Boston, MA 02111-1307, USA.
24 /* hyperlink.c : implements the Hyperlink interface */
28 #include <libspi/hyperlink.h>
29 #include <libspi/action.h>
30 #include <libspi/accessible.h>
32 /* Static function declarations */
35 spi_hyperlink_class_init (SpiHyperlinkClass *klass);
37 spi_hyperlink_init (SpiHyperlink *hyperlink);
39 impl_getURI (PortableServer_Servant _servant,
40 const CORBA_long i, CORBA_Environment * ev);
42 impl__get_n_anchors (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_getObject (PortableServer_Servant _servant,
53 CORBA_Environment * ev);
55 impl_isValid (PortableServer_Servant _servant,
56 CORBA_Environment * ev);
59 BONOBO_TYPE_FUNC_FULL (SpiHyperlink,
60 Accessibility_Hyperlink,
66 spi_hyperlink_class_init (SpiHyperlinkClass *klass)
68 POA_Accessibility_Hyperlink__epv *epv = &klass->epv;
70 /* Initialize epv table */
72 epv->_get_nAnchors = impl__get_n_anchors;
73 epv->getURI = impl_getURI;
74 epv->_get_startIndex = impl__get_startIndex;
75 epv->_get_endIndex = impl__get_endIndex;
76 epv->getObject = impl_getObject;
77 epv->isValid = impl_isValid;
82 spi_hyperlink_init (SpiHyperlink *hyperlink)
88 spi_hyperlink_new (AtkHyperlink *object)
90 SpiHyperlink *new_hyperlink = g_object_new (
91 SPI_HYPERLINK_TYPE, NULL);
93 spi_base_construct (SPI_BASE (new_hyperlink), G_OBJECT(object));
96 * some hyperlinks are actionable... this is an ATK convention
97 * that seems convenient though possibly poorly documented or unintended.
99 if (ATK_IS_ACTION (object))
101 bonobo_object_add_interface (bonobo_object (new_hyperlink),
102 BONOBO_OBJECT (spi_action_interface_new (ATK_OBJECT (object))));
104 return new_hyperlink;
107 static AtkHyperlink *
108 get_hyperlink_from_servant (PortableServer_Servant servant)
110 SpiBase *object = SPI_BASE (bonobo_object_from_servant (servant));
112 g_return_val_if_fail (object != NULL, NULL);
113 g_return_val_if_fail (ATK_IS_HYPERLINK(object->gobj), NULL);
114 return ATK_HYPERLINK (object->gobj);
119 impl__get_n_anchors (PortableServer_Servant servant,
120 CORBA_Environment *ev)
122 AtkHyperlink *link = get_hyperlink_from_servant (servant);
124 g_return_val_if_fail (link != NULL, 0);
126 return atk_hyperlink_get_n_anchors (link);
131 impl__get_startIndex (PortableServer_Servant servant,
132 CORBA_Environment *ev)
134 AtkHyperlink *link = get_hyperlink_from_servant (servant);
136 g_return_val_if_fail (link != NULL, -1);
138 return atk_hyperlink_get_start_index (link);
143 impl__get_endIndex (PortableServer_Servant servant,
144 CORBA_Environment *ev)
146 AtkHyperlink *link = get_hyperlink_from_servant (servant);
148 g_return_val_if_fail (link != NULL, -1);
150 return atk_hyperlink_get_end_index (link);
155 impl_getURI (PortableServer_Servant servant,
156 const CORBA_long i, CORBA_Environment *ev)
160 AtkHyperlink *link = get_hyperlink_from_servant (servant);
162 g_return_val_if_fail (link != NULL, CORBA_string_dup (""));
164 uri = atk_hyperlink_get_uri (link, i);
167 rv = CORBA_string_dup (uri);
171 rv = CORBA_string_dup ("");
177 static Accessibility_Accessible
178 impl_getObject (PortableServer_Servant servant,
180 CORBA_Environment *ev)
182 AtkObject *atk_object;
183 AtkHyperlink *link = get_hyperlink_from_servant (servant);
185 g_return_val_if_fail (link != NULL, CORBA_OBJECT_NIL);
187 atk_object = atk_hyperlink_get_object (link, i);
189 return spi_accessible_new_return (atk_object, FALSE, ev);
194 impl_isValid (PortableServer_Servant servant,
195 CORBA_Environment *ev)
197 AtkHyperlink *link = get_hyperlink_from_servant (servant);
199 g_return_val_if_fail (link != NULL, TRUE);
201 return atk_hyperlink_is_valid (link);