docs: Fixed mention to atkobject methods
[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 enum {
23   LOAD_COMPLETE,
24   RELOAD,
25   LOAD_STOPPED,
26   LAST_SIGNAL
27 };
28
29 static void atk_document_base_init (AtkDocumentIface *class);
30
31 static guint atk_document_signals[LAST_SIGNAL] = {0};
32
33 GType
34 atk_document_get_type (void)
35 {
36   static GType type = 0;
37
38   if (!type) {
39     static const GTypeInfo tinfo =
40     {
41       sizeof (AtkDocumentIface),
42       (GBaseInitFunc) atk_document_base_init,
43       (GBaseFinalizeFunc) NULL,
44
45     };
46
47     type = g_type_register_static (G_TYPE_INTERFACE, "AtkDocument", &tinfo, 0);
48   }
49
50   return type;
51 }
52
53 static void
54 atk_document_base_init (AtkDocumentIface *class)
55 {
56   static gboolean initialized = FALSE;
57   if (!initialized)
58     {
59       atk_document_signals[LOAD_COMPLETE] =
60         g_signal_new ("load_complete",
61                       ATK_TYPE_DOCUMENT,
62                       G_SIGNAL_RUN_LAST,
63                       0,
64                       (GSignalAccumulator) NULL, NULL,
65                       g_cclosure_marshal_VOID__VOID,
66                       G_TYPE_NONE, 0);
67       atk_document_signals[RELOAD] =
68         g_signal_new ("reload",
69                       ATK_TYPE_DOCUMENT,
70                       G_SIGNAL_RUN_LAST,
71                       0,
72                       (GSignalAccumulator) NULL, NULL,
73                       g_cclosure_marshal_VOID__VOID,
74                       G_TYPE_NONE, 0);
75       atk_document_signals[LOAD_STOPPED] =
76         g_signal_new ("load_stopped",
77                       ATK_TYPE_DOCUMENT,
78                       G_SIGNAL_RUN_LAST,
79                       0,
80                       (GSignalAccumulator) NULL, NULL,
81                       g_cclosure_marshal_VOID__VOID,
82                       G_TYPE_NONE, 0);
83
84       initialized = TRUE;
85     }
86 }
87
88 /**
89  * atk_document_get_document_type:
90  * @document: a #GObject instance that implements AtkDocumentIface
91  *
92  * Gets a string indicating the document type.
93  *
94  * Returns: a string indicating the document type
95  **/
96 const gchar*
97 atk_document_get_document_type (AtkDocument *document)
98 {
99   AtkDocumentIface *iface;
100
101   g_return_val_if_fail (ATK_IS_DOCUMENT (document), NULL);
102
103   iface = ATK_DOCUMENT_GET_IFACE (document);
104
105   if (iface->get_document_type)
106     {
107       return (iface->get_document_type) (document);
108     }
109   else
110     {
111       return NULL;
112     }
113 }
114
115 /**
116  * atk_document_get_document:
117  * @document: a #GObject instance that implements AtkDocumentIface
118  *
119  * Gets a %gpointer that points to an instance of the DOM.  It is
120  * up to the caller to check atk_document_get_type to determine
121  * how to cast this pointer.
122  *
123  * Returns: (transfer none): a %gpointer that points to an instance of the DOM.
124  **/
125 gpointer 
126 atk_document_get_document (AtkDocument *document)
127 {
128   AtkDocumentIface *iface;
129
130   g_return_val_if_fail (ATK_IS_DOCUMENT (document), NULL);
131
132   iface = ATK_DOCUMENT_GET_IFACE (document);
133
134   if (iface->get_document)
135     {
136       return (iface->get_document) (document);
137     }
138   else
139     {
140       return NULL;
141     }
142 }
143
144 /**
145  * atk_document_get_locale:
146  * @document: a #GObject instance that implements AtkDocumentIface
147  *
148  * Gets a UTF-8 string indicating the POSIX-style LC_MESSAGES locale
149  *          of the content of this document instance.  Individual
150  *          text substrings or images within this document may have
151  *          a different locale, see atk_text_get_attributes and
152  *          atk_image_get_image_locale.
153  *
154  * Deprecated: This method is deprecated since ATK version
155  * 2.7.90. Please use atk_object_get_object_locale() instead.
156  *
157  * Returns: a UTF-8 string indicating the POSIX-style LC_MESSAGES
158  *          locale of the document content as a whole, or NULL if
159  *          the document content does not specify a locale.
160  * Virtual: get_document_locale
161  **/
162 const gchar *
163 atk_document_get_locale (AtkDocument *document)
164 {
165   AtkDocumentIface *iface;
166
167   g_return_val_if_fail (ATK_IS_DOCUMENT (document), NULL);
168
169   iface = ATK_DOCUMENT_GET_IFACE (document);
170
171   if (iface->get_document_locale)
172     {
173       return (iface->get_document_locale) (document);
174     }
175   else
176     {
177       return NULL;
178     }
179 }
180
181
182 /**
183  * atk_document_get_attributes:
184  * @document: a #GObject instance that implements AtkDocumentIface
185  *
186  * Gets an AtkAttributeSet which describes document-wide
187  *          attributes as name-value pairs.
188  *
189  * Since: 1.12
190  *
191  * Returns: (transfer none): An AtkAttributeSet containing the explicitly
192  *          set name-value-pair attributes associated with this document
193  *          as a whole.
194  * Virtual: get_document_attributes
195  **/
196 AtkAttributeSet *
197 atk_document_get_attributes (AtkDocument *document)
198 {
199   AtkDocumentIface *iface;
200
201   g_return_val_if_fail (ATK_IS_DOCUMENT (document), NULL);
202
203   iface = ATK_DOCUMENT_GET_IFACE (document);
204
205   if (iface->get_document_attributes)
206     {
207       return (iface->get_document_attributes) (document);
208     }
209   else
210     {
211       return NULL;
212     }
213 }
214
215 /**
216  * atk_document_get_attribute_value:
217  * @document: a #GObject instance that implements AtkDocumentIface
218  * @attribute_name: a character string representing the name of the attribute
219  *            whose value is being queried.
220  *
221  * Since: 1.12
222  *
223  * Returns: a string value associated with the named attribute for this
224  *    document, or NULL if a value for #attribute_name has not been specified
225  *    for this document.
226  * Virtual: get_document_attribute_value
227  */
228 const gchar *
229 atk_document_get_attribute_value (AtkDocument *document, 
230                                   const gchar *attribute_name)
231 {
232   AtkDocumentIface *iface;
233
234   g_return_val_if_fail (ATK_IS_DOCUMENT (document), NULL);
235
236   iface = ATK_DOCUMENT_GET_IFACE (document);
237
238   if (iface->get_document_attribute_value)
239     {
240       return (iface->get_document_attribute_value) (document, attribute_name);
241     }
242   else
243     {
244       return NULL;
245     }
246 }
247
248 /**
249  * atk_document_set_attribute_value:
250  * @document: a #GObject instance that implements AtkDocumentIface
251  * @attribute_name: a character string representing the name of the attribute
252  *            whose value is being set.
253  * @attribute_value: a string value to be associated with #attribute_name.
254  *
255  * Since: 1.12
256  *
257  * Returns: TRUE if #value is successfully associated with #attribute_name
258  *          for this document, FALSE otherwise (e.g. if the document does not
259  *          allow the attribute to be modified).
260  * Virtual: set_document_attribute
261  */
262 gboolean
263 atk_document_set_attribute_value (AtkDocument *document, 
264                                   const gchar *attribute_name,
265                                   const gchar *attribute_value)
266 {
267   AtkDocumentIface *iface;
268
269   g_return_val_if_fail (ATK_IS_DOCUMENT (document), FALSE);
270
271   iface = ATK_DOCUMENT_GET_IFACE (document);
272
273   if (iface->set_document_attribute)
274     {
275       return (iface->set_document_attribute) (document, attribute_name, attribute_value);
276     }
277   else
278     {
279       return FALSE;
280     }
281 }