![]() |
![]() |
![]() |
![]() |
Writing Native plugins is very simple, but since it's C/C++ it's a bit more complicated.
There are currently no C++ bindings and no intention to write them, but the C API is still usable from C++.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
#include <gplugin.h> #include <gplugin-native.h> /* gplugin_plugin_query is called by the native loader to determine if * the plugin is loadable. It must have this signature and should * return a valid GPluginPluginInfo if everything is fine. If something * went wrong, error should be set to a valid GError and NULL should be * returned. */ G_MODULE_EXPORT GPluginPluginInfo * gplugin_plugin_query(GError **error) { /* Authors is a list of authors of the plugin. Generally these are * in the "Name Surname <user@domain.com>" format. */ const gchar * const authors[] = { "author", NULL }; /* gplugin_plugin_info_new only requires that the id be set, and the * rest are here for demonstration purposes. */ return gplugin_plugin_info_new( "gplugin/basic-native-plugin", GPLUGIN_NATIVE_PLUGIN_ABI_VERSION, "name", "name", "version", "version", "summary", "summary", "description", "description", "authors", authors, "website", "website", NULL ); } /* gplugin_plugin_load is called by the loader when the plugin should * be loaded. It must have this exact signature and return TRUE if * loading was successful, otherwise it should return FALSE with error * set to a valid GError. */ G_MODULE_EXPORT gboolean gplugin_plugin_load(GPluginNativePlugin *plugin, GError **error) { return TRUE; } /* gplugin_plugin_unload is called by the loader when the plugin should * be unloaded. It must have this exact signature and should return TRUE * if unloading was successful, otherwise it should return FALSE with * error set to a valid GError. */ G_MODULE_EXPORT gboolean gplugin_plugin_unload(GPluginNativePlugin *plugin, GError **error) { return TRUE; } |