mirror of
https://github.com/labwc/labwc.git
synced 2025-10-31 22:25:34 -04:00
common: add and use CONNECT_SIGNAL macro
This makes the code a bit more readable IMHO (and forces us to be consistent with event handler function names). Adjust scripts/checkpatch.pl to not complain.
This commit is contained in:
parent
a036d985d7
commit
5cb1d0e83f
6 changed files with 73 additions and 101 deletions
|
|
@ -16,4 +16,20 @@
|
|||
*/
|
||||
#define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]))
|
||||
|
||||
/**
|
||||
* CONNECT_SIGNAL() - Connect a signal handler function to a wl_signal.
|
||||
*
|
||||
* @param src Signal emitter (struct containing wl_signal)
|
||||
* @param dest Signal receiver (struct containing wl_listener)
|
||||
* @param name Signal name
|
||||
*
|
||||
* This assumes that the common pattern is followed where:
|
||||
* - the wl_signal is (*src).events.<name>
|
||||
* - the wl_listener is (*dest).<name>
|
||||
* - the signal handler function is named handle_<name>
|
||||
*/
|
||||
#define CONNECT_SIGNAL(src, dest, name) \
|
||||
(dest)->name.notify = handle_##name; \
|
||||
wl_signal_add(&(src)->events.name, &(dest)->name)
|
||||
|
||||
#endif /* LABWC_MACROS_H */
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue