[gnome-builder] libide/foundry: add description for configurations



commit b89514638a2da7f8ca89a68145ca6bb9fb0db287
Author: Christian Hergert <chergert redhat com>
Date:   Sat Aug 27 16:18:50 2022 -0700

    libide/foundry: add description for configurations
    
    That way we can give users some info about what subsystem a configuration
    came from.

 po/POTFILES.in                                   |  1 +
 src/libide/foundry/ide-config.c                  | 36 ++++++++++++++++++++++++
 src/libide/foundry/ide-config.h                  |  3 ++
 src/plugins/buildconfig/ide-buildconfig-config.c |  9 ++++++
 src/plugins/flatpak/gbp-flatpak-manifest.c       | 11 ++++++++
 5 files changed, 60 insertions(+)
---
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 7db8e7f19..a89b86127 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -186,6 +186,7 @@ src/plugins/flatpak/gbp-flatpak-config-provider.c
 src/plugins/flatpak/gbp-flatpak-download-stage.c
 src/plugins/flatpak/gbp-flatpak-install-dialog.c
 src/plugins/flatpak/gbp-flatpak-install-dialog.ui
+src/plugins/flatpak/gbp-flatpak-manifest.c
 src/plugins/flatpak/gbp-flatpak-pipeline-addin.c
 src/plugins/flatpak/gbp-flatpak-run-command-provider.c
 src/plugins/flatpak/gbp-flatpak-runtime.c
diff --git a/src/libide/foundry/ide-config.c b/src/libide/foundry/ide-config.c
index 93ba2c24e..3bcd112d2 100644
--- a/src/libide/foundry/ide-config.c
+++ b/src/libide/foundry/ide-config.c
@@ -106,6 +106,7 @@ enum {
   PROP_TOOLCHAIN,
   PROP_RUN_OPTS,
   PROP_SUPPORTED_RUNTIMES,
+  PROP_DESCRIPTION,
   N_PROPS
 };
 
