mirror of
git://git.tartarus.org/simon/puzzles.git
synced 2025-04-21 16:05:44 -07:00
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:
@ -1,6 +1,6 @@
|
|||||||
# -*- makefile -*-
|
# -*- makefile -*-
|
||||||
|
|
||||||
blackbox : [X] GTK COMMON blackbox
|
blackbox : [X] GTK COMMON blackbox blackbox-icon|no-icon
|
||||||
|
|
||||||
blackbox : [G] WINDOWS COMMON blackbox blackbox.res?
|
blackbox : [G] WINDOWS COMMON blackbox blackbox.res?
|
||||||
|
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
BRIDGES = bridges dsf
|
BRIDGES = bridges dsf
|
||||||
|
|
||||||
bridges : [X] GTK COMMON BRIDGES
|
bridges : [X] GTK COMMON BRIDGES bridges-icon|no-icon
|
||||||
|
|
||||||
bridges : [G] WINDOWS COMMON BRIDGES bridges.res?
|
bridges : [G] WINDOWS COMMON BRIDGES bridges.res?
|
||||||
|
|
||||||
|
2
cube.R
2
cube.R
@ -1,6 +1,6 @@
|
|||||||
# -*- makefile -*-
|
# -*- makefile -*-
|
||||||
|
|
||||||
cube : [X] GTK COMMON cube
|
cube : [X] GTK COMMON cube cube-icon|no-icon
|
||||||
|
|
||||||
cube : [G] WINDOWS COMMON cube cube.res?
|
cube : [G] WINDOWS COMMON cube cube.res?
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
# -*- makefile -*-
|
# -*- makefile -*-
|
||||||
|
|
||||||
dominosa : [X] GTK COMMON dominosa
|
dominosa : [X] GTK COMMON dominosa dominosa-icon|no-icon
|
||||||
|
|
||||||
dominosa : [G] WINDOWS COMMON dominosa dominosa.res?
|
dominosa : [G] WINDOWS COMMON dominosa dominosa.res?
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
# -*- makefile -*-
|
# -*- makefile -*-
|
||||||
|
|
||||||
fifteen : [X] GTK COMMON fifteen
|
fifteen : [X] GTK COMMON fifteen fifteen-icon|no-icon
|
||||||
|
|
||||||
fifteen : [G] WINDOWS COMMON fifteen fifteen.res?
|
fifteen : [G] WINDOWS COMMON fifteen fifteen.res?
|
||||||
|
|
||||||
|
2
flip.R
2
flip.R
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
FLIP = flip tree234
|
FLIP = flip tree234
|
||||||
|
|
||||||
flip : [X] GTK COMMON FLIP
|
flip : [X] GTK COMMON FLIP flip-icon|no-icon
|
||||||
|
|
||||||
flip : [G] WINDOWS COMMON FLIP flip.res?
|
flip : [G] WINDOWS COMMON FLIP flip.res?
|
||||||
|
|
||||||
|
21
gtk.c
21
gtk.c
@ -15,6 +15,8 @@
|
|||||||
#include <gtk/gtk.h>
|
#include <gtk/gtk.h>
|
||||||
#include <gdk/gdkkeysyms.h>
|
#include <gdk/gdkkeysyms.h>
|
||||||
|
|
||||||
|
#include <gdk-pixbuf/gdk-pixbuf.h>
|
||||||
|
|
||||||
#include <gdk/gdkx.h>
|
#include <gdk/gdkx.h>
|
||||||
#include <X11/Xlib.h>
|
#include <X11/Xlib.h>
|
||||||
#include <X11/Xutil.h>
|
#include <X11/Xutil.h>
|
||||||
@ -1458,8 +1460,12 @@ static frontend *new_window(char *arg, int argtype, char **error)
|
|||||||
frontend *fe;
|
frontend *fe;
|
||||||
GtkBox *vbox;
|
GtkBox *vbox;
|
||||||
GtkWidget *menubar, *menu, *menuitem;
|
GtkWidget *menubar, *menu, *menuitem;
|
||||||
|
GdkPixmap *iconpm;
|
||||||
|
GList *iconlist;
|
||||||
int x, y, n;
|
int x, y, n;
|
||||||
char errbuf[1024];
|
char errbuf[1024];
|
||||||
|
extern char *const *const xpm_icons[];
|
||||||
|
extern const int n_xpm_icons;
|
||||||
|
|
||||||
fe = snew(frontend);
|
fe = snew(frontend);
|
||||||
|
|
||||||
@ -1745,6 +1751,21 @@ static frontend *new_window(char *arg, int argtype, char **error)
|
|||||||
GDK_BUTTON_RELEASE_MASK |
|
GDK_BUTTON_RELEASE_MASK |
|
||||||
GDK_BUTTON_MOTION_MASK);
|
GDK_BUTTON_MOTION_MASK);
|
||||||
|
|
||||||
|
if (n_xpm_icons) {
|
||||||
|
gtk_widget_realize(fe->window);
|
||||||
|
iconpm = gdk_pixmap_create_from_xpm_d(fe->window->window, NULL,
|
||||||
|
NULL, (gchar **)xpm_icons[0]);
|
||||||
|
gdk_window_set_icon(fe->window->window, NULL, iconpm, NULL);
|
||||||
|
iconlist = NULL;
|
||||||
|
for (n = 0; n < n_xpm_icons; n++) {
|
||||||
|
iconlist =
|
||||||
|
g_list_append(iconlist,
|
||||||
|
gdk_pixbuf_new_from_xpm_data((const gchar **)
|
||||||
|
xpm_icons[n]));
|
||||||
|
}
|
||||||
|
gdk_window_set_icon_list(fe->window->window, iconlist);
|
||||||
|
}
|
||||||
|
|
||||||
gtk_widget_show(fe->area);
|
gtk_widget_show(fe->area);
|
||||||
gtk_widget_show(fe->window);
|
gtk_widget_show(fe->window);
|
||||||
|
|
||||||
|
2
guess.R
2
guess.R
@ -1,6 +1,6 @@
|
|||||||
# -*- makefile -*-
|
# -*- makefile -*-
|
||||||
|
|
||||||
guess : [X] GTK COMMON guess
|
guess : [X] GTK COMMON guess guess-icon|no-icon
|
||||||
|
|
||||||
guess : [G] WINDOWS COMMON guess guess.res?
|
guess : [G] WINDOWS COMMON guess guess.res?
|
||||||
|
|
||||||
|
@ -19,6 +19,7 @@ P16D24 = $(patsubst %,%-16d24.png,$(PUZZLES))
|
|||||||
P16D8 = $(patsubst %,%-16d8.png,$(PUZZLES))
|
P16D8 = $(patsubst %,%-16d8.png,$(PUZZLES))
|
||||||
P16D4 = $(patsubst %,%-16d4.png,$(PUZZLES))
|
P16D4 = $(patsubst %,%-16d4.png,$(PUZZLES))
|
||||||
ICONS = $(patsubst %,%.ico,$(PUZZLES))
|
ICONS = $(patsubst %,%.ico,$(PUZZLES))
|
||||||
|
CICONS = $(patsubst %,%-icon.c,$(PUZZLES))
|
||||||
RC = $(patsubst %,%.rc,$(PUZZLES))
|
RC = $(patsubst %,%.rc,$(PUZZLES))
|
||||||
|
|
||||||
BIN = ../
|
BIN = ../
|
||||||
@ -28,6 +29,7 @@ base: $(BASE)
|
|||||||
web: $(WEB)
|
web: $(WEB)
|
||||||
pngicons: $(P48D24) $(P32D24) $(P16D24)
|
pngicons: $(P48D24) $(P32D24) $(P16D24)
|
||||||
winicons: $(ICONS) $(RC)
|
winicons: $(ICONS) $(RC)
|
||||||
|
gtkicons: $(CICONS)
|
||||||
|
|
||||||
# Build the base puzzle screenshots from which all the other images
|
# Build the base puzzle screenshots from which all the other images
|
||||||
# are derived. Some of them involve showing a move animation
|
# are derived. Some of them involve showing a move animation
|
||||||
@ -120,5 +122,9 @@ $(ICONS): %.ico: %-48d24.png %-48d8.png %-48d4.png \
|
|||||||
$(RC): %.rc:
|
$(RC): %.rc:
|
||||||
echo '200 ICON "$*.ico"' > $@
|
echo '200 ICON "$*.ico"' > $@
|
||||||
|
|
||||||
|
# Build the GTK icon source files.
|
||||||
|
$(CICONS): %-icon.c: %-16d24.png %-32d24.png %-48d24.png
|
||||||
|
$(PIC)cicon.pl $^ > $@
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
rm -f *.png *.ico *.rc
|
rm -f *.png *.ico *.rc *-icon.c
|
||||||
|
27
icons/cicon.pl
Executable file
27
icons/cicon.pl
Executable 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";
|
@ -1,6 +1,6 @@
|
|||||||
# -*- makefile -*-
|
# -*- makefile -*-
|
||||||
|
|
||||||
inertia : [X] GTK COMMON inertia
|
inertia : [X] GTK COMMON inertia inertia-icon|no-icon
|
||||||
|
|
||||||
inertia : [G] WINDOWS COMMON inertia inertia.res?
|
inertia : [G] WINDOWS COMMON inertia inertia.res?
|
||||||
|
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
LIGHTUP = lightup combi
|
LIGHTUP = lightup combi
|
||||||
|
|
||||||
lightup : [X] GTK COMMON LIGHTUP
|
lightup : [X] GTK COMMON LIGHTUP lightup-icon|no-icon
|
||||||
|
|
||||||
lightup : [G] WINDOWS COMMON LIGHTUP lightup.res?
|
lightup : [G] WINDOWS COMMON LIGHTUP lightup.res?
|
||||||
|
|
||||||
|
2
loopy.R
2
loopy.R
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
LOOPY = loopy tree234 dsf
|
LOOPY = loopy tree234 dsf
|
||||||
|
|
||||||
loopy : [X] GTK COMMON LOOPY
|
loopy : [X] GTK COMMON LOOPY loopy-icon|no-icon
|
||||||
|
|
||||||
loopy : [G] WINDOWS COMMON LOOPY loopy.res?
|
loopy : [G] WINDOWS COMMON LOOPY loopy.res?
|
||||||
|
|
||||||
|
2
map.R
2
map.R
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
MAP = map dsf
|
MAP = map dsf
|
||||||
|
|
||||||
map : [X] GTK COMMON MAP
|
map : [X] GTK COMMON MAP map-icon|no-icon
|
||||||
|
|
||||||
map : [G] WINDOWS COMMON MAP map.res?
|
map : [G] WINDOWS COMMON MAP map.res?
|
||||||
|
|
||||||
|
2
mines.R
2
mines.R
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
MINES = mines tree234
|
MINES = mines tree234
|
||||||
|
|
||||||
mines : [X] GTK COMMON MINES
|
mines : [X] GTK COMMON MINES mines-icon|no-icon
|
||||||
|
|
||||||
mines : [G] WINDOWS COMMON MINES mines.res?
|
mines : [G] WINDOWS COMMON MINES mines.res?
|
||||||
|
|
||||||
|
15
mkfiles.pl
15
mkfiles.pl
@ -131,11 +131,22 @@ readinput: while (1) {
|
|||||||
$type = substr($i,1,(length $i)-2);
|
$type = substr($i,1,(length $i)-2);
|
||||||
} else {
|
} else {
|
||||||
if ($i =~ /\?$/) {
|
if ($i =~ /\?$/) {
|
||||||
# Source files with a trailing question mark are optional:
|
# Object files with a trailing question mark are optional:
|
||||||
# the build can proceed fine without them, so we only use
|
# the build can proceed fine without them, so we only use
|
||||||
# them if they're present.
|
# them if their primary source files are present.
|
||||||
$i =~ s/\?$//;
|
$i =~ s/\?$//;
|
||||||
$i = undef unless defined &finddep($i);
|
$i = undef unless defined &finddep($i);
|
||||||
|
} elsif ($i =~ /\|/) {
|
||||||
|
# Object file descriptions containing a vertical bar are
|
||||||
|
# lists of choices: we use the _first_ one whose primary
|
||||||
|
# source file is present.
|
||||||
|
@options = split /\|/, $i;
|
||||||
|
$j = undef;
|
||||||
|
foreach $k (@options) {
|
||||||
|
$j=$k, last if defined &finddep($k);
|
||||||
|
}
|
||||||
|
die "no alternative found for $i\n" unless defined $j;
|
||||||
|
$i = $j;
|
||||||
}
|
}
|
||||||
if (defined $i) {
|
if (defined $i) {
|
||||||
push @$listref, $i;
|
push @$listref, $i;
|
||||||
|
2
net.R
2
net.R
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
NET = net tree234 dsf
|
NET = net tree234 dsf
|
||||||
|
|
||||||
net : [X] GTK COMMON NET
|
net : [X] GTK COMMON NET net-icon|no-icon
|
||||||
|
|
||||||
# The Windows Net shouldn't be called `net.exe' since Windows
|
# The Windows Net shouldn't be called `net.exe' since Windows
|
||||||
# already has a reasonably important utility program by that name!
|
# already has a reasonably important utility program by that name!
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
NETSLIDE = netslide tree234
|
NETSLIDE = netslide tree234
|
||||||
|
|
||||||
netslide : [X] GTK COMMON NETSLIDE
|
netslide : [X] GTK COMMON NETSLIDE netslide-icon|no-icon
|
||||||
|
|
||||||
netslide : [G] WINDOWS COMMON NETSLIDE netslide.res?
|
netslide : [G] WINDOWS COMMON NETSLIDE netslide.res?
|
||||||
|
|
||||||
|
9
no-icon.c
Normal file
9
no-icon.c
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
#include <X11/Intrinsic.h>
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Dummy source file which replaces the files generated in the
|
||||||
|
* `icons' subdirectory, when they're absent.
|
||||||
|
*/
|
||||||
|
|
||||||
|
const char *const *const xpm_icons[] = { 0 };
|
||||||
|
const int n_xpm_icons = 0;
|
@ -8,5 +8,5 @@
|
|||||||
# it in the Makefile because it will be worse than useless if it
|
# it in the Makefile because it will be worse than useless if it
|
||||||
# ever fails to compile, so it's important that it should actually
|
# ever fails to compile, so it's important that it should actually
|
||||||
# be built on a regular basis.
|
# be built on a regular basis.
|
||||||
nullgame : [X] GTK COMMON nullgame
|
nullgame : [X] GTK COMMON nullgame nullgame-icon|no-icon
|
||||||
nullgame : [G] WINDOWS COMMON nullgame
|
nullgame : [G] WINDOWS COMMON nullgame
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
# -*- makefile -*-
|
# -*- makefile -*-
|
||||||
|
|
||||||
pattern : [X] GTK COMMON pattern
|
pattern : [X] GTK COMMON pattern pattern-icon|no-icon
|
||||||
|
|
||||||
pattern : [G] WINDOWS COMMON pattern pattern.res?
|
pattern : [G] WINDOWS COMMON pattern pattern.res?
|
||||||
|
|
||||||
|
2
pegs.R
2
pegs.R
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
PEGS = pegs tree234
|
PEGS = pegs tree234
|
||||||
|
|
||||||
pegs : [X] GTK COMMON PEGS
|
pegs : [X] GTK COMMON PEGS pegs-icon|no-icon
|
||||||
|
|
||||||
pegs : [G] WINDOWS COMMON PEGS pegs.res?
|
pegs : [G] WINDOWS COMMON PEGS pegs.res?
|
||||||
|
|
||||||
|
2
rect.R
2
rect.R
@ -1,6 +1,6 @@
|
|||||||
# -*- makefile -*-
|
# -*- makefile -*-
|
||||||
|
|
||||||
rect : [X] GTK COMMON rect
|
rect : [X] GTK COMMON rect rect-icon|no-icon
|
||||||
|
|
||||||
rect : [G] WINDOWS COMMON rect rect.res?
|
rect : [G] WINDOWS COMMON rect rect.res?
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
# -*- makefile -*-
|
# -*- makefile -*-
|
||||||
|
|
||||||
samegame : [X] GTK COMMON samegame
|
samegame : [X] GTK COMMON samegame samegame-icon|no-icon
|
||||||
|
|
||||||
samegame : [G] WINDOWS COMMON samegame samegame.res?
|
samegame : [G] WINDOWS COMMON samegame samegame.res?
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
# -*- makefile -*-
|
# -*- makefile -*-
|
||||||
|
|
||||||
sixteen : [X] GTK COMMON sixteen
|
sixteen : [X] GTK COMMON sixteen sixteen-icon|no-icon
|
||||||
|
|
||||||
sixteen : [G] WINDOWS COMMON sixteen sixteen.res?
|
sixteen : [G] WINDOWS COMMON sixteen sixteen.res?
|
||||||
|
|
||||||
|
2
slant.R
2
slant.R
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
SLANT = slant dsf
|
SLANT = slant dsf
|
||||||
|
|
||||||
slant : [X] GTK COMMON SLANT
|
slant : [X] GTK COMMON SLANT slant-icon|no-icon
|
||||||
|
|
||||||
slant : [G] WINDOWS COMMON SLANT slant.res?
|
slant : [G] WINDOWS COMMON SLANT slant.res?
|
||||||
|
|
||||||
|
2
solo.R
2
solo.R
@ -1,6 +1,6 @@
|
|||||||
# -*- makefile -*-
|
# -*- makefile -*-
|
||||||
|
|
||||||
solo : [X] GTK COMMON solo
|
solo : [X] GTK COMMON solo solo-icon|no-icon
|
||||||
|
|
||||||
solo : [G] WINDOWS COMMON solo solo.res?
|
solo : [G] WINDOWS COMMON solo solo.res?
|
||||||
|
|
||||||
|
2
tents.R
2
tents.R
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
TENTS = tents maxflow
|
TENTS = tents maxflow
|
||||||
|
|
||||||
tents : [X] GTK COMMON TENTS
|
tents : [X] GTK COMMON TENTS tents-icon|no-icon
|
||||||
|
|
||||||
tents : [G] WINDOWS COMMON TENTS tents.res?
|
tents : [G] WINDOWS COMMON TENTS tents.res?
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
# -*- makefile -*-
|
# -*- makefile -*-
|
||||||
|
|
||||||
twiddle : [X] GTK COMMON twiddle
|
twiddle : [X] GTK COMMON twiddle twiddle-icon|no-icon
|
||||||
|
|
||||||
twiddle : [G] WINDOWS COMMON twiddle twiddle.res?
|
twiddle : [G] WINDOWS COMMON twiddle twiddle.res?
|
||||||
|
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
UNTANGLE = untangle tree234
|
UNTANGLE = untangle tree234
|
||||||
|
|
||||||
untangle : [X] GTK COMMON UNTANGLE
|
untangle : [X] GTK COMMON UNTANGLE untangle-icon|no-icon
|
||||||
|
|
||||||
untangle : [G] WINDOWS COMMON UNTANGLE untangle.res?
|
untangle : [G] WINDOWS COMMON UNTANGLE untangle.res?
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user