From aca4c87b2d4a36e6897923368c3016f3d6fcb36d Mon Sep 17 00:00:00 2001 From: Christian Hergert Date: Mon, 20 Mar 2023 20:00:02 -0700 Subject: tests: move PeasActivatable to IntrospectionActivatable We need this in the introspection library and there is no need to keep it in the "Peas" namespace now that it isn't part of libpeas shared library. --- tests/libpeas/extension-c.c | 6 +- tests/libpeas/extension-lua.c | 12 +- tests/libpeas/extension-py.c | 6 +- tests/libpeas/extension-set.c | 26 ++-- .../introspection/introspection-activatable.c | 135 +++++++++++++++++++++ .../introspection/introspection-activatable.h | 51 ++++++++ tests/libpeas/introspection/meson.build | 2 + tests/libpeas/plugins/embedded/embedded-plugin.c | 16 +-- tests/libpeas/plugins/embedded/meson.build | 2 +- .../plugins/extension-python/extension-py.py.in | 5 +- tests/libpeas/testing/testing-extension.c | 11 +- tests/plugins/builtin/builtin-plugin.c | 16 +-- tests/plugins/builtin/meson.build | 2 +- tests/plugins/has-dep/has-dep-plugin.c | 16 +-- tests/plugins/has-dep/meson.build | 2 +- tests/plugins/loadable/loadable-plugin.c | 18 +-- tests/plugins/loadable/meson.build | 2 +- tests/plugins/self-dep/meson.build | 2 +- tests/plugins/self-dep/self-dep-plugin.c | 16 +-- tests/testing-util/meson.build | 2 - tests/testing-util/peas-activatable.c | 135 --------------------- tests/testing-util/peas-activatable.h | 74 ----------- 22 files changed, 267 insertions(+), 290 deletions(-) create mode 100644 tests/libpeas/introspection/introspection-activatable.c create mode 100644 tests/libpeas/introspection/introspection-activatable.h delete mode 100644 tests/testing-util/peas-activatable.c delete mode 100644 tests/testing-util/peas-activatable.h diff --git a/tests/libpeas/extension-c.c b/tests/libpeas/extension-c.c index c2e9a24..55c559c 100644 --- a/tests/libpeas/extension-c.c +++ b/tests/libpeas/extension-c.c @@ -31,7 +31,7 @@ #include "plugins/embedded/embedded-plugin.h" #include "plugins/embedded/embedded-resources.h" -#include "peas-activatable.h" +#include "introspection/introspection-activatable.h" static void test_extension_c_embedded (PeasEngine *engine) @@ -67,7 +67,7 @@ test_extension_c_embedded (PeasEngine *engine) g_assert (peas_plugin_info_is_loaded (info)); extension = peas_engine_create_extension (engine, info, - PEAS_TYPE_ACTIVATABLE, + INTROSPECTION_TYPE_ACTIVATABLE, NULL); g_assert (TESTING_IS_EMBEDDED_PLUGIN (extension)); @@ -137,7 +137,7 @@ test_extension_c_local_linkage (PeasEngine *engine, INTROSPECTION_TYPE_BASE, NULL); loadable_extension = peas_engine_create_extension (engine, loadable_info, - PEAS_TYPE_ACTIVATABLE, + INTROSPECTION_TYPE_ACTIVATABLE, NULL); g_assert (G_IS_OBJECT (c_extension)); diff --git a/tests/libpeas/extension-lua.c b/tests/libpeas/extension-lua.c index 1fbd09e..0818025 100644 --- a/tests/libpeas/extension-lua.c +++ b/tests/libpeas/extension-lua.c @@ -45,18 +45,18 @@ set_garbage_collector_state (PeasEngine *engine, GObject *extension; extension = peas_engine_create_extension (engine, info, - PEAS_TYPE_ACTIVATABLE, + INTROSPECTION_TYPE_ACTIVATABLE, NULL); if (start) { /* collectgarbage('restart') */ - peas_activatable_activate (PEAS_ACTIVATABLE (extension)); + peas_activatable_activate (INTROSPECTION_ACTIVATABLE (extension)); } else { /* collectgarbage('stop') */ - peas_activatable_deactivate (PEAS_ACTIVATABLE (extension)); + peas_activatable_deactivate (INTROSPECTION_ACTIVATABLE (extension)); } g_object_unref (extension); @@ -71,7 +71,7 @@ test_extension_lua_instance_refcount (PeasEngine *engine, set_garbage_collector_state (engine, info, FALSE); extension = peas_engine_create_extension (engine, info, - PEAS_TYPE_ACTIVATABLE, + INTROSPECTION_TYPE_ACTIVATABLE, NULL); g_object_add_weak_pointer (extension, (gpointer *) &extension); @@ -87,7 +87,7 @@ test_extension_lua_instance_refcount (PeasEngine *engine, g_assert_cmpint (G_OBJECT (extension)->ref_count, ==, 1); /* Create a new Lua wrapper around the extension */ - peas_activatable_update_state (PEAS_ACTIVATABLE (extension)); + peas_activatable_update_state (INTROSPECTION_ACTIVATABLE (extension)); g_assert_cmpint (G_OBJECT (extension)->ref_count, ==, 2); /* The Lua wrapper still exists */ @@ -120,7 +120,7 @@ test_extension_lua_activatable_subject_refcount (PeasEngine *engine, /* We pre-create the wrapper to make it easier to check reference count */ extension = peas_engine_create_extension (engine, info, - PEAS_TYPE_ACTIVATABLE, + INTROSPECTION_TYPE_ACTIVATABLE, "object", object, NULL); g_object_add_weak_pointer (extension, (gpointer *) &extension); diff --git a/tests/libpeas/extension-py.c b/tests/libpeas/extension-py.c index 132482f..ed086e2 100644 --- a/tests/libpeas/extension-py.c +++ b/tests/libpeas/extension-py.c @@ -28,9 +28,9 @@ #include "libpeas/peas-engine-priv.h" -#include "peas-activatable.h" - #include "testing/testing-extension.h" + +#include "introspection/introspection-activatable.h" #include "introspection/introspection-base.h" #define PY_LOADER python @@ -73,7 +73,7 @@ test_extension_py_activatable_subject_refcount (PeasEngine *engine, /* we pre-create the wrapper to make it easier to check reference count */ extension = peas_engine_create_extension (engine, info, - PEAS_TYPE_ACTIVATABLE, + INTROSPECTION_TYPE_ACTIVATABLE, "object", object, NULL); diff --git a/tests/libpeas/extension-set.c b/tests/libpeas/extension-set.c index 06aa318..60cec72 100644 --- a/tests/libpeas/extension-set.c +++ b/tests/libpeas/extension-set.c @@ -29,7 +29,7 @@ #include #include -#include "peas-activatable.h" +#include "introspection-activatable.h" #include "testing/testing.h" @@ -71,7 +71,7 @@ testing_extension_set_new (PeasEngine *engine, PeasExtensionSet *extension_set; extension_set = peas_extension_set_new (engine, - PEAS_TYPE_ACTIVATABLE, + INTROSPECTION_TYPE_ACTIVATABLE, "object", NULL, NULL); @@ -106,7 +106,7 @@ testing_extension_set_new (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 IntrospectionActivatable */ info = peas_engine_get_plugin_info (engine, "extension-c"); g_assert (peas_engine_load_plugin (engine, info)); @@ -142,7 +142,7 @@ test_extension_set_create_valid (PeasEngine *engine) PeasExtensionSet *extension_set; extension_set = peas_extension_set_new (engine, - PEAS_TYPE_ACTIVATABLE, + INTROSPECTION_TYPE_ACTIVATABLE, "object", NULL, NULL); @@ -156,7 +156,7 @@ valid_extension_added_cb (PeasExtensionSet *extension_set, GObject **obj_ptr) { g_clear_object (obj_ptr); - g_object_get (PEAS_ACTIVATABLE (extension), "object", obj_ptr, NULL); + g_object_get (INTROSPECTION_ACTIVATABLE (extension), "object", obj_ptr, NULL); } static void @@ -174,7 +174,7 @@ test_extension_set_create_valid_with_properties (PeasEngine *engine) g_value_set_object (&prop_value, obj); extension_set = peas_extension_set_new_with_properties (engine, - PEAS_TYPE_ACTIVATABLE, + INTROSPECTION_TYPE_ACTIVATABLE, G_N_ELEMENTS (prop_names), prop_names, &prop_value); @@ -202,7 +202,7 @@ test_extension_set_create_invalid (PeasEngine *engine) PeasExtensionSet *extension_set; testing_util_push_log_hook ("*assertion*G_TYPE_IS_INTERFACE*failed"); - testing_util_push_log_hook ("*type 'PeasActivatable' has no property named 'invalid-property'"); + testing_util_push_log_hook ("*type 'IntrospectionActivatable' has no property named 'invalid-property'"); /* Invalid GType */ extension_set = peas_extension_set_new (engine, G_TYPE_INVALID, NULL); @@ -216,7 +216,7 @@ test_extension_set_create_invalid (PeasEngine *engine) /* Interface does not have an 'invalid-property' property */ extension_set = peas_extension_set_new (engine, - PEAS_TYPE_ACTIVATABLE, + INTROSPECTION_TYPE_ACTIVATABLE, "invalid-property", "does-not-exist", NULL); g_assert (!PEAS_IS_EXTENSION_SET (extension_set)); @@ -242,7 +242,7 @@ test_extension_set_create_invalid_with_properties (PeasEngine *engine) /* Interface has a NULL property name*/ n_elements = G_N_ELEMENTS (prop_values); extension_set = peas_extension_set_new_with_properties (engine, - PEAS_TYPE_ACTIVATABLE, + INTROSPECTION_TYPE_ACTIVATABLE, n_elements, prop_names, prop_values); @@ -258,7 +258,7 @@ test_extension_set_create_invalid_with_properties (PeasEngine *engine) /* Uninitialized GValue */ n_elements = 1; extension_set = peas_extension_set_new_with_properties (engine, - PEAS_TYPE_ACTIVATABLE, + INTROSPECTION_TYPE_ACTIVATABLE, n_elements, prop_names, prop_values); @@ -269,7 +269,7 @@ test_extension_set_create_invalid_with_properties (PeasEngine *engine) g_value_set_pointer (&prop_values[0], NULL); n_elements = G_N_ELEMENTS (prop_names_not_exist); extension_set = peas_extension_set_new_with_properties (engine, - PEAS_TYPE_ACTIVATABLE, + INTROSPECTION_TYPE_ACTIVATABLE, n_elements, prop_names_not_exist, prop_values); @@ -307,7 +307,7 @@ test_extension_set_extension_removed (PeasEngine *engine) extension_set = testing_extension_set_new (engine, &active); - /* Unload the plugin that does not provide a PeasActivatable */ + /* Unload the plugin that does not provide a IntrospectionActivatable */ info = peas_engine_get_plugin_info (engine, "extension-c"); g_assert (peas_engine_unload_plugin (engine, info)); @@ -337,7 +337,7 @@ test_extension_set_get_extension (PeasEngine *engine) info = peas_engine_get_plugin_info (engine, loadable_plugins[0]); extension = peas_extension_set_get_extension (extension_set, info); - g_assert (PEAS_IS_ACTIVATABLE (extension)); + g_assert (INTROSPECTION_IS_ACTIVATABLE (extension)); g_object_add_weak_pointer (G_OBJECT (extension), (gpointer) &extension); diff --git a/tests/libpeas/introspection/introspection-activatable.c b/tests/libpeas/introspection/introspection-activatable.c new file mode 100644 index 0000000..1805c61 --- /dev/null +++ b/tests/libpeas/introspection/introspection-activatable.c @@ -0,0 +1,135 @@ +/* + * introspection-activatable.c + * This file is part of libintrospection + * + * Copyright (C) 2010 Steve Frécinaux + * + * libintrospection is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * libintrospection 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * SPDX-License-Identifier: LGPL-2.1-or-later + */ + +#include "config.h" + +#include "introspection-activatable.h" + +/** + * IntrospectionActivatable: + * + * Interface for activatable plugins. + * + * #IntrospectionActivatable is an interface which should be implemented by plugins + * that should be activated on an object of a certain type (depending on the + * application). For instance, in a typical windowed application, + * #IntrospectionActivatable plugin instances could be bound to individual toplevel + * windows. + * + * It is typical to use #IntrospectionActivatable along with [class@ExtensionSet] in order + * to activate and deactivate extensions automatically when plugins are loaded + * or unloaded. + * + * You can also use the code of this interface as a base for your own + * extension types, as illustrated by gedit's %GeditWindowActivatable and + * %GeditDocumentActivatable interfaces. + **/ + +G_DEFINE_INTERFACE(IntrospectionActivatable, introspection_activatable, G_TYPE_OBJECT) + +static void +introspection_activatable_default_init (IntrospectionActivatableInterface *iface) +{ + /** + * IntrospectionActivatable:object: + * + * The object property contains the targetted object for this #IntrospectionActivatable + * instance. + * + * For example a toplevel window in a typical windowed application. It is set + * at construction time and won't change. + */ + g_object_interface_install_property (iface, + g_param_spec_object ("object", + "Object", + "Object", + G_TYPE_OBJECT, + G_PARAM_READWRITE | + G_PARAM_CONSTRUCT_ONLY | + G_PARAM_STATIC_STRINGS)); +} + +/** + * introspection_activatable_activate: + * @activatable: A #IntrospectionActivatable. + * + * Activates the extension on the targetted object. + * + * On activation, the extension should hook itself to the object + * where it makes sense. + */ +void +introspection_activatable_activate (IntrospectionActivatable *activatable) +{ + IntrospectionActivatableInterface *iface; + + g_return_if_fail (INTROSPECTION_IS_ACTIVATABLE (activatable)); + + iface = INTROSPECTION_ACTIVATABLE_GET_IFACE (activatable); + g_return_if_fail (iface->activate != NULL); + + iface->activate (activatable); +} + +/** + * introspection_activatable_deactivate: + * @activatable: A #IntrospectionActivatable. + * + * Deactivates the extension on the targetted object. + * + * On deactivation, an extension should remove itself from all the hooks it + * used and should perform any cleanup required, so it can be unreffed safely + * and without any more effect on the host application. + */ +void +introspection_activatable_deactivate (IntrospectionActivatable *activatable) +{ + IntrospectionActivatableInterface *iface; + + g_return_if_fail (INTROSPECTION_IS_ACTIVATABLE (activatable)); + + iface = INTROSPECTION_ACTIVATABLE_GET_IFACE (activatable); + g_return_if_fail (iface->deactivate != NULL); + + iface->deactivate (activatable); +} + +/** + * introspection_activatable_update_state: + * @activatable: A #IntrospectionActivatable. + * + * Triggers an update of the extension internal state to take into account + * state changes in the targetted object, due to some event or user action. + */ +void +introspection_activatable_update_state (IntrospectionActivatable *activatable) +{ + IntrospectionActivatableInterface *iface; + + g_return_if_fail (INTROSPECTION_IS_ACTIVATABLE (activatable)); + + iface = INTROSPECTION_ACTIVATABLE_GET_IFACE (activatable); + if (iface->update_state != NULL) + iface->update_state (activatable); +} + diff --git a/tests/libpeas/introspection/introspection-activatable.h b/tests/libpeas/introspection/introspection-activatable.h new file mode 100644 index 0000000..c38456a --- /dev/null +++ b/tests/libpeas/introspection/introspection-activatable.h @@ -0,0 +1,51 @@ +/* + * introspection-activatable.h + * This file is part of libintrospection + * + * Copyright (C) 2010 - Steve Frécinaux + * + * libintrospection is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * libintrospection 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * SPDX-License-Identifier: LGPL-2.1-or-later + */ + +#pragma once + +#include + +G_BEGIN_DECLS + +#define INTROSPECTION_TYPE_ACTIVATABLE (introspection_activatable_get_type ()) +#define INTROSPECTION_ACTIVATABLE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), INTROSPECTION_TYPE_ACTIVATABLE, IntrospectionActivatable)) +#define INTROSPECTION_ACTIVATABLE_IFACE(obj) (G_TYPE_CHECK_CLASS_CAST ((obj), INTROSPECTION_TYPE_ACTIVATABLE, IntrospectionActivatableInterface)) +#define INTROSPECTION_IS_ACTIVATABLE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), INTROSPECTION_TYPE_ACTIVATABLE)) +#define INTROSPECTION_ACTIVATABLE_GET_IFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), INTROSPECTION_TYPE_ACTIVATABLE, IntrospectionActivatableInterface)) + +typedef struct _IntrospectionActivatable IntrospectionActivatable; /* dummy typedef */ +typedef struct _IntrospectionActivatableInterface IntrospectionActivatableInterface; + +struct _IntrospectionActivatableInterface { + GTypeInterface g_iface; + void (*activate) (IntrospectionActivatable *activatable); + void (*deactivate) (IntrospectionActivatable *activatable); + void (*update_state) (IntrospectionActivatable *activatable); +}; + +GType introspection_activatable_get_type (void) G_GNUC_CONST; +void introspection_activatable_activate (IntrospectionActivatable *activatable); +void introspection_activatable_deactivate (IntrospectionActivatable *activatable); +void introspection_activatable_update_state (IntrospectionActivatable *activatable); + +G_END_DECLS diff --git a/tests/libpeas/introspection/meson.build b/tests/libpeas/introspection/meson.build index f2e3853..a7eb8c1 100644 --- a/tests/libpeas/introspection/meson.build +++ b/tests/libpeas/introspection/meson.build @@ -3,6 +3,7 @@ libintrospection_string = '@0@-@1@'.format(libintrospection_name, api_version) libintrospection_public_h = [ 'introspection-abstract.h', + 'introspection-activatable.h', 'introspection-base.h', 'introspection-callable.h', 'introspection-has-prerequisite.h', @@ -12,6 +13,7 @@ libintrospection_public_h = [ libintrospection_c = [ 'introspection-abstract.c', + 'introspection-activatable.c', 'introspection-base.c', 'introspection-callable.c', 'introspection-has-prerequisite.c', diff --git a/tests/libpeas/plugins/embedded/embedded-plugin.c b/tests/libpeas/plugins/embedded/embedded-plugin.c index 747b2c5..22fe447 100644 --- a/tests/libpeas/plugins/embedded/embedded-plugin.c +++ b/tests/libpeas/plugins/embedded/embedded-plugin.c @@ -29,21 +29,21 @@ #include "embedded-plugin.h" -#include "peas-activatable.h" +#include "introspection-activatable.h" typedef struct { GObject *object; } TestingEmbeddedPluginPrivate; -static void peas_activatable_iface_init (PeasActivatableInterface *iface); +static void introspection_activatable_iface_init (IntrospectionActivatableInterface *iface); G_DEFINE_TYPE_EXTENDED (TestingEmbeddedPlugin, testing_embedded_plugin, PEAS_TYPE_EXTENSION_BASE, 0, G_ADD_PRIVATE (TestingEmbeddedPlugin) - G_IMPLEMENT_INTERFACE (PEAS_TYPE_ACTIVATABLE, - peas_activatable_iface_init)) + G_IMPLEMENT_INTERFACE (INTROSPECTION_TYPE_ACTIVATABLE, + introspection_activatable_iface_init)) #define GET_PRIV(o) \ (testing_embedded_plugin_get_instance_private (o)) @@ -101,12 +101,12 @@ testing_embedded_plugin_init (TestingEmbeddedPlugin *plugin) } static void -testing_embedded_plugin_activate (PeasActivatable *activatable) +testing_embedded_plugin_activate (IntrospectionActivatable *activatable) { } static void -testing_embedded_plugin_deactivate (PeasActivatable *activatable) +testing_embedded_plugin_deactivate (IntrospectionActivatable *activatable) { } @@ -122,7 +122,7 @@ testing_embedded_plugin_class_init (TestingEmbeddedPluginClass *klass) } static void -peas_activatable_iface_init (PeasActivatableInterface *iface) +introspection_activatable_iface_init (IntrospectionActivatableInterface *iface) { iface->activate = testing_embedded_plugin_activate; iface->deactivate = testing_embedded_plugin_deactivate; @@ -132,6 +132,6 @@ G_MODULE_EXPORT void testing_embedded_plugin_register_types (PeasObjectModule *module) { peas_object_module_register_extension_type (module, - PEAS_TYPE_ACTIVATABLE, + INTROSPECTION_TYPE_ACTIVATABLE, TESTING_TYPE_EMBEDDED_PLUGIN); } diff --git a/tests/libpeas/plugins/embedded/meson.build b/tests/libpeas/plugins/embedded/meson.build index bd8b81b..c7711b9 100644 --- a/tests/libpeas/plugins/embedded/meson.build +++ b/tests/libpeas/plugins/embedded/meson.build @@ -33,7 +33,7 @@ libembedded_res = gnome.compile_resources( libembedded_deps = [ glib_dep, libpeas_dep, - libtesting_util_dep, + libintrospection_dep, ] libembedded_lib = shared_library( diff --git a/tests/libpeas/plugins/extension-python/extension-py.py.in b/tests/libpeas/plugins/extension-python/extension-py.py.in index 59070c4..75e8cd1 100644 --- a/tests/libpeas/plugins/extension-python/extension-py.py.in +++ b/tests/libpeas/plugins/extension-python/extension-py.py.in @@ -21,7 +21,7 @@ import threading -from gi.repository import GObject, Introspection, Peas +from gi.repository import GObject, Introspection __all__ = [ 'ExtensionPythonAbstract', 'ExtensionPythonPlugin' ] @@ -31,7 +31,8 @@ class ExtensionPythonAbstract(Introspection.Abstract): pass -class ExtensionPythonPlugin(Introspection.Prerequisite, Peas.Activatable, +class ExtensionPythonPlugin(Introspection.Prerequisite, + Introspection.Activatable, Introspection.Base, Introspection.Callable, Introspection.HasPrerequisite): diff --git a/tests/libpeas/testing/testing-extension.c b/tests/libpeas/testing/testing-extension.c index 796bcc8..d4790d5 100644 --- a/tests/libpeas/testing/testing-extension.c +++ b/tests/libpeas/testing/testing-extension.c @@ -34,13 +34,12 @@ #include "testing-extension.h" #include "introspection-abstract.h" +#include "introspection-activatable.h" #include "introspection-base.h" #include "introspection-callable.h" #include "introspection-has-prerequisite.h" #include "introspection-unimplemented.h" -#include "peas-activatable.h" - typedef struct _TestFixture TestFixture; struct _TestFixture { @@ -477,13 +476,13 @@ test_extension_multiple_threads_nonglobal_loaders (PeasEngine *engine, } static void -multiple_threads_callbacks_in_thread (guint nth_thread, - PeasActivatable *activatable) +multiple_threads_callbacks_in_thread (guint nth_thread, + IntrospectionActivatable *activatable) { gint i; for (i = 0; i < 100; ++i) - peas_activatable_update_state (activatable); + introspection_activatable_update_state (activatable); } static void @@ -494,7 +493,7 @@ test_extension_multiple_threads_callbacks (PeasEngine *engine, gint n_threads, update_count; extension = peas_engine_create_extension (engine, info, - PEAS_TYPE_ACTIVATABLE, + INTROSPECTION_TYPE_ACTIVATABLE, NULL); n_threads = run_in_multiple_threads ((GFunc) multiple_threads_callbacks_in_thread, diff --git a/tests/plugins/builtin/builtin-plugin.c b/tests/plugins/builtin/builtin-plugin.c index f191068..1d6800d 100644 --- a/tests/plugins/builtin/builtin-plugin.c +++ b/tests/plugins/builtin/builtin-plugin.c @@ -29,7 +29,7 @@ #include -#include "peas-activatable.h" +#include "introspection-activatable.h" #include "builtin-plugin.h" @@ -37,15 +37,15 @@ typedef struct { GObject *object; } TestingBuiltinPluginPrivate; -static void peas_activatable_iface_init (PeasActivatableInterface *iface); +static void introspection_activatable_iface_init (IntrospectionActivatableInterface *iface); G_DEFINE_DYNAMIC_TYPE_EXTENDED (TestingBuiltinPlugin, testing_builtin_plugin, PEAS_TYPE_EXTENSION_BASE, 0, G_ADD_PRIVATE_DYNAMIC (TestingBuiltinPlugin) - G_IMPLEMENT_INTERFACE_DYNAMIC (PEAS_TYPE_ACTIVATABLE, - peas_activatable_iface_init)) + G_IMPLEMENT_INTERFACE_DYNAMIC (INTROSPECTION_TYPE_ACTIVATABLE, + introspection_activatable_iface_init)) #define GET_PRIV(o) \ (testing_builtin_plugin_get_instance_private (o)) @@ -103,12 +103,12 @@ testing_builtin_plugin_init (TestingBuiltinPlugin *plugin) } static void -testing_builtin_plugin_activate (PeasActivatable *activatable) +testing_builtin_plugin_activate (IntrospectionActivatable *activatable) { } static void -testing_builtin_plugin_deactivate (PeasActivatable *activatable) +testing_builtin_plugin_deactivate (IntrospectionActivatable *activatable) { } @@ -136,7 +136,7 @@ testing_builtin_plugin_class_init (TestingBuiltinPluginClass *klass) } static void -peas_activatable_iface_init (PeasActivatableInterface *iface) +introspection_activatable_iface_init (IntrospectionActivatableInterface *iface) { iface->activate = testing_builtin_plugin_activate; iface->deactivate = testing_builtin_plugin_deactivate; @@ -153,6 +153,6 @@ peas_register_types (PeasObjectModule *module) testing_builtin_plugin_register_type (G_TYPE_MODULE (module)); peas_object_module_register_extension_type (module, - PEAS_TYPE_ACTIVATABLE, + INTROSPECTION_TYPE_ACTIVATABLE, TESTING_TYPE_BUILTIN_PLUGIN); } diff --git a/tests/plugins/builtin/meson.build b/tests/plugins/builtin/meson.build index 578ec82..6361672 100644 --- a/tests/plugins/builtin/meson.build +++ b/tests/plugins/builtin/meson.build @@ -16,7 +16,7 @@ libbuiltin_plugin_deps = [ glib_dep, gobject_dep, libpeas_dep, - libtesting_util_dep, + libintrospection_dep, ] libbuiltin_lib = shared_library( diff --git a/tests/plugins/has-dep/has-dep-plugin.c b/tests/plugins/has-dep/has-dep-plugin.c index 57cb237..eaa3d17 100644 --- a/tests/plugins/has-dep/has-dep-plugin.c +++ b/tests/plugins/has-dep/has-dep-plugin.c @@ -29,7 +29,7 @@ #include -#include "peas-activatable.h" +#include "introspection-activatable.h" #include "has-dep-plugin.h" @@ -37,15 +37,15 @@ typedef struct { GObject *object; } TestingHasDepPluginPrivate; -static void peas_activatable_iface_init (PeasActivatableInterface *iface); +static void introspection_activatable_iface_init (IntrospectionActivatableInterface *iface); G_DEFINE_DYNAMIC_TYPE_EXTENDED (TestingHasDepPlugin, testing_has_dep_plugin, PEAS_TYPE_EXTENSION_BASE, 0, G_ADD_PRIVATE_DYNAMIC (TestingHasDepPlugin) - G_IMPLEMENT_INTERFACE_DYNAMIC (PEAS_TYPE_ACTIVATABLE, - peas_activatable_iface_init)) + G_IMPLEMENT_INTERFACE_DYNAMIC (INTROSPECTION_TYPE_ACTIVATABLE, + introspection_activatable_iface_init)) #define GET_PRIV(o) \ (testing_has_dep_plugin_get_instance_private (o)) @@ -103,12 +103,12 @@ testing_has_dep_plugin_init (TestingHasDepPlugin *plugin) } static void -testing_has_dep_plugin_activate (PeasActivatable *activatable) +testing_has_dep_plugin_activate (IntrospectionActivatable *activatable) { } static void -testing_has_dep_plugin_deactivate (PeasActivatable *activatable) +testing_has_dep_plugin_deactivate (IntrospectionActivatable *activatable) { } @@ -124,7 +124,7 @@ testing_has_dep_plugin_class_init (TestingHasDepPluginClass *klass) } static void -peas_activatable_iface_init (PeasActivatableInterface *iface) +introspection_activatable_iface_init (IntrospectionActivatableInterface *iface) { iface->activate = testing_has_dep_plugin_activate; iface->deactivate = testing_has_dep_plugin_deactivate; @@ -141,6 +141,6 @@ peas_register_types (PeasObjectModule *module) testing_has_dep_plugin_register_type (G_TYPE_MODULE (module)); peas_object_module_register_extension_type (module, - PEAS_TYPE_ACTIVATABLE, + INTROSPECTION_TYPE_ACTIVATABLE, TESTING_TYPE_HAS_DEP_PLUGIN); } diff --git a/tests/plugins/has-dep/meson.build b/tests/plugins/has-dep/meson.build index 66cb099..9c158af 100644 --- a/tests/plugins/has-dep/meson.build +++ b/tests/plugins/has-dep/meson.build @@ -17,7 +17,7 @@ libhas_dep_plugin_deps = [ gobject_dep, gmodule_dep, libpeas_dep, - libtesting_util_dep, + libintrospection_dep, ] libhas_dep_lib = shared_library( diff --git a/tests/plugins/loadable/loadable-plugin.c b/tests/plugins/loadable/loadable-plugin.c index f279407..3f32817 100644 --- a/tests/plugins/loadable/loadable-plugin.c +++ b/tests/plugins/loadable/loadable-plugin.c @@ -29,7 +29,7 @@ #include -#include "peas-activatable.h" +#include "introspection-activatable.h" #include "loadable-plugin.h" @@ -37,15 +37,15 @@ typedef struct { GObject *object; } TestingLoadablePluginPrivate; -static void peas_activatable_iface_init (PeasActivatableInterface *iface); +static void introspection_activatable_iface_init (IntrospectionActivatableInterface *iface); G_DEFINE_DYNAMIC_TYPE_EXTENDED (TestingLoadablePlugin, testing_loadable_plugin, G_TYPE_OBJECT, 0, G_ADD_PRIVATE_DYNAMIC (TestingLoadablePlugin) - G_IMPLEMENT_INTERFACE_DYNAMIC (PEAS_TYPE_ACTIVATABLE, - peas_activatable_iface_init)) + G_IMPLEMENT_INTERFACE_DYNAMIC (INTROSPECTION_TYPE_ACTIVATABLE, + introspection_activatable_iface_init)) #define GET_PRIV(o) \ (testing_loadable_plugin_get_instance_private (o)) @@ -54,7 +54,7 @@ enum { PROP_0, PROP_GLOBAL_SYMBOL_CLASH, - /* PeasActivatable */ + /* IntrospectionActivatable */ PROP_OBJECT, N_PROPERTIES = PROP_OBJECT }; @@ -113,12 +113,12 @@ testing_loadable_plugin_init (TestingLoadablePlugin *plugin) } static void -testing_loadable_plugin_activate (PeasActivatable *activatable) +testing_loadable_plugin_activate (IntrospectionActivatable *activatable) { } static void -testing_loadable_plugin_deactivate (PeasActivatable *activatable) +testing_loadable_plugin_deactivate (IntrospectionActivatable *activatable) { } @@ -143,7 +143,7 @@ testing_loadable_plugin_class_init (TestingLoadablePluginClass *klass) } static void -peas_activatable_iface_init (PeasActivatableInterface *iface) +introspection_activatable_iface_init (IntrospectionActivatableInterface *iface) { iface->activate = testing_loadable_plugin_activate; iface->deactivate = testing_loadable_plugin_deactivate; @@ -160,6 +160,6 @@ peas_register_types (PeasObjectModule *module) testing_loadable_plugin_register_type (G_TYPE_MODULE (module)); peas_object_module_register_extension_type (module, - PEAS_TYPE_ACTIVATABLE, + INTROSPECTION_TYPE_ACTIVATABLE, TESTING_TYPE_LOADABLE_PLUGIN); } diff --git a/tests/plugins/loadable/meson.build b/tests/plugins/loadable/meson.build index 95b5a54..f6cd96f 100644 --- a/tests/plugins/loadable/meson.build +++ b/tests/plugins/loadable/meson.build @@ -16,7 +16,7 @@ libloadable_plugin_deps = [ glib_dep, gobject_dep, libpeas_dep, - libtesting_util_dep, + libintrospection_dep, ] libloadable_lib = shared_library( diff --git a/tests/plugins/self-dep/meson.build b/tests/plugins/self-dep/meson.build index ade0879..4db0038 100644 --- a/tests/plugins/self-dep/meson.build +++ b/tests/plugins/self-dep/meson.build @@ -16,7 +16,7 @@ libself_dep_plugin_deps = [ glib_dep, gobject_dep, libpeas_dep, - libtesting_util_dep, + libintrospection_dep, ] libself_dep_lib = shared_library( diff --git a/tests/plugins/self-dep/self-dep-plugin.c b/tests/plugins/self-dep/self-dep-plugin.c index 45d5f4d..8ee10f8 100644 --- a/tests/plugins/self-dep/self-dep-plugin.c +++ b/tests/plugins/self-dep/self-dep-plugin.c @@ -29,7 +29,7 @@ #include -#include "peas-activatable.h" +#include "introspection-activatable.h" #include "self-dep-plugin.h" @@ -37,15 +37,15 @@ typedef struct { GObject *object; } TestingSelfDepPluginPrivate; -static void peas_activatable_iface_init (PeasActivatableInterface *iface); +static void introspection_activatable_iface_init (IntrospectionActivatableInterface *iface); G_DEFINE_DYNAMIC_TYPE_EXTENDED (TestingSelfDepPlugin, testing_self_dep_plugin, PEAS_TYPE_EXTENSION_BASE, 0, G_ADD_PRIVATE_DYNAMIC (TestingSelfDepPlugin) - G_IMPLEMENT_INTERFACE_DYNAMIC (PEAS_TYPE_ACTIVATABLE, - peas_activatable_iface_init)) + G_IMPLEMENT_INTERFACE_DYNAMIC (INTROSPECTION_TYPE_ACTIVATABLE, + introspection_activatable_iface_init)) #define GET_PRIV(o) \ (testing_self_dep_plugin_get_instance_private (o)) @@ -103,12 +103,12 @@ testing_self_dep_plugin_init (TestingSelfDepPlugin *plugin) } static void -testing_self_dep_plugin_activate (PeasActivatable *activatable) +testing_self_dep_plugin_activate (IntrospectionActivatable *activatable) { } static void -testing_self_dep_plugin_deactivate (PeasActivatable *activatable) +testing_self_dep_plugin_deactivate (IntrospectionActivatable *activatable) { } @@ -124,7 +124,7 @@ testing_self_dep_plugin_class_init (TestingSelfDepPluginClass *klass) } static void -peas_activatable_iface_init (PeasActivatableInterface *iface) +introspection_activatable_iface_init (IntrospectionActivatableInterface *iface) { iface->activate = testing_self_dep_plugin_activate; iface->deactivate = testing_self_dep_plugin_deactivate; @@ -141,6 +141,6 @@ peas_register_types (PeasObjectModule *module) testing_self_dep_plugin_register_type (G_TYPE_MODULE (module)); peas_object_module_register_extension_type (module, - PEAS_TYPE_ACTIVATABLE, + INTROSPECTION_TYPE_ACTIVATABLE, TESTING_TYPE_SELF_DEP_PLUGIN); } diff --git a/tests/testing-util/meson.build b/tests/testing-util/meson.build index 521337d..62f0397 100644 --- a/tests/testing-util/meson.build +++ b/tests/testing-util/meson.build @@ -3,12 +3,10 @@ libtesting_util_string = '@0@-@1@'.format(libtesting_util_name, api_version) libtesting_util_public_h = [ 'testing-util.h', - 'peas-activatable.h', ] libtesting_util_c = [ 'testing-util.c', - 'peas-activatable.c', ] libtesting_util_deps = [ diff --git a/tests/testing-util/peas-activatable.c b/tests/testing-util/peas-activatable.c deleted file mode 100644 index 2d1c935..0000000 --- a/tests/testing-util/peas-activatable.c +++ /dev/null @@ -1,135 +0,0 @@ -/* - * peas-activatable.c - * This file is part of libpeas - * - * Copyright (C) 2010 Steve Frécinaux - * - * libpeas is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * libpeas 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * SPDX-License-Identifier: LGPL-2.1-or-later - */ - -#include "config.h" - -#include "peas-activatable.h" - -/** - * PeasActivatable: - * - * Interface for activatable plugins. - * - * #PeasActivatable is an interface which should be implemented by plugins - * that should be activated on an object of a certain type (depending on the - * application). For instance, in a typical windowed application, - * #PeasActivatable plugin instances could be bound to individual toplevel - * windows. - * - * It is typical to use #PeasActivatable along with [class@ExtensionSet] in order - * to activate and deactivate extensions automatically when plugins are loaded - * or unloaded. - * - * You can also use the code of this interface as a base for your own - * extension types, as illustrated by gedit's %GeditWindowActivatable and - * %GeditDocumentActivatable interfaces. - **/ - -G_DEFINE_INTERFACE(PeasActivatable, peas_activatable, G_TYPE_OBJECT) - -static void -peas_activatable_default_init (PeasActivatableInterface *iface) -{ - /** - * PeasActivatable:object: - * - * The object property contains the targetted object for this #PeasActivatable - * instance. - * - * For example a toplevel window in a typical windowed application. It is set - * at construction time and won't change. - */ - g_object_interface_install_property (iface, - g_param_spec_object ("object", - "Object", - "Object", - G_TYPE_OBJECT, - G_PARAM_READWRITE | - G_PARAM_CONSTRUCT_ONLY | - G_PARAM_STATIC_STRINGS)); -} - -/** - * peas_activatable_activate: - * @activatable: A #PeasActivatable. - * - * Activates the extension on the targetted object. - * - * On activation, the extension should hook itself to the object - * where it makes sense. - */ -void -peas_activatable_activate (PeasActivatable *activatable) -{ - PeasActivatableInterface *iface; - - g_return_if_fail (PEAS_IS_ACTIVATABLE (activatable)); - - iface = PEAS_ACTIVATABLE_GET_IFACE (activatable); - g_return_if_fail (iface->activate != NULL); - - iface->activate (activatable); -} - -/** - * peas_activatable_deactivate: - * @activatable: A #PeasActivatable. - * - * Deactivates the extension on the targetted object. - * - * On deactivation, an extension should remove itself from all the hooks it - * used and should perform any cleanup required, so it can be unreffed safely - * and without any more effect on the host application. - */ -void -peas_activatable_deactivate (PeasActivatable *activatable) -{ - PeasActivatableInterface *iface; - - g_return_if_fail (PEAS_IS_ACTIVATABLE (activatable)); - - iface = PEAS_ACTIVATABLE_GET_IFACE (activatable); - g_return_if_fail (iface->deactivate != NULL); - - iface->deactivate (activatable); -} - -/** - * peas_activatable_update_state: - * @activatable: A #PeasActivatable. - * - * Triggers an update of the extension internal state to take into account - * state changes in the targetted object, due to some event or user action. - */ -void -peas_activatable_update_state (PeasActivatable *activatable) -{ - PeasActivatableInterface *iface; - - g_return_if_fail (PEAS_IS_ACTIVATABLE (activatable)); - - iface = PEAS_ACTIVATABLE_GET_IFACE (activatable); - if (iface->update_state != NULL) - iface->update_state (activatable); -} - diff --git a/tests/testing-util/peas-activatable.h b/tests/testing-util/peas-activatable.h deleted file mode 100644 index 157f567..0000000 --- a/tests/testing-util/peas-activatable.h +++ /dev/null @@ -1,74 +0,0 @@ -/* - * peas-activatable.h - * This file is part of libpeas - * - * Copyright (C) 2010 - Steve Frécinaux - * - * libpeas is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * libpeas 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * SPDX-License-Identifier: LGPL-2.1-or-later - */ - -#pragma once - -#include - -G_BEGIN_DECLS - -/* - * Type checking and casting macros - */ -#define PEAS_TYPE_ACTIVATABLE (peas_activatable_get_type ()) -#define PEAS_ACTIVATABLE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), PEAS_TYPE_ACTIVATABLE, PeasActivatable)) -#define PEAS_ACTIVATABLE_IFACE(obj) (G_TYPE_CHECK_CLASS_CAST ((obj), PEAS_TYPE_ACTIVATABLE, PeasActivatableInterface)) -#define PEAS_IS_ACTIVATABLE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PEAS_TYPE_ACTIVATABLE)) -#define PEAS_ACTIVATABLE_GET_IFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), PEAS_TYPE_ACTIVATABLE, PeasActivatableInterface)) - -/** - * PeasActivatable: - * - * Interface for activatable plugins. - */ -typedef struct _PeasActivatable PeasActivatable; /* dummy typedef */ -typedef struct _PeasActivatableInterface PeasActivatableInterface; - -/** - * PeasActivatableInterface: - * @g_iface: The parent interface. - * @activate: Activates the plugin. - * @deactivate: Deactivates the plugin. - * @update_state: Updates the plugin's internal state to take account of - * a change in the target object's state. - * - * Provides an interface for activatable plugins. - */ -struct _PeasActivatableInterface { - GTypeInterface g_iface; - - /* Virtual public methods */ - void (*activate) (PeasActivatable *activatable); - void (*deactivate) (PeasActivatable *activatable); - void (*update_state) (PeasActivatable *activatable); -}; - -/* - * Public methods - */ -GType peas_activatable_get_type (void) G_GNUC_CONST; -void peas_activatable_activate (PeasActivatable *activatable); -void peas_activatable_deactivate (PeasActivatable *activatable); -void peas_activatable_update_state (PeasActivatable *activatable); - -G_END_DECLS -- cgit v1.2.1