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

EAPI=8

DISTUTILS_USE_PEP517=flit
PYTHON_COMPAT=( python3_{10..13} )

inherit distutils-r1 pypi xdg-utils desktop

DESCRIPTION="An integrated editor for the typst typesetting system"
HOMEPAGE="https://github.com/Bzero/typstwrite"

LICENSE="MIT"
SLOT="0"
KEYWORDS="~amd64"

DEPEND=">=dev-lang/python-3.10
        >=dev-python/pygments-2.18[${PYTHON_USEDEP}]
        >=dev-python/pyside6-6.4[${PYTHON_USEDEP},positioning,webengine,charts]
        >=dev-python/qtpy-2.3[${PYTHON_USEDEP},pyside6]
        >=dev-python/send2trash-1.8[${PYTHON_USEDEP}]
"
RDEPEND="${DEPEND}"
BDEPEND=""

distutils_enable_tests pytest

src_install() {
        distutils-r1_src_install

        # Prepare the icons
        newicon "${PN}/icons/${PN}.svg" "${PN}.svg"

        # Create a desktop entry
        make_desktop_entry "${PN}" "" "${PN}" ""
}

pkg_postinst() {
        xdg_icon_cache_update
        xdg_desktop_database_update
}

pkg_postrm() {
        xdg_icon_cache_update
        xdg_desktop_database_update
}
