[libpeas/proxys] [Seed] Revamp Seed loader for PeasExtension support.



commit def52cbb8deae8c868b74129efa3a16b47948f2d
Author: Steve Frécinaux <code istique net>
Date:   Sat May 22 02:05:45 2010 +0200

    [Seed] Revamp Seed loader for PeasExtension support.
    
    Current known limitations are:
     - we don't support 'out' and 'inout' arguments
     - we don't support complex types (lists, arrays, hash tables, errors)
    
    This is enough to support PeasActivatable, but not PeasUIConfigurable.

 loaders/seed/Makefile.am                 |    4 +-
 loaders/seed/peas-extension-seed.c       |  314 ++++++++++++++++++++++++++++++
 loaders/seed/peas-extension-seed.h       |   62 ++++++
 loaders/seed/peas-plugin-loader-seed.c   |  114 ++++++++++--
 loaders/seed/peas-plugin-loader-seed.h   |    5 +-
 loaders/seed/peas-seed-plugin.c          |  213 --------------------
 loaders/seed/peas-seed-plugin.h          |   61 ------
 peas-demo/plugins/seedhello/seedhello.js |   13 ++-
 8 files changed, 493 insertions(+), 293 deletions(-)
---
diff --git a/loaders/seed/Makefile.am b/loaders/seed/Makefile.am
index 415f6ec..89a7e1a 100644
--- a/loaders/seed/Makefile.am
+++ b/loaders/seed/Makefile.am
@@ -12,8 +12,8 @@ INCLUDES = \
 loader_LTLIBRARIES = libseedloader.la
 
 libseedloader_la_SOURCES = \
-	peas-seed-plugin.c		\
-	peas-seed-plugin.h		\
+	peas-extension-seed.c		\
+	peas-extension-seed.h		\
 	peas-plugin-loader-seed.c 	\
 	peas-plugin-loader-seed.h
 
