Initial revision
[platform/upstream/atk.git] / atk / atkobjectfactory.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 "atkobjectfactory.h"
21 #include "atknoopobjectfactory.h"
22
23 static void atk_object_factory_class_init   (AtkObjectFactoryClass        *klass);
24
25 static gpointer    parent_class = NULL;
26
27 GType
28 atk_object_factory_get_type ()
29 {
30   static GType type = 0;
31
32   if (!type) {
33     GTypeInfo tinfo =
34     {
35       sizeof (AtkObjectFactoryClass),
36       (GBaseInitFunc) NULL, /* base init */
37       (GBaseFinalizeFunc) NULL, /* base finalize */
38       (GClassInitFunc) atk_object_factory_class_init, /* class init */
39       (GClassFinalizeFunc) NULL, /* class finalize */
40       NULL, /* class data */
41       sizeof (AtkObjectFactory), /* instance size */
42       0, /* nb preallocs */
43       (GInstanceInitFunc) NULL, /* instance init */
44       NULL /* value table */
45     };
46
47     type = g_type_register_static (G_TYPE_OBJECT, "AtkObjectFactory", &tinfo, 0);
48   }
49   return type;
50 }
51
52 static void 
53 atk_object_factory_class_init (AtkObjectFactoryClass *klass)
54 {
55   parent_class = g_type_class_ref (G_TYPE_OBJECT);
56
57 }
58
59
60 AtkObject* 
61 atk_object_factory_create_accessible (AtkObjectFactory *factory,
62                                       GObject          *obj)
63 {
64   AtkObjectFactoryClass *klass;
65   AtkObject *accessible = NULL;
66
67   g_return_val_if_fail ((factory != NULL), NULL);
68   g_return_val_if_fail (ATK_IS_OBJECT_FACTORY (factory), NULL);
69   g_return_val_if_fail (obj != NULL, NULL);
70   g_return_val_if_fail (G_IS_OBJECT (obj), NULL);
71
72   klass = ATK_OBJECT_FACTORY_GET_CLASS (factory);
73
74   if (klass->create_accessible)
75   {
76       accessible = klass->create_accessible (obj);
77   }
78   return accessible;
79
80
81 void 
82 atk_object_factory_invalidate (AtkObjectFactory *factory)
83 {
84   AtkObjectFactoryClass *klass;
85
86   g_return_if_fail (factory != NULL);
87   g_return_if_fail (ATK_OBJECT_FACTORY (factory));
88
89   klass = ATK_OBJECT_FACTORY_GET_CLASS (factory);
90   if (klass->invalidate)
91      (klass->invalidate) (factory);
92 }