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

EAPI=8

CRATES=" "
RUST_MIN_VER="1.94.0"

inherit cargo desktop xdg

DESCRIPTION="Rhythmbox-style media manager written in pure Rust with GTK4 and libadwaita"
HOMEPAGE="https://github.com/jm2/tributary"
SRC_URI="
	https://github.com/jm2/${PN}/archive/refs/tags/v${PV}.tar.gz -> ${P}.tar.gz
	https://github.com/gentoo-crate-dist/${PN}/releases/download/v${PV}/${P}-crates.tar.xz
"

LICENSE="GPL-3+"
# Dependent crate licenses
LICENSE+="
	Apache-2.0 Apache-2.0-with-LLVM-exceptions BSD CC0-1.0
	CDLA-Permissive-2.0 ISC MIT MPL-2.0 UoI-NCSA Unicode-3.0 ZLIB
"
SLOT="0"
KEYWORDS="~amd64"

DEPEND="
	>=gui-libs/gtk-4.16:4
	>=gui-libs/libadwaita-1.6:1
	>=media-libs/gstreamer-1.16:1.0
	sys-apps/dbus
"
RDEPEND="${DEPEND}
	media-plugins/gst-plugins-meta:1.0
"
BDEPEND="
	>=sys-devel/gettext-0.19.6:0
	virtual/pkgconfig
"

# Rust package
QA_FLAGS_IGNORED="usr/bin/${PN}"

src_prepare() {
	default
	ln -s "${WORKDIR}"/vendor/* "${ECARGO_VENDOR}/" || die
}

src_install() {
	default
	cargo_src_install

	insinto /usr/share/metainfo
	doins data/io.github.jm2.tributary.metainfo.xml

	local size
	for size in 16 24 32 48 64 128 256 512; do
		doicon --size ${size} data/icons/hicolor/${size}x${size}/apps/io.github.jm2.tributary.png
	done
	doicon --size scalable data/icons/hicolor/scalable/actions/io.github.jm2.tributary-equalizer-symbolic.svg

	domenu data/io.github.jm2.tributary.desktop
}