[libpeas/proxys] [Python] Add a "plugin_info" attribute to python extensions.



commit 0824a99d7981720f24c39fe81fc30b0671cd6f0b
Author: Steve Frécinaux <code istique net>
Date:   Wed May 26 00:59:21 2010 +0200

    [Python] Add a "plugin_info" attribute to python extensions.
    
    This way python objects can get infos about the plugin as well.

 loaders/python/peas-plugin-loader-python.c |    8 +++++++-
 1 files changed, 7 insertions(+), 1 deletions(-)
---
diff --git a/loaders/python/peas-plugin-loader-python.c b/loaders/python/peas-plugin-loader-python.c
index 2675dc8..998628f 100644
--- a/loaders/python/peas-plugin-loader-python.c
+++ b/loaders/python/peas-plugin-loader-python.c
@@ -129,6 +129,7 @@ peas_plugin_loader_python_get_extension (PeasPluginLoader *loader,
   PyObject *pyobject;
   PyGObject *pygobject;
   PyObject *emptyarg;
+  PyObject *pyplinfo;
 
   pyinfo = (PythonInfo *) g_hash_table_lookup (pyloader->priv->loaded_plugins, info);
 
@@ -162,7 +163,7 @@ peas_plugin_loader_python_get_extension (PeasPluginLoader *loader,
       return NULL;
     }
 
-  pygobject_construct (pygobject, "plugin-info", info, NULL);
+  pygobject_construct (pygobject, NULL);
 
   if (pygobject->obj == NULL)
     {
@@ -182,6 +183,11 @@ peas_plugin_loader_python_get_extension (PeasPluginLoader *loader,
       Py_DECREF (emptyarg);
     }
 
+  /* Set the plugin info as an attribute of the instance */
+  pyplinfo = pyg_boxed_new (PEAS_TYPE_PLUGIN_INFO, info, TRUE, TRUE);
+  PyObject_SetAttrString (pyobject, "plugin_info", pyplinfo);
+  Py_DECREF (pyplinfo);
+
   return peas_extension_python_new (exten_type, pyobject);
 }
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]