Hook#

class Hook(*args, **kwargs)#

The Hook struct represents a single hook function in a HookList.

Methods#

class Hook
compare_ids(sibling: Hook) int#

Compares the ids of two Hook elements, returning a negative value if the second id is greater than the first.

Parameters:

sibling – a Hook to compare with new_hook

destroy(hook_list: HookList, hook_id: int) bool#

Destroys a Hook, given its ID.

Parameters:
  • hook_list – a HookList

  • hook_id – a hook ID

Removes one Hook from a HookList, marking it inactive and calling unref() on it.

Parameters:
free(hook_list: HookList, hook: Hook) None#

Calls the HookList finalize_hook function if it exists, and frees the memory allocated for the Hook.

Parameters:
insert_before(hook_list: HookList, sibling: Hook | None, hook: Hook) None#

Inserts a Hook into a HookList, before a given Hook.

Parameters:
  • hook_list – a HookList

  • sibling – the Hook to insert the new Hook before

  • hook – the Hook to insert

insert_sorted(hook_list: HookList, hook: Hook, func: Callable[[Hook, Hook], int]) None#

Inserts a Hook into a HookList, sorted by the given function.

Parameters:
  • hook_list – a HookList

  • hook – the Hook to insert

  • func – the comparison function used to sort the Hook elements

prepend(hook_list: HookList, hook: Hook) None#

Prepends a Hook on the start of a HookList.

Parameters:
  • hook_list – a HookList

  • hook – the Hook to add to the start of hook_list

Fields#

class Hook
data#

Data which is passed to func when this hook is invoked

flags#

Flags which are set for this hook. See GHookFlagMask for predefined flags

func#

The function to call when this hook is invoked. The possible signatures for this function are GHookFunc and GHookCheckFunc

hook_id#

The id of this hook, which is unique within its list

next#

Pointer to the next hook in the list

prev#

Pointer to the previous hook in the list

ref_count#

The reference count of this hook