event-dispatcher: expose iterator to iterate over the registered hooks
This commit is contained in:

committed by
Julian Bouzas

parent
b100bdda4a
commit
5a435fae11
@@ -603,3 +603,18 @@ wp_event_dispatcher_unregister_hook (WpEventDispatcher * self,
|
||||
wp_event_hook_set_dispatcher (hook, NULL);
|
||||
g_ptr_array_remove_fast (self->hooks, hook);
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Returns an iterator to iterate over all the registered hooks
|
||||
* \ingroup wpeventdispatcher
|
||||
*
|
||||
* \param self the event dispatcher
|
||||
* \return (transfer full): a new iterator
|
||||
*/
|
||||
WpIterator *
|
||||
wp_event_dispatcher_new_hooks_iterator (WpEventDispatcher * self)
|
||||
{
|
||||
GPtrArray *items =
|
||||
g_ptr_array_copy (self->hooks, (GCopyFunc) g_object_ref, NULL);
|
||||
return wp_iterator_new_ptr_array (items, WP_TYPE_EVENT_HOOK);
|
||||
}
|
||||
|
@@ -85,6 +85,9 @@ WP_API
|
||||
void wp_event_dispatcher_unregister_hook (WpEventDispatcher * self,
|
||||
WpEventHook * hook);
|
||||
|
||||
WP_API
|
||||
WpIterator * wp_event_dispatcher_new_hooks_iterator (WpEventDispatcher * self);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif
|
||||
|
Reference in New Issue
Block a user