Support for run-time icons in the GTK puzzles. This involved another

mkfiles.pl change (I don't seem to be planning ahead very well this
week), this time to provide a list of fallback options for an object
file. That way, I have a no-icon.c which quietly replaces
icons/foo-icon.c if the latter doesn't exist, and so again people
checking straight out from Subversion shouldn't have trouble.

[originally from svn r7021]
This commit is contained in:
Simon Tatham
2006-12-27 15:10:59 +00:00
parent be8076a6e6
commit 61b983ae3a
30 changed files with 102 additions and 28 deletions

View File

@ -19,6 +19,7 @@ P16D24 = $(patsubst %,%-16d24.png,$(PUZZLES))
P16D8 = $(patsubst %,%-16d8.png,$(PUZZLES))
P16D4 = $(patsubst %,%-16d4.png,$(PUZZLES))
ICONS = $(patsubst %,%.ico,$(PUZZLES))
CICONS = $(patsubst %,%-icon.c,$(PUZZLES))
RC = $(patsubst %,%.rc,$(PUZZLES))
BIN = ../
@ -28,6 +29,7 @@ base: $(BASE)
web: $(WEB)
pngicons: $(P48D24) $(P32D24) $(P16D24)
winicons: $(ICONS) $(RC)
gtkicons: $(CICONS)
# Build the base puzzle screenshots from which all the other images
# are derived. Some of them involve showing a move animation
@ -120,5 +122,9 @@ $(ICONS): %.ico: %-48d24.png %-48d8.png %-48d4.png \
$(RC): %.rc:
echo '200 ICON "$*.ico"' > $@
# Build the GTK icon source files.
$(CICONS): %-icon.c: %-16d24.png %-32d24.png %-48d24.png
$(PIC)cicon.pl $^ > $@
clean:
rm -f *.png *.ico *.rc
rm -f *.png *.ico *.rc *-icon.c

27
icons/cicon.pl Executable file
View File

@ -0,0 +1,27 @@
#!/usr/bin/perl
# Given a list of input PNGs, create a C source file file
# containing a const array of XPMs, under the name `xpm_icon'.
$k = 0;
@xpms = ();
foreach $f (@ARGV) {
# XPM format is generated directly by ImageMagick, so that's easy
# enough. We just have to adjust the declaration line so that it
# has the right name, linkage and storage class.
@lines = ();
open XPM, "convert $f xpm:- |";
push @lines, $_ while <XPM>;
close XPM;
die "XPM from $f in unexpected format\n" unless $lines[1] =~ /^static.*\{$/;
$lines[1] = "static const char *const xpm_icon_$k"."[] = {\n";
$k++;
push @xpms, @lines, "\n";
}
# Now output.
foreach $line (@xpms) { print $line; }
print "const char *const *const xpm_icons[] = {\n";
for ($i = 0; $i < $k; $i++) { print " xpm_icon_$i,\n"; }
print "};\n";
print "const int n_xpm_icons = $k;\n";