Started fixing IDL docs.
[platform/core/uifw/at-spi2-atk.git] / libspi / hypertext.c
1 /*
2  * AT-SPI - Assistive Technology Service Provider Interface
3  * (Gnome Accessibility Project; http://developer.gnome.org/projects/gap)
4  *
5  * Copyright 2001 Sun Microsystems Inc.
6  *
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.
11  *
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.
16  *
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.
21  */
22
23 /* hypertext.c : implements the HyperText interface */
24
25 #include <config.h>
26 #include <stdio.h>
27 #include <libspi/hyperlink.h>
28 #include <libspi/hypertext.h>
29
30 /* Static function declarations */
31
32 static GObjectClass *parent_class;
33
34 static void
35 spi_hypertext_finalize (GObject *obj)
36 {
37   SpiHypertext *hypertext = SPI_HYPERTEXT(obj);
38   g_object_unref (hypertext->atko);
39   hypertext->atko = NULL;
40   parent_class->finalize (obj);
41 }
42
43 SpiHypertext *
44 spi_hypertext_interface_new (AtkObject *obj)
45 {
46   SpiHypertext *new_hypertext = g_object_new (SPI_HYPERTEXT_TYPE, NULL);
47   new_hypertext->atko = obj;
48   g_object_ref (obj);
49   return new_hypertext;
50 }
51
52
53
54 static CORBA_long
55 impl_getNLinks (PortableServer_Servant _servant,
56                 CORBA_Environment * ev)
57 {
58   SpiHypertext *hypertext = SPI_HYPERTEXT(bonobo_object_from_servant(_servant));
59   return (CORBA_long)
60     atk_hypertext_get_n_links (ATK_HYPERTEXT(hypertext->atko));
61 }
62
63
64
65 static Accessibility_Hyperlink
66 impl_getLink (PortableServer_Servant servant,
67               const CORBA_long       linkIndex,
68               CORBA_Environment     *ev)
69 {
70   AtkHyperlink *link;
71   SpiHypertext *hypertext;
72   Accessibility_Hyperlink rv;
73   
74   hypertext = SPI_HYPERTEXT (bonobo_object_from_servant (servant));
75
76   link = atk_hypertext_get_link (
77           ATK_HYPERTEXT (hypertext->atko), linkIndex);
78
79   rv = bonobo_object_corba_objref (BONOBO_OBJECT (
80           spi_hyperlink_new (ATK_OBJECT (link))));
81
82   return rv;
83 }
84
85
86
87 static CORBA_long
88 impl_getLinkIndex (PortableServer_Servant _servant,
89                    const CORBA_long characterIndex,
90                                   CORBA_Environment * ev)
91 {
92   SpiHypertext *hypertext = SPI_HYPERTEXT(bonobo_object_from_servant(_servant));
93   return (CORBA_long)
94     atk_hypertext_get_link_index (ATK_HYPERTEXT(hypertext->atko),
95                                   (gint) characterIndex);
96 }
97
98 static void
99 spi_hypertext_class_init (SpiHypertextClass *klass)
100 {
101   GObjectClass * object_class = (GObjectClass *) klass;
102   POA_Accessibility_Hypertext__epv *epv = &klass->epv;
103   parent_class = g_type_class_peek_parent (klass);
104
105   object_class->finalize = spi_hypertext_finalize;
106
107   /* Initialize epv table */
108
109   epv->getNLinks = impl_getNLinks;
110   epv->getLink = impl_getLink;
111   epv->getLinkIndex = impl_getLinkIndex;
112 }
113
114 static void
115 spi_hypertext_init (SpiHypertext *hypertext)
116 {
117 }
118
119 BONOBO_TYPE_FUNC_FULL (SpiHypertext,
120                        Accessibility_Hypertext,
121                        BONOBO_TYPE_OBJECT,
122                        spi_hypertext);