Async methods must take in consideration the GMainContext
Submitted by Luca Bruno
Link to original bug (#663498)
Description
Hello, currently async methods provide a .callback so that people can use Idle.add (foo.callback). But it's generally not correct to resume the async method in the default main context. For example gdbusconnection.c in gio stores the the GMainContext the async operation was created in, and creates idles and timeouts in that context. Proposal:
- Store the main context when in the async data structure
- Add a convenient .idle_callback method that automatically creates an idle source and attaches it to the right context. Most of the time Idle.add() is used to resume the async method.
- Add a .main_context field to access the main context to allow other kind of sources to be attached.