Subject: [bug#48909] [PATCH] gnu: Add goldendict.

From: Sergey Trofimov <[email-masked]>
Date: Mon, 28 Mar 2022 10:26:54 +0200

* gnu/packages/dictionaries.scm (goldendict): New variable.
---
 gnu/local.mk                                  |  1 +
 gnu/packages/dictionaries.scm                 | 53 +++++++++++++++++++
 .../goldendict-remove-check-for-update.patch  | 52 ++++++++++++++++++
 3 files changed, 106 insertions(+)
 create mode 100644 gnu/packages/patches/goldendict-remove-check-for-update.patch

diff --git a/gnu/local.mk b/gnu/local.mk
index 4f60046a5e..c1fe54d514 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -1204,6 +1204,7 @@ dist_patch_DATA =						\
   %D%/packages/patches/gobject-introspection-absolute-shlib-path.patch \
   %D%/packages/patches/gobject-introspection-cc.patch		\
   %D%/packages/patches/gobject-introspection-girepository.patch	\
+  %D%/packages/patches/goldendict-remove-check-for-update.patch	\
   %D%/packages/patches/go-fix-script-tests.patch			\
   %D%/packages/patches/go-github-com-golang-snappy-32bit-test.patch \
   %D%/packages/patches/go-github-com-urfave-cli-fix-tests.patch \
diff --git a/gnu/packages/dictionaries.scm b/gnu/packages/dictionaries.scm
index f9d6e57877..fd4172ebb6 100644
--- a/gnu/packages/dictionaries.scm
+++ b/gnu/packages/dictionaries.scm
@@ -38,6 +38,7 @@ (define-module (gnu packages dictionaries)
   #:use-module (gnu packages autotools)
   #:use-module (gnu packages base)
   #:use-module (gnu packages curl)
+  #:use-module (gnu packages education)
   #:use-module (gnu packages emacs)
   #:use-module (gnu packages flex)
   #:use-module (gnu packages fribidi)
@@ -52,6 +53,13 @@ (define-module (gnu packages dictionaries)
   #:use-module (gnu packages texinfo)
   #:use-module (gnu packages compression)
   #:use-module (gnu packages tcl)
+  #:use-module (gnu packages xiph)
+  #:use-module (gnu packages libreoffice)
+  #:use-module (gnu packages xorg)
+  #:use-module (gnu packages image)
+  #:use-module (gnu packages textutils)
+  #:use-module (gnu packages qt)
+  #:use-module (gnu packages video)
   #:use-module (gnu packages xml))

@@ -389,6 +397,51 @@ (define-public apertium
     (license (list license:gpl2 ; main license
                    license:expat)))) ; utf8/*
 
+(define-public goldendict
+  (let ((commit "8acb288c9e9bdb3c6bf2e803954dd3b6ac273c05")
+        (revision "0"))
+    (package
+      (name "goldendict")
+      (version (git-version "1.5.0-RC2" revision commit))
+      (source
+       (origin
+         (method git-fetch)
+         (uri (git-reference
+               (url "https://github.com/goldendict/goldendict")
+               (commit commit)))
+         (file-name (git-file-name name version))
+         (sha256
+          (base32 "0lhpmrsglqmwz9d6hr29ncm163hvdqqnxmw9frhgyrblw977wzni"))
+         (patches (search-patches "goldendict-remove-check-for-update.patch"))
+         (modules '((guix build utils)))
+         (snippet '(begin
+                     ;; Remove bundled libraries.
+                     (for-each delete-file-recursively
+                               '("winlibs" "maclibs"))))))
+      (build-system gnu-build-system)
+      (arguments
+       `(#:phases
+         (modify-phases %standard-phases
+           (replace 'configure
+             (lambda* (#:key inputs outputs #:allow-other-keys)
+               (invoke "qmake" "goldendict.pro"
+                       "CONFIG+=chinese_conversion_support"
+                       "QMAKE_LRELEASE=lrelease"
+                       (string-append "PREFIX="
+                                      (assoc-ref outputs "out"))))))))
+
+      (native-inputs (list pkg-config qttools))
+      (inputs (list ao bzip2 hunspell ffmpeg libeb libtiff libvorbis libxtst
+                    opencc qtx11extras qtbase-5 qtmultimedia qtsvg qtwebkit
+                    qtwebview lzo xorgproto zlib))
+      (synopsis "Feature-rich dictionary lookup program")
+      (description
+       "GoldenDict is a dictionary lookup program,
+supporting multiple dictionary formats (StarDict, Babylon, Lingvo, Dictd, AARD,
+MDict, SDict) and online dictionaries.")
+      (home-page "http://goldendict.org/")
+      (license license:gpl3+))))
+
 (define-public sdcv
   (package
     (name "sdcv")
diff --git a/gnu/packages/patches/goldendict-remove-check-for-update.patch b/gnu/packages/patches/goldendict-remove-check-for-update.patch
new file mode 100644
index 0000000000..84d9b1767e
--- /dev/null
+++ b/gnu/packages/patches/goldendict-remove-check-for-update.patch
@@ -0,0 +1,52 @@
+https://github.com/NixOS/nixpkgs/blob/217b221/pkgs/applications/misc/goldendict/0001-dont-check-for-updates.patch
+Disable calling home for updates.
+
+diff --git i/config.cc w/config.cc
+index 04b63f5..7a453d9 100644
+--- i/config.cc
++++ w/config.cc
+@@ -182,7 +182,7 @@ Preferences::Preferences():
+   pronounceOnLoadPopup( false ),
+   useInternalPlayer( InternalPlayerBackend::anyAvailable() ),
+   internalPlayerBackend( InternalPlayerBackend::defaultBackend() ),
+-  checkForNewReleases( true ),
++  checkForNewReleases( false ),
+   disallowContentFromOtherSites( false ),
+   enableWebPlugins( false ),
+   hideGoldenDictHeader( false ),
+@@ -867,8 +867,8 @@ Class load() THROW_SPEC( exError )
+       c.preferences.proxyServer.systemProxyPassword = proxy.namedItem( "systemProxyPassword" ).toElement().text();
+     }
+
+-    if ( !preferences.namedItem( "checkForNewReleases" ).isNull() )
+-      c.preferences.checkForNewReleases = ( preferences.namedItem( "checkForNewReleases" ).toElement().text() == "1" );
++    //if ( !preferences.namedItem( "checkForNewReleases" ).isNull() )
++    //  c.preferences.checkForNewReleases = ( preferences.namedItem( "checkForNewReleases" ).toElement().text() == "1" );
+
+     if ( !preferences.namedItem( "disallowContentFromOtherSites" ).isNull() )
+       c.preferences.disallowContentFromOtherSites = ( preferences.namedItem( "disallowContentFromOtherSites" ).toElement().text() == "1" );
+@@ -1819,9 +1819,9 @@ void save( Class const & c ) THROW_SPEC( exError )
+       proxy.appendChild( opt );
+     }
+
+-    opt = dd.createElement( "checkForNewReleases" );
+-    opt.appendChild( dd.createTextNode( c.preferences.checkForNewReleases ? "1" : "0" ) );
+-    preferences.appendChild( opt );
++    //opt = dd.createElement( "checkForNewReleases" );
++    //opt.appendChild( dd.createTextNode( c.preferences.checkForNewReleases ? "1" : "0" ) );
++    //preferences.appendChild( opt );
+
+     opt = dd.createElement( "disallowContentFromOtherSites" );
+     opt.appendChild( dd.createTextNode( c.preferences.disallowContentFromOtherSites ? "1" : "0" ) );
+diff --git i/preferences.cc w/preferences.cc
+index 72c3147..7e48f00 100644
+--- i/preferences.cc
++++ w/preferences.cc
+@@ -314,6 +314,7 @@ Preferences::Preferences( QWidget * parent, Config::Class & cfg_ ):
+            this, SLOT( customProxyToggled( bool ) ) );
+
+   ui.checkForNewReleases->setChecked( p.checkForNewReleases );
++  ui.checkForNewReleases->setEnabled( false );
+   ui.disallowContentFromOtherSites->setChecked( p.disallowContentFromOtherSites );
+   ui.enableWebPlugins->setChecked( p.enableWebPlugins );
+   ui.hideGoldenDictHeader->setChecked( p.hideGoldenDictHeader );
-- 
2.34.0