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

pkgname=mate-applets
pkgver=1.4.0
pkgrel=1rl
source=("http://pub.mate-desktop.org/releases/1.4/mate-applets-1.4.0.tar.xz" "help.patch")
docs=("readme" "install" "copying*" "changelog" "authors" "news" "todo" "hacking" "maintainers")
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
}

slackdesc=\
(
#|-----handy-ruler------------------------------------------------------|
"mate-applets (MATE Panel Applets)"
"MATE Applets are small applications which generally run in the"
"background and display their output to the MATE panel."
)


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

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

	./autogen.sh --prefix=/usr \
		--localstatedir=/var \
		--libdir=/usr/lib${LIBDIRSUFFIX} \
		--sysconfdir=/etc \
		--with-omf-dir=/usr/share/omf \
		--disable-scrollkeeper \
		--disable-schemas-install \
		--with-mateconf-source="xml::/etc/mateconf/mateconf.xml.defaults" \
		--disable-static \
		--build=$arch-slackware-linux \
		--disable-introspection \
		--disable-static \
		--enable-mixer-applet
	make || return 1
	make install DESTDIR=$startdir/pkg
	
	rm -rf $startdir/pkg/usr/share/gtk-doc

	# mateconf stuff
	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
	for i in `ls $startdir/pkg/usr/share/mate/help/`; do
		find $startdir/pkg/usr/share/mate/help/$i/* -maxdepth 0 -type d ! -name C -exec rm -rf {} \;
	done

	# put icons in hicolor dir, not everyone has to use the mate
	# icon theme
	mkdir -p $startdir/pkg/usr/share/icons/hicolor
	mv $startdir/pkg/usr/share/icons/mate/* $startdir/pkg/usr/share/icons/hicolor/
	rmdir $startdir/pkg/usr/share/icons/mate
}