406cf775fc637d768d7ff5caa31304413f31b9dd
[platform/upstream/atk.git] / atk / atknoopobjectfactory.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, see <http://www.gnu.org/licenses/>.
16  */
17
18 #include "atkobject.h"
19 #include "atknoopobject.h"
20 #include "atknoopobjectfactory.h"
21
22 /**
23  * SECTION:atknoopobjectfactory
24  * @Short_description: The AtkObjectFactory which creates an AtkNoOpObject.
25  * @Title:AtkNoOpObjectFactory
26  *
27  * The AtkObjectFactory which creates an AtkNoOpObject. An instance of
28  * this is created by an AtkRegistry if no factory type has not been
29  * specified to create an accessible object of a particular type.
30  */
31 static void atk_no_op_object_factory_class_init (
32                               AtkNoOpObjectFactoryClass        *klass);
33
34 static AtkObject* atk_no_op_object_factory_create_accessible (
35                               GObject                          *obj);
36 static GType      atk_no_op_object_factory_get_accessible_type (void);
37
38 static gpointer    parent_class = NULL;
39
40 GType
41 atk_no_op_object_factory_get_type (void)
42 {
43   static GType type = 0;
44
45   if (!type) 
46   {
47     static const GTypeInfo tinfo =
48     {
49       sizeof (AtkNoOpObjectFactoryClass),
50       (GBaseInitFunc) NULL, /* base init */
51       (GBaseFinalizeFunc) NULL, /* base finalize */
52       (GClassInitFunc) atk_no_op_object_factory_class_init, /* class init */
53       (GClassFinalizeFunc) NULL, /* class finalize */
54       NULL, /* class data */
55       sizeof (AtkNoOpObjectFactory), /* instance size */
56       0, /* nb preallocs */
57       (GInstanceInitFunc) NULL, /* instance init */
58       NULL /* value table */
59     };
60     type = g_type_register_static (
61                            ATK_TYPE_OBJECT_FACTORY, 
62                            "AtkNoOpObjectFactory" , &tinfo, 0);
63   }
64
65   return type;
66 }
67
68 static void 
69 atk_no_op_object_factory_class_init (AtkNoOpObjectFactoryClass *klass)
70 {
71   AtkObjectFactoryClass *class = ATK_OBJECT_FACTORY_CLASS (klass);
72
73   parent_class = g_type_class_peek_parent (klass);
74
75   class->create_accessible = atk_no_op_object_factory_create_accessible;
76   class->get_accessible_type = atk_no_op_object_factory_get_accessible_type;
77 }
78
79 /**
80  * atk_no_op_object_factory_new:
81  *
82  * Creates an instance of an #AtkObjectFactory which generates primitive
83  * (non-functioning) #AtkObjects. 
84  *
85  * Returns: an instance of an #AtkObjectFactory
86  **/
87 AtkObjectFactory* 
88 atk_no_op_object_factory_new (void)
89 {
90   GObject *factory;
91
92   factory = g_object_new (ATK_TYPE_NO_OP_OBJECT_FACTORY, NULL);
93
94   g_return_val_if_fail (factory != NULL, NULL);
95   return ATK_OBJECT_FACTORY (factory);
96
97
98 static AtkObject* 
99 atk_no_op_object_factory_create_accessible (GObject   *obj)
100 {
101   AtkObject     *accessible;
102
103   accessible = atk_no_op_object_new (obj);
104
105   return accessible;
106 }
107
108 static GType
109 atk_no_op_object_factory_get_accessible_type (void)
110 {
111   return ATK_TYPE_NO_OP_OBJECT;
112 }