[gedit] Port gedit to libpeas 0.5.0



commit dbc98da7fda69981e61c5764af50c72b756eb2cc
Author: Steve Frécinaux <code istique net>
Date:   Sun Jun 13 19:46:28 2010 +0200

    Port gedit to libpeas 0.5.0
    
    No plugin have been updated yet.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=606363

 Makefile.am                              |    2 +-
 configure.ac                             |    4 +-
 gedit/Makefile.am                        |   10 -
 gedit/dialogs/gedit-preferences-dialog.c |   10 +-
 gedit/gedit-dirs.c                       |   30 +-
 gedit/gedit-dirs.h                       |    5 +-
 gedit/gedit-plugin-info-priv.h           |   69 ---
 gedit/gedit-plugin-info.c                |  402 --------------
 gedit/gedit-plugin-info.h                |   64 ---
 gedit/gedit-plugin-loader.c              |  132 -----
 gedit/gedit-plugin-loader.h              |  108 ----
 gedit/gedit-plugin-manager.c             |  895 ------------------------------
 gedit/gedit-plugin-manager.h             |   85 ---
 gedit/gedit-plugin.c                     |  339 -----------
 gedit/gedit-plugin.h                     |  242 --------
 gedit/gedit-plugins-engine.c             |  863 +++--------------------------
 gedit/gedit-plugins-engine.h             |   43 +--
 gedit/gedit-window-private.h             |    3 +
 gedit/gedit-window.c                     |   77 ++-
 plugin-loaders/Makefile.am               |    3 -
 plugin-loaders/c/Makefile.am             |   24 -
 plugin-loaders/c/gedit-plugin-loader-c.c |  183 ------
 plugin-loaders/c/gedit-plugin-loader-c.h |   61 --
 23 files changed, 170 insertions(+), 3484 deletions(-)
---
diff --git a/Makefile.am b/Makefile.am
index e57b203..9c3bd85 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -1,7 +1,7 @@
 ## Process this file with automake to produce Makefile.in
 ACLOCAL_AMFLAGS = -I m4
 
-SUBDIRS = gedit pixmaps po data plugin-loaders plugins docs tests win32 osx
+SUBDIRS = gedit pixmaps po data docs tests win32 osx
 
 if !OS_OSX
 SUBDIRS += help
diff --git a/configure.ac b/configure.ac
index 3ff43ea..5da30d4 100644
--- a/configure.ac
+++ b/configure.ac
@@ -271,6 +271,8 @@ PKG_CHECK_MODULES(GEDIT, [
 	gio-2.0 >= 2.25.10
 	gtk+-3.0 >= 2.90.0
 	gtksourceview-3.0 >= 2.11.2
+	libpeas-1.0
+	libpeasui-1.0
 ])
 
 if test "$os_osx" = "no" &&
@@ -400,8 +402,6 @@ gedit/smclient/Makefile
 gedit/Makefile
 help/Makefile
 pixmaps/Makefile
-plugin-loaders/Makefile
-plugin-loaders/c/Makefile
 plugins/Makefile
 plugins/changecase/Makefile
 plugins/checkupdate/org.gnome.gedit.checkupdate.gschema.xml.in
diff --git a/gedit/Makefile.am b/gedit/Makefile.am
index 0548420..dc79446 100644
--- a/gedit/Makefile.am
+++ b/gedit/Makefile.am
@@ -111,11 +111,6 @@ NOINST_H_FILES =			\
 	gedit-language-manager.h	\
 	gedit-multi-notebook.h		\
 	gedit-notebook.h		\
-	gedit-object-module.h		\
-	gedit-plugin-info.h		\
-	gedit-plugin-info-priv.h	\
-	gedit-plugin-loader.h		\
-	gedit-plugin-manager.h		\
 	gedit-plugins-engine.h		\
 	gedit-print-job.h		\
 	gedit-print-preview.h		\
@@ -140,7 +135,6 @@ INST_H_FILES =				\
 	gedit-message-type.h		\
 	gedit-message.h			\
 	gedit-panel.h			\
-	gedit-plugin.h			\
 	gedit-progress-info-bar.h	\
 	gedit-statusbar.h		\
 	gedit-status-combo-box.h	\
@@ -191,10 +185,6 @@ libgedit_c_files =			\
 	gedit-object-module.c		\
 	gedit-notebook.c		\
 	gedit-panel.c			\
-	gedit-plugin-info.c		\
-	gedit-plugin.c			\
-	gedit-plugin-loader.c		\
-	gedit-plugin-manager.c		\
 	gedit-plugins-engine.c		\
 	gedit-print-job.c		\
 	gedit-print-preview.c		\
