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 | /* keystrokelistener.c: implement the KeystrokeListener interface */ |
---|
24 | |
---|
25 | #include <config.h> |
---|
26 | #ifdef SPI_DEBUG |
---|
27 | # include <stdio.h> |
---|
28 | #endif |
---|
29 | #include <libspi/listener.h> |
---|
30 | #include <libspi/keystrokelistener.h> |
---|
31 | |
---|
32 | /* Our parent Gtk object type */ |
---|
33 | #define PARENT_TYPE BONOBO_TYPE_OBJECT |
---|
34 | |
---|
35 | enum { |
---|
36 | KEY_EVENT, |
---|
37 | LAST_SIGNAL |
---|
38 | }; |
---|
39 | static guint signals [LAST_SIGNAL]; |
---|
40 | |
---|
41 | /* |
---|
42 | * CORBA Accessibility::KeystrokeListener::keyEvent method implementation |
---|
43 | */ |
---|
44 | static CORBA_boolean |
---|
45 | impl_key_event (PortableServer_Servant servant, |
---|
46 | const Accessibility_DeviceEvent *key, |
---|
47 | CORBA_Environment *ev) |
---|
48 | { |
---|
49 | gboolean was_consumed = FALSE; |
---|
50 | SpiKeystrokeListener *listener = SPI_KEYSTROKE_LISTENER ( |
---|
51 | bonobo_object_from_servant (servant)); |
---|
52 | |
---|
53 | g_signal_emit (G_OBJECT (listener), signals [KEY_EVENT], 0, key, &was_consumed); |
---|
54 | |
---|
55 | return was_consumed; |
---|
56 | } |
---|
57 | |
---|
58 | static gboolean |
---|
59 | boolean_handled_accumulator (GSignalInvocationHint *ihint, |
---|
60 | GValue *return_accu, |
---|
61 | const GValue *handler_return, |
---|
62 | gpointer dummy) |
---|
63 | { |
---|
64 | gboolean continue_emission; |
---|
65 | gboolean signal_handled; |
---|
66 | |
---|
67 | signal_handled = g_value_get_boolean (handler_return); |
---|
68 | g_value_set_boolean (return_accu, signal_handled); |
---|
69 | continue_emission = !signal_handled; |
---|
70 | |
---|
71 | return continue_emission; |
---|
72 | } |
---|
73 | |
---|
74 | void |
---|
75 | marshal_BOOLEAN__POINTER (GClosure *closure, |
---|
76 | GValue *return_value, |
---|
77 | guint n_param_values, |
---|
78 | const GValue *param_values, |
---|
79 | gpointer invocation_hint, |
---|
80 | gpointer marshal_data) |
---|
81 | { |
---|
82 | typedef gboolean (*GMarshalFunc_BOOLEAN__POINTER) (gpointer data1, |
---|
83 | gpointer arg_1, |
---|
84 | gpointer data2); |
---|
85 | register GMarshalFunc_BOOLEAN__POINTER callback; |
---|
86 | register GCClosure *cc = (GCClosure*) closure; |
---|
87 | register gpointer data1, data2; |
---|
88 | gboolean v_return; |
---|
89 | |
---|
90 | g_return_if_fail (return_value != NULL); |
---|
91 | g_return_if_fail (n_param_values == 2); |
---|
92 | |
---|
93 | if (G_CCLOSURE_SWAP_DATA (closure)) |
---|
94 | { |
---|
95 | data1 = closure->data; |
---|
96 | data2 = g_value_peek_pointer (param_values + 0); |
---|
97 | } |
---|
98 | else |
---|
99 | { |
---|
100 | data1 = g_value_peek_pointer (param_values + 0); |
---|
101 | data2 = closure->data; |
---|
102 | } |
---|
103 | callback = (GMarshalFunc_BOOLEAN__POINTER) (marshal_data ? marshal_data : cc->callback); |
---|
104 | |
---|
105 | v_return = callback (data1, |
---|
106 | g_value_get_pointer (param_values + 1), |
---|
107 | data2); |
---|
108 | |
---|
109 | g_value_set_boolean (return_value, v_return); |
---|
110 | } |
---|
111 | |
---|
112 | static void |
---|
113 | spi_keystroke_listener_class_init (SpiKeystrokeListenerClass *klass) |
---|
114 | { |
---|
115 | POA_Accessibility_DeviceEventListener__epv *epv = &klass->epv; |
---|
116 | |
---|
117 | signals [KEY_EVENT] = g_signal_new ( |
---|
118 | "key_event", |
---|
119 | G_TYPE_FROM_CLASS (klass), |
---|
120 | G_SIGNAL_RUN_LAST, |
---|
121 | G_STRUCT_OFFSET (SpiKeystrokeListenerClass, key_event), |
---|
122 | boolean_handled_accumulator, NULL, |
---|
123 | marshal_BOOLEAN__POINTER, |
---|
124 | G_TYPE_BOOLEAN, 1, G_TYPE_POINTER); |
---|
125 | |
---|
126 | epv->notifyEvent = impl_key_event; |
---|
127 | } |
---|
128 | |
---|
129 | static void |
---|
130 | spi_keystroke_listener_init (SpiKeystrokeListener *keystroke_listener) |
---|
131 | { |
---|
132 | } |
---|
133 | |
---|
134 | BONOBO_TYPE_FUNC_FULL (SpiKeystrokeListener, |
---|
135 | Accessibility_DeviceEventListener, |
---|
136 | BONOBO_TYPE_OBJECT, |
---|
137 | spi_keystroke_listener); |
---|
138 | |
---|
139 | SpiKeystrokeListener * |
---|
140 | spi_keystroke_listener_new (void) |
---|
141 | { |
---|
142 | SpiKeystrokeListener *retval = g_object_new ( |
---|
143 | SPI_KEYSTROKE_LISTENER_TYPE, NULL); |
---|
144 | return retval; |
---|
145 | } |
---|