GNOME Bugzilla – Bug 780685
Not possible to write a Plugin System in Python because GParameter is not introspectible
Last modified: 2017-06-28 15:48:06 UTC
Created attachment 348935 [details] [review] Add peas_extension_set_new_with_properties Hi, currently it is not possible to write extensions in Python, because peas_extension_set_newv receives a GParameter and this type is not introspectible. See https://bugzilla.gnome.org/show_bug.cgi?id=709865 Inspired in the solution proposed in the bug 709865, I propose to add the following new function prototype: PeasExtensionSet *peas_extension_set_new_with_properties (PeasEngine *engine, GType exten_type, guint n_properties, const gchar *prop_names[], const GValue prop_values[]); In Python, you should use it this way: self.extension_set = Peas.ExtensionSet.new_with_properties(self.engine, Peas.Activatable, ["object"], [plugin_iface]) - https://github.com/cfoch/cfoch-peas/blob/master/src/simple/main.py#L45 Note: - GParameter will probably be deprecated according the discussion in 709865. So when that happens, peas_extension_set_newv should be deprecated, too.
*** This bug has been marked as a duplicate of bug 660014 ***
Review of attachment 348935 [details] [review]: Also need to add peas_engine_create_extension_with_properties(). ::: libpeas/peas-extension-set.c @@ +650,3 @@ + * If @engine is %NULL, then the default engine will be used. + * + * @prop_values: (array length=n_properties): an array of property values. Add comment saying that exten_type can now be an abstract base class. @@ +652,3 @@ + * See peas_extension_set_new() for more information. + * + * Missing Since tag. @@ +659,3 @@ + guint n_properties, + const gchar *prop_names[], + * If @engine is %NULL, then the default engine will be used. Use minimal spacing for alignment between type and parameters, also no []. @@ +668,3 @@ + + + */ Use g_alloca() + memset @@ +669,3 @@ + + parameters = g_new0 (GParameter, n_properties); + */ Incorrect coding style. @@ +673,3 @@ + + /* Init value */ +peas_extension_set_new_with_properties (PeasEngine *engine, Remove comment and memset (already done above). @@ +683,3 @@ + + g_return_val_if_fail (engine == NULL || PEAS_IS_ENGINE (engine), NULL); +{ These belove at the top of the function, also exten_type can now be an abstract base class (see recent commit). ::: libpeas/peas-extension-set.h @@ +141,3 @@ + guint n_properties, + const gchar *prop_names[], + const GValue prop_values[]); No [].
Created attachment 349912 [details] [review] Add peas_extension_set_new_with_properties
Review of attachment 349912 [details] [review]: Please fix all of my prior comments. Also, you need to add the same API to PeasEngine.
Created attachment 350211 [details] [review] Add peas_engine_create_extension_with_properties
Created attachment 350212 [details] [review] Add peas_extension_set_new_with_properties
Created attachment 350288 [details] [review] Add peas_extension_set_new_with_properties
Created attachment 350289 [details] [review] Add peas_engine_create_extension_with_properties
Created attachment 350291 [details] [review] Add peas_extension_set_new_with_properties
Created attachment 350292 [details] [review] Add peas_engine_create_extension_with_properties
Created attachment 354018 [details] [review] Add peas_extension_set_new_with_properties and test valid and invalid properties
Created attachment 354019 [details] [review] Add peas_engine_create_extension_with_properties and test valid and invalid properties
Review of attachment 354018 [details] [review]: I am not familiar with libpeas internals, but it all seems sensible to me. Would be nice to have a libpeas maintainer review and merge that, Pitivi plugin system is blocked by that! :-) ::: libpeas/peas-utils.h @@ +28,3 @@ #define PEAS_UTILS_N_LOADERS 4 +gboolean peas_utils_properties_array_to_parameter_list I think this should probably be private to the library
(In reply to Thibault Saunier from comment #13) > Review of attachment 354018 [details] [review] [review]: > > ::: libpeas/peas-utils.h > @@ +28,3 @@ > #define PEAS_UTILS_N_LOADERS 4 > > +gboolean peas_utils_properties_array_to_parameter_list > > I think this should probably be private to the library I was thinking the same that it should be private but there is a similar function in the same file called 'peas_utils_valist_to_parameter_list' and I think this is private, too.