Replace these calls with direct use of GMainContext api.
This has testcases for some issues around invalidation of marks.