[gnome-builder/wip/gtk4-port] libide/projeects: add helper to get license resource path



commit 410833df3ffdb4d1bd6b3fef825a7394812162df
Author: Christian Hergert <chergert redhat com>
Date:   Fri May 27 18:11:07 2022 -0700

    libide/projeects: add helper to get license resource path

 src/libide/projects/ide-template-input.c | 23 +++++++++++++++++++++++
 src/libide/projects/ide-template-input.h |  2 ++
 2 files changed, 25 insertions(+)
---
diff --git a/src/libide/projects/ide-template-input.c b/src/libide/projects/ide-template-input.c
index 0ca2bbfb5..1397d4d33 100644
--- a/src/libide/projects/ide-template-input.c
+++ b/src/libide/projects/ide-template-input.c
@@ -887,6 +887,29 @@ ide_template_input_to_scope (IdeTemplateInput *self)
   return g_steal_pointer (&scope);
 }
 
+/**
+ * ide_template_input_get_license_path:
+ * @self: a #IdeTemplateInput
+ *
+ * Gets a path to a #GResource containing the full license text.
+ *
+ * Returns: (transfer full) (nullable): a resource path or %NULL
+ */
+char *
+ide_template_input_get_license_path (IdeTemplateInput *self)
+{
+  g_return_val_if_fail (IDE_IS_TEMPLATE_INPUT (self), NULL);
+
+  for (guint i = 0; i < G_N_ELEMENTS (licenses); i++)
+    {
+      if (g_strcmp0 (licenses[i].spdx, self->license_name) == 0)
+        return g_strdup_printf ("/org/gnome/libide-projects/licenses/%s",
+                                licenses[i].full_path);
+    }
+
+  return NULL;
+}
+
 /**
  * ide_template_input_get_templates_model:
  * @self: a #IdeTemplateInput
diff --git a/src/libide/projects/ide-template-input.h b/src/libide/projects/ide-template-input.h
index eec9c7365..9d3d0da96 100644
--- a/src/libide/projects/ide-template-input.h
+++ b/src/libide/projects/ide-template-input.h
@@ -101,6 +101,8 @@ GListModel                 *ide_template_input_get_licenses_model      (IdeTempl
 IDE_AVAILABLE_IN_ALL
 IdeTemplateInputValidation  ide_template_input_validate                (IdeTemplateInput     *self);
 IDE_AVAILABLE_IN_ALL
+char                       *ide_template_input_get_license_path        (IdeTemplateInput     *self);
+IDE_AVAILABLE_IN_ALL
 void                        ide_template_input_expand_async            (IdeTemplateInput     *self,
                                                                         GCancellable         *cancellable,
                                                                         GAsyncReadyCallback   callback,


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