[geany/geany-plugins] 1b0b25: Store per-plugin GeanyPlugin pointer

Thomas Martitz git-noreply at xxxxx
Sun Mar 6 12:24:10 UTC 2016


Branch:      refs/heads/master
Author:      Thomas Martitz <kugel at rockbox.org>
Committer:   Thomas Martitz <kugel at rockbox.org>
Date:        Sun, 06 Mar 2016 12:24:10 UTC
Commit:      1b0b25fc5b20bb0e8eaf27e5448c235373f5d36b
             https://github.com/geany/geany-plugins/commit/1b0b25fc5b20bb0e8eaf27e5448c235373f5d36b

Log Message:
-----------
Store per-plugin GeanyPlugin pointer

This is required for some APIs, e.g. keybindings, and is made possible
trough the proxy plugin conversion, since now Geany actually creates
GeanyPlugin instances for Geanypy plugins.


Modified Paths:
--------------
    geanypy/src/geanypy-plugin.c
    geanypy/src/geanypy-plugin.h

Modified: geanypy/src/geanypy-plugin.c
2 lines changed, 2 insertions(+), 0 deletions(-)
===================================================================
@@ -273,9 +273,11 @@ geanypy_load(GeanyPlugin *proxy, GeanyPlugin *subplugin, const gchar *filename,
 		GeanyPyPluginData *pdata = g_slice_new(GeanyPyPluginData);
 		PluginInfo *info     = subplugin->info;
 		GeanyPluginFuncs *funcs = subplugin->funcs;
+		PyObject *caps = PyCapsule_New(subplugin, "GeanyPlugin", NULL);
 		Py_INCREF(found);
 		pdata->module        = module;
 		pdata->class         = found;
+		PyObject_SetAttrString(pdata->class, "__geany_plugin__", caps);
 		pdata->instance      = NULL;
 		info->name           = string_from_attr(pdata->class, "__plugin_name__");
 		info->description    = string_from_attr(pdata->class, "__plugin_description__");


Modified: geanypy/src/geanypy-plugin.h
7 lines changed, 7 insertions(+), 0 deletions(-)
===================================================================
@@ -33,6 +33,13 @@ extern GeanyData *geany_data;
 #define PyMODINIT_FUNC void
 #endif
 
+static inline GeanyPlugin *plugin_get(PyObject *self)
+{
+	PyObject *caps = PyObject_GetAttrString(self, "__geany_plugin__");
+	return PyCapsule_GetPointer(caps, "GeanyPlugin");
+}
+
+
 
 #ifdef __cplusplus
 } /* extern "C" */



--------------
This E-Mail was brought to you by github_commit_mail.py (Source: https://github.com/geany/infrastructure).


More information about the Plugins-Commits mailing list