# -*- coding: utf-8; mode: tcl; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- vim:fenc=utf-8:filetype=tcl:et:sw=4:ts=4:sts=4

PortSystem          1.0
PortGroup           github 1.0
PortGroup           meson 1.0

github.setup        jcupitt vipsdisp 3.1.0 v
revision            0
categories          graphics
license             MIT
maintainers         nomaintainer

description         Tiny libvips/gtk+4 image viewer
long_description    {*}${description}

checksums           rmd160  550d8cce748232f19c3dc0c4eacd2221847e000f \
                    sha256  53c9dc008b2f6ace62dc2a985cebf1958205d4d5c6df32392d2f98ed96b6453e \
                    size    2438640
github.tarball_from archive

set py_ver          3.12
set py_ver_nodot    [string map {. {}} ${py_ver}]

depends_build-append \
                    path:bin/pkg-config:pkgconfig \
                    port:python${py_ver_nodot}

depends_lib-append  port:desktop-file-utils \
                    path:lib/pkgconfig/glib-2.0.pc:glib2 \
                    path:lib/pkgconfig/gtk4.pc:gtk4 \
                    port:vips

configure.python    ${prefix}/bin/python${py_ver}

post-patch {
    reinplace "s|/usr/bin/env python3|${configure.python}|" \
        ${worksrcpath}/meson_post_install.py
}

# cc1: error: unrecognized command line option "-std=gnu11"
compiler.c_standard 2011

post-activate {
    system "${prefix}/bin/glib-compile-schemas ${prefix}/share/glib-2.0/schemas"
    system "${prefix}/bin/gtk4-update-icon-cache -f -t ${prefix}/share/icons/hicolor"
    system "${prefix}/bin/update-desktop-database ${prefix}/share/applications"
}

# https://trac.macports.org/ticket/70137
notes "
If you get an error upon launching the app,\
try setting GSK_RENDERER=cairo in the environment.\
You may also add it into a shell config file.
"
