:right-sidebar: True Hook =================================================================== .. currentmodule:: gi.repository.GLib .. class:: Hook(*args, **kwargs) :no-contents-entry: The :obj:`~gi.repository.GLib.Hook` struct represents a single hook function in a :obj:`~gi.repository.GLib.HookList`\. Methods ------- .. rst-class:: interim-class .. class:: Hook :no-index: .. method:: compare_ids(sibling: ~gi.repository.GLib.Hook) -> int Compares the ids of two :obj:`~gi.repository.GLib.Hook` elements, returning a negative value if the second id is greater than the first. :param sibling: a :obj:`~gi.repository.GLib.Hook` to compare with ``new_hook`` .. classmethod:: destroy(hook_id: int) -> bool Destroys a :obj:`~gi.repository.GLib.Hook`\, given its ID. :param hook_id: a hook ID .. classmethod:: destroy_link(hook: ~gi.repository.GLib.Hook) -> None Removes one :obj:`~gi.repository.GLib.Hook` from a :obj:`~gi.repository.GLib.HookList`\, marking it inactive and calling :func:`~gi.repository.GLib.Hook.unref` on it. :param hook: the :obj:`~gi.repository.GLib.Hook` to remove .. classmethod:: free(hook: ~gi.repository.GLib.Hook) -> None Calls the :obj:`~gi.repository.GLib.HookList` ``finalize_hook`` function if it exists, and frees the memory allocated for the :obj:`~gi.repository.GLib.Hook`\. :param hook: the :obj:`~gi.repository.GLib.Hook` to free .. classmethod:: insert_before(sibling: ~gi.repository.GLib.Hook | None, hook: ~gi.repository.GLib.Hook) -> None Inserts a :obj:`~gi.repository.GLib.Hook` into a :obj:`~gi.repository.GLib.HookList`\, before a given :obj:`~gi.repository.GLib.Hook`\. :param sibling: the :obj:`~gi.repository.GLib.Hook` to insert the new :obj:`~gi.repository.GLib.Hook` before :param hook: the :obj:`~gi.repository.GLib.Hook` to insert .. classmethod:: insert_sorted(hook: ~gi.repository.GLib.Hook, func: ~typing.Callable[[~gi.repository.GLib.Hook, ~gi.repository.GLib.Hook], int]) -> None Inserts a :obj:`~gi.repository.GLib.Hook` into a :obj:`~gi.repository.GLib.HookList`\, sorted by the given function. :param hook: the :obj:`~gi.repository.GLib.Hook` to insert :param func: the comparison function used to sort the :obj:`~gi.repository.GLib.Hook` elements .. classmethod:: prepend(hook: ~gi.repository.GLib.Hook) -> None Prepends a :obj:`~gi.repository.GLib.Hook` on the start of a :obj:`~gi.repository.GLib.HookList`\. :param hook: the :obj:`~gi.repository.GLib.Hook` to add to the start of ``hook_list`` Fields ------ .. rst-class:: interim-class .. class:: Hook :no-index: .. attribute:: data Data which is passed to func when this hook is invoked .. attribute:: flags Flags which are set for this hook. See ``GHookFlagMask`` for predefined flags .. attribute:: func The function to call when this hook is invoked. The possible signatures for this function are ``GHookFunc`` and ``GHookCheckFunc`` .. attribute:: hook_id The id of this hook, which is unique within its list .. attribute:: next Pointer to the next hook in the list .. attribute:: prev Pointer to the previous hook in the list .. attribute:: ref_count The reference count of this hook