Initial revision
[platform/upstream/atk.git] / atk / atkhypertext.c
1 /* ATK - The Accessibility Toolkit for GTK+
2  * Copyright 2001 Sun Microsystems Inc.
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Library General Public
6  * License as published by the Free Software Foundation; either
7  * version 2 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12  * Library General Public License for more details.
13  *
14  * You should have received a copy of the GNU Library General Public
15  * License along with this library; if not, write to the
16  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17  * Boston, MA 02111-1307, USA.
18  */
19
20 #include "atkhypertext.h"
21
22 struct _AtkHypertextIfaceClass
23 {
24   GObjectClass parent;
25 };
26
27 typedef struct _AtkHypertextIfaceClass AtkHypertextIfaceClass;
28
29 static void atk_hypertext_interface_init (AtkHypertextIfaceClass *klass);
30
31 static gpointer parent_class = NULL;
32
33
34 GType
35 atk_hypertext_get_type ()
36 {
37   static GType type = 0;
38
39   if (!type) {
40     static const GTypeInfo tinfo =
41     {
42       sizeof (AtkHypertextIface),
43       NULL,
44       NULL,
45       (GInterfaceInitFunc) atk_hypertext_interface_init,
46     };
47
48     type = g_type_register_static (G_TYPE_INTERFACE, "AtkHypertext", &tinfo, 0);
49   }
50
51   return type;
52 }
53
54
55 /*
56  */
57
58 static void
59 atk_hypertext_interface_init (AtkHypertextIfaceClass *klass)
60 {
61   parent_class = g_type_class_ref (ATK_TYPE_HYPERTEXT);
62 }
63
64 AtkHyperLink* 
65 atk_hypertext_get_link (AtkHypertext  *hypertext,
66                         gint          link_index)
67 {
68   AtkHypertextIface *iface;
69
70   g_return_val_if_fail (hypertext != NULL, NULL);
71   g_return_val_if_fail (ATK_IS_HYPERTEXT (hypertext), NULL);
72
73   iface = ATK_HYPERTEXT_GET_IFACE (hypertext);
74
75   if (iface->get_link)
76     return (*(iface->get_link)) (hypertext, link_index);
77   else
78     return NULL;
79 }
80
81 gint 
82 atk_hypertext_get_n_links (AtkHypertext  *hypertext)
83 {
84   AtkHypertextIface *iface;
85
86   g_return_val_if_fail (hypertext != NULL, 0);
87   g_return_val_if_fail (ATK_IS_HYPERTEXT (hypertext), 0);
88
89   iface = ATK_HYPERTEXT_GET_IFACE (hypertext);
90
91   if (iface->get_n_links)
92     return (*(iface->get_n_links)) (hypertext);
93   else
94     return 0;
95 }
96
97 gint 
98 atk_hypertext_get_link_index (AtkHypertext  *hypertext,
99                               gint          char_index)
100 {
101   AtkHypertextIface *iface;
102
103   g_return_val_if_fail (hypertext != NULL, -1);
104   g_return_val_if_fail (ATK_IS_HYPERTEXT (hypertext), -1);
105
106   iface = ATK_HYPERTEXT_GET_IFACE (hypertext);
107
108   if (iface->get_link_index)
109     return (*(iface->get_link_index)) (hypertext, char_index);
110   else
111     return -1;
112 }