[gnome-builder] plugins/buildui: expose runtimes as listmodel to tweaks



commit 6f6d70d411fb991d37cd841dd3557accf171b098
Author: Christian Hergert <chergert redhat com>
Date:   Tue Aug 23 23:54:49 2022 -0700

    plugins/buildui: expose runtimes as listmodel to tweaks

 src/plugins/buildui/gbp-buildui-tweaks-addin.c | 42 ++++++++++++++++++++++++--
 1 file changed, 40 insertions(+), 2 deletions(-)
---
diff --git a/src/plugins/buildui/gbp-buildui-tweaks-addin.c b/src/plugins/buildui/gbp-buildui-tweaks-addin.c
index 57cb838a6..b65d9a215 100644
--- a/src/plugins/buildui/gbp-buildui-tweaks-addin.c
+++ b/src/plugins/buildui/gbp-buildui-tweaks-addin.c
@@ -22,23 +22,61 @@
 
 #include "config.h"
 
+#include <libide-foundry.h>
+
 #include "gbp-buildui-tweaks-addin.h"
 
 struct _GbpBuilduiTweaksAddin
 {
   IdeTweaksAddin parent_instance;
+  IdeContext *context;
 };
 
 G_DEFINE_FINAL_TYPE (GbpBuilduiTweaksAddin, gbp_buildui_tweaks_addin, IDE_TYPE_TWEAKS_ADDIN)
 
+static void
+gbp_buildui_tweaks_addin_load (IdeTweaksAddin *addin,
+                               IdeTweaks      *tweaks)
+{
+  GbpBuilduiTweaksAddin *self = (GbpBuilduiTweaksAddin *)addin;
+
+  g_assert (GBP_IS_BUILDUI_TWEAKS_ADDIN (self));
+  g_assert (IDE_IS_TWEAKS (tweaks));
+
+  if ((self->context = ide_tweaks_get_context (tweaks)))
+    {
+      IdeRuntimeManager *runtime_manager = ide_runtime_manager_from_context (self->context);
+      ide_tweaks_expose_object (tweaks, "Runtimes", G_OBJECT (runtime_manager));
+    }
+
+  ide_tweaks_addin_set_resource_paths (IDE_TWEAKS_ADDIN (self),
+                                       IDE_STRV_INIT ("/plugins/buildui/tweaks.ui"));
+
+  IDE_TWEAKS_ADDIN_CLASS (gbp_buildui_tweaks_addin_parent_class)->load (addin, tweaks);
+}
+
+static void
+gbp_buildui_tweaks_addin_unload (IdeTweaksAddin *addin,
+                                 IdeTweaks      *tweaks)
+{
+  GbpBuilduiTweaksAddin *self = (GbpBuilduiTweaksAddin *)addin;
+
+  g_assert (GBP_IS_BUILDUI_TWEAKS_ADDIN (self));
+  g_assert (IDE_IS_TWEAKS (tweaks));
+
+  self->context = NULL;
+}
+
 static void
 gbp_buildui_tweaks_addin_class_init (GbpBuilduiTweaksAddinClass *klass)
 {
+  IdeTweaksAddinClass *tweaks_addin_class = IDE_TWEAKS_ADDIN_CLASS (klass);
+
+  tweaks_addin_class->load = gbp_buildui_tweaks_addin_load;
+  tweaks_addin_class->unload = gbp_buildui_tweaks_addin_unload;
 }
 
 static void
 gbp_buildui_tweaks_addin_init (GbpBuilduiTweaksAddin *self)
 {
-  ide_tweaks_addin_set_resource_paths (IDE_TWEAKS_ADDIN (self),
-                                       IDE_STRV_INIT ("/plugins/buildui/tweaks.ui"));
 }


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