[gnome-builder/wip/chergert/pipeline-merge] runtime-provider: add hooks to install a runtime by id
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder/wip/chergert/pipeline-merge] runtime-provider: add hooks to install a runtime by id
- Date: Fri, 10 Feb 2017 07:20:09 +0000 (UTC)
commit 649f0b07186153d6d1cd99cbf2725d17c8c6a210
Author: Christian Hergert <chergert redhat com>
Date: Thu Feb 9 23:19:08 2017 -0800
runtime-provider: add hooks to install a runtime by id
This will allow us to locate a runtime provider that can install a runtime
from a known runtime-id (such as might come from a .buildconfig or flatpak
configuration).
Doing so will mean we can install missing runtimes as necessary before
setting up the build pipeline.
libide/runtimes/ide-runtime-provider.c | 68 ++++++++++++++++++++++++++++++++
libide/runtimes/ide-runtime-provider.h | 36 +++++++++++++----
2 files changed, 96 insertions(+), 8 deletions(-)
---
diff --git a/libide/runtimes/ide-runtime-provider.c b/libide/runtimes/ide-runtime-provider.c
index 41483e6..165401a 100644
--- a/libide/runtimes/ide-runtime-provider.c
+++ b/libide/runtimes/ide-runtime-provider.c
@@ -33,11 +33,44 @@ ide_runtime_provider_real_unload (IdeRuntimeProvider *self,
{
}
+static gboolean
+ide_runtime_provider_real_can_install (IdeRuntimeProvider *self,
+ const gchar *runtime_id)
+{
+ return FALSE;
+}
+
+void
+ide_runtime_provider_real_install_async (IdeRuntimeProvider *self,
+ const gchar *runtime_id,
+ GCancellable *cancellable,
+ GAsyncReadyCallback callback,
+ gpointer user_data)
+{
+ g_task_report_new_error (self, callback, user_data,
+ ide_runtime_provider_real_install_async,
+ G_IO_ERROR,
+ G_IO_ERROR_NOT_SUPPORTED,
+ "%s does not support installing runtimes",
+ G_OBJECT_TYPE_NAME (self));
+}
+
+gboolean
+ide_runtime_provider_real_install_finish (IdeRuntimeProvider *self,
+ GAsyncResult *result,
+ GError **error)
+{
+ return g_task_propagate_boolean (G_TASK (result), error);
+}
+
static void
ide_runtime_provider_default_init (IdeRuntimeProviderInterface *iface)
{
iface->load = ide_runtime_provider_real_load;
iface->unload = ide_runtime_provider_real_unload;
+ iface->can_install = ide_runtime_provider_real_can_install;
+ iface->install_async = ide_runtime_provider_real_install_async;
+ iface->install_finish = ide_runtime_provider_real_install_finish;
}
void
@@ -59,3 +92,38 @@ ide_runtime_provider_unload (IdeRuntimeProvider *self,
IDE_RUNTIME_PROVIDER_GET_IFACE (self)->unload (self, manager);
}
+
+gboolean
+ide_runtime_provider_can_install (IdeRuntimeProvider *self,
+ const gchar *runtime_id)
+{
+ g_return_val_if_fail (IDE_IS_RUNTIME_PROVIDER (self), FALSE);
+ g_return_val_if_fail (runtime_id != NULL, FALSE);
+
+ return IDE_RUNTIME_PROVIDER_GET_IFACE (self)->can_install (self, runtime_id);
+}
+
+void
+ide_runtime_provider_install_async (IdeRuntimeProvider *self,
+ const gchar *runtime_id,
+ GCancellable *cancellable,
+ GAsyncReadyCallback callback,
+ gpointer user_data)
+{
+ g_return_if_fail (IDE_IS_RUNTIME_PROVIDER (self));
+ g_return_if_fail (runtime_id != NULL);
+ g_return_if_fail (!cancellable || G_IS_CANCELLABLE (cancellable));
+
+ IDE_RUNTIME_PROVIDER_GET_IFACE (self)->install_async (self, runtime_id, cancellable, callback, user_data);
+}
+
+gboolean
+ide_runtime_provider_install_finish (IdeRuntimeProvider *self,
+ GAsyncResult *result,
+ GError **error)
+{
+ g_return_val_if_fail (IDE_IS_RUNTIME_PROVIDER (self), FALSE);
+ g_return_val_if_fail (G_IS_ASYNC_RESULT (result), FALSE);
+
+ return IDE_RUNTIME_PROVIDER_GET_IFACE (self)->install_finish (self, result, error);
+}
diff --git a/libide/runtimes/ide-runtime-provider.h b/libide/runtimes/ide-runtime-provider.h
index 15098d9..a806acb 100644
--- a/libide/runtimes/ide-runtime-provider.h
+++ b/libide/runtimes/ide-runtime-provider.h
@@ -33,16 +33,36 @@ struct _IdeRuntimeProviderInterface
{
GTypeInterface parent;
- void (*load) (IdeRuntimeProvider *self,
- IdeRuntimeManager *manager);
- void (*unload) (IdeRuntimeProvider *self,
- IdeRuntimeManager *manager);
+ void (*load) (IdeRuntimeProvider *self,
+ IdeRuntimeManager *manager);
+ void (*unload) (IdeRuntimeProvider *self,
+ IdeRuntimeManager *manager);
+ gboolean (*can_install) (IdeRuntimeProvider *self,
+ const gchar *runtime_id);
+ void (*install_async) (IdeRuntimeProvider *self,
+ const gchar *runtime_id,
+ GCancellable *cancellable,
+ GAsyncReadyCallback callback,
+ gpointer user_data);
+ gboolean (*install_finish) (IdeRuntimeProvider *self,
+ GAsyncResult *result,
+ GError **error);
};
-void ide_runtime_provider_load (IdeRuntimeProvider *self,
- IdeRuntimeManager *manager);
-void ide_runtime_provider_unload (IdeRuntimeProvider *self,
- IdeRuntimeManager *manager);
+void ide_runtime_provider_load (IdeRuntimeProvider *self,
+ IdeRuntimeManager *manager);
+void ide_runtime_provider_unload (IdeRuntimeProvider *self,
+ IdeRuntimeManager *manager);
+gboolean ide_runtime_provider_can_install (IdeRuntimeProvider *self,
+ const gchar *runtime_id);
+void ide_runtime_provider_install_async (IdeRuntimeProvider *self,
+ const gchar *runtime_id,
+ GCancellable *cancellable,
+ GAsyncReadyCallback callback,
+ gpointer user_data);
+gboolean ide_runtime_provider_install_finish (IdeRuntimeProvider *self,
+ GAsyncResult *result,
+ GError **error);
G_END_DECLS
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]