diff --git a/loaders/seed/peas-extension-seed.c b/loaders/seed/peas-extension-seed.c
new file mode 100644
index 0000000..c741930
--- /dev/null
+++ b/loaders/seed/peas-extension-seed.c
@@ -0,0 +1,314 @@
+/*
+ * peas-extension-seed.c
+ * This file is part of libpeas
+ *
+ * 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
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU Library General Public License for more details.
+ *
+ *  You should have received a copy of the GNU Library General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+#include "peas-extension-seed.h"
+#include <libpeas/peas-introspection.h>
+#include <girepository.h>
+
+G_DEFINE_DYNAMIC_TYPE (PeasExtensionSeed, peas_extension_seed, PEAS_TYPE_EXTENSION);
+
+enum {
+  PROP_0,
+  PROP_EXTEN_TYPE,
+  PROP_JS_CONTEXT,
+  PROP_JS_OBJECT,
+};
+
+static void
+peas_extension_seed_init (PeasExtensionSeed *sexten)
+{
+}
+
+static void
+peas_extension_seed_set_property (GObject      *object,
+                                  guint         prop_id,
+                                  const GValue *value,
+                                  GParamSpec   *pspec)
+{
+  PeasExtensionSeed *sexten = PEAS_EXTENSION_SEED (object);
+
+  switch (prop_id)
+    {
+    case PROP_EXTEN_TYPE:
+      sexten->exten_type = g_value_get_gtype (value);
+      break;
+    case PROP_JS_CONTEXT:
+      sexten->js_context = g_value_get_pointer (value);
+      break;
+    case PROP_JS_OBJECT:
+      sexten->js_object = g_value_get_pointer (value);
+      break;
+    default:
+      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+    }
+}
+
+static void
+peas_extension_seed_constructed (GObject *object)
+{
+  PeasExtensionSeed *sexten = PEAS_EXTENSION_SEED (object);
+
+  /* We do this here as we can't be sure the context is already set when
+   * the "JS_PLUGIN" property is set. */
+  seed_context_ref (sexten->js_context);
+  seed_value_protect (sexten->js_context, sexten->js_object);
+}
+
+static void
+peas_extension_seed_finalize (GObject *object)
+{
+  PeasExtensionSeed *sexten = PEAS_EXTENSION_SEED (object);
+
+  seed_value_unprotect (sexten->js_context, sexten->js_object);
+  seed_context_unref (sexten->js_context);
+}
+
+static SeedValue
+read_next_argument (SeedContext ctx,
+                    va_list args,
+                    GITypeInfo *arg_type_info,
+                    SeedException *exc)
+{
+  /* Notes: According to GCC 4.4,
+   *  - int8, uint8, int16, uint16, short and ushort are promoted to int when passed through '...'
+   *  - float is promoted to double when passed through '...'
+   */
+  switch (g_type_info_get_tag (arg_type_info))
+    {
+    case GI_TYPE_TAG_VOID:
+      g_assert_not_reached ();
+      break;
+    case GI_TYPE_TAG_BOOLEAN:
+      return seed_value_from_boolean (ctx, va_arg (args, gboolean), exc);
+    case GI_TYPE_TAG_INT8:
+    case GI_TYPE_TAG_UINT8:
+    case GI_TYPE_TAG_INT16:
+    case GI_TYPE_TAG_UINT16:
+    case GI_TYPE_TAG_SHORT:
+    case GI_TYPE_TAG_USHORT:
+    case GI_TYPE_TAG_INT:
+      return seed_value_from_int (ctx, va_arg (args, gint), exc);
+    case GI_TYPE_TAG_UINT:
+      return seed_value_from_uint (ctx, va_arg (args, guint), exc);
+    case GI_TYPE_TAG_INT32:
+      return seed_value_from_long (ctx, va_arg (args, gint32), exc);
+    case GI_TYPE_TAG_UINT32:
+      return seed_value_from_ulong (ctx, va_arg (args, guint32), exc);
+    case GI_TYPE_TAG_LONG:
+      return seed_value_from_long (ctx, va_arg (args, glong), exc);
+    case GI_TYPE_TAG_ULONG:
+      return seed_value_from_ulong (ctx, va_arg (args, gulong), exc);
+    case GI_TYPE_TAG_INT64:
+      return seed_value_from_int64 (ctx, va_arg (args, gint64), exc);
+    case GI_TYPE_TAG_UINT64:
+      return seed_value_from_uint64 (ctx, va_arg (args, guint64), exc);
+    case GI_TYPE_TAG_FLOAT:
+    case GI_TYPE_TAG_DOUBLE:
+      return seed_value_from_double (ctx, va_arg (args, gdouble), exc);
+      break;
+
+    case GI_TYPE_TAG_SSIZE:
+      return seed_value_from_long (ctx, va_arg (args, gssize), exc);
+    case GI_TYPE_TAG_SIZE:
+      return seed_value_from_ulong (ctx, va_arg (args, gsize), exc);
+    case GI_TYPE_TAG_TIME_T:
+      return seed_value_from_int64 (ctx, va_arg (args, time_t), exc);
+    case GI_TYPE_TAG_GTYPE:
+      /* apparently, GType is meant to be a gsize, from gobject/gtype.h in glib */
+      return seed_value_from_ulong (ctx, va_arg (args, GType), exc);
+
+    case GI_TYPE_TAG_UTF8:
+      return seed_value_from_string (ctx, va_arg (args, gchar *), exc);
+    case GI_TYPE_TAG_FILENAME:
+      return seed_value_from_filename (ctx, va_arg (args, gchar *), exc);
+
+    case GI_TYPE_TAG_INTERFACE:
+      return seed_value_from_object (ctx, va_arg (args, GObject *), exc);
+
+    /* FIXME */
+    case GI_TYPE_TAG_ARRAY:
+    case GI_TYPE_TAG_GLIST:
+    case GI_TYPE_TAG_GSLIST:
+    case GI_TYPE_TAG_GHASH:
+    case GI_TYPE_TAG_ERROR:
+      return seed_make_undefined (ctx);
+
+    default:
+      g_return_val_if_reached (seed_make_undefined (ctx));
+    }
+}
+
+static gboolean
+peas_extension_seed_call (PeasExtension *exten,
+                          const gchar   *method_name,
+                          va_list        args)
+{
+  PeasExtensionSeed *sexten = PEAS_EXTENSION_SEED (exten);
+  SeedValue js_method;
+  GICallableInfo *func_info;
+  guint n_args, n_in_args, n_out_args, i;
+  SeedValue *js_method_args;
+  SeedException exc = NULL;
+  gchar *exc_string;
+
+  g_return_val_if_fail (sexten->js_context != NULL, FALSE);
+  g_return_val_if_fail (sexten->js_object != NULL, FALSE);
+
+  /* Fetch the JS method we want to call */
+  js_method = seed_object_get_property (sexten->js_context,
+                                        sexten->js_object,
+                                        method_name);
+  if (seed_value_is_undefined (sexten->js_context, js_method))
+    {
+      g_warning ("Method %s.%s is not defined",
+                 g_type_name (sexten->exten_type), method_name);
+      return FALSE;
+    }
+
+  /* We want to display an error if the method is defined but is not a function. */
+  if (!seed_value_is_function (sexten->js_context, js_method))
+    {
+      g_warning ("Method %s.%s is not a function",
+                 g_type_name (sexten->exten_type), method_name);
+      return FALSE;
+    }
+
+  /* Prepare the arguments */
+  func_info = peas_method_get_info (sexten->exten_type, method_name);
+  n_args = g_callable_info_get_n_args (func_info);
+  n_in_args = 0;
+  n_out_args = 0;
+
+  js_method_args = g_new0 (SeedValue, n_args);
+
+  for (i = 0; i < n_args && exc == NULL; i++)
+    {
+      GIArgInfo *arg_info;
+      GITypeInfo *arg_type_info;
+
+      arg_info = g_callable_info_get_arg (func_info, i);
+      arg_type_info = g_arg_info_get_type (arg_info);
+
+      switch (g_arg_info_get_direction (arg_info))
+        {
+        case GI_DIRECTION_IN:
+          js_method_args[n_in_args++] = read_next_argument (sexten->js_context,
+                                                            args,
+                                                            arg_type_info,
+                                                            &exc);
+          break;
+        default:
+          seed_make_exception (sexten->js_context,
+                               &exc,
+                               "dir_not_supported",
+                               "Argument direction '%s' not supported yet",
+                               g_arg_info_get_direction (arg_info) == GI_DIRECTION_OUT ? "out" : "inout");
+          break;
+        }
+
+      g_base_info_unref ((GIBaseInfo *) arg_type_info);
+      g_base_info_unref ((GIBaseInfo *) arg_info);
+    }
+
+  if (exc == NULL)
+    {
+      seed_object_call (sexten->js_context,
+                        js_method,
+                        sexten->js_object,
+                        n_in_args,
+                        js_method_args,
+                        &exc);
+    }
+
+  g_base_info_unref ((GIBaseInfo *) func_info);
+
+  if (exc == NULL)
+    return TRUE;
+
+  exc_string = seed_exception_to_string (sexten->js_context, exc);
+  g_warning ("Seed Exception: %s", exc_string);
+  g_free (exc_string);
+  return FALSE;
+}
+
+static void
+peas_extension_seed_class_init (PeasExtensionSeedClass *klass)
+{
+  GObjectClass *object_class = G_OBJECT_CLASS (klass);
+  PeasExtensionClass *extension_class = PEAS_EXTENSION_CLASS (klass);
+
+  object_class->set_property = peas_extension_seed_set_property;
+  object_class->constructed = peas_extension_seed_constructed;
+  object_class->finalize = peas_extension_seed_finalize;
+
+  extension_class->call = peas_extension_seed_call;
+
+  g_object_class_install_property (object_class,
+                                   PROP_EXTEN_TYPE,
+                                   g_param_spec_gtype ("extension-type",
+                                                       "The extension type",
+                                                       "The type we need to proxy",
+                                                       G_TYPE_NONE,
+                                                       G_PARAM_WRITABLE |
+                                                       G_PARAM_CONSTRUCT_ONLY));
+
+  g_object_class_install_property (object_class,
+                                   PROP_JS_CONTEXT,
+                                   g_param_spec_pointer ("js-context",
+                                                         "Javascript Context",
+                                                         "A Javascript context from Seed",
+                                                         G_PARAM_WRITABLE |
+                                                         G_PARAM_CONSTRUCT_ONLY));
+
+  g_object_class_install_property (object_class,
+                                   PROP_JS_OBJECT,
+                                   g_param_spec_pointer ("js-object",
+                                                         "Javascript Object",
+                                                         "A Javascript object from Seed",
+                                                         G_PARAM_WRITABLE |
+                                                         G_PARAM_CONSTRUCT_ONLY));
+}
+
+static void
+peas_extension_seed_class_finalize (PeasExtensionSeedClass *klass)
+{
+}
+
+void
+peas_extension_seed_register (GTypeModule *type_module)
+{
+  peas_extension_seed_register_type (type_module);
+}
+
+PeasExtension *
+peas_extension_seed_new (GType       exten_type,
+                         SeedContext js_context,
+                         SeedObject  js_object)
+{
+  g_return_val_if_fail (js_context != NULL, NULL);
+  g_return_val_if_fail (js_object != NULL, NULL);
+
+  return PEAS_EXTENSION (g_object_new (PEAS_TYPE_EXTENSION_SEED,
+                                       "extension-type", exten_type,
+                                       "js-context", js_context,
+                                       "js-object", js_object,
+                                       NULL));
+}
diff --git a/loaders/seed/peas-extension-seed.h b/loaders/seed/peas-extension-seed.h
new file mode 100644
index 0000000..a226c45
--- /dev/null
+++ b/loaders/seed/peas-extension-seed.h
@@ -0,0 +1,62 @@
+/*
+ * peas-extension-seed.h
+ * This file is part of libpeas
+ *
+ * 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
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU Library General Public License for more details.
+ *
+ *  You should have received a copy of the GNU Library General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+#ifndef __PEAS_EXTENSION_SEED_H__
+#define __PEAS_EXTENSION_SEED_H__
+
+#include <libpeas/peas-extension.h>
+#include <seed.h>
+
+G_BEGIN_DECLS
+
+#define PEAS_TYPE_EXTENSION_SEED            (peas_extension_seed_get_type ())
+#define PEAS_EXTENSION_SEED(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj), PEAS_TYPE_EXTENSION_SEED, PeasExtensionSeed))
+#define PEAS_EXTENSION_SEED_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST ((klass), PEAS_TYPE_EXTENSION_SEED, PeasExtensionSeedClass))
+#define PEAS_IS_EXTENSION_SEED(obj)         (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PEAS_TYPE_EXTENSION_SEED))
+#define PEAS_IS_EXTENSION_SEED_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), PEAS_TYPE_EXTENSION_SEED))
+#define PEAS_EXTENSION_SEED_GET_CLASS(obj)  (G_TYPE_INSTANCE_GET_CLASS ((obj), PEAS_TYPE_EXTENSION_SEED, PeasExtensionSeedClass))
+
+typedef struct _PeasExtensionSeed        PeasExtensionSeed;
+typedef struct _PeasExtensionSeedClass   PeasExtensionSeedClass;
+
+struct _PeasExtensionSeed {
+  PeasExtension parent;
+
+  GType exten_type;
+  SeedContext js_context;
+  SeedObject js_object;
+};
+
+struct _PeasExtensionSeedClass {
+  PeasExtensionClass parent_class;
+};
+
+GType            peas_extension_seed_get_type (void) G_GNUC_CONST;
+void             peas_extension_seed_register (GTypeModule    *type_module);
+
+PeasExtension   *peas_extension_seed_new      (GType       exten_type,
+                                               SeedContext js_context,
+                                               SeedObject  js_object);
+
+G_END_DECLS
+
+#endif /* __PEAS_EXTENSION_SEED_H__ */
+
diff --git a/loaders/seed/peas-plugin-loader-seed.c b/loaders/seed/peas-plugin-loader-seed.c
index 7402839..369da75 100644
--- a/loaders/seed/peas-plugin-loader-seed.c
+++ b/loaders/seed/peas-plugin-loader-seed.c
@@ -22,11 +22,16 @@
 #include <seed.h>
 
 #include "peas-plugin-loader-seed.h"