diff --git a/gedit/dialogs/gedit-preferences-dialog.c b/gedit/dialogs/gedit-preferences-dialog.c
index e63258b..0e0009e 100644
--- a/gedit/dialogs/gedit-preferences-dialog.c
+++ b/gedit/dialogs/gedit-preferences-dialog.c
@@ -1,7 +1,5 @@
 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
 /*
-	gedit_plugins_engine_activate_plugins (gedit_plugins_engine_get_default (),
-					        window);
  * gedit-preferences-dialog.c
  * This file is part of gedit
  *
@@ -39,14 +37,15 @@
 #include <string.h>
 
 #include <glib/gi18n.h>
+#include <libpeasui/peas-ui-plugin-manager.h>
 
 #include "gedit-preferences-dialog.h"
 #include "gedit-utils.h"
 #include "gedit-debug.h"
 #include "gedit-document.h"
 #include "gedit-style-scheme-manager.h"
-#include "gedit-plugin-manager.h"
 #include "gedit-dirs.h"
+#include "gedit-plugins-engine.h"
 #include "gedit-settings.h"
 #include "gedit-utils.h"
 
@@ -905,11 +904,14 @@ setup_font_colors_page (GeditPreferencesDialog *dlg)
 static void
 setup_plugins_page (GeditPreferencesDialog *dlg)
 {
+	GeditPluginsEngine *engine;
 	GtkWidget *page_content;
 
 	gedit_debug (DEBUG_PREFS);
 
-	page_content = gedit_plugin_manager_new ();
+	engine = gedit_plugins_engine_get_default ();
+
+	page_content = peas_ui_plugin_manager_new (PEAS_ENGINE (engine));
 	g_return_if_fail (page_content != NULL);
 
 	gtk_box_pack_start (GTK_BOX (dlg->priv->plugin_manager_place_holder),
diff --git a/gedit/gedit-dirs.c b/gedit/gedit-dirs.c
index a85e2b0..4fee92f 100644
--- a/gedit/gedit-dirs.c
+++ b/gedit/gedit-dirs.c
@@ -288,19 +288,25 @@ gedit_dirs_get_gedit_plugins_dir (void)
 }
 
 gchar *
-gedit_dirs_get_gedit_plugin_loaders_dir (void)
+gedit_dirs_get_gedit_plugins_data_dir (void)
 {
-	gchar *lib_dir;
-	gchar *loader_dir;
-	
-	lib_dir = gedit_dirs_get_gedit_lib_dir ();
-	
-	loader_dir = g_build_filename (lib_dir,
-				       "plugin-loaders",
-				       NULL);
-	g_free (lib_dir);
-	
-	return loader_dir;
+	gchar *data_dir;
+	gchar *plugin_data_dir;
+
+	data_dir = gedit_dirs_get_gedit_data_dir ();
+
+	plugin_data_dir = g_build_filename (data_dir,
+					    "plugins",
+					    NULL);
+	g_free (data_dir);
+
+	return plugin_data_dir;
+}
+
+gchar *
+gedit_dirs_get_binding_modules_dir (void)
+{
+	return gedit_dirs_get_gedit_lib_dir ();
 }
 
 gchar *
diff --git a/gedit/gedit-dirs.h b/gedit/gedit-dirs.h
index ba79cee..e0be2f9 100644
--- a/gedit/gedit-dirs.h
+++ b/gedit/gedit-dirs.h
@@ -44,8 +44,9 @@ gchar		*gedit_dirs_get_gedit_lib_dir		(void);
 
 gchar		*gedit_dirs_get_gedit_plugins_dir	(void);
 
-gchar		*gedit_dirs_get_gedit_plugin_loaders_dir
-							(void);
+gchar		*gedit_dirs_get_gedit_plugins_data_dir	(void);
+
+gchar		*gedit_dirs_get_binding_modules_dir	(void);
 
 gchar		*gedit_dirs_get_ui_file			(const gchar *file);
 
diff --git a/gedit/gedit-plugins-engine.c b/gedit/gedit-plugins-engine.c
index 8902662..13e2d77 100644
--- a/gedit/gedit-plugins-engine.c
+++ b/gedit/gedit-plugins-engine.c
@@ -3,6 +3,7 @@
  * This file is part of gedit
  *
  * Copyright (C) 2002-2005 Paolo Maggi 
+ * Copyright (C) 2010 Steve Frécinaux
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -35,14 +36,11 @@
 #include <string.h>
 
 #include <glib/gi18n.h>
+#include <girepository.h>
 
 #include "gedit-plugins-engine.h"
-#include "gedit-plugin-info-priv.h"
-#include "gedit-plugin.h"
 #include "gedit-debug.h"
 #include "gedit-app.h"
-#include "gedit-plugin-loader.h"
-#include "gedit-object-module.h"
 #include "gedit-dirs.h"
 #include "gedit-settings.h"
 #include "gedit-utils.h"
@@ -50,852 +48,145 @@
 #define GEDIT_PLUGINS_ENGINE_BASE_KEY "/apps/gedit-2/plugins"
 #define GEDIT_PLUGINS_ENGINE_KEY GEDIT_PLUGINS_ENGINE_BASE_KEY "/active-plugins"
 
-#define PLUGIN_EXT	".gedit-plugin"
-#define LOADER_EXT	G_MODULE_SUFFIX
-
-typedef struct
-{
-	GeditPluginLoader *loader;
-	GeditObjectModule *module;
-} LoaderInfo;
-
-/* Signals */
-enum
-{
-	ACTIVATE_PLUGIN,
-	DEACTIVATE_PLUGIN,
-	LAST_SIGNAL
-};
-
-static guint signals[LAST_SIGNAL];
-
-G_DEFINE_TYPE(GeditPluginsEngine, gedit_plugins_engine, G_TYPE_OBJECT)
+G_DEFINE_TYPE(GeditPluginsEngine, gedit_plugins_engine, PEAS_TYPE_ENGINE)
 
 struct _GeditPluginsEnginePrivate
 {
 	GSettings *plugin_settings;
-
-	GList *plugin_list;
-	GHashTable *loaders;
-
-	gboolean activate_from_prefs;
-	
-	guint scanned : 1;
+	gboolean loading_plugin_list : 1;
 };
 
 GeditPluginsEngine *default_engine = NULL;
 
