[gnome-builder] libide/gui: add helper to list application plugins



commit de3ffd7f7cd9011a811a3760bfffc73acd4e2d8e
Author: Christian Hergert <chergert redhat com>
Date:   Wed Aug 17 14:52:20 2022 -0700

    libide/gui: add helper to list application plugins

 src/libide/gui/ide-application-plugins.c | 39 ++++++++++++++++++++++++++++++++
 src/libide/gui/ide-application-private.h |  1 +
 2 files changed, 40 insertions(+)
---
diff --git a/src/libide/gui/ide-application-plugins.c b/src/libide/gui/ide-application-plugins.c
index 272bdbee9..6d6d399ba 100644
--- a/src/libide/gui/ide-application-plugins.c
+++ b/src/libide/gui/ide-application-plugins.c
@@ -500,3 +500,42 @@ _ide_application_unload_addins (IdeApplication *self)
 
   g_clear_object (&self->addins);
 }
+
+/**
+ * ide_application_list_plugins:
+ * @self: a #IdeApplication
+ *
+ * Gets a list of plugins.
+ *
+ * The result contains instances of #IdePlugin as #PeasPluginInfo is a boxed
+ * type which cannot be used with #GListModel.
+ *
+ * Returns: (transfer full): a #GListModel of IdePlugin
+ */
+GListModel *
+_ide_application_list_plugins (IdeApplication *self)
+{
+  GListStore *store;
+  const GList *plugins;
+
+  g_return_val_if_fail (IDE_IS_APPLICATION (self), NULL);
+
+  store = g_list_store_new (IDE_TYPE_PLUGIN);
+  plugins = peas_engine_get_plugin_list (peas_engine_get_default ());
+
+  for (const GList *iter = plugins; iter; iter = iter->next)
+    {
+      const PeasPluginInfo *plugin_info = iter->data;
+      g_autoptr(IdePlugin) plugin = NULL;
+
+      if (peas_plugin_info_is_hidden (plugin_info))
+        continue;
+
+      plugin = g_object_new (IDE_TYPE_PLUGIN,
+                             "info", plugin_info,
+                             NULL);
+      g_list_store_append (store, plugin);
+    }
+
+  return G_LIST_MODEL (store);
+}
diff --git a/src/libide/gui/ide-application-private.h b/src/libide/gui/ide-application-private.h
index 51c0e5908..69186b18c 100644
--- a/src/libide/gui/ide-application-private.h
+++ b/src/libide/gui/ide-application-private.h
@@ -119,5 +119,6 @@ void            _ide_application_add_resources            (IdeApplication
                                                            const char              *path);
 void            _ide_application_remove_resources         (IdeApplication          *self,
                                                            const char              *path);
+GListModel     *_ide_application_list_plugins             (IdeApplication          *self);
 
 G_END_DECLS


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