* AT-SPI - Assistive Technology Service Provider Interface
* (Gnome Accessibility Project; http://developer.gnome.org/projects/gap)
*
- * Copyright 2001 Sun Microsystems Inc.
+ * Copyright 2001, 2002 Sun Microsystems Inc.,
+ * Copyright 2001, 2002 Ximian, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
#ifdef SPI_DEBUG
#include <stdio.h>
#endif
-#include <libspi/accessibleeventlistener.h>
+#include <libspi/eventlistener.h>
/* Our parent Gtk object type */
#define PARENT_TYPE SPI_LISTENER_TYPE
-/* A pointer to our parent object class */
-static SpiListenerClass *spi_event_listener_parent_class;
-
-/*
- * Implemented GObject::finalize
- */
-static void
-spi_event_listener_object_finalize (GObject *object)
-{
-#ifdef SPI_DEBUG
- fprintf(stderr, "spi_listener_object_finalize called\n");
-#endif
- ((GObjectClass *) spi_event_listener_parent_class)->finalize (object);
-}
+enum {
+ EVENT,
+ LAST_SIGNAL
+};
+static guint signals [LAST_SIGNAL];
/*
* CORBA Accessibility::Listener::notifyEvent method implementation
*/
-
static void
impl_accessible_event_notify_event (PortableServer_Servant servant,
const Accessibility_Event *e,
CORBA_Environment *ev)
{
- int n;
- int len;
- VoidSpiEventListenerCB cb;
- SpiEventListener *listener = SPI_ACCESSIBLE_EVENT_SPI_LISTENER (
- bonobo_object_from_servant (servant));
- len = g_list_length (listener->callbacks);
+ SpiEventListener *listener = SPI_EVENT_LISTENER (
+ bonobo_object_from_servant (servant));
+
+ g_signal_emit (G_OBJECT (listener), signals [EVENT], 0, e);
- for (n=0; n<len; ++n)
- {
- cb = (VoidSpiEventListenerCB) g_list_nth_data (listener->callbacks, n);
- if (cb)
- {
- (*cb) (e);
- }
- }
- /* Accessibility_Accessible_unref (e->source, ev); */
}
static void
spi_event_listener_class_init (SpiEventListenerClass *klass)
{
- GObjectClass * object_class = (GObjectClass *) klass;
- SpiListenerClass * spi_listener_class = (SpiListenerClass *) klass;
+ SpiListenerClass *spi_listener_class = (SpiListenerClass *) klass;
POA_Accessibility_EventListener__epv *epv = &spi_listener_class->epv;
- spi_event_listener_parent_class = g_type_class_ref (SPI_LISTENER_TYPE);
- object_class->finalize = spi_event_listener_object_finalize;
+ signals [EVENT] = g_signal_new (
+ "event",
+ G_TYPE_FROM_CLASS (klass),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (SpiEventListenerClass, event),
+ NULL, NULL,
+ g_cclosure_marshal_VOID__POINTER,
+ G_TYPE_NONE, 1, G_TYPE_POINTER);
epv->notifyEvent = impl_accessible_event_notify_event;
}
static void
spi_event_listener_init (SpiEventListener *listener)
{
- listener->callbacks = NULL;
}
BONOBO_TYPE_FUNC (SpiEventListener,
SpiEventListener *
spi_event_listener_new ()
{
- SpiEventListener *retval =
- SPI_ACCESSIBLE_EVENT_SPI_LISTENER (g_object_new (spi_event_listener_get_type (), NULL));
+ SpiEventListener *retval = g_object_new (
+ SPI_EVENT_LISTENER_TYPE, NULL);
return retval;
}
-
-void spi_event_listener_add_callback (SpiEventListener *listener,
- VoidSpiEventListenerCB callback)
-{
- listener->callbacks = g_list_append (listener->callbacks, callback);
-}
-
-void spi_event_listener_remove_callback (SpiEventListener *listener,
- VoidSpiEventListenerCB callback)
-{
- listener->callbacks = g_list_remove (listener->callbacks, callback);
-}