-static void	gedit_plugins_engine_activate_plugin_real	(GeditPluginsEngine *engine,
-								 GeditPluginInfo    *info);
-static void	gedit_plugins_engine_deactivate_plugin_real	(GeditPluginsEngine *engine,
-								 GeditPluginInfo    *info);
-
-typedef gboolean (*LoadDirCallback)(GeditPluginsEngine *engine, const gchar *filename, gpointer userdata);
-
-static gboolean
-load_dir_real (GeditPluginsEngine *engine,
-	       const gchar        *dir,
-	       const gchar        *suffix,
-	       LoadDirCallback     callback,
-	       gpointer            userdata)
-{
-	GError *error = NULL;
-	GDir *d;
-	const gchar *dirent;
-	gboolean ret = TRUE;
-
-	g_return_val_if_fail (dir != NULL, TRUE);
-
-	gedit_debug_message (DEBUG_PLUGINS, "DIR: %s", dir);
-
-	d = g_dir_open (dir, 0, &error);
-	if (!d)
-	{
-		g_warning ("%s", error->message);
-		g_error_free (error);
-		return TRUE;
-	}
-	
-	while ((dirent = g_dir_read_name (d)))
-	{
-		gchar *filename;
-
-		if (!g_str_has_suffix (dirent, suffix))
-			continue;
-
-		filename = g_build_filename (dir, dirent, NULL);
-
-		ret = callback (engine, filename, userdata);
-
-		g_free (filename);
-
-		if (!ret)
-			break;
-	}
-
-	g_dir_close (d);
-	return ret;
-}
-
-static gboolean
-load_plugin_info (GeditPluginsEngine *engine,
-		  const gchar        *filename,
-		  gpointer            userdata)
-{
-	GeditPluginInfo *info;
-	
-	info = _gedit_plugin_info_new (filename);
-
-	if (info == NULL)
-		return TRUE;
-
-	/* If a plugin with this name has already been loaded
-	 * drop this one (user plugins override system plugins) */
-	if (gedit_plugins_engine_get_plugin_info (engine, gedit_plugin_info_get_module_name (info)) != NULL)
-	{
-		gedit_debug_message (DEBUG_PLUGINS, "Two or more plugins named '%s'. "
-				     "Only the first will be considered.\n",
-				     gedit_plugin_info_get_module_name (info));
-
-		_gedit_plugin_info_unref (info);
-
-		return TRUE;
-	}
-
-	engine->priv->plugin_list = g_list_prepend (engine->priv->plugin_list, info);
-
-	gedit_debug_message (DEBUG_PLUGINS, "Plugin %s loaded", info->name);
-	return TRUE;
-}
-
-static void
-load_all_plugins (GeditPluginsEngine *engine)
-{
-	gchar *plugin_dir;
-	const gchar *pdirs_env = NULL;
-
-	/* load user plugins */
-	plugin_dir = gedit_dirs_get_user_plugins_dir ();
-	if (g_file_test (plugin_dir, G_FILE_TEST_IS_DIR))
-	{
-		load_dir_real (engine,
-			       plugin_dir,
-			       PLUGIN_EXT,
-			       load_plugin_info,
-			       NULL);
-
-	}
-	g_free (plugin_dir);
-
-	/* load system plugins */
-	pdirs_env = g_getenv ("GEDIT_PLUGINS_PATH");
-
-	gedit_debug_message (DEBUG_PLUGINS, "GEDIT_PLUGINS_PATH=%s", pdirs_env);
-
-	if (pdirs_env != NULL)
-	{
-		gchar **pdirs;
-		gint i;
-
-		pdirs = g_strsplit (pdirs_env, G_SEARCHPATH_SEPARATOR_S, 0);
-
-		for (i = 0; pdirs[i] != NULL; i++)
-		{
-			if (!load_dir_real (engine,
-					    pdirs[i],
-					    PLUGIN_EXT,
-					    load_plugin_info,
-					    NULL))
-			{
-				break;
-			}
-		}
-
-		g_strfreev (pdirs);
-	}
-	else
-	{
-		plugin_dir = gedit_dirs_get_gedit_plugins_dir ();
-
-		load_dir_real (engine,
-			       plugin_dir,
-			       PLUGIN_EXT,
-			       load_plugin_info,
-			       NULL);
-
-		g_free (plugin_dir);
-	}
-}
-
-static guint
-hash_lowercase (gconstpointer data)
-{
-	gchar *lowercase;
-	guint ret;
-	
-	lowercase = g_ascii_strdown ((const gchar *)data, -1);
-	ret = g_str_hash (lowercase);
-	g_free (lowercase);
-	
-	return ret;
-}
-
-static gboolean
-equal_lowercase (gconstpointer a, gconstpointer b)
-{
-	return g_ascii_strcasecmp ((const gchar *)a, (const gchar *)b) == 0;
-}
-
-static void
-loader_destroy (LoaderInfo *info)
-{
-	if (!info)
-		return;
-	
-	if (info->loader)
-		g_object_unref (info->loader);
-	
-	g_free (info);
-}
-
-static void
-add_loader (GeditPluginsEngine *engine,
-	    const gchar        *loader_id,
-	    GeditObjectModule  *module)
-{
-	LoaderInfo *info;
-
-	info = g_new (LoaderInfo, 1);
-	info->loader = NULL;
-	info->module = module;
-
-	g_hash_table_insert (engine->priv->loaders, g_strdup (loader_id), info);
-}
-
 static void
 gedit_plugins_engine_init (GeditPluginsEngine *engine)
 {
 	gedit_debug (DEBUG_PLUGINS);
 
-	if (!g_module_supported ())
-	{
-		g_warning ("gedit is not able to initialize the plugins engine.");
-		return;
-	}
-
 	engine->priv = G_TYPE_INSTANCE_GET_PRIVATE (engine,
 						    GEDIT_TYPE_PLUGINS_ENGINE,
 						    GeditPluginsEnginePrivate);
 
 	engine->priv->plugin_settings = g_settings_new ("org.gnome.gedit.plugins");
 
-	load_all_plugins (engine);
-
-	/* make sure that the first reactivation will read active plugins
-	   from the prefs */
-	engine->priv->activate_from_prefs = TRUE;
-
-	/* mapping from loadername -> loader object */
-	engine->priv->loaders = g_hash_table_new_full (hash_lowercase,
-						       equal_lowercase,
-						       (GDestroyNotify)g_free,
-						       (GDestroyNotify)loader_destroy);
+	engine->priv->loading_plugin_list = FALSE;
 }
 
 static void
-loader_garbage_collect (const char *id, LoaderInfo *info)
+save_plugin_list (GeditPluginsEngine *engine)
 {
-	if (info->loader)
-		gedit_plugin_loader_garbage_collect (info->loader);
-}
+	gchar **loaded_plugins;
 
-void
-gedit_plugins_engine_garbage_collect (GeditPluginsEngine *engine)
-{
-	g_hash_table_foreach (engine->priv->loaders,
-			      (GHFunc) loader_garbage_collect,
-			      NULL);
-}
+	loaded_plugins = peas_engine_get_loaded_plugins (PEAS_ENGINE (engine));
 
-static void
-gedit_plugins_engine_finalize (GObject *object)
-{
-	GeditPluginsEngine *engine = GEDIT_PLUGINS_ENGINE (object);
-	GList *item;
-	
-	gedit_debug (DEBUG_PLUGINS);
+	g_settings_set_strv (engine->priv->plugin_settings,
+			     GEDIT_SETTINGS_ACTIVE_PLUGINS,
+			     (const gchar * const *) loaded_plugins);
 
-	/* Firs deactivate all plugins */
-	for (item = engine->priv->plugin_list; item; item = item->next)
-	{
-		GeditPluginInfo *info = GEDIT_PLUGIN_INFO (item->data);
-		
-		if (gedit_plugin_info_is_active (info))
-			gedit_plugins_engine_deactivate_plugin_real (engine, info);
-	}
-	
-	/* unref the loaders */	
-	g_hash_table_destroy (engine->priv->loaders);
-
-	/* and finally free the infos */
-	for (item = engine->priv->plugin_list; item; item = item->next)
-	{
-		GeditPluginInfo *info = GEDIT_PLUGIN_INFO (item->data);
-
-		_gedit_plugin_info_unref (info);
-	}
-
-	g_list_free (engine->priv->plugin_list);
-
-	G_OBJECT_CLASS (gedit_plugins_engine_parent_class)->finalize (object);
+	g_strfreev (loaded_plugins);
 }
 
 static void
