Minor cleanup of initial checkin.
[platform/core/uifw/at-spi2-atk.git] / libspi / listener.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  * listener.c: test for accessibility implementation
25  *
26  */
27 #define DEBUG_PRINTSTUFF
28 #ifdef DEBUG_PRINTSTUFF
29 #include <stdio.h>
30 #endif
31 #include <config.h>
32 #include <bonobo/Bonobo.h>
33 #include <Accessible.h>
34
35 /*
36  * This pulls the definition for the BonoboObject (GType)
37  */
38 #include "listener.h"
39
40 /*
41  * Our parent Gtk object type
42  */
43 #define PARENT_TYPE BONOBO_X_OBJECT_TYPE
44
45 /*
46  * A pointer to our parent object class
47  */
48 static GObjectClass *listener_parent_class;
49
50 /*
51  * Implemented GObject::finalize
52  */
53 static void
54 listener_object_finalize (GObject *object)
55 {
56 /*        Listener *listener = LISTENER (object); */
57
58         printf("listener_object_finalize called\n");
59
60         listener_parent_class->finalize (object);
61 }
62
63 /*
64  * CORBA Accessibility::Listener::notifyEvent method implementation
65  */
66
67 static void
68 impl_notify_event (PortableServer_Servant     servant,
69                    const Accessibility_Event *e,
70                    CORBA_Environment         *ev)
71 {
72   fprintf (stderr, "notify...\n");
73   fprintf (stderr, "source name: '%s'\n",
74            Accessibility_Accessible__get_name(e->target, ev));
75 }
76
77 static void
78 listener_class_init (ListenerClass *klass)
79 {
80         GObjectClass * object_class = (GObjectClass *) klass;
81         POA_Accessibility_EventListener__epv *epv = &klass->epv;
82         listener_parent_class = g_type_class_ref (BONOBO_X_OBJECT_TYPE);
83
84         object_class->finalize = listener_object_finalize;
85
86         epv->notifyEvent = impl_notify_event;
87 }
88
89 static void
90 listener_init (Listener *listener)
91 {
92 }
93
94 GType
95 listener_get_type (void)
96 {
97         static GType type = 0;
98
99         if (!type) {
100                 static const GTypeInfo tinfo = {
101                         sizeof (ListenerClass),
102                         (GBaseInitFunc) NULL,
103                         (GBaseFinalizeFunc) NULL,
104                         (GClassInitFunc) listener_class_init,
105                         (GClassFinalizeFunc) NULL,
106                         NULL, /* class data */
107                         sizeof (Listener),
108                         0, /* n preallocs */
109                         (GInstanceInitFunc) listener_init,
110                         NULL /* value table */
111                 };
112                 /*
113                  *   Here we use bonobo_x_type_unique instead of
114                  * gtk_type_unique, this auto-generates a load of
115                  * CORBA structures for us. All derived types must
116                  * use bonobo_x_type_unique.
117                  */
118                 type = bonobo_x_type_unique (
119                         PARENT_TYPE,
120                         POA_Accessibility_EventListener__init,
121                         NULL,
122                         G_STRUCT_OFFSET (ListenerClass, epv),
123                         &tinfo,
124                         "Listener");
125         }
126
127         return type;
128 }
129
130 Listener *
131 listener_new (void)
132 {
133     Listener *retval =
134                LISTENER (g_object_new (listener_get_type (), NULL));
135     return retval;
136 }