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

pkgname=mate-terminal
pkgver=1.2.1
pkgrel=1gv
source=("http://pub.mate-desktop.org/releases/1.2/mate-terminal-1.2.1.tar.xz" "no-g_assert.patch" "help.patch")
docs=("readme" "install" "copying" "changelog" "authors" "news" "todo")
options=('noautodotnew')

slackdesc=\
(
"mate-terminal (Terminal emulator for the MATE desktop)"
"MATE Terminal is a terminal emulation application that you can use to"
"perform the following actions:"
" - Access a UNIX shell in the MATE environment."
" - Run any application that is designed to run on VT102, VT220, and"
"   xterm terminals."
""
"MATE Terminal features the ability to use multiple terminals in a"
"single window (tabs) and profiles support."
)


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

	patch -p1 < $startdir/src/no-g_assert.patch || exit 1
	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 \
		--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

	# colors and font
	mateconftool-2 --direct --config-source xml::$startdir/pkg/etc/mateconf/mateconf.xml.defaults --type bool --set /apps/mate-terminal/profiles/Default/use_theme_colors false
	mateconftool-2 --direct --config-source xml::$startdir/pkg/etc/mateconf/mateconf.xml.defaults --type string --set /apps/mate-terminal/profiles/Default/background_color "#000000000000"
	mateconftool-2 --direct --config-source xml::$startdir/pkg/etc/mateconf/mateconf.xml.defaults --type string --set /apps/mate-terminal/profiles/Default/foreground_color "#FFFFFFFFFFFF"
	mateconftool-2 --direct --config-source xml::$startdir/pkg/etc/mateconf/mateconf.xml.defaults --type bool --set /apps/mate-terminal/profiles/Default/use_system_font false
	mateconftool-2 --direct --config-source xml::$startdir/pkg/etc/mateconf/mateconf.xml.defaults --type string --set /apps/mate-terminal/profiles/Default/font "Terminus 10"

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