@@ -363,6 +364,10 @@ ide_config_get_property (GObject    *object,
 
   switch (prop_id)
     {
+    case PROP_DESCRIPTION:
+      g_value_take_string (value, ide_config_get_description (self));
+      break;
+
     case PROP_CONFIG_OPTS:
       g_value_set_string (value, ide_config_get_config_opts (self));
       break;
@@ -566,6 +571,11 @@ ide_config_class_init (IdeConfigClass *klass)
   klass->get_runtime = ide_config_real_get_runtime;
   klass->set_runtime = ide_config_real_set_runtime;
 
+  properties[PROP_DESCRIPTION] =
+    g_param_spec_string ("description", NULL, NULL,
+                         NULL,
+                         (G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
+
   properties [PROP_PREPEND_PATH] =
     g_param_spec_string ("prepend-path",
                          "Prepend Path",
@@ -1941,3 +1951,29 @@ ide_config_set_args_for_phase (IdeConfig           *self,
 
   g_hash_table_insert (priv->pipeline_args, GINT_TO_POINTER (phase), g_strdupv ((gchar **)args));
 }
+
+/**
+ * ide_config_get_description:
+ * @self: a #IdeConfig
+ *
+ * Describes the type of config this is.
+ *
+ * Examples might include ".buildconfig" or "Flatpak".
+ *
+ * Returns: (transfer full): a string describing the configuration.
+ */
+char *
+ide_config_get_description (IdeConfig *self)
+{
+  char *ret = NULL;
+
+  g_return_val_if_fail (IDE_IS_CONFIG (self), NULL);
+
+  if (IDE_CONFIG_GET_CLASS (self)->get_description)
+    ret = IDE_CONFIG_GET_CLASS (self)->get_description (self);
+
+  if (ret == NULL)
+    ret = g_strdup (G_OBJECT_TYPE_NAME (self));
+
+  return ret;
+}
diff --git a/src/libide/foundry/ide-config.h b/src/libide/foundry/ide-config.h
index f5c224fad..919977eda 100644
--- a/src/libide/foundry/ide-config.h
+++ b/src/libide/foundry/ide-config.h
@@ -54,11 +54,14 @@ struct _IdeConfigClass
   gboolean    (*supports_runtime) (IdeConfig  *self,
                                    IdeRuntime *runtime);
   GPtrArray  *(*get_extensions)   (IdeConfig  *self);
+  char       *(*get_description)  (IdeConfig  *self);
 
   /*< private >*/
   gpointer _reserved[15];
 };
 
+IDE_AVAILABLE_IN_ALL
+char                 *ide_config_get_description           (IdeConfig             *self);
 IDE_AVAILABLE_IN_ALL
 const gchar          *ide_config_get_prepend_path          (IdeConfig             *self);
 IDE_AVAILABLE_IN_ALL
diff --git a/src/plugins/buildconfig/ide-buildconfig-config.c 
b/src/plugins/buildconfig/ide-buildconfig-config.c
index 9d7910528..6239afda9 100644
--- a/src/plugins/buildconfig/ide-buildconfig-config.c
+++ b/src/plugins/buildconfig/ide-buildconfig-config.c
@@ -45,6 +45,12 @@ G_DEFINE_FINAL_TYPE (IdeBuildconfigConfig, ide_buildconfig_config, IDE_TYPE_CONF
 
 static GParamSpec *properties [N_PROPS];
 
+static char *
+ide_buildconfig_config_get_description (IdeConfig *config)
+{
+  return g_strdup (".buildconfig");
+}
+
 static void
 ide_buildconfig_config_finalize (GObject *object)
 {
@@ -115,11 +121,14 @@ static void
 ide_buildconfig_config_class_init (IdeBuildconfigConfigClass *klass)
 {
   GObjectClass *object_class = G_OBJECT_CLASS (klass);
+  IdeConfigClass *config_class = IDE_CONFIG_CLASS (klass);
 
   object_class->finalize = ide_buildconfig_config_finalize;
   object_class->get_property = ide_buildconfig_config_get_property;
   object_class->set_property = ide_buildconfig_config_set_property;
 
+  config_class->get_description = ide_buildconfig_config_get_description;
+
   properties [PROP_PREBUILD] =
     g_param_spec_boxed ("prebuild", NULL, NULL,
                         G_TYPE_STRV,
diff --git a/src/plugins/flatpak/gbp-flatpak-manifest.c b/src/plugins/flatpak/gbp-flatpak-manifest.c
index 479c47198..81d39047d 100644
--- a/src/plugins/flatpak/gbp-flatpak-manifest.c
+++ b/src/plugins/flatpak/gbp-flatpak-manifest.c
@@ -21,6 +21,10 @@
 
 #define G_LOG_DOMAIN "gbp-flatpak-manifest"
 
+#include "config.h"
+
+#include <glib/gi18n.h>
+
 #include <json-glib/json-glib.h>
 
 #include "gbp-flatpak-client.h"
@@ -674,6 +678,12 @@ gbp_flatpak_manifest_get_extensions (IdeConfig *config)
   return g_steal_pointer (&ret);
 }
 
+static char *
+gbp_flatpak_manifest_get_description (IdeConfig *config)
+{
+  return g_strdup (_("Flatpak"));
+}
+
 static void
 gbp_flatpak_manifest_finalize (GObject *object)
 {
@@ -751,6 +761,7 @@ gbp_flatpak_manifest_class_init (GbpFlatpakManifestClass *klass)
 
   config_class->get_extensions = gbp_flatpak_manifest_get_extensions;
   config_class->supports_runtime = gbp_flatpak_manifest_supports_runtime;
+  config_class->get_description = gbp_flatpak_manifest_get_description;
 
   properties [PROP_FILE] =
     g_param_spec_object ("file",


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