Subject: Re: bug#63427: gdk-pixbuf unable to recognize image formats (JPG, PNG, etc.)

From: "pelzflorian (Florian Pelz)" <[email-masked]>
Date: Sat, 13 May 2023 12:49:16 +0200

Nathan Dehnel <[email-masked]> writes:
> Yes, that one works

That’s good.  This means maybe either

- if guix shell without --pure works too, you just have not run “guix
  upgrade” recently, or

- --pure helped and viewnior is not compatible with the Adwaita dark
    theme, or

- --pure helped because you have misconfigured something that breaks the
  installed viewnior, but leaves the pure one intact.

What remains as a bug is wrapping the viewnior program inside
gdk-pixbuf, so installing gdk-pixbuf is not needed anymore.  Untested
patch is attached.

But then other image loaders installed by the user to support
e.g. libexif would not be usable anymore.  We could also add libexif,
but do we even want the attached patch?  Or should it be up to the user
to install image loaders?

Regards,
Florian

>From 29c76710eea6720aa4b5e774a83ce19e577937ac Mon Sep 17 00:00:00 2001
Message-Id: <29c[email-masked]>
From: Florian Pelz <[email-masked]>
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 | 18 +++++++++++++++---
 1 file changed, 15 insertions(+), 3 deletions(-)

diff --git a/gnu/packages/image-viewers.scm b/gnu/packages/image-viewers.scm
index db7a44d4ff..bbe26aadbe 100644
--- a/gnu/packages/image-viewers.scm
+++ b/gnu/packages/image-viewers.scm
@@ -27,6 +27,7 @@
 ;;; Copyright © 2022, 2023 Maxim Cournoyer <[email-masked]>
 ;;; Copyright © 2022 Tomasz Jeneralczyk <[email-masked]>
 ;;; Copyright © 2022 Cairn <[email-masked]>
+;;; Copyright © 2023 Florian Pelz <[email-masked]>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -425,12 +426,22 @@ (define-public viewnior
         (base32 "14qvx1wajncd5ab0207274cwk32f4ipfnlaci6phmah0cwra2did"))))
     (build-system meson-build-system)
     (arguments
-     '(#:phases (modify-phases %standard-phases
+     '(#: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*") "")))))
+                        (("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
@@ -440,7 +451,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