Allow running without WebKitGTK installed

Resolves: RHEL-26698
This commit is contained in:
Michael Catanzaro 2024-03-06 14:54:53 -06:00
parent 701bc1d8ab
commit 916590e6c6
2 changed files with 77 additions and 1 deletions

69
optional-webkitgtk.patch Normal file
View File

@ -0,0 +1,69 @@
diff --git a/meson.build b/meson.build
index be1ccd4..116f145 100644
--- a/meson.build
+++ b/meson.build
@@ -21,7 +21,7 @@ gtk_x11_dep = dependency('gtk+-x11-3.0', required: get_option('X11'))
gtk_wayland_dep = dependency('gtk+-wayland-3.0', version: '>= 3.21.5', required: get_option('wayland'))
gtksourceview_dep = dependency('gtksourceview-4', version: '>=4.0.3')
harfbuzz_dep = dependency('harfbuzz', version: '>=0.9.9')
-webkit_dep = dependency('webkit2gtk-4.0')
+webkit_dep = dependency('webkit2gtk-4.0', required: false)
bindir = join_paths(get_option('prefix'), get_option('bindir'))
datadir = join_paths(get_option('prefix'), get_option('datadir'))
diff --git a/src/ui/main.js b/src/ui/main.js
index b0cb7de..2aa0b71 100644
--- a/src/ui/main.js
+++ b/src/ui/main.js
@@ -39,7 +39,6 @@ pkg.require({
Pango: '1.0',
Soup: '2.4',
Sushi: '1.0',
- WebKit2: '4.0',
});
const {Gio, GLib} = imports.gi;
diff --git a/src/viewers/html.js b/src/viewers/html.js
index 3de4455..28d34de 100644
--- a/src/viewers/html.js
+++ b/src/viewers/html.js
@@ -23,11 +23,22 @@
*
*/
-const {Gtk, GLib, GObject, Sushi, WebKit2} = imports.gi;
+const {Gtk, GLib, GObject, Sushi} = imports.gi;
+
+var WebKit2;
+try {
+ imports.gi.versions.WebKit2 = '4.0';
+ WebKit2 = imports.gi.WebKit2;
+} catch(e) {
+}
+
+function _isAvailable() {
+ return WebKit2 !== undefined;
+}
const Renderer = imports.ui.renderer;
-var Klass = GObject.registerClass({
+var Klass = _isAvailable() ? GObject.registerClass({
Implements: [Renderer.Renderer],
Properties: {
fullscreen: GObject.ParamSpec.boolean('fullscreen', '', '',
@@ -63,8 +74,10 @@ var Klass = GObject.registerClass({
get moveOnClick() {
return false;
}
-});
+}) : undefined;
-var mimeTypes = [
- 'text/html'
-];
+var mimeTypes = [];
+if (_isAvailable())
+ mimeTypes = [
+ 'text/html'
+ ];

View File

@ -2,7 +2,7 @@
Name: sushi Name: sushi
Version: 3.38.1 Version: 3.38.1
Release: 2%{?dist} Release: 3%{?dist}
Summary: A quick previewer for Nautilus Summary: A quick previewer for Nautilus
License: GPLv2+ with exceptions License: GPLv2+ with exceptions
@ -14,6 +14,9 @@ Patch0: drop-libmusicbrainz-dep.patch
# https://gitlab.gnome.org/GNOME/sushi/-/merge_requests/30 # https://gitlab.gnome.org/GNOME/sushi/-/merge_requests/30
Patch1: enable-sandbox.patch Patch1: enable-sandbox.patch
# https://gitlab.gnome.org/GNOME/sushi/-/merge_requests/53
Patch2: optional-webkitgtk.patch
BuildRequires: gettext BuildRequires: gettext
BuildRequires: gjs-devel BuildRequires: gjs-devel
BuildRequires: meson BuildRequires: meson
@ -57,6 +60,10 @@ file manager.
%changelog %changelog
* Wed Mar 06 2024 Michael Catanzaro <mcatanzaro@redhat.com> - 3.38.1-3
- Allow running without WebKitGTK installed
Resolves: RHEL-26698
* Mon May 23 2022 Michael Catanzaro <mcatanzaro@redhat.com> - 3.38.1-2 * Mon May 23 2022 Michael Catanzaro <mcatanzaro@redhat.com> - 3.38.1-2
- Enable web process sandbox - Enable web process sandbox
Resolves: #2070670 Resolves: #2070670