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.
24 * component.c : bonobo wrapper for accessible component implementation
28 #include <bonobo/Bonobo.h>
33 * This pulls the CORBA definitions for the "Accessibility::Accessible" server
35 #include <libspi/Accessibility.h>
38 * This pulls the definition of the hyperlink bonobo object
40 #include "hyperlink.h"
43 * Static function declarations
47 hyperlink_class_init (HyperlinkClass *klass);
49 hyperlink_init (Hyperlink *hyperlink);
51 hyperlink_finalize (GObject *obj);
53 impl_getURI (PortableServer_Servant _servant,
54 const CORBA_long i, CORBA_Environment * ev);
56 impl__get_n_anchors (PortableServer_Servant _servant,
57 CORBA_Environment * ev);
59 impl__get_startIndex (PortableServer_Servant _servant,
60 CORBA_Environment * ev);
62 impl__get_endIndex (PortableServer_Servant _servant,
63 CORBA_Environment * ev);
64 static Accessibility_Accessible
65 impl_getObject (PortableServer_Servant _servant,
67 CORBA_Environment * ev);
69 impl_isValid (PortableServer_Servant _servant,
70 CORBA_Environment * ev);
72 static GObjectClass *parent_class;
75 hyperlink_get_type (void)
77 static GType type = 0;
80 static const GTypeInfo tinfo = {
81 sizeof (HyperlinkClass),
83 (GBaseFinalizeFunc) NULL,
84 (GClassInitFunc) hyperlink_class_init,
85 (GClassFinalizeFunc) NULL,
86 NULL, /* class data */
89 (GInstanceInitFunc) hyperlink_init,
90 NULL /* value table */
94 * Bonobo_type_unique auto-generates a load of
95 * CORBA structures for us. All derived types must
96 * use bonobo_type_unique.
98 type = bonobo_type_unique (
100 POA_Accessibility_Hyperlink__init,
102 G_STRUCT_OFFSET (HyperlinkClass, epv),
104 "AccessibleHyperlink");
111 hyperlink_class_init (HyperlinkClass *klass)
113 GObjectClass * object_class = (GObjectClass *) klass;
114 POA_Accessibility_Hyperlink__epv *epv = &klass->epv;
115 parent_class = g_type_class_peek_parent (klass);
117 object_class->finalize = hyperlink_finalize;
119 /* Initialize epv table */
121 epv->_get_nAnchors = impl__get_n_anchors;
122 epv->getURI = impl_getURI;
123 epv->_get_startIndex = impl__get_startIndex;
124 epv->_get_endIndex = impl__get_endIndex;
125 epv->getObject = impl_getObject;
126 epv->isValid = impl_isValid;
130 hyperlink_init (Hyperlink *hyperlink)
135 hyperlink_finalize (GObject *obj)
137 Hyperlink *hyperlink = HYPERLINK(obj);
138 g_object_unref (hyperlink->atko);
139 hyperlink->atko = NULL;
140 parent_class->finalize (obj);
144 hyperlink_interface_new (AtkObject *obj)
146 Hyperlink *new_hyperlink =
147 HYPERLINK(g_object_new (HYPERLINK_TYPE, NULL));
148 new_hyperlink->atko = obj;
150 return new_hyperlink;
156 impl__get_n_anchors (PortableServer_Servant _servant,
157 CORBA_Environment * ev)
159 Hyperlink *link = HYPERLINK(bonobo_object_from_servant(_servant));
160 return (CORBA_short) atk_hyperlink_get_n_anchors (ATK_HYPERLINK(link->atko));
166 impl__get_startIndex (PortableServer_Servant _servant,
167 CORBA_Environment * ev)
169 Hyperlink *link = HYPERLINK(bonobo_object_from_servant(_servant));
170 return (CORBA_long) atk_hyperlink_get_start_index (ATK_HYPERLINK(link->atko));
176 impl__get_endIndex (PortableServer_Servant _servant,
177 CORBA_Environment * ev)
179 Hyperlink *link = HYPERLINK(bonobo_object_from_servant(_servant));
180 return (CORBA_long) atk_hyperlink_get_end_index (ATK_HYPERLINK(link->atko));
186 impl_getURI (PortableServer_Servant _servant,
187 const CORBA_long i, CORBA_Environment * ev)
189 Hyperlink *link = HYPERLINK(bonobo_object_from_servant(_servant));
192 uri = atk_hyperlink_get_uri (ATK_HYPERLINK(link->atko), (gint) i);
195 rv = CORBA_string_dup (uri);
199 rv = CORBA_string_dup ("");
205 static Accessibility_Accessible
206 impl_getObject (PortableServer_Servant _servant,
208 CORBA_Environment * ev)
210 Hyperlink *link = HYPERLINK(bonobo_object_from_servant(_servant));
211 AtkObject *atk_object;
212 Accessibility_Accessible rv;
213 atk_object = atk_hyperlink_get_object (ATK_HYPERLINK(link->atko), (gint) i);
214 rv = bonobo_object_corba_objref (BONOBO_OBJECT(accessible_new(atk_object)));
221 impl_isValid (PortableServer_Servant _servant,
222 CORBA_Environment * ev)
224 Hyperlink *link = HYPERLINK(bonobo_object_from_servant(_servant));
225 return (CORBA_boolean) atk_hyperlink_is_valid (ATK_HYPERLINK(link->atko));