#Packager: George Vlahavas (vlahavas~at~gmail~dot~com)

pkgname=epdfview
pkgver=0.1.7
pkgrel=5gv
source=("http://trac.emma-soft.com/epdfview/chrome/site/releases/epdfview-$pkgver.tar.bz2" "0001-r329.patch" " 0002-r354.patch" " 0003-r357.patch" " m_Linearized.patch")
docs=("readme" "install" "copying" "changelog" "authors" "news" "todo" "maintainers" "about-nls" "thanks")
url=http://trac.emma-soft.com/epdfview

doinst() {
	if [ -x /usr/bin/update-desktop-database ]; then
		/usr/bin/update-desktop-database -q
	fi
	if [ -x /usr/bin/update-mime-database ]; then
	          /usr/bin/update-mime-database usr/share/mime >/dev/null 2>&1
	fi
}

slackdesc=\
(
#|-----handy-ruler------------------------------------------------------|
"epdfview (a PDF document viewer)"
"ePDFView is a free lightweight PDF document viewer using Poppler"
"and GTK+ libraries."
)


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

	# fix mousewheel scrolling
	patch -p2 < $startdir/src/0001-r329.patch || exit 1
	# patch poppler api changes
	patch -p2 < $startdir/src/0002-r354.patch || exit 1
	patch -p2 < $startdir/src/0003-r357.patch || exit 1
	# fix segfault on close
	patch -p0 < $startdir/src/m_Linearized.patch || exit 1
	# apply changes from r354 and r357 to configure.ac
	touch ChangeLog
	autoreconf -fi

	./configure --prefix=/usr --libdir=/usr/lib${LIBDIRSUFFIX} --localstatedir=/var --sysconfdir=/etc --build=$arch-slackware-linux
	make || return 1
	make install DESTDIR=$startdir/pkg

	# Fix the .desktop file
	sed -i -e 's/.png//' $startdir/pkg/usr/share/applications/epdfview.desktop
	sed -i -e 's/Categories=\(.*\)/Categories=GTK;Office;Viewer;/' $startdir/pkg/usr/share/applications/epdfview.desktop
	sed -i -e 's/Icon=\(.*\)/Icon=epdfview/' $startdir/pkg/usr/share/applications/epdfview.desktop

	# Symlink icons
	mkdir -p $startdir/pkg/usr/share/icons/hicolor/48x48/apps
	mkdir -p $startdir/pkg/usr/share/icons/hicolor/32x32/apps
	mkdir -p $startdir/pkg/usr/share/icons/hicolor/24x24/apps
	cd $startdir/pkg/usr/share/icons/hicolor/48x48/apps
	ln -s ../../../../epdfview/pixmaps/icon_epdfview-48.png epdfview.png
	cd $startdir/pkg/usr/share/icons/hicolor/32x32/apps
	ln -s ../../../../epdfview/pixmaps/icon_epdfview-32.png epdfview.png
	cd $startdir/pkg/usr/share/icons/hicolor/24x24/apps
	ln -s ../../../../epdfview/pixmaps/icon_epdfview-24.png epdfview.png
}