# Copyright 2016 Julian Ospald <hasufell@posteo.de>
# Distributed under the terms of the GNU General Public License v2

require gtk-icon-cache

SUMMARY="An open-source jukebox for large collections of mp3/ogg/flac files"
HOMEPAGE="http://gmusicbrowser.org/"
DOWNLOADS="http://${PN}.org/download/${PNV}.tar.gz"

LICENCES="GPL-3"
SLOT="0"
PLATFORMS="~amd64 ~x86"
MYOPTIONS=""

DEPENDENCIES="
    build:
        sys-devel/gettext
    run:
        dev-lang/perl:*
        dev-perl/Gtk2-Perl
        dev-perl/MIME-Base64
        net-misc/wget
    suggestion:
        media/mpv [[ description = [ audio backend via media/mpv ] ]]
        (
            media-sound/flac123
            media-sound/mpg123
            media-sound/vorbis-tools
            sys-sound/alsa-utils
        ) [[ *description = [ alternative audio backend ]
             *group-name = [ alt-audio ] ]]
        (
            dev-perl/GStreamer
            dev-perl/GStreamer-Interfaces
            media-plugins/gst-plugins-bad:0
            media-plugins/gst-plugins-base:0.10
            media-plugins/gst-plugins-good:0.10
            media-plugins/gst-plugins-ugly:0.10
        ) [[ *description = [ gstreamer based audio backend ]
             *group-name = [ gstreamer-audio ] ]]
        dev-perl/Net-DBus [[ description = [ for dbus support and mpris1/2
                                             plugins ] ]]
"
# TODO:
#   dev-perl/Gtk2-WebKit (for Web context plugin)
#   dev-perl/Gtk2-Notify (for Notify plugin)
#   dev-perl/gnome2-wnck (for Titlebar plugin)

DEFAULT_SRC_PREPARE_PATCHES=(
    "${FILES}"/853840eb9dad0b59ad2dac5d303f5929b2f09f21.patch
)

src_prepare() {
    edo sed -i \
        -e "s|\$FindBin::RealBin\,'\.\.'|'/usr'|" \
        -e "s|\$FindBin::RealBin\.SLASH\.'\.\.'|SLASH\.'usr'|" \
        gmusicbrowser.pl

    default
}

src_install() {
    emake \
        DOCS="AUTHORS NEWS README" \
        DESTDIR="${IMAGE}" \
        bindir="${IMAGE}/usr/$(exhost --target)/bin" \
        iconsdir="${IMAGE}/usr/share/icons/hicolor/" \
        liconsdir="${IMAGE}/usr/share/icons/hicolor/48x48/apps" \
        miconsdir="${IMAGE}/usr/share/pixmaps" \
        install
}