#!/bin/sh
# Author : 	Charles Bouveyron <charles.bouveyron@free.fr>
#		Alessandro Faggiano <>
#		Mathieu Vilaplana <mathieu@creationgif.com>

FILE="";
ANGLE=$1;
let "nbfiles = $# -1"
dcopRef=`kdialog --progressbar "Kim - Initialising ..." $nbfiles`
dcop $dcopRef showCancelButton true

compteur=0
for i in "$@";do
	if [ -f "$i" ];then
		#test if cancel button has been pushed
		if test "true" = `dcop $dcopRef wasCancelled`;then
			dcop $dcopRef close
			exit 1
		fi
		let "compteur +=1"
		FILE="$i"
		mogrify -$ANGLE "$FILE"
		dcop $dcopRef setLabel "Kim - Rotating file: `basename "$FILE"`"
 		dcop $dcopRef setProgress $compteur
	fi;
done

dcop $dcopRef close
