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 spi_hyperlink_finalize (GObject *obj);
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);
58 static GObjectClass *parent_class;
61 BONOBO_TYPE_FUNC_FULL (SpiHyperlink,
62 Accessibility_Hyperlink,
67 spi_hyperlink_class_init (SpiHyperlinkClass *klass)
69 GObjectClass * object_class = (GObjectClass *) klass;
70 POA_Accessibility_Hyperlink__epv *epv = &klass->epv;
71 parent_class = g_type_class_peek_parent (klass);
73 object_class->finalize = spi_hyperlink_finalize;
75 /* Initialize epv table */
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;
86 spi_hyperlink_init (SpiHyperlink *hyperlink)
91 spi_hyperlink_finalize (GObject *obj)
93 SpiHyperlink *hyperlink = SPI_HYPERLINK(obj);
94 g_object_unref (hyperlink->hyperlink);
95 hyperlink->hyperlink = NULL;
96 parent_class->finalize (obj);
100 spi_hyperlink_new (AtkHyperlink *hyperlink)
102 SpiHyperlink *new_hyperlink =
103 SPI_HYPERLINK(g_object_new (SPI_HYPERLINK_TYPE, NULL));
104 g_object_ref (hyperlink);
105 new_hyperlink->hyperlink = hyperlink;
106 return new_hyperlink;
112 impl__get_n_anchors (PortableServer_Servant _servant,
113 CORBA_Environment * ev)
115 SpiHyperlink *link = SPI_HYPERLINK(bonobo_object_from_servant(_servant));
116 return (CORBA_short) atk_hyperlink_get_n_anchors (ATK_HYPERLINK(link->hyperlink));
122 impl__get_startIndex (PortableServer_Servant _servant,
123 CORBA_Environment * ev)
125 SpiHyperlink *link = SPI_HYPERLINK(bonobo_object_from_servant(_servant));
126 return (CORBA_long) atk_hyperlink_get_start_index (ATK_HYPERLINK(link->hyperlink));
132 impl__get_endIndex (PortableServer_Servant _servant,
133 CORBA_Environment * ev)
135 SpiHyperlink *link = SPI_HYPERLINK(bonobo_object_from_servant(_servant));
136 return (CORBA_long) atk_hyperlink_get_end_index (ATK_HYPERLINK(link->hyperlink));
142 impl_getURI (PortableServer_Servant _servant,
143 const CORBA_long i, CORBA_Environment * ev)
145 SpiHyperlink *link = SPI_HYPERLINK(bonobo_object_from_servant(_servant));
148 uri = atk_hyperlink_get_uri (ATK_HYPERLINK(link->hyperlink), (gint) i);
151 rv = CORBA_string_dup (uri);
155 rv = CORBA_string_dup ("");
161 static Accessibility_Accessible
162 impl_getObject (PortableServer_Servant _servant,
164 CORBA_Environment * ev)
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)));
177 impl_isValid (PortableServer_Servant _servant,
178 CORBA_Environment * ev)
180 SpiHyperlink *link = SPI_HYPERLINK(bonobo_object_from_servant(_servant));
181 return (CORBA_boolean) atk_hyperlink_is_valid (ATK_HYPERLINK(link->hyperlink));