-#include "peas-seed-plugin.h"
+#include "peas-extension-seed.h"
 #include "config.h"
 
 G_DEFINE_DYNAMIC_TYPE (PeasPluginLoaderSeed, peas_plugin_loader_seed, PEAS_TYPE_PLUGIN_LOADER);
 
+typedef struct {
+  SeedContext context;
+  SeedObject extensions;
+} SeedInfo;
+
 static SeedEngine *seed = NULL;
 
 static void
@@ -72,16 +77,16 @@ get_script_for_plugin_info (PeasPluginInfo   *info,
   return script;
 }
 
-static PeasPlugin *
+static gboolean
 peas_plugin_loader_seed_load (PeasPluginLoader *loader,
                               PeasPluginInfo   *info)
 {
+  PeasPluginLoaderSeed *sloader = PEAS_PLUGIN_LOADER_SEED (loader);
   SeedContext context;
   gchar *script;
-  SeedObject global;
-  SeedValue plugin_object;
   SeedException exc = NULL;
-  PeasPlugin *plugin = NULL;
+  SeedObject global, extensions;
+  SeedInfo *sinfo;
 
   context = seed_context_create (seed->group, NULL);
 
@@ -96,25 +101,94 @@ peas_plugin_loader_seed_load (PeasPluginLoader *loader,
       gchar *exc_string = seed_exception_to_string (context, exc);
       g_warning ("Seed Exception: %s", exc_string);
       g_free (exc_string);
+      seed_context_unref (context);
+      return FALSE;
     }
   else
     {
       global = seed_context_get_global_object (context);
-      plugin_object = seed_object_get_property (context, global, "plugin");
-
-      if (seed_value_is_object (context, plugin_object))
-        plugin = peas_seed_plugin_new (info, context, plugin_object);
+      extensions = seed_object_get_property (context, global, "extensions");
+
+      if (seed_value_is_object (context, extensions))
+        {
+          sinfo = g_slice_new (SeedInfo);
+          sinfo->context = context;
+          sinfo->extensions = extensions;
+          seed_context_ref (context);
+          seed_value_protect (context, extensions);
+
+          g_hash_table_insert (sloader->loaded_plugins, info, sinfo);
+        }
     }
 
   seed_context_unref (context);
 
-  return plugin;
+  return TRUE;
+}
+
+static gboolean
+peas_plugin_loader_seed_provides_extension  (PeasPluginLoader *loader,
+                                             PeasPluginInfo   *info,
+                                             GType             exten_type)
+{
+  PeasPluginLoaderSeed *sloader = PEAS_PLUGIN_LOADER_SEED (loader);
+  SeedInfo *sinfo;
+  SeedObject *extension;
+
+  sinfo = (SeedInfo *) g_hash_table_lookup (sloader->loaded_plugins, info);
+  if (!sinfo)
+    return FALSE;
+
+  extension = seed_object_get_property (sinfo->context,
+                                        sinfo->extensions,
+                                        g_type_name (exten_type));
+  return extension != NULL;
+}
+
+static PeasExtension *
+peas_plugin_loader_seed_get_extension (PeasPluginLoader *loader,
+                                       PeasPluginInfo   *info,
+                                       GType             exten_type)
+{
+  PeasPluginLoaderSeed *sloader = PEAS_PLUGIN_LOADER_SEED (loader);
+  SeedInfo *sinfo;
+  SeedValue extension;
+
+  sinfo = (SeedInfo *) g_hash_table_lookup (sloader->loaded_plugins, info);
+  if (!sinfo)
+    return NULL;
+
+  extension = seed_object_get_property (sinfo->context,
+                                        sinfo->extensions,
+                                        g_type_name (exten_type));
+  if (!extension)
+    return NULL;
+
+  if (!seed_value_is_object (sinfo->context, extension))
+    {
+      g_warning ("Extension %s in plugin %s is not a javascript object.",
+                 g_type_name (exten_type), peas_plugin_info_get_module_name (info));
+      return NULL;
+    }
+
+  return peas_extension_seed_new (exten_type, sinfo->context, extension);
 }
 
 static void
 peas_plugin_loader_seed_unload (PeasPluginLoader *loader,
                                 PeasPluginInfo   *info)
 {
+  PeasPluginLoaderSeed *sloader = PEAS_PLUGIN_LOADER_SEED (loader);
+  SeedInfo *sinfo;
+
+  sinfo = (SeedInfo *) g_hash_table_lookup (sloader->loaded_plugins, info);
+  if (!sinfo)
+    return;
+
+  g_hash_table_remove (sloader->loaded_plugins, info);
+  seed_value_unprotect (sinfo->context, sinfo->extensions);
+  seed_context_unref (sinfo->context);
+  g_slice_free (SeedInfo, sinfo);
 }
 
 static void
