alternative to assert
[gtkD.git] / gtkD / src / gtk / Signals.d
blobdc5915fcc24ad08d3edc0d3a74f7c2e087799684
1 /*
2 * This file is part of gtkD.
4 * gtkD is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as published by
6 * the Free Software Foundation; either version 2.1 of the License, or
7 * (at your option) any later version.
9 * gtkD is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public License
15 * along with gtkD; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 // generated automatically - do not change
20 // find conversion definition on APILookup.txt
21 // implement new conversion functionalities on the wrap.utils pakage
24 * Conversion parameters:
25 * inFile = gtk-Signals.html
26 * outPack = gtk
27 * outFile = Signals
28 * strct =
29 * realStrct=
30 * ctorStrct=
31 * clss = Signals
32 * interf =
33 * class Code: No
34 * interface Code: No
35 * template for:
36 * extend =
37 * implements:
38 * prefixes:
39 * - gtk_signal_
40 * - gtk_
41 * omit structs:
42 * omit prefixes:
43 * omit code:
44 * imports:
45 * - glib.Str
46 * - gtk.ObjectGtk
47 * - glib.Str
48 * structWrap:
49 * - GtkObject* -> ObjectGtk
50 * module aliases:
51 * local aliases:
54 module gtk.Signals;
56 version(noAssert)
58 version(Tango)
60 import tango.io.Stdout; // use the tango loging?
64 private import gtkc.gtktypes;
66 private import gtkc.gtk;
69 private import glib.Str;
70 private import gtk.ObjectGtk;
71 private import glib.Str;
76 /**
77 * Description
78 * The GTK+ signal system merely proxies the GLib signal system now. For future
79 * usage, direct use of the GSignal API is recommended, this avoids significant
80 * performance hits where GtkArg structures have to be converted into GValues.
81 * What are signals?
82 * Signals are a way to get notification when something happens
83 * and to customize object behavior according to the
84 * user's needs.
85 * Every signal is uniquely identified by a name,
86 * "class_name::signal_name", where signal_name might be something like
87 * "clicked" and class_name might be "GtkButton". Note that some other class
88 * may also define a "clicked" callback, so long as it doesn't derive from
89 * GtkButton.
90 * When they are created, they are also assigned a unique positive integer,
91 * the signal id (1 is the first signal id- 0 is used to flag an error).
92 * Each is also tied to an array of types that describes
93 * the prototype of the function pointer(s) (handlers) you may
94 * connect to the signal. Finally, every signal has
95 * a default handler that is given by a function pointer
96 * in its class structure: it is run by default whenever the
97 * signal is emitted. (It is possible that a signal will
98 * be emitted and a user-defined handler will prevent the default handler
99 * from being run.)
100 * Signals are used by everyone, but they are only
101 * created on a per class basis -- so you should not call
102 * call gtk_signal_new() unless you are writing
103 * a new GtkObject type. However, if you want to make a new signal
104 * for an existing type, you may use gtk_object_class_user_signal_new()
105 * to create a signal that doesn't correspond to a class's builtin
106 * methods.
107 * <hr>
108 * How are signals used?
109 * There are two basic actions in the signal handling game.
110 * If you want notification of an event, you must connect
111 * a function pointer and a data pointer to that signal; the data pointer
112 * will be passed as the last argument to the function (so long as you
113 * are using the default marshalling functions).
114 * You will receive a connection id, a unique positive integer
115 * corresponding to that attachment.
116 * Functions that want to notify the user of certain actions,
117 * emit signals.
118 * <hr>
119 * Basic Terminology
120 * signal
121 * A class method, e.g. GtkButton::clicked.
122 * More precisely it is a unique class-branch/signal-name pair.
123 * This means you may not define a signal handler for a class which
124 * derives from GtkButton that is called clicked,
125 * but it is okay to share signals names if they are separate in
126 * the class tree.
127 * default handler
128 * The object's internal method which is invoked
129 * when the signal is emitted.
130 * user-defined handler
131 * A function pointer and data connected
132 * to a signal (for a particular object).
133 * There are really two types: those which are connected
134 * normally, and those which are connected by one
135 * of the connect_after functions. The connect_after handlers
136 * are always run after the default handler.
137 * Many toolkits refer to these as callbacks.
138 * emission
139 * the whole process of emitting a signal,
140 * including the invocation of all
141 * the different handler types mentioned above.
142 * signal id
143 * The unique positive (nonzero) integer
144 * used to identify a signal. It can be used instead of
145 * a name to many functions for a slight performance
146 * improvement.
147 * connection id
148 * The unique positive (nonzero) integer
149 * used to identify the connection of a user-defined handler
150 * to a signal. Notice that it is allowed to connect the
151 * same function-pointer/user-data pair twice, so
152 * there is no guarantee that a function-pointer/user-data
153 * maps to a unique connection id.
154 * <hr>
155 * A brief note on how they work.
156 * The functions responsible for translating an array of GtkArgs
157 * to your C compiler's normal semantics are called Marshallers.
158 * They are identified by
159 * gtk_marshal_return_value__parameter_list()
160 * for example a C function returning a gboolean and taking a gint
161 * can be invoked by using gtk_marshal_BOOL__INT().
162 * Not all possibly combinations of return/params are available,
163 * of course, so if you are writing a GtkObject with parameters
164 * you might have to write a marshaller.
166 public class Signals
175 * Warning
176 * gtk_signal_new is deprecated and should not be used in newly-written code. Use g_signal_new() instead.
177 * Creates a new signal type. (This is usually done in the
178 * class initializer.)
179 * name:
180 * the event name for the signal, e.g. "clicked".
181 * signal_flags:
182 * a combination of GTK_RUN flags
183 * specifying detail of when the default handler is to be invoked.
184 * You should at least specify GTK_RUN_FIRST
185 * or GTK_RUN_LAST.
186 * object_type:
187 * the type of object this signal pertains to.
188 * It will also pertain to derivers of this type automatically.
189 * function_offset:
190 * How many bytes the function pointer is in
191 * the class structure for this type. Used to invoke a class
192 * method generically.
193 * marshaller:
194 * the function to translate between an array
195 * of GtkArgs and the native calling convention. Usually they
196 * are identified just by the type of arguments they take:
197 * for example, gtk_marshal_BOOL__STRING() describes a marshaller
198 * which takes a string and returns a boolean value.
199 * return_val:
200 * the type of return value, or GTK_TYPE_NONE for a signal
201 * without a return value.
202 * n_args:
203 * the number of parameter the handlers may take.
204 * ...:
205 * a list of GTK_TYPE_*, one for each parameter.
206 * Returns:
207 * the signal id.
209 public static uint newSignals(char[] name, GtkSignalRunType signalFlags, GtkType objectType, uint functionOffset, GtkSignalMarshaller marshaller, GtkType returnVal, uint nArgs, ... )
211 // guint gtk_signal_new (const gchar *name, GtkSignalRunType signal_flags, GtkType object_type, guint function_offset, GtkSignalMarshaller marshaller, GtkType return_val, guint n_args, ...);
212 return gtk_signal_new(Str.toStringz(name), signalFlags, objectType, functionOffset, marshaller, returnVal, nArgs);
216 * Warning
217 * gtk_signal_newv is deprecated and should not be used in newly-written code. Use g_signal_newv() instead.
218 * Creates a new signal type. (This is usually done in a
219 * class initializer.)
220 * This function take the types as an array, instead of a list
221 * following the arguments. Otherwise the same as gtk_signal_new().
222 * name:
223 * the name of the signal to create.
224 * signal_flags:
225 * see gtk_signal_new().
226 * object_type:
227 * the type of GtkObject to associate the signal with.
228 * function_offset:
229 * how many bytes the function pointer is in
230 * the class structure for this type.
231 * marshaller:
232 * return_val:
233 * the type of the return value, or GTK_TYPE_NONE if
234 * you don't want a return value.
235 * n_args:
236 * the number of parameters to the user-defined handlers.
237 * args:
238 * an array of GtkTypes, describing the prototype to
239 * the callbacks.
240 * Returns:
241 * the signal id.
243 public static uint newv(char[] name, GtkSignalRunType signalFlags, GtkType objectType, uint functionOffset, GtkSignalMarshaller marshaller, GtkType returnVal, uint nArgs, GtkType* args)
245 // guint gtk_signal_newv (const gchar *name, GtkSignalRunType signal_flags, GtkType object_type, guint function_offset, GtkSignalMarshaller marshaller, GtkType return_val, guint n_args, GtkType *args);
246 return gtk_signal_newv(Str.toStringz(name), signalFlags, objectType, functionOffset, marshaller, returnVal, nArgs, args);
252 * Warning
253 * gtk_signal_emit is deprecated and should not be used in newly-written code. Use g_signal_emit() instead.
254 * Emits a signal. This causes the default handler and user-defined
255 * handlers to be run.
256 * Here is what gtk_signal_emit() does:
257 * 1. Calls the default handler and the user-connected handlers.
258 * The default handler will be called first if
259 * GTK_RUN_FIRST is set, and last if GTK_RUN_LAST is set.
260 * 2. Calls all handlers connected with the "after" flag set.
261 * object:
262 * the object that emits the signal.
263 * signal_id:
264 * the signal identifier.
265 * ...:
266 * the parameters to the function, followed
267 * by a pointer to the return type, if any.
269 public static void emit(ObjectGtk object, uint signalId, ... )
271 // void gtk_signal_emit (GtkObject *object, guint signal_id, ...);
272 gtk_signal_emit((object is null) ? null : object.getObjectGtkStruct(), signalId);
276 * Warning
277 * gtk_signal_emit_by_name is deprecated and should not be used in newly-written code. Use g_signal_emit_by_name() instead.
278 * Emits a signal. This causes the default handler and user-connected
279 * handlers to be run.
280 * object:
281 * the object that emits the signal.
282 * name:
283 * the name of the signal.
284 * ...:
285 * the parameters to the function, followed
286 * by a pointer to the return type, if any.
288 public static void emitByName(ObjectGtk object, char[] name, ... )
290 // void gtk_signal_emit_by_name (GtkObject *object, const gchar *name, ...);
291 gtk_signal_emit_by_name((object is null) ? null : object.getObjectGtkStruct(), Str.toStringz(name));
295 * Warning
296 * gtk_signal_emitv is deprecated and should not be used in newly-written code. Use g_signal_emitv() instead.
297 * Emits a signal. This causes the default handler and user-connected
298 * handlers to be run. This differs from gtk_signal_emit() by taking
299 * an array of GtkArgs instead of using C's varargs mechanism.
300 * object:
301 * the object to emit the signal to.
302 * signal_id:
303 * the signal identifier.
304 * args:
305 * an array of GtkArgs, one for each parameter,
306 * followed by one which is a pointer to the return type.
308 public static void emitv(ObjectGtk object, uint signalId, GtkArg* args)
310 // void gtk_signal_emitv (GtkObject *object, guint signal_id, GtkArg *args);
311 gtk_signal_emitv((object is null) ? null : object.getObjectGtkStruct(), signalId, args);
315 * Warning
316 * gtk_signal_emitv_by_name is deprecated and should not be used in newly-written code. Use g_signal_emitv() and g_signal_lookup() instead.
317 * Emits a signal by name. This causes the default handler and user-connected
318 * handlers to be run. This differs from gtk_signal_emit() by taking
319 * an array of GtkArgs instead of using C's varargs mechanism.
320 * object:
321 * the object to emit the signal to.
322 * name:
323 * the name of the signal.
324 * args:
325 * an array of GtkArgs, one for each parameter,
326 * followed by one which is a pointer to the return type.
328 public static void emitvByName(ObjectGtk object, char[] name, GtkArg* args)
330 // void gtk_signal_emitv_by_name (GtkObject *object, const gchar *name, GtkArg *args);
331 gtk_signal_emitv_by_name((object is null) ? null : object.getObjectGtkStruct(), Str.toStringz(name), args);
336 * Warning
337 * gtk_signal_emit_stop_by_name is deprecated and should not be used in newly-written code. Use g_signal_stop_emission_by_name() instead.
338 * This function aborts a signal's current emission.
339 * It is just like gtk_signal_emit_stop()
340 * except it will lookup the signal id for you.
341 * object:
342 * the object whose signal handlers you wish to stop.
343 * name:
344 * the name of the signal you wish to stop.
346 public static void emitStopByName(ObjectGtk object, char[] name)
348 // void gtk_signal_emit_stop_by_name (GtkObject *object, const gchar *name);
349 gtk_signal_emit_stop_by_name((object is null) ? null : object.getObjectGtkStruct(), Str.toStringz(name));
357 * Warning
358 * gtk_signal_connect_full is deprecated and should not be used in newly-written code. Use g_signal_connect_data() instead.
359 * Attaches a function pointer and user data to a signal with
360 * more control.
361 * object:
362 * the object which emits the signal. For example, a button
363 * in the button press signal.
364 * name:
365 * the name of the signal.
366 * func:
367 * function pointer to attach to the signal.
368 * unsupported:
369 * data:
370 * the user data associated with the function.
371 * destroy_func:
372 * function to call when this particular hook is
373 * disconnected.
374 * object_signal:
375 * whether this is an object signal-- basically an "object
376 * signal" is one that wants its user_data and object fields switched,
377 * which is useful for calling functions which operate on another
378 * object primarily.
379 * after:
380 * whether to invoke the user-defined handler after the signal, or to let
381 * the signal's default behavior preside (i.e. depending on GTK_RUN_FIRST
382 * and GTK_RUN_LAST).
383 * Returns:
384 * the connection id.
386 public static uint connectFull(ObjectGtk object, char[] name, GtkSignalFunc func, GtkCallbackMarshal unsupported, void* data, GtkDestroyNotify destroyFunc, int objectSignal, int after)
388 // gulong gtk_signal_connect_full (GtkObject *object, const gchar *name, GtkSignalFunc func, GtkCallbackMarshal unsupported, gpointer data, GtkDestroyNotify destroy_func, gint object_signal, gint after);
389 return gtk_signal_connect_full((object is null) ? null : object.getObjectGtkStruct(), Str.toStringz(name), func, unsupported, data, destroyFunc, objectSignal, after);
393 * Warning
394 * gtk_signal_connect_while_alive is deprecated and should not be used in newly-written code. Use g_signal_connect_object() instead.
395 * Attaches a function pointer and another GtkObject to a signal.
396 * This function takes an object whose "destroy" signal
397 * should be trapped.
398 * That way, you don't have to clean up the
399 * signal handler when you destroy the object.
400 * It is a little less efficient though.
401 * (Instead you may call gtk_signal_disconnect_by_data(), if you want
402 * to explicitly delete all attachments to this object. This
403 * is perhaps not recommended since it could be confused
404 * with an integer masquerading as a pointer (through GINT_TO_POINTER()).)
405 * object:
406 * the object that emits the signal.
407 * name:
408 * name of the signal.
409 * func:
410 * function pointer to attach to the signal.
411 * func_data:
412 * pointer to pass to func.
413 * alive_object:
414 * object whose death should cause the handler connection
415 * to be destroyed.
417 public static void connectWhileAlive(ObjectGtk object, char[] name, GtkSignalFunc func, void* funcData, ObjectGtk aliveObject)
419 // void gtk_signal_connect_while_alive (GtkObject *object, const gchar *name, GtkSignalFunc func, gpointer func_data, GtkObject *alive_object);
420 gtk_signal_connect_while_alive((object is null) ? null : object.getObjectGtkStruct(), Str.toStringz(name), func, funcData, (aliveObject is null) ? null : aliveObject.getObjectGtkStruct());
424 * Warning
425 * gtk_signal_connect_object_while_alive is deprecated and should not be used in newly-written code. Use g_signal_connect_object() instead, passing
426 * G_CONNECT_SWAPPED as connect_flags.
427 * These signal connectors are for signals which refer to objects,
428 * so they must not be called after the object is deleted.
429 * Unlike gtk_signal_connect_while_alive(),
430 * this swaps the object and user data, making it suitable for
431 * use with functions which primarily operate on the user data.
432 * This function acts just like gtk_signal_connect_object() except
433 * it traps the "destroy" signal to prevent you from having to
434 * clean up the handler.
435 * object:
436 * the object associated with the signal.
437 * name:
438 * name of the signal.
439 * func:
440 * function pointer to attach to the signal.
441 * alive_object:
442 * the user data, which must be an object, whose destruction
443 * should signal the removal of this signal.
445 public static void connectObjectWhileAlive(ObjectGtk object, char[] name, GtkSignalFunc func, ObjectGtk aliveObject)
447 // void gtk_signal_connect_object_while_alive (GtkObject *object, const gchar *name, GtkSignalFunc func, GtkObject *alive_object);
448 gtk_signal_connect_object_while_alive((object is null) ? null : object.getObjectGtkStruct(), Str.toStringz(name), func, (aliveObject is null) ? null : aliveObject.getObjectGtkStruct());