1 /*
2  * This file is part of gtkD.
3  *
4  * gtkD is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU Lesser General Public License
6  * as published by the Free Software Foundation; either version 3
7  * of the License, or (at your option) any later version, with
8  * some exceptions, please read the COPYING file.
9  *
10  * gtkD is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public License
16  * along with gtkD; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA
18  */
19 
20 // generated automatically - do not change
21 // find conversion definition on APILookup.txt
22 // implement new conversion functionalities on the wrap.utils pakage
23 
24 
25 module gobject.Signals;
26 
27 private import glib.Str;
28 private import gobject.Closure;
29 private import gobject.DClosure;
30 private import gobject.ObjectG;
31 private import gobject.TypeInstance;
32 private import gobject.Value;
33 private import gobject.c.functions;
34 public  import gobject.c.types;
35 public  import gtkc.gobjecttypes;
36 private import std.traits;
37 
38 
39 /** */
40 public struct Signals
41 {
42 	/**
43 	 * Connects a callback to a signal for a particular object.
44 	 *
45 	 * The handler will be called before the default handler of the signal.
46 	 *
47 	 * Params:
48 	 *     instance       = the instance to connect to.
49 	 *     detailedSignal = a string of the form "signal-name::detail".
50 	 *     callback       = the callback to connect.
51 	 *     connectFlags   = a combination of ConnectFlags.
52 	 *
53 	 * Returns: the handler ID, of type gulong (always greater than 0 for successful connections)
54 	 */
55 	public static gulong connect(T)(ObjectG instance, string detailedSignal, T callback, ConnectFlags connectFlags = cast(ConnectFlags)0)
56 	if ( isCallable!T && !is(T == GCallback) )
57 	{
58 		bool after = (connectFlags & ConnectFlags.AFTER) != false;
59 		bool swap = (connectFlags & ConnectFlags.SWAPPED) != false;
60 
61 		DClosure closure = new DClosure(callback, swap);
62 		gulong id = Signals.connectClosure(instance, detailedSignal, closure, after);
63 
64 		instance.signals[id] = closure;
65 		return id;
66 	}
67 
68 	deprecated public static gulong connectData(void* instanc, string detailedSignal, GCallback cHandler, Object data, GClosureNotify destroyData, GConnectFlags connectFlags)
69 	{
70 		return g_signal_connect_data(instanc, Str.toStringz(detailedSignal), cHandler, cast(void*)data, destroyData, connectFlags);
71 	}
72 
73 	/**
74 	 * Disconnects a handler from an instance so it will not be called during
75 	 * any future or currently ongoing emissions of the signal it has been
76 	 * connected to. The @handler_id becomes invalid and may be reused.
77 	 *
78 	 * The @handler_id has to be a valid signal handler id, connected to a
79 	 * signal of @instance.
80 	 *
81 	 * Params:
82 	 *     instance = The instance to remove the signal handler from.
83 	 *     handlerId = Handler id of the handler to be disconnected.
84 	 */
85 	public static void handlerDisconnect(ObjectG instance, gulong handlerId)
86 	{
87 		instance.signals.remove(handlerId);
88 		g_signal_handler_disconnect((instance is null) ? null : instance.getObjectGStruct(), handlerId);
89 	}
90 
91 	/**
92 	 * Connects a GCallback function to a signal for a particular object.
93 	 *
94 	 * The handler will be called before the default handler of the signal.
95 	 *
96 	 * See [memory management of signal handlers][signal-memory-management] for
97 	 * details on how to handle the return value and memory management of @data.
98 	 *
99 	 * Params:
100 	 *     instance       = the instance to connect to.
101 	 *     detailedSignal = a string of the form "signal-name::detail".
102 	 *     cHandler       = the GCallback to connect.
103 	 *     data           = data to pass to cHandler calls.
104 	 *
105 	 * Returns: the handler ID, of type gulong (always greater than 0 for successful connections)
106 	 */
107 	public static gulong connect(ObjectG instanc, string detailedSignal, GCallback cHandler, void* data)
108 	{
109 		return g_signal_connect_data((instanc is null) ? null : instanc.getObjectGStruct(), Str.toStringz(detailedSignal), cHandler, data, null, cast(ConnectFlags)0);
110 	}
111 
112 	/**
113 	 */
114 
115 	/**
116 	 * A predefined #GSignalAccumulator for signals intended to be used as a
117 	 * hook for application code to provide a particular value.  Usually
118 	 * only one such value is desired and multiple handlers for the same
119 	 * signal don't make much sense (except for the case of the default
120 	 * handler defined in the class structure, in which case you will
121 	 * usually want the signal connection to override the class handler).
122 	 *
123 	 * This accumulator will use the return value from the first signal
124 	 * handler that is run as the return value for the signal and not run
125 	 * any further handlers (ie: the first handler "wins").
126 	 *
127 	 * Params:
128 	 *     ihint = standard #GSignalAccumulator parameter
129 	 *     returnAccu = standard #GSignalAccumulator parameter
130 	 *     handlerReturn = standard #GSignalAccumulator parameter
131 	 *     dummy = standard #GSignalAccumulator parameter
132 	 *
133 	 * Returns: standard #GSignalAccumulator result
134 	 *
135 	 * Since: 2.28
136 	 */
137 	public static bool accumulatorFirstWins(GSignalInvocationHint* ihint, Value returnAccu, Value handlerReturn, void* dummy)
138 	{
139 		return g_signal_accumulator_first_wins(ihint, (returnAccu is null) ? null : returnAccu.getValueStruct(), (handlerReturn is null) ? null : handlerReturn.getValueStruct(), dummy) != 0;
140 	}
141 
142 	/**
143 	 * A predefined #GSignalAccumulator for signals that return a
144 	 * boolean values. The behavior that this accumulator gives is
145 	 * that a return of %TRUE stops the signal emission: no further
146 	 * callbacks will be invoked, while a return of %FALSE allows
147 	 * the emission to continue. The idea here is that a %TRUE return
148 	 * indicates that the callback handled the signal, and no further
149 	 * handling is needed.
150 	 *
151 	 * Params:
152 	 *     ihint = standard #GSignalAccumulator parameter
153 	 *     returnAccu = standard #GSignalAccumulator parameter
154 	 *     handlerReturn = standard #GSignalAccumulator parameter
155 	 *     dummy = standard #GSignalAccumulator parameter
156 	 *
157 	 * Returns: standard #GSignalAccumulator result
158 	 *
159 	 * Since: 2.4
160 	 */
161 	public static bool accumulatorTrueHandled(GSignalInvocationHint* ihint, Value returnAccu, Value handlerReturn, void* dummy)
162 	{
163 		return g_signal_accumulator_true_handled(ihint, (returnAccu is null) ? null : returnAccu.getValueStruct(), (handlerReturn is null) ? null : handlerReturn.getValueStruct(), dummy) != 0;
164 	}
165 
166 	/**
167 	 * Adds an emission hook for a signal, which will get called for any emission
168 	 * of that signal, independent of the instance. This is possible only
169 	 * for signals which don't have #G_SIGNAL_NO_HOOKS flag set.
170 	 *
171 	 * Params:
172 	 *     signalId = the signal identifier, as returned by g_signal_lookup().
173 	 *     detail = the detail on which to call the hook.
174 	 *     hookFunc = a #GSignalEmissionHook function.
175 	 *     hookData = user data for @hook_func.
176 	 *     dataDestroy = a #GDestroyNotify for @hook_data.
177 	 *
178 	 * Returns: the hook id, for later use with g_signal_remove_emission_hook().
179 	 */
180 	public static gulong addEmissionHook(uint signalId, GQuark detail, GSignalEmissionHook hookFunc, void* hookData, GDestroyNotify dataDestroy)
181 	{
182 		return g_signal_add_emission_hook(signalId, detail, hookFunc, hookData, dataDestroy);
183 	}
184 
185 	/**
186 	 * Calls the original class closure of a signal. This function should only
187 	 * be called from an overridden class closure; see
188 	 * g_signal_override_class_closure() and
189 	 * g_signal_override_class_handler().
190 	 *
191 	 * Params:
192 	 *     instanceAndParams = the argument list of the signal emission.
193 	 *         The first element in the array is a #GValue for the instance the signal
194 	 *         is being emitted on. The rest are any arguments to be passed to the signal.
195 	 *     returnValue = Location for the return value.
196 	 */
197 	public static void chainFromOverridden(Value[] instanceAndParams, Value returnValue)
198 	{
199 		GValue[] instanceAndParamsArray = new GValue[instanceAndParams.length];
200 		for ( int i = 0; i < instanceAndParams.length; i++ )
201 		{
202 			instanceAndParamsArray[i] = *(instanceAndParams[i].getValueStruct());
203 		}
204 
205 		g_signal_chain_from_overridden(instanceAndParamsArray.ptr, (returnValue is null) ? null : returnValue.getValueStruct());
206 	}
207 
208 	/**
209 	 * Connects a closure to a signal for a particular object.
210 	 *
211 	 * Params:
212 	 *     instance_ = the instance to connect to.
213 	 *     detailedSignal = a string of the form "signal-name::detail".
214 	 *     closure = the closure to connect.
215 	 *     after = whether the handler should be called before or after the
216 	 *         default handler of the signal.
217 	 *
218 	 * Returns: the handler ID (always greater than 0 for successful connections)
219 	 */
220 	public static gulong connectClosure(ObjectG instance_, string detailedSignal, Closure closure, bool after)
221 	{
222 		return g_signal_connect_closure((instance_ is null) ? null : instance_.getObjectGStruct(), Str.toStringz(detailedSignal), (closure is null) ? null : closure.getClosureStruct(), after);
223 	}
224 
225 	/**
226 	 * Connects a closure to a signal for a particular object.
227 	 *
228 	 * Params:
229 	 *     instance_ = the instance to connect to.
230 	 *     signalId = the id of the signal.
231 	 *     detail = the detail.
232 	 *     closure = the closure to connect.
233 	 *     after = whether the handler should be called before or after the
234 	 *         default handler of the signal.
235 	 *
236 	 * Returns: the handler ID (always greater than 0 for successful connections)
237 	 */
238 	public static gulong connectClosureById(ObjectG instance_, uint signalId, GQuark detail, Closure closure, bool after)
239 	{
240 		return g_signal_connect_closure_by_id((instance_ is null) ? null : instance_.getObjectGStruct(), signalId, detail, (closure is null) ? null : closure.getClosureStruct(), after);
241 	}
242 
243 	/**
244 	 * Connects a #GCallback function to a signal for a particular object. Similar
245 	 * to g_signal_connect(), but allows to provide a #GClosureNotify for the data
246 	 * which will be called when the signal handler is disconnected and no longer
247 	 * used. Specify @connect_flags if you need `..._after()` or
248 	 * `..._swapped()` variants of this function.
249 	 *
250 	 * Params:
251 	 *     instance_ = the instance to connect to.
252 	 *     detailedSignal = a string of the form "signal-name::detail".
253 	 *     cHandler = the #GCallback to connect.
254 	 *     data = data to pass to @c_handler calls.
255 	 *     destroyData = a #GClosureNotify for @data.
256 	 *     connectFlags = a combination of #GConnectFlags.
257 	 *
258 	 * Returns: the handler ID (always greater than 0 for successful connections)
259 	 */
260 	public static gulong connectData(ObjectG instance_, string detailedSignal, GCallback cHandler, void* data, GClosureNotify destroyData, GConnectFlags connectFlags)
261 	{
262 		return g_signal_connect_data((instance_ is null) ? null : instance_.getObjectGStruct(), Str.toStringz(detailedSignal), cHandler, data, destroyData, connectFlags);
263 	}
264 
265 	/**
266 	 * This is similar to g_signal_connect_data(), but uses a closure which
267 	 * ensures that the @gobject stays alive during the call to @c_handler
268 	 * by temporarily adding a reference count to @gobject.
269 	 *
270 	 * When the @gobject is destroyed the signal handler will be automatically
271 	 * disconnected.  Note that this is not currently threadsafe (ie:
272 	 * emitting a signal while @gobject is being destroyed in another thread
273 	 * is not safe).
274 	 *
275 	 * Params:
276 	 *     instance_ = the instance to connect to.
277 	 *     detailedSignal = a string of the form "signal-name::detail".
278 	 *     cHandler = the #GCallback to connect.
279 	 *     gobject = the object to pass as data
280 	 *         to @c_handler.
281 	 *     connectFlags = a combination of #GConnectFlags.
282 	 *
283 	 * Returns: the handler id.
284 	 */
285 	public static gulong connectObject(TypeInstance instance_, string detailedSignal, GCallback cHandler, ObjectG gobject, GConnectFlags connectFlags)
286 	{
287 		return g_signal_connect_object((instance_ is null) ? null : instance_.getTypeInstanceStruct(), Str.toStringz(detailedSignal), cHandler, (gobject is null) ? null : gobject.getObjectGStruct(), connectFlags);
288 	}
289 
290 	/**
291 	 * Emits a signal.
292 	 *
293 	 * Note that g_signal_emit_valist() resets the return value to the default
294 	 * if no handlers are connected, in contrast to g_signal_emitv().
295 	 *
296 	 * Params:
297 	 *     instance_ = the instance the signal is being
298 	 *         emitted on.
299 	 *     signalId = the signal id
300 	 *     detail = the detail
301 	 *     varArgs = a list of parameters to be passed to the signal, followed by a
302 	 *         location for the return value. If the return type of the signal
303 	 *         is #G_TYPE_NONE, the return value location can be omitted.
304 	 */
305 	public static void emitValist(TypeInstance instance_, uint signalId, GQuark detail, void* varArgs)
306 	{
307 		g_signal_emit_valist((instance_ is null) ? null : instance_.getTypeInstanceStruct(), signalId, detail, varArgs);
308 	}
309 
310 	/**
311 	 * Emits a signal.
312 	 *
313 	 * Note that g_signal_emitv() doesn't change @return_value if no handlers are
314 	 * connected, in contrast to g_signal_emit() and g_signal_emit_valist().
315 	 *
316 	 * Params:
317 	 *     instanceAndParams = argument list for the signal emission.
318 	 *         The first element in the array is a #GValue for the instance the signal
319 	 *         is being emitted on. The rest are any arguments to be passed to the signal.
320 	 *     signalId = the signal id
321 	 *     detail = the detail
322 	 *     returnValue = Location to
323 	 *         store the return value of the signal emission. This must be provided if the
324 	 *         specified signal returns a value, but may be ignored otherwise.
325 	 */
326 	public static void emitv(Value[] instanceAndParams, uint signalId, GQuark detail, ref Value returnValue)
327 	{
328 		GValue[] instanceAndParamsArray = new GValue[instanceAndParams.length];
329 		for ( int i = 0; i < instanceAndParams.length; i++ )
330 		{
331 			instanceAndParamsArray[i] = *(instanceAndParams[i].getValueStruct());
332 		}
333 
334 		g_signal_emitv(instanceAndParamsArray.ptr, signalId, detail, (returnValue is null) ? null : returnValue.getValueStruct());
335 	}
336 
337 	/**
338 	 * Returns the invocation hint of the innermost signal emission of instance.
339 	 *
340 	 * Params:
341 	 *     instance_ = the instance to query
342 	 *
343 	 * Returns: the invocation hint of the innermost signal  emission.
344 	 */
345 	public static GSignalInvocationHint* getInvocationHint(ObjectG instance_)
346 	{
347 		return g_signal_get_invocation_hint((instance_ is null) ? null : instance_.getObjectGStruct());
348 	}
349 
350 	/**
351 	 * Blocks a handler of an instance so it will not be called during any
352 	 * signal emissions unless it is unblocked again. Thus "blocking" a
353 	 * signal handler means to temporarily deactive it, a signal handler
354 	 * has to be unblocked exactly the same amount of times it has been
355 	 * blocked before to become active again.
356 	 *
357 	 * The @handler_id has to be a valid signal handler id, connected to a
358 	 * signal of @instance.
359 	 *
360 	 * Params:
361 	 *     instance_ = The instance to block the signal handler of.
362 	 *     handlerId = Handler id of the handler to be blocked.
363 	 */
364 	public static void handlerBlock(ObjectG instance_, gulong handlerId)
365 	{
366 		g_signal_handler_block((instance_ is null) ? null : instance_.getObjectGStruct(), handlerId);
367 	}
368 
369 	/**
370 	 * Finds the first signal handler that matches certain selection criteria.
371 	 * The criteria mask is passed as an OR-ed combination of #GSignalMatchType
372 	 * flags, and the criteria values are passed as arguments.
373 	 * The match @mask has to be non-0 for successful matches.
374 	 * If no handler was found, 0 is returned.
375 	 *
376 	 * Params:
377 	 *     instance_ = The instance owning the signal handler to be found.
378 	 *     mask = Mask indicating which of @signal_id, @detail, @closure, @func
379 	 *         and/or @data the handler has to match.
380 	 *     signalId = Signal the handler has to be connected to.
381 	 *     detail = Signal detail the handler has to be connected to.
382 	 *     closure = The closure the handler will invoke.
383 	 *     func = The C closure callback of the handler (useless for non-C closures).
384 	 *     data = The closure data of the handler's closure.
385 	 *
386 	 * Returns: A valid non-0 signal handler id for a successful match.
387 	 */
388 	public static gulong handlerFind(ObjectG instance_, GSignalMatchType mask, uint signalId, GQuark detail, Closure closure, void* func, void* data)
389 	{
390 		return g_signal_handler_find((instance_ is null) ? null : instance_.getObjectGStruct(), mask, signalId, detail, (closure is null) ? null : closure.getClosureStruct(), func, data);
391 	}
392 
393 	/**
394 	 * Returns whether @handler_id is the ID of a handler connected to @instance.
395 	 *
396 	 * Params:
397 	 *     instance_ = The instance where a signal handler is sought.
398 	 *     handlerId = the handler ID.
399 	 *
400 	 * Returns: whether @handler_id identifies a handler connected to @instance.
401 	 */
402 	public static bool handlerIsConnected(ObjectG instance_, gulong handlerId)
403 	{
404 		return g_signal_handler_is_connected((instance_ is null) ? null : instance_.getObjectGStruct(), handlerId) != 0;
405 	}
406 
407 	/**
408 	 * Undoes the effect of a previous g_signal_handler_block() call.  A
409 	 * blocked handler is skipped during signal emissions and will not be
410 	 * invoked, unblocking it (for exactly the amount of times it has been
411 	 * blocked before) reverts its "blocked" state, so the handler will be
412 	 * recognized by the signal system and is called upon future or
413 	 * currently ongoing signal emissions (since the order in which
414 	 * handlers are called during signal emissions is deterministic,
415 	 * whether the unblocked handler in question is called as part of a
416 	 * currently ongoing emission depends on how far that emission has
417 	 * proceeded yet).
418 	 *
419 	 * The @handler_id has to be a valid id of a signal handler that is
420 	 * connected to a signal of @instance and is currently blocked.
421 	 *
422 	 * Params:
423 	 *     instance_ = The instance to unblock the signal handler of.
424 	 *     handlerId = Handler id of the handler to be unblocked.
425 	 */
426 	public static void handlerUnblock(ObjectG instance_, gulong handlerId)
427 	{
428 		g_signal_handler_unblock((instance_ is null) ? null : instance_.getObjectGStruct(), handlerId);
429 	}
430 
431 	/**
432 	 * Blocks all handlers on an instance that match a certain selection criteria.
433 	 * The criteria mask is passed as an OR-ed combination of #GSignalMatchType
434 	 * flags, and the criteria values are passed as arguments.
435 	 * Passing at least one of the %G_SIGNAL_MATCH_CLOSURE, %G_SIGNAL_MATCH_FUNC
436 	 * or %G_SIGNAL_MATCH_DATA match flags is required for successful matches.
437 	 * If no handlers were found, 0 is returned, the number of blocked handlers
438 	 * otherwise.
439 	 *
440 	 * Params:
441 	 *     instance_ = The instance to block handlers from.
442 	 *     mask = Mask indicating which of @signal_id, @detail, @closure, @func
443 	 *         and/or @data the handlers have to match.
444 	 *     signalId = Signal the handlers have to be connected to.
445 	 *     detail = Signal detail the handlers have to be connected to.
446 	 *     closure = The closure the handlers will invoke.
447 	 *     func = The C closure callback of the handlers (useless for non-C closures).
448 	 *     data = The closure data of the handlers' closures.
449 	 *
450 	 * Returns: The number of handlers that matched.
451 	 */
452 	public static uint handlersBlockMatched(ObjectG instance_, GSignalMatchType mask, uint signalId, GQuark detail, Closure closure, void* func, void* data)
453 	{
454 		return g_signal_handlers_block_matched((instance_ is null) ? null : instance_.getObjectGStruct(), mask, signalId, detail, (closure is null) ? null : closure.getClosureStruct(), func, data);
455 	}
456 
457 	/**
458 	 * Destroy all signal handlers of a type instance. This function is
459 	 * an implementation detail of the #GObject dispose implementation,
460 	 * and should not be used outside of the type system.
461 	 *
462 	 * Params:
463 	 *     instance_ = The instance whose signal handlers are destroyed
464 	 */
465 	public static void handlersDestroy(ObjectG instance_)
466 	{
467 		g_signal_handlers_destroy((instance_ is null) ? null : instance_.getObjectGStruct());
468 	}
469 
470 	/**
471 	 * Disconnects all handlers on an instance that match a certain
472 	 * selection criteria. The criteria mask is passed as an OR-ed
473 	 * combination of #GSignalMatchType flags, and the criteria values are
474 	 * passed as arguments.  Passing at least one of the
475 	 * %G_SIGNAL_MATCH_CLOSURE, %G_SIGNAL_MATCH_FUNC or
476 	 * %G_SIGNAL_MATCH_DATA match flags is required for successful
477 	 * matches.  If no handlers were found, 0 is returned, the number of
478 	 * disconnected handlers otherwise.
479 	 *
480 	 * Params:
481 	 *     instance_ = The instance to remove handlers from.
482 	 *     mask = Mask indicating which of @signal_id, @detail, @closure, @func
483 	 *         and/or @data the handlers have to match.
484 	 *     signalId = Signal the handlers have to be connected to.
485 	 *     detail = Signal detail the handlers have to be connected to.
486 	 *     closure = The closure the handlers will invoke.
487 	 *     func = The C closure callback of the handlers (useless for non-C closures).
488 	 *     data = The closure data of the handlers' closures.
489 	 *
490 	 * Returns: The number of handlers that matched.
491 	 */
492 	public static uint handlersDisconnectMatched(ObjectG instance_, GSignalMatchType mask, uint signalId, GQuark detail, Closure closure, void* func, void* data)
493 	{
494 		return g_signal_handlers_disconnect_matched((instance_ is null) ? null : instance_.getObjectGStruct(), mask, signalId, detail, (closure is null) ? null : closure.getClosureStruct(), func, data);
495 	}
496 
497 	/**
498 	 * Unblocks all handlers on an instance that match a certain selection
499 	 * criteria. The criteria mask is passed as an OR-ed combination of
500 	 * #GSignalMatchType flags, and the criteria values are passed as arguments.
501 	 * Passing at least one of the %G_SIGNAL_MATCH_CLOSURE, %G_SIGNAL_MATCH_FUNC
502 	 * or %G_SIGNAL_MATCH_DATA match flags is required for successful matches.
503 	 * If no handlers were found, 0 is returned, the number of unblocked handlers
504 	 * otherwise. The match criteria should not apply to any handlers that are
505 	 * not currently blocked.
506 	 *
507 	 * Params:
508 	 *     instance_ = The instance to unblock handlers from.
509 	 *     mask = Mask indicating which of @signal_id, @detail, @closure, @func
510 	 *         and/or @data the handlers have to match.
511 	 *     signalId = Signal the handlers have to be connected to.
512 	 *     detail = Signal detail the handlers have to be connected to.
513 	 *     closure = The closure the handlers will invoke.
514 	 *     func = The C closure callback of the handlers (useless for non-C closures).
515 	 *     data = The closure data of the handlers' closures.
516 	 *
517 	 * Returns: The number of handlers that matched.
518 	 */
519 	public static uint handlersUnblockMatched(ObjectG instance_, GSignalMatchType mask, uint signalId, GQuark detail, Closure closure, void* func, void* data)
520 	{
521 		return g_signal_handlers_unblock_matched((instance_ is null) ? null : instance_.getObjectGStruct(), mask, signalId, detail, (closure is null) ? null : closure.getClosureStruct(), func, data);
522 	}
523 
524 	/**
525 	 * Returns whether there are any handlers connected to @instance for the
526 	 * given signal id and detail.
527 	 *
528 	 * If @detail is 0 then it will only match handlers that were connected
529 	 * without detail.  If @detail is non-zero then it will match handlers
530 	 * connected both without detail and with the given detail.  This is
531 	 * consistent with how a signal emitted with @detail would be delivered
532 	 * to those handlers.
533 	 *
534 	 * Since 2.46 this also checks for a non-default class closure being
535 	 * installed, as this is basically always what you want.
536 	 *
537 	 * One example of when you might use this is when the arguments to the
538 	 * signal are difficult to compute. A class implementor may opt to not
539 	 * emit the signal if no one is attached anyway, thus saving the cost
540 	 * of building the arguments.
541 	 *
542 	 * Params:
543 	 *     instance_ = the object whose signal handlers are sought.
544 	 *     signalId = the signal id.
545 	 *     detail = the detail.
546 	 *     mayBeBlocked = whether blocked handlers should count as match.
547 	 *
548 	 * Returns: %TRUE if a handler is connected to the signal, %FALSE
549 	 *     otherwise.
550 	 */
551 	public static bool hasHandlerPending(ObjectG instance_, uint signalId, GQuark detail, bool mayBeBlocked)
552 	{
553 		return g_signal_has_handler_pending((instance_ is null) ? null : instance_.getObjectGStruct(), signalId, detail, mayBeBlocked) != 0;
554 	}
555 
556 	/**
557 	 * Lists the signals by id that a certain instance or interface type
558 	 * created. Further information about the signals can be acquired through
559 	 * g_signal_query().
560 	 *
561 	 * Params:
562 	 *     itype = Instance or interface type.
563 	 *
564 	 * Returns: Newly allocated array of signal IDs.
565 	 */
566 	public static uint[] listIds(GType itype)
567 	{
568 		uint nIds;
569 
570 		auto __p = g_signal_list_ids(itype, &nIds);
571 
572 		return __p[0 .. nIds];
573 	}
574 
575 	/**
576 	 * Given the name of the signal and the type of object it connects to, gets
577 	 * the signal's identifying integer. Emitting the signal by number is
578 	 * somewhat faster than using the name each time.
579 	 *
580 	 * Also tries the ancestors of the given type.
581 	 *
582 	 * The type class passed as @itype must already have been instantiated (for
583 	 * example, using g_type_class_ref()) for this function to work, as signals are
584 	 * always installed during class initialization.
585 	 *
586 	 * See g_signal_new() for details on allowed signal names.
587 	 *
588 	 * Params:
589 	 *     name = the signal's name.
590 	 *     itype = the type that the signal operates on.
591 	 *
592 	 * Returns: the signal's identifying number, or 0 if no signal was found.
593 	 */
594 	public static uint lookup(string name, GType itype)
595 	{
596 		return g_signal_lookup(Str.toStringz(name), itype);
597 	}
598 
599 	/**
600 	 * Given the signal's identifier, finds its name.
601 	 *
602 	 * Two different signals may have the same name, if they have differing types.
603 	 *
604 	 * Params:
605 	 *     signalId = the signal's identifying number.
606 	 *
607 	 * Returns: the signal name, or %NULL if the signal number was invalid.
608 	 */
609 	public static string name(uint signalId)
610 	{
611 		return Str.toString(g_signal_name(signalId));
612 	}
613 
614 	/**
615 	 * Creates a new signal. (This is usually done in the class initializer.)
616 	 *
617 	 * See g_signal_new() for details on allowed signal names.
618 	 *
619 	 * If c_marshaller is %NULL, g_cclosure_marshal_generic() will be used as
620 	 * the marshaller for this signal.
621 	 *
622 	 * Params:
623 	 *     signalName = the name for the signal
624 	 *     itype = the type this signal pertains to. It will also pertain to
625 	 *         types which are derived from this type.
626 	 *     signalFlags = a combination of #GSignalFlags specifying detail of when
627 	 *         the default handler is to be invoked. You should at least specify
628 	 *         %G_SIGNAL_RUN_FIRST or %G_SIGNAL_RUN_LAST.
629 	 *     classClosure = The closure to invoke on signal emission; may be %NULL.
630 	 *     accumulator = the accumulator for this signal; may be %NULL.
631 	 *     accuData = user data for the @accumulator.
632 	 *     cMarshaller = the function to translate arrays of parameter
633 	 *         values to signal emissions into C language callback invocations or %NULL.
634 	 *     returnType = the type of return value, or #G_TYPE_NONE for a signal
635 	 *         without a return value.
636 	 *     nParams = the number of parameter types in @args.
637 	 *     args = va_list of #GType, one for each parameter.
638 	 *
639 	 * Returns: the signal id
640 	 */
641 	public static uint newValist(string signalName, GType itype, GSignalFlags signalFlags, Closure classClosure, GSignalAccumulator accumulator, void* accuData, GSignalCMarshaller cMarshaller, GType returnType, uint nParams, void* args)
642 	{
643 		return g_signal_new_valist(Str.toStringz(signalName), itype, signalFlags, (classClosure is null) ? null : classClosure.getClosureStruct(), accumulator, accuData, cMarshaller, returnType, nParams, args);
644 	}
645 
646 	/**
647 	 * Creates a new signal. (This is usually done in the class initializer.)
648 	 *
649 	 * See g_signal_new() for details on allowed signal names.
650 	 *
651 	 * If c_marshaller is %NULL, g_cclosure_marshal_generic() will be used as
652 	 * the marshaller for this signal.
653 	 *
654 	 * Params:
655 	 *     signalName = the name for the signal
656 	 *     itype = the type this signal pertains to. It will also pertain to
657 	 *         types which are derived from this type
658 	 *     signalFlags = a combination of #GSignalFlags specifying detail of when
659 	 *         the default handler is to be invoked. You should at least specify
660 	 *         %G_SIGNAL_RUN_FIRST or %G_SIGNAL_RUN_LAST
661 	 *     classClosure = The closure to invoke on signal emission;
662 	 *         may be %NULL
663 	 *     accumulator = the accumulator for this signal; may be %NULL
664 	 *     accuData = user data for the @accumulator
665 	 *     cMarshaller = the function to translate arrays of
666 	 *         parameter values to signal emissions into C language callback
667 	 *         invocations or %NULL
668 	 *     returnType = the type of return value, or #G_TYPE_NONE for a signal
669 	 *         without a return value
670 	 *     paramTypes = an array of types, one for
671 	 *         each parameter
672 	 *
673 	 * Returns: the signal id
674 	 */
675 	public static uint newv(string signalName, GType itype, GSignalFlags signalFlags, Closure classClosure, GSignalAccumulator accumulator, void* accuData, GSignalCMarshaller cMarshaller, GType returnType, GType[] paramTypes)
676 	{
677 		return g_signal_newv(Str.toStringz(signalName), itype, signalFlags, (classClosure is null) ? null : classClosure.getClosureStruct(), accumulator, accuData, cMarshaller, returnType, cast(uint)paramTypes.length, paramTypes.ptr);
678 	}
679 
680 	/**
681 	 * Overrides the class closure (i.e. the default handler) for the given signal
682 	 * for emissions on instances of @instance_type. @instance_type must be derived
683 	 * from the type to which the signal belongs.
684 	 *
685 	 * See g_signal_chain_from_overridden() and
686 	 * g_signal_chain_from_overridden_handler() for how to chain up to the
687 	 * parent class closure from inside the overridden one.
688 	 *
689 	 * Params:
690 	 *     signalId = the signal id
691 	 *     instanceType = the instance type on which to override the class closure
692 	 *         for the signal.
693 	 *     classClosure = the closure.
694 	 */
695 	public static void overrideClassClosure(uint signalId, GType instanceType, Closure classClosure)
696 	{
697 		g_signal_override_class_closure(signalId, instanceType, (classClosure is null) ? null : classClosure.getClosureStruct());
698 	}
699 
700 	/**
701 	 * Overrides the class closure (i.e. the default handler) for the
702 	 * given signal for emissions on instances of @instance_type with
703 	 * callback @class_handler. @instance_type must be derived from the
704 	 * type to which the signal belongs.
705 	 *
706 	 * See g_signal_chain_from_overridden() and
707 	 * g_signal_chain_from_overridden_handler() for how to chain up to the
708 	 * parent class closure from inside the overridden one.
709 	 *
710 	 * Params:
711 	 *     signalName = the name for the signal
712 	 *     instanceType = the instance type on which to override the class handler
713 	 *         for the signal.
714 	 *     classHandler = the handler.
715 	 *
716 	 * Since: 2.18
717 	 */
718 	public static void overrideClassHandler(string signalName, GType instanceType, GCallback classHandler)
719 	{
720 		g_signal_override_class_handler(Str.toStringz(signalName), instanceType, classHandler);
721 	}
722 
723 	/**
724 	 * Internal function to parse a signal name into its @signal_id
725 	 * and @detail quark.
726 	 *
727 	 * Params:
728 	 *     detailedSignal = a string of the form "signal-name::detail".
729 	 *     itype = The interface/instance type that introduced "signal-name".
730 	 *     signalIdP = Location to store the signal id.
731 	 *     detailP = Location to store the detail quark.
732 	 *     forceDetailQuark = %TRUE forces creation of a #GQuark for the detail.
733 	 *
734 	 * Returns: Whether the signal name could successfully be parsed and @signal_id_p and @detail_p contain valid return values.
735 	 */
736 	public static bool parseName(string detailedSignal, GType itype, out uint signalIdP, out GQuark detailP, bool forceDetailQuark)
737 	{
738 		return g_signal_parse_name(Str.toStringz(detailedSignal), itype, &signalIdP, &detailP, forceDetailQuark) != 0;
739 	}
740 
741 	/**
742 	 * Queries the signal system for in-depth information about a
743 	 * specific signal. This function will fill in a user-provided
744 	 * structure to hold signal-specific information. If an invalid
745 	 * signal id is passed in, the @signal_id member of the #GSignalQuery
746 	 * is 0. All members filled into the #GSignalQuery structure should
747 	 * be considered constant and have to be left untouched.
748 	 *
749 	 * Params:
750 	 *     signalId = The signal id of the signal to query information for.
751 	 *     query = A user provided structure that is
752 	 *         filled in with constant values upon success.
753 	 */
754 	public static void query(uint signalId, out GSignalQuery query)
755 	{
756 		g_signal_query(signalId, &query);
757 	}
758 
759 	/**
760 	 * Deletes an emission hook.
761 	 *
762 	 * Params:
763 	 *     signalId = the id of the signal
764 	 *     hookId = the id of the emission hook, as returned by
765 	 *         g_signal_add_emission_hook()
766 	 */
767 	public static void removeEmission(uint signalId, gulong hookId)
768 	{
769 		g_signal_remove_emission_hook(signalId, hookId);
770 	}
771 
772 	/**
773 	 * Change the #GSignalCVaMarshaller used for a given signal.  This is a
774 	 * specialised form of the marshaller that can often be used for the
775 	 * common case of a single connected signal handler and avoids the
776 	 * overhead of #GValue.  Its use is optional.
777 	 *
778 	 * Params:
779 	 *     signalId = the signal id
780 	 *     instanceType = the instance type on which to set the marshaller.
781 	 *     vaMarshaller = the marshaller to set.
782 	 *
783 	 * Since: 2.32
784 	 */
785 	public static void setVaMarshaller(uint signalId, GType instanceType, GSignalCVaMarshaller vaMarshaller)
786 	{
787 		g_signal_set_va_marshaller(signalId, instanceType, vaMarshaller);
788 	}
789 
790 	/**
791 	 * Stops a signal's current emission.
792 	 *
793 	 * This will prevent the default method from running, if the signal was
794 	 * %G_SIGNAL_RUN_LAST and you connected normally (i.e. without the "after"
795 	 * flag).
796 	 *
797 	 * Prints a warning if used on a signal which isn't being emitted.
798 	 *
799 	 * Params:
800 	 *     instance_ = the object whose signal handlers you wish to stop.
801 	 *     signalId = the signal identifier, as returned by g_signal_lookup().
802 	 *     detail = the detail which the signal was emitted with.
803 	 */
804 	public static void stopEmission(ObjectG instance_, uint signalId, GQuark detail)
805 	{
806 		g_signal_stop_emission((instance_ is null) ? null : instance_.getObjectGStruct(), signalId, detail);
807 	}
808 
809 	/**
810 	 * Stops a signal's current emission.
811 	 *
812 	 * This is just like g_signal_stop_emission() except it will look up the
813 	 * signal id for you.
814 	 *
815 	 * Params:
816 	 *     instance_ = the object whose signal handlers you wish to stop.
817 	 *     detailedSignal = a string of the form "signal-name::detail".
818 	 */
819 	public static void stopEmissionByName(ObjectG instance_, string detailedSignal)
820 	{
821 		g_signal_stop_emission_by_name((instance_ is null) ? null : instance_.getObjectGStruct(), Str.toStringz(detailedSignal));
822 	}
823 
824 	/**
825 	 * Creates a new closure which invokes the function found at the offset
826 	 * @struct_offset in the class structure of the interface or classed type
827 	 * identified by @itype.
828 	 *
829 	 * Params:
830 	 *     itype = the #GType identifier of an interface or classed type
831 	 *     structOffset = the offset of the member function of @itype's class
832 	 *         structure which is to be invoked by the new closure
833 	 *
834 	 * Returns: a floating reference to a new #GCClosure
835 	 */
836 	public static Closure typeCclosureNew(GType itype, uint structOffset)
837 	{
838 		auto __p = g_signal_type_cclosure_new(itype, structOffset);
839 
840 		if(__p is null)
841 		{
842 			return null;
843 		}
844 
845 		return ObjectG.getDObject!(Closure)(cast(GClosure*) __p);
846 	}
847 
848 	/**
849 	 * Disconnects a handler from @instance so it will not be called during
850 	 * any future or currently ongoing emissions of the signal it has been
851 	 * connected to. The @handler_id_ptr is then set to zero, which is never a valid handler ID value (see g_signal_connect()).
852 	 *
853 	 * If the handler ID is 0 then this function does nothing.
854 	 *
855 	 * A macro is also included that allows this function to be used without
856 	 * pointer casts.
857 	 *
858 	 * Params:
859 	 *     handlerIdPtr = A pointer to a handler ID (of type #gulong) of the handler to be disconnected.
860 	 *     instance_ = The instance to remove the signal handler from.
861 	 *
862 	 * Since: 2.62
863 	 */
864 	public static void clearSignalHandler(gulong* handlerIdPtr, ObjectG instance_)
865 	{
866 		g_clear_signal_handler(handlerIdPtr, (instance_ is null) ? null : instance_.getObjectGStruct());
867 	}
868 }