2001-12-11 Michael Meeks <michael@ximian.com>
[platform/core/uifw/at-spi2-atk.git] / cspi / spi_event.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 #include <cspi/spi-private.h>
24
25 /**
26  * createAccessibleEventListener:
27  * @callback : an #AccessibleEventListenerCB callback function, or NULL.
28  * @user_data: a pointer to data which will be passed to the callback when invoked.
29  *
30  * Create a new #AccessibleEventListener with a specified (in-process) callback function.
31  *
32  * Returns: a pointer to a newly-created #AccessibleEventListener.
33  *
34  **/
35 AccessibleEventListener *
36 createAccessibleEventListener (AccessibleEventListenerCB callback,
37                                void                     *user_data)
38 {
39   AccessibleEventListener *listener = cspi_event_listener_new ();
40   if (callback)
41     {
42       AccessibleEventListener_addCallback (listener, callback, user_data);
43     }
44   return listener;
45 }
46
47 /**
48  * AccessibleEventListener_addCallback:
49  * @listener: the #AccessibleEventListener instance to modify.
50  * @callback: an #AccessibleEventListenerCB function pointer.
51  * @user_data: a pointer to data which will be passed to the callback when invoked.
52  *
53  * Add an in-process callback function to an existing AccessibleEventListener.
54  * Note that the callback function must live in the same address
55  * space as the AccessibleEventListener implementation code, thus one should not
56  * use this function to attach callbacks to a 'remote' event listener
57  * (that is, one that was not created by a client call to
58  * createAccessibleEventListener ();
59  *
60  * Returns: #TRUE if successful, otherwise #FALSE.
61  *
62  **/
63 SPIBoolean
64 AccessibleEventListener_addCallback (AccessibleEventListener *listener,
65                                      AccessibleEventListenerCB callback,
66                                      void                     *user_data)
67 {
68   cspi_event_listener_add_cb (listener, callback, user_data);
69   return TRUE;
70 }
71
72 /**
73  * AccessibleEventListener_unref:
74  * @listener: a pointer to the #AccessibleEventListener being operated on.
75  *
76  * Decrements an #AccessibleEventListener's reference count.
77  **/
78 void
79 AccessibleEventListener_unref (AccessibleEventListener *listener)
80 {
81   cspi_event_listener_unref (listener);
82 }
83
84 /**
85  * AccessibleEventListener_removeCallback:
86  * @listener: the #AccessibleEventListener instance to modify.
87  * @callback: an #AccessibleEventListenerCB function pointer.
88  *
89  * Remove an in-process callback function from an existing AccessibleEventListener.
90  *
91  * Returns: #TRUE if successful, otherwise #FALSE.
92  *
93  **/
94 SPIBoolean
95 AccessibleEventListener_removeCallback (AccessibleEventListener  *listener,
96                                         AccessibleEventListenerCB callback)
97 {
98   cspi_event_listener_remove_cb (listener, callback);
99   return TRUE;
100 }
101
102 /**
103  * createAccessibleKeystrokeListener:
104  * @callback : an #AccessibleKeystrokeListenerCB callback function, or NULL.
105  * @user_data: a pointer to data which will be passed to the callback when invoked.
106  *
107  * Create a new #AccessibleKeystrokeListener with a specified callback function.
108  *
109  * Returns: a pointer to a newly-created #AccessibleKeystrokeListener.
110  *
111  **/
112 AccessibleKeystrokeListener *
113 createAccessibleKeystrokeListener (AccessibleKeystrokeListenerCB callback,
114                                    void                         *user_data)
115 {
116   AccessibleKeystrokeListener *listener = cspi_keystroke_listener_new ();
117   if (callback)
118     {
119       AccessibleKeystrokeListener_addCallback (listener, callback, user_data);
120     }
121   return listener;
122 }
123
124 /**
125  * AccessibleKeystrokeListener_addCallback:
126  * @listener: the #AccessibleKeystrokeListener instance to modify.
127  * @callback: an #AccessibleKeystrokeListenerCB function pointer.
128  * @user_data: a pointer to data which will be passed to the callback when invoked.
129  *
130  * Add an in-process callback function to an existing #AccessibleKeystrokeListener.
131  *
132  * Returns: #TRUE if successful, otherwise #FALSE.
133  *
134  **/
135 SPIBoolean
136 AccessibleKeystrokeListener_addCallback (AccessibleKeystrokeListener *listener,
137                                          AccessibleKeystrokeListenerCB callback,
138                                          void                         *user_data)
139 {
140   cspi_keystroke_listener_add_cb (listener, callback, user_data);
141   return TRUE;
142 }
143
144 /**
145  * AccessibleKeystrokeListener_removeCallback:
146  * @listener: the #AccessibleKeystrokeListener instance to modify.
147  * @callback: an #AccessibleKeystrokeListenerCB function pointer.
148  *
149  * Remove an in-process callback function from an existing #AccessibleKeystrokeListener.
150  *
151  * Returns: #TRUE if successful, otherwise #FALSE.
152  *
153  **/
154 SPIBoolean
155 AccessibleKeystrokeListener_removeCallback (AccessibleKeystrokeListener *listener,
156                                             AccessibleKeystrokeListenerCB callback)
157 {
158   cspi_keystroke_listener_remove_cb (listener, callback);
159   return TRUE;
160 }
161
162 /**
163  * AccessibleKeystrokeListener_unref:
164  * @listener: a pointer to the #AccessibleKeystrokeListener being operated on.
165  *
166  * Decrements an #AccessibleKeystrokeListener's reference count.
167  **/
168 void
169 AccessibleKeystrokeListener_unref (AccessibleKeystrokeListener *listener)
170 {
171   cspi_keystroke_listener_unref (listener);
172 }