[gnome-builder] plugins: check dependencies of plugin-info



commit 1d13011397b68fedbae0dc096446ab865941efff
Author: Christian Hergert <chergert redhat com>
Date:   Mon Jun 25 12:39:38 2018 -0700

    plugins: check dependencies of plugin-info
    
    When checking if we can load a plugin, we need to ensure that the deps
    are not also disabled. We'll only go one level deep here, as I don't want
    to get us into some dependency solving madness (yet).

 src/libide/application/ide-application-plugins.c | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)
---
diff --git a/src/libide/application/ide-application-plugins.c 
b/src/libide/application/ide-application-plugins.c
index 090b5bb86..1c26c6a2b 100644
--- a/src/libide/application/ide-application-plugins.c
+++ b/src/libide/application/ide-application-plugins.c
@@ -28,6 +28,9 @@
 #include "application/ide-application-private.h"
 #include "util/ide-flatpak.h"
 
+static GSettings *_ide_application_plugin_get_settings (IdeApplication *self,
+                                                        const gchar    *module_name);
+
 static const gchar *blacklisted_plugins[] = {
   "build-tools-plugin", /* Renamed to buildui */
 };
@@ -37,6 +40,7 @@ ide_application_can_load_plugin (IdeApplication *self,
                                  PeasPluginInfo *plugin_info)
 {
   const gchar *module_name;
+  const gchar **deps;
 
   g_assert (IDE_IS_APPLICATION (self));
   g_assert (plugin_info != NULL);
@@ -86,6 +90,21 @@ ide_application_can_load_plugin (IdeApplication *self,
    * Gedit's IAge is similar here, but we would need it per-structure.
    */
 
+  /*
+   * If this plugin has dependencies, we need to check that the dependencies
+   * can also be loaded.
+   */
+  if ((deps = peas_plugin_info_get_dependencies (plugin_info)))
+    {
+      for (guint i = 0; deps[i]; i++)
+        {
+          GSettings *settings = _ide_application_plugin_get_settings (self, deps[i]);
+
+          if (!g_settings_get_boolean (settings, "enabled"))
+            return FALSE;
+        }
+    }
+
   return TRUE;
 }
 


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