2 * AT-SPI - Assistive Technology Service Provider Interface
3 * (Gnome Accessibility Project; http://developer.gnome.org/projects/gap)
5 * Copyright 2001 Sun Microsystems Inc.
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.
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.
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.
24 * accessibleeventlistener.c: bonobo implementation of Listener.idl,
25 * with added ability to attach/remove in-process callbacks.
34 #include <bonobo/Bonobo.h>
35 #include <libspi/Accessibility.h>
38 * This pulls the definition for the BonoboObject (GType)
40 #include "accessibleeventlistener.h"
43 * Our parent Gtk object type
45 #define PARENT_TYPE LISTENER_TYPE
48 * A pointer to our parent object class
50 static ListenerClass *accessible_event_listener_parent_class;
53 * Implemented GObject::finalize
56 accessible_event_listener_object_finalize (GObject *object)
59 fprintf(stderr, "listener_object_finalize called\n");
61 ((GObjectClass *) accessible_event_listener_parent_class)->finalize (object);
65 * CORBA Accessibility::Listener::notifyEvent method implementation
69 impl_accessible_event_notify_event (PortableServer_Servant servant,
70 const Accessibility_Event *e,
71 CORBA_Environment *ev)
75 VoidEventListenerCB cb;
76 AccessibleEventListener *listener = ACCESSIBLE_EVENT_LISTENER (
77 bonobo_object_from_servant (servant));
78 len = g_list_length (listener->callbacks);
82 cb = (VoidEventListenerCB) g_list_nth_data (listener->callbacks, n);
88 /* Accessibility_Accessible_unref (e->source, ev); */
92 accessible_event_listener_class_init (AccessibleEventListenerClass *klass)
94 GObjectClass * object_class = (GObjectClass *) klass;
95 ListenerClass * listener_class = (ListenerClass *) klass;
96 POA_Accessibility_EventListener__epv *epv = &listener_class->epv;
97 accessible_event_listener_parent_class = g_type_class_ref (LISTENER_TYPE);
99 object_class->finalize = accessible_event_listener_object_finalize;
101 epv->notifyEvent = impl_accessible_event_notify_event;
105 accessible_event_listener_init (AccessibleEventListener *listener)
107 listener->callbacks = NULL;
111 accessible_event_listener_get_type (void)
113 static GType type = 0;
116 static const GTypeInfo tinfo = {
117 sizeof (AccessibleEventListenerClass),
118 (GBaseInitFunc) NULL,
119 (GBaseFinalizeFunc) NULL,
120 (GClassInitFunc) accessible_event_listener_class_init,
121 (GClassFinalizeFunc) NULL,
122 NULL, /* class data */
125 (GInstanceInitFunc) accessible_event_listener_init,
126 NULL /* value table */
129 * Here we use bonobo_type_unique instead of
130 * gtk_type_unique, this auto-generates a load of
131 * CORBA structures for us. All derived types must
132 * use bonobo_type_unique.
134 type = bonobo_type_unique (
136 POA_Accessibility_EventListener__init,
138 G_STRUCT_OFFSET (ListenerClass, epv),
140 "AccessibleEventListener");
146 AccessibleEventListener *
147 accessible_event_listener_new ()
149 AccessibleEventListener *retval =
150 ACCESSIBLE_EVENT_LISTENER (g_object_new (accessible_event_listener_get_type (), NULL));
154 void accessible_event_listener_add_callback (AccessibleEventListener *listener,
155 VoidEventListenerCB callback)
157 listener->callbacks = g_list_append (listener->callbacks, callback);
160 void accessible_event_listener_remove_callback (AccessibleEventListener *listener,
161 VoidEventListenerCB callback)
163 listener->callbacks = g_list_remove (listener->callbacks, callback);