93d5575
diff -up xzgv-0.9/Makefile.foo xzgv-0.9/Makefile
93d5575
--- xzgv-0.9/Makefile.foo	2007-09-09 20:12:48.000000000 +0200
93d5575
+++ xzgv-0.9/Makefile	2009-01-10 15:20:11.000000000 +0100
93d5575
@@ -42,9 +42,9 @@ doc/xzgv.1: doc/xzgv.texi doc/makeman.aw
93d5575
 
93d5575
 # Like in GNU stuff, info files aren't automatically remade,
93d5575
 # as I don't want to assume everyone has texinfo's `makeinfo' handy.
93d5575
-info: doc/xzgv.gz
93d5575
+info: doc/xzgv.info.gz
93d5575
 
93d5575
-doc/xzgv.gz: doc/xzgv.texi
93d5575
+doc/xzgv.info.gz: doc/xzgv.texi
93d5575
 	cd doc && $(MAKE) info
93d5575
 
93d5575
 clean:
93d5575
@@ -52,6 +52,11 @@ clean:
93d5575
 	cd doc && $(MAKE) clean
93d5575
 	$(RM) *~
93d5575
 
93d5575
+realclean:
93d5575
+	cd src && $(MAKE) realclean
93d5575
+	cd doc && $(MAKE) realclean
93d5575
+	$(RM) *~
93d5575
+
93d5575
 install: all
93d5575
 	cd src && $(MAKE) install
93d5575
 	cd doc && $(MAKE) install
93d5575
diff -up xzgv-0.9/doc/Makefile.foo xzgv-0.9/doc/Makefile
93d5575
--- xzgv-0.9/doc/Makefile.foo	2007-09-09 20:27:58.000000000 +0200
93d5575
+++ xzgv-0.9/doc/Makefile	2009-01-10 15:20:11.000000000 +0100
93d5575
@@ -10,12 +10,12 @@ include ../config.mk
93d5575
 
93d5575
 all: info man
93d5575
 
93d5575
-info: xzgv.gz
93d5575
+info: xzgv.info.gz
93d5575
 dvi: xzgv.dvi
93d5575
 
93d5575
-xzgv.gz: xzgv.texi
93d5575
-	makeinfo xzgv.texi
93d5575
-	gzip -f xzgv
93d5575
+xzgv.info.gz: xzgv.texi
93d5575
+	makeinfo --no-split xzgv.texi
93d5575
+	gzip -9f xzgv.info
93d5575
 
93d5575
 # `-c' removes the huge number of associated files created by TeX.
93d5575
 # This saves doing a `make clean' from hell. :-)
93d5575
@@ -38,16 +38,20 @@ installdirs:
93d5575
 
93d5575
 install: installdirs
93d5575
 	install xzgv.1 $(MANDIR)
93d5575
-	install xzgv.gz $(INFODIR)
93d5575
-	install-info  --infodir=$(INFODIR) xzgv.gz
93d5575
+	install -m 644 xzgv.info.gz $(INFODIR)
93d5575
+	install-info --infodir=$(INFODIR) xzgv.info.gz
93d5575
 
93d5575
 uninstall:
93d5575
 	$(RM) $(MANDIR)/xzgv.1
93d5575
 	$(RM) $(INFODIR)/xzgv.gz
93d5575
-	install-info --remove xzgv
93d5575
+	install-info --remove xzgv.info.gz
93d5575
 
93d5575
 # This *doesn't* remove the Info files, which should stick around to
93d5575
 # be included in the distribution. Ditto for the man page, since
93d5575
 # building it requires gawk.
93d5575
 clean:
93d5575
 	$(RM) *~ xzgv.dvi
93d5575
+
93d5575
+realclean: clean
93d5575
+	$(RM) xzgv.1 xzgv.info.gz
93d5575
+
93d5575
diff -up xzgv-0.9/doc/xzgv.texi.foo xzgv-0.9/doc/xzgv.texi
93d5575
--- xzgv-0.9/doc/xzgv.texi.foo	2007-09-09 20:27:28.000000000 +0200
93d5575
+++ xzgv-0.9/doc/xzgv.texi	2009-01-10 15:20:11.000000000 +0100
93d5575
@@ -1,6 +1,6 @@
93d5575
 \input texinfo   @c -*-texinfo-*-
93d5575
 @c %**start of header
93d5575
-@setfilename xzgv
93d5575
+@setfilename xzgv.info
93d5575
 @settitle The xzgv manual
93d5575
 @setchapternewpage odd
93d5575
 @c %**end of header
