void-packages/srcpkgs/ulauncher/patches/libwebkit2gtk41.patch

58 lines
2.6 KiB
Diff

From 08b52d22df8054fd6b8cd8e61dec72d8ab6dc846 Mon Sep 17 00:00:00 2001
From: Albin Larsson <mail@fridaythe14th.com>
Date: Sat, 27 Apr 2024 14:13:36 +0200
Subject: [PATCH] fix: support gir1.2-webkit2-4.1 for ubuntu 24.04
---
debian/control | 2 +-
.../ui/windows/PreferencesUlauncherDialog.py | 4 ++--
ulauncher/utils/WebKit2.py | 15 +++++++++++++++
3 files changed, 18 insertions(+), 3 deletions(-)
create mode 100644 ulauncher/utils/WebKit2.py
diff --git a/ulauncher/ui/windows/PreferencesUlauncherDialog.py b/ulauncher/ui/windows/PreferencesUlauncherDialog.py
index 2fe19efaa..e4e304192 100644
--- a/ulauncher/ui/windows/PreferencesUlauncherDialog.py
+++ b/ulauncher/ui/windows/PreferencesUlauncherDialog.py
@@ -12,10 +12,9 @@
gi.require_version('Gio', '2.0')
gi.require_version('GLib', '2.0')
gi.require_version('Gtk', '3.0')
-gi.require_version('WebKit2', '4.0')
# pylint: disable=wrong-import-position,unused-argument
-from gi.repository import Gio, Gtk, WebKit2, GLib # type: ignore
+from gi.repository import Gio, Gtk, GLib # type: ignore
from ulauncher.api.shared.action.OpenAction import OpenAction
from ulauncher.ui.windows.HotkeyDialog import HotkeyDialog
@@ -39,6 +38,7 @@
from ulauncher.utils.Settings import Settings
from ulauncher.utils.Router import Router, get_url_params
from ulauncher.utils.AutostartPreference import AutostartPreference
+from ulauncher.utils.WebKit2 import WebKit2
from ulauncher.ui.AppIndicator import AppIndicator
from ulauncher.search.shortcuts.ShortcutsDb import ShortcutsDb
from ulauncher.config import get_data_file, get_options, get_version, EXTENSIONS_DIR
diff --git a/ulauncher/utils/WebKit2.py b/ulauncher/utils/WebKit2.py
new file mode 100644
index 000000000..70589eb63
--- /dev/null
+++ b/ulauncher/utils/WebKit2.py
@@ -0,0 +1,15 @@
+import gi
+
+# The package version refers to the "build environment". Not the actual Webkit version
+# 4.0 means it was built with GTK 3 and libsoup 2
+# 4.1 means it was built with GTK 3 and libsoup 3 (HTTP/2)
+# 5.0 means it was built with GTK 4 and libsoup 3 (incompatible w Ulauncher, and was only supported for a short period)
+# 6.0 means the same as 5.0, but the API has major changes, and the package name was renamed, dropping the "2"
+# https://blog.tingping.se/2021/06/07/http2-in-libsoup.html
+# https://discourse.gnome.org/t/please-build-against-libsoup-3-by-default/10190
+# https://bugs.webkit.org/show_bug.cgi?id=245296
+try:
+ gi.require_version('WebKit2', '4.1')
+except ValueError:
+ gi.require_version('WebKit2', '4.0')
+from gi.repository import WebKit2 # type: ignore[attr-defined] # noqa: F401