Changes to introspection generation to remove DOCTYPE and XML
[platform/core/uifw/at-spi2-atk.git] / atk-adaptor / devicelistener.c
1 /*
2  * AT-SPI - Assistive Technology Service Provider Interface
3  * (Gnome Accessibility Project; http://developer.gnome.org/projects/gap)
4  *
5  * Copyright 2001, 2002 Sun Microsystems Inc.,
6  * Copyright 2001, 2002 Ximian, Inc.
7  *
8  * This library is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU Library General Public
10  * License as published by the Free Software Foundation; either
11  * version 2 of the License, or (at your option) any later version.
12  *
13  * This library is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16  * Library General Public License for more details.
17  *
18  * You should have received a copy of the GNU Library General Public
19  * License along with this library; if not, write to the
20  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
21  * Boston, MA 02111-1307, USA.
22  */
23
24 /* devicelistener.c: implement the DeviceListener interface */
25
26 #include <config.h>
27 #ifdef SPI_DEBUG
28 #  include <stdio.h>
29 #endif
30 #include <libspi/listener.h>
31 #include <libspi/devicelistener.h>
32
33 /* Our parent Gtk object type  */
34 #define PARENT_TYPE BONOBO_TYPE_OBJECT
35
36 enum {
37         DEVICE_EVENT,
38         LAST_SIGNAL
39 };
40 static guint signals [LAST_SIGNAL];
41
42 /*
43  * CORBA Accessibility::DeviceListener::keyEvent method implementation
44  */
45 static CORBA_boolean
46 impl_device_event (PortableServer_Servant           servant,
47                    const Accessibility_DeviceEvent *key,
48                    CORBA_Environment               *ev)
49 {
50   gboolean was_consumed = FALSE;
51   SpiDeviceListener *listener = SPI_DEVICE_LISTENER (
52           bonobo_object_from_servant (servant));
53
54   g_signal_emit (G_OBJECT (listener), signals [DEVICE_EVENT], 0, key, &was_consumed);
55
56   return was_consumed;
57 }
58
59 static gboolean
60 boolean_handled_accumulator (GSignalInvocationHint *ihint,
61                              GValue                *return_accu,
62                              const GValue          *handler_return,
63                              gpointer               dummy)
64 {
65   gboolean continue_emission;
66   gboolean signal_handled;
67   
68   signal_handled = g_value_get_boolean (handler_return);
69   g_value_set_boolean (return_accu, signal_handled);
70   continue_emission = !signal_handled;
71   
72   return continue_emission;
73 }
74
75 void
76 marshal_BOOLEAN__POINTER (GClosure     *closure,
77                           GValue       *return_value,
78                           guint         n_param_values,
79                           const GValue *param_values,
80                           gpointer      invocation_hint,
81                           gpointer      marshal_data)
82 {
83   typedef gboolean (*GMarshalFunc_BOOLEAN__POINTER) (gpointer     data1,
84                                                      gpointer     arg_1,
85                                                      gpointer     data2);
86   register GMarshalFunc_BOOLEAN__POINTER callback;
87   register GCClosure *cc = (GCClosure*) closure;
88   register gpointer data1, data2;
89   gboolean v_return;
90
91   g_return_if_fail (return_value != NULL);
92   g_return_if_fail (n_param_values == 2);
93
94   if (G_CCLOSURE_SWAP_DATA (closure))
95     {
96       data1 = closure->data;
97       data2 = g_value_peek_pointer (param_values + 0);
98     }
99   else
100     {
101       data1 = g_value_peek_pointer (param_values + 0);
102       data2 = closure->data;
103     }
104   callback = (GMarshalFunc_BOOLEAN__POINTER) (marshal_data ? marshal_data : cc->callback);
105
106   v_return = callback (data1,
107                        g_value_get_pointer (param_values + 1),
108                        data2);
109
110   g_value_set_boolean (return_value, v_return);
111 }
112
113 static void
114 spi_device_listener_class_init (SpiDeviceListenerClass *klass)
115 {
116   POA_Accessibility_DeviceEventListener__epv *epv = &klass->epv;
117   
118   signals [DEVICE_EVENT] = g_signal_new (
119     "device_event",
120     G_TYPE_FROM_CLASS (klass),
121     G_SIGNAL_RUN_LAST,
122     G_STRUCT_OFFSET (SpiDeviceListenerClass, device_event),
123     boolean_handled_accumulator, NULL,
124     marshal_BOOLEAN__POINTER,
125     G_TYPE_BOOLEAN, 1, G_TYPE_POINTER);
126   
127   epv->notifyEvent = impl_device_event;
128 }
129
130 static void
131 spi_device_listener_init (SpiDeviceListener *device_listener)
132 {
133 }
134
135 BONOBO_TYPE_FUNC_FULL (SpiDeviceListener,
136                        Accessibility_DeviceEventListener,
137                        BONOBO_TYPE_OBJECT,
138                        spi_device_listener)
139
140 SpiDeviceListener *
141 spi_device_listener_new (void)
142 {
143     SpiDeviceListener *retval = g_object_new (
144             SPI_DEVICE_LISTENER_TYPE, NULL);
145     return retval;
146 }