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

PortSystem          1.0
PortGroup           active_variants 1.1
PortGroup           github 1.0
PortGroup           meson 1.0

github.setup        GNOME nautilus 50.2.2
revision            0
set branch          [join [lrange [split ${version} .] 0 1] .]
description         The GNOME filemanager
long_description    Nautilus is the official file manager for the GNOME \
                    desktop. It is designed to be primarly a file manager, \
                    but there are support for web and file viewing too.
maintainers         {devans @dbevans} openmaintainer
categories          gnome sysutils
license             GPL-2+
homepage            https://wiki.gnome.org/Apps/Nautilus
checksums           rmd160  aba6448a72ac5cf5840d7abd13e5405a49c30d79 \
                    sha256  689382c91590b371f697d846a14c0bf9b4708556346be4113d250b35a76ff411 \
                    size    6648494
github.tarball_from archive

# The source was poisoned by rusty glycin
patchfiles          patch-degarbagify.diff
# Unconditional linuxisms
patchfiles-append   patch-nautilus-file-utilities.c
# Avoid non-portable functions
patchfiles-append   patch-no-memrchr.diff

set py_ver          3.14
set py_ver_nodot    [string map {. {}} ${py_ver}]
configure.python    ${prefix}/bin/python${py_ver}

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

depends_lib-append  path:lib/pkgconfig/gdk-pixbuf-2.0.pc:gdk-pixbuf2 \
                    port:gexiv2 \
                    path:lib/pkgconfig/glib-2.0.pc:glib2 \
                    port:gnome-autoar \
                    port:gnome-desktop-gtk4 \
                    port:graphene \
                    port:gsettings-desktop-schemas \
                    port:gstreamer1-gst-plugins-base \
                    path:lib/pkgconfig/gtk4.pc:gtk4 \
                    port:gvfs \
                    path:lib/pkgconfig/icu-uc.pc:icu \
                    port:libadwaita \
                    port:libportal-gtk4 \
                    port:libxml2 \
                    port:shared-mime-info \
                    port:tinysparql \
                    port:xorg-libX11

depends_run         port:adwaita-icon-theme \
                    port:desktop-file-utils \
                    port:tracker3-miners \
                    port:webp-pixbuf-loader

require_active_variants path:lib/pkgconfig/gtk4.pc:gtk4 x11

compiler.c_standard 2011

configure.args-append \
                    -Dcloudproviders=disabled \
                    -Ddocs=false \
                    -Dextensions=true \
                    -Dintrospection=true \
                    -Dpackagekit=false \
                    -Dselinux=false \
                    -Dtests="none"

if {[string match *clang* ${configure.compiler}]} {
    configure.cflags-append \
                    -Wno-error=incompatible-pointer-types-discards-qualifiers
}

post-activate {
    system "${prefix}/bin/update-desktop-database ${prefix}/share/applications"
    system "${prefix}/bin/update-mime-database ${prefix}/share/mime"
    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"
}

notes "
Since GTK-4 has a broken GL renderer, you may need to export GSK_RENDERER=cairo
"

livecheck.type      gnome
