gi: Replace deprecated FFI closure API
This is a reimplemented fc776c20 with the proper fix for the regression introduced by that commit which required a revert.
This is a reimplemented fc776c20 with the proper fix for the regression introduced by that commit which required a revert.