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.
23 /* accessibleeventlistener.c: implementation of SpiListener.idl */
29 #include <libspi/accessibleeventlistener.h>
31 /* Our parent Gtk object type */
32 #define PARENT_TYPE SPI_LISTENER_TYPE
34 /* A pointer to our parent object class */
35 static SpiListenerClass *spi_event_listener_parent_class;
41 static guint signals [LAST_SIGNAL];
44 * Implemented GObject::finalize
47 spi_event_listener_object_finalize (GObject *object)
49 SpiEventListener *listener = SPI_ACCESSIBLE_EVENT_SPI_LISTENER (object);
51 fprintf(stderr, "spi_listener_object_finalize called\n");
53 g_list_free (listener->callbacks);
55 ((GObjectClass *) spi_event_listener_parent_class)->finalize (object);
59 * CORBA Accessibility::Listener::notifyEvent method implementation
63 impl_accessible_event_notify_event (PortableServer_Servant servant,
64 const Accessibility_Event *e,
65 CORBA_Environment *ev)
68 VoidSpiEventListenerCB cb;
69 SpiEventListener *listener = SPI_ACCESSIBLE_EVENT_SPI_LISTENER (
70 bonobo_object_from_servant (servant));
72 for (l = listener->callbacks; l; l = l->next)
74 cb = (VoidSpiEventListenerCB) l->data;
81 g_signal_emit (G_OBJECT (listener), signals [EVENT], 0, e);
85 spi_event_listener_class_init (SpiEventListenerClass *klass)
87 GObjectClass * object_class = (GObjectClass *) klass;
88 SpiListenerClass * spi_listener_class = (SpiListenerClass *) klass;
89 POA_Accessibility_EventListener__epv *epv = &spi_listener_class->epv;
90 spi_event_listener_parent_class = g_type_class_ref (SPI_LISTENER_TYPE);
92 signals [EVENT] = g_signal_new (
94 G_TYPE_FROM_CLASS (klass),
96 G_STRUCT_OFFSET (SpiEventListenerClass, event),
98 g_cclosure_marshal_VOID__POINTER,
99 G_TYPE_NONE, 1, G_TYPE_POINTER);
101 object_class->finalize = spi_event_listener_object_finalize;
103 epv->notifyEvent = impl_accessible_event_notify_event;
107 spi_event_listener_init (SpiEventListener *listener)
109 listener->callbacks = NULL;
112 BONOBO_TYPE_FUNC (SpiEventListener,
117 spi_event_listener_new ()
119 SpiEventListener *retval = g_object_new (
120 SPI_ACCESSIBLE_EVENT_SPI_LISTENER_TYPE, NULL);
125 spi_event_listener_add_callback (SpiEventListener *listener,
126 VoidSpiEventListenerCB callback)
128 listener->callbacks = g_list_prepend (listener->callbacks, callback);
132 spi_event_listener_remove_callback (SpiEventListener *listener,
133 VoidSpiEventListenerCB callback)
135 listener->callbacks = g_list_remove (listener->callbacks, callback);