Web lists-archives.com

Re: glib - main event loop

On Sun, 20 Mar 2016 06:25:10 +0100
Krzysztof <kj@xxxxxxxxxxxx> wrote:
> Thanks Chris. It worked.
> Does it mean that idle source can be effectively added to global loop 
> only? Can't I have idle source in other contexts?

You can, but you have to use g_source_attach().  So you would have
something like:

guint idle_add_with_context(GMainContext *context, gint priority,
                            GSourceFunc func, gpointer data,
                            GDestroyNotify notify)
  GSource *source = g_idle_source_new();
  if (priority != G_PRIORITY_DEFAULT_IDLE)
    g_source_set_priority(source, priority);
  g_source_set_callback(source, func, data, notify);
  guint id = g_source_attach(source, context);
  return id;

gtk-list mailing list