Description
The GHookList, GHook and their related functions provide support for
lists of hook functions. Functions can be added and removed from the lists,
and the list of hook functions can be invoked.
Details
struct GHookList
struct GHookList
{
guint seq_id;
guint hook_size;
guint is_setup : 1;
GHook *hooks;
GMemChunk *hook_memchunk;
GHookFreeFunc hook_free; /* virtual function */
GHookFreeFunc hook_destroy; /* virtual function */
}; |
struct GHook
struct GHook
{
gpointer data;
GHook *next;
GHook *prev;
guint ref_count;
guint hook_id;
guint flags;
gpointer func;
GDestroyNotify destroy;
}; |
G_HOOK_DEFERRED_DESTROY
#define G_HOOK_DEFERRED_DESTROY ((GHookFreeFunc) 0x01) |
g_hook_list_init ()
Initializes a GHookList.
This must be called before the GHookList is used.
g_hook_list_invoke_check ()
Calls all of the GHook functions in a GHookList.
Any function which returns TRUE is removed from the GHookList.
g_hook_list_marshal_check ()
g_hook_alloc ()
Allocates space for a GHook and initializes it.
g_hook_append()
#define g_hook_append( hook_list, hook ) |
Appends a GHook onto the end of a GHookList.
g_hook_insert_sorted ()
Inserts a GHook into a GHookList, sorted by the given function.
g_hook_compare_ids ()
Compares the ids of two GHook elements, returning a negative value
if the second id is greater than the first.
g_hook_get ()
Returns the GHook with the given id, or NULL if it is not found.
g_hook_find ()
Finds a GHook in a GHookList using the given function to test for a match.
g_hook_find_func ()
Finds a GHook in a GHookList with the given function.
g_hook_find_func_data ()
Finds a GHook in a GHookList with the given function and data.
g_hook_next_valid ()
Returns the next GHook in a GHookList which has not been destroyed.
The reference count for the GHook is incremented, so you must call
g_hook_unref() to restore it when no longer needed. (Or continue to call
g_hook_next_valid() until NULL is returned.)
enum GHookFlagMask
typedef enum
{
G_HOOK_FLAG_ACTIVE = 1 << 0,
G_HOOK_FLAG_IN_CALL = 1 << 1,
G_HOOK_FLAG_MASK = 0x0f
} GHookFlagMask; |
G_HOOK_FLAG_USER_SHIFT
#define G_HOOK_FLAG_USER_SHIFT (4) |
G_HOOK_IS_VALID()
#define G_HOOK_IS_VALID(hook) |
Returns TRUE if the GHook is valid, i.e. it is in a GHookList, it is active
and it has not been destroyed.
G_HOOK_ACTIVE()
#define G_HOOK_ACTIVE(hook) |
Returns TRUE if the GHook is active, which is normally TRUE until the GHook
is destroyed.
G_HOOK_IN_CALL()
#define G_HOOK_IN_CALL(hook) |
Returns TRUE if the GHook function is currently executing.
G_HOOK_IS_UNLINKED()
#define G_HOOK_IS_UNLINKED(hook) |
Returns TRUE if the GHook is not in a GHookList.
g_hook_ref ()
Increments the reference count for a GHook.
g_hook_unref ()
Decrements the reference count of a GHook.
If the reference count falls to 0, the GHook is removed from the GHookList
and g_hook_free() is called to free it.
g_hook_free ()
Calls the GHookList hook_free function if it exists, and frees the memory
allocated for the GHook.
g_hook_destroy ()
Destroys a GHook, given its ID.
g_hook_destroy_link ()
Removes one GHook from a GHookList, calling the hook_destroy function in
the GHookList, and the destroy function of the GHook, if they exist.