From a9d7f2db6bc963805147f5eaba764b00ad996c79 Mon Sep 17 00:00:00 2001 From: Yaakov Selkowitz Date: Wed, 20 Dec 2023 13:13:46 -0500 Subject: [PATCH] Make webkitgtk dependency optional --- sushi.spec | 9 +++-- webkit-optional.patch | 84 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 91 insertions(+), 2 deletions(-) create mode 100644 webkit-optional.patch diff --git a/sushi.spec b/sushi.spec index b0d8f09..006e57a 100644 --- a/sushi.spec +++ b/sushi.spec @@ -5,12 +5,14 @@ Name: sushi Version: 45.0 -Release: 1%{?dist} +Release: 2%{?dist} Summary: A quick previewer for Nautilus License: GPLv2+ with exceptions URL: https://gitlab.gnome.org/GNOME/sushi Source0: https://download.gnome.org/sources/%{name}/%{url_ver}/%{name}-%{tarball_version}.tar.xz +# https://gitlab.gnome.org/GNOME/sushi/-/merge_requests/53 +Patch0: webkit-optional.patch BuildRequires: gettext BuildRequires: gjs-devel @@ -20,11 +22,11 @@ BuildRequires: pkgconfig(gobject-2.0) BuildRequires: pkgconfig(gstreamer-audio-1.0) BuildRequires: pkgconfig(gtk+-3.0) BuildRequires: pkgconfig(gtksourceview-4) -BuildRequires: pkgconfig(webkit2gtk-4.1) Obsoletes: sushi-devel < 0.5.1 Requires: gtksourceview4 +Recommends: webkit2gtk4.1 #Description from upstream's README. %description @@ -58,6 +60,9 @@ file manager. %changelog +* Wed Dec 20 2023 Yaakov Selkowitz - 45.0-2 +- Make webkitgtk dependency optional + * Wed Sep 20 2023 Kalev Lember - 45.0-1 - Update to 45.0 diff --git a/webkit-optional.patch b/webkit-optional.patch new file mode 100644 index 0000000..2475746 --- /dev/null +++ b/webkit-optional.patch @@ -0,0 +1,84 @@ +From 2d3fbd0eec2806b15533b04edf8620f4f5c389d4 Mon Sep 17 00:00:00 2001 +From: Yaakov Selkowitz +Date: Thu, 30 Nov 2023 18:26:51 -0500 +Subject: [PATCH] main: make WebKit2 optional + +webkitgtk is being removed from the core desktop dependencies, so it +should not be presumed available. +--- + meson.build | 1 - + src/ui/main.js | 1 - + src/viewers/html.js | 25 +++++++++++++++++++------ + 3 files changed, 19 insertions(+), 8 deletions(-) + +diff --git a/meson.build b/meson.build +index c7c4428..5994e21 100644 +--- a/meson.build ++++ b/meson.build +@@ -21,7 +21,6 @@ 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.1') + + 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 2dd6124..9f8638a 100644 +--- a/src/ui/main.js ++++ b/src/ui/main.js +@@ -39,7 +39,6 @@ pkg.require({ + Pango: '1.0', + Soup: '3.0', + Sushi: '1.0', +- WebKit2: '4.1', + }); + + const {Gio, GLib} = imports.gi; +diff --git a/src/viewers/html.js b/src/viewers/html.js +index 985d957..01bd59f 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.1'; ++ WebKit2 = imports.gi.WebKit2; ++} catch(e) { ++} ++ ++var isAvailable = function() { ++ 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', '', '', +@@ -67,8 +78,10 @@ var Klass = GObject.registerClass({ + get moveOnClick() { + return false; + } +-}); ++}) : undefined; + +-var mimeTypes = [ +- 'text/html' +-]; ++var mimeTypes = []; ++if (isAvailable()) ++ mimeTypes = [ ++ 'text/html' ++ ]; +-- +2.43.0 +