#!/bin/sh
# small util to fix icons in the glade file. Use this after u modify the glade file using the Glade designer
if [ "$1" = "" ]; then
   echo "USAGE : $0 <glade file name>"
   exit 1
fi
if [ ! -w $1 ]; then
  echo "File $1 does not exists or not writable"
  exit 1
fi
# create temp file
TEMP_FILE=`mktemp -t $1.XXXXXXXXXX`
if [ $? -ne 0 ]; then
  echo "Could not create temp file"
  exit 1
fi
# back up the content
cp $1 $TEMP_FILE
if [ $? -ne 0 ]; then
  echo "Could not copy $1 contents to temporary file $TEMP_FILE"
  rm -f $TEMP_FILE
  exit 1
fi
# fix the pixmap location (currently hardcoded to subdirectory pixmap)
#sed -e 's/<property name=\"icon\">\(.*\)<\/property>/<property name=\"icon\">pixmaps\/\1<\/property\>/' $TEMP_FILE > $1
sed -e 's/<property name=\"\(\(icon\)\|\(pixbuf\)\)\">\(.*\)<\/property>/<property name=\"\1\">pixmaps\/\4<\/property\>/' $TEMP_FILE > $1

#clean up temp file
rm -f $TEMP_FILE