-gedit_plugins_engine_dispose (GObject *object)
+gedit_plugins_engine_load_plugin (PeasEngine     *engine,
+				  PeasPluginInfo *info)
 {
-	GeditPluginsEngine *engine = GEDIT_PLUGINS_ENGINE (object);
-	
-	if (engine->priv->plugin_settings != NULL)
-	{
-		g_object_unref (engine->priv->plugin_settings);
-		engine->priv->plugin_settings = NULL;
-	}
-	
-	G_OBJECT_CLASS (gedit_plugins_engine_parent_class)->dispose (object);
-}
-
-static void
-gedit_plugins_engine_class_init (GeditPluginsEngineClass *klass)
-{
-	GType the_type = G_TYPE_FROM_CLASS (klass);
-	GObjectClass *object_class = G_OBJECT_CLASS (klass);
-
-	object_class->finalize = gedit_plugins_engine_finalize;
-	object_class->dispose = gedit_plugins_engine_dispose;
-	klass->activate_plugin = gedit_plugins_engine_activate_plugin_real;
-	klass->deactivate_plugin = gedit_plugins_engine_deactivate_plugin_real;
-
-	signals[ACTIVATE_PLUGIN] =
-		g_signal_new ("activate-plugin",
-			      the_type,
-			      G_SIGNAL_RUN_LAST,
-			      G_STRUCT_OFFSET (GeditPluginsEngineClass, activate_plugin),
-			      NULL, NULL,
-			      g_cclosure_marshal_VOID__BOXED,
-			      G_TYPE_NONE,
-			      1,
-			      GEDIT_TYPE_PLUGIN_INFO | G_SIGNAL_TYPE_STATIC_SCOPE);
-
-	signals[DEACTIVATE_PLUGIN] =
-		g_signal_new ("deactivate-plugin",
-			      the_type,
-			      G_SIGNAL_RUN_LAST,
-			      G_STRUCT_OFFSET (GeditPluginsEngineClass, deactivate_plugin),
-			      NULL, NULL,
-			      g_cclosure_marshal_VOID__BOXED,
-			      G_TYPE_NONE,
-			      1,
-			      GEDIT_TYPE_PLUGIN_INFO | G_SIGNAL_TYPE_STATIC_SCOPE);
+	GeditPluginsEngine *gengine = GEDIT_PLUGINS_ENGINE (engine);
 
-	g_type_class_add_private (klass, sizeof (GeditPluginsEnginePrivate));
-}
+	PEAS_ENGINE_CLASS (gedit_plugins_engine_parent_class)->load_plugin (engine, info);
 
-static gboolean
-load_loader (GeditPluginsEngine *engine,
-	     const gchar        *filename,
-	     gpointer		 data)
-{
-	GeditObjectModule *module;
-	gchar *base;
-	gchar *path;
-	const gchar *id;
-	GType type;
-	
-	/* try to load in the module */
-	path = g_path_get_dirname (filename);
-	base = g_path_get_basename (filename);
-
-	/* for now they are all resident */
-	module = gedit_object_module_new (base,
-					  path,
-					  "register_gedit_plugin_loader",
-					  TRUE);
-
-	g_free (base);
-	g_free (path);
-
-	/* make sure to load the type definition */
-	if (!g_type_module_use (G_TYPE_MODULE (module)))
+	/* We won't save the plugin list if we are currently loading the
+	 * plugins from the saved list */
+	if (!gengine->priv->loading_plugin_list && peas_plugin_info_is_loaded (info))
 	{
-		g_object_unref (module);
-		g_warning ("Plugin loader module `%s' could not be loaded", filename);
-
-		return TRUE;
+		save_plugin_list (gengine);
 	}
-
-	/* get the exported type and check the name as exported by the 
-	 * loader interface */
-	type = gedit_object_module_get_object_type (module);
-	id = gedit_plugin_loader_type_get_id (type);
-	
-	add_loader (engine, id, module);	
-	g_type_module_unuse (G_TYPE_MODULE (module));
-
-	return TRUE;
 }
 
 static void
-ensure_loader (LoaderInfo *info)
-{
-	if (info->loader == NULL && info->module != NULL)
-	{
-		/* create a new loader object */
-		GeditPluginLoader *loader;
-		loader = (GeditPluginLoader *)gedit_object_module_new_object (info->module, NULL);
-	
-		if (loader == NULL || !GEDIT_IS_PLUGIN_LOADER (loader))
-		{
-			g_warning ("Loader object is not a valid GeditPluginLoader instance");
-		
-			if (loader != NULL && G_IS_OBJECT (loader))
-				g_object_unref (loader);
-		}
-		else
-		{
-			info->loader = loader;
-		}
-	}
-}
-
-static GeditPluginLoader *
-get_plugin_loader (GeditPluginsEngine *engine,
-		   GeditPluginInfo    *info)
+gedit_plugins_engine_unload_plugin (PeasEngine     *engine,
+				    PeasPluginInfo *info)
 {
-	const gchar *loader_id;
-	LoaderInfo *loader_info;
-
-	loader_id = info->loader;
-
-	loader_info = (LoaderInfo *)g_hash_table_lookup (
-			engine->priv->loaders, 
-			loader_id);
+	GeditPluginsEngine *gengine = GEDIT_PLUGINS_ENGINE (engine);
 
-	if (loader_info == NULL && !engine->priv->scanned)
-	{
-		gchar *loader_dir;
-
-		loader_dir = gedit_dirs_get_gedit_plugin_loaders_dir ();
-
-		/* loader could not be found in the hash, try to find it by 
-		   scanning */
-		load_dir_real (engine, 
-			       loader_dir,
-			       LOADER_EXT,
-			       (LoadDirCallback)load_loader,
-			       NULL);
-		g_free (loader_dir);
-		
-		loader_info = (LoaderInfo *)g_hash_table_lookup (
-				engine->priv->loaders, 
-				loader_id);
-
-		engine->priv->scanned = TRUE;
-	}
+	PEAS_ENGINE_CLASS (gedit_plugins_engine_parent_class)->unload_plugin (engine, info);
 
-	if (loader_info == NULL)
+	/* We won't save the plugin list if we are currently unloading the
+	 * plugins from the saved list */
+	if (!gengine->priv->loading_plugin_list && !peas_plugin_info_is_loaded (info))
 	{
-		/* cache non-existent so we don't scan again */
-		add_loader (engine, loader_id, NULL);
-		return NULL;
+		save_plugin_list (gengine);
 	}
-	
-	ensure_loader (loader_info);
-	return loader_info->loader;
-}
-
-GeditPluginsEngine *
-gedit_plugins_engine_get_default (void)
-{
-	if (default_engine != NULL)
-		return default_engine;
-
-	default_engine = GEDIT_PLUGINS_ENGINE (g_object_new (GEDIT_TYPE_PLUGINS_ENGINE, NULL));
-	g_object_add_weak_pointer (G_OBJECT (default_engine),
-				   (gpointer) &default_engine);
-	return default_engine;
-}
-
-const GList *
-gedit_plugins_engine_get_plugin_list (GeditPluginsEngine *engine)
-{
-	gedit_debug (DEBUG_PLUGINS);
-
-	return engine->priv->plugin_list;
-}
-
-static gint
-compare_plugin_info_and_name (GeditPluginInfo *info,
-			      const gchar     *module_name)
-{
-	return strcmp (gedit_plugin_info_get_module_name (info), module_name);
-}
-
-GeditPluginInfo *
-gedit_plugins_engine_get_plugin_info (GeditPluginsEngine *engine,
-				      const gchar        *name)
-{
-	GList *l = g_list_find_custom (engine->priv->plugin_list,
-				       name,
-				       (GCompareFunc) compare_plugin_info_and_name);
-
-	return l == NULL ? NULL : (GeditPluginInfo *) l->data;
-}
-
-static void
-save_active_plugin_list (GeditPluginsEngine *engine)
-{
-	GSList *active_plugins = NULL;
-	GList *l;
-
-	for (l = engine->priv->plugin_list; l != NULL; l = l->next)
-	{
-		GeditPluginInfo *info = (GeditPluginInfo *) l->data;
-
-		if (gedit_plugin_info_is_active (info))
-		{
-			active_plugins = g_slist_prepend (active_plugins,
-							  (gpointer)gedit_plugin_info_get_module_name (info));
-		}
-	}
-
-	gedit_settings_set_list (engine->priv->plugin_settings,
-				 GEDIT_SETTINGS_ACTIVE_PLUGINS,
-				 active_plugins);
-
-	g_slist_free (active_plugins);
-}
-
-static gboolean
-load_plugin (GeditPluginsEngine *engine,
-	     GeditPluginInfo    *info)
-{
-	GeditPluginLoader *loader;
-	gchar *path;
-
-	if (gedit_plugin_info_is_active (info))
-		return TRUE;
-	
-	if (!gedit_plugin_info_is_available (info))
-		return FALSE;
-
-	loader = get_plugin_loader (engine, info);
-	
-	if (loader == NULL)
-	{
-		g_warning ("Could not find loader `%s' for plugin `%s'", info->loader, info->name);
-		info->available = FALSE;
-		return FALSE;
-	}
-	
-	path = g_path_get_dirname (info->file);
-	g_return_val_if_fail (path != NULL, FALSE);
-
-	info->plugin = gedit_plugin_loader_load (loader, info, path);
-	
-	g_free (path);
-	
-	if (info->plugin == NULL)
-	{
-		g_warning ("Error loading plugin '%s'", info->name);
-		info->available = FALSE;
-		return FALSE;
-	}
-	
-	return TRUE;
 }
 
 static void
