[gnome-builder/gnome-builder-43] libide/foundry: add translation API to IdeConfig
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder/gnome-builder-43] libide/foundry: add translation API to IdeConfig
- Date: Fri, 30 Sep 2022 00:58:54 +0000 (UTC)
commit afc302aa98ec6338a6cfb482506899d5f70678eb
Author: Christian Hergert <chergert redhat com>
Date: Thu Sep 29 17:48:09 2022 -0700
libide/foundry: add translation API to IdeConfig
We really want this at the config level than just on a runtime because
it allows more control over complex resolution. For example, Flatpak
manifests will need to look in SDK extensions, SDKs, Debug runtimes,
the platform runtime, and additionally the staging directory while building
the application.
This is a backport for GNOME 43 and therefore API stays private.
src/libide/foundry/ide-config.c | 37 +++++++++++++++++++++++++++++++++++++
src/libide/foundry/ide-config.h | 8 ++++++--
2 files changed, 43 insertions(+), 2 deletions(-)
---
diff --git a/src/libide/foundry/ide-config.c b/src/libide/foundry/ide-config.c
index c635ce555..4fd7834f8 100644
--- a/src/libide/foundry/ide-config.c
+++ b/src/libide/foundry/ide-config.c
@@ -172,6 +172,21 @@ ide_config_emit_changed (IdeConfig *self)
g_signal_emit (self, signals [CHANGED], 0);
}
+static GFile *
+ide_config_real_translate_file (IdeConfig *self,
+ GFile *file)
+{
+ IdeRuntime *runtime;
+
+ g_assert (IDE_IS_CONFIG (self));
+ g_assert (G_IS_FILE (file));
+
+ if ((runtime = ide_config_get_runtime (self)))
+ return ide_runtime_translate_file (runtime, file);
+
+ return g_object_ref (file);
+}
+
static IdeRuntime *
ide_config_real_get_runtime (IdeConfig *self)
{
@@ -587,6 +602,7 @@ ide_config_class_init (IdeConfigClass *klass)
klass->get_runtime = ide_config_real_get_runtime;
klass->set_runtime = ide_config_real_set_runtime;
+ klass->translate_file = ide_config_real_translate_file;
properties[PROP_DESCRIPTION] =
g_param_spec_string ("description", NULL, NULL,
@@ -1994,3 +2010,24 @@ ide_config_get_description (IdeConfig *self)
return ret;
}
+
+/**
+ * ide_config_translate_file:
+ * @self: a #IdeConfig
+ *
+ * Requests translation of the file path to one available in the
+ * current process. That might mean translating to a path that
+ * allows access outside Builder's sandbox such as using
+ * /var/run/host or depoy-directories of OSTree commits.
+ *
+ * Returns: (transfer full) (nullable): a #GFile or %NULL
+ */
+GFile *
+ide_config_translate_file (IdeConfig *self,
+ GFile *file)
+{
+ g_return_val_if_fail (IDE_IS_CONFIG (self), NULL);
+ g_return_val_if_fail (G_IS_FILE (file), NULL);
+
+ return IDE_CONFIG_GET_CLASS (self)->translate_file (self, file);
+}
diff --git a/src/libide/foundry/ide-config.h b/src/libide/foundry/ide-config.h
index 919977eda..372466ee9 100644
--- a/src/libide/foundry/ide-config.h
+++ b/src/libide/foundry/ide-config.h
@@ -55,9 +55,11 @@ struct _IdeConfigClass
IdeRuntime *runtime);
GPtrArray *(*get_extensions) (IdeConfig *self);
char *(*get_description) (IdeConfig *self);
+ GFile *(*translate_file) (IdeConfig *self,
+ GFile *file);
/*< private >*/
- gpointer _reserved[15];
+ gpointer _reserved[14];
};
IDE_AVAILABLE_IN_ALL
@@ -239,6 +241,8 @@ IDE_AVAILABLE_IN_ALL
void ide_config_set_args_for_phase (IdeConfig *self,
IdePipelinePhase phase,
const gchar *const *args);
-
+G_GNUC_INTERNAL
+GFile *ide_config_translate_file (IdeConfig *self,
+ GFile *file);
G_END_DECLS
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]