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