[gnome-builder] prefs: load IdePreferencesAddin into perspective



commit 6fc3703ee51aa6f57a4eeb3103b5b218f3f1d2b4
Author: Christian Hergert <chergert redhat com>
Date:   Sat Nov 7 12:09:37 2015 -0800

    prefs: load IdePreferencesAddin into perspective

 libide/preferences/ide-preferences-perspective.c |   43 ++++++++++++++++++++++
 1 files changed, 43 insertions(+), 0 deletions(-)
---
diff --git a/libide/preferences/ide-preferences-perspective.c 
b/libide/preferences/ide-preferences-perspective.c
index 52ae1b2..9ffc295 100644
--- a/libide/preferences/ide-preferences-perspective.c
+++ b/libide/preferences/ide-preferences-perspective.c
@@ -19,9 +19,11 @@
 #define G_LOG_DOMAIN "ide-preferences-perspective"
 
 #include <glib/gi18n.h>
+#include <libpeas/peas.h>
 
 #include "ide-perspective.h"
 #include "ide-preferences.h"
+#include "ide-preferences-addin.h"
 #include "ide-preferences-builtin.h"
 #include "ide-preferences-container.h"
 #include "ide-preferences-font-button.h"
@@ -38,6 +40,7 @@ struct _IdePreferencesPerspective
 
   guint                  last_widget_id;
 
+  PeasExtensionSet      *extensions;
   GSequence             *pages;
   GHashTable            *widgets;
 
@@ -75,6 +78,28 @@ sort_by_priority (gconstpointer a,
 }
 
 static void
+ide_preferences_perspective_extension_added (PeasExtensionSet *set,
+                                             PeasPluginInfo   *plugin_info,
+                                             PeasExtension    *extension,
+                                             gpointer          user_data)
+{
+  IdePreferencesPerspective *self = user_data;
+
+  ide_preferences_addin_load (IDE_PREFERENCES_ADDIN (extension), IDE_PREFERENCES (self));
+}
+
+static void
+ide_preferences_perspective_extension_removed (PeasExtensionSet *set,
+                                               PeasPluginInfo   *plugin_info,
+                                               PeasExtension    *extension,
+                                               gpointer          user_data)
+{
+  IdePreferencesPerspective *self = user_data;
+
+  ide_preferences_addin_unload (IDE_PREFERENCES_ADDIN (extension), IDE_PREFERENCES (self));
+}
+
+static void
 ide_preferences_perspective_constructed (GObject *object)
 {
   IdePreferencesPerspective *self = (IdePreferencesPerspective *)object;
@@ -82,6 +107,24 @@ ide_preferences_perspective_constructed (GObject *object)
   G_OBJECT_CLASS (ide_preferences_perspective_parent_class)->constructed (object);
 
   _ide_preferences_builtin_register (IDE_PREFERENCES (self));
+
+  self->extensions = peas_extension_set_new (peas_engine_get_default (),
+                                             IDE_TYPE_PREFERENCES_ADDIN,
+                                             NULL);
+
+  g_signal_connect (self->extensions,
+                    "extension-added",
+                    G_CALLBACK (ide_preferences_perspective_extension_added),
+                    self);
+
+  g_signal_connect (self->extensions,
+                    "extension-removed",
+                    G_CALLBACK (ide_preferences_perspective_extension_removed),
+                    self);
+
+  peas_extension_set_foreach (self->extensions,
+                              ide_preferences_perspective_extension_added,
+                              self);
 }
 
 static void


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