sushi/optional-webkitgtk.patch
2024-04-17 09:34:48 -05:00

68 lines
1.7 KiB
Diff

diff --git a/configure.ac b/configure.ac
index 98ce0c2..9d69588 100644
--- a/configure.ac
+++ b/configure.ac
@@ -71,8 +71,7 @@ PKG_CHECK_MODULES(SUSHI,
libmusicbrainz5
evince-document-3.0
evince-view-3.0
- gtksourceview-3.0
- webkit2gtk-4.0)
+ gtksourceview-3.0)
GLIB_COMPILE_RESOURCES=`$PKG_CONFIG --variable glib_compile_resources gio-2.0`
AC_SUBST(GLIB_COMPILE_RESOURCES)
diff --git a/src/js/viewers/html.js b/src/js/viewers/html.js
index 5135e2b..c7d078f 100644
--- a/src/js/viewers/html.js
+++ b/src/js/viewers/html.js
@@ -28,12 +28,22 @@ const Gtk = imports.gi.Gtk;
const GLib = imports.gi.GLib;
const Lang = imports.lang;
const Sushi = imports.gi.Sushi;
-const WebKit = imports.gi.WebKit2;
const MimeHandler = imports.ui.mimeHandler;
const Utils = imports.ui.utils;
-const HTMLRenderer = new Lang.Class({
+var WebKit;
+try {
+ imports.gi.versions.WebKit2 = '4.0';
+ WebKit = imports.gi.WebKit2;
+} catch(e) {
+}
+
+function _isAvailable() {
+ return WebKit !== undefined;
+}
+
+var HTMLRenderer = _isAvailable() ? new Lang.Class({
Name: 'HTMLRenderer',
_init : function(args) {
@@ -89,13 +99,15 @@ const HTMLRenderer = new Lang.Class({
return this._toolbarActor;
}
-});
+}) : undefined;
-let handler = new MimeHandler.MimeHandler();
-let renderer = new HTMLRenderer();
+if (_isAvailable()) {
+ let handler = new MimeHandler.MimeHandler();
+ let renderer = new HTMLRenderer();
-let mimeTypes = [
- 'text/html'
-];
+ let mimeTypes = [
+ 'text/html'
+ ];
-handler.registerMimeTypes(mimeTypes, renderer);
+ handler.registerMimeTypes(mimeTypes, renderer);
+}