2 * AT-SPI - Assistive Technology Service Provider Interface
3 * (Gnome Accessibility Project; http://developer.gnome.org/projects/gap)
5 * Copyright 2001, 2002 Sun Microsystems Inc.,
6 * Copyright 2001, 2002 Ximian, Inc.
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Library General Public
10 * License as published by the Free Software Foundation; either
11 * version 2 of the License, or (at your option) any later version.
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Library General Public License for more details.
18 * You should have received a copy of the GNU Library General Public
19 * License along with this library; if not, write to the
20 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
21 * Boston, MA 02111-1307, USA.
24 #include <cspi/spi-private.h>
29 * SPI_freeAccessibleKeySet:
30 * @keyset: An AccessibleKeyset to free.
32 * Release the memory used by an AccessibleKeySet.
36 SPI_freeAccessibleKeySet (AccessibleKeySet *keyset)
39 g_free (keyset->keysyms);
40 g_free (keyset->keycodes);
41 while (keyset->keystrings [i])
43 g_free (keyset->keystrings [i++]);
45 g_free (keyset->keystrings);
50 * SPI_createAccessibleKeySet:
51 * @len: the number of key values in the key set.
52 * @keysyms: a UTF-8 string containing symbolic key values to be matched, or NULL if
53 * matching is performed against other key values instead.
54 * @keycodes: an array of unsigned short values which are the hardware keycodes
55 * to be matched, or NULL if the keyset is specified solely by keysyms
57 * @keystrings: an array of null-terminated character strings which specify key
58 * name values to match, or NULL if the keyset is specified solely by
59 * keycodes and/or keysyms.
61 * Create a new #AccessibleKeySet of a specified length.
62 * A KeySet is used typically to match key event values, and a matches are made
63 * using the following criteria: a match exists with a key event if all non-null
64 * i-th members of the keyset match the key event.
65 * If both keystring and keysym values are NULL, a keycode value match is
66 * forced, thus the match for keysym=0, keycode=0, keystring=NULL is
69 * Returns: a pointer to a newly-created #AccessibleKeySet.
73 SPI_createAccessibleKeySet (int len, const char *keysyms, short *keycodes,
74 const char **keystrings)
76 AccessibleKeySet *keyset = g_new0 (AccessibleKeySet, 1);
77 int i, keysym_len = 0;
78 const char *keysym_ptr = keysyms;
80 keyset->keysyms = g_new0 (unsigned long, len);
81 keyset->keycodes = g_new0 (unsigned short, len);
82 keyset->keystrings = g_new0 (char *, len);
85 keysym_len = g_utf8_strlen (keysyms, -1);
87 for (i = 0; i < len; ++i)
91 keyset->keysyms [i] = (unsigned long) g_utf8_get_char (keysym_ptr);
92 keysym_ptr = g_utf8_find_next_char (keysym_ptr, NULL);
96 keyset->keysyms [i] = 0;
100 keyset->keycodes [i] = keycodes [i];
104 keyset->keystrings [i] = g_strdup (keystrings [i]);
111 * SPI_createAccessibleEventListener:
112 * @callback : an #AccessibleEventListenerCB callback function, or NULL.
113 * @user_data: a pointer to data which will be passed to the callback when invoked.
115 * Create a new #AccessibleEventListener with a specified (in-process) callback function.
117 * Returns: a pointer to a newly-created #AccessibleEventListener.
120 AccessibleEventListener *
121 SPI_createAccessibleEventListener (AccessibleEventListenerCB callback,
124 AccessibleEventListener *listener = cspi_event_listener_new ();
127 AccessibleEventListener_addCallback (listener, callback, user_data);
133 * AccessibleEventListener_addCallback:
134 * @listener: the #AccessibleEventListener instance to modify.
135 * @callback: an #AccessibleEventListenerCB function pointer.
136 * @user_data: a pointer to data which will be passed to the callback when invoked.
138 * Add an in-process callback function to an existing AccessibleEventListener.
139 * Note that the callback function must live in the same address
140 * space as the AccessibleEventListener implementation code, thus one should not
141 * use this function to attach callbacks to a 'remote' event listener
142 * (that is, one that was not created by a client call to
143 * createAccessibleEventListener ();
145 * Returns: #TRUE if successful, otherwise #FALSE.
149 AccessibleEventListener_addCallback (AccessibleEventListener *listener,
150 AccessibleEventListenerCB callback,
153 cspi_event_listener_add_cb (listener, callback, user_data);
158 * AccessibleEventListener_unref:
159 * @listener: a pointer to the #AccessibleEventListener being operated on.
161 * Decrements an #AccessibleEventListener's reference count.
164 AccessibleEventListener_unref (AccessibleEventListener *listener)
166 cspi_event_listener_unref (listener);
170 * AccessibleEventListener_removeCallback:
171 * @listener: the #AccessibleEventListener instance to modify.
172 * @callback: an #AccessibleEventListenerCB function pointer.
174 * Remove an in-process callback function from an existing AccessibleEventListener.
176 * Returns: #TRUE if successful, otherwise #FALSE.
180 AccessibleEventListener_removeCallback (AccessibleEventListener *listener,
181 AccessibleEventListenerCB callback)
183 cspi_event_listener_remove_cb (listener, callback);
188 * SPI_createAccessibleKeystrokeListener:
189 * @callback : an #AccessibleKeystrokeListenerCB callback function, or NULL.
190 * @user_data: a pointer to data which will be passed to the callback when invoked.
192 * Create a new #AccessibleKeystrokeListener with a specified callback function.
194 * Returns: a pointer to a newly-created #AccessibleKeystrokeListener.
197 AccessibleKeystrokeListener *
198 SPI_createAccessibleKeystrokeListener (AccessibleKeystrokeListenerCB callback,
201 AccessibleKeystrokeListener *listener = cspi_keystroke_listener_new ();
204 AccessibleKeystrokeListener_addCallback (listener, callback, user_data);
210 * AccessibleKeystrokeListener_addCallback:
211 * @listener: the #AccessibleKeystrokeListener instance to modify.
212 * @callback: an #AccessibleKeystrokeListenerCB function pointer.
213 * @user_data: a pointer to data which will be passed to the callback when invoked.
215 * Add an in-process callback function to an existing #AccessibleKeystrokeListener.
217 * Returns: #TRUE if successful, otherwise #FALSE.
221 AccessibleKeystrokeListener_addCallback (AccessibleKeystrokeListener *listener,
222 AccessibleKeystrokeListenerCB callback,
225 cspi_keystroke_listener_add_cb (listener, callback, user_data);
230 * AccessibleKeystrokeListener_removeCallback:
231 * @listener: the #AccessibleKeystrokeListener instance to modify.
232 * @callback: an #AccessibleKeystrokeListenerCB function pointer.
234 * Remove an in-process callback function from an existing #AccessibleKeystrokeListener.
236 * Returns: #TRUE if successful, otherwise #FALSE.
240 AccessibleKeystrokeListener_removeCallback (AccessibleKeystrokeListener *listener,
241 AccessibleKeystrokeListenerCB callback)
243 cspi_keystroke_listener_remove_cb (listener, callback);
248 * AccessibleKeystrokeListener_unref:
249 * @listener: a pointer to the #AccessibleKeystrokeListener being operated on.
251 * Decrements an #AccessibleKeystrokeListener's reference count.
254 AccessibleKeystrokeListener_unref (AccessibleKeystrokeListener *listener)
256 cspi_keystroke_listener_unref (listener);