[gnome-builder] runtime: add ide_runtime_translate_file()



commit ca46b47ca44b118cc1111056a3f0ff76e8c1cddd
Author: Christian Hergert <chergert redhat com>
Date:   Tue Dec 13 17:17:29 2016 -0800

    runtime: add ide_runtime_translate_file()
    
    This allows plugins to get access to a file that is inside of a runtime.
    That may be necessary when performing operations such as compilations that
    require access to the raw files such as clang. Otherwise, we have no way
    to know what /app/include/foo/foo.h means from outside the runtime and
    therefore unable to provide valuable code-insight.

 libide/runtimes/ide-runtime.c |   28 ++++++++++++++++++++++++++++
 libide/runtimes/ide-runtime.h |    5 ++++-
 2 files changed, 32 insertions(+), 1 deletions(-)
---
diff --git a/libide/runtimes/ide-runtime.c b/libide/runtimes/ide-runtime.c
index 2123e19..1476e0e 100644
--- a/libide/runtimes/ide-runtime.c
+++ b/libide/runtimes/ide-runtime.c
@@ -572,3 +572,31 @@ ide_runtime_error_quark (void)
 
   return quark;
 }
+
+/**
+ * ide_runtime_translate_file:
+ * @self: An #IdeRuntime
+ * @file: A #GFile
+ *
+ * Translates the file from a path within the runtime to a path that can
+ * be accessed from the host system.
+ *
+ * Returns: (transfer full) (not nullable): A #GFile.
+ */
+GFile *
+ide_runtime_translate_file (IdeRuntime *self,
+                            GFile      *file)
+{
+  GFile *ret = NULL;
+
+  g_return_val_if_fail (IDE_IS_RUNTIME (self), NULL);
+  g_return_val_if_fail (G_IS_FILE (file), NULL);
+
+  if (IDE_RUNTIME_GET_CLASS (self)->translate_file)
+    ret = IDE_RUNTIME_GET_CLASS (self)->translate_file (self, file);
+
+  if (ret == NULL)
+    ret = g_object_ref (file);
+
+  return ret;
+}
diff --git a/libide/runtimes/ide-runtime.h b/libide/runtimes/ide-runtime.h
index 988ee4f..533a7ee 100644
--- a/libide/runtimes/ide-runtime.h
+++ b/libide/runtimes/ide-runtime.h
@@ -76,8 +76,9 @@ struct _IdeRuntimeClass
   gboolean               (*postinstall_finish)       (IdeRuntime           *self,
                                                       GAsyncResult         *result,
                                                       GError              **error);
+  GFile                 *(*translate_file)           (IdeRuntime           *self,
+                                                      GFile                *file);
 
-  gpointer _reserved3;
   gpointer _reserved4;
   gpointer _reserved5;
   gpointer _reserved6;
@@ -136,6 +137,8 @@ void                   ide_runtime_set_id                   (IdeRuntime
 const gchar           *ide_runtime_get_display_name         (IdeRuntime           *self);
 void                   ide_runtime_set_display_name         (IdeRuntime           *self,
                                                              const gchar          *display_name);
+GFile                 *ide_runtime_translate_file           (IdeRuntime           *self,
+                                                             GFile                *file);
 
 G_END_DECLS
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]