summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitignore3
-rw-r--r--configure.ac4
-rw-r--r--libpeas/Makefile.am2
-rw-r--r--libpeas/peas-plugin-info-priv.h2
-rw-r--r--libpeas/peas-plugin-info.c75
-rw-r--r--libpeas/peas-plugin-info.h4
-rw-r--r--tests/libpeas/extension-c.c25
-rw-r--r--tests/libpeas/extension-gjs.c32
-rw-r--r--tests/libpeas/extension-python.c27
-rw-r--r--tests/libpeas/extension-seed.c32
-rw-r--r--tests/libpeas/extension-set.c8
-rw-r--r--tests/libpeas/introspection/Makefile.am33
-rw-r--r--tests/libpeas/introspection/introspection-base.c71
-rw-r--r--tests/libpeas/introspection/introspection-base.h59
-rw-r--r--tests/libpeas/introspection/introspection-callable.c4
-rw-r--r--tests/libpeas/introspection/introspection-has-prerequisite.c4
-rw-r--r--tests/libpeas/plugins/extension-c/callable-plugin.c85
-rw-r--r--tests/libpeas/plugins/extension-c/callable-plugin.h9
-rw-r--r--tests/libpeas/plugins/extension-c/extension-c-plugin.c3
-rw-r--r--tests/libpeas/plugins/extension-c/extension-c.gschema.xml9
-rw-r--r--tests/libpeas/plugins/extension-js/Makefile.am17
-rw-r--r--tests/libpeas/plugins/extension-js/extension-js.gschema.xml9
-rw-r--r--tests/libpeas/plugins/extension-js/extension-js.js39
-rw-r--r--tests/libpeas/plugins/extension-python/extension-python.gschema.xml9
-rw-r--r--tests/libpeas/plugins/extension-python/extension-python.py33
-rw-r--r--tests/libpeas/testing/testing-extension.c61
-rw-r--r--tests/plugins/loadable/loadable-plugin.h5
27 files changed, 408 insertions, 256 deletions
diff --git a/.gitignore b/.gitignore
index 47ad3a5..f5a7293 100644
--- a/.gitignore
+++ b/.gitignore
@@ -11,6 +11,7 @@
*.gcov
.deps
.libs
+gschemas.compiled
Makefile
Makefile.in
/ABOUT-NLS
@@ -79,8 +80,10 @@ Makefile.in
/tests/libpeas/extension-seed
/tests/libpeas/extension-set
/tests/libpeas/plugin-info
+/tests/libpeas/plugins/extension-js/extension-gjs.gschema.xml
/tests/libpeas/plugins/extension-js/extension-gjs.js
/tests/libpeas/plugins/extension-js/extension-gjs.plugin
+/tests/libpeas/plugins/extension-js/extension-seed.gschema.xml
/tests/libpeas/plugins/extension-js/extension-seed.js
/tests/libpeas/plugins/extension-js/extension-seed.plugin
/tests/libpeas-gtk/plugin-manager
diff --git a/configure.ac b/configure.ac
index fedaaba..56eb2d4 100644
--- a/configure.ac
+++ b/configure.ac
@@ -85,12 +85,14 @@ dnl ================================================================
PKG_PROG_PKG_CONFIG
GLIB_REQUIRED=2.28.0
+GIO_REQUIRED=2.31.2
INTROSPECTION_REQUIRED=0.10.1
PKG_CHECK_MODULES(PEAS, [
glib-2.0 >= $GLIB_REQUIRED
gobject-2.0 >= $GLIB_REQUIRED
gmodule-2.0 >= $GLIB_REQUIRED
+ gio-2.0 >= $GIO_REQUIRED
gobject-introspection-1.0 >= $INTROSPECTION_REQUIRED
])
@@ -437,9 +439,11 @@ AC_SUBST(LT_AGE)
PLUGIN_LIBTOOL_FLAGS="-module -avoid-version"
TEST_PLUGIN_LIBTOOL_FLAGS="$PLUGIN_LIBTOOL_FLAGS -rpath /nowhere"
+TEST_INTROSPECTION_LIBTOOL_FLAGS="-rpath /nowhere -export-dynamic -no-undefined"
LOADER_LIBTOOL_FLAGS="-module -avoid-version -export-symbols-regex peas_register_types"
AC_SUBST(PLUGIN_LIBTOOL_FLAGS)
AC_SUBST(TEST_PLUGIN_LIBTOOL_FLAGS)
+AC_SUBST(TEST_INTROSPECTION_LIBTOOL_FLAGS)
AC_SUBST(LOADER_LIBTOOL_FLAGS)
dnl ================================================================
diff --git a/libpeas/Makefile.am b/libpeas/Makefile.am
index 101fdb5..3bc5159 100644
--- a/libpeas/Makefile.am
+++ b/libpeas/Makefile.am
@@ -94,7 +94,7 @@ if HAVE_INTROSPECTION
introspection_sources = $(INST_H_FILES) $(C_FILES)
Peas-1.0.gir: libpeas-1.0.la
- Peas_1_0_gir_INCLUDES = GObject-2.0 GModule-2.0 GIRepository-2.0
+ Peas_1_0_gir_INCLUDES = GObject-2.0 GModule-2.0 Gio-2.0 GIRepository-2.0
Peas_1_0_gir_CFLAGS = $(PEAS_CFLAGS)
Peas_1_0_gir_LIBS = libpeas-1.0.la
Peas_1_0_gir_FILES = $(addprefix $(srcdir)/,$(introspection_sources))
diff --git a/libpeas/peas-plugin-info-priv.h b/libpeas/peas-plugin-info-priv.h
index 304f3ec..12a08ef 100644
--- a/libpeas/peas-plugin-info-priv.h
+++ b/libpeas/peas-plugin-info-priv.h
@@ -32,6 +32,8 @@ struct _PeasPluginInfo {
gchar *module_dir;
gchar *data_dir;
+ GSettingsSchemaSource *schema_source;
+
gchar *module_name;
gchar *loader;
gchar **dependencies;
diff --git a/libpeas/peas-plugin-info.c b/libpeas/peas-plugin-info.c
index 1eef90a..a71fd22 100644
--- a/libpeas/peas-plugin-info.c
+++ b/libpeas/peas-plugin-info.c
@@ -79,6 +79,8 @@ _peas_plugin_info_unref (PeasPluginInfo *info)
g_free (info->module_dir);
g_free (info->data_dir);
+ if (info->schema_source != NULL)
+ g_settings_schema_source_unref (info->schema_source);
g_free (info->module_name);
g_strfreev (info->dependencies);
g_free (info->name);
@@ -427,6 +429,79 @@ peas_plugin_info_get_data_dir (const PeasPluginInfo *info)
}
/**
+ * peas_plugin_info_get_settings:
+ * @info: A #PeasPluginInfo.
+ * @schema_id: (allow-none): The schema id.
+ *
+ * Creates a new #GSettings for the given @schema_id and if
+ * gschemas.compiled is not in the module directory an attempt
+ * will be made to create it.
+ *
+ * Returns: (transfer full): a new #GSettings, or %NULL.
+ */
+GSettings *
+peas_plugin_info_get_settings (const PeasPluginInfo *info,
+ const gchar *schema_id)
+{
+ GSettingsSchema *schema;
+ GSettings *settings;
+
+ g_return_val_if_fail (info != NULL, NULL);
+
+ if (info->schema_source == NULL)
+ {
+ GFile *module_dir_location;
+ GFile *gschema_compiled;
+ GSettingsSchemaSource *default_source;
+
+ module_dir_location = g_file_new_for_path (info->module_dir);
+ gschema_compiled = g_file_get_child (module_dir_location,
+ "gschemas.compiled");
+
+ if (!g_file_query_exists (gschema_compiled, NULL))
+ {
+ const gchar *argv[] = {
+ "glib-compile-schemas",
+ "--targetdir", info->module_dir,
+ info->module_dir,
+ NULL
+ };
+
+ g_spawn_sync (NULL, (gchar **) argv, NULL, G_SPAWN_SEARCH_PATH,
+ NULL, NULL, NULL, NULL, NULL, NULL);
+ }
+
+ g_object_unref (gschema_compiled);
+ g_object_unref (module_dir_location);
+
+ default_source = g_settings_schema_source_get_default ();
+ ((PeasPluginInfo *) info)->schema_source =
+ g_settings_schema_source_new_from_directory (info->module_dir,
+ default_source,
+ FALSE, NULL);
+
+ /* glib-compile-schemas already outputted a message */
+ if (info->schema_source == NULL)
+ return NULL;
+ }
+
+ if (schema_id == NULL)
+ schema_id = info->module_name;
+
+ schema = g_settings_schema_source_lookup (info->schema_source, schema_id,
+ FALSE);
+
+ if (schema == NULL)
+ return NULL;
+
+ settings = g_settings_new_full (schema, NULL, NULL);
+
+ g_settings_schema_unref (schema);
+
+ return settings;
+}
+
+/**
* peas_plugin_info_get_dependencies:
* @info: A #PeasPluginInfo.
*
diff --git a/libpeas/peas-plugin-info.h b/libpeas/peas-plugin-info.h
index 3d95a32..8cb7da6 100644
--- a/libpeas/peas-plugin-info.h
+++ b/libpeas/peas-plugin-info.h
@@ -23,7 +23,7 @@
#ifndef __PEAS_PLUGIN_INFO_H__
#define __PEAS_PLUGIN_INFO_H__
-#include <glib-object.h>
+#include <gio/gio.h>
G_BEGIN_DECLS
@@ -80,6 +80,8 @@ gboolean peas_plugin_info_is_hidden (const PeasPluginInfo *info);
const gchar *peas_plugin_info_get_module_name (const PeasPluginInfo *info);
const gchar *peas_plugin_info_get_module_dir (const PeasPluginInfo *info);
const gchar *peas_plugin_info_get_data_dir (const PeasPluginInfo *info);
+GSettings *peas_plugin_info_get_settings (const PeasPluginInfo *info,
+ const gchar *schema_id);
const gchar **peas_plugin_info_get_dependencies (const PeasPluginInfo *info);
gboolean peas_plugin_info_has_dependency (const PeasPluginInfo *info,
const gchar *module_name);
diff --git a/tests/libpeas/extension-c.c b/tests/libpeas/extension-c.c
index 8ea9f9a..43d4687 100644
--- a/tests/libpeas/extension-c.c
+++ b/tests/libpeas/extension-c.c
@@ -26,7 +26,7 @@
#include "libpeas/peas.h"
#include "testing/testing-extension.h"
-#include "introspection/introspection-callable.h"
+#include "introspection/introspection-base.h"
static void
test_extension_c_instance_refcount (PeasEngine *engine,
@@ -35,7 +35,7 @@ test_extension_c_instance_refcount (PeasEngine *engine,
PeasExtension *extension;
extension = peas_engine_create_extension (engine, info,
- INTROSPECTION_TYPE_CALLABLE,
+ INTROSPECTION_TYPE_BASE,
NULL);
g_assert (PEAS_IS_EXTENSION (extension));
@@ -49,26 +49,6 @@ test_extension_c_instance_refcount (PeasEngine *engine,
}
static void
-test_extension_c_plugin_info (PeasEngine *engine)
-{
- PeasPluginInfo *info;
- PeasExtension *extension;
-
- info = peas_engine_get_plugin_info (engine, "loadable");
-
- g_assert (peas_engine_load_plugin (engine, info));
-
- extension = peas_engine_create_extension (engine, info,
- PEAS_TYPE_ACTIVATABLE,
- NULL);
-
- g_assert (PEAS_IS_EXTENSION_BASE (extension));
- g_assert (peas_extension_base_get_plugin_info (PEAS_EXTENSION_BASE (extension)) == info);
-
- g_object_unref (extension);
-}
-
-static void
test_extension_c_nonexistent (PeasEngine *engine)
{
PeasPluginInfo *info;
@@ -98,7 +78,6 @@ main (int argc,
testing_extension_callable ("c");
EXTENSION_TEST (c, "instance-refcount", instance_refcount);
- EXTENSION_TEST (c, "plugin-info", plugin_info);
EXTENSION_TEST (c, "nonexistent", nonexistent);
return testing_extension_run_tests ();
diff --git a/tests/libpeas/extension-gjs.c b/tests/libpeas/extension-gjs.c
index e57764d..3004943 100644
--- a/tests/libpeas/extension-gjs.c
+++ b/tests/libpeas/extension-gjs.c
@@ -28,37 +28,6 @@
#include "loaders/gjs/peas-extension-gjs.h"
#include "testing/testing-extension.h"
-#include "introspection/introspection-callable.h"
-
-static void
-test_extension_gjs_plugin_info (PeasEngine *engine,
- PeasPluginInfo *info)
-{
- PeasExtension *extension;
- PeasExtensionGjs *gexten;
- jsval js_value;
- GValue gvalue = { 0 };
-
- extension = peas_engine_create_extension (engine, info,
- INTROSPECTION_TYPE_CALLABLE,
- NULL);
-
- g_assert (PEAS_IS_EXTENSION (extension));
-
- gexten = (PeasExtensionGjs *) extension;
-
- g_value_init (&gvalue, PEAS_TYPE_PLUGIN_INFO);
-
- g_assert (JS_GetProperty (gexten->js_context, gexten->js_object,
- "plugin_info", &js_value));
- g_assert (gjs_value_to_g_value (gexten->js_context, js_value, &gvalue));
-
- g_assert (g_value_get_boxed (&gvalue) == info);
-
- g_value_unset (&gvalue);
-
- g_object_unref (extension);
-}
static void
test_extension_gjs_nonexistent (PeasEngine *engine)
@@ -83,7 +52,6 @@ main (int argc,
testing_extension_all ("gjs");
- EXTENSION_TEST (gjs, "plugin-info", plugin_info);
EXTENSION_TEST (gjs, "nonexistent", nonexistent);
return testing_extension_run_tests ();
diff --git a/tests/libpeas/extension-python.c b/tests/libpeas/extension-python.c
index 0b577ad..7f10436 100644
--- a/tests/libpeas/extension-python.c
+++ b/tests/libpeas/extension-python.c
@@ -29,7 +29,7 @@
#include "loaders/python/peas-extension-python.h"
#include "testing/testing-extension.h"
-#include "introspection/introspection-callable.h"
+#include "introspection/introspection-base.h"
static void
test_extension_python_instance_refcount (PeasEngine *engine,
@@ -39,7 +39,7 @@ test_extension_python_instance_refcount (PeasEngine *engine,
PyObject *instance;
extension = peas_engine_create_extension (engine, info,
- INTROSPECTION_TYPE_CALLABLE,
+ INTROSPECTION_TYPE_BASE,
NULL);
g_assert (PEAS_IS_EXTENSION (extension));
@@ -96,28 +96,6 @@ test_extension_python_activatable_subject_refcount (PeasEngine *engine,
}
static void
-test_extension_python_plugin_info (PeasEngine *engine,
- PeasPluginInfo *info)
-{
- PeasExtension *extension;
- PyObject *instance;
- PyObject *plugin_info;
-
- extension = peas_engine_create_extension (engine, info,
- INTROSPECTION_TYPE_CALLABLE,
- NULL);
-
- g_assert (PEAS_IS_EXTENSION (extension));
-
- instance = ((PeasExtensionPython *) extension)->instance;
-
- plugin_info = PyObject_GetAttrString (instance, "plugin_info");
- g_assert (((PyGBoxed *) plugin_info)->boxed == info);
-
- g_object_unref (extension);
-}
-
-static void
test_extension_python_nonexistent (PeasEngine *engine)
{
PeasPluginInfo *info;
@@ -140,7 +118,6 @@ main (int argc,
EXTENSION_TEST (python, "instance-refcount", instance_refcount);
EXTENSION_TEST (python, "activatable-subject-refcount", activatable_subject_refcount);
- EXTENSION_TEST (python, "plugin-info", plugin_info);
EXTENSION_TEST (python, "nonexistent", nonexistent);
return testing_extension_run_tests ();
diff --git a/tests/libpeas/extension-seed.c b/tests/libpeas/extension-seed.c
index ceff7eb..cd31750 100644
--- a/tests/libpeas/extension-seed.c
+++ b/tests/libpeas/extension-seed.c
@@ -28,37 +28,6 @@
#include "loaders/seed/peas-extension-seed.h"
#include "testing/testing-extension.h"
-#include "introspection/introspection-callable.h"
-
-static void
-test_extension_seed_plugin_info (PeasEngine *engine,
- PeasPluginInfo *info)
-{
- PeasExtension *extension;
- PeasExtensionSeed *sexten;
- SeedValue seed_value;
- GValue gvalue = { 0 };
-
- extension = peas_engine_create_extension (engine, info,
- INTROSPECTION_TYPE_CALLABLE,
- NULL);
-
- g_assert (PEAS_IS_EXTENSION (extension));
-
- sexten = (PeasExtensionSeed *) extension;
- seed_value = seed_object_get_property (sexten->js_context, sexten->js_object,
- "plugin_info");
-
- g_assert (seed_value_to_gvalue (sexten->js_context, seed_value,
- PEAS_TYPE_PLUGIN_INFO, &gvalue,
- NULL));
-
- g_assert (g_value_get_boxed (&gvalue) == info);
-
- g_value_unset (&gvalue);
-
- g_object_unref (extension);
-}
static void
test_extension_seed_nonexistent (PeasEngine *engine)
@@ -83,7 +52,6 @@ main (int argc,
testing_extension_all ("seed");
- EXTENSION_TEST (seed, "plugin-info", plugin_info);
EXTENSION_TEST (seed, "nonexistent", nonexistent);
return testing_extension_run_tests ();
diff --git a/tests/libpeas/extension-set.c b/tests/libpeas/extension-set.c
index 64c5efc..073e04a 100644
--- a/tests/libpeas/extension-set.c
+++ b/tests/libpeas/extension-set.c
@@ -158,9 +158,9 @@ test_extension_set_activate (PeasEngine *engine)
g_assert (peas_engine_load_plugin (engine, info));
}
- /* Load a plugin that does not provide a PeasActivatable
+ /* Load a plugin that does not provide a PeasActivatable */
info = peas_engine_get_plugin_info (engine, "extension-c");
- g_assert (peas_engine_load_plugin (engine, info)); */
+ g_assert (peas_engine_load_plugin (engine, info));
g_assert_cmpint (active, ==, G_N_ELEMENTS (loadable_plugins));
@@ -185,9 +185,9 @@ test_extension_set_deactivate (PeasEngine *engine)
test_extension_set_activate (engine);
- /* Unload the plugin that does not provide a PeasActivatable
+ /* Unload the plugin that does not provide a PeasActivatable */
info = peas_engine_get_plugin_info (engine, "extension-c");
- g_assert (peas_engine_unload_plugin (engine, info)); */
+ g_assert (peas_engine_unload_plugin (engine, info));
/* To keep deps in order */
for (i = G_N_ELEMENTS (loadable_plugins); i > 0; --i)
diff --git a/tests/libpeas/introspection/Makefile.am b/tests/libpeas/introspection/Makefile.am
index 1907573..1d522d3 100644
--- a/tests/libpeas/introspection/Makefile.am
+++ b/tests/libpeas/introspection/Makefile.am
@@ -1,20 +1,20 @@
noinst_LTLIBRARIES = libintrospection-1.0.la
-INTROSPECTION_INCLUDES = \
- -I$(top_srcdir) \
- -I$(srcdir) \
- $(PEAS_CFLAGS)
-
INCLUDES = \
+ -I$(top_srcdir) \
+ -I$(srcdir) \
+ $(PEAS_CFLAGS) \
$(WARN_CFLAGS) \
$(DISABLE_DEPRECATED)
-libintrospection_1_0_la_LDFLAGS = \
- -export-dynamic -no-undefined -export-symbols-regex "^[^_].*"
-
-libintrospection_1_0_la_LIBADD = $(PEAS_LIBS)
+libintrospection_1_0_la_LDFLAGS = $(TEST_INTROSPECTION_LIBTOOL_FLAGS)
+libintrospection_1_0_la_LIBADD = \
+ $(PEAS_LIBS) \
+ $(top_builddir)/libpeas/libpeas-1.0.la
libintrospection_1_0_la_SOURCES = \
+ introspection-base.c \
+ introspection-base.h \
introspection-callable.c \
introspection-callable.h \
introspection-has-missing-prerequisite.c \
@@ -26,21 +26,24 @@ libintrospection_1_0_la_SOURCES = \
introspection-unimplemented.c \
introspection-unimplemented.h
-INCLUDES += $(INTROSPECTION_INCLUDES)
-
-
-include $(INTROSPECTION_MAKEFILE)
INTROSPECTION_GIRS = Introspection-1.0.gir
INTROSPECTION_TYPELIBS = $(INTROSPECTION_GIRS:.gir=.typelib)
-INTROSPECTION_SCANNER_ARGS = --warn-all
+INTROSPECTION_SCANNER_ARGS = \
+ --add-include-path=$(top_builddir)/libpeas \
+ --warn-all
+INTROSPECTION_COMPILER_ARGS = \
+ --includedir=$(top_srcdir)/libpeas \
+ --includedir=$(top_builddir)/libpeas
introspection_sources = $(libintrospection_1_0_la_SOURCES)
Introspection-1.0.gir: libintrospection-1.0.la
Introspection_1_0_gir_INCLUDES = GObject-2.0
-Introspection_1_0_gir_CFLAGS = $(INTROSPECTION_INCLUDES)
-Introspection_1_0_gir_LIBS = libintrospection-1.0.la
+Introspection_1_0_gir_CFLAGS = $(PEAS_CFLAGS) -I$(top_srcdir)
+Introspection_1_0_gir_LIBS = $(top_builddir)/libpeas/libpeas-1.0.la libintrospection-1.0.la
Introspection_1_0_gir_FILES = $(addprefix $(srcdir)/,$(introspection_sources))
+Introspection_1_0_gir_SCANNERFLAGS = --include-uninstalled=$(top_builddir)/libpeas/Peas-1.0.gir
CLEANFILES = $(INTROSPECTION_GIRS) $(INTROSPECTION_TYPELIBS)
diff --git a/tests/libpeas/introspection/introspection-base.c b/tests/libpeas/introspection/introspection-base.c
new file mode 100644
index 0000000..f502969
--- /dev/null
+++ b/tests/libpeas/introspection/introspection-base.c
@@ -0,0 +1,71 @@
+/*
+ * introspection-base.h
+ * This file is part of libpeas
+ *
+ * Copyright (C) 2011 - Garrett Regier
+ *
+ * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "introspection-base.h"
+
+G_DEFINE_INTERFACE(IntrospectionBase, introspection_base, G_TYPE_OBJECT)
+
+void
+introspection_base_default_init (IntrospectionBaseInterface *iface)
+{
+}
+
+/**
+ * introspection_base_get_plugin_info:
+ * @base:
+ *
+ * Returns: (transfer none):
+ */
+const PeasPluginInfo *
+introspection_base_get_plugin_info (IntrospectionBase *base)
+{
+ IntrospectionBaseInterface *iface;
+
+ g_return_val_if_fail (INTROSPECTION_IS_BASE (base), NULL);
+
+ iface = INTROSPECTION_BASE_GET_IFACE (base);
+ g_assert (iface->get_plugin_info != NULL);
+
+ return iface->get_plugin_info (base);
+}
+
+/**
+ * introspection_base_get_settings:
+ * @base:
+ *
+ * Returns: (transfer full):
+ */
+GSettings *
+introspection_base_get_settings (IntrospectionBase *base)
+{
+ IntrospectionBaseInterface *iface;
+
+ g_return_val_if_fail (INTROSPECTION_IS_BASE (base), NULL);
+
+ iface = INTROSPECTION_BASE_GET_IFACE (base);
+ g_assert (iface->get_settings != NULL);
+
+ return iface->get_settings (base);
+}
diff --git a/tests/libpeas/introspection/introspection-base.h b/tests/libpeas/introspection/introspection-base.h
new file mode 100644
index 0000000..24d57d2
--- /dev/null
+++ b/tests/libpeas/introspection/introspection-base.h
@@ -0,0 +1,59 @@
+/*
+ * introspection-base.h
+ * This file is part of libpeas
+ *
+ * Copyright (C) 2011 - Garrett Regier
+ *
+ * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+#ifndef __INTROSPECTION_BASE_H__
+#define __INTROSPECTION_BASE_H__
+
+#include <libpeas/peas.h>
+
+G_BEGIN_DECLS
+
+/*
+ * Type checking and casting macros
+ */
+#define INTROSPECTION_TYPE_BASE (introspection_base_get_type ())
+#define INTROSPECTION_BASE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), INTROSPECTION_TYPE_BASE, IntrospectionBase))
+#define INTROSPECTION_BASE_IFACE(obj) (G_TYPE_CHECK_CLASS_CAST ((obj), INTROSPECTION_TYPE_BASE, IntrospectionBaseInterface))
+#define INTROSPECTION_IS_BASE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), INTROSPECTION_TYPE_BASE))
+#define INTROSPECTION_BASE_GET_IFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), INTROSPECTION_TYPE_BASE, IntrospectionBaseInterface))
+
+typedef struct _IntrospectionBase IntrospectionBase; /* dummy typedef */
+typedef struct _IntrospectionBaseInterface IntrospectionBaseInterface;
+
+struct _IntrospectionBaseInterface {
+ GTypeInterface g_iface;
+
+ /* Virtual public methods */
+ const PeasPluginInfo *(*get_plugin_info) (IntrospectionBase *base);
+ GSettings *(*get_settings) (IntrospectionBase *base);
+};
+
+/*
+ * Public methods
+ */
+GType introspection_base_get_type (void) G_GNUC_CONST;
+
+const PeasPluginInfo *introspection_base_get_plugin_info (IntrospectionBase *base);
+GSettings *introspection_base_get_settings (IntrospectionBase *base);
+
+G_END_DECLS
+
+#endif /* __INTROSPECTION_BASE_H__ */
diff --git a/tests/libpeas/introspection/introspection-callable.c b/tests/libpeas/introspection/introspection-callable.c
index fb5d513..a411480 100644
--- a/tests/libpeas/introspection/introspection-callable.c
+++ b/tests/libpeas/introspection/introspection-callable.c
@@ -52,6 +52,10 @@ introspection_callable_call_with_return (IntrospectionCallable *callable)
return NULL;
}
+/**
+ * introspection_callable_call_no_args:
+ * @callable:
+ */
void
introspection_callable_call_no_args (IntrospectionCallable *callable)
{
diff --git a/tests/libpeas/introspection/introspection-has-prerequisite.c b/tests/libpeas/introspection/introspection-has-prerequisite.c
index 625be31..d6c6b64 100644
--- a/tests/libpeas/introspection/introspection-has-prerequisite.c
+++ b/tests/libpeas/introspection/introspection-has-prerequisite.c
@@ -25,11 +25,11 @@
#include "introspection-has-prerequisite.h"
-#include "introspection-callable.h"
+#include "introspection-base.h"
G_DEFINE_INTERFACE(IntrospectionHasPrerequisite,
introspection_has_prerequisite,
- INTROSPECTION_TYPE_CALLABLE)
+ INTROSPECTION_TYPE_BASE)
void
introspection_has_prerequisite_default_init (IntrospectionHasPrerequisiteInterface *iface)
diff --git a/tests/libpeas/plugins/extension-c/callable-plugin.c b/tests/libpeas/plugins/extension-c/callable-plugin.c
index b52ab37..b8b1366 100644
--- a/tests/libpeas/plugins/extension-c/callable-plugin.c
+++ b/tests/libpeas/plugins/extension-c/callable-plugin.c
@@ -29,89 +29,46 @@
#include <libpeas/peas.h>
+#include "introspection-base.h"
#include "introspection-callable.h"
#include "introspection-has-prerequisite.h"
#include "callable-plugin.h"
-struct _TestingCallablePluginPrivate {
- GObject *object;
-};
-
-static void introspection_activatable_iface_init (PeasActivatableInterface *iface);
+static void introspection_base_iface_init (IntrospectionBaseInterface *iface);
static void introspection_callable_iface_init (IntrospectionCallableInterface *iface);
static void introspection_has_prerequisite_iface_init (IntrospectionHasPrerequisiteInterface *iface);
G_DEFINE_DYNAMIC_TYPE_EXTENDED (TestingCallablePlugin,
testing_callable_plugin,
- G_TYPE_OBJECT,
+ PEAS_TYPE_EXTENSION_BASE,
0,
- G_IMPLEMENT_INTERFACE_DYNAMIC (PEAS_TYPE_ACTIVATABLE,
- introspection_activatable_iface_init)
+ G_IMPLEMENT_INTERFACE_DYNAMIC (INTROSPECTION_TYPE_BASE,
+ introspection_base_iface_init)
G_IMPLEMENT_INTERFACE_DYNAMIC (INTROSPECTION_TYPE_CALLABLE,
introspection_callable_iface_init)
G_IMPLEMENT_INTERFACE_DYNAMIC (INTROSPECTION_TYPE_HAS_PREREQUISITE,
introspection_has_prerequisite_iface_init))
-enum {
- PROP_0,
- PROP_OBJECT
-};
-
static void
-testing_callable_plugin_set_property (GObject *object,
- guint prop_id,
- const GValue *value,
- GParamSpec *pspec)
+testing_callable_plugin_init (TestingCallablePlugin *plugin)
{
- TestingCallablePlugin *plugin = TESTING_CALLABLE_PLUGIN (object);
-
- switch (prop_id)
- {
- case PROP_OBJECT:
- plugin->priv->object = g_value_get_object (value);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
}
-static void
-testing_callable_plugin_get_property (GObject *object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec)
+static const PeasPluginInfo *
+testing_callable_plugin_get_plugin_info (IntrospectionBase *base)
{
- TestingCallablePlugin *plugin = TESTING_CALLABLE_PLUGIN (object);
-
- switch (prop_id)
- {
- case PROP_OBJECT:
- g_value_set_object (value, plugin->priv->object);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
+ return peas_extension_base_get_plugin_info (PEAS_EXTENSION_BASE (base));
}
-static void
-testing_callable_plugin_init (TestingCallablePlugin *plugin)
+static GSettings *
+testing_callable_plugin_get_settings (IntrospectionBase *base)
{
- plugin->priv = G_TYPE_INSTANCE_GET_PRIVATE (plugin,
- TESTING_TYPE_CALLABLE_PLUGIN,
- TestingCallablePluginPrivate);
-}
+ PeasPluginInfo *info;
-static void
-testing_callable_plugin_activate (PeasActivatable *activatable)
-{
-}
+ info = peas_extension_base_get_plugin_info (PEAS_EXTENSION_BASE (base));
-static void
-testing_callable_plugin_deactivate (PeasActivatable *activatable)
-{
+ return peas_plugin_info_get_settings (info, NULL);
}
static const gchar *
@@ -140,21 +97,13 @@ testing_callable_plugin_call_multi_args (IntrospectionCallable *callable,
static void
testing_callable_plugin_class_init (TestingCallablePluginClass *klass)
{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
-
- object_class->set_property = testing_callable_plugin_set_property;
- object_class->get_property = testing_callable_plugin_get_property;
-
- g_object_class_override_property (object_class, PROP_OBJECT, "object");
-
- g_type_class_add_private (klass, sizeof (TestingCallablePluginPrivate));
}
static void
-introspection_activatable_iface_init (PeasActivatableInterface *iface)
+introspection_base_iface_init (IntrospectionBaseInterface *iface)
{
- iface->activate = testing_callable_plugin_activate;
- iface->deactivate = testing_callable_plugin_deactivate;
+ iface->get_plugin_info = testing_callable_plugin_get_plugin_info;
+ iface->get_settings = testing_callable_plugin_get_settings;
}
static void
diff --git a/tests/libpeas/plugins/extension-c/callable-plugin.h b/tests/libpeas/plugins/extension-c/callable-plugin.h
index e48b250..74df477 100644
--- a/tests/libpeas/plugins/extension-c/callable-plugin.h
+++ b/tests/libpeas/plugins/extension-c/callable-plugin.h
@@ -38,16 +38,11 @@ typedef struct _TestingCallablePluginClass TestingCallablePluginClass;
typedef struct _TestingCallablePluginPrivate TestingCallablePluginPrivate;
struct _TestingCallablePlugin {
- /* Inherit from GObject and not PeasExtensionBase
- * to check that it is possible
- */
- GObject parent_instance;
-
- TestingCallablePluginPrivate *priv;
+ PeasExtensionBase parent_instance;
};
struct _TestingCallablePluginClass {
- GObjectClass parent_class;
+ PeasExtensionBaseClass parent_class;
};
GType testing_callable_plugin_get_type (void) G_GNUC_CONST;
diff --git a/tests/libpeas/plugins/extension-c/extension-c-plugin.c b/tests/libpeas/plugins/extension-c/extension-c-plugin.c
index 84f85de..321eed0 100644
--- a/tests/libpeas/plugins/extension-c/extension-c-plugin.c
+++ b/tests/libpeas/plugins/extension-c/extension-c-plugin.c
@@ -25,6 +25,7 @@
#include "extension-c-plugin.h"
+#include "introspection-base.h"
#include "introspection-callable.h"
#include "introspection-has-prerequisite.h"
@@ -36,7 +37,7 @@ peas_register_types (PeasObjectModule *module)
testing_callable_plugin_register (G_TYPE_MODULE (module));
peas_object_module_register_extension_type (module,
- PEAS_TYPE_ACTIVATABLE,
+ INTROSPECTION_TYPE_BASE,
TESTING_TYPE_CALLABLE_PLUGIN);
peas_object_module_register_extension_type (module,
INTROSPECTION_TYPE_CALLABLE,
diff --git a/tests/libpeas/plugins/extension-c/extension-c.gschema.xml b/tests/libpeas/plugins/extension-c/extension-c.gschema.xml
new file mode 100644
index 0000000..0bf761a
--- /dev/null
+++ b/tests/libpeas/plugins/extension-c/extension-c.gschema.xml
@@ -0,0 +1,9 @@
+<schemalist>
+ <schema id="extension-c" path="/org/gnome/libpeas/tests/extension-c/">
+ <key name="a-setting" type="s">
+ <default>'Blah'</default>
+ <summary>Just a setting.</summary>
+ <description>Just a setting.</description>
+ </key>
+ </schema>
+</schemalist>
diff --git a/tests/libpeas/plugins/extension-js/Makefile.am b/tests/libpeas/plugins/extension-js/Makefile.am
index cab7122..24d6dee 100644
--- a/tests/libpeas/plugins/extension-js/Makefile.am
+++ b/tests/libpeas/plugins/extension-js/Makefile.am
@@ -1,21 +1,28 @@
noinst_DATA = \
- extension-gjs.js \
- extension-gjs.plugin \
- extension-seed.js \
+ extension-gjs.gschema.xml \
+ extension-gjs.js \
+ extension-gjs.plugin \
+ extension-seed.gschema.xml \
+ extension-seed.js \
extension-seed.plugin
extension-js.%:
test -e $@
+%.gschema.xml: extension-js.gschema.xml
+ $(AM_V_GEN) cp $< $@ && \
+ $(SED) -i -e 's/JS_LOADER/$(@:extension-%.gschema.xml=%)/g' $@
+
%.js: extension-js.js
$(AM_V_GEN) $(LN_S) $< $@
%.plugin: extension-js.plugin
$(AM_V_GEN) cp $< $@ && \
- $(SED) -i -e 's/JS_LOADER/$(@:extension-%.plugin=%)/' $@
+ $(SED) -i -e 's/JS_LOADER/$(@:extension-%.plugin=%)/g' $@
EXTRA_DIST = \
- extension-js.js \
+ extension-js.gschema.xml \
+ extension-js.js \
extension-js.plugin
CLEANFILES = $(noinst_DATA)
diff --git a/tests/libpeas/plugins/extension-js/extension-js.gschema.xml b/tests/libpeas/plugins/extension-js/extension-js.gschema.xml
new file mode 100644
index 0000000..043a6ee
--- /dev/null
+++ b/tests/libpeas/plugins/extension-js/extension-js.gschema.xml
@@ -0,0 +1,9 @@
+<schemalist>
+ <schema id="extension-JS_LOADER" path="/org/gnome/libpeas/tests/extension-JS_LOADER/">
+ <key name="a-setting" type="s">
+ <default>'Blah'</default>
+ <summary>Just a setting.</summary>
+ <description>Just a setting.</description>
+ </key>
+ </schema>
+</schemalist>
diff --git a/tests/libpeas/plugins/extension-js/extension-js.js b/tests/libpeas/plugins/extension-js/extension-js.js
index 6953d6b..d3c2291 100644
--- a/tests/libpeas/plugins/extension-js/extension-js.js
+++ b/tests/libpeas/plugins/extension-js/extension-js.js
@@ -1,35 +1,44 @@
-function callable_extension() {
+const Peas = imports.gi.Peas;
+const Introspection = imports.gi.Introspection;
+
+function extension_js_plugin() {
+ this.read_only = "read-only";
+ this.readwrite = "readwrite";
}
-callable_extension.prototype = {
+extension_js_plugin.prototype = {
activate: function() {
},
deactivate: function() {
},
+
+ get_plugin_info: function() {
+ return this.plugin_info;
+ },
+ get_settings: function() {
+ return this.plugin_info.get_settings(null);
+ },
+
call_with_return: function() {
- return "Hello, World!"
+ return "Hello, World!";
},
call_no_args: function() {
},
call_single_arg: function() {
- return true
+ return true;
},
call_multi_args: function(in_, inout) {
- return [ inout, in_ ]
+ return [ inout, in_ ];
}
-}
-
-function properties_extension() {
- this.read_only = "read-only";
- this.readwrite = "readwrite";
-}
+};
function missing_prerequisite_extension() {}
var extensions = {
- "PeasActivatable": callable_extension,
- "IntrospectionCallable": callable_extension,
- "IntrospectionProperties": properties_extension,
- "IntrospectionHasPrerequisite": callable_extension,
+ "PeasActivatable": extension_js_plugin,
+ "IntrospectionBase": extension_js_plugin,
+ "IntrospectionCallable": extension_js_plugin,
+ "IntrospectionProperties": extension_js_plugin,
+ "IntrospectionHasPrerequisite": extension_js_plugin,
"IntrospectionHasMissingPrerequisite": missing_prerequisite_extension
};
diff --git a/tests/libpeas/plugins/extension-python/extension-python.gschema.xml b/tests/libpeas/plugins/extension-python/extension-python.gschema.xml
new file mode 100644
index 0000000..8ba4ee4
--- /dev/null
+++ b/tests/libpeas/plugins/extension-python/extension-python.gschema.xml
@@ -0,0 +1,9 @@
+<schemalist>
+ <schema id="extension-python" path="/org/gnome/libpeas/tests/extension-python/">
+ <key name="a-setting" type="s">
+ <default>'Blah'</default>
+ <summary>Just a setting.</summary>
+ <description>Just a setting.</description>
+ </key>
+ </schema>
+</schemalist>
diff --git a/tests/libpeas/plugins/extension-python/extension-python.py b/tests/libpeas/plugins/extension-python/extension-python.py
index 2791c15..242fc3d 100644
--- a/tests/libpeas/plugins/extension-python/extension-python.py
+++ b/tests/libpeas/plugins/extension-python/extension-python.py
@@ -3,19 +3,34 @@
from gi.repository import GObject, Introspection, Peas
-class ActivatablePythonPlugin(GObject.Object, Peas.Activatable):
+class ExtensionPythonPlugin(GObject.Object, Peas.Activatable,
+ Introspection.Base, Introspection.Callable,
+ Introspection.Properties,
+ Introspection.HasPrerequisite):
+
object = GObject.property(type=GObject.Object)
+ construct_only = GObject.property(type=str)
+ read_only = GObject.property(type=str, default="read-only")
+ write_only = GObject.property(type=str)
+ readwrite = GObject.property(type=str, default="readwrite")
+
def do_activate(self):
pass
def do_deactivate(self):
pass
- def update_state(self):
+ def do_update_state(self):
pass
-class CallablePythonPlugin(ActivatablePythonPlugin, Introspection.Callable):
+
+ def do_get_plugin_info(self):
+ return self.plugin_info
+
+ def do_get_settings(self):
+ return self.plugin_info.get_settings(None)
+
def do_call_with_return(self):
return "Hello, World!";
@@ -27,15 +42,3 @@ class CallablePythonPlugin(ActivatablePythonPlugin, Introspection.Callable):
def do_call_multi_args(self, in_, inout):
return (inout, in_)
-
-class PropertiesPythonPlugin(GObject.Object, Introspection.Properties):
- construct_only = GObject.property(type=str)
-
- read_only = GObject.property(type=str, default="read-only")
-
- write_only = GObject.property(type=str)
-
- readwrite = GObject.property(type=str, default="readwrite")
-
-class HasPrerequisitePythonPlugin(CallablePythonPlugin, Introspection.HasPrerequisite):
- pass
diff --git a/tests/libpeas/testing/testing-extension.c b/tests/libpeas/testing/testing-extension.c
index e14b391..b10293c 100644
--- a/tests/libpeas/testing/testing-extension.c
+++ b/tests/libpeas/testing/testing-extension.c
@@ -33,6 +33,7 @@
#include "testing.h"
#include "testing-extension.h"
+#include "introspection-base.h"
#include "introspection-callable.h"
#include "introspection-has-missing-prerequisite.h"
#include "introspection-has-prerequisite.h"
@@ -214,7 +215,7 @@ test_extension_create_with_prerequisite (PeasEngine *engine,
}
static void
-test_extension_reload (PeasEngine *engine,
+test_extension_reload (PeasEngine *engine,
PeasPluginInfo *info)
{
gint i;
@@ -227,6 +228,49 @@ test_extension_reload (PeasEngine *engine,
}
static void
+test_extension_plugin_info (PeasEngine *engine,
+ PeasPluginInfo *info)
+{
+ PeasExtension *extension;
+ IntrospectionBase *base;
+
+ g_assert (peas_engine_load_plugin (engine, info));
+
+ extension = peas_engine_create_extension (engine, info,
+ INTROSPECTION_TYPE_BASE,
+ NULL);
+
+ base = INTROSPECTION_BASE (extension);
+
+ g_assert (introspection_base_get_plugin_info (base) == info);
+
+ g_object_unref (extension);
+}
+
+static void
+test_extension_get_settings (PeasEngine *engine,
+ PeasPluginInfo *info)
+{
+ PeasExtension *extension;
+ IntrospectionBase *base;
+ GSettings *settings;
+
+ g_assert (peas_engine_load_plugin (engine, info));
+
+ extension = peas_engine_create_extension (engine, info,
+ INTROSPECTION_TYPE_BASE,
+ NULL);
+
+ base = INTROSPECTION_BASE (extension);
+
+ settings = introspection_base_get_settings (base);
+ g_assert (G_IS_SETTINGS (settings));
+
+ g_object_unref (settings);
+ g_object_unref (extension);
+}
+
+static void
test_extension_call_no_args (PeasEngine *engine,
PeasPluginInfo *info)
{
@@ -234,8 +278,7 @@ test_extension_call_no_args (PeasEngine *engine,
IntrospectionCallable *callable;
extension = peas_engine_create_extension (engine, info,
- PEAS_TYPE_ACTIVATABLE,
- "object", NULL,
+ INTROSPECTION_TYPE_CALLABLE,
NULL);
callable = INTROSPECTION_CALLABLE (extension);
@@ -255,8 +298,7 @@ test_extension_call_with_return (PeasEngine *engine,
const gchar *return_val = NULL;
extension = peas_engine_create_extension (engine, info,
- PEAS_TYPE_ACTIVATABLE,
- "object", NULL,
+ INTROSPECTION_TYPE_CALLABLE,
NULL);
callable = INTROSPECTION_CALLABLE (extension);
@@ -281,8 +323,7 @@ test_extension_call_single_arg (PeasEngine *engine,
gboolean called = FALSE;
extension = peas_engine_create_extension (engine, info,
- PEAS_TYPE_ACTIVATABLE,
- "object", NULL,
+ INTROSPECTION_TYPE_CALLABLE,
NULL);
callable = INTROSPECTION_CALLABLE (extension);
@@ -308,8 +349,7 @@ test_extension_call_multi_args (PeasEngine *engine,
gint inout_saved;
extension = peas_engine_create_extension (engine, info,
- PEAS_TYPE_ACTIVATABLE,
- "object", NULL,
+ INTROSPECTION_TYPE_CALLABLE,
NULL);
callable = INTROSPECTION_CALLABLE (extension);
@@ -437,6 +477,9 @@ testing_extension_basic (const gchar *loader)
_EXTENSION_TEST (loader, "create-with-prerequisite", create_with_prerequisite);
_EXTENSION_TEST (loader, "reload", reload);
+
+ _EXTENSION_TEST (loader, "plugin-info", plugin_info);
+ _EXTENSION_TEST (loader, "get-settings", get_settings);
}
void
diff --git a/tests/plugins/loadable/loadable-plugin.h b/tests/plugins/loadable/loadable-plugin.h
index 30530cb..178c721 100644
--- a/tests/plugins/loadable/loadable-plugin.h
+++ b/tests/plugins/loadable/loadable-plugin.h
@@ -38,7 +38,10 @@ typedef struct _TestingLoadablePluginClass TestingLoadablePluginClass;
typedef struct _TestingLoadablePluginPrivate TestingLoadablePluginPrivate;
struct _TestingLoadablePlugin {
- PeasExtensionBase parent_instance;
+ /* Inherit from GObject and not PeasExtensionBase
+ * to check that it is possible
+ */
+ GObject parent_instance;
TestingLoadablePluginPrivate *priv;
};