[libpeas] Seed: add back support for the old way of defining extensions.



commit dc4be16c5288ef9983fcecb36b52869bddfb5110
Author: Steve Frécinaux <code istique net>
Date:   Tue Apr 5 23:26:39 2011 +0200

    Seed: add back support for the old way of defining extensions.
    
    The old way, using an array of functions, is officially deprecated but
    should still be supported since the API has been frozen for 1.0. But you
    really should not use it.

 configure.ac                           |   10 ++++++++++
 loaders/seed/peas-plugin-loader-seed.c |   28 +++++++++++++++++++++++++++-
 2 files changed, 37 insertions(+), 1 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 667f3b0..5bf6bda 100644
--- a/configure.ac
+++ b/configure.ac
@@ -461,6 +461,15 @@ GNOME_COMPILE_WARNINGS([maximum])
 # Use --enable-maintainer-mode to disabled deprecated symbols
 GNOME_MAINTAINER_MODE_DEFINES
 
+AC_ARG_ENABLE([deprecation],
+             AS_HELP_STRING([--disable-deprecation],[Disable deprecated libpeas features]),
+             [enable_deprecation=$enableval],
+             [enable_deprecation=$USE_MAINTAINER_MODE])
+if test "$enable_deprecation" = "yes"; then
+       AC_MSG_NOTICE([disabling deprecated libpeas features])
+       AC_DEFINE([PEAS_DISABLE_DEPRECATED],[1],[Disable deprecated features])
+fi
+
 
 AC_CONFIG_FILES([
 Makefile
@@ -523,6 +532,7 @@ Configuration:
         Build libpeas-gtk             : ${enable_gtk}
         Coverage testing              : ${enable_gcov}
         Glade Catalog                 : ${found_glade_catalog}
+        Disable deprecated features   : ${enable_deprecation}
         Seed JS support               : ${found_seed}
         GJS JS support                : ${found_gjs}
         Python support                : ${found_python}
diff --git a/loaders/seed/peas-plugin-loader-seed.c b/loaders/seed/peas-plugin-loader-seed.c
index f412de9..e2df6df 100644
--- a/loaders/seed/peas-plugin-loader-seed.c
+++ b/loaders/seed/peas-plugin-loader-seed.c
@@ -160,9 +160,35 @@ peas_plugin_loader_seed_create_extension (PeasPluginLoader *loader,
 
   if (extension == NULL)
     {
-      g_warning ("Extension '%s' in plugin '%s' is not a valid constructor object",
+#ifndef PEAS_DISABLE_DEPRECATED
+      gchar **property_names;
+
+      g_warning ("DEPRECATION WARNING: Extension '%s' in plugin '%s' is not a valid "
+                 "constructor function. Support for extension initialization by array "
+                 "copy will be dropped soon.",
+                 g_type_name (exten_type), peas_plugin_info_get_module_name (info));
+
+      extension = seed_make_object (sinfo->context, NULL, NULL);
+      property_names = seed_object_copy_property_names (sinfo->context,
+                                                        extension_ctor);
+      for (i = 0; property_names[i] != NULL; i++)
+        {
+          SeedValue value;
+          value = seed_object_get_property (sinfo->context,
+                                            extension_ctor,
+                                            property_names[i]);
+          seed_object_set_property (sinfo->context,
+                                    extension,
+                                    property_names[i],
+                                    value);
+        }
+
+        g_strfreev (property_names);
+#else
+      g_warning ("Extension '%s' in plugin '%s' is not a valid constructor",
                  g_type_name (exten_type), peas_plugin_info_get_module_name (info));
       return NULL;
+#endif
     }
 
   /* Set the properties as well, cannot use



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