Factor out Motmot-GLib event layer implementation