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 ide_configuration_constructed (GObject *object) { IdeConfiguration *self = (IdeConfiguration *)object; IdeContext *context; IdeDeviceManager *device_manager; IdeRuntimeManager *runtime_manager; G_OBJECT_CLASS (ide_configuration_parent_class)->constructed (object); context = ide_object_get_context (IDE_OBJECT (self)); device_manager = ide_context_get_device_manager (context); runtime_manager = ide_context_get_runtime_manager (context); g_signal_connect_object (device_manager, "items-changed", G_CALLBACK (ide_configuration_device_manager_items_changed), self, G_CONNECT_SWAPPED); g_signal_connect_object (runtime_manager, "items-changed", G_CALLBACK (ide_configuration_runtime_manager_items_changed), self, G_CONNECT_SWAPPED); ide_configuration_device_manager_items_changed (self, 0, 0, 0, device_manager); ide_configuration_runtime_manager_items_changed (self, 0, 0, 0, runtime_manager); }
void ide_configuration_set_device_id (IdeConfiguration *self, const gchar *device_id) { g_return_if_fail (IDE_IS_CONFIGURATION (self)); g_return_if_fail (device_id != NULL); if (g_strcmp0 (device_id, self->device_id) != 0) { IdeContext *context; IdeDeviceManager *device_manager; g_free (self->device_id); self->device_id = g_strdup (device_id); ide_configuration_set_dirty (self, TRUE); g_object_notify_by_pspec (G_OBJECT (self), properties [PROP_DEVICE_ID]); g_object_notify_by_pspec (G_OBJECT (self), properties [PROP_DEVICE]); context = ide_object_get_context (IDE_OBJECT (self)); device_manager = ide_context_get_device_manager (context); ide_configuration_device_manager_items_changed (self, 0, 0, 0, device_manager); } }
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")); }
/** * ide_configuration_get_device: * @self: An #IdeConfiguration * * Gets the device for the configuration. * * Returns: (transfer none) (nullable): An #IdeDevice. */ IdeDevice * ide_configuration_get_device (IdeConfiguration *self) { IdeDeviceManager *device_manager; IdeContext *context; g_return_val_if_fail (IDE_IS_CONFIGURATION (self), NULL); context = ide_object_get_context (IDE_OBJECT (self)); device_manager = ide_context_get_device_manager (context); return ide_device_manager_get_device (device_manager, self->device_id); }