Hello,
based on the discussion I refined my proposal (see below). Additionally
I have implemented all of this, including updating demoplugin.c, see
[1]. And last but not least, I have a fully working implementation of
proxy plugins aka pluxies (in fact, I simply updated my year-old branch
to use the new hooks) plus a real-world pluxy for libpeas-based plugins,
see [2], [3].
I also formally suggest this work for merging. I havent done a pull
request yet, though, because it depends on the linkage-cleanup work,
which should be merged first. I do target the 1.25 release still, and
I'd absolutely love to if we can make this happen.
The changes since my initial proposal summed up:
- geany_plugin_register() now additionally takes the API version the
plugin is compiled against (in addition to the minimum API it needs and
the ABI version). This gives Geany full insight of what the plugin can
be expected to work with.
- set_info() is removed from the hooks. version_check() is obviously
obsolete (the checks are performed within geany_plugin_register()). The
plugin is expected to full plugin->info before calling
geany_plugin_register() which makes set_info() superfluous
- The conceptual role of geany_load_module() is extended: It should also
check for plugin-specific runtime dependencies, and return FALSE if such
checks fail (as a result the plugin will be hidden from the PM dialog).
Otherwise call geany_plugin_register() appropriately.
- geany_load_module() passes Geany's API version, sos that plugins can
perform their own specific checks based on the API of the currently
running Geany instance (this can very well be != the plugins
GEANY_API_VERSION)
- The GeanyData pointer is now part of GeanyPlugin structure for plugins
to access (not passed to init anymore). Actually it was this way in my
first version too, but I didn't explicitly mention it.
- PluginHooks is renamed to GeanyPluginHooks
Now to the (updated) proposal:
Please see my initial mail [4] about the motivation and advantages of
this work.
gboolean geany_load_module(GeanyPlugin *plugin, GModule *module, gint
geany_api_version);
gboolean geany_plugin_register(GeanyPlugin *plugin, gint api_version,
gint min_api_version,
gint abi_version, GeanyPluginHooks
*hooks, gpointer pdata);
typedef struct _GeanyPluginHooks
{
/** Array of plugin-provided signal handlers (@see PluginCallback) */
PluginCallback *callbacks;
/** Called when the plugin is enabled by the user */
void (*init) (GeanyPlugin *plugin, gpointer pdata);
/** plugins configure dialog, optional (can be @c NULL) */
GtkWidget* (*configure) (GeanyPlugin *plugin, GtkDialog *dialog,
gpointer pdata);
/** Called when the plugin should show some help, optional (can be
@c NULL) */
void (*help) (GeanyPlugin *plugin, gpointer pdata);
/** Called when the plugin is disabled or when Geany exits */
void (*cleanup) (GeanyPlugin *plugin, gpointer pdata);
}
GeanyPluginHooks;
Plugins from now on define a single global function,
geany_load_module(), which is called by Geany via pointer obtained from
g_module_symbol(). In this function the plugin should perform the
following steps:
- Test against the passed geany_api_version if it can function under the
current Geany.
- Test for any additional runtime dependencies
- Call geany_plugin_register() appropate and test the return value
If any of the above steps fail FALSE should be returned, else TRUE.
The plugin shall pass a statically allocated instance of
GeanyPluginHooks as part of the geany_plugin_register() call. The
function pointers should point to function that are semantically the
same as the current plugin_{init,configure,help,cleanup}. Except these
function get other parameters and can make use of them.
This proposal does not implement pluxies by itself, however I have done
the work to implement pluxies on top of the new loader. I will post
another mail about this when we finalized the new loader.
[1] https://github.com/kugel-/geany/tree/new_hooks
[2] https://github.com/kugel-/geany/tree/pluxy
[3] https://github.com/kugel-/peasy
[4] http://lists.geany.org/pipermail/devel/2015-March/009299.html
Please reply with your options or other ideas.
Best regards
_______________________________________________
Devel mailing list
Devel@lists.geany.org
https://lists.geany.org/cgi-bin/mailman/listinfo/devel