[mutter] Load plugins separately from initializing
- From: Owen Taylor <otaylor src gnome org>
- To: svn-commits-list gnome org
- Subject: [mutter] Load plugins separately from initializing
- Date: Fri, 24 Apr 2009 09:57:14 -0400 (EDT)
commit a4746d75e66d22b1e3b91c7eb014188d559e7edd
Author: Colin Walters <walters verbum org>
Date: Thu Nov 13 17:06:07 2008 -0500
Load plugins separately from initializing
Add separate mutter_plugin_manager_load() and
mutter_plugin_manager_initialize() calls so that we can just
load the plugins without start them. This is useful for introspecting
a gnome-shell plugin at build time.
http://bugzilla.gnome.org/show_bug.cgi?id=580032
---
src/compositor/mutter/compositor-mutter.c | 4 +
src/compositor/mutter/mutter-plugin-manager.c | 74 ++++++++++++++++---------
src/compositor/mutter/mutter-plugin-manager.h | 2 +
3 files changed, 53 insertions(+), 27 deletions(-)
diff --git a/src/compositor/mutter/compositor-mutter.c b/src/compositor/mutter/compositor-mutter.c
index 4824395..fe17a5a 100644
--- a/src/compositor/mutter/compositor-mutter.c
+++ b/src/compositor/mutter/compositor-mutter.c
@@ -1906,6 +1906,10 @@ clutter_cmp_manage_screen (MetaCompositor *compositor,
info->plugin_mgr =
mutter_plugin_manager_new (screen);
+ if (!mutter_plugin_manager_load (info->plugin_mgr))
+ g_critical ("failed to load plugins");
+ if (!mutter_plugin_manager_initialize (info->plugin_mgr))
+ g_critical ("failed to initialize plugins");
/*
* Delay the creation of the overlay window as long as we can, to avoid
diff --git a/src/compositor/mutter/mutter-plugin-manager.c b/src/compositor/mutter/mutter-plugin-manager.c
index 7ec17ef..98d3f19 100644
--- a/src/compositor/mutter/mutter-plugin-manager.c
+++ b/src/compositor/mutter/mutter-plugin-manager.c
@@ -41,12 +41,19 @@ struct MutterPluginManager
{
MetaScreen *screen;
- GList *plugins;
- GList *unload; /* Plugins that are disabled and pending unload */
+ GList /* MutterPluginPending */ *pending_plugin_modules; /* Plugins not yet fully loaded */
+ GList /* MutterPlugin */ *plugins; /* TODO -- maybe use hash table */
+ GList *unload; /* Plugins that are disabled and pending unload */
guint idle_unload_id;
};
+typedef struct MutterPluginPending
+{
+ MutterModule *module;
+ char *path;
+ char *params;
+} MutterPluginPending;
/*
* Checks that the plugin is compatible with the WM and sets up the plugin
@@ -200,7 +207,7 @@ mutter_plugin_manager_get_module (const gchar *path)
/*
* Loads all plugins listed in gconf registry.
*/
-static gboolean
+gboolean
mutter_plugin_manager_load (MutterPluginManager *plugin_mgr)
{
const gchar *dpath = MUTTER_PLUGIN_DIR "/";
@@ -246,7 +253,6 @@ mutter_plugin_manager_load (MutterPluginManager *plugin_mgr)
if (module)
{
- MutterPlugin *p;
gboolean use_succeeded;
/*
@@ -258,18 +264,15 @@ mutter_plugin_manager_load (MutterPluginManager *plugin_mgr)
*/
use_succeeded = g_type_module_use (G_TYPE_MODULE (module));
- if (use_succeeded &&
- (p = mutter_plugin_load (plugin_mgr, module, params)))
- {
- plugin_mgr->plugins = g_list_prepend (plugin_mgr->plugins, p);
- }
- else
+ if (use_succeeded)
{
- g_warning ("Plugin load for [%s] failed", path);
+ MutterPluginPending *pending = g_new0 (MutterPluginPending, 1);
+ pending->module = module;
+ pending->path = g_strdup (path);
+ pending->params = g_strdup (params);
+ plugin_mgr->pending_plugin_modules =
+ g_list_prepend (plugin_mgr->pending_plugin_modules, pending);
}
-
- if (use_succeeded)
- g_type_module_unuse (G_TYPE_MODULE (module));
}
else
g_warning ("Unable to load plugin module [%s]: %s",
@@ -286,7 +289,7 @@ mutter_plugin_manager_load (MutterPluginManager *plugin_mgr)
if (fallback)
g_slist_free (fallback);
- if (plugin_mgr->plugins != NULL)
+ if (plugin_mgr->pending_plugin_modules != NULL)
{
meta_prefs_add_listener (prefs_changed_callback, plugin_mgr);
return TRUE;
@@ -295,6 +298,35 @@ mutter_plugin_manager_load (MutterPluginManager *plugin_mgr)
return FALSE;
}
+gboolean
+mutter_plugin_manager_initialize (MutterPluginManager *plugin_mgr)
+{
+ GList *iter;
+
+ for (iter = plugin_mgr->pending_plugin_modules; iter; iter = iter->next)
+ {
+ MutterPluginPending *pending = (MutterPluginPending*) iter->data;
+ MutterPlugin *p;
+
+ if ((p = mutter_plugin_load (plugin_mgr, pending->module, pending->params)))
+ {
+ plugin_mgr->plugins = g_list_prepend (plugin_mgr->plugins, p);
+ }
+ else
+ {
+ g_warning ("Plugin load for [%s] failed", pending->path);
+ }
+
+ g_type_module_unuse (G_TYPE_MODULE (pending->module));
+ g_free (pending->path);
+ g_free (pending->params);
+ g_free (pending);
+ }
+ g_list_free (plugin_mgr->pending_plugin_modules);
+ plugin_mgr->pending_plugin_modules = NULL;
+ return TRUE;
+}
+
/*
* Reloads all plugins
*/
@@ -309,12 +341,6 @@ mutter_plugin_manager_reload (MutterPluginManager *plugin_mgr)
return mutter_plugin_manager_load (plugin_mgr);
}
-static gboolean
-mutter_plugin_manager_init (MutterPluginManager *plugin_mgr)
-{
- return mutter_plugin_manager_load (plugin_mgr);
-}
-
MutterPluginManager *
mutter_plugin_manager_new (MetaScreen *screen)
{
@@ -330,12 +356,6 @@ mutter_plugin_manager_new (MetaScreen *screen)
plugin_mgr->screen = screen;
- if (!mutter_plugin_manager_init (plugin_mgr))
- {
- g_free (plugin_mgr);
- plugin_mgr = NULL;
- }
-
return plugin_mgr;
}
diff --git a/src/compositor/mutter/mutter-plugin-manager.h b/src/compositor/mutter/mutter-plugin-manager.h
index e4647b6..e7b75de 100644
--- a/src/compositor/mutter/mutter-plugin-manager.h
+++ b/src/compositor/mutter/mutter-plugin-manager.h
@@ -34,6 +34,8 @@
typedef struct MutterPluginManager MutterPluginManager;
MutterPluginManager * mutter_plugin_manager_new (MetaScreen *screen);
+gboolean mutter_plugin_manager_load (MutterPluginManager *mgr);
+gboolean mutter_plugin_manager_initialize (MutterPluginManager *plugin_mgr);
gboolean mutter_plugin_manager_event_simple (MutterPluginManager *mgr,
MutterWindow *actor,
unsigned long event);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]