alternative to assert
[gtkD.git] / gtkD / src / gobject / Signals.d
blob169b98363979675ae51339c636575d847ac1a65c
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 = gobject-Signals.html
26 * outPack = gobject
27 * outFile = Signals
28 * strct =
29 * realStrct=
30 * ctorStrct=
31 * clss = Signals
32 * interf =
33 * class Code: Yes
34 * interface Code: No
35 * template for:
36 * extend =
37 * implements:
38 * prefixes:
39 * - g_signal_
40 * omit structs:
41 * omit prefixes:
42 * omit code:
43 * imports:
44 * - glib.Str
45 * - gobject.Closure
46 * - gobject.Type
47 * - gobject.Value
48 * - glib.Quark
49 * structWrap:
50 * - GClosure* -> Closure
51 * - GQuark* -> Quark
52 * - GValue* -> Value
53 * module aliases:
54 * local aliases:
57 module gobject.Signals;
59 version(noAssert)
61 version(Tango)
63 import tango.io.Stdout; // use the tango loging?
67 private import gtkc.gobjecttypes;
69 private import gtkc.gobject;
72 private import glib.Str;
73 private import gobject.Closure;
74 private import gobject.Type;
75 private import gobject.Value;
76 private import glib.Quark;
81 /**
82 * Description
83 * The basic concept of the signal system is that of the emission
84 * of a signal.
85 * Signals are introduced per-type and are identified through strings.
86 * Signals introduced for a parent type are available in derived types as well,
87 * so basically they are a per-type facility that is inherited.
88 * A signal emission mainly involves invocation of a certain set of callbacks in
89 * precisely defined manner. There are two main categories of such callbacks,
90 * per-object
91 * [12]
92 * ones and user provided ones.
93 * The per-object callbacks are most often referred to as "object method
94 * handler" or "default (signal) handler", while user provided callbacks are
95 * usually just called "signal handler".
96 * The object method handler is provided at signal creation time (this most
97 * frequently happens at the end of an object class' creation), while user
98 * provided handlers are frequently connected and disconnected to/from a certain
99 * signal on certain object instances.
100 * A signal emission consists of five stages, unless prematurely stopped:
101 * 1 - Invocation of the object method handler for G_SIGNAL_RUN_FIRST signals
102 * 2 - Invocation of normal user-provided signal handlers (after flag FALSE)
103 * 3 - Invocation of the object method handler for G_SIGNAL_RUN_LAST signals
104 * 4 - Invocation of user provided signal handlers, connected with an after flag of TRUE
105 * 5 - Invocation of the object method handler for G_SIGNAL_RUN_CLEANUP signals
106 * The user-provided signal handlers are called in the order they were
107 * connected in.
108 * All handlers may prematurely stop a signal emission, and any number of
109 * handlers may be connected, disconnected, blocked or unblocked during
110 * a signal emission.
111 * There are certain criteria for skipping user handlers in stages 2 and 4
112 * of a signal emission.
113 * First, user handlers may be blocked, blocked handlers are omitted
114 * during callback invocation, to return from the "blocked" state, a
115 * handler has to get unblocked exactly the same amount of times
116 * it has been blocked before.
117 * Second, upon emission of a G_SIGNAL_DETAILED signal, an additional
118 * "detail" argument passed in to g_signal_emit() has to match the detail
119 * argument of the signal handler currently subject to invocation.
120 * Specification of no detail argument for signal handlers (omission of the
121 * detail part of the signal specification upon connection) serves as a
122 * wildcard and matches any detail argument passed in to emission.
124 public class Signals
127 public static uint connectData(void* instanc, char[] detailedSignal, GCallback cHandler, Object data, GClosureNotify destroyData, GConnectFlags connectFlags)
129 // gulong g_signal_connect_data (gpointer instance, const gchar *detailed_signal, GCallback c_handler, gpointer data, GClosureNotify destroy_data, GConnectFlags connect_flags);
130 return g_signal_connect_data(instanc, Str.toStringz(detailedSignal), cHandler, cast(void*)data, destroyData, connectFlags);
148 * Creates a new signal. (This is usually done in the class initializer.)
149 * A signal name consists of segments consisting of ASCII letters and
150 * digits, separated by either the '-' or '_' character. The first
151 * character of a signal name must be a letter. Names which violate these
152 * rules lead to undefined behaviour of the GSignal system.
153 * When registering a signal and looking up a signal, either separator can
154 * be used, but they cannot be mixed.
155 * signal_name:
156 * the name for the signal
157 * itype:
158 * the type this signal pertains to. It will also pertain to
159 * types which are derived from this type.
160 * signal_flags:
161 * a combination of GSignalFlags specifying detail of when
162 * the default handler is to be invoked. You should at least specify
163 * G_SIGNAL_RUN_FIRST or G_SIGNAL_RUN_LAST.
164 * class_offset:
165 * The offset of the function pointer in the class structure
166 * for this type. Used to invoke a class method generically. Pass 0 to
167 * not associate a class method with this signal.
168 * accumulator:
169 * the accumulator for this signal; may be NULL.
170 * accu_data:
171 * user data for the accumulator.
172 * c_marshaller:
173 * the function to translate arrays of parameter values to
174 * signal emissions into C language callback invocations.
175 * return_type:
176 * the type of return value, or G_TYPE_NONE for a signal
177 * without a return value.
178 * n_params:
179 * the number of parameter types to follow.
180 * ...:
181 * a list of types, one for each parameter.
182 * Returns:
183 * the signal id
185 public static uint newSignals(char[] signalName, GType itype, GSignalFlags signalFlags, uint classOffset, GSignalAccumulator accumulator, void* accuData, GSignalCMarshaller cMarshaller, GType returnType, uint nParams, ... )
187 // guint g_signal_new (const gchar *signal_name, GType itype, GSignalFlags signal_flags, guint class_offset, GSignalAccumulator accumulator, gpointer accu_data, GSignalCMarshaller c_marshaller, GType return_type, guint n_params, ...);
188 return g_signal_new(Str.toStringz(signalName), itype, signalFlags, classOffset, accumulator, accuData, cMarshaller, returnType, nParams);
192 * Creates a new signal. (This is usually done in the class initializer.)
193 * See g_signal_new() for details on allowed signal names.
194 * signal_name:
195 * the name for the signal
196 * itype:
197 * the type this signal pertains to. It will also pertain to
198 * types which are derived from this type.
199 * signal_flags:
200 * a combination of GSignalFlags specifying detail of when
201 * the default handler is to be invoked. You should at least specify
202 * G_SIGNAL_RUN_FIRST or G_SIGNAL_RUN_LAST.
203 * class_closure:
204 * The closure to invoke on signal emission; may be NULL.
205 * accumulator:
206 * the accumulator for this signal; may be NULL.
207 * accu_data:
208 * user data for the accumulator.
209 * c_marshaller:
210 * the function to translate arrays of parameter values to
211 * signal emissions into C language callback invocations.
212 * return_type:
213 * the type of return value, or G_TYPE_NONE for a signal
214 * without a return value.
215 * n_params:
216 * the length of param_types.
217 * param_types:
218 * an array types, one for each parameter.
219 * Returns:
220 * the signal id
222 public static uint newv(char[] signalName, GType itype, GSignalFlags signalFlags, Closure classClosure, GSignalAccumulator accumulator, void* accuData, GSignalCMarshaller cMarshaller, GType returnType, uint nParams, GType* paramTypes)
224 // guint g_signal_newv (const gchar *signal_name, GType itype, GSignalFlags signal_flags, GClosure *class_closure, GSignalAccumulator accumulator, gpointer accu_data, GSignalCMarshaller c_marshaller, GType return_type, guint n_params, GType *param_types);
225 return g_signal_newv(Str.toStringz(signalName), itype, signalFlags, (classClosure is null) ? null : classClosure.getClosureStruct(), accumulator, accuData, cMarshaller, returnType, nParams, paramTypes);
229 * Creates a new signal. (This is usually done in the class initializer.)
230 * See g_signal_new() for details on allowed signal names.
231 * signal_name:
232 * the name for the signal
233 * itype:
234 * the type this signal pertains to. It will also pertain to
235 * types which are derived from this type.
236 * signal_flags:
237 * a combination of GSignalFlags specifying detail of when
238 * the default handler is to be invoked. You should at least specify
239 * G_SIGNAL_RUN_FIRST or G_SIGNAL_RUN_LAST.
240 * class_closure:
241 * The closure to invoke on signal emission; may be NULL.
242 * accumulator:
243 * the accumulator for this signal; may be NULL.
244 * accu_data:
245 * user data for the accumulator.
246 * c_marshaller:
247 * the function to translate arrays of parameter values to
248 * signal emissions into C language callback invocations.
249 * return_type:
250 * the type of return value, or G_TYPE_NONE for a signal
251 * without a return value.
252 * n_params:
253 * the number of parameter types in args.
254 * args:
255 * va_list of GType, one for each parameter.
256 * Returns:
257 * the signal id
259 public static uint newValist(char[] signalName, GType itype, GSignalFlags signalFlags, Closure classClosure, GSignalAccumulator accumulator, void* accuData, GSignalCMarshaller cMarshaller, GType returnType, uint nParams, void* args)
261 // guint g_signal_new_valist (const gchar *signal_name, GType itype, GSignalFlags signal_flags, GClosure *class_closure, GSignalAccumulator accumulator, gpointer accu_data, GSignalCMarshaller c_marshaller, GType return_type, guint n_params, va_list args);
262 return g_signal_new_valist(Str.toStringz(signalName), itype, signalFlags, (classClosure is null) ? null : classClosure.getClosureStruct(), accumulator, accuData, cMarshaller, returnType, nParams, args);
266 * Queries the signal system for in-depth information about a
267 * specific signal. This function will fill in a user-provided
268 * structure to hold signal-specific information. If an invalid
269 * signal id is passed in, the signal_id member of the GSignalQuery
270 * is 0. All members filled into the GSignalQuery structure should
271 * be considered constant and have to be left untouched.
272 * signal_id:
273 * The signal id of the signal to query information for.
274 * query:
275 * A user provided structure that is filled in with constant
276 * values upon success.
278 public static void query(uint signalId, GSignalQuery* query)
280 // void g_signal_query (guint signal_id, GSignalQuery *query);
281 g_signal_query(signalId, query);
285 * Given the name of the signal and the type of object it connects to, gets
286 * the signal's identifying integer. Emitting the signal by number is
287 * somewhat faster than using the name each time.
288 * Also tries the ancestors of the given type.
289 * See g_signal_new() for details on allowed signal names.
290 * name:
291 * the signal's name.
292 * itype:
293 * the type that the signal operates on.
294 * Returns:
295 * the signal's identifying number, or 0 if no signal was found.
297 public static uint lookup(char[] name, GType itype)
299 // guint g_signal_lookup (const gchar *name, GType itype);
300 return g_signal_lookup(Str.toStringz(name), itype);
304 * Given the signal's identifier, finds its name.
305 * Two different signals may have the same name, if they have differing types.
306 * signal_id:
307 * the signal's identifying number.
308 * Returns:
309 * the signal name, or NULL if the signal number was invalid.
311 public static char[] name(uint signalId)
313 // const gchar* g_signal_name (guint signal_id);
314 return Str.toString(g_signal_name(signalId) );
318 * Lists the signals by id that a certain instance or interface type
319 * created. Further information about the signals can be acquired through
320 * g_signal_query().
321 * itype:
322 * Instance or interface type.
323 * n_ids:
324 * Location to store the number of signal ids for itype.
325 * Returns:
326 * Newly allocated array of signal IDs.
328 public static uint* listIds(GType itype, uint* nIds)
330 // guint* g_signal_list_ids (GType itype, guint *n_ids);
331 return g_signal_list_ids(itype, nIds);
335 * Emits a signal.
336 * Note that g_signal_emit() resets the return value to the default
337 * if no handlers are connected, in contrast to g_signal_emitv().
338 * instance:
339 * the instance the signal is being emitted on.
340 * signal_id:
341 * the signal id
342 * detail:
343 * the detail
344 * ...:
345 * parameters to be passed to the signal, followed by a
346 * location for the return value. If the return type of the signal
347 * is G_TYPE_NONE, the return value location can be omitted.
349 public static void emit(void* instanc, uint signalId, GQuark detail, ... )
351 // void g_signal_emit (gpointer instance, guint signal_id, GQuark detail, ...);
352 g_signal_emit(instanc, signalId, detail);
356 * Emits a signal.
357 * Note that g_signal_emit_by_name() resets the return value to the default
358 * if no handlers are connected, in contrast to g_signal_emitv().
359 * instance:
360 * the instance the signal is being emitted on.
361 * detailed_signal:
362 * a string of the form "signal-name::detail".
363 * ...:
364 * parameters to be passed to the signal, followed by a
365 * location for the return value. If the return type of the signal
366 * is G_TYPE_NONE, the return value location can be omitted.
368 public static void emitByName(void* instanc, char[] detailedSignal, ... )
370 // void g_signal_emit_by_name (gpointer instance, const gchar *detailed_signal, ...);
371 g_signal_emit_by_name(instanc, Str.toStringz(detailedSignal));
375 * Emits a signal.
376 * Note that g_signal_emitv() doesn't change return_value if no handlers are
377 * connected, in contrast to g_signal_emit() and g_signal_emit_valist().
378 * instance_and_params:
379 * argument list for the signal emission. The first
380 * element in the array is a GValue for the instance the signal is
381 * being emitted on. The rest are any arguments to be passed to the
382 * signal.
383 * signal_id:
384 * the signal id
385 * detail:
386 * the detail
387 * return_value:
388 * Location to store the return value of the signal emission.
390 public static void emitv(Value instanceAndParams, uint signalId, GQuark detail, Value returnValue)
392 // void g_signal_emitv (const GValue *instance_and_params, guint signal_id, GQuark detail, GValue *return_value);
393 g_signal_emitv((instanceAndParams is null) ? null : instanceAndParams.getValueStruct(), signalId, detail, (returnValue is null) ? null : returnValue.getValueStruct());
397 * Emits a signal.
398 * Note that g_signal_emit_valist() resets the return value to the default
399 * if no handlers are connected, in contrast to g_signal_emitv().
400 * instance:
401 * the instance the signal is being emitted on.
402 * signal_id:
403 * the signal id
404 * detail:
405 * the detail
406 * var_args:
407 * a list of parameters to be passed to the signal, followed by a
408 * location for the return value. If the return type of the signal
409 * is G_TYPE_NONE, the return value location can be omitted.
411 public static void emitValist(void* instanc, uint signalId, GQuark detail, void* varArgs)
413 // void g_signal_emit_valist (gpointer instance, guint signal_id, GQuark detail, va_list var_args);
414 g_signal_emit_valist(instanc, signalId, detail, varArgs);
421 * This is similar to g_signal_connect_data(), but uses a closure which
422 * ensures that the gobject stays alive during the call to c_handler
423 * by temporarily adding a reference count to gobject.
424 * Note that there is a bug in GObject that makes this function
425 * much less useful than it might seem otherwise. Once gobject is
426 * disposed, the callback will no longer be called, but, the signal
427 * handler is not currently disconnected. If the
428 * instance is itself being freed at the same time than this doesn't
429 * matter, since the signal will automatically be removed, but
430 * if instance persists, then the signal handler will leak. You
431 * should not remove the signal yourself because in a future versions of
432 * GObject, the handler will automatically
433 * be disconnected.
434 * It's possible to work around this problem in a way that will
435 * continue to work with future versions of GObject by checking
436 * that the signal handler is still connected before disconnected it:
437 * if (g_signal_handler_is_connected (instance, id))
438 * g_signal_handler_disconnect (instance, id);
439 * instance:
440 * the instance to connect to.
441 * detailed_signal:
442 * a string of the form "signal-name::detail".
443 * c_handler:
444 * the GCallback to connect.
445 * gobject:
446 * the object to pass as data to c_handler.
447 * connect_flags:
448 * a combination of GConnnectFlags.
449 * Returns:
450 * the handler id.
452 public static uint connectObject(void* instanc, char[] detailedSignal, GCallback cHandler, void* gobject, GConnectFlags connectFlags)
454 // gulong g_signal_connect_object (gpointer instance, const gchar *detailed_signal, GCallback c_handler, gpointer gobject, GConnectFlags connect_flags);
455 return g_signal_connect_object(instanc, Str.toStringz(detailedSignal), cHandler, gobject, connectFlags);
460 * Connects a GCallback function to a signal for a particular object. Similar
461 * to g_signal_connect(), but allows to provide a GClosureNotify for the data
462 * which will be called when the signal handler is disconnected and no longer
463 * used. Specify connect_flags if you need ..._after() pr
464 * ..._swapped() variants of this function.
465 * instance:
466 * the instance to connect to.
467 * detailed_signal:
468 * a string of the form "signal-name::detail".
469 * c_handler:
470 * the GCallback to connect.
471 * data:
472 * data to pass to c_handler calls.
473 * destroy_data:
474 * a GClosureNotify for data.
475 * connect_flags:
476 * a combination of GConnectFlags.
477 * Returns:
478 * the handler id
480 public static uint connectData(void* instanc, char[] detailedSignal, GCallback cHandler, void* data, GClosureNotify destroyData, GConnectFlags connectFlags)
482 // gulong g_signal_connect_data (gpointer instance, const gchar *detailed_signal, GCallback c_handler, gpointer data, GClosureNotify destroy_data, GConnectFlags connect_flags);
483 return g_signal_connect_data(instanc, Str.toStringz(detailedSignal), cHandler, data, destroyData, connectFlags);
487 * Connects a closure to a signal for a particular object.
488 * instance:
489 * the instance to connect to.
490 * detailed_signal:
491 * a string of the form "signal-name::detail".
492 * closure:
493 * the closure to connect.
494 * after:
495 * whether the handler should be called before or after the
496 * default handler of the signal.
497 * Returns:
498 * the handler id
500 public static uint connectClosure(void* instanc, char[] detailedSignal, Closure closure, int after)
502 // gulong g_signal_connect_closure (gpointer instance, const gchar *detailed_signal, GClosure *closure, gboolean after);
503 return g_signal_connect_closure(instanc, Str.toStringz(detailedSignal), (closure is null) ? null : closure.getClosureStruct(), after);
507 * Connects a closure to a signal for a particular object.
508 * instance:
509 * the instance to connect to.
510 * signal_id:
511 * the id of the signal.
512 * detail:
513 * the detail.
514 * closure:
515 * the closure to connect.
516 * after:
517 * whether the handler should be called before or after the
518 * default handler of the signal.
519 * Returns:
520 * the handler id
522 public static uint connectClosureById(void* instanc, uint signalId, GQuark detail, Closure closure, int after)
524 // gulong g_signal_connect_closure_by_id (gpointer instance, guint signal_id, GQuark detail, GClosure *closure, gboolean after);
525 return g_signal_connect_closure_by_id(instanc, signalId, detail, (closure is null) ? null : closure.getClosureStruct(), after);
529 * Blocks a handler of an instance so it will not be called during
530 * any signal emissions unless it is unblocked again. Thus "blocking"
531 * a signal handler means to temporarily deactive it, a signal handler
532 * has to be unblocked exactly the same amount of times it has been
533 * blocked before to become active again.
534 * The handler_id has to be a valid signal handler id, connected to a
535 * signal of instance.
536 * instance:
537 * The instance to block the signal handler of.
538 * handler_id:
539 * Handler id of the handler to be blocked.
541 public static void handlerBlock(void* instanc, uint handlerId)
543 // void g_signal_handler_block (gpointer instance, gulong handler_id);
544 g_signal_handler_block(instanc, handlerId);
548 * Undoes the effect of a previous g_signal_handler_block() call.
549 * A blocked handler is skipped during signal emissions and will not be
550 * invoked, unblocking it (for exactly the amount of times it has been
551 * blocked before) reverts its "blocked" state, so the handler will be
552 * recognized by the signal system and is called upon future or currently
553 * ongoing signal emissions (since the order in which handlers are
554 * called during signal emissions is deterministic, whether the
555 * unblocked handler in question is called as part of a currently
556 * ongoing emission depends on how far that emission has proceeded
557 * yet).
558 * The handler_id has to be a valid id of a signal handler that is
559 * connected to a signal of instance and is currently blocked.
560 * instance:
561 * The instance to unblock the signal handler of.
562 * handler_id:
563 * Handler id of the handler to be unblocked.
565 public static void handlerUnblock(void* instanc, uint handlerId)
567 // void g_signal_handler_unblock (gpointer instance, gulong handler_id);
568 g_signal_handler_unblock(instanc, handlerId);
572 * Disconnects a handler from an instance so it will not be called during
573 * any future or currently ongoing emissions of the signal it has been
574 * connected to. The handler_id becomes invalid and may be reused.
575 * The handler_id has to be a valid signal handler id, connected to a
576 * signal of instance.
577 * instance:
578 * The instance to remove the signal handler from.
579 * handler_id:
580 * Handler id of the handler to be disconnected.
582 public static void handlerDisconnect(void* instanc, uint handlerId)
584 // void g_signal_handler_disconnect (gpointer instance, gulong handler_id);
585 g_signal_handler_disconnect(instanc, handlerId);
589 * Finds the first signal handler that matches certain selection criteria.
590 * The criteria mask is passed as an OR-ed combination of GSignalMatchType
591 * flags, and the criteria values are passed as arguments.
592 * The match mask has to be non-0 for successful matches.
593 * If no handler was found, 0 is returned.
594 * instance:
595 * The instance owning the signal handler to be found.
596 * mask:
597 * Mask indicating which of signal_id, detail, closure, func
598 * and/or data the handler has to match.
599 * signal_id:
600 * Signal the handler has to be connected to.
601 * detail:
602 * Signal detail the handler has to be connected to.
603 * closure:
604 * The closure the handler will invoke.
605 * func:
606 * The C closure callback of the handler (useless for non-C closures).
607 * data:
608 * The closure data of the handler's closure.
609 * Returns:
610 * A valid non-0 signal handler id for a successful match.
612 public static uint handlerFind(void* instanc, GSignalMatchType mask, uint signalId, GQuark detail, Closure closure, void* func, void* data)
614 // gulong g_signal_handler_find (gpointer instance, GSignalMatchType mask, guint signal_id, GQuark detail, GClosure *closure, gpointer func, gpointer data);
615 return g_signal_handler_find(instanc, mask, signalId, detail, (closure is null) ? null : closure.getClosureStruct(), func, data);
619 * Blocks all handlers on an instance that match a certain selection criteria.
620 * The criteria mask is passed as an OR-ed combination of GSignalMatchType
621 * flags, and the criteria values are passed as arguments.
622 * Passing at least one of the G_SIGNAL_MATCH_CLOSURE, G_SIGNAL_MATCH_FUNC
623 * or G_SIGNAL_MATCH_DATA match flags is required for successful matches.
624 * If no handlers were found, 0 is returned, the number of blocked handlers
625 * otherwise.
626 * instance:
627 * The instance to block handlers from.
628 * mask:
629 * Mask indicating which of signal_id, detail, closure, func
630 * and/or data the handlers have to match.
631 * signal_id:
632 * Signal the handlers have to be connected to.
633 * detail:
634 * Signal detail the handlers have to be connected to.
635 * closure:
636 * The closure the handlers will invoke.
637 * func:
638 * The C closure callback of the handlers (useless for non-C closures).
639 * data:
640 * The closure data of the handlers' closures.
641 * Returns:
642 * The amount of handlers that got blocked.
644 public static uint handlersBlockMatched(void* instanc, GSignalMatchType mask, uint signalId, GQuark detail, Closure closure, void* func, void* data)
646 // guint g_signal_handlers_block_matched (gpointer instance, GSignalMatchType mask, guint signal_id, GQuark detail, GClosure *closure, gpointer func, gpointer data);
647 return g_signal_handlers_block_matched(instanc, mask, signalId, detail, (closure is null) ? null : closure.getClosureStruct(), func, data);
651 * Unblocks all handlers on an instance that match a certain selection
652 * criteria. The criteria mask is passed as an OR-ed combination of
653 * GSignalMatchType flags, and the criteria values are passed as arguments.
654 * Passing at least one of the G_SIGNAL_MATCH_CLOSURE, G_SIGNAL_MATCH_FUNC
655 * or G_SIGNAL_MATCH_DATA match flags is required for successful matches.
656 * If no handlers were found, 0 is returned, the number of unblocked handlers
657 * otherwise. The match criteria should not apply to any handlers that are
658 * not currently blocked.
659 * instance:
660 * The instance to unblock handlers from.
661 * mask:
662 * Mask indicating which of signal_id, detail, closure, func
663 * and/or data the handlers have to match.
664 * signal_id:
665 * Signal the handlers have to be connected to.
666 * detail:
667 * Signal detail the handlers have to be connected to.
668 * closure:
669 * The closure the handlers will invoke.
670 * func:
671 * The C closure callback of the handlers (useless for non-C closures).
672 * data:
673 * The closure data of the handlers' closures.
674 * Returns:
675 * The amount of handlers that got unblocked.
677 public static uint handlersUnblockMatched(void* instanc, GSignalMatchType mask, uint signalId, GQuark detail, Closure closure, void* func, void* data)
679 // guint g_signal_handlers_unblock_matched (gpointer instance, GSignalMatchType mask, guint signal_id, GQuark detail, GClosure *closure, gpointer func, gpointer data);
680 return g_signal_handlers_unblock_matched(instanc, mask, signalId, detail, (closure is null) ? null : closure.getClosureStruct(), func, data);
684 * Disconnects all handlers on an instance that match a certain selection
685 * criteria. The criteria mask is passed as an OR-ed combination of
686 * GSignalMatchType flags, and the criteria values are passed as arguments.
687 * Passing at least one of the G_SIGNAL_MATCH_CLOSURE, G_SIGNAL_MATCH_FUNC
688 * or G_SIGNAL_MATCH_DATA match flags is required for successful matches.
689 * If no handlers were found, 0 is returned, the number of disconnected
690 * handlers otherwise.
691 * instance:
692 * The instance to remove handlers from.
693 * mask:
694 * Mask indicating which of signal_id, detail, closure, func
695 * and/or data the handlers have to match.
696 * signal_id:
697 * Signal the handlers have to be connected to.
698 * detail:
699 * Signal detail the handlers have to be connected to.
700 * closure:
701 * The closure the handlers will invoke.
702 * func:
703 * The C closure callback of the handlers (useless for non-C closures).
704 * data:
705 * The closure data of the handlers' closures.
706 * Returns:
707 * The amount of handlers that got disconnected.
709 public static uint handlersDisconnectMatched(void* instanc, GSignalMatchType mask, uint signalId, GQuark detail, Closure closure, void* func, void* data)
711 // guint g_signal_handlers_disconnect_matched (gpointer instance, GSignalMatchType mask, guint signal_id, GQuark detail, GClosure *closure, gpointer func, gpointer data);
712 return g_signal_handlers_disconnect_matched(instanc, mask, signalId, detail, (closure is null) ? null : closure.getClosureStruct(), func, data);
716 * Returns whether handler_id is the id of a handler connected to instance.
717 * instance:
718 * The instance where a signal handler is sought.
719 * handler_id:
720 * the handler id.
721 * Returns:
722 * whether handler_id identifies a handler connected to instance.
724 public static int handlerIsConnected(void* instanc, uint handlerId)
726 // gboolean g_signal_handler_is_connected (gpointer instance, gulong handler_id);
727 return g_signal_handler_is_connected(instanc, handlerId);
734 * Returns whether there are any handlers connected to instance for the
735 * given signal id and detail.
736 * One example of when you might use this is when the arguments to the
737 * signal are difficult to compute. A class implementor may opt to not emit
738 * the signal if no one is attached anyway, thus saving the cost of building
739 * the arguments.
740 * instance:
741 * the object whose signal handlers are sought.
742 * signal_id:
743 * the signal id.
744 * detail:
745 * the detail.
746 * may_be_blocked:
747 * whether blocked handlers should count as match.
748 * Returns:
749 * TRUE if a handler is connected to the signal,
750 * FALSE otherwise.
752 public static int hasHandlerPending(void* instanc, uint signalId, GQuark detail, int mayBeBlocked)
754 // gboolean g_signal_has_handler_pending (gpointer instance, guint signal_id, GQuark detail, gboolean may_be_blocked);
755 return g_signal_has_handler_pending(instanc, signalId, detail, mayBeBlocked);
759 * Stops a signal's current emission.
760 * This will prevent the default method from running, if the signal was
761 * G_SIGNAL_RUN_LAST and you connected normally (i.e. without the "after"
762 * flag).
763 * Prints a warning if used on a signal which isn't being emitted.
764 * instance:
765 * the object whose signal handlers you wish to stop.
766 * signal_id:
767 * the signal identifier, as returned by g_signal_lookup().
768 * detail:
769 * the detail which the signal was emitted with.
771 public static void stopEmission(void* instanc, uint signalId, GQuark detail)
773 // void g_signal_stop_emission (gpointer instance, guint signal_id, GQuark detail);
774 g_signal_stop_emission(instanc, signalId, detail);
778 * Stops a signal's current emission.
779 * This is just like g_signal_stop_emission() except it will look up the
780 * signal id for you.
781 * instance:
782 * the object whose signal handlers you wish to stop.
783 * detailed_signal:
784 * a string of the form "signal-name::detail".
786 public static void stopEmissionByName(void* instanc, char[] detailedSignal)
788 // void g_signal_stop_emission_by_name (gpointer instance, const gchar *detailed_signal);
789 g_signal_stop_emission_by_name(instanc, Str.toStringz(detailedSignal));
793 * Overrides the class closure (i.e. the default handler) for the given signal
794 * for emissions on instances of instance_type. instance_type must be derived
795 * from the type to which the signal belongs.
796 * signal_id:
797 * the signal id
798 * instance_type:
799 * the instance type on which to override the class closure
800 * for the signal.
801 * class_closure:
802 * the closure.
804 public static void overrideClassClosure(uint signalId, GType instanceType, Closure classClosure)
806 // void g_signal_override_class_closure (guint signal_id, GType instance_type, GClosure *class_closure);
807 g_signal_override_class_closure(signalId, instanceType, (classClosure is null) ? null : classClosure.getClosureStruct());
811 * Calls the original class closure of a signal. This function should only
812 * be called from an overridden class closure; see
813 * g_signal_override_class_closure().
814 * instance_and_params:
815 * the argument list of the signal emission. The first
816 * element in the array is a GValue for the instance the signal is being
817 * emitted on. The rest are any arguments to be passed to the signal.
818 * return_value:
819 * Location for the return value.
821 public static void chainFromOverridden(Value instanceAndParams, Value returnValue)
823 // void g_signal_chain_from_overridden (const GValue *instance_and_params, GValue *return_value);
824 g_signal_chain_from_overridden((instanceAndParams is null) ? null : instanceAndParams.getValueStruct(), (returnValue is null) ? null : returnValue.getValueStruct());
828 * Adds an emission hook for a signal, which will get called for any emission
829 * of that signal, independent of the instance. This is possible only
830 * for signals which don't have G_SIGNAL_NO_HOOKS flag set.
831 * signal_id:
832 * the signal identifier, as returned by g_signal_lookup().
833 * detail:
834 * the detail on which to call the hook.
835 * hook_func:
836 * a GSignalEmissionHook function.
837 * hook_data:
838 * user data for hook_func.
839 * data_destroy:
840 * a GDestroyNotify for hook_data.
841 * Returns:
842 * the hook id, for later use with g_signal_remove_emission_hook().
844 public static uint addEmissionHook(uint signalId, GQuark detail, GSignalEmissionHook hookFunc, void* hookData, GDestroyNotify dataDestroy)
846 // gulong g_signal_add_emission_hook (guint signal_id, GQuark detail, GSignalEmissionHook hook_func, gpointer hook_data, GDestroyNotify data_destroy);
847 return g_signal_add_emission_hook(signalId, detail, hookFunc, hookData, dataDestroy);
851 * Deletes an emission hook.
852 * signal_id:
853 * the id of the signal
854 * hook_id:
855 * the id of the emission hook, as returned by
856 * g_signal_add_emission_hook()
858 public static void removeEmissionHook(uint signalId, uint hookId)
860 // void g_signal_remove_emission_hook (guint signal_id, gulong hook_id);
861 g_signal_remove_emission_hook(signalId, hookId);
865 * Internal function to parse a signal name into its signal_id
866 * and detail quark.
867 * detailed_signal:
868 * a string of the form "signal-name::detail".
869 * itype:
870 * The interface/instance type that introduced "signal-name".
871 * signal_id_p:
872 * Location to store the signal id.
873 * detail_p:
874 * Location to store the detail quark.
875 * force_detail_quark:
876 * TRUE forces creation of a GQuark for the detail.
877 * Returns:
878 * Whether the signal name could successfully be parsed and signal_id_p and detail_p contain valid return values.
880 public static int parseName(char[] detailedSignal, GType itype, uint* signalIdP, Quark detailP, int forceDetailQuark)
882 // gboolean g_signal_parse_name (const gchar *detailed_signal, GType itype, guint *signal_id_p, GQuark *detail_p, gboolean force_detail_quark);
883 return g_signal_parse_name(Str.toStringz(detailedSignal), itype, signalIdP, (detailP is null) ? null : detailP.getQuarkStruct(), forceDetailQuark);
887 * Returns the invocation hint of the innermost signal emission of instance.
888 * instance:
889 * the instance to query
890 * Returns:
891 * the invocation hint of the innermost signal emission.
893 public static GSignalInvocationHint* getInvocationHint(void* instanc)
895 // GSignalInvocationHint* g_signal_get_invocation_hint (gpointer instance);
896 return g_signal_get_invocation_hint(instanc);
900 * Creates a new closure which invokes the function found at the offset
901 * struct_offset in the class structure of the interface or classed type
902 * identified by itype.
903 * itype:
904 * the GType identifier of an interface or classed type
905 * struct_offset:
906 * the offset of the member function of itype's class
907 * structure which is to be invoked by the new closure
908 * Returns:
909 * a new GCClosure
911 public static Closure typeCclosureNew(GType itype, uint structOffset)
913 // GClosure* g_signal_type_cclosure_new (GType itype, guint struct_offset);
914 return new Closure( g_signal_type_cclosure_new(itype, structOffset) );
918 * A predefined GSignalAccumulator for signals that return a
919 * boolean values. The behavior that this accumulator gives is
920 * that a return of TRUE stops the signal emission: no further
921 * callbacks will be invoked, while a return of FALSE allows
922 * the emission to coninue. The idea here is that a TRUE return
923 * indicates that the callback handled the signal,
924 * and no further handling is needed.
925 * ihint:
926 * standard GSignalAccumulator parameter
927 * return_accu:
928 * standard GSignalAccumulator parameter
929 * handler_return:
930 * standard GSignalAccumulator parameter
931 * dummy:
932 * standard GSignalAccumulator parameter
933 * Returns:
934 * standard GSignalAccumulator result
935 * Since 2.4
936 * [12] Although signals can deal with any kind of instantiatable type,
937 * i'm referring to those types as "object types" in the following, simply
938 * because that is the context most users will encounter signals in.
940 public static int accumulatorTrueHandled(GSignalInvocationHint* ihint, Value returnAccu, Value handlerReturn, void* dummy)
942 // gboolean g_signal_accumulator_true_handled (GSignalInvocationHint *ihint, GValue *return_accu, const GValue *handler_return, gpointer dummy);
943 return g_signal_accumulator_true_handled(ihint, (returnAccu is null) ? null : returnAccu.getValueStruct(), (handlerReturn is null) ? null : handlerReturn.getValueStruct(), dummy);