#include <glib.h>
Go to the source code of this file.
Defines | |
#define | LISTENER_ADD(signal, callback) |
#define | LISTENER_REMOVE(signal, callback) |
#define | LISTENER_EMIT(signal, params) |
Typedefs | |
typedef GSList * | listeners_t |
To use the macros below with a "node_added" signal for example, you need to have a storage stucture to hold the listeners list This needs to be defined in the following fashion. |
|
Value: G_STMT_START { \ gpointer p = cast_func_to_gpointer((func_ptr_t) (callback)); \ g_assert(NULL != p); \ CAT2(signal,_listeners) = g_slist_append(CAT2(signal,_listeners), p); \ } G_STMT_END |
|
Value: G_STMT_START { \ GSList *sl; \ for (sl = CAT2(signal,_listeners); sl != NULL; sl = g_slist_next(sl)) { \ CAT2(signal,_listener_t) fn; \ g_assert(NULL != sl->data); \ fn = (CAT2(signal,_listener_t)) cast_gpointer_to_func(sl->data); \ fn params; \ } \ } G_STMT_END |
|
Value: G_STMT_START { \ gpointer p = cast_func_to_gpointer((func_ptr_t) (callback)); \ g_assert(NULL != p); \ CAT2(signal,_listeners) = g_slist_remove(CAT2(signal,_listeners), p); \ } G_STMT_END |
|
To use the macros below with a "node_added" signal for example, you need to have a storage stucture to hold the listeners list This needs to be defined in the following fashion. The name is important for the macros to access the structure. For a "node_removed" signal replace node_added_listeners with node_removed_listeners. listeners_t node_added_listeners = NULL; You also need a special type defined which holds the signature of the callback function. For example: typedef void (*node_added_listener_t) (gnutella_node_t *, const gchar *); Again the name is important (like above). |