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
This commit is contained in:
parent
52638b9d8e
commit
a4746d75e6
@ -1906,6 +1906,10 @@ clutter_cmp_manage_screen (MetaCompositor *compositor,
|
|||||||
|
|
||||||
info->plugin_mgr =
|
info->plugin_mgr =
|
||||||
mutter_plugin_manager_new (screen);
|
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
|
* Delay the creation of the overlay window as long as we can, to avoid
|
||||||
|
@ -41,12 +41,19 @@ struct MutterPluginManager
|
|||||||
{
|
{
|
||||||
MetaScreen *screen;
|
MetaScreen *screen;
|
||||||
|
|
||||||
GList *plugins;
|
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 */
|
GList *unload; /* Plugins that are disabled and pending unload */
|
||||||
|
|
||||||
guint idle_unload_id;
|
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
|
* 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.
|
* Loads all plugins listed in gconf registry.
|
||||||
*/
|
*/
|
||||||
static gboolean
|
gboolean
|
||||||
mutter_plugin_manager_load (MutterPluginManager *plugin_mgr)
|
mutter_plugin_manager_load (MutterPluginManager *plugin_mgr)
|
||||||
{
|
{
|
||||||
const gchar *dpath = MUTTER_PLUGIN_DIR "/";
|
const gchar *dpath = MUTTER_PLUGIN_DIR "/";
|
||||||
@ -246,7 +253,6 @@ mutter_plugin_manager_load (MutterPluginManager *plugin_mgr)
|
|||||||
|
|
||||||
if (module)
|
if (module)
|
||||||
{
|
{
|
||||||
MutterPlugin *p;
|
|
||||||
gboolean use_succeeded;
|
gboolean use_succeeded;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -258,18 +264,15 @@ mutter_plugin_manager_load (MutterPluginManager *plugin_mgr)
|
|||||||
*/
|
*/
|
||||||
use_succeeded = g_type_module_use (G_TYPE_MODULE (module));
|
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
|
|
||||||
{
|
|
||||||
g_warning ("Plugin load for [%s] failed", path);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (use_succeeded)
|
if (use_succeeded)
|
||||||
g_type_module_unuse (G_TYPE_MODULE (module));
|
{
|
||||||
|
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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
g_warning ("Unable to load plugin module [%s]: %s",
|
g_warning ("Unable to load plugin module [%s]: %s",
|
||||||
@ -286,7 +289,7 @@ mutter_plugin_manager_load (MutterPluginManager *plugin_mgr)
|
|||||||
if (fallback)
|
if (fallback)
|
||||||
g_slist_free (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);
|
meta_prefs_add_listener (prefs_changed_callback, plugin_mgr);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
@ -295,6 +298,35 @@ mutter_plugin_manager_load (MutterPluginManager *plugin_mgr)
|
|||||||
return FALSE;
|
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
|
* Reloads all plugins
|
||||||
*/
|
*/
|
||||||
@ -309,12 +341,6 @@ mutter_plugin_manager_reload (MutterPluginManager *plugin_mgr)
|
|||||||
return mutter_plugin_manager_load (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 *
|
MutterPluginManager *
|
||||||
mutter_plugin_manager_new (MetaScreen *screen)
|
mutter_plugin_manager_new (MetaScreen *screen)
|
||||||
{
|
{
|
||||||
@ -330,12 +356,6 @@ mutter_plugin_manager_new (MetaScreen *screen)
|
|||||||
|
|
||||||
plugin_mgr->screen = screen;
|
plugin_mgr->screen = screen;
|
||||||
|
|
||||||
if (!mutter_plugin_manager_init (plugin_mgr))
|
|
||||||
{
|
|
||||||
g_free (plugin_mgr);
|
|
||||||
plugin_mgr = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
return plugin_mgr;
|
return plugin_mgr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -34,6 +34,8 @@
|
|||||||
typedef struct MutterPluginManager MutterPluginManager;
|
typedef struct MutterPluginManager MutterPluginManager;
|
||||||
|
|
||||||
MutterPluginManager * mutter_plugin_manager_new (MetaScreen *screen);
|
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,
|
gboolean mutter_plugin_manager_event_simple (MutterPluginManager *mgr,
|
||||||
MutterWindow *actor,
|
MutterWindow *actor,
|
||||||
unsigned long event);
|
unsigned long event);
|
||||||
|
Loading…
Reference in New Issue
Block a user