-gedit_plugins_engine_activate_plugin_real (GeditPluginsEngine *engine,
-					   GeditPluginInfo    *info)
-{
-	const GList *wins;
-
-	if (!load_plugin (engine, info))
-		return;
-
-	for (wins = gedit_app_get_windows (gedit_app_get_default ());
-	     wins != NULL;
-	     wins = wins->next)
-	{
-		gedit_plugin_activate (info->plugin, GEDIT_WINDOW (wins->data));
-	}
-}
-
-gboolean
-gedit_plugins_engine_activate_plugin (GeditPluginsEngine *engine,
-				      GeditPluginInfo    *info)
-{
-	gedit_debug (DEBUG_PLUGINS);
-
-	g_return_val_if_fail (info != NULL, FALSE);
-
-	if (!gedit_plugin_info_is_available (info))
-		return FALSE;
-		
-	if (gedit_plugin_info_is_active (info))
-		return TRUE;
-
-	g_signal_emit (engine, signals[ACTIVATE_PLUGIN], 0, info);
-
-	if (gedit_plugin_info_is_active (info))
-		save_active_plugin_list (engine);
-
-	return gedit_plugin_info_is_active (info);
-}
-
-static void
-call_plugin_deactivate (GeditPlugin *plugin, 
-			GeditWindow *window)
-{
-	gedit_plugin_deactivate (plugin, window);
-
-	/* ensure update of ui manager, because we suspect it does something
-	   with expected static strings in the type module (when unloaded the
-	   strings don't exist anymore, and ui manager updates in an idle
-	   func) */
-	gtk_ui_manager_ensure_update (gedit_window_get_ui_manager (window));
-}
-
-static void
-gedit_plugins_engine_deactivate_plugin_real (GeditPluginsEngine *engine,
-					     GeditPluginInfo    *info)
-{
-	const GList *wins;
-	GeditPluginLoader *loader;
-
-	if (!gedit_plugin_info_is_active (info) || 
-	    !gedit_plugin_info_is_available (info))
-		return;
-
-	for (wins = gedit_app_get_windows (gedit_app_get_default ());
-	     wins != NULL;
-	     wins = wins->next)
-	{
-		call_plugin_deactivate (info->plugin, GEDIT_WINDOW (wins->data));
-	}
-
-	/* first unref the plugin (the loader still has one) */
-	g_object_unref (info->plugin);
-	
-	/* find the loader and tell it to gc and unload the plugin */
-	loader = get_plugin_loader (engine, info);
-	
-	gedit_plugin_loader_garbage_collect (loader);
-	gedit_plugin_loader_unload (loader, info);
-	
-	info->plugin = NULL;
-}
-
-gboolean
-gedit_plugins_engine_deactivate_plugin (GeditPluginsEngine *engine,
-					GeditPluginInfo    *info)
+gedit_plugins_engine_class_init (GeditPluginsEngineClass *klass)
 {
-	gedit_debug (DEBUG_PLUGINS);
-
-	g_return_val_if_fail (info != NULL, FALSE);
-
-	if (!gedit_plugin_info_is_active (info))
-		return TRUE;
+	PeasEngineClass *engine_class = PEAS_ENGINE_CLASS (klass);
 
-	g_signal_emit (engine, signals[DEACTIVATE_PLUGIN], 0, info);
-	if (!gedit_plugin_info_is_active (info))
-		save_active_plugin_list (engine);
+	engine_class->load_plugin = gedit_plugins_engine_load_plugin;
+	engine_class->unload_plugin = gedit_plugins_engine_unload_plugin;
 
-	return !gedit_plugin_info_is_active (info);
+	g_type_class_add_private (klass, sizeof (GeditPluginsEnginePrivate));
 }
 
