Bug 640574: gobject-introspection annotation and documentation fixes
[atk.git] / atk / atkdocument.c
blob707271335e46511a32262b4d5fa3be20654aa8a4
1 /* ATK - Accessibility Toolkit
2 * Copyright 2001 Sun Microsystems Inc.
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.
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.
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.
20 #include "atkdocument.h"
22 enum {
23 LOAD_COMPLETE,
24 RELOAD,
25 LOAD_STOPPED,
26 LAST_SIGNAL
29 static void atk_document_base_init (AtkDocumentIface *class);
31 static guint atk_document_signals[LAST_SIGNAL] = {0};
33 GType
34 atk_document_get_type (void)
36 static GType type = 0;
38 if (!type) {
39 static const GTypeInfo tinfo =
41 sizeof (AtkDocumentIface),
42 (GBaseInitFunc) atk_document_base_init,
43 (GBaseFinalizeFunc) NULL,
47 type = g_type_register_static (G_TYPE_INTERFACE, "AtkDocument", &tinfo, 0);
50 return type;
53 static void
54 atk_document_base_init (AtkDocumentIface *class)
56 static gboolean initialized = FALSE;
57 if (!initialized)
59 atk_document_signals[LOAD_COMPLETE] =
60 g_signal_new ("load_complete",
61 ATK_TYPE_DOCUMENT,
62 G_SIGNAL_RUN_LAST,
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,
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,
80 (GSignalAccumulator) NULL, NULL,
81 g_cclosure_marshal_VOID__VOID,
82 G_TYPE_NONE, 0);
84 initialized = TRUE;
88 /**
89 * atk_document_get_document_type:
90 * @document: a #GObject instance that implements AtkDocumentIface
92 * Gets a string indicating the document type.
94 * Returns: a string indicating the document type
95 **/
96 G_CONST_RETURN gchar*
97 atk_document_get_document_type (AtkDocument *document)
99 AtkDocumentIface *iface;
101 g_return_val_if_fail (ATK_IS_DOCUMENT (document), NULL);
103 iface = ATK_DOCUMENT_GET_IFACE (document);
105 if (iface->get_document_type)
107 return (iface->get_document_type) (document);
109 else
111 return NULL;
116 * atk_document_get_document:
117 * @document: a #GObject instance that implements AtkDocumentIface
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.
123 * Returns: (transfer none): a %gpointer that points to an instance of the DOM.
125 gpointer
126 atk_document_get_document (AtkDocument *document)
128 AtkDocumentIface *iface;
130 g_return_val_if_fail (ATK_IS_DOCUMENT (document), NULL);
132 iface = ATK_DOCUMENT_GET_IFACE (document);
134 if (iface->get_document)
136 return (iface->get_document) (document);
138 else
140 return NULL;
145 * atk_document_get_locale:
146 * @document: a #GObject instance that implements AtkDocumentIface
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.
154 * Returns: a UTF-8 string indicating the POSIX-style LC_MESSAGES
155 * locale of the document content as a whole, or NULL if
156 * the document content does not specify a locale.
158 G_CONST_RETURN gchar *
159 atk_document_get_locale (AtkDocument *document)
161 AtkDocumentIface *iface;
163 g_return_val_if_fail (ATK_IS_DOCUMENT (document), NULL);
165 iface = ATK_DOCUMENT_GET_IFACE (document);
167 if (iface->get_document_locale)
169 return (iface->get_document_locale) (document);
171 else
173 return NULL;
179 * atk_document_get_attributes:
180 * @document: a #GObject instance that implements AtkDocumentIface
182 * Gets an AtkAttributeSet which describes document-wide
183 * attributes as name-value pairs.
185 * Since: 1.12
187 * Returns: (transfer none): An AtkAttributeSet containing the explicitly
188 * set name-value-pair attributes associated with this document
189 * as a whole.
191 AtkAttributeSet *
192 atk_document_get_attributes (AtkDocument *document)
194 AtkDocumentIface *iface;
196 g_return_val_if_fail (ATK_IS_DOCUMENT (document), NULL);
198 iface = ATK_DOCUMENT_GET_IFACE (document);
200 if (iface->get_document_attributes)
202 return (iface->get_document_attributes) (document);
204 else
206 return NULL;
211 * atk_document_get_attribute_value:
212 * @document: a #GObject instance that implements AtkDocumentIface
213 * @attribute_name: a character string representing the name of the attribute
214 * whose value is being queried.
216 * Since: 1.12
218 * Returns: a string value associated with the named attribute for this
219 * document, or NULL if a value for #attribute_name has not been specified
220 * for this document.
222 G_CONST_RETURN gchar *
223 atk_document_get_attribute_value (AtkDocument *document,
224 const gchar *attribute_name)
226 AtkDocumentIface *iface;
228 g_return_val_if_fail (ATK_IS_DOCUMENT (document), NULL);
230 iface = ATK_DOCUMENT_GET_IFACE (document);
232 if (iface->get_document_attribute_value)
234 return (iface->get_document_attribute_value) (document, attribute_name);
236 else
238 return NULL;
243 * atk_document_set_attribute_value:
244 * @document: a #GObject instance that implements AtkDocumentIface
245 * @attribute_name: a character string representing the name of the attribute
246 * whose value is being set.
247 * @attribute_value: a string value to be associated with #attribute_name.
249 * Since: 1.12
251 * Returns: TRUE if #value is successfully associated with #attribute_name
252 * for this document, FALSE otherwise (e.g. if the document does not
253 * allow the attribute to be modified).
255 gboolean
256 atk_document_set_attribute_value (AtkDocument *document,
257 const gchar *attribute_name,
258 const gchar *attribute_value)
260 AtkDocumentIface *iface;
262 g_return_val_if_fail (ATK_IS_DOCUMENT (document), FALSE);
264 iface = ATK_DOCUMENT_GET_IFACE (document);
266 if (iface->set_document_attribute)
268 return (iface->set_document_attribute) (document, attribute_name, attribute_value);
270 else
272 return FALSE;