Skip to content

GLib.Hook

record (struct)

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

Methods

compare_ids

def compare_ids(self, 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

Static functions

destroy

@staticmethod
def destroy(hook_list: HookList, hook_id: int) -> bool

Destroys a Hook, given its ID.

Parameters:

  • hook_list — a HookList
  • hook_id — a hook ID
@staticmethod
def destroy_link(hook_list: HookList, hook: Hook) -> None

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

Parameters:

free

@staticmethod
def 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

@staticmethod
def 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

@staticmethod
def insert_sorted(hook_list: HookList, hook: Hook, func: HookCompareFunc) -> 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

@staticmethod
def 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

unref

@staticmethod
def unref(hook_list: HookList, hook: Hook) -> None

Decrements the reference count of a Hook. If the reference count falls to 0, the Hook is removed from the HookList and Hook.free is called to free it.

Parameters:

Properties

data

data: int  # read/write

next

next: Hook  # read/write

prev

prev: Hook  # read/write

ref_count

ref_count: int  # read/write

hook_id

hook_id: int  # read/write

flags

flags: int  # read/write

func

func: int  # read/write

destroy

destroy: DestroyNotify  # read/write