-void
-gedit_plugins_engine_activate_plugins (GeditPluginsEngine *engine,
-					GeditWindow       *window)
+GeditPluginsEngine *
+gedit_plugins_engine_get_default (void)
 {
-	GSList *active_plugins = NULL;
-	GList *pl;
+	gchar *modules_dir;
+	gchar **search_paths;
 
-	gedit_debug (DEBUG_PLUGINS);
-
-	g_return_if_fail (GEDIT_IS_PLUGINS_ENGINE (engine));
-	g_return_if_fail (GEDIT_IS_WINDOW (window));
-
-	/* the first time, we get the 'active' plugins from gconf */
-	if (engine->priv->activate_from_prefs)
+	if (default_engine != NULL)
 	{
-		active_plugins = gedit_settings_get_list (engine->priv->plugin_settings,
-							  GEDIT_SETTINGS_ACTIVE_PLUGINS);
+		return default_engine;
 	}
 
-	for (pl = engine->priv->plugin_list; pl; pl = pl->next)
-	{
-		GeditPluginInfo *info = (GeditPluginInfo*)pl->data;
-		
-		if (engine->priv->activate_from_prefs && 
-		    g_slist_find_custom (active_plugins,
-					 gedit_plugin_info_get_module_name (info),
-					 (GCompareFunc)strcmp) == NULL)
-		{
-			continue;
-		}
-		
-		/* If plugin is not active, don't try to activate/load it */
-		if (!engine->priv->activate_from_prefs && 
-		    !gedit_plugin_info_is_active (info))
-		{
-			continue;
-		}
-
-		if (load_plugin (engine, info))
-		{
-			gedit_plugin_activate (info->plugin,
-					       window);
-		}
-	}
-	
-	if (engine->priv->activate_from_prefs)
-	{
-		g_slist_foreach (active_plugins, (GFunc) g_free, NULL);
-		g_slist_free (active_plugins);
-		engine->priv->activate_from_prefs = FALSE;
-	}
-	
-	gedit_debug_message (DEBUG_PLUGINS, "End");
+	/* This should be moved to libpeas */
+	g_irepository_require (g_irepository_get_default (),
+			       "Peas", "1.0", 0, NULL);
+	g_irepository_require (g_irepository_get_default (),
+			       "PeasUI", "1.0", 0, NULL);
+
+	modules_dir = gedit_dirs_get_binding_modules_dir ();
+	search_paths = g_new (gchar *, 5);
+	/* Add the user plugins dir in ~ */
+	search_paths[0] = gedit_dirs_get_user_plugins_dir ();
+	search_paths[1] = gedit_dirs_get_user_plugins_dir ();
+	/* Add the system plugins dir */
+	search_paths[2] = gedit_dirs_get_gedit_plugins_dir ();
+	search_paths[3] = gedit_dirs_get_gedit_plugins_data_dir ();
+	/* Add the trailing NULL */
+	search_paths[4] = NULL;
+
+	default_engine = GEDIT_PLUGINS_ENGINE (g_object_new (GEDIT_TYPE_PLUGINS_ENGINE,
+							     "app-name", "Gedit",
+							     "base-module-dir", modules_dir,
+							     "search-paths", search_paths,
+							     NULL));
+
+	g_strfreev (search_paths);
+	g_free (modules_dir);
 
-	/* also call update_ui after activation */
-	gedit_plugins_engine_update_plugins_ui (engine, window);
-}
+	g_object_add_weak_pointer (G_OBJECT (default_engine),
+				   (gpointer) &default_engine);
 
-void
-gedit_plugins_engine_deactivate_plugins (GeditPluginsEngine *engine,
-					  GeditWindow       *window)
-{
-	GList *pl;
-	
-	gedit_debug (DEBUG_PLUGINS);
+	gedit_plugins_engine_active_plugins_changed (default_engine);
 
-	g_return_if_fail (GEDIT_IS_PLUGINS_ENGINE (engine));
-	g_return_if_fail (GEDIT_IS_WINDOW (window));
-	
-	for (pl = engine->priv->plugin_list; pl; pl = pl->next)
-	{
-		GeditPluginInfo *info = (GeditPluginInfo*)pl->data;
-		
-		/* check if the plugin is actually active */
-		if (!gedit_plugin_info_is_active (info))
-			continue;
-		
-		/* call deactivate for the plugin for this window */
-		gedit_plugin_deactivate (info->plugin, window);
-	}
-	
-	gedit_debug_message (DEBUG_PLUGINS, "End");
+	return default_engine;
 }
 
 void
-gedit_plugins_engine_update_plugins_ui (GeditPluginsEngine *engine,
-					 GeditWindow       *window)
-{
-	GList *pl;
-
-	gedit_debug (DEBUG_PLUGINS);
-
-	g_return_if_fail (GEDIT_IS_PLUGINS_ENGINE (engine));
-	g_return_if_fail (GEDIT_IS_WINDOW (window));
-
-	/* call update_ui for all active plugins */
-	for (pl = engine->priv->plugin_list; pl; pl = pl->next)
-	{
-		GeditPluginInfo *info = (GeditPluginInfo*)pl->data;
-
-		if (!gedit_plugin_info_is_active (info))
-			continue;
-			
-	       	gedit_debug_message (DEBUG_PLUGINS, "Updating UI of %s", info->name);
-		gedit_plugin_update_ui (info->plugin, window);
-	}
-}
-
-void 	 
-gedit_plugins_engine_configure_plugin (GeditPluginsEngine *engine,
-				       GeditPluginInfo    *info,
-				       GtkWindow          *parent)
-{
-	GtkWidget *conf_dlg;
-	
-	GtkWindowGroup *wg;
-	
-	gedit_debug (DEBUG_PLUGINS);
-
-	g_return_if_fail (info != NULL);
-
-	conf_dlg = gedit_plugin_create_configure_dialog (info->plugin);
-	g_return_if_fail (conf_dlg != NULL);
-	gtk_window_set_transient_for (GTK_WINDOW (conf_dlg),
-				      parent);
-
-	if (gtk_window_has_group (parent))
-	{
-		wg = gtk_window_get_group (parent);
-	}
-	else
-	{
-		wg = gtk_window_group_new ();
-		gtk_window_group_add_window (wg, parent);
-	}
-			
-	gtk_window_group_add_window (wg,
-				     GTK_WINDOW (conf_dlg));
-		
-	gtk_window_set_modal (GTK_WINDOW (conf_dlg), TRUE);		     
-	gtk_widget_show (conf_dlg);
-}
-
-void 
 gedit_plugins_engine_active_plugins_changed (GeditPluginsEngine *engine)
 {
-	gboolean to_activate;
-	GSList *active_plugins;
-	GList *pl;
-
-	gedit_debug (DEBUG_PLUGINS);
-
-	active_plugins = gedit_settings_get_list (engine->priv->plugin_settings,
-						  GEDIT_SETTINGS_ACTIVE_PLUGINS);
-
-	for (pl = engine->priv->plugin_list; pl; pl = pl->next)
-	{
-		GeditPluginInfo *info = (GeditPluginInfo*)pl->data;
-
-		if (!gedit_plugin_info_is_available (info))
-			continue;
+	gchar **loaded_plugins;
 
-		to_activate = (g_slist_find_custom (active_plugins,
-						    gedit_plugin_info_get_module_name (info),
-						    (GCompareFunc)strcmp) != NULL);
+	loaded_plugins = g_settings_get_strv (engine->priv->plugin_settings,
+					      GEDIT_SETTINGS_ACTIVE_PLUGINS);
 
-		if (!gedit_plugin_info_is_active (info) && to_activate)
-			g_signal_emit (engine, signals[ACTIVATE_PLUGIN], 0, info);
-		else if (gedit_plugin_info_is_active (info) && !to_activate)
-			g_signal_emit (engine, signals[DEACTIVATE_PLUGIN], 0, info);
-	}
-
-	g_slist_foreach (active_plugins, (GFunc) g_free, NULL);
-	g_slist_free (active_plugins);
-}
-
-void
-gedit_plugins_engine_rescan_plugins (GeditPluginsEngine *engine)
-{
-	gedit_debug (DEBUG_PLUGINS);
-	
-	load_all_plugins (engine);
+	engine->priv->loading_plugin_list = TRUE;
+	peas_engine_set_loaded_plugins (PEAS_ENGINE (engine),
+					(const gchar **) loaded_plugins);
+	engine->priv->loading_plugin_list = FALSE;
+	g_strfreev (loaded_plugins);
 }
 
