I don't have great practice in GTK, but you can try this test.sh:
Code:
export DISPLAY=:0
export scriptdir=`/usr/bin/dirname $0`
cd $scriptdir
./test > output.txt 2> error.txt
This will write any error message to output.txt and error.txt in your program directory. Please post the files here, then we could help you a little more.