@@ -131,6 +205,8 @@ peas_plugin_loader_seed_init (PeasPluginLoaderSeed *sloader)
    * is no way to avoid having it shared... */
   if (!seed)
     seed = seed_init (NULL, NULL);
+
+  sloader->loaded_plugins = g_hash_table_new (g_direct_hash, g_direct_equal);
 }
 
 static void
@@ -140,6 +216,8 @@ peas_plugin_loader_seed_class_init (PeasPluginLoaderSeedClass *klass)
 
   loader_class->add_module_directory = peas_plugin_loader_seed_add_module_directory;
   loader_class->load = peas_plugin_loader_seed_load;
+  loader_class->provides_extension = peas_plugin_loader_seed_provides_extension;
+  loader_class->get_extension = peas_plugin_loader_seed_get_extension;
   loader_class->unload = peas_plugin_loader_seed_unload;
   loader_class->garbage_collect = peas_plugin_loader_seed_garbage_collect;
 }
@@ -149,11 +227,17 @@ peas_plugin_loader_seed_class_finalize (PeasPluginLoaderSeedClass *klass)
 {
 }
 
-G_MODULE_EXPORT GObject *
-register_peas_plugin_loader (GTypeModule *type_module)
+static GObject *
+create_plugin_loader (gconstpointer user_data)
 {
-  peas_plugin_loader_seed_register_type (type_module);
-  peas_seed_plugin_register_type_ext (type_module);
-
   return g_object_new (PEAS_TYPE_PLUGIN_LOADER_SEED, NULL);
 }
