void ide_recent_projects_discover_async (IdeRecentProjects *self, gboolean recent_only, GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data) { g_autoptr(GTask) task = NULL; gsize i; g_return_if_fail (IDE_IS_RECENT_PROJECTS (self)); g_return_if_fail (!cancellable || G_IS_CANCELLABLE (cancellable)); task = g_task_new (self, cancellable, callback, user_data); if (self->discovered) { g_task_return_new_error (task, G_IO_ERROR, G_IO_ERROR_FAILED, _("%s() may only be executed once"), G_STRFUNC); return; } self->discovered = TRUE; ide_recent_projects_load_recent (self); if (recent_only) { g_task_return_boolean (task, TRUE); return; } self->active = self->miners->len; if (self->active == 0) { g_task_return_boolean (task, TRUE); return; } for (i = 0; i < self->miners->len; i++) { IdeProjectMiner *miner; miner = g_ptr_array_index (self->miners, i); ide_project_miner_mine_async (miner, self->cancellable, ide_recent_projects__miner_mine_cb, g_object_ref (task)); } }
int main (int argc, gchar *argv[]) { static const GOptionEntry entries[] = { { "verbose", 'v', G_OPTION_FLAG_NO_ARG|G_OPTION_FLAG_IN_MAIN, G_OPTION_ARG_CALLBACK, verbose_cb }, { NULL } }; IdeProjectMiner *miner; GOptionContext *context; GMainLoop *main_loop; GError *error = NULL; ide_log_init (TRUE, NULL); context = g_option_context_new (_("- discover projects")); g_option_context_add_main_entries (context, entries, NULL); if (!g_option_context_parse (context, &argc, &argv, &error)) { g_printerr ("%s\n", error->message); return EXIT_FAILURE; } miner = g_object_new (IDE_TYPE_AUTOTOOLS_PROJECT_MINER, "root-directory", NULL, NULL); g_signal_connect (miner, "discovered", G_CALLBACK (discovered_cb), NULL); main_loop = g_main_loop_new (NULL, FALSE); ide_project_miner_mine_async (miner, NULL, mine_cb, main_loop); g_main_loop_run (main_loop); g_main_loop_unref (main_loop); ide_log_shutdown (); return 0; }