Added new API for ATK 1.11/1.12. Minor docs cleanup.
[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  * Returns: An AtkAttributeSet containing the explicitly
140  *          set name-value-pair attributes associated with this document
141  *          as a whole.
142  * @Since: ATK 1.12
143  **/
144 AtkAttributeSet *
145 atk_document_get_attributes (AtkDocument *document)
146 {
147   AtkDocumentIface *iface;
148
149   g_return_val_if_fail (ATK_IS_DOCUMENT (document), NULL);
150
151   iface = ATK_DOCUMENT_GET_IFACE (document);
152
153   if (iface->get_document_attributes)
154     {
155       return (iface->get_document_attributes) (document);
156     }
157   else
158     {
159       return NULL;
160     }
161 }
162
163 /**
164  * atk_document_get_attribute_value:
165  * @document: a #GObject instance that implements AtkDocumentIface
166  * @attribute_name: a character string representing the name of the attribute
167  *            whose value is being queried.
168  *
169  * Returns: a string value associated with the named attribute for this
170  *    document, or NULL if a value for #attribute_name has not been specified
171  *    for this document.
172  * @Since: ATK 1.12
173  */
174 G_CONST_RETURN gchar *
175 atk_document_get_attribute_value (AtkDocument *document, 
176                                   const gchar *attribute_name)
177 {
178   AtkDocumentIface *iface;
179
180   g_return_val_if_fail (ATK_IS_DOCUMENT (document), NULL);
181
182   iface = ATK_DOCUMENT_GET_IFACE (document);
183
184   if (iface->get_document_attribute_value)
185     {
186       return (iface->get_document_attribute_value) (document, attribute_name);
187     }
188   else
189     {
190       return NULL;
191     }
192 }
193
194 /**
195  * atk_document_set_attribute_value:
196  * @document: a #GObject instance that implements AtkDocumentIface
197  * @attribute_name: a character string representing the name of the attribute
198  *            whose value is being set.
199  * @value: a string value to be associated with #attribute_name.
200  *
201  * Returns: TRUE if #value is successfully associated with #attribute_name
202  *          for this document, FALSE otherwise (e.g. if the document does not
203  *          allow the attribute to be modified).
204  * @Since ATK 1.12
205  */
206 gboolean
207 atk_document_set_attribute_value (AtkDocument *document, 
208                                   const gchar *attribute_name,
209                                   const gchar *value)
210 {
211   AtkDocumentIface *iface;
212
213   g_return_val_if_fail (ATK_IS_DOCUMENT (document), FALSE);
214
215   iface = ATK_DOCUMENT_GET_IFACE (document);
216
217   if (iface->set_document_attribute)
218     {
219       return (iface->set_document_attribute) (document, attribute_name, value);
220     }
221   else
222     {
223       return FALSE;
224     }
225 }