93d5575
@@ -47,6 +47,7 @@ The xzgv manual, for version @value{VERS
93d5575
 @value{UPDATED}.
93d5575
 
93d5575
 Copyright 1999-2001 Russell Marks.
93d5575
+Copyright 2007 Reuben Thomas.
93d5575
 
93d5575
 Permission is granted to make and distribute verbatim copies of this
93d5575
 manual provided the copyright notice and this permission notice are
93d5575
@@ -74,12 +75,13 @@ approved by the Free Software Foundation
93d5575
 @title xzgv
93d5575
 @subtitle A picture viewer for X, with thumbnail-based file selector
93d5575
 @subtitle version @value{VERSION}
93d5575
-@author Russell Marks
93d5575
+@author Russell Marks and Reuben Thomas
93d5575
 
93d5575
 @c The following two commands start the copyright page.
93d5575
 @page
93d5575
 @vskip 0pt plus 1filll
93d5575
 Copyright @copyright{} 1999-2001 Russell Marks.
93d5575
+Copyright @copyright{} 2007 Reuben Thomas.
93d5575
 
93d5575
 Permission is granted to make and distribute verbatim copies of this
93d5575
 manual provided the copyright notice and this permission notice are
93d5575
@@ -149,8 +151,7 @@ The thumbnails used (thumbnails being sm
93d5575
 pictures) are compatible with xv, zgv, and the Gimp. The kinds of
93d5575
 pictures xzgv allows to be viewed are raster-format pictures (sometimes
93d5575
 called `bitmaps' and/or `pixmaps'); things like GIF files, JPEG files,
93d5575
-PNG files, and so on. (Details of file formats supported are given
93d5575
-elsewhere. @xref{Supported File Formats}.)
93d5575
+PNG files, and so on.
93d5575
 
93d5575
 Most of the time, you will probably want to use xzgv's file selector
93d5575
 (@pxref{The File Selector}) to pick which file(s) to view. This is what
93d5575
@@ -192,17 +193,11 @@ xzgv. xzgv can do a lot more; read on to
93d5575
 @c first, direct (or direct-ish :-)) xzgv contributions:
93d5575
 
93d5575
 xzgv was primarily written by Russell Marks, also the author of this
93d5575
-manual.
93d5575
+manual. It is maintained by Reuben Thomas.
93d5575
 
93d5575
 Costa Sapuntzakis contributed code for much faster JPEG thumbnail
93d5575
 generation (to zgv, which I adapted for xzgv).
93d5575
 
93d5575
-@c this isn't really `direct', but I think it belongs here.
93d5575
-@code{install-info} is a (very) slightly modified version of the
93d5575
-original (which is part of the @code{texinfo} package). This program is
93d5575
-used during installation. I think it was mostly written by Karl Berry,
93d5575
-but it's not terribly clear.
93d5575
-
93d5575
 The directory/file icons used were loosely based on gmc's
93d5575
 @file{dir-close.xpm}. I think Tuomas Kuosmanen was responsible for
93d5575
 that, judging from the change log.
93d5575
@@ -213,28 +208,12 @@ was written by Noah Friedman. (This is a
93d5575
 @c now libraries etc.:
93d5575
 
93d5575
 Huge thanks go to the many people responsible for GTK+, without which
93d5575
-xzgv would almost certainly not have happened. Thanks also to the
93d5575
-Rasterman (Carsten Haiztler) for Imlib, without which xzgv would most
93d5575
-likely have been a complete pain to write. (But no thanks for Electric
93d5575
-Eyes, which was nearly nice enough for me not to bother with xzgv at
93d5575
-all! :-))
93d5575
-
93d5575
-This program is based in part on the work of the Independent JPEG
93d5575
-Group. (I don't think I actually need this line any more, but I like
93d5575
-giving these guys a credit, it's a neat library. :-))
93d5575
-
93d5575
-xzgv uses (or rather it does if @code{INTERP_MMX} was defined when
93d5575
-compiling, and if it's running on an MMX-capable CPU) MMX instructions
93d5575
-for interpolation, with the help of libmmx, by Hank Dietz and Randy
93d5575
-Fisher.
93d5575
+xzgv would almost certainly not have happened. (But no thanks for
93d5575
+Electric Eyes, which was nearly nice enough for me not to bother with
93d5575
+xzgv at all! :-))
93d5575
 
93d5575
 @file{getopt*.[ch]} are from the GNU libc.
93d5575
 
93d5575
-``The Graphics Interchange Format(c) is the Copyright property of
93d5575
-CompuServe Incorporated. GIF(sm) is a Service Mark property of
93d5575
-CompuServe Incorporated.''
93d5575
-
93d5575
-
93d5575
 @node  Invoking xzgv, A Note on Notation, Acknowledgements, Top
93d5575
 @comment  node-name,  next,  previous,  up
93d5575
 @chapter Invoking xzgv
93d5575
@@ -300,11 +279,6 @@ Here's what the options do:
93d5575
 Automatically hide selector when a picture is selected, allowing the
93d5575
 viewer to use the whole window.
93d5575
 
93d5575
-@c I would never have defaulted to the fast/sloppy method if given
93d5575
-@c a choice, but Imlib1 did it without my knowing, such that when
93d5575
-@c I started reading JPEGs natively, I `had' to do it this way
93d5575
-@c around to avoid apparently gratuitous slowdown. :-(
93d5575
-@c
93d5575
 @vindex careful-jpeg
93d5575
 @item --careful-jpeg
93d5575
 Enable libjpeg `fancy upsampling'. xzgv defaults to using the faster
93d5575
@@ -322,10 +296,9 @@ override.)
93d5575
 
93d5575
 @vindex dither-hicol
93d5575
 @item --dither-hicol
93d5575
-Use dithering in 15/16-bit, whatever Imlib's default setting is.
93d5575
+Use dithering in 15/16-bit, whatever the default setting is.
93d5575
 @xref{Viewer Options}, for a discussion of benefits/drawbacks. You can
93d5575
-also use @code{--dither-hicol=off} to disable this if Imlib normally has
93d5575
-it enabled.
93d5575
+also use @code{--dither-hicol=off} to disable this.
93d5575
 
93d5575
 @vindex exif-orient
93d5575
 @item --exif-orient
93d5575
@@ -503,10 +476,7 @@ If started with @code{xzgv @var{files}},
93d5575
 and treats the file or files as if they were the sole contents of a
93d5575
 directory. (It also automatically loads the first file.) As such, you
93d5575
 can use the Next Image and Previous Image commands to navigate between
93d5575
-the images, or do Exit to Selector and use the selector directly. (By
93d5575
-the way, running like this also makes it possible to view files without
93d5575
-the usual extensions such as @file{.gif}, etc. @xref{File Type
93d5575
-Identification}.)
93d5575
+the images, or do Exit to Selector and use the selector directly.
93d5575
 
93d5575
 If started with @code{xzgv @var{start-dir}}, xzgv starts up as usual,
93d5575
 but with the selector starting on the directory specified (rather than
93d5575
@@ -830,13 +800,13 @@ move around the list, but it reads them 
93d5575
 The thumbnails used in xzgv require 256 colours to display. This can be
93d5575
 a problem if you're running X in 256 colours or less as, even if you're
93d5575
 running an 8-bit (256 colour) server, there will almost inevitably be
93d5575
-fewer colours available. Currently, xzgv just uses whatever Imlib
93d5575
+fewer colours available. Currently, xzgv just uses whatever gdk
93d5575
 reports as the closest match to each individual colour used in
93d5575
 thumbnails. This gives a tolerable result on 8-bit servers, assuming
93d5575
-Imlib was able to allocate a large number of colours; however, it gives
93d5575
+gdk was able to allocate a large number of colours; however, it gives
93d5575
 terrible results if it couldn't, or if running on 4-bit or 1-bit
93d5575
 servers. Sorry about this --- it should be fixed in future (either by
93d5575
-using Imlib to draw the thumbnail pixmaps, or by dithering them `by
93d5575
+using gdk to draw the thumbnail pixmaps, or by dithering them `by
93d5575
 hand' to suit the colours available).
93d5575
 
93d5575
 @item
93d5575
@@ -2548,14 +2518,13 @@ and see. (No keyboard shortcut --- see a
93d5575
 @cindex pictures, file formats used by
93d5575
 
93d5575
 Picture files are stored in a variety of different forms, or `file
93d5575
-formats'. xzgv, via Imlib, supports many.
93d5575
+formats'. xzgv, via gdk, supports many.
93d5575
 
93d5575
 @menu
93d5575
 * File Type Identification::    How xzgv identifies the type of a file.
93d5575
-* Supported File Formats::      The file formats that xzgv supports.
93d5575
 @end menu
93d5575
 
93d5575
-@node  File Type Identification, Supported File Formats, File Formats, File Formats
93d5575
+@node  File Type Identification,  , File Formats, File Formats
93d5575
 @comment  node-name,  next,  previous,  up
93d5575
 @section File Type Identification
93d5575
 
93d5575
@@ -2564,120 +2533,13 @@ formats'. xzgv, via Imlib, supports many
93d5575
 @cindex picture format, identification of 
93d5575
 @cindex file format, identification of
93d5575
 
93d5575
-The format a file is in is identified in two different ways. The file
93d5575
-selector picks filenames to display based on the `extension' --- for
93d5575
-instance, if a filename ends in @file{.jpg} or @file{.jpeg}, xzgv assumes
93d5575
-it is a JPEG. This way of working is not always right, but it's much
93d5575
-faster than the alternative (reading part of every single file) and is
93d5575
-usually sufficient.
93d5575
-
93d5575
-The file-reading code relies on Imlib to determine the file type and
93d5575
-read the file correctly; generally this uses the format's `magic number'
93d5575
-to determine file type --- e.g. a JPEG/JFIF file starts with the (hex)
93d5575
-bytes @code{FF D8}. So if you start xzgv with @samp{xzgv foo}, and foo
93d5575
-is in a format supported by Imlib (such as JPEG), the format will be
93d5575
-figured out and the file loaded even though the `extension' is absent.
93d5575
-
93d5575
-One extension to this is xzgv's built-in support for my relatively
93d5575
-obscure `mrf' format. :-) Since there's probably not much interest in
93d5575
-supporting this in Imlib, and it's really quite a simple format, it's
93d5575
-not unreasonable for xzgv to support this directly. But xzgv acts as if
93d5575
-Imlib supported mrf, so this distinction can be largely ignored.
93d5575
-
93d5575
-In fact, xzgv is gradually moving towards reading several of the more
93d5575
-popular formats natively, as part of an attempt to avoid being tied to a
93d5575
-single image rendering/loading backend; at the time of writing, GIF,
93d5575
-JPEG, PNG, and TIFF are also read in this way.
93d5575
-
93d5575
-
93d5575
-@node  Supported File Formats,  , File Type Identification, File Formats
93d5575
-@comment  node-name,  next,  previous,  up
93d5575
-@section Supported File Formats
93d5575
-
93d5575
-@cindex supported file formats
93d5575
-@cindex file formats, supported
93d5575
-@cindex types of picture supported
93d5575
-@cindex GIF
93d5575
-@cindex JPEG
93d5575
-@cindex PNG
93d5575
-@cindex PBM
93d5575
-@cindex PGM
93d5575
-@cindex PPM
93d5575
-@cindex PNM
93d5575
-@cindex TGA
93d5575
-@cindex Targa
93d5575
-@cindex PCX
93d5575
-@cindex mrf
93d5575
-@cindex PRF
93d5575
-@cindex XBM
93d5575
-@cindex bitmaps, X
93d5575
-@cindex XPM
93d5575
-@cindex pixmaps, X
93d5575
-@cindex TIFF
93d5575
-@cindex TIM
93d5575
-@cindex XWD
93d5575
-
93d5575
-xzgv supports the following file formats:
93d5575
-
93d5575
-@itemize @bullet
93d5575
-@item
93d5575
-GIF.
93d5575
-
93d5575
-@item
93d5575
-JPEG.
93d5575
-
93d5575
-@item
93d5575
-PNG.
93d5575
-
93d5575
-@item
93d5575
-PBM/PGM/PPM, collectively known as `PNM'. This is a nice simple format
93d5575
-used by pbmplus and netpbm.
93d5575
-
93d5575
-@item
93d5575
-BMP.
93d5575
-
93d5575
-@item
93d5575
-TGA (Targa).
93d5575
-
93d5575
-@item
93d5575
-PCX.
93d5575
-
93d5575
-@item
93d5575
-mrf. Mrf files can be converted to/from PBM with mrftopbm/pbmtomrf, and
93d5575
-the format is documented in the @cite{mrf(5)} man page.
93d5575
-
93d5575
-@item
93d5575
-PRF. PRF is an extension of mrf, similarly converted with
93d5575
-prftopnm/pnmtoprf, and documented in the @cite{prf(5)} man page.
93d5575
-
93d5575
-@item
93d5575
-XBM (X bitmap files).
93d5575
-
93d5575
-@item
93d5575
-XPM.
93d5575
-
93d5575
-@item
93d5575
-TIFF.
93d5575
-
93d5575
-@item
93d5575
-TIM. This is an image format used (on the Sony PlayStation) by some
93d5575
-games (e.g. Wipeout) for storing 2D images.
93d5575
-
93d5575
-@item
93d5575
-XWD (X window dumps, as produced by xwd).
93d5575
-
93d5575
-@c [XXX xzgv doesn't support these as files yet (will need yet more
93d5575
-@c Imlib-bypassing code, sigh), and doesn't treat them as their own
93d5575
-@c thumbnails]
93d5575
-@c Xv format thumbnail files. Normally you won't want to view these other
93d5575
-@c than in the file selector, but xzgv lets you view them as normal picture
93d5575
-@c files if you want. Note that in the file selector, thumbnail files are
93d5575
-@c indistinguishable from the files they represent (other than the
93d5575
-@c @file{.xvpics} in the directory's filename) --- they have the same
93d5575
-@c filenames, and thumbnails are their own thumbnails. :-)
93d5575
-
93d5575
-@end itemize
93d5575
-
93d5575
+The format a file is in is identified by its content. The file-reading
93d5575
+code relies on libgdk to determine the file type and read the file
93d5575
+correctly; generally this uses the format's `magic number' to determine
93d5575
+file type --- e.g. a JPEG/JFIF file starts with the (hex) bytes @code{FF
93d5575
+D8}. So if you start xzgv with @samp{xzgv foo}, and foo is in a
93d5575
+supported format (such as JPEG), the format will be figured out and the
93d5575
+file loaded even though the `extension' is absent.
93d5575
 
93d5575
 @node  Configuring xzgv, Rationale, File Formats, Top
93d5575
 @comment  node-name,  next,  previous,  up
93d5575
@@ -3037,8 +2899,8 @@ hiding/showing selector or resizing from
93d5575
 I kludged it :-)).
93d5575
 
93d5575
 @item
93d5575
-When scaling up and imlib is dithering, you end up with a crappy-looking
93d5575
-picture if you drag the picture around slowly (since each exposed bit is
93d5575
+When scaling up and dithering, you end up with a crappy-looking picture
93d5575
+if you drag the picture around slowly (since each exposed bit is
93d5575
 dithered independently, with no regard given to matching up to any
93d5575
 previous error-diffusion).
93d5575
 
93d5575
@@ -3060,10 +2922,10 @@ window-splitting bit, but I'm not sure. 
93d5575
 across scrollbar sliders and the paned window splitter handle.
93d5575
 
93d5575
 @item
93d5575
-It doesn't apply any tranparency mask returned by imlib. The practical
93d5575
-result of this seems to be purple transparent bits in thumbnails and
93d5575
-scaled-up images, and black transparent bits elsewhere. This doesn't
93d5575
-affect PNG files, though.
93d5575
+It doesn't apply any tranparency mask. The practical result of this
93d5575
+seems to be purple transparent bits in thumbnails and scaled-up images,
93d5575
+and black transparent bits elsewhere. This doesn't affect PNG files,
93d5575
+though.
93d5575
 
93d5575
 @item
93d5575
 If a GIF file is corrupted in such a way that the decompressed image
93d5575
@@ -3089,13 +2951,7 @@ nature, see xzgv''. :-)
93d5575
 @itemize @minus
93d5575
 @item
93d5575
 Thumbnails are given an accurate width/height `IMGINFO' comment, but are
93d5575
-always claimed to be "RGB", as Imlib doesn't provide any way to find out
93d5575
-what type they are.
93d5575
-
93d5575
-@item
93d5575
-xzgv should have an option to treat all files as images, since it
93d5575
-currently applies a zgv-like file extension filter. This is a bit
93d5575
-inflexible, given that Imlib supports `all' formats.
93d5575
+always claimed to be "RGB".
93d5575
 
93d5575
 @item
93d5575
 xzgv @emph{doesn't} duplicate zgv's behaviour of generating thumbnails
93d5575
@@ -3115,9 +2971,6 @@ suboptimal, but as an incompatibility wi
93d5575
 
93d5575
 @itemize @minus
93d5575
 @item
93d5575
-GIF89a extension blocks are ignored.
93d5575
-
93d5575
-@item
93d5575
 Only the first image of a multiple-image GIF is used. (These days,
93d5575
 multiple-image GIFs are usually animations.)
93d5575
 @end itemize
93d5575
@@ -3148,11 +3001,8 @@ Here are some details you should include
93d5575
 The version of xzgv you are running. @code{xzgv --version} reports this.
93d5575
 
93d5575
 @item
93d5575
-The versions of GTK+ and Imlib you are using. @code{xzgv --version-gtk}
93d5575
-reports the GTK+ version being used by xzgv, but Imlib is a little more
93d5575
-tricky --- @code{imlib-config --version} should work if you have a full
93d5575
-Imlib installation, but failing that, try @code{ls -l
93d5575
-/usr/lib/libImlib*} or @code{ls -l /usr/X11R6/lib/libImlib*}.
93d5575
+The versions of GTK+ you are using. @code{xzgv --version-gtk} reports
93d5575
+the GTK+ version being used by xzgv.
93d5575
 
93d5575
 @item
93d5575
 The bitdepth your X server is running in (common depths are 8-bit (256
93d5575
@@ -3162,7 +3012,7 @@ depth you're running in, try @code{xdpyi
93d5575
 @item
93d5575
 A description of the bug --- what effects it has, the circumstances it
93d5575
 occurs in, and so on. Does it only happen for certain types of file?
93d5575
-Only when in 8-bit modes? Only when dithering is enabled in Imlib? Even
93d5575
+Only when in 8-bit modes? Only when dithering is enabled? Even
93d5575
 `irrelevant' details can sometimes be useful.
93d5575
 
93d5575
 @item
93d5575
@@ -3173,7 +3023,7 @@ the patch using @code{diff -c} or (prefe
93d5575
 @end itemize
93d5575
 
93d5575
 So, if you think you've found a bug in xzgv, report it by emailing me at
93d5575
-@email{rus@@svgalib.org}.
93d5575
+@email{rrt@@sc3d.org}.
93d5575
 
93d5575
 
93d5575
 @node  Reporting Documentation Bugs,  , Reporting Bugs, Bugs and Restrictions
93d5575
diff -up xzgv-0.9/src/Makefile.foo xzgv-0.9/src/Makefile
93d5575
--- xzgv-0.9/src/Makefile.foo	2007-08-14 00:39:16.000000000 +0200
93d5575
+++ xzgv-0.9/src/Makefile	2009-01-10 15:20:11.000000000 +0100
93d5575
@@ -39,6 +39,7 @@ clean:
93d5575
 	$(RM) *~ *.o xzgv
93d5575
 	$(RM) rcfile_opt.h rcfile_var.h rcfile_short.h
93d5575
 
93d5575
+realclean: clean
93d5575
 
93d5575
 # dependancies
93d5575
 backend.o: backend.c backend.h
93d5575
diff -up xzgv-0.9/src/help.c.foo xzgv-0.9/src/help.c
93d5575
--- xzgv-0.9/src/help.c.foo	2007-09-09 02:45:46.000000000 +0200
93d5575
+++ xzgv-0.9/src/help.c	2009-01-10 15:20:11.000000000 +0100
93d5575
@@ -46,7 +46,8 @@ gtk_window_set_modal(GTK_WINDOW(about_wi
93d5575
 
93d5575
 label=gtk_label_new("xzgv " XZGV_VER " - picture viewer for X with file selector\n"
93d5575
                     "Copyright (C) 1999-2005 Russell Marks\n"
93d5575
-                    "Homepage - http://rus.members.beeb.net/xzgv.html");
93d5575
+                    "Copyright (C) 2007 Reuben Thomas\n"
93d5575
+                    "Homepage - http://sourceforge.net/projects/xzgv");
93d5575
 gtk_box_pack_start(GTK_BOX(vbox),label,TRUE,TRUE,2);
93d5575
 gtk_widget_show(label);
93d5575
 
93d5575
diff -up xzgv-0.9/src/main.c.foo xzgv-0.9/src/main.c
93d5575
--- xzgv-0.9/src/main.c.foo	2007-09-09 02:36:21.000000000 +0200
93d5575
+++ xzgv-0.9/src/main.c	2009-01-10 15:20:36.000000000 +0100
93d5575
@@ -38,7 +38,8 @@
93d5575
 #include <gtk/gtk.h>
93d5575
 #include <gdk/gdkkeysyms.h>
93d5575
 #include <gdk/gdkx.h>		/* needed for iconify stuff */
93d5575
-#include <X11/Xlib.h>		/* ditto */
93d5575
+#include <gdk/gdkrgb.h>     /* http://bugs.debian.org/457252 */
93d5575
+#include <X11/Xlib.h>		/* needed for iconify stuff */
93d5575
 
93d5575
 #include "backend.h"
93d5575
 #include "resizepic.h"
93d5575
@@ -105,7 +106,7 @@ guint tn_id;			/* `thumbnail' id for sta
93d5575
 
93d5575
 GtkWidget *mainwin;
93d5575
 
93d5575
-gint xvpic_pal[256];		/* palette for thumbnails */
93d5575
+guint8 xvpic_pal[256][3];		/* palette for thumbnails */
93d5575
 
93d5575
 /* image & rendered pixmap for currently-loaded image */
93d5575
 xzgv_image *theimage=NULL;
93d5575
@@ -1704,6 +1705,9 @@ void xy_scaling_double(int do_x,int do_y
93d5575
 static int in_routine=0;
93d5575
 int xtmp=xscaling,ytmp=yscaling,oldxsc=xscaling,oldysc=yscaling;
93d5575
 
93d5575
+/* if there's no image, don't do anything */
93d5575
+if (!theimage) return;
93d5575
+
93d5575
 /* if recursed, don't bother */
93d5575
 if(in_routine) return;
93d5575
 in_routine=1;
93d5575
@@ -1752,6 +1756,9 @@ void xy_scaling_add(int do_x,int do_y)
93d5575
 static int in_routine=0;
93d5575
 int xtmp=xscaling,ytmp=yscaling,oldxsc=xscaling,oldysc=yscaling;
93d5575
 
93d5575
+/* if there's no image, don't do anything */
93d5575
+if (!theimage) return;
93d5575
+
93d5575
 /* if recursed, don't bother */
93d5575
 if(in_routine) return;
93d5575
 in_routine=1;
93d5575
@@ -1800,6 +1807,9 @@ void xy_scaling_halve(int do_x,int do_y)
93d5575
 static int in_routine=0;
93d5575
 int xtmp=xscaling,ytmp=yscaling,oldxsc=xscaling,oldysc=yscaling;
93d5575
 
93d5575
+/* if there's no image, don't do anything */
93d5575
+if (!theimage) return;
93d5575
+
93d5575
 /* if recursed, don't bother */
93d5575
 if(in_routine) return;
93d5575
 in_routine=1;
93d5575
@@ -1851,6 +1861,9 @@ void xy_scaling_sub(int do_x,int do_y)
93d5575
 static int in_routine=0;
93d5575
 int xtmp=xscaling,ytmp=yscaling,oldxsc=xscaling,oldysc=yscaling;
93d5575
 
93d5575
+/* if there's no image, don't do anything */
93d5575
+if (!theimage) return;
93d5575
+
93d5575
 /* if recursed, don't bother */
93d5575
 if(in_routine) return;
93d5575
 in_routine=1;
93d5575
@@ -2101,6 +2114,7 @@ listen_to_toggles=1;
93d5575
 
93d5575
 void cb_flip(void)
93d5575
 {
93d5575
+if (!theimage) return;
93d5575
 RECURSE_PROTECT_START;
93d5575
 backend_flip_vert(theimage);
93d5575
 orient_current_state=orient_state_flip[orient_current_state];
93d5575
@@ -2111,6 +2125,7 @@ RECURSE_PROTECT_END;
93d5575
 
93d5575
 void cb_mirror(void)
93d5575
 {
93d5575
+if (!theimage) return;
93d5575
 RECURSE_PROTECT_START;
93d5575
 backend_flip_horiz(theimage);
93d5575
 orient_current_state=orient_state_mirror[orient_current_state];
93d5575
@@ -2121,6 +2136,7 @@ RECURSE_PROTECT_END;
93d5575
 
93d5575
 void cb_rot_cw(void)
93d5575
 {
93d5575
+if (!theimage) return;
93d5575
 RECURSE_PROTECT_START;
93d5575
 /* swap x and y scaling, since the effect if we don't do that
93d5575
  * is of the image mysteriously changing. :-)
93d5575
@@ -2135,6 +2151,7 @@ RECURSE_PROTECT_END;
93d5575
 
93d5575
 void cb_rot_acw(void)
93d5575
 {
93d5575
+if (!theimage) return;
93d5575
 RECURSE_PROTECT_START;
93d5575
 backend_rotate_acw(theimage);
93d5575
 orient_current_state=orient_state_rot_acw[orient_current_state];
93d5575
@@ -2146,6 +2163,7 @@ RECURSE_PROTECT_END;
93d5575
 
93d5575
 void cb_normal_orient(void)
93d5575
 {
93d5575
+if (!theimage) return;
93d5575
 RECURSE_PROTECT_START;
93d5575
 if(orient_current_state!=0)
93d5575
   {
93d5575
@@ -2514,113 +2532,93 @@ return(1);
93d5575
  */
93d5575
 void find_xvpic_cols(void)
93d5575
 {
93d5575
-GdkColor col;
93d5575
-int r,g,b;
93d5575
-int n;
93d5575
-
93d5575
-for(n=0,r=0;r<8;r++)
93d5575
-  for(g=0;g<8;g++)	/* colours are 3:3:2 */
93d5575
-    for(b=0;b<4;b++,n++)
93d5575
-      {
93d5575
-      col.red=r*0xffff/7; col.green=g*0xffff/7; col.blue=b*0xffff/3;
93d5575
-      backend_get_closest_colour(&col);
93d5575
-      xvpic_pal[n]=col.pixel;
93d5575
-      }
93d5575
+    int r,g,b;
93d5575
+    int n;
93d5575
+
93d5575
+    for(n=0,r=0;r<8;r++) {
93d5575
+        for(g=0;g<8;g++) {/* colours are 3:3:2 */
93d5575
+            for(b=0;b<4;b++,n++) {
93d5575
+                xvpic_pal[n][0]=r*0xff/7; 
93d5575
+                xvpic_pal[n][1]=g*0xff/7;
93d5575
+                xvpic_pal[n][2]=b*0xff/3;
93d5575
+            }
93d5575
+        }
93d5575
+    }
93d5575
 }
93d5575
 
93d5575
 
93d5575
 GdkPixmap *xvpic2pixmap(unsigned char *xvpic,int w,int h,GdkPixmap **smallp)
93d5575
 {
93d5575
 GdkPixmap *pixmap,*small_pixmap;
93d5575
-GdkImage *image;
93d5575
+guint8 *buffer;
93d5575
 unsigned char *ptr=xvpic;
93d5575
 int x,y;
93d5575
 int small_w,small_h;
93d5575
 
93d5575
 if(w==0 || h==0) return(NULL);
93d5575
 
93d5575
-/* we allocate pixmap and image, draw into image, copy to pixmap,
93d5575
- * and ditch the image.
93d5575
- */
93d5575
-
93d5575
-if((image=gdk_image_new(GDK_IMAGE_FASTEST,backend_get_visual(),w,h))==NULL)
93d5575
-  return(NULL);
93d5575
-
93d5575
-if((pixmap=gdk_pixmap_new(mainwin->window,w,h,
93d5575
-                          gdk_visual_get_best_depth()))==NULL)
93d5575
-  {
93d5575
-  gdk_image_destroy(image);
93d5575
-  return(NULL);
93d5575
-  }
93d5575
-
93d5575
-for(y=0;y
93d5575
-  for(x=0;x
93d5575
-    gdk_image_put_pixel(image,x,y,xvpic_pal[*ptr++]);
93d5575
 
93d5575
-gdk_draw_image(pixmap,clist->style->white_gc,image,0,0,0,0,w,h);
93d5575
-gdk_flush();
93d5575
+if (NULL == (pixmap=gdk_pixmap_new(mainwin->window,w,h, -1))) { 
93d5575
+    return(NULL);
93d5575
+}
93d5575
 
93d5575
-/* reuse image to draw scaled-down version for thin rows */
93d5575
 small_w=w/ROW_HEIGHT_DIV;
93d5575
 small_h=h/ROW_HEIGHT_DIV;
93d5575
 if(small_w==0) small_w=1;
93d5575
 if(small_h==0) small_h=1;
93d5575
 
93d5575
-if((small_pixmap=gdk_pixmap_new(mainwin->window,small_w,small_h,
93d5575
-                                gdk_visual_get_best_depth()))==NULL)
93d5575
-  {
93d5575
-  gdk_pixmap_unref(pixmap);
93d5575
-  gdk_image_destroy(image);
93d5575
-  return(NULL);
93d5575
+if((small_pixmap=gdk_pixmap_new(mainwin->window,small_w,small_h,-1))==NULL)
93d5575
+{
93d5575
+    gdk_pixmap_unref(pixmap);
93d5575
+    return(NULL);
93d5575
+}
93d5575
+
93d5575
+buffer = malloc (w * h * sizeof (guint8) * 3);
93d5575
+
93d5575
+if (NULL == buffer) {
93d5575
+    /* malloc failed */
93d5575
+    gdk_pixmap_unref(pixmap);
93d5575
+    gdk_pixmap_unref(small_pixmap);
93d5575
+    return NULL;
93d5575
+}
93d5575
+
93d5575
+
93d5575
+for(y=0;y
93d5575
+  for(x=0;x
93d5575
+      buffer[3*(y*w + x)+0] = xvpic_pal[*ptr][0]; /* red */
93d5575
+      buffer[3*(y*w + x)+1] = xvpic_pal[*ptr][1]; /* green */
93d5575
+      buffer[3*(y*w + x)+2] = xvpic_pal[*ptr][2]; /* blue */
93d5575
+      ptr++;
93d5575
   }
93d5575
+}
93d5575
 
93d5575
-for(y=0;y
93d5575
-  for(x=0;x
93d5575
-    gdk_image_put_pixel(image,x,y,
93d5575
-                        xvpic_pal[xvpic[(y*w+x)*ROW_HEIGHT_DIV]]);
93d5575
+gdk_draw_rgb_image(pixmap,clist->style->white_gc,0,0,w,h,
93d5575
+        GDK_RGB_DITHER_NORMAL,
93d5575
+        (guchar*)buffer, w * 3);
93d5575
+gdk_flush();
93d5575
 
93d5575
-gdk_draw_image(small_pixmap,clist->style->white_gc,image,
93d5575
-               0,0,0,0,small_w,small_h);
93d5575
+/* reuse image to draw scaled-down version for thin rows */
93d5575
 
93d5575
-gdk_image_destroy(image);
93d5575
 
93d5575
-*smallp=small_pixmap;
93d5575
-return(pixmap);
93d5575
+for(y=0;y
93d5575
+  for(x=0;x
93d5575
+      buffer[3*(y*w + x)+0] = xvpic_pal[xvpic[(y*w+x)*ROW_HEIGHT_DIV]][0];
93d5575
+      buffer[3*(y*w + x)+1] = xvpic_pal[xvpic[(y*w+x)*ROW_HEIGHT_DIV]][1];
93d5575
+      buffer[3*(y*w + x)+2] = xvpic_pal[xvpic[(y*w+x)*ROW_HEIGHT_DIV]][2];
93d5575
+  }
93d5575
 }
93d5575
 
93d5575
+gdk_draw_rgb_image(small_pixmap,clist->style->white_gc,0,0,small_w, small_h,
93d5575
+        GDK_RGB_DITHER_NORMAL,
93d5575
+        (guchar*)buffer, small_w * 3);
93d5575
 
93d5575
-int is_picture(char *filename)
93d5575
-{
93d5575
-int l=strlen(filename);
93d5575
+*smallp=small_pixmap;
93d5575
 
93d5575
-if(l<=4) return(0);
93d5575
+if (NULL != buffer) {
93d5575
+    free (buffer);
93d5575
+}
93d5575
 
93d5575
-/* at time of writing, imlib1 supports PPM/PGM/TIFF/PNG/XPM/JPEG
93d5575
- * natively, and uses ImageMagick's `convert' for others.
93d5575
- * But we have our own GIF/PNG/mrf readers.
93d5575
- */
93d5575
-if((!strcasecmp(filename+l-4,".gif")) ||
93d5575
-   (!strcasecmp(filename+l-4,".jpg")) ||
93d5575
-   (!strcasecmp(filename+l-5,".jpeg")) ||
93d5575
-   (!strcasecmp(filename+l-4,".png")) ||
93d5575
-   (!strcasecmp(filename+l-4,".mrf")) ||
93d5575
-   (!strcasecmp(filename+l-4,".xbm")) ||
93d5575
-   (!strcasecmp(filename+l-5,".icon")) ||	/* presumably an XBM */
93d5575
-   (!strcasecmp(filename+l-4,".xpm")) ||
93d5575
-   (!strcasecmp(filename+l-4,".pbm")) ||
93d5575
-   (!strcasecmp(filename+l-4,".pgm")) ||
93d5575
-   (!strcasecmp(filename+l-4,".ppm")) ||
93d5575
-   (!strcasecmp(filename+l-4,".bmp")) ||
93d5575
-   (!strcasecmp(filename+l-4,".tga")) ||
93d5575
-   (!strcasecmp(filename+l-4,".pcx")) ||
93d5575
-   (!strcasecmp(filename+l-4,".tif")) ||
93d5575
-   (!strcasecmp(filename+l-5,".tiff")) ||
93d5575
-   (!strcasecmp(filename+l-4,".prf")) ||
93d5575
-   (!strcasecmp(filename+l-4,".tim")) ||
93d5575
-   (!strcasecmp(filename+l-4,".xwd")))
93d5575
-  return(1);
93d5575
-else
93d5575
-  return(0);
93d5575
+return(pixmap);
93d5575
 }
93d5575
 
93d5575
 
93d5575
@@ -2993,9 +2991,6 @@ while((dent=readdir(dirfile))!=NULL)
93d5575
     }
93d5575
   isdir=S_ISDIR(sbuf.st_mode);
93d5575
   
93d5575
-  if(!isdir && !is_picture(dent->d_name))
93d5575
-    continue;
93d5575
-  
93d5575
   if(clist_add_new_row(dent->d_name,&sbuf))
93d5575
     numrows++;
93d5575
   }
93d5575
@@ -3687,7 +3682,11 @@ static GtkItemFactoryEntry viewer_menu_i
93d5575
   };
93d5575
 
93d5575
 
93d5575
+gtk_widget_push_visual(gdk_rgb_get_visual());
93d5575
+gtk_widget_push_colormap(gdk_rgb_get_cmap());
93d5575
 mainwin=gtk_window_new(GTK_WINDOW_TOPLEVEL);
93d5575
+gtk_widget_pop_visual();
93d5575
+gtk_widget_pop_colormap();
93d5575
 GTK_WIDGET_UNSET_FLAGS(mainwin,GTK_CAN_FOCUS);
93d5575
 gtk_signal_connect(GTK_OBJECT(mainwin),"destroy",
93d5575
                    GTK_SIGNAL_FUNC(cb_quit),NULL);