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