2 * AT-SPI - Assistive Technology Service Provider Interface
3 * (Gnome Accessibility Project; http://developer.gnome.org/projects/gap)
5 * Copyright 2001, 2002 Sun Microsystems Inc.,
6 * Copyright 2001, 2002 Ximian, Inc.
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.
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.
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.
24 /* devicelistener.c: implement the DeviceListener interface */
30 #include <libspi/listener.h>
31 #include <libspi/devicelistener.h>
33 /* Our parent Gtk object type */
34 #define PARENT_TYPE BONOBO_TYPE_OBJECT
40 static guint signals [LAST_SIGNAL];
43 * CORBA Accessibility::DeviceListener::keyEvent method implementation
46 impl_device_event (PortableServer_Servant servant,
47 const Accessibility_DeviceEvent *key,
48 CORBA_Environment *ev)
50 gboolean was_consumed = FALSE;
51 SpiDeviceListener *listener = SPI_DEVICE_LISTENER (
52 bonobo_object_from_servant (servant));
54 g_signal_emit (G_OBJECT (listener), signals [DEVICE_EVENT], 0, key, &was_consumed);
60 boolean_handled_accumulator (GSignalInvocationHint *ihint,
62 const GValue *handler_return,
65 gboolean continue_emission;
66 gboolean signal_handled;
68 signal_handled = g_value_get_boolean (handler_return);
69 g_value_set_boolean (return_accu, signal_handled);
70 continue_emission = !signal_handled;
72 return continue_emission;
76 marshal_BOOLEAN__POINTER (GClosure *closure,
79 const GValue *param_values,
80 gpointer invocation_hint,
81 gpointer marshal_data)
83 typedef gboolean (*GMarshalFunc_BOOLEAN__POINTER) (gpointer data1,
86 register GMarshalFunc_BOOLEAN__POINTER callback;
87 register GCClosure *cc = (GCClosure*) closure;
88 register gpointer data1, data2;
91 g_return_if_fail (return_value != NULL);
92 g_return_if_fail (n_param_values == 2);
94 if (G_CCLOSURE_SWAP_DATA (closure))
96 data1 = closure->data;
97 data2 = g_value_peek_pointer (param_values + 0);
101 data1 = g_value_peek_pointer (param_values + 0);
102 data2 = closure->data;
104 callback = (GMarshalFunc_BOOLEAN__POINTER) (marshal_data ? marshal_data : cc->callback);
106 v_return = callback (data1,
107 g_value_get_pointer (param_values + 1),
110 g_value_set_boolean (return_value, v_return);
114 spi_device_listener_class_init (SpiDeviceListenerClass *klass)
116 POA_Accessibility_DeviceEventListener__epv *epv = &klass->epv;
118 signals [DEVICE_EVENT] = g_signal_new (
120 G_TYPE_FROM_CLASS (klass),
122 G_STRUCT_OFFSET (SpiDeviceListenerClass, device_event),
123 boolean_handled_accumulator, NULL,
124 marshal_BOOLEAN__POINTER,
125 G_TYPE_BOOLEAN, 1, G_TYPE_POINTER);
127 epv->notifyEvent = impl_device_event;
131 spi_device_listener_init (SpiDeviceListener *device_listener)
135 BONOBO_TYPE_FUNC_FULL (SpiDeviceListener,
136 Accessibility_DeviceEventListener,
141 spi_device_listener_new (void)
143 SpiDeviceListener *retval = g_object_new (
144 SPI_DEVICE_LISTENER_TYPE, NULL);