# -*- 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

name                catgirl-downloader
github.setup        NyarchLinux CatgirlDownloader 0.2.8
revision            0

categories          www graphics
license             GPL-3
maintainers         {@barracuda156 gmail.com:vital.had} openmaintainer

description         GTK4 application that downloads images of catgirl
long_description    {*}${description} based on https://nekos.moe

checksums           rmd160  753c228de3bbe65891271ae2040ff3ede316f946 \
                    sha256  f0bc84816a5aa7ddff5b2b2a6b35b3cbca6195d243fcd7ae21b1b092dde6fdf1 \
                    size    7112175
github.tarball_from archive

meson.wrap_mode     nodownload

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

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

patchfiles-append   patch-use-right-python.diff

post-patch {
    reinplace "s|@PYTHON@|${configure.python}|" ${worksrcpath}/src/meson.build
}

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

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

# https://trac.macports.org/ticket/70538
depends_run-append  port:libadwaita \
                    port:py${py_ver_nodot}-gobject3 \
                    port:py${py_ver_nodot}-requests

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

# 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.
"
