[libpeas] Add support for g_object_new-like parameters in PeasCreateFunc.



commit ea147ede657b0404656e4c5b1a014c8a9bb46fd4
Author: Steve Frécinaux <code istique net>
Date:   Wed Jun 23 22:47:12 2010 +0200

    Add support for g_object_new-like parameters in PeasCreateFunc.

 libpeas/peas-engine.c            |    2 +-
 libpeas/peas-object-module.c     |   15 +++++++++++----
 libpeas/peas-object-module.h     |    8 ++++++--
 loaders/c/peas-plugin-loader-c.c |    2 +-
 4 files changed, 19 insertions(+), 8 deletions(-)
---
diff --git a/libpeas/peas-engine.c b/libpeas/peas-engine.c
index fc0e69c..c518208 100644
--- a/libpeas/peas-engine.c
+++ b/libpeas/peas-engine.c
@@ -525,7 +525,7 @@ load_plugin_loader (PeasEngine  *engine,
   if (g_type_module_use (G_TYPE_MODULE (module)))
     {
       peas_object_module_register_types (module);
-      loader = (PeasPluginLoader *) peas_object_module_create_object (module, PEAS_TYPE_PLUGIN_LOADER);
+      loader = (PeasPluginLoader *) peas_object_module_create_object (module, PEAS_TYPE_PLUGIN_LOADER, 0, NULL);
 
       if (loader == NULL || !PEAS_IS_PLUGIN_LOADER (loader))
         {
diff --git a/libpeas/peas-object-module.c b/libpeas/peas-object-module.c
index b3674a2..62e0fd2 100644
--- a/libpeas/peas-object-module.c
+++ b/libpeas/peas-object-module.c
@@ -6,6 +6,7 @@
  * Copyright (C) 2003-2004 Christian Persch
  * Copyright (C) 2005-2007 Paolo Maggi
  * Copyright (C) 2008 Jesse van den Kieboom
+ * Copyright (C) 2010 Steve Frécinaux
  *
  *  This program is free software; you can redistribute it and/or modify
  *  it under the terms of the GNU Library General Public License as published by
@@ -275,7 +276,9 @@ peas_object_module_register_types (PeasObjectModule *module)
 
 GObject *
 peas_object_module_create_object (PeasObjectModule *module,
-                                  GType             interface)
+                                  GType             interface,
+                                  guint             n_parameters,
+                                  GParameter       *parameters)
 {
   guint i;
   InterfaceImplementation *impls;
@@ -288,7 +291,7 @@ peas_object_module_create_object (PeasObjectModule *module,
   impls = (InterfaceImplementation *) module->priv->implementations->data;
   for (i = 0; i < module->priv->implementations->len; ++i)
     if (impls[i].iface_type == interface)
-      return impls[i].func (impls[i].user_data);
+      return impls[i].func (n_parameters, parameters, impls[i].user_data);
 
   return NULL;
 }
@@ -350,9 +353,13 @@ peas_object_module_register_extension (PeasObjectModule *module,
 }
 
 static GObject *
-create_gobject_from_type (gconstpointer user_data)
+create_gobject_from_type (guint          n_parameters,
+                          GParameter    *parameters,
+                          gconstpointer  user_data)
 {
-  return g_object_new (GPOINTER_TO_SIZE (user_data), NULL);
+  return g_object_newv (GPOINTER_TO_SIZE (user_data),
+                        n_parameters,
+                        parameters);
 }
 
 void
diff --git a/libpeas/peas-object-module.h b/libpeas/peas-object-module.h
index 06b2c02..b2ecfeb 100644
--- a/libpeas/peas-object-module.h
+++ b/libpeas/peas-object-module.h
@@ -41,7 +41,9 @@ typedef struct _PeasObjectModule        PeasObjectModule;
 typedef struct _PeasObjectModuleClass   PeasObjectModuleClass;
 typedef struct _PeasObjectModulePrivate PeasObjectModulePrivate;
 
-typedef GObject *(*PeasCreateFunc)   (gconstpointer user_data);
+typedef GObject *(*PeasCreateFunc)   (guint          n_parameters,
+                                      GParameter    *parameters,
+                                      gconstpointer  user_data);
 
 struct _PeasObjectModule {
   GTypeModule parent;
@@ -60,7 +62,9 @@ PeasObjectModule   *peas_object_module_new                    (const gchar
 
 void                peas_object_module_register_types         (PeasObjectModule *module);
 GObject            *peas_object_module_create_object          (PeasObjectModule *module,
-                                                               GType             interface);
+                                                               GType             interface,
+                                                               guint             n_parameters,
+                                                               GParameter       *parameters);
 gboolean            peas_object_module_provides_object        (PeasObjectModule *module,
                                                                GType             interface);
 
diff --git a/loaders/c/peas-plugin-loader-c.c b/loaders/c/peas-plugin-loader-c.c
index e6b724f..d1f9f18 100644
--- a/loaders/c/peas-plugin-loader-c.c
+++ b/loaders/c/peas-plugin-loader-c.c
@@ -121,7 +121,7 @@ peas_plugin_loader_c_get_extension (PeasPluginLoader *loader,
                                                      info);
   g_return_val_if_fail (module != NULL, NULL);
 
-  instance = peas_object_module_create_object (module, exten_type);
+  instance = peas_object_module_create_object (module, exten_type, 0, NULL);
 
   if (instance == NULL)
     {



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