Added new atk document interface.
[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 ()
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 (document != NULL, NULL);
56   g_return_val_if_fail (ATK_IS_DOCUMENT (document), NULL);
57
58   iface = ATK_DOCUMENT_GET_IFACE (document);
59
60   if (iface->get_document_type)
61     {
62       return (iface->get_document_type) (document);
63     }
64   else
65     {
66       return NULL;
67     }
68 }
69
70 /**
71  * atk_document_get_document:
72  * @document: a #GObject instance that implements AtkDocumentIface
73  *
74  * Gets a %gpointer that points to an instance of the DOM.  It is
75  * up to the caller to check atk_document_get_type to determine
76  * how to cast this pointer.
77  *
78  * Returns: a %gpointer that points to an instance of the DOM.
79  **/
80 gpointer 
81 atk_document_get_document (AtkDocument *document)
82 {
83   AtkDocumentIface *iface;
84
85   g_return_val_if_fail (document != NULL, NULL);
86   g_return_val_if_fail (ATK_IS_DOCUMENT (document), NULL);
87
88   iface = ATK_DOCUMENT_GET_IFACE (document);
89
90   if (iface->get_document)
91     {
92       return (iface->get_document) (document);
93     }
94   else
95     {
96       return NULL;
97     }
98 }
99