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