# Copyright 1999-2018 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2

EAPI=5
PYTHON_COMPAT=( python3_6)
PYTHON_REQ_USE="threads(+)" # threads for waf

inherit eutils xdg-utils gnome2-utils python-single-r1 waf-utils

DESCRIPTION="kupfer, a smart, quick launcher"
HOMEPAGE="https://kupferlauncher.github.io/"
SRC_URI="https://github.com/kupferlauncher/${PN}/releases/download/v${PV}/${PN}-v${PV}.tar.xz"
S="${WORKDIR}/${PN}-v${PV}"

LICENSE="Apache-2.0 GPL-2 GPL-3"
SLOT="0"
KEYWORDS="~amd64 ~x86"
IUSE="+keybinder appindicator nautilus"

COMMON_DEPEND="${PYTHON_DEPS}
	dev-python/pygtk
	dev-python/pyxdg
	dev-python/dbus-python
	dev-python/pygobject:3
	dev-python/setproctitle
	>=x11-libs/libwnck-3.20.1
	dev-python/pycairo"
DEPEND="${COMMON_DEPEND}
	dev-python/docutils
	dev-util/intltool"
RDEPEND="${COMMON_DEPEND}
	keybinder? ( dev-libs/keybinder:3 )
	appindicator? ( dev-libs/libappindicator:3 )
	nautilus? ( gnome-base/nautilus )"

REQUIRED_USE="${PYTHON_REQUIRED_USE}"

src_prepare() {
	epatch --ignore-whitespace "${FILESDIR}/${P}-remove-errcheck.patch"
}

src_configure() {
	local myopts=""
	waf-utils_src_configure --no-update-mime --no-update-icon-cache --nopyc ${myopts}
}

src_compile() {
	waf-utils_src_compile
}

src_install() {
	waf-utils_src_install
}

pkg_preinst() {
	gnome2_icon_savelist
}

pkg_postinst() {
	gnome2_icon_cache_update
	xdg_mimeinfo_database_update
	xdg_desktop_database_update
	elog "Some Kupfer plugins require optional runtime dependencies"
	elog "check ${HOMEPAGE} for details"
	elog "e.g. dev-python/gdata"
}

pkg_postrm() {
	gnome2_icon_cache_update
	xdg_mimeinfo_database_update
	xdg_desktop_database_update
}
