Added missing files.
[platform/core/uifw/at-spi2-atk.git] / libspi / component.c
1 /*
2  * AT-SPI - Assistive Technology Service Provider Interface
3  * (Gnome Accessibility Project; http://developer.gnome.org/projects/gap)
4  *
5  * Copyright 2001 Sun Microsystems Inc.
6  *
7  * This library is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Library General Public
9  * License as published by the Free Software Foundation; either
10  * version 2 of the License, or (at your option) any later version.
11  *
12  * This library is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15  * Library General Public License for more details.
16  *
17  * You should have received a copy of the GNU Library General Public
18  * License along with this library; if not, write to the
19  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
20  * Boston, MA 02111-1307, USA.
21  */
22
23 /*
24  * component.c : bonobo wrapper for accessible component implementation
25  *
26  */
27 #include <config.h>
28 #include <bonobo/Bonobo.h>
29
30 #include <stdio.h>
31
32 /*
33  * This pulls the CORBA definitions for the "Accessibility::Accessible" server
34  */
35 #include <libspi/Accessibility.h>
36
37 /*
38  * This pulls the definition for the BonoboObject (Gtk Type)
39  */
40 #include "component.h"
41
42 /*
43  * Our parent Gtk object type
44  */
45 #define PARENT_TYPE BONOBO_OBJECT_TYPE
46
47 /*
48  * A pointer to our parent object class
49  */
50 static GObjectClass *component_parent_class;
51
52 /*
53  * Implemented GObject::finalize
54  */
55 static void
56 accessibility_component_object_finalize (GObject *object)
57 {
58         Component *component = COMPONENT (object);
59
60         printf("accessible_component_object_finalize called\n");
61         component->atko = NULL;
62
63         printf("atko freed, calling parent finalize\n");
64         component_parent_class->finalize (object);
65 }
66
67 /*
68  * CORBA Accessibility::Component::contains method implementation
69  */
70 static CORBA_boolean
71 impl_accessibility_component_contains (PortableServer_Servant servant,
72                                        const CORBA_long x,
73                                        const CORBA_long y,
74                                        CORBA_short coord_type,
75                                        CORBA_Environment     *ev)
76 {
77   CORBA_boolean retval;
78   Component *component = COMPONENT (bonobo_object_from_servant (servant));
79   retval = atk_component_contains (ATK_COMPONENT (component->atko), (gint) x, (gint) y,
80                                   (AtkCoordType) coord_type);
81   fprintf (stderr, "Component contains() called: %s\n", retval ? "true" : "false" );
82   return retval;
83 }
84
85 static void
86 accessibility_component_class_init (ComponentClass *klass)
87 {
88         GObjectClass * object_class = (GObjectClass *) klass;
89         POA_Accessibility_Component__epv *epv = &klass->epv;
90         component_parent_class = g_type_class_peek_parent (klass);
91
92         object_class->finalize = accessibility_component_object_finalize;
93
94         epv->contains = impl_accessibility_component_contains;
95 }
96
97 static void
98 accessibility_component_init (Component *component)
99 {
100 }
101
102 GType
103 accessibility_component_get_type (void)
104 {
105         static GType type = 0;
106
107         if (!type) {
108                 static const GTypeInfo tinfo = {
109                         sizeof (ComponentClass),
110                         (GBaseInitFunc) NULL,
111                         (GBaseFinalizeFunc) NULL,
112                         (GClassInitFunc) accessibility_component_class_init,
113                         (GClassFinalizeFunc) NULL,
114                         NULL, /* class data */
115                         sizeof (Component),
116                         0, /* n preallocs */
117                         (GInstanceInitFunc) accessibility_component_init,
118                         NULL /* value table */
119                 };
120                 /*
121                  * Bonobo_type_unique auto-generates a load of
122                  * CORBA structures for us. All derived types must
123                  * use bonobo_type_unique.
124                  */
125                 type = bonobo_type_unique (
126                         PARENT_TYPE,
127                         POA_Accessibility_Component__init,
128                         NULL,
129                         G_STRUCT_OFFSET (ComponentClass, epv),
130                         &tinfo,
131                         "AccessibleComponent");
132         }
133
134         return type;
135 }
136
137 Component *
138 component_interface_new (AtkObject *o)
139 {
140     Component *retval =
141                COMPONENT (g_object_new (accessibility_component_get_type (), NULL));
142     /* don't increment AtkObject refcount, ref is held by containing Accessible instance */
143     retval->atko = ATK_OBJECT (o);
144     return retval;
145 }