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