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 store the return value of the signal emission. 252 */ 253 public static void emitv(Value[] instanceAndParams, uint signalId, GQuark detail, Value returnValue) 254 { 255 GValue[] instanceAndParamsArray = new GValue[instanceAndParams.length]; 256 for ( int i = 0; i < instanceAndParams.length; i++ ) 257 { 258 instanceAndParamsArray[i] = *(instanceAndParams[i].getValueStruct()); 259 } 260 261 g_signal_emitv(instanceAndParamsArray.ptr, signalId, detail, (returnValue is null) ? null : returnValue.getValueStruct()); 262 } 263 264 /** 265 * Returns the invocation hint of the innermost signal emission of instance. 266 * 267 * Params: 268 * instanc = the instance to query 269 * 270 * Return: the invocation hint of the innermost signal emission. 271 */ 272 public static GSignalInvocationHint* getInvocationHint(ObjectG instanc) 273 { 274 return g_signal_get_invocation_hint((instanc is null) ? null : instanc.getObjectGStruct()); 275 } 276 277 /** 278 * Blocks a handler of an instance so it will not be called during any 279 * signal emissions unless it is unblocked again. Thus "blocking" a 280 * signal handler means to temporarily deactive it, a signal handler 281 * has to be unblocked exactly the same amount of times it has been 282 * blocked before to become active again. 283 * 284 * The @handler_id has to be a valid signal handler id, connected to a 285 * signal of @instance. 286 * 287 * Params: 288 * instanc = The instance to block the signal handler of. 289 * handlerId = Handler id of the handler to be blocked. 290 */ 291 public static void handlerBlock(ObjectG instanc, gulong handlerId) 292 { 293 g_signal_handler_block((instanc is null) ? null : instanc.getObjectGStruct(), handlerId); 294 } 295 296 /** 297 * Disconnects a handler from an instance so it will not be called during 298 * any future or currently ongoing emissions of the signal it has been 299 * connected to. The @handler_id becomes invalid and may be reused. 300 * 301 * The @handler_id has to be a valid signal handler id, connected to a 302 * signal of @instance. 303 * 304 * Params: 305 * instanc = The instance to remove the signal handler from. 306 * handlerId = Handler id of the handler to be disconnected. 307 */ 308 public static void handlerDisconnect(ObjectG instanc, gulong handlerId) 309 { 310 g_signal_handler_disconnect((instanc is null) ? null : instanc.getObjectGStruct(), handlerId); 311 } 312 313 /** 314 * Finds the first signal handler that matches certain selection criteria. 315 * The criteria mask is passed as an OR-ed combination of #GSignalMatchType 316 * flags, and the criteria values are passed as arguments. 317 * The match @mask has to be non-0 for successful matches. 318 * If no handler was found, 0 is returned. 319 * 320 * Params: 321 * instanc = The instance owning the signal handler to be found. 322 * mask = Mask indicating which of @signal_id, @detail, @closure, @func 323 * and/or @data the handler has to match. 324 * signalId = Signal the handler has to be connected to. 325 * detail = Signal detail the handler has to be connected to. 326 * closure = The closure the handler will invoke. 327 * func = The C closure callback of the handler (useless for non-C closures). 328 * data = The closure data of the handler's closure. 329 * 330 * Return: A valid non-0 signal handler id for a successful match. 331 */ 332 public static gulong handlerFind(ObjectG instanc, GSignalMatchType mask, uint signalId, GQuark detail, Closure closure, void* func, void* data) 333 { 334 return g_signal_handler_find((instanc is null) ? null : instanc.getObjectGStruct(), mask, signalId, detail, (closure is null) ? null : closure.getClosureStruct(), func, data); 335 } 336 337 /** 338 * Returns whether @handler_id is the id of a handler connected to @instance. 339 * 340 * Params: 341 * instanc = The instance where a signal handler is sought. 342 * handlerId = the handler id. 343 * 344 * Return: whether @handler_id identifies a handler connected to @instance. 345 */ 346 public static bool handlerIsConnected(ObjectG instanc, gulong handlerId) 347 { 348 return g_signal_handler_is_connected((instanc is null) ? null : instanc.getObjectGStruct(), handlerId) != 0; 349 } 350 351 /** 352 * Undoes the effect of a previous g_signal_handler_block() call. A 353 * blocked handler is skipped during signal emissions and will not be 354 * invoked, unblocking it (for exactly the amount of times it has been 355 * blocked before) reverts its "blocked" state, so the handler will be 356 * recognized by the signal system and is called upon future or 357 * currently ongoing signal emissions (since the order in which 358 * handlers are called during signal emissions is deterministic, 359 * whether the unblocked handler in question is called as part of a 360 * currently ongoing emission depends on how far that emission has 361 * proceeded yet). 362 * 363 * The @handler_id has to be a valid id of a signal handler that is 364 * connected to a signal of @instance and is currently blocked. 365 * 366 * Params: 367 * instanc = The instance to unblock the signal handler of. 368 * handlerId = Handler id of the handler to be unblocked. 369 */ 370 public static void handlerUnblock(ObjectG instanc, gulong handlerId) 371 { 372 g_signal_handler_unblock((instanc is null) ? null : instanc.getObjectGStruct(), handlerId); 373 } 374 375 /** 376 * Blocks all handlers on an instance that match a certain selection criteria. 377 * The criteria mask is passed as an OR-ed combination of #GSignalMatchType 378 * flags, and the criteria values are passed as arguments. 379 * Passing at least one of the %G_SIGNAL_MATCH_CLOSURE, %G_SIGNAL_MATCH_FUNC 380 * or %G_SIGNAL_MATCH_DATA match flags is required for successful matches. 381 * If no handlers were found, 0 is returned, the number of blocked handlers 382 * otherwise. 383 * 384 * Params: 385 * instanc = The instance to block handlers from. 386 * mask = Mask indicating which of @signal_id, @detail, @closure, @func 387 * and/or @data the handlers have to match. 388 * signalId = Signal the handlers have to be connected to. 389 * detail = Signal detail the handlers have to be connected to. 390 * closure = The closure the handlers will invoke. 391 * func = The C closure callback of the handlers (useless for non-C closures). 392 * data = The closure data of the handlers' closures. 393 * 394 * Return: The number of handlers that matched. 395 */ 396 public static uint handlersBlockMatched(ObjectG instanc, GSignalMatchType mask, uint signalId, GQuark detail, Closure closure, void* func, void* data) 397 { 398 return g_signal_handlers_block_matched((instanc is null) ? null : instanc.getObjectGStruct(), mask, signalId, detail, (closure is null) ? null : closure.getClosureStruct(), func, data); 399 } 400 401 /** 402 * Destroy all signal handlers of a type instance. This function is 403 * an implementation detail of the #GObject dispose implementation, 404 * and should not be used outside of the type system. 405 * 406 * Params: 407 * instanc = The instance whose signal handlers are destroyed 408 */ 409 public static void handlersDestroy(ObjectG instanc) 410 { 411 g_signal_handlers_destroy((instanc is null) ? null : instanc.getObjectGStruct()); 412 } 413 414 /** 415 * Disconnects all handlers on an instance that match a certain 416 * selection criteria. The criteria mask is passed as an OR-ed 417 * combination of #GSignalMatchType flags, and the criteria values are 418 * passed as arguments. Passing at least one of the 419 * %G_SIGNAL_MATCH_CLOSURE, %G_SIGNAL_MATCH_FUNC or 420 * %G_SIGNAL_MATCH_DATA match flags is required for successful 421 * matches. If no handlers were found, 0 is returned, the number of 422 * disconnected handlers otherwise. 423 * 424 * Params: 425 * instanc = The instance to remove handlers from. 426 * mask = Mask indicating which of @signal_id, @detail, @closure, @func 427 * and/or @data the handlers have to match. 428 * signalId = Signal the handlers have to be connected to. 429 * detail = Signal detail the handlers have to be connected to. 430 * closure = The closure the handlers will invoke. 431 * func = The C closure callback of the handlers (useless for non-C closures). 432 * data = The closure data of the handlers' closures. 433 * 434 * Return: The number of handlers that matched. 435 */ 436 public static uint handlersDisconnectMatched(ObjectG instanc, GSignalMatchType mask, uint signalId, GQuark detail, Closure closure, void* func, void* data) 437 { 438 return g_signal_handlers_disconnect_matched((instanc is null) ? null : instanc.getObjectGStruct(), mask, signalId, detail, (closure is null) ? null : closure.getClosureStruct(), func, data); 439 } 440 441 /** 442 * Unblocks all handlers on an instance that match a certain selection 443 * criteria. The criteria mask is passed as an OR-ed combination of 444 * #GSignalMatchType flags, and the criteria values are passed as arguments. 445 * Passing at least one of the %G_SIGNAL_MATCH_CLOSURE, %G_SIGNAL_MATCH_FUNC 446 * or %G_SIGNAL_MATCH_DATA match flags is required for successful matches. 447 * If no handlers were found, 0 is returned, the number of unblocked handlers 448 * otherwise. The match criteria should not apply to any handlers that are 449 * not currently blocked. 450 * 451 * Params: 452 * instanc = The instance to unblock handlers from. 453 * mask = Mask indicating which of @signal_id, @detail, @closure, @func 454 * and/or @data the handlers have to match. 455 * signalId = Signal the handlers have to be connected to. 456 * detail = Signal detail the handlers have to be connected to. 457 * closure = The closure the handlers will invoke. 458 * func = The C closure callback of the handlers (useless for non-C closures). 459 * data = The closure data of the handlers' closures. 460 * 461 * Return: The number of handlers that matched. 462 */ 463 public static uint handlersUnblockMatched(ObjectG instanc, GSignalMatchType mask, uint signalId, GQuark detail, Closure closure, void* func, void* data) 464 { 465 return g_signal_handlers_unblock_matched((instanc is null) ? null : instanc.getObjectGStruct(), mask, signalId, detail, (closure is null) ? null : closure.getClosureStruct(), func, data); 466 } 467 468 /** 469 * Returns whether there are any handlers connected to @instance for the 470 * given signal id and detail. 471 * 472 * One example of when you might use this is when the arguments to the 473 * signal are difficult to compute. A class implementor may opt to not 474 * emit the signal if no one is attached anyway, thus saving the cost 475 * of building the arguments. 476 * 477 * Params: 478 * instanc = the object whose signal handlers are sought. 479 * signalId = the signal id. 480 * detail = the detail. 481 * mayBeBlocked = whether blocked handlers should count as match. 482 * 483 * Return: %TRUE if a handler is connected to the signal, %FALSE 484 * otherwise. 485 */ 486 public static bool hasHandlerPending(ObjectG instanc, uint signalId, GQuark detail, bool mayBeBlocked) 487 { 488 return g_signal_has_handler_pending((instanc is null) ? null : instanc.getObjectGStruct(), signalId, detail, mayBeBlocked) != 0; 489 } 490 491 /** 492 * Lists the signals by id that a certain instance or interface type 493 * created. Further information about the signals can be acquired through 494 * g_signal_query(). 495 * 496 * Params: 497 * itype = Instance or interface type. 498 * nIds = Location to store the number of signal ids for @itype. 499 * 500 * Return: Newly allocated array of signal IDs. 501 */ 502 public static uint[] listIds(GType itype) 503 { 504 uint nIds; 505 506 auto p = g_signal_list_ids(itype, &nIds); 507 508 return p[0 .. nIds]; 509 } 510 511 /** 512 * Given the name of the signal and the type of object it connects to, gets 513 * the signal's identifying integer. Emitting the signal by number is 514 * somewhat faster than using the name each time. 515 * 516 * Also tries the ancestors of the given type. 517 * 518 * See g_signal_new() for details on allowed signal names. 519 * 520 * Params: 521 * name = the signal's name. 522 * itype = the type that the signal operates on. 523 * 524 * Return: the signal's identifying number, or 0 if no signal was found. 525 */ 526 public static uint lookup(string name, GType itype) 527 { 528 return g_signal_lookup(Str.toStringz(name), itype); 529 } 530 531 /** 532 * Given the signal's identifier, finds its name. 533 * 534 * Two different signals may have the same name, if they have differing types. 535 * 536 * Params: 537 * signalId = the signal's identifying number. 538 * 539 * Return: the signal name, or %NULL if the signal number was invalid. 540 */ 541 public static string name(uint signalId) 542 { 543 return Str.toString(g_signal_name(signalId)); 544 } 545 546 /** 547 * Creates a new signal. (This is usually done in the class initializer.) 548 * 549 * See g_signal_new() for details on allowed signal names. 550 * 551 * If c_marshaller is %NULL, g_cclosure_marshal_generic() will be used as 552 * the marshaller for this signal. 553 * 554 * Params: 555 * signalName = the name for the signal 556 * itype = the type this signal pertains to. It will also pertain to 557 * types which are derived from this type. 558 * signalFlags = a combination of #GSignalFlags specifying detail of when 559 * the default handler is to be invoked. You should at least specify 560 * %G_SIGNAL_RUN_FIRST or %G_SIGNAL_RUN_LAST. 561 * classClosure = The closure to invoke on signal emission; may be %NULL. 562 * accumulator = the accumulator for this signal; may be %NULL. 563 * accuData = user data for the @accumulator. 564 * cMarshaller = the function to translate arrays of parameter 565 * values to signal emissions into C language callback invocations or %NULL. 566 * returnType = the type of return value, or #G_TYPE_NONE for a signal 567 * without a return value. 568 * nParams = the number of parameter types in @args. 569 * args = va_list of #GType, one for each parameter. 570 * 571 * Return: the signal id 572 */ 573 public static uint newValist(string signalName, GType itype, GSignalFlags signalFlags, Closure classClosure, GSignalAccumulator accumulator, void* accuData, GSignalCMarshaller cMarshaller, GType returnType, uint nParams, void* args) 574 { 575 return g_signal_new_valist(Str.toStringz(signalName), itype, signalFlags, (classClosure is null) ? null : classClosure.getClosureStruct(), accumulator, accuData, cMarshaller, returnType, nParams, args); 576 } 577 578 /** 579 * Creates a new signal. (This is usually done in the class initializer.) 580 * 581 * See g_signal_new() for details on allowed signal names. 582 * 583 * If c_marshaller is %NULL, g_cclosure_marshal_generic() will be used as 584 * the marshaller for this signal. 585 * 586 * Params: 587 * signalName = the name for the signal 588 * itype = the type this signal pertains to. It will also pertain to 589 * types which are derived from this type 590 * signalFlags = a combination of #GSignalFlags specifying detail of when 591 * the default handler is to be invoked. You should at least specify 592 * %G_SIGNAL_RUN_FIRST or %G_SIGNAL_RUN_LAST 593 * classClosure = The closure to invoke on signal emission; 594 * may be %NULL 595 * accumulator = the accumulator for this signal; may be %NULL 596 * accuData = user data for the @accumulator 597 * cMarshaller = the function to translate arrays of 598 * parameter values to signal emissions into C language callback 599 * invocations or %NULL 600 * returnType = the type of return value, or #G_TYPE_NONE for a signal 601 * without a return value 602 * nParams = the length of @param_types 603 * paramTypes = an array of types, one for 604 * each parameter 605 * 606 * Return: the signal id 607 */ 608 public static uint newv(string signalName, GType itype, GSignalFlags signalFlags, Closure classClosure, GSignalAccumulator accumulator, void* accuData, GSignalCMarshaller cMarshaller, GType returnType, GType[] paramTypes) 609 { 610 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); 611 } 612 613 /** 614 * Overrides the class closure (i.e. the default handler) for the given signal 615 * for emissions on instances of @instance_type. @instance_type must be derived 616 * from the type to which the signal belongs. 617 * 618 * See g_signal_chain_from_overridden() and 619 * g_signal_chain_from_overridden_handler() for how to chain up to the 620 * parent class closure from inside the overridden one. 621 * 622 * Params: 623 * signalId = the signal id 624 * instanceType = the instance type on which to override the class closure 625 * for the signal. 626 * classClosure = the closure. 627 */ 628 public static void overrideClassClosure(uint signalId, GType instanceType, Closure classClosure) 629 { 630 g_signal_override_class_closure(signalId, instanceType, (classClosure is null) ? null : classClosure.getClosureStruct()); 631 } 632 633 /** 634 * Overrides the class closure (i.e. the default handler) for the 635 * given signal for emissions on instances of @instance_type with 636 * callback @class_handler. @instance_type must be derived from the 637 * type to which the signal belongs. 638 * 639 * See g_signal_chain_from_overridden() and 640 * g_signal_chain_from_overridden_handler() for how to chain up to the 641 * parent class closure from inside the overridden one. 642 * 643 * Params: 644 * signalName = the name for the signal 645 * instanceType = the instance type on which to override the class handler 646 * for the signal. 647 * classHandler = the handler. 648 * 649 * Since: 2.18 650 */ 651 public static void overrideClassHandler(string signalName, GType instanceType, GCallback classHandler) 652 { 653 g_signal_override_class_handler(Str.toStringz(signalName), instanceType, classHandler); 654 } 655 656 /** 657 * Internal function to parse a signal name into its @signal_id 658 * and @detail quark. 659 * 660 * Params: 661 * detailedSignal = a string of the form "signal-name::detail". 662 * itype = The interface/instance type that introduced "signal-name". 663 * signalIdP = Location to store the signal id. 664 * detailP = Location to store the detail quark. 665 * forceDetailQuark = %TRUE forces creation of a #GQuark for the detail. 666 * 667 * Return: Whether the signal name could successfully be parsed and @signal_id_p and @detail_p contain valid return values. 668 */ 669 public static bool parseName(string detailedSignal, GType itype, out uint signalIdP, out GQuark detailP, bool forceDetailQuark) 670 { 671 return g_signal_parse_name(Str.toStringz(detailedSignal), itype, &signalIdP, &detailP, forceDetailQuark) != 0; 672 } 673 674 /** 675 * Queries the signal system for in-depth information about a 676 * specific signal. This function will fill in a user-provided 677 * structure to hold signal-specific information. If an invalid 678 * signal id is passed in, the @signal_id member of the #GSignalQuery 679 * is 0. All members filled into the #GSignalQuery structure should 680 * be considered constant and have to be left untouched. 681 * 682 * Params: 683 * signalId = The signal id of the signal to query information for. 684 * query = A user provided structure that is 685 * filled in with constant values upon success. 686 */ 687 public static void query(uint signalId, out GSignalQuery query) 688 { 689 g_signal_query(signalId, &query); 690 } 691 692 /** 693 * Deletes an emission hook. 694 * 695 * Params: 696 * signalId = the id of the signal 697 * hookId = the id of the emission hook, as returned by 698 * g_signal_add_emission_hook() 699 */ 700 public static void removeEmission(uint signalId, gulong hookId) 701 { 702 g_signal_remove_emission_hook(signalId, hookId); 703 } 704 705 public static void setVaMarshaller(uint signalId, GType instanceType, GSignalCVaMarshaller vaMarshaller) 706 { 707 g_signal_set_va_marshaller(signalId, instanceType, vaMarshaller); 708 } 709 710 /** 711 * Stops a signal's current emission. 712 * 713 * This will prevent the default method from running, if the signal was 714 * %G_SIGNAL_RUN_LAST and you connected normally (i.e. without the "after" 715 * flag). 716 * 717 * Prints a warning if used on a signal which isn't being emitted. 718 * 719 * Params: 720 * instanc = the object whose signal handlers you wish to stop. 721 * signalId = the signal identifier, as returned by g_signal_lookup(). 722 * detail = the detail which the signal was emitted with. 723 */ 724 public static void stopEmission(ObjectG instanc, uint signalId, GQuark detail) 725 { 726 g_signal_stop_emission((instanc is null) ? null : instanc.getObjectGStruct(), signalId, detail); 727 } 728 729 /** 730 * Stops a signal's current emission. 731 * 732 * This is just like g_signal_stop_emission() except it will look up the 733 * signal id for you. 734 * 735 * Params: 736 * instanc = the object whose signal handlers you wish to stop. 737 * detailedSignal = a string of the form "signal-name::detail". 738 */ 739 public static void stopEmissionByName(ObjectG instanc, string detailedSignal) 740 { 741 g_signal_stop_emission_by_name((instanc is null) ? null : instanc.getObjectGStruct(), Str.toStringz(detailedSignal)); 742 } 743 744 /** 745 * Creates a new closure which invokes the function found at the offset 746 * @struct_offset in the class structure of the interface or classed type 747 * identified by @itype. 748 * 749 * Params: 750 * itype = the #GType identifier of an interface or classed type 751 * structOffset = the offset of the member function of @itype's class 752 * structure which is to be invoked by the new closure 753 * 754 * Return: a new #GCClosure 755 */ 756 public static Closure typeCclosureNew(GType itype, uint structOffset) 757 { 758 auto p = g_signal_type_cclosure_new(itype, structOffset); 759 760 if(p is null) 761 { 762 return null; 763 } 764 765 return ObjectG.getDObject!(Closure)(cast(GClosure*) p); 766 } 767 }