#Packager: George Vlahavas <vlahavas~at~gmail~dot~com>

pkgname=mate-document-viewer
pkgver=1.4.0
pkgrel=1gv
source=("http://pub.mate-desktop.org/releases/1.4/mate-document-viewer-1.4.0.tar.xz" "help.patch")
docs=("readme" "install" "copying" "changelog" "authors" "news" "todo")
options=('noautodotnew')

doinst() {
# Update the scrollkeeper database (Remove stale pieces)
if [ -x /usr/bin/scrollkeeper-update ]; then
        /usr/bin/scrollkeeper-update > /dev/null 2>&1
fi
# compile schemas
if [ -x /usr/bin/glib-compile-schemas ]; then
        /usr/bin/glib-compile-schemas usr/share/glib-2.0/schemas > /dev/null 2>&1
fi
}

slackdesc=\
(
#|-----handy-ruler------------------------------------------------------|
"mate-document-viewer (simply a document viewer)"
"Atril is a simple multi-page document viewer. It can display and"
"print PostScript (PS), Encapsulated PostScript (EPS), DJVU and"
"Portable Document Format (PDF) files. When supported by the document,"
"it also allows searching for text, copying text to the clipboard,"
"hypertext navigation, and table-of-contents bookmarks."
)


build() {
	cd $startdir/src/$pkgname-$pkgver

	patch -p1 < $startdir/src/help.patch || exit 1

	./autogen.sh \
		--prefix=/usr \
		--libdir=/usr/lib${LIBDIRSUFFIX} \
		--localstatedir=/var \
		--sysconfdir=/etc \
		--disable-schemas-install \
		--disable-scrollkeeper \
		--disable-static \
		--with-mateconf-source="xml::/etc/mateconf/mateconf.xml.defaults" \
		--build=$arch-slackware-linux
	make -j $numjobs || return 1
	make install DESTDIR=$startdir/pkg

	# Install mateconf schemas in the package
        export MATECONF_CONFIG_SOURCE="xml::$startdir/pkg/etc/mateconf/mateconf.xml.defaults"
        if [ -d $startdir/pkg/etc/mateconf/schemas ]; then
            install -v -d -m755 $startdir/pkg/etc/mateconf/mateconf.xml.defaults
            SCHEMAS=$startdir/pkg/etc/mateconf/schemas
            for schema in $SCHEMAS/*.schemas; do
                mateconftool-2 --makefile-install-rule $schema
            done
            # Reset / Verify correct permissions
            ( cd $startdir/pkg/etc/mateconf ; find . -type d -exec chmod 755 {} \; )
            ( cd $startdir/pkg/etc/mateconf ; find . -type f -exec chmod 644 {} \; )
        fi

	# remove unnecessary help files
        find $startdir/pkg/usr/share/mate/help/atril/* -maxdepth 0 -type d ! -name C -exec rm -rf {} \;

	# wtf?
	sed -i "/^NoDisplay/d" $startdir/pkg/usr/share/applications/atril.desktop
} 
