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