-/* ex:ts=8:noet: */
+/* ex:set ts=8 noet: */
diff --git a/gedit/gedit-plugins-engine.h b/gedit/gedit-plugins-engine.h
index 0ebb7f2..dba35f4 100644
--- a/gedit/gedit-plugins-engine.h
+++ b/gedit/gedit-plugins-engine.h
@@ -3,6 +3,7 @@
  * This file is part of gedit
  *
  * Copyright (C) 2002-2005 - Paolo Maggi 
+ * Copyright (C) 2010 - Steve Frécinaux
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -32,9 +33,7 @@
 #define __GEDIT_PLUGINS_ENGINE_H__
 
 #include <glib.h>
-#include "gedit-window.h"
-#include "gedit-plugin-info.h"
-#include "gedit-plugin.h"
+#include <libpeas/peas-engine.h>
 
 G_BEGIN_DECLS
 
@@ -50,7 +49,7 @@ typedef struct _GeditPluginsEnginePrivate	GeditPluginsEnginePrivate;
 
 struct _GeditPluginsEngine
 {
-	GObject parent;
+	PeasEngine parent;
 	GeditPluginsEnginePrivate *priv;
 };
 
@@ -58,50 +57,16 @@ typedef struct _GeditPluginsEngineClass		GeditPluginsEngineClass;
 
 struct _GeditPluginsEngineClass
 {
-	GObjectClass parent_class;
-
-	void	 (* activate_plugin)		(GeditPluginsEngine *engine,
-						 GeditPluginInfo    *info);
-
-	void	 (* deactivate_plugin)		(GeditPluginsEngine *engine,
-						 GeditPluginInfo    *info);
+	PeasEngineClass parent_class;
 };
 
 GType			 gedit_plugins_engine_get_type		(void) G_GNUC_CONST;
 
 GeditPluginsEngine	*gedit_plugins_engine_get_default	(void);
 
-void			 gedit_plugins_engine_garbage_collect	(GeditPluginsEngine *engine);
-
-const GList		*gedit_plugins_engine_get_plugin_list 	(GeditPluginsEngine *engine);
-
-GeditPluginInfo		*gedit_plugins_engine_get_plugin_info	(GeditPluginsEngine *engine,
-								 const gchar        *name);
-
-/* plugin load and unloading (overall, for all windows) */
-gboolean 		 gedit_plugins_engine_activate_plugin 	(GeditPluginsEngine *engine,
-								 GeditPluginInfo    *info);
-gboolean 		 gedit_plugins_engine_deactivate_plugin	(GeditPluginsEngine *engine,
-								 GeditPluginInfo    *info);
-
-void	 		 gedit_plugins_engine_configure_plugin	(GeditPluginsEngine *engine,
-								 GeditPluginInfo    *info,
-								 GtkWindow          *parent);
-
-/* plugin activation/deactivation per window, private to GeditWindow */
-void 			 gedit_plugins_engine_activate_plugins	(GeditPluginsEngine *engine,
-								  GeditWindow        *window);
-void 			 gedit_plugins_engine_deactivate_plugins
-								(GeditPluginsEngine *engine,
-								  GeditWindow        *window);
-void			 gedit_plugins_engine_update_plugins_ui	(GeditPluginsEngine *engine,
-								  GeditWindow        *window);
-
 /* private for gconf notification */
 void		 gedit_plugins_engine_active_plugins_changed	(GeditPluginsEngine *engine);
 
-void		 gedit_plugins_engine_rescan_plugins		(GeditPluginsEngine *engine);
-
 G_END_DECLS
 
 #endif  /* __GEDIT_PLUGINS_ENGINE_H__ */
diff --git a/gedit/gedit-window-private.h b/gedit/gedit-window-private.h
index 9f02055..b3dac50 100644
--- a/gedit/gedit-window-private.h
+++ b/gedit/gedit-window-private.h
@@ -31,6 +31,8 @@
 #ifndef __GEDIT_WINDOW_PRIVATE_H__
 #define __GEDIT_WINDOW_PRIVATE_H__
 
+#include <libpeas/peas-extension-set.h>
+
 #include "gedit/gedit-window.h"
 #include "gedit-message-bus.h"
 #include "gedit-settings.h"
@@ -62,6 +64,7 @@ struct _GeditWindowPrivate
 	GtkWidget      *language_combo;
 	
 	GeditMessageBus *message_bus;	
+	PeasExtensionSet *extensions;
 
 	/* Widgets for fullscreen mode */
 	GtkWidget      *fullscreen_controls;
diff --git a/gedit/gedit-window.c b/gedit/gedit-window.c
index 071ff57..1ffc82d 100644
--- a/gedit/gedit-window.c
+++ b/gedit/gedit-window.c
@@ -38,6 +38,8 @@
 
 #include <glib/gi18n.h>
 #include <gio/gio.h>
