[gnome-builder/wip/gtk4-port: 1220/1774] libide/projeects: add helper to get license resource path
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder/wip/gtk4-port: 1220/1774] libide/projeects: add helper to get license resource path
- Date: Mon, 11 Jul 2022 22:31:38 +0000 (UTC)
commit c5e206b59384e9cd9e1cb29f9637b63cc8afd890
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]