+
+G_MODULE_EXPORT void
+peas_register_types (PeasObjectModule *module)
+{
+  peas_plugin_loader_seed_register_type (G_TYPE_MODULE (module));
+  peas_extension_seed_register (G_TYPE_MODULE (module));
+
+  peas_object_module_register_extension (module, PEAS_TYPE_PLUGIN_LOADER, create_plugin_loader, NULL);
+}
diff --git a/loaders/seed/peas-plugin-loader-seed.h b/loaders/seed/peas-plugin-loader-seed.h
index 77979d8..20bbc2f 100644
--- a/loaders/seed/peas-plugin-loader-seed.h
+++ b/loaders/seed/peas-plugin-loader-seed.h
@@ -23,6 +23,7 @@
 #define __PEAS_PLUGIN_LOADER_SEED_H__
 
 #include <libpeas/peas-plugin-loader.h>
+#include <libpeas/peas-object-module.h>
 
 G_BEGIN_DECLS
 
@@ -38,6 +39,8 @@ typedef struct _PeasPluginLoaderSeedClass    PeasPluginLoaderSeedClass;
 
 struct _PeasPluginLoaderSeed {
   PeasPluginLoader parent;
+
+  GHashTable *loaded_plugins;
 };
 
 struct _PeasPluginLoaderSeedClass {
@@ -45,7 +48,7 @@ struct _PeasPluginLoaderSeedClass {
 };
 
 GType                    peas_plugin_loader_seed_get_type  (void) G_GNUC_CONST;
-G_MODULE_EXPORT GObject *register_peas_plugin_loader       (GTypeModule *module);
+G_MODULE_EXPORT void     peas_register_types               (PeasObjectModule *module);
 
 G_END_DECLS
 
diff --git a/peas-demo/plugins/seedhello/seedhello.js b/peas-demo/plugins/seedhello/seedhello.js
index 521935f..d19e6d7 100644
--- a/peas-demo/plugins/seedhello/seedhello.js
+++ b/peas-demo/plugins/seedhello/seedhello.js
@@ -4,7 +4,7 @@ var LABEL_STRING = "Seed Says Hello Too!";
 
 print("LABEL_STRING=" +  LABEL_STRING);
 
-plugin = {
+activatable_extension = {
   activate: function(win) {
     print("SeedHelloPlugin.activate");
     win._seedhello_label = new Gtk.Label({ label: LABEL_STRING });
@@ -16,4 +16,15 @@ plugin = {
     win.get_child().remove(win._seedhello_label);
     win._seedhello_label.destroy();
   },
+  update_state: function(win) {
+    print("SeedHelloPlugin.update_state");
+  }
+};
+
+configurable_extension = {
+};
+
+extensions = {
+  'PeasActivatable': activatable_extension,
+  'PeasUIConfigurable': configurable_extension,
 };



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