+#include <libpeas/peas-activatable.h>
+#include <libpeas/peas-extension-set.h>
 
 #include "gedit-ui.h"
 #include "gedit-window.h"
@@ -255,7 +257,7 @@ gedit_window_dispose (GObject *object)
 	/* First of all, force collection so that plugins
 	 * really drop some of the references.
 	 */
-	gedit_plugins_engine_garbage_collect (gedit_plugins_engine_get_default ());
+	peas_engine_garbage_collect (PEAS_ENGINE (gedit_plugins_engine_get_default ()));
 
 	/* save the panes position and make sure to deactivate plugins
 	 * for this window, but only once */
@@ -264,8 +266,14 @@ gedit_window_dispose (GObject *object)
 		save_window_state (GTK_WIDGET (window));
 		save_panes_state (window);
 
-		gedit_plugins_engine_deactivate_plugins (gedit_plugins_engine_get_default (),
-					                  window);
+		peas_extension_set_call (window->priv->extensions,
+					 "deactivate",
+					 window);
+
+		g_object_unref (window->priv->extensions);
+
+		peas_engine_garbage_collect (PEAS_ENGINE (gedit_plugins_engine_get_default ()));
+
 		window->priv->dispose_has_run = TRUE;
 	}
 
@@ -332,7 +340,7 @@ gedit_window_dispose (GObject *object)
 	/* Now that there have broken some reference loops,
 	 * force collection again.
 	 */
-	gedit_plugins_engine_garbage_collect (gedit_plugins_engine_get_default ());
+	peas_engine_garbage_collect (PEAS_ENGINE (gedit_plugins_engine_get_default ()));
 
 #ifdef OS_OSX
 	remove_mac_root_menu (window);
@@ -439,7 +447,7 @@ static void
 gedit_window_tab_removed (GeditWindow *window,
 			  GeditTab    *tab)
 {
-	gedit_plugins_engine_garbage_collect (gedit_plugins_engine_get_default ());
+	peas_engine_garbage_collect (PEAS_ENGINE (gedit_plugins_engine_get_default ()));
 }
 
 static void
@@ -965,8 +973,7 @@ set_sensitivity_according_to_tab (GeditWindow *window,
 
 	update_next_prev_doc_sensitivity (window, tab);
 
-	gedit_plugins_engine_update_plugins_ui (gedit_plugins_engine_get_default (),
-						window);
+	peas_extension_set_call (window->priv->extensions, "update_state", window);
 }
 
 static void
@@ -3014,8 +3021,7 @@ sync_name (GeditTab    *tab,
 	g_free (escaped_name);
 	g_free (tip);
 
-	gedit_plugins_engine_update_plugins_ui (gedit_plugins_engine_get_default (),
-						 window);
+	peas_extension_set_call (window->priv->extensions, "update_state", window);
 }
 
 static GeditWindow *
@@ -3417,8 +3423,7 @@ selection_changed (GeditDocument *doc,
 				  editable &&
 				  gtk_text_buffer_get_has_selection (GTK_TEXT_BUFFER (doc)));
 
-	gedit_plugins_engine_update_plugins_ui (gedit_plugins_engine_get_default (),
-						 window);
+	peas_extension_set_call (window->priv->extensions, "update_state", window);
 }
 
 static void
@@ -3427,8 +3432,7 @@ sync_languages_menu (GeditDocument *doc,
 		     GeditWindow   *window)
 {
 	update_languages_menu (window);
-	gedit_plugins_engine_update_plugins_ui (gedit_plugins_engine_get_default (),
-						 window);
+	peas_extension_set_call (window->priv->extensions, "update_state", window);
 }
 
 static void
@@ -3441,8 +3445,7 @@ readonly_changed (GeditDocument *doc,
 
 	sync_name (gedit_window_get_active_tab (window), NULL, window);
 
-	gedit_plugins_engine_update_plugins_ui (gedit_plugins_engine_get_default (),
-						window);
+	peas_extension_set_call (window->priv->extensions, "update_state", window);
 }
 
 static void
@@ -3450,8 +3453,7 @@ editable_changed (GeditView  *view,
                   GParamSpec  *arg1,
                   GeditWindow *window)
 {
-	gedit_plugins_engine_update_plugins_ui (gedit_plugins_engine_get_default (),
-						 window);
+	peas_extension_set_call (window->priv->extensions, "update_state", window);
 }
 
 static void
@@ -3683,8 +3685,7 @@ on_tab_removed (GeditMultiNotebook *multi,
 
 		if (num_tabs == 0)
 		{
-			gedit_plugins_engine_update_plugins_ui (gedit_plugins_engine_get_default (),
-								window);
+			peas_extension_set_call (window->priv->extensions, "update_state", window);
 		}
 	}
 
@@ -4118,6 +4119,30 @@ setup_mac_menu (GeditWindow *window)
 #endif
 
 static void
+extension_added (PeasExtensionSet *extensions,
+		 PeasPluginInfo   *info,
+		 PeasExtension    *exten,
+		 GeditWindow      *window)
+{
+	peas_extension_call (exten, "activate", window);
+}
+
+static void
+extension_removed (PeasExtensionSet *extensions,
+		   PeasPluginInfo   *info,
+		   PeasExtension    *exten,
+		   GeditWindow      *window)
+{
+	peas_extension_call (exten, "deactivate", window);
+
+	/* Ensure update of ui manager, because we suspect it does something
+	 * with expected static strings in the type module (when unloaded the
+	 * strings don't exist anymore, and ui manager updates in an idle
+	 * func) */
+	gtk_ui_manager_ensure_update (window->priv->manager);
+}
+
+static void
 gedit_window_init (GeditWindow *window)
 {
 	GtkWidget *main_box;
@@ -4288,8 +4313,18 @@ gedit_window_init (GeditWindow *window)
 
 	gedit_debug_message (DEBUG_WINDOW, "Update plugins ui");
 	
-	gedit_plugins_engine_activate_plugins (gedit_plugins_engine_get_default (),
-					        window);
+	window->priv->extensions = peas_extension_set_new (PEAS_ENGINE (gedit_plugins_engine_get_default ()),
+							   PEAS_TYPE_ACTIVATABLE);
+	g_signal_connect (window->priv->extensions,
+			  "extension-added",
+			  G_CALLBACK (extension_added),
+			  window);
+	g_signal_connect (window->priv->extensions,
+			  "extension-removed",
+			  G_CALLBACK (extension_removed),
+			  window);
+	peas_extension_set_call (window->priv->extensions, "activate", window);
+
 
 	/* set visibility of panes.
 	 * This needs to be done after plugins activatation */



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