# Copyright 2016 Julian Ospald <hasufell@posteo.de>
# Distributed under the terms of the GNU General Public License v2

require gtk-icon-cache freedesktop-desktop
require setup-py [ import=distutils blacklist="2" multibuild=false python_opts="[sqlite]" ]

SUMMARY="A desktop wiki"
HOMEPAGE="http://zim-wiki.org/"
DOWNLOADS="http://zim-wiki.org/downloads/${PNV/_rc/-rc}.tar.gz"

LICENCES="
    BSD-3
    || ( GPL-2 GPL-3 )
"
SLOT="0"
PLATFORMS="~amd64 ~x86"
MYOPTIONS=""

DEPENDENCIES="
    build:
        x11-apps/xdg-utils
    build+run:
        gnome-bindings/pygobject:3[python_abis:*(-)?]
        x11-libs/gtk+:3[>=3.18]
    recommendation:
        dev-python/pyxdg[python_abis:*(-)?]
    suggestion:
        app-text/dvipng
        app-text/texlive-core
        dev-libs/zeitgeist:2.0
        dev-scm/bzr
        media-gfx/ImageMagick
        media-gfx/graphviz
        media-gfx/scrot
        media-sound/lilypond
        sci-apps/gnuplot
"

# Requires X server
RESTRICT="test"

WORK=${WORKBASE}/${PNV/_rc/-rc}

pkg_setup() {
    unset DISPLAY  # tries to access X socket
}

src_test() {
    PYTHONPATH="${PWD}/build/lib" \
        edo ${PYTHON} test.py
}

pkg_postinst() {
    freedesktop-desktop_pkg_postinst
    gtk-icon-cache_pkg_postinst
}

pkg_postrm() {
    freedesktop-desktop_pkg_postrm
    gtk-icon-cache_pkg_postrm
}