### this file is sourced not run
PKGVER=2.32.0
PKGBUILD=2 # build 2 removes ROX MIME-types, fatdog-script will handle that
PKGARCH=x86_64

# BLFS 2013-08-01 - this is the latest build that runs on GTK2
TARBALL=evince-2.32.0.tar.bz2
MD5SUM=ebc3ce6df8dcbf29cb9492f8dd031319 
SRC_URL=http://ftp.gnome.org/pub/gnome/sources/evince/2.32/$TARBALL
BUNDLE=

SLACKREQ='libspectre libdjvulibre poppler gtk2 libxml2'
SLACKDESC='evince: evince 2.32.0 (Document Viewer)  
evince:  
evince: Evince is a versatile document viewer capable of viewing PDF, 
evince: Postscript, and Djvu documents.  
evince: 
evince: 
evince: 
evince: 
evince: 
evince: 
evince: 
'
SLACKINSTALL='glib-compile-schemas ./usr/share/glib-2.0/schemas'

### default pkg_download
### prepare
pkg_prepare() {
	pkg_prepare_default &&
	
	# apply patches from Arch
	cd tmp/evince* &&
	patch -Np1 -i ../pkg/0001-tiff-fix-compile-warning.patch &&
	patch -Np1 -i ../pkg/kill-missing-gconf-complaints.patch &&
	patch -Np1 -i ../pkg/libview-crash.patch &&
	patch -Np1 -i ../pkg/update-poppler.patch &&
	patch -Np1 -i ../pkg/mime-type-change.patch &&
	patch -Np1 -i ../pkg/xzpdf.patch &&

	# CVE-2017-1000083 fix
	# ref: https://bugzilla.gnome.org/show_bug.cgi?id=784630
	patch -Np1 -i ../pkg/CVE-2017-1000083.patch &&
	true
}

### default pkg_package
### build
pkg_build() {
#	return 1
	export LIBS="-lICE" &&
	CONFFLAGS="$CONFFLAGS --enable-pixbuf \
	--without-gconf --without-keyring \
	--disable-nautilus --disable-help  --disable-scrollkeeper \
	--disable-schemas-compile \
	--disable-dbus --disable-static"
	
	cd /tmp/evince* &&
	autoreconf -fi &&
	pkg_build_autoconf &&
	pkg_build_slackdesc &&
	rm -f /usr/share/icons/hicolor/icon-theme.cache &&
	
	## Add ROX SendTo
	mkdir -p /etc/xdg/rox.sourceforge.net/SendTo/.application_pdf &&
	cd /etc/xdg/rox.sourceforge.net/SendTo &&
	ln -sfv /usr/share/applications/evince.desktop evince &&
	ln -sfv /usr/share/applications/evince.desktop .application_pdf/Open-with-Evince &&

<< "DISABLED" # ROX MIME-types
	mkdir -p /etc/xdg/rox.sourceforge.net/MIME-types &&
	cd /etc/xdg/rox.sourceforge.net/MIME-types &&
	ln -sfv /usr/bin/evince application_postscript &&
	ln -sfv /usr/bin/evince image_x-eps &&
	ln -sfv /usr/bin/evince application_x-dvi &&
	ln -sfv /usr/bin/evince image_vnd.djvu &&
	ln -sfv /usr/bin/evince image_vnd.djvu+multipage &&
	ln -sfv /usr/bin/evince application_pdf &&
	ln -sfv /usr/bin/evince application_x-cb7 &&
	ln -sfv /usr/bin/evince application_x-cbr &&
	ln -sfv /usr/bin/evince application_vnd.comicbook-rar &&
	ln -sfv /usr/bin/evince application_x-cbt &&
	ln -sfv /usr/bin/evince application_vnd.comicbook+zip &&
	ln -sfv /usr/bin/evince application_x-cbz &&

	# compressed versions of the above
	ln -sfv /usr/bin/evince application_x-gzpdf &&
	ln -sfv /usr/bin/evince application_x-bzpdf &&
	ln -sfv /usr/bin/evince application_x-xzpdf &&
	ln -sfv /usr/bin/evince application_x-gzpostscript &&
	ln -sfv /usr/bin/evince application_x-bzpostscript &&
	ln -sfv /usr/bin/evince application_x-xzpostscript &&
	ln -sfv /usr/bin/evince image_x-gzeps &&
	ln -sfv /usr/bin/evince image_x-bzeps &&
	ln -sfv /usr/bin/evince image_x-xzeps &&
	ln -sfv /usr/bin/evince application_x-gzdvi &&
	ln -sfv /usr/bin/evince application_x-bzdvi &&
	ln -sfv /usr/bin/evince application_x-xzdvi &&
DISABLED

	# enable desktop file
	sed -i -e '/^NoDisplay/d; s/^Categories.*/Categories=X-DocumentUtility;/' /usr/share/applications/evince.desktop
}
