static void context_cb (GObject *object, GAsyncResult *result, gpointer user_data) { g_autoptr(IdeContext) context = NULL; g_autoptr(GError) error = NULL; IdeDeviceManager *device_manager; context = ide_context_new_finish (result, &error); if (!context) { g_printerr ("%s\n", error->message); quit (EXIT_FAILURE); return; } device_manager = ide_context_get_device_manager (context); if (!ide_device_manager_get_settled (device_manager)) g_signal_connect (device_manager, "notify::settled", G_CALLBACK (settled_cb), NULL); else settled_cb (device_manager, NULL, NULL); }
static void context_cb (GObject *object, GAsyncResult *result, gpointer user_data) { g_autoptr(IdeContext) context = NULL; g_autoptr(GError) error = NULL; GPtrArray *devices; IdeDeviceManager *device_manager; guint i; context = ide_context_new_finish (result, &error); if (!context) { g_printerr ("%s\n", error->message); quit (EXIT_FAILURE); return; } ide_context = g_object_ref (context); /* * Try to locate the device we are building for. If the device is not found, * we will wait for a timeout period while devices show up during device * settling. */ device_manager = ide_context_get_device_manager (context); devices = ide_device_manager_get_devices (device_manager); for (i = 0; i < devices->len; i++) { IdeDevice *device; const gchar *device_id; device = g_ptr_array_index (devices, i); device_id = ide_device_get_id (device); if (g_strcmp0 (device_id, deviceId) == 0) { build_for_device (context, device); g_ptr_array_unref (devices); return; } } g_ptr_array_unref (devices); added_handler = g_signal_connect (device_manager, "device-added", G_CALLBACK (device_added_cb), NULL); timeout = g_timeout_add_seconds (60, timeout_cb, NULL); g_printerr (_("Waiting up to 60 seconds for devices to settle. Ctrl+C to exit.\n")); }