#!/bin/sh

. `dirname $0`/setup

# installs artwork, opportunistically from src to dest

src=$1
dest=$2

echo "do artwork tweaks ..."

if test -d $dest/setup_native; then
	mkdir -p $dest/setup_native/source/win32/nsis
	cp $src/ooobitmap_*.bmp $dest/setup_native/source/win32/nsis/ || echo "no nsis installer images to copy"
	cp $src/ooobanner_*.bmp $dest/setup_native/source/win32/nsis/ || echo "no nsis banner images to copy"
	cp $src/ooosetup_*.ico $dest/setup_native/source/win32/nsis/ || echo "no installer icon to copy"
else
	echo "	skipping setup_native"
fi

if test -d $dest/instsetoo_native; then
	mkdir -p $dest/instsetoo_native/res
	cp $src/nologoinstall_*.bmp $dest/instsetoo_native/res/ || echo "no installer sidebar images to copy"
	cp $src/banner_*.bmp $dest/instsetoo_native/res/ || echo "no installer banner images to copy"
else
	echo "	skipping instsetoo_native"
fi

if test -d $dest/svx; then
	mkdir -p $dest/svx/res
	cp $src/open*_*.bmp $dest/svx/res/ || echo "no intro images to copy"
else
	echo "	skipping svx"
fi

if test -d $dest/default_images; then
	mkdir -p $dest/default_images/svx/res
	mkdir -p $dest/default_images/sw/res
	cp $src/open*_*.png $dest/default_images/svx/res/ || echo "no about images to copy"
	cp $src/*-team.png $dest/default_images/sw/res/ || echo "no team images to copy"

	mkdir -p $dest/default_images/res/commandimagelist
	mkdir -p $dest/ooo_custom_images/industrial/res/commandimagelist
	mkdir -p $dest/ooo_custom_images/tango/res/commandimagelist
	cp $src/layout/*.png $dest/default_images/res/commandimagelist
	cp $src/layout/*.png $dest/ooo_custom_images/industrial/res/commandimagelist
	cp $src/layout/*.png $dest/ooo_custom_images/tango/res/commandimagelist
	${GNUTAR} -C $src/layout --exclude=.svn -cf- default_images ooo_custom_images | ${GNUTAR} -C $dest -xf-

	# Extra command images
	cp -f $src/icons/*.png $dest/default_images/res/commandimagelist/ || exit 1
	cp -f $src/icons/tango/*.png $dest/ooo_custom_images/tango/res/commandimagelist/ || exit 1

	# Tango icon for the GNOME quickstarter applet..."
	cp -f $src/tango_mainapp_16.png $dest/ooo_custom_images/tango/res/mainapp_16.png || exit 1;

	# Copy extra ooo-build specific images into build.  All files under default_images 
	# are copied into the build recursively.
    (cd $src && {
	    for img in `find default_images -type f`; do
            test $? -eq 0 || exit 1
	        # TODO: maybe we should check if the file is really an image file ?
	        imgdir=`dirname $img` || exit 1
	        mkdir -p $dest/$imgdir || exit 1
	        cp -f $img $dest/$img || exit 1
	    done
    })
else
	echo "	skipping default_images"
fi
