///|
extern "c" fn moonbit_glib_idle_add(
  function : FuncRef[(() -> Bool) -> Bool],
  closure : () -> Bool,
) -> UInt = "moonbit_glib_idle_add"

///|
/// Schedule a callback to run when the main loop is idle.
/// The callback returns `true` to be called again, `false` to be removed.
pub fn idle_add(callback : () -> Bool) -> UInt {
  moonbit_glib_idle_add(fn(f) { f() }, callback)
}