/* Returns: the ID (greater than 0) for the source within the #GMainContext.  */
guint g_source_attach(GSource *source, GMainContext *context)
/* Returns: the ID (greater than 0) for the source within the #GMainContext.  */
guint g_source_attach(GSource *source, GMainContext *context)
{
  guint result = 0;
  g_return_val_if_fail (source->context == NULL, 0);
  g_return_val_if_fail (!SOURCE_DESTROYED (source), 0);
  TRACE (GLIB_MAIN_SOURCE_ATTACH (g_source_get_name (source)));
  if (!context)
    context = g_main_context_default ();
  LOCK_CONTEXT (context);
  result = g_source_attach_unlocked (source, context, TRUE);
  UNLOCK_CONTEXT (context);
  return result;
}