# Copyright 2025-2026 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2

# Autogenerated by pycargoebuild 0.15.0

EAPI=8

CRATES=""

inherit cargo gnome2-utils meson optfeature

DESCRIPTION="An internet radio player"
HOMEPAGE="https://apps.gnome.org/Shortwave/"
SRC_URI="
	https://gitlab.gnome.org/World/Shortwave/-/archive/${PV}/Shortwave-${PV}.tar.bz2
	https://github.com/puleglot/Shortwave/releases/download/${PV}/Shortwave-${PV}-crates.tar.xz
"
S="${WORKDIR}/Shortwave-${PV}"

LICENSE="GPL-3+"
# Dependent crate licenses
LICENSE+="
	Apache-2.0 Apache-2.0-with-LLVM-exceptions BSD-2 BSD Boost-1.0 ISC
	MIT MPL-2.0 Unicode-3.0
"
SLOT="0"
KEYWORDS="~amd64"

DEPEND="
	dev-db/sqlite:3
	dev-libs/glib
	dev-libs/gobject-introspection
	dev-libs/openssl:0=
	>=gui-libs/gtk-4.16
	>=gui-libs/libadwaita-1.8
	media-libs/glycin:2
	media-libs/gst-plugins-bad
	media-libs/gst-plugins-base
	media-libs/gstreamer
	media-libs/lcms:2
	>=media-libs/libshumate-1.3
	sys-libs/libseccomp
"
# Runtime deps:
#  - media-libs/glycin-loaders - required for displaying station covers.
#  - media-plugins/gst-plugins-meta[http] - required to successfully build a gsreamer
#    pipeline, since most (all?) stations have http/https URLs.
#  - media-plugins/gst-plugins-meta[pulseaudio] - preferred audiosink. Volume control
#    is supported only with pulsesink.
#  - media-plugins/gst-plugins-meta[vorbis] - needed for recording feature.
#    Shortwave will crash after each played track if vorbisenc is unavailable.
RDEPEND="
	${DEPEND}
	media-libs/glycin-loaders
	media-plugins/gst-plugins-meta[http]
	media-plugins/gst-plugins-meta[pulseaudio]
	media-plugins/gst-plugins-meta[vorbis]
"
BDEPEND="
	sys-devel/gettext
	virtual/pkgconfig
"

BUILD_DIR="${WORKDIR}/${P}-build"
ECARGO_HOME=${BUILD_DIR}/cargo-home

pkg_postinst() {
	# Popular codecs used by radio stations
	optfeature "AAC playback support" "media-plugins/gst-plugins-meta[aac]"
	optfeature "MP3 playback support" "media-plugins/gst-plugins-meta[mp3]"
	optfeature "Opus playback support" "media-plugins/gst-plugins-meta[opus]"

	gnome2_schemas_update
	xdg_icon_cache_update
}

pkg_postrm() {
	gnome2_schemas_update
	xdg_icon_cache_update
}
