doc/plumbing.png
disobedience/manual.h
disobedience/manual.html
+disobedience/images.h
])
archpkg([disobedience], [ m4_dnl
- $(MAKE) DESTDIR=`pwd`/debian/disobedience -C images installdirs install
mkdir -p debian/disobedience/usr/bin
mkdir -p debian/disobedience/usr/share/man/man1
$(INSTALL) -m 755 disobedience/disobedience \
AM_CPPFLAGS=-I${top_srcdir}/lib -I../lib
AM_CFLAGS=$(GLIB_CFLAGS) $(GTK_CFLAGS)
+PNGS:=$(wildcard ${top_srcdir}/images/*.png)
disobedience_SOURCES=disobedience.h disobedience.c client.c queue.c \
choose.c misc.c style.h control.c properties.c menu.c \
${top_srcdir}/scripts/text2c manual manual.html > $@.tmp
mv $@.tmp $@
+misc.o: images.h
+
+images.h: $(PNGS)
+ exec > @$.new; \
+ for png in $(PNGS); do \
+ name=`echo $$png | sed 's,.*/,,;s,\.png,,;'`; \
+ gdk-pixbuf-csource --raw --name=image_$$name $$png; \
+ done; \
+ echo "static const struct image images[] = {"; \
+ for png in $(PNGS); do \
+ name=`echo $$png | sed 's,.*/,,;s,\.png,,;'`; \
+ echo " { \"$$name.png\", image_$$name },"; \
+ done; \
+ echo "};"
+ mv @$.new $@
+
EXTRA_DIST=disobedience.rc
# check everything has working --help
*/
#include "disobedience.h"
+#include "table.h"
+
+struct image {
+ const char *name;
+ const guint8 *data;
+};
+
+#include "images.h"
/* Miscellaneous GTK+ stuff ------------------------------------------------ */
GdkPixbuf *pb;
char *path;
GError *err = 0;
+ int n;
if(!(pb = (GdkPixbuf *)cache_get(&image_cache_type, name))) {
- byte_xasprintf(&path, "%s/static/%s", pkgdatadir, name);
- if(!(pb = gdk_pixbuf_new_from_file(path, &err))) {
- error(0, "%s", err->message);
- return 0;
+ if((n = TABLE_FIND(images, struct image, name, name)) >= 0) {
+ /* Use the built-in copy */
+ if(!(pb = gdk_pixbuf_new_from_inline(-1, images[n].data, FALSE, &err))) {
+ error(0, "%s", err->message);
+ return 0;
+ }
+ } else {
+ /* See if there's a copy on disk */
+ byte_xasprintf(&path, "%s/static/%s", pkgdatadir, name);
+ if(!(pb = gdk_pixbuf_new_from_file(path, &err))) {
+ error(0, "%s", err->message);
+ return 0;
+ }
}
NW(cached_image);
cache_put(&image_cache_type, name, pb);