2 * AT-SPI - Assistive Technology Service Provider Interface
3 * (Gnome Accessibility Project; http://developer.gnome.org/projects/gap)
5 * Copyright 2001 Sun Microsystems Inc.
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.
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.
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.
23 #include <cspi/spi-private.h>
28 * SPI_freeAccessibleKeySet:
29 * @keyset: An AccessibleKeyset to free.
31 * Release the memory used by an AccessibleKeySet.
35 SPI_freeAccessibleKeySet (AccessibleKeySet *keyset)
38 g_free (keyset->keysyms);
39 g_free (keyset->keycodes);
40 while (keyset->keystrings [i])
42 g_free (keyset->keystrings [i++]);
44 g_free (keyset->keystrings);
49 * SPI_createAccessibleKeySet:
50 * @len: the number of key values in the key set.
51 * @keysyms: a UTF-8 string containing symbolic key values to be matched, or NULL if
52 * matching is performed against other key values instead.
53 * @keycodes: an array of unsigned short values which are the hardware keycodes
54 * to be matched, or NULL if the keyset is specified solely by keysyms
56 * @keystrings: an array of null-terminated character strings which specify key
57 * name values to match, or NULL if the keyset is specified solely by
58 * keycodes and/or keysyms.
60 * Create a new #AccessibleKeySet of a specified length.
61 * A KeySet is used typically to match key event values, and a matches are made
62 * using the following criteria: a match exists with a key event if all non-null
63 * i-th members of the keyset match the key event.
64 * If both keystring and keysym values are NULL, a keycode value match is
65 * forced, thus the match for keysym=0, keycode=0, keystring=NULL is
68 * Returns: a pointer to a newly-created #AccessibleKeySet.
72 SPI_createAccessibleKeySet (int len, const char *keysyms, short *keycodes, const char **keystrings)
74 AccessibleKeySet *keyset = g_new0 (AccessibleKeySet, 1);
75 int i, keysym_len = 0;
76 const char *keysym_ptr = keysyms;
78 keyset->keysyms = g_new0 (unsigned long, len);
79 keyset->keycodes = g_new0 (unsigned short, len);
80 keyset->keystrings = g_new0 (char *, len);
83 keysym_len = g_utf8_strlen (keysyms, -1);
85 for (i = 0; i < len; ++i)
89 keyset->keysyms [i] = (unsigned long) g_utf8_get_char (keysym_ptr);
90 keysym_ptr = g_utf8_find_next_char (keysym_ptr, NULL);
94 keyset->keysyms [i] = 0;
96 if (keycodes) keyset->keycodes [i] = keycodes [i];
97 if (keystrings) keyset->keystrings [i] = keystrings [i];
103 * SPI_createAccessibleEventListener:
104 * @callback : an #AccessibleEventListenerCB callback function, or NULL.
105 * @user_data: a pointer to data which will be passed to the callback when invoked.
107 * Create a new #AccessibleEventListener with a specified (in-process) callback function.
109 * Returns: a pointer to a newly-created #AccessibleEventListener.
112 AccessibleEventListener *
113 SPI_createAccessibleEventListener (AccessibleEventListenerCB callback,
116 AccessibleEventListener *listener = cspi_event_listener_new ();
119 AccessibleEventListener_addCallback (listener, callback, user_data);
125 * AccessibleEventListener_addCallback:
126 * @listener: the #AccessibleEventListener instance to modify.
127 * @callback: an #AccessibleEventListenerCB function pointer.
128 * @user_data: a pointer to data which will be passed to the callback when invoked.
130 * Add an in-process callback function to an existing AccessibleEventListener.
131 * Note that the callback function must live in the same address
132 * space as the AccessibleEventListener implementation code, thus one should not
133 * use this function to attach callbacks to a 'remote' event listener
134 * (that is, one that was not created by a client call to
135 * createAccessibleEventListener ();
137 * Returns: #TRUE if successful, otherwise #FALSE.
141 AccessibleEventListener_addCallback (AccessibleEventListener *listener,
142 AccessibleEventListenerCB callback,
145 cspi_event_listener_add_cb (listener, callback, user_data);
150 * AccessibleEventListener_unref:
151 * @listener: a pointer to the #AccessibleEventListener being operated on.
153 * Decrements an #AccessibleEventListener's reference count.
156 AccessibleEventListener_unref (AccessibleEventListener *listener)
158 cspi_event_listener_unref (listener);
162 * AccessibleEventListener_removeCallback:
163 * @listener: the #AccessibleEventListener instance to modify.
164 * @callback: an #AccessibleEventListenerCB function pointer.
166 * Remove an in-process callback function from an existing AccessibleEventListener.
168 * Returns: #TRUE if successful, otherwise #FALSE.
172 AccessibleEventListener_removeCallback (AccessibleEventListener *listener,
173 AccessibleEventListenerCB callback)
175 cspi_event_listener_remove_cb (listener, callback);
180 * createAccessibleKeystrokeListener:
181 * @callback : an #AccessibleKeystrokeListenerCB callback function, or NULL.
182 * @user_data: a pointer to data which will be passed to the callback when invoked.
184 * Create a new #AccessibleKeystrokeListener with a specified callback function.
186 * Returns: a pointer to a newly-created #AccessibleKeystrokeListener.
189 AccessibleKeystrokeListener *
190 SPI_createAccessibleKeystrokeListener (AccessibleKeystrokeListenerCB callback,
193 AccessibleKeystrokeListener *listener = cspi_keystroke_listener_new ();
196 AccessibleKeystrokeListener_addCallback (listener, callback, user_data);
202 * AccessibleKeystrokeListener_addCallback:
203 * @listener: the #AccessibleKeystrokeListener instance to modify.
204 * @callback: an #AccessibleKeystrokeListenerCB function pointer.
205 * @user_data: a pointer to data which will be passed to the callback when invoked.
207 * Add an in-process callback function to an existing #AccessibleKeystrokeListener.
209 * Returns: #TRUE if successful, otherwise #FALSE.
213 AccessibleKeystrokeListener_addCallback (AccessibleKeystrokeListener *listener,
214 AccessibleKeystrokeListenerCB callback,
217 cspi_keystroke_listener_add_cb (listener, callback, user_data);
222 * AccessibleKeystrokeListener_removeCallback:
223 * @listener: the #AccessibleKeystrokeListener instance to modify.
224 * @callback: an #AccessibleKeystrokeListenerCB function pointer.
226 * Remove an in-process callback function from an existing #AccessibleKeystrokeListener.
228 * Returns: #TRUE if successful, otherwise #FALSE.
232 AccessibleKeystrokeListener_removeCallback (AccessibleKeystrokeListener *listener,
233 AccessibleKeystrokeListenerCB callback)
235 cspi_keystroke_listener_remove_cb (listener, callback);
240 * AccessibleKeystrokeListener_unref:
241 * @listener: a pointer to the #AccessibleKeystrokeListener being operated on.
243 * Decrements an #AccessibleKeystrokeListener's reference count.
246 AccessibleKeystrokeListener_unref (AccessibleKeystrokeListener *listener)
248 cspi_keystroke_listener_unref (listener);