Revise atk-docs.sgml to add indices for deprecated and new
[platform/upstream/atk.git] / atk / atkdocument.c
1 /* ATK -  Accessibility Toolkit
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 Lesser 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  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser 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 "atkdocument.h"
21
22 GType
23 atk_document_get_type (void)
24 {
25   static GType type = 0;
26
27   if (!type) {
28     static const GTypeInfo tinfo =
29     {
30       sizeof (AtkDocumentIface),
31       (GBaseInitFunc) NULL,
32       (GBaseFinalizeFunc) NULL,
33
34     };
35
36     type = g_type_register_static (G_TYPE_INTERFACE, "AtkDocument", &tinfo, 0);
37   }
38
39   return type;
40 }
41
42 /**
43  * atk_document_get_document_type:
44  * @document: a #GObject instance that implements AtkDocumentIface
45  *
46  * Gets a string indicating the document type.
47  *
48  * Returns: a string indicating the document type
49  **/
50 G_CONST_RETURN gchar*
51 atk_document_get_document_type (AtkDocument *document)
52 {
53   AtkDocumentIface *iface;
54
55   g_return_val_if_fail (ATK_IS_DOCUMENT (document), NULL);
56
57   iface = ATK_DOCUMENT_GET_IFACE (document);
58
59   if (iface->get_document_type)
60     {
61       return (iface->get_document_type) (document);
62     }
63   else
64     {
65       return NULL;
66     }
67 }
68
69 /**
70  * atk_document_get_document:
71  * @document: a #GObject instance that implements AtkDocumentIface
72  *
73  * Gets a %gpointer that points to an instance of the DOM.  It is
74  * up to the caller to check atk_document_get_type to determine
75  * how to cast this pointer.
76  *
77  * Returns: a %gpointer that points to an instance of the DOM.
78  **/
79 gpointer 
80 atk_document_get_document (AtkDocument *document)
81 {
82   AtkDocumentIface *iface;
83
84   g_return_val_if_fail (ATK_IS_DOCUMENT (document), NULL);
85
86   iface = ATK_DOCUMENT_GET_IFACE (document);
87
88   if (iface->get_document)
89     {
90       return (iface->get_document) (document);
91     }
92   else
93     {
94       return NULL;
95     }
96 }
97
98 /**
99  * atk_document_get_locale:
100  * @document: a #GObject instance that implements AtkDocumentIface
101  *
102  * Gets a UTF-8 string indicating the POSIX-style LC_MESSAGES locale
103  *          of the content of this document instance.  Individual
104  *          text substrings or images within this document may have
105  *          a different locale, see atk_text_get_attributes and
106  *          atk_image_get_image_locale.
107  *
108  * Returns: a UTF-8 string indicating the POSIX-style LC_MESSAGES
109  *          locale of the document content as a whole, or NULL if
110  *          the document content does not specify a locale.
111  **/
112 G_CONST_RETURN gchar *
113 atk_document_get_locale (AtkDocument *document)
114 {
115   AtkDocumentIface *iface;
116
117   g_return_val_if_fail (ATK_IS_DOCUMENT (document), NULL);
118
119   iface = ATK_DOCUMENT_GET_IFACE (document);
120
121   if (iface->get_document_locale)
122     {
123       return (iface->get_document_locale) (document);
124     }
125   else
126     {
127       return NULL;
128     }
129 }
130
131
132 /**
133  * atk_document_get_attributes:
134  * @document: a #GObject instance that implements AtkDocumentIface
135  *
136  * Gets an AtkAttributeSet which describes document-wide
137  *          attributes as name-value pairs.
138  *
139  * Since: ATK 1.12
140  *
141  * Returns: An AtkAttributeSet containing the explicitly
142  *          set name-value-pair attributes associated with this document
143  *          as a whole.
144  **/
145 AtkAttributeSet *
146 atk_document_get_attributes (AtkDocument *document)
147 {
148   AtkDocumentIface *iface;
149
150   g_return_val_if_fail (ATK_IS_DOCUMENT (document), NULL);
151
152   iface = ATK_DOCUMENT_GET_IFACE (document);
153
154   if (iface->get_document_attributes)
155     {
156       return (iface->get_document_attributes) (document);
157     }
158   else
159     {
160       return NULL;
161     }
162 }
163
164 /**
165  * atk_document_get_attribute_value:
166  * @document: a #GObject instance that implements AtkDocumentIface
167  * @attribute_name: a character string representing the name of the attribute
168  *            whose value is being queried.
169  *
170  * Since: ATK 1.12
171  *
172  * Returns: a string value associated with the named attribute for this
173  *    document, or NULL if a value for #attribute_name has not been specified
174  *    for this document.
175  */
176 G_CONST_RETURN gchar *
177 atk_document_get_attribute_value (AtkDocument *document, 
178                                   const gchar *attribute_name)
179 {
180   AtkDocumentIface *iface;
181
182   g_return_val_if_fail (ATK_IS_DOCUMENT (document), NULL);
183
184   iface = ATK_DOCUMENT_GET_IFACE (document);
185
186   if (iface->get_document_attribute_value)
187     {
188       return (iface->get_document_attribute_value) (document, attribute_name);
189     }
190   else
191     {
192       return NULL;
193     }
194 }
195
196 /**
197  * atk_document_set_attribute_value:
198  * @document: a #GObject instance that implements AtkDocumentIface
199  * @attribute_name: a character string representing the name of the attribute
200  *            whose value is being set.
201  * @attribute_value: a string value to be associated with #attribute_name.
202  *
203  * Since: ATK 1.12
204  *
205  * Returns: TRUE if #value is successfully associated with #attribute_name
206  *          for this document, FALSE otherwise (e.g. if the document does not
207  *          allow the attribute to be modified).
208  */
209 gboolean
210 atk_document_set_attribute_value (AtkDocument *document, 
211                                   const gchar *attribute_name,
212                                   const gchar *attribute_value)
213 {
214   AtkDocumentIface *iface;
215
216   g_return_val_if_fail (ATK_IS_DOCUMENT (document), FALSE);
217
218   iface = ATK_DOCUMENT_GET_IFACE (document);
219
220   if (iface->set_document_attribute)
221     {
222       return (iface->set_document_attribute) (document, attribute_name, attribute_value);
223     }
224   else
225     {
226       return FALSE;
227     }
228 }