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,
73 const char **keystrings)
75 AccessibleKeySet *keyset = g_new0 (AccessibleKeySet, 1);
76 int i, keysym_len = 0;
77 const char *keysym_ptr = keysyms;
79 keyset->keysyms = g_new0 (unsigned long, len);
80 keyset->keycodes = g_new0 (unsigned short, len);
81 keyset->keystrings = g_new0 (char *, len);
84 keysym_len = g_utf8_strlen (keysyms, -1);
86 for (i = 0; i < len; ++i)
90 keyset->keysyms [i] = (unsigned long) g_utf8_get_char (keysym_ptr);
91 keysym_ptr = g_utf8_find_next_char (keysym_ptr, NULL);
95 keyset->keysyms [i] = 0;
99 keyset->keycodes [i] = keycodes [i];
103 keyset->keystrings [i] = g_strdup (keystrings [i]);
110 * SPI_createAccessibleEventListener:
111 * @callback : an #AccessibleEventListenerCB callback function, or NULL.
112 * @user_data: a pointer to data which will be passed to the callback when invoked.
114 * Create a new #AccessibleEventListener with a specified (in-process) callback function.
116 * Returns: a pointer to a newly-created #AccessibleEventListener.
119 AccessibleEventListener *
120 SPI_createAccessibleEventListener (AccessibleEventListenerCB callback,
123 AccessibleEventListener *listener = cspi_event_listener_new ();
126 AccessibleEventListener_addCallback (listener, callback, user_data);
132 * AccessibleEventListener_addCallback:
133 * @listener: the #AccessibleEventListener instance to modify.
134 * @callback: an #AccessibleEventListenerCB function pointer.
135 * @user_data: a pointer to data which will be passed to the callback when invoked.
137 * Add an in-process callback function to an existing AccessibleEventListener.
138 * Note that the callback function must live in the same address
139 * space as the AccessibleEventListener implementation code, thus one should not
140 * use this function to attach callbacks to a 'remote' event listener
141 * (that is, one that was not created by a client call to
142 * createAccessibleEventListener ();
144 * Returns: #TRUE if successful, otherwise #FALSE.
148 AccessibleEventListener_addCallback (AccessibleEventListener *listener,
149 AccessibleEventListenerCB callback,
152 cspi_event_listener_add_cb (listener, callback, user_data);
157 * AccessibleEventListener_unref:
158 * @listener: a pointer to the #AccessibleEventListener being operated on.
160 * Decrements an #AccessibleEventListener's reference count.
163 AccessibleEventListener_unref (AccessibleEventListener *listener)
165 cspi_event_listener_unref (listener);
169 * AccessibleEventListener_removeCallback:
170 * @listener: the #AccessibleEventListener instance to modify.
171 * @callback: an #AccessibleEventListenerCB function pointer.
173 * Remove an in-process callback function from an existing AccessibleEventListener.
175 * Returns: #TRUE if successful, otherwise #FALSE.
179 AccessibleEventListener_removeCallback (AccessibleEventListener *listener,
180 AccessibleEventListenerCB callback)
182 cspi_event_listener_remove_cb (listener, callback);
187 * createAccessibleKeystrokeListener:
188 * @callback : an #AccessibleKeystrokeListenerCB callback function, or NULL.
189 * @user_data: a pointer to data which will be passed to the callback when invoked.
191 * Create a new #AccessibleKeystrokeListener with a specified callback function.
193 * Returns: a pointer to a newly-created #AccessibleKeystrokeListener.
196 AccessibleKeystrokeListener *
197 SPI_createAccessibleKeystrokeListener (AccessibleKeystrokeListenerCB callback,
200 AccessibleKeystrokeListener *listener = cspi_keystroke_listener_new ();
203 AccessibleKeystrokeListener_addCallback (listener, callback, user_data);
209 * AccessibleKeystrokeListener_addCallback:
210 * @listener: the #AccessibleKeystrokeListener instance to modify.
211 * @callback: an #AccessibleKeystrokeListenerCB function pointer.
212 * @user_data: a pointer to data which will be passed to the callback when invoked.
214 * Add an in-process callback function to an existing #AccessibleKeystrokeListener.
216 * Returns: #TRUE if successful, otherwise #FALSE.
220 AccessibleKeystrokeListener_addCallback (AccessibleKeystrokeListener *listener,
221 AccessibleKeystrokeListenerCB callback,
224 cspi_keystroke_listener_add_cb (listener, callback, user_data);
229 * AccessibleKeystrokeListener_removeCallback:
230 * @listener: the #AccessibleKeystrokeListener instance to modify.
231 * @callback: an #AccessibleKeystrokeListenerCB function pointer.
233 * Remove an in-process callback function from an existing #AccessibleKeystrokeListener.
235 * Returns: #TRUE if successful, otherwise #FALSE.
239 AccessibleKeystrokeListener_removeCallback (AccessibleKeystrokeListener *listener,
240 AccessibleKeystrokeListenerCB callback)
242 cspi_keystroke_listener_remove_cb (listener, callback);
247 * AccessibleKeystrokeListener_unref:
248 * @listener: a pointer to the #AccessibleKeystrokeListener being operated on.
250 * Decrements an #AccessibleKeystrokeListener's reference count.
253 AccessibleKeystrokeListener_unref (AccessibleKeystrokeListener *listener)
255 cspi_keystroke_listener_unref (listener);