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 * Since 2.46 this also checks for a non-default class closure being 482 * installed, as this is basically always what you want. 483 * 484 * One example of when you might use this is when the arguments to the 485 * signal are difficult to compute. A class implementor may opt to not 486 * emit the signal if no one is attached anyway, thus saving the cost 487 * of building the arguments. 488 * 489 * Params: 490 * instanc = the object whose signal handlers are sought. 491 * signalId = the signal id. 492 * detail = the detail. 493 * mayBeBlocked = whether blocked handlers should count as match. 494 * 495 * Return: %TRUE if a handler is connected to the signal, %FALSE 496 * otherwise. 497 */ 498 public static bool hasHandlerPending(ObjectG instanc, uint signalId, GQuark detail, bool mayBeBlocked) 499 { 500 return g_signal_has_handler_pending((instanc is null) ? null : instanc.getObjectGStruct(), signalId, detail, mayBeBlocked) != 0; 501 } 502 503 /** 504 * Lists the signals by id that a certain instance or interface type 505 * created. Further information about the signals can be acquired through 506 * g_signal_query(). 507 * 508 * Params: 509 * itype = Instance or interface type. 510 * 511 * Return: Newly allocated array of signal IDs. 512 */ 513 public static uint[] listIds(GType itype) 514 { 515 uint nIds; 516 517 auto p = g_signal_list_ids(itype, &nIds); 518 519 return p[0 .. nIds]; 520 } 521 522 /** 523 * Given the name of the signal and the type of object it connects to, gets 524 * the signal's identifying integer. Emitting the signal by number is 525 * somewhat faster than using the name each time. 526 * 527 * Also tries the ancestors of the given type. 528 * 529 * See g_signal_new() for details on allowed signal names. 530 * 531 * Params: 532 * name = the signal's name. 533 * itype = the type that the signal operates on. 534 * 535 * Return: the signal's identifying number, or 0 if no signal was found. 536 */ 537 public static uint lookup(string name, GType itype) 538 { 539 return g_signal_lookup(Str.toStringz(name), itype); 540 } 541 542 /** 543 * Given the signal's identifier, finds its name. 544 * 545 * Two different signals may have the same name, if they have differing types. 546 * 547 * Params: 548 * signalId = the signal's identifying number. 549 * 550 * Return: the signal name, or %NULL if the signal number was invalid. 551 */ 552 public static string name(uint signalId) 553 { 554 return Str.toString(g_signal_name(signalId)); 555 } 556 557 /** 558 * Creates a new signal. (This is usually done in the class initializer.) 559 * 560 * See g_signal_new() for details on allowed signal names. 561 * 562 * If c_marshaller is %NULL, g_cclosure_marshal_generic() will be used as 563 * the marshaller for this signal. 564 * 565 * Params: 566 * signalName = the name for the signal 567 * itype = the type this signal pertains to. It will also pertain to 568 * types which are derived from this type. 569 * signalFlags = a combination of #GSignalFlags specifying detail of when 570 * the default handler is to be invoked. You should at least specify 571 * %G_SIGNAL_RUN_FIRST or %G_SIGNAL_RUN_LAST. 572 * classClosure = The closure to invoke on signal emission; may be %NULL. 573 * accumulator = the accumulator for this signal; may be %NULL. 574 * accuData = user data for the @accumulator. 575 * cMarshaller = the function to translate arrays of parameter 576 * values to signal emissions into C language callback invocations or %NULL. 577 * returnType = the type of return value, or #G_TYPE_NONE for a signal 578 * without a return value. 579 * nParams = the number of parameter types in @args. 580 * args = va_list of #GType, one for each parameter. 581 * 582 * Return: the signal id 583 */ 584 public static uint newValist(string signalName, GType itype, GSignalFlags signalFlags, Closure classClosure, GSignalAccumulator accumulator, void* accuData, GSignalCMarshaller cMarshaller, GType returnType, uint nParams, void* args) 585 { 586 return g_signal_new_valist(Str.toStringz(signalName), itype, signalFlags, (classClosure is null) ? null : classClosure.getClosureStruct(), accumulator, accuData, cMarshaller, returnType, nParams, args); 587 } 588 589 /** 590 * Creates a new signal. (This is usually done in the class initializer.) 591 * 592 * See g_signal_new() for details on allowed signal names. 593 * 594 * If c_marshaller is %NULL, g_cclosure_marshal_generic() will be used as 595 * the marshaller for this signal. 596 * 597 * Params: 598 * signalName = the name for the signal 599 * itype = the type this signal pertains to. It will also pertain to 600 * types which are derived from this type 601 * signalFlags = a combination of #GSignalFlags specifying detail of when 602 * the default handler is to be invoked. You should at least specify 603 * %G_SIGNAL_RUN_FIRST or %G_SIGNAL_RUN_LAST 604 * classClosure = The closure to invoke on signal emission; 605 * may be %NULL 606 * accumulator = the accumulator for this signal; may be %NULL 607 * accuData = user data for the @accumulator 608 * cMarshaller = the function to translate arrays of 609 * parameter values to signal emissions into C language callback 610 * invocations or %NULL 611 * returnType = the type of return value, or #G_TYPE_NONE for a signal 612 * without a return value 613 * nParams = the length of @param_types 614 * paramTypes = an array of types, one for 615 * each parameter 616 * 617 * Return: the signal id 618 */ 619 public static uint newv(string signalName, GType itype, GSignalFlags signalFlags, Closure classClosure, GSignalAccumulator accumulator, void* accuData, GSignalCMarshaller cMarshaller, GType returnType, GType[] paramTypes) 620 { 621 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); 622 } 623 624 /** 625 * Overrides the class closure (i.e. the default handler) for the given signal 626 * for emissions on instances of @instance_type. @instance_type must be derived 627 * from the type to which the signal belongs. 628 * 629 * See g_signal_chain_from_overridden() and 630 * g_signal_chain_from_overridden_handler() for how to chain up to the 631 * parent class closure from inside the overridden one. 632 * 633 * Params: 634 * signalId = the signal id 635 * instanceType = the instance type on which to override the class closure 636 * for the signal. 637 * classClosure = the closure. 638 */ 639 public static void overrideClassClosure(uint signalId, GType instanceType, Closure classClosure) 640 { 641 g_signal_override_class_closure(signalId, instanceType, (classClosure is null) ? null : classClosure.getClosureStruct()); 642 } 643 644 /** 645 * Overrides the class closure (i.e. the default handler) for the 646 * given signal for emissions on instances of @instance_type with 647 * callback @class_handler. @instance_type must be derived from the 648 * type to which the signal belongs. 649 * 650 * See g_signal_chain_from_overridden() and 651 * g_signal_chain_from_overridden_handler() for how to chain up to the 652 * parent class closure from inside the overridden one. 653 * 654 * Params: 655 * signalName = the name for the signal 656 * instanceType = the instance type on which to override the class handler 657 * for the signal. 658 * classHandler = the handler. 659 * 660 * Since: 2.18 661 */ 662 public static void overrideClassHandler(string signalName, GType instanceType, GCallback classHandler) 663 { 664 g_signal_override_class_handler(Str.toStringz(signalName), instanceType, classHandler); 665 } 666 667 /** 668 * Internal function to parse a signal name into its @signal_id 669 * and @detail quark. 670 * 671 * Params: 672 * detailedSignal = a string of the form "signal-name::detail". 673 * itype = The interface/instance type that introduced "signal-name". 674 * signalIdP = Location to store the signal id. 675 * detailP = Location to store the detail quark. 676 * forceDetailQuark = %TRUE forces creation of a #GQuark for the detail. 677 * 678 * Return: Whether the signal name could successfully be parsed and @signal_id_p and @detail_p contain valid return values. 679 */ 680 public static bool parseName(string detailedSignal, GType itype, out uint signalIdP, out GQuark detailP, bool forceDetailQuark) 681 { 682 return g_signal_parse_name(Str.toStringz(detailedSignal), itype, &signalIdP, &detailP, forceDetailQuark) != 0; 683 } 684 685 /** 686 * Queries the signal system for in-depth information about a 687 * specific signal. This function will fill in a user-provided 688 * structure to hold signal-specific information. If an invalid 689 * signal id is passed in, the @signal_id member of the #GSignalQuery 690 * is 0. All members filled into the #GSignalQuery structure should 691 * be considered constant and have to be left untouched. 692 * 693 * Params: 694 * signalId = The signal id of the signal to query information for. 695 * query = A user provided structure that is 696 * filled in with constant values upon success. 697 */ 698 public static void query(uint signalId, out GSignalQuery query) 699 { 700 g_signal_query(signalId, &query); 701 } 702 703 /** 704 * Deletes an emission hook. 705 * 706 * Params: 707 * signalId = the id of the signal 708 * hookId = the id of the emission hook, as returned by 709 * g_signal_add_emission_hook() 710 */ 711 public static void removeEmission(uint signalId, gulong hookId) 712 { 713 g_signal_remove_emission_hook(signalId, hookId); 714 } 715 716 /** 717 * Change the #GSignalCVaMarshaller used for a given signal. This is a 718 * specialised form of the marshaller that can often be used for the 719 * common case of a single connected signal handler and avoids the 720 * overhead of #GValue. Its use is optional. 721 * 722 * Params: 723 * signalId = the signal id 724 * instanceType = the instance type on which to set the marshaller. 725 * vaMarshaller = the marshaller to set. 726 * 727 * Since: 2.32 728 */ 729 public static void setVaMarshaller(uint signalId, GType instanceType, GSignalCVaMarshaller vaMarshaller) 730 { 731 g_signal_set_va_marshaller(signalId, instanceType, vaMarshaller); 732 } 733 734 /** 735 * Stops a signal's current emission. 736 * 737 * This will prevent the default method from running, if the signal was 738 * %G_SIGNAL_RUN_LAST and you connected normally (i.e. without the "after" 739 * flag). 740 * 741 * Prints a warning if used on a signal which isn't being emitted. 742 * 743 * Params: 744 * instanc = the object whose signal handlers you wish to stop. 745 * signalId = the signal identifier, as returned by g_signal_lookup(). 746 * detail = the detail which the signal was emitted with. 747 */ 748 public static void stopEmission(ObjectG instanc, uint signalId, GQuark detail) 749 { 750 g_signal_stop_emission((instanc is null) ? null : instanc.getObjectGStruct(), signalId, detail); 751 } 752 753 /** 754 * Stops a signal's current emission. 755 * 756 * This is just like g_signal_stop_emission() except it will look up the 757 * signal id for you. 758 * 759 * Params: 760 * instanc = the object whose signal handlers you wish to stop. 761 * detailedSignal = a string of the form "signal-name::detail". 762 */ 763 public static void stopEmissionByName(ObjectG instanc, string detailedSignal) 764 { 765 g_signal_stop_emission_by_name((instanc is null) ? null : instanc.getObjectGStruct(), Str.toStringz(detailedSignal)); 766 } 767 768 /** 769 * Creates a new closure which invokes the function found at the offset 770 * @struct_offset in the class structure of the interface or classed type 771 * identified by @itype. 772 * 773 * Params: 774 * itype = the #GType identifier of an interface or classed type 775 * structOffset = the offset of the member function of @itype's class 776 * structure which is to be invoked by the new closure 777 * 778 * Return: a new #GCClosure 779 */ 780 public static Closure typeCclosureNew(GType itype, uint structOffset) 781 { 782 auto p = g_signal_type_cclosure_new(itype, structOffset); 783 784 if(p is null) 785 { 786 return null; 787 } 788 789 return ObjectG.getDObject!(Closure)(cast(GClosure*) p, true); 790 } 791 }