# -*- 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                   github 1.0
PortGroup                   meson 1.0

github.setup                pithos pithos 1.6.2
revision                    1
categories                  audio
platforms                   any
maintainers                 {@ForestExpertise}
license                     GPL-3

description                 GTK-based pandora.com player

long_description            ${name} is a GUI client for the personalized web radio pandora \
                            (http://www.pandora.com).

checksums                   rmd160  841c7d87f8cd93a4092adde0103945190403858a \
                            sha256  69fffb5af07787eaf603d9e63b6facf25cc41760109dee5a92514354edd1068d \
                            size    122622
github.tarball_from         archive
supported_archs             noarch

# Match gstreamer1
set py_ver                  312
set py_branch               [string index ${py_ver} 0].[string range ${py_ver} 1 end]
set py_prefix               ${frameworks_dir}/Python.framework/Versions/${py_branch}
set py_libdir               ${py_prefix}/lib
set py_pkgd                 ${py_libdir}/python${py_branch}/site-packages

configure.python            ${py_prefix}/bin/python${py_branch}

patchfiles                  patch-meson-build.diff

post-patch {
    reinplace "s|/usr/bin/env python3|${configure.python}|" \
        ${worksrcpath}/bin/pithos.in ${worksrcpath}/docs/conf.py ${worksrcpath}/meson_post_install.py
    reinplace "s|@pkgd@|${py_pkgd}|" \
        ${worksrcpath}/meson.build
}

depends_build-append        port:appstream-glib \
                            port:gettext \
                            port:help2man

depends_lib-append          port:dbus-python${py_ver} \
                            port:gettext-runtime \
                            port:gnome-keyring \
                            path:lib/pkgconfig/gobject-introspection-1.0.pc:gobject-introspection \
                            port:gstreamer1-gst-libav \
                            port:gstreamer1-gst-plugins-bad \
                            port:gstreamer1-gst-plugins-base \
                            port:gstreamer1-gst-plugins-good \
                            path:lib/pkgconfig/gtk+-3.0.pc:gtk3 \
                            port:libsecret \
                            port:py-gst-python \
                            port:py${py_ver}-gobject3 \
                            port:py${py_ver}-pylast

depends_run-append          port:desktop-file-utils \
                            path:bin/pkg-config:pkgconfig

# See https://trac.macports.org/ticket/38634
post-activate {
    system "${prefix}/bin/glib-compile-schemas ${prefix}/share/glib-2.0/schemas"
    system "${prefix}/bin/update-desktop-database ${prefix}/share/applications"
    system "${prefix}/bin/gtk-update-icon-cache -f -t ${prefix}/share/icons/hicolor"
}

notes "
${name} uses dbus at runtime. If dbus service is not running, please start it with:\
launchctl load -w /Library/LaunchAgents/org.freedesktop.dbus-session.plist

Also, you need a U.S. IP address or proxy to play Pandora music.
"
