* 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
* Boston, MA 02111-1307, USA.
*/
-/*
- * accessibleeventlistener.c: bonobo implementation of SpiListener.idl,
- * with added ability to attach/remove in-process callbacks.
- *
- */
+/* accessibleeventlistener.c: implementation of SpiListener.idl */
+#include <config.h>
#ifdef SPI_DEBUG
#include <stdio.h>
#endif
+#include <libspi/eventlistener.h>
-#include <config.h>
-#include <bonobo/Bonobo.h>
-#include <libspi/Accessibility.h>
-
-/*
- * This pulls the definition for the BonoboObject (GType)
- */
-#include "accessibleeventlistener.h"
-
-/*
- * Our parent Gtk object type
- */
+/* Our parent Gtk object type */
#define PARENT_TYPE SPI_LISTENER_TYPE
-/*
- * A pointer to our parent object class
- */
-static SpiListenerClass *spi_accessible_event_listener_parent_class;
-
-/*
- * Implemented GObject::finalize
- */
-static void
-spi_accessible_event_listener_object_finalize (GObject *object)
-{
-#ifdef SPI_DEBUG
- fprintf(stderr, "spi_listener_object_finalize called\n");
-#endif
- ((GObjectClass *) spi_accessible_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;
- VoidEventListenerCB cb;
- SpiAccessibleEventListener *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 = (VoidEventListenerCB) g_list_nth_data (listener->callbacks, n);
- if (cb)
- {
- (*cb) (e);
- }
- }
- /* Accessibility_Accessible_unref (e->source, ev); */
}
static void
-spi_accessible_event_listener_class_init (SpiAccessibleEventListenerClass *klass)
+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_accessible_event_listener_parent_class = g_type_class_ref (SPI_LISTENER_TYPE);
- object_class->finalize = spi_accessible_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_accessible_event_listener_init (SpiAccessibleEventListener *listener)
+spi_event_listener_init (SpiEventListener *listener)
{
- listener->callbacks = NULL;
}
-GType
-spi_accessible_event_listener_get_type (void)
-{
- static GType type = 0;
-
- if (!type) {
- static const GTypeInfo tinfo = {
- sizeof (SpiAccessibleEventListenerClass),
- (GBaseInitFunc) NULL,
- (GBaseFinalizeFunc) NULL,
- (GClassInitFunc) spi_accessible_event_listener_class_init,
- (GClassFinalizeFunc) NULL,
- NULL, /* class data */
- sizeof (SpiListener),
- 0, /* n preallocs */
- (GInstanceInitFunc) spi_accessible_event_listener_init,
- NULL /* value table */
- };
- /*
- * Here we use bonobo_type_unique instead of
- * gtk_type_unique, this auto-generates a load of
- * CORBA structures for us. All derived types must
- * use bonobo_type_unique.
- */
- type = bonobo_type_unique (
- PARENT_TYPE,
- POA_Accessibility_EventListener__init,
- NULL,
- G_STRUCT_OFFSET (SpiListenerClass, epv),
- &tinfo,
- "SpiAccessibleEventListener");
- }
+BONOBO_TYPE_FUNC (SpiEventListener,
+ PARENT_TYPE,
+ spi_event_listener);
- return type;
-}
-
-SpiAccessibleEventListener *
-spi_accessible_event_listener_new ()
+SpiEventListener *
+spi_event_listener_new ()
{
- SpiAccessibleEventListener *retval =
- SPI_ACCESSIBLE_EVENT_SPI_LISTENER (g_object_new (spi_accessible_event_listener_get_type (), NULL));
+ SpiEventListener *retval = g_object_new (
+ SPI_EVENT_LISTENER_TYPE, NULL);
return retval;
}
-
-void spi_accessible_event_listener_add_callback (SpiAccessibleEventListener *listener,
- VoidEventListenerCB callback)
-{
- listener->callbacks = g_list_append (listener->callbacks, callback);
-}
-
-void spi_accessible_event_listener_remove_callback (SpiAccessibleEventListener *listener,
- VoidEventListenerCB callback)
-{
- listener->callbacks = g_list_remove (listener->callbacks, callback);
-}