Revved micro version, since API was added last checkin.
[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 GType
23 atk_hypertext_get_type ()
24 {
25   static GType type = 0;
26
27   if (!type) {
28     static const GTypeInfo tinfo =
29     {
30       sizeof (AtkHypertextIface),
31       (GBaseInitFunc) NULL,
32       (GBaseFinalizeFunc) NULL,
33
34     };
35
36     type = g_type_register_static (G_TYPE_INTERFACE, "AtkHypertext", &tinfo, 0);
37   }
38
39   return type;
40 }
41
42 /**
43  * atk_hypertext_get_link:
44  * @hypertext: an #AtkHypertext
45  * @link_index: an integer specifying the desired link
46  *
47  * Gets the link in this hypertext document at index 
48  * @link_index
49  *
50  * Returns: the link in this hypertext document at
51  * index @link_index
52  **/
53 AtkHyperlink* 
54 atk_hypertext_get_link (AtkHypertext  *hypertext,
55                         gint          link_index)
56 {
57   AtkHypertextIface *iface;
58
59   g_return_val_if_fail (ATK_IS_HYPERTEXT (hypertext), NULL);
60
61   iface = ATK_HYPERTEXT_GET_IFACE (hypertext);
62
63   if (iface->get_link)
64     return (*(iface->get_link)) (hypertext, link_index);
65   else
66     return NULL;
67 }
68
69 /**
70  * atk_hypertext_get_n_links:
71  * @hypertext: an #AtkHypertext
72  *
73  * Gets the number of links within this hypertext document.
74  *
75  * Returns: the number of links within this hypertext document
76  **/
77 gint 
78 atk_hypertext_get_n_links (AtkHypertext  *hypertext)
79 {
80   AtkHypertextIface *iface;
81
82   g_return_val_if_fail (ATK_IS_HYPERTEXT (hypertext), 0);
83
84   iface = ATK_HYPERTEXT_GET_IFACE (hypertext);
85
86   if (iface->get_n_links)
87     return (*(iface->get_n_links)) (hypertext);
88   else
89     return 0;
90 }
91
92 /**
93  * atk_hypertext_get_link_index:
94  * @hypertext: an #AtkHypertext
95  * @char_index: a character index
96  *
97  * Gets the index into the array of hyperlinks that is associated with
98  * the character specified by @char_index, or -1 if there is no hyperlink
99  * associated with this character.
100  *
101  * Returns: an index into the array of hyperlinks in @hypertext
102  **/
103 gint 
104 atk_hypertext_get_link_index (AtkHypertext  *hypertext,
105                               gint          char_index)
106 {
107   AtkHypertextIface *iface;
108
109   g_return_val_if_fail (ATK_IS_HYPERTEXT (hypertext), -1);
110
111   iface = ATK_HYPERTEXT_GET_IFACE (hypertext);
112
113   if (iface->get_link_index)
114     return (*(iface->get_link_index)) (hypertext, char_index);
115   else
116     return -1;
117 }