# Copyright 1999-2011 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: $

EAPI=5
inherit eutils

DESCRIPTION="GUI for the command line video converter ffmpeg"
HOMEPAGE="http://winff.org/"
PRESETS="presets-libavcodec53-v4.xml"
SRC_URI="https://winff.googlecode.com/files/WinFF-${PV}-source.tar.gz
	https://winff.googlecode.com/files/${PRESETS}.gz"

LICENSE="GPL-3 doc? ( FDL-1.3 )"
SLOT="0"
KEYWORDS="~amd64 ~x86"
IUSE="doc"

DEPEND="
	dev-lang/lazarus
"
RDEPEND="
	virtual/ffmpeg
	x11-libs/gtk+:2
"

S="${WORKDIR}"

src_prepare() {
	cp "${FILESDIR}/environmentoptions.xml" . || die
}

src_compile() {
	lazbuild --primary-config-path=. -B winff.lpi || die
}

src_install() {
	dobin ${PN}
	dodoc README* changelog.txt
	doman ${PN}.1
	insinto /usr/share/${PN}
	newins "${WORKDIR}/${PRESETS}" presets.xml
	doins -r languages
	local res
	for res in 16x16 24x24 32x32 48x48; do
		insinto /usr/share/icons/hicolor/${res}/apps
		doins ${PN}-icons/${res}/${PN}.png
	done
	doicon ${PN}-icons/48x48/${PN}.png || die
	make_desktop_entry ${PN} WinFF ${PN} "AudioVideo;AudioVideoEditing;GTK;"
	if use doc; then
		dodoc docs/WinFF*
		# don't compress the odt files
		docompress -x /usr/share/doc/${PF}
	fi
}

pkg_postinst() {
	einfo "You need to install x11-terms/gnome-terminal or x11-terms/xterm or"
	einfo "set the 'unix/terminal' option in Preferences."
}