# -*- 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           python 1.0
PortGroup           app 1.0
PortGroup           active_variants 1.1

name                quodlibet
version             3.9.1
revision            1
categories-append   audio gnome
maintainers         nomaintainer
license             GPL-2
platforms           darwin
description         audio library manager and player for GTK+

long_description \
Quod Libet is a GTK+-based audio player written in Python, \
using the Mutagen tagging library and GStreamer for playback.\
It provides several different ways to view your audio library, \
as well as support for Internet radio and audio feeds.\
It has extremely flexible metadata tag editing and searching capabilities.

homepage            https://code.google.com/p/quodlibet/
master_sites        https://github.com/quodlibet/quodlibet/releases/download/release-${version}/

checksums           rmd160  77c4e7776d2f28dcad447eefbd227d68af3ee47d \
                    sha256  d2b42df5d439213973dc97149fddc779a6c90cec389c24baf1c0bdcc39ffe591

python.default_version 27

depends_build       port:intltool

depends_lib         port:dbus-python27 \
                    port:gstreamer1-gst-plugins-good \
                    port:py27-futures \
                    port:py27-mutagen \
                    port:py27-feedparser \
                    port:py27-gobject3 \
                    port:py27-pyobjc-cocoa

depends_run         port:adwaita-icon-theme

# - patch-ignore_psn.diff
#   when run as an application, the argument -psn_x_xxxxx is passed to the program
#   but quodlibet is not prepared to handle it...
patchfiles          patch-ignore_psn.diff

if {$subport ne $name} {
    depends_build   port:py${python.version}-distutils

    if {${python.version} == 27} {
        depends_lib-append  port:py27-faulthandler
    }

    livecheck.type  none
}

variant quartz {

    depends_lib-append  port:gtk-osx-application-gtk3

}

post-patch {
    foreach file { quodlibet.py exfalso.py operon.py } {
        reinplace "s|/usr/bin/env python3|${frameworks_dir}/Python.framework/Versions/2.7/bin/python2.7|g" \
            ${worksrcpath}/${file}
    }
}


post-destroot {
    # icon keeps bouncing in the dock otherwise
    if {![variant_isset quartz]} {
      reinplace -E {s|(<string>APPL</string>)|\1 <key>LSUIElement</key><string>1</string>|} \
                "${destroot}${applications_dir}/Quodlibet.app/Contents/Info.plist"
    }
    
}

app.icon       quodlibet/images/hicolor/scalable/apps/quodlibet.svg

app.executable "${frameworks_dir}/Python.framework/Versions/2.7/bin/quodlibet"


notes "If you want to play mp3 files, don't forget to install gstreamer1-gst-plugins-ugly"

livecheck.type      regex
livecheck.url       https://${name}.readthedocs.org/en/latest/downloads.html
livecheck.regex     "${name}-(\\d+(?:\\.\\d+)*)${extract.suffix}"
