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