Debian Codegraph @

tools/x11/xfixicon.sh

raw
1 #! /bin/sh
2
3 # Generate X11 icon
4 # Usage: xfixicon iconfile
5
6 if test -z "$1"; then
7 echo "Usage:"
8 echo " xfixicon iconfile [-o outputfile]"
9 echo "this will generate a C file that can be linked with your application"
10 echo "to set the X11 icon automatically."
11 echo ""
12 echo "Options:"
13 echo " -o Set the name of the output file. Default name is allegro_icon.c"
14 exit
15 fi
16
17 outfile="allegro_icon.c"
18
19 while !(test -z "$1"); do
20 if (test "$1" = "-o"); then
21 outfile=$2
22 shift
23 else
24 file=$1
25 fi
26 shift
27 done
28
29 if !(test -e "$file"); then
30 echo "File not found: $file"
31 exit 1
32 fi
33
34 if !(convert -transparent "magenta" "$file" "/tmp/allegico_xpm.xpm"); then
35 echo "Conversion failed"
36 exit 1
37 fi
38
39 echo "#include <allegro5.h>" > $outfile
40 cat /tmp/allegico_xpm.xpm | sed -e 's,static char,static const char,' >> $outfile
41 echo "#if defined ALLEGRO_WITH_XWINDOWS && defined ALLEGRO_USE_CONSTRUCTOR" >> $outfile
42 echo "extern void *allegro_icon;" >> $outfile
43 echo "CONSTRUCTOR_FUNCTION(static void _set_allegro_icon(void));" >> $outfile
44 echo "static void _set_allegro_icon(void)" >> $outfile
45 echo "{" >> $outfile
46 echo " allegro_icon = allegico_xpm;" >> $outfile
47 echo "}" >> $outfile
48 echo "#endif" >> $outfile
49
50 rm /tmp/allegico_xpm.xpm