summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorChristian Hergert <chergert@redhat.com>2023-03-16 16:05:24 -0700
committerChristian Hergert <chergert@redhat.com>2023-03-22 16:44:35 -0700
commita0a2fd1b5bea9fc2bc19d1e17ce806806766c288 (patch)
tree847be4586567a5e04092d3eddf458784100d039a /tests
parent37b9fae8ab0f31f64761762cb1693807add68613 (diff)
downloadlibpeas-a0a2fd1b5bea9fc2bc19d1e17ce806806766c288.tar.gz
libpeas: remove PeasActivatable
We still use this for tests, but it can live within the testing-util library rather than in libpeas-2 directly. This is part of the effort to shrink down further what is in the public ABI.
Diffstat (limited to 'tests')
-rw-r--r--tests/libpeas/extension-c.c1
-rw-r--r--tests/libpeas/extension-set.c4
-rw-r--r--tests/libpeas/plugins/embedded/embedded-plugin.c2
-rw-r--r--tests/libpeas/plugins/embedded/meson.build1
-rw-r--r--tests/libpeas/testing/testing-extension.c2
-rw-r--r--tests/plugins/builtin/builtin-plugin.c2
-rw-r--r--tests/plugins/builtin/meson.build1
-rw-r--r--tests/plugins/has-dep/has-dep-plugin.c2
-rw-r--r--tests/plugins/has-dep/meson.build1
-rw-r--r--tests/plugins/loadable/loadable-plugin.c2
-rw-r--r--tests/plugins/loadable/meson.build1
-rw-r--r--tests/plugins/self-dep/meson.build3
-rw-r--r--tests/plugins/self-dep/self-dep-plugin.c2
-rw-r--r--tests/testing-util/meson.build2
-rw-r--r--tests/testing-util/peas-activatable.c133
-rw-r--r--tests/testing-util/peas-activatable.h75
16 files changed, 232 insertions, 2 deletions
diff --git a/tests/libpeas/extension-c.c b/tests/libpeas/extension-c.c
index 4b6834c..6693629 100644
--- a/tests/libpeas/extension-c.c
+++ b/tests/libpeas/extension-c.c
@@ -31,6 +31,7 @@
#include "plugins/embedded/embedded-plugin.h"
#include "plugins/embedded/embedded-resources.h"
+#include "peas-activatable.h"
static void
test_extension_c_embedded (PeasEngine *engine)
diff --git a/tests/libpeas/extension-set.c b/tests/libpeas/extension-set.c
index 3264651..2f5d588 100644
--- a/tests/libpeas/extension-set.c
+++ b/tests/libpeas/extension-set.c
@@ -29,6 +29,8 @@
#include <glib-object.h>
#include <libpeas/peas.h>
+#include "peas-activatable.h"
+
#include "testing/testing.h"
typedef struct _TestFixture TestFixture;
@@ -282,7 +284,7 @@ test_extension_set_extension_added (PeasEngine *engine)
* be synced with the number of added extensions
*/
extension_set = testing_extension_set_new (engine, &active);
-
+
g_object_unref (extension_set);
/* Verify that freeing the extension
diff --git a/tests/libpeas/plugins/embedded/embedded-plugin.c b/tests/libpeas/plugins/embedded/embedded-plugin.c
index 945d6f4..7dcdd95 100644
--- a/tests/libpeas/plugins/embedded/embedded-plugin.c
+++ b/tests/libpeas/plugins/embedded/embedded-plugin.c
@@ -29,6 +29,8 @@
#include "embedded-plugin.h"
+#include "peas-activatable.h"
+
typedef struct {
GObject *object;
} TestingEmbeddedPluginPrivate;
diff --git a/tests/libpeas/plugins/embedded/meson.build b/tests/libpeas/plugins/embedded/meson.build
index 675eccd..bd8b81b 100644
--- a/tests/libpeas/plugins/embedded/meson.build
+++ b/tests/libpeas/plugins/embedded/meson.build
@@ -33,6 +33,7 @@ libembedded_res = gnome.compile_resources(
libembedded_deps = [
glib_dep,
libpeas_dep,
+ libtesting_util_dep,
]
libembedded_lib = shared_library(
diff --git a/tests/libpeas/testing/testing-extension.c b/tests/libpeas/testing/testing-extension.c
index 122c274..29534af 100644
--- a/tests/libpeas/testing/testing-extension.c
+++ b/tests/libpeas/testing/testing-extension.c
@@ -39,6 +39,8 @@
#include "introspection-has-prerequisite.h"
#include "introspection-unimplemented.h"
+#include "peas-activatable.h"
+
typedef struct _TestFixture TestFixture;
struct _TestFixture {
diff --git a/tests/plugins/builtin/builtin-plugin.c b/tests/plugins/builtin/builtin-plugin.c
index 71ebc7d..b2fe598 100644
--- a/tests/plugins/builtin/builtin-plugin.c
+++ b/tests/plugins/builtin/builtin-plugin.c
@@ -29,6 +29,8 @@
#include <libpeas/peas.h>
+#include "peas-activatable.h"
+
#include "builtin-plugin.h"
typedef struct {
diff --git a/tests/plugins/builtin/meson.build b/tests/plugins/builtin/meson.build
index 1603c30..578ec82 100644
--- a/tests/plugins/builtin/meson.build
+++ b/tests/plugins/builtin/meson.build
@@ -16,6 +16,7 @@ libbuiltin_plugin_deps = [
glib_dep,
gobject_dep,
libpeas_dep,
+ libtesting_util_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 c1a6031..3ddcb04 100644
--- a/tests/plugins/has-dep/has-dep-plugin.c
+++ b/tests/plugins/has-dep/has-dep-plugin.c
@@ -29,6 +29,8 @@
#include <libpeas/peas.h>
+#include "peas-activatable.h"
+
#include "has-dep-plugin.h"
typedef struct {
diff --git a/tests/plugins/has-dep/meson.build b/tests/plugins/has-dep/meson.build
index 21a4da7..66cb099 100644
--- a/tests/plugins/has-dep/meson.build
+++ b/tests/plugins/has-dep/meson.build
@@ -17,6 +17,7 @@ libhas_dep_plugin_deps = [
gobject_dep,
gmodule_dep,
libpeas_dep,
+ libtesting_util_dep,
]
libhas_dep_lib = shared_library(
diff --git a/tests/plugins/loadable/loadable-plugin.c b/tests/plugins/loadable/loadable-plugin.c
index 95c92c2..d05cd7c 100644
--- a/tests/plugins/loadable/loadable-plugin.c
+++ b/tests/plugins/loadable/loadable-plugin.c
@@ -29,6 +29,8 @@
#include <libpeas/peas.h>
+#include "peas-activatable.h"
+
#include "loadable-plugin.h"
typedef struct {
diff --git a/tests/plugins/loadable/meson.build b/tests/plugins/loadable/meson.build
index 76ee40b..95b5a54 100644
--- a/tests/plugins/loadable/meson.build
+++ b/tests/plugins/loadable/meson.build
@@ -16,6 +16,7 @@ libloadable_plugin_deps = [
glib_dep,
gobject_dep,
libpeas_dep,
+ libtesting_util_dep,
]
libloadable_lib = shared_library(
diff --git a/tests/plugins/self-dep/meson.build b/tests/plugins/self-dep/meson.build
index f44ee2c..ade0879 100644
--- a/tests/plugins/self-dep/meson.build
+++ b/tests/plugins/self-dep/meson.build
@@ -16,6 +16,7 @@ libself_dep_plugin_deps = [
glib_dep,
gobject_dep,
libpeas_dep,
+ libtesting_util_dep,
]
libself_dep_lib = shared_library(
@@ -31,4 +32,4 @@ custom_target(
output: libself_dep_plugin_data,
command: [copyfile_script, '@INPUT@', '@OUTDIR@'],
build_by_default: true,
-) \ No newline at end of file
+)
diff --git a/tests/plugins/self-dep/self-dep-plugin.c b/tests/plugins/self-dep/self-dep-plugin.c
index 02adb42..0b0113c 100644
--- a/tests/plugins/self-dep/self-dep-plugin.c
+++ b/tests/plugins/self-dep/self-dep-plugin.c
@@ -29,6 +29,8 @@
#include <libpeas/peas.h>
+#include "peas-activatable.h"
+
#include "self-dep-plugin.h"
typedef struct {
diff --git a/tests/testing-util/meson.build b/tests/testing-util/meson.build
index 1c40740..34fd221 100644
--- a/tests/testing-util/meson.build
+++ b/tests/testing-util/meson.build
@@ -3,10 +3,12 @@ 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
new file mode 100644
index 0000000..7714d1d
--- /dev/null
+++ b/tests/testing-util/peas-activatable.c
@@ -0,0 +1,133 @@
+/*
+ * 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.
+ */
+
+#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
new file mode 100644
index 0000000..8148de6
--- /dev/null
+++ b/tests/testing-util/peas-activatable.h
@@ -0,0 +1,75 @@
+/*
+ * 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.
+ */
+
+#ifndef __PEAS_ACTIVATABLE_H__
+#define __PEAS_ACTIVATABLE_H__
+
+#include <glib-object.h>
+
+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
+
+#endif /* __PEAS_ACTIVATABLE_H__ */