Hi Liliana and all.  Until now the user could decide what image loaders
to install alongside.  Or so I thought.  However, surprisingly I cannot
get any other loader except gdk-pixbuf and librsvg to work anyway.

That is,

guix shell viewnior webp-pixbuf-loader

surprisingly does not see webp files.  I do not understand.

If this changed patch looks fine, now with proper gexp use, I will push
it.  The patch continues to include gdk-pixbuf among the inputs even
though gtk+@2 propagates gdk-pixbuf anyway, but better be explicit.

Regards,
Florian
>From 6acc7322695a13c326918c4b83a999e324406b21 Mon Sep 17 00:00:00 2001
Message-Id: <6acc7322695a13c326918c4b83a999e324406b21.1684001649.git.pelzflor...@pelzflorian.de>
From: Florian Pelz <pelzflor...@pelzflorian.de>
Date: Sat, 13 May 2023 12:33:26 +0200
Subject: [PATCH] gnu: viewnior: Support image formats out of the box.

* gnu/packages/image-viewers.scm (viewnior)
[inputs]: Add 'librsvg-for-system'.
[arguments]: Enable 'glib-or-gtk?' to make available
GDK_PIXBUF_MODULE_FILE.  Wrap viewnior to use it instead
of the image loaders installed by the user.
---
 gnu/packages/image-viewers.scm | 29 +++++++++++++++++++++--------
 1 file changed, 21 insertions(+), 8 deletions(-)

diff --git a/gnu/packages/image-viewers.scm b/gnu/packages/image-viewers.scm
index db7a44d4ff..798a8e50e8 100644
--- a/gnu/packages/image-viewers.scm
+++ b/gnu/packages/image-viewers.scm
@@ -27,6 +27,7 @@
 ;;; Copyright © 2022, 2023 Maxim Cournoyer <maxim.courno...@gmail.com>
 ;;; Copyright © 2022 Tomasz Jeneralczyk <t...@schwi.pl>
 ;;; Copyright © 2022 Cairn <ca...@pm.me>
+;;; Copyright © 2023 Florian Pelz <pelzflor...@pelzflorian.de>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -425,13 +426,24 @@ (define-public viewnior
         (base32 "14qvx1wajncd5ab0207274cwk32f4ipfnlaci6phmah0cwra2did"))))
     (build-system meson-build-system)
     (arguments
-     '(#:phases (modify-phases %standard-phases
-                  (add-after 'unpack 'patch-source
-                    (lambda _
-                      ;; Don't create 'icon-theme.cache'
-                      (substitute* "meson.build"
-                        (("meson.add_install_script*") "")))))
-       #:tests? #f))                    ;no tests
+     (list #:glib-or-gtk? #t
+           #:phases
+           #~(modify-phases %standard-phases
+               (add-after 'unpack 'patch-source
+                 (lambda _
+                   ;; Don't create 'icon-theme.cache'
+                   (substitute* "meson.build"
+                     (("meson.add_install_script*") ""))))
+               (add-after 'glib-or-gtk-wrap 'wrap-pixbuf
+                 (lambda* (#:key outputs #:allow-other-keys)
+                   (let ((viewnior (string-append #$output "/bin/viewnior")))
+                     (wrap-program viewnior
+                       ;; Wrap GDK_PIXBUF_MODULE_FILE so viewnior can be used
+                       ;; to view JPG, PNG and SVG, without the user needing
+                       ;; to install gdk-pixbuf or librsvg.
+                       `("GDK_PIXBUF_MODULE_FILE" =
+                         (,(getenv "GDK_PIXBUF_MODULE_FILE"))))))))
+           #:tests? #f))                    ;no tests
     (native-inputs
      (list gettext-minimal
            `(,glib "bin")               ;glib-genmarshal
@@ -440,7 +452,8 @@ (define-public viewnior
     (inputs
      (list exiv2
            gdk-pixbuf
-           gtk+-2))
+           gtk+-2
+           (librsvg-for-system)))
     (home-page "https://siyanpanayotov.com/project/viewnior";)
     (synopsis "Simple, fast and elegant image viewer")
     (description "Viewnior is an image viewer program.  Created to be simple,

base-commit: e3e011a08141058598cc7631aeb52d620a3ccb8c
-- 
2.39.2

Reply via email to