Skip to content

Commit

Permalink
Allow plugins to get the data they set
Browse files Browse the repository at this point in the history
  • Loading branch information
codebrainz committed Aug 4, 2017
1 parent a108f91 commit 7261742
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/plugindata.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ G_BEGIN_DECLS
* @warning You should not test for values below 200 as previously
* @c GEANY_API_VERSION was defined as an enum value, not a macro.
*/
#define GEANY_API_VERSION 233
#define GEANY_API_VERSION 234

/* hack to have a different ABI when built with GTK3 because loading GTK2-linked plugins
* with GTK3-linked Geany leads to crash */
Expand Down Expand Up @@ -315,6 +315,7 @@ gboolean geany_plugin_register(GeanyPlugin *plugin, gint api_version,
gboolean geany_plugin_register_full(GeanyPlugin *plugin, gint api_version,
gint min_api_version, gint abi_version,
gpointer data, GDestroyNotify free_func);
gpointer geany_plugin_get_data(const GeanyPlugin *plugin);
void geany_plugin_set_data(GeanyPlugin *plugin, gpointer data, GDestroyNotify free_func);

/** Convenience macro to register a plugin.
Expand Down
18 changes: 18 additions & 0 deletions src/pluginutils.c
Original file line number Diff line number Diff line change
Expand Up @@ -570,6 +570,24 @@ void plugin_builder_connect_signals(GeanyPlugin *plugin,
}


/** Get the additional data that corresponds to the plugin.
*
* @param plugin The plugin provided by Geany
* @return The data corresponding to the plugin or @c NULL if none set.
*
* @since 1.32 (API 234)
*
* @see geany_plugin_set_data()
*/
gpointer geany_plugin_get_data(const GeanyPlugin *plugin)
{
g_return_val_if_fail (plugin != NULL, NULL);
g_return_val_if_fail (PLUGIN_LOADED_OK (plugin->priv), NULL);

return plugin->priv->cb_data;
}


/** Add additional data that corresponds to the plugin.
*
* @p pdata is the pointer going to be passed to the individual plugin callbacks
Expand Down

0 comments on commit 7261742

Please sign in to comment.