Port plugins from libpeas-1 to libpeas-2

The newer version of libpeas was released a couple of years ago already,
and at this point should probably be consdered the only maintained
version.

The changes are pretty minimal, and most should be pretty obvious from
the libpeas migration guide. The only annoying thing is that we can't
use `Peas.Engine.create_extension()` directly, since it's not exposed to
language bindings (even to Vala, which supports varargs, but alas).

Link: https://gnome.pages.gitlab.gnome.org/libpeas/libpeas-2/migrating-1to2.html

Fixes: https://gitlab.gnome.org/GNOME/geary/-/issues/1690
This commit is contained in:
Niels De Graef 2025-12-12 00:34:02 +01:00
parent f2d5f8b249
commit 0dad64a81d
4 changed files with 24 additions and 9 deletions

View file

@ -74,7 +74,7 @@ build.container.fedora@x86_64:
libgee-devel
libhandy1-devel
libicu-devel
libpeas1-devel
libpeas-devel
libsecret-devel
libstemmer-devel
libunwind-devel
@ -94,7 +94,7 @@ build.container.fedora@x86_64:
# release branch name to ensure that a new image will
# be created, tailored for the stable branch.
BRANCH_NAME: 'main'
CONTAINER_TAG: '2025-11-23.0'
CONTAINER_TAG: '2025-12-11.0'
FEDORA_VERSION: latest
# Derive FDO variables from this automatically.
# DO NOT edit, instead change the variables above

View file

@ -87,7 +87,7 @@ javascriptcoregtk = dependency('javascriptcoregtk-4.1', version: '>=' + target_w
json_glib = dependency('json-glib-1.0', version: '>= 1.0')
libhandy = dependency('libhandy-1', version: '>= 1.6', required: false)
libmath = cc.find_library('m')
libpeas = dependency('libpeas-1.0', version: '>= 1.24.0')
libpeas = dependency('libpeas-2')
libsecret = dependency('libsecret-1', version: '>= 0.11')
libsoup = dependency('libsoup-3.0')
libstemmer_dep = cc.find_library('stemmer')

View file

@ -218,11 +218,19 @@
{
"name": "libpeas",
"buildsystem": "meson",
"config-opts": [
"-Dgtk_doc=false",
"-Dintrospection=true",
"-Dvapi=true",
"-Dlua51=false",
"-Dgjs=false",
"-Dpython3=false"
],
"sources": [
{
"type": "git",
"url": "https://gitlab.gnome.org/GNOME/libpeas.git",
"commit": "7f245fa5158204621c3469756a951b68a651c4fe"
"url": "https://gitlab.gnome.org/GNOME/libpeas",
"branch": "main"
}
]
},

View file

@ -89,10 +89,13 @@ public class Application.PluginManager : GLib.Object {
Client application,
PluginGlobals globals) throws GLib.Error {
var app_impl = new ApplicationImpl(application, this, globals);
var instance = engine.create_extension(
var app_impl_val = GLib.Value(typeof(ApplicationImpl));
app_impl_val.set_object(app_impl);
var instance = engine.create_extension_with_properties(
info,
typeof(Plugin.PluginBase),
"plugin_application", app_impl
{ "plugin_application" },
{ app_impl_val }
) as Plugin.PluginBase;
if (instance == null) {
throw new Plugin.Error.NOT_SUPPORTED(
@ -594,7 +597,9 @@ public class Application.PluginManager : GLib.Object {
controller.composer_deregistered.connect(this.on_composer_deregistered);
string[] optional_names = this.config.get_optional_plugins();
foreach (Peas.PluginInfo info in this.plugin_engine.get_plugin_list()) {
for (uint i = 0; i < this.plugin_engine.get_n_items(); i++) {
var info = (Peas.PluginInfo) this.plugin_engine.get_item(i);
string name = info.get_module_name();
try {
if (info.is_available()) {
@ -638,7 +643,9 @@ public class Application.PluginManager : GLib.Object {
public Gee.Collection<Peas.PluginInfo> get_optional_plugins() {
var plugins = new Gee.LinkedList<Peas.PluginInfo>();
foreach (Peas.PluginInfo plugin in this.plugin_engine.get_plugin_list()) {
for (uint i = 0; i < this.plugin_engine.get_n_items(); i++) {
var plugin = (Peas.PluginInfo) this.plugin_engine.get_item(i);
try {
plugin.is_available();
if (!is_autoload(plugin)) {