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