2001-12-07 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  *
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  *
52  * Add an in-process callback function to an existing AccessibleEventListener.
53  * Note that the callback function must live in the same address
54  * space as the AccessibleEventListener implementation code, thus one should not
55  * use this function to attach callbacks to a 'remote' event listener
56  * (that is, one that was not created by a client call to
57  * createAccessibleEventListener ();
58  *
59  * Returns: #TRUE if successful, otherwise #FALSE.
60  *
61  **/
62 SPIBoolean
63 AccessibleEventListener_addCallback (AccessibleEventListener *listener,
64                                      AccessibleEventListenerCB callback,
65                                      void                     *user_data)
66 {
67   cspi_event_listener_add_callback (listener, callback, user_data);
68   return TRUE;
69 }
70
71 /**
72  * AccessibleEventListener_removeCallback:
73  * @listener: the #AccessibleEventListener instance to modify.
74  * @callback: an #AccessibleEventListenerCB function pointer.
75  *
76  * Remove an in-process callback function from an existing AccessibleEventListener.
77  *
78  * Returns: #TRUE if successful, otherwise #FALSE.
79  *
80  **/
81 SPIBoolean
82 AccessibleEventListener_removeCallback (AccessibleEventListener  *listener,
83                                         AccessibleEventListenerCB callback)
84 {
85   cspi_event_listener_remove_callback (listener, callback);
86   return TRUE;
87 }
88
89 /**
90  * createAccessibleKeystrokeListener:
91  * @callback : an #AccessibleKeystrokeListenerCB callback function, or NULL.
92  *
93  * Create a new #AccessibleKeystrokeListener with a specified callback function.
94  *
95  * Returns: a pointer to a newly-created #AccessibleKeystrokeListener.
96  *
97  **/
98 AccessibleKeystrokeListener *
99 createAccessibleKeystrokeListener (AccessibleKeystrokeListenerCB callback,
100                                    void                         *user_data)
101 {
102   CSpiKeystrokeListener *listener = cspi_keystroke_listener_new ();
103   if (callback)
104     {
105       AccessibleKeystrokeListener_addCallback (listener, callback, user_data);
106     }
107   return (AccessibleKeystrokeListener *)listener;
108 }
109
110 /**
111  * AccessibleKeystrokeListener_addCallback:
112  * @listener: the #AccessibleKeystrokeListener instance to modify.
113  * @callback: an #AccessibleKeystrokeListenerCB function pointer.
114  *
115  * Add an in-process callback function to an existing #AccessibleKeystrokeListener.
116  *
117  * Returns: #TRUE if successful, otherwise #FALSE.
118  *
119  **/
120 SPIBoolean
121 AccessibleKeystrokeListener_addCallback (AccessibleKeystrokeListener *listener,
122                                          AccessibleKeystrokeListenerCB callback,
123                                          void                         *user_data)
124 {
125   cspi_keystroke_listener_add_callback (listener, callback, user_data);
126   return TRUE;
127 }
128
129 /**
130  * AccessibleKeystrokeListener_removeCallback:
131  * @listener: the #AccessibleKeystrokeListener instance to modify.
132  * @callback: an #AccessibleKeystrokeListenerCB function pointer.
133  *
134  * Remove an in-process callback function from an existing #AccessibleKeystrokeListener.
135  *
136  * Returns: #TRUE if successful, otherwise #FALSE.
137  *
138  **/
139 SPIBoolean
140 AccessibleKeystrokeListener_removeCallback (AccessibleKeystrokeListener *listener,
141                                             AccessibleKeystrokeListenerCB callback)
142 {
143   cspi_keystroke_listener_remove_callback (listener, callback);
144   return TRUE;
145 }
146
147 /**
148  * AccessibleKeystrokeListener_unref:
149  * @listener: a pointer to the #AccessibleKeystrokeListener being operated on.
150  *
151  * Decrements an #AccessibleKeystrokeListener's reference count.
152  **/
153 void
154 AccessibleKeystrokeListener_unref (AccessibleKeystrokeListener *listener)
155 {
156   /* Would prefer this not to be bonobo api */
157   bonobo_object_unref (BONOBO_OBJECT (listener));
158 }