From b503b4a5b500a8af20a3844ab308b7a49e681b75 Mon Sep 17 00:00:00 2001 From: Johannes Sasongko Date: Tue, 25 Mar 2025 14:50:14 +1100 Subject: [PATCH] plugins: Support GIRepository-3.0 GLib 2.84 integrates GIRepository (as `-3.0`). Rather than checking the GLib version for the right GIRepository version to `require_version`, this commit simply uses a try-except. This also moves the `require_version` call from main.py to plugins.py, where the GIRepository import actually is. Fixes: https://github.com/exaile/exaile/issues/962 --- xl/main.py | 1 - xl/plugins.py | 7 +++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/xl/main.py b/xl/main.py index 197bcd85e..63e633939 100644 --- a/xl/main.py +++ b/xl/main.py @@ -54,7 +54,6 @@ def _do_heavy_imports(): gi.require_version('Gdk', '3.0') gi.require_version('Gtk', '3.0') gi.require_version('Gst', '1.0') - gi.require_version('GIRepository', '2.0') gi.require_version('GstPbutils', '1.0') from gi.repository import GLib, Gio, Gtk diff --git a/xl/plugins.py b/xl/plugins.py index 07efcc133..94b57accc 100644 --- a/xl/plugins.py +++ b/xl/plugins.py @@ -259,6 +259,13 @@ def is_potentially_broken(self, info): :param info: The data returned from get_plugin_info() """ import pkgutil + import gi + + # https://github.com/exaile/exaile/issues/962 + try: + gi.require_version('GIRepository', '3.0') + except ValueError: + gi.require_version('GIRepository', '2.0') from gi.repository import GIRepository gir = GIRepository.Repository.get_default()