Geany dev
|
This page briefly describes the deprecated, legacy plugin entry points. These have been in place prior to Geany 1.26 and are still loadable and working for the time being. However, do not create new plugins against these. For this reason, the actual description here is rather minimalistic and concentrates on porting legacy plugins to the new interface. Basically its main purpose is to give newcomers an idea of what they are looking at if they come across a legacy plugin.
The legacy entry points consist of a number of pre-defined symbols (functions and variables) exported by plugins. There is no active registration procedure. It is implicit simply by exporting the mandatory symbols. The entirety of the symbols is described at the page Plugin Symbols .
At the very least plugins must define the functions plugin_init(GeanyData *) and plugin_version_check(gint). Additionally, an instance of the struct PluginInfo named plugin_info must be exported as well, this contains the same metadata already known from GeanyPlugin::info. The functions plugin_cleanup(), plugin_help(), plugin_configure(GtkDialog *) and plugin_configure_single(GtkWidget *) are optional, however Geany prints a warning if plugin_cleanup() is missing and only one of plugin_configure(GtkDialog *) and plugin_configure_single(GtkWidget *) is used for any single plugin.
By convention, plugin_version_check() is implicitly defined through the use of PLUGIN_VERSION_CHECK(), and similarly plugin_info is defined through PLUGIN_SET_INFO() or PLUGIN_SET_TRANSLATABLE_INFO().
The functions should generally perform the same tasks as their equivalents in GeanyPlugin::funcs.
Geany also recognized numerous variable fields if the plugin exported them globally, and actually set a few of them inside the plugins data section.
Given a legacy plugin it can be modified to use the new entry points without much effort. This section gives a basic recipe that should work for most existing plugins. The transition should be easy and painless so it is recommended that you adapt your plugin as soon as possible.
Probably the biggest hurdle is the dropped support of the long-deprecated plugin_configure_single(). This means you first have to port the configuration dialog (if any) to the combined plugin dialog. While you previously created a custom dialog you now attach the main widget of that dialog to the combined plugin dialog simply by returning it from GeanyPluginFuncs::configure. You don't actually add it, Geany will do that for you. The pointer to the dialog is passed to configure simply to allow you to connect to its "response" or "close" signals.
The following lists the function mapping of previous plugin_* functions to the new GeanyPlugin::funcs. They are semantically the same, however the new functions receive more parameters which you may use or not.
TRUE
unconditionally.Exported global variables are not recognized anymore. They are replaced in the following ways:
plugin_info is simply removed. Instead, you have to assign the values to GeanyPlugin::info yourself, and it must be done inside your geany_load_module().
Example:
becomes
The plugin_callbacks array is supported by assigning the GeanyPluginFuncs::callbacks to the array.
plugin_fields is not supported anymore. Use ui_add_document_sensitive() instead. PLUGIN_KEY_GROUP
and plugin_key_group are also not supported anymore. Use plugin_set_key_group() and keybindings_set_item() respectively.
Additionally, Geany traditionally set a few variables. This is not the case anymore. geany_functions has been removed in 1.25 and since then existed only for compatibility and has been empty. You can simply remove its declaration from your source code. geany_plugin is passed to each GeanyPluginFuncs function. You need to store it yourself somewhere if you need it elsewhere. geany_data is now available as a member of GeanyPlugin.
geany_plugin is now also passed by default to the PluginCallback signal handlers as data pointer if it's set to NULL.