![]() |
![]() |
![]() |
Peas Reference Manual | ![]() |
---|---|---|---|---|
Top | Description | Object Hierarchy | Properties | Signals |
PeasEngine; PeasEngineClass; PeasEngine * peas_engine_new (const gchar *app_name
,const gchar *base_module_dir
,const gchar **search_paths
); void peas_engine_rescan_plugins (PeasEngine *engine
); const GList * peas_engine_get_plugin_list (PeasEngine *engine
); gchar ** peas_engine_get_loaded_plugins (PeasEngine *engine
); void peas_engine_set_loaded_plugins (PeasEngine *engine
,const gchar **plugin_names
); PeasPluginInfo * peas_engine_get_plugin_info (PeasEngine *engine
,const gchar *plugin_name
); gboolean peas_engine_load_plugin (PeasEngine *engine
,PeasPluginInfo *info
); gboolean peas_engine_unload_plugin (PeasEngine *engine
,PeasPluginInfo *info
); void peas_engine_garbage_collect (PeasEngine *engine
); gboolean peas_engine_provides_extension (PeasEngine *engine
,PeasPluginInfo *info
,GType extension_type
); PeasExtension * peas_engine_get_extension (PeasEngine *engine
,PeasPluginInfo *info
,GType extension_type
); void peas_engine_disable_loader (PeasEngine *engine
,const gchar *loader_id
);
"app-name" gchar* : Read / Write / Construct Only "base-module-dir" gchar* : Read / Write / Construct Only "plugin-list" gpointer : Read "search-paths" GStrv* : Read / Write / Construct Only
The PeasEngine is the object which manages the plugins. Its role is twofold: First it will fetch all the information about the available plugins from all the registered plugin directories, and second it will provide you an API to load, control and unload the plugins from within your application.
typedef struct { GObjectClass parent_class; void (*load_plugin) (PeasEngine *engine, PeasPluginInfo *info); void (*unload_plugin) (PeasEngine *engine, PeasPluginInfo *info); } PeasEngineClass;
PeasEngine * peas_engine_new (const gchar *app_name
,const gchar *base_module_dir
,const gchar **search_paths
);
Returns a new PeasEngine object. See the properties description for more information about the parameters.
|
The name of the application. [allow-none] |
|
The base directory for language modules |
|
The paths where to look for plugins |
Returns : |
a newly created PeasEngine object. |
void peas_engine_rescan_plugins (PeasEngine *engine
);
Rescan all the registered directories to find new or updated plugins.
Calling this function will make the newly installed plugin infos to be loaded by the engine, so the new plugins can actually be used without restarting the application.
|
A PeasEngine. |
const GList * peas_engine_get_plugin_list (PeasEngine *engine
);
Returns the list of PeasPluginInfo known to the engine.
|
A PeasEngine. |
Returns : |
a GList of PeasPluginInfo. Note that the list belongs to the engine and should not be freed. [transfer none][element-type Peas.PluginInfo] |
gchar ** peas_engine_get_loaded_plugins (PeasEngine *engine
);
Returns the list of the names of all the loaded plugins, or NULL
if there
is no plugin currently loaded. Please note that the returned array is a
newly allocated one: you will need to free it using g_strfreev()
.
|
A PeasEngine. |
Returns : |
A newly-allocated NULL-terminated array of strings, or NULL .
|
void peas_engine_set_loaded_plugins (PeasEngine *engine
,const gchar **plugin_names
);
Sets the list of loaded plugins for engine
. When this function is called,
the PeasEngine will load all the plugins whose names are in plugin_names
,
and ensures all other active plugins are unloaded.
|
A PeasEngine. |
|
A NULL -terminated array of plugin names.
|
PeasPluginInfo * peas_engine_get_plugin_info (PeasEngine *engine
,const gchar *plugin_name
);
|
A PeasEngine. |
|
A plugin name. |
Returns : |
the PeasPluginInfo corresponding with a given plugin name. |
gboolean peas_engine_load_plugin (PeasEngine *engine
,PeasPluginInfo *info
);
Loads the plugin corresponding to info
if it's not currently loaded.
|
A PeasEngine. |
|
A PeasPluginInfo. |
Returns : |
whether the plugin has been successfuly loaded. |
gboolean peas_engine_unload_plugin (PeasEngine *engine
,PeasPluginInfo *info
);
Unloads the plugin corresponding to info
.
|
A PeasEngine. |
|
A PeasPluginInfo. |
Returns : |
whether the plugin has been successfuly unloaded. |
void peas_engine_garbage_collect (PeasEngine *engine
);
This function triggers garbage collection on all the loaders currently owned by the PeasEngine. This can be used to force the loaders to destroy managed objects that still hold references to objects that are about to disappear.
|
A PeasEngine. |
gboolean peas_engine_provides_extension (PeasEngine *engine
,PeasPluginInfo *info
,GType extension_type
);
PeasExtension * peas_engine_get_extension (PeasEngine *engine
,PeasPluginInfo *info
,GType extension_type
);
void peas_engine_disable_loader (PeasEngine *engine
,const gchar *loader_id
);
Disable a loader, avoiding using the plugins written using the
related language to be loaded. This method must be called before
any plugin relying on the loader loader_id
has been loaded.
For instance, the following code will prevent any python plugin from being loaded:
1 |
peas_engine_disable_loader (engine, "python"); |
|
A PeasEngine. |
|
The id of the loader to inhibit. |
"app-name"
property "app-name" gchar* : Read / Write / Construct Only
The application name. Filename extension and section header for PeasPluginInfo files are actually derived from this value.
For instance, if app-name is "Gedit", then info files will have the .gedit-plugin extension, and the engine will look for a "Gedit Plugin" section in it to load the plugin data.
Default value: "Peas"
"base-module-dir"
property "base-module-dir" gchar* : Read / Write / Construct Only
The base application directory for binding modules lookup.
Each loader module will load its modules from a subdirectory of the base module directory. For instance, the python loader will look for python modules in "${base-module-dir}/python/".
Default value: NULL
"plugin-list"
property "plugin-list" gpointer : Read
The list of found plugins.
This will be modified when peas_engine_rescan_plugins()
is called.
Note that the list belongs to the engine and should not be modified or freed.
"search-paths"
property "search-paths" GStrv* : Read / Write / Construct Only
The list of path where to look for plugins.
A so-called "search path" actually consists on a couple of both a module directory (where the shared libraries or language modules lie) and a data directory (where the plugin data is).
The PeasPlugin will be able to use a correct data dir depending on
where it is installed, hence allowing to keep the plugin agnostic
when it comes to installation location: the same plugin can be
installed both in the system path or in the user's home directory,
without taking other special care than using
egg_plugin_get_data_dir()
when looking for its data files.
Concretely, this property contains a NULL-terminated array of strings, whose even-indexed strings are module directories, and odd-indexed ones are the associated data directories. Here is an example of such an array:
1 2 3 4 5 6 7 8 9 |
gchar const * const search_paths[] = { // Plugins in ~/.config g_build_filename (g_get_user_config_dir (), "example/plugins", NULL), g_build_filename (g_get_user_config_dir (), "example/plugins", NULL), // System plugins EXAMPLE_PREFIX "/lib/example/plugins/", EXAMPLE_PREFIX "/share/example/plugins/", NULL }; |
"load-plugin"
signalvoid user_function (PeasEngine *engine, PeasPluginInfo *info, gpointer user_data) : Run Last
The load-plugin signal is emitted when a plugin is being loaded.
|
A PeasEngine. |
|
A PeasPluginInfo. |
|
user data set when the signal handler was connected. |
"unload-plugin"
signalvoid user_function (PeasEngine *engine, PeasPluginInfo *info, gpointer user_data) : Run Last
The unload-plugin signal is emitted when a plugin is being unloaded.
|
A PeasEngine. |
|
A PeasPluginInfo. |
|
user data set when the signal handler was connected. |