|
|
|||
File indexing completed on 2025-12-16 10:17:40
0001 /* GObject - GLib Type, Object, Parameter and Signal Library 0002 * Copyright (C) 2000-2001 Red Hat, Inc. 0003 * 0004 * SPDX-License-Identifier: LGPL-2.1-or-later 0005 * 0006 * This library is free software; you can redistribute it and/or 0007 * modify it under the terms of the GNU Lesser General Public 0008 * License as published by the Free Software Foundation; either 0009 * version 2.1 of the License, or (at your option) any later version. 0010 * 0011 * This library is distributed in the hope that it will be useful, 0012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 0013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 0014 * Lesser General Public License for more details. 0015 * 0016 * You should have received a copy of the GNU Lesser General 0017 * Public License along with this library; if not, see <http://www.gnu.org/licenses/>. 0018 */ 0019 #ifndef __G_SIGNAL_H__ 0020 #define __G_SIGNAL_H__ 0021 0022 #if !defined (__GLIB_GOBJECT_H_INSIDE__) && !defined (GOBJECT_COMPILATION) 0023 #error "Only <glib-object.h> can be included directly." 0024 #endif 0025 0026 #include <gobject/gclosure.h> 0027 #include <gobject/gvalue.h> 0028 #include <gobject/gparam.h> 0029 #include <gobject/gmarshal.h> 0030 0031 G_BEGIN_DECLS 0032 0033 /* --- typedefs --- */ 0034 typedef struct _GSignalQuery GSignalQuery; 0035 typedef struct _GSignalInvocationHint GSignalInvocationHint; 0036 /** 0037 * GSignalCMarshaller: 0038 * 0039 * This is the signature of marshaller functions, required to marshall 0040 * arrays of parameter values to signal emissions into C language callback 0041 * invocations. 0042 * 0043 * It is merely an alias to #GClosureMarshal since the #GClosure mechanism 0044 * takes over responsibility of actual function invocation for the signal 0045 * system. 0046 */ 0047 typedef GClosureMarshal GSignalCMarshaller; 0048 /** 0049 * GSignalCVaMarshaller: 0050 * 0051 * This is the signature of va_list marshaller functions, an optional 0052 * marshaller that can be used in some situations to avoid 0053 * marshalling the signal argument into GValues. 0054 */ 0055 typedef GVaClosureMarshal GSignalCVaMarshaller; 0056 /** 0057 * GSignalEmissionHook: 0058 * @ihint: Signal invocation hint, see #GSignalInvocationHint. 0059 * @n_param_values: the number of parameters to the function, including 0060 * the instance on which the signal was emitted. 0061 * @param_values: (array length=n_param_values): the instance on which 0062 * the signal was emitted, followed by the parameters of the emission. 0063 * @data: user data associated with the hook. 0064 * 0065 * A simple function pointer to get invoked when the signal is emitted. 0066 * 0067 * Emission hooks allow you to tie a hook to the signal type, so that it will 0068 * trap all emissions of that signal, from any object. 0069 * 0070 * You may not attach these to signals created with the %G_SIGNAL_NO_HOOKS flag. 0071 * 0072 * Returns: whether it wants to stay connected. If it returns %FALSE, the signal 0073 * hook is disconnected (and destroyed). 0074 */ 0075 typedef gboolean (*GSignalEmissionHook) (GSignalInvocationHint *ihint, 0076 guint n_param_values, 0077 const GValue *param_values, 0078 gpointer data); 0079 /** 0080 * GSignalAccumulator: 0081 * @ihint: Signal invocation hint, see #GSignalInvocationHint. 0082 * @return_accu: Accumulator to collect callback return values in, this 0083 * is the return value of the current signal emission. 0084 * @handler_return: A #GValue holding the return value of the signal handler. 0085 * @data: Callback data that was specified when creating the signal. 0086 * 0087 * The signal accumulator is a special callback function that can be used 0088 * to collect return values of the various callbacks that are called 0089 * during a signal emission. 0090 * 0091 * The signal accumulator is specified at signal creation time, if it is 0092 * left %NULL, no accumulation of callback return values is performed. 0093 * The return value of signal emissions is then the value returned by the 0094 * last callback. 0095 * 0096 * Returns: The accumulator function returns whether the signal emission 0097 * should be aborted. Returning %TRUE will continue with 0098 * the signal emission. Returning %FALSE will abort the current emission. 0099 * Since 2.62, returning %FALSE will skip to the CLEANUP stage. In this case, 0100 * emission will occur as normal in the CLEANUP stage and the handler's 0101 * return value will be accumulated. 0102 */ 0103 typedef gboolean (*GSignalAccumulator) (GSignalInvocationHint *ihint, 0104 GValue *return_accu, 0105 const GValue *handler_return, 0106 gpointer data); 0107 0108 0109 /* --- run, match and connect types --- */ 0110 /** 0111 * GSignalFlags: 0112 * @G_SIGNAL_RUN_FIRST: Invoke the object method handler in the first emission stage. 0113 * @G_SIGNAL_RUN_LAST: Invoke the object method handler in the third emission stage. 0114 * @G_SIGNAL_RUN_CLEANUP: Invoke the object method handler in the last emission stage. 0115 * @G_SIGNAL_NO_RECURSE: Signals being emitted for an object while currently being in 0116 * emission for this very object will not be emitted recursively, 0117 * but instead cause the first emission to be restarted. 0118 * @G_SIGNAL_DETAILED: This signal supports "::detail" appendices to the signal name 0119 * upon handler connections and emissions. 0120 * @G_SIGNAL_ACTION: Action signals are signals that may freely be emitted on alive 0121 * objects from user code via g_signal_emit() and friends, without 0122 * the need of being embedded into extra code that performs pre or 0123 * post emission adjustments on the object. They can also be thought 0124 * of as object methods which can be called generically by 0125 * third-party code. 0126 * @G_SIGNAL_NO_HOOKS: No emissions hooks are supported for this signal. 0127 * @G_SIGNAL_MUST_COLLECT: Varargs signal emission will always collect the 0128 * arguments, even if there are no signal handlers connected. Since 2.30. 0129 * @G_SIGNAL_DEPRECATED: The signal is deprecated and will be removed 0130 * in a future version. A warning will be generated if it is connected while 0131 * running with G_ENABLE_DIAGNOSTIC=1. Since 2.32. 0132 * @G_SIGNAL_ACCUMULATOR_FIRST_RUN: Only used in #GSignalAccumulator accumulator 0133 * functions for the #GSignalInvocationHint::run_type field to mark the first 0134 * call to the accumulator function for a signal emission. Since 2.68. 0135 * 0136 * The signal flags are used to specify a signal's behaviour. 0137 */ 0138 typedef enum 0139 { 0140 G_SIGNAL_RUN_FIRST = 1 << 0, 0141 G_SIGNAL_RUN_LAST = 1 << 1, 0142 G_SIGNAL_RUN_CLEANUP = 1 << 2, 0143 G_SIGNAL_NO_RECURSE = 1 << 3, 0144 G_SIGNAL_DETAILED = 1 << 4, 0145 G_SIGNAL_ACTION = 1 << 5, 0146 G_SIGNAL_NO_HOOKS = 1 << 6, 0147 G_SIGNAL_MUST_COLLECT = 1 << 7, 0148 G_SIGNAL_DEPRECATED = 1 << 8, 0149 /* normal signal flags until 1 << 16 */ 0150 G_SIGNAL_ACCUMULATOR_FIRST_RUN = 1 << 17, 0151 } GSignalFlags; 0152 /** 0153 * G_SIGNAL_FLAGS_MASK: 0154 * 0155 * A mask for all #GSignalFlags bits. 0156 */ 0157 #define G_SIGNAL_FLAGS_MASK 0x1ff 0158 /** 0159 * GConnectFlags: 0160 * @G_CONNECT_DEFAULT: Default behaviour (no special flags). Since: 2.74 0161 * @G_CONNECT_AFTER: If set, the handler should be called after the 0162 * default handler of the signal. Normally, the handler is called before 0163 * the default handler. 0164 * @G_CONNECT_SWAPPED: If set, the instance and data should be swapped when 0165 * calling the handler; see g_signal_connect_swapped() for an example. 0166 * 0167 * The connection flags are used to specify the behaviour of a signal's 0168 * connection. 0169 */ 0170 typedef enum 0171 { 0172 G_CONNECT_DEFAULT GOBJECT_AVAILABLE_ENUMERATOR_IN_2_74 = 0, 0173 G_CONNECT_AFTER = 1 << 0, 0174 G_CONNECT_SWAPPED = 1 << 1 0175 } GConnectFlags; 0176 /** 0177 * GSignalMatchType: 0178 * @G_SIGNAL_MATCH_ID: The signal id must be equal. 0179 * @G_SIGNAL_MATCH_DETAIL: The signal detail must be equal. 0180 * @G_SIGNAL_MATCH_CLOSURE: The closure must be the same. 0181 * @G_SIGNAL_MATCH_FUNC: The C closure callback must be the same. 0182 * @G_SIGNAL_MATCH_DATA: The closure data must be the same. 0183 * @G_SIGNAL_MATCH_UNBLOCKED: Only unblocked signals may be matched. 0184 * 0185 * The match types specify what g_signal_handlers_block_matched(), 0186 * g_signal_handlers_unblock_matched() and g_signal_handlers_disconnect_matched() 0187 * match signals by. 0188 */ 0189 typedef enum 0190 { 0191 G_SIGNAL_MATCH_ID = 1 << 0, 0192 G_SIGNAL_MATCH_DETAIL = 1 << 1, 0193 G_SIGNAL_MATCH_CLOSURE = 1 << 2, 0194 G_SIGNAL_MATCH_FUNC = 1 << 3, 0195 G_SIGNAL_MATCH_DATA = 1 << 4, 0196 G_SIGNAL_MATCH_UNBLOCKED = 1 << 5 0197 } GSignalMatchType; 0198 /** 0199 * G_SIGNAL_MATCH_MASK: 0200 * 0201 * A mask for all #GSignalMatchType bits. 0202 */ 0203 #define G_SIGNAL_MATCH_MASK 0x3f 0204 /** 0205 * G_SIGNAL_TYPE_STATIC_SCOPE: 0206 * 0207 * This macro flags signal argument types for which the signal system may 0208 * assume that instances thereof remain persistent across all signal emissions 0209 * they are used in. This is only useful for non ref-counted, value-copy types. 0210 * 0211 * To flag a signal argument in this way, add `| G_SIGNAL_TYPE_STATIC_SCOPE` 0212 * to the corresponding argument of g_signal_new(). 0213 * |[ 0214 * g_signal_new ("size_request", 0215 * G_TYPE_FROM_CLASS (gobject_class), 0216 * G_SIGNAL_RUN_FIRST, 0217 * G_STRUCT_OFFSET (GtkWidgetClass, size_request), 0218 * NULL, NULL, 0219 * _gtk_marshal_VOID__BOXED, 0220 * G_TYPE_NONE, 1, 0221 * GTK_TYPE_REQUISITION | G_SIGNAL_TYPE_STATIC_SCOPE); 0222 * ]| 0223 */ 0224 #define G_SIGNAL_TYPE_STATIC_SCOPE (G_TYPE_FLAG_RESERVED_ID_BIT) 0225 0226 0227 /* --- signal information --- */ 0228 /** 0229 * GSignalInvocationHint: 0230 * @signal_id: The signal id of the signal invoking the callback 0231 * @detail: The detail passed on for this emission 0232 * @run_type: The stage the signal emission is currently in, this 0233 * field will contain one of %G_SIGNAL_RUN_FIRST, 0234 * %G_SIGNAL_RUN_LAST or %G_SIGNAL_RUN_CLEANUP and %G_SIGNAL_ACCUMULATOR_FIRST_RUN. 0235 * %G_SIGNAL_ACCUMULATOR_FIRST_RUN is only set for the first run of the accumulator 0236 * function for a signal emission. 0237 * 0238 * The #GSignalInvocationHint structure is used to pass on additional information 0239 * to callbacks during a signal emission. 0240 */ 0241 struct _GSignalInvocationHint 0242 { 0243 guint signal_id; 0244 GQuark detail; 0245 GSignalFlags run_type; 0246 }; 0247 /** 0248 * GSignalQuery: 0249 * @signal_id: The signal id of the signal being queried, or 0 if the 0250 * signal to be queried was unknown. 0251 * @signal_name: The signal name. 0252 * @itype: The interface/instance type that this signal can be emitted for. 0253 * @signal_flags: The signal flags as passed in to g_signal_new(). 0254 * @return_type: The return type for user callbacks. 0255 * @n_params: The number of parameters that user callbacks take. 0256 * @param_types: (array length=n_params): The individual parameter types for 0257 * user callbacks, note that the effective callback signature is: 0258 * |[<!-- language="C" --> 0259 * @return_type callback (#gpointer data1, 0260 * [param_types param_names,] 0261 * gpointer data2); 0262 * ]| 0263 * 0264 * A structure holding in-depth information for a specific signal. 0265 * 0266 * See also: g_signal_query() 0267 */ 0268 struct _GSignalQuery 0269 { 0270 guint signal_id; 0271 const gchar *signal_name; 0272 GType itype; 0273 GSignalFlags signal_flags; 0274 GType return_type; /* mangled with G_SIGNAL_TYPE_STATIC_SCOPE flag */ 0275 guint n_params; 0276 const GType *param_types; /* mangled with G_SIGNAL_TYPE_STATIC_SCOPE flag */ 0277 }; 0278 0279 0280 /* --- signals --- */ 0281 GOBJECT_AVAILABLE_IN_ALL 0282 guint g_signal_newv (const gchar *signal_name, 0283 GType itype, 0284 GSignalFlags signal_flags, 0285 GClosure *class_closure, 0286 GSignalAccumulator accumulator, 0287 gpointer accu_data, 0288 GSignalCMarshaller c_marshaller, 0289 GType return_type, 0290 guint n_params, 0291 GType *param_types); 0292 GOBJECT_AVAILABLE_IN_ALL 0293 guint g_signal_new_valist (const gchar *signal_name, 0294 GType itype, 0295 GSignalFlags signal_flags, 0296 GClosure *class_closure, 0297 GSignalAccumulator accumulator, 0298 gpointer accu_data, 0299 GSignalCMarshaller c_marshaller, 0300 GType return_type, 0301 guint n_params, 0302 va_list args); 0303 GOBJECT_AVAILABLE_IN_ALL 0304 guint g_signal_new (const gchar *signal_name, 0305 GType itype, 0306 GSignalFlags signal_flags, 0307 guint class_offset, 0308 GSignalAccumulator accumulator, 0309 gpointer accu_data, 0310 GSignalCMarshaller c_marshaller, 0311 GType return_type, 0312 guint n_params, 0313 ...); 0314 GOBJECT_AVAILABLE_IN_ALL 0315 guint g_signal_new_class_handler (const gchar *signal_name, 0316 GType itype, 0317 GSignalFlags signal_flags, 0318 GCallback class_handler, 0319 GSignalAccumulator accumulator, 0320 gpointer accu_data, 0321 GSignalCMarshaller c_marshaller, 0322 GType return_type, 0323 guint n_params, 0324 ...); 0325 GOBJECT_AVAILABLE_IN_ALL 0326 void g_signal_set_va_marshaller (guint signal_id, 0327 GType instance_type, 0328 GSignalCVaMarshaller va_marshaller); 0329 0330 GOBJECT_AVAILABLE_IN_ALL 0331 void g_signal_emitv (const GValue *instance_and_params, 0332 guint signal_id, 0333 GQuark detail, 0334 GValue *return_value); 0335 GOBJECT_AVAILABLE_IN_ALL 0336 void g_signal_emit_valist (gpointer instance, 0337 guint signal_id, 0338 GQuark detail, 0339 va_list var_args); 0340 GOBJECT_AVAILABLE_IN_ALL 0341 void g_signal_emit (gpointer instance, 0342 guint signal_id, 0343 GQuark detail, 0344 ...); 0345 GOBJECT_AVAILABLE_IN_ALL 0346 void g_signal_emit_by_name (gpointer instance, 0347 const gchar *detailed_signal, 0348 ...); 0349 GOBJECT_AVAILABLE_IN_ALL 0350 guint g_signal_lookup (const gchar *name, 0351 GType itype); 0352 GOBJECT_AVAILABLE_IN_ALL 0353 const gchar * g_signal_name (guint signal_id); 0354 GOBJECT_AVAILABLE_IN_ALL 0355 void g_signal_query (guint signal_id, 0356 GSignalQuery *query); 0357 GOBJECT_AVAILABLE_IN_ALL 0358 guint* g_signal_list_ids (GType itype, 0359 guint *n_ids); 0360 GOBJECT_AVAILABLE_IN_2_66 0361 gboolean g_signal_is_valid_name (const gchar *name); 0362 GOBJECT_AVAILABLE_IN_ALL 0363 gboolean g_signal_parse_name (const gchar *detailed_signal, 0364 GType itype, 0365 guint *signal_id_p, 0366 GQuark *detail_p, 0367 gboolean force_detail_quark); 0368 GOBJECT_AVAILABLE_IN_ALL 0369 GSignalInvocationHint* g_signal_get_invocation_hint (gpointer instance); 0370 0371 0372 /* --- signal emissions --- */ 0373 GOBJECT_AVAILABLE_IN_ALL 0374 void g_signal_stop_emission (gpointer instance, 0375 guint signal_id, 0376 GQuark detail); 0377 GOBJECT_AVAILABLE_IN_ALL 0378 void g_signal_stop_emission_by_name (gpointer instance, 0379 const gchar *detailed_signal); 0380 GOBJECT_AVAILABLE_IN_ALL 0381 gulong g_signal_add_emission_hook (guint signal_id, 0382 GQuark detail, 0383 GSignalEmissionHook hook_func, 0384 gpointer hook_data, 0385 GDestroyNotify data_destroy); 0386 GOBJECT_AVAILABLE_IN_ALL 0387 void g_signal_remove_emission_hook (guint signal_id, 0388 gulong hook_id); 0389 0390 0391 /* --- signal handlers --- */ 0392 GOBJECT_AVAILABLE_IN_ALL 0393 gboolean g_signal_has_handler_pending (gpointer instance, 0394 guint signal_id, 0395 GQuark detail, 0396 gboolean may_be_blocked); 0397 GOBJECT_AVAILABLE_IN_ALL 0398 gulong g_signal_connect_closure_by_id (gpointer instance, 0399 guint signal_id, 0400 GQuark detail, 0401 GClosure *closure, 0402 gboolean after); 0403 GOBJECT_AVAILABLE_IN_ALL 0404 gulong g_signal_connect_closure (gpointer instance, 0405 const gchar *detailed_signal, 0406 GClosure *closure, 0407 gboolean after); 0408 GOBJECT_AVAILABLE_IN_ALL 0409 gulong g_signal_connect_data (gpointer instance, 0410 const gchar *detailed_signal, 0411 GCallback c_handler, 0412 gpointer data, 0413 GClosureNotify destroy_data, 0414 GConnectFlags connect_flags); 0415 GOBJECT_AVAILABLE_IN_ALL 0416 void g_signal_handler_block (gpointer instance, 0417 gulong handler_id); 0418 GOBJECT_AVAILABLE_IN_ALL 0419 void g_signal_handler_unblock (gpointer instance, 0420 gulong handler_id); 0421 GOBJECT_AVAILABLE_IN_ALL 0422 void g_signal_handler_disconnect (gpointer instance, 0423 gulong handler_id); 0424 GOBJECT_AVAILABLE_IN_ALL 0425 gboolean g_signal_handler_is_connected (gpointer instance, 0426 gulong handler_id); 0427 GOBJECT_AVAILABLE_IN_ALL 0428 gulong g_signal_handler_find (gpointer instance, 0429 GSignalMatchType mask, 0430 guint signal_id, 0431 GQuark detail, 0432 GClosure *closure, 0433 gpointer func, 0434 gpointer data); 0435 GOBJECT_AVAILABLE_IN_ALL 0436 guint g_signal_handlers_block_matched (gpointer instance, 0437 GSignalMatchType mask, 0438 guint signal_id, 0439 GQuark detail, 0440 GClosure *closure, 0441 gpointer func, 0442 gpointer data); 0443 GOBJECT_AVAILABLE_IN_ALL 0444 guint g_signal_handlers_unblock_matched (gpointer instance, 0445 GSignalMatchType mask, 0446 guint signal_id, 0447 GQuark detail, 0448 GClosure *closure, 0449 gpointer func, 0450 gpointer data); 0451 GOBJECT_AVAILABLE_IN_ALL 0452 guint g_signal_handlers_disconnect_matched (gpointer instance, 0453 GSignalMatchType mask, 0454 guint signal_id, 0455 GQuark detail, 0456 GClosure *closure, 0457 gpointer func, 0458 gpointer data); 0459 0460 GOBJECT_AVAILABLE_IN_2_62 0461 void g_clear_signal_handler (gulong *handler_id_ptr, 0462 gpointer instance); 0463 0464 #define g_clear_signal_handler(handler_id_ptr, instance) \ 0465 G_STMT_START { \ 0466 gpointer const _instance = (instance); \ 0467 gulong *const _handler_id_ptr = (handler_id_ptr); \ 0468 const gulong _handler_id = *_handler_id_ptr; \ 0469 \ 0470 if (_handler_id > 0) \ 0471 { \ 0472 *_handler_id_ptr = 0; \ 0473 g_signal_handler_disconnect (_instance, _handler_id); \ 0474 } \ 0475 } G_STMT_END \ 0476 GOBJECT_AVAILABLE_MACRO_IN_2_62 0477 0478 /* --- overriding and chaining --- */ 0479 GOBJECT_AVAILABLE_IN_ALL 0480 void g_signal_override_class_closure (guint signal_id, 0481 GType instance_type, 0482 GClosure *class_closure); 0483 GOBJECT_AVAILABLE_IN_ALL 0484 void g_signal_override_class_handler (const gchar *signal_name, 0485 GType instance_type, 0486 GCallback class_handler); 0487 GOBJECT_AVAILABLE_IN_ALL 0488 void g_signal_chain_from_overridden (const GValue *instance_and_params, 0489 GValue *return_value); 0490 GOBJECT_AVAILABLE_IN_ALL 0491 void g_signal_chain_from_overridden_handler (gpointer instance, 0492 ...); 0493 0494 0495 /* --- convenience --- */ 0496 /** 0497 * g_signal_connect: 0498 * @instance: the instance to connect to. 0499 * @detailed_signal: a string of the form "signal-name::detail". 0500 * @c_handler: the #GCallback to connect. 0501 * @data: data to pass to @c_handler calls. 0502 * 0503 * Connects a [type@GObject.Callback] function to a signal for a particular object. 0504 * 0505 * The handler will be called synchronously, before the default handler of the signal. 0506 * [func@GObject.signal_emit] will not return control until all handlers are called. 0507 * 0508 * See [memory management of signal handlers](signals.html#Memory_management_of_signal_handlers) for 0509 * details on how to handle the return value and memory management of @data. 0510 * 0511 * This function cannot fail. If the given signal doesn’t exist, a critical 0512 * warning is emitted. 0513 * 0514 * Returns: the handler ID, of type `gulong` (always greater than 0) 0515 */ 0516 /* Intentionally not using G_CONNECT_DEFAULT here to avoid deprecation 0517 * warnings with older GLIB_VERSION_MAX_ALLOWED */ 0518 #define g_signal_connect(instance, detailed_signal, c_handler, data) \ 0519 g_signal_connect_data ((instance), (detailed_signal), (c_handler), (data), NULL, (GConnectFlags) 0) 0520 /** 0521 * g_signal_connect_after: 0522 * @instance: the instance to connect to. 0523 * @detailed_signal: a string of the form "signal-name::detail". 0524 * @c_handler: the #GCallback to connect. 0525 * @data: data to pass to @c_handler calls. 0526 * 0527 * Connects a #GCallback function to a signal for a particular object. 0528 * 0529 * The handler will be called synchronously, after the default handler of the signal. 0530 * 0531 * This function cannot fail. If the given signal doesn’t exist, a critical 0532 * warning is emitted. 0533 * 0534 * Returns: the handler ID, of type `gulong` (always greater than 0) 0535 */ 0536 #define g_signal_connect_after(instance, detailed_signal, c_handler, data) \ 0537 g_signal_connect_data ((instance), (detailed_signal), (c_handler), (data), NULL, G_CONNECT_AFTER) 0538 /** 0539 * g_signal_connect_swapped: 0540 * @instance: the instance to connect to. 0541 * @detailed_signal: a string of the form "signal-name::detail". 0542 * @c_handler: the #GCallback to connect. 0543 * @data: data to pass to @c_handler calls. 0544 * 0545 * Connects a #GCallback function to a signal for a particular object. 0546 * 0547 * The instance on which the signal is emitted and @data will be swapped when 0548 * calling the handler. This is useful when calling pre-existing functions to 0549 * operate purely on the @data, rather than the @instance: swapping the 0550 * parameters avoids the need to write a wrapper function. 0551 * 0552 * For example, this allows the shorter code: 0553 * |[<!-- language="C" --> 0554 * g_signal_connect_swapped (button, "clicked", 0555 * (GCallback) gtk_widget_hide, other_widget); 0556 * ]| 0557 * 0558 * Rather than the cumbersome: 0559 * |[<!-- language="C" --> 0560 * static void 0561 * button_clicked_cb (GtkButton *button, GtkWidget *other_widget) 0562 * { 0563 * gtk_widget_hide (other_widget); 0564 * } 0565 * 0566 * ... 0567 * 0568 * g_signal_connect (button, "clicked", 0569 * (GCallback) button_clicked_cb, other_widget); 0570 * ]| 0571 * 0572 * This function cannot fail. If the given signal doesn’t exist, a critical 0573 * warning is emitted. 0574 * 0575 * Returns: the handler ID, of type `gulong` (always greater than 0) 0576 */ 0577 #define g_signal_connect_swapped(instance, detailed_signal, c_handler, data) \ 0578 g_signal_connect_data ((instance), (detailed_signal), (c_handler), (data), NULL, G_CONNECT_SWAPPED) 0579 /** 0580 * g_signal_handlers_disconnect_by_func: 0581 * @instance: The instance to remove handlers from. 0582 * @func: The C closure callback of the handlers (useless for non-C closures). 0583 * @data: The closure data of the handlers' closures. 0584 * 0585 * Disconnects all handlers on an instance that match @func and @data. 0586 * 0587 * Returns: The number of handlers that matched. 0588 */ 0589 #define g_signal_handlers_disconnect_by_func(instance, func, data) \ 0590 g_signal_handlers_disconnect_matched ((instance), \ 0591 (GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), \ 0592 0, 0, NULL, (func), (data)) 0593 0594 /** 0595 * g_signal_handlers_disconnect_by_data: 0596 * @instance: The instance to remove handlers from 0597 * @data: the closure data of the handlers' closures 0598 * 0599 * Disconnects all handlers on an instance that match @data. 0600 * 0601 * Returns: The number of handlers that matched. 0602 * 0603 * Since: 2.32 0604 */ 0605 #define g_signal_handlers_disconnect_by_data(instance, data) \ 0606 g_signal_handlers_disconnect_matched ((instance), G_SIGNAL_MATCH_DATA, 0, 0, NULL, NULL, (data)) 0607 0608 /** 0609 * g_signal_handlers_block_by_func: 0610 * @instance: The instance to block handlers from. 0611 * @func: The C closure callback of the handlers (useless for non-C closures). 0612 * @data: The closure data of the handlers' closures. 0613 * 0614 * Blocks all handlers on an instance that match @func and @data. 0615 * 0616 * Returns: The number of handlers that matched. 0617 */ 0618 #define g_signal_handlers_block_by_func(instance, func, data) \ 0619 g_signal_handlers_block_matched ((instance), \ 0620 (GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), \ 0621 0, 0, NULL, (func), (data)) 0622 /** 0623 * g_signal_handlers_unblock_by_func: 0624 * @instance: The instance to unblock handlers from. 0625 * @func: The C closure callback of the handlers (useless for non-C closures). 0626 * @data: The closure data of the handlers' closures. 0627 * 0628 * Unblocks all handlers on an instance that match @func and @data. 0629 * 0630 * Returns: The number of handlers that matched. 0631 */ 0632 #define g_signal_handlers_unblock_by_func(instance, func, data) \ 0633 g_signal_handlers_unblock_matched ((instance), \ 0634 (GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), \ 0635 0, 0, NULL, (func), (data)) 0636 0637 0638 GOBJECT_AVAILABLE_IN_ALL 0639 gboolean g_signal_accumulator_true_handled (GSignalInvocationHint *ihint, 0640 GValue *return_accu, 0641 const GValue *handler_return, 0642 gpointer dummy); 0643 0644 GOBJECT_AVAILABLE_IN_ALL 0645 gboolean g_signal_accumulator_first_wins (GSignalInvocationHint *ihint, 0646 GValue *return_accu, 0647 const GValue *handler_return, 0648 gpointer dummy); 0649 0650 /*< private >*/ 0651 GOBJECT_AVAILABLE_IN_ALL 0652 void g_signal_handlers_destroy (gpointer instance); 0653 void _g_signals_destroy (GType itype); 0654 0655 G_END_DECLS 0656 0657 #endif /* __G_SIGNAL_H__ */
| [ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
|
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
|