+/* Helper for e_source_registry_create_sources_sync() */
+static gboolean
+source_registry_create_sources_main_loop_quit_cb (gpointer user_data)
+{
+ GMainLoop *main_loop = user_data;
+
+ g_main_loop_quit (main_loop);
+
+ return FALSE;
+}
+
+/* Helper for e_source_registry_create_sources_sync() */
+static void
+source_registry_create_sources_object_added_cb (GDBusObjectManager *object_manager,
+ GDBusObject *dbus_object,
+ CreateContext *create_context)
+{
+ EDBusObject *e_dbus_object;
+ EDBusSource *e_dbus_source;
+ const gchar *uid;
+
+ e_dbus_object = E_DBUS_OBJECT (dbus_object);
+ e_dbus_source = e_dbus_object_get_source (e_dbus_object);
+ uid = e_dbus_source_get_uid (e_dbus_source);
+
+ g_hash_table_remove (create_context->pending_uids, uid);
+
+ /* The hash table will be empty when all of the expected
+ * GDBusObjects have been added to the GDBusObjectManager. */
+ if (g_hash_table_size (create_context->pending_uids) == 0) {
+ GSource *idle_source;
+
+ idle_source = g_idle_source_new ();
+ g_source_set_callback (
+ idle_source,
+ source_registry_create_sources_main_loop_quit_cb,
+ g_main_loop_ref (create_context->main_loop),
+ (GDestroyNotify) g_main_loop_unref);
+ g_source_attach (idle_source, create_context->main_context);
+ g_source_unref (idle_source);
+ }
+}
+