gsignal.h 24 KB

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