2001-12-10 Michael Meeks <michael@ximian.com>
[platform/core/uifw/at-spi2-atk.git] / libspi / eventlistener.c
1 /*
2  * AT-SPI - Assistive Technology Service Provider Interface
3  * (Gnome Accessibility Project; http://developer.gnome.org/projects/gap)
4  *
5  * Copyright 2001 Sun Microsystems Inc.
6  *
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.
11  *
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.
16  *
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.
21  */
22
23 /* accessibleeventlistener.c: implementation of SpiListener.idl */
24
25 #include <config.h>
26 #ifdef SPI_DEBUG
27 #include <stdio.h>
28 #endif
29 #include <libspi/eventlistener.h>
30
31 /* Our parent Gtk object type */
32 #define PARENT_TYPE SPI_LISTENER_TYPE
33
34 enum {
35         EVENT,
36         LAST_SIGNAL
37 };
38 static guint signals [LAST_SIGNAL];
39
40 /*
41  * CORBA Accessibility::Listener::notifyEvent method implementation
42  */
43 static void
44 impl_accessible_event_notify_event (PortableServer_Servant     servant,
45                                     const Accessibility_Event *e,
46                                     CORBA_Environment         *ev)
47 {
48   SpiEventListener *listener = SPI_EVENT_LISTENER (
49           bonobo_object_from_servant (servant));
50
51   g_signal_emit (G_OBJECT (listener), signals [EVENT], 0, e);
52
53   if (e->source != CORBA_OBJECT_NIL)
54     {
55       Accessibility_Accessible_unref (e->source, ev);
56     }
57 }
58
59 static void
60 spi_event_listener_class_init (SpiEventListenerClass *klass)
61 {
62         SpiListenerClass *spi_listener_class = (SpiListenerClass *) klass;
63         POA_Accessibility_EventListener__epv *epv = &spi_listener_class->epv;
64
65         signals [EVENT] = g_signal_new (
66                 "event",
67                 G_TYPE_FROM_CLASS (klass),
68                 G_SIGNAL_RUN_LAST,
69                 G_STRUCT_OFFSET (SpiEventListenerClass, event),
70                 NULL, NULL,
71                 g_cclosure_marshal_VOID__POINTER,
72                 G_TYPE_NONE, 1, G_TYPE_POINTER);
73
74         epv->notifyEvent = impl_accessible_event_notify_event;
75 }
76
77 static void
78 spi_event_listener_init (SpiEventListener *listener)
79 {
80 }
81
82 BONOBO_TYPE_FUNC (SpiEventListener,
83                   PARENT_TYPE,
84                   spi_event_listener);
85
86 SpiEventListener *
87 spi_event_listener_new ()
88 {
89     SpiEventListener *retval = g_object_new (
90             SPI_EVENT_LISTENER_TYPE, NULL);
91     return retval;
92 }