2 * AT-SPI - Assistive Technology Service Provider Interface
3 * (Gnome Accessibility Project; http://developer.gnome.org/projects/gap)
5 * Copyright 2001 Sun Microsystems Inc.
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.
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.
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.
23 /* keystrokelistener.c: implement the KeystrokeListener interface */
29 #include <libspi/listener.h>
30 #include <libspi/keystrokelistener.h>
32 /* Our parent Gtk object type */
33 #define PARENT_TYPE BONOBO_TYPE_OBJECT
39 static guint signals [LAST_SIGNAL];
42 * CORBA Accessibility::KeystrokeListener::keyEvent method implementation
45 impl_key_event (PortableServer_Servant servant,
46 const Accessibility_DeviceEvent *key,
47 CORBA_Environment *ev)
49 gboolean was_consumed = FALSE;
50 SpiKeystrokeListener *listener = SPI_KEYSTROKE_LISTENER (
51 bonobo_object_from_servant (servant));
53 g_signal_emit (G_OBJECT (listener), signals [KEY_EVENT], 0, key, &was_consumed);
59 boolean_handled_accumulator (GSignalInvocationHint *ihint,
61 const GValue *handler_return,
64 gboolean continue_emission;
65 gboolean signal_handled;
67 signal_handled = g_value_get_boolean (handler_return);
68 g_value_set_boolean (return_accu, signal_handled);
69 continue_emission = !signal_handled;
71 return continue_emission;
75 marshal_BOOLEAN__POINTER (GClosure *closure,
78 const GValue *param_values,
79 gpointer invocation_hint,
80 gpointer marshal_data)
82 typedef gboolean (*GMarshalFunc_BOOLEAN__POINTER) (gpointer data1,
85 register GMarshalFunc_BOOLEAN__POINTER callback;
86 register GCClosure *cc = (GCClosure*) closure;
87 register gpointer data1, data2;
90 g_return_if_fail (return_value != NULL);
91 g_return_if_fail (n_param_values == 2);
93 if (G_CCLOSURE_SWAP_DATA (closure))
95 data1 = closure->data;
96 data2 = g_value_peek_pointer (param_values + 0);
100 data1 = g_value_peek_pointer (param_values + 0);
101 data2 = closure->data;
103 callback = (GMarshalFunc_BOOLEAN__POINTER) (marshal_data ? marshal_data : cc->callback);
105 v_return = callback (data1,
106 g_value_get_pointer (param_values + 1),
109 g_value_set_boolean (return_value, v_return);
113 spi_keystroke_listener_class_init (SpiKeystrokeListenerClass *klass)
115 POA_Accessibility_DeviceEventListener__epv *epv = &klass->epv;
117 signals [KEY_EVENT] = g_signal_new (
119 G_TYPE_FROM_CLASS (klass),
121 G_STRUCT_OFFSET (SpiKeystrokeListenerClass, key_event),
122 boolean_handled_accumulator, NULL,
123 marshal_BOOLEAN__POINTER,
124 G_TYPE_BOOLEAN, 1, G_TYPE_POINTER);
126 epv->notifyEvent = impl_key_event;
130 spi_keystroke_listener_init (SpiKeystrokeListener *keystroke_listener)
134 BONOBO_TYPE_FUNC_FULL (SpiKeystrokeListener,
135 Accessibility_DeviceEventListener,
137 spi_keystroke_listener);
139 SpiKeystrokeListener *
140 spi_keystroke_listener_new (void)
142 SpiKeystrokeListener *retval = g_object_new (
143 SPI_KEYSTROKE_LISTENER_TYPE, NULL);