1 /* -*- Mode: C; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim:expandtab:shiftwidth=2:tabstop=2:
3  */
4 /* This Source Code Form is subject to the terms of the Mozilla Public
5  * License, v. 2.0. If a copy of the MPL was not distributed with this
6  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 
8 #include <atk/atk.h>
9 #include "maiRedundantObjectFactory.h"
10 
11 static void mai_redundant_object_factory_class_init(
12     maiRedundantObjectFactoryClass* klass);
13 
14 static AtkObject* mai_redundant_object_factory_create_accessible(GObject* obj);
15 static GType mai_redundant_object_factory_get_accessible_type(void);
16 
mai_redundant_object_factory_get_type(void)17 GType mai_redundant_object_factory_get_type(void) {
18   static GType type = 0;
19 
20   if (!type) {
21     static const GTypeInfo tinfo = {
22         sizeof(maiRedundantObjectFactoryClass),
23         (GBaseInitFunc)NULL,     /* base init */
24         (GBaseFinalizeFunc)NULL, /* base finalize */
25         (GClassInitFunc)
26             mai_redundant_object_factory_class_init, /* class init */
27         (GClassFinalizeFunc)NULL,                    /* class finalize */
28         NULL,                                        /* class data */
29         sizeof(maiRedundantObjectFactory),           /* instance size */
30         0,                                           /* nb preallocs */
31         (GInstanceInitFunc)NULL,                     /* instance init */
32         NULL                                         /* value table */
33     };
34     type = g_type_register_static(ATK_TYPE_OBJECT_FACTORY,
35                                   "MaiRedundantObjectFactory", &tinfo, 0);
36   }
37 
38   return type;
39 }
40 
mai_redundant_object_factory_class_init(maiRedundantObjectFactoryClass * klass)41 static void mai_redundant_object_factory_class_init(
42     maiRedundantObjectFactoryClass* klass) {
43   AtkObjectFactoryClass* class = ATK_OBJECT_FACTORY_CLASS(klass);
44 
45   class->create_accessible = mai_redundant_object_factory_create_accessible;
46   class->get_accessible_type = mai_redundant_object_factory_get_accessible_type;
47 }
48 
49 /**
50  * mai_redundant_object_factory_new:
51  *
52  * Creates an instance of an #AtkObjectFactory which generates primitive
53  * (non-functioning) #AtkObjects.
54  *
55  * Returns: an instance of an #AtkObjectFactory
56  **/
mai_redundant_object_factory_new()57 AtkObjectFactory* mai_redundant_object_factory_new() {
58   GObject* factory;
59 
60   factory = g_object_new(mai_redundant_object_factory_get_type(), NULL);
61 
62   g_return_val_if_fail(factory != NULL, NULL);
63   return ATK_OBJECT_FACTORY(factory);
64 }
65 
mai_redundant_object_factory_create_accessible(GObject * obj)66 static AtkObject* mai_redundant_object_factory_create_accessible(GObject* obj) {
67   AtkObject* accessible;
68 
69   g_return_val_if_fail(obj != NULL, NULL);
70 
71   accessible = g_object_new(ATK_TYPE_OBJECT, NULL);
72   g_return_val_if_fail(accessible != NULL, NULL);
73 
74   accessible->role = ATK_ROLE_REDUNDANT_OBJECT;
75 
76   return accessible;
77 }
78 
mai_redundant_object_factory_get_accessible_type()79 static GType mai_redundant_object_factory_get_accessible_type() {
80   return mai_redundant_object_factory_get_type();
81 }
82