| 1 | /* GObject - GLib Type, Object, Parameter and Signal Library |
| 2 | * Copyright (C) 2000-2001 Red Hat, Inc. |
| 3 | * |
| 4 | * This library is free software; you can redistribute it and/or |
| 5 | * modify it under the terms of the GNU Lesser General Public |
| 6 | * License as published by the Free Software Foundation; either |
| 7 | * version 2.1 of the License, or (at your option) any later version. |
| 8 | * |
| 9 | * This library is distributed in the hope that it will be useful, |
| 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 12 | * Lesser General Public License for more details. |
| 13 | * |
| 14 | * You should have received a copy of the GNU Lesser General |
| 15 | * Public License along with this library; if not, see <http://www.gnu.org/licenses/>. |
| 16 | */ |
| 17 | #ifndef __G_SIGNAL_H__ |
| 18 | #define __G_SIGNAL_H__ |
| 19 | |
| 20 | #if !defined (__GLIB_GOBJECT_H_INSIDE__) && !defined (GOBJECT_COMPILATION) |
| 21 | #error "Only <glib-object.h> can be included directly." |
| 22 | #endif |
| 23 | |
| 24 | #include <gobject/gclosure.h> |
| 25 | #include <gobject/gvalue.h> |
| 26 | #include <gobject/gparam.h> |
| 27 | #include <gobject/gmarshal.h> |
| 28 | |
| 29 | G_BEGIN_DECLS |
| 30 | |
| 31 | /* --- typedefs --- */ |
| 32 | typedef struct _GSignalQuery GSignalQuery; |
| 33 | typedef struct _GSignalInvocationHint GSignalInvocationHint; |
| 34 | /** |
| 35 | * GSignalCMarshaller: |
| 36 | * |
| 37 | * This is the signature of marshaller functions, required to marshall |
| 38 | * arrays of parameter values to signal emissions into C language callback |
| 39 | * invocations. |
| 40 | * |
| 41 | * It is merely an alias to #GClosureMarshal since the #GClosure mechanism |
| 42 | * takes over responsibility of actual function invocation for the signal |
| 43 | * system. |
| 44 | */ |
| 45 | typedef GClosureMarshal GSignalCMarshaller; |
| 46 | /** |
| 47 | * GSignalCVaMarshaller: |
| 48 | * |
| 49 | * This is the signature of va_list marshaller functions, an optional |
| 50 | * marshaller that can be used in some situations to avoid |
| 51 | * marshalling the signal argument into GValues. |
| 52 | */ |
| 53 | typedef GVaClosureMarshal GSignalCVaMarshaller; |
| 54 | /** |
| 55 | * GSignalEmissionHook: |
| 56 | * @ihint: Signal invocation hint, see #GSignalInvocationHint. |
| 57 | * @n_param_values: the number of parameters to the function, including |
| 58 | * the instance on which the signal was emitted. |
| 59 | * @param_values: (array length=n_param_values): the instance on which |
| 60 | * the signal was emitted, followed by the parameters of the emission. |
| 61 | * @data: user data associated with the hook. |
| 62 | * |
| 63 | * A simple function pointer to get invoked when the signal is emitted. |
| 64 | * |
| 65 | * Emission hooks allow you to tie a hook to the signal type, so that it will |
| 66 | * trap all emissions of that signal, from any object. |
| 67 | * |
| 68 | * You may not attach these to signals created with the %G_SIGNAL_NO_HOOKS flag. |
| 69 | * |
| 70 | * Returns: whether it wants to stay connected. If it returns %FALSE, the signal |
| 71 | * hook is disconnected (and destroyed). |
| 72 | */ |
| 73 | typedef gboolean (*GSignalEmissionHook) (GSignalInvocationHint *ihint, |
| 74 | guint n_param_values, |
| 75 | const GValue *param_values, |
| 76 | gpointer data); |
| 77 | /** |
| 78 | * GSignalAccumulator: |
| 79 | * @ihint: Signal invocation hint, see #GSignalInvocationHint. |
| 80 | * @return_accu: Accumulator to collect callback return values in, this |
| 81 | * is the return value of the current signal emission. |
| 82 | * @handler_return: A #GValue holding the return value of the signal handler. |
| 83 | * @data: Callback data that was specified when creating the signal. |
| 84 | * |
| 85 | * The signal accumulator is a special callback function that can be used |
| 86 | * to collect return values of the various callbacks that are called |
| 87 | * during a signal emission. |
| 88 | * |
| 89 | * The signal accumulator is specified at signal creation time, if it is |
| 90 | * left %NULL, no accumulation of callback return values is performed. |
| 91 | * The return value of signal emissions is then the value returned by the |
| 92 | * last callback. |
| 93 | * |
| 94 | * Returns: The accumulator function returns whether the signal emission |
| 95 | * should be aborted. Returning %TRUE will continue with |
| 96 | * the signal emission. Returning %FALSE will abort the current emission. |
| 97 | * Since 2.62, returning %FALSE will skip to the CLEANUP stage. In this case, |
| 98 | * emission will occur as normal in the CLEANUP stage and the handler's |
| 99 | * return value will be accumulated. |
| 100 | */ |
| 101 | typedef gboolean (*GSignalAccumulator) (GSignalInvocationHint *ihint, |
| 102 | GValue *return_accu, |
| 103 | const GValue *handler_return, |
| 104 | gpointer data); |
| 105 | |
| 106 | |
| 107 | /* --- run, match and connect types --- */ |
| 108 | /** |
| 109 | * GSignalFlags: |
| 110 | * @G_SIGNAL_RUN_FIRST: Invoke the object method handler in the first emission stage. |
| 111 | * @G_SIGNAL_RUN_LAST: Invoke the object method handler in the third emission stage. |
| 112 | * @G_SIGNAL_RUN_CLEANUP: Invoke the object method handler in the last emission stage. |
| 113 | * @G_SIGNAL_NO_RECURSE: Signals being emitted for an object while currently being in |
| 114 | * emission for this very object will not be emitted recursively, |
| 115 | * but instead cause the first emission to be restarted. |
| 116 | * @G_SIGNAL_DETAILED: This signal supports "::detail" appendices to the signal name |
| 117 | * upon handler connections and emissions. |
| 118 | * @G_SIGNAL_ACTION: Action signals are signals that may freely be emitted on alive |
| 119 | * objects from user code via g_signal_emit() and friends, without |
| 120 | * the need of being embedded into extra code that performs pre or |
| 121 | * post emission adjustments on the object. They can also be thought |
| 122 | * of as object methods which can be called generically by |
| 123 | * third-party code. |
| 124 | * @G_SIGNAL_NO_HOOKS: No emissions hooks are supported for this signal. |
| 125 | * @G_SIGNAL_MUST_COLLECT: Varargs signal emission will always collect the |
| 126 | * arguments, even if there are no signal handlers connected. Since 2.30. |
| 127 | * @G_SIGNAL_DEPRECATED: The signal is deprecated and will be removed |
| 128 | * in a future version. A warning will be generated if it is connected while |
| 129 | * running with G_ENABLE_DIAGNOSTIC=1. Since 2.32. |
| 130 | * @G_SIGNAL_ACCUMULATOR_FIRST_RUN: Only used in #GSignalAccumulator accumulator |
| 131 | * functions for the #GSignalInvocationHint::run_type field to mark the first |
| 132 | * call to the accumulator function for a signal emission. Since 2.68. |
| 133 | * |
| 134 | * The signal flags are used to specify a signal's behaviour. |
| 135 | */ |
| 136 | typedef enum |
| 137 | { |
| 138 | G_SIGNAL_RUN_FIRST = 1 << 0, |
| 139 | G_SIGNAL_RUN_LAST = 1 << 1, |
| 140 | G_SIGNAL_RUN_CLEANUP = 1 << 2, |
| 141 | G_SIGNAL_NO_RECURSE = 1 << 3, |
| 142 | G_SIGNAL_DETAILED = 1 << 4, |
| 143 | G_SIGNAL_ACTION = 1 << 5, |
| 144 | G_SIGNAL_NO_HOOKS = 1 << 6, |
| 145 | G_SIGNAL_MUST_COLLECT = 1 << 7, |
| 146 | G_SIGNAL_DEPRECATED = 1 << 8, |
| 147 | /* normal signal flags until 1 << 16 */ |
| 148 | G_SIGNAL_ACCUMULATOR_FIRST_RUN = 1 << 17, |
| 149 | } GSignalFlags; |
| 150 | /** |
| 151 | * G_SIGNAL_FLAGS_MASK: |
| 152 | * |
| 153 | * A mask for all #GSignalFlags bits. |
| 154 | */ |
| 155 | #define G_SIGNAL_FLAGS_MASK 0x1ff |
| 156 | /** |
| 157 | * GConnectFlags: |
| 158 | * @G_CONNECT_AFTER: whether the handler should be called before or after the |
| 159 | * default handler of the signal. |
| 160 | * @G_CONNECT_SWAPPED: whether the instance and data should be swapped when |
| 161 | * calling the handler; see g_signal_connect_swapped() for an example. |
| 162 | * |
| 163 | * The connection flags are used to specify the behaviour of a signal's |
| 164 | * connection. |
| 165 | */ |
| 166 | typedef enum |
| 167 | { |
| 168 | G_CONNECT_AFTER = 1 << 0, |
| 169 | G_CONNECT_SWAPPED = 1 << 1 |
| 170 | } GConnectFlags; |
| 171 | /** |
| 172 | * GSignalMatchType: |
| 173 | * @G_SIGNAL_MATCH_ID: The signal id must be equal. |
| 174 | * @G_SIGNAL_MATCH_DETAIL: The signal detail must be equal. |
| 175 | * @G_SIGNAL_MATCH_CLOSURE: The closure must be the same. |
| 176 | * @G_SIGNAL_MATCH_FUNC: The C closure callback must be the same. |
| 177 | * @G_SIGNAL_MATCH_DATA: The closure data must be the same. |
| 178 | * @G_SIGNAL_MATCH_UNBLOCKED: Only unblocked signals may be matched. |
| 179 | * |
| 180 | * The match types specify what g_signal_handlers_block_matched(), |
| 181 | * g_signal_handlers_unblock_matched() and g_signal_handlers_disconnect_matched() |
| 182 | * match signals by. |
| 183 | */ |
| 184 | typedef enum |
| 185 | { |
| 186 | G_SIGNAL_MATCH_ID = 1 << 0, |
| 187 | G_SIGNAL_MATCH_DETAIL = 1 << 1, |
| 188 | G_SIGNAL_MATCH_CLOSURE = 1 << 2, |
| 189 | G_SIGNAL_MATCH_FUNC = 1 << 3, |
| 190 | G_SIGNAL_MATCH_DATA = 1 << 4, |
| 191 | G_SIGNAL_MATCH_UNBLOCKED = 1 << 5 |
| 192 | } GSignalMatchType; |
| 193 | /** |
| 194 | * G_SIGNAL_MATCH_MASK: |
| 195 | * |
| 196 | * A mask for all #GSignalMatchType bits. |
| 197 | */ |
| 198 | #define G_SIGNAL_MATCH_MASK 0x3f |
| 199 | /** |
| 200 | * G_SIGNAL_TYPE_STATIC_SCOPE: |
| 201 | * |
| 202 | * This macro flags signal argument types for which the signal system may |
| 203 | * assume that instances thereof remain persistent across all signal emissions |
| 204 | * they are used in. This is only useful for non ref-counted, value-copy types. |
| 205 | * |
| 206 | * To flag a signal argument in this way, add `| G_SIGNAL_TYPE_STATIC_SCOPE` |
| 207 | * to the corresponding argument of g_signal_new(). |
| 208 | * |[ |
| 209 | * g_signal_new ("size_request", |
| 210 | * G_TYPE_FROM_CLASS (gobject_class), |
| 211 | * G_SIGNAL_RUN_FIRST, |
| 212 | * G_STRUCT_OFFSET (GtkWidgetClass, size_request), |
| 213 | * NULL, NULL, |
| 214 | * _gtk_marshal_VOID__BOXED, |
| 215 | * G_TYPE_NONE, 1, |
| 216 | * GTK_TYPE_REQUISITION | G_SIGNAL_TYPE_STATIC_SCOPE); |
| 217 | * ]| |
| 218 | */ |
| 219 | #define G_SIGNAL_TYPE_STATIC_SCOPE (G_TYPE_FLAG_RESERVED_ID_BIT) |
| 220 | |
| 221 | |
| 222 | /* --- signal information --- */ |
| 223 | /** |
| 224 | * GSignalInvocationHint: |
| 225 | * @signal_id: The signal id of the signal invoking the callback |
| 226 | * @detail: The detail passed on for this emission |
| 227 | * @run_type: The stage the signal emission is currently in, this |
| 228 | * field will contain one of %G_SIGNAL_RUN_FIRST, |
| 229 | * %G_SIGNAL_RUN_LAST or %G_SIGNAL_RUN_CLEANUP and %G_SIGNAL_ACCUMULATOR_FIRST_RUN. |
| 230 | * %G_SIGNAL_ACCUMULATOR_FIRST_RUN is only set for the first run of the accumulator |
| 231 | * function for a signal emission. |
| 232 | * |
| 233 | * The #GSignalInvocationHint structure is used to pass on additional information |
| 234 | * to callbacks during a signal emission. |
| 235 | */ |
| 236 | struct _GSignalInvocationHint |
| 237 | { |
| 238 | guint signal_id; |
| 239 | GQuark detail; |
| 240 | GSignalFlags run_type; |
| 241 | }; |
| 242 | /** |
| 243 | * GSignalQuery: |
| 244 | * @signal_id: The signal id of the signal being queried, or 0 if the |
| 245 | * signal to be queried was unknown. |
| 246 | * @signal_name: The signal name. |
| 247 | * @itype: The interface/instance type that this signal can be emitted for. |
| 248 | * @signal_flags: The signal flags as passed in to g_signal_new(). |
| 249 | * @return_type: The return type for user callbacks. |
| 250 | * @n_params: The number of parameters that user callbacks take. |
| 251 | * @param_types: (array length=n_params): The individual parameter types for |
| 252 | * user callbacks, note that the effective callback signature is: |
| 253 | * |[<!-- language="C" --> |
| 254 | * @return_type callback (#gpointer data1, |
| 255 | * [param_types param_names,] |
| 256 | * gpointer data2); |
| 257 | * ]| |
| 258 | * |
| 259 | * A structure holding in-depth information for a specific signal. |
| 260 | * |
| 261 | * See also: g_signal_query() |
| 262 | */ |
| 263 | struct _GSignalQuery |
| 264 | { |
| 265 | guint signal_id; |
| 266 | const gchar *signal_name; |
| 267 | GType itype; |
| 268 | GSignalFlags signal_flags; |
| 269 | GType return_type; /* mangled with G_SIGNAL_TYPE_STATIC_SCOPE flag */ |
| 270 | guint n_params; |
| 271 | const GType *param_types; /* mangled with G_SIGNAL_TYPE_STATIC_SCOPE flag */ |
| 272 | }; |
| 273 | |
| 274 | |
| 275 | /* --- signals --- */ |
| 276 | GLIB_AVAILABLE_IN_ALL |
| 277 | guint g_signal_newv (const gchar *signal_name, |
| 278 | GType itype, |
| 279 | GSignalFlags signal_flags, |
| 280 | GClosure *class_closure, |
| 281 | GSignalAccumulator accumulator, |
| 282 | gpointer accu_data, |
| 283 | GSignalCMarshaller c_marshaller, |
| 284 | GType return_type, |
| 285 | guint n_params, |
| 286 | GType *param_types); |
| 287 | GLIB_AVAILABLE_IN_ALL |
| 288 | guint g_signal_new_valist (const gchar *signal_name, |
| 289 | GType itype, |
| 290 | GSignalFlags signal_flags, |
| 291 | GClosure *class_closure, |
| 292 | GSignalAccumulator accumulator, |
| 293 | gpointer accu_data, |
| 294 | GSignalCMarshaller c_marshaller, |
| 295 | GType return_type, |
| 296 | guint n_params, |
| 297 | va_list args); |
| 298 | GLIB_AVAILABLE_IN_ALL |
| 299 | guint g_signal_new (const gchar *signal_name, |
| 300 | GType itype, |
| 301 | GSignalFlags signal_flags, |
| 302 | guint class_offset, |
| 303 | GSignalAccumulator accumulator, |
| 304 | gpointer accu_data, |
| 305 | GSignalCMarshaller c_marshaller, |
| 306 | GType return_type, |
| 307 | guint n_params, |
| 308 | ...); |
| 309 | GLIB_AVAILABLE_IN_ALL |
| 310 | guint g_signal_new_class_handler (const gchar *signal_name, |
| 311 | GType itype, |
| 312 | GSignalFlags signal_flags, |
| 313 | GCallback class_handler, |
| 314 | GSignalAccumulator accumulator, |
| 315 | gpointer accu_data, |
| 316 | GSignalCMarshaller c_marshaller, |
| 317 | GType return_type, |
| 318 | guint n_params, |
| 319 | ...); |
| 320 | GLIB_AVAILABLE_IN_ALL |
| 321 | void g_signal_set_va_marshaller (guint signal_id, |
| 322 | GType instance_type, |
| 323 | GSignalCVaMarshaller va_marshaller); |
| 324 | |
| 325 | GLIB_AVAILABLE_IN_ALL |
| 326 | void g_signal_emitv (const GValue *instance_and_params, |
| 327 | guint signal_id, |
| 328 | GQuark detail, |
| 329 | GValue *return_value); |
| 330 | GLIB_AVAILABLE_IN_ALL |
| 331 | void g_signal_emit_valist (gpointer instance, |
| 332 | guint signal_id, |
| 333 | GQuark detail, |
| 334 | va_list var_args); |
| 335 | GLIB_AVAILABLE_IN_ALL |
| 336 | void g_signal_emit (gpointer instance, |
| 337 | guint signal_id, |
| 338 | GQuark detail, |
| 339 | ...); |
| 340 | GLIB_AVAILABLE_IN_ALL |
| 341 | void g_signal_emit_by_name (gpointer instance, |
| 342 | const gchar *detailed_signal, |
| 343 | ...); |
| 344 | GLIB_AVAILABLE_IN_ALL |
| 345 | guint g_signal_lookup (const gchar *name, |
| 346 | GType itype); |
| 347 | GLIB_AVAILABLE_IN_ALL |
| 348 | const gchar * g_signal_name (guint signal_id); |
| 349 | GLIB_AVAILABLE_IN_ALL |
| 350 | void g_signal_query (guint signal_id, |
| 351 | GSignalQuery *query); |
| 352 | GLIB_AVAILABLE_IN_ALL |
| 353 | guint* g_signal_list_ids (GType itype, |
| 354 | guint *n_ids); |
| 355 | GLIB_AVAILABLE_IN_2_66 |
| 356 | gboolean g_signal_is_valid_name (const gchar *name); |
| 357 | GLIB_AVAILABLE_IN_ALL |
| 358 | gboolean g_signal_parse_name (const gchar *detailed_signal, |
| 359 | GType itype, |
| 360 | guint *signal_id_p, |
| 361 | GQuark *detail_p, |
| 362 | gboolean force_detail_quark); |
| 363 | GLIB_AVAILABLE_IN_ALL |
| 364 | GSignalInvocationHint* g_signal_get_invocation_hint (gpointer instance); |
| 365 | |
| 366 | |
| 367 | /* --- signal emissions --- */ |
| 368 | GLIB_AVAILABLE_IN_ALL |
| 369 | void g_signal_stop_emission (gpointer instance, |
| 370 | guint signal_id, |
| 371 | GQuark detail); |
| 372 | GLIB_AVAILABLE_IN_ALL |
| 373 | void g_signal_stop_emission_by_name (gpointer instance, |
| 374 | const gchar *detailed_signal); |
| 375 | GLIB_AVAILABLE_IN_ALL |
| 376 | gulong g_signal_add_emission_hook (guint signal_id, |
| 377 | GQuark detail, |
| 378 | GSignalEmissionHook hook_func, |
| 379 | gpointer hook_data, |
| 380 | GDestroyNotify data_destroy); |
| 381 | GLIB_AVAILABLE_IN_ALL |
| 382 | void g_signal_remove_emission_hook (guint signal_id, |
| 383 | gulong hook_id); |
| 384 | |
| 385 | |
| 386 | /* --- signal handlers --- */ |
| 387 | GLIB_AVAILABLE_IN_ALL |
| 388 | gboolean g_signal_has_handler_pending (gpointer instance, |
| 389 | guint signal_id, |
| 390 | GQuark detail, |
| 391 | gboolean may_be_blocked); |
| 392 | GLIB_AVAILABLE_IN_ALL |
| 393 | gulong g_signal_connect_closure_by_id (gpointer instance, |
| 394 | guint signal_id, |
| 395 | GQuark detail, |
| 396 | GClosure *closure, |
| 397 | gboolean after); |
| 398 | GLIB_AVAILABLE_IN_ALL |
| 399 | gulong g_signal_connect_closure (gpointer instance, |
| 400 | const gchar *detailed_signal, |
| 401 | GClosure *closure, |
| 402 | gboolean after); |
| 403 | GLIB_AVAILABLE_IN_ALL |
| 404 | gulong g_signal_connect_data (gpointer instance, |
| 405 | const gchar *detailed_signal, |
| 406 | GCallback c_handler, |
| 407 | gpointer data, |
| 408 | GClosureNotify destroy_data, |
| 409 | GConnectFlags connect_flags); |
| 410 | GLIB_AVAILABLE_IN_ALL |
| 411 | void g_signal_handler_block (gpointer instance, |
| 412 | gulong handler_id); |
| 413 | GLIB_AVAILABLE_IN_ALL |
| 414 | void g_signal_handler_unblock (gpointer instance, |
| 415 | gulong handler_id); |
| 416 | GLIB_AVAILABLE_IN_ALL |
| 417 | void g_signal_handler_disconnect (gpointer instance, |
| 418 | gulong handler_id); |
| 419 | GLIB_AVAILABLE_IN_ALL |
| 420 | gboolean g_signal_handler_is_connected (gpointer instance, |
| 421 | gulong handler_id); |
| 422 | GLIB_AVAILABLE_IN_ALL |
| 423 | gulong g_signal_handler_find (gpointer instance, |
| 424 | GSignalMatchType mask, |
| 425 | guint signal_id, |
| 426 | GQuark detail, |
| 427 | GClosure *closure, |
| 428 | gpointer func, |
| 429 | gpointer data); |
| 430 | GLIB_AVAILABLE_IN_ALL |
| 431 | guint g_signal_handlers_block_matched (gpointer instance, |
| 432 | GSignalMatchType mask, |
| 433 | guint signal_id, |
| 434 | GQuark detail, |
| 435 | GClosure *closure, |
| 436 | gpointer func, |
| 437 | gpointer data); |
| 438 | GLIB_AVAILABLE_IN_ALL |
| 439 | guint g_signal_handlers_unblock_matched (gpointer instance, |
| 440 | GSignalMatchType mask, |
| 441 | guint signal_id, |
| 442 | GQuark detail, |
| 443 | GClosure *closure, |
| 444 | gpointer func, |
| 445 | gpointer data); |
| 446 | GLIB_AVAILABLE_IN_ALL |
| 447 | guint g_signal_handlers_disconnect_matched (gpointer instance, |
| 448 | GSignalMatchType mask, |
| 449 | guint signal_id, |
| 450 | GQuark detail, |
| 451 | GClosure *closure, |
| 452 | gpointer func, |
| 453 | gpointer data); |
| 454 | |
| 455 | GLIB_AVAILABLE_IN_2_62 |
| 456 | void g_clear_signal_handler (gulong *handler_id_ptr, |
| 457 | gpointer instance); |
| 458 | |
| 459 | #define g_clear_signal_handler(handler_id_ptr, instance) \ |
| 460 | G_STMT_START { \ |
| 461 | gpointer const _instance = (instance); \ |
| 462 | gulong *const _handler_id_ptr = (handler_id_ptr); \ |
| 463 | const gulong _handler_id = *_handler_id_ptr; \ |
| 464 | \ |
| 465 | if (_handler_id > 0) \ |
| 466 | { \ |
| 467 | *_handler_id_ptr = 0; \ |
| 468 | g_signal_handler_disconnect (_instance, _handler_id); \ |
| 469 | } \ |
| 470 | } G_STMT_END \ |
| 471 | GLIB_AVAILABLE_MACRO_IN_2_62 |
| 472 | |
| 473 | /* --- overriding and chaining --- */ |
| 474 | GLIB_AVAILABLE_IN_ALL |
| 475 | void g_signal_override_class_closure (guint signal_id, |
| 476 | GType instance_type, |
| 477 | GClosure *class_closure); |
| 478 | GLIB_AVAILABLE_IN_ALL |
| 479 | void g_signal_override_class_handler (const gchar *signal_name, |
| 480 | GType instance_type, |
| 481 | GCallback class_handler); |
| 482 | GLIB_AVAILABLE_IN_ALL |
| 483 | void g_signal_chain_from_overridden (const GValue *instance_and_params, |
| 484 | GValue *return_value); |
| 485 | GLIB_AVAILABLE_IN_ALL |
| 486 | void g_signal_chain_from_overridden_handler (gpointer instance, |
| 487 | ...); |
| 488 | |
| 489 | |
| 490 | /* --- convenience --- */ |
| 491 | /** |
| 492 | * g_signal_connect: |
| 493 | * @instance: the instance to connect to. |
| 494 | * @detailed_signal: a string of the form "signal-name::detail". |
| 495 | * @c_handler: the #GCallback to connect. |
| 496 | * @data: data to pass to @c_handler calls. |
| 497 | * |
| 498 | * Connects a #GCallback function to a signal for a particular object. |
| 499 | * |
| 500 | * The handler will be called synchronously, before the default handler of the signal. g_signal_emit() will not return control until all handlers are called. |
| 501 | * |
| 502 | * See [memory management of signal handlers][signal-memory-management] for |
| 503 | * details on how to handle the return value and memory management of @data. |
| 504 | * |
| 505 | * Returns: the handler ID, of type #gulong (always greater than 0 for successful connections) |
| 506 | */ |
| 507 | #define g_signal_connect(instance, detailed_signal, c_handler, data) \ |
| 508 | g_signal_connect_data ((instance), (detailed_signal), (c_handler), (data), NULL, (GConnectFlags) 0) |
| 509 | /** |
| 510 | * g_signal_connect_after: |
| 511 | * @instance: the instance to connect to. |
| 512 | * @detailed_signal: a string of the form "signal-name::detail". |
| 513 | * @c_handler: the #GCallback to connect. |
| 514 | * @data: data to pass to @c_handler calls. |
| 515 | * |
| 516 | * Connects a #GCallback function to a signal for a particular object. |
| 517 | * |
| 518 | * The handler will be called synchronously, after the default handler of the signal. |
| 519 | * |
| 520 | * Returns: the handler ID, of type #gulong (always greater than 0 for successful connections) |
| 521 | */ |
| 522 | #define g_signal_connect_after(instance, detailed_signal, c_handler, data) \ |
| 523 | g_signal_connect_data ((instance), (detailed_signal), (c_handler), (data), NULL, G_CONNECT_AFTER) |
| 524 | /** |
| 525 | * g_signal_connect_swapped: |
| 526 | * @instance: the instance to connect to. |
| 527 | * @detailed_signal: a string of the form "signal-name::detail". |
| 528 | * @c_handler: the #GCallback to connect. |
| 529 | * @data: data to pass to @c_handler calls. |
| 530 | * |
| 531 | * Connects a #GCallback function to a signal for a particular object. |
| 532 | * |
| 533 | * The instance on which the signal is emitted and @data will be swapped when |
| 534 | * calling the handler. This is useful when calling pre-existing functions to |
| 535 | * operate purely on the @data, rather than the @instance: swapping the |
| 536 | * parameters avoids the need to write a wrapper function. |
| 537 | * |
| 538 | * For example, this allows the shorter code: |
| 539 | * |[<!-- language="C" --> |
| 540 | * g_signal_connect_swapped (button, "clicked", |
| 541 | * (GCallback) gtk_widget_hide, other_widget); |
| 542 | * ]| |
| 543 | * |
| 544 | * Rather than the cumbersome: |
| 545 | * |[<!-- language="C" --> |
| 546 | * static void |
| 547 | * button_clicked_cb (GtkButton *button, GtkWidget *other_widget) |
| 548 | * { |
| 549 | * gtk_widget_hide (other_widget); |
| 550 | * } |
| 551 | * |
| 552 | * ... |
| 553 | * |
| 554 | * g_signal_connect (button, "clicked", |
| 555 | * (GCallback) button_clicked_cb, other_widget); |
| 556 | * ]| |
| 557 | * |
| 558 | * Returns: the handler ID, of type #gulong (always greater than 0 for successful connections) |
| 559 | */ |
| 560 | #define g_signal_connect_swapped(instance, detailed_signal, c_handler, data) \ |
| 561 | g_signal_connect_data ((instance), (detailed_signal), (c_handler), (data), NULL, G_CONNECT_SWAPPED) |
| 562 | /** |
| 563 | * g_signal_handlers_disconnect_by_func: |
| 564 | * @instance: The instance to remove handlers from. |
| 565 | * @func: The C closure callback of the handlers (useless for non-C closures). |
| 566 | * @data: The closure data of the handlers' closures. |
| 567 | * |
| 568 | * Disconnects all handlers on an instance that match @func and @data. |
| 569 | * |
| 570 | * Returns: The number of handlers that matched. |
| 571 | */ |
| 572 | #define g_signal_handlers_disconnect_by_func(instance, func, data) \ |
| 573 | g_signal_handlers_disconnect_matched ((instance), \ |
| 574 | (GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), \ |
| 575 | 0, 0, NULL, (func), (data)) |
| 576 | |
| 577 | /** |
| 578 | * g_signal_handlers_disconnect_by_data: |
| 579 | * @instance: The instance to remove handlers from |
| 580 | * @data: the closure data of the handlers' closures |
| 581 | * |
| 582 | * Disconnects all handlers on an instance that match @data. |
| 583 | * |
| 584 | * Returns: The number of handlers that matched. |
| 585 | * |
| 586 | * Since: 2.32 |
| 587 | */ |
| 588 | #define g_signal_handlers_disconnect_by_data(instance, data) \ |
| 589 | g_signal_handlers_disconnect_matched ((instance), G_SIGNAL_MATCH_DATA, 0, 0, NULL, NULL, (data)) |
| 590 | |
| 591 | /** |
| 592 | * g_signal_handlers_block_by_func: |
| 593 | * @instance: The instance to block handlers from. |
| 594 | * @func: The C closure callback of the handlers (useless for non-C closures). |
| 595 | * @data: The closure data of the handlers' closures. |
| 596 | * |
| 597 | * Blocks all handlers on an instance that match @func and @data. |
| 598 | * |
| 599 | * Returns: The number of handlers that matched. |
| 600 | */ |
| 601 | #define g_signal_handlers_block_by_func(instance, func, data) \ |
| 602 | g_signal_handlers_block_matched ((instance), \ |
| 603 | (GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), \ |
| 604 | 0, 0, NULL, (func), (data)) |
| 605 | /** |
| 606 | * g_signal_handlers_unblock_by_func: |
| 607 | * @instance: The instance to unblock handlers from. |
| 608 | * @func: The C closure callback of the handlers (useless for non-C closures). |
| 609 | * @data: The closure data of the handlers' closures. |
| 610 | * |
| 611 | * Unblocks all handlers on an instance that match @func and @data. |
| 612 | * |
| 613 | * Returns: The number of handlers that matched. |
| 614 | */ |
| 615 | #define g_signal_handlers_unblock_by_func(instance, func, data) \ |
| 616 | g_signal_handlers_unblock_matched ((instance), \ |
| 617 | (GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), \ |
| 618 | 0, 0, NULL, (func), (data)) |
| 619 | |
| 620 | |
| 621 | GLIB_AVAILABLE_IN_ALL |
| 622 | gboolean g_signal_accumulator_true_handled (GSignalInvocationHint *ihint, |
| 623 | GValue *return_accu, |
| 624 | const GValue *handler_return, |
| 625 | gpointer dummy); |
| 626 | |
| 627 | GLIB_AVAILABLE_IN_ALL |
| 628 | gboolean g_signal_accumulator_first_wins (GSignalInvocationHint *ihint, |
| 629 | GValue *return_accu, |
| 630 | const GValue *handler_return, |
| 631 | gpointer dummy); |
| 632 | |
| 633 | /*< private >*/ |
| 634 | GLIB_AVAILABLE_IN_ALL |
| 635 | void g_signal_handlers_destroy (gpointer instance); |
| 636 | void _g_signals_destroy (GType itype); |
| 637 | |
| 638 | G_END_DECLS |
| 639 | |
| 640 | #endif /* __G_SIGNAL_H__ */ |
| 641 | |