6 /* A hook is a function to call with the supplied hook data, and with
7 call site specific data (e.g., hooks for events are called with a
8 pointer to the current event). */
10 typedef gboolean (*LttvHook
)(void *hook_data
, void *call_data
);
13 /* A list of hooks allows registering hooks to be called later. */
15 typedef GArray LttvHooks
;
18 /* Create and destroy a list of hooks */
20 LttvHooks
*lttv_hooks_new();
22 void lttv_hooks_destroy(LttvHooks
*h
);
25 /* Add a hook and its hook data to the list */
27 void lttv_hooks_add(LttvHooks
*h
, LttvHook f
, void *hook_data
);
30 /* Add a list of hooks to the list h */
32 void lttv_hooks_add_list(LttvHooks
*h
, LttvHooks
*list
);
35 /* Remove a hook from the list. Return the hook data. */
37 void *lttv_hooks_remove(LttvHooks
*h
, LttvHook f
);
40 /* Remove a hook from the list checking that the hook data match. */
42 void lttv_hooks_remove_data(LttvHooks
*h
, LttvHook f
, void *hook_data
);
45 /* Remove a list of hooks from the hooks list in h. */
47 void lttv_hooks_remove_data_list(LttvHooks
*h
, LttvHook
*list
);
50 /* Return the number of hooks in the list */
52 unsigned lttv_hooks_number(LttvHooks
*h
);
55 /* Return the hook at the specified position in the list */
57 void lttv_hooks_get(LttvHooks
*h
, unsigned i
, LttvHook
*f
, void **hook_data
);
60 /* Remove the specified hook. The position of the following hooks may change */
62 void lttv_hooks_remove_by_position(LttvHooks
*h
, unsigned i
);
65 /* Call all the hooks in the list, each with its hook data,
66 with the specified call data. Return TRUE if one hook returned TRUE. */
68 gboolean
lttv_hooks_call(LttvHooks
*h
, void *call_data
);
71 /* Call the hooks in the list until one returns true, in which case TRUE is
74 gboolean
lttv_hooks_call_check(LttvHooks
*h
, void *call_data
);
77 /* Sometimes different hooks need to be called based on the case. The
78 case is represented by an unsigned integer id */
80 typedef GPtrArray LttvHooksById
;
83 /* Create and destroy a hooks by id list */
85 LttvHooksById
*lttv_hooks_by_id_new();
87 void lttv_hooks_by_id_destroy(LttvHooksById
*h
);
90 /* Obtain the hooks for a given id, creating a list if needed */
92 LttvHooks
*lttv_hooks_by_id_find(LttvHooksById
*h
, unsigned id
);
95 /* Return an id larger than any for which a list exists. */
97 unsigned lttv_hooks_by_id_max_id(LttvHooksById
*h
);
100 /* Get the list of hooks for an id, NULL if none exists */
102 LttvHooks
*lttv_hooks_by_id_get(LttvHooksById
*h
, unsigned id
);
105 /* Remove the list of hooks associated with an id */
107 void lttv_hooks_by_id_remove(LttvHooksById
*h
, unsigned id
);
This page took 0.030762 seconds and 4 git commands to generate.