Exemple #1
0
/*
 * Loads the given plugin.
 */
void
meta_plugin_manager_load (MetaPluginManager *plugin_mgr,
                          const gchar       *plugin_name)
{
  const gchar *dpath = MUTTER_PLUGIN_DIR "/";
  gchar       *path;
  MetaModule  *module;
  GType        plugin_type;

  if (g_path_is_absolute (plugin_name))
    path = g_strdup (plugin_name);
  else
    path = g_strconcat (dpath, plugin_name, ".so", NULL);

  module = g_object_new (META_TYPE_MODULE, "path", path, NULL);
  if (!module || !g_type_module_use (G_TYPE_MODULE (module)))
    {
      /* This is fatal under the assumption that a monitoring
       * process like gnome-session will take over and handle
       * our untimely exit.
       */
      g_printerr ("Unable to load plugin module [%s]: %s",
                  path, g_module_error());
      exit (1);
    }

  plugin_type = meta_module_get_plugin_type (module);
  meta_plugin_manager_register (plugin_mgr, plugin_type);

  g_type_module_unuse (G_TYPE_MODULE (module));
  g_free (path);
}
/**
 * meta_plugin_type_register:
 * @plugin_type: a #MetaPlugin type
 *
 * Register @plugin_type as a compositor plugin type to be used.
 * You must call this before calling meta_init().
 */
void
meta_plugin_type_register (GType plugin_type)
{
  MetaPluginManager *plugin_manager;

  plugin_manager = meta_plugin_manager_get_default ();
  meta_plugin_manager_register (plugin_manager, plugin_type);
}