summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/Makefile.in112
-rw-r--r--src/Makefile.in.WIN327
-rw-r--r--src/Makefile.in.orig213
-rw-r--r--src/Plustek-logo.xpm271
-rw-r--r--src/cursor/cursor_autoraise_scanarea.xbm7
-rw-r--r--src/cursor/cursor_autoraise_scanarea_mask.xbm7
-rw-r--r--src/cursor/cursor_zoom_select.xbm7
-rw-r--r--src/cursor/cursor_zoom_select_mask.xbm7
-rw-r--r--src/xsane-16x16.pngbin0 -> 711 bytes
-rw-r--r--src/xsane-16x16.xpm88
-rw-r--r--src/xsane-32x32.pngbin0 -> 1974 bytes
-rw-r--r--src/xsane-48x48.pngbin0 -> 3298 bytes
-rw-r--r--src/xsane-WIN32.txt85
-rw-r--r--src/xsane-back-gtk.c1047
-rw-r--r--src/xsane-back-gtk.h43
-rw-r--r--src/xsane-batch-scan.c1041
-rw-r--r--src/xsane-batch-scan.h74
-rw-r--r--src/xsane-device-preferences.c124
-rw-r--r--src/xsane-device-preferences.h2
-rw-r--r--src/xsane-eula.txt10
-rw-r--r--src/xsane-fixedtext.h7
-rw-r--r--src/xsane-front-gtk.c1222
-rw-r--r--src/xsane-front-gtk.h27
-rw-r--r--src/xsane-gamma.c473
-rw-r--r--src/xsane-gamma.h3
-rw-r--r--src/xsane-gimp-1_0-compat.h6
-rw-r--r--src/xsane-gpl.txt (renamed from src/xsane-license.txt)0
-rw-r--r--src/xsane-gtk-1_x-compat.h68
-rwxr-xr-xsrc/xsane-icon.rc1
-rw-r--r--src/xsane-icons.c1523
-rw-r--r--src/xsane-icons.h43
-rw-r--r--src/xsane-preferences.c187
-rw-r--r--src/xsane-preferences.h21
-rw-r--r--src/xsane-preview.c2328
-rw-r--r--src/xsane-preview.h28
-rw-r--r--src/xsane-rc-io.c15
-rw-r--r--src/xsane-rc-io.h2
-rw-r--r--src/xsane-save.c2013
-rw-r--r--src/xsane-save.h24
-rw-r--r--src/xsane-scan.c504
-rw-r--r--src/xsane-scan.h4
-rw-r--r--src/xsane-setup.c508
-rw-r--r--src/xsane-setup.h2
-rw-r--r--src/xsane-text.h190
-rw-r--r--src/xsane-viewer.c1236
-rw-r--r--src/xsane-viewer.h56
-rw-r--r--src/xsane.c4760
-rw-r--r--src/xsane.h364
-rw-r--r--src/xsaneopts.h52
49 files changed, 14429 insertions, 4383 deletions
diff --git a/src/Makefile.in b/src/Makefile.in
index 620859c..62916b7 100644
--- a/src/Makefile.in
+++ b/src/Makefile.in
@@ -32,7 +32,7 @@ INSTALL_DATA = @INSTALL_DATA@
CC = @CC@
INCLUDES = -I. -I$(srcdir) -I$(top_builddir)/include -I$(top_srcdir)/include @INCLUDES@
DEFS = @DEFS@ -DLOCALEDIR=$(datadir)/locale
-CPPFLAGS = @CPPFLAGS@ -DPATH_XSANE_DOC_DIR=\$(xsanedocdir) -DPATH_SANE_DATA_DIR=\$(sanedatadir)
+CPPFLAGS = @CPPFLAGS@ -DPATH_XSANE_DOC_DIR=$(xsanedocdir) -DPATH_SANE_DATA_DIR=$(sanedatadir)
CFLAGS = @CFLAGS@ @SANE_CFLAGS@ @GIMP_CFLAGS@ @GTK_CFLAGS@
LDFLAGS = @LDFLAGS@ @SANE_LDFLAGS@
LIBS = @SANE_LIBS@ @GIMP_LIBS@ @GTK_LIBS@ @INTLLIBS@ @LIBS@
@@ -49,9 +49,9 @@ LIBLIB = ../lib/liblib.a
XSANE_OBJS = xsane-back-gtk.o xsane-front-gtk.o xsane-gamma.o \
xsane-preview.o xsane-viewer.o \
- xsane-rc-io.o xsane-device-preferences.o \
+ xsane-rc-io.o xsane-device-preferences.o xsane-batch-scan.o \
xsane-preferences.o xsane-setup.o xsane-save.o xsane-scan.o \
- xsane-icons.o xsane.o
+ xsane-icons.o xsane.o @XSANE_ICON@
.c.o:
@@ -68,7 +68,8 @@ install: $(PROGRAMS)
$(INSTALL_DATA) $(srcdir)/xsane-startimage.pnm $(sanedatadir)/xsane/xsane-startimage.pnm
$(INSTALL_DATA) $(srcdir)/xsane-calibration.pnm $(sanedatadir)/xsane/xsane-calibration.pnm
$(INSTALL_DATA) $(srcdir)/xsane-logo.xpm $(sanedatadir)/xsane/xsane-logo.xpm
- $(INSTALL_DATA) $(srcdir)/xsane-license.txt $(sanedatadir)/xsane/xsane-license.txt
+ $(INSTALL_DATA) $(srcdir)/xsane-gpl.txt $(sanedatadir)/xsane/xsane-gpl.txt
+ $(INSTALL_DATA) $(srcdir)/xsane-eula.txt $(sanedatadir)/xsane/xsane-eula.txt
@for logo in *-logo.xpm; do \
echo installing $(sanedatadir)/xsane/$${logo}; \
$(INSTALL_DATA) $(srcdir)/$${logo} $(sanedatadir)/xsane/$${logo}; \
@@ -96,6 +97,8 @@ xsane: $(XSANE_OBJS) $(LIBLIB)
$(LINK) $(XSANE_OBJS) \
$(LIBLIB) $(LIBS) $(SANE_LIBS)
+xsane-icon.opc: xsane-icon.rc xsane.ico
+ windres -i xsane-icon.rc -o xsane-icon.opc
clean:
rm -f *.o *~ .*~ *.bak
@@ -108,3 +111,104 @@ depend:
makedepend $(INCLUDES) *.c
.PHONY: all install depend clean distclean
+
+xsane.o: xsane.h
+xsane.o: xsane-back-gtk.h
+xsane.o: xsane-front-gtk.h
+xsane.o: xsane-preview.h
+xsane.o: xsane-save.h
+xsane.o: xsane-gamma.h
+xsane.o: xsane-setup.h
+xsane.o: xsane-scan.h
+xsane.o: xsane-rc-io.h
+xsane.o: xsane-device-preferences.h
+xsane.o: xsane-preferences.h
+xsane.o: xsane-icons.h
+xsane.o: xsane-batch-scan.h
+
+xsane-back-gtk.o: xsane.h
+xsane-back-gtk.o: xsane-back-gtk.h
+xsane-back-gtk.o: xsane-front-gtk.h
+xsane-back-gtk.o: xsane-preferences.h
+xsane-back-gtk.o: xsane-gamma.h
+
+xsane-front-gtk.o: xsane.h
+xsane-front-gtk.o: xsane-back-gtk.h
+xsane-front-gtk.o: xsane-preferences.h
+xsane-front-gtk.o: xsane-preview.h
+xsane-front-gtk.o: xsane-save.h
+xsane-front-gtk.o: xsane-gamma.h
+xsane-front-gtk.o: xsane-setup.h
+
+xsane-batch-scan.o: xsane.h
+xsane-batch-scan.o: xsane-scan.h
+xsane-batch-scan.o: xsane-batch-scan.h
+xsane-batch-scan.o: xsane-back-gtk.h
+xsane-batch-scan.o: xsane-front-gtk.h
+xsane-batch-scan.o: xsane-rc-io.h
+xsane-batch-scan.o: xsane-preview.h
+xsane-batch-scan.o: xsane-gamma.h
+
+xsane-preview.o: xsane.h
+xsane-preview.o: xsane-back-gtk.h
+xsane-preview.o: xsane-front-gtk.h
+xsane-preview.o: xsane-batch-scan.h
+xsane-preview.o: xsane-preview.h
+xsane-preview.o: xsane-preferences.h
+xsane-preview.o: xsane-gamma.h
+
+xsane-preferecnes.o: xsane.h
+xsane-preferecnes.o: xsane-preferences.h
+xsane-preferecnes.o: xsane-rc-io.h
+
+xsane-device-preferences.o: xsane.h
+xsane-device-preferences.o: xsane-rc-io.h
+xsane-device-preferences.o: xsane-back-gtk.h
+xsane-device-preferences.o: xsane-front-gtk.h
+xsane-device-preferences.o: xsane-gamma.h
+
+xsane-rc-io.o: xsane.h
+xsane-rc-io.o: xsane-rc-io.h
+
+xsane-save.o: xsane.h
+xsane-save.o: xsane-back-gtk.h
+xsane-save.o: xsane-front-gtk.h
+
+xsane-scan.o: xsane.h
+xsane-scan.o: xsane-back-gtk.h
+xsane-scan.o: xsane-front-gtk.h
+xsane-scan.o: xsane-preferences.h
+xsane-scan.o: xsane-preview.h
+xsane-scan.o: xsane-viewer.h
+xsane-scan.o: xsane-save.h
+xsane-scan.o: xsane-gamma.h
+xsane-scan.o: xsane-setup.h
+
+xsane-gamma.o: xsane.h
+xsane-gamma.o: xsane-back-gtk.h
+xsane-gamma.o: xsane-front-gtk.h
+xsane-gamma.o: xsane-preferences.h
+xsane-gamma.o: xsane-preview.h
+xsane-gamma.o: xsane-save.h
+
+xsane-setup.o: xsane.h
+xsane-setup.o: xsane-back-gtk.h
+xsane-setup.o: xsane-front-gtk.h
+xsane-setup.o: xsane-preferences.h
+xsane-setup.o: xsane-device-preferences.h
+xsane-setup.o: xsane-preview.h
+xsane-setup.o: xsane-save.h
+xsane-setup.o: xsane-gamma.h
+xsane-setup.o: xsane-batch-scan.h
+
+xsane-viewer.o: xsane.h
+xsane-viewer.o: xsane-back-gtk.h
+xsane-viewer.o: xsane-front-gtk.h
+xsane-viewer.o: xsane-preferences.h
+xsane-viewer.o: xsane-viewer.h
+xsane-viewer.o: xsane-gamma.h
+xsane-viewer.o: xsane-icons.h
+xsane-viewer.o: xsane-save.h
+
+
+
diff --git a/src/Makefile.in.WIN32 b/src/Makefile.in.WIN32
index 46619d3..77c5320 100644
--- a/src/Makefile.in.WIN32
+++ b/src/Makefile.in.WIN32
@@ -19,7 +19,7 @@ INSTALL_DATA = @INSTALL_DATA@
CC = @CC@ -mwindows
INCLUDES = -I. -I$(srcdir) -I$(top_builddir)/include -I$(top_srcdir)/include \
@GTK_CFLAGS@ @INCLUDES@ -I/usr/include -I/usr/include/gdk
-DEFS = -D_WIN32 @DEFS@ -DXSANE_FIXED_HOME_PATH=$(sanedir)'\\'home -DTEMP_PATH=c:'\\'temp -DSLASH=92 -DBUGGY_GDK_INPUT_EXCEPTION -DLOCALEDIR=share/locale
+DEFS = -D_WIN32 @DEFS@ -DXSANE_FIXED_HOME_PATH=$(sanedir)'\\'home -DTEMP_PATH=c:'\\'temp -DSLASH=92 -DBUGGY_GDK_INPUT_EXCEPTION -DLOCALEDIR=/cygdrive/c/sane/share/locale
CPPFLAGS = @CPPFLAGS@ -DPATH_XSANE_DOC_DIR=\$(xsanedocdir) -DPATH_SANE_DATA_DIR=\$(sanedatadir)
CFLAGS = @CFLAGS@ -fnative-struct
LDFLAGS = @LDFLAGS@
@@ -40,7 +40,7 @@ PROGRAMS = $(BINPROGS)
LIBLIB = ../lib/liblib.a
XSANE_OBJS = xsane-back-gtk.o xsane-front-gtk.o xsane-gamma.o xsane-preview.o \
- xsane-viewer.o xsane-rc-io.o xsane-device-preferences.o \
+ xsane-viewer.o xsane-rc-io.o xsane-device-preferences.o xsane-batch-scan.o \
xsane-preferences.o xsane-setup.o xsane-save.o xsane-scan.o \
xsane-icons.o xsane.o
@@ -59,7 +59,8 @@ install: $(PROGRAMS)
$(INSTALL_DATA) $(srcdir)/xsane-startimage.pnm $(sanedatadir)/xsane/xsane-startimage.pnm
$(INSTALL_DATA) $(srcdir)/xsane-calibration.pnm $(sanedatadir)/xsane/xsane-calibration.pnm
$(INSTALL_DATA) $(srcdir)/xsane-logo.xpm $(sanedatadir)/xsane/xsane-logo.xpm
- $(INSTALL_DATA) $(srcdir)/xsane-license.txt $(sanedatadir)/xsane/xsane-license.txt
+ $(INSTALL_DATA) $(srcdir)/xsane-gpl.txt $(sanedatadir)/xsane/xsane-gpl.txt
+ $(INSTALL_DATA) $(srcdir)/xsane-eula.txt $(sanedatadir)/xsane/xsane-eula.txt
@for logo in *-logo.xpm; do \
echo installing $(sanedatadir)/xsane/$${logo}; \
$(INSTALL_DATA) $(srcdir)/$${logo} $(sanedatadir)/xsane/$${logo}; \
diff --git a/src/Makefile.in.orig b/src/Makefile.in.orig
new file mode 100644
index 0000000..b171027
--- /dev/null
+++ b/src/Makefile.in.orig
@@ -0,0 +1,213 @@
+SHELL = /bin/sh
+
+VPATH = @srcdir@
+srcdir = @srcdir@
+top_srcdir = @top_srcdir@
+top_builddir = ..
+
+sane_prefix = @SANE_PREFIX@
+prefix = @prefix@
+exec_prefix = @exec_prefix@
+bindir = @bindir@
+sbindir = @sbindir@
+libexecdir = @libexecdir@
+datadir = @datadir@
+sysconfdir = @sysconfdir@
+sharedstatedir = @sharedstatedir@
+localstatedir = @localstatedir@
+libdir = @libdir@
+infodir = @infodir@
+mandir = @mandir@
+includedir = @includedir@
+oldincludedir = /usr/include
+configdir = ${sysconfdir}/sane.d
+sanedatadir = ${datadir}/sane
+xsanedocdir = ${datadir}/sane/xsane/doc
+
+MKINSTALLDIRS = @MKINSTALLDIRS@
+INSTALL = @INSTALL@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_DATA = @INSTALL_DATA@
+
+CC = @CC@
+INCLUDES = -I. -I$(srcdir) -I$(top_builddir)/include -I$(top_srcdir)/include @INCLUDES@
+DEFS = @DEFS@ -DLOCALEDIR=$(datadir)/locale
+CPPFLAGS = @CPPFLAGS@ -DPATH_XSANE_DOC_DIR=\$(xsanedocdir) -DPATH_SANE_DATA_DIR=\$(sanedatadir)
+CFLAGS = @CFLAGS@ @SANE_CFLAGS@ @GIMP_CFLAGS@ @GTK_CFLAGS@
+LDFLAGS = @LDFLAGS@ @SANE_LDFLAGS@
+LIBS = @SANE_LIBS@ @GIMP_LIBS@ @GTK_LIBS@ @INTLLIBS@ @LIBS@
+
+COMPILE = $(CC) -c $(DEFS) $(INCLUDES) $(CPPFLAGS) $(CFLAGS)
+LINK = $(CC) $(LDFLAGS) -o $@
+
+BINPROGS = @BINPROGS@
+
+@SET_MAKE@
+
+PROGRAMS = $(BINPROGS)
+LIBLIB = ../lib/liblib.a
+
+XSANE_OBJS = xsane-back-gtk.o xsane-front-gtk.o xsane-gamma.o \
+ xsane-preview.o xsane-viewer.o \
+ xsane-rc-io.o xsane-device-preferences.o xsane-batch-scan.o \
+ xsane-preferences.o xsane-setup.o xsane-save.o xsane-scan.o \
+ xsane-icons.o xsane.o
+
+
+.c.o:
+ $(COMPILE) $<
+
+all: $(PROGRAMS)
+
+install: $(PROGRAMS)
+ $(MKINSTALLDIRS) $(bindir) $(sbindir) $(datadir) $(sanedatadir) $(xsanedocdir) $(sanedatadir)/xsane
+ @for program in $(BINPROGS); do \
+ $(INSTALL_PROGRAM) $${program} $(bindir)/$${program}; \
+ done
+ $(INSTALL_DATA) $(srcdir)/xsane-style.rc $(sanedatadir)/xsane/xsane-style.rc
+ $(INSTALL_DATA) $(srcdir)/xsane-startimage.pnm $(sanedatadir)/xsane/xsane-startimage.pnm
+ $(INSTALL_DATA) $(srcdir)/xsane-calibration.pnm $(sanedatadir)/xsane/xsane-calibration.pnm
+ $(INSTALL_DATA) $(srcdir)/xsane-logo.xpm $(sanedatadir)/xsane/xsane-logo.xpm
+ $(INSTALL_DATA) $(srcdir)/xsane-gpl.txt $(sanedatadir)/xsane/xsane-gpl.txt
+ $(INSTALL_DATA) $(srcdir)/xsane-eula.txt $(sanedatadir)/xsane/xsane-eula.txt
+ @for logo in *-logo.xpm; do \
+ echo installing $(sanedatadir)/xsane/$${logo}; \
+ $(INSTALL_DATA) $(srcdir)/$${logo} $(sanedatadir)/xsane/$${logo}; \
+ done
+
+uninstall:
+ @for program in $(BINPROGS); do \
+ echo uninstalling $(bindir)/$${program}...; \
+ rm -f $(bindir)/$${program}; \
+ done
+ echo uninstalling $(sanedatadir)/xsane/xsane-style.rc...
+ rm -f $(sanedatadir)/xsane/xsane-style.rc
+ echo uninstalling $(sanedatadir)/xsane/xsane-startimage.pnm...
+ rm -f $(sanedatadir)/xsane/xsane-startimage.pnm
+ echo uninstalling $(sanedatadir)/xsane/xsane-calibration.pnm...
+ rm -f $(sanedatadir)/xsane/xsane-calibration.pnm
+ echo uninstalling $(sanedatadir)/xsane/xsane-logo.xpm...
+ rm -f $(sanedatadir)/xsane/xsane-logo.xpm
+ @for logo in *-logo.xpm; do \
+ echo uninstalling $(sanedatadir)/xsane/$${logo}; \
+ rm -f $(sanedatadir)/xsane/$${logo}; \
+ done
+
+xsane: $(XSANE_OBJS) $(LIBLIB)
+ $(LINK) $(XSANE_OBJS) \
+ $(LIBLIB) $(LIBS) $(SANE_LIBS)
+
+
+clean:
+ rm -f *.o *~ .*~ *.bak
+ rm -rf .libs
+
+distclean: clean
+ rm -f Makefile $(PROGRAMS)
+
+depend:
+ makedepend $(INCLUDES) *.c
+
+.PHONY: all install depend clean distclean
+
+xsane.o: xsane.h
+xsane.o: xsane-back-gtk.h
+xsane.o: xsane-front-gtk.h
+xsane.o: xsane-preview.h
+xsane.o: xsane-save.h
+xsane.o: xsane-gamma.h
+xsane.o: xsane-setup.h
+xsane.o: xsane-scan.h
+xsane.o: xsane-rc-io.h
+xsane.o: xsane-device-preferences.h
+xsane.o: xsane-preferences.h
+xsane.o: xsane-icons.h
+xsane.o: xsane-batch-scan.h
+
+xsane-back-gtk.o: xsane.h
+xsane-back-gtk.o: xsane-back-gtk.h
+xsane-back-gtk.o: xsane-front-gtk.h
+xsane-back-gtk.o: xsane-preferences.h
+xsane-back-gtk.o: xsane-gamma.h
+
+xsane-front-gtk.o: xsane.h
+xsane-front-gtk.o: xsane-back-gtk.h
+xsane-front-gtk.o: xsane-preferences.h
+xsane-front-gtk.o: xsane-preview.h
+xsane-front-gtk.o: xsane-save.h
+xsane-front-gtk.o: xsane-gamma.h
+xsane-front-gtk.o: xsane-setup.h
+
+xsane-batch-scan.o: xsane.h
+xsane-batch-scan.o: xsane-scan.h
+xsane-batch-scan.o: xsane-batch-scan.h
+xsane-batch-scan.o: xsane-back-gtk.h
+xsane-batch-scan.o: xsane-front-gtk.h
+xsane-batch-scan.o: xsane-rc-io.h
+xsane-batch-scan.o: xsane-preview.h
+xsane-batch-scan.o: xsane-gamma.h
+
+xsane-preview.o: xsane.h
+xsane-preview.o: xsane-back-gtk.h
+xsane-preview.o: xsane-front-gtk.h
+xsane-preview.o: xsane-batch-scan.h
+xsane-preview.o: xsane-preview.h
+xsane-preview.o: xsane-preferences.h
+xsane-preview.o: xsane-gamma.h
+
+xsane-preferecnes.o: xsane.h
+xsane-preferecnes.o: xsane-preferences.h
+xsane-preferecnes.o: xsane-rc-io.h
+
+xsane-device-preferences.o: xsane.h
+xsane-device-preferences.o: xsane-rc-io.h
+xsane-device-preferences.o: xsane-back-gtk.h
+xsane-device-preferences.o: xsane-front-gtk.h
+xsane-device-preferences.o: xsane-gamma.h
+
+xsane-rc-io.o: xsane.h
+xsane-rc-io.o: xsane-rc-io.h
+
+xsane-save.o: xsane.h
+xsane-save.o: xsane-back-gtk.h
+xsane-save.o: xsane-front-gtk.h
+
+xsane-scan.o: xsane.h
+xsane-scan.o: xsane-back-gtk.h
+xsane-scan.o: xsane-front-gtk.h
+xsane-scan.o: xsane-preferences.h
+xsane-scan.o: xsane-preview.h
+xsane-scan.o: xsane-viewer.h
+xsane-scan.o: xsane-save.h
+xsane-scan.o: xsane-gamma.h
+xsane-scan.o: xsane-setup.h
+
+xsane-gamma.o: xsane.h
+xsane-gamma.o: xsane-back-gtk.h
+xsane-gamma.o: xsane-front-gtk.h
+xsane-gamma.o: xsane-preferences.h
+xsane-gamma.o: xsane-preview.h
+xsane-gamma.o: xsane-save.h
+
+xsane-setup.o: xsane.h
+xsane-setup.o: xsane-back-gtk.h
+xsane-setup.o: xsane-front-gtk.h
+xsane-setup.o: xsane-preferences.h
+xsane-setup.o: xsane-device-preferences.h
+xsane-setup.o: xsane-preview.h
+xsane-setup.o: xsane-save.h
+xsane-setup.o: xsane-gamma.h
+xsane-setup.o: xsane-batch-scan.h
+
+xsane-viewer.o: xsane.h
+xsane-viewer.o: xsane-back-gtk.h
+xsane-viewer.o: xsane-front-gtk.h
+xsane-viewer.o: xsane-preferences.h
+xsane-viewer.o: xsane-viewer.h
+xsane-viewer.o: xsane-gamma.h
+xsane-viewer.o: xsane-icons.h
+xsane-viewer.o: xsane-save.h
+
+
+
+
diff --git a/src/Plustek-logo.xpm b/src/Plustek-logo.xpm
index 21b0897..6b3f8a0 100644
--- a/src/Plustek-logo.xpm
+++ b/src/Plustek-logo.xpm
@@ -1,75 +1,198 @@
/* XPM */
-static char * plustek_logo_2_xpm[] = {
-"256 48 24 1",
-" c None",
-". c #3A4A52",
-"+ c #3E4E56",
-"@ c #3E4E52",
-"# c #42525A",
-"$ c #46565E",
-"% c #3E4A52",
-"& c #46525A",
-"* c #4A5A62",
-"= c #46565A",
-"- c #723A42",
-"; c #6A2A32",
-"> c #6A2A36",
-", c #6E363E",
-"' c #6E323E",
-") c #6E323A",
-"! c #723642",
-"~ c #6A2E36",
-"{ c #72363E",
-"] c #4A565E",
-"^ c #424E56",
-"/ c #4A5A5E",
-"( c #425256",
-"_ c #763A42",
-" ",
-" . +@ ",
-" ... #... ",
-" .@.@. $....% ",
-" ......+ &..@@..@ ",
-" .@.@@%..%% ..+@...@@. ",
-" .......@@.@# %@...@.....@ ",
-" .@..@........* +............. ",
-" *...@@....%@.%. #%%@.@...@@..@. ",
-" +....@.@.@@@@%%.....@@...@# ",
-" =@.@.......@.@.@...@.. - ",
-" #.........@....... ;;;;;;;;;;;;;;;;;>>;> ;;;;;;;;; ;;;;;;;;> ",
-" =@....@...@.@... ;;;;;;;;;;;;;;;>;;;;;>, ;;;;;;;;, ' ;;;;;;;;; ",
-" @.@@@@.......@@.$ >>>>>>>>>>>>>;;;;;;>>;;) >>>>>>>; !;>;; >>>>>>>;; ",
-"%@$ #.......@.@.@...@@.@= #% ;;;;;;;;;;~~~>;;;>;;;;;;{ ;;;;;;;; ~;;>;>;; ;;;;;;>>; ",
-"...%# @%.+.......@.........@%.# @+.. ;;;;;;;;; ~>;;;;;;;> ;;;;;;>; ;;;;;;;; ;;;;;;;;; ",
-"@.....] ^.+..@....@...@.@.......%.../ +..%@@ ;;;;;;;>> ;;;>>;>;; ;;;;;;;; >;;>;>>> ;;;;;;;;> ",
-".@@%%@.@ #@@..@..@@@@..@ .@@..@.@.%%@.. ^....@.. >>>>>>>;; ;>>;;>;;; ~>>>>>;>> );;;;;;;;;;;;;;;;;>;>;;;;;;;;;;;; ,;;>>;;;) ;>>>>;;>; ~;;;;;;;; ",
-"...@.@.@.@* &.............@ $@@...@....@@@@* &@.@.....@ ;;;;;;;;~ ;;;;;;;;; ;;;;;;;;; ;;;;;;;;; ;;;;;;;; );;;;;;;;;;;;;;;;;;;;;;>;>;;;;;;;;;; );>>>;;>;;>>>>~ ;;;;>>;;; ~;;;;;;;; ",
-"..@........%^ /@.@@..@..@....$ #@..@@......@.( /@.@...@@.... -;;;;;;;>- ;;;;;;>>> ;;;;;>;;> >>>>>>>>- ;>>>>>>> ;>;>>;>>>>>>>>>>>>>>>;;;;;;;;;;;>>>;~ ~;;;;;;;;;;;;;;;;;> ;;;;;;;;; ~;>>>>>>~ ",
-"..........@...@ ..@.....@..@.. +...@.......@.. /..@..@....@@.@ -;;;;;>;> ;>>;>;;;> ;;;;;;;;; ;;;;;;;; ;;;;;;;; ;;;;>;;;;;~~~~~~~~~~>>;;>;>>;>>~~~~~ ;;;;;;;> ;;;;;;;> ;;;;;;>>; ;>;;;;;;~ ",
-"@..@.@.@.@..@...+@%.....@@..@../ @@....@.@...@.@@..@.......@.... ,>>>>>;;; ->>;;>;;;> >>>>;>>;; ;;;;;;;; ;;;;;;;; ;>;;;;;;; -;;;;;>;; ;;;>>;;> >>;;;;;; >>>;;>;;> ~;;;;;;;~ ",
-".@.@.@.@..@.@.....@@.........# @@@...............@.@.....@.@ ~;;;;;>;> >>>;;;;;;;;;~ ;;;;;;;;; ;;;;;;>; ;;;;;;>; ;;;;;;;;; ;>;;;;;; ~;>;;>>; ;>>>>;;; ;;>>;;;;> ,;;;;;;;; ",
-"@............@@..@...@@..@.@ ..@.@.@..@.@@..@...@@...... ~>;;;;;;; ~;;;;;;;;>>' ;;;>;;>>> >>>>>>;; >>>>>>;> ;>>;>>>>; ~;;;;;;;; >>;;;;;~ ;;;;;;;>, ;;;;;;;;; ,>;;>>>>; ",
-" #......@.....@....@..... $.@..@.....@..@....@@.@./ ;;;;>;>;> >>;>>;>~, ;;;;;;;; ;;;;;;>> ;;;;;;;> ,;;;;;;>>; >;>>;>;;; ;;;;;;;;>-- -;;;;>>;;; ;;;;>>;;> ~;>>;;;;> ",
-" +.@.@..@....@......@@( ...@..@..@.......@...] ;>>>;;;>; ~;>,, >>;>>;;; ;;;;;;;; ,;;;;;;;; ;;;;>;;>;) >>;;>;;;; >;;>>;;;;;>;;;;;;;;;;;;;;> >;;>;;>;; ~;;;;;;;; ",
-" @..@.@.....@@....... (...........@.@.....$ ;;;;>;;;~ ;;;;;;;; >;;;>;;> >;;;;>;;~ ~;;;;;;>;; ;;;;;>;>> ;>;;>>;;>;>;;;;;>>>>;;;;;' >>;;;;>;; ;;;;;;;>, ",
-" ....@@..@...@@...@.% &.@.@..@.@@..@...@@.@ ;;;;;;;;> ;>;;>>>> ;>>>;;;; ;>>>>;;;~ ;;;;>;;;;_ ;;;;;;>;; >;;;;;>;, ;;;;;;;;> ,;>>>>;;> ",
-" @..@....@........%.@ =@..@%.@.....@..@...+ ;;>;>;>;, ;;;;;;;> ;;;;>>;> ;;;;;>;;, ~>;;;;;>>! >>;>;;;;; ;;;;;;>;- ;;>>;;>;; ~;;;>;;;~ ",
-" =.@......@+ @+@.@.@ ....@.. &.@..@....@ >>;;;>;; ;>>;;;>; ;;;;;;;;, ;;;;;;;>; ;;;>>;;;; ;;>;;;;;> ;>>;;;;;~ ;>;;>;;;> ~;;;;;;;; ",
-" $@@.... ..@...%.+ ......... $....@. ;;>;;;;; >;;;;;;;; ;;>;;>;>;, >>;;;>;;;> ;>;;>;;;> ;;;>;>>;> ;;>>;;>;; ;;;;>;;;; ;;>>>>;; ",
-" #.@ ....@..@@.= +..@@@..@.. +.@ ;;;;;;>> ;;;>>>;>; >>;;;;>;;>;;;;;>>>;;;>; ) >;;;;;;;; ;;;;>;;;; ;;;>;;>>; ;;;;;;>;; ,;;;;;;>; ",
-" ....@@...@.@/ ^.@....@..@@@ >;>;>;;; >;;;;;;;; ;;>>;;;;;;;;;;;;;;>;;;; >>;>>;;~;;;;;>>>;; ;>;;;;;;;;;;>> ;;;>;;;>;;; -~;; >>;;>;;;> ;;;;>;;;) ",
-" @.@.....@.....& (%...@....@.... ;;;>;;;; ;>;;;>;>> ;;;;;;;>;>;>;;~;;;;>;;> ;;;;;;;;;;>>;;;;>' ~;;;;;>;;>;>;; ~;;;;;;;;>;;;>>;>;;;> ;;>;;;>>; ;;;;;;;;- ",
-" @........@..%.%%...@%............ -~;;;;;>; ;;;;;;;;> ;;>;>;;;>;>~ ;>;;;>;; );;;>;;;>;;>;;;~ ~;>>;>>;>;;>, ;;;;>>;;;>;;;;;>>;, ;;>;;;;;> ,>;;>;;>; ",
-" ..@..@@....@.@@.@...@..@@@..@...@ ,>;;;>>;> ;>>>;>;;; >;>;;>;;; >;;;>;;> >>>;>>>;;;;;~ ~;;;;;;;;;; >;;;;;;;;;;;>;;; ;;;;>;;;; ;;>;>;;;; ",
-" ..@@...@.@.@..@..@..@....@..@@@.@ ,~;;, -,~,, ,,~,,, '~;>>>;~ ",
-" /.....@.........@....@....@..... ",
-" (...@.........@...........$ ",
-" #...@.@@.@...@..@@@..+ ",
-" (.@..@..@..@....@.* ",
-" .....@....@...$ ",
-" ....@.....+ ",
-" $+.@.+ ",
-" + ",
-" ",
-" ",
-" "};
+static char * plustek_logo_3_xpm[] = {
+"256 48 147 2",
+" c None",
+". c #969EA2",
+"+ c #929A9E",
+"@ c #6E7A82",
+"# c #8A969A",
+"$ c #3A4A52",
+"% c #525E66",
+"& c #7A868A",
+"* c #3E4E56",
+"= c #3E4E52",
+"- c #5A666E",
+"; c #AEB6BA",
+"> c #42525A",
+", c #869296",
+"' c #5A666A",
+") c #828E92",
+"! c #6A7A7E",
+"~ c #46565E",
+"{ c #3E4A52",
+"] c #4E5E62",
+"^ c #626E72",
+"/ c #46525A",
+"( c #768286",
+"_ c #B2B6BA",
+": c #5A6A6E",
+"< c #868E92",
+"[ c #AAB2B2",
+"} c #66767A",
+"| c #4A5A62",
+"1 c #7E868A",
+"2 c #A2AAAE",
+"3 c #6A767E",
+"4 c #AEB6B6",
+"5 c #4E5A62",
+"6 c #5E6E72",
+"7 c #6A767A",
+"8 c #9AA2A6",
+"9 c #626E76",
+"0 c #9EA6AA",
+"a c #46565A",
+"b c #BA9EA2",
+"c c #763E46",
+"d c #8A5A62",
+"e c #8E6266",
+"f c #AA868E",
+"g c #CAB6B6",
+"h c #763A46",
+"i c #723A42",
+"j c #966A72",
+"k c #526266",
+"l c #828A92",
+"m c #AE8E92",
+"n c #6A2A32",
+"o c #6A2A36",
+"p c #824E52",
+"q c #9E767A",
+"r c #CAB2B6",
+"s c #8E5E66",
+"t c #5E6A6E",
+"u c #6E363E",
+"v c #A6828A",
+"w c #8E626A",
+"x c #AA828A",
+"y c #966E72",
+"z c #8A5E62",
+"A c #7E4A52",
+"B c #6E323E",
+"C c #9E7A7E",
+"D c #56666A",
+"E c #6E7A7E",
+"F c #8A9296",
+"G c #AAB2B6",
+"H c #6E323A",
+"I c #B69A9E",
+"J c #824E56",
+"K c #92666E",
+"L c #7A464A",
+"M c #723642",
+"N c #9E767E",
+"O c #7E8A8E",
+"P c #5E6A72",
+"Q c #6A2E36",
+"R c #72363E",
+"S c #86525A",
+"T c #A27E82",
+"U c #A68286",
+"V c #AA8A8E",
+"W c #9A727A",
+"X c #4A565E",
+"Y c #424E56",
+"Z c #4A5A5E",
+"` c #A6AEB2",
+" . c #76424A",
+".. c #C2AAAE",
+"+. c #B6969A",
+"@. c #B2969A",
+"#. c #B6969E",
+"$. c #C6AAAE",
+"%. c #A67E86",
+"&. c #AA868A",
+"*. c #BAA2A6",
+"=. c #969EA6",
+"-. c #4E5E66",
+";. c #7E868E",
+">. c #667276",
+",. c #86565E",
+"'. c #C6B2B6",
+"). c #7A424A",
+"!. c #C6AEB2",
+"~. c #86565A",
+"{. c #AE8A8E",
+"]. c #8A565E",
+"^. c #BEA2A6",
+"/. c #A27A7E",
+"(. c #BEA6AA",
+"_. c #B29296",
+":. c #BA9A9E",
+"<. c #66727A",
+"[. c #425256",
+"}. c #966A6E",
+"|. c #8E5E62",
+"1. c #A6868A",
+"2. c #727E82",
+"3. c #627276",
+"4. c #7A464E",
+"5. c #92666A",
+"6. c #BEA6A6",
+"7. c #B2929A",
+"8. c #CAB6BA",
+"9. c #A2A6AA",
+"0. c #727E86",
+"a. c #C2A6AA",
+"b. c #767E86",
+"c. c #763A42",
+"d. c #9A7276",
+"e. c #8E969A",
+"f. c #CEB6BA",
+"g. c #9A6E76",
+"h. c #8A5A5E",
+"i. c #A27A82",
+"j. c #C6B2B2",
+"k. c #7A828A",
+"l. c #9E727A",
+"m. c #B28E92",
+"n. c #9EA2A6",
+"o. c #C6AEAE",
+"p. c #92626A",
+" . + @ ",
+" # $ % . & * = ",
+" # $ $ $ - + ; & > $ $ $ ",
+" , $ = $ = $ ' ) ! ~ $ $ $ $ { ",
+" # $ $ $ $ $ $ * ] & ^ / $ $ = = $ $ = ",
+" , $ = $ = = { $ $ { { ( _ : $ $ * = $ $ $ = = $ ",
+" , $ $ $ $ $ $ $ = = $ = > < [ } { = $ $ $ = $ $ $ $ $ = ",
+" # $ = $ $ = $ $ $ $ $ $ $ $ | 1 2 3 * $ $ $ $ $ $ $ $ $ $ $ $ $ ",
+" 4 | $ $ $ = = $ $ $ $ { = $ { $ 5 6 > { { = $ = $ $ $ = = $ $ = $ 7 ",
+" 8 ] * $ $ $ $ = $ = $ = = = = { { $ $ $ $ $ = = $ $ $ = > 9 ",
+" 0 6 a = $ = $ $ $ $ $ $ $ = $ = $ = $ $ $ = $ $ ] ( b c c c c c c c c c c c c c c c c c d e f g f c c c c c c c c h c c c c c c c c i j ",
+" 0 3 > $ $ $ $ $ $ $ $ $ = $ $ $ $ $ $ $ k l m n n n n n n n n n n n n n n n n n o o n o p b q n n n n n n n n n r n n n n n n n n o s ",
+" 2 a = $ $ $ $ = $ $ $ = $ = $ $ $ t m n n n n n n n n n n n n n n n o n n n n n o u v w n n n n n n n n u b x y z A B n n n n n n n n n C ",
+"D , E = $ = = = = $ $ $ $ $ $ $ = = $ ~ F 7 G m o o o o o o o o o o o o o n n n n n n o o n n H I J o o o o o o o n A K A L M n o n n c o o o o o o o n n N ",
+"{ = ~ O 6 > $ $ $ $ $ $ $ = $ = $ = $ $ $ = = $ = a , P > { 0 y n n n n n n n n n n Q Q Q o n n n o n n n n n n R A n n n n n n n n S Q n n o n o n n A n n n n n n o o n T ",
+"$ $ $ { > ) } = { $ * $ $ $ $ $ $ $ = $ $ $ $ $ $ $ $ $ = { $ > , ; 6 = * $ $ 0 w n n n n n n n n n z U m V W J Q o n n n n n n n o b A n n n n n n o n q n n n n n n n n A n n n n n n n n n I ",
+"= $ $ $ $ $ X < G E Y $ * $ $ = $ $ $ $ = $ $ $ = $ = $ $ $ $ $ $ $ { $ $ $ Z F ` E * $ $ { = = 0 w n n n n n n n o o y n n n o o n o n n y .n n n n n n n n C ..I +.+.+.+.+.+.+.+.+.+.+.+.+.+.@.#.C o n n o n o o o c @.+.+.+.#. $.I V T T %.&.#... n n n n n n n n o *. I +.+.+.+.+.+.+.+.#. ",
+"$ = = { { = $ = ] 1 2 ! > = = $ $ = $ $ = = = = $ $ = ! =.-.$ = = $ $ = $ = $ { { = $ $ % ;. 0 >.Y $ $ $ $ = $ $ 0 w o o o o o o o n n n o o n n o n n n ,. Q o o o o o n o o @. '.).).).).).).).).). !.).).).).).).).).~. {.d .H n n n n n n n n n n n n n n n n n o n o n n n n n n n n n n n n +.K A u n n o o n n n H c ].C n o o o o n n o n ^. /.Q n n n n n n n n T ",
+"$ $ $ = $ = $ = $ = | E 2 t / $ $ $ $ $ $ $ $ $ $ $ $ $ = : . ~ = = $ $ $ = $ $ $ $ = = = = | ( 8 - / = $ = $ $ $ $ $ = 0 ,.n n n n n n n n Q n n n n n n n n n z n n n n n n n n n b (.n n n n n n n n n _.n n n n n n n n d w H n n n n n n n n n n n n n n n n n n n n n n o n o n n n n n n n n n n :.A H n o o o n n o n n o o o o Q .q n n n n o o n n n *. v Q n n n n n n n n W ",
+"$ $ = $ $ $ $ $ $ $ $ { Y 9 0 Z = $ = = $ $ = $ $ = $ $ $ $ ~ <. 8 k > = $ $ = = $ $ $ $ $ $ = $ [.<. 8 Z = $ = $ $ $ = = $ $ $ $ 0 i n n n n n n n o i [ n n n n n n o o o V n n n n n o n n o (.o o o o o o o o i V n o o o o o o o }. _.n o n o o n o o o o o o o o o o o o o o o n n n n n n n n n n n o o o n Q |.Q n n n n n n n n n n n n n n n n n o J n n n n n n n n n 1.Q n o o o o o o Q q ",
+"$ $ $ $ $ $ $ $ $ $ = $ $ $ = <. 0 k $ $ = $ $ $ $ $ = $ $ = $ $ ] 2. 8 3.* $ $ $ = $ $ $ $ $ $ $ = $ $ 2. + Z $ $ = $ $ = $ $ $ $ = = $ = 0 i n n n n n o n o z ).n o o n o n n n o n n n n n n n n n (.n n n n n n n n 4. m n n n n n n n n V J n n n n o n n n n n Q Q Q Q Q Q Q Q Q Q o o n n o n o o n o o Q Q Q Q Q . d n n n n n n n o A 5.y w A n n n n n n n o s n n n n n n o o n m n o n n n n n n Q N ",
+"= $ $ = $ = $ = $ = $ $ = $ $ $ * = { $ $ $ $ $ = = $ $ = $ $ Z O 2 } = = $ $ $ $ = $ = $ $ $ = $ = = $ $ = $ $ $ $ $ $ $ = $ $ $ $ 0 u o o o o o n n n y @.+.V y i o o n n o n n n o ~. o o o o n o o n n 6.n n n n n n n n w T n n n n n n n n I .n o n n n n n n n z 1.@.m @.m @.m @.m _._.+ i n n n n n o n n w _._._._.b W n n n o o n n o q A o o n n n n n n '. o o o n n o n n o 7.Q n n n n n n n Q N ",
+"$ = $ = $ = $ = $ $ = $ = $ $ $ $ $ = = $ $ $ $ $ $ $ $ $ > O ` 9 = = = $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ = $ = $ $ $ $ $ = $ = 0 Q n n n n n o n o 1. }.o o o n n n n n n n n n Q 8.n n n n n n n n n V n n n n n n o n y K n n n n n n o n '. ,.n n n n n n n n n @. p n o n n n n n n 9. Q n o n n o o n ,. b n o o o o n n n K n n o o n n n n o b u n n n n n n n n W ",
+"= $ $ $ $ $ $ $ $ $ $ $ $ = = $ $ = $ $ $ = = $ $ = $ = ( G k $ $ = $ = $ = $ $ = $ = = $ $ = $ $ $ = = $ $ $ $ $ $ 0 Q o n n n n n n n ^. Q n n n n n n n n o o B '. 9.n n n o n n o o o C o o o o o o n n &. z o o o o o o n o *.n o o n o o o o n L Q n n n n n n n n d o o n n n n n Q '. n n n n n n n o u n n n n n n n n n !.u o n n o o o o n }. ",
+"k > $ $ $ $ $ $ = $ $ $ $ $ = $ $ $ $ = $ $ $ $ $ ] ;. 6 ~ $ = $ $ = $ $ $ $ $ = $ $ = $ $ $ $ = = $ = $ Z G n n n n o n o n o 8. K o o n o o n o Q u z b n n n n n n n n . T n n n n n n o o I c n n n n n n n o U u n n n n n n o o n e o n o o n o n n n n n n n n n n n o i i c c c c h i n n n n o o n n n n n n n o o n n o v Q n o o n n n n o K ",
+" + 6 * $ = $ = $ $ = $ $ $ $ = $ $ $ $ $ $ = = [.8 ! $ $ $ = $ $ = $ $ = $ $ $ $ $ $ $ = $ $ $ X 0.; n o o o n n n o n Q n o u u 4.,.C C o o n o o n n n 4. C n n n n n n n n a. u n n n n n n n n F .n n n n o n n o n H N o o n n o n n n n 6.o n n o o n n n n n o n n n n n n n n n n n n n n o o n n o n n o n n q Q n n n n n n n n m ",
+" 0 9 = $ $ = $ = $ $ $ $ $ = = $ $ $ $ $ $ $ D # [ b.[.$ $ $ $ $ $ $ $ $ $ $ = $ = $ $ $ $ $ ~ O n n n n o n n n Q b @.@.` .. C n n n n n n n n z T o n n n o n n o o n n n n o n n Q y Q n n n n n n o n n A 6. n n n n n o n o o 1.n o n n o o n n o n o n n n n n o o o o n n n n n B o o n n n n o n n K n n n n n n n o u ",
+" ` : $ $ $ $ = = $ $ = $ $ $ = = $ $ $ = $ { k ;. G 7 / $ = $ = $ $ = $ = = $ $ = $ $ $ = = $ = & n n n n n n n n o ' n o n n o o o o y C n o o o n n n n r (.n o o o o n n n Q 2 ~.n n n n o n n n n c.:. ` n n n n n n o n n y o n n n n n o n u K 5.K K K K w w w 5.w w w w K 5.C n n n n n n n n o u n o o o o n n o ,. ",
+" ` -.= $ $ = $ $ $ $ = $ $ $ $ $ $ $ $ { $ = 5 ( [ t a = $ $ = { $ = $ $ $ $ $ = $ $ = $ $ $ * 0. !.n n o n o n o n u S n n n n n n n o d. d n n n n o o n o V ~.n n n n n o n n u 1.Q o n n n n n o o M ^.o o n o n n n n n j n n n n n n o n i n n o o n n o n n ..Q n n n o n n n Q f ",
+" G >.a $ = $ $ $ $ $ $ = * -.( } = * = $ = $ = E ` k $ $ $ $ = $ $ 0 9 / $ = $ $ = $ $ $ $ = % & e.o o n n n o n n ,. .n o o n n n o n 7. ~.n n n n n n n n u y n n n n n n n o n ,. [ n n n o o n n n n y . n n o n n n n n o . n o o n n n n n Q n o n n o n n n o b.Q n n n n n n n n f. ",
+" G @ ~ = = $ $ $ $ k ) , $ $ = $ $ $ { $ * & 2 t $ $ $ $ $ $ $ $ $ ` ! ~ $ $ $ $ = $ D , {.n n o n n n n n ,. o n n n n n n n n I ,.n n o n n o n o n u j g.A o o n n n o n n n o h. r n o n n o n n n o A i.n n n o n o o n o b $.n n o o n n o n n J n n n n o n n n n ~.n n o o o o n n 4. ",
+" ( > $ = ] # F $ $ $ $ = $ $ = = $ a b._ 8 3.* $ $ = = = $ $ = $ $ 0.* $ = k + y n n n n n n o o y n n n o o o n o n I J o o n n n n o n n o n n n n n o o o n n n o n K j.H 4.s W T T U W J o n n n n n n n n ). k.n n n n o n n n n c q U C j 1. .n n n o n n o o n A 1.r a.m i.w f 2 n n n n n n o n n u n n n n n n o n l. ",
+" ( e. , $ $ $ $ = = $ $ $ = $ = Z ! ; e.: Y $ = $ $ $ $ = $ $ = = = @ 8 j o n o n o n n n T o n n n n n n n n y n n o o n n n n n n n n n n n n n n o n n n n T o o n o o n n Q n n n n n o o o n n j m.n o n n n n n n n n n n o o m n.n n n o n n n o n n n c A J J J A L i Q n n I *.o o n n o n n n o m n n n n o n n n H o. ",
+" # = $ = $ $ $ $ $ = $ $ $ $ $ / - ) 5 [.{ $ $ $ = $ $ $ $ = $ $ $ $ .n n n o n n n n U n o n n n o n o o n.n n n n n n n o n o n o n n Q n n n n o n n o U n n n n n n n n n n o o n n n n o B Q n n n n n o n n o n o n n 7 Q n n n n n n n n o n n n o o n o n n n o n.n n o n n n o o n ,.n n n n n n n n i ",
+" , = $ $ $ $ $ $ $ $ = $ $ { $ { { $ $ $ = { $ $ $ $ $ $ $ $ $ $ $ $ i Q n n n n n o n U ..n n n n n n n n o A n n o n o n n n o n o Q ~.t n o n n n o n n U H n n n o n n n o n n o n n n Q .(. z Q n o o n o o n o n n o u U .n n n n o o n n n o n n n n n o o n u U n n o n n n n n o u o n n o n n o n d ",
+" F $ $ = $ $ = = $ $ $ $ = $ = = $ = $ $ $ = $ $ = = = $ $ = $ $ $ = u o n n n o o n o T e.n o o o n o n n n A o n o n n o n n n .1. e.o n n n o n n o U 4.o o o n o o o n n n n n Q .W - Q n n n n n n n n n n ~. G y .o n n n n n n n n n n n o n n n ,. b.n n n n o n n n n e.n n o n o n n n n V ",
+" F $ $ = = $ $ $ = $ = $ = $ $ = $ $ = $ $ = $ $ $ $ = $ $ = = = $ = z w t w w w w z K b *.w w w t 5.z w K K e.,.u Q n n u ~.1 $.w z w w w w w K !. 8.@.C w J i u Q u u .J y n. 6.y J u u Q u u u A w .. @.C ,. .B Q n o o o n Q c A e W !. I w w ^ z w w w K K d.w w w w K w K p.g. ",
+" Z $ $ $ $ $ = $ $ $ $ $ $ $ $ $ = $ $ $ $ = $ $ $ $ = $ $ $ $ $ } 8. 8. ",
+" 0 k [.$ $ $ = $ $ $ $ $ $ $ $ $ = $ $ $ $ $ $ $ $ $ $ $ ~ ! ",
+" 0 3.> $ $ $ = $ = = $ = $ $ $ = $ $ = = = $ $ * ] ( ",
+" 2 ! [.$ = $ $ = $ $ = $ $ = $ $ $ $ = $ | ) ",
+" 4 7 $ $ $ $ $ = $ $ $ $ = $ $ $ ~ F ",
+" 6 $ $ $ $ = $ $ $ $ $ * l ",
+" } ~ * $ = $ * ] , ",
+" 0.5 * P # ",
+" 0 ",
+" ",
+" "};
diff --git a/src/cursor/cursor_autoraise_scanarea.xbm b/src/cursor/cursor_autoraise_scanarea.xbm
new file mode 100644
index 0000000..d5895f7
--- /dev/null
+++ b/src/cursor/cursor_autoraise_scanarea.xbm
@@ -0,0 +1,7 @@
+/* Erzeugt mit Gimp */
+#define cursor_autoraise_scanare_width 16
+#define cursor_autoraise_scanare_height 16
+static unsigned char cursor_autoraise_scanare_bits[] = {
+ 0xaa, 0x2a, 0xc1, 0x41, 0xe0, 0x03, 0x81, 0x40, 0x80, 0x00, 0x85, 0x50,
+ 0x86, 0x30, 0x7f, 0x7f, 0x86, 0x30, 0x85, 0x50, 0x80, 0x00, 0x81, 0x40,
+ 0xe0, 0x03, 0xc1, 0x41, 0xaa, 0x2a, 0x00, 0x00 };
diff --git a/src/cursor/cursor_autoraise_scanarea_mask.xbm b/src/cursor/cursor_autoraise_scanarea_mask.xbm
new file mode 100644
index 0000000..e4adeda
--- /dev/null
+++ b/src/cursor/cursor_autoraise_scanarea_mask.xbm
@@ -0,0 +1,7 @@
+/* Erzeugt mit Gimp */
+#define cursor_autoraise_scanare_width 16
+#define cursor_autoraise_scanare_height 16
+static unsigned char cursor_autoraise_scanare_bits[] = {
+ 0xea, 0x2b, 0xe1, 0x43, 0xf0, 0x07, 0xc1, 0x41, 0xc4, 0x11, 0xc7, 0x71,
+ 0xff, 0x7f, 0x7f, 0x7f, 0xff, 0x7f, 0xc7, 0x71, 0xc4, 0x11, 0xc1, 0x41,
+ 0xf0, 0x07, 0xe1, 0x43, 0xea, 0x2b, 0x00, 0x00 };
diff --git a/src/cursor/cursor_zoom_select.xbm b/src/cursor/cursor_zoom_select.xbm
new file mode 100644
index 0000000..4c88a36
--- /dev/null
+++ b/src/cursor/cursor_zoom_select.xbm
@@ -0,0 +1,7 @@
+/* Erzeugt mit Gimp */
+#define cursor_zoom_select_width 16
+#define cursor_zoom_select_height 16
+static unsigned char cursor_zoom_select_bits[] = {
+ 0x00, 0x00, 0xf0, 0x01, 0x08, 0x02, 0x44, 0x04, 0x42, 0x08, 0x42, 0x08,
+ 0xba, 0x0b, 0x42, 0x08, 0x42, 0x08, 0x44, 0x04, 0x08, 0x06, 0xf0, 0x0f,
+ 0x00, 0x1c, 0x00, 0x38, 0x00, 0x70, 0x00, 0xe0 };
diff --git a/src/cursor/cursor_zoom_select_mask.xbm b/src/cursor/cursor_zoom_select_mask.xbm
new file mode 100644
index 0000000..81f1b9c
--- /dev/null
+++ b/src/cursor/cursor_zoom_select_mask.xbm
@@ -0,0 +1,7 @@
+/* Erzeugt mit Gimp */
+#define cursor_zoom_select_mask_width 16
+#define cursor_zoom_select_mask_height 16
+static unsigned char cursor_zoom_select_mask_bits[] = {
+ 0xf0, 0x01, 0xf8, 0x03, 0x0c, 0x06, 0x46, 0x0c, 0x53, 0x19, 0xe3, 0x18,
+ 0xbb, 0x1b, 0xe3, 0x18, 0x53, 0x19, 0x46, 0x0c, 0x0c, 0x0e, 0xf8, 0x1f,
+ 0xf0, 0x3f, 0x00, 0x7c, 0x00, 0xf8, 0x00, 0xf0 };
diff --git a/src/xsane-16x16.png b/src/xsane-16x16.png
new file mode 100644
index 0000000..2341807
--- /dev/null
+++ b/src/xsane-16x16.png
Binary files differ
diff --git a/src/xsane-16x16.xpm b/src/xsane-16x16.xpm
new file mode 100644
index 0000000..14c2f13
--- /dev/null
+++ b/src/xsane-16x16.xpm
@@ -0,0 +1,88 @@
+/* XPM */
+static char * xsane_16x16_xpm[] = {
+"16 16 69 1",
+" c None",
+". c #CECAB6",
+"+ c #DED6B2",
+"@ c #B6AA82",
+"# c #D2CAA2",
+"$ c #CABE96",
+"% c #AEA67E",
+"& c #C2B68E",
+"* c #CEC29A",
+"= c #C6BA92",
+"- c #BAAE86",
+"; c #CEC69E",
+"> c #CAC29A",
+", c #B2A67E",
+"' c #BEB28A",
+") c #968E6A",
+"! c #E2D6B2",
+"~ c #B2AA86",
+"{ c #AEA27E",
+"] c #867A5E",
+"^ c #2E2A1E",
+"/ c #221E16",
+"( c #322E22",
+"_ c #665E46",
+": c #AAA27E",
+"< c #A29672",
+"[ c #625E46",
+"} c #020206",
+"| c #D6CEA6",
+"1 c #E2DAB6",
+"2 c #8A8262",
+"3 c #A69A76",
+"4 c #9E9272",
+"5 c #BEB68E",
+"6 c #C6BE96",
+"7 c #A69E7A",
+"8 c #1A1A12",
+"9 c #1E1A16",
+"0 c #EAE2C2",
+"a c #867E5E",
+"b c #4E4A36",
+"c c #3E3A2A",
+"d c #7E765A",
+"e c #8E8666",
+"f c #524A3A",
+"g c #222EFA",
+"h c #423E2E",
+"i c #726A52",
+"j c #2632FA",
+"k c #A6BAFE",
+"l c #1E22FA",
+"m c #D6CAA6",
+"n c #566AFE",
+"o c #FAFAF6",
+"p c #5E72FE",
+"q c #F2EED6",
+"r c #EAE6C6",
+"s c #26261E",
+"t c #465AFE",
+"u c #161EFA",
+"v c #DAD2AE",
+"w c #AA9E7A",
+"x c #AEA682",
+"y c #DACEAA",
+"z c #C2BA92",
+"A c #524E3A",
+"B c #9E9672",
+"C c #9A8E6E",
+"D c #222216",
+" ",
+" .+@#$%#&%* ",
+" =-;@->,';@'>) ",
+" !~&'{]^/(_:='<[",
+" $:$} |-:&",
+" 1,@- 23$@4",
+" 5=67 {8",
+" -$9 0=|= ; ",
+" abc(bd: ;e ",
+" fg7 $h",
+" ijklm ,@",
+" 0 }nopq ==",
+" rs ;tnub v$e",
+" |wx 2=8 y-$x ",
+" 36&'>$z;='=2 ",
+" A4B&=:CD "};
diff --git a/src/xsane-32x32.png b/src/xsane-32x32.png
new file mode 100644
index 0000000..8cfaff5
--- /dev/null
+++ b/src/xsane-32x32.png
Binary files differ
diff --git a/src/xsane-48x48.png b/src/xsane-48x48.png
new file mode 100644
index 0000000..febbd0b
--- /dev/null
+++ b/src/xsane-48x48.png
Binary files differ
diff --git a/src/xsane-WIN32.txt b/src/xsane-WIN32.txt
index e7476dc..5e5a79f 100644
--- a/src/xsane-WIN32.txt
+++ b/src/xsane-WIN32.txt
@@ -1,9 +1,7 @@
README for xsane for win32:
-This is an early Version of xsane for win32.
-It may have several bugs. It is not tested very well
-but short tests looked very good.
+This is a win32 of xsane. It may have some bugs.
This version supports:
- preview scan, preview zoom
@@ -11,19 +9,19 @@ This version supports:
- handling of all backend options
- helpfiles
- copy mode (printing via ghostscript, see section "copy mode")
- - gimp-plugin
+ - gimp-plugin (if compiled in)
It does not support:
- fax mode (no compatible faxsoftware)
- - internationalization not set up correct
Installation:
=============
- unpack the archiv to c:\
that creates the directory c:\Sane with several files
- you do not need to copy any files, simply call xsane or scanimage
+ you do not need to copy any files, simply call c:\sane\bin\xsane or
+ c:\sane\bin\scanimage
- Sane MUST BE installed in c:\sane because the paths are hardcoded.
Xsane will not work correct if you install it at any other place!
@@ -31,10 +29,10 @@ Installation:
- make sure you have a directory c:\temp (or whatever you
define as temporary directory in xsane's setup)
- - there are two icons (xsane-32x32.ico and xsane-48x48.ico)
- that you can use if you set a link from xsane.exe to your desktop,
- for that use right mouse button and change properties of the link,
- change icon and select "c:\sane\xsane-??x??.ico"
+ - there are three icons (xsane.ico, xsane-32x32.ico and xsane-48x48.ico)
+ in c:\sane\bin that you can use if you set a link from xsane.exe to
+ your desktop, for that use right mouse button and change properties
+ of the link, change icon and select "c:\sane\bin\xsane-??x??.ico"
Configuration:
@@ -45,38 +43,49 @@ Configuration:
system IP-addresses are not accepted; if you experience
any problems try the NetBUI names.
-example for net.conf:
-myhost1
-myhost2.mydomain.com
-192.168.0.1
-192.169.1.73
+ example for net.conf:
+ myhost1
+ myhost2.mydomain.com
+ 192.168.0.1
+ 192.169.1.73
- you also can start xsane with host:backend:device given as command line option:
- xsane 192.168.0.1:umax:/dev/scanner
-or
- xsane myhost:umax:/dev/scanner
+ you also can start xsane with net:host:backend:device given as command line option:
+ xsane net:192.168.0.1:umax:/dev/scanner
+ or
+ xsane net:myhost:umax:/dev/scanner
+
+
+Localisation:
+=============
+ You have to set the environment variable LANG to the language
+ you want to select, for e.g. german this looks like this:
+ set LANG=de
+ xsane
+ It is a good idea to do this in a script that is started at system boot,
+ e.g. in autoexec.bat
Copy-Mode:
===========
-If you want to use copy mode, you need ghostscript for win32.
-You can download it e.g. from http://www.cs.wisc.edu/~ghost/
-Enter Setup/Copy options:
-enter as Command:
+ If you want to use copy mode, you need ghostscript for win32.
+ You can download it e.g. from http://www.cs.wisc.edu/~ghost/
+ Enter Setup/Copy options:
+ enter as Command:
c:/gs/gs6.50/bin/gswin32c -sDEVICE=mswinpr2 -dNOPAUSE -
-Pay attention: you have to use "/", don´t use "\".
-With sDEVICE=mswinpr2 you select the Printer Dialog of Windows.
+ Pay attention: you have to use "/", don´t use "\".
+ With sDEVICE=mswinpr2 you select the Printer Dialog of Windows.
-You also can enter DEVICE-name of your printer (e.g. laserjet).
-To get a list of available device names open a dos box,
-and call c:\gs\gs6.50\bin\gswin32c -h
+ You also can enter DEVICE-name of your printer (e.g. laserjet).
+ To get a list of available device names open a dos box,
+ and call c:\gs\gs6.50\bin\gswin32c -h
Gimp-Plugin:
===========
-If you want to use xsane as gimp plugin,
-copy xsane.exe and *.dll to the GIMP´s plug-ins driectory
-(e.g. c:\Program Files\GIMP\plug-ins)
+ (Does only work when xsane.exe is compiled as gimp plugin)
+ If you want to use xsane as gimp plugin,
+ copy xsane.exe and *.dll to the GIMP´s plug-ins driectory
+ (e.g. c:\Program Files\GIMP\plug-ins)
Support:
@@ -100,24 +109,26 @@ Licence:
* The sourcecode of xsane can be found at http://www.xsane.org
- * The sourcecode of sane can be found at http://www.mostang.com/sane
+ * The sourcecode of sane can be found at http://www.sane-project.org
* For any information about cygwin take a look at http://cygwin.com
* For any information about gtk/gdk for win32 take a look at
- http://user.sgic.fi/~tml/gimp/win32/
+ http://www.gtk.org or http://www.gimp.org/win32/
Compile it yourself:
====================
- * In xsane.WIN32-compilation I wrote down what I did to create xsane.exe
+ * There is an instruction in the file xsane.WIN32-compilation
Contact:
========
You can contact me via email: Oliver.Rauch@rauch-domain.de
- but don`t ask for help/support for xsane-win32, I do not have the
- time to give support to it and want to use my free time to
- work on the code - please understand that.
+ bugreports, bugfixes and feature requests (that are not
+ already listed) are welcome. Please don`t ask for help/support
+ for xsane-win32, I do not have the time to give support for it,
+ I want to use my free time to work on the code - please understand
+ that.
Oliver Rauch
diff --git a/src/xsane-back-gtk.c b/src/xsane-back-gtk.c
index bced94d..0aa382e 100644
--- a/src/xsane-back-gtk.c
+++ b/src/xsane-back-gtk.c
@@ -3,7 +3,7 @@
xsane-back-gtk.c
Oliver Rauch <Oliver.Rauch@rauch-domain.de>
- Copyright (C) 1998-2002 Oliver Rauch
+ Copyright (C) 1998-2005 Oliver Rauch
This file is part of the XSANE package.
This program is free software; you can redistribute it and/or modify
@@ -172,6 +172,22 @@ SANE_Status xsane_control_option(SANE_Handle handle, SANE_Int option, SANE_Actio
{
SANE_Status status;
+#if 1
+ /* I am not sure about a correct and intelligent way to handle an option that has not defined SANE_CAP_SOFT_DETECT */
+ /* the test backend creates an option without SANE_CAP_SOFT_DETECT that causes an error message when I do not do the following */
+ if (action == SANE_ACTION_GET_VALUE)
+ {
+ const SANE_Option_Descriptor *opt;
+
+ opt = xsane_get_option_descriptor(xsane.dev, option);
+ if ((opt) && (!(opt->cap & SANE_CAP_SOFT_DETECT)))
+ {
+ DBG(DBG_warning, "WARNING: xsane_control_option(option = %d, action = %d): SANE_CAP_SOFT_DETECT is not set\n", option, action);
+ return SANE_STATUS_GOOD;
+ }
+ }
+#endif
+
status = sane_control_option(handle, option, action, val, info);
if (status)
{
@@ -207,7 +223,7 @@ const char *xsane_back_gtk_unit_string(SANE_Unit unit)
return "in";
}
return "mm";
- case SANE_UNIT_MICROSECOND: return "\265s";
+ case SANE_UNIT_MICROSECOND: return "\302\265s"; /* UTF8 µs */
}
return 0;
}
@@ -236,13 +252,13 @@ int xsane_back_gtk_make_path(size_t buf_size, char *buf, const char *prog_name,
if (location == XSANE_PATH_LOCAL_SANE) /* make path to local file */
{
- if (getenv(STRINGIFY(ENVIRONMENT_HOME_DIR_NAME)) != NULL)
+ if (getenv(STRINGIFY(ENVIRONMENT_APPDATA_DIR_NAME)) != NULL)
{
- snprintf(buf, buf_size-2, "%s%c.sane", getenv(STRINGIFY(ENVIRONMENT_HOME_DIR_NAME)), SLASH);
+ snprintf(buf, buf_size-2, "%s%c.sane", getenv(STRINGIFY(ENVIRONMENT_APPDATA_DIR_NAME)), SLASH);
}
else
{
- snprintf(buf, buf_size-2, "%s", STRINGIFY(XSANE_FIXED_HOME_PATH));
+ snprintf(buf, buf_size-2, "%s", STRINGIFY(XSANE_FIXED_APPDATA_DIR));
}
mkdir(buf, 0777); /* ensure ~/.sane directory exists */
}
@@ -317,7 +333,7 @@ int xsane_back_gtk_make_path(size_t buf_size, char *buf, const char *prog_name,
if (dev_name)
{
- /* Turn devicename into valid filename by replacing slashes by "_", "_" gets "__", spaces are erased */
+ /* Turn devicename into valid filename by replacing slashes and other forbidden characters by "_", "_" gets "__", spaces are erased */
for (i = 0; dev_name[i]; ++i)
{
@@ -384,7 +400,7 @@ int xsane_back_gtk_make_path(size_t buf_size, char *buf, const char *prog_name,
int fd;
uid = getuid();
- snprintf(tmpbuf, sizeof(tmpbuf), "-%d-", uid);
+ snprintf(tmpbuf, sizeof(tmpbuf), "-%d-", (int) uid);
extra = strlen(tmpbuf);
if (len + extra >= buf_size)
@@ -473,6 +489,10 @@ void xsane_back_gtk_set_option(int opt_num, void *val, SANE_Action action)
update_gamma = TRUE; /* scanner gamma correction may have changed, medium may need update */
}
+ else if (info & SANE_INFO_INEXACT)
+ {
+ /* XXXXXXXXXXXXXX this also has to be handled XXXXXXXXXXXXXXX */
+ }
if (xsane.xsane_colors != old_colors)
{
@@ -489,60 +509,190 @@ void xsane_back_gtk_set_option(int opt_num, void *val, SANE_Action action)
/* ----------------------------------------------------------------------------------------------------------------- */
-void xsane_back_gtk_close_dialog_callback(GtkWidget * widget, gpointer data)
+int xsane_back_gtk_get_option_double(int option, double *val, SANE_Int *unit)
+/* return values: */
+/* 0 = OK */
+/* -1 = option number < 0 */
+/* -2 = failed to set option */
{
- DBG(DBG_proc, "xsane_back_gtk_close_dialog_callback\n");
+ const SANE_Option_Descriptor *opt;
+ SANE_Handle dev;
+ SANE_Word word;
+
+ DBG(DBG_proc, "xsane_back_gtk_get_option_double\n");
+
+ if (option <= 0)
+ {
+ return -1;
+ }
+
+ if (xsane_control_option(xsane.dev, option, SANE_ACTION_GET_VALUE, &word, 0) == SANE_STATUS_GOOD)
+ {
+ dev = xsane.dev;
+ opt = xsane_get_option_descriptor(dev, option);
+
+ if (unit)
+ {
+ *unit = opt->unit;
+ }
+
+ if (val)
+ {
+ if (opt->type == SANE_TYPE_FIXED)
+ {
+ *val = (float) word / 65536.0;
+ }
+ else
+ {
+ *val = (float) word;
+ }
+ }
- gtk_widget_destroy(data);
- xsane.back_gtk_message_dialog_active = 0;
+ return 0;
+ }
+ else if (val)
+ {
+ *val = 0;
+ }
+ return -2;
}
/* ----------------------------------------------------------------------------------------------------------------- */
-static gint decision_flag;
-static GtkWidget *decision_dialog;
+int xsane_back_gtk_set_option_double(int option, double value)
+{
+ const SANE_Option_Descriptor *opt;
+ SANE_Word word;
+
+ DBG(DBG_proc, "xsane_set_option_double\n");
+
+ if (option <= 0 || value <= -INF || value >= INF)
+ {
+ return -1;
+ }
+
+ opt = xsane_get_option_descriptor(xsane.dev, option);
+ if (opt)
+ {
+ if (opt->type == SANE_TYPE_FIXED)
+ {
+ word = SANE_FIX(value);
+ }
+ else
+ {
+ word = value + 0.5;
+ }
-void xsane_back_gtk_decision_callback(GtkWidget * widget, gpointer data)
+ if (xsane_control_option(xsane.dev, option, SANE_ACTION_SET_VALUE, &word, 0))
+ {
+ return -2;
+ }
+ }
+ else
+ {
+ return -1;
+ }
+
+ return 0;
+}
+
+/* ----------------------------------------------------------------------------------------------------------------- */
+
+static int xsane_back_gtk_decision_delete_event(GtkWidget * widget, GdkEvent *event, gpointer data)
+{
+ gint *decision_flag = (gint *) data;
+
+ DBG(DBG_proc, "xsane_back_gtk_decision_delete_event\n");
+
+ xsane.back_gtk_message_dialog_active--;
+
+ if (decision_flag)
+ {
+ *decision_flag = -1;
+ }
+
+ return FALSE; /* continue with original delete even routine */
+}
+
+/* ----------------------------------------------------------------------------------------------------------------- */
+
+static void xsane_back_gtk_decision_ok_callback(GtkWidget *widget, gpointer data)
{
- DBG(DBG_proc, "xsane_back_gtk_decision_callback\n");
+ gint *decision_flag = (gint *) data;
+
+ DBG(DBG_proc, "xsane_back_gtk_decision_ok_callback\n");
+
+ gtk_widget_destroy(widget->parent->parent->parent->parent);
+ xsane.back_gtk_message_dialog_active--;
- gtk_widget_destroy(decision_dialog);
- xsane.back_gtk_message_dialog_active = 0;
- decision_flag = (long) data;
+ if (decision_flag)
+ {
+ *decision_flag = 1;
+ }
+}
+
+/* ----------------------------------------------------------------------------------------------------------------- */
+
+static void xsane_back_gtk_decision_reject_callback(GtkWidget *widget, gpointer data)
+{
+ gint *decision_flag = (gint *) data;
+
+ DBG(DBG_proc, "xsane_back_gtk_decision_reject_callback\n");
+
+ gtk_widget_destroy(widget->parent->parent->parent->parent);
+ xsane.back_gtk_message_dialog_active--;
+
+ if (decision_flag)
+ {
+ *decision_flag = -1;
+ }
}
/* ----------------------------------------------------------------------------------------------------------------- */
gint xsane_back_gtk_decision(gchar *title, gchar **xpm_d, gchar *message, gchar *oktext, gchar *rejecttext, int wait)
{
- GtkWidget *main_vbox, *hbox, *label, *button;
+ GtkWidget *main_vbox, *hbox, *label, *button, *frame;
GdkPixmap *pixmap;
GdkBitmap *mask;
GtkWidget *pixmapwidget;
+ GtkWidget *decision_dialog;
+ GtkAccelGroup *accelerator_group;
+ gint decision_flag;
+ gint *decision_flag_ptr = NULL;
DBG(DBG_proc, "xsane_back_gtk_decision\n");
- if (xsane.back_gtk_message_dialog_active)
+ if (wait)
{
- DBG(DBG_error0, "%s: %s\n", title, message);
- return TRUE;
+ decision_flag_ptr = &decision_flag;
}
- xsane.back_gtk_message_dialog_active = 1;
- decision_dialog = gtk_window_new(GTK_WINDOW_DIALOG);
+
+ xsane.back_gtk_message_dialog_active++;
+ decision_dialog = gtk_window_new(GTK_WINDOW_TOPLEVEL);
gtk_window_set_position(GTK_WINDOW(decision_dialog), GTK_WIN_POS_MOUSE);
gtk_window_set_title(GTK_WINDOW(decision_dialog), title);
- gtk_signal_connect(GTK_OBJECT(decision_dialog), "delete_event",
- GTK_SIGNAL_FUNC(xsane_back_gtk_decision_callback), (void *) -1); /* -1 = cancel */
+ g_signal_connect(GTK_OBJECT(decision_dialog), "delete_event", GTK_SIGNAL_FUNC(xsane_back_gtk_decision_delete_event), (void *) decision_flag_ptr);
xsane_set_window_icon(decision_dialog, 0);
+ accelerator_group = gtk_accel_group_new();
+ gtk_window_add_accel_group(GTK_WINDOW(decision_dialog), accelerator_group);
+
+ /* create a frame */
+ frame = gtk_frame_new(NULL);
+ gtk_container_set_border_width(GTK_CONTAINER(frame), 10);
+ gtk_frame_set_shadow_type(GTK_FRAME(frame), GTK_SHADOW_ETCHED_IN);
+ gtk_container_add(GTK_CONTAINER(decision_dialog), frame);
+ gtk_widget_show(frame);
+
/* create the main vbox */
- main_vbox = gtk_vbox_new(TRUE, 5);
+ main_vbox = gtk_vbox_new(FALSE, 5);
gtk_container_set_border_width(GTK_CONTAINER(main_vbox), 5);
gtk_widget_show(main_vbox);
+ gtk_container_add(GTK_CONTAINER(frame), main_vbox);
- gtk_container_add(GTK_CONTAINER(decision_dialog), main_vbox);
-
+ /* create a horizontal box to put the icon and the text insode */
hbox = gtk_hbox_new(FALSE, 2);
gtk_container_set_border_width(GTK_CONTAINER(hbox), 4);
gtk_box_pack_start(GTK_BOX(main_vbox), hbox, FALSE, FALSE, 0);
@@ -551,10 +701,10 @@ gint xsane_back_gtk_decision(gchar *title, gchar **xpm_d, gchar *message, gchar
if (xpm_d)
{
pixmap = gdk_pixmap_create_from_xpm_d(decision_dialog->window, &mask, xsane.bg_trans, xpm_d);
- pixmapwidget = gtk_pixmap_new(pixmap, mask);
+ pixmapwidget = gtk_image_new_from_pixmap(pixmap, mask);
gtk_box_pack_start(GTK_BOX(hbox), pixmapwidget, FALSE, FALSE, 10);
gtk_widget_show(pixmapwidget);
- gdk_pixmap_unref(pixmap);
+ gdk_drawable_unref(pixmap);
}
/* the message */
@@ -572,7 +722,7 @@ gint xsane_back_gtk_decision(gchar *title, gchar **xpm_d, gchar *message, gchar
/* the confirmation button */
button = gtk_button_new_with_label(oktext);
GTK_WIDGET_SET_FLAGS(button, GTK_CAN_DEFAULT);
- gtk_signal_connect(GTK_OBJECT(button), "clicked", (GtkSignalFunc) xsane_back_gtk_decision_callback, (void *) 1 /* confirm */);
+ g_signal_connect(GTK_OBJECT(button), "clicked", (GtkSignalFunc) xsane_back_gtk_decision_ok_callback, (void *) decision_flag_ptr);
gtk_box_pack_start(GTK_BOX(hbox), button, TRUE, TRUE, 5);
gtk_widget_grab_default(button);
gtk_widget_show(button);
@@ -581,14 +731,19 @@ gint xsane_back_gtk_decision(gchar *title, gchar **xpm_d, gchar *message, gchar
if (rejecttext) /* the rejection button */
{
button = gtk_button_new_with_label(rejecttext);
- gtk_signal_connect(GTK_OBJECT(button), "clicked", (GtkSignalFunc) xsane_back_gtk_decision_callback, (void *) -1 /* reject */);
+ g_signal_connect(GTK_OBJECT(button), "clicked", (GtkSignalFunc) xsane_back_gtk_decision_reject_callback, (void *) decision_flag_ptr);
gtk_box_pack_start(GTK_BOX(hbox), button, TRUE, TRUE, 5);
gtk_widget_show(button);
}
- gtk_widget_show(hbox);
+ /* if rejectbutton is available then the following command is valid for the reject button */
+ /* otherwise it is valid for the ok button */
+ gtk_widget_add_accelerator(button, "clicked", accelerator_group, GDK_Escape, 0, DEF_GTK_ACCEL_LOCKED);
+
+ gtk_widget_show(hbox);
gtk_widget_show(decision_dialog);
+
while (gtk_events_pending())
{
gtk_main_iteration();
@@ -621,11 +776,26 @@ gint xsane_back_gtk_decision(gchar *title, gchar **xpm_d, gchar *message, gchar
/* ----------------------------------------------------------------------------------------------------------------- */
+void xsane_back_gtk_ipc_dialog_callback(gpointer data, gint source, GdkInputCondition cond)
+{
+ char message[256];
+ size_t bytes;
+
+ DBG(DBG_proc, "xsane_back_gtk_message\n");
+
+ bytes = read(xsane.ipc_pipefd[0], message, 255);
+ message[bytes] = 0;
+
+ xsane_back_gtk_decision(ERR_HEADER_CHILD_PROCESS_ERROR, (gchar **) error_xpm, message, BUTTON_CLOSE, 0 /* no reject text */, FALSE);
+}
+
+/* ----------------------------------------------------------------------------------------------------------------- */
+
void xsane_back_gtk_message(gchar *title, gchar **icon_xpm, gchar *message, int wait)
{
DBG(DBG_proc, "xsane_back_gtk_message\n");
- xsane_back_gtk_decision(title, icon_xpm, message, BUTTON_OK, 0 /* no reject text */, wait);
+ xsane_back_gtk_decision(title, icon_xpm, message, BUTTON_CLOSE, 0 /* no reject text */, wait);
}
/* ----------------------------------------------------------------------------------------------------------------- */
@@ -688,6 +858,231 @@ void xsane_back_gtk_info(gchar *info, int wait)
}
}
+/* ---------------------------------------------------------------------------------------------------------------------- */
+
+GtkWidget *fileselection;
+char *fileselection_filetype = NULL;
+
+static void xsane_back_gtk_filetype_callback(GtkWidget *widget, gpointer data)
+{
+ char *extension, *filename;
+ char buffer[256];
+ char *new_filetype = (char *) data;
+
+ DBG(DBG_proc, "xsane_filetype_callback\n");
+
+ filename = strdup(gtk_file_selection_get_filename(GTK_FILE_SELECTION(fileselection)));
+
+ if ((new_filetype) && (*new_filetype))
+ {
+ extension = strrchr(filename, '.');
+
+ if ((extension) && (extension != filename))
+ {
+ if ( (!strcasecmp(extension, ".pnm")) || (!strcasecmp(extension, ".raw"))
+ || (!strcasecmp(extension, ".png")) || (!strcasecmp(extension, ".ps"))
+ || (!strcasecmp(extension, ".rgba"))
+ || (!strcasecmp(extension, ".tiff")) || (!strcasecmp(extension, ".tif"))
+ || (!strcasecmp(extension, ".text")) || (!strcasecmp(extension, ".txt"))
+ || (!strcasecmp(extension, ".jpg")) || (!strcasecmp(extension, ".jpeg"))
+ ) /* remove filetype extension */
+ {
+ *extension = 0; /* remove extension */
+ }
+ }
+ snprintf(buffer, sizeof(buffer), "%s%s", filename, new_filetype);
+ free(filename);
+ filename = strdup(buffer);
+ }
+
+ if (fileselection_filetype)
+ {
+ free(fileselection_filetype);
+ fileselection_filetype = NULL;
+ }
+
+ if (data)
+ {
+ fileselection_filetype = strdup(new_filetype);
+ }
+
+ gtk_file_selection_set_filename(GTK_FILE_SELECTION(fileselection), filename);
+
+ free(filename);
+}
+
+/* ---------------------------------------------------------------------------------------------------------------------- */
+
+void xsane_back_gtk_filetype_menu_set_history(GtkWidget *xsane_filetype_option_menu, char *filetype)
+{
+ int filetype_nr;
+ int select_item;
+
+ filetype_nr = 0;
+ select_item = 0;
+
+#ifdef HAVE_LIBJPEG
+ filetype_nr++;
+ if ( (filetype) && (!strcasecmp(filetype, XSANE_FILETYPE_JPEG)) )
+ {
+ select_item = filetype_nr;
+ }
+#endif
+
+#ifdef HAVE_LIBPNG
+#ifdef HAVE_LIBZ
+ filetype_nr++;
+ if ( (filetype) && (!strcasecmp(filetype, XSANE_FILETYPE_PNG)) )
+ {
+ select_item = filetype_nr;
+ }
+#endif
+#endif
+
+ filetype_nr++;
+ if ( (filetype) && (!strcasecmp(filetype, XSANE_FILETYPE_PNM)) )
+ {
+ select_item = filetype_nr;
+ }
+
+ filetype_nr++;
+ if ( (filetype) && (!strcasecmp(filetype, XSANE_FILETYPE_PS)) )
+ {
+ select_item = filetype_nr;
+ }
+
+#ifdef SUPPORT_RGBA
+ filetype_nr++;
+ if ( (filetype) && (!strcasecmp(filetype, XSANE_FILETYPE_RGBA)) )
+ {
+ select_item = filetype_nr;
+ }
+#endif
+
+ filetype_nr++;
+ if ( (filetype) && (!strcasecmp(filetype, XSANE_FILETYPE_TEXT)) )
+ {
+ select_item = filetype_nr;
+ }
+
+#ifdef HAVE_LIBTIFF
+ filetype_nr++;
+ if ( (filetype) && (!strcasecmp(filetype, XSANE_FILETYPE_TIFF)) )
+ {
+ select_item = filetype_nr;
+ }
+#endif
+
+ gtk_option_menu_set_history(GTK_OPTION_MENU(xsane_filetype_option_menu), select_item);
+}
+
+/* ---------------------------------------------------------------------------------------------------------------------- */
+
+GtkWidget *xsane_back_gtk_filetype_menu_new(char *filetype, GtkSignalFunc filetype_callback)
+{
+ GtkWidget *xsane_filetype_menu, *xsane_filetype_item;
+ GtkWidget *xsane_filetype_option_menu;
+ int filetype_nr;
+ int select_item;
+
+ xsane_filetype_menu = gtk_menu_new();
+
+ xsane_filetype_item = gtk_menu_item_new_with_label(MENU_ITEM_FILETYPE_BY_EXT);
+ gtk_container_add(GTK_CONTAINER(xsane_filetype_menu), xsane_filetype_item);
+ g_signal_connect(GTK_OBJECT(xsane_filetype_item), "activate", filetype_callback, (void *) XSANE_FILETYPE_BY_EXT);
+ gtk_widget_show(xsane_filetype_item);
+
+ filetype_nr = 0;
+ select_item = 0;
+
+#ifdef HAVE_LIBJPEG
+ xsane_filetype_item = gtk_menu_item_new_with_label(MENU_ITEM_FILETYPE_JPEG);
+ gtk_container_add(GTK_CONTAINER(xsane_filetype_menu), xsane_filetype_item);
+ g_signal_connect(GTK_OBJECT(xsane_filetype_item), "activate", filetype_callback, (void *) XSANE_FILETYPE_JPEG);
+ gtk_widget_show(xsane_filetype_item);
+ filetype_nr++;
+ if ( (filetype) && (!strcasecmp(filetype, XSANE_FILETYPE_JPEG)) )
+ {
+ select_item = filetype_nr;
+ }
+#endif
+
+#ifdef HAVE_LIBPNG
+#ifdef HAVE_LIBZ
+ xsane_filetype_item = gtk_menu_item_new_with_label(MENU_ITEM_FILETYPE_PNG);
+ gtk_container_add(GTK_CONTAINER(xsane_filetype_menu), xsane_filetype_item);
+ g_signal_connect(GTK_OBJECT(xsane_filetype_item), "activate", filetype_callback, (void *) XSANE_FILETYPE_PNG);
+ gtk_widget_show(xsane_filetype_item);
+ filetype_nr++;
+ if ( (filetype) && (!strcasecmp(filetype, XSANE_FILETYPE_PNG)) )
+ {
+ select_item = filetype_nr;
+ }
+#endif
+#endif
+
+ xsane_filetype_item = gtk_menu_item_new_with_label(MENU_ITEM_FILETYPE_PNM);
+ gtk_container_add(GTK_CONTAINER(xsane_filetype_menu), xsane_filetype_item);
+ g_signal_connect(GTK_OBJECT(xsane_filetype_item), "activate", filetype_callback, (void *) XSANE_FILETYPE_PNM);
+ gtk_widget_show(xsane_filetype_item);
+ filetype_nr++;
+ if ( (filetype) && (!strcasecmp(filetype, XSANE_FILETYPE_PNM)) )
+ {
+ select_item = filetype_nr;
+ }
+
+ xsane_filetype_item = gtk_menu_item_new_with_label(MENU_ITEM_FILETYPE_PS);
+ gtk_container_add(GTK_CONTAINER(xsane_filetype_menu), xsane_filetype_item);
+ g_signal_connect(GTK_OBJECT(xsane_filetype_item), "activate", filetype_callback, (void *) XSANE_FILETYPE_PS);
+ gtk_widget_show(xsane_filetype_item);
+ filetype_nr++;
+ if ( (filetype) && (!strcasecmp(filetype, XSANE_FILETYPE_PS)) )
+ {
+ select_item = filetype_nr;
+ }
+
+#ifdef SUPPORT_RGBA
+ xsane_filetype_item = gtk_menu_item_new_with_label(MENU_ITEM_FILETYPE_RGBA);
+ gtk_container_add(GTK_CONTAINER(xsane_filetype_menu), xsane_filetype_item);
+ g_signal_connect(GTK_OBJECT(xsane_filetype_item), "activate", filetype_callback, (void *) XSANE_FILETYPE_RGBA);
+ gtk_widget_show(xsane_filetype_item);
+ filetype_nr++;
+ if ( (filetype) && (!strcasecmp(filetype, XSANE_FILETYPE_RGBA)) )
+ {
+ select_item = filetype_nr;
+ }
+#endif
+
+ xsane_filetype_item = gtk_menu_item_new_with_label(MENU_ITEM_FILETYPE_TEXT);
+ gtk_container_add(GTK_CONTAINER(xsane_filetype_menu), xsane_filetype_item);
+ g_signal_connect(GTK_OBJECT(xsane_filetype_item), "activate", filetype_callback, (void *) XSANE_FILETYPE_TEXT);
+ gtk_widget_show(xsane_filetype_item);
+ filetype_nr++;
+ if ( (filetype) && (!strcasecmp(filetype, XSANE_FILETYPE_TEXT)) )
+ {
+ select_item = filetype_nr;
+ }
+
+#ifdef HAVE_LIBTIFF
+ xsane_filetype_item = gtk_menu_item_new_with_label(MENU_ITEM_FILETYPE_TIFF);
+ gtk_container_add(GTK_CONTAINER(xsane_filetype_menu), xsane_filetype_item);
+ g_signal_connect(GTK_OBJECT(xsane_filetype_item), "activate", filetype_callback, (void *) XSANE_FILETYPE_TIFF);
+ gtk_widget_show(xsane_filetype_item);
+ filetype_nr++;
+ if ( (filetype) && (!strcasecmp(filetype, XSANE_FILETYPE_TIFF)) )
+ {
+ select_item = filetype_nr;
+ }
+#endif
+
+ xsane_filetype_option_menu = gtk_option_menu_new();
+ xsane_back_gtk_set_tooltip(xsane.tooltips, xsane_filetype_option_menu, DESC_FILETYPE);
+ gtk_option_menu_set_menu(GTK_OPTION_MENU(xsane_filetype_option_menu), xsane_filetype_menu);
+ gtk_option_menu_set_history(GTK_OPTION_MENU(xsane_filetype_option_menu), select_item);
+
+ return (xsane_filetype_option_menu);
+}
+
/* ----------------------------------------------------------------------------------------------------------------- */
static void xsane_back_gtk_get_filename_button_clicked(GtkWidget *w, gpointer data)
@@ -700,41 +1095,56 @@ static void xsane_back_gtk_get_filename_button_clicked(GtkWidget *w, gpointer da
/* ----------------------------------------------------------------------------------------------------------------- */
-int xsane_back_gtk_get_filename(const char *label, const char *default_name, size_t max_len, char *filename,
- int show_fileopts, int shorten_path, int hide_file_list)
+int xsane_back_gtk_get_filename(const char *label, const char *default_name, size_t max_len, char *filename, char **filetype,
+ int show_fileopts, int shorten_path, int select_directory, int show_filetype_menu)
{
int cancel = 0, ok = 0, destroy = 0;
- GtkWidget *fileselection;
GtkAccelGroup *accelerator_group;
+ GtkWidget *xsane_filetype_option_menu;
DBG(DBG_proc, "xsane_back_gtk_get_filename\n");
+ if (fileselection)
+ {
+ gdk_beep();
+ return -1; /* cancel => do not allow to open more than one fileselection dialog */
+ }
fileselection = gtk_file_selection_new((char *) label);
accelerator_group = gtk_accel_group_new();
- gtk_accel_group_attach(accelerator_group, GTK_OBJECT(fileselection));
+ gtk_window_add_accel_group(GTK_WINDOW(fileselection), accelerator_group);
- gtk_signal_connect(GTK_OBJECT(fileselection),
- "destroy", GTK_SIGNAL_FUNC(xsane_back_gtk_get_filename_button_clicked), &destroy);
+ g_signal_connect(GTK_OBJECT(fileselection), "destroy", GTK_SIGNAL_FUNC(xsane_back_gtk_get_filename_button_clicked), &destroy);
- gtk_signal_connect(GTK_OBJECT(GTK_FILE_SELECTION(fileselection)->cancel_button),
- "clicked", (GtkSignalFunc) xsane_back_gtk_get_filename_button_clicked, &cancel);
+ g_signal_connect(GTK_OBJECT(GTK_FILE_SELECTION(fileselection)->cancel_button), "clicked", (GtkSignalFunc) xsane_back_gtk_get_filename_button_clicked, &cancel);
gtk_widget_add_accelerator(GTK_FILE_SELECTION(fileselection)->cancel_button, "clicked",
- accelerator_group, GDK_Escape, 0, GTK_ACCEL_LOCKED);
+ accelerator_group, GDK_Escape, 0, DEF_GTK_ACCEL_LOCKED);
- gtk_signal_connect(GTK_OBJECT(GTK_FILE_SELECTION(fileselection)->ok_button),
- "clicked", (GtkSignalFunc) xsane_back_gtk_get_filename_button_clicked, &ok);
- if (default_name)
- {
- DBG(DBG_info, "xsane_back_gtk_get_filename: default_name =%s\n", default_name);
- gtk_file_selection_set_filename(GTK_FILE_SELECTION(fileselection), (char *) default_name);
- }
+ g_signal_connect(GTK_OBJECT(GTK_FILE_SELECTION(fileselection)->ok_button), "clicked", (GtkSignalFunc) xsane_back_gtk_get_filename_button_clicked, &ok);
- if (hide_file_list)
+ if (select_directory)
{
- DBG(DBG_info, "xsane_back_gtk_get_filename: hiding file-list and delete-file-widget\n");
+ DBG(DBG_info, "xsane_back_gtk_get_filename: select directory\n");
gtk_widget_hide(GTK_FILE_SELECTION(fileselection)->file_list->parent);
gtk_widget_hide(GTK_FILE_SELECTION(fileselection)->fileop_del_file);
+ gtk_widget_hide(GTK_FILE_SELECTION(fileselection)->fileop_ren_file);
+ gtk_widget_hide(GTK_FILE_SELECTION(fileselection)->selection_entry);
+
+ gtk_widget_set_size_request(GTK_FILE_SELECTION(fileselection)->dir_list, 280, 230);
+
+ if (default_name) /* add "/." to end of directory name so that the gtkfilesel* behaves correct */
+ {
+ char directory_name[PATH_MAX];
+
+ snprintf(directory_name, sizeof(directory_name), "%s%c", default_name, SLASH);
+ DBG(DBG_info, "xsane_back_gtk_get_filename: directory_name =%s\n", directory_name);
+ gtk_file_selection_set_filename(GTK_FILE_SELECTION(fileselection), (char *) directory_name);
+ }
+ }
+ else if (default_name) /* select file */
+ {
+ DBG(DBG_info, "xsane_back_gtk_get_filename: default_name =%s\n", default_name);
+ gtk_file_selection_set_filename(GTK_FILE_SELECTION(fileselection), (char *) default_name);
}
if (show_fileopts)
@@ -748,15 +1158,51 @@ int xsane_back_gtk_get_filename(const char *label, const char *default_name, siz
gtk_file_selection_hide_fileop_buttons(GTK_FILE_SELECTION(fileselection));
}
+ if (show_filetype_menu)
+ {
+ GtkWidget *hbox;
+ GtkWidget *vbox;
+ GtkWidget *label;
+
+ DBG(DBG_info, "xsane_back_gtk_get_filename: showing filetype menu\n");
+
+ if (fileselection_filetype)
+ {
+ free(fileselection_filetype);
+ }
+
+ if ((filetype) && (*filetype))
+ {
+ fileselection_filetype = strdup(*filetype);
+ }
+ else
+ {
+ fileselection_filetype = NULL;
+ }
+
+ vbox = gtk_vbox_new(FALSE, 2);
+ gtk_box_pack_start(GTK_BOX(GTK_FILE_SELECTION(fileselection)->action_area), vbox, TRUE, TRUE, 0);
+ gtk_widget_show(vbox);
+
+ hbox = gtk_hbox_new(FALSE, 2);
+ gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
+ gtk_widget_show(hbox);
+
+ label = gtk_label_new(TEXT_FILETYPE);
+ gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);
+ gtk_widget_show(label);
+
+ xsane_filetype_option_menu = xsane_back_gtk_filetype_menu_new(fileselection_filetype, (GtkSignalFunc) xsane_back_gtk_filetype_callback);
+ gtk_box_pack_start(GTK_BOX(hbox), xsane_filetype_option_menu, TRUE, TRUE, 2);
+ gtk_widget_show(xsane_filetype_option_menu);
+ }
+
gtk_widget_show(fileselection);
DBG(DBG_info, "xsane_back_gtk_get_filename: waiting for user action\n");
while (!cancel && !ok && !destroy)
{
- if (gtk_events_pending())
- {
- gtk_main_iteration();
- }
+ gtk_main_iteration();
}
if (ok)
@@ -766,7 +1212,33 @@ int xsane_back_gtk_get_filename(const char *label, const char *default_name, siz
DBG(DBG_info, "ok button pressed\n");
+ if ((filetype) && (*filetype))
+ {
+ free(*filetype);
+ *filetype = NULL;
+ }
+
+ if (fileselection_filetype)
+ {
+ if (filetype)
+ {
+ *filetype = strdup(fileselection_filetype);
+ }
+
+ free(fileselection_filetype);
+ fileselection_filetype = NULL;
+ }
+
strncpy(filename, gtk_file_selection_get_filename(GTK_FILE_SELECTION(fileselection)), max_len - 1);
+
+#ifndef HAVE_GTK2
+ /* in gtk1 we have to remove the text that is defined in the selection entry to get a proper behaviour */
+ if (select_directory)
+ {
+ *(filename+strlen(filename)-strlen(gtk_entry_get_text(GTK_ENTRY(GTK_FILE_SELECTION(fileselection)->selection_entry)))) = '\0';
+ }
+#endif
+
filename[max_len - 1] = '\0';
len = strlen(filename);
@@ -790,12 +1262,14 @@ int xsane_back_gtk_get_filename(const char *label, const char *default_name, siz
gtk_widget_destroy(fileselection);
}
+ fileselection = NULL;
+
return ok ? 0 : -1;
}
/* ----------------------------------------------------------------------------------------------------------------- */
-static gint xsane_back_gtk_autobutton_update(GtkWidget *widget, GSGDialogElement *elem)
+static gint xsane_back_gtk_autobutton_update(GtkWidget *widget, DialogElement *elem)
{
int opt_num = elem - xsane.element;
const SANE_Option_Descriptor *opt;
@@ -809,9 +1283,23 @@ static gint xsane_back_gtk_autobutton_update(GtkWidget *widget, GSGDialogElement
if (GTK_TOGGLE_BUTTON(widget)->active)
{
xsane_back_gtk_set_option(opt_num, 0, SANE_ACTION_SET_AUTO);
+
+ gtk_widget_set_sensitive(elem->widget, FALSE);
+
+ if (elem->widget2)
+ {
+ gtk_widget_set_sensitive(elem->widget2, FALSE);
+ }
}
else
{
+ gtk_widget_set_sensitive(elem->widget, TRUE);
+
+ if (elem->widget2)
+ {
+ gtk_widget_set_sensitive(elem->widget2, TRUE);
+ }
+
status = xsane_control_option(xsane.dev, opt_num, SANE_ACTION_GET_VALUE, &val, 0);
if (status != SANE_STATUS_GOOD)
{
@@ -825,32 +1313,26 @@ static gint xsane_back_gtk_autobutton_update(GtkWidget *widget, GSGDialogElement
/* ----------------------------------------------------------------------------------------------------------------- */
-static void xsane_back_gtk_autobutton_new(GtkWidget *parent, GSGDialogElement *elem,
- GtkWidget *label, GtkTooltips *tooltips)
+static void xsane_back_gtk_autobutton_new(GtkWidget *parent, DialogElement *elem,
+ GtkTooltips *tooltips)
{
- GtkWidget *button, *alignment;
+ GtkWidget *button;
DBG(DBG_proc, "xsane_back_gtk_autobutton_new\n");
button = gtk_check_button_new();
gtk_container_set_border_width(GTK_CONTAINER(button), 0);
- gtk_widget_set_usize(button, 20, 20);
- gtk_signal_connect(GTK_OBJECT(button), "toggled", (GtkSignalFunc) xsane_back_gtk_autobutton_update, elem);
- xsane_back_gtk_set_tooltip(tooltips, button, "Turns on automatic mode.");
-
- alignment = gtk_alignment_new(0.0, 1.0, 0.5, 0.5);
- gtk_container_add(GTK_CONTAINER(alignment), button);
-
- gtk_box_pack_end(GTK_BOX(parent), label, FALSE, FALSE, 0);
- gtk_box_pack_end(GTK_BOX(parent), alignment, FALSE, FALSE, 2);
+ gtk_widget_set_size_request(button, 20, 20);
+ g_signal_connect(GTK_OBJECT(button), "toggled", (GtkSignalFunc) xsane_back_gtk_autobutton_update, elem);
+ xsane_back_gtk_set_tooltip(tooltips, button, DESC_AUTOMATIC);
- gtk_widget_show(alignment);
+ gtk_box_pack_end(GTK_BOX(parent), button, FALSE, FALSE, 2);
gtk_widget_show(button);
}
/* ----------------------------------------------------------------------------------------------------------------- */
-static gint xsane_back_gtk_button_update(GtkWidget * widget, GSGDialogElement * elem)
+static gint xsane_back_gtk_button_update(GtkWidget * widget, DialogElement * elem)
{
int opt_num = elem - xsane.element;
const SANE_Option_Descriptor *opt;
@@ -871,7 +1353,7 @@ static gint xsane_back_gtk_button_update(GtkWidget * widget, GSGDialogElement *
/* ----------------------------------------------------------------------------------------------------------------- */
void xsane_back_gtk_button_new(GtkWidget * parent, const char *name, SANE_Word val,
- GSGDialogElement * elem, GtkTooltips *tooltips, const char *desc, SANE_Int settable)
+ DialogElement * elem, GtkTooltips *tooltips, const char *desc, SANE_Int settable)
{
GtkWidget *button;
@@ -879,34 +1361,35 @@ void xsane_back_gtk_button_new(GtkWidget * parent, const char *name, SANE_Word v
button = gtk_check_button_new_with_label((char *) name);
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button), val);
- gtk_signal_connect(GTK_OBJECT(button), "toggled", (GtkSignalFunc) xsane_back_gtk_button_update, elem);
+ g_signal_connect(GTK_OBJECT(button), "toggled", (GtkSignalFunc) xsane_back_gtk_button_update, elem);
gtk_box_pack_start(GTK_BOX(parent), button, FALSE, TRUE, 0);
gtk_widget_show(button);
xsane_back_gtk_set_tooltip(tooltips, button, desc);
gtk_widget_set_sensitive(button, settable);
- elem->widget = button;
+ elem->widget = button;
}
/* ----------------------------------------------------------------------------------------------------------------- */
-static void xsane_back_gtk_scale_update(GtkAdjustment * adj_data, GSGDialogElement * elem)
+/* called from xsane_back_gtk_value_new and xsane_back_gtk_range_new */
+static void xsane_back_gtk_value_update(GtkAdjustment *adj_data, DialogElement *elem)
{
const SANE_Option_Descriptor *opt;
SANE_Word val, new_val;
int opt_num;
double d;
- DBG(DBG_proc, "xsane_back_gtk_scale_update\n");
+ DBG(DBG_proc, "xsane_back_gtk_value_update\n");
opt_num = elem - xsane.element;
opt = xsane_get_option_descriptor(xsane.dev, opt_num);
switch(opt->type)
{
case SANE_TYPE_INT:
- val = adj_data->value + 0.5;
- break;
+ val = adj_data->value; /* OLD: + 0.5 but this mad problems with negative values */
+ break;
case SANE_TYPE_FIXED:
d = adj_data->value;
@@ -915,109 +1398,249 @@ static void xsane_back_gtk_scale_update(GtkAdjustment * adj_data, GSGDialogEleme
d *= preferences.length_unit;
}
val = SANE_FIX(d);
- break;
+ break;
default:
- DBG(DBG_error, "xsane_back_gtk_scale_update: %s %d\n", ERR_UNKNOWN_TYPE, opt->type);
- return;
+ DBG(DBG_error, "xsane_back_gtk_value_update: %s %d\n", ERR_UNKNOWN_TYPE, opt->type);
+ return;
}
xsane_back_gtk_set_option(opt_num, &val, SANE_ACTION_SET_VALUE);
xsane_control_option(xsane.dev, opt_num, SANE_ACTION_GET_VALUE, &new_val, 0);
+
if (new_val != val)
{
val = new_val;
- goto value_changed;
- }
- return; /* value didn't change */
-
-value_changed:
- switch(opt->type)
+ switch(opt->type)
{
- case SANE_TYPE_INT:
- adj_data->value = val;
- break;
+ case SANE_TYPE_INT:
+ adj_data->value = val;
+ break;
- case SANE_TYPE_FIXED:
- d = SANE_UNFIX(val);
- if (opt->unit == SANE_UNIT_MM)
- {
- d /= preferences.length_unit;
- }
- adj_data->value = d;
- break;
+ case SANE_TYPE_FIXED:
+ d = SANE_UNFIX(val);
+ if (opt->unit == SANE_UNIT_MM)
+ {
+ d /= preferences.length_unit;
+ }
+ adj_data->value = d;
+ break;
- default:
- break;
+ default:
+ break;
}
- /* Let widget know that value changed _again_. This must converge
- quickly---otherwise things would get very slow very quickly (as
- in "infinite recursion"): */
- gtk_signal_emit_by_name(GTK_OBJECT(adj_data), "value_changed");
- return;
+ g_signal_emit_by_name(GTK_OBJECT(adj_data), "value_changed");
+ }
+
+ return; /* value didn't change */
}
/* ----------------------------------------------------------------------------------------------------------------- */
-void xsane_back_gtk_scale_new(GtkWidget * parent, const char *name, gfloat val,
+static void xsane_back_gtk_range_display_value_right_callback(GtkAdjustment *adjust, gpointer data)
+{
+ gchar buf[256];
+ int digits = (int) data;
+ GtkLabel *label;
+
+ snprintf(buf, sizeof(buf), "%1.*f", digits, adjust->value);
+ label = (GtkLabel *) gtk_object_get_data(GTK_OBJECT(adjust), "value-label");
+ gtk_label_set_text(label, buf);
+}
+/* ----------------------------------------------------------------------------------------------------------------- */
+
+void xsane_back_gtk_range_new(GtkWidget *parent, const char *name, gfloat val,
gfloat min, gfloat max, gfloat quant, int automatic,
- GSGDialogElement * elem, GtkTooltips *tooltips, const char *desc, SANE_Int settable)
+ DialogElement *elem, GtkTooltips *tooltips, const char *desc, SANE_Int settable)
{
- GtkWidget *hbox, *label, *scale;
+ GtkWidget *hbox, *label, *slider = NULL, *spinbutton, *value_label;
+ int digits;
- DBG(DBG_proc, "xsane_back_gtk_scale_new(%s)\n", name);
+ DBG(DBG_proc, "xsane_back_gtk_range_new(%s)\n", name);
+
+ if (quant - (int) quant == 0.0)
+ {
+ digits = 0;
+ }
+ else
+ {
+ digits = (int) (log10(1/quant)+0.8); /* set number of digits in dependance of quantization */
+ }
+
+ if (digits < 0)
+ {
+ digits = 0;
+ }
hbox = gtk_hbox_new(FALSE, 2);
- gtk_container_set_border_width(GTK_CONTAINER(hbox), 0);
+ gtk_container_set_border_width(GTK_CONTAINER(hbox), 2);
gtk_box_pack_start(GTK_BOX(parent), hbox, FALSE, FALSE, 0);
label = gtk_label_new((char *) name);
gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 2);
- elem->data = gtk_adjustment_new(val, min, max, quant, quant*10, 0.0);
- scale = gtk_hscale_new(GTK_ADJUSTMENT(elem->data));
- xsane_back_gtk_set_tooltip(tooltips, scale, desc);
- gtk_widget_set_usize(scale, 150, 0);
+ elem->data = gtk_adjustment_new(val, min, max, quant, quant*10, (max-min) * 1e-30);
+ /* 1e-30 => hscrollbar has an unwanted side effect: the maximum is not the maximum */
+ /* of the given range, it is reduced by the page_size, so it has to be very small */
+
+ /* value label */
+ if (preferences.show_range_mode & 8)
+ {
+ value_label = gtk_label_new("");
+ gtk_widget_set_size_request(value_label, 45, -1);
+ gtk_box_pack_end(GTK_BOX(hbox), value_label, FALSE, FALSE, 1);
+
+ g_signal_connect(elem->data, "value_changed", (GtkSignalFunc) xsane_back_gtk_range_display_value_right_callback, (void *) digits);
+ gtk_object_set_data(GTK_OBJECT(elem->data), "value-label", value_label);
+ g_signal_emit_by_name(GTK_OBJECT(elem->data), "value_changed"); /* update value */
+ gtk_widget_show(value_label);
+ gtk_widget_set_sensitive(value_label, settable);
+ }
+
+ /* spinbutton */
+ if (preferences.show_range_mode & 4)
+ {
+#ifndef HAVE_GTK2
+ if (digits > 5)
+ {
+ digits = 5;
+ }
+#endif
+ spinbutton = gtk_spin_button_new(GTK_ADJUSTMENT(elem->data), 0, digits);
+
+ if (preferences.show_range_mode & 3) /* slider also visible */
+ {
+ gtk_widget_set_size_request(spinbutton, 70, -1);
+ }
+ else /* slider not visible */
+ {
+ gtk_widget_set_size_request(spinbutton, 100, -1);
+ }
+
+ xsane_back_gtk_set_tooltip(xsane.tooltips, spinbutton, desc);
+ gtk_spin_button_set_wrap(GTK_SPIN_BUTTON(spinbutton), FALSE);
+ gtk_box_pack_end(GTK_BOX(hbox), spinbutton, FALSE, FALSE, 5); /* make spinbutton not sizeable */
+ gtk_widget_show(spinbutton);
+ gtk_widget_set_sensitive(spinbutton, settable);
+ elem->widget = spinbutton;
+ }
+
+ /* slider */
+ if (preferences.show_range_mode & 3)
+ {
+ if (preferences.show_range_mode & 1) /* bit 0 (val 1) : scale */
+ {
+ slider = gtk_hscale_new(GTK_ADJUSTMENT(elem->data));
+ gtk_scale_set_draw_value(GTK_SCALE(slider), FALSE);
+ }
+ else /* bit 1 (val 2) : scrollbar */
+ {
+ slider = gtk_hscrollbar_new(GTK_ADJUSTMENT(elem->data));
+ }
+ xsane_back_gtk_set_tooltip(xsane.tooltips, slider, desc);
+ gtk_widget_set_size_request(slider, 140, -1);
+ /* GTK_UPDATE_CONTINUOUS, GTK_UPDATE_DISCONTINUOUS, GTK_UPDATE_DELAYED */
+ gtk_range_set_update_policy(GTK_RANGE(slider), preferences.gtk_update_policy);
+ gtk_box_pack_end(GTK_BOX(hbox), slider, FALSE, FALSE, 5); /* make slider not sizeable */
+ gtk_widget_show(slider);
+ gtk_widget_set_sensitive(slider, settable);
+ }
if (automatic)
{
- xsane_back_gtk_autobutton_new(hbox, elem, scale, tooltips);
+ xsane_back_gtk_autobutton_new(hbox, elem, tooltips);
+ }
+
+ g_signal_connect(elem->data, "value_changed", (GtkSignalFunc) xsane_back_gtk_value_update, elem);
+
+ gtk_widget_show(label);
+ gtk_widget_show(hbox);
+
+ if (elem->widget)
+ {
+ elem->widget2 = slider; /* widget is used by spinbutton */
}
else
{
- gtk_box_pack_end(GTK_BOX(hbox), scale, FALSE, FALSE, 0); /* make scales fixed */
-/* gtk_box_pack_end(GTK_BOX(hbox), scale, TRUE, TRUE, 0); */ /* make scales sizeable */
+ elem->widget = slider; /* we do not have a spinbutton */
}
+}
- gtk_range_set_update_policy(GTK_RANGE(scale), GTK_UPDATE_CONTINUOUS);
- gtk_scale_set_value_pos(GTK_SCALE(scale), GTK_POS_TOP);
+/* ----------------------------------------------------------------------------------------------------------------- */
+
+void xsane_back_gtk_value_new(GtkWidget *parent, const char *name, gfloat val,
+ gfloat quant, int automatic,
+ DialogElement *elem, GtkTooltips *tooltips, const char *desc, SANE_Int settable)
+{
+ GtkWidget *hbox, *label, *spinbutton;
+ int digits;
+
+ DBG(DBG_proc, "xsane_back_gtk_value_new(%s)\n", name);
if (quant - (int) quant == 0.0)
{
- gtk_scale_set_digits(GTK_SCALE(scale), 0);
+ digits = 0;
}
else
{
- /* set number of digits in dependacne of quantization */
- gtk_scale_set_digits(GTK_SCALE(scale), (int) log10(1/quant)+0.8);
+ digits = (int) (log10(1/quant)+0.8); /* set number of digits in dependance of quantization */
}
- gtk_signal_connect(elem->data, "value_changed", (GtkSignalFunc) xsane_back_gtk_scale_update, elem);
+ if (digits < 0)
+ {
+ digits = 0;
+ }
- gtk_widget_show(label);
- gtk_widget_show(scale);
- gtk_widget_show(hbox);
+ hbox = gtk_hbox_new(FALSE, 2);
+ gtk_container_set_border_width(GTK_CONTAINER(hbox), 2);
+ gtk_box_pack_start(GTK_BOX(parent), hbox, FALSE, FALSE, 0);
- gtk_widget_set_sensitive(scale, settable);
+ label = gtk_label_new((char *) name);
+ gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 2);
+
+ elem->data = gtk_adjustment_new(val, -1e29, 1e29, 1, 10, 1e-30);
- elem->widget = scale;
+ /* spinbutton */
+#ifndef HAVE_GTK2
+ if (digits > 5)
+ {
+ digits = 5;
+ }
+#endif
+ spinbutton = gtk_spin_button_new(GTK_ADJUSTMENT(elem->data), 0, digits);
+
+ if (preferences.show_range_mode & 3) /* sliders are visible */
+ {
+ gtk_widget_set_size_request(spinbutton, 70, -1);
+ }
+ else /* sliders not visible */
+ {
+ gtk_widget_set_size_request(spinbutton, 100, -1);
+ }
+
+ xsane_back_gtk_set_tooltip(xsane.tooltips, spinbutton, desc);
+ gtk_spin_button_set_wrap(GTK_SPIN_BUTTON(spinbutton), FALSE);
+ gtk_box_pack_end(GTK_BOX(hbox), spinbutton, FALSE, FALSE, 5); /* make spinbutton not sizeable */
+ gtk_widget_show(spinbutton);
+ gtk_widget_set_sensitive(spinbutton, settable);
+ elem->widget = spinbutton;
+
+ if (automatic)
+ {
+ xsane_back_gtk_autobutton_new(hbox, elem, tooltips);
+ }
+
+ g_signal_connect(elem->data, "value_changed", (GtkSignalFunc) xsane_back_gtk_value_update, elem);
+
+ gtk_widget_show(label);
+ gtk_widget_show(hbox);
}
/* ----------------------------------------------------------------------------------------------------------------- */
void xsane_back_gtk_push_button_callback(GtkWidget * widget, gpointer data)
{
- GSGDialogElement *elem = data;
+ DialogElement *elem = data;
int opt_num;
DBG(DBG_proc, "xsane_back_gtk_push_button_callback\n");
@@ -1028,13 +1651,13 @@ void xsane_back_gtk_push_button_callback(GtkWidget * widget, gpointer data)
/* ----------------------------------------------------------------------------------------------------------------- */
-static int xsane_back_gtk_option_menu_lookup(GSGMenuItem menu_items[], const char *string)
+static int xsane_back_gtk_option_menu_lookup(MenuItem menu_items[], const char *string)
{
int i;
DBG(DBG_proc, "xsane_back_gtk_option_menu_lookup\n");
- for (i = 0; strcmp(menu_items[i].label, string) != 0; ++i);
+ for (i = 0; (menu_items[i].label) && strcmp(menu_items[i].label, string) != 0; ++i);
return i;
}
@@ -1043,8 +1666,8 @@ static int xsane_back_gtk_option_menu_lookup(GSGMenuItem menu_items[], const cha
static void xsane_back_gtk_option_menu_callback(GtkWidget * widget, gpointer data)
{
- GSGMenuItem *menu_item = data;
- GSGDialogElement *elem = menu_item->elem;
+ MenuItem *menu_item = data;
+ DialogElement *elem = menu_item->elem;
const SANE_Option_Descriptor *opt;
int opt_num;
double dval;
@@ -1059,20 +1682,20 @@ static void xsane_back_gtk_option_menu_callback(GtkWidget * widget, gpointer dat
{
case SANE_TYPE_INT:
sscanf(menu_item->label, "%d", &val);
- break;
+ break;
case SANE_TYPE_FIXED:
sscanf(menu_item->label, "%lg", &dval);
val = SANE_FIX(dval);
- break;
+ break;
case SANE_TYPE_STRING:
valp = menu_item->label;
- break;
+ break;
default:
DBG(DBG_error, "xsane_back_gtk_option_menu_callback: %s %d\n", ERR_UNKNOWN_TYPE, opt->type);
- break;
+ break;
}
xsane_back_gtk_set_option(opt_num, valp, SANE_ACTION_SET_VALUE);
}
@@ -1080,11 +1703,11 @@ static void xsane_back_gtk_option_menu_callback(GtkWidget * widget, gpointer dat
/* ----------------------------------------------------------------------------------------------------------------- */
void xsane_back_gtk_option_menu_new(GtkWidget *parent, const char *name, char *str_list[],
- const char *val, GSGDialogElement * elem,
+ const char *val, DialogElement *elem,
GtkTooltips *tooltips, const char *desc, SANE_Int settable)
{
GtkWidget *hbox, *label, *option_menu, *menu, *item;
- GSGMenuItem *menu_items;
+ MenuItem *menu_items;
int i, num_items;
DBG(DBG_proc, "xsane_back_gtk_option_menu_new(%s)\n", name);
@@ -1096,15 +1719,18 @@ void xsane_back_gtk_option_menu_new(GtkWidget *parent, const char *name, char *s
label = gtk_label_new((char *) name);
gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 2);
- for (num_items = 0; str_list[num_items]; ++num_items);
- menu_items = malloc(num_items * sizeof(menu_items[0]));
+ for (num_items = 0; str_list[num_items]; ++num_items)
+ {
+ }
+
+ menu_items = malloc((num_items + 1) * sizeof(menu_items[0]));
menu = gtk_menu_new();
for (i = 0; i < num_items; ++i)
{
item = gtk_menu_item_new_with_label(_BGT(str_list[i]));
gtk_container_add(GTK_CONTAINER(menu), item);
- gtk_signal_connect(GTK_OBJECT(item), "activate", (GtkSignalFunc) xsane_back_gtk_option_menu_callback, menu_items + i);
+ g_signal_connect(GTK_OBJECT(item), "activate", (GtkSignalFunc) xsane_back_gtk_option_menu_callback, menu_items + i);
gtk_widget_show(item);
@@ -1113,6 +1739,11 @@ void xsane_back_gtk_option_menu_new(GtkWidget *parent, const char *name, char *s
menu_items[i].index = i;
}
+ /* add empty element as end of list marker */
+ menu_items[i].label = NULL;
+ menu_items[i].elem = NULL;
+ menu_items[i].index = 0;
+
option_menu = gtk_option_menu_new();
gtk_box_pack_end(GTK_BOX(hbox), option_menu, FALSE, FALSE, 2);
gtk_option_menu_set_menu(GTK_OPTION_MENU(option_menu), menu);
@@ -1125,7 +1756,7 @@ void xsane_back_gtk_option_menu_new(GtkWidget *parent, const char *name, char *s
gtk_widget_set_sensitive(option_menu, settable);
- elem->widget = option_menu;
+ elem->widget = option_menu;
elem->menu_size = num_items;
elem->menu = menu_items;
}
@@ -1134,9 +1765,9 @@ void xsane_back_gtk_option_menu_new(GtkWidget *parent, const char *name, char *s
static void xsane_back_gtk_text_entry_callback(GtkWidget *w, gpointer data)
{
- GSGDialogElement *elem = data;
+ DialogElement *elem = data;
const SANE_Option_Descriptor *opt;
- gchar *text;
+ const gchar *text;
int opt_num;
char *buf;
@@ -1165,7 +1796,7 @@ static void xsane_back_gtk_text_entry_callback(GtkWidget *w, gpointer data)
/* ----------------------------------------------------------------------------------------------------------------- */
-void xsane_back_gtk_text_entry_new(GtkWidget * parent, const char *name, const char *val, GSGDialogElement *elem,
+void xsane_back_gtk_text_entry_new(GtkWidget * parent, const char *name, const char *val, DialogElement *elem,
GtkTooltips *tooltips, const char *desc, SANE_Int settable)
{
GtkWidget *hbox, *text, *label;
@@ -1183,7 +1814,7 @@ void xsane_back_gtk_text_entry_new(GtkWidget * parent, const char *name, const c
gtk_entry_set_text(GTK_ENTRY(text), (char *) val);
/* gtk_box_pack_start(GTK_BOX(hbox), text, FALSE, TRUE, 0); */ /* text entry fixed */
gtk_box_pack_start(GTK_BOX(hbox), text, TRUE, TRUE, 0); /* text entry sizeable */
- gtk_signal_connect(GTK_OBJECT(text), "changed", (GtkSignalFunc) xsane_back_gtk_text_entry_callback, elem);
+ g_signal_connect(GTK_OBJECT(text), "changed", (GtkSignalFunc) xsane_back_gtk_text_entry_callback, elem);
xsane_back_gtk_set_tooltip(tooltips, text, desc);
gtk_widget_show(hbox);
@@ -1192,7 +1823,7 @@ void xsane_back_gtk_text_entry_new(GtkWidget * parent, const char *name, const c
gtk_widget_set_sensitive(text, settable);
- elem->widget = text;
+ elem->widget = text;
}
/* ----------------------------------------------------------------------------------------------------------------- */
@@ -1230,15 +1861,25 @@ static void tooltips_destroy(void)
static void xsane_back_gtk_panel_destroy(void)
{
const SANE_Option_Descriptor *opt;
- GSGDialogElement *elem;
+ DialogElement *elem;
int i, j;
DBG(DBG_proc, "xsane_back_gtk_panel_destroy\n");
+ if (!xsane.xsane_hbox)
+ {
+ DBG(DBG_proc, "xsane_back_gtk_panel_destroy: panel does not exist\n");
+ return;
+ }
+
gtk_widget_destroy(xsane.xsane_hbox);
gtk_widget_destroy(xsane.standard_hbox);
gtk_widget_destroy(xsane.advanced_hbox);
+ xsane.xsane_hbox = NULL;
+ xsane.standard_hbox = NULL;
+ xsane.advanced_hbox = NULL;
+
/* free the menu labels of integer/fix-point word-lists: */
for (i = 0; i < xsane.num_elements; ++i)
{
@@ -1266,12 +1907,6 @@ static void xsane_back_gtk_panel_destroy(void)
/* ----------------------------------------------------------------------------------------------------------------- */
-/* When an setting an option changes the dialog, everything may
- change: the option titles, the activity-status of the option, its
- constraints or what not. Thus, rather than trying to be clever in
- detecting what exactly changed, we use a brute-force method of
- rebuilding the entire dialog. */
-
static void xsane_back_gtk_panel_rebuild(void)
{
DBG(DBG_proc, "xsane_back_gtk_panel_rebuild\n");
@@ -1296,7 +1931,7 @@ void xsane_back_gtk_update_scan_window(void)
{
const SANE_Option_Descriptor *opt;
double old_val, new_val;
- GSGDialogElement *elem;
+ DialogElement *elem;
SANE_Status status;
SANE_Word word;
int i, optnum;
@@ -1340,7 +1975,7 @@ void xsane_back_gtk_update_scan_window(void)
if (old_val != new_val)
{
- gtk_signal_emit_by_name(GTK_OBJECT(elem->data), "value_changed");
+ g_signal_emit_by_name(GTK_OBJECT(elem->data), "value_changed");
}
break;
@@ -1366,65 +2001,6 @@ void xsane_back_gtk_update_scan_window(void)
/* ----------------------------------------------------------------------------------------------------------------- */
-/* Ensure sure the device has up-to-date option values. Except for
- vectors, all option values are kept current. Vectors are
- downloaded into the device during this call. */
-void xsane_back_gtk_sync(void)
-{
- const SANE_Option_Descriptor *opt;
- gfloat val, *vector;
- SANE_Word *optval;
- int i, j, optlen;
- GtkWidget *curve;
-
- DBG(DBG_proc, "xsane_back_gtk_sync\n");
-
- for (i = 1; i < xsane.num_elements; ++i)
- {
- opt = xsane_get_option_descriptor(xsane.dev, i);
-
- if (!SANE_OPTION_IS_ACTIVE(opt->cap))
- {
- continue;
- }
-
- if (opt->type != SANE_TYPE_INT && opt->type != SANE_TYPE_FIXED)
- {
- continue;
- }
-
- if (opt->size == sizeof(SANE_Word))
- {
- continue;
- }
-
- /* ok, we're dealing with an active vector */
-
- optlen = opt->size / sizeof(SANE_Word);
- optval = alloca(optlen * sizeof(optval[0]));
- vector = alloca(optlen * sizeof(vector[0]));
-
- curve = GTK_GAMMA_CURVE(xsane.element[i].widget)->curve;
- gtk_curve_get_vector(GTK_CURVE(curve), optlen, vector);
- for (j = 0; j < optlen; ++j)
- {
- val = vector[j];
- if (opt->type == SANE_TYPE_FIXED)
- {
- optval[j] = SANE_FIX(val);
- }
- else
- {
- optval[j] = val + 0.5;
- }
- }
-
- xsane_back_gtk_set_option(i, optval, SANE_ACTION_SET_VALUE);
- }
-}
-
-/* ----------------------------------------------------------------------------------------------------------------- */
-
void xsane_back_gtk_update_vector(int opt_num, SANE_Int *vector)
{
const SANE_Option_Descriptor *opt;
@@ -1533,17 +2109,27 @@ void xsane_back_gtk_set_sensitivity(int sensitive)
void xsane_set_sensitivity(SANE_Int sensitivity)
{
- DBG(DBG_proc, "xsane_set_sensitivity\n");
+ DBG(DBG_proc, "xsane_set_sensitivity(%d)\n", sensitivity);
if (xsane.shell)
{
+ /* clear or rebuild histogram */
+ if (sensitivity)
+ {
+ xsane_update_histogram(TRUE /* update raw */);
+ }
+ else
+ {
+ xsane_clear_histogram(&xsane.histogram_raw);
+ xsane_clear_histogram(&xsane.histogram_enh);
+ }
+
gtk_widget_set_sensitive(xsane.menubar, sensitivity);
gtk_widget_set_sensitive(xsane.xsane_window, sensitivity);
gtk_widget_set_sensitive(GTK_WIDGET(xsane.start_button), sensitivity);
gtk_widget_set_sensitive(xsane.standard_options_shell, sensitivity);
gtk_widget_set_sensitive(xsane.advanced_options_shell, sensitivity);
gtk_widget_set_sensitive(xsane.histogram_dialog, sensitivity);
-
#ifdef HAVE_WORKING_GTK_GAMMACURVE
gtk_widget_set_sensitive(xsane.gamma_dialog, sensitivity);
#endif
@@ -1552,6 +2138,7 @@ void xsane_set_sensitivity(SANE_Int sensitivity)
if (xsane.preview)
{
gtk_widget_set_sensitive(xsane.preview->button_box, sensitivity); /* button box at top of window */
+ gtk_widget_set_sensitive(xsane.preview->menu_box, sensitivity); /* menu box at top of window */
#if 1
gtk_widget_set_sensitive(xsane.preview->viewport, sensitivity); /* Preview image selection */
#endif
@@ -1560,16 +2147,26 @@ void xsane_set_sensitivity(SANE_Int sensitivity)
if (xsane.fax_dialog)
{
- gtk_widget_set_sensitive(xsane.fax_dialog, sensitivity);
+ /* do not change sensitivity of fax_dialog, we want the progress bar */
+ /* to be sensitive */
+ gtk_widget_set_sensitive(xsane.fax_project_box, sensitivity);
+ gtk_widget_set_sensitive(xsane.fax_project_exists, sensitivity);
+ gtk_widget_set_sensitive(xsane.fax_project_entry_box, sensitivity);
}
-#if 0
- xsane_back_gtk_set_sensitivity(sensitivity);
-#endif
+ if (xsane.mail_dialog)
+ {
+ /* do not change sensitivity of mail_dialog, we want the progress bar */
+ /* to be sensitive */
+ gtk_widget_set_sensitive(xsane.mail_project_box, sensitivity);
+ gtk_widget_set_sensitive(xsane.mail_project_exists, sensitivity);
+ gtk_widget_set_sensitive(xsane.mail_project_entry_box, sensitivity);
+ }
- while (gtk_events_pending()) /* make sure set_sensitivity is displayed */
+ if (xsane.batch_scan_dialog)
{
- gtk_main_iteration();
+ gtk_widget_set_sensitive(xsane.batch_scan_button_box, sensitivity);
+ gtk_widget_set_sensitive(xsane.batch_scan_action_box, sensitivity);
}
xsane.sensitivity = sensitivity;
diff --git a/src/xsane-back-gtk.h b/src/xsane-back-gtk.h
index feb52e9..584e6d5 100644
--- a/src/xsane-back-gtk.h
+++ b/src/xsane-back-gtk.h
@@ -3,7 +3,7 @@
xsane-back-gtk.h
Oliver Rauch <Oliver.Rauch@rauch-domain.de>
- Copyright (C) 1998-2002 Oliver Rauch
+ Copyright (C) 1998-2005 Oliver Rauch
This file is part of the XSANE package.
This program is free software; you can redistribute it and/or modify
@@ -28,6 +28,7 @@
/* ---------------------------------------------------------------------------------------------------------------------- */
#include "xsane.h"
+#include "xsane-batch-scan.h"
/* ---------------------------------------------------------------------------------------------------------------------- */
@@ -38,7 +39,7 @@ typedef enum
xsane_back_gtk_BR_X, /* bottom-right x */
xsane_back_gtk_BR_Y /* bottom-right y */
}
-GSGCornerCoordinates;
+CornerCoordinates;
/* ---------------------------------------------------------------------------------------------------------------------- */
@@ -54,15 +55,17 @@ extern const SANE_Option_Descriptor *xsane_get_option_descriptor(SANE_Handle han
extern SANE_Status xsane_control_option(SANE_Handle handle, SANE_Int option, SANE_Action action, void *val, SANE_Int *info);
extern int xsane_back_gtk_make_path(size_t max_len, char *filename_ret, const char *prog_name, const char *dir_name,
const char *prefix, const char *dev_name, const char *postfix, int local);
-extern gint xsane_back_gtk_decision(gchar *title, gchar** icon_xpm, gchar *message, gchar *oktext, gchar *rejecttext, int wait);
-extern void xsane_back_gtk_message(gchar *title, gchar** icon_xpm, gchar *message, int wait);
+extern gint xsane_back_gtk_decision(gchar *title, gchar **icon_xpm, gchar *message, gchar *oktext, gchar *rejecttext, int wait);
+extern void xsane_back_gtk_ipc_dialog_callback(gpointer data, gint source, GdkInputCondition cond);
+extern void xsane_back_gtk_message(gchar *title, gchar **icon_xpm, gchar *message, int wait);
extern void xsane_back_gtk_error(gchar *error_message, int wait);
extern void xsane_back_gtk_warning(gchar *warning_message, int wait);
extern void xsane_back_gtk_info(gchar *info_message, int wait);
-extern int xsane_back_gtk_get_filename(const char *label, const char *default_name, size_t max_len, char *filename,
- int show_fileopts, int shorten_path, int hide_file_list);
+extern void xsane_back_gtk_filetype_menu_set_history(GtkWidget *xsane_filetype_option_menu, char *filetype);
+extern GtkWidget *xsane_back_gtk_filetype_menu_new(char *filetype, GtkSignalFunc filetype_callback);
+extern int xsane_back_gtk_get_filename(const char *label, const char *default_name, size_t max_len, char *filename, char **filetype,
+ int show_fileopts, int shorten_path, int hide_file_list, int show_filetype_menu);
-extern void xsane_back_gtk_sync(void);
extern void xsane_back_gtk_update_vector(int opt_num, SANE_Int *vector);
extern void xsane_back_gtk_refresh_dialog(void);
/* extern void xsane_back_gtk_vector_new(GtkWidget *box, int num_vopts, int *vopts); */
@@ -74,18 +77,26 @@ extern void xsane_back_gtk_set_sensitivity(int sensitive);
extern void xsane_set_sensitivity(SANE_Int sensitivity);
extern void xsane_back_gtk_destroy_dialog(void);
extern void xsane_back_gtk_set_option(int opt_num, void *val, SANE_Action action);
-extern GtkWidget *xsane_back_gtk_group_new (GtkWidget *parent, const char * title);
-extern void xsane_back_gtk_button_new(GtkWidget * parent, const char *name, SANE_Word val,
- GSGDialogElement *elem, GtkTooltips *tooltips, const char *desc, SANE_Int settable);
-extern void xsane_back_gtk_scale_new(GtkWidget * parent, const char *name, gfloat val,
+extern int xsane_back_gtk_set_option_double(int option, double value);
+extern int xsane_back_gtk_get_option_double(int option, double *val, SANE_Int *unit);
+extern void xsane_back_gtk_set_option(int opt_num, void *val, SANE_Action action);
+extern void xsane_back_gtk_get_batch_parameters(Batch_Scan_Parameters *parameters, SANE_Int *unit);
+extern void xsane_back_gtk_establish_batch_parameters(Batch_Scan_Parameters *parameters, int panel_rebuild, int set_scanmode, int set_resolution);
+extern GtkWidget *xsane_back_gtk_group_new (GtkWidget *parent, const char *title);
+extern void xsane_back_gtk_button_new(GtkWidget *parent, const char *name, SANE_Word val,
+ DialogElement *elem, GtkTooltips *tooltips, const char *desc, SANE_Int settable);
+extern void xsane_back_gtk_range_new(GtkWidget *parent, const char *name, gfloat val,
gfloat min, gfloat max, gfloat quant, int automatic,
- GSGDialogElement *elem, GtkTooltips *tooltips, const char *desc, SANE_Int settable);
+ DialogElement *elem, GtkTooltips *tooltips, const char *desc, SANE_Int settable);
+extern void xsane_back_gtk_value_new(GtkWidget *parent, const char *name, gfloat val,
+ gfloat quant, int automatic,
+ DialogElement *elem, GtkTooltips *tooltips, const char *desc, SANE_Int settable);
extern void xsane_back_gtk_option_menu_new(GtkWidget *parent, const char *name, char *str_list[],
- const char *val, GSGDialogElement * elem, GtkTooltips *tooltips, const char *desc, SANE_Int settable);
+ const char *val, DialogElement *elem, GtkTooltips *tooltips, const char *desc, SANE_Int settable);
extern void xsane_back_gtk_text_entry_new(GtkWidget *parent, const char *name, const char *val,
- GSGDialogElement *elem, GtkTooltips *tooltips, const char *desc, SANE_Int settable);
-extern void xsane_back_gtk_push_button_callback(GtkWidget * widget, gpointer data);
+ DialogElement *elem, GtkTooltips *tooltips, const char *desc, SANE_Int settable);
+extern void xsane_back_gtk_push_button_callback(GtkWidget *widget, gpointer data);
extern const char *xsane_back_gtk_unit_string(SANE_Unit unit);
-void xsane_set_window_icon(GtkWidget *gtk_window, gchar **xpm_d);
+extern void xsane_set_window_icon(GtkWidget *gtk_window, gchar **xpm_d);
#endif
diff --git a/src/xsane-batch-scan.c b/src/xsane-batch-scan.c
new file mode 100644
index 0000000..bf5f57c
--- /dev/null
+++ b/src/xsane-batch-scan.c
@@ -0,0 +1,1041 @@
+/* xsane -- a graphical (X11, gtk) scanner-oriented SANE frontend
+
+ xsane-batch-scan.c
+
+ Oliver Rauch <Oliver.Rauch@rauch-domain.de>
+ Copyright (C) 1998-2005 Oliver Rauch
+ This file is part of the XSANE package.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
+
+/* ---------------------------------------------------------------------------------------------------------------------- */
+
+#include "xsane.h"
+#include "xsane-scan.h"
+#include "xsane-batch-scan.h"
+#include "xsane-back-gtk.h"
+#include "xsane-front-gtk.h"
+#include "xsane-rc-io.h"
+#include "xsane-preview.h"
+#include "xsane-gamma.h"
+
+/* ---------------------------------------------------------------------------------------------------------------------- */
+
+static GtkWidget *xsane_batch_scan_create_list_entry(Batch_Scan_Parameters *parameters);
+
+/* ---------------------------------------------------------------------------------------------------------------------- */
+
+#define BOFFSET(field) ((char *) &((Batch_Scan_Parameters *) 0)->field - (char *) 0)
+
+/* ---------------------------------------------------------------------------------------------------------------------- */
+
+static struct
+ {
+ SANE_String name;
+ void (*codec) (Wire *w, void *p, long offset);
+ long offset;
+ }
+desc[] =
+ {
+ {"name", xsane_rc_pref_string, BOFFSET(name)},
+ {"scanmode", xsane_rc_pref_string, BOFFSET(scanmode)},
+ {"tl-x", xsane_rc_pref_double, BOFFSET(tl_x)},
+ {"tl-y", xsane_rc_pref_double, BOFFSET(tl_y)},
+ {"br-x", xsane_rc_pref_double, BOFFSET(br_x)},
+ {"br-y", xsane_rc_pref_double, BOFFSET(br_y)},
+ {"unit", xsane_rc_pref_int, BOFFSET(unit)},
+ {"rotation", xsane_rc_pref_int, BOFFSET(rotation)},
+ {"resolution-x", xsane_rc_pref_double, BOFFSET(resolution_x)},
+ {"resolution-y", xsane_rc_pref_double, BOFFSET(resolution_y)},
+ {"bit-depth", xsane_rc_pref_int, BOFFSET(bit_depth)},
+ {"gamma", xsane_rc_pref_double, BOFFSET(gamma)},
+ {"gamma-red", xsane_rc_pref_double, BOFFSET(gamma_red)},
+ {"gamma-green", xsane_rc_pref_double, BOFFSET(gamma_green)},
+ {"gamma-blue", xsane_rc_pref_double, BOFFSET(gamma_blue)},
+ {"contrast", xsane_rc_pref_double, BOFFSET(contrast)},
+ {"contrast-red", xsane_rc_pref_double, BOFFSET(contrast_red)},
+ {"contrast-green", xsane_rc_pref_double, BOFFSET(contrast_green)},
+ {"contrast-blue", xsane_rc_pref_double, BOFFSET(contrast_blue)},
+ {"brightness", xsane_rc_pref_double, BOFFSET(brightness)},
+ {"brightness-red", xsane_rc_pref_double, BOFFSET(brightness_red)},
+ {"brightness-green", xsane_rc_pref_double, BOFFSET(brightness_green)},
+ {"brightness-blue", xsane_rc_pref_double, BOFFSET(brightness_blue)},
+ {"enhancement-rgb-default", xsane_rc_pref_int, BOFFSET(enhancement_rgb_default)},
+ {"negative", xsane_rc_pref_int, BOFFSET(negative)},
+ {"BATCH_END", xsane_rc_pref_string, 0}
+ };
+
+/* ---------------------------------------------------------------------------------------------------------------------- */
+
+static void xsane_batch_scan_get_parameters(Batch_Scan_Parameters *parameters)
+{
+ char buf[255];
+ SANE_Int unit;
+
+ DBG(DBG_proc, "xsane_batch_scan_get_parameters\n");
+
+ xsane_back_gtk_get_option_double(xsane.well_known.coord[0], &parameters->tl_x, &unit);
+ xsane_back_gtk_get_option_double(xsane.well_known.coord[1], &parameters->tl_y, &unit);
+ xsane_back_gtk_get_option_double(xsane.well_known.coord[2], &parameters->br_x, &unit);
+ xsane_back_gtk_get_option_double(xsane.well_known.coord[3], &parameters->br_y, &unit);
+
+ parameters->unit = unit;
+
+ if (!xsane_back_gtk_get_option_double(xsane.well_known.dpi_x, &parameters->resolution_x, NULL))
+ {
+ if (xsane_back_gtk_get_option_double(xsane.well_known.dpi_y, &parameters->resolution_y, NULL))
+ {
+ parameters->resolution_y = parameters->resolution_x;
+ }
+ }
+ else /* only one resolution available */
+ {
+ xsane_back_gtk_get_option_double(xsane.well_known.dpi, &parameters->resolution_x, NULL);
+ parameters->resolution_y = parameters->resolution_x;
+ }
+
+
+ if (xsane_control_option(xsane.dev, xsane.well_known.bit_depth, SANE_ACTION_GET_VALUE, &parameters->bit_depth, 0))
+ {
+ parameters->bit_depth = -1;
+ }
+
+ if (xsane_control_option(xsane.dev, xsane.well_known.scanmode, SANE_ACTION_GET_VALUE, buf, 0))
+ {
+ parameters->scanmode = NULL;
+ }
+ else
+ {
+ parameters->scanmode = strdup(buf);
+ }
+
+ parameters->rotation = xsane.preview->rotation;
+
+ parameters->gamma = xsane.gamma;
+ parameters->gamma_red = xsane.gamma_red;
+ parameters->gamma_green = xsane.gamma_green;
+ parameters->gamma_blue = xsane.gamma_blue;
+
+ parameters->brightness = xsane.brightness;
+ parameters->brightness_red = xsane.brightness_red;
+ parameters->brightness_green = xsane.brightness_green;
+ parameters->brightness_blue = xsane.brightness_blue;
+
+ parameters->contrast = xsane.contrast;
+ parameters->contrast_red = xsane.contrast_red;
+ parameters->contrast_green = xsane.contrast_green;
+ parameters->contrast_blue = xsane.contrast_blue;
+
+ parameters->enhancement_rgb_default = xsane.enhancement_rgb_default;
+ parameters->negative = xsane.negative;
+}
+
+/* ---------------------------------------------------------------------------------------------------------------------- */
+
+void xsane_batch_scan_establish_parameters(Batch_Scan_Parameters *parameters, int panel_rebuild)
+{
+ SANE_Int info = 0;
+
+ if ( (parameters->scanmode) && (xsane.batch_scan_use_stored_scanmode) )
+ {
+ xsane_control_option(xsane.dev, xsane.well_known.scanmode, SANE_ACTION_SET_VALUE, parameters->scanmode, &info);
+ }
+
+ xsane_back_gtk_set_option_double(xsane.well_known.coord[0], parameters->tl_x);
+ xsane_back_gtk_set_option_double(xsane.well_known.coord[1], parameters->tl_y);
+ xsane_back_gtk_set_option_double(xsane.well_known.coord[2], parameters->br_x);
+ xsane_back_gtk_set_option_double(xsane.well_known.coord[3], parameters->br_y);
+
+ xsane.scan_rotation = parameters->rotation;
+
+ if (xsane.batch_scan_use_stored_resolution)
+ {
+ if (!xsane_back_gtk_set_option_double(xsane.well_known.dpi_x, parameters->resolution_x))
+ {
+ xsane_back_gtk_set_option_double(xsane.well_known.dpi_y, parameters->resolution_y);
+ }
+ else /* only one resolution */
+ {
+ xsane_back_gtk_set_option_double(xsane.well_known.dpi, parameters->resolution_x);
+ }
+ }
+
+ if (xsane.batch_scan_use_stored_bit_depth)
+ {
+ /* XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX */
+ }
+
+ if (info & SANE_INFO_RELOAD_OPTIONS)
+ {
+ xsane_refresh_dialog();
+ preview_update_surface(xsane.preview, 0);
+ }
+
+ xsane_update_param(0);
+ xsane_update_gamma_curve(TRUE);
+}
+
+/* ---------------------------------------------------------------------------------------------------------------------- */
+
+static int xsane_batch_scan_list_item_activated_callback(GtkObject *list_item, gpointer data)
+
+{
+ Batch_Scan_Parameters *parameters;
+
+ if (list_item)
+ {
+ parameters = gtk_object_get_data(list_item, "parameters");
+
+ if (parameters)
+ {
+ xsane_batch_scan_establish_parameters(parameters, TRUE);
+ }
+ }
+
+ return 0;
+}
+
+/* ---------------------------------------------------------------------------------------------------------------------- */
+
+static void xsane_batch_scan_empty_list(void)
+{
+ GtkObject *list_item;
+ GList *list = GTK_LIST(xsane.batch_scan_list)->children;
+ Batch_Scan_Parameters *parameters = NULL;
+
+ while (list)
+ {
+ list_item = GTK_OBJECT(list->data);
+
+ parameters = gtk_object_get_data(list_item, "parameters");
+
+ if (parameters)
+ {
+ free(parameters);
+ }
+
+ list = list->next;
+
+ gtk_widget_destroy(GTK_WIDGET(list_item)); /* delete list element */
+ }
+}
+
+/* ---------------------------------------------------------------------------------------------------------------------- */
+
+static int xsane_batch_scan_read_parameters(Wire *w, Batch_Scan_Parameters *parameters)
+/* returns 0 if ok, otherwise error/eof */
+{
+ SANE_String name;
+ int i;
+
+ DBG(DBG_proc, "batch_scan_read_parameters\n");
+
+ while (1)
+ {
+ xsane_rc_io_w_space(w, 3);
+ if (w->status)
+ {
+ return -1;
+ }
+
+ xsane_rc_io_w_string(w, &name);
+ if (w->status || !name)
+ {
+ return -2;
+ }
+
+ if (!strcmp(name, "BATCH_END"))
+ {
+ return 0; /* ok */
+ }
+
+ for (i = 0; i < NELEMS (desc); ++i)
+ {
+ if (strcmp(name, desc[i].name) == 0)
+ {
+ DBG(DBG_info2, "reading batch-scan-parameter for %s\n", desc[i].name);
+ (*desc[i].codec) (w, parameters, desc[i].offset);
+ break;
+ }
+ }
+ }
+
+ return -3; /* we should never come here */
+}
+
+/* ---------------------------------------------------------------------------------------------------------------------- */
+
+/* returns 0 if OK, -1 if file could not be loaded */
+int xsane_batch_scan_load_list_from_file(char *filename)
+{
+ Batch_Scan_Parameters *parameters = NULL;
+ int fd;
+ int eof = 0;
+ Wire w;
+
+ DBG(DBG_proc, "xsane_batch_scan_load_list_from_file(%s)\n", filename);
+
+ xsane_batch_scan_empty_list();
+
+ fd = open(filename, O_RDONLY);
+
+ if (fd > 0)
+ {
+ w.io.fd = fd;
+ w.io.read = read;
+ w.io.write = write;
+ xsane_rc_io_w_init(&w);
+ xsane_rc_io_w_set_dir(&w, WIRE_DECODE);
+
+ while (!eof)
+ {
+ eof = 1;
+
+ parameters = calloc(1, sizeof(Batch_Scan_Parameters));
+
+ if (parameters)
+ {
+ eof = xsane_batch_scan_read_parameters(&w, parameters);
+
+ if (!eof)
+ {
+ xsane_batch_scan_create_list_entry(parameters);
+ }
+ }
+ }
+ free(parameters); /* last one is unused */
+
+ xsane_rc_io_w_exit(&w);
+
+ close(fd);
+
+ /* scroll list to beginning */
+ gtk_adjustment_set_value(xsane.batch_scan_vadjustment, xsane.batch_scan_vadjustment->lower);
+ gtk_adjustment_value_changed(xsane.batch_scan_vadjustment);
+
+ return 0;
+ }
+
+ return -1;
+}
+
+/* ---------------------------------------------------------------------------------------------------------------------- */
+
+static void xsane_batch_scan_load_list(void)
+{
+ char filename[PATH_MAX];
+ char windowname[256];
+
+ DBG(DBG_proc, "xsane_batch_scan_load_list\n");
+
+ xsane_set_sensitivity(FALSE);
+
+ sprintf(windowname, "%s %s %s", xsane.prog_name, WINDOW_LOAD_BATCH_LIST, xsane.device_text);
+ xsane_back_gtk_make_path(sizeof(filename), filename, "xsane", "batch-lists", 0, "default", ".xbl", XSANE_PATH_LOCAL_SANE);
+
+ if (!xsane_back_gtk_get_filename(windowname, filename, sizeof(filename), filename, NULL, FALSE, FALSE, FALSE, FALSE))
+ {
+ if (xsane_batch_scan_load_list_from_file(filename)) /* error while loading file ? */
+ {
+ char buf[256];
+
+ snprintf(buf, sizeof(buf), "%s `%s': %s", ERR_OPEN_FAILED, filename, strerror(errno));
+ xsane_back_gtk_error(buf, TRUE);
+ }
+ }
+
+ xsane_set_sensitivity(TRUE);
+}
+
+/* ---------------------------------------------------------------------------------------------------------------------- */
+
+static void xsane_batch_scan_write_parameters(Wire *w, Batch_Scan_Parameters *parameters)
+{
+ int i;
+
+ DBG(DBG_proc, "batch_scan_parameters_save\n");
+
+ for (i = 0; i < NELEMS(desc)-1; ++i)
+ {
+ DBG(DBG_info2, "saving batch-scan-parameter for %s\n", desc[i].name);
+ xsane_rc_io_w_string(w, &desc[i].name);
+ (*desc[i].codec) (w, parameters, desc[i].offset);
+ }
+
+ xsane_rc_io_w_string(w, &desc[NELEMS(desc)-1].name); /* write BATCH_END */
+}
+
+/* ---------------------------------------------------------------------------------------------------------------------- */
+
+static void xsane_batch_scan_save_list(void)
+{
+ GtkObject *list_item;
+ GList *list = GTK_LIST(xsane.batch_scan_list)->children;
+ Batch_Scan_Parameters *parameters = NULL;
+ int fd;
+ Wire w;
+ char filename[PATH_MAX];
+ char windowname[256];
+
+ DBG(DBG_proc, "xsane_batch_scan_save_list\n");
+
+ xsane_set_sensitivity(FALSE);
+
+ sprintf(windowname, "%s %s %s", xsane.prog_name, WINDOW_SAVE_BATCH_LIST, xsane.device_text);
+ xsane_back_gtk_make_path(sizeof(filename), filename, "xsane", "batch-lists", 0, "default", ".xbl", XSANE_PATH_LOCAL_SANE);
+
+ if (!xsane_back_gtk_get_filename(windowname, filename, sizeof(filename), filename, NULL, FALSE, FALSE, FALSE, FALSE))
+ {
+ fd = open(filename, O_WRONLY | O_CREAT | O_TRUNC, 0600);
+
+ if (fd > 0)
+ {
+ w.io.fd = fd;
+ w.io.read = read;
+ w.io.write = write;
+ xsane_rc_io_w_init(&w);
+ xsane_rc_io_w_set_dir(&w, WIRE_ENCODE);
+
+ while (list)
+ {
+ list_item = GTK_OBJECT(list->data);
+
+ parameters = gtk_object_get_data(list_item, "parameters");
+
+ if (parameters)
+ {
+ xsane_batch_scan_write_parameters(&w, parameters);
+ }
+
+ list = list->next;
+ }
+
+ xsane_rc_io_w_set_dir(&w, WIRE_DECODE); /* flush it out */
+ xsane_rc_io_w_exit(&w);
+
+ close(fd);
+ }
+ else
+ {
+ char buf[256];
+
+ snprintf(buf, sizeof(buf), "%s `%s': %s", ERR_OPEN_FAILED, filename, strerror(errno));
+ xsane_back_gtk_error(buf, TRUE);
+ }
+ }
+
+ xsane_set_sensitivity(TRUE);
+}
+
+/* ---------------------------------------------------------------------------------------------------------------------- */
+
+static void xsane_batch_scan_scan_list(void)
+{
+ GtkObject *list_item;
+ GList *list = GTK_LIST(xsane.batch_scan_list)->children;
+ Batch_Scan_Parameters *parameters = NULL;
+ SANE_Int val_start = SANE_TRUE;
+ SANE_Int val_loop = SANE_TRUE;
+ SANE_Int val_end = SANE_FALSE;
+ SANE_Word val_next_tl_y = SANE_FIX(0.0);
+
+ gtk_list_scroll_vertical(GTK_LIST(xsane.batch_scan_list), GTK_SCROLL_JUMP, 0.0);
+
+ while (gtk_events_pending())
+ {
+ gtk_main_iteration();
+ }
+
+
+ while (list)
+ {
+ if (!list->next) /* last scan */
+ {
+ val_loop = SANE_FALSE;
+ val_end = SANE_TRUE;
+ val_next_tl_y = SANE_FIX(0.0);
+ }
+ else /* not last scan */
+ {
+ parameters = gtk_object_get_data(GTK_OBJECT(list->next->data), "parameters");
+ if (parameters)
+ {
+ val_next_tl_y = SANE_FIX(parameters->tl_y);
+ }
+ }
+ xsane_control_option(xsane.dev, xsane.well_known.batch_scan_start, SANE_ACTION_SET_VALUE, &val_start, NULL);
+ xsane_control_option(xsane.dev, xsane.well_known.batch_scan_loop, SANE_ACTION_SET_VALUE, &val_loop, NULL);
+ xsane_control_option(xsane.dev, xsane.well_known.batch_scan_end, SANE_ACTION_SET_VALUE, &val_end, NULL);
+ xsane_control_option(xsane.dev, xsane.well_known.batch_scan_next_tl_y, SANE_ACTION_SET_VALUE, &val_next_tl_y, NULL);
+
+ val_start = SANE_FALSE;
+
+ xsane.batch_loop = val_loop; /* tell scanning routine if we have more scans */
+
+ list_item = GTK_OBJECT(list->data);
+
+ gtk_list_select_child(GTK_LIST(xsane.batch_scan_list), GTK_WIDGET(list_item));
+ /* selecting the child normally does establish the parameters, but not always for the first element! */
+
+ parameters = gtk_object_get_data(list_item, "parameters");
+
+ if (parameters)
+ {
+ xsane_batch_scan_establish_parameters(parameters, FALSE);
+ }
+
+ while (gtk_events_pending())
+ {
+ gtk_main_iteration();
+ }
+
+ xsane_scan_dialog();
+
+ while (xsane.scanning)
+ {
+#if 0
+ if (gtk_events_pending())
+ {
+ gtk_main_iteration();
+ }
+#elseif
+ gtk_main_iteration();
+#endif
+ }
+
+ if ( (xsane.status_of_last_scan != SANE_STATUS_GOOD) && (xsane.status_of_last_scan != SANE_STATUS_EOF) )
+ {
+ break; /* cancel or error occured */
+ }
+
+ list = list->next;
+
+ gtk_list_scroll_vertical(GTK_LIST(xsane.batch_scan_list), GTK_SCROLL_STEP_FORWARD, 1.0);
+ }
+
+ val_start = SANE_FALSE;
+ val_loop = SANE_FALSE;
+ val_end = SANE_FALSE;
+ val_next_tl_y = SANE_FIX(0.0);
+
+ /* make sure all batch scan options are reset */
+ xsane_control_option(xsane.dev, xsane.well_known.batch_scan_start, SANE_ACTION_SET_VALUE, &val_start, NULL);
+ xsane_control_option(xsane.dev, xsane.well_known.batch_scan_loop, SANE_ACTION_SET_VALUE, &val_loop, NULL);
+ xsane_control_option(xsane.dev, xsane.well_known.batch_scan_end, SANE_ACTION_SET_VALUE, &val_end, NULL);
+ xsane_control_option(xsane.dev, xsane.well_known.batch_scan_next_tl_y, SANE_ACTION_SET_VALUE, &val_next_tl_y, NULL);
+
+ xsane.batch_loop = FALSE; /* make sure we reset the batch scan loop flag */
+
+ if (parameters)
+ {
+ xsane_batch_scan_establish_parameters(parameters, FALSE);
+ }
+}
+
+/* ---------------------------------------------------------------------------------------------------------------------- */
+
+static void xsane_batch_scan_scan_selected(void)
+{
+ GList *select;
+ GtkObject *list_item;
+ Batch_Scan_Parameters *parameters = NULL;
+
+ select = GTK_LIST(xsane.batch_scan_list)->selection;
+ if (select)
+ {
+ list_item = GTK_OBJECT(select->data);
+
+ parameters = gtk_object_get_data(list_item, "parameters");
+
+ if (parameters)
+ {
+ xsane_batch_scan_establish_parameters(parameters, TRUE);
+ }
+
+ xsane_scan_dialog();
+ }
+}
+
+/* ---------------------------------------------------------------------------------------------------------------------- */
+
+static void xsane_batch_scan_delete(void)
+{
+ GList *select;
+ GtkObject *list_item;
+ Batch_Scan_Parameters *parameters = NULL;
+
+ DBG(DBG_proc, "xsane_batch_scan_delete\n");
+
+ select = GTK_LIST(xsane.batch_scan_list)->selection;
+ if (select)
+ {
+ list_item = GTK_OBJECT(select->data);
+
+ parameters = gtk_object_get_data(list_item, "parameters");
+
+ if (parameters)
+ {
+ free(parameters);
+ }
+
+ gtk_widget_destroy(GTK_WIDGET(list_item));
+ }
+}
+
+/* ---------------------------------------------------------------------------------------------------------------------- */
+
+static void xsane_batch_scan_update_label(Batch_Scan_Parameters *parameters)
+{
+ char buf[256];
+ const char *unit_str;
+ double tl_x = parameters->tl_x;
+ double tl_y = parameters->tl_y;
+ double br_x = parameters->br_x;
+ double br_y = parameters->br_y;
+ char areaname_str[100];
+ char geometry_tl_str[100];
+ char geometry_size_str[100];
+ char scanmode_str[100];
+ char resolution_str[100];
+ char bit_depth_str[100];
+
+
+ snprintf(areaname_str, sizeof(areaname_str), "%s %s", TEXT_BATCH_LIST_AREANAME, parameters->name);
+
+ if (xsane.batch_scan_use_stored_scanmode)
+ {
+ snprintf(scanmode_str, sizeof(scanmode_str), "%s %s", TEXT_BATCH_LIST_SCANMODE, parameters->scanmode);
+ }
+ else
+ {
+ snprintf(scanmode_str, sizeof(scanmode_str), "%s %s", TEXT_BATCH_LIST_SCANMODE, TEXT_BATCH_LIST_BY_GUI);
+ }
+
+ unit_str = xsane_back_gtk_unit_string(parameters->unit);
+ if (parameters->unit == SANE_UNIT_MM)
+ {
+ tl_x /= preferences.length_unit;
+ tl_y /= preferences.length_unit;
+ br_x /= preferences.length_unit;
+ br_y /= preferences.length_unit;
+ }
+ snprintf(geometry_tl_str, sizeof(geometry_tl_str), "%s %0.2f %s, %0.2f %s", TEXT_BATCH_LIST_GEOMETRY_TL,
+ tl_x, unit_str, tl_y, unit_str);
+
+ snprintf(geometry_size_str, sizeof(geometry_size_str), "%s %0.2f %s x %0.2f %s", TEXT_BATCH_LIST_GEOMETRY_SIZE,
+ br_x - tl_x, unit_str, br_y - tl_y, unit_str);
+
+ if (xsane.batch_scan_use_stored_resolution)
+ {
+ snprintf(resolution_str, sizeof(resolution_str), "%s %3.0f dpi x %3.0f dpi", TEXT_BATCH_LIST_RESOLUTION,
+ parameters->resolution_x, parameters->resolution_y);
+ }
+ else
+ {
+ snprintf(resolution_str, sizeof(resolution_str), "%s %s", TEXT_BATCH_LIST_RESOLUTION, TEXT_BATCH_LIST_BY_GUI);
+ }
+
+ if (xsane.batch_scan_use_stored_bit_depth)
+ {
+ snprintf(bit_depth_str, sizeof(bit_depth_str), "%s %d", TEXT_BATCH_LIST_BIT_DEPTH, parameters->bit_depth);
+ }
+ else
+ {
+ snprintf(bit_depth_str, sizeof(bit_depth_str), "%s %s", TEXT_BATCH_LIST_BIT_DEPTH, TEXT_BATCH_LIST_BY_GUI);
+ }
+
+ snprintf(buf, sizeof(buf), "%s\n" /* name */
+ "%s\n" /* scanmode */
+ "%s\n" /* geometry_tl */
+ "%s\n" /* geometry_size */
+ "%s\n" /* resolution */
+ "%s", /* bit_depth */
+ areaname_str,
+ scanmode_str,
+ geometry_tl_str,
+ geometry_size_str,
+ resolution_str,
+ bit_depth_str);
+
+ gtk_label_set_text(GTK_LABEL(parameters->label), buf);
+}
+
+/* ---------------------------------------------------------------------------------------------------------------------- */
+
+static GtkWidget *xsane_batch_scan_create_list_entry(Batch_Scan_Parameters *parameters)
+{
+ GtkWidget *list_item;
+ GtkWidget *hbox;
+ int size = 120;
+ char *data;
+
+ list_item = gtk_list_item_new();
+
+ hbox = gtk_hbox_new(FALSE, 10);
+ gtk_container_add(GTK_CONTAINER(list_item), hbox);
+ gtk_widget_show(hbox);
+
+ data = calloc(size, size);
+
+ parameters->gtk_preview = gtk_preview_new(GTK_PREVIEW_COLOR);
+ gtk_preview_size(GTK_PREVIEW(parameters->gtk_preview), size, size);
+ gtk_box_pack_start(GTK_BOX(hbox), parameters->gtk_preview, FALSE, FALSE, 0);
+ gtk_widget_show(parameters->gtk_preview);
+
+ parameters->gtk_preview_size = size;
+
+ preview_create_batch_icon(xsane.preview, parameters);
+
+
+ parameters->label = gtk_label_new("");
+ gtk_box_pack_start(GTK_BOX(hbox), parameters->label, FALSE, FALSE, 0);
+ gtk_label_set_justify(GTK_LABEL(parameters->label), GTK_JUSTIFY_LEFT);
+ gtk_widget_show(parameters->label);
+ xsane_batch_scan_update_label(parameters);
+
+ gtk_object_set_data(GTK_OBJECT(list_item), "parameters", parameters);
+ g_signal_connect(GTK_OBJECT(list_item), "select", (GtkSignalFunc) xsane_batch_scan_list_item_activated_callback, NULL);
+ gtk_container_add(GTK_CONTAINER(xsane.batch_scan_list), list_item);
+ gtk_widget_show(list_item);
+
+ return(list_item);
+}
+
+/* ---------------------------------------------------------------------------------------------------------------------- */
+
+void xsane_batch_scan_add()
+{
+ Batch_Scan_Parameters *parameters;
+ GtkWidget *list_item;
+
+ DBG(DBG_proc, "xsane_batch_scan_add\n");
+
+ parameters = calloc(1, sizeof(Batch_Scan_Parameters));
+
+ if (parameters)
+ {
+ xsane_batch_scan_get_parameters(parameters);
+
+ parameters->name = strdup(TEXT_BATCH_AREA_DEFAULT_NAME);
+ }
+
+ list_item = xsane_batch_scan_create_list_entry(parameters);
+
+ /* scroll list to end */
+ gtk_adjustment_set_value(xsane.batch_scan_vadjustment, xsane.batch_scan_vadjustment->upper);
+ gtk_adjustment_value_changed(xsane.batch_scan_vadjustment);
+}
+
+/* ---------------------------------------------------------------------------------------------------------------------- */
+
+void xsane_batch_scan_update_label_list(void)
+{
+ GtkObject *list_item;
+ GList *list = GTK_LIST(xsane.batch_scan_list)->children;
+ Batch_Scan_Parameters *parameters = NULL;
+
+ while (list)
+ {
+ list_item = GTK_OBJECT(list->data);
+
+ parameters = gtk_object_get_data(list_item, "parameters");
+
+ if (parameters)
+ {
+ xsane_batch_scan_update_label(parameters);
+ }
+
+ list = list->next;
+ }
+
+ gtk_widget_queue_draw(xsane.batch_scan_list); /* update gtk_pixmap widgets */
+}
+
+/* ---------------------------------------------------------------------------------------------------------------------- */
+
+void xsane_batch_scan_update_icon_list(void)
+{
+ GtkObject *list_item;
+ GList *list = GTK_LIST(xsane.batch_scan_list)->children;
+ Batch_Scan_Parameters *parameters = NULL;
+
+ while (list)
+ {
+ list_item = GTK_OBJECT(list->data);
+
+ parameters = gtk_object_get_data(list_item, "parameters");
+
+ if (parameters)
+ {
+ preview_create_batch_icon(xsane.preview, parameters);
+ }
+
+ list = list->next;
+ }
+
+ gtk_widget_queue_draw(xsane.batch_scan_list); /* update gtk_pixmap widgets */
+}
+
+/* ---------------------------------------------------------------------------------------------------------------------- */
+
+static void xsane_batch_scan_rotate_mirror(GtkWidget *widget, gpointer data)
+{
+ GList *select;
+ GtkObject *list_item;
+ Batch_Scan_Parameters *parameters = NULL;
+ int rotate_info = (int) data;
+ int rotate, mirror;
+
+ DBG(DBG_proc, "xsane_batch_scan_rotate_mirror\n");
+
+ select = GTK_LIST(xsane.batch_scan_list)->selection;
+ if (select)
+ {
+ list_item = GTK_OBJECT(select->data);
+
+ parameters = gtk_object_get_data(list_item, "parameters");
+
+ if (parameters)
+ {
+ rotate = parameters->rotation & 3;
+ mirror = parameters->rotation & 4;
+
+ if (parameters->rotation < 4)
+ {
+ parameters->rotation = ( (rotate + rotate_info) & 3 ) + ( (mirror+ rotate_info) & 4);
+ }
+ else
+ {
+ parameters->rotation = ( (rotate - rotate_info) & 3 ) + ( (mirror+ rotate_info) & 4);
+ }
+
+ xsane_batch_scan_update_icon_list();
+ }
+ }
+}
+
+/* ---------------------------------------------------------------------------------------------------------------------- */
+int xsane_batch_scan_rename;
+
+static void xsane_batch_scan_rename_button_callback(GtkWidget *widget, gpointer data)
+{
+ DBG(DBG_proc, "xsane_batch_scan_rename\n");
+
+ xsane_batch_scan_rename = (int) data;
+}
+
+
+static void xsane_batch_scan_rename_callback(GtkWidget *widget, gpointer data)
+{
+ GList *select;
+ GtkObject *list_item;
+ Batch_Scan_Parameters *parameters = NULL;
+ GtkWidget *rename_dialog;
+ GtkWidget *text;
+ GtkWidget *button;
+ GtkWidget *vbox, *hbox;
+ char buf[256];
+
+ DBG(DBG_proc, "xsane_batch_scan_rename\n");
+
+ select = GTK_LIST(xsane.batch_scan_list)->selection;
+ if (select)
+ {
+ list_item = GTK_OBJECT(select->data);
+
+ parameters = gtk_object_get_data(list_item, "parameters");
+
+ if (parameters)
+ {
+ xsane_set_sensitivity(FALSE);
+
+ rename_dialog = gtk_window_new(GTK_WINDOW_TOPLEVEL);
+ xsane_set_window_icon(rename_dialog, 0);
+
+ /* set the main vbox */
+ vbox = gtk_vbox_new(FALSE, 0);
+ gtk_container_set_border_width(GTK_CONTAINER(vbox), 0);
+ gtk_container_add(GTK_CONTAINER(rename_dialog), vbox);
+ gtk_widget_show(vbox);
+
+ /* set the main hbox */
+ hbox = gtk_hbox_new(FALSE, 0);
+ xsane_separator_new(vbox, 2);
+ gtk_box_pack_end(GTK_BOX(vbox), hbox, FALSE, FALSE, 5);
+ gtk_container_set_border_width(GTK_CONTAINER(hbox), 5);
+ gtk_widget_show(hbox);
+
+ gtk_window_set_position(GTK_WINDOW(rename_dialog), GTK_WIN_POS_CENTER);
+ gtk_window_set_resizable(GTK_WINDOW(rename_dialog), FALSE);
+ snprintf(buf, sizeof(buf), "%s %s", xsane.prog_name, WINDOW_BATCH_RENAME);
+ gtk_window_set_title(GTK_WINDOW(rename_dialog), buf);
+ g_signal_connect(GTK_OBJECT(rename_dialog), "delete_event", (GtkSignalFunc) xsane_batch_scan_rename_button_callback,(void *) -1);
+ gtk_widget_show(rename_dialog);
+
+ text = gtk_entry_new();
+ xsane_back_gtk_set_tooltip(xsane.tooltips, text, DESC_BATCH_RENAME);
+ gtk_entry_set_max_length(GTK_ENTRY(text), 64);
+ gtk_entry_set_text(GTK_ENTRY(text), parameters->name);
+ gtk_widget_set_size_request(text, 300, -1);
+ gtk_box_pack_start(GTK_BOX(vbox), text, TRUE, TRUE, 4);
+ gtk_widget_show(text);
+
+#ifdef HAVE_GTK2
+ button = gtk_button_new_from_stock(GTK_STOCK_OK);
+#else
+ button = gtk_button_new_with_label(BUTTON_OK);
+#endif
+ GTK_WIDGET_SET_FLAGS(button, GTK_CAN_DEFAULT);
+ g_signal_connect(GTK_OBJECT(button), "clicked", (GtkSignalFunc) xsane_batch_scan_rename_button_callback, (void *) 1);
+ gtk_box_pack_start(GTK_BOX(hbox), button, TRUE, TRUE, 0);
+ gtk_widget_grab_default(button);
+ gtk_widget_show(button);
+
+
+#ifdef HAVE_GTK2
+ button = gtk_button_new_from_stock(GTK_STOCK_CANCEL);
+#else
+ button = gtk_button_new_with_label(BUTTON_CANCEL);
+#endif
+ g_signal_connect(GTK_OBJECT(button), "clicked", (GtkSignalFunc) xsane_batch_scan_rename_button_callback, (void *) -1);
+ gtk_box_pack_start(GTK_BOX(hbox), button, TRUE, TRUE, 0);
+ gtk_widget_show(button);
+
+ xsane_batch_scan_rename = 0;
+
+ while (xsane_batch_scan_rename == 0)
+ {
+ while (gtk_events_pending())
+ {
+ gtk_main_iteration();
+ }
+ }
+
+ if (xsane_batch_scan_rename == 1)
+ {
+ free(parameters->name);
+ parameters->name = strdup(gtk_entry_get_text(GTK_ENTRY(text)));
+ xsane_batch_scan_update_label(parameters);
+ }
+ gtk_widget_destroy(rename_dialog);
+
+ xsane_set_sensitivity(TRUE);
+ }
+ }
+}
+
+/* ---------------------------------------------------------------------------------------------------------------------- */
+
+static gint xsane_batch_scan_win_delete(GtkWidget *widget, gpointer data)
+{
+ DBG(DBG_proc, "xsane_batch_scan_win_delete\n");
+
+ gtk_widget_hide(widget);
+ preferences.show_batch_scan = FALSE;
+ gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(xsane.show_batch_scan_widget), preferences.show_batch_scan);
+ return TRUE;
+}
+
+/* ---------------------------------------------------------------------------------------------------------------------- */
+
+void xsane_create_batch_scan_dialog(const char *devicetext)
+{
+ GtkWidget *batch_scan_vbox, *button, *scrolled_window;
+ char buf[64];
+
+ DBG(DBG_proc, "xsane_batch_scan_dialog\n");
+
+ xsane.batch_scan_dialog = gtk_window_new(GTK_WINDOW_TOPLEVEL);
+ xsane_set_window_icon(xsane.batch_scan_dialog, 0);
+ gtk_window_add_accel_group(GTK_WINDOW(xsane.batch_scan_dialog), xsane.accelerator_group);
+
+ snprintf(buf, sizeof(buf), "%s %s", WINDOW_BATCH_SCAN, devicetext);
+ gtk_window_set_title(GTK_WINDOW(xsane.batch_scan_dialog), buf);
+ gtk_widget_set_size_request(xsane.batch_scan_dialog, 400, -1);
+
+ g_signal_connect(GTK_OBJECT(xsane.batch_scan_dialog), "delete_event", GTK_SIGNAL_FUNC(xsane_batch_scan_win_delete), NULL);
+
+ /* set the main vbox */
+ batch_scan_vbox = gtk_vbox_new(FALSE, 0);
+ gtk_container_set_border_width(GTK_CONTAINER(batch_scan_vbox), 5);
+ gtk_container_add(GTK_CONTAINER(xsane.batch_scan_dialog), batch_scan_vbox);
+ gtk_widget_show(batch_scan_vbox);
+
+ /* set the hbox for load/save */
+ xsane.batch_scan_button_box = gtk_hbox_new(FALSE, 0);
+ gtk_box_pack_start(GTK_BOX(batch_scan_vbox), xsane.batch_scan_button_box, FALSE, FALSE, 0);
+ gtk_container_set_border_width(GTK_CONTAINER(xsane.batch_scan_button_box), 0);
+ gtk_widget_show(xsane.batch_scan_button_box);
+
+ xsane_button_new_with_pixmap(xsane.batch_scan_dialog->window, xsane.batch_scan_button_box, empty_batch_xpm, DESC_BATCH_LIST_EMPTY, (GtkSignalFunc) xsane_batch_scan_empty_list, NULL);
+ xsane_button_new_with_pixmap(xsane.batch_scan_dialog->window, xsane.batch_scan_button_box, load_xpm, DESC_BATCH_LIST_LOAD, (GtkSignalFunc) xsane_batch_scan_load_list, NULL);
+ xsane_button_new_with_pixmap(xsane.batch_scan_dialog->window, xsane.batch_scan_button_box, save_xpm, DESC_BATCH_LIST_SAVE, (GtkSignalFunc) xsane_batch_scan_save_list, NULL);
+
+ xsane_vseparator_new(xsane.batch_scan_button_box, 3);
+
+ xsane_button_new_with_pixmap(xsane.batch_scan_dialog->window, xsane.batch_scan_button_box, add_batch_xpm, DESC_BATCH_ADD, (GtkSignalFunc) xsane_batch_scan_add, NULL);
+
+ xsane_vseparator_new(xsane.batch_scan_button_box, 3);
+
+ xsane_button_new_with_pixmap(xsane.batch_scan_dialog->window, xsane.batch_scan_button_box, del_batch_xpm, DESC_BATCH_DEL, (GtkSignalFunc) xsane_batch_scan_delete, NULL);
+
+ xsane_button_new_with_pixmap(xsane.batch_scan_dialog->window, xsane.batch_scan_button_box, ascii_xpm, DESC_BATCH_RENAME, (GtkSignalFunc) xsane_batch_scan_rename_callback, NULL);
+ xsane_button_new_with_pixmap(xsane.batch_scan_dialog->window, xsane.batch_scan_button_box, rotate90_xpm, DESC_ROTATE90, (GtkSignalFunc) xsane_batch_scan_rotate_mirror, (void *) 1);
+ xsane_button_new_with_pixmap(xsane.batch_scan_dialog->window, xsane.batch_scan_button_box, rotate180_xpm, DESC_ROTATE180, (GtkSignalFunc) xsane_batch_scan_rotate_mirror, (void *) 2);
+ xsane_button_new_with_pixmap(xsane.batch_scan_dialog->window, xsane.batch_scan_button_box, rotate270_xpm, DESC_ROTATE270, (GtkSignalFunc) xsane_batch_scan_rotate_mirror, (void *) 3);
+ xsane_button_new_with_pixmap(xsane.batch_scan_dialog->window, xsane.batch_scan_button_box, mirror_x_xpm, DESC_MIRROR_X, (GtkSignalFunc) xsane_batch_scan_rotate_mirror, (void *) 4);
+ xsane_button_new_with_pixmap(xsane.batch_scan_dialog->window, xsane.batch_scan_button_box, mirror_y_xpm, DESC_MIRROR_Y, (GtkSignalFunc) xsane_batch_scan_rotate_mirror, (void *) 6);
+
+
+ /* the scolled window with the list */
+ scrolled_window = gtk_scrolled_window_new(0, 0);
+ gtk_widget_set_size_request(scrolled_window, 400, 200);
+ gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolled_window), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
+ gtk_container_add(GTK_CONTAINER(batch_scan_vbox), scrolled_window);
+ gtk_widget_show(scrolled_window);
+
+ xsane.batch_scan_list = gtk_list_new();
+
+ gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(scrolled_window), xsane.batch_scan_list);
+
+ xsane.batch_scan_vadjustment = gtk_scrolled_window_get_vadjustment(GTK_SCROLLED_WINDOW(scrolled_window));
+ gtk_container_set_focus_vadjustment(GTK_CONTAINER(xsane.batch_scan_list), xsane.batch_scan_vadjustment);
+
+ gtk_widget_show(xsane.batch_scan_list);
+
+
+ xsane_separator_new(batch_scan_vbox, 2);
+
+
+ /* set the hbox for scan all / scan selected */
+ xsane.batch_scan_action_box = gtk_hbox_new(TRUE, 0);
+ gtk_box_pack_start(GTK_BOX(batch_scan_vbox), xsane.batch_scan_action_box, FALSE, FALSE, 0);
+ gtk_container_set_border_width(GTK_CONTAINER(xsane.batch_scan_action_box), 0);
+ gtk_widget_show(xsane.batch_scan_action_box);
+
+ button = gtk_button_new_with_label(BUTTON_BATCH_LIST_SCAN);
+ g_signal_connect(GTK_OBJECT(button), "clicked", (GtkSignalFunc) xsane_batch_scan_scan_list, NULL);
+ gtk_box_pack_start(GTK_BOX(xsane.batch_scan_action_box), button, TRUE, TRUE, 0);
+ gtk_widget_show(button);
+
+ button = gtk_button_new_with_label(BUTTON_BATCH_AREA_SCAN);
+ g_signal_connect(GTK_OBJECT(button), "clicked", (GtkSignalFunc) xsane_batch_scan_scan_selected, NULL);
+ gtk_box_pack_start(GTK_BOX(xsane.batch_scan_action_box), button, TRUE, TRUE, 0);
+ gtk_widget_show(button);
+
+ gtk_widget_realize(xsane.batch_scan_dialog);
+}
+
+/* ---------------------------------------------------------------------------------------------------------------------- */
diff --git a/src/xsane-batch-scan.h b/src/xsane-batch-scan.h
new file mode 100644
index 0000000..7437ae8
--- /dev/null
+++ b/src/xsane-batch-scan.h
@@ -0,0 +1,74 @@
+/* xsane -- a graphical (X11, gtk) scanner-oriented SANE frontend
+
+ xsane-batch-scan.h
+
+ Oliver Rauch <Oliver.Rauch@rauch-domain.de>
+ Copyright (C) 1998-2005 Oliver Rauch
+ This file is part of the XSANE package.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
+
+/* ---------------------------------------------------------------------------------------------------------------------- */
+
+#ifndef xsane_batch_scan_h
+#define xsane_batch_scan_h
+
+/* ---------------------------------------------------------------------------------------------------------------------- */
+
+#include <sane/sane.h>
+
+/* ---------------------------------------------------------------------------------------------------------------------- */
+
+typedef struct
+{
+ char *name;
+ char *scanmode;
+ double tl_x;
+ double tl_y;
+ double br_x;
+ double br_y;
+ SANE_Unit unit;
+ int rotation;
+ double resolution_x;
+ double resolution_y;
+ int bit_depth;
+ double gamma;
+ double gamma_red;
+ double gamma_green;
+ double gamma_blue;
+ double contrast;
+ double contrast_red;
+ double contrast_green;
+ double contrast_blue;
+ double brightness;
+ double brightness_red;
+ double brightness_green;
+ double brightness_blue;
+ int enhancement_rgb_default;
+ int negative;
+ GtkWidget *label;
+ GtkWidget *gtk_preview;
+ int gtk_preview_size;
+} Batch_Scan_Parameters;
+
+/* ---------------------------------------------------------------------------------------------------------------------- */
+
+extern void xsane_batch_scan_add();
+extern void xsane_create_batch_scan_dialog(const char *devicetext);
+extern void xsane_batch_scan_update_label_list(void);
+extern void xsane_batch_scan_update_icon_list(void);
+extern int xsane_batch_scan_load_list_from_file(char *filename);
+
+#endif /* batch_scan_h */
diff --git a/src/xsane-device-preferences.c b/src/xsane-device-preferences.c
index 7f6a80e..f70590b 100644
--- a/src/xsane-device-preferences.c
+++ b/src/xsane-device-preferences.c
@@ -3,7 +3,7 @@
xsane-device-preferences.c
Oliver Rauch <Oliver.Rauch@rauch-domain.de>
- Copyright (C) 1998-2002 Oliver Rauch
+ Copyright (C) 1998-2005 Oliver Rauch
This file is part of the XSANE package.
This program is free software; you can redistribute it and/or modify
@@ -65,6 +65,9 @@ desc_xsane_device[] =
{"xsane-gamma-window-x-position", xsane_rc_pref_int, DPOFFSET(gamma_dialog_posx)},
{"xsane-gamma-window-y-position", xsane_rc_pref_int, DPOFFSET(gamma_dialog_posy)},
+ {"xsane-batch-window-x-position", xsane_rc_pref_int, DPOFFSET(batch_dialog_posx)},
+ {"xsane-batch-window-y-position", xsane_rc_pref_int, DPOFFSET(batch_dialog_posy)},
+
{"xsane-preview-window-x-position", xsane_rc_pref_int, DPOFFSET(preview_dialog_posx)},
{"xsane-preview-window-y-position", xsane_rc_pref_int, DPOFFSET(preview_dialog_posy)},
{"xsane-preview-window-width", xsane_rc_pref_int, DPOFFSET(preview_dialog_width)},
@@ -162,7 +165,7 @@ static int xsane_device_preferences_load_values(Wire *w, SANE_Handle device)
status = SANE_STATUS_GOOD;
info = 0;
- for (i = 1; (opt = xsane_get_option_descriptor(device, i)); ++i) /* search all options */
+ for (i = 1; (i < num_options) && (opt = xsane_get_option_descriptor(device, i)); ++i) /* search all options */
{
if (!opt->name || strcmp(opt->name, name) != 0) /* test if option names are equal */
{
@@ -240,10 +243,13 @@ static int xsane_device_preferences_save_values(Wire *w, SANE_Handle device)
SANE_String str = 0;
SANE_Word word;
int i;
+ SANE_Int num_options;
DBG(DBG_proc, "xsane_device_preferences_save_values\n");
- for (i = 0; (opt = xsane_get_option_descriptor(device, i)); ++i)
+ xsane_control_option(device, 0, SANE_ACTION_GET_VALUE, &num_options, 0);
+
+ for (i = 0; (i < num_options) && (opt = xsane_get_option_descriptor(device, i)); ++i)
{
if ((opt->cap & (SANE_CAP_SOFT_SELECT | SANE_CAP_SOFT_DETECT)) !=
(SANE_CAP_SOFT_SELECT | SANE_CAP_SOFT_DETECT) || !opt->name)
@@ -384,6 +390,12 @@ void xsane_device_preferences_load_file(char *filename)
xsane.histogram_dialog_posx = XSANE_HISTOGRAM_POS_X;
xsane.histogram_dialog_posy = XSANE_HISTOGRAM_POS_Y;
+ xsane.gamma_dialog_posx = XSANE_GAMMA_POS_X;
+ xsane.gamma_dialog_posy = XSANE_GAMMA_POS_Y;
+
+ xsane.batch_dialog_posx = XSANE_BATCH_POS_X;
+ xsane.batch_dialog_posy = XSANE_BATCH_POS_Y;
+
xsane.preview_dialog_posx = XSANE_PREVIEW_POS_X;
xsane.preview_dialog_posy = XSANE_PREVIEW_POS_Y;
xsane.preview_dialog_width = XSANE_PREVIEW_WIDTH;
@@ -483,58 +495,6 @@ void xsane_device_preferences_load_file(char *filename)
return;
}
-
-#if 0
-/* add here: read version info */
-#if 0
- while (!feof(file))
- {
- fgets(option, sizeof(option), file); /* get option name */
- option[strlen(option)-1] = 0; /* remove cr */
- if (strcmp(option, "\"xsane-version\"") == 0)
- {
- fgets(option, sizeof(option), file); /* get version */
- option[strlen(option)-1] = 0; /* remove cr */
- len = strlen(option);
- if (len)
- {
- if (option[len-1] == 34)
- {
- option[len-1] = 0; /* remove " */
- }
- }
- version = strdup(option+1);
- }
- else
- {
- fgets(option, sizeof(option), file); /* skip option */
- }
- }
-#endif
-
-
- if (version)
- {
- if (strcmp(version, XSANE_VERSION))
- {
- snprintf(buf, sizeof(buf), "File: \"%s\"\n"
- "has been saved with xsane-%s,\n"
- "this may cause problems!", filename, version);
- xsane_back_gtk_warning(buf, TRUE);
- }
- free(version);
- }
- else
- {
- snprintf(buf, sizeof(buf), "File: \"%s\"\n"
- "has been saved with xsane before version 0.40,\n"
- "this may cause problems!", filename);
- xsane_back_gtk_warning(buf, TRUE);
- }
-#endif
-
-
-
while (1) /* read device dependant xsane options */
{
xsane_rc_io_w_space(&w, 3);
@@ -592,12 +552,16 @@ void xsane_device_preferences_load_file(char *filename)
}
}
}
- gtk_widget_set_uposition(xsane.shell, xsane.shell_posx, xsane.shell_posy);
+ gtk_window_move(GTK_WINDOW(xsane.shell), xsane.shell_posx, xsane.shell_posy);
gtk_window_set_default_size(GTK_WINDOW(xsane.shell), xsane.shell_width, xsane.shell_height);
- gtk_widget_set_uposition(xsane.standard_options_shell, xsane.standard_options_shell_posx, xsane.standard_options_shell_posy);
- gtk_widget_set_uposition(xsane.advanced_options_shell, xsane.advanced_options_shell_posx, xsane.advanced_options_shell_posy);
- gtk_widget_set_uposition(xsane.histogram_dialog, xsane.histogram_dialog_posx, xsane.histogram_dialog_posy);
- gtk_widget_set_uposition(xsane.preview->top, xsane.preview_dialog_posx, xsane.preview_dialog_posy);
+ gtk_window_move(GTK_WINDOW(xsane.standard_options_shell), xsane.standard_options_shell_posx, xsane.standard_options_shell_posy);
+ gtk_window_move(GTK_WINDOW(xsane.advanced_options_shell), xsane.advanced_options_shell_posx, xsane.advanced_options_shell_posy);
+ gtk_window_move(GTK_WINDOW(xsane.histogram_dialog), xsane.histogram_dialog_posx, xsane.histogram_dialog_posy);
+#if 0
+ gtk_window_move(GTK_WINDOW(xsane.gamma_dialog), xsane.gamma_dialog_posx, xsane.gamma_dialog_posy);
+#endif
+ gtk_window_move(GTK_WINDOW(xsane.batch_scan_dialog), xsane.batch_dialog_posx, xsane.batch_dialog_posy);
+ gtk_window_move(GTK_WINDOW(xsane.preview->top), xsane.preview_dialog_posx, xsane.preview_dialog_posy);
gtk_window_set_default_size(GTK_WINDOW(xsane.preview->top), xsane.preview_dialog_width, xsane.preview_dialog_height);
xsane_update_param(0);
@@ -636,14 +600,12 @@ void xsane_device_preferences_load(void)
DBG(DBG_proc, "xsane_device_preferences_load\n");
- xsane_clear_histogram(&xsane.histogram_raw);
- xsane_clear_histogram(&xsane.histogram_enh);
xsane_set_sensitivity(FALSE);
sprintf(windowname, "%s %s %s", xsane.prog_name, WINDOW_LOAD_SETTINGS, xsane.device_text);
xsane_back_gtk_make_path(sizeof(filename), filename, "xsane", 0, 0, xsane.device_set_filename, ".drc", XSANE_PATH_LOCAL_SANE);
- if (!xsane_back_gtk_get_filename(windowname, filename, sizeof(filename), filename, FALSE, FALSE, FALSE))
+ if (!xsane_back_gtk_get_filename(windowname, filename, sizeof(filename), filename, NULL, FALSE, FALSE, FALSE, FALSE))
{
xsane_device_preferences_load_file(filename);
}
@@ -693,25 +655,33 @@ void xsane_device_preferences_save_file(char *filename)
XSANE_RC_IO_W_STRINGCONST(&w, XSANE_VERSION);
/* make geometry and position values up to date */
- xsane_widget_get_uposition(xsane.shell, &xsane.shell_posx, &xsane.shell_posy);
- gdk_window_get_size(xsane.shell->window, &xsane.shell_width, &xsane.shell_height);
- gtk_widget_set_uposition(xsane.shell, xsane.shell_posx, xsane.shell_posy); /* geometry used when window closed and opened again */
+ xsane_window_get_position(xsane.shell, &xsane.shell_posx, &xsane.shell_posy);
+ gdk_drawable_get_size(xsane.shell->window, &xsane.shell_width, &xsane.shell_height);
+ gtk_window_move(GTK_WINDOW(xsane.shell), xsane.shell_posx, xsane.shell_posy); /* geometry used when window closed and opened again */
gtk_window_set_default_size(GTK_WINDOW(xsane.shell), xsane.shell_width, xsane.shell_height);
- xsane_widget_get_uposition(xsane.standard_options_shell, &xsane.standard_options_shell_posx, &xsane.standard_options_shell_posy);
- gtk_widget_set_uposition(xsane.standard_options_shell, xsane.standard_options_shell_posx, xsane.standard_options_shell_posy);
+ xsane_window_get_position(xsane.standard_options_shell, &xsane.standard_options_shell_posx, &xsane.standard_options_shell_posy);
+ gtk_window_move(GTK_WINDOW(xsane.standard_options_shell), xsane.standard_options_shell_posx, xsane.standard_options_shell_posy);
- xsane_widget_get_uposition(xsane.advanced_options_shell, &xsane.advanced_options_shell_posx, &xsane.advanced_options_shell_posy);
- gtk_widget_set_uposition(xsane.advanced_options_shell, xsane.advanced_options_shell_posx, xsane.advanced_options_shell_posy);
+ xsane_window_get_position(xsane.advanced_options_shell, &xsane.advanced_options_shell_posx, &xsane.advanced_options_shell_posy);
+ gtk_window_move(GTK_WINDOW(xsane.advanced_options_shell), xsane.advanced_options_shell_posx, xsane.advanced_options_shell_posy);
+
+ xsane_window_get_position(xsane.histogram_dialog, &xsane.histogram_dialog_posx, &xsane.histogram_dialog_posy);
+ gtk_window_move(GTK_WINDOW(xsane.histogram_dialog), xsane.histogram_dialog_posx, xsane.histogram_dialog_posy);
+
+#if 0
+ xsane_window_get_position(xsane.gamma_dialog, &xsane.gamma_dialog_posx, &xsane.gamma_dialog_posy);
+ gtk_window_move(GTK_WINDOW(xsane.gamma_dialog), xsane.gamma_dialog_posx, xsane.gamma_dialog_posy);
+#endif
- xsane_widget_get_uposition(xsane.histogram_dialog, &xsane.histogram_dialog_posx, &xsane.histogram_dialog_posy);
- gtk_widget_set_uposition(xsane.histogram_dialog, xsane.histogram_dialog_posx, xsane.histogram_dialog_posy);
+ xsane_window_get_position(xsane.batch_scan_dialog, &xsane.batch_dialog_posx, &xsane.batch_dialog_posy);
+ gtk_window_move(GTK_WINDOW(xsane.batch_scan_dialog), xsane.batch_dialog_posx, xsane.batch_dialog_posy);
if (xsane.preview)
{
- xsane_widget_get_uposition(xsane.preview->top, &xsane.preview_dialog_posx, &xsane.preview_dialog_posy);
- gdk_window_get_size(xsane.preview->top->window, &xsane.preview_dialog_width, &xsane.preview_dialog_height);
- gtk_widget_set_uposition(xsane.preview->top, xsane.preview_dialog_posx, xsane.preview_dialog_posy);
+ xsane_window_get_position(xsane.preview->top, &xsane.preview_dialog_posx, &xsane.preview_dialog_posy);
+ gdk_drawable_get_size(xsane.preview->top->window, &xsane.preview_dialog_width, &xsane.preview_dialog_height);
+ gtk_window_move(GTK_WINDOW(xsane.preview->top), xsane.preview_dialog_posx, xsane.preview_dialog_posy);
gtk_window_set_default_size(GTK_WINDOW(xsane.preview->top), xsane.preview_dialog_width, xsane.preview_dialog_height);
}
@@ -749,14 +719,12 @@ void xsane_device_preferences_save(void)
DBG(DBG_proc, "xsane_device_preferences_save\n");
- xsane_clear_histogram(&xsane.histogram_raw);
- xsane_clear_histogram(&xsane.histogram_enh);
xsane_set_sensitivity(FALSE);
sprintf(windowname, "%s %s %s", xsane.prog_name, WINDOW_SAVE_SETTINGS, xsane.device_text);
xsane_back_gtk_make_path(sizeof(filename), filename, "xsane", 0, 0, xsane.device_set_filename, ".drc", XSANE_PATH_LOCAL_SANE);
- if (!xsane_back_gtk_get_filename(windowname, filename, sizeof(filename), filename, FALSE, FALSE, FALSE))
+ if (!xsane_back_gtk_get_filename(windowname, filename, sizeof(filename), filename, NULL, FALSE, FALSE, FALSE, FALSE))
{
xsane_device_preferences_save_file(filename);
}
diff --git a/src/xsane-device-preferences.h b/src/xsane-device-preferences.h
index 053c2a8..e980d47 100644
--- a/src/xsane-device-preferences.h
+++ b/src/xsane-device-preferences.h
@@ -3,7 +3,7 @@
xsane-device-preferences.h
Oliver Rauch <Oliver.Rauch@rauch-domain.de>
- Copyright (C) 1998-2002 Oliver Rauch
+ Copyright (C) 1998-2005 Oliver Rauch
This file is part of the XSANE package.
This program is free software; you can redistribute it and/or modify
diff --git a/src/xsane-eula.txt b/src/xsane-eula.txt
new file mode 100644
index 0000000..504fc82
--- /dev/null
+++ b/src/xsane-eula.txt
@@ -0,0 +1,10 @@
+
+ NO WARRANTY
+
+1. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
+
+
+2. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+
+
+ END OF TERMS AND CONDITIONS
diff --git a/src/xsane-fixedtext.h b/src/xsane-fixedtext.h
index 2bff8cc..baa318b 100644
--- a/src/xsane-fixedtext.h
+++ b/src/xsane-fixedtext.h
@@ -3,7 +3,7 @@
xsane-fixedtext.h
Oliver Rauch <Oliver.Rauch@rauch-domain.de>
- Copyright (C) 1998-2002 Oliver Rauch
+ Copyright (C) 1998-2005 Oliver Rauch
This file is part of the XSANE package.
This program is free software; you can redistribute it and/or modify
@@ -33,18 +33,19 @@
# define XSANE_FILETYPE_TIFF ".tiff"
#endif
+#define XSANE_FILETYPE_BY_EXT ""
#define XSANE_FILETYPE_PNG ".png"
#define XSANE_FILETYPE_PNM ".pnm"
#define XSANE_FILETYPE_PS ".ps"
-#define XSANE_FILETYPE_RAW ".raw"
#define XSANE_FILETYPE_RGBA ".rgba"
+#define XSANE_FILETYPE_TEXT ".txt"
#define MENU_ITEM_FILETYPE_JPEG "JPEG"
#define MENU_ITEM_FILETYPE_TIFF "TIFF"
#define MENU_ITEM_FILETYPE_PNG "PNG"
#define MENU_ITEM_FILETYPE_PNM "PNM"
#define MENU_ITEM_FILETYPE_PS "PostScript"
-#define MENU_ITEM_FILETYPE_RAW "RAW"
#define MENU_ITEM_FILETYPE_RGBA "RGBA"
+#define MENU_ITEM_FILETYPE_TEXT "TEXT"
#endif
diff --git a/src/xsane-front-gtk.c b/src/xsane-front-gtk.c
index b4373ed..3695db8 100644
--- a/src/xsane-front-gtk.c
+++ b/src/xsane-front-gtk.c
@@ -3,7 +3,7 @@
xsane-front-gtk.c
Oliver Rauch <Oliver.Rauch@rauch-domain.de>
- Copyright (C) 1998-2002 Oliver Rauch
+ Copyright (C) 1998-2005 Oliver Rauch
This file is part of the XSANE package.
This program is free software; you can redistribute it and/or modify
@@ -68,20 +68,22 @@ void xsane_option_menu_new_with_pixmap(GdkWindow *window, GtkBox *parent, const
char *str_list[], const char *val,
GtkObject **data, int option,
void *option_menu_callback, SANE_Int settable, const gchar *widget_name);
-void xsane_scale_new(GtkBox *parent, char *labeltext, const char *desc,
- float min, float max, float quant, float step, float page_step,
- int digits, double *val, GtkObject **data, void *xsane_scale_callback, SANE_Int settable);
-void xsane_scale_new_with_pixmap(GdkWindow *window, GtkBox *parent, const char *xpm_d[], const char *desc,
- float min, float max, float quant, float step, float page_step, int digits,
- double *val, GtkObject **data, int option, void *xsane_scale_callback, SANE_Int settable);
+void xsane_range_new(GtkBox *parent, char *labeltext, const char *desc,
+ float min, float max, float quant, float page_step,
+ int digits, double *val, GtkObject **data, void *xsane_range_callback, SANE_Int settable);
+void xsane_range_new_with_pixmap(GdkWindow *window, GtkBox *parent, const char *xpm_d[], const char *desc,
+ float min, float max, float quant, float page_step, int digits,
+ double *val, GtkObject **data, int option, void *xsane_range_callback, SANE_Int settable);
+static void xsane_outputfilename_changed_callback(GtkWidget *widget, gpointer data);
+void xsane_set_filename(gchar *filename);
void xsane_separator_new(GtkWidget *xsane_parent, int dist);
+void xsane_vseparator_new(GtkWidget *xsane_parent, int dist);
GtkWidget *xsane_info_table_text_new(GtkWidget *table, gchar *text, int row, int colomn);
GtkWidget *xsane_info_text_new(GtkWidget *parent, gchar *text);
void xsane_refresh_dialog(void);
-void xsane_set_sensitivity(SANE_Int sensitivity);
void xsane_update_param(void *arg);
void xsane_define_output_filename(void);
-int xsane_identify_output_format(char *filename, char **ext);
+int xsane_identify_output_format(char *filename, char *filetype, char **ext);
/* ---------------------------------------------------------------------------------------------------------------------- */
@@ -141,7 +143,7 @@ void xsane_get_bounds(const SANE_Option_Descriptor *opt, double *minp, double *m
case SANE_CONSTRAINT_RANGE:
min = opt->constraint.range->min;
max = opt->constraint.range->max;
- break;
+ break;
case SANE_CONSTRAINT_WORD_LIST:
min = INF;
@@ -333,8 +335,11 @@ int xsane_set_resolution(int well_known_option, double resolution)
return 1; /* error */
}
+ /* it makes problems to call xsane_back_gtk_set_option. This would allow a */
+ /* panel_rebuild that can mess up a lot at this place*/
xsane_control_option(xsane.dev, well_known_option, SANE_ACTION_SET_VALUE, &dpi, 0);
- return 0; /* everything is ok */
+
+ return 0; /* everything is ok */
}
/* ---------------------------------------------------------------------------------------------------------------------- */
@@ -345,15 +350,6 @@ void xsane_set_all_resolutions(void)
DBG(DBG_proc, "xsane_set_all_resolutions\n");
-#if 0
- xsane_set_resolution(xsane.well_known.dpi_y, xsane.resolution_y); /* set y resolution if possible */
- if (xsane_set_resolution(xsane.well_known.dpi_x, xsane.resolution_x)) /* set x resolution if possible */
- {
- xsane_set_resolution(xsane.well_known.dpi, xsane.resolution); /* set common resolution if necessary */
- xsane.resolution_x = xsane.resolution;
- xsane.resolution_y = xsane.resolution;
- }
-#else
if (xsane_set_resolution(xsane.well_known.dpi_y, xsane.resolution_y)) /* set y resolution if possible */
{
xsane_set_resolution(xsane.well_known.dpi, xsane.resolution); /* set common resolution if necessary */
@@ -364,7 +360,6 @@ void xsane_set_all_resolutions(void)
{
xsane_set_resolution(xsane.well_known.dpi_x, xsane.resolution_x); /* set x resolution if possible */
}
-#endif
switch (xsane.param.format)
{
@@ -377,7 +372,7 @@ void xsane_set_all_resolutions(void)
{
printer_resolution = preferences.printer[preferences.printernr]->grayscale_resolution;
}
- break;
+ break;
case SANE_FRAME_RGB:
case SANE_FRAME_RED:
@@ -385,7 +380,7 @@ void xsane_set_all_resolutions(void)
case SANE_FRAME_BLUE:
default:
printer_resolution = preferences.printer[preferences.printernr]->color_resolution;
- break;
+ break;
}
xsane.zoom = xsane.resolution / printer_resolution;
@@ -410,45 +405,47 @@ void xsane_define_maximum_output_size()
case XSANE_SAVE:
xsane_define_output_filename();
- xsane.xsane_output_format = xsane_identify_output_format(xsane.output_filename, 0);
+ xsane.xsane_output_format = xsane_identify_output_format(xsane.output_filename, preferences.filetype, 0);
- preview_set_maximum_output_size(xsane.preview, INF, INF);
+ preview_set_maximum_output_size(xsane.preview, INF, INF, 0);
break;
case XSANE_VIEWER:
- preview_set_maximum_output_size(xsane.preview, INF, INF);
+ preview_set_maximum_output_size(xsane.preview, INF, INF, 0);
break;
case XSANE_COPY:
- if (preferences.psrotate) /* rotate: landscape */
+ if (preferences.paper_orientation >= 8) /* rotate: landscape */
{
preview_set_maximum_output_size(xsane.preview,
preferences.printer[preferences.printernr]->height / xsane.zoom_y,
- preferences.printer[preferences.printernr]->width / xsane.zoom_x);
+ preferences.printer[preferences.printernr]->width / xsane.zoom_x,
+ preferences.paper_orientation);
}
else /* do not rotate: portrait */
{
preview_set_maximum_output_size(xsane.preview,
preferences.printer[preferences.printernr]->width / xsane.zoom_x,
- preferences.printer[preferences.printernr]->height / xsane.zoom_y);
+ preferences.printer[preferences.printernr]->height / xsane.zoom_y,
+ preferences.paper_orientation);
}
break;
case XSANE_FAX:
- preview_set_maximum_output_size(xsane.preview, preferences.fax_width, preferences.fax_height);
+ preview_set_maximum_output_size(xsane.preview, preferences.fax_width, preferences.fax_height, 0);
break;
case XSANE_MAIL:
- preview_set_maximum_output_size(xsane.preview, INF, INF);
+ preview_set_maximum_output_size(xsane.preview, INF, INF, 0);
break;
default:
- preview_set_maximum_output_size(xsane.preview, INF, INF);
+ preview_set_maximum_output_size(xsane.preview, INF, INF, 0);
}
}
else
{
- preview_set_maximum_output_size(xsane.preview, INF, INF);
+ preview_set_maximum_output_size(xsane.preview, INF, INF, 0);
}
}
@@ -483,7 +480,7 @@ gint xsane_authorization_callback(SANE_String_Const resource,
GtkWidget *authorize_dialog, *vbox, *hbox, *button, *label;
GtkWidget *username_widget, *password_widget;
char buf[SANE_MAX_PASSWORD_LEN+SANE_MAX_USERNAME_LEN+128];
- char *input;
+ const gchar *input;
char *resource_string;
int len;
int resource_len;
@@ -586,11 +583,10 @@ gint xsane_authorization_callback(SANE_String_Const resource,
if (query_user)
{
- authorize_dialog = gtk_window_new(GTK_WINDOW_DIALOG);
+ authorize_dialog = gtk_window_new(GTK_WINDOW_TOPLEVEL);
gtk_window_set_position(GTK_WINDOW(authorize_dialog), GTK_WIN_POS_CENTER);
- gtk_window_set_policy(GTK_WINDOW(authorize_dialog), FALSE, FALSE, FALSE);
- gtk_signal_connect(GTK_OBJECT(authorize_dialog), "delete_event",
- GTK_SIGNAL_FUNC(xsane_authorization_button_callback), (void *) -1); /* -1 = cancel */
+ gtk_window_set_resizable(GTK_WINDOW(authorize_dialog), FALSE);
+ g_signal_connect(GTK_OBJECT(authorize_dialog), "delete_event", GTK_SIGNAL_FUNC(xsane_authorization_button_callback), (void *) -1); /* -1 = cancel */
snprintf(buf, sizeof(buf), "%s %s", xsane.prog_name, WINDOW_AUTHORIZE);
gtk_window_set_title(GTK_WINDOW(authorize_dialog), buf);
xsane_set_window_icon(authorize_dialog, 0);
@@ -627,7 +623,7 @@ gint xsane_authorization_callback(SANE_String_Const resource,
gtk_widget_show(label);
username_widget = gtk_entry_new_with_max_length(SANE_MAX_USERNAME_LEN-1);
- gtk_widget_set_usize(username_widget, 250, 0);
+ gtk_widget_set_size_request(username_widget, 250, -1);
gtk_entry_set_text(GTK_ENTRY(username_widget), "");
gtk_box_pack_end(GTK_BOX(hbox), username_widget, FALSE, FALSE, 10); /* x-space around input filed */
gtk_widget_show(username_widget);
@@ -644,7 +640,7 @@ gint xsane_authorization_callback(SANE_String_Const resource,
password_widget = gtk_entry_new_with_max_length(SANE_MAX_PASSWORD_LEN-1);
gtk_entry_set_visibility(GTK_ENTRY(password_widget), FALSE); /* make entered text invisible */
- gtk_widget_set_usize(password_widget, 250, 0);
+ gtk_widget_set_size_request(password_widget, 250, -1);
gtk_entry_set_text(GTK_ENTRY(password_widget), "");
gtk_box_pack_end(GTK_BOX(hbox), password_widget, FALSE, FALSE, 10); /* x-space around input filed */
gtk_widget_show(password_widget);
@@ -654,15 +650,23 @@ gint xsane_authorization_callback(SANE_String_Const resource,
hbox = gtk_hbox_new(TRUE, 10); /* x-space between buttons */
gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 10); /* y-space around buttons */
+#ifdef HAVE_GTK2
+ button = gtk_button_new_from_stock(GTK_STOCK_OK);
+#else
button = gtk_button_new_with_label(BUTTON_OK);
+#endif
GTK_WIDGET_SET_FLAGS(button, GTK_CAN_DEFAULT);
- gtk_signal_connect(GTK_OBJECT(button), "clicked", GTK_SIGNAL_FUNC(xsane_authorization_button_callback), (void *) 1);
+ g_signal_connect(GTK_OBJECT(button), "clicked", GTK_SIGNAL_FUNC(xsane_authorization_button_callback), (void *) 1);
gtk_box_pack_start(GTK_BOX(hbox), button, TRUE, TRUE, 10); /* x-space around OK-button */
gtk_widget_grab_default(button);
gtk_widget_show(button);
+#ifdef HAVE_GTK2
+ button = gtk_button_new_from_stock(GTK_STOCK_CANCEL);
+#else
button = gtk_button_new_with_label(BUTTON_CANCEL);
- gtk_signal_connect(GTK_OBJECT(button), "clicked", GTK_SIGNAL_FUNC(xsane_authorization_button_callback), (void *) -1);
+#endif
+ g_signal_connect(GTK_OBJECT(button), "clicked", GTK_SIGNAL_FUNC(xsane_authorization_button_callback), (void *) -1);
gtk_box_pack_start(GTK_BOX(hbox), button, TRUE, TRUE, 10); /* x-space around cancel-button */
gtk_widget_show(button);
@@ -742,7 +746,7 @@ void xsane_progress_new(char *bar_text, char *info, GtkSignalFunc callback, int
gtk_progress_bar_update(GTK_PROGRESS_BAR(xsane.progress_bar), 0.0);
gtk_widget_set_sensitive(GTK_WIDGET(xsane.cancel_button), TRUE);
gtk_object_set_data(GTK_OBJECT(xsane.cancel_button), "progress-cancel-data-pointer", cancel_data_pointer);
- gtk_signal_connect(GTK_OBJECT(xsane.cancel_button), "clicked", (GtkSignalFunc) xsane_progress_cancel, callback);
+ g_signal_connect(GTK_OBJECT(xsane.cancel_button), "clicked", (GtkSignalFunc) xsane_progress_cancel, callback);
xsane.cancel_callback = callback;
}
@@ -759,7 +763,7 @@ void xsane_progress_clear()
if (xsane.cancel_callback)
{
- gtk_signal_disconnect_by_func(GTK_OBJECT(xsane.cancel_button), (GtkSignalFunc) xsane_progress_cancel, xsane.cancel_callback);
+ g_signal_handlers_disconnect_by_func(GTK_OBJECT(xsane.cancel_button), (GtkSignalFunc) xsane_progress_cancel, xsane.cancel_callback);
xsane.cancel_callback = 0;
}
}
@@ -792,7 +796,7 @@ GtkWidget *xsane_vendor_pixmap_new(GdkWindow *window, GtkWidget *parent)
char filename[PATH_MAX];
GtkWidget *hbox, *vbox;
GtkWidget *pixmapwidget = NULL;
- GdkBitmap *mask;
+ GdkBitmap *mask = NULL;
GdkPixmap *pixmap = NULL;
if (xsane.devlist[xsane.selected_dev]->vendor)
@@ -824,9 +828,9 @@ GtkWidget *xsane_vendor_pixmap_new(GdkWindow *window, GtkWidget *parent)
gtk_container_set_border_width(GTK_CONTAINER(hbox), 0);
gtk_widget_show(hbox);
- pixmapwidget = gtk_pixmap_new(pixmap, mask); /* now add the pixmap */
+ pixmapwidget = gtk_image_new_from_pixmap(pixmap, mask); /* now add the pixmap */
gtk_box_pack_start(GTK_BOX(hbox), pixmapwidget, FALSE /* expand */, FALSE /* fill */, 2);
- gdk_pixmap_unref(pixmap);
+ gdk_drawable_unref(pixmap);
gtk_widget_show(pixmapwidget);
}
@@ -849,13 +853,13 @@ GtkWidget *xsane_toggle_button_new_with_pixmap(GdkWindow *window, GtkWidget *par
xsane_back_gtk_set_tooltip(xsane.tooltips, button, desc);
pixmap = gdk_pixmap_create_from_xpm_d(window, &mask, xsane.bg_trans, (gchar **) xpm_d);
- pixmapwidget = gtk_pixmap_new(pixmap, mask);
+ pixmapwidget = gtk_image_new_from_pixmap(pixmap, mask);
gtk_container_add(GTK_CONTAINER(button), pixmapwidget);
gtk_widget_show(pixmapwidget);
- gdk_pixmap_unref(pixmap);
+ gdk_drawable_unref(pixmap);
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button), *state);
- gtk_signal_connect(GTK_OBJECT(button), "toggled", (GtkSignalFunc) xsane_toggle_button_callback, (GtkObject *) state);
+ g_signal_connect(GTK_OBJECT(button), "toggled", (GtkSignalFunc) xsane_toggle_button_callback, (GtkObject *) state);
gtk_box_pack_start(GTK_BOX(parent), button, FALSE, FALSE, 0);
gtk_widget_show(button);
@@ -878,14 +882,14 @@ GtkWidget *xsane_button_new_with_pixmap(GdkWindow *window, GtkWidget *parent, co
xsane_back_gtk_set_tooltip(xsane.tooltips, button, desc);
pixmap = gdk_pixmap_create_from_xpm_d(window, &mask, xsane.bg_trans, (gchar **) xpm_d);
- pixmapwidget = gtk_pixmap_new(pixmap, mask);
+ pixmapwidget = gtk_image_new_from_pixmap(pixmap, mask);
gtk_container_add(GTK_CONTAINER(button), pixmapwidget);
gtk_widget_show(pixmapwidget);
- gdk_pixmap_unref(pixmap);
+ gdk_drawable_unref(pixmap);
if (xsane_button_callback)
{
- gtk_signal_connect(GTK_OBJECT(button), "clicked", (GtkSignalFunc) xsane_button_callback, data);
+ g_signal_connect(GTK_OBJECT(button), "clicked", (GtkSignalFunc) xsane_button_callback, data);
}
gtk_box_pack_start(GTK_BOX(parent), button, FALSE, FALSE, 0);
gtk_widget_show(button);
@@ -895,22 +899,25 @@ GtkWidget *xsane_button_new_with_pixmap(GdkWindow *window, GtkWidget *parent, co
/* ---------------------------------------------------------------------------------------------------------------------- */
-static int xsane_option_menu_lookup(GSGMenuItem menu_items[], const char *string)
+static int xsane_option_menu_lookup(MenuItem menu_items[], const char *string)
{
int i;
DBG(DBG_proc, "xsane_option_menu_lookup\n");
- for (i = 0; strcmp(menu_items[i].label, string) != 0; ++i);
- return i;
+ for (i = 0; (menu_items[i].label) && strcmp(menu_items[i].label, string); ++i)
+ {
+ }
+
+ return i;
}
/* ---------------------------------------------------------------------------------------------------------------------- */
static void xsane_option_menu_callback(GtkWidget *widget, gpointer data)
{
- GSGMenuItem *menu_item = data;
- GSGDialogElement *elem = menu_item->elem;
+ MenuItem *menu_item = data;
+ DialogElement *elem = menu_item->elem;
const SANE_Option_Descriptor *opt;
int opt_num;
double dval;
@@ -925,20 +932,20 @@ static void xsane_option_menu_callback(GtkWidget *widget, gpointer data)
{
case SANE_TYPE_INT:
sscanf(menu_item->label, "%d", &val);
- break;
+ break;
case SANE_TYPE_FIXED:
sscanf(menu_item->label, "%lg", &dval);
val = SANE_FIX(dval);
- break;
+ break;
case SANE_TYPE_STRING:
valp = menu_item->label;
- break;
+ break;
default:
DBG(DBG_error, "xsane_option_menu_callback: %s %d\n", ERR_UNKNOWN_TYPE, opt->type);
- break;
+ break;
}
xsane_back_gtk_set_option(opt_num, valp, SANE_ACTION_SET_VALUE);
}
@@ -949,16 +956,19 @@ void xsane_option_menu_new(GtkWidget *parent, char *str_list[], const char *val,
void *option_menu_callback, SANE_Int settable, const gchar *widget_name)
{
GtkWidget *option_menu, *menu, *item;
- GSGMenuItem *menu_items;
- GSGDialogElement *elem;
+ MenuItem *menu_items;
+ DialogElement *elem;
int i, num_items;
DBG(DBG_proc, "xsane_option_menu_new\n");
elem = xsane.element + option_number;
- for (num_items = 0; str_list[num_items]; ++num_items);
- menu_items = malloc(num_items * sizeof(menu_items[0]));
+ for (num_items = 0; str_list[num_items]; ++num_items)
+ {
+ }
+
+ menu_items = malloc((num_items + 1) * sizeof(menu_items[0]));
menu = gtk_menu_new();
if (widget_name)
@@ -973,11 +983,11 @@ void xsane_option_menu_new(GtkWidget *parent, char *str_list[], const char *val,
if (option_menu_callback)
{
- gtk_signal_connect(GTK_OBJECT(item), "activate", (GtkSignalFunc) option_menu_callback, menu_items + i);
+ g_signal_connect(GTK_OBJECT(item), "activate", (GtkSignalFunc) option_menu_callback, menu_items + i);
}
else
{
- gtk_signal_connect(GTK_OBJECT(item), "activate", (GtkSignalFunc) xsane_option_menu_callback, menu_items + i);
+ g_signal_connect(GTK_OBJECT(item), "activate", (GtkSignalFunc) xsane_option_menu_callback, menu_items + i);
}
gtk_widget_show(item);
@@ -987,6 +997,11 @@ void xsane_option_menu_new(GtkWidget *parent, char *str_list[], const char *val,
menu_items[i].index = i;
}
+ /* add empty element as end of list marker */
+ menu_items[i].label = NULL;
+ menu_items[i].elem = NULL;
+ menu_items[i].index = 0;
+
option_menu = gtk_option_menu_new();
xsane_back_gtk_set_tooltip(xsane.tooltips, option_menu, desc);
gtk_box_pack_end(GTK_BOX(parent), option_menu, FALSE, FALSE, 2);
@@ -997,7 +1012,7 @@ void xsane_option_menu_new(GtkWidget *parent, char *str_list[], const char *val,
gtk_widget_set_sensitive(option_menu, settable);
- elem->widget = option_menu;
+ elem->widget = option_menu;
elem->menu_size = num_items;
elem->menu = menu_items;
}
@@ -1020,7 +1035,7 @@ void xsane_option_menu_new_with_pixmap(GdkWindow *window, GtkBox *parent, const
gtk_box_pack_start(parent, hbox, FALSE, FALSE, 0);
pixmap = gdk_pixmap_create_from_xpm_d(window, &mask, xsane.bg_trans, (gchar **) xpm_d);
- pixmapwidget = gtk_pixmap_new(pixmap, mask);
+ pixmapwidget = gtk_image_new_from_pixmap(pixmap, mask);
gtk_box_pack_start(GTK_BOX(hbox), pixmapwidget, FALSE, FALSE, 2);
gtk_widget_show(pixmapwidget);
@@ -1030,97 +1045,431 @@ void xsane_option_menu_new_with_pixmap(GdkWindow *window, GtkBox *parent, const
/* ---------------------------------------------------------------------------------------------------------------------- */
-void xsane_scale_new(GtkBox *parent, char *labeltext, const char *desc,
- float min, float max, float quant, float page_step, float page_size,
- int digits, double *val, GtkObject **data, void *xsane_scale_callback, SANE_Int settable)
+static void xsane_range_display_value_right_callback(GtkAdjustment *adjust, gpointer data)
+{
+ gchar buf[256];
+ int digits = (int) data;
+ GtkLabel *label;
+
+ snprintf(buf, sizeof(buf), "%1.*f", digits, adjust->value);
+ label = (GtkLabel *) gtk_object_get_data(GTK_OBJECT(adjust), "value-label");
+ gtk_label_set_text(label, buf);
+}
+
+/* ---------------------------------------------------------------------------------------------------------------------- */
+
+void xsane_range_new(GtkBox *parent, char *labeltext, const char *desc,
+ float min, float max, float quant, float page_step,
+ int digits, double *val, GtkObject **data, void *xsane_range_callback, SANE_Int settable)
{
GtkWidget *hbox;
GtkWidget *label;
- GtkWidget *scale;
+ GtkWidget *slider = NULL;
+ GtkWidget *spinbutton;
+ GtkWidget *value_label;
- DBG(DBG_proc, "xsane_scale_new\n");
+ DBG(DBG_proc, "xsane_range_new\n");
hbox = gtk_hbox_new(FALSE, 5);
- gtk_box_pack_start(parent, hbox, FALSE, FALSE, 0);
+ gtk_box_pack_start(parent, hbox, FALSE, FALSE, 2);
label = gtk_label_new(labeltext);
- gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 2);
+ gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 1);
- *data = gtk_adjustment_new(*val, min, max, quant, page_step, page_size);
- scale = gtk_hscale_new(GTK_ADJUSTMENT(*data));
- xsane_back_gtk_set_tooltip(xsane.tooltips, scale, desc);
- gtk_widget_set_usize(scale, 201, 0); /* minimum scale with = 201 pixels */
- gtk_range_set_update_policy(GTK_RANGE(scale), preferences.gtk_update_policy);
- /* GTK_UPDATE_CONTINUOUS, GTK_UPDATE_DISCONTINUOUS, GTK_UPDATE_DELAYED */
- gtk_scale_set_value_pos(GTK_SCALE(scale), GTK_POS_TOP);
- gtk_scale_set_digits(GTK_SCALE(scale), digits);
- gtk_box_pack_end(GTK_BOX(hbox), scale, FALSE, TRUE, 5); /* make scale not sizeable */
+ *data = gtk_adjustment_new(*val, min, max, quant, page_step, (max-min) * 1e-30);
+ /* 1e-30 => hscrollbar has an unwanted side effect: the maximum is not the maximum */
+ /* of the given range, it is reduced by the page_size, so it has to be very small */
- if (xsane_scale_callback)
+ /* value label */
+ if (preferences.show_range_mode & 8)
{
- gtk_signal_connect(*data, "value_changed", (GtkSignalFunc) xsane_scale_callback, val);
+ value_label = gtk_label_new("");
+ gtk_widget_set_size_request(value_label, 35, -1);
+ gtk_box_pack_end(GTK_BOX(hbox), value_label, FALSE, FALSE, 1);
+
+ g_signal_connect(*data, "value_changed", (GtkSignalFunc) xsane_range_display_value_right_callback, (void *) digits);
+ gtk_object_set_data(GTK_OBJECT(*data), "value-label", value_label);
+ g_signal_emit_by_name(GTK_OBJECT(*data), "value_changed"); /* update value */
+ gtk_widget_show(value_label);
+ gtk_widget_set_sensitive(value_label, settable);
}
- gtk_widget_show(label);
- gtk_widget_show(scale);
- gtk_widget_show(hbox);
+ /* spinbutton */
+ if (preferences.show_range_mode & 4)
+ {
+ spinbutton = gtk_spin_button_new(GTK_ADJUSTMENT(*data), 0, digits);
+ if (preferences.show_range_mode & 3) /* slider also visible */
+ {
+ gtk_widget_set_size_request(spinbutton, 60, -1);
+ }
+ else /* slider not visible */
+ {
+ gtk_widget_set_size_request(spinbutton, 100, -1);
+ }
+ xsane_back_gtk_set_tooltip(xsane.tooltips, spinbutton, desc);
+ gtk_spin_button_set_wrap(GTK_SPIN_BUTTON(spinbutton), FALSE);
+ gtk_box_pack_end(GTK_BOX(hbox), spinbutton, FALSE, FALSE, 5); /* make spinbutton not sizeable */
+ gtk_widget_show(spinbutton);
+ gtk_widget_set_sensitive(spinbutton, settable);
+ }
+
+ /* slider */
+ if (preferences.show_range_mode & 3)
+ {
+ if (preferences.show_range_mode & 1) /* bit 0 (val 1) : scale */
+ {
+ slider = gtk_hscale_new(GTK_ADJUSTMENT(*data));
+ gtk_scale_set_draw_value(GTK_SCALE(slider), FALSE);
+ gtk_scale_set_digits(GTK_SCALE(slider), digits);
+ }
+ else /* bit 1 (val 2) : scrollbar */
+ {
+ slider = gtk_hscrollbar_new(GTK_ADJUSTMENT(*data));
+ }
+ xsane_back_gtk_set_tooltip(xsane.tooltips, slider, desc);
+ gtk_widget_set_size_request(slider, 180, -1);
+ /* GTK_UPDATE_CONTINUOUS, GTK_UPDATE_DISCONTINUOUS, GTK_UPDATE_DELAYED */
+ gtk_range_set_update_policy(GTK_RANGE(slider), preferences.gtk_update_policy);
+ gtk_box_pack_end(GTK_BOX(hbox), slider, FALSE, FALSE, 5); /* make slider not sizeable */
+ gtk_widget_show(slider);
+ gtk_widget_set_sensitive(slider, settable);
+ }
- gtk_widget_set_sensitive(scale, settable);
+ if (xsane_range_callback)
+ {
+ g_signal_connect(*data, "value_changed", (GtkSignalFunc) xsane_range_callback, val);
+ }
+ gtk_widget_show(label);
+ gtk_widget_show(hbox);
}
/* ---------------------------------------------------------------------------------------------------------------------- */
-void xsane_scale_new_with_pixmap(GdkWindow *window, GtkBox *parent, const char *xpm_d[], const char *desc,
- float min, float max, float quant, float page_step, float page_size,
- int digits, double *val, GtkObject **data, int option, void *xsane_scale_callback, SANE_Int settable)
+void xsane_range_new_with_pixmap(GdkWindow *window, GtkBox *parent, const char *xpm_d[], const char *desc,
+ float min, float max, float quant, float page_step,
+ int digits, double *val, GtkObject **data, int option, void *xsane_range_callback, SANE_Int settable)
{
GtkWidget *hbox;
- GtkWidget *scale;
+ GtkWidget *slider = NULL;
+ GtkWidget *spinbutton;
GtkWidget *pixmapwidget;
GdkBitmap *mask;
GdkPixmap *pixmap;
+ GtkWidget *value_label;
- DBG(DBG_proc, "xsane_scale_new_with_pixmap\n");
+ DBG(DBG_proc, "xsane_slider_new_with_pixmap\n");
hbox = gtk_hbox_new(FALSE, 5);
- gtk_box_pack_start(parent, hbox, FALSE, FALSE, 0);
+ gtk_box_pack_start(parent, hbox, FALSE, FALSE, 1);
pixmap = gdk_pixmap_create_from_xpm_d(window, &mask, xsane.bg_trans, (gchar **) xpm_d);
- pixmapwidget = gtk_pixmap_new(pixmap, mask);
+ pixmapwidget = gtk_image_new_from_pixmap(pixmap, mask);
gtk_box_pack_start(GTK_BOX(hbox), pixmapwidget, FALSE, FALSE, 2);
+ gtk_widget_show(pixmapwidget);
+ gdk_drawable_unref(pixmap);
- *data = gtk_adjustment_new(*val, min, max, quant, page_step, page_size);
- scale = gtk_hscale_new(GTK_ADJUSTMENT(*data));
- xsane_back_gtk_set_tooltip(xsane.tooltips, scale, desc);
- gtk_widget_set_usize(scale, 201, 0); /* minimum scale with = 201 pixels */
- gtk_range_set_update_policy(GTK_RANGE(scale), preferences.gtk_update_policy);
- /* GTK_UPDATE_CONTINUOUS, GTK_UPDATE_DISCONTINUOUS, GTK_UPDATE_DELAYED */
- gtk_scale_set_value_pos(GTK_SCALE(scale), GTK_POS_TOP);
- gtk_scale_set_digits(GTK_SCALE(scale), digits);
- gtk_box_pack_end(GTK_BOX(hbox), scale, TRUE, TRUE, 5); /* make scale sizeable */
+ *data = gtk_adjustment_new(*val, min, max, quant, page_step, (max-min) * 1e-30);
+ /* 1e-30 => hscrollbar has an unwanted side effect: the maximum is not the maximum */
+ /* of the given range, it is reduced by the page_size, so it has to be very small */
- if (xsane_scale_callback)
+ /* value label */
+ if (preferences.show_range_mode & 8)
{
- gtk_signal_connect(*data, "value_changed", (GtkSignalFunc) xsane_scale_callback, val);
+ value_label = gtk_label_new("");
+ gtk_widget_set_size_request(value_label, 35, -1);
+ gtk_box_pack_end(GTK_BOX(hbox), value_label, FALSE, FALSE, 1);
+
+ g_signal_connect(*data, "value_changed", (GtkSignalFunc) xsane_range_display_value_right_callback, (void *) digits);
+ gtk_object_set_data(GTK_OBJECT(*data), "value-label", value_label);
+ g_signal_emit_by_name(GTK_OBJECT(*data), "value_changed"); /* update value */
+ gtk_widget_show(value_label);
+ gtk_widget_set_sensitive(value_label, settable);
}
- gtk_widget_show(pixmapwidget);
- gtk_widget_show(scale);
- gtk_widget_show(hbox);
+ /* spinbutton */
+ if (preferences.show_range_mode & 4)
+ {
+ spinbutton = gtk_spin_button_new(GTK_ADJUSTMENT(*data), 0, digits);
+ gtk_widget_set_size_request(spinbutton, 60, -1);
+ xsane_back_gtk_set_tooltip(xsane.tooltips, spinbutton, desc);
+ gtk_spin_button_set_wrap(GTK_SPIN_BUTTON(spinbutton), FALSE);
+ if (preferences.show_range_mode & 3) /* slider also visible */
+ {
+ gtk_box_pack_end(GTK_BOX(hbox), spinbutton, FALSE, FALSE, 5); /* make spinbutton not sizeable */
+ }
+ else /* slider not visible */
+ {
+ gtk_box_pack_end(GTK_BOX(hbox), spinbutton, TRUE, TRUE, 5); /* make spinbutton sizeable */
+ }
+ gtk_widget_show(spinbutton);
+ gtk_widget_set_sensitive(spinbutton, settable);
+ }
- gtk_widget_set_sensitive(scale, settable);
+ /* slider */
+ if (preferences.show_range_mode & 3)
+ {
+ if (preferences.show_range_mode & 1) /* bit 0 (val 1) : scale */
+ {
+ slider = gtk_hscale_new(GTK_ADJUSTMENT(*data));
+ gtk_scale_set_draw_value(GTK_SCALE(slider), FALSE);
+ gtk_scale_set_digits(GTK_SCALE(slider), digits);
+ }
+ else /* bit 1 (val 2) : scrollbar */
+ {
+ slider = gtk_hscrollbar_new(GTK_ADJUSTMENT(*data));
+ }
+ xsane_back_gtk_set_tooltip(xsane.tooltips, slider, desc);
+ gtk_widget_set_size_request(slider, 170, -1);
+ /* GTK_UPDATE_CONTINUOUS, GTK_UPDATE_DISCONTINUOUS, GTK_UPDATE_DELAYED */
+ gtk_range_set_update_policy(GTK_RANGE(slider), preferences.gtk_update_policy);
+ gtk_box_pack_end(GTK_BOX(hbox), slider, TRUE, TRUE, 5); /* make slider sizeable */
+ gtk_widget_show(slider);
+ gtk_widget_set_sensitive(slider, settable);
+ }
- gdk_pixmap_unref(pixmap);
+ if (xsane_range_callback)
+ {
+ g_signal_connect(*data, "value_changed", (GtkSignalFunc) xsane_range_callback, val);
+ }
+
+ gtk_widget_show(hbox);
if (option)
{
- GSGDialogElement *elem;
+ DialogElement *elem;
elem=xsane.element + option;
- elem->data = *data;
- elem->widget = scale;
+ elem->data = *data;
+ elem->widget = slider;
+ }
+}
+
+/* ----------------------------------------------------------------------------------------------------------------- */
+
+static void xsane_browse_filename_callback(GtkWidget *widget, gpointer data)
+{
+ char filename[1024];
+ char windowname[256];
+
+ DBG(DBG_proc, "xsane_browse_filename_callback\n");
+
+ xsane_set_sensitivity(FALSE);
+
+ if (preferences.filename) /* make sure a correct filename is defined */
+ {
+ strncpy(filename, preferences.filename, sizeof(filename));
+ filename[sizeof(filename) - 1] = '\0';
+ }
+ else /* no filename given, take standard filename */
+ {
+ strcpy(filename, OUT_FILENAME);
+ }
+
+ snprintf(windowname, sizeof(windowname), "%s %s %s", xsane.prog_name, WINDOW_OUTPUT_FILENAME, xsane.device_text);
+
+ umask((mode_t) preferences.directory_umask); /* define new file permissions */
+ xsane_back_gtk_get_filename(windowname, filename, sizeof(filename), filename, &preferences.filetype, TRUE, TRUE, FALSE, TRUE);
+ umask(XSANE_DEFAULT_UMASK); /* define new file permissions */
+
+ if (preferences.filename)
+ {
+ free((void *) preferences.filename);
+ }
+
+ preferences.filename = strdup(filename);
+
+ xsane_set_sensitivity(TRUE);
+
+ xsane_back_gtk_filetype_menu_set_history(xsane.filetype_option_menu, preferences.filetype);
+
+ /* correct length of filename counter if it is shorter than minimum length */
+ xsane_update_counter_in_filename(&preferences.filename, FALSE, 0, preferences.filename_counter_len);
+
+ xsane_set_filename(preferences.filename);
+
+ xsane_define_maximum_output_size(); /* is necessary in postscript mode */
+}
+
+/* ---------------------------------------------------------------------------------------------------------------------- */
+
+void xsane_set_filename(gchar *filename)
+{
+ g_signal_handlers_block_by_func(GTK_OBJECT(xsane.outputfilename_entry), (GtkSignalFunc) xsane_outputfilename_changed_callback, NULL);
+ gtk_entry_set_text(GTK_ENTRY(xsane.outputfilename_entry), (char *) filename); /* update filename in entry */
+ gtk_entry_set_position(GTK_ENTRY(xsane.outputfilename_entry), strlen(filename)); /* set cursor to right position of filename */
+
+ g_signal_handlers_unblock_by_func(GTK_OBJECT(xsane.outputfilename_entry), (GtkSignalFunc) xsane_outputfilename_changed_callback, NULL);
+}
+
+/* ---------------------------------------------------------------------------------------------------------------------- */
+
+static void xsane_filename_counter_step_callback(GtkWidget *widget, gpointer data)
+{
+ DBG(DBG_proc, "xsane_filename_counter_step_callback\n");
+
+ preferences.filename_counter_step = (int) data;
+}
+
+/* ---------------------------------------------------------------------------------------------------------------------- */
+
+static void xsane_filetype_callback(GtkWidget *widget, gpointer data)
+{
+ char *new_filetype = (char *) data;
+ char buffer[PATH_MAX];
+ char *filename;
+
+ DBG(DBG_proc, "xsane_filetype_callback\n");
+
+ filename = preferences.filename;
+
+ if ((new_filetype) && (*new_filetype)) /* filetype exists and is not empty (by ext) */
+ {
+ char *extension;
+
+ extension = strrchr(preferences.filename, '.');
+
+ if ((extension) && (extension != preferences.filename))
+ {
+ if ( (!strcasecmp(extension, ".pnm")) || (!strcasecmp(extension, ".raw"))
+ || (!strcasecmp(extension, ".png")) || (!strcasecmp(extension, ".ps"))
+ || (!strcasecmp(extension, ".rgba"))
+ || (!strcasecmp(extension, ".tiff")) || (!strcasecmp(extension, ".tif"))
+ || (!strcasecmp(extension, ".text")) || (!strcasecmp(extension, ".txt"))
+ || (!strcasecmp(extension, ".jpg")) || (!strcasecmp(extension, ".jpeg"))
+ ) /* remove filetype extension */
+ {
+ *extension = 0; /* remove extension */
+ }
+ }
+ snprintf(buffer, sizeof(buffer), "%s%s", filename, new_filetype);
+ free(filename);
+ preferences.filename = strdup(buffer);
+ }
+
+ if (preferences.filetype)
+ {
+ free(preferences.filetype);
+ preferences.filetype = NULL;
+ }
+
+ if (new_filetype)
+ {
+ preferences.filetype = strdup(new_filetype);
+ }
+
+ /* correct length of filename counter if it is shorter than minimum length */
+ xsane_update_counter_in_filename(&preferences.filename, FALSE, 0, preferences.filename_counter_len);
+ xsane_set_filename(preferences.filename);
+ xsane_define_maximum_output_size(); /* is necessary in postscript mode */
+}
+
+/* ---------------------------------------------------------------------------------------------------------------------- */
+
+static void xsane_outputfilename_changed_callback(GtkWidget *widget, gpointer data)
+{
+ DBG(DBG_proc, "xsane_outputfilename_changed_callback\n");
+
+ if (preferences.filename)
+ {
+ free((void *) preferences.filename);
+ }
+ preferences.filename = strdup(gtk_entry_get_text(GTK_ENTRY(widget)));
+
+ xsane_define_maximum_output_size(); /* is necessary in postscript mode */
+}
+
+/* ---------------------------------------------------------------------------------------------------------------------- */
+
+void xsane_outputfilename_new(GtkWidget *vbox)
+{
+ GtkWidget *hbox;
+ GtkWidget *text;
+ GtkWidget *button;
+ GtkWidget *xsane_filename_counter_step_option_menu;
+ GtkWidget *xsane_filename_counter_step_menu;
+ GtkWidget *xsane_filename_counter_step_item;
+ GtkWidget *xsane_label;
+ gchar buf[200];
+ int i,j;
+ int select_item = 0;
+
+ DBG(DBG_proc, "xsane_outputfilename_new\n");
+
+ /* first line: disk icon, filename box */
+
+ hbox = gtk_hbox_new(FALSE, 2);
+ gtk_container_set_border_width(GTK_CONTAINER(hbox), 2);
+ gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 2);
+
+ button = xsane_button_new_with_pixmap(xsane.xsane_window->window, hbox, file_xpm, DESC_BROWSE_FILENAME,
+ (GtkSignalFunc) xsane_browse_filename_callback, NULL);
+ gtk_widget_add_accelerator(button, "clicked", xsane.accelerator_group, GDK_B, GDK_CONTROL_MASK, DEF_GTK_ACCEL_LOCKED);
+
+ text = gtk_entry_new();
+ gtk_widget_set_size_request(text, 80, -1); /* set minimum size */
+ xsane_back_gtk_set_tooltip(xsane.tooltips, text, DESC_FILENAME);
+ gtk_entry_set_max_length(GTK_ENTRY(text), 255);
+ gtk_entry_set_text(GTK_ENTRY(text), (char *) preferences.filename);
+ gtk_entry_set_position(GTK_ENTRY(text), strlen(preferences.filename)); /* set cursor to right position of filename */
+
+ gtk_box_pack_start(GTK_BOX(hbox), text, TRUE, TRUE, 4);
+ g_signal_connect(GTK_OBJECT(text), "changed", (GtkSignalFunc) xsane_outputfilename_changed_callback, NULL);
+
+ xsane.outputfilename_entry = text;
+
+ gtk_widget_show(text);
+ gtk_widget_show(hbox);
+
+
+ /* second line: Step, Type */
+
+ hbox = gtk_hbox_new(FALSE, 2);
+ gtk_container_set_border_width(GTK_CONTAINER(hbox), 2);
+ gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 2);
+
+ /* filename counter step */
+
+ xsane_label = gtk_label_new(TEXT_FILENAME_COUNTER_STEP);
+ gtk_box_pack_start(GTK_BOX(hbox), xsane_label, FALSE, FALSE, 2);
+ gtk_widget_show(xsane_label);
+
+ xsane_filename_counter_step_option_menu = gtk_option_menu_new();
+ xsane_back_gtk_set_tooltip(xsane.tooltips, xsane_filename_counter_step_option_menu, DESC_FILENAME_COUNTER_STEP);
+ gtk_box_pack_start(GTK_BOX(hbox), xsane_filename_counter_step_option_menu, FALSE, FALSE, 2);
+ gtk_widget_show(xsane_filename_counter_step_option_menu);
+ gtk_widget_show(hbox);
+
+ xsane_filename_counter_step_menu = gtk_menu_new();
+
+ select_item = 0;
+ j = -2;
+ for (i=0; i < 5; i++)
+ {
+ snprintf(buf, sizeof(buf), "%+d", j);
+ xsane_filename_counter_step_item = gtk_menu_item_new_with_label(buf);
+ gtk_container_add(GTK_CONTAINER(xsane_filename_counter_step_menu), xsane_filename_counter_step_item);
+ g_signal_connect(GTK_OBJECT(xsane_filename_counter_step_item), "activate", (GtkSignalFunc) xsane_filename_counter_step_callback, (void *) j);
+ gtk_widget_show(xsane_filename_counter_step_item);
+ if (preferences.filename_counter_step == j++)
+ {
+ select_item = i;
+ }
}
+
+ gtk_option_menu_set_menu(GTK_OPTION_MENU(xsane_filename_counter_step_option_menu), xsane_filename_counter_step_menu);
+ gtk_option_menu_set_history(GTK_OPTION_MENU(xsane_filename_counter_step_option_menu), select_item);
+
+ xsane.filetype_option_menu = xsane_back_gtk_filetype_menu_new(preferences.filetype, (GtkSignalFunc) xsane_filetype_callback);
+ gtk_box_pack_end(GTK_BOX(hbox), xsane.filetype_option_menu, FALSE, FALSE, 2);
+ gtk_widget_show(xsane.filetype_option_menu);
+
+ xsane_label = gtk_label_new(TEXT_FILETYPE); /* opposite order because of box_pack_end */
+ gtk_box_pack_end(GTK_BOX(hbox), xsane_label, FALSE, FALSE, 2);
+ gtk_widget_show(xsane_label);
+
+ gtk_widget_show(text);
+ gtk_widget_show(hbox);
}
/* ---------------------------------------------------------------------------------------------------------------------- */
@@ -1138,6 +1487,20 @@ void xsane_separator_new(GtkWidget *xsane_parent, int dist)
/* ---------------------------------------------------------------------------------------------------------------------- */
+void xsane_vseparator_new(GtkWidget *xsane_parent, int dist)
+{
+ GtkWidget *xsane_vseparator;
+
+ DBG(DBG_proc, "xsane_vseparator_new\n");
+
+ xsane_vseparator = gtk_vseparator_new();
+ gtk_box_pack_start(GTK_BOX(xsane_parent), xsane_vseparator, FALSE, FALSE, dist);
+ gtk_widget_show(xsane_vseparator);
+
+}
+
+/* ---------------------------------------------------------------------------------------------------------------------- */
+
GtkWidget *xsane_info_table_text_new(GtkWidget *table, gchar *text, int row, int colomn)
{
GtkWidget *hbox, *label;
@@ -1293,8 +1656,6 @@ void xsane_update_param(void *arg)
void xsane_define_output_filename(void)
{
- char buffer[256];
-
DBG(DBG_proc, "xsane_define_output_filename\n");
if (xsane.output_filename)
@@ -1305,52 +1666,44 @@ void xsane_define_output_filename(void)
if (!xsane.force_filename)
{
- if (xsane.filetype)
- {
- snprintf(buffer, sizeof(buffer), "%s%s", preferences.filename, xsane.filetype);
- xsane.output_filename = strdup(buffer);
- }
- else
- {
- xsane.output_filename = strdup(preferences.filename);
- }
+ xsane.output_filename = strdup(preferences.filename);
}
else
{
- xsane.output_filename = strdup(xsane.external_filename);
+ xsane.output_filename = strdup(xsane.external_filename);
}
}
/* ---------------------------------------------------------------------------------------------------------------------- */
-int xsane_identify_output_format(char *filename, char **ext)
+int xsane_identify_output_format(char *filename, char *filetype, char **ext)
{
char *extension;
int output_format=-1;
DBG(DBG_proc, "xsane_identify_output_format\n");
- extension = strrchr(filename, '.');
- if (extension)
+ if ((filetype) && (*filetype))
{
- extension++; /* skip "." */
+ extension = filetype+1; /* go to filetype, skip leading dot */
+ }
+ else
+ {
+ extension = strrchr(filename, '.');
+ if (extension)
+ {
+ extension++; /* skip "." */
+ }
}
output_format = XSANE_UNKNOWN;
if (extension)
{
- if (!strcasecmp(extension, "raw"))
+ if ( (!strcasecmp(extension, "pnm")) || (!strcasecmp(extension, "ppm")) ||
+ (!strcasecmp(extension, "pgm")) || (!strcasecmp(extension, "pbm")) )
{
- if (xsane.param.depth == 16)
- {
- output_format = XSANE_RAW16;
- }
- }
- else if ( (!strcasecmp(extension, "pnm")) || (!strcasecmp(extension, "ppm")) ||
- (!strcasecmp(extension, "pgm")) || (!strcasecmp(extension, "pbm")) )
- {
- if (xsane.param.depth == 16)
+ if ((xsane.param.depth == 16) && (!preferences.reduce_16bit_to_8bit) )
{
output_format = XSANE_PNM16;
}
@@ -1359,6 +1712,10 @@ int xsane_identify_output_format(char *filename, char **ext)
output_format = XSANE_PNM;
}
}
+ else if ( (!strcasecmp(extension, "txt")) || (!strcasecmp(extension, "text")) )
+ {
+ output_format = XSANE_TEXT;
+ }
#ifdef HAVE_LIBPNG
#ifdef HAVE_LIBZ
else if (!strcasecmp(extension, "png"))
@@ -1420,7 +1777,7 @@ void xsane_change_working_directory(void)
sprintf(windowname, "%s %s %s", xsane.prog_name, WINDOW_CHANGE_WORKING_DIR, xsane.device_text);
if (getcwd(filename, sizeof(filename)))
{
- xsane_back_gtk_get_filename(windowname, filename, sizeof(filename), filename, TRUE, FALSE, TRUE);
+ xsane_back_gtk_get_filename(windowname, filename, sizeof(filename), filename, NULL, TRUE, FALSE, TRUE, FALSE);
if (chdir(filename))
{
char buf[256];
@@ -1430,6 +1787,14 @@ void xsane_change_working_directory(void)
xsane_set_sensitivity(TRUE);
return;
}
+ else
+ {
+ if (preferences.working_directory)
+ {
+ free(preferences.working_directory);
+ }
+ preferences.working_directory = strdup(filename);
+ }
}
xsane_set_sensitivity(TRUE);
@@ -1437,55 +1802,79 @@ void xsane_change_working_directory(void)
/* ---------------------------------------------------------------------------------------------------------------------- */
-static int license_flag;
-static GtkWidget *license_dialog = NULL;
+static int eula_accept_flag;
+static GtkWidget *eula_dialog = NULL;
-static void xsane_license_button_callback(GtkWidget *widget, gpointer data)
+static gboolean xsane_eula_delete_event(GtkWidget *widget, GdkEvent *event, gpointer data)
{
- license_flag = (int) data;
+ eula_accept_flag = (int) data;
- DBG(DBG_proc ,"xsane_license_button_callback(%d)\n", license_flag);
+ DBG(DBG_proc ,"xsane_eula_delete_event(%d)\n", eula_accept_flag);
+ eula_dialog = NULL;
- gtk_widget_destroy(license_dialog);
- license_dialog = NULL;
+ return FALSE; /* continue with original delete even routine */
}
-/* ---------------------------------------------------------------------------------------------------------------------- */
+/* -------------------------------------- */
+
+static void xsane_eula_button_callback(GtkWidget *widget, gpointer data)
+{
+ eula_accept_flag = (int) data;
+
+ DBG(DBG_proc ,"xsane_eula_button_callback(%d)\n", eula_accept_flag);
+
+ gtk_widget_destroy(eula_dialog);
+ eula_dialog = NULL;
+}
+
+/* -------------------------------------- */
-int xsane_display_license(int ask_for_accept)
+int xsane_display_eula(int ask_for_accept)
/* returns FALSE if accepted, TRUE if not accepted */
{
- GtkWidget *vbox, *hbox, *button, *label;
- GtkWidget *text, *vscrollbar;
+ GtkWidget *vbox, *hbox, *button, *label, *frame;
GtkAccelGroup *accelerator_group;
char buf[1024];
char filename[PATH_MAX];
FILE *infile;
- DBG(DBG_proc, "xsane_display_license(%d)\n", ask_for_accept);
+ DBG(DBG_proc, "xsane_display_eula(%d)\n", ask_for_accept);
- if (license_dialog) /* make sure the dialog is only opend once */
+ if (eula_dialog) /* make sure the dialog is only opend once */
{
return 0;
}
- license_dialog = gtk_window_new(GTK_WINDOW_DIALOG);
- gtk_widget_set_usize(license_dialog, 550, 580);
- gtk_window_set_position(GTK_WINDOW(license_dialog), GTK_WIN_POS_CENTER);
- gtk_window_set_policy(GTK_WINDOW(license_dialog), FALSE, TRUE, FALSE);
- gtk_signal_connect(GTK_OBJECT(license_dialog), "delete_event",
- GTK_SIGNAL_FUNC(xsane_license_button_callback), (void *) -1); /* -1 = cancel */
- snprintf(buf, sizeof(buf), "%s %s", xsane.prog_name, WINDOW_LICENSE);
- gtk_window_set_title(GTK_WINDOW(license_dialog), buf);
- xsane_set_window_icon(license_dialog, 0);
-
+ eula_dialog = gtk_window_new(GTK_WINDOW_TOPLEVEL);
+ gtk_widget_set_size_request(eula_dialog, 550, 580);
+ gtk_window_set_position(GTK_WINDOW(eula_dialog), GTK_WIN_POS_CENTER);
+ gtk_window_set_resizable(GTK_WINDOW(eula_dialog), TRUE);
+ g_signal_connect(GTK_OBJECT(eula_dialog), "delete_event", GTK_SIGNAL_FUNC(xsane_eula_delete_event), (void *) -1); /* -1 = cancel */
+ snprintf(buf, sizeof(buf), "%s %s", xsane.prog_name, WINDOW_EULA);
+ gtk_window_set_title(GTK_WINDOW(eula_dialog), buf);
accelerator_group = gtk_accel_group_new();
- gtk_accel_group_attach(accelerator_group, GTK_OBJECT(license_dialog));
+ gtk_window_add_accel_group(GTK_WINDOW(eula_dialog), accelerator_group);
+
+#if 0
+ xsane_set_window_icon(eula_dialog, 0);
+#endif
+
+ /* create a frame */
+ frame = gtk_frame_new(NULL);
+ gtk_container_set_border_width(GTK_CONTAINER(frame), 10);
+ gtk_frame_set_shadow_type(GTK_FRAME(frame), GTK_SHADOW_ETCHED_IN);
+ gtk_container_add(GTK_CONTAINER(eula_dialog), frame);
+ gtk_widget_show(frame);
vbox = gtk_vbox_new(FALSE, 5);
gtk_container_set_border_width(GTK_CONTAINER(vbox), 5);
- gtk_container_add(GTK_CONTAINER(license_dialog), vbox);
+ gtk_container_add(GTK_CONTAINER(frame), vbox);
gtk_widget_show(vbox);
+#if 1
+ /* this is normally done directly after gtk_window_set_title() */
+ /* but gtk crashes when we would do that and select a text with the mouse */
+ xsane_set_window_icon(eula_dialog, 0);
+#endif
/* display XSane copyright message */
snprintf(buf, sizeof(buf), "XSane %s %s\n"
@@ -1496,7 +1885,7 @@ int xsane_display_license(int ask_for_accept)
"%s %s\n",
TEXT_VERSION, XSANE_VERSION,
XSANE_COPYRIGHT_SIGN, XSANE_COPYRIGHT_TXT,
- TEXT_GPL,
+ TEXT_EULA,
TEXT_HOMEPAGE, XSANE_HOMEPAGE,
TEXT_EMAIL, XSANE_EMAIL);
@@ -1504,52 +1893,103 @@ int xsane_display_license(int ask_for_accept)
gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0);
gtk_widget_show(label);
- /* add hbox with text and scrollbar to display the license text */
+ /* add hbox with text and scrollbar to display the eula text */
hbox = gtk_hbox_new(FALSE, 2);
gtk_container_set_border_width(GTK_CONTAINER(hbox), 4);
gtk_box_pack_start(GTK_BOX(vbox), hbox, TRUE, TRUE, 0);
gtk_widget_show(hbox);
+
+#ifdef HAVE_GTK_TEXT_VIEW_H
+ {
+ GtkWidget *scrolled_window, *text_view;
+ GtkTextBuffer *text_buffer;
+
+ /* create a scrolled window to get a vertical scrollbar */
+ scrolled_window = gtk_scrolled_window_new(NULL, NULL);
+ gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolled_window),
+ GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
+ gtk_container_add(GTK_CONTAINER(hbox), scrolled_window);
+ gtk_widget_show(scrolled_window);
- /* Create the GtkText widget */
- text = gtk_text_new(NULL, NULL);
- gtk_text_set_editable(GTK_TEXT(text), FALSE); /* text is not editable */
- gtk_text_set_word_wrap(GTK_TEXT(text), TRUE); /* wrap complete words */
- gtk_box_pack_start(GTK_BOX(hbox), text, TRUE, TRUE, 0);
- gtk_widget_show(text);
+ /* create the gtk_text_view widget */
+ text_view = gtk_text_view_new();
+ gtk_text_view_set_editable(GTK_TEXT_VIEW(text_view), FALSE);
+ gtk_text_view_set_wrap_mode(GTK_TEXT_VIEW(text_view), GTK_WRAP_WORD);
+ gtk_container_add(GTK_CONTAINER(scrolled_window), text_view);
+ gtk_widget_show(text_view);
+
+ /* get the text_buffer widget and insert the text from file */
+ text_buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(text_view));
+
+ xsane_back_gtk_make_path(sizeof(filename), filename, "xsane", 0, "xsane-eula", 0, ".txt", XSANE_PATH_SYSTEM);
+ infile = fopen(filename, "r");
+
+ if (infile)
+ {
+ char buffer[4096];
+ int nchars;
+
+ while (!feof(infile))
+ {
+ nchars = fread(buffer, 1, 4096, infile);
+ gtk_text_buffer_insert_at_cursor(text_buffer, buffer, nchars);
+ }
- /* Add a vertical scrollbar to the GtkText widget */
- vscrollbar = gtk_vscrollbar_new(GTK_TEXT(text)->vadj);
- gtk_box_pack_start(GTK_BOX(hbox), vscrollbar, FALSE, FALSE, 0);
- gtk_widget_show(vscrollbar);
+ fclose(infile);
+ }
+ else
+ {
+ DBG(DBG_error0, "ERROR: eula text not found. Looks like xsane is not installed correct.\n");
+ return TRUE;
+ }
+
+ }
+#else /* we do not have gtk_text_view, so we use gtk_text */
+ {
+ GtkWidget *text, *vscrollbar;
+
+ /* Create the gtk_text widget */
+ text = gtk_text_new(NULL, NULL);
+ gtk_text_set_editable(GTK_TEXT(text), FALSE); /* text is not editable */
+ gtk_text_set_word_wrap(GTK_TEXT(text), TRUE); /* wrap complete words */
+ gtk_box_pack_start(GTK_BOX(hbox), text, TRUE, TRUE, 0);
+ gtk_widget_show(text);
+
+ /* Add a vertical scrollbar to the GtkText widget */
+ vscrollbar = gtk_vscrollbar_new(GTK_TEXT(text)->vadj);
+ gtk_box_pack_start(GTK_BOX(hbox), vscrollbar, FALSE, FALSE, 0);
+ gtk_widget_show(vscrollbar);
- /* Freeze the text widget, ready for multiple updates */
- gtk_text_freeze(GTK_TEXT(text));
+ /* Freeze the text widget, ready for multiple updates */
+ gtk_text_freeze(GTK_TEXT(text));
- /* Load the file text.c into the text window */
- xsane_back_gtk_make_path(sizeof(filename), filename, "xsane", 0, "xsane-license", 0, ".txt", XSANE_PATH_SYSTEM);
- infile = fopen(filename, "r");
+ /* Load the file text.c into the text window */
+ xsane_back_gtk_make_path(sizeof(filename), filename, "xsane", 0, "xsane-eula", 0, ".txt", XSANE_PATH_SYSTEM);
+ infile = fopen(filename, "r");
- if (infile)
- {
- char buffer[4096];
- int nchars;
+ if (infile)
+ {
+ char buffer[4096];
+ int nchars;
+
+ while (!feof(infile))
+ {
+ nchars = fread(buffer, 1, 4096, infile);
+ gtk_text_insert(GTK_TEXT(text), NULL, NULL, NULL, buffer, nchars);
+ }
- while (!feof(infile))
+ fclose(infile);
+ }
+ else
{
- nchars = fread(buffer, 1, 4096, infile);
- gtk_text_insert(GTK_TEXT(text), NULL, NULL, NULL, buffer, nchars);
+ DBG(DBG_error0, "ERROR: eula text not found. Looks like xsane is not installed correct.\n");
+ return TRUE;
}
-
- fclose(infile);
- }
- else
- {
- DBG(DBG_error0, "ERROR: license text not found. Looks like xsane is not installed correct.\n");
- return TRUE;
- }
- /* Thaw the text widget, allowing the updates to become visible */
- gtk_text_thaw(GTK_TEXT(text));
+ /* Thaw the text widget, allowing the updates to become visible */
+ gtk_text_thaw(GTK_TEXT(text));
+ }
+#endif
@@ -1560,24 +2000,28 @@ int xsane_display_license(int ask_for_accept)
if (ask_for_accept) /* show accept + not accept buttons */
{
button = gtk_button_new_with_label(BUTTON_ACCEPT);
- gtk_signal_connect(GTK_OBJECT(button), "clicked", (GtkSignalFunc) xsane_license_button_callback, (void *) 0 /* accept */);
+ g_signal_connect(GTK_OBJECT(button), "clicked", (GtkSignalFunc) xsane_eula_button_callback, (void *) 0 /* accept */);
gtk_container_add(GTK_CONTAINER(hbox), button);
gtk_widget_show(button);
button = gtk_button_new_with_label(BUTTON_NOT_ACCEPT);
- gtk_widget_add_accelerator(button, "clicked", accelerator_group, GDK_Escape, 0, GTK_ACCEL_LOCKED);
+ gtk_widget_add_accelerator(button, "clicked", accelerator_group, GDK_Escape, 0, DEF_GTK_ACCEL_LOCKED);
GTK_WIDGET_SET_FLAGS(button, GTK_CAN_DEFAULT);
- gtk_signal_connect(GTK_OBJECT(button), "clicked", (GtkSignalFunc) xsane_license_button_callback, (void *) 1 /* not accept */);
+ g_signal_connect(GTK_OBJECT(button), "clicked", (GtkSignalFunc) xsane_eula_button_callback, (void *) 1 /* not accept */);
gtk_container_add(GTK_CONTAINER(hbox), button);
gtk_widget_grab_default(button);
gtk_widget_show(button);
}
else /* show close button */
{
+#ifdef HAVE_GTK2
+ button = gtk_button_new_from_stock(GTK_STOCK_CLOSE);
+#else
button = gtk_button_new_with_label(BUTTON_CLOSE);
- gtk_widget_add_accelerator(button, "clicked", accelerator_group, GDK_Escape, 0, GTK_ACCEL_LOCKED);
+#endif
+ gtk_widget_add_accelerator(button, "clicked", accelerator_group, GDK_Escape, 0, DEF_GTK_ACCEL_LOCKED);
GTK_WIDGET_SET_FLAGS(button, GTK_CAN_DEFAULT);
- gtk_signal_connect(GTK_OBJECT(button), "clicked", (GtkSignalFunc) xsane_license_button_callback, (void *) 0 /* ok = accept */);
+ g_signal_connect(GTK_OBJECT(button), "clicked", (GtkSignalFunc) xsane_eula_button_callback, (void *) 0 /* ok = accept */);
gtk_container_add(GTK_CONTAINER(hbox), button);
gtk_widget_grab_default(button);
gtk_widget_show(button);
@@ -1585,16 +2029,16 @@ int xsane_display_license(int ask_for_accept)
gtk_widget_show(hbox);
gtk_widget_show(vbox);
- gtk_widget_show(license_dialog);
+ gtk_widget_show(eula_dialog);
if (ask_for_accept == 0) /* do not ask for accept */
{
return 0;
}
- license_flag = -255;
+ eula_accept_flag = -255;
- while(license_flag == -255)
+ while(eula_accept_flag == -255)
{
gtk_main_iteration(); /* allow gtk to react to user action */
}
@@ -1604,29 +2048,241 @@ int xsane_display_license(int ask_for_accept)
gtk_main_iteration();
}
- return license_flag;
+ return eula_accept_flag;
+}
+
+/* ---------------------------------------------------------------------------------------------------------------------- */
+
+static GtkWidget *license_dialog = NULL;
+
+static void xsane_close_license_dialog_callback(GtkWidget *widget, gpointer data)
+{
+ DBG(DBG_proc ,"xsane_close_license_dialog_callback\n");
+
+ gtk_widget_destroy(license_dialog);
+ license_dialog = NULL;
+}
+
+/* ------------------------------------------------ */
+
+static gboolean xsane_license_dialog_delete_event(GtkWidget *widget, GdkEvent *event, gpointer data)
+{
+ DBG(DBG_proc ,"xsane_license_dialog_delete_event\n");
+
+ license_dialog = NULL;
+
+ return FALSE; /* continue with original delete even routine */
+}
+
+/* ------------------------------------------------ */
+
+void xsane_display_gpl(void)
+{
+ GtkWidget *vbox, *hbox, *button, *label, *frame;
+ GtkAccelGroup *accelerator_group;
+ char buf[1024];
+ char filename[PATH_MAX];
+ FILE *infile;
+
+ if (license_dialog) /* make sure the dialog is only opend once */
+ {
+ return;
+ }
+
+ license_dialog = gtk_window_new(GTK_WINDOW_TOPLEVEL);
+ gtk_widget_set_size_request(license_dialog, 550, 580);
+ gtk_window_set_position(GTK_WINDOW(license_dialog), GTK_WIN_POS_CENTER);
+ gtk_window_set_resizable(GTK_WINDOW(license_dialog), TRUE);
+ g_signal_connect(GTK_OBJECT(license_dialog), "delete_event", GTK_SIGNAL_FUNC(xsane_license_dialog_delete_event), NULL);
+ snprintf(buf, sizeof(buf), "%s: %s", xsane.prog_name, WINDOW_GPL);
+ gtk_window_set_title(GTK_WINDOW(license_dialog), buf);
+ accelerator_group = gtk_accel_group_new();
+ gtk_window_add_accel_group(GTK_WINDOW(license_dialog), accelerator_group);
+
+#if 0
+ xsane_set_window_icon(license_dialog, 0);
+#endif
+
+ /* create a frame */
+ frame = gtk_frame_new(NULL);
+ gtk_container_set_border_width(GTK_CONTAINER(frame), 10);
+ gtk_frame_set_shadow_type(GTK_FRAME(frame), GTK_SHADOW_ETCHED_IN);
+ gtk_container_add(GTK_CONTAINER(license_dialog), frame);
+ gtk_widget_show(frame);
+
+ vbox = gtk_vbox_new(FALSE, 5);
+ gtk_container_set_border_width(GTK_CONTAINER(vbox), 5);
+ gtk_container_add(GTK_CONTAINER(frame), vbox);
+ gtk_widget_show(vbox);
+#if 1
+ /* this is normally done directly after gtk_window_set_title() */
+ /* but gtk crashes when we would do that and select a text with the mouse */
+ xsane_set_window_icon(license_dialog, 0);
+#endif
+
+ /* display XSane copyright message */
+ snprintf(buf, sizeof(buf), "XSane %s %s\n"
+ "%s %s\n"
+ "\n"
+ "%s\n"
+ "%s %s\n"
+ "%s %s\n",
+ TEXT_VERSION, XSANE_VERSION,
+ XSANE_COPYRIGHT_SIGN, XSANE_COPYRIGHT_TXT,
+ TEXT_GPL,
+ TEXT_HOMEPAGE, XSANE_HOMEPAGE,
+ TEXT_EMAIL, XSANE_EMAIL);
+
+ label = gtk_label_new(buf);
+ gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0);
+ gtk_widget_show(label);
+
+ /* add hbox with text and scrollbar to display the license text */
+ hbox = gtk_hbox_new(FALSE, 2);
+ gtk_container_set_border_width(GTK_CONTAINER(hbox), 4);
+ gtk_box_pack_start(GTK_BOX(vbox), hbox, TRUE, TRUE, 0);
+ gtk_widget_show(hbox);
+
+#ifdef HAVE_GTK_TEXT_VIEW_H
+ {
+ GtkWidget *scrolled_window, *text_view;
+ GtkTextBuffer *text_buffer;
+
+ /* create a scrolled window to get a vertical scrollbar */
+ scrolled_window = gtk_scrolled_window_new(NULL, NULL);
+ gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolled_window),
+ GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
+ gtk_container_add(GTK_CONTAINER(hbox), scrolled_window);
+ gtk_widget_show(scrolled_window);
+
+ /* create the gtk_text_view widget */
+ text_view = gtk_text_view_new();
+ gtk_text_view_set_editable(GTK_TEXT_VIEW(text_view), FALSE);
+ gtk_text_view_set_wrap_mode(GTK_TEXT_VIEW(text_view), GTK_WRAP_WORD);
+ gtk_container_add(GTK_CONTAINER(scrolled_window), text_view);
+ gtk_widget_show(text_view);
+
+ /* get the text_buffer widget and insert the text from file */
+ text_buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(text_view));
+
+ xsane_back_gtk_make_path(sizeof(filename), filename, "xsane", 0, "xsane-gpl", 0, ".txt", XSANE_PATH_SYSTEM);
+ infile = fopen(filename, "r");
+
+ if (infile)
+ {
+ char buffer[4096];
+ int nchars;
+
+ while (!feof(infile))
+ {
+ nchars = fread(buffer, 1, 4096, infile);
+ gtk_text_buffer_insert_at_cursor(text_buffer, buffer, nchars);
+ }
+
+ fclose(infile);
+ }
+ else
+ {
+ DBG(DBG_error0, "ERROR: license text not found. Looks like xsane is not installed correct.\n");
+ return;
+ }
+
+ }
+#else /* we do not have gtk_text_view, so we use gtk_text */
+ {
+ GtkWidget *text, *vscrollbar;
+
+ /* Create the gtk_text widget */
+ text = gtk_text_new(NULL, NULL);
+ gtk_text_set_editable(GTK_TEXT(text), FALSE); /* text is not editable */
+ gtk_text_set_word_wrap(GTK_TEXT(text), TRUE); /* wrap complete words */
+ gtk_box_pack_start(GTK_BOX(hbox), text, TRUE, TRUE, 0);
+ gtk_widget_show(text);
+
+ /* Add a vertical scrollbar to the GtkText widget */
+ vscrollbar = gtk_vscrollbar_new(GTK_TEXT(text)->vadj);
+ gtk_box_pack_start(GTK_BOX(hbox), vscrollbar, FALSE, FALSE, 0);
+ gtk_widget_show(vscrollbar);
+
+ /* Freeze the text widget, ready for multiple updates */
+ gtk_text_freeze(GTK_TEXT(text));
+
+ /* Load the file text.c into the text window */
+ xsane_back_gtk_make_path(sizeof(filename), filename, "xsane", 0, "xsane-gpl", 0, ".txt", XSANE_PATH_SYSTEM);
+ infile = fopen(filename, "r");
+
+ if (infile)
+ {
+ char buffer[4096];
+ int nchars;
+
+ while (!feof(infile))
+ {
+ nchars = fread(buffer, 1, 4096, infile);
+ gtk_text_insert(GTK_TEXT(text), NULL, NULL, NULL, buffer, nchars);
+ }
+
+ fclose(infile);
+ }
+ else
+ {
+ DBG(DBG_error0, "ERROR: license text not found. Looks like xsane is not installed correct.\n");
+ return;
+ }
+
+ /* Thaw the text widget, allowing the updates to become visible */
+ gtk_text_thaw(GTK_TEXT(text));
+ }
+#endif
+
+
+
+ hbox = gtk_hbox_new(FALSE, 2);
+ gtk_container_set_border_width(GTK_CONTAINER(hbox), 4);
+ gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
+
+#ifdef HAVE_GTK2
+ button = gtk_button_new_from_stock(GTK_STOCK_CLOSE);
+#else
+ button = gtk_button_new_with_label(BUTTON_CLOSE);
+#endif
+ gtk_widget_add_accelerator(button, "clicked", accelerator_group, GDK_Escape, 0, DEF_GTK_ACCEL_LOCKED);
+ GTK_WIDGET_SET_FLAGS(button, GTK_CAN_DEFAULT);
+ g_signal_connect(GTK_OBJECT(button), "clicked", (GtkSignalFunc) xsane_close_license_dialog_callback, (void *) 0 /* ok = accept */);
+ gtk_container_add(GTK_CONTAINER(hbox), button);
+ gtk_widget_grab_default(button);
+ gtk_widget_show(button);
+
+ gtk_widget_show(hbox);
+ gtk_widget_show(vbox);
+ gtk_widget_show(license_dialog);
}
/* ---------------------------------------------------------------------------------------------------------------------- */
-void xsane_widget_get_uposition(GtkWidget *gtk_window, gint *x, gint *y)
+void xsane_window_get_position(GtkWidget *gtk_window, gint *x, gint *y)
{
+#ifdef USE_GTK2_WINDOW_GET_POSITION
+ gtk_window_get_position(GTK_WINDOW(gtk_window), x, y);
+#else
if (xsane.get_deskrelative_origin)
{
- DBG(DBG_proc, "xsane_widget_get_uposition(deskrelative)\n");
+ DBG(DBG_proc, "xsane_window_get_position(deskrelative)\n");
gdk_window_get_deskrelative_origin(gtk_window->window, x, y);
}
else
{
- DBG(DBG_proc, "xsane_widget_get_uposition(root)\n");
+ DBG(DBG_proc, "xsane_window_get_position(root)\n");
gdk_window_get_root_origin(gtk_window->window, x, y);
}
+#endif
}
/* ---------------------------------------------------------------------------------------------------------------------- */
void xsane_widget_test_uposition(GtkWidget *gtk_window)
{
+#ifndef USE_GTK2_WINDOW_GET_POSITION
gint x, y, x_orig, y_orig;
DBG(DBG_proc, "xsane_widget_test_uposition\n");
@@ -1638,16 +2294,16 @@ void xsane_widget_test_uposition(GtkWidget *gtk_window)
gtk_main_iteration();
}
- xsane_widget_get_uposition(gtk_window, &x, &y);
- xsane_widget_get_uposition(gtk_window, &x, &y);
+ xsane_window_get_position(gtk_window, &x, &y);
+ xsane_window_get_position(gtk_window, &x, &y);
DBG(DBG_info, "xsane_widget_test_uposition: original position = %d, %d\n", x, y);
x_orig = x;
y_orig = y;
- gtk_widget_set_uposition(gtk_window, x, y);
+ gtk_window_move(GTK_WINDOW(gtk_window), x, y);
- xsane_widget_get_uposition(gtk_window, &x, &y);
+ xsane_window_get_position(gtk_window, &x, &y);
DBG(DBG_info, "xsane_widget_test_uposition: new position = %d, %d\n", x, y);
if ( (x != x_orig) || (y != y_orig) )
@@ -1659,6 +2315,132 @@ void xsane_widget_test_uposition(GtkWidget *gtk_window)
{
DBG(DBG_proc, "xsane_widget_test_uposition: using root function\n");
}
+#endif
}
/* ---------------------------------------------------------------------------------------------------------------------- */
+
+static int xsane_front_gtk_getname_button;
+
+static void xsane_front_gtk_getname_button_callback(GtkWidget *widget, gpointer data)
+{
+ DBG(DBG_proc, "xsane_front_gtk_getname_button_callback\n");
+
+ xsane_front_gtk_getname_button = (int) data;
+}
+
+/* ---------------------------------------------------------------------------------------------------------------------- */
+
+int xsane_front_gtk_getname_dialog(const char *dialog_title, const char *desc_text, char *oldname, char **newname)
+{
+ GtkWidget *getname_dialog;
+ GtkWidget *text;
+ GtkWidget *button;
+ GtkWidget *vbox, *hbox;
+ GtkAccelGroup *accelerator_group;
+ char buf[256];
+
+ DBG(DBG_proc, "xsane_getname_dialog, oldname = %s\n", oldname);
+
+ getname_dialog = gtk_window_new(GTK_WINDOW_TOPLEVEL);
+ xsane_set_window_icon(getname_dialog, 0);
+
+ /* set getname dialog */
+ gtk_window_set_position(GTK_WINDOW(getname_dialog), GTK_WIN_POS_CENTER);
+ gtk_window_set_resizable(GTK_WINDOW(getname_dialog), FALSE);
+ snprintf(buf, sizeof(buf), "%s %s", xsane.prog_name, dialog_title);
+ gtk_window_set_title(GTK_WINDOW(getname_dialog), buf);
+ g_signal_connect(GTK_OBJECT(getname_dialog), "delete_event", (GtkSignalFunc) xsane_front_gtk_getname_button_callback, (void *) -1);
+ gtk_widget_show(getname_dialog);
+
+ /* set the main vbox */
+ vbox = gtk_vbox_new(FALSE, 0);
+ gtk_container_set_border_width(GTK_CONTAINER(vbox), 0);
+ gtk_container_add(GTK_CONTAINER(getname_dialog), vbox);
+ gtk_widget_show(vbox);
+
+ /* set the main hbox */
+ hbox = gtk_hbox_new(FALSE, 0);
+ xsane_separator_new(vbox, 2);
+ gtk_box_pack_end(GTK_BOX(vbox), hbox, FALSE, FALSE, 5);
+ gtk_container_set_border_width(GTK_CONTAINER(hbox), 5);
+ gtk_widget_show(hbox);
+
+ text = gtk_entry_new_with_max_length(64);
+ xsane_back_gtk_set_tooltip(xsane.tooltips, text, desc_text);
+ gtk_entry_set_text(GTK_ENTRY(text), oldname);
+ gtk_widget_set_size_request(text, 300, -1);
+ gtk_box_pack_start(GTK_BOX(vbox), text, TRUE, TRUE, 4);
+ gtk_widget_show(text);
+
+ accelerator_group = gtk_accel_group_new();
+ gtk_window_add_accel_group(GTK_WINDOW(getname_dialog), accelerator_group);
+
+#ifdef HAVE_GTK2
+ button = gtk_button_new_from_stock(GTK_STOCK_OK);
+#else
+ button = gtk_button_new_with_label(BUTTON_OK);
+#endif
+ g_signal_connect(GTK_OBJECT(button), "clicked", (GtkSignalFunc) xsane_front_gtk_getname_button_callback, (void *) 1);
+ GTK_WIDGET_SET_FLAGS(button, GTK_CAN_DEFAULT);
+ gtk_box_pack_start(GTK_BOX(hbox), button, TRUE, TRUE, 0);
+ gtk_widget_show(button);
+
+#ifdef HAVE_GTK2
+ button = gtk_button_new_from_stock(GTK_STOCK_CANCEL);
+#else
+ button = gtk_button_new_with_label(BUTTON_CANCEL);
+#endif
+ g_signal_connect(GTK_OBJECT(button), "clicked", (GtkSignalFunc) xsane_front_gtk_getname_button_callback, (void *) -1);
+ gtk_widget_add_accelerator(button, "clicked", accelerator_group, GDK_Escape, 0, DEF_GTK_ACCEL_LOCKED); /* ESC */
+ gtk_box_pack_start(GTK_BOX(hbox), button, TRUE, TRUE, 0);
+ gtk_widget_show(button);
+
+ xsane_front_gtk_getname_button = 0;
+
+ while (xsane_front_gtk_getname_button == 0)
+ {
+ while (gtk_events_pending())
+ {
+ DBG(DBG_info, "xsane_getname_dialog: calling gtk_main_iteration\n");
+ gtk_main_iteration();
+ }
+ }
+
+ *newname = strdup(gtk_entry_get_text(GTK_ENTRY(text)));
+
+ gtk_widget_destroy(getname_dialog);
+
+ xsane_set_sensitivity(TRUE);
+
+ if (xsane_front_gtk_getname_button == 1) /* OK button has been pressed */
+ {
+ DBG(DBG_info, "renaming %s to %s\n", oldname, *newname);
+ return 0; /* OK */
+ }
+
+ return 1; /* Escape */
+}
+
+/* ---------------------------------------------------------------------------------------------------------------------- */
+#ifdef XSANE_ACTIVATE_MAIL
+void xsane_front_gtk_mail_project_update_lockfile_status()
+{
+ FILE *lockfile;
+ char filename[PATH_MAX];
+
+ snprintf(filename, sizeof(filename), "%s/lockfile", preferences.mail_project);
+ lockfile = fopen(filename, "wb");
+
+ if (lockfile)
+ {
+ fprintf(lockfile, "%s\n", xsane.mail_status); /* first line is status of mail */
+ fprintf(lockfile, "%3d\n", (int) (xsane.mail_progress_val * 100));
+ }
+
+ fclose(lockfile);
+}
+#endif
+/* ---------------------------------------------------------------------------------------------------------------------- */
+
+
diff --git a/src/xsane-front-gtk.h b/src/xsane-front-gtk.h
index b894b06..19aad87 100644
--- a/src/xsane-front-gtk.h
+++ b/src/xsane-front-gtk.h
@@ -3,7 +3,7 @@
xsane-front-gtk.h
Oliver Rauch <Oliver.Rauch@rauch-domain.de>
- Copyright (C) 1998-2002 Oliver Rauch
+ Copyright (C) 1998-2005 Oliver Rauch
This file is part of the XSANE package.
This program is free software; you can redistribute it and/or modify
@@ -59,23 +59,30 @@ extern void xsane_option_menu_new_with_pixmap(GdkWindow *window, GtkBox *parent,
char *str_list[], const char *val,
GtkObject **data, int option,
void *option_menu_callback, SANE_Int settable, const gchar *widget_name);
-extern void xsane_scale_new(GtkBox *parent, char *labeltext, const char *desc,
- float min, float max, float quant, float page_step, float page_size,
- int digits, double *val, GtkObject **data, void *xsane_scale_callback, SANE_Int settable);
-extern void xsane_scale_new_with_pixmap(GdkWindow *window, GtkBox *parent, const char *xpm_d[], const char *desc,
- float min, float max, float quant, float page_step, float page_size, int digits,
- double *val, GtkObject **data, int option, void *xsane_scale_callback, SANE_Int settable);
+extern void xsane_range_new(GtkBox *parent, char *labeltext, const char *desc,
+ float min, float max, float quant, float page_step,
+ int digits, double *val, GtkObject **data, void *xsane_range_callback, SANE_Int settable);
+extern void xsane_range_new_with_pixmap(GdkWindow *window, GtkBox *parent, const char *xpm_d[], const char *desc,
+ float min, float max, float quant, float page_step, int digits,
+ double *val, GtkObject **data, int option, void *xsane_range_callback, SANE_Int settable);
+extern void xsane_set_filename(gchar *filename);
+extern void xsane_outputfilename_new(GtkWidget *vbox);
extern void xsane_separator_new(GtkWidget *xsane_parent, int dist);
+extern void xsane_vseparator_new(GtkWidget *xsane_parent, int dist);
extern GtkWidget *xsane_info_table_text_new(GtkWidget *table, gchar *text, int row, int colomn);
extern GtkWidget *xsane_info_text_new(GtkWidget *parent, gchar *text);
extern void xsane_refresh_dialog(void);
extern void xsane_update_param(void *arg);
extern void xsane_define_output_filename(void);
-extern int xsane_identify_output_format(char *filename, char **ext);
+extern int xsane_identify_output_format(char *filename, char *filetype, char **ext);
extern void xsane_change_working_directory(void);
-extern int xsane_display_license(int ask_for_accept);
-extern void xsane_widget_get_uposition(GtkWidget *gtk_window, gint *x, gint *y);
+extern int xsane_display_eula(int ask_for_accept);
+extern int xsane_display_gpl(void);
+extern void xsane_window_get_position(GtkWidget *gtk_window, gint *x, gint *y);
extern void xsane_widget_test_uposition(GtkWidget *gtk_window);
+extern int xsane_front_gtk_getname_dialog(const char *dialog_title, const char *desc_text, char *oldname, char **newname);
+extern void xsane_front_gtk_mail_project_update_lockfile_status();
+
/* ---------------------------------------------------------------------------------------------------------------------- */
diff --git a/src/xsane-gamma.c b/src/xsane-gamma.c
index d47f6b7..d43eecf 100644
--- a/src/xsane-gamma.c
+++ b/src/xsane-gamma.c
@@ -3,7 +3,7 @@
xsane-gamma.c
Oliver Rauch <Oliver.Rauch@rauch-domain.de>
- Copyright (C) 1998-2002 Oliver Rauch
+ Copyright (C) 1998-2005 Oliver Rauch
This file is part of the XSANE package.
This program is free software; you can redistribute it and/or modify
@@ -55,7 +55,8 @@ void xsane_update_sliders(void);
static gint xsane_slider_callback(GtkWidget *widget, GdkEvent *event, XsaneSlider *slider);
void xsane_create_slider(XsaneSlider *slider);
void xsane_create_histogram(GtkWidget *parent, const char *title, int width, int height, XsanePixmap *hist);
-void xsane_get_free_gamma_curve(gfloat *free_color_gamma_data, SANE_Int *gammadata,
+/* void xsane_get_free_gamma_curve(gfloat *free_color_gamma_data, SANE_Int *gammadata, */
+void xsane_get_free_gamma_curve(gfloat *free_color_gamma_data, u_char *gammadata,
int negative, double gamma, double brightness, double contrast,
int len, int maxout);
static void xsane_calculate_auto_enhancement(SANE_Int *count_raw,
@@ -96,19 +97,12 @@ void xsane_set_auto_enhancement(void);
void xsane_clear_histogram(XsanePixmap *hist)
{
- GdkRectangle rect;
-
DBG(DBG_proc, "xsane_clear_histogram\n");
if(hist->pixmap)
{
- rect.x=0;
- rect.y=0;
- rect.width = HIST_WIDTH;
- rect.height = HIST_HEIGHT;
-
gdk_draw_rectangle(hist->pixmap, xsane.gc_backg, TRUE, 0, 0, HIST_WIDTH, HIST_HEIGHT);
- gtk_widget_draw(hist->pixmapwid, &rect);
+ gtk_widget_queue_draw(hist->pixmapwid);
}
}
@@ -118,7 +112,6 @@ static void xsane_draw_histogram_with_points(XsanePixmap *hist,
SANE_Int *count, SANE_Int *count_red, SANE_Int *count_green, SANE_Int *count_blue,
int show_red, int show_green, int show_blue, int show_inten, double scale)
{
- GdkRectangle rect;
int i;
int inten, red, green, blue;
@@ -129,11 +122,6 @@ static void xsane_draw_histogram_with_points(XsanePixmap *hist,
if(hist->pixmap)
{
- rect.x=0;
- rect.y=0;
- rect.width = HIST_WIDTH;
- rect.height = HIST_HEIGHT;
-
gdk_draw_rectangle(hist->pixmap, xsane.gc_backg, TRUE, 0, 0, HIST_WIDTH, HIST_HEIGHT);
red = 0;
@@ -170,7 +158,25 @@ static void xsane_draw_histogram_with_points(XsanePixmap *hist,
gdk_draw_rectangle(hist->pixmap, xsane.gc_black, TRUE, i, HIST_HEIGHT - inten, XD, YD);
}
- gtk_widget_draw(hist->pixmapwid, &rect);
+#ifdef HAVE_GTK2
+ gtk_widget_queue_draw(hist->pixmapwid);
+
+ if (hist->pixmapwid->window)
+ {
+ gdk_window_process_updates(hist->pixmapwid->window, FALSE);
+ }
+#else
+ {
+ GdkRectangle rect;
+
+ rect.x=0;
+ rect.y=0;
+ rect.width = HIST_WIDTH;
+ rect.height = HIST_HEIGHT;
+
+ gtk_widget_draw(hist->pixmapwid, &rect);
+ }
+#endif
}
}
/* ---------------------------------------------------------------------------------------------------------------------- */
@@ -179,7 +185,6 @@ static void xsane_draw_histogram_with_lines(XsanePixmap *hist,
SANE_Int *count, SANE_Int *count_red, SANE_Int *count_green, SANE_Int *count_blue,
int show_red, int show_green, int show_blue, int show_inten, double scale)
{
- GdkRectangle rect;
int i, j, k;
int inten, red, green, blue;
int inten0=0, red0=0, green0=0, blue0=0;
@@ -193,11 +198,6 @@ static void xsane_draw_histogram_with_lines(XsanePixmap *hist,
if (hist->pixmap)
{
- rect.x=0;
- rect.y=0;
- rect.width = HIST_WIDTH;
- rect.height = HIST_HEIGHT;
-
gdk_draw_rectangle(hist->pixmap, xsane.gc_backg, TRUE, 0, 0, HIST_WIDTH, HIST_HEIGHT);
red = 0;
@@ -282,7 +282,25 @@ static void xsane_draw_histogram_with_lines(XsanePixmap *hist,
gdk_draw_line(hist->pixmap, xsane.gc_black, i, HIST_HEIGHT - inten, i, HIST_HEIGHT - inten0);
}
- gtk_widget_draw(hist->pixmapwid, &rect);
+#ifdef HAVE_GTK2
+ gtk_widget_queue_draw(hist->pixmapwid);
+
+ if (hist->pixmapwid->window)
+ {
+ gdk_window_process_updates(hist->pixmapwid->window, FALSE);
+ }
+#else
+ {
+ GdkRectangle rect;
+
+ rect.x=0;
+ rect.y=0;
+ rect.width = HIST_WIDTH;
+ rect.height = HIST_HEIGHT;
+
+ gtk_widget_draw(hist->pixmapwid, &rect);
+ }
+#endif
}
}
@@ -292,7 +310,6 @@ void xsane_establish_slider(XsaneSlider *slider)
{
int x, y, pos, len;
guchar buf[XSANE_SLIDER_WIDTH*3];
- GdkRectangle rect;
DBG(DBG_proc, "xsane_establish_slider\n");
@@ -390,12 +407,25 @@ void xsane_establish_slider(XsaneSlider *slider)
gtk_preview_draw_row(GTK_PREVIEW(slider->preview),buf, 0, y, XSANE_SLIDER_WIDTH);
}
- rect.x=0;
- rect.y=0;
- rect.width = XSANE_SLIDER_WIDTH;
- rect.height = XSANE_SLIDER_HEIGHT;
+#ifdef HAVE_GTK2
+ gtk_widget_queue_draw(slider->preview);
- gtk_widget_draw(slider->preview, &rect);
+ if (slider->preview->window)
+ {
+ gdk_window_process_updates(slider->preview->window, FALSE);
+ }
+#else
+ {
+ GdkRectangle rect;
+
+ rect.x=0;
+ rect.y=0;
+ rect.width = HIST_WIDTH;
+ rect.height = HIST_HEIGHT;
+
+ gtk_widget_draw(slider->preview, &rect);
+ }
+#endif
}
/* ---------------------------------------------------------------------------------------------------------------------- */
@@ -404,7 +434,6 @@ void xsane_draw_slider_level(XsaneSlider *slider)
{
int i;
guchar buf[XSANE_SLIDER_WIDTH*3];
- GdkRectangle rect;
DBG(DBG_proc, "xsane_draw_slider_level\n");
@@ -431,12 +460,25 @@ void xsane_draw_slider_level(XsaneSlider *slider)
gtk_preview_draw_row(GTK_PREVIEW(slider->preview),buf, 0, i, XSANE_SLIDER_WIDTH);
}
- rect.x=0;
- rect.y=0;
- rect.width = XSANE_SLIDER_WIDTH;
- rect.height = XSANE_SLIDER_HEIGHT;
+#ifdef HAVE_GTK2
+ gtk_widget_queue_draw(slider->preview);
+
+ if (slider->preview->window)
+ {
+ gdk_window_process_updates(slider->preview->window, FALSE);
+ }
+#else
+ {
+ GdkRectangle rect;
+
+ rect.x=0;
+ rect.y=0;
+ rect.width = HIST_WIDTH;
+ rect.height = HIST_HEIGHT;
- gtk_widget_draw(slider->preview, &rect);
+ gtk_widget_draw(slider->preview, &rect);
+ }
+#endif
}
/* ---------------------------------------------------------------------------------------------------------------------- */
@@ -511,6 +553,20 @@ void xsane_update_sliders()
/* ---------------------------------------------------------------------------------------------------------------------- */
+static gint xsane_batch_scan_gamma_event()
+{
+ DBG(DBG_proc, "xsane_batch_scan_gamma_event\n");
+
+ xsane_batch_scan_update_icon_list(); /* update gamma of batch scan icons */
+
+ gtk_timeout_remove(xsane.batch_scan_gamma_timer);
+ xsane.batch_scan_gamma_timer = 0;
+
+ return FALSE;
+}
+
+/* ---------------------------------------------------------------------------------------------------------------------- */
+
static gint xsane_slider_hold_event()
{
DBG(DBG_proc, "xsane_slider_hold_event\n");
@@ -650,7 +706,7 @@ void xsane_create_slider(XsaneSlider *slider)
slider->preview = gtk_preview_new(GTK_PREVIEW_COLOR);
gtk_preview_size(GTK_PREVIEW(slider->preview), XSANE_SLIDER_WIDTH, XSANE_SLIDER_HEIGHT);
gtk_widget_set_events(slider->preview, XSANE_SLIDER_EVENTS);
- gtk_signal_connect(GTK_OBJECT(slider->preview), "event", GTK_SIGNAL_FUNC(xsane_slider_callback), slider);
+ g_signal_connect(GTK_OBJECT(slider->preview), "event", GTK_SIGNAL_FUNC(xsane_slider_callback), slider);
}
/* ---------------------------------------------------------------------------------------------------------------------- */
@@ -663,7 +719,7 @@ void xsane_create_histogram(GtkWidget *parent, const char *title, int width, int
hist->frame = gtk_frame_new(title);
hist->pixmap = gdk_pixmap_new(xsane.histogram_dialog->window, width, height, -1);
- hist->pixmapwid = gtk_pixmap_new(hist->pixmap, mask);
+ hist->pixmapwid = gtk_image_new_from_pixmap(hist->pixmap, mask);
gtk_container_add(GTK_CONTAINER(hist->frame), hist->pixmapwid);
gdk_draw_rectangle(hist->pixmap, xsane.gc_backg, TRUE, 0, 0, width, height);
@@ -1078,7 +1134,7 @@ void xsane_create_preview_threshold_curve(u_char *gammadata, double threshold, i
}
/* ---------------------------------------------------------------------------------------------------------------------- */
-
+#if 0
void xsane_create_preview_gamma_curve(u_char *gammadata, int negative, double gamma,
double brightness, double contrast,
double medium_shadow, double medium_highlight, double medium_gamma,
@@ -1089,9 +1145,193 @@ void xsane_create_preview_gamma_curve(u_char *gammadata, int negative, double ga
double val;
double m;
double b;
+ double medium_m;
+ double medium_mid;
int maxin = numbers-1;
+ double clip_shadow, clip_highlight;
+ double m_shadow, m_highlight;
+ double s2 = 0.0, s3 = 0.0;
+ double h2 = 0.0, h3 = 0.0;
+ double clip_alpha = 0.34; /* 1/3 ... 1/2 are allowed */
+ int medium_range;
+ int unclipped_range;
+ double medium_shadow_val, medium_highlight_val;
+ double medium_highlight_val_from_maxin;
+ double clip_highlight_from_maxin;
+
+ medium_range = (medium_highlight - medium_shadow)/ 100.0 * maxin;
+
+ m_shadow = 1.0;
+ m_highlight = 1.0;
+
+ medium_shadow_val = medium_shadow/100.0 * maxin;
+ medium_highlight_val = medium_highlight/100.0 * maxin;
+ medium_highlight_val_from_maxin = maxin - medium_highlight_val;
+
+ for (i=1; i<10; i++)
+ {
+ clip_shadow = clip_alpha * m_shadow * medium_shadow_val;
+ clip_highlight_from_maxin = clip_alpha * (m_highlight * medium_highlight_val_from_maxin);
+ clip_highlight = maxin - clip_highlight_from_maxin;
+ unclipped_range = clip_highlight - clip_shadow;
+
+ m_shadow = (4 * m_shadow + unclipped_range / medium_range / medium_gamma) / 5;
+ m_highlight = (4 * m_highlight + unclipped_range / medium_range) / 5;
+ }
+ m_shadow = 1.0;
+ m_highlight = 1.0;
+
+ /* soft clipping constants for shadow of medium */
+
+ if (medium_shadow_val)
+ {
+ clip_shadow = clip_alpha * m_shadow * medium_shadow_val;
+ s2 = 3 * clip_shadow / (medium_shadow_val * medium_shadow_val) - m_shadow / medium_shadow_val;
+ s3 = m_shadow / (medium_shadow_val * medium_shadow_val) - 2 * clip_shadow / (medium_shadow_val * medium_shadow_val * medium_shadow_val);
+
+ DBG(DBG_info2, "\n");
+ DBG(DBG_info2, "maxin = %d\n", maxin);
+ DBG(DBG_info2, "m_shadow = %f\n", m_shadow);
+ DBG(DBG_info2, "medium_shadow_val = %d\n", medium_shadow_val);
+ DBG(DBG_info2, "clip_shadow = %f\n", clip_shadow);
+ DBG(DBG_info2, "s2 = %f\n", s2);
+ DBG(DBG_info2, "s3 = %f\n", s3);
+ DBG(DBG_info2, "s2*shadow^2 + s3*shadow^3 = %f\n", s2 * medium_shadow_val * medium_shadow_val + s3 * medium_shadow_val * medium_shadow_val* medium_shadow_val);
+ }
+ else
+ {
+ clip_shadow = 0;
+ }
+
+
+ /* soft clipping constants for highlight of medium */
+
+ if (medium_highlight_val < maxin)
+ {
+ medium_highlight_val_from_maxin = maxin - medium_highlight_val;
+ clip_highlight_from_maxin = clip_alpha * (m_highlight * medium_highlight_val_from_maxin);
+ clip_highlight = maxin - clip_highlight_from_maxin;
+ h2 = 3 * clip_highlight_from_maxin / (medium_highlight_val_from_maxin * medium_highlight_val_from_maxin) - m_highlight / medium_highlight_val_from_maxin;
+ h3 = m_highlight / (medium_highlight_val_from_maxin * medium_highlight_val_from_maxin) - 2 * clip_highlight_from_maxin / (medium_highlight_val_from_maxin * medium_highlight_val_from_maxin * medium_highlight_val_from_maxin);
+
+ DBG(DBG_info2, "\n");
+ DBG(DBG_info2, "maxin = %d\n", maxin);
+ DBG(DBG_info2, "m_highlight = %f\n", m_highlight);
+ DBG(DBG_info2, "medium_highlight_val = %d\n", medium_highlight_val);
+ DBG(DBG_info2, "clip_highlight = %f\n", clip_highlight);
+ DBG(DBG_info2, "h2 = %f\n", h2);
+ DBG(DBG_info2, "h3 = %f\n", h3);
+ DBG(DBG_info2, "h2*highlight^2 + h3*highlight^3 = %f\n", h2 * (maxin - medium_highlight_val) * (maxin - medium_highlight_val) + h3 * (maxin - medium_highlight_val) * (maxin - medium_highlight_val) * (maxin - medium_highlight_val));
+ }
+ else
+ {
+ clip_highlight = maxin;
+ }
+
+ /* standard gamma constants for medium */
+
+ unclipped_range = clip_highlight - clip_shadow;
+ DBG(DBG_info2, "medium_range = %d\n", medium_range);
+ DBG(DBG_info2, "unclipped_range = %d\n", unclipped_range);
+
+ medium_m = 100.0/(medium_highlight - medium_shadow);
+ medium_mid = (medium_shadow + medium_highlight)/200.0 * maxin;
+
+ DBG(DBG_proc, "xsane_create_preview_gamma_curve(neg=%d, gam=%3.2f, bri=%3.2f, ctr=%3.2f, nrs=%d)\n",
+ negative, gamma, brightness, contrast, numbers);
+
+ if (contrast < -100.0)
+ {
+ contrast = -100.0;
+ }
+
+ midin = (int)(numbers / 2.0);
+
+ m = 1.0 + contrast/100.0;
+ b = (1.0 + brightness/100.0) * midin;
+
+ if (negative)
+ {
+ for (i=0; i <= maxin; i++)
+ {
+ val = ((double) i);
+
+ /* medium correction */
+ val = (val - medium_mid) * medium_m + midin;
+ val = maxin - val; /* invert */
+
+ if (i < medium_shadow_val)
+ {
+ val = maxin - s2 * i * i - s3 * i * i * i;
+ }
+ else if (i > medium_highlight_val)
+ {
+ val = h2 * (maxin - i) * (maxin - i) + h3 * (maxin - i) * (maxin - i) * (maxin - i);
+ }
+ else
+ {
+ xsane_bound_double(&val, 0.0, maxin);
+ val = (maxin - clip_highlight) + unclipped_range * pow( val/maxin, (1.0/medium_gamma) );
+ }
+
+ val = val - midin;
+
+ /* user correction */
+ val = val * m + b;
+ xsane_bound_double(&val, 0.0, maxin);
+
+ gammadata[i] = (u_char) (255.99999 * pow( ceil(val)/maxin, (1.0/gamma) ));
+ }
+ }
+ else /* positive */
+ {
+ for (i=0; i <= maxin; i++)
+ {
+ val = ((double) i);
+
+ /* medium correction */
+ val = (val - medium_mid) * medium_m + midin;
+
+ if (i < medium_shadow_val)
+ {
+ val = s2 * i * i + s3 * i * i * i;
+ }
+ else if (i > medium_highlight_val)
+ {
+ val = maxin - (h2 * (maxin - i) * (maxin - i) + h3 * (maxin - i) * (maxin - i) * (maxin - i));
+ }
+ else
+ {
+ xsane_bound_double(&val, 0.0, maxin);
+ val = clip_shadow + unclipped_range * pow( val/maxin, (1.0/medium_gamma) );
+ }
+
+ val = val - midin;
+
+ /* user correction */
+ val = val * m + b;
+ xsane_bound_double(&val, 0.0, maxin);
+
+ gammadata[i] = (u_char) (255.99999 * pow( val/maxin, (1.0/gamma) ));
+ }
+ }
+}
+
+#else
+
+void xsane_create_preview_gamma_curve(u_char *gammadata, int negative, double gamma,
+ double brightness, double contrast,
+ double medium_shadow, double medium_highlight, double medium_gamma,
+ int numbers)
+{
+ int i;
+ double midin;
+ double val;
+ double m;
+ double b;
double medium_m;
double medium_mid;
+ int maxin = numbers-1;
medium_m = 100.0/(medium_highlight - medium_shadow);
medium_mid = (medium_shadow + medium_highlight)/200.0 * maxin;
@@ -1127,7 +1367,7 @@ void xsane_create_preview_gamma_curve(u_char *gammadata, int negative, double ga
val = val * m + b;
xsane_bound_double(&val, 0.0, maxin);
- gammadata[i] = (u_char) (255 * pow( val/maxin, (1.0/gamma) ));
+ gammadata[i] = (u_char) (255.99999 * pow( ceil(val)/maxin, (1.0/gamma) ));
}
}
else /* positive */
@@ -1147,10 +1387,11 @@ void xsane_create_preview_gamma_curve(u_char *gammadata, int negative, double ga
val = val * m + b;
xsane_bound_double(&val, 0.0, maxin);
- gammadata[i] = (u_char) (255 * pow( val/maxin, (1.0/gamma) ));
+ gammadata[i] = (u_char) (255.99999 * pow( val/maxin, (1.0/gamma) ));
}
}
}
+#endif
/* ---------------------------------------------------------------------------------------------------------------------- */
@@ -1205,7 +1446,7 @@ void xsane_create_gamma_curve(SANE_Int *gammadata,
/* user correction */
val = val * m + b;
xsane_bound_double(&val, 0.0, maxin);
- gammadata[i] = maxout * pow( val/maxin, (1.0/gamma) );
+ gammadata[i] = (int) (maxout * pow( val/maxin, (1.0/gamma) ));
}
}
else /* positive */
@@ -1224,7 +1465,7 @@ void xsane_create_gamma_curve(SANE_Int *gammadata,
/* user correction */
val = val * m + b;
xsane_bound_double(&val, 0.0, maxin);
- gammadata[i] = maxout * pow( val/maxin, (1.0/gamma) );
+ gammadata[i] = (int) (maxout * pow( val/maxin, (1.0/gamma) ));
}
}
}
@@ -1578,8 +1819,6 @@ void xsane_update_gamma_curve(int update_raw)
static void xsane_enhancement_update(void)
{
- guint sig_changed=0;
-
DBG(DBG_proc, "xsane_enhancement_update\n");
if (xsane.param.depth == 1) /* lineart? no gamma */
@@ -1587,43 +1826,28 @@ static void xsane_enhancement_update(void)
return;
}
- sig_changed = gtk_signal_lookup("changed", GTK_OBJECT_TYPE(xsane.gamma_widget));
+ xsane.block_enhancement_update = TRUE;
- GTK_ADJUSTMENT(xsane.gamma_widget)->value = xsane.gamma;
- GTK_ADJUSTMENT(xsane.brightness_widget)->value = xsane.brightness;
- GTK_ADJUSTMENT(xsane.contrast_widget)->value = xsane.contrast;
+ gtk_adjustment_set_value(GTK_ADJUSTMENT(xsane.gamma_widget), xsane.gamma);
+ gtk_adjustment_set_value(GTK_ADJUSTMENT(xsane.brightness_widget), xsane.brightness);
+ gtk_adjustment_set_value(GTK_ADJUSTMENT(xsane.contrast_widget), xsane.contrast);
if ( (xsane.xsane_colors > 1) && (!xsane.enhancement_rgb_default) )
{
- GTK_ADJUSTMENT(xsane.gamma_red_widget)->value = xsane.gamma_red;
- GTK_ADJUSTMENT(xsane.gamma_green_widget)->value = xsane.gamma_green;
- GTK_ADJUSTMENT(xsane.gamma_blue_widget)->value = xsane.gamma_blue;
-
- GTK_ADJUSTMENT(xsane.brightness_red_widget)->value = xsane.brightness_red;
- GTK_ADJUSTMENT(xsane.brightness_green_widget)->value = xsane.brightness_green;
- GTK_ADJUSTMENT(xsane.brightness_blue_widget)->value = xsane.brightness_blue;
+ gtk_adjustment_set_value(GTK_ADJUSTMENT(xsane.gamma_red_widget), xsane.gamma_red);
+ gtk_adjustment_set_value(GTK_ADJUSTMENT(xsane.brightness_red_widget), xsane.brightness_red);
+ gtk_adjustment_set_value(GTK_ADJUSTMENT(xsane.contrast_red_widget), xsane.contrast_red);
- GTK_ADJUSTMENT(xsane.contrast_red_widget)->value = xsane.contrast_red;
- GTK_ADJUSTMENT(xsane.contrast_green_widget)->value = xsane.contrast_green;
- GTK_ADJUSTMENT(xsane.contrast_blue_widget)->value = xsane.contrast_blue;
+ gtk_adjustment_set_value(GTK_ADJUSTMENT(xsane.gamma_green_widget), xsane.gamma_green);
+ gtk_adjustment_set_value(GTK_ADJUSTMENT(xsane.brightness_green_widget), xsane.brightness_green);
+ gtk_adjustment_set_value(GTK_ADJUSTMENT(xsane.contrast_green_widget), xsane.contrast_green);
- gtk_signal_emit(xsane.gamma_red_widget, sig_changed);
- gtk_signal_emit(xsane.gamma_green_widget, sig_changed);
- gtk_signal_emit(xsane.gamma_blue_widget, sig_changed);
-
- gtk_signal_emit(xsane.brightness_red_widget, sig_changed);
- gtk_signal_emit(xsane.brightness_green_widget, sig_changed);
- gtk_signal_emit(xsane.brightness_blue_widget, sig_changed);
-
- gtk_signal_emit(xsane.contrast_red_widget, sig_changed);
- gtk_signal_emit(xsane.contrast_green_widget, sig_changed);
- gtk_signal_emit(xsane.contrast_blue_widget, sig_changed);
-
+ gtk_adjustment_set_value(GTK_ADJUSTMENT(xsane.gamma_blue_widget), xsane.gamma_blue);
+ gtk_adjustment_set_value(GTK_ADJUSTMENT(xsane.brightness_blue_widget), xsane.brightness_blue);
+ gtk_adjustment_set_value(GTK_ADJUSTMENT(xsane.contrast_blue_widget), xsane.contrast_blue);
}
- gtk_signal_emit(xsane.gamma_widget, sig_changed);
- gtk_signal_emit(xsane.brightness_widget, sig_changed);
- gtk_signal_emit(xsane.contrast_widget, sig_changed);
+ xsane.block_enhancement_update = FALSE;
xsane_update_sliders(); /* update histogram slider */
}
@@ -1680,9 +1904,9 @@ void xsane_enhancement_by_gamma(void)
brightness = xsane.brightness + xsane.brightness_red;
gamma = xsane.gamma * xsane.gamma_red;
- if (contrast < -100)
+ if (contrast < xsane.contrast_min)
{
- contrast = -100;
+ contrast = xsane.contrast_min;
}
xsane_gamma_to_histogram(&min, &mid, &max, contrast, brightness, gamma);
@@ -1698,9 +1922,9 @@ void xsane_enhancement_by_gamma(void)
brightness = xsane.brightness + xsane.brightness_green;
gamma = xsane.gamma * xsane.gamma_green;
- if (contrast < -100)
+ if (contrast < xsane.contrast_min)
{
- contrast = -100;
+ contrast = xsane.contrast_min;
}
xsane_gamma_to_histogram(&min, &mid, &max, contrast, brightness, gamma);
@@ -1715,9 +1939,9 @@ void xsane_enhancement_by_gamma(void)
brightness = xsane.brightness + xsane.brightness_blue;
gamma = xsane.gamma * xsane.gamma_blue;
- if (contrast < -100)
+ if (contrast < xsane.contrast_min)
{
- contrast = -100;
+ contrast = xsane.contrast_min;
}
xsane_gamma_to_histogram(&min, &mid, &max, contrast, brightness, gamma);
@@ -1729,6 +1953,12 @@ void xsane_enhancement_by_gamma(void)
xsane_enhancement_update();
xsane_update_gamma_curve(FALSE);
+
+ if (xsane.batch_scan_gamma_timer)
+ {
+ gtk_timeout_remove(xsane.batch_scan_gamma_timer);
+ }
+ xsane.batch_scan_gamma_timer = gtk_timeout_add(XSANE_CONTINUOUS_HOLD_TIME * 4, xsane_batch_scan_gamma_event, 0);
}
/* ---------------------------------------------------------------------------------------------------------------------- */
@@ -1824,7 +2054,7 @@ static int xsane_histogram_to_gamma(XsaneSlider *slider,
*contrast = (10000.0 / (slider->value[2] - slider->value[0]) - 100.0);
if (correct_bound)
{
- xsane_bound_double(contrast, -100.0 + contrast_offset, xsane.contrast_max + contrast_offset);
+ xsane_bound_double(contrast, xsane.contrast_min + contrast_offset, xsane.contrast_max + contrast_offset);
}
*brightness = - (slider->value[0] - 50.0) * (*contrast + 100.0)/50.0 - 100.0;
@@ -1837,17 +2067,19 @@ static int xsane_histogram_to_gamma(XsaneSlider *slider,
range = slider->value[2] - slider->value[0];
*gamma = log(mid/range) / log(0.5);
+
if (correct_bound)
{
xsane_bound_double(gamma, XSANE_GAMMA_MIN * gamma_multiplier, XSANE_GAMMA_MAX * gamma_multiplier);
return 1; /* in bound */
}
- else if (xsane_check_bound_double(*contrast, -100.0 + contrast_offset, xsane.contrast_max + contrast_offset) &&
- xsane_check_bound_double(*brightness, XSANE_BRIGHTNESS_MIN + brightness_offset, xsane.brightness_max + brightness_offset) &&
+ else if (xsane_check_bound_double(*contrast, xsane.contrast_min + contrast_offset, xsane.contrast_max + contrast_offset) &&
+ xsane_check_bound_double(*brightness, xsane.brightness_min + brightness_offset, xsane.brightness_max + brightness_offset) &&
xsane_check_bound_double(*gamma, XSANE_GAMMA_MIN * gamma_multiplier, XSANE_GAMMA_MAX * gamma_multiplier))
{
return 1; /* in bound */
}
+
return 0; /* out of bound */
}
@@ -1949,14 +2181,14 @@ void xsane_create_histogram_dialog(const char *devicetext)
DBG(DBG_proc, "xsane_create_histogram_dialog\n");
- xsane.histogram_dialog = gtk_window_new(GTK_WINDOW_DIALOG);
- gtk_window_set_policy(GTK_WINDOW(xsane.histogram_dialog), FALSE, FALSE, FALSE);
- gtk_widget_set_uposition(xsane.histogram_dialog, XSANE_HISTOGRAM_POS_X, XSANE_HISTOGRAM_POS_Y);
- gtk_signal_connect(GTK_OBJECT(xsane.histogram_dialog), "delete_event", GTK_SIGNAL_FUNC(xsane_histogram_win_delete), NULL);
+ xsane.histogram_dialog = gtk_window_new(GTK_WINDOW_TOPLEVEL);
+ gtk_window_set_resizable(GTK_WINDOW(xsane.histogram_dialog), FALSE);
+ gtk_window_move(GTK_WINDOW(xsane.histogram_dialog), XSANE_HISTOGRAM_POS_X, XSANE_HISTOGRAM_POS_Y);
+ g_signal_connect(GTK_OBJECT(xsane.histogram_dialog), "delete_event", GTK_SIGNAL_FUNC(xsane_histogram_win_delete), NULL);
sprintf(windowname, "%s %s", WINDOW_HISTOGRAM, devicetext);
gtk_window_set_title(GTK_WINDOW(xsane.histogram_dialog), windowname);
xsane_set_window_icon(xsane.histogram_dialog, 0);
- gtk_accel_group_attach(xsane.accelerator_group, GTK_OBJECT(xsane.histogram_dialog));
+ gtk_window_add_accel_group(GTK_WINDOW(xsane.histogram_dialog), xsane.accelerator_group);
xsane_histogram_vbox = gtk_vbox_new(FALSE, 0);
gtk_container_set_border_width(GTK_CONTAINER(xsane_histogram_vbox), 5);
@@ -1976,7 +2208,7 @@ void xsane_create_histogram_dialog(const char *devicetext)
xsane.gc_trans = style->bg_gc[GTK_STATE_NORMAL];
xsane.bg_trans = &style->bg[GTK_STATE_NORMAL];
- colormap = gdk_window_get_colormap(xsane.histogram_dialog->window);
+ colormap = gdk_drawable_get_colormap(xsane.histogram_dialog->window);
xsane.gc_black = gdk_gc_new(xsane.histogram_dialog->window);
color_black.red = 0;
@@ -2078,27 +2310,27 @@ void xsane_create_histogram_dialog(const char *devicetext)
button = xsane_toggle_button_new_with_pixmap(xsane.histogram_dialog->window, xsane_color_hbox, intensity_xpm, DESC_HIST_INTENSITY,
&xsane.histogram_int, xsane_histogram_toggle_button_callback);
- gtk_widget_add_accelerator(button, "clicked", xsane.accelerator_group, GDK_I, GDK_MOD1_MASK, GTK_ACCEL_LOCKED);
+ gtk_widget_add_accelerator(button, "clicked", xsane.accelerator_group, GDK_I, GDK_MOD1_MASK, DEF_GTK_ACCEL_LOCKED);
button = xsane_toggle_button_new_with_pixmap(xsane.histogram_dialog->window, xsane_color_hbox, red_xpm, DESC_HIST_RED,
&xsane.histogram_red, xsane_histogram_toggle_button_callback);
- gtk_widget_add_accelerator(button, "clicked", xsane.accelerator_group, GDK_R, GDK_MOD1_MASK, GTK_ACCEL_LOCKED);
+ gtk_widget_add_accelerator(button, "clicked", xsane.accelerator_group, GDK_R, GDK_MOD1_MASK, DEF_GTK_ACCEL_LOCKED);
button = xsane_toggle_button_new_with_pixmap(xsane.histogram_dialog->window, xsane_color_hbox, green_xpm, DESC_HIST_GREEN,
&xsane.histogram_green, xsane_histogram_toggle_button_callback);
- gtk_widget_add_accelerator(button, "clicked", xsane.accelerator_group, GDK_G, GDK_MOD1_MASK, GTK_ACCEL_LOCKED);
+ gtk_widget_add_accelerator(button, "clicked", xsane.accelerator_group, GDK_G, GDK_MOD1_MASK, DEF_GTK_ACCEL_LOCKED);
button = xsane_toggle_button_new_with_pixmap(xsane.histogram_dialog->window, xsane_color_hbox, blue_xpm, DESC_HIST_BLUE,
&xsane.histogram_blue, xsane_histogram_toggle_button_callback);
- gtk_widget_add_accelerator(button, "clicked", xsane.accelerator_group, GDK_B, GDK_MOD1_MASK, GTK_ACCEL_LOCKED);
+ gtk_widget_add_accelerator(button, "clicked", xsane.accelerator_group, GDK_B, GDK_MOD1_MASK, DEF_GTK_ACCEL_LOCKED);
button = xsane_toggle_button_new_with_pixmap(xsane.histogram_dialog->window, xsane_color_hbox, pixel_xpm, DESC_HIST_PIXEL,
&xsane.histogram_lines, xsane_histogram_toggle_button_callback);
- gtk_widget_add_accelerator(button, "clicked", xsane.accelerator_group, GDK_M, GDK_MOD1_MASK, GTK_ACCEL_LOCKED);
+ gtk_widget_add_accelerator(button, "clicked", xsane.accelerator_group, GDK_M, GDK_MOD1_MASK, DEF_GTK_ACCEL_LOCKED);
button = xsane_toggle_button_new_with_pixmap(xsane.histogram_dialog->window, xsane_color_hbox, log_xpm, DESC_HIST_LOG,
&xsane.histogram_log, xsane_histogram_toggle_button_callback);
- gtk_widget_add_accelerator(button, "clicked", xsane.accelerator_group, GDK_L, GDK_MOD1_MASK, GTK_ACCEL_LOCKED);
+ gtk_widget_add_accelerator(button, "clicked", xsane.accelerator_group, GDK_L, GDK_MOD1_MASK, DEF_GTK_ACCEL_LOCKED);
gtk_widget_show(xsane_color_hbox);
}
@@ -2107,7 +2339,8 @@ void xsane_create_histogram_dialog(const char *devicetext)
#ifdef HAVE_WORKING_GTK_GAMMACURVE
/* xsane_get_free_gamma_curve transforms gamma table with 65536 entries and value range 0.0-1.0 to requested gamma table */
/* it combines the color gamma table given by gamma_widget and the gray gamma table (xsane.gamma_curve_gray) */
-void xsane_get_free_gamma_curve(gfloat *free_color_gamma_data, SANE_Int *gammadata,
+/* void xsane_get_free_gamma_curve(gfloat *free_color_gamma_data, SANE_Int *gammadata, */
+void xsane_get_free_gamma_curve(gfloat *free_color_gamma_data, u_char *gammadata,
int negative, double gamma, double brightness, double contrast,
int len, int maxout)
{
@@ -2238,13 +2471,13 @@ GtkWidget* xsane_gamma_curve_notebook_page_new(GtkWidget *notebook, char *title)
gtk_widget_show(label);
gamma = gtk_gamma_curve_new();
- gtk_widget_set_usize(gamma, 0, 256);
+ gtk_widget_set_size_request(gamma, -1, 256);
curve = GTK_GAMMA_CURVE(gamma)->curve;
vector = alloca(optlen * sizeof(vector[0]));
gtk_curve_set_range(GTK_CURVE(curve), 0, optlen - 1, fmin, fmax);
-#if 1
+#if 0
gtk_curve_maintain_accuracy(GTK_CURVE(curve), 1.0);
#endif
@@ -2269,14 +2502,14 @@ void xsane_create_gamma_dialog(const char *devicetext)
xsane.free_gamma_data_green = calloc(65536, sizeof(xsane.free_gamma_data_green[0]));
xsane.free_gamma_data_blue = calloc(65536, sizeof(xsane.free_gamma_data_green[0]));
- xsane.gamma_dialog = gtk_window_new(GTK_WINDOW_DIALOG);
- gtk_window_set_policy(GTK_WINDOW(xsane.gamma_dialog), FALSE, FALSE, FALSE);
- gtk_widget_set_uposition(xsane.gamma_dialog, XSANE_GAMMA_POS_X, XSANE_GAMMA_POS_Y);
- gtk_signal_connect(GTK_OBJECT(xsane.gamma_dialog), "delete_event", GTK_SIGNAL_FUNC(xsane_gamma_win_delete), NULL);
+ xsane.gamma_dialog = gtk_window_new(GTK_WINDOW_TOPLEVEL);
+ gtk_window_set_resizable(GTK_WINDOW(xsane.gamma_dialog), FALSE);
+ gtk_window_move(GTK_WINDOW(xsane.gamma_dialog), XSANE_GAMMA_POS_X, XSANE_GAMMA_POS_Y);
+ g_signal_connect(GTK_OBJECT(xsane.gamma_dialog), "delete_event", GTK_SIGNAL_FUNC(xsane_gamma_win_delete), NULL);
sprintf(windowname, "%s %s", WINDOW_GAMMA, devicetext);
gtk_window_set_title(GTK_WINDOW(xsane.gamma_dialog), windowname);
xsane_set_window_icon(xsane.gamma_dialog, 0);
- gtk_accel_group_attach(xsane.accelerator_group, GTK_OBJECT(xsane.gamma_dialog));
+ gtk_window_add_accel_group(GTK_WINDOW(xsane.gamma_dialog), xsane.accelerator_group);
xsane_vbox_gamma = gtk_vbox_new(TRUE, 5);
gtk_container_set_border_width(GTK_CONTAINER(xsane_vbox_gamma), 5);
@@ -2354,6 +2587,40 @@ void xsane_set_auto_enhancement()
}
/* ---------------------------------------------------------------------------------------------------------------------- */
+
+/* set medium values as gamma/contrast/brightness */
+void xsane_apply_medium_definition_as_enhancement(Preferences_medium_t *medium)
+{
+ xsane.gamma = medium->gamma_gray;
+ xsane.contrast = 10000.0 / (medium->highlight_gray - medium->shadow_gray) - 100.0;
+ xsane.brightness = - (medium->shadow_gray - 50.0) * (xsane.contrast + 100.0) / 50.0 - 100.0;
+
+ xsane.gamma_red = medium->gamma_red / xsane.gamma;
+ xsane.gamma_green = medium->gamma_green / xsane.gamma;
+ xsane.gamma_blue = medium->gamma_blue / xsane.gamma;
+
+ xsane.contrast_red = 10000.0 / (medium->highlight_red - medium->shadow_red) - 100.0 - xsane.contrast;
+ xsane.contrast_green = 10000.0 / (medium->highlight_green - medium->shadow_green) - 100.0 - xsane.contrast;
+ xsane.contrast_blue = 10000.0 / (medium->highlight_blue - medium->shadow_blue) - 100.0 - xsane.contrast;
+
+ xsane.brightness_red = - (medium->shadow_red - 50.0) * (xsane.contrast + xsane.contrast_red + 100.0) / 50.0 - 100.0 - xsane.brightness;
+ xsane.brightness_green = - (medium->shadow_green - 50.0) * (xsane.contrast + xsane.contrast_green + 100.0) / 50.0 - 100.0 - xsane.brightness;
+ xsane.brightness_blue = - (medium->shadow_blue - 50.0) * (xsane.contrast + xsane.contrast_blue + 100.0) / 50.0 - 100.0 - xsane.brightness;
+
+ xsane.negative = medium->negative;
+
+ if (xsane.negative)
+ {
+ xsane.brightness = -xsane.brightness;
+ xsane.brightness_red = -xsane.brightness_red;
+ xsane.brightness_green = -xsane.brightness_green;
+ xsane.brightness_blue = -xsane.brightness_blue;
+ }
+}
+
+/* ---------------------------------------------------------------------------------------------------------------------- */
+
+/* set medium values */
void xsane_set_medium(Preferences_medium_t *medium)
{
const SANE_Option_Descriptor *opt;
diff --git a/src/xsane-gamma.h b/src/xsane-gamma.h
index 124b21a..e948a92 100644
--- a/src/xsane-gamma.h
+++ b/src/xsane-gamma.h
@@ -3,7 +3,7 @@
xsane-gamma.h
Oliver Rauch <Oliver.Rauch@rauch-domain.de>
- Copyright (C) 1998-2002 Oliver Rauch
+ Copyright (C) 1998-2005 Oliver Rauch
This file is part of the XSANE package.
This program is free software; you can redistribute it and/or modify
@@ -53,6 +53,7 @@ extern void xsane_create_histogram_dialog(const char *devicetext);
extern void xsane_create_gamma_dialog(const char *devicetext);
extern void xsane_update_gamma_dialog(void);
extern void xsane_set_auto_enhancement(void);
+extern void xsane_apply_medium_definition_as_enhancement(Preferences_medium_t *medium);
extern void xsane_set_medium(Preferences_medium_t *medium);
/* ---------------------------------------------------------------------------------------------------------------------- */
diff --git a/src/xsane-gimp-1_0-compat.h b/src/xsane-gimp-1_0-compat.h
index 363c826..1bdc758 100644
--- a/src/xsane-gimp-1_0-compat.h
+++ b/src/xsane-gimp-1_0-compat.h
@@ -3,7 +3,7 @@
xsane-gimp-1_0-compat.h
Oliver Rauch <Oliver.Rauch@rauch-domain.de>
- Copyright (C) 2000-2002 Oliver Rauch
+ Copyright (C) 2000-2005 Oliver Rauch
This file is part of the XSANE package.
This program is free software; you can redistribute it and/or modify
@@ -20,8 +20,8 @@
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
-#ifndef XSANE_OLDGIMP_H
-#define XSANE_OLDGIMP_H
+#ifndef XSANE_GIMP_1_0_COMPAT_H
+#define XSANE_GIMP_1_0_COMPAT_H
#define GimpPlugInInfo GPlugInInfo
#define GimpParam GParam
diff --git a/src/xsane-license.txt b/src/xsane-gpl.txt
index b5ab307..b5ab307 100644
--- a/src/xsane-license.txt
+++ b/src/xsane-gpl.txt
diff --git a/src/xsane-gtk-1_x-compat.h b/src/xsane-gtk-1_x-compat.h
new file mode 100644
index 0000000..1653c33
--- /dev/null
+++ b/src/xsane-gtk-1_x-compat.h
@@ -0,0 +1,68 @@
+/* xsane -- a graphical (X11, gtk) scanner-oriented SANE frontend
+
+ xsane-gtk-1_x-compat.h
+
+ Oliver Rauch <Oliver.Rauch@rauch-domain.de>
+ Copyright (C) 2002-2005 Oliver Rauch
+ This file is part of the XSANE package.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
+
+#ifndef XSANE_GTK_1_x_COMPAT_H
+#define XSANE_GTK_1_x_COMPAT_H
+
+# define DEF_GTK_MENU_ACCEL_VISIBLE 0
+
+# define g_signal_connect(instance, detailed_signal, c_handler, data) \
+ gtk_signal_connect(instance, detailed_signal, c_handler, data)
+# define g_signal_connect_after(instance, detailed_signal, c_handler, data) \
+ gtk_signal_connect_after(instance, detailed_signal, c_handler, data)
+# define g_signal_connect_swapped(instance, detailed_signal, c_handler, data) \
+ gtk_signal_connect_object(instance, detailed_signal, c_handler, data)
+# define g_signal_handlers_block_by_func(instance, func, data) \
+ gtk_signal_handler_block_by_func(instance, func, data)
+# define g_signal_handlers_unblock_by_func(instance, func, data) \
+ gtk_signal_handler_unblock_by_func(instance, func, data)
+# define g_signal_handlers_disconnect_by_func(instance, func, data) \
+ gtk_signal_disconnect_by_func(instance, func, data)
+# define g_signal_lookup(name, itype) \
+ gtk_signal_lookup(name, itype)
+# define g_signal_emit(instance, signal_id, detail) \
+ gtk_signal_emit(instance, signal_id)
+# define g_signal_emit_by_name(instance, detailed_signal) \
+ gtk_signal_emit_by_name(instance, detailed_signal)
+
+# define gtk_widget_set_size_request(widget, width, height) \
+ gtk_widget_set_usize(widget, width, height)
+
+# define gdk_drawable_get_size(widget, width, height) \
+ gdk_window_get_size(widget, width, height)
+# define gdk_drawable_get_colormap(widget) \
+ gdk_window_get_colormap(widget)
+# define gdk_cursor_unref(widget) \
+ gdk_cursor_destroy(widget)
+# define gdk_gc_unref(widget) \
+ gdk_gc_destroy(widget)
+/* the following change is not unique, but we only need gdk_pixmap_unref, so it is ok */
+# define gdk_drawable_unref(widget) \
+ gdk_pixmap_unref(widget)
+# define gtk_window_move(widget, x, y) \
+ gtk_widget_set_uposition((GtkWidget *) widget, x, y)
+# define gtk_window_set_resizable(widget, resizable) \
+ gtk_window_set_policy(widget, FALSE, resizable, FALSE)
+# define gtk_image_new_from_pixmap(pixmap, mask) \
+ gtk_pixmap_new(pixmap, mask)
+
+#endif
diff --git a/src/xsane-icon.rc b/src/xsane-icon.rc
new file mode 100755
index 0000000..ba814aa
--- /dev/null
+++ b/src/xsane-icon.rc
@@ -0,0 +1 @@
+AppIcon ICON "xsane.ico"
diff --git a/src/xsane-icons.c b/src/xsane-icons.c
index baa5f32..b09d2f4 100644
--- a/src/xsane-icons.c
+++ b/src/xsane-icons.c
@@ -3,7 +3,7 @@
xsane-icons.c
Oliver Rauch <Oliver.Rauch@rauch-domain.de>
- Copyright (C) 1998-2002 Oliver Rauch
+ Copyright (C) 1998-2005 Oliver Rauch
This file is part of the XSANE package.
This program is free software; you can redistribute it and/or modify
@@ -59,153 +59,269 @@ const char *error_xpm[] =
"40 40 6 1",
" c None",
". c #FE0809",
-"+ c #FDFDFC",
-"@ c #E5D5D6",
-"# c #E1A09F",
-"$ c #FE8081",
-" #@@++++@@# ",
-" #@++++++++++++@# ",
-" #+++@#$......$$@+++# ",
-" #+++#..............#+++# ",
-" #++#..................@++# ",
-" @++$....................$++@ ",
-" @+@........................++@ ",
-" #+@$.........................@+# ",
-" #++...........................$++# ",
-" ++$.....@+...............++....$++ ",
-" #+#.....+++@.............+++@....#+# ",
-" ++.....$+++++...........@++++$....++ ",
-" #+#......#++++@.........+++++#.....#+# ",
-" @+........#+++++.......@++++$.......+@ ",
-" +@.........$++++@.....+++++#........++ ",
-"#+$..........#+++++...@++++$.........$+#",
-"@+$...........$+++++$@++++#..........$+@",
-"@+.............#+++++++++$............+@",
-"++..............$+++++++#.............++",
-"++...............#+++++#..............++",
-"++...............++++++@..............++",
-"++..............@++++++++.............++",
-"@+.............+++++@++++@............+@",
-"@+$...........@++++#.#+++++..........$+@",
-"#+$..........+++++$...$++++@.........$+#",
-" +@.........@++++#.....#+++++........@+ ",
-" @+........+++++$.......$++++@.......+@ ",
-" #+#......@++++#.........#+++++.....#+# ",
-" ++.....#++++#...........$++++$....++ ",
-" @+#.....$++$.............#++$....#+# ",
-" ++$.....#$...............$#....$++ ",
-" #++............................++# ",
-" #++..........................++# ",
-" @++........................++@ ",
-" @++$....................$++@ ",
-" #++#..................#++# ",
-" #+++#..............#+++# ",
-" #+++@$$......$$++++# ",
-" #+++++++++++++@# ",
-" #@@++++@@# "
-};
-
-/* --------------------------------------------------- */
-
-const char *warning_xpm[] =
-{
-"40 40 4 1",
-" c None",
-". c #FFFFFF",
-"+ c #FFFA00",
-"@ c #000000",
-" ",
-" .. ",
-" .. ",
-" .++. ",
-" .++. ",
-" .++++. ",
-" .++++. ",
-" .++++++. ",
-" .++++++. ",
-" .++++++++. ",
-" .++++++++. ",
-" .++++++++++. ",
-" .++++@@++++. ",
-" .++++@@@@++++. ",
-" .+++@@@@@@+++. ",
-" .++++@@@@@@++++. ",
-" .+++@@@@@@@@+++. ",
-" .++++@@@@@@@@++++. ",
-" .++++@@@@@@@@++++. ",
-" .++++++@@@@@@++++++. ",
-" .++++++@@@@@@++++++. ",
-" .+++++++@@@@@@+++++++. ",
-" .+++++++@@@@@@+++++++. ",
-" .+++++++++@@@@+++++++++. ",
-" .+++++++++@@@@+++++++++. ",
-" .++++++++++@@@@++++++++++. ",
-" .+++++++++++@@+++++++++++. ",
-" .++++++++++++++++++++++++++. ",
-" .++++++++++++++++++++++++++. ",
-" .++++++++++++++++++++++++++++. ",
-" .+++++++++++++@@+++++++++++++. ",
-" .+++++++++++++@@@@+++++++++++++. ",
-" .+++++++++++++@@@@+++++++++++++. ",
-" .+++++++++++++++@@+++++++++++++++. ",
-" .++++++++++++++++++++++++++++++++. ",
-" .++++++++++++++++++++++++++++++++++. ",
-" .++++++++++++++++++++++++++++++++++. ",
-" ..++++++++++++++++++++++++++++++++++.. ",
-" ...................................... ",
-"........................................"
-};
-
-/* --------------------------------------------------- */
-
-const char *info_xpm[] =
-{
-"40 40 4 1",
-" c None",
-". c #FFFFFF",
+"+ c #FFFFFF",
+"@ c #FF8080",
+"- c #7A7A7A",
+"# c #6C6B6B",
+" ---------- ",
+" -- @@@+@@@--### ",
+" --@@+++++++++@@--## ",
+" --@+++@@@...@@@+++@--## ",
+" -@+++@...........@+++@-## ",
+" -@++@...............@++@-## ",
+" -@++@.................@++@-## ",
+" -@+@.....................++@-## ",
+" -@+@@......................@+@-## ",
+" -@++........................@++@-# ",
+" --++@.....@+............++....@++-## ",
+" -@+@.....+++@..........+++@....@+@-# ",
+" --++.....@+++++........@++++@....++-## ",
+" -@+@......@++++@......+++++@.....@+@-# ",
+" -@+........@+++++....@++++@.......+@-# ",
+" -+@.........@++++@..+++++@........++-##",
+"-@+@..........@+++++@++++@.........@+@-#",
+"-@+@...........@++++++++@..........@+@-#",
+"-@+.............@++++++@............+@-#",
+"-++..............@++++@.............++-#",
+"-@+.............+++++++@............+@-#",
+"-@+@...........@+++++++++..........@+@-#",
+"-@+@..........+++++@@++++@.........@+@-#",
+" -+@.........@++++@..@+++++........@+-##",
+" -@+........+++++@....@++++@.......+@-# ",
+" -@+@......@++++@......@+++++.....@+@-# ",
+" -++.....@++++@........@++++@....++-## ",
+" -@+@.....@++@..........@++@....@+@-# ",
+" -++@.....@@............@@....@++-## ",
+" -@++.........................++@-# ",
+" -@++.......................++@-## ",
+" -@++.....................++@-## ",
+" --@++@.................@++@-## ",
+" --@++@...............@++@-## ",
+" --@+++@...........@+++@-## ",
+" ---@+++@@@...@@++++@--## ",
+" ---@++++++++++@@--### ",
+" ----@@@+@@@---### ",
+" ----------#### ",
+" --####### "
+};
+
+/* --------------------------------------------------- */
+
+const char *warning_xpm[] = {
+"40 40 6 1",
+" c None",
+". c #FFFFFF",
+"+ c #FFFA00",
+"@ c #000000",
+"- c #7A7A7A",
+"# c #6C6B6B",
+" ----## ",
+" -..-### ",
+" -....-## ",
+" -....-### ",
+" -..++..-## ",
+" -..++..-### ",
+" -..++++..-## ",
+" -..++++..-### ",
+" -..++++++..-## ",
+" -..++++++..-### ",
+" -..++++++++..-## ",
+" -..+++@@+++..-### ",
+" -..+++@@@@+++..-## ",
+" -..++@@@@@@++..-### ",
+" -..+++@@@@@@+++..-## ",
+" -..++@@@@@@@@++..-### ",
+" -..+++@@@@@@@@+++..-## ",
+" -..+++@@@@@@@@+++..-### ",
+" -..+++++@@@@@@+++++..-## ",
+" -..+++++@@@@@@+++++..-### ",
+" -..++++++@@@@@@++++++..-## ",
+" -..++++++@@@@@@++++++..-### ",
+" -..++++++++@@@@++++++++..-## ",
+" -..++++++++@@@@++++++++..-### ",
+" -..+++++++++@@@@+++++++++..-## ",
+" -..++++++++++@@++++++++++..-### ",
+" -..++++++++++++++++++++++++..-## ",
+" -..++++++++++++++++++++++++..-### ",
+" -..++++++++++++++++++++++++++..-## ",
+" -..++++++++++++@@++++++++++++..-### ",
+" -..++++++++++++@@@@++++++++++++..-## ",
+" -..++++++++++++@@@@++++++++++++..-## ",
+" -..++++++++++++++@@++++++++++++++..-## ",
+" -..++++++++++++++++++++++++++++++..-## ",
+"-..++++++++++++++++++++++++++++++++..-##",
+"-....................................-##",
+"-....................................-##",
+"--------------------------------------##",
+" #######################################",
+" ##################################### "};
+
+/* --------------------------------------------------- */
+
+const char *info_xpm[] = {
+"40 40 6 1",
+" c None",
+". c #FFFFFF",
"+ c #00A000",
-"@ c #000000",
+"@ c #000000",
+"- c #7A7A7A",
+"# c #6C6B6B",
+" ----## ",
+" -..-### ",
+" -....-## ",
+" -....-### ",
+" -..++..-## ",
+" -..++..-### ",
+" -..++++..-## ",
+" -..++++..-### ",
+" -..++++++..-## ",
+" -..++++++..-### ",
+" -..++++++++..-## ",
+" -..+++@@+++..-### ",
+" -..+++@@@@+++..-## ",
+" -..++@@@@@@++..-### ",
+" -..+++@@@@@@+++..-## ",
+" -..++@@@@@@@@++..-### ",
+" -..+++@@@@@@@@+++..-## ",
+" -..+++@@@@@@@@+++..-### ",
+" -..+++++@@@@@@+++++..-## ",
+" -..+++++@@@@@@+++++..-### ",
+" -..++++++@@@@@@++++++..-## ",
+" -..++++++@@@@@@++++++..-### ",
+" -..++++++++@@@@++++++++..-## ",
+" -..++++++++@@@@++++++++..-### ",
+" -..+++++++++@@@@+++++++++..-## ",
+" -..++++++++++@@++++++++++..-### ",
+" -..++++++++++++++++++++++++..-## ",
+" -..++++++++++++++++++++++++..-### ",
+" -..++++++++++++++++++++++++++..-## ",
+" -..++++++++++++@@++++++++++++..-### ",
+" -..++++++++++++@@@@++++++++++++..-## ",
+" -..++++++++++++@@@@++++++++++++..-## ",
+" -..++++++++++++++@@++++++++++++++..-## ",
+" -..++++++++++++++++++++++++++++++..-## ",
+"-..++++++++++++++++++++++++++++++++..-##",
+"-....................................-##",
+"-....................................-##",
+"--------------------------------------##",
+" #######################################",
+" ##################################### "};
+
+/* --------------------------------------------------- */
+
+const char *device_xpm[] = {
+"40 40 12 1",
+" c None",
+". c #FFFFFF",
+"* c #FAFAFA",
+"+ c #F8F8F8",
+"0 c #F2F2F2",
+"- c #808080",
+"_ c #505050",
+"@ c #000000",
+"A c #A0E0F8",
+"B c #A8E8FA",
+"C c #B0F0FF",
+"D c #C0F8FF",
" ",
-" .. ",
-" .. ",
-" .++. ",
-" .++. ",
-" .++++. ",
-" .++++. ",
-" .++++++. ",
-" .++++++. ",
-" .++++++++. ",
-" .++++++++. ",
-" .++++++++++. ",
-" .++++@@++++. ",
-" .++++@@@@++++. ",
-" .+++@@@@@@+++. ",
-" .++++@@@@@@++++. ",
-" .+++@@@@@@@@+++. ",
-" .++++@@@@@@@@++++. ",
-" .++++@@@@@@@@++++. ",
-" .++++++@@@@@@++++++. ",
-" .++++++@@@@@@++++++. ",
-" .+++++++@@@@@@+++++++. ",
-" .+++++++@@@@@@+++++++. ",
-" .+++++++++@@@@+++++++++. ",
-" .+++++++++@@@@+++++++++. ",
-" .++++++++++@@@@++++++++++. ",
-" .+++++++++++@@+++++++++++. ",
-" .++++++++++++++++++++++++++. ",
-" .++++++++++++++++++++++++++. ",
-" .++++++++++++++++++++++++++++. ",
-" .+++++++++++++@@+++++++++++++. ",
-" .+++++++++++++@@@@+++++++++++++. ",
-" .+++++++++++++@@@@+++++++++++++. ",
-" .+++++++++++++++@@+++++++++++++++. ",
-" .++++++++++++++++++++++++++++++++. ",
-" .++++++++++++++++++++++++++++++++++. ",
-" .++++++++++++++++++++++++++++++++++. ",
-" ..++++++++++++++++++++++++++++++++++.. ",
-" ...................................... ",
-"........................................"
-};
+" ",
+" ",
+" -- ",
+" ---..--- ",
+" ---.....*--- ",
+" --.......***--- @@@ ",
+" _-......****+--- @@ @ ",
+" _-....****+++---@ @ ",
+" _-..****+++++-@- @ ",
+" _-****+++++++--- @@@ ",
+" -_-**+++++++++--- ",
+" -.._-+++++++++++--- ",
+" -...A_-++++++++000--- ",
+" -...AAA_-++++++00000--- ",
+" -...AAAAA_-++++0000000--- ",
+" -...AAAAAAA_-++000000000--- ",
+" -...AAAAAAAAA_-00000000000--- ",
+" -...AAAAAAAAAAB_-000000000-_---",
+" -...AAAAAAAAAABBB_-000000--_----",
+" -...AAAAAAAAAABBBBB_-000--_-+_---",
+" -...AAAAAAAAAABBBBCCC_---_--+_--- ",
+" -...AAAAAAAAAABBBBCCCCC__---+_--- ",
+" -+...AAAAAAAAABBBBCCCCDDD---+_--- ",
+" -+..*AAAAAAABBBBCCCCDDD..-+_--- ",
+" -+***AAAAABBBBCCCCDDD000+_--- ",
+" -+**AAAABBBBCCCCDDD000+_--- ",
+" -+**AABBBBCCCCDDD000+_--- ",
+" -+++BBBBCCCCDDD000+_--- ",
+" -++0BBCCCCDDD000+_--- ",
+" -+00CCCCDDD000+_--- ",
+" -+000CDDD000+_--- ",
+" -+000DD000+_--- ",
+" -+0++000+_--- ",
+" -++++++_--- ",
+" -++++_--- ",
+" -++_--- ",
+" ----- ",
+" --- ",
+" "};
+
+/* --------------------------------------------------- */
+
+const char *no_device_xpm[] = {
+"40 40 13 1",
+" c None",
+". c #FFFFFF",
+"* c #FAFAFA",
+"+ c #F8F8F8",
+"0 c #F2F2F2",
+"- c #808080",
+"_ c #505050",
+"@ c #000000",
+"A c #A0E0F8",
+"B c #A8E8FA",
+"C c #B0F0FF",
+"D c #C0F8FF",
+"# c #C03030",
+" ",
+" ",
+" ",
+" -- ",
+" ---..--- ",
+" ## ---.....*--- ## ",
+" #### --.......***--- #### ",
+" #### _-......****+---#### ",
+" #### _-....****+++-#### ",
+" #### _-..****++++#### ",
+" #### _-****++++####-- ",
+" #### -_-**++++####+--- ",
+" ####.._-++++####+++--- ",
+" ####.A_-++####++000--- ",
+" -####AA_-####++00000--- ",
+" -..####AA####++0000000--- ",
+" -...A########++000000000--- ",
+" -...AAA######_-00000000000--- ",
+" -...AAAAA####AA_-000000000-_---",
+" -...AAAAA######BB_-000000--_----",
+" -...AAAAA########BB_-000--_-+_---",
+" -...AAAAA####A####CCC_---_--+_--- ",
+" -...AAAAA####ABB####CCC__---+_--- ",
+" -+...AAAA####ABBBB####DDD---+_--- ",
+" -+..*AA####ABBBBCC####D..-+_--- ",
+" -+***####ABBBBCCCC####00+_--- ",
+" -+*####ABBBBCCCCDD####+_--- ",
+" -####ABBBBCCCCDDD0####--- ",
+" ####+BBBBCCCCDDD000####- ",
+" ####+00BBCCCCDDD000+_#### ",
+" #### -+00CCCCDDD000+_--#### ",
+" ## -+000CDDD000+_--- ## ",
+" -+000DD000+_--- ",
+" -+0++000+_--- ",
+" -++++++_--- ",
+" -++++_--- ",
+" -++_--- ",
+" ----- ",
+" --- ",
+" "};
+
/* --------------------------------------------------- */
const char *file_xpm[] =
@@ -242,6 +358,76 @@ const char *file_xpm[] =
/* --------------------------------------------------- */
+const char *load_xpm[] =
+{
+/* width height num_colors chars_per_pixel */
+" 20 20 5 1",
+/* colors */
+"* c #000000",
+". c #ffff70",
+"+ c #505000",
+"- c #e0e0e0",
+" none",
+/* pixels */
+" ",
+" ** ",
+" *..**** ",
+" *......**** ",
+" *..........**** ",
+" ****..............*",
+"*---++++...........*",
+"*-------++++.......*",
+"*-----------++++...*",
+"*---------------+..*",
+" *--------------+..*",
+" *--------------+..*",
+" *---------------+.*",
+" *--------------+.*",
+" *--------------+.*",
+" *---------------+*",
+" ****-----------+*",
+" ****-------+*",
+" *********",
+" "
+};
+
+/* --------------------------------------------------- */
+
+const char *save_xpm[] =
+{
+/* width height num_colors chars_per_pixel */
+" 20 20 5 1",
+/* colors */
+"* c #000000",
+". c #70b070",
+"+ c #609060",
+"- c #e0e0e0",
+" none",
+/* pixels */
+" ",
+" ................ ",
+" .*............*. ",
+" .*............*. ",
+" ................ ",
+" ................ ",
+" ................ ",
+" ................ ",
+" ................ ",
+" ................ ",
+" ................ ",
+" ................ ",
+" ....--------.... ",
+" ....-+++----.... ",
+" ....-+++----.... ",
+" ....-+++----.... ",
+" ....-+++----.... ",
+" ............... ",
+" ",
+" "
+};
+
+/* --------------------------------------------------- */
+
const char *ocr_xpm[] =
{
/* width height num_colors chars_per_pixel */
@@ -379,6 +565,42 @@ const char *blur_xpm[] =
/* --------------------------------------------------- */
+const char *undo_xpm[] =
+{
+/* width height num_colors chars_per_pixel */
+" 20 20 4 1",
+/* colors */
+"* c #000000",
+"+ c #404040",
+". c #808080",
+" none",
+/* pixels */
+" ",
+" ",
+" ** **** ",
+" ** *** *** ",
+" ** ** ** ",
+" **** ** ",
+" ******* ** ",
+" ******* ** ",
+" ** ",
+" ** ",
+" ** ",
+" ** ",
+" ** ",
+" ** ",
+" ** ",
+" ** ",
+" ** ",
+" ** ",
+" ** ",
+" ** ",
+" ** ",
+" "
+};
+
+/* --------------------------------------------------- */
+
const char *clone_xpm[] =
{
/* width height num_colors chars_per_pixel */
@@ -623,6 +845,38 @@ const char *faxreceiver_xpm[] =
" 20 20 3 1",
/* colors */
"* c #000000",
+"- c #404040",
+" none",
+/* pixels */
+" **** ",
+" **** **** ",
+" ** ** ",
+" * *",
+" * ******* *",
+" * * * * ",
+" *** *** ",
+" * ** ** ** ** * ",
+" * ** ** ** ** * ",
+" * * ",
+" * ** ** ** ** * ",
+" * ** ** ** ** * ",
+" * * ",
+" * ** ** ** ** * ",
+" * ** ** ** ** * ",
+" * * ",
+" * ** ** ** ** * ",
+" * ** ** ** ** * ",
+" * *",
+" ***************** ",
+};
+/* --------------------------------------------------- */
+#if 0
+const char *person_xpm[] =
+{
+/* width height num_colors chars_per_pixel */
+" 20 20 3 1",
+/* colors */
+"* c #000000",
"- c #e0e0e0",
" none",
/* pixels */
@@ -647,6 +901,7 @@ const char *faxreceiver_xpm[] =
" *------*** ",
" *----* ",
};
+#endif
/* --------------------------------------------------- */
@@ -834,6 +1089,42 @@ const char *medium_xpm[] = {
/* --------------------------------------------------- */
+const char *medium_edit_xpm[] = {
+/* width height num_colors chars_per_pixel */
+" 50 20 7 1",
+/* colors */
+". c #000000",
+"# c #a05020",
+"- c #608060",
+"0 c #80c080",
+"+ c #a0a0a0",
+"* c #ffffff",
+" none",
+/* pixels */
+" ",
+" ################ ",
+" ################ ",
+" #..##########..# ",
+" #..##########..# ",
+" ################ ",
+" ################ ",
+" #..##########..# ++++++++++++++++++++++++++++ ",
+" #..##########..# +0000000**.**00000000000000- ",
+" ################ +0000000**.**00000000000000- ",
+" ################ +0000000**.**00000000000000- ",
+" #..##########..# +0000000**.**00000000000000- ",
+" #..##########..# ---------------------------- ",
+" ################ ",
+" ################ ",
+" #..##########..# ",
+" #..##########..# ",
+" ################ ",
+" ################ ",
+" "
+};
+
+/* --------------------------------------------------- */
+
const char *medium_delete_xpm[] = {
/* width height num_colors chars_per_pixel */
" 20 20 4 1",
@@ -1521,14 +1812,148 @@ const char *default_enhancement_xpm[] =
/* --------------------------------------------------- */
-const char *pipette_white_xpm[] =
+const char *add_batch_xpm[] =
{
/* width height num_colors chars_per_pixel */
" 20 20 3 1",
/* colors */
". c #000000",
" none",
+"g c #70a070",
+/* pixels */
+" ",
+" ... ... ... ... .. ",
+" . . ",
+" . . ",
+" ",
+" . . ",
+" . gg . ",
+" . gg . ",
+" gg ",
+" . gg . ",
+" . gggggggggg . ",
+" . gggggggggg . ",
+" gg ",
+" . gg . ",
+" . gg . ",
+" . gg . ",
+" ",
+" . . ",
+" . . ",
+" ... ... ... ... .. ",
+};
+
+/* --------------------------------------------------- */
+
+const char *del_batch_xpm[] =
+{
+/* width height num_colors chars_per_pixel */
+" 20 20 3 1",
+/* colors */
+". c #000000",
+" none",
+"r c #d07070",
+/* pixels */
+" ",
+"rr.. ... ... ... .rr",
+" rr rr ",
+" .rr rr. ",
+" rr rr ",
+" . rr rr . ",
+" . rr rr . ",
+" . rr rr . ",
+" rr rr ",
+" . rrrr . ",
+" . rr . ",
+" . rrrr . ",
+" rr rr ",
+" . rr rr . ",
+" . rr rr . ",
+" . rr rr . ",
+" rr rr ",
+" .rr rr. ",
+" rr rr ",
+"rr.. ... ... ... .rr",
+};
+
+/* --------------------------------------------------- */
+
+const char *empty_batch_xpm[] =
+{
+/* width height num_colors chars_per_pixel */
+" 20 20 3 1",
+/* colors */
+". c #000000",
+" none",
+"* c #ffffff",
+/* pixels */
+" ",
+" ................ ",
+" .**************. ",
+" .**************. ",
+" .**************. ",
+" .**************. ",
+" .**************. ",
+" .**************. ",
+" .**************. ",
+" .**************. ",
+" .**************. ",
+" .**************. ",
+" .**************. ",
+" .**************. ",
+" .**************. ",
+" .**************. ",
+" .**************. ",
+" .**************. ",
+" .**************. ",
+" ................ ",
+};
+
+/* --------------------------------------------------- */
+
+const char *ascii_xpm[] =
+{
+/* width height num_colors chars_per_pixel */
+" 20 20 2 1",
+/* colors */
+". c #000000",
+" none",
+/* pixels */
+" ",
+" ",
+" ",
+" ",
+" ..... .... ... ",
+" . . . . . . ",
+" . . . . . ",
+" ..... ..... . ",
+" . . . . . ",
+" . . . . . . ",
+" . . .... ... ",
+" ",
+" .................. ",
+" ",
+" ",
+" ",
+" ",
+" ",
+" ",
+" ",
+};
+
+/* --------------------------------------------------- */
+
+const char *pipette_white_xpm[] =
+{
+/* width height num_colors chars_per_pixel */
+" 20 20 6 1",
+/* colors */
+". c #000000",
+" none",
"a c #ffffff",
+"r c #af8f8f",
+"g c #8fff8f",
+"b c #8f8fff",
/* pixels */
" ",
" ",
@@ -1537,18 +1962,18 @@ const char *pipette_white_xpm[] =
" ...... ",
" ......... ",
" ...... ",
-" .aaa.. ",
-" .aaaa.. ",
-" .aaaa. . ",
-" .aaaa. . ",
-" .aaaa. ",
-" .aaaa. ",
-" .aaaa. ",
-" .aaaa. ",
-" .aaaa. ",
-" .aaaa. ",
-" .aaaa. ",
-" .aaa. ",
+" .abg.. ",
+" .abgr.. ",
+" .abgr. . ",
+" .abgr. . ",
+" .abgr. ",
+" .abgr. ",
+" .abgr. ",
+" .abgr. ",
+" .abgr. ",
+" .abgr. ",
+" .abgr. ",
+" .bgr. ",
" ... ",
};
@@ -1557,12 +1982,15 @@ const char *pipette_white_xpm[] =
const char *pipette_gray_xpm[] =
{
/* width height num_colors chars_per_pixel */
-" 20 20 4 1",
+" 20 20 7 1",
/* colors */
". c #000000",
" none",
"a c #ffffff",
"X c #808080",
+"r c #af8f8f",
+"g c #8fff8f",
+"b c #8f8fff",
/* pixels */
" ",
" ",
@@ -1571,9 +1999,9 @@ const char *pipette_gray_xpm[] =
" ...... ",
" ......... ",
" ...... ",
-" .aaa.. ",
-" .aaaa.. ",
-" .aaaa. . ",
+" .abg.. ",
+" .abgr.. ",
+" .abgr. . ",
" .XXXX. . ",
" .XXXX. ",
" .XXXX. ",
@@ -1590,11 +2018,14 @@ const char *pipette_gray_xpm[] =
const char *pipette_black_xpm[] =
{
/* width height num_colors chars_per_pixel */
-" 20 20 3 1",
+" 20 20 6 1",
/* colors */
". c #000000",
" none",
"a c #ffffff",
+"r c #af8f8f",
+"g c #8fff8f",
+"b c #8f8fff",
/* pixels */
" ",
" ",
@@ -1603,9 +2034,9 @@ const char *pipette_black_xpm[] =
" ...... ",
" ......... ",
" ...... ",
-" .aaa.. ",
-" .aaaa.. ",
-" .aaaa. . ",
+" .abg.. ",
+" .abgr.. ",
+" .abgr. . ",
" ...... . ",
" ...... ",
" ...... ",
@@ -1620,27 +2051,67 @@ const char *pipette_black_xpm[] =
/* --------------------------------------------------- */
+const char *zoom_area_xpm[] =
+{
+/* width height num_colors chars_per_pixel */
+" 20 20 7 1",
+/* colors */
+" none",
+". c #000000",
+"+ c #c0c0c0",
+"a c #ffffff",
+"r c #af8f8f",
+"g c #8fff8f",
+"b c #8f8fff",
+/* pixels */
+" ",
+" ",
+" ..... ",
+" .+aaaa. ",
+" .++aaaag. ",
+" .+++aabagr. ",
+" .aaaaabbgr. ",
+" .aabbbbbgr. ",
+" .aaaabbgrr. ",
+" .gggggrr. ",
+" .rrrrr. ",
+" ....... ",
+" ... ",
+" ... ",
+" . . . . ... ",
+" . . ... ",
+" . . ... ",
+" . . .. ",
+" . . . . ",
+" ",
+};
+
+/* --------------------------------------------------- */
+
const char *zoom_in_xpm[] =
{
/* width height num_colors chars_per_pixel */
-" 20 20 4 1",
+" 20 20 7 1",
/* colors */
" none",
". c #000000",
"+ c #c0c0c0",
"a c #ffffff",
+"r c #af8f8f",
+"g c #8fff8f",
+"b c #8f8fff",
/* pixels */
" ",
" ",
" ..... ",
" .+aaaa. ",
-" .++aaaaa. ",
-" .+++aaaaaa. ",
-" .aaaaaaaaa. ",
-" .aaaaaaaaa. ",
-" .aaaaaaaaa. ",
-" .aaaaaaa. ",
-" .aaaaa. ",
+" .++aaaag. ",
+" .+++aabagr. ",
+" .aaaaabbgr. ",
+" .aabbbbbgr. ",
+" .aaaabbgrr. ",
+" .gggggrr. ",
+" .rrrrr. ",
" ....... ",
" ... ",
" . ... ",
@@ -1657,24 +2128,27 @@ const char *zoom_in_xpm[] =
const char *zoom_not_xpm[] =
{
/* width height num_colors chars_per_pixel */
-" 20 20 4 1",
+" 20 20 7 1",
/* colors */
" none",
". c #000000",
"+ c #c0c0c0",
"a c #ffffff",
+"r c #af8f8f",
+"g c #8fff8f",
+"b c #8f8fff",
/* pixels */
" ",
" ",
" .. ..... .. ",
" ...+aaaa. .. ",
-" ..+aaaaa. .. ",
-" .+..aaaaaa. .. ",
-" .aa..aaaaa... ",
-" .aaa..aaaa.. ",
-" .aaaa..aa.. ",
-" .aaaa.... ",
-" .aaaa.. ",
+" ..+aaaag. .. ",
+" .+..aabagr. .. ",
+" .aa..abbgr... ",
+" .aab..bbgr.. ",
+" .aaaa..ag.. ",
+" .gggg.... ",
+" .rrrr.. ",
" ....... ",
" .. ... ",
" .. ... ",
@@ -1691,24 +2165,27 @@ const char *zoom_not_xpm[] =
const char *zoom_undo_xpm[] =
{
/* width height num_colors chars_per_pixel */
-" 20 20 4 1",
+" 20 20 7 1",
/* colors */
" none",
". c #000000",
"+ c #c0c0c0",
"a c #ffffff",
+"r c #af8f8f",
+"g c #8fff8f",
+"b c #8f8fff",
/* pixels */
" ",
" ",
" ..... ",
" .+aaaa. ",
-" .++aaaaa. ",
-" .+++aaaaaa. ",
-" .aaaaaaaaa. ",
-" .aaaaaaaaa. ",
-" .aaaaaaaaa. ",
-" .aaaaaaa. ",
-" .aaaaa. ",
+" .++aaaag. ",
+" .+++aabagr. ",
+" .aaaaabbgr. ",
+" .aabbbbbgr. ",
+" .aaaabbgrr. ",
+" .gggggrr. ",
+" .rrrrr. ",
" ....... ",
" ... ",
" ",
@@ -1725,24 +2202,27 @@ const char *zoom_undo_xpm[] =
const char *zoom_out_xpm[] =
{
/* width height num_colors chars_per_pixel */
-" 20 20 4 1",
+" 20 20 7 1",
/* colors */
" none",
". c #000000",
"+ c #c0c0c0",
"a c #ffffff",
+"r c #af8f8f",
+"g c #8fff8f",
+"b c #8f8fff",
/* pixels */
" ",
" ",
" ..... ",
" .+aaaa. ",
-" .++aaaaa. ",
-" .+++aaaaaa. ",
-" .aaaaaaaaa. ",
-" .aaaaaaaaa. ",
-" .aaaaaaaaa. ",
-" .aaaaaaa. ",
-" .aaaaa. ",
+" .++aaaag. ",
+" .+++aabagr. ",
+" .aaaaabbgr. ",
+" .aabbbbbgr. ",
+" .aaaabbgrr. ",
+" .gggggrr. ",
+" .rrrrr. ",
" ....... ",
" ... ",
" ... ",
@@ -1763,27 +2243,61 @@ const char *full_preview_area_xpm[] =
/* colors */
" none",
". c #000000",
-"+ c #c0c0c0",
+"+ c #208020",
+"a c #ffffff",
+/* pixels */
+" ",
+" ................. ",
+" .+++++++++++++++. ",
+" .+ . +. ",
+" .+ ... +. ",
+" .+ . . . +. ",
+" .+ . +. ",
+" .+ . +. ",
+" .+ . . . +. ",
+" .+ . . . +. ",
+" .+.............+. ",
+" .+ . . . +. ",
+" .+ . . . +. ",
+" .+ . +. ",
+" .+ . . . +. ",
+" .+ ... +. ",
+" .+ . +. ",
+" .+++++++++++++++. ",
+" ................. ",
+" ",
+};
+
+/* --------------------------------------------------- */
+
+const char *auto_raise_preview_area_xpm[] =
+{
+/* width height num_colors chars_per_pixel */
+" 20 20 4 1",
+/* colors */
+" none",
+". c #000000",
+"+ c #208020",
"a c #ffffff",
/* pixels */
" ",
" ................. ",
" . . ",
-" . . . ",
-" . ... . ",
-" . . . . . ",
-" . . . ",
-" . . . ",
-" . . . . . ",
-" . . . . . ",
-" . ............. . ",
-" . . . . . ",
-" . . . . . ",
-" . . . ",
-" . . . ",
-" . . . . . ",
-" . ... . ",
-" . . . ",
+" . . ",
+" . +++++++++++ . ",
+" . + . + . ",
+" . + ... + . ",
+" . + . + . ",
+" . + . + . ",
+" . + . . . + . ",
+" . +.........+ . ",
+" . + . . . + . ",
+" . + . + . ",
+" . + . + . ",
+" . + ... + . ",
+" . + . + . ",
+" . +++++++++++ . ",
+" . . ",
" ................. ",
" ",
};
@@ -1797,7 +2311,7 @@ const char *auto_select_preview_area_xpm[] =
/* colors */
" none",
". c #000000",
-"+ c #c0c0c0",
+"+ c #208020",
"a c #ffffff",
/* pixels */
" ",
@@ -1806,14 +2320,14 @@ const char *auto_select_preview_area_xpm[] =
" . . . . . ",
" . ... . ",
" . . . ",
-" . ....... . ",
-" . . . . ",
-" . . . . . . ",
-" . . . . . . ",
-" ...... ...... ",
-" . . . . . . ",
-" . . . . . . ",
-" . ....... . ",
+" . +++++++ . ",
+" . + + . ",
+" . . + + . . ",
+" . . + + . . ",
+" .....+ +..... ",
+" . . + + . . ",
+" . . + + . . ",
+" . +++++++ . ",
" . . . ",
" . ... . ",
" . . . . . ",
@@ -1837,16 +2351,16 @@ const char *delete_images_xpm[] =
" ........ ",
" .......... ",
" ............ ",
-" ... .. ... ",
-" ... .. ... ",
+" .. .. .. ",
+" .. .. .. ",
" .............. ",
-" ..... ..... ",
+" .... .... ",
+" .... .... ",
" .......... ",
-" ........ ",
-" ...... ",
-" ...... ",
-".. ...... ..",
-".... .... ....",
+" .......... ",
+" .......... ",
+".. ........ ..",
+".... ...... ....",
" ... ... ",
" ... ... ",
" .... ",
@@ -1858,6 +2372,175 @@ const char *delete_images_xpm[] =
/* --------------------------------------------------- */
+const char *size_xpm[] =
+{
+/* width height num_colors chars_per_pixel */
+" 20 20 4 1",
+/* colors */
+" none",
+". c #000000",
+"+ c #c0c0c0",
+"a c #ffffff",
+/* pixels */
+" ",
+" .................. ",
+" . . ",
+" . . . ",
+" . . ",
+" . . . ",
+" . . ",
+" . . . ",
+" . . ",
+" . . . . . . . . ",
+" . . ",
+" . . ",
+" . . ",
+" . . ",
+" . . ",
+" . . ",
+" . . ",
+" . . ",
+" .................. ",
+" ",
+};
+
+/* --------------------------------------------------- */
+
+const char *size_x_xpm[] =
+{
+/* width height num_colors chars_per_pixel */
+" 20 20 4 1",
+/* colors */
+" none",
+". c #000000",
+"+ c #8080f0",
+"a c #ffffff",
+/* pixels */
+" ",
+" .................. ",
+" . . ",
+" . . ",
+" . . ",
+" . . ",
+" . . ",
+" . + + . ",
+" . ++ ++ . ",
+" .++++++++++++++++. ",
+" .++++++++++++++++. ",
+" . ++ ++ . ",
+" . + + . ",
+" . . ",
+" . . ",
+" . . ",
+" . . ",
+" . . ",
+" .................. ",
+" ",
+};
+/* --------------------------------------------------- */
+
+const char *size_y_xpm[] =
+{
+/* width height num_colors chars_per_pixel */
+" 20 20 4 1",
+/* colors */
+" none",
+". c #000000",
+"+ c #8080f0",
+"a c #ffffff",
+/* pixels */
+" ",
+" .................. ",
+" . ++ . ",
+" . ++++ . ",
+" . ++++++ . ",
+" . ++ . ",
+" . ++ . ",
+" . ++ . ",
+" . ++ . ",
+" . ++ . ",
+" . ++ . ",
+" . ++ . ",
+" . ++ . ",
+" . ++ . ",
+" . ++ . ",
+" . ++++++ . ",
+" . ++++ . ",
+" . ++ . ",
+" .................. ",
+" ",
+};
+
+/* --------------------------------------------------- */
+
+const char *rotation_xpm[] =
+{
+/* width height num_colors chars_per_pixel */
+" 20 20 4 1",
+/* colors */
+" none",
+". c #000000",
+"+ c #c0c0c0",
+"a c #ffffff",
+/* pixels */
+" ",
+" .. ",
+" .. ",
+" .. ",
+" .. ",
+" .. ",
+" ....... ",
+" .. . ",
+" .. . ",
+" .. . ",
+" .. . ",
+" .. . ",
+" .. . ",
+" .. . ",
+" .. . ",
+" .. ..... ",
+" .. ... ",
+" ... . . . . . . . ",
+" .. . . . . . . . . ",
+" ",
+};
+
+/* --------------------------------------------------- */
+
+const char *aspect_ratio_xpm[] =
+{
+/* width height num_colors chars_per_pixel */
+" 20 20 4 1",
+/* colors */
+" none",
+". c #000000",
+"+ c #c0c0c0",
+"a c #ffffff",
+/* pixels */
+" ",
+" ",
+" ",
+" ",
+" ................. ",
+" . . ",
+" . . . ",
+" . . . ",
+" . . . ",
+" . . . ",
+" . . . ",
+" . . . ",
+" . . . ",
+" ................. ",
+" ",
+" ",
+" ",
+" ",
+" ",
+" ",
+};
+
+/* --------------------------------------------------- */
+
const char *printer_xpm[] =
{
/* width height num_colors chars_per_pixel */
@@ -2521,6 +3204,346 @@ const char *incomplete_xpm[] =
/* --------------------------------------------------- */
+const char *paper_orientation_portrait_center_xpm[] =
+{
+/* width height num_colors chars_per_pixel */
+" 20 20 4 1",
+/* colors */
+". c #00A000",
+"+ c #000000",
+"- c #ffffff",
+" none",
+/* pixels */
+" ++++++++++++ ",
+" ++++++++++++ ",
+" +----------+ ",
+" +----------+ ",
+" +----------+ ",
+" +----------+ ",
+" +----------+ ",
+" +---....---+ ",
+" +---....---+ ",
+" +---....---+ ",
+" +---....---+ ",
+" +---....---+ ",
+" +---....---+ ",
+" +----------+ ",
+" +----------+ ",
+" +----------+ ",
+" +----------+ ",
+" +----------+ ",
+" ++++++++++++ ",
+" ",
+};
+
+/* --------------------------------------------------- */
+
+const char *paper_orientation_portrait_top_left_xpm[] =
+{
+/* width height num_colors chars_per_pixel */
+" 20 20 4 1",
+/* colors */
+". c #00A000",
+"+ c #000000",
+"- c #ffffff",
+" none",
+/* pixels */
+" ++++++++++++ ",
+" ++++++++++++ ",
+" +....------+ ",
+" +....------+ ",
+" +....------+ ",
+" +....------+ ",
+" +....------+ ",
+" +....------+ ",
+" +----------+ ",
+" +----------+ ",
+" +----------+ ",
+" +----------+ ",
+" +----------+ ",
+" +----------+ ",
+" +----------+ ",
+" +----------+ ",
+" +----------+ ",
+" +----------+ ",
+" ++++++++++++ ",
+" ",
+};
+
+/* --------------------------------------------------- */
+
+const char *paper_orientation_portrait_top_right_xpm[] =
+{
+/* width height num_colors chars_per_pixel */
+" 20 20 4 1",
+/* colors */
+". c #00A000",
+"+ c #000000",
+"- c #ffffff",
+" none",
+/* pixels */
+" ++++++++++++ ",
+" ++++++++++++ ",
+" +------....+ ",
+" +------....+ ",
+" +------....+ ",
+" +------....+ ",
+" +------....+ ",
+" +------....+ ",
+" +----------+ ",
+" +----------+ ",
+" +----------+ ",
+" +----------+ ",
+" +----------+ ",
+" +----------+ ",
+" +----------+ ",
+" +----------+ ",
+" +----------+ ",
+" +----------+ ",
+" ++++++++++++ ",
+" ",
+};
+
+/* --------------------------------------------------- */
+
+const char *paper_orientation_portrait_bottom_left_xpm[] =
+{
+/* width height num_colors chars_per_pixel */
+" 20 20 4 1",
+/* colors */
+". c #00A000",
+"+ c #000000",
+"- c #ffffff",
+" none",
+/* pixels */
+" ++++++++++++ ",
+" ++++++++++++ ",
+" +----------+ ",
+" +----------+ ",
+" +----------+ ",
+" +----------+ ",
+" +----------+ ",
+" +----------+ ",
+" +----------+ ",
+" +----------+ ",
+" +----------+ ",
+" +----------+ ",
+" +....------+ ",
+" +....------+ ",
+" +....------+ ",
+" +....------+ ",
+" +....------+ ",
+" +....------+ ",
+" ++++++++++++ ",
+" ",
+};
+
+/* --------------------------------------------------- */
+
+const char *paper_orientation_portrait_bottom_right_xpm[] =
+{
+/* width height num_colors chars_per_pixel */
+" 20 20 4 1",
+/* colors */
+". c #00A000",
+"+ c #000000",
+"- c #ffffff",
+" none",
+/* pixels */
+" ++++++++++++ ",
+" ++++++++++++ ",
+" +----------+ ",
+" +----------+ ",
+" +----------+ ",
+" +----------+ ",
+" +----------+ ",
+" +----------+ ",
+" +----------+ ",
+" +----------+ ",
+" +----------+ ",
+" +----------+ ",
+" +------....+ ",
+" +------....+ ",
+" +------....+ ",
+" +------....+ ",
+" +------....+ ",
+" +------....+ ",
+" ++++++++++++ ",
+" ",
+};
+
+/* --------------------------------------------------- */
+
+const char *paper_orientation_landscape_center_xpm[] =
+{
+/* width height num_colors chars_per_pixel */
+" 20 20 4 1",
+/* colors */
+". c #00A000",
+"+ c #000000",
+"- c #ffffff",
+" none",
+/* pixels */
+" ",
+" ",
+" ",
+" ",
+" +++++++++++++++++++",
+" +----------------++",
+" +----------------++",
+" +----------------++",
+" +----........----++",
+" +----........----++",
+" +----........----++",
+" +----........----++",
+" +----------------++",
+" +----------------++",
+" +----------------++",
+" +++++++++++++++++++",
+" ",
+" ",
+" ",
+" ",
+};
+
+/* --------------------------------------------------- */
+
+const char *paper_orientation_landscape_top_left_xpm[] =
+{
+/* width height num_colors chars_per_pixel */
+" 20 20 4 1",
+/* colors */
+". c #00A000",
+"+ c #000000",
+"- c #ffffff",
+" none",
+/* pixels */
+" ",
+" ",
+" ",
+" ",
+" +++++++++++++++++++",
+" +........--------++",
+" +........--------++",
+" +........--------++",
+" +........--------++",
+" +----------------++",
+" +----------------++",
+" +----------------++",
+" +----------------++",
+" +----------------++",
+" +----------------++",
+" +++++++++++++++++++",
+" ",
+" ",
+" ",
+" ",
+};
+
+/* --------------------------------------------------- */
+
+const char *paper_orientation_landscape_top_right_xpm[] =
+{
+/* width height num_colors chars_per_pixel */
+" 20 20 4 1",
+/* colors */
+". c #00A000",
+"+ c #000000",
+"- c #ffffff",
+" none",
+/* pixels */
+" ",
+" ",
+" ",
+" ",
+" +++++++++++++++++++",
+" +--------........++",
+" +--------........++",
+" +--------........++",
+" +--------........++",
+" +----------------++",
+" +----------------++",
+" +----------------++",
+" +----------------++",
+" +----------------++",
+" +----------------++",
+" +++++++++++++++++++",
+" ",
+" ",
+" ",
+" ",
+};
+
+/* --------------------------------------------------- */
+
+const char *paper_orientation_landscape_bottom_left_xpm[] =
+{
+/* width height num_colors chars_per_pixel */
+" 20 20 4 1",
+/* colors */
+". c #00A000",
+"+ c #000000",
+"- c #ffffff",
+" none",
+/* pixels */
+" ",
+" ",
+" ",
+" ",
+" +++++++++++++++++++",
+" +----------------++",
+" +----------------++",
+" +----------------++",
+" +----------------++",
+" +----------------++",
+" +----------------++",
+" +........--------++",
+" +........--------++",
+" +........--------++",
+" +........--------++",
+" +++++++++++++++++++",
+" ",
+" ",
+" ",
+" ",
+};
+
+/* --------------------------------------------------- */
+
+const char *paper_orientation_landscape_bottom_right_xpm[] =
+{
+/* width height num_colors chars_per_pixel */
+" 20 20 4 1",
+/* colors */
+". c #00A000",
+"+ c #000000",
+"- c #ffffff",
+" none",
+/* pixels */
+" ",
+" ",
+" ",
+" ",
+" +++++++++++++++++++",
+" +----------------++",
+" +----------------++",
+" +----------------++",
+" +----------------++",
+" +----------------++",
+" +----------------++",
+" +--------........++",
+" +--------........++",
+" +--------........++",
+" +--------........++",
+" +++++++++++++++++++",
+" ",
+" ",
+" ",
+" ",
+};
+
+/* --------------------------------------------------- */
+
const unsigned char cursor_pipette_white[] =
{
0x00, 0x70, 0x00, 0xf8, 0x80, 0xff, 0x00, 0xfe, 0x00, 0x7d, 0x80, 0x38,
@@ -2556,3 +3579,39 @@ const unsigned char cursor_pipette_mask[] =
};
/* --------------------------------------------------- */
+
+const unsigned char cursor_autoraise_scanarea[] =
+{
+ 0xaa, 0x2a, 0xc1, 0x41, 0xe0, 0x03, 0x81, 0x40, 0x80, 0x00, 0x85, 0x50,
+ 0x86, 0x30, 0x7f, 0x7f, 0x86, 0x30, 0x85, 0x50, 0x80, 0x00, 0x81, 0x40,
+ 0xe0, 0x03, 0xc1, 0x41, 0xaa, 0x2a, 0x00, 0x00
+};
+
+/* --------------------------------------------------- */
+
+const unsigned char cursor_autoraise_scanarea_mask[] =
+{
+ 0xea, 0x2b, 0xe1, 0x43, 0xf0, 0x07, 0xc1, 0x41, 0xc4, 0x11, 0xc7, 0x71,
+ 0xff, 0x7f, 0x7f, 0x7f, 0xff, 0x7f, 0xc7, 0x71, 0xc4, 0x11, 0xc1, 0x41,
+ 0xf0, 0x07, 0xe1, 0x43, 0xea, 0x2b, 0x00, 0x00
+};
+
+/* --------------------------------------------------- */
+
+const unsigned char cursor_zoom[] =
+{
+ 0x00, 0x00, 0xf0, 0x01, 0x08, 0x02, 0x44, 0x04, 0x42, 0x08, 0x42, 0x08,
+ 0xba, 0x0b, 0x42, 0x08, 0x42, 0x08, 0x44, 0x04, 0x08, 0x06, 0xf0, 0x0f,
+ 0x00, 0x1c, 0x00, 0x38, 0x00, 0x70, 0x00, 0xe0
+};
+
+/* --------------------------------------------------- */
+
+const unsigned char cursor_zoom_mask[] =
+{
+ 0xf0, 0x01, 0xf8, 0x03, 0x0c, 0x06, 0x46, 0x0c, 0x53, 0x19, 0xe3, 0x18,
+ 0xbb, 0x1b, 0xe3, 0x18, 0x53, 0x19, 0x46, 0x0c, 0x0c, 0x0e, 0xf8, 0x1f,
+ 0xf0, 0x3f, 0x00, 0x7c, 0x00, 0xf8, 0x00, 0xf0
+};
+
+/* --------------------------------------------------- */
diff --git a/src/xsane-icons.h b/src/xsane-icons.h
index c4d2ec7..900ad17 100644
--- a/src/xsane-icons.h
+++ b/src/xsane-icons.h
@@ -3,7 +3,7 @@
xsane-icons.h
Oliver Rauch <Oliver.Rauch@rauch-domain.de>
- Copyright (C) 1998-2002 Oliver Rauch
+ Copyright (C) 1998-2005 Oliver Rauch
This file is part of the XSANE package.
This program is free software; you can redistribute it and/or modify
@@ -29,16 +29,29 @@
#define CURSOR_PIPETTE_HEIGHT 16
#define CURSOR_PIPETTE_HOT_X 1
#define CURSOR_PIPETTE_HOT_Y 14
+#define CURSOR_AUTORAISE_SCANAREA_WIDTH 16
+#define CURSOR_AUTORAISE_SCANAREA_HEIGHT 16
+#define CURSOR_AUTORAISE_SCANAREA_HOT_X 7
+#define CURSOR_AUTORAISE_SCANAREA_HOT_Y 7
+#define CURSOR_ZOOM_WIDTH 16
+#define CURSOR_ZOOM_HEIGHT 16
+#define CURSOR_ZOOM_HOT_X 6
+#define CURSOR_ZOOM_HOT_Y 6
extern const char *xsane_window_icon_xpm[];
extern const char *error_xpm[];
extern const char *warning_xpm[];
extern const char *info_xpm[];
+extern const char *device_xpm[];
+extern const char *no_device_xpm[];
extern const char *file_xpm[];
+extern const char *load_xpm[];
+extern const char *save_xpm[];
extern const char *ocr_xpm[];
extern const char *scale_xpm[];
extern const char *despeckle_xpm[];
extern const char *blur_xpm[];
+extern const char *undo_xpm[];
extern const char *clone_xpm[];
extern const char *rotate90_xpm[];
extern const char *rotate180_xpm[];
@@ -52,6 +65,7 @@ extern const char *mailreceiver_xpm[];
extern const char *subject_xpm[];
extern const char *colormode_xpm[];
extern const char *medium_xpm[];
+extern const char *medium_edit_xpm[];
extern const char *medium_delete_xpm[];
extern const char *Gamma_xpm[];
extern const char *Gamma_red_xpm[];
@@ -72,16 +86,28 @@ extern const char *enhance_xpm[];
extern const char *store_enhancement_xpm[];
extern const char *restore_enhancement_xpm[];
extern const char *default_enhancement_xpm[];
+extern const char *add_batch_xpm[];
+extern const char *del_batch_xpm[];
+extern const char *empty_batch_xpm[];
+extern const char *ascii_xpm[];
+
extern const char *pipette_white_xpm[];
extern const char *pipette_gray_xpm[];
extern const char *pipette_black_xpm[];
extern const char *zoom_not_xpm[];
extern const char *zoom_out_xpm[];
extern const char *zoom_in_xpm[];
+extern const char *zoom_area_xpm[];
extern const char *zoom_undo_xpm[];
extern const char *full_preview_area_xpm[];
extern const char *auto_select_preview_area_xpm[];
+extern const char *auto_raise_preview_area_xpm[];
extern const char *delete_images_xpm[];
+extern const char *size_xpm[];
+extern const char *size_x_xpm[];
+extern const char *size_y_xpm[];
+extern const char *rotation_xpm[];
+extern const char *aspect_ratio_xpm[];
extern const char *printer_xpm[];
extern const char *zoom_xpm[];
extern const char *zoom_x_xpm[];
@@ -102,9 +128,22 @@ extern const char *scanning_xpm[];
extern const char *invalid_xpm[];
extern const char *valid_xpm[];
extern const char *incomplete_xpm[];
+extern const char *paper_orientation_portrait_center_xpm[];
+extern const char *paper_orientation_portrait_top_left_xpm[];
+extern const char *paper_orientation_portrait_top_right_xpm[];
+extern const char *paper_orientation_portrait_bottom_left_xpm[];
+extern const char *paper_orientation_portrait_bottom_right_xpm[];
+extern const char *paper_orientation_landscape_center_xpm[];
+extern const char *paper_orientation_landscape_top_left_xpm[];
+extern const char *paper_orientation_landscape_top_right_xpm[];
+extern const char *paper_orientation_landscape_bottom_left_xpm[];
+extern const char *paper_orientation_landscape_bottom_right_xpm[];
extern const char cursor_pipette_white[];
extern const char cursor_pipette_gray[];
extern const char cursor_pipette_black[];
extern const char cursor_pipette_mask[];
-
+extern const char cursor_autoraise_scanarea[];
+extern const char cursor_autoraise_scanarea_mask[];
+extern const char cursor_zoom[];
+extern const char cursor_zoom_mask[];
#endif
diff --git a/src/xsane-preferences.c b/src/xsane-preferences.c
index 4ceec06..83da4e5 100644
--- a/src/xsane-preferences.c
+++ b/src/xsane-preferences.c
@@ -3,7 +3,7 @@
xsane-preferences.c
Oliver Rauch <Oliver.Rauch@rauch-domain.de>
- Copyright (C) 1998-2002 Oliver Rauch
+ Copyright (C) 1998-2005 Oliver Rauch
This file is part of the XSANE package.
This program is free software; you can redistribute it and/or modify
@@ -51,7 +51,9 @@ Preferences preferences =
{
0, /* xsane-version string */
0, /* default path to temporary directory (not defined here) */
+ 0, /* default working_directory */
0, /* no default filename */
+ 0, /* no default filetype */
0137, /* image umask (permission mask for -rw-r------) */
0027, /* directory umask (permission mask for -rwxr-x----) */
0, /* no fax project */
@@ -65,6 +67,8 @@ Preferences preferences =
296.98, /* fax_height: height of fax paper in mm */
0.0, /* fax_leftoffset */
0.0, /* fax_bottomoffset */
+ 1, /* fax_fine_mode */
+#ifdef XSANE_ACTIVATE_MAIL
0, /* no default from email address */
0, /* no default reply to email address */
0, /* no default smtp server */
@@ -76,9 +80,14 @@ Preferences preferences =
0, /* no default pop3 passsword */
0, /* no mail project */
0, /* no mail viewer */
+ 0, /* no mail filetype */
+#endif
0, /* no default ocrcommand */
0, /* no default ocr input file option */
0, /* no default ocr output file option */
+ 0, /* do not use progress pipe */
+ 0, /* no option for progress pipe filedeskriptor */
+ 0, /* no progress keyword */
0, /* no doc viewer */
80.0, /* jpeg_quality */
7.0, /* png_compression */
@@ -88,15 +97,18 @@ Preferences preferences =
1, /* save_devprefs_at_exit */
1, /* overwrite_warning */
1, /* skip_existing_numbers */
+ 0, /* save_pnm16_as_ascii */
0, /* reduce_16bit_to_8bit */
1, /* filename_counter_step */
4, /* filename_counter_len */
+ 6, /* show_range_mode */
1, /* tooltips enabled */
- 1, /* (dont) show histogram */
- 1, /* (dont) show gamma */
- 1, /* (dont) show standard options */
- 0, /* (dont) show advanced options */
- 0, /* (dont) show resolution list */
+ 1, /* show histogram */
+ 1, /* show gamma */
+ 0, /* don't show batch scan */
+ 1, /* show standard options */
+ 0, /* don`t show advanced options */
+ 0, /* don`t show resolution list */
10.0, /* length unit */
1, /* main window fixed (1) or scrolled (0) */
0, /* preview_own_cmap */
@@ -126,7 +138,7 @@ Preferences preferences =
1, /* preselect_scanarea after preview scan */
1, /* auto_correct_colors after preview scan */
GTK_UPDATE_DISCONTINUOUS, /* update policy for gtk frontend sliders */
- 0, /* psrotate: rotate in postscript mode (landscape) */
+ 0, /* paper_orientation */
0, /* preset_area_definitions */
0, /* printernr */
0 /* printerdefinitions */
@@ -144,7 +156,9 @@ desc[] =
{
{"xsane-version", xsane_rc_pref_string, POFFSET(xsane_version_str)},
{"tmp-path", xsane_rc_pref_string, POFFSET(tmp_path)},
+ {"working-directory", xsane_rc_pref_string, POFFSET(working_directory)},
{"filename", xsane_rc_pref_string, POFFSET(filename)},
+ {"filetype", xsane_rc_pref_string, POFFSET(filetype)},
{"image-umask", xsane_rc_pref_int, POFFSET(image_umask)},
{"directory-umask", xsane_rc_pref_int, POFFSET(directory_umask)},
{"fax-project", xsane_rc_pref_string, POFFSET(fax_project)},
@@ -158,6 +172,8 @@ desc[] =
{"fax-height", xsane_rc_pref_double, POFFSET(fax_height)},
{"fax-left-offset", xsane_rc_pref_double, POFFSET(fax_leftoffset)},
{"fax-bottom-offset", xsane_rc_pref_double, POFFSET(fax_bottomoffset)},
+ {"fax-fine-mode", xsane_rc_pref_int, POFFSET(fax_fine_mode)},
+#ifdef XSANE_ACTIVATE_MAIL
{"mail-from", xsane_rc_pref_string, POFFSET(mail_from)},
{"mail-reply-to", xsane_rc_pref_string, POFFSET(mail_reply_to)},
{"mail-smtp-server", xsane_rc_pref_string, POFFSET(mail_smtp_server)},
@@ -168,11 +184,16 @@ desc[] =
{"mail-pop3-user", xsane_rc_pref_string, POFFSET(mail_pop3_user)},
{"mail-pop3-pass", xsane_rc_pref_string, POFFSET(mail_pop3_pass)},
{"mail-project", xsane_rc_pref_string, POFFSET(mail_project)},
- {"mail-viewert", xsane_rc_pref_string, POFFSET(mail_viewer)},
+ {"mail-viewer", xsane_rc_pref_string, POFFSET(mail_viewer)},
+ {"mail-filetype", xsane_rc_pref_string, POFFSET(mail_filetype)},
+#endif
{"ocr-command", xsane_rc_pref_string, POFFSET(ocr_command)},
{"ocr-inputfile-option", xsane_rc_pref_string, POFFSET(ocr_inputfile_option)},
{"ocr-outputfile-options", xsane_rc_pref_string, POFFSET(ocr_outputfile_option)},
- {"doc-viewer", xsane_rc_pref_string, POFFSET(doc_viewer)},
+ {"ocr-use-gui-pipe", xsane_rc_pref_int, POFFSET(ocr_use_gui_pipe)},
+ {"ocr-gui-outfd-option", xsane_rc_pref_string, POFFSET(ocr_gui_outfd_option)},
+ {"ocr-progress-keyword", xsane_rc_pref_string, POFFSET(ocr_progress_keyword)},
+ {"browser", xsane_rc_pref_string, POFFSET(browser)},
{"jpeg-quality", xsane_rc_pref_double, POFFSET(jpeg_quality)},
{"png-compression", xsane_rc_pref_double, POFFSET(png_compression)},
{"tiff-compression16_nr", xsane_rc_pref_int, POFFSET(tiff_compression16_nr)},
@@ -181,12 +202,15 @@ desc[] =
{"save-devprefs-at-exit", xsane_rc_pref_int, POFFSET(save_devprefs_at_exit)},
{"overwrite-warning", xsane_rc_pref_int, POFFSET(overwrite_warning)},
{"skip-existing-numbers", xsane_rc_pref_int, POFFSET(skip_existing_numbers)},
+ {"save-pnm16-as-ascii", xsane_rc_pref_int, POFFSET( save_pnm16_as_ascii)},
{"reduce-16bit-to8bit", xsane_rc_pref_int, POFFSET(reduce_16bit_to_8bit)},
{"filename-counter-step", xsane_rc_pref_int, POFFSET(filename_counter_step)},
{"filename-counter-len", xsane_rc_pref_int, POFFSET(filename_counter_len)},
+ {"show-range-mode", xsane_rc_pref_int, POFFSET(show_range_mode)},
{"tool-tips", xsane_rc_pref_int, POFFSET(tooltips_enabled)},
{"show-histogram", xsane_rc_pref_int, POFFSET(show_histogram)},
{"show-gamma", xsane_rc_pref_int, POFFSET(show_gamma)},
+ {"show-batch-scan", xsane_rc_pref_int, POFFSET(show_batch_scan)},
{"show-standard-options", xsane_rc_pref_int, POFFSET(show_standard_options)},
{"show-advanced-options", xsane_rc_pref_int, POFFSET(show_advanced_options)},
{"show-resolution-list", xsane_rc_pref_int, POFFSET(show_resolution_list)},
@@ -219,9 +243,8 @@ desc[] =
{"preselect-scanarea", xsane_rc_pref_int, POFFSET(preselect_scanarea)},
{"auto-correct-colors", xsane_rc_pref_int, POFFSET(auto_correct_colors)},
{"gtk-update-policy", xsane_rc_pref_int, POFFSET(gtk_update_policy)},
- {"postscript-rotate", xsane_rc_pref_int, POFFSET(psrotate)},
+ {"paper-orientation", xsane_rc_pref_int, POFFSET(paper_orientation)},
{"preset-area-definitions", xsane_rc_pref_int, POFFSET(preset_area_definitions)},
- {"medium-definitions", xsane_rc_pref_int, POFFSET(medium_definitions)},
{"printernr", xsane_rc_pref_int, POFFSET(printernr)},
{"printerdefinitions", xsane_rc_pref_int, POFFSET(printerdefinitions)}
};
@@ -347,23 +370,6 @@ void preferences_save(int fd)
n++;
}
- /* save mediums */
-
- n=0;
-
- while (n < preferences.medium_definitions)
- {
- DBG(DBG_info2, "saving preferences medium definition %s\n", preferences.medium[n]->name);
- for (i = 0; i < NELEMS(desc_medium); ++i)
- {
- xsane_rc_io_w_string(&w, &desc_medium[i].name);
- (*desc_medium[i].codec) (&w, preferences.medium[n], desc_medium[i].offset);
- }
- n++;
- }
-
-
-
xsane_rc_io_w_set_dir(&w, WIRE_DECODE); /* flush it out */
xsane_rc_io_w_exit(&w);
}
@@ -390,28 +396,43 @@ void preferences_restore(int fd)
if (w.status)
{
xsane_rc_io_w_exit(&w);
+ preferences.printerdefinitions = 0;
+ preferences.preset_area_definitions = 0;
return;
}
xsane_rc_io_w_string(&w, &name);
- if (w.status || !name)
+ if (w.status == EINVAL) /* not a string */
+ {
+ w.status = 0;
+ xsane_rc_io_w_skip_newline(&w); /* skip this line */
+ }
+ else if (w.status || !name) /* other error */
{
xsane_rc_io_w_exit(&w);
return;
}
-
- for (i = 0; i < NELEMS (desc); ++i)
+ else /* identifier read */
{
- if (strcmp(name, desc[i].name) == 0)
+ for (i = 0; i < NELEMS(desc); ++i)
+ {
+ if (strcmp(name, desc[i].name) == 0)
+ {
+ DBG(DBG_info2, "reading preferences value for %s\n", desc[i].name);
+ (*desc[i].codec) (&w, &preferences, desc[i].offset);
+ break;
+ }
+ }
+
+ if (!strcmp(name, "printerdefinitions"))
{
- DBG(DBG_info2, "reading preferences value for %s\n", desc[i].name);
- (*desc[i].codec) (&w, &preferences, desc[i].offset);
break;
}
- }
- if (!strcmp(name, "printerdefinitions"))
- {
- break;
+ else if (i == NELEMS(desc))
+ {
+ DBG(DBG_info2, "preferences identifier %s unknown\n", name);
+ xsane_rc_io_w_skip_newline(&w); /* skip this line */
+ }
}
}
@@ -494,8 +515,94 @@ void preferences_restore(int fd)
}
}
+ xsane_rc_io_w_exit(&w);
+}
+
+/* --------------------------------------------------------------------- */
+/* --------------------------------------------------------------------- */
+
+void preferences_save_media(int fd)
+{
+ Wire w;
+ int i, n;
+ char *medium_defs="MEDIUM_DEFINITIONS";
+
+ DBG(DBG_proc, "preferences_save_media\n");
+
+ w.io.fd = fd;
+ w.io.read = read;
+ w.io.write = write;
+ xsane_rc_io_w_init(&w);
+ xsane_rc_io_w_set_dir(&w, WIRE_ENCODE);
+
+ xsane_rc_io_w_string(&w, &medium_defs);
+ xsane_rc_io_w_word(&w, &preferences.medium_definitions);
+
+ /* save media */
+
+ n=0;
+
+ DBG(DBG_info, "saving %d medium definitions\n", preferences.medium_definitions);
+
+ while (n < preferences.medium_definitions)
+ {
+ DBG(DBG_info2, "=> saving medium definition %s\n", preferences.medium[n]->name);
+ for (i = 0; i < NELEMS(desc_medium); ++i)
+ {
+ xsane_rc_io_w_string(&w, &desc_medium[i].name);
+ (*desc_medium[i].codec) (&w, preferences.medium[n], desc_medium[i].offset);
+ }
+ n++;
+ }
+
+ xsane_rc_io_w_set_dir(&w, WIRE_DECODE); /* flush it out */
+ xsane_rc_io_w_exit(&w);
+}
+
+/* --------------------------------------------------------------------- */
+
+void preferences_restore_media(int fd)
+{
+ SANE_String name;
+ Wire w;
+ int i, n;
+
+ DBG(DBG_proc, "preferences_restore_media\n");
+
+ w.io.fd = fd;
+ w.io.read = read;
+ w.io.write = write;
+ xsane_rc_io_w_init(&w);
+ xsane_rc_io_w_set_dir(&w, WIRE_DECODE);
+
+ preferences.medium_definitions = 0;
+
+ xsane_rc_io_w_space(&w, 3);
+ if (w.status)
+ {
+ xsane_rc_io_w_exit(&w);
+ return;
+ }
+
+ xsane_rc_io_w_string(&w, &name);
+ if (w.status || !name)
+ {
+ xsane_rc_io_w_exit(&w);
+ return;
+ }
+
+ if (strcmp(name, "MEDIUM_DEFINITIONS")) /* falsche Datei */
+ {
+ DBG(DBG_info, "no medium definitions in file\n");
+ xsane_rc_io_w_exit(&w);
+ return;
+ }
+
+ xsane_rc_io_w_word(&w, &preferences.medium_definitions);
+
if (preferences.medium_definitions)
{
+ DBG(DBG_info, "reading %d medium definition\n", preferences.medium_definitions);
preferences.medium = calloc(preferences.medium_definitions, sizeof(void *));
n=0;
@@ -527,10 +634,12 @@ void preferences_restore(int fd)
break;
}
}
- DBG(DBG_info2, "preferences medium definition %s read\n", preferences.medium[n]->name);
+ DBG(DBG_info2, "=> medium definition %s read\n", preferences.medium[n]->name);
n++;
}
}
xsane_rc_io_w_exit(&w);
}
+
+/* --------------------------------------------------------------------- */
diff --git a/src/xsane-preferences.h b/src/xsane-preferences.h
index a6686b5..e0b90c0 100644
--- a/src/xsane-preferences.h
+++ b/src/xsane-preferences.h
@@ -3,7 +3,7 @@
xsane-preferences.h
Oliver Rauch <Oliver.Rauch@rauch-domain.de>
- Copyright (C) 1998-2002 Oliver Rauch
+ Copyright (C) 1998-2005 Oliver Rauch
This file is part of the XSANE package.
This program is free software; you can redistribute it and/or modify
@@ -88,7 +88,9 @@ typedef struct
{
char *xsane_version_str; /* xsane-version string */
char *tmp_path; /* path to temporary directory */
+ char *working_directory; /* directory where xsane saves images etc */
char *filename; /* default filename */
+ char *filetype; /* default filetype */
int image_umask; /* image umask (permisson mask) */
int directory_umask; /* directory umask (permisson mask) */
@@ -103,7 +105,9 @@ typedef struct
double fax_height; /* height of fax paper in mm */
double fax_leftoffset; /* left offset of fax paper in mm */
double fax_bottomoffset; /* bottom offset of fax paper in mm */
+ int fax_fine_mode; /* use fine or normal mode */
+#ifdef XSANE_ACTIVATE_MAIL
char *mail_from; /* email address of sender */
char *mail_reply_to; /* email address for replied emails */
char *mail_smtp_server; /* ip address or domain name of smtp server */
@@ -115,12 +119,17 @@ typedef struct
char *mail_pop3_pass; /* password for pop3 server */
char *mail_project; /* mail project */
char *mail_viewer; /* mail viewer */
+ char *mail_filetype; /* mail filetype */
+#endif
char *ocr_command; /* ocrcommand */
char *ocr_inputfile_option; /* option for input file */
char *ocr_outputfile_option; /* option for output file */
+ int ocr_use_gui_pipe; /* use progress pipe */
+ char *ocr_gui_outfd_option; /* option for progress pipe filedeskriptor */
+ char *ocr_progress_keyword; /* keyword for progress value in gui pipe */
- char *doc_viewer; /* doc viewer for helpfiles */
+ char *browser; /* doc viewer for helpfiles */
double jpeg_quality; /* quality when saving image as jpeg */
double png_compression; /* compression when saving image as pnm */
@@ -130,13 +139,16 @@ typedef struct
int save_devprefs_at_exit; /* save device preferences at exit */
int overwrite_warning; /* warn if file exists */
int skip_existing_numbers; /* skip used filenames when automatically increase counter */
+ int save_pnm16_as_ascii; /* selection if pnm 16 bit is saved as ascii or binary file */
int reduce_16bit_to_8bit; /* reduce images with 16 bits/color to 8 bits/color */
int filename_counter_step; /* filename_counter += filename_counter_step; */
int filename_counter_len; /* minimum length of filename_counter */
+ int show_range_mode; /* how to show a range */
int tooltips_enabled; /* should tooltips be disabled? */
int show_histogram; /* show histogram ? */
int show_gamma; /* show gamma curve ? */
+ int show_batch_scan; /* show batch scan dialog ? */
int show_standard_options; /* show standard options ? */
int show_advanced_options; /* show advanced options ? */
int show_resolution_list; /* show resolution list instead of slider ? */
@@ -171,7 +183,7 @@ typedef struct
int auto_correct_colors; /* automatic color correction after preview scan */
int gtk_update_policy;
- int psrotate; /* rotate by 90 degree in postscript mode - landscape */
+ int paper_orientation; /* image position on printer and page orientation */
int printernr; /* number of printers */
int printerdefinitions;
Preferences_printer_t **printer;
@@ -187,4 +199,7 @@ extern Preferences preferences;
extern void preferences_save (int fd);
extern void preferences_restore (int fd);
+extern void preferences_save_media (int fd);
+extern void preferences_restore_media (int fd);
+
#endif /* preferences_h */
diff --git a/src/xsane-preview.c b/src/xsane-preview.c
index da81e3f..879bc99 100644
--- a/src/xsane-preview.c
+++ b/src/xsane-preview.c
@@ -3,7 +3,7 @@
xsane-preview.c
Oliver Rauch <Oliver.Rauch@rauch-domain.de>
- Copyright (C) 1998-2002 Oliver Rauch
+ Copyright (C) 1998-2005 Oliver Rauch
This file is part of the XSANE package.
This program is free software; you can redistribute it and/or modify
@@ -76,6 +76,7 @@
/* #include <sys/param.h> */
#include "xsane-back-gtk.h"
#include "xsane-front-gtk.h"
+#include "xsane-batch-scan.h"
#include "xsane-preview.h"
#include "xsane-preferences.h"
#include "xsane-gamma.h"
@@ -102,6 +103,11 @@
/* ---------------------------------------------------------------------------------------------------------------------- */
+#define XSANE_ZOOM_SIZE 80
+#define XSANE_ZOOM_FACTOR 4
+
+/* ---------------------------------------------------------------------------------------------------------------------- */
+
static u_char *preview_gamma_data_red = 0;
static u_char *preview_gamma_data_green = 0;
static u_char *preview_gamma_data_blue = 0;
@@ -117,6 +123,8 @@ static u_char *histogram_medium_gamma_data_blue = 0;
static int preview_gamma_input_bits;
+static char *ratio_string[] = { "free", " 2:1", "16:9", "15:10", " 4:3", " 1:1", " 3:4", " 9:16", "10:15", " 1:2"};
+static float ratio_value[] = { 0.0, 2.0, 16.0/9.0, 15.0/10.0, 4.0/3.0, 1.0, 0.75, 0.5625, 10.0/15.0, 0.5 };
/* ---------------------------------------------------------------------------------------------------------------------- */
/* forward declarations */
@@ -161,14 +169,18 @@ static void preview_cancel_button_clicked(GtkWidget *widget, gpointer data);
static void preview_area_correct(Preview *p);
static void preview_save_image(Preview *p);
static void preview_delete_images(Preview *p);
+static void preview_select_zoom_point(Preview *p, int preview_x, int preview_y);
static void preview_zoom_not(GtkWidget *window, gpointer data);
static void preview_zoom_out(GtkWidget *window, gpointer data);
static void preview_zoom_in(GtkWidget *window, gpointer data);
+static void preview_zoom_area(GtkWidget *window, gpointer data);
static void preview_zoom_undo(GtkWidget *window, gpointer data);
static void preview_get_color(Preview *p, int x, int y, int range, int *red, int *green, int *blue);
+static void preview_add_batch(GtkWidget *window, Preview *p);
static void preview_pipette_white(GtkWidget *window, gpointer data);
static void preview_pipette_gray(GtkWidget *window, gpointer data);
static void preview_pipette_black(GtkWidget *window, gpointer data);
+static void preview_init_autoraise_scanarea(GtkWidget *window, gpointer data);
void preview_select_full_preview_area(Preview *p);
static void preview_full_preview_area_callback(GtkWidget *widget, gpointer call_data);
static void preview_delete_images_callback(GtkWidget *widget, gpointer call_data);
@@ -178,8 +190,10 @@ static gint preview_preset_area_delete_callback(GtkWidget *widget, GtkWidget *pr
static gint preview_preset_area_move_up_callback(GtkWidget *widget, GtkWidget *preset_area_widget);
static gint preview_preset_area_move_down_callback(GtkWidget *widget, GtkWidget *preset_area_widget);
static gint preview_preset_area_context_menu_callback(GtkWidget *widget, GdkEvent *event);
-static void preview_preset_area_callback(GtkWidget *widget, gpointer call_data);
-static void preview_rotation_callback(GtkWidget *widget, gpointer call_data);
+static void preview_preset_area_callback(GtkWidget *widget, gpointer data);
+static void preview_rotation_callback(GtkWidget *widget, gpointer data);
+static void preview_establish_ratio(Preview *p);
+static void preview_ratio_callback(GtkWidget *widget, gpointer data);
static void preview_autoselect_scanarea_callback(GtkWidget *window, gpointer data);
void preview_do_gamma_correction(Preview *p);
@@ -192,7 +206,8 @@ void preview_gamma_correction(Preview *p, int gamma_input_bits,
void preview_area_resize(Preview *p);
gint preview_area_resize_handler(GtkWidget *widget, GdkEvent *event, gpointer data);
void preview_update_maximum_output_size(Preview *p);
-void preview_set_maximum_output_size(Preview *p, float width, float height);
+void preview_set_maximum_output_size(Preview *p, float width, float height, int paper_orientation);
+void preview_autoraise_scanarea(Preview *p, int preview_x, int preview_y, float *autoselect_coord);
void preview_autoselect_scanarea(Preview *p, float *autoselect_coord);
void preview_display_valid(Preview *p);
@@ -574,16 +589,17 @@ static void preview_bound_selection(Preview *p)
if (p->selection.active)
{
-#if 0
+#if 1
xsane_bound_float(&p->selection.coordinate[0], p->scanner_surface[0], p->scanner_surface[2]);
xsane_bound_float(&p->selection.coordinate[2], p->scanner_surface[0], p->scanner_surface[2]);
xsane_bound_float(&p->selection.coordinate[1], p->scanner_surface[1], p->scanner_surface[3]);
xsane_bound_float(&p->selection.coordinate[3], p->scanner_surface[1], p->scanner_surface[3]);
-#endif
+#else
xsane_bound_float(&p->selection.coordinate[0], p->surface[0], p->surface[2]);
xsane_bound_float(&p->selection.coordinate[2], p->surface[0], p->surface[2]);
xsane_bound_float(&p->selection.coordinate[1], p->surface[1], p->surface[3]);
xsane_bound_float(&p->selection.coordinate[3], p->surface[1], p->surface[3]);
+#endif
}
}
@@ -1304,7 +1320,14 @@ static void preview_restore_option(Preview *p, int option, void *saved_value, in
{
char buf[256];
opt = xsane_get_option_descriptor(dev, option);
- snprintf(buf, sizeof(buf), "%s %s: %s.", ERR_SET_OPTION, opt->name, XSANE_STRSTATUS(status));
+ if (opt && opt->name)
+ {
+ snprintf(buf, sizeof(buf), "%s %s: %s.", ERR_SET_OPTION, opt->name, XSANE_STRSTATUS(status));
+ }
+ else
+ {
+ snprintf(buf, sizeof(buf), "%s %d: %s.", ERR_SET_OPTION, option, XSANE_STRSTATUS(status));
+ }
xsane_back_gtk_error(buf, TRUE);
}
}
@@ -1413,8 +1436,8 @@ static int preview_increment_image_y(Preview *p)
if ( (!p->image_data_enh) || (!p->image_data_raw) )
{
- preview_scan_done(p, 0);
snprintf(buf, sizeof(buf), "%s %s.", ERR_FAILED_ALLOCATE_IMAGE, strerror(errno));
+ preview_scan_done(p, 0);
xsane_back_gtk_error(buf, TRUE);
return -1;
}
@@ -1435,8 +1458,6 @@ static void preview_read_image_data(gpointer data, gint source, GdkInputConditio
SANE_Handle dev;
SANE_Int len;
int i, j;
- int offset = 0;
- char last = 0;
DBG(DBG_proc, "preview_read_image_data\n");
@@ -1449,11 +1470,12 @@ static void preview_read_image_data(gpointer data, gint source, GdkInputConditio
}
else if (p->params.depth == 16)
{
- if (offset)
+ if (p->read_offset_16)
{
- buf16[0] = last; /* ATTENTION: that is wrong! */
- /* use sizeof(buf) here because sizeof(buf16) returns the size of a pointer */
- status = sane_read(dev, ((SANE_Byte *) buf16) + 1, sizeof(buf) - 1, &len);
+ buf[0] = p->last_offset_16_byte;
+ /* use buf and sizeof(buf) here because sizeof(buf16) returns the size of a pointer */
+ status = sane_read(dev, buf+1, sizeof(buf) - 1, &len);
+ len++;
}
else
{
@@ -1463,18 +1485,18 @@ static void preview_read_image_data(gpointer data, gint source, GdkInputConditio
if (len % 2) /* odd number of bytes */
{
len--;
- last = buf16[len];
- offset = 1;
+ p->last_offset_16_byte = buf16[len];
+ p->read_offset_16 = 1;
}
else /* even number of bytes */
{
- offset = 0;
+ p->read_offset_16 = 0;
}
}
else /* bad bitdepth */
{
- preview_scan_done(p, 0);
snprintf(buf, sizeof(buf), "%s %d.", ERR_PREVIEW_BAD_DEPTH, p->params.depth);
+ preview_scan_done(p, 0);
xsane_back_gtk_error(buf, TRUE);
return;
}
@@ -1526,7 +1548,19 @@ static void preview_read_image_data(gpointer data, gint source, GdkInputConditio
if (!len)
{
- break; /* out of data for now */
+ if (p->input_tag >= 0) /* we have a selecet fd */
+ {
+ break; /* leave preview_read_image_data, will be called by gdk when select_fd event occurs */
+ }
+ else
+ {
+ while (gtk_events_pending())
+ {
+ DBG(DBG_info, "preview_read_image_data: calling gtk_main_iteration\n");
+ gtk_main_iteration();
+ }
+ continue; /* we have to keep this loop running because it will never be called again */
+ }
}
switch (p->params.format)
@@ -1581,8 +1615,8 @@ static void preview_read_image_data(gpointer data, gint source, GdkInputConditio
break;
default:
- preview_scan_done(p, 0);
snprintf(buf, sizeof(buf), "%s %d.", ERR_PREVIEW_BAD_DEPTH, p->params.depth);
+ preview_scan_done(p, 0);
xsane_back_gtk_error(buf, TRUE);
return;
}
@@ -1678,8 +1712,8 @@ static void preview_read_image_data(gpointer data, gint source, GdkInputConditio
break;
default:
- preview_scan_done(p, 0);
snprintf(buf, sizeof(buf), "%s %d.", ERR_PREVIEW_BAD_DEPTH, p->params.depth);
+ preview_scan_done(p, 0);
xsane_back_gtk_error(buf, TRUE);
return;
}
@@ -1705,8 +1739,8 @@ static void preview_read_image_data(gpointer data, gint source, GdkInputConditio
u_char gl = (mask & 1) ? 0xff : 0x00;
mask >>= 1;
- p->image_data_raw[p->image_offset] = gl * 256;
- p->image_data_enh[p->image_offset++] = gl;
+ p->image_data_raw[p->image_offset] = gl * 256;
+ p->image_data_enh[p->image_offset] = gl;
p->image_offset += 3;
if (++p->image_x >= p->image_width && preview_increment_image_y(p) < 0)
@@ -1756,16 +1790,16 @@ static void preview_read_image_data(gpointer data, gint source, GdkInputConditio
break;
default:
- preview_scan_done(p, 0);
snprintf(buf, sizeof(buf), "%s %d.", ERR_PREVIEW_BAD_DEPTH, p->params.depth);
+ preview_scan_done(p, 0);
xsane_back_gtk_error(buf, TRUE);
return;
}
break;
default:
- preview_scan_done(p, 0);
snprintf(buf, sizeof(buf), "%s %d.", ERR_BAD_FRAME_FORMAT, p->params.format);
+ preview_scan_done(p, 0);
xsane_back_gtk_error(buf, TRUE);
return;
}
@@ -1839,7 +1873,7 @@ static void preview_scan_done(Preview *p, int save_image)
sane_get_parameters(xsane.dev, &xsane.param); /* update xsane.param */
- if ( (preferences.preselect_scanarea) && (!p->startimage))
+ if ((preferences.preselect_scanarea) && (!p->startimage) && (!xsane.medium_calibration))
{
preview_autoselect_scanarea(p, p->selection.coordinate); /* get autoselection coordinates */
preview_draw_selection(p);
@@ -1847,12 +1881,14 @@ static void preview_scan_done(Preview *p, int save_image)
xsane_update_histogram(TRUE /* update_raw */); /* update histogram (necessary because overwritten by preview_update_surface) */
}
- if (preferences.auto_correct_colors)
+ if ((preferences.auto_correct_colors) && (!xsane.medium_calibration))
{
xsane_calculate_raw_histogram();
xsane_set_auto_enhancement();
xsane_enhancement_by_histogram(preferences.auto_enhance_gamma);
}
+
+ xsane_batch_scan_update_icon_list();
}
/* ---------------------------------------------------------------------------------------------------------------------- */
@@ -1927,17 +1963,11 @@ static void preview_scan_start(Preview *p)
SANE_Status status;
char buf[256];
int fd, y;
- int gamma_gray_size = 256; /* set this values to image depth for more than 8bpp input support!!! */
- int gamma_red_size = 256;
- int gamma_green_size = 256;
- int gamma_blue_size = 256;
- int gamma_gray_max = 255; /* set this to to image depth for more than 8bpp output support */
- int gamma_red_max = 255;
- int gamma_green_max = 255;
- int gamma_blue_max = 255;
DBG(DBG_proc, "preview_scan_start\n");
+ p->read_offset_16 = 0;
+
xsane.medium_changed = FALSE;
preview_display_valid(p);
@@ -1966,95 +1996,6 @@ static void preview_scan_start(Preview *p)
p->input_tag = -1;
}
- if (xsane.well_known.gamma_vector >0)
- {
- const SANE_Option_Descriptor *opt;
-
- opt = xsane_get_option_descriptor(xsane.dev, xsane.well_known.gamma_vector);
- if (SANE_OPTION_IS_ACTIVE(opt->cap))
- {
- SANE_Int *gamma_data;
-
- opt = xsane_get_option_descriptor(xsane.dev, xsane.well_known.gamma_vector);
- gamma_gray_size = opt->size / sizeof(opt->type);
- gamma_gray_max = opt->constraint.range->max;
-
- gamma_data = malloc(gamma_gray_size * sizeof(SANE_Int));
-
- if ((xsane.xsane_colors > 1) || (xsane.no_preview_medium_gamma)) /* color scan or medium preview gamma disabled */
- {
- xsane_create_gamma_curve(gamma_data, 0, 1.0, 0.0, 0.0, 0.0, 100.0, 1.0, gamma_gray_size, gamma_gray_max);
- }
- else /* grayscale scan */
- {
- xsane_create_gamma_curve(gamma_data, xsane.medium_negative, 1.0, 0.0, 0.0,
- xsane.medium_shadow_gray, xsane.medium_highlight_gray, xsane.medium_gamma_gray,
- gamma_gray_size, gamma_gray_max);
- }
-
- xsane_back_gtk_update_vector(xsane.well_known.gamma_vector, gamma_data);
- free(gamma_data);
- }
- }
-
- if (xsane.well_known.gamma_vector_r >0)
- {
- const SANE_Option_Descriptor *opt;
-
- opt = xsane_get_option_descriptor(xsane.dev, xsane.well_known.gamma_vector_r);
- if (SANE_OPTION_IS_ACTIVE(opt->cap))
- {
- SANE_Int *gamma_data_red, *gamma_data_green, *gamma_data_blue;
-
- opt = xsane_get_option_descriptor(xsane.dev, xsane.well_known.gamma_vector_r);
- gamma_red_size = opt->size / sizeof(opt->type);
- gamma_red_max = opt->constraint.range->max;
-
- opt = xsane_get_option_descriptor(xsane.dev, xsane.well_known.gamma_vector_g);
- gamma_green_size = opt->size / sizeof(opt->type);
- gamma_green_max = opt->constraint.range->max;
-
- opt = xsane_get_option_descriptor(xsane.dev, xsane.well_known.gamma_vector_b);
- gamma_blue_size = opt->size / sizeof(opt->type);
- gamma_blue_max = opt->constraint.range->max;
-
- gamma_data_red = malloc(gamma_red_size * sizeof(SANE_Int));
- gamma_data_green = malloc(gamma_green_size * sizeof(SANE_Int));
- gamma_data_blue = malloc(gamma_blue_size * sizeof(SANE_Int));
-
- if (xsane.no_preview_medium_gamma) /* do not use medium gamma for preview */
- {
- DBG(DBG_info, "preview: not using medium gamma table\n");
-
- xsane_create_gamma_curve(gamma_data_red, 0, 1.0, 0.0, 0.0, 0.0, 100.0, 1.0, gamma_red_size, gamma_red_max);
- xsane_create_gamma_curve(gamma_data_green, 0, 1.0, 0.0, 0.0, 0.0, 100.0, 1.0, gamma_green_size, gamma_green_max);
- xsane_create_gamma_curve(gamma_data_blue, 0, 1.0, 0.0, 0.0, 0.0, 100.0, 1.0, gamma_blue_size, gamma_blue_max);
- }
- else /* use medium gamma for preview */
- {
- DBG(DBG_info, "preview: using medium gamma table\n");
-
- xsane_create_gamma_curve(gamma_data_red, xsane.medium_negative, 1.0, 0.0, 0.0,
- xsane.medium_shadow_red, xsane.medium_highlight_red, xsane.medium_gamma_red,
- gamma_red_size, gamma_red_max);
- xsane_create_gamma_curve(gamma_data_green, xsane.medium_negative, 1.0, 0.0, 0.0,
- xsane.medium_shadow_green, xsane.medium_highlight_green, xsane.medium_gamma_green,
- gamma_green_size, gamma_green_max);
- xsane_create_gamma_curve(gamma_data_blue, xsane.medium_negative, 1.0, 0.0, 0.0,
- xsane.medium_shadow_blue, xsane.medium_highlight_blue, xsane.medium_gamma_blue,
- gamma_blue_size, gamma_blue_max);
- }
-
- xsane_back_gtk_update_vector(xsane.well_known.gamma_vector_r, gamma_data_red);
- xsane_back_gtk_update_vector(xsane.well_known.gamma_vector_g, gamma_data_green);
- xsane_back_gtk_update_vector(xsane.well_known.gamma_vector_b, gamma_data_blue);
-
- free(gamma_data_red);
- free(gamma_data_green);
- free(gamma_data_blue);
- }
- }
-
status = sane_start(dev);
if (status != SANE_STATUS_GOOD)
{
@@ -2110,15 +2051,11 @@ static void preview_scan_start(Preview *p)
p->previous_selection_maximum.active = FALSE;
#ifndef BUGGY_GDK_INPUT_EXCEPTION
- /* for unix */
if ((sane_set_io_mode(dev, SANE_TRUE) == SANE_STATUS_GOOD) && (sane_get_select_fd(dev, &fd) == SANE_STATUS_GOOD))
{
p->input_tag = gdk_input_add(fd, GDK_INPUT_READ | GDK_INPUT_EXCEPTION, preview_read_image_data, p);
}
else
-#else
- /* for win32 */
- sane_set_io_mode(dev, SANE_FALSE);
#endif
{
preview_read_image_data(p, -1, GDK_INPUT_READ);
@@ -2133,12 +2070,370 @@ static int preview_make_image_path(Preview *p, size_t filename_size, char *filen
DBG(DBG_proc, "preview_make_image_path\n");
- snprintf(buf, sizeof(buf), "preview-level-%d-", level);
+ snprintf(buf, sizeof(buf), "xsane-preview-level-%d-", level);
return xsane_back_gtk_make_path(filename_size, filename, 0, 0, buf, xsane.dev_name, ".ppm", XSANE_PATH_TMP);
}
/* ---------------------------------------------------------------------------------------------------------------------- */
+int preview_create_batch_icon_from_file(Preview *p, FILE *in, Batch_Scan_Parameters *parameters, int min_quality, int *min_time)
+{
+ u_int psurface_type, psurface_unit;
+ int image_width, image_height;
+ int xoffset, yoffset, width, height;
+ int max_val;
+ int x, y, dx, dy;
+ int time;
+ float psurface[4];
+ float dsurface[4];
+ char buf[255];
+ float scale;
+ int header = 0;
+ int rotate16 = 16 - preview_gamma_input_bits;
+ int rotate8 = preview_gamma_input_bits - 8;
+ guint16 r,g,b;
+ int c;
+ int maximum_size;
+ int quality = 0;
+ int xx, yy;
+ int offset = 0;
+ guchar *data;
+
+ DBG(DBG_proc, "preview_create_batch_icon_from_file\n");
+
+ if (!in)
+ {
+ return min_quality;
+ }
+
+ /* See whether there is a saved preview and load it if present: */
+ if (fscanf(in, "P6\n"
+ "# surface: %g %g %g %g %u %u\n"
+ "# time: %d\n"
+ "%d %d\n%d",
+ psurface + 0, psurface + 1, psurface + 2, psurface + 3,
+ &psurface_type, &psurface_unit,
+ &time,
+ &image_width, &image_height,
+ &max_val) != 10)
+ {
+ DBG(DBG_info, "no preview image\n");
+ return min_quality;
+ }
+
+ fgets(buf, sizeof(buf), in); /* skip newline character. this made a lot of problems in the past, so I skip it this way */
+
+ header = ftell(in);
+
+ if (min_quality >= 0) /* read real preview */
+ {
+ if ((psurface_type != p->surface_type) || (psurface_unit != p->surface_unit))
+ {
+ DBG(DBG_info, "incompatible surface types %d <> %d\n", psurface_type, p->surface_type);
+ return min_quality;
+ }
+
+ preview_rotate_previewsurface_to_devicesurface(p->rotation, p->surface, dsurface);
+
+
+ DBG(DBG_info, "stored image surface = [%3.2f %3.2f %3.2f %3.2f]\n",
+ psurface[0], psurface[1], psurface[2], psurface[3]);
+ DBG(DBG_info, "batch selection = [%3.2f %3.2f %3.2f %3.2f]\n",
+ parameters->tl_x, parameters->tl_y, parameters->br_x, parameters->br_y);
+ DBG(DBG_info, "preview device surface = [%3.2f %3.2f %3.2f %3.2f]\n",
+ dsurface[0], dsurface[1], dsurface[2], dsurface[3]);
+
+ xoffset = (parameters->tl_x - psurface[0])/(psurface[2] - psurface[0]) * image_width;
+ yoffset = (parameters->tl_y - psurface[1])/(psurface[3] - psurface[1]) * image_height;
+ width = (parameters->br_x - parameters->tl_x)/(psurface[2] - psurface[0]) * image_width;
+ height = (parameters->br_y - parameters->tl_y)/(psurface[3] - psurface[1]) * image_height;
+
+ quality = width;
+
+ if ((xoffset < 0) || (yoffset < 0) ||
+ (xoffset+width > image_width) || (yoffset+height > image_height) ||
+ (width == 0) || (height == 0))
+ {
+ DBG(DBG_info, "image does not cover wanted surface part\n");
+ return min_quality;
+ }
+
+ DBG(DBG_info, "quality = %d\n", quality);
+
+ if ( ((float) min_quality / (quality+1)) > 1.05) /* already loaded image has better quality */
+ {
+ DBG(DBG_info, "already loaded image has higher quality\n");
+ return min_quality;
+ }
+
+ if ( ((float) min_quality / (quality+1)) > 0.95) /* qualities are comparable */
+ {
+ if (*min_time > time) /* take more recent scan */
+ {
+ DBG(DBG_info, "images have comparable quality, already loaded is more up to date\n");
+ return min_quality;
+ }
+ DBG(DBG_info, "images have comparable quality, this image is more up to date\n");
+ }
+ else
+ {
+ DBG(DBG_info, "image has best quality\n");
+ }
+ }
+ else
+ {
+ xoffset = 0;
+ yoffset = 0;
+ width = image_width;
+ height = image_height;
+ }
+
+
+ {
+ float xscale = (float)width / parameters->gtk_preview_size;
+ float yscale = (float)height / parameters->gtk_preview_size;
+
+ if (xscale > yscale)
+ {
+ scale = xscale;
+ }
+ else
+ {
+ scale = yscale;
+ }
+ }
+
+ width = width / scale;
+ height = height / scale;
+
+ if (width > parameters->gtk_preview_size)
+ {
+ width = parameters->gtk_preview_size;
+ }
+
+ if (height > parameters->gtk_preview_size)
+ {
+ height = parameters->gtk_preview_size;
+ }
+
+ maximum_size = parameters->gtk_preview_size -1;
+
+ dx = (parameters->gtk_preview_size - width) / 2;
+ dy = (parameters->gtk_preview_size - height) / 2;
+
+
+ data = malloc(parameters->gtk_preview_size * parameters->gtk_preview_size * 3);
+ if (!data)
+ {
+ DBG(DBG_error, "preview_create_batch_icon_from_file: out of memory\n");
+ return min_quality;
+ }
+
+ /* make unused parts white */
+ for (x = 0; x< parameters->gtk_preview_size * parameters->gtk_preview_size * 3; x++)
+ {
+ data[x] = 0xF0;
+ }
+
+ if (max_val == 65535)
+ {
+ for (y=0; y < height; y++)
+ {
+ for (x=0; x < width; x++)
+ {
+ fseek(in, header + (xoffset + (int)(x * scale) + (yoffset + (int)(y * scale)) * image_width) * 6, SEEK_SET);
+
+ fread(&r, 2, 1, in); /* read 16 bit value in machines byte order */
+ r = preview_gamma_data_red[r >> rotate16];
+
+ fread(&g, 2, 1, in);
+ g = preview_gamma_data_green[g >> rotate16];
+
+ fread(&b, 2, 1, in);
+ b = preview_gamma_data_blue[b >> rotate16];
+
+ c = r * 65536 + g * 256 + b;
+
+ switch (parameters->rotation)
+ {
+ case 0: /* 0 degree */
+ xx = x + dx;
+ yy = y + dy;
+ offset = parameters->gtk_preview_size * 3 * yy + 3*(xx);
+ break;
+
+ case 1: /* 90 degree */
+ xx = maximum_size - y;
+ yy = x + dx;
+ offset = parameters->gtk_preview_size * 3 * yy + 3*(xx);
+ break;
+
+ case 2: /* 180 degree */
+ xx = maximum_size - x - dx;
+ yy = maximum_size - y - dy;
+ offset = parameters->gtk_preview_size * 3 * yy + 3*(xx);
+ break;
+
+ case 3: /* 270 degree */
+ xx = y + dy;
+ yy = maximum_size - x - dx;
+ offset = parameters->gtk_preview_size * 3 * yy + 3*(xx);
+ break;
+
+ case 4: /* 0 degree, x-mirror */
+ xx = maximum_size - x - dx;
+ yy = y + dy;
+ offset = parameters->gtk_preview_size * 3 * yy + 3*(xx);
+ break;
+
+ case 5: /* 90 degree, x-mirror */
+ xx = y + dy;
+ yy = x + dx;
+ offset = parameters->gtk_preview_size * 3 * yy + 3*(xx);
+ break;
+
+ case 6: /* 180 degree, x-mirror */
+ xx = x + dx;
+ yy = maximum_size - y - dy;
+ offset = parameters->gtk_preview_size * 3 * yy + 3*(xx);
+ break;
+
+ case 7: /* 270 degree, x-mirror */
+ xx = maximum_size - y - dy;
+ yy = maximum_size - x - dx;
+ offset = parameters->gtk_preview_size * 3 * yy + 3*(xx);
+ break;
+ }
+
+ data[offset + 0] = r;
+ data[offset + 1] = g;
+ data[offset + 2] = b;
+ }
+ }
+
+ for (y = 0; y < parameters->gtk_preview_size; y++)
+ {
+ gtk_preview_draw_row(GTK_PREVIEW(parameters->gtk_preview), data + 3 * parameters->gtk_preview_size * y,
+ 0, y, parameters->gtk_preview_size);
+ }
+ }
+ else /* depth = 8 */
+ {
+ for (y=0; y < height; y++)
+ {
+ for (x=0; x < width; x++)
+ {
+ fseek(in, header + (xoffset + (int)(x * scale) + (yoffset + (int)(y * scale)) * image_width) * 3, SEEK_SET);
+
+ r = fgetc(in);
+ r = preview_gamma_data_red[r << rotate8];
+
+ g = fgetc(in);
+ g = preview_gamma_data_green[g << rotate8];
+
+ b = fgetc(in);
+ b = preview_gamma_data_blue[b << rotate8];
+ switch (parameters->rotation)
+ {
+ case 0: /* 0 degree */
+ xx = x + dx;
+ yy = y + dy;
+ offset = parameters->gtk_preview_size * 3 * yy + 3*(xx);
+ break;
+
+ case 1: /* 90 degree */
+ xx = maximum_size - y;
+ yy = x + dx;
+ offset = parameters->gtk_preview_size * 3 * yy + 3*(xx);
+ break;
+
+ case 2: /* 180 degree */
+ xx = maximum_size - x - dx;
+ yy = maximum_size - y - dy;
+ offset = parameters->gtk_preview_size * 3 * yy + 3*(xx);
+ break;
+
+ case 3: /* 270 degree */
+ xx = y + dy;
+ yy = maximum_size - x - dx;
+ offset = parameters->gtk_preview_size * 3 * yy + 3*(xx);
+ break;
+
+ case 4: /* 0 degree, x-mirror */
+ xx = maximum_size - x - dx;
+ yy = y + dy;
+ offset = parameters->gtk_preview_size * 3 * yy + 3*(xx);
+ break;
+
+ case 5: /* 90 degree, x-mirror */
+ xx = y + dy;
+ yy = x + dx;
+ offset = parameters->gtk_preview_size * 3 * yy + 3*(xx);
+ break;
+
+ case 6: /* 180 degree, x-mirror */
+ xx = x + dx;
+ yy = maximum_size - y - dy;
+ offset = parameters->gtk_preview_size * 3 * yy + 3*(xx);
+ break;
+
+ case 7: /* 270 degree, x-mirror */
+ xx = maximum_size - y - dy;
+ yy = maximum_size - x - dx;
+ offset = parameters->gtk_preview_size * 3 * yy + 3*(xx);
+ break;
+ }
+
+ data[offset + 0] = r;
+ data[offset + 1] = g;
+ data[offset + 2] = b;
+ }
+ }
+
+ for (y = 0; y < parameters->gtk_preview_size; y++)
+ {
+ gtk_preview_draw_row(GTK_PREVIEW(parameters->gtk_preview), data + 3 * parameters->gtk_preview_size * y,
+ 0, y, parameters->gtk_preview_size);
+ }
+ }
+
+ free(data);
+
+ return quality;
+}
+
+/* ---------------------------------------------------------------------------------------------------------------------- */
+
+void preview_create_batch_icon(Preview *p, Batch_Scan_Parameters *parameters)
+{
+ FILE *in;
+ int quality = 0;
+ int time = 0;
+
+ in = fopen(xsane.preview->filename[0], "rb");
+ quality = preview_create_batch_icon_from_file(xsane.preview, in, parameters, quality, &time);
+
+ if (quality <= 0)
+ {
+ char filename[PATH_MAX];
+
+ if (in)
+ {
+ fclose(in);
+ }
+
+ xsane_back_gtk_make_path(sizeof(filename), filename, "xsane", 0, "xsane-startimage", 0, ".pnm", XSANE_PATH_SYSTEM);
+ in = fopen(filename, "rb"); /* read binary (b for win32) */
+ if (in)
+ {
+ preview_create_batch_icon_from_file(xsane.preview, in, parameters, -1, &time);
+ }
+ }
+ fclose(in);
+}
+
+/* ---------------------------------------------------------------------------------------------------------------------- */
+
static int preview_restore_image_from_file(Preview *p, FILE *in, int min_quality, int *min_time)
{
u_int psurface_type, psurface_unit;
@@ -2202,6 +2497,7 @@ static int preview_restore_image_from_file(Preview *p, FILE *in, int min_quality
yoffset = (dsurface[1] - psurface[1])/(psurface[3] - psurface[1]) * image_height;
width = (dsurface[2] - dsurface[0])/(psurface[2] - psurface[0]) * image_width;
height = (dsurface[3] - dsurface[1])/(psurface[3] - psurface[1]) * image_height;
+
quality = width;
if ((xoffset < 0) || (yoffset < 0) ||
@@ -2397,6 +2693,284 @@ static void preview_restore_image(Preview *p)
/* ---------------------------------------------------------------------------------------------------------------------- */
+static int preview_get_pixel_color(Preview *p, int x, int y, int *raw_red, int *raw_green, int *raw_blue,
+ int *enh_red, int *enh_green, int *enh_blue)
+{
+ int image_x, image_y;
+ int offset;
+ int rotate = 16 - preview_gamma_input_bits;
+
+ DBG(DBG_proc, "preview_get_pixel_color\n");
+
+ if (p->image_data_raw)
+ {
+ preview_transform_coordinate_window_to_image(p, x, y, &image_x, &image_y);
+
+ if ( (image_x >= 0) && (image_x < p->image_width) && (image_y >=0) && (image_y < p->image_height) )
+ {
+ offset = 3 * (image_y * p->image_width + image_x);
+
+ if (!xsane.negative) /* positive */
+ {
+ *raw_red = (p->image_data_raw[offset ]) >> 8;
+ *raw_green = (p->image_data_raw[offset + 1]) >> 8;
+ *raw_blue = (p->image_data_raw[offset + 2]) >> 8;
+ }
+ else /* negative */
+ {
+ *raw_red = 255 - ((p->image_data_raw[offset ]) >> 8);
+ *raw_green = 255 - ((p->image_data_raw[offset + 1]) >> 8);
+ *raw_blue = 255 - ((p->image_data_raw[offset + 2]) >> 8);
+ }
+
+ /* the enhanced pixels are already inverted when negative is selected */
+ /* do not use image_data_enh because the preview gamma value is applied to this */
+ *enh_red = histogram_gamma_data_red [(p->image_data_raw[offset ]) >> rotate];
+ *enh_green = histogram_gamma_data_green[(p->image_data_raw[offset + 1]) >> rotate];
+ *enh_blue = histogram_gamma_data_blue [(p->image_data_raw[offset + 2]) >> rotate];
+
+ return 0;
+ }
+ }
+
+ return -1;
+}
+
+/* ---------------------------------------------------------------------------------------------------------------------- */
+
+static void xsane_swap_int(int *a, int *b)
+{
+ int i;
+ i = *a;
+ *a = *b;
+ *b = i;
+}
+
+static void preview_display_zoom(Preview *p, int x, int y, int zoom)
+{
+ int pointer_x, pointer_y;
+ int image_x, image_y;
+ int image_x_lof, image_x_rof;
+ int image_y_tof, image_y_bof;
+ int image_x_min, image_y_min;
+ int image_x_max, image_y_max;
+ int image_x_direction, image_y_direction;
+ int offset;
+ int r, g, b;
+ int px, py;
+ int i;
+ char *row;
+
+ DBG(DBG_proc, "preview_display_zoom");
+
+ if (!p->image_data_raw)
+ {
+ return;
+ }
+
+ row = calloc(XSANE_ZOOM_SIZE, 3);
+
+ if (row)
+ {
+ preview_transform_coordinate_window_to_image(p, x, y, &image_x, &image_y);
+ preview_transform_coordinate_window_to_image(p, x, y, &pointer_x, &pointer_y);
+
+ image_x_min = image_x - XSANE_ZOOM_SIZE/(zoom*2);
+ image_y_min = image_y - XSANE_ZOOM_SIZE/(zoom*2);
+
+ image_x_max = image_x_min + XSANE_ZOOM_SIZE/zoom + 1;
+ image_y_max = image_y_min + XSANE_ZOOM_SIZE/zoom + 1;
+
+ xsane_bound_int(&image_x_min, 0, p->image_width - 1);
+ xsane_bound_int(&image_x_max, 0, p->image_width - 1);
+ xsane_bound_int(&image_y_min, 0, p->image_height - 1);
+ xsane_bound_int(&image_y_max, 0, p->image_height - 1);
+
+ if ((image_x_max - image_x_min) && (image_y_max - image_y_min))
+ {
+ image_x_lof = image_x_min - (image_x - XSANE_ZOOM_SIZE/(zoom*2));
+ image_x_rof = image_x - XSANE_ZOOM_SIZE/(zoom*2) + XSANE_ZOOM_SIZE/zoom + 1 - image_x_max;
+ image_y_tof = image_y_min - (image_y - XSANE_ZOOM_SIZE/(zoom*2));
+ image_y_bof = image_y - XSANE_ZOOM_SIZE/(zoom*2) + XSANE_ZOOM_SIZE/zoom + 1 - image_y_max;
+
+ image_x_direction = 1;
+ image_y_direction = 1;
+
+ switch (p->rotation & 3)
+ {
+ case 0: /* do not rotate - 0 degree */
+ default:
+ break;
+
+ case 1: /* 90 degree */
+ xsane_swap_int(&image_y_min, &image_y_max);
+ xsane_swap_int(&image_y_tof, &image_y_bof);
+ image_y_direction *= -1;
+ break;
+
+ case 2: /* 180 degree */
+ xsane_swap_int(&image_x_min, &image_x_max);
+ xsane_swap_int(&image_x_lof, &image_x_rof);
+ xsane_swap_int(&image_y_min, &image_y_max);
+ xsane_swap_int(&image_y_tof, &image_y_bof);
+ image_x_direction *= -1;
+ image_y_direction *= -1;
+ break;
+
+ case 3: /* 270 degree */
+ xsane_swap_int(&image_x_min, &image_x_max);
+ xsane_swap_int(&image_x_lof, &image_x_rof);
+ image_x_direction *= -1;
+ break;
+ }
+
+
+ if ((p->rotation & 1) == 0)
+ {
+ if (p->rotation & 4) /* mirror */
+ {
+ xsane_swap_int(&image_x_min, &image_x_max);
+ xsane_swap_int(&image_x_lof, &image_x_rof);
+ image_x_direction *= -1;
+ }
+
+ py = image_y_tof * zoom;
+
+ for (i=0; i < py; i++)
+ {
+ gtk_preview_draw_row(GTK_PREVIEW(p->zoom), row, 0, i, XSANE_ZOOM_SIZE);
+ }
+
+ for (image_y = image_y_min; image_y != image_y_max + image_y_direction; image_y += image_y_direction)
+ {
+ px = image_x_lof * zoom;
+
+ for (image_x = image_x_min; image_x != image_x_max + image_x_direction; image_x += image_x_direction)
+ {
+ offset = 3 * (image_y * p->image_width + image_x);
+
+ r = (p->image_data_enh[offset ]);
+ g = (p->image_data_enh[offset+1]);
+ b = (p->image_data_enh[offset+2]);
+
+ if ( (image_x == pointer_x) && (image_y == pointer_y) )
+ {
+ r = g = b = (128 + (r+g+b) / 3) & 255; /* mark the cursor position */
+ }
+
+ for (i=0; (i<zoom) && (px < XSANE_ZOOM_SIZE); i++)
+ {
+ row[px*3+0] = r;
+ row[px*3+1] = g;
+ row[px*3+2] = b;
+ px++;
+ }
+ }
+
+ for (i=0; (i<zoom) && (py < XSANE_ZOOM_SIZE); i++)
+ {
+ gtk_preview_draw_row(GTK_PREVIEW(p->zoom), row, 0, py++, XSANE_ZOOM_SIZE);
+ }
+ }
+ }
+ else /* swap x and y */
+ {
+ if (p->rotation & 4) /* mirror */
+ {
+ xsane_swap_int(&image_y_min, &image_y_max);
+ xsane_swap_int(&image_y_tof, &image_y_bof);
+ image_y_direction *= -1;
+ }
+
+ py = image_x_lof * zoom;
+
+ for (i=0; i < py; i++)
+ {
+ gtk_preview_draw_row(GTK_PREVIEW(p->zoom), row, 0, i, XSANE_ZOOM_SIZE);
+ }
+
+ for (image_x = image_x_min; image_x != image_x_max + image_x_direction; image_x += image_x_direction)
+ {
+ px = image_y_tof * zoom;
+
+ for (image_y = image_y_min; image_y != image_y_max + image_y_direction; image_y += image_y_direction)
+ {
+ offset = 3 * (image_y * p->image_width + image_x);
+
+ r = (p->image_data_enh[offset ]);
+ g = (p->image_data_enh[offset+1]);
+ b = (p->image_data_enh[offset+2]);
+
+ if ( (image_x == pointer_x) && (image_y == pointer_y) )
+ {
+ r = g = b = (128 + (r+g+b) / 3) & 255; /* mark the cursor position */
+ }
+
+ for (i=0; (i<zoom) && (px < XSANE_ZOOM_SIZE); i++)
+ {
+ row[px*3+0] = r;
+ row[px*3+1] = g;
+ row[px*3+2] = b;
+ px++;
+ }
+ }
+
+ for (i=0; (i<zoom) && (py < XSANE_ZOOM_SIZE); i++)
+ {
+ gtk_preview_draw_row(GTK_PREVIEW(p->zoom), row, 0, py++, XSANE_ZOOM_SIZE);
+ }
+ }
+ }
+
+ for (i=0; i < XSANE_ZOOM_SIZE; i++)
+ {
+ row[i*3+0] = 0;
+ row[i*3+1] = 0;
+ row[i*3+2] = 0;
+ }
+
+ for (i=py; i < XSANE_ZOOM_SIZE; i++)
+ {
+ gtk_preview_draw_row(GTK_PREVIEW(p->zoom), row, 0, i, XSANE_ZOOM_SIZE);
+ }
+ }
+ else
+ {
+ for (i = 0; i < XSANE_ZOOM_SIZE; i++)
+ {
+ gtk_preview_draw_row(GTK_PREVIEW(p->zoom), row, 0, i, XSANE_ZOOM_SIZE);
+ }
+ }
+ gtk_widget_queue_draw(p->zoom);
+
+ free(row);
+ }
+}
+
+/* ---------------------------------------------------------------------------------------------------------------------- */
+
+static void preview_display_color_components(Preview *p, int x, int y)
+{
+ char buffer[256];
+ int raw_red, raw_green, raw_blue, enh_red, enh_green, enh_blue;
+
+ if (! preview_get_pixel_color(p, x, y, &raw_red, &raw_green, &raw_blue, &enh_red, &enh_green, &enh_blue))
+ {
+ snprintf(buffer, sizeof(buffer), " %03d, %03d, %03d \n" \
+ " %03d, %03d, %03d ",
+ raw_red, raw_green, raw_blue, enh_red, enh_green, enh_blue);
+ }
+ else
+ {
+ snprintf(buffer, sizeof(buffer), " ###, ###, ### \n" \
+ " ###, ###, ### ");
+ }
+
+ gtk_label_set_text(GTK_LABEL(p->rgb_label), buffer);
+}
+
+/* ---------------------------------------------------------------------------------------------------------------------- */
+
static gint preview_hold_event_handler(gpointer data)
{
Preview *p = data;
@@ -2437,6 +3011,9 @@ static gint preview_motion_event_handler(GtkWidget *window, GdkEvent *event, gpo
if (!p->scanning)
{
+ preview_display_zoom(p, event->motion.x, event->motion.y, XSANE_ZOOM_FACTOR);
+ preview_display_color_components(p, event->motion.x, event->motion.y);
+
switch (((GdkEventMotion *)event)->state &
GDK_Num_Lock & GDK_Caps_Lock & GDK_Shift_Lock & GDK_Scroll_Lock) /* mask all Locks */
{
@@ -2447,8 +3024,159 @@ static gint preview_motion_event_handler(GtkWidget *window, GdkEvent *event, gpo
if ( (p->selection_drag) || (p->selection_drag_edge) )
{
p->selection.active = TRUE;
- p->selection.coordinate[p->selection_xedge] = preview_x;
- p->selection.coordinate[p->selection_yedge] = preview_y;
+
+ if (preview_x < p->scanner_surface[p->index_xmin])
+ {
+ preview_x = p->scanner_surface[p->index_xmin];
+ }
+ else if (preview_x > p->scanner_surface[p->index_xmax])
+ {
+ preview_x = p->scanner_surface[p->index_xmax];
+ }
+
+ if (preview_y < p->scanner_surface[p->index_ymin])
+ {
+ preview_y = p->scanner_surface[p->index_ymin];
+ }
+ else if (preview_y > p->scanner_surface[p->index_ymax])
+ {
+ preview_y = p->scanner_surface[p->index_ymax];
+ }
+
+
+ if (p->selection_xedge != -1)
+ {
+ p->selection.coordinate[p->selection_xedge] = preview_x;
+ }
+
+ if (p->selection_yedge != -1)
+ {
+ p->selection.coordinate[p->selection_yedge] = preview_y;
+ }
+
+ if (p->ratio) /* forced preview ratio ? */
+ {
+ if ( (p->selection_xedge == p->index_xmin) && (p->selection_yedge == p->index_ymin) ) /* top left corner */
+ {
+ float width;
+ width = fabs(p->selection.coordinate[p->index_xmax] - p->selection.coordinate[p->index_xmin]);
+
+ p->selection.coordinate[p->index_ymax] = p->selection.coordinate[p->index_ymin] + width / p->ratio;
+
+ if (p->selection.coordinate[p->index_ymax] > p->scanner_surface[p->index_ymax])
+ {
+ float height;
+ p->selection.coordinate[p->index_ymax] = p->scanner_surface[p->index_ymax];
+ height = fabs(p->selection.coordinate[p->index_ymax] - p->selection.coordinate[p->index_ymin]);
+ p->selection.coordinate[p->index_xmin] = p->selection.coordinate[p->index_xmax] - height * p->ratio;
+ }
+ }
+ else if ( (p->selection_xedge == p->index_xmax) && (p->selection_yedge == p->index_ymin) )/* top right corner */
+ {
+ float width;
+ width = fabs(p->selection.coordinate[p->index_xmax] - p->selection.coordinate[p->index_xmin]);
+
+ p->selection.coordinate[p->index_ymax] = p->selection.coordinate[p->index_ymin] + width / p->ratio;
+
+ if (p->selection.coordinate[p->index_ymax] > p->scanner_surface[p->index_ymax])
+ {
+ float height;
+ p->selection.coordinate[p->index_ymax] = p->scanner_surface[p->index_ymax];
+ height = fabs(p->selection.coordinate[p->index_ymax] - p->selection.coordinate[p->index_ymin]);
+ p->selection.coordinate[p->index_xmax] = p->selection.coordinate[p->index_xmin] + height * p->ratio;
+ }
+ }
+ else if ( (p->selection_xedge == p->index_xmin) && (p->selection_yedge == p->index_ymax) ) /* bottom left edge */
+ {
+ float width;
+ width = fabs(p->selection.coordinate[p->index_xmax] - p->selection.coordinate[p->index_xmin]);
+
+ p->selection.coordinate[p->index_ymin] = p->selection.coordinate[p->index_ymax] - width / p->ratio;
+
+ if (p->selection.coordinate[p->index_ymin] < p->scanner_surface[p->index_ymin])
+ {
+ float height;
+ p->selection.coordinate[p->index_ymin] = p->scanner_surface[p->index_ymin];
+ height = fabs(p->selection.coordinate[p->index_ymax] - p->selection.coordinate[p->index_ymin]);
+ p->selection.coordinate[p->index_xmin] = p->selection.coordinate[p->index_xmax] - height * p->ratio;
+ }
+ }
+ else if ( (p->selection_xedge == p->index_xmax) && (p->selection_yedge == p->index_ymax) ) /* bottom right edge */
+ {
+ float width;
+ width = fabs(p->selection.coordinate[p->index_xmax] - p->selection.coordinate[p->index_xmin]);
+
+ p->selection.coordinate[p->index_ymin] = p->selection.coordinate[p->index_ymax] - width / p->ratio;
+
+ if (p->selection.coordinate[p->index_ymin] < p->scanner_surface[p->index_ymin])
+ {
+ float height;
+ p->selection.coordinate[p->index_ymin] = p->scanner_surface[p->index_ymin];
+ height = fabs(p->selection.coordinate[p->index_ymax] - p->selection.coordinate[p->index_ymin]);
+ p->selection.coordinate[p->index_xmax] = p->selection.coordinate[p->index_xmin] + height * p->ratio;
+ }
+ }
+ else if (p->selection_xedge == p->index_xmin) /* left edge */
+ {
+ float width;
+ width = fabs(p->selection.coordinate[p->index_xmax] - p->selection.coordinate[p->index_xmin]);
+
+ p->selection.coordinate[p->index_ymax] = p->selection.coordinate[p->index_ymin] + width / p->ratio;
+
+ if (p->selection.coordinate[p->index_ymax] > p->scanner_surface[p->index_ymax])
+ {
+ float height;
+ p->selection.coordinate[p->index_ymax] = p->scanner_surface[p->index_ymax];
+ height = fabs(p->selection.coordinate[p->index_ymax] - p->selection.coordinate[p->index_ymin]);
+ p->selection.coordinate[p->index_xmin] = p->selection.coordinate[p->index_xmax] - height * p->ratio;
+ }
+ }
+ else if (p->selection_xedge == p->index_xmax) /* right edge */
+ {
+ float width;
+ width = fabs(p->selection.coordinate[p->index_xmax] - p->selection.coordinate[p->index_xmin]);
+
+ p->selection.coordinate[p->index_ymax] = p->selection.coordinate[p->index_ymin] + width / p->ratio;
+
+ if (p->selection.coordinate[p->index_ymax] > p->scanner_surface[p->index_ymax])
+ {
+ float height;
+ p->selection.coordinate[p->index_ymax] = p->scanner_surface[p->index_ymax];
+ height = fabs(p->selection.coordinate[p->index_ymax] - p->selection.coordinate[p->index_ymin]);
+ p->selection.coordinate[p->index_xmax] = p->selection.coordinate[p->index_xmin] + height * p->ratio;
+ }
+ }
+ else if (p->selection_yedge == p->index_ymin) /* top edge */
+ {
+ float height;
+ height = fabs(p->selection.coordinate[p->index_ymax] - p->selection.coordinate[p->index_ymin]);
+
+ p->selection.coordinate[p->index_xmax] = p->selection.coordinate[p->index_xmin] + height * p->ratio;
+
+ if (p->selection.coordinate[p->index_xmax] > p->scanner_surface[p->index_xmax])
+ {
+ float width;
+ p->selection.coordinate[p->index_xmax] = p->scanner_surface[p->index_xmax];
+ width = fabs(p->selection.coordinate[p->index_xmax] - p->selection.coordinate[p->index_xmin]);
+ p->selection.coordinate[p->index_ymin] = p->selection.coordinate[p->index_ymax] - width / p->ratio;
+ }
+ }
+ else if (p->selection_yedge == p->index_ymax) /* bottom edge */
+ {
+ float height;
+ height = fabs(p->selection.coordinate[p->index_ymax] - p->selection.coordinate[p->index_ymin]);
+
+ p->selection.coordinate[p->index_xmax] = p->selection.coordinate[p->index_xmin] + height * p->ratio;
+
+ if (p->selection.coordinate[p->index_xmax] > p->scanner_surface[p->index_xmax])
+ {
+ float width;
+ p->selection.coordinate[p->index_xmax] = p->scanner_surface[p->index_xmax];
+ width = fabs(p->selection.coordinate[p->index_xmax] - p->selection.coordinate[p->index_xmin]);
+ p->selection.coordinate[p->index_ymax] = p->selection.coordinate[p->index_ymin] + width / p->ratio;
+ }
+ }
+ }
preview_order_selection(p);
preview_bound_selection(p);
@@ -2551,7 +3279,7 @@ static gint preview_motion_event_handler(GtkWidget *window, GdkEvent *event, gpo
{
cursor = gdk_cursor_new(cursornr); /* set curosr */
gdk_window_set_cursor(p->window->window, cursor);
- gdk_cursor_destroy(cursor);
+ gdk_cursor_unref(cursor);
p->cursornr = cursornr;
}
break;
@@ -2727,7 +3455,7 @@ static gint preview_motion_event_handler(GtkWidget *window, GdkEvent *event, gpo
{
cursor = gdk_cursor_new(cursornr); /* set curosr */
gdk_window_set_cursor(p->window->window, cursor);
- gdk_cursor_destroy(cursor);
+ gdk_cursor_unref(cursor);
p->cursornr = cursornr;
}
break;
@@ -2842,7 +3570,7 @@ static gint preview_button_press_event_handler(GtkWidget *window, GdkEvent *even
cursor = gdk_cursor_new(XSANE_CURSOR_PREVIEW);
gdk_window_set_cursor(p->window->window, cursor);
- gdk_cursor_destroy(cursor);
+ gdk_cursor_unref(cursor);
p->cursornr = XSANE_CURSOR_PREVIEW;
}
break;
@@ -2947,7 +3675,7 @@ static gint preview_button_press_event_handler(GtkWidget *window, GdkEvent *even
cursor = gdk_cursor_new(XSANE_CURSOR_PREVIEW);
gdk_window_set_cursor(p->window->window, cursor);
- gdk_cursor_destroy(cursor);
+ gdk_cursor_unref(cursor);
p->cursornr = XSANE_CURSOR_PREVIEW;
}
break;
@@ -3037,11 +3765,51 @@ static gint preview_button_press_event_handler(GtkWidget *window, GdkEvent *even
cursor = gdk_cursor_new(XSANE_CURSOR_PREVIEW);
gdk_window_set_cursor(p->window->window, cursor);
- gdk_cursor_destroy(cursor);
+ gdk_cursor_unref(cursor);
+ p->cursornr = XSANE_CURSOR_PREVIEW;
+ }
+ break;
+
+ case MODE_AUTORAISE_SCANAREA:
+ {
+ DBG(DBG_info, "autoraise scanarea mode\n");
+
+ if ( ( (((GdkEventButton *)event)->button == 1) || (((GdkEventButton *)event)->button == 2) ) &&
+ (p->image_data_raw) ) /* left or middle button */
+ {
+ preview_autoraise_scanarea(p, event->button.x, event->button.y, p->selection.coordinate); /* raise selection area */
+ }
+
+ p->mode = MODE_NORMAL;
+
+ cursor = gdk_cursor_new(XSANE_CURSOR_PREVIEW);
+ gdk_window_set_cursor(p->window->window, cursor);
+ gdk_cursor_unref(cursor);
p->cursornr = XSANE_CURSOR_PREVIEW;
}
break;
+ case MODE_ZOOM_IN:
+ {
+ DBG(DBG_info, "zoom in mode\n");
+
+ if ( ( (((GdkEventButton *)event)->button == 1) || (((GdkEventButton *)event)->button == 2) ) &&
+ (p->image_data_raw) ) /* left or middle button */
+ {
+ preview_select_zoom_point(p, event->button.x, event->button.y); /* select zoom point */
+ }
+ else
+ {
+ p->mode = MODE_NORMAL;
+
+ cursor = gdk_cursor_new(XSANE_CURSOR_PREVIEW);
+ gdk_window_set_cursor(p->window->window, cursor);
+ gdk_cursor_unref(cursor);
+ p->cursornr = XSANE_CURSOR_PREVIEW;
+ }
+ }
+ break;
+
case MODE_NORMAL:
{
DBG(DBG_info, "normal mode\n");
@@ -3117,7 +3885,7 @@ static gint preview_button_press_event_handler(GtkWidget *window, GdkEvent *even
cursornr = GDK_CROSS;
cursor = gdk_cursor_new(cursornr); /* set curosr */
gdk_window_set_cursor(p->window->window, cursor);
- gdk_cursor_destroy(cursor);
+ gdk_cursor_unref(cursor);
p->cursornr = cursornr;
}
break;
@@ -3139,7 +3907,7 @@ static gint preview_button_press_event_handler(GtkWidget *window, GdkEvent *even
cursornr = GDK_HAND2;
cursor = gdk_cursor_new(cursornr); /* set curosr */
gdk_window_set_cursor(p->window->window, cursor);
- gdk_cursor_destroy(cursor);
+ gdk_cursor_unref(cursor);
p->cursornr = cursornr;
}
break;
@@ -3184,7 +3952,7 @@ static gint preview_button_release_event_handler(GtkWidget *window, GdkEvent *ev
cursornr = XSANE_CURSOR_PREVIEW;
cursor = gdk_cursor_new(cursornr); /* set curosr */
gdk_window_set_cursor(p->window->window, cursor);
- gdk_cursor_destroy(cursor);
+ gdk_cursor_unref(cursor);
p->cursornr = cursornr;
}
@@ -3220,7 +3988,7 @@ static gint preview_expose_event_handler_start(GtkWidget *window, GdkEvent *even
if (!p->gc_selection)
{
DBG(DBG_info, "defining line styles for selection and page frames\n");
- colormap = gdk_window_get_colormap(p->window->window);
+ colormap = gdk_drawable_get_colormap(p->window->window);
p->gc_selection = gdk_gc_new(p->window->window);
gdk_gc_set_function(p->gc_selection, GDK_INVERT);
@@ -3265,7 +4033,7 @@ static gint preview_expose_event_handler_end(GtkWidget *window, GdkEvent *event,
if (!p->gc_selection)
{
DBG(DBG_info, "defining line styles for selection and page frames\n");
- colormap = gdk_window_get_colormap(p->window->window);
+ colormap = gdk_drawable_get_colormap(p->window->window);
p->gc_selection = gdk_gc_new(p->window->window);
gdk_gc_set_function(p->gc_selection, GDK_INVERT);
@@ -3283,8 +4051,8 @@ static gint preview_expose_event_handler_end(GtkWidget *window, GdkEvent *event,
}
else
{
- p->selection.active = expose_event_selection_active;
- p->selection_maximum.active = expose_event_selection_maximum_active;
+ p->selection.active = expose_event_selection_active;
+ p->selection_maximum.active = expose_event_selection_maximum_active;
preview_draw_selection(p); /* draw selections again */
}
}
@@ -3335,8 +4103,8 @@ static void preview_create_preset_area_menu(Preview *p, int selection)
{
preset_area_item = gtk_menu_item_new_with_label(preferences.preset_area[i]->name);
gtk_container_add(GTK_CONTAINER(preset_area_menu), preset_area_item);
- gtk_signal_connect(GTK_OBJECT(preset_area_item), "button_press_event", (GtkSignalFunc) preview_preset_area_context_menu_callback, p);
- gtk_signal_connect(GTK_OBJECT(preset_area_item), "activate", (GtkSignalFunc) preview_preset_area_callback, p);
+ g_signal_connect(GTK_OBJECT(preset_area_item), "button_press_event", (GtkSignalFunc) preview_preset_area_context_menu_callback, p);
+ g_signal_connect(GTK_OBJECT(preset_area_item), "activate", (GtkSignalFunc) preview_preset_area_callback, p);
gtk_object_set_data(GTK_OBJECT(preset_area_item), "Selection", (void *) i);
gtk_object_set_data(GTK_OBJECT(preset_area_item), "Preview", (void *) p);
@@ -3410,16 +4178,20 @@ Preview *preview_new(void)
GtkWidget *table, *frame;
GtkSignalFunc signal_func;
GtkWidgetClass *class;
- GtkWidget *vbox, *hbox;
+ GtkWidget *vbox, *action_box;
+ GtkWidget *outer_hbox, *middle_vbox;
GdkCursor *cursor;
GtkWidget *preset_area_option_menu;
GtkWidget *rotation_option_menu, *rotation_menu, *rotation_item;
+ GtkWidget *ratio_option_menu, *ratio_menu, *ratio_item;
GtkWidget *delete_images;
GdkBitmap *mask;
GdkPixmap *pixmap = NULL;
+ GtkWidget *pixmapwidget;
Preview *p;
int i;
char buf[256];
+ int ratio_nr = 0;
DBG(DBG_proc, "preview_new\n");
@@ -3468,12 +4240,14 @@ Preview *preview_new(void)
p->maximum_output_width = INF; /* full output with */
p->maximum_output_height = INF; /* full output height */
+ p->block_update_maximum_output_size_clipping = FALSE;
p->preview_colors = -1;
p->invalid = TRUE; /* no valid preview */
+ p->ratio = 0.0;
#ifndef XSERVER_WITH_BUGGY_VISUALS
- gtk_widget_push_visual(gtk_preview_get_visual());
+ gtk_widget_push_visual(gtk_preview_get_visual()); /* this has no function for gtk+-2.0 */
#endif
gtk_widget_push_colormap(gtk_preview_get_cmap());
@@ -3481,7 +4255,8 @@ Preview *preview_new(void)
p->top = gtk_window_new(GTK_WINDOW_TOPLEVEL);
gtk_window_set_title(GTK_WINDOW(p->top), buf);
xsane_set_window_icon(p->top, 0);
- gtk_accel_group_attach(xsane.accelerator_group, GTK_OBJECT(p->top));
+ gtk_window_add_accel_group(GTK_WINDOW(p->top), xsane.accelerator_group);
+
/* set the main vbox */
vbox = gtk_vbox_new(FALSE, 0);
@@ -3489,39 +4264,51 @@ Preview *preview_new(void)
gtk_container_add(GTK_CONTAINER(p->top), vbox);
gtk_widget_show(vbox);
- /* set the main hbox */
- hbox = gtk_hbox_new(FALSE, 0);
- gtk_box_pack_end(GTK_BOX(vbox), hbox, FALSE, FALSE, 5);
- gtk_container_set_border_width(GTK_CONTAINER(hbox), 5);
- gtk_widget_show(hbox);
- /* top hbox for icons */
+ /* the button_box (hbox) */
p->button_box = gtk_hbox_new(FALSE, 1);
- gtk_container_set_border_width(GTK_CONTAINER(p->button_box), 1);
+ gtk_container_set_border_width(GTK_CONTAINER(p->button_box), 0);
gtk_box_pack_start(GTK_BOX(vbox), p->button_box, FALSE, FALSE, 0);
+
+ /* add new selection for batch scanning */
+ p->add_batch = xsane_button_new_with_pixmap(p->top->window, p->button_box, add_batch_xpm, DESC_ADD_BATCH, (GtkSignalFunc) preview_add_batch, p);
+
+ xsane_vseparator_new(p->button_box, 3);
+
/* White, gray and black pipette button */
p->pipette_white = xsane_button_new_with_pixmap(p->top->window, p->button_box, pipette_white_xpm, DESC_PIPETTE_WHITE, (GtkSignalFunc) preview_pipette_white, p);
p->pipette_gray = xsane_button_new_with_pixmap(p->top->window, p->button_box, pipette_gray_xpm, DESC_PIPETTE_GRAY, (GtkSignalFunc) preview_pipette_gray, p);
p->pipette_black = xsane_button_new_with_pixmap(p->top->window, p->button_box, pipette_black_xpm, DESC_PIPETTE_BLACK, (GtkSignalFunc) preview_pipette_black, p);
+ xsane_vseparator_new(p->button_box, 3);
+
/* Zoom not, zoom out and zoom in button */
- p->zoom_not = xsane_button_new_with_pixmap(p->top->window, p->button_box, zoom_not_xpm, DESC_ZOOM_FULL, (GtkSignalFunc) preview_zoom_not, p);
- p->zoom_out = xsane_button_new_with_pixmap(p->top->window, p->button_box, zoom_out_xpm, DESC_ZOOM_OUT, (GtkSignalFunc) preview_zoom_out, p);
- p->zoom_in = xsane_button_new_with_pixmap(p->top->window, p->button_box, zoom_in_xpm, DESC_ZOOM_IN, (GtkSignalFunc) preview_zoom_in, p);
- p->zoom_undo = xsane_button_new_with_pixmap(p->top->window, p->button_box, zoom_undo_xpm, DESC_ZOOM_UNDO, (GtkSignalFunc) preview_zoom_undo, p);
- p->full_area = xsane_button_new_with_pixmap(p->top->window, p->button_box, auto_select_preview_area_xpm, DESC_AUTOSELECT_SCANAREA, (GtkSignalFunc) preview_autoselect_scanarea_callback, p);
- p->autoselect = xsane_button_new_with_pixmap(p->top->window, p->button_box, full_preview_area_xpm, DESC_FULL_PREVIEW_AREA, (GtkSignalFunc) preview_full_preview_area_callback, p);
- delete_images = xsane_button_new_with_pixmap(p->top->window, p->button_box, delete_images_xpm, DESC_DELETE_IMAGES, (GtkSignalFunc) preview_delete_images_callback, p);
-
- gtk_widget_add_accelerator(p->zoom_not, "clicked", xsane.accelerator_group, GDK_KP_Multiply, GDK_MOD1_MASK, GTK_ACCEL_LOCKED); /* Alt keypad_* */
- gtk_widget_add_accelerator(p->zoom_out, "clicked", xsane.accelerator_group, GDK_KP_Subtract, GDK_MOD1_MASK, GTK_ACCEL_LOCKED); /* Alt keypad_- */
- gtk_widget_add_accelerator(p->zoom_in, "clicked", xsane.accelerator_group, GDK_KP_Add, GDK_MOD1_MASK, GTK_ACCEL_LOCKED); /* Alt keypad_+ */
- gtk_widget_add_accelerator(p->zoom_undo, "clicked", xsane.accelerator_group, GDK_KP_Divide, GDK_MOD1_MASK, GTK_ACCEL_LOCKED); /* Alt keypad_/ */
- gtk_widget_add_accelerator(p->full_area, "clicked", xsane.accelerator_group, GDK_A, GDK_MOD1_MASK, GTK_ACCEL_LOCKED); /* Alt keypad_* */
- gtk_widget_add_accelerator(p->autoselect, "clicked", xsane.accelerator_group, GDK_V, GDK_MOD1_MASK, GTK_ACCEL_LOCKED); /* Alt keypad_* */
- gtk_widget_add_accelerator(delete_images, "clicked", xsane.accelerator_group, GDK_KP_Delete, GDK_MOD1_MASK, GTK_ACCEL_LOCKED); /* Alt keypad_* */
+ p->zoom_not = xsane_button_new_with_pixmap(p->top->window, p->button_box, zoom_not_xpm, DESC_ZOOM_FULL, (GtkSignalFunc) preview_zoom_not, p);
+ p->zoom_out = xsane_button_new_with_pixmap(p->top->window, p->button_box, zoom_out_xpm, DESC_ZOOM_OUT, (GtkSignalFunc) preview_zoom_out, p);
+ p->zoom_in = xsane_button_new_with_pixmap(p->top->window, p->button_box, zoom_in_xpm, DESC_ZOOM_IN, (GtkSignalFunc) preview_zoom_in, p);
+ p->zoom_area = xsane_button_new_with_pixmap(p->top->window, p->button_box, zoom_area_xpm, DESC_ZOOM_AREA, (GtkSignalFunc) preview_zoom_area, p);
+ p->zoom_undo = xsane_button_new_with_pixmap(p->top->window, p->button_box, zoom_undo_xpm, DESC_ZOOM_UNDO, (GtkSignalFunc) preview_zoom_undo, p);
+
+ xsane_vseparator_new(p->button_box, 3);
+
+ p->full_area = xsane_button_new_with_pixmap(p->top->window, p->button_box, auto_select_preview_area_xpm, DESC_AUTOSELECT_SCANAREA, (GtkSignalFunc) preview_autoselect_scanarea_callback, p);
+ p->autoraise = xsane_button_new_with_pixmap(p->top->window, p->button_box, auto_raise_preview_area_xpm, DESC_AUTORAISE_SCANAREA, (GtkSignalFunc) preview_init_autoraise_scanarea, p);
+ p->autoselect = xsane_button_new_with_pixmap(p->top->window, p->button_box, full_preview_area_xpm, DESC_FULL_PREVIEW_AREA, (GtkSignalFunc) preview_full_preview_area_callback, p);
+
+ xsane_vseparator_new(p->button_box, 3);
+
+ delete_images = xsane_button_new_with_pixmap(p->top->window, p->button_box, delete_images_xpm, DESC_DELETE_IMAGES, (GtkSignalFunc) preview_delete_images_callback, p);
+
+ gtk_widget_add_accelerator(p->zoom_not, "clicked", xsane.accelerator_group, GDK_KP_Multiply, GDK_MOD1_MASK, DEF_GTK_ACCEL_LOCKED); /* Alt keypad_* */
+ gtk_widget_add_accelerator(p->zoom_out, "clicked", xsane.accelerator_group, GDK_KP_Subtract, GDK_MOD1_MASK, DEF_GTK_ACCEL_LOCKED); /* Alt keypad_- */
+ gtk_widget_add_accelerator(p->zoom_in, "clicked", xsane.accelerator_group, GDK_KP_Add, GDK_MOD1_MASK, DEF_GTK_ACCEL_LOCKED); /* Alt keypad_+ */
+ gtk_widget_add_accelerator(p->zoom_area, "clicked", xsane.accelerator_group, GDK_KP_Enter, GDK_MOD1_MASK, DEF_GTK_ACCEL_LOCKED); /* Alt keypad_Enter */
+ gtk_widget_add_accelerator(p->zoom_undo, "clicked", xsane.accelerator_group, GDK_KP_Divide, GDK_MOD1_MASK, DEF_GTK_ACCEL_LOCKED); /* Alt keypad_/ */
+ gtk_widget_add_accelerator(p->full_area, "clicked", xsane.accelerator_group, GDK_A, GDK_MOD1_MASK, DEF_GTK_ACCEL_LOCKED); /* Alt keypad_* */
+ gtk_widget_add_accelerator(p->autoselect, "clicked", xsane.accelerator_group, GDK_V, GDK_MOD1_MASK, DEF_GTK_ACCEL_LOCKED); /* Alt keypad_* */
+ gtk_widget_add_accelerator(delete_images, "clicked", xsane.accelerator_group, GDK_KP_Delete, GDK_MOD1_MASK, DEF_GTK_ACCEL_LOCKED); /* Alt keypad_* */
gtk_widget_set_sensitive(p->zoom_not, FALSE); /* no zoom at this point, so no zoom not */
gtk_widget_set_sensitive(p->zoom_out, FALSE); /* no zoom at this point, so no zoom out */
@@ -3530,42 +4317,157 @@ Preview *preview_new(void)
gtk_widget_set_sensitive(p->autoselect, FALSE); /* no selection */
+ gtk_widget_show(p->button_box);
+ /* the button box is ready */
+
+
+
+ /* construct the preview area (table with sliders & preview window) */
+
+ table = gtk_table_new(2, 2, /* homogeneous */ FALSE);
+ gtk_table_set_col_spacing(GTK_TABLE(table), 0, 1);
+ gtk_table_set_row_spacing(GTK_TABLE(table), 0, 1);
+ gtk_container_set_border_width(GTK_CONTAINER(table), 1);
+ gtk_box_pack_start(GTK_BOX(vbox), table, /* expand */ TRUE, /* fill */ TRUE, /* padding */ 0);
+ gtk_widget_show(table);
+
+ /* the empty box in the top-left corner */
+ frame = gtk_frame_new(/* label */ 0);
+ gtk_frame_set_shadow_type(GTK_FRAME(frame), GTK_SHADOW_OUT);
+ gtk_table_attach(GTK_TABLE(table), frame, 0, 1, 0, 1, GTK_FILL, GTK_FILL, 0, 0);
+ gtk_widget_show(frame);
+
+ /* the unit label */
+ p->unit_label = gtk_label_new("cm");
+ gtk_container_add(GTK_CONTAINER(frame), p->unit_label);
+ gtk_widget_show(p->unit_label);
+
+ /* the horizontal ruler */
+ p->hruler = gtk_hruler_new();
+ gtk_table_attach(GTK_TABLE(table), p->hruler, 1, 2, 0, 1, GTK_FILL, 0, 0, 0);
+ gtk_widget_show(p->hruler);
+
+ /* the vertical ruler */
+ p->vruler = gtk_vruler_new();
+ gtk_table_attach(GTK_TABLE(table), p->vruler, 0, 1, 1, 2, 0, GTK_FILL, 0, 0);
+ gtk_widget_show(p->vruler);
+
+ /* the preview area */
+ p->window = gtk_preview_new(GTK_PREVIEW_COLOR);
+ gtk_preview_set_expand(GTK_PREVIEW(p->window), TRUE);
+
+ gtk_widget_set_events(p->window, GDK_EXPOSURE_MASK | GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK |
+ GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK);
+
+ /* the first expose_event is responsible to undraw the selection frame */
+ g_signal_connect(GTK_OBJECT(p->window), "expose_event", (GtkSignalFunc) preview_expose_event_handler_start, p);
+ g_signal_connect(GTK_OBJECT(p->window), "button_press_event", (GtkSignalFunc) preview_button_press_event_handler, p);
+ g_signal_connect(GTK_OBJECT(p->window), "motion_notify_event", (GtkSignalFunc) preview_motion_event_handler, p);
+ g_signal_connect(GTK_OBJECT(p->window), "button_release_event", (GtkSignalFunc) preview_button_release_event_handler, p);
+
+ g_signal_connect_after(GTK_OBJECT(p->window), "size_allocate", (GtkSignalFunc) preview_area_resize_handler, p);
+ /* the second expose_event is responsible to redraw the selection frame */
+ g_signal_connect_after(GTK_OBJECT(p->window), "expose_event", (GtkSignalFunc) preview_expose_event_handler_end, p);
+
+ /* Connect the motion-notify events of the preview area with the rulers. Nifty stuff! */
+
+#ifdef HAVE_GTK2
+ class = (GtkWidgetClass *) GTK_HSCROLLBAR_GET_CLASS(p->hruler);
+#else
+ class = GTK_WIDGET_CLASS(GTK_OBJECT(p->hruler)->klass);
+#endif
+
+ signal_func = (GtkSignalFunc) class->motion_notify_event;
+ g_signal_connect_swapped(GTK_OBJECT(p->window), "motion_notify_event", signal_func, GTK_OBJECT(p->hruler));
+
+#ifdef HAVE_GTK2
+ class = (GtkWidgetClass *) GTK_VSCROLLBAR_GET_CLASS(p->vruler);
+#else
+ class = GTK_WIDGET_CLASS(GTK_OBJECT(p->vruler)->klass);
+#endif
+
+ signal_func = (GtkSignalFunc) class->motion_notify_event;
+ g_signal_connect_swapped(GTK_OBJECT(p->window), "motion_notify_event", signal_func, GTK_OBJECT(p->vruler));
+
+
+ p->viewport = gtk_frame_new(/* label */ 0);
+ gtk_frame_set_shadow_type(GTK_FRAME(p->viewport), GTK_SHADOW_IN);
+ gtk_container_add(GTK_CONTAINER(p->viewport), p->window);
+ gtk_widget_show(p->viewport);
+
+ gtk_table_attach(GTK_TABLE(table), p->viewport, 1, 2, 1, 2,
+ GTK_FILL | GTK_EXPAND | GTK_SHRINK, GTK_FILL | GTK_EXPAND | GTK_SHRINK, 0, 0);
+ /* the preview area is ready */
+
+
+
+ /* the outer hbox at the bottom */
+ outer_hbox = gtk_hbox_new(FALSE, 4);
+ gtk_container_set_border_width(GTK_CONTAINER(outer_hbox), 1);
+ gtk_box_pack_start(GTK_BOX(vbox), outer_hbox, FALSE, FALSE, 0);
+ gtk_widget_show(outer_hbox);
+
+ /* the middle vbox at the bottom */
+ middle_vbox = gtk_vbox_new(FALSE, 4);
+ gtk_container_set_border_width(GTK_CONTAINER(middle_vbox), 1);
+ gtk_box_pack_start(GTK_BOX(outer_hbox), middle_vbox, FALSE, FALSE, 0);
+ gtk_widget_show(middle_vbox);
+
+ /* the menu_box (hbox) */
+ p->menu_box = gtk_hbox_new(FALSE, 4);
+ gtk_container_set_border_width(GTK_CONTAINER(p->menu_box), 1);
+ gtk_box_pack_start(GTK_BOX(middle_vbox), p->menu_box, FALSE, FALSE, 0);
+
+ xsane_separator_new(middle_vbox, 1);
+
+
/* select maximum scanarea */
+ pixmap = gdk_pixmap_create_from_xpm_d(p->top->window, &mask, xsane.bg_trans, (gchar **) size_xpm);
+ pixmapwidget = gtk_image_new_from_pixmap(pixmap, mask);
+ gtk_box_pack_start(GTK_BOX(p->menu_box), pixmapwidget, FALSE, FALSE, 2);
+ gtk_widget_show(pixmapwidget);
+ gdk_drawable_unref(pixmap);
preset_area_option_menu = gtk_option_menu_new();
xsane_back_gtk_set_tooltip(xsane.tooltips, preset_area_option_menu, DESC_PRESET_AREA);
- gtk_box_pack_start(GTK_BOX(p->button_box), preset_area_option_menu, FALSE, FALSE, 0);
+ gtk_box_pack_start(GTK_BOX(p->menu_box), preset_area_option_menu, FALSE, FALSE, 0);
gtk_widget_show(preset_area_option_menu);
p->preset_area_option_menu = preset_area_option_menu;
preview_create_preset_area_menu(p, 0); /* build menu and set default to 0=full size */
+ xsane_vseparator_new(p->menu_box, 3);
/* select rotation */
+ pixmap = gdk_pixmap_create_from_xpm_d(p->top->window, &mask, xsane.bg_trans, (gchar **) rotation_xpm);
+ pixmapwidget = gtk_image_new_from_pixmap(pixmap, mask);
+ gtk_box_pack_start(GTK_BOX(p->menu_box), pixmapwidget, FALSE, FALSE, 2);
+ gtk_widget_show(pixmapwidget);
+ gdk_drawable_unref(pixmap);
+
rotation_menu = gtk_menu_new();
for (i = 0; i < 12; ++i)
{
- char buffer[256];
int rot;
if (i<4)
{
- snprintf(buffer, sizeof(buffer), "%03d ", i*90);
+ snprintf(buf, sizeof(buf), "%03d ", i*90);
rot = i;
}
else if (i<8)
{
- snprintf(buffer, sizeof(buffer), "%03d |", i*90-360);
+ snprintf(buf, sizeof(buf), "%03d |", i*90-360);
rot = i;
}
else
{
- snprintf(buffer, sizeof(buffer), "%03d -", i*90-2*360);
+ snprintf(buf, sizeof(buf), "%03d -", i*90-2*360);
rot = (((i & 3) + 2) & 3) + 4;
}
- rotation_item = gtk_menu_item_new_with_label(buffer);
+ rotation_item = gtk_menu_item_new_with_label(buf);
gtk_container_add(GTK_CONTAINER(rotation_menu), rotation_item);
- gtk_signal_connect(GTK_OBJECT(rotation_item), "activate", (GtkSignalFunc) preview_rotation_callback, p);
+ g_signal_connect(GTK_OBJECT(rotation_item), "activate", (GtkSignalFunc) preview_rotation_callback, p);
gtk_object_set_data(GTK_OBJECT(rotation_item), "Selection", (void *) rot);
gtk_widget_show(rotation_item);
@@ -3573,133 +4475,143 @@ Preview *preview_new(void)
rotation_option_menu = gtk_option_menu_new();
xsane_back_gtk_set_tooltip(xsane.tooltips, rotation_option_menu, DESC_ROTATION);
- gtk_box_pack_start(GTK_BOX(p->button_box), rotation_option_menu, FALSE, FALSE, 0);
+ gtk_box_pack_start(GTK_BOX(p->menu_box), rotation_option_menu, FALSE, FALSE, 0);
gtk_option_menu_set_menu(GTK_OPTION_MENU(rotation_option_menu), rotation_menu);
gtk_option_menu_set_history(GTK_OPTION_MENU(rotation_option_menu), p->rotation); /* set rotation */
-/* xsane_back_gtk_set_tooltip(tooltips, rotation_option_menu, desc); */
gtk_widget_show(rotation_option_menu);
p->rotation_option_menu = rotation_option_menu;
+ xsane_vseparator_new(p->menu_box, 3);
- gtk_widget_show(p->button_box);
-
+ /* the preview aspect ratio menu */
+ pixmap = gdk_pixmap_create_from_xpm_d(p->top->window, &mask, xsane.bg_trans, (gchar **) aspect_ratio_xpm);
+ pixmapwidget = gtk_image_new_from_pixmap(pixmap, mask);
+ gtk_box_pack_start(GTK_BOX(p->menu_box), pixmapwidget, FALSE, FALSE, 2);
+ gtk_widget_show(pixmapwidget);
+ gdk_drawable_unref(pixmap);
+ ratio_menu = gtk_menu_new();
- /* construct the preview area (table with sliders & preview window) */
- table = gtk_table_new(2, 2, /* homogeneous */ FALSE);
- gtk_table_set_col_spacing(GTK_TABLE(table), 0, 1);
- gtk_table_set_row_spacing(GTK_TABLE(table), 0, 1);
- gtk_container_set_border_width(GTK_CONTAINER(table), 1);
- gtk_box_pack_start(GTK_BOX(vbox), table, /* expand */ TRUE, /* fill */ TRUE, /* padding */ 0);
+ for (i = 0; i < sizeof(ratio_value)/sizeof(float); ++i)
+ {
+ ratio_item = gtk_menu_item_new_with_label(ratio_string[i]);
+ gtk_container_add(GTK_CONTAINER(ratio_menu), ratio_item);
+ g_signal_connect(GTK_OBJECT(ratio_item), "activate", (GtkSignalFunc) preview_ratio_callback, p);
+ gtk_object_set_data(GTK_OBJECT(ratio_item), "Selection", &ratio_value[i]);
- /* the empty box in the top-left corner */
- frame = gtk_frame_new(/* label */ 0);
- gtk_frame_set_shadow_type(GTK_FRAME(frame), GTK_SHADOW_OUT);
- gtk_table_attach(GTK_TABLE(table), frame, 0, 1, 0, 1, GTK_FILL, GTK_FILL, 0, 0);
+ gtk_widget_show(ratio_item);
- /* the unit label */
- p->unit_label = gtk_label_new("cm");
- gtk_container_add(GTK_CONTAINER(frame), p->unit_label);
- gtk_widget_show(p->unit_label);
+ if (ratio_value[i] == p->ratio)
+ {
+ ratio_nr = i;
+ }
+ }
- /* the horizontal ruler */
- p->hruler = gtk_hruler_new();
- gtk_table_attach(GTK_TABLE(table), p->hruler, 1, 2, 0, 1, GTK_FILL, 0, 0, 0);
+ ratio_option_menu = gtk_option_menu_new();
+ xsane_back_gtk_set_tooltip(xsane.tooltips, ratio_option_menu, DESC_RATIO);
+ gtk_box_pack_start(GTK_BOX(p->menu_box), ratio_option_menu, FALSE, FALSE, 0);
+ gtk_option_menu_set_menu(GTK_OPTION_MENU(ratio_option_menu), ratio_menu);
+ gtk_option_menu_set_history(GTK_OPTION_MENU(ratio_option_menu), ratio_nr); /* set ratio */
- /* the vertical ruler */
- p->vruler = gtk_vruler_new();
- gtk_table_attach(GTK_TABLE(table), p->vruler, 0, 1, 1, 2, 0, GTK_FILL, 0, 0);
+ gtk_widget_show(ratio_option_menu);
+ p->ratio_option_menu = ratio_option_menu;
- /* the preview area */
- p->window = gtk_preview_new(GTK_PREVIEW_COLOR);
- gtk_preview_set_expand(GTK_PREVIEW(p->window), TRUE);
-
- gtk_widget_set_events(p->window, GDK_EXPOSURE_MASK | GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK |
- GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK);
-
- /* the first expose_event is responsible to undraw the selection frame */
- gtk_signal_connect(GTK_OBJECT(p->window), "expose_event", (GtkSignalFunc) preview_expose_event_handler_start, p);
- gtk_signal_connect(GTK_OBJECT(p->window), "button_press_event", (GtkSignalFunc) preview_button_press_event_handler, p);
- gtk_signal_connect(GTK_OBJECT(p->window), "motion_notify_event", (GtkSignalFunc) preview_motion_event_handler, p);
- gtk_signal_connect(GTK_OBJECT(p->window), "button_release_event", (GtkSignalFunc) preview_button_release_event_handler, p);
- gtk_signal_connect_after(GTK_OBJECT(p->window), "size_allocate", (GtkSignalFunc) preview_area_resize_handler, p);
- /* the second expose_event is responsible to redraw the selection frame */
- gtk_signal_connect_after(GTK_OBJECT(p->window), "expose_event", (GtkSignalFunc) preview_expose_event_handler_end, p);
+ /* the pointer zoom */
+ frame = gtk_frame_new(0);
+ gtk_box_pack_start(GTK_BOX(outer_hbox), frame, FALSE, FALSE, 3);
+ gtk_container_set_border_width(GTK_CONTAINER(frame), 0);
+ gtk_widget_show(frame);
+ p->zoom = gtk_preview_new(GTK_PREVIEW_COLOR);
+ gtk_preview_size(GTK_PREVIEW(p->zoom), XSANE_ZOOM_SIZE, XSANE_ZOOM_SIZE);
+ gtk_container_add(GTK_CONTAINER(frame), p->zoom);
+ gtk_widget_show(p->zoom);
- /* Connect the motion-notify events of the preview area with the rulers. Nifty stuff! */
- class = GTK_WIDGET_CLASS(GTK_OBJECT(p->hruler)->klass);
- signal_func = (GtkSignalFunc) class->motion_notify_event;
- gtk_signal_connect_object(GTK_OBJECT(p->window), "motion_notify_event", signal_func, GTK_OBJECT(p->hruler));
- class = GTK_WIDGET_CLASS(GTK_OBJECT(p->vruler)->klass);
- signal_func = (GtkSignalFunc) class->motion_notify_event;
- gtk_signal_connect_object(GTK_OBJECT(p->window), "motion_notify_event", signal_func, GTK_OBJECT(p->vruler));
+#if 0
+ /* the RGB label */
+ frame = gtk_frame_new(0);
+ gtk_box_pack_start(GTK_BOX(p->menu_box), frame, FALSE, FALSE, 3);
+ gtk_widget_show(frame);
+ p->rgb_label = gtk_label_new(0);
+ gtk_container_add(GTK_CONTAINER(frame), p->rgb_label);
+ gtk_widget_show(p->rgb_label);
+ preview_display_color_components(p, -1, -1); /* display "###, ###, ###" */
+#endif
+ gtk_widget_show(p->menu_box);
+ /* the menu box is ready */
- p->viewport = gtk_frame_new(/* label */ 0);
- gtk_frame_set_shadow_type(GTK_FRAME(p->viewport), GTK_SHADOW_IN);
- gtk_container_add(GTK_CONTAINER(p->viewport), p->window);
- gtk_table_attach(GTK_TABLE(table), p->viewport, 1, 2, 1, 2,
- GTK_FILL | GTK_EXPAND | GTK_SHRINK, GTK_FILL | GTK_EXPAND | GTK_SHRINK, 0, 0);
- preview_update_surface(p, 0);
+ /* set the action_hbox */
+ action_box = gtk_hbox_new(FALSE, 0);
+ gtk_box_pack_start(GTK_BOX(middle_vbox), action_box, FALSE, FALSE, 2);
+ gtk_container_set_border_width(GTK_CONTAINER(action_box), 0);
+ gtk_widget_show(action_box);
- /* fill in action area: */
/* the (in)valid pixmaps */
pixmap = gdk_pixmap_create_from_xpm_d(p->top->window, &mask, xsane.bg_trans, (gchar **) valid_xpm);
- p->valid_pixmap = gtk_pixmap_new(pixmap, mask);
- gtk_box_pack_start(GTK_BOX(hbox), p->valid_pixmap, FALSE, FALSE, 0);
+ p->valid_pixmap = gtk_image_new_from_pixmap(pixmap, mask);
+ gtk_box_pack_start(GTK_BOX(action_box), p->valid_pixmap, FALSE, FALSE, 0);
gtk_widget_show(p->valid_pixmap);
- gdk_pixmap_unref(pixmap);
+ gdk_drawable_unref(pixmap);
pixmap = gdk_pixmap_create_from_xpm_d(p->top->window, &mask, xsane.bg_trans, (gchar **) scanning_xpm);
- p->scanning_pixmap = gtk_pixmap_new(pixmap, mask);
- gtk_box_pack_start(GTK_BOX(hbox), p->scanning_pixmap, FALSE, FALSE, 0);
+ p->scanning_pixmap = gtk_image_new_from_pixmap(pixmap, mask);
+ gtk_box_pack_start(GTK_BOX(action_box), p->scanning_pixmap, FALSE, FALSE, 0);
gtk_widget_show(p->scanning_pixmap);
- gdk_pixmap_unref(pixmap);
+ gdk_drawable_unref(pixmap);
pixmap = gdk_pixmap_create_from_xpm_d(p->top->window, &mask, xsane.bg_trans, (gchar **) incomplete_xpm);
- p->incomplete_pixmap = gtk_pixmap_new(pixmap, mask);
- gtk_box_pack_start(GTK_BOX(hbox), p->incomplete_pixmap, FALSE, FALSE, 0);
+ p->incomplete_pixmap = gtk_image_new_from_pixmap(pixmap, mask);
+ gtk_box_pack_start(GTK_BOX(action_box), p->incomplete_pixmap, FALSE, FALSE, 0);
gtk_widget_show(p->incomplete_pixmap);
- gdk_pixmap_unref(pixmap);
+ gdk_drawable_unref(pixmap);
pixmap = gdk_pixmap_create_from_xpm_d(p->top->window, &mask, xsane.bg_trans, (gchar **) invalid_xpm);
- p->invalid_pixmap = gtk_pixmap_new(pixmap, mask);
- gtk_box_pack_start(GTK_BOX(hbox), p->invalid_pixmap, FALSE, FALSE, 0);
+ p->invalid_pixmap = gtk_image_new_from_pixmap(pixmap, mask);
+ gtk_box_pack_start(GTK_BOX(action_box), p->invalid_pixmap, FALSE, FALSE, 0);
gtk_widget_show(p->invalid_pixmap);
- gdk_pixmap_unref(pixmap);
+ gdk_drawable_unref(pixmap);
+
/* Start button */
p->start = gtk_button_new_with_label(BUTTON_PREVIEW_ACQUIRE);
xsane_back_gtk_set_tooltip(xsane.tooltips, p->start, DESC_PREVIEW_ACQUIRE);
- gtk_signal_connect(GTK_OBJECT(p->start), "clicked", (GtkSignalFunc) preview_start_button_clicked, p);
- gtk_box_pack_start(GTK_BOX(hbox), p->start, TRUE, TRUE, 10);
- gtk_widget_add_accelerator(p->start, "clicked", xsane.accelerator_group, GDK_P, GDK_MOD1_MASK, GTK_ACCEL_LOCKED); /* Alt P */
+ g_signal_connect(GTK_OBJECT(p->start), "clicked", (GtkSignalFunc) preview_start_button_clicked, p);
+ gtk_box_pack_start(GTK_BOX(action_box), p->start, TRUE, TRUE, 5);
+ gtk_widget_add_accelerator(p->start, "clicked", xsane.accelerator_group, GDK_P, GDK_MOD1_MASK, DEF_GTK_ACCEL_LOCKED); /* Alt P */
+ gtk_widget_show(p->start);
/* Cancel button */
p->cancel = gtk_button_new_with_label(BUTTON_PREVIEW_CANCEL);
xsane_back_gtk_set_tooltip(xsane.tooltips, p->cancel, DESC_PREVIEW_CANCEL);
- gtk_signal_connect(GTK_OBJECT(p->cancel), "clicked", (GtkSignalFunc) preview_cancel_button_clicked, p);
- gtk_box_pack_start(GTK_BOX(hbox), p->cancel, TRUE, TRUE, 10);
- gtk_widget_add_accelerator(p->cancel, "clicked", xsane.accelerator_group, GDK_Escape, GDK_MOD1_MASK, GTK_ACCEL_LOCKED); /* Alt ESC */
+ g_signal_connect(GTK_OBJECT(p->cancel), "clicked", (GtkSignalFunc) preview_cancel_button_clicked, p);
+ gtk_box_pack_start(GTK_BOX(action_box), p->cancel, TRUE, TRUE, 5);
+ gtk_widget_add_accelerator(p->cancel, "clicked", xsane.accelerator_group, GDK_Escape, GDK_MOD1_MASK, DEF_GTK_ACCEL_LOCKED); /* Alt ESC */
+ gtk_widget_show(p->cancel);
gtk_widget_set_sensitive(p->cancel, FALSE);
- gtk_widget_show(p->cancel);
- gtk_widget_show(p->start);
- gtk_widget_show(p->viewport);
- gtk_widget_show(p->window);
- gtk_widget_show(p->hruler);
- gtk_widget_show(p->vruler);
+#if 1
+ /* the RGB label */
+ frame = gtk_frame_new(0);
+ gtk_box_pack_start(GTK_BOX(action_box), frame, FALSE, FALSE, 3);
gtk_widget_show(frame);
- gtk_widget_show(table);
+ p->rgb_label = gtk_label_new(0);
+ gtk_container_add(GTK_CONTAINER(frame), p->rgb_label);
+ gtk_widget_show(p->rgb_label);
+ preview_display_color_components(p, -1, -1); /* display "###, ###, ###" */
+#endif
+
+ preview_update_surface(p, 0);
+
+ gtk_widget_show(p->window);
gtk_widget_show(p->top);
cursor = gdk_cursor_new(XSANE_CURSOR_PREVIEW); /* set default curosr */
gdk_window_set_cursor(p->window->window, cursor);
- gdk_cursor_destroy(cursor);
+ gdk_cursor_unref(cursor);
p->cursornr = XSANE_CURSOR_PREVIEW;
gtk_widget_pop_colormap();
@@ -3875,6 +4787,7 @@ void preview_update_surface(Preview *p, int surface_changed)
{
gtk_widget_set_sensitive(p->preset_area_option_menu, TRUE); /* enable preset area */
gtk_widget_set_sensitive(p->zoom_in, TRUE); /* zoom in is allowed at all */
+ gtk_widget_set_sensitive(p->zoom_area, TRUE); /* zoom area is allowed at all */
gtk_widget_set_sensitive(p->full_area, TRUE); /* enable selection buttons */
gtk_widget_set_sensitive(p->autoselect, TRUE);
}
@@ -3882,6 +4795,7 @@ void preview_update_surface(Preview *p, int surface_changed)
{
gtk_widget_set_sensitive(p->preset_area_option_menu, FALSE); /* disable preset area */
gtk_widget_set_sensitive(p->zoom_in, FALSE); /* no zoom at all */
+ gtk_widget_set_sensitive(p->zoom_area, FALSE);
gtk_widget_set_sensitive(p->zoom_out, FALSE);
gtk_widget_set_sensitive(p->zoom_undo, FALSE);
gtk_widget_set_sensitive(p->zoom_not, FALSE);
@@ -3906,7 +4820,11 @@ void preview_update_surface(Preview *p, int surface_changed)
width = p->surface[p->index_xmax] - p->surface[p->index_xmin];
height = p->surface[p->index_ymax] - p->surface[p->index_ymin];
+#if 0
if ( (p->calibration) || (p->startimage) ) /* predefined image should have constant aspect */
+#else
+ if (p->calibration) /* predefined calibration image should have constant aspect */
+#endif
{
p->aspect = fabs(p->image_width/(float) p->image_height);
}
@@ -3942,7 +4860,7 @@ void preview_update_surface(Preview *p, int surface_changed)
p->preview_window_width = 0.3 * gdk_screen_width();
p->preview_window_height = 0.5 * gdk_screen_height();
preview_area_correct(p); /* calculate preview_width and height */
- gtk_widget_set_usize(GTK_WIDGET(p->window), p->preview_width, p->preview_height);
+ gtk_widget_set_size_request(GTK_WIDGET(p->window), p->preview_width, p->preview_height);
}
else if (surface_changed) /* establish new surface */
{
@@ -3967,6 +4885,7 @@ void preview_update_surface(Preview *p, int surface_changed)
/* ---------------------------------------------------------------------------------------------------------------------- */
+/* preview_scan is called once when the "Preview scan" button is pressed */
void preview_scan(Preview *p)
{
double min, max, swidth, sheight, width, height, dpi = 0;
@@ -3974,6 +4893,14 @@ void preview_scan(Preview *p)
gint gwidth, gheight;
int i;
float dsurface[4];
+ int gamma_gray_size = 256; /* set this values to image depth for more than 8bpp input support!!! */
+ int gamma_red_size = 256;
+ int gamma_green_size = 256;
+ int gamma_blue_size = 256;
+ int gamma_gray_max = 255; /* set this to to image depth for more than 8bpp output support */
+ int gamma_red_max = 255;
+ int gamma_green_max = 255;
+ int gamma_blue_max = 255;
DBG(DBG_proc, "preview_scan\n");
@@ -3995,10 +4922,6 @@ void preview_scan(Preview *p)
preview_save_option(p, xsane.well_known.bit_depth, &p->saved_bit_depth, &p->saved_bit_depth_valid);
-#if 0
- xsane_set_medium(preferences.medium[xsane.medium_nr]); /* make sure medium gamma values are up to date */
-#endif
-
/* determine dpi, if necessary: */
if (xsane.well_known.dpi > 0)
@@ -4066,6 +4989,7 @@ void preview_scan(Preview *p)
xsane_set_resolution(xsane.well_known.dpi_y, dpi); /* set resolution to dpi or next higher value that is available */
}
+
preview_rotate_previewsurface_to_devicesurface(p->rotation, p->surface, dsurface);
for (i = 0; i < 4; ++i)
@@ -4087,6 +5011,97 @@ void preview_scan(Preview *p)
}
#endif
+
+ if (xsane.well_known.gamma_vector >0)
+ {
+ const SANE_Option_Descriptor *opt;
+
+ opt = xsane_get_option_descriptor(xsane.dev, xsane.well_known.gamma_vector);
+ if (SANE_OPTION_IS_ACTIVE(opt->cap))
+ {
+ SANE_Int *gamma_data;
+
+ opt = xsane_get_option_descriptor(xsane.dev, xsane.well_known.gamma_vector);
+ gamma_gray_size = opt->size / sizeof(opt->type);
+ gamma_gray_max = opt->constraint.range->max;
+
+ gamma_data = malloc(gamma_gray_size * sizeof(SANE_Int));
+
+ if ((xsane.xsane_colors > 1) || (xsane.no_preview_medium_gamma)) /* color scan or medium preview gamma disabled */
+ {
+ xsane_create_gamma_curve(gamma_data, 0, 1.0, 0.0, 0.0, 0.0, 100.0, 1.0, gamma_gray_size, gamma_gray_max);
+ }
+ else /* grayscale scan */
+ {
+ xsane_create_gamma_curve(gamma_data, xsane.medium_negative, 1.0, 0.0, 0.0,
+ xsane.medium_shadow_gray, xsane.medium_highlight_gray, xsane.medium_gamma_gray,
+ gamma_gray_size, gamma_gray_max);
+ }
+
+ xsane_back_gtk_update_vector(xsane.well_known.gamma_vector, gamma_data);
+ free(gamma_data);
+ }
+ }
+
+ if (xsane.well_known.gamma_vector_r >0)
+ {
+ const SANE_Option_Descriptor *opt;
+
+ opt = xsane_get_option_descriptor(xsane.dev, xsane.well_known.gamma_vector_r);
+ if (SANE_OPTION_IS_ACTIVE(opt->cap))
+ {
+ SANE_Int *gamma_data_red, *gamma_data_green, *gamma_data_blue;
+
+ opt = xsane_get_option_descriptor(xsane.dev, xsane.well_known.gamma_vector_r);
+ gamma_red_size = opt->size / sizeof(opt->type);
+ gamma_red_max = opt->constraint.range->max;
+
+ opt = xsane_get_option_descriptor(xsane.dev, xsane.well_known.gamma_vector_g);
+ gamma_green_size = opt->size / sizeof(opt->type);
+ gamma_green_max = opt->constraint.range->max;
+
+ opt = xsane_get_option_descriptor(xsane.dev, xsane.well_known.gamma_vector_b);
+ gamma_blue_size = opt->size / sizeof(opt->type);
+ gamma_blue_max = opt->constraint.range->max;
+
+ gamma_data_red = malloc(gamma_red_size * sizeof(SANE_Int));
+ gamma_data_green = malloc(gamma_green_size * sizeof(SANE_Int));
+ gamma_data_blue = malloc(gamma_blue_size * sizeof(SANE_Int));
+
+ if (xsane.no_preview_medium_gamma) /* do not use medium gamma for preview */
+ {
+ DBG(DBG_info, "preview: not using medium gamma table\n");
+
+ xsane_create_gamma_curve(gamma_data_red, 0, 1.0, 0.0, 0.0, 0.0, 100.0, 1.0, gamma_red_size, gamma_red_max);
+ xsane_create_gamma_curve(gamma_data_green, 0, 1.0, 0.0, 0.0, 0.0, 100.0, 1.0, gamma_green_size, gamma_green_max);
+ xsane_create_gamma_curve(gamma_data_blue, 0, 1.0, 0.0, 0.0, 0.0, 100.0, 1.0, gamma_blue_size, gamma_blue_max);
+ }
+ else /* use medium gamma for preview */
+ {
+ DBG(DBG_info, "preview: using medium gamma table\n");
+
+ xsane_create_gamma_curve(gamma_data_red, xsane.medium_negative, 1.0, 0.0, 0.0,
+ xsane.medium_shadow_red, xsane.medium_highlight_red, xsane.medium_gamma_red,
+ gamma_red_size, gamma_red_max);
+ xsane_create_gamma_curve(gamma_data_green, xsane.medium_negative, 1.0, 0.0, 0.0,
+ xsane.medium_shadow_green, xsane.medium_highlight_green, xsane.medium_gamma_green,
+ gamma_green_size, gamma_green_max);
+ xsane_create_gamma_curve(gamma_data_blue, xsane.medium_negative, 1.0, 0.0, 0.0,
+ xsane.medium_shadow_blue, xsane.medium_highlight_blue, xsane.medium_gamma_blue,
+ gamma_blue_size, gamma_blue_max);
+ }
+
+ xsane_back_gtk_update_vector(xsane.well_known.gamma_vector_r, gamma_data_red);
+ xsane_back_gtk_update_vector(xsane.well_known.gamma_vector_g, gamma_data_green);
+ xsane_back_gtk_update_vector(xsane.well_known.gamma_vector_b, gamma_data_blue);
+
+ free(gamma_data_red);
+ free(gamma_data_green);
+ free(gamma_data_blue);
+ }
+ }
+
+
xsane.block_update_param = FALSE;
p->preview_colors = xsane.xsane_colors;
p->scan_incomplete = FALSE;
@@ -4189,6 +5204,8 @@ static void preview_delete_images(Preview *p)
fclose(out);
}
preview_update_surface(p, 1);
+
+ xsane_batch_scan_update_icon_list();
}
/* ---------------------------------------------------------------------------------------------------------------------- */
@@ -4232,12 +5249,12 @@ void preview_destroy(Preview *p)
if (p->gc_selection)
{
- gdk_gc_destroy(p->gc_selection);
+ gdk_gc_unref(p->gc_selection);
}
if (p->gc_selection_maximum)
{
- gdk_gc_destroy(p->gc_selection_maximum);
+ gdk_gc_unref(p->gc_selection_maximum);
}
if (p->top)
@@ -4251,6 +5268,27 @@ void preview_destroy(Preview *p)
/* ---------------------------------------------------------------------------------------------------------------------- */
+static void preview_zoom_area(GtkWidget *window, gpointer data)
+{
+ Preview *p=data;
+ int i;
+
+ DBG(DBG_proc, "preview_zoom_area\n");
+
+ for (i=0; i<4; i++)
+ {
+ p->old_surface[i] = p->surface[i];
+ p->surface[i] = p->selection.coordinate[i];
+ }
+
+ preview_update_surface(p, 1);
+ gtk_widget_set_sensitive(p->zoom_not, TRUE); /* allow unzoom */
+ gtk_widget_set_sensitive(p->zoom_out, TRUE); /* allow zoom out */
+ gtk_widget_set_sensitive(p->zoom_undo,TRUE); /* allow zoom undo */
+}
+
+/* ---------------------------------------------------------------------------------------------------------------------- */
+
static void preview_zoom_not(GtkWidget *window, gpointer data)
{
Preview *p=data;
@@ -4320,19 +5358,25 @@ static void preview_zoom_out(GtkWidget *window, gpointer data)
/* ---------------------------------------------------------------------------------------------------------------------- */
-static void preview_zoom_in(GtkWidget *window, gpointer data)
+static void preview_select_zoom_point(Preview *p, int preview_x, int preview_y)
{
- Preview *p=data;
int i;
+ float device_x, device_y;
- DBG(DBG_proc, "preview_zoom_in\n");
+ DBG(DBG_proc, "preview_select_zoom_point(%d, %d)\n", preview_x, preview_y);
+
+ preview_transform_coordinate_window_to_device(p, preview_x, preview_y, &device_x, &device_y);
for (i=0; i<4; i++)
{
p->old_surface[i] = p->surface[i];
- p->surface[i] = p->selection.coordinate[i];
}
+ p->surface[0] = device_x + (p->surface[0] - device_x) * 0.8;
+ p->surface[1] = device_y + (p->surface[1] - device_y) * 0.8;
+ p->surface[2] = device_x + (p->surface[2] - device_x) * 0.8;
+ p->surface[3] = device_y + (p->surface[3] - device_y) * 0.8;
+
preview_update_surface(p, 1);
gtk_widget_set_sensitive(p->zoom_not, TRUE); /* allow unzoom */
gtk_widget_set_sensitive(p->zoom_out, TRUE); /* allow zoom out */
@@ -4375,7 +5419,7 @@ static void preview_get_color(Preview *p, int x, int y, int range, int *red, int
{
preview_transform_coordinate_window_to_image(p, x, y, &image_x, &image_y);
- if ( (image_x < p->image_width) && (image_y < p->image_height) )
+ if ( (image_x >= 0) && (image_x < p->image_width) && (image_y >=0) && (image_y < p->image_height) )
{
image_x_min = image_x - range/2;
image_y_min = image_y - range/2;
@@ -4423,6 +5467,20 @@ static void preview_get_color(Preview *p, int x, int y, int range, int *red, int
/* ---------------------------------------------------------------------------------------------------------------------- */
+static void preview_add_batch(GtkWidget *window, Preview *data)
+{
+ DBG(DBG_proc, "preview_add_batch\n");
+
+ xsane_batch_scan_add(); /* add active settings to batch list */
+
+#if 0
+ preview_draw_selection(p); /* read selection from backend: correct rotation */
+ preview_establish_selection(p); /* read selection from backend: correct rotation */
+#endif
+}
+
+/* ---------------------------------------------------------------------------------------------------------------------- */
+
static void preview_pipette_white(GtkWidget *window, gpointer data)
{
Preview *p=data;
@@ -4450,7 +5508,7 @@ static void preview_pipette_white(GtkWidget *window, gpointer data)
cursor = gdk_cursor_new_from_pixmap(pixmap, mask, &fg, &bg, CURSOR_PIPETTE_HOT_X, CURSOR_PIPETTE_HOT_Y);
gdk_window_set_cursor(p->window->window, cursor);
- gdk_cursor_destroy(cursor);
+ gdk_cursor_unref(cursor);
p->cursornr = -1;
}
@@ -4483,7 +5541,7 @@ static void preview_pipette_gray(GtkWidget *window, gpointer data)
cursor = gdk_cursor_new_from_pixmap(pixmap, mask, &fg, &bg, CURSOR_PIPETTE_HOT_X, CURSOR_PIPETTE_HOT_Y);
gdk_window_set_cursor(p->window->window, cursor);
- gdk_cursor_destroy(cursor);
+ gdk_cursor_unref(cursor);
p->cursornr = -1;
}
@@ -4516,12 +5574,77 @@ static void preview_pipette_black(GtkWidget *window, gpointer data)
cursor = gdk_cursor_new_from_pixmap(pixmap, mask, &fg, &bg, CURSOR_PIPETTE_HOT_X, CURSOR_PIPETTE_HOT_Y);
gdk_window_set_cursor(p->window->window, cursor);
- gdk_cursor_destroy(cursor);
+ gdk_cursor_unref(cursor);
+ p->cursornr = -1;
+}
+
+/* ---------------------------------------------------------------------------------------------------------------------- */
+
+static void preview_init_autoraise_scanarea(GtkWidget *window, gpointer data)
+{
+ Preview *p=data;
+ GdkCursor *cursor;
+ GdkColor fg;
+ GdkColor bg;
+ GdkPixmap *pixmap;
+ GdkPixmap *mask;
+
+ DBG(DBG_proc, "preview_init_autoraise_scanarea\n");
+
+ p->mode = MODE_AUTORAISE_SCANAREA;
+
+ pixmap = gdk_bitmap_create_from_data(p->top->window, cursor_autoraise_scanarea, CURSOR_AUTORAISE_SCANAREA_WIDTH, CURSOR_AUTORAISE_SCANAREA_HEIGHT);
+ mask = gdk_bitmap_create_from_data(p->top->window, cursor_autoraise_scanarea_mask, CURSOR_AUTORAISE_SCANAREA_WIDTH, CURSOR_AUTORAISE_SCANAREA_HEIGHT);
+
+ fg.red = 0;
+ fg.green = 0;
+ fg.blue = 0;
+
+ bg.red = 65535;
+ bg.green = 65535;
+ bg.blue = 65535;
+
+ cursor = gdk_cursor_new_from_pixmap(pixmap, mask, &fg, &bg, CURSOR_AUTORAISE_SCANAREA_HOT_X, CURSOR_AUTORAISE_SCANAREA_HOT_Y);
+
+ gdk_window_set_cursor(p->window->window, cursor);
+ gdk_cursor_unref(cursor);
p->cursornr = -1;
}
/* ---------------------------------------------------------------------------------------------------------------------- */
+static void preview_zoom_in(GtkWidget *window, gpointer data)
+{
+ Preview *p=data;
+ GdkCursor *cursor;
+ GdkColor fg;
+ GdkColor bg;
+ GdkPixmap *pixmap;
+ GdkPixmap *mask;
+
+ DBG(DBG_proc, "preview_zoom\n");
+
+ p->mode = MODE_ZOOM_IN;
+
+ pixmap = gdk_bitmap_create_from_data(p->top->window, cursor_zoom, CURSOR_ZOOM_WIDTH, CURSOR_ZOOM_HEIGHT);
+ mask = gdk_bitmap_create_from_data(p->top->window, cursor_zoom_mask, CURSOR_ZOOM_WIDTH, CURSOR_ZOOM_HEIGHT);
+
+ fg.red = 0;
+ fg.green = 0;
+ fg.blue = 0;
+
+ bg.red = 65535;
+ bg.green = 65535;
+ bg.blue = 65535;
+
+ cursor = gdk_cursor_new_from_pixmap(pixmap, mask, &fg, &bg, CURSOR_ZOOM_HOT_X, CURSOR_ZOOM_HOT_Y);
+
+ gdk_window_set_cursor(p->window->window, cursor);
+ gdk_cursor_unref(cursor);
+ p->cursornr = -1;
+}
+/* ---------------------------------------------------------------------------------------------------------------------- */
+
void preview_select_full_preview_area(Preview *p)
{
int i;
@@ -4566,32 +5689,15 @@ static void preview_delete_images_callback(GtkWidget *widget, gpointer call_data
/* ---------------------------------------------------------------------------------------------------------------------- */
-int xsane_preset_area_entry_rename;
-
-static void xsane_preset_area_entry_rename_button_callback(GtkWidget *widget, gpointer data)
-{
- DBG(DBG_proc, "xsane_preset_area_entry_rename\n");
-
- xsane_preset_area_entry_rename = (int) data;
-}
-
-/* ---------------------------------------------------------------------------------------------------------------------- */
-
static gint preview_preset_area_rename_callback(GtkWidget *widget, GtkWidget *preset_area_widget)
{
int selection;
char *oldname;
char *newname;
Preview *p;
- GtkWidget *rename_dialog;
- GtkWidget *text;
- GtkWidget *button;
- GtkWidget *vbox, *hbox;
GtkWidget *old_preset_area_menu;
- char buf[256];
int old_selection;
-
DBG(DBG_proc, "preview_preset_area_rename_callback\n");
selection = (int) gtk_object_get_data(GTK_OBJECT(preset_area_widget), "Selection");
@@ -4599,71 +5705,15 @@ static gint preview_preset_area_rename_callback(GtkWidget *widget, GtkWidget *pr
DBG(DBG_info ,"rename %s\n", preferences.preset_area[selection]->name);
+ /* set menu in correct state, is a bit strange this way but I do not have a better idea */
old_preset_area_menu = gtk_option_menu_get_menu(GTK_OPTION_MENU(p->preset_area_option_menu));
old_selection = (int) gtk_object_get_data(GTK_OBJECT(gtk_menu_get_active(GTK_MENU(old_preset_area_menu))), "Selection");
-
gtk_menu_popdown(GTK_MENU(old_preset_area_menu));
- /* set menu in correct state, is a bit strange this way but I do not have a better idea */
gtk_option_menu_set_history(GTK_OPTION_MENU(p->preset_area_option_menu), old_selection);
oldname = strdup(preferences.preset_area[selection]->name);
- rename_dialog = gtk_window_new(GTK_WINDOW_DIALOG);
- xsane_set_window_icon(rename_dialog, 0);
-
- /* set rename dialog */
- gtk_window_set_position(GTK_WINDOW(rename_dialog), GTK_WIN_POS_CENTER);
- gtk_window_set_policy(GTK_WINDOW(rename_dialog), FALSE, FALSE, FALSE);
- snprintf(buf, sizeof(buf), "%s %s", xsane.prog_name, WINDOW_PRESET_AREA_RENAME);
- gtk_window_set_title(GTK_WINDOW(rename_dialog), buf);
- gtk_signal_connect(GTK_OBJECT(rename_dialog), "delete_event", (GtkSignalFunc) xsane_preset_area_entry_rename_button_callback, (void *) -1);
- gtk_widget_show(rename_dialog);
-
- /* set the main vbox */
- vbox = gtk_vbox_new(FALSE, 0);
- gtk_container_set_border_width(GTK_CONTAINER(vbox), 0);
- gtk_container_add(GTK_CONTAINER(rename_dialog), vbox);
- gtk_widget_show(vbox);
-
- /* set the main hbox */
- hbox = gtk_hbox_new(FALSE, 0);
- xsane_separator_new(vbox, 2);
- gtk_box_pack_end(GTK_BOX(vbox), hbox, FALSE, FALSE, 5);
- gtk_container_set_border_width(GTK_CONTAINER(hbox), 5);
- gtk_widget_show(hbox);
-
- text = gtk_entry_new_with_max_length(64);
- xsane_back_gtk_set_tooltip(xsane.tooltips, text, DESC_PRESET_AREA_NAME);
- gtk_entry_set_text(GTK_ENTRY(text), oldname);
- gtk_widget_set_usize(text, 300, 0);
- gtk_box_pack_start(GTK_BOX(vbox), text, TRUE, TRUE, 4);
- gtk_widget_show(text);
-
-
- button = gtk_button_new_with_label("OK");
- gtk_signal_connect(GTK_OBJECT(button), "clicked", (GtkSignalFunc) xsane_preset_area_entry_rename_button_callback, (void *) 1);
- gtk_box_pack_start(GTK_BOX(hbox), button, TRUE, TRUE, 0);
- gtk_widget_show(button);
-
- button = gtk_button_new_with_label("Cancel");
- gtk_signal_connect(GTK_OBJECT(button), "clicked", (GtkSignalFunc) xsane_preset_area_entry_rename_button_callback, (void *) -1);
- gtk_box_pack_start(GTK_BOX(hbox), button, TRUE, TRUE, 0);
- gtk_widget_show(button);
-
- xsane_preset_area_entry_rename = 0;
-
- while (xsane_preset_area_entry_rename == 0)
- {
- while (gtk_events_pending())
- {
- DBG(DBG_info, "preview_preset_area_rename_callback: calling gtk_main_iteration\n");
- gtk_main_iteration();
- }
- }
-
- newname = strdup(gtk_entry_get_text(GTK_ENTRY(text)));
-
- if (xsane_preset_area_entry_rename == 1) /* OK button has been pressed */
+ if (!xsane_front_gtk_getname_dialog(WINDOW_PRESET_AREA_RENAME, DESC_PRESET_AREA_RENAME, oldname, &newname))
{
gtk_option_menu_remove_menu(GTK_OPTION_MENU(p->preset_area_option_menu));
@@ -4682,8 +5732,6 @@ static gint preview_preset_area_rename_callback(GtkWidget *widget, GtkWidget *pr
free(oldname);
free(newname);
- gtk_widget_destroy(rename_dialog);
-
xsane_set_sensitivity(TRUE);
return TRUE; /* event is handled */
@@ -4695,6 +5743,9 @@ static gint preview_preset_area_add_callback(GtkWidget *widget, GtkWidget *prese
{
int selection, i, old_selection = 0;
Preview *p;
+ float coord[4];
+ char suggested_name[256];
+ char *newname;
GtkWidget *old_preset_area_menu;
DBG(DBG_proc, "preview_preset_area_add_callback\n");
@@ -4702,11 +5753,18 @@ static gint preview_preset_area_add_callback(GtkWidget *widget, GtkWidget *prese
selection = (int) gtk_object_get_data(GTK_OBJECT(preset_area_widget), "Selection");
p = (Preview *) gtk_object_get_data(GTK_OBJECT(preset_area_widget), "Preview");
- if (selection < preferences.preset_area_definitions)
- {
- char buf[256];
- float coord[4];
+ /* set menu in correct state, is a bit strange this way but I do not have a better idea */
+ old_preset_area_menu = gtk_option_menu_get_menu(GTK_OPTION_MENU(p->preset_area_option_menu));
+ old_selection = (int) gtk_object_get_data(GTK_OBJECT(gtk_menu_get_active(GTK_MENU(old_preset_area_menu))), "Selection");
+ gtk_menu_popdown(GTK_MENU(old_preset_area_menu));
+ gtk_option_menu_set_history(GTK_OPTION_MENU(p->preset_area_option_menu), old_selection);
+
+ /* sugggest name = size in mm */
+ preview_rotate_previewsurface_to_devicesurface(p->rotation, p->selection.coordinate, coord);
+ snprintf(suggested_name, sizeof(suggested_name), "%d mm x %d mm", (int) (coord[2]-coord[0]), (int) (coord[3]-coord[1]));
+ if (!xsane_front_gtk_getname_dialog(WINDOW_PRESET_AREA_ADD, DESC_PRESET_AREA_ADD, suggested_name, &newname))
+ {
preferences.preset_area = realloc(preferences.preset_area, (preferences.preset_area_definitions+1) * sizeof(void *));
/* shift all items after selection */
@@ -4715,32 +5773,18 @@ static gint preview_preset_area_add_callback(GtkWidget *widget, GtkWidget *prese
preferences.preset_area[i+1] = preferences.preset_area[i];
}
- /* insert new item behind selected item, name is size in mm */
- preview_rotate_previewsurface_to_devicesurface(p->rotation, p->selection.coordinate, coord);
- snprintf(buf, sizeof(buf), "%d mm x %d mm", (int) (coord[2]-coord[0]), (int) (coord[3]-coord[1]));
+ /* insert new item behind selected item */
preferences.preset_area[selection+1] = calloc(sizeof(Preferences_preset_area_t), 1);
- preferences.preset_area[selection+1]->name = strdup(buf);
+ preferences.preset_area[selection+1]->name = strdup(newname);
preferences.preset_area[selection+1]->xoffset = coord[0];
preferences.preset_area[selection+1]->yoffset = coord[1];
preferences.preset_area[selection+1]->width = coord[2] - coord[0];
preferences.preset_area[selection+1]->height = coord[3] - coord[1];
- DBG(DBG_proc, "added %s\n", buf);
+ DBG(DBG_proc, "added %s\n", newname);
preferences.preset_area_definitions++;
- old_preset_area_menu = gtk_option_menu_get_menu(GTK_OPTION_MENU(p->preset_area_option_menu));
-
- gtk_option_menu_remove_menu(GTK_OPTION_MENU(p->preset_area_option_menu));
- old_selection = (int) gtk_object_get_data(GTK_OBJECT(gtk_menu_get_active(GTK_MENU(old_preset_area_menu))), "Selection");
-
- if (old_selection > selection) /* we are moving the selected surface */
- {
- old_selection++;
- }
-
- gtk_widget_destroy(old_preset_area_menu);
-
preview_create_preset_area_menu(p, old_selection);
}
@@ -4895,6 +5939,7 @@ static gint preview_preset_area_context_menu_callback(GtkWidget *widget, GdkEven
GtkWidget *menu_item;
GdkEventButton *event_button;
int selection;
+ char buf[256];
DBG(DBG_proc, "preview_preset_area_context_menu_callback\n");
@@ -4912,42 +5957,51 @@ static gint preview_preset_area_context_menu_callback(GtkWidget *widget, GdkEven
menu_item = gtk_menu_item_new_with_label(MENU_ITEM_PRESET_AREA_ADD_SEL);
gtk_widget_show(menu_item);
gtk_container_add(GTK_CONTAINER(menu), menu_item);
- gtk_signal_connect(GTK_OBJECT(menu_item), "activate", (GtkSignalFunc) preview_preset_area_add_callback, widget);
+ g_signal_connect(GTK_OBJECT(menu_item), "activate", (GtkSignalFunc) preview_preset_area_add_callback, widget);
+
+ /* add separator */
+ menu_item = gtk_menu_item_new();
+ gtk_widget_show(menu_item);
+ gtk_container_add(GTK_CONTAINER(menu), menu_item);
/* rename preset area */
- menu_item = gtk_menu_item_new_with_label(MENU_ITEM_PRESET_AREA_RENAME);
+ snprintf(buf, sizeof(buf), "%s: %s", preferences.preset_area[selection]->name, MENU_ITEM_RENAME);
+ menu_item = gtk_menu_item_new_with_label(buf);
gtk_widget_show(menu_item);
gtk_container_add(GTK_CONTAINER(menu), menu_item);
- gtk_signal_connect(GTK_OBJECT(menu_item), "activate", (GtkSignalFunc) preview_preset_area_rename_callback, widget);
+ g_signal_connect(GTK_OBJECT(menu_item), "activate", (GtkSignalFunc) preview_preset_area_rename_callback, widget);
if (selection) /* not available for "full area" */
{
/* delete preset area */
- menu_item = gtk_menu_item_new_with_label(MENU_ITEM_PRESET_AREA_DELETE);
+ snprintf(buf, sizeof(buf), "%s: %s", preferences.preset_area[selection]->name, MENU_ITEM_DELETE);
+ menu_item = gtk_menu_item_new_with_label(buf);
gtk_widget_show(menu_item);
gtk_container_add(GTK_CONTAINER(menu), menu_item);
- gtk_signal_connect(GTK_OBJECT(menu_item), "activate", (GtkSignalFunc) preview_preset_area_delete_callback, widget);
+ g_signal_connect(GTK_OBJECT(menu_item), "activate", (GtkSignalFunc) preview_preset_area_delete_callback, widget);
}
if (selection>1) /* available from 3rd item */
{
/* move up */
- menu_item = gtk_menu_item_new_with_label(MENU_OTEM_PRESET_AREA_MOVE_UP);
+ snprintf(buf, sizeof(buf), "%s: %s", preferences.preset_area[selection]->name, MENU_ITEM_MOVE_UP);
+ menu_item = gtk_menu_item_new_with_label(buf);
gtk_widget_show(menu_item);
gtk_container_add(GTK_CONTAINER(menu), menu_item);
- gtk_signal_connect(GTK_OBJECT(menu_item), "activate", (GtkSignalFunc) preview_preset_area_move_up_callback, widget);
+ g_signal_connect(GTK_OBJECT(menu_item), "activate", (GtkSignalFunc) preview_preset_area_move_up_callback, widget);
}
if ((selection) && (selection < preferences.preset_area_definitions-1))
{
/* move down */
- menu_item = gtk_menu_item_new_with_label(MENU_OTEM_PRESET_AREA_MOVE_DWN);
+ snprintf(buf, sizeof(buf), "%s: %s", preferences.preset_area[selection]->name, MENU_ITEM_MOVE_DWN);
+ menu_item = gtk_menu_item_new_with_label(buf);
gtk_widget_show(menu_item);
gtk_container_add(GTK_CONTAINER(menu), menu_item);
- gtk_signal_connect(GTK_OBJECT(menu_item), "activate", (GtkSignalFunc) preview_preset_area_move_down_callback, widget);
+ g_signal_connect(GTK_OBJECT(menu_item), "activate", (GtkSignalFunc) preview_preset_area_move_down_callback, widget);
}
- gtk_widget_show(menu);
+/* gtk_widget_show(menu); */
gtk_menu_popup(GTK_MENU(menu), NULL, NULL, NULL, NULL, event_button->button, event_button->time);
return TRUE; /* event is handled */
@@ -4959,9 +6013,9 @@ static gint preview_preset_area_context_menu_callback(GtkWidget *widget, GdkEven
/* ---------------------------------------------------------------------------------------------------------------------- */
-static void preview_preset_area_callback(GtkWidget *widget, gpointer call_data)
+static void preview_preset_area_callback(GtkWidget *widget, gpointer data)
{
- Preview *p = call_data;
+ Preview *p = data;
int selection;
DBG(DBG_proc, "preview_preset_area_callback\n");
@@ -4982,9 +6036,9 @@ static void preview_preset_area_callback(GtkWidget *widget, gpointer call_data)
/* ---------------------------------------------------------------------------------------------------------------------- */
-static void preview_rotation_callback(GtkWidget *widget, gpointer call_data)
+static void preview_rotation_callback(GtkWidget *widget, gpointer data)
{
- Preview *p = call_data;
+ Preview *p = data;
float rotated_surface[4];
int rot;
@@ -5070,8 +6124,84 @@ static void preview_rotation_callback(GtkWidget *widget, gpointer call_data)
p->rotation = rot;
- preview_update_selection(p); /* read selection from backend: correct rotation */
+ p->block_update_maximum_output_size_clipping = TRUE; /* necessary when in copy mode */
preview_update_surface(p, 2); /* rotate surfaces */
+ p->block_update_maximum_output_size_clipping = FALSE;
+ preview_update_selection(p); /* read selection from backend: correct rotation */
+ xsane_batch_scan_update_icon_list(); /* rotate batch scan icons */
+ preview_establish_ratio(p); /* make sure ratio is like selected - when selected */
+}
+
+/* ---------------------------------------------------------------------------------------------------------------------- */
+
+static void preview_establish_ratio(Preview *p)
+{
+ float width, height;
+
+ DBG(DBG_proc, "preview_establish_ratio\n");
+
+ if (p->ratio == 0.0)
+ {
+ return;
+ }
+
+ width = fabs(p->selection.coordinate[p->index_xmax] - p->selection.coordinate[p->index_xmin]);
+ height = fabs(p->selection.coordinate[p->index_ymax] - p->selection.coordinate[p->index_ymin]);
+
+ if ( (0.99 < width / p->ratio / height) && (width / p->ratio / height < 1.01) )
+ {
+ return;
+ }
+
+ if ( (0.99 < width * p->ratio / height) && (width * p->ratio / height < 1.01) )
+ {
+ width = height;
+
+ if (width > p->scanner_surface[p->index_xmax] - p->scanner_surface[p->index_xmin])
+ {
+ width = p->scanner_surface[p->index_xmax] - p->scanner_surface[p->index_xmin];
+ }
+ }
+
+ height = width / p->ratio;
+ if (height > p->scanner_surface[p->index_ymax] - p->scanner_surface[p->index_ymin])
+ {
+ height = p->scanner_surface[p->index_ymax] - p->scanner_surface[p->index_ymin];
+ width = height * p->ratio;
+ }
+
+ p->selection.coordinate[p->index_xmax] = p->selection.coordinate[p->index_xmin] + width;
+ if (p->selection.coordinate[p->index_xmax] > p->scanner_surface[p->index_xmax])
+ {
+ p->selection.coordinate[p->index_xmax] = p->scanner_surface[p->index_xmax];
+ p->selection.coordinate[p->index_xmin] = p->selection.coordinate[p->index_xmax] - width;
+ }
+
+ p->selection.coordinate[p->index_ymax] = p->selection.coordinate[p->index_ymin] + height;
+ if (p->selection.coordinate[p->index_ymax] > p->scanner_surface[p->index_ymax])
+ {
+ p->selection.coordinate[p->index_ymax] = p->scanner_surface[p->index_ymax];
+ p->selection.coordinate[p->index_ymin] = p->selection.coordinate[p->index_ymax] - height;
+ }
+
+ preview_draw_selection(p);
+ preview_establish_selection(p);
+}
+
+/* ---------------------------------------------------------------------------------------------------------------------- */
+
+static void preview_ratio_callback(GtkWidget *widget, gpointer data)
+{
+ Preview *p = data;
+ float *ratio;
+
+ DBG(DBG_proc, "preview_ratio_callback\n");
+
+ ratio = (float *) gtk_object_get_data(GTK_OBJECT(widget), "Selection");
+
+ p->ratio = *ratio;
+
+ preview_establish_ratio(p);
}
/* ---------------------------------------------------------------------------------------------------------------------- */
@@ -5092,8 +6222,8 @@ void preview_do_gamma_correction(Preview *p)
{
int x,y;
int offset;
- u_char *image_data_enhp;
- guint16 *image_data_rawp;
+ u_char *image_data_enhp = NULL;
+ guint16 *image_data_rawp = NULL;
int rotate = 16 - preview_gamma_input_bits;
DBG(DBG_proc, "preview_do_gamma_correction\n");
@@ -5142,7 +6272,10 @@ void preview_do_gamma_correction(Preview *p)
for (x=0; x < p->image_width; x++)
{
- level = ((*image_data_rawp++) + (*image_data_rawp++) + (*image_data_rawp++)) / 3;
+ level = (*image_data_rawp++); /* red */
+ level += (*image_data_rawp++); /* green */
+ level += (*image_data_rawp++); /* blue */
+ level /= 3;
level >>= rotate;
*image_data_enhp++ = preview_gamma_data_red [level]; /* use 12 bit gamma table */
*image_data_enhp++ = preview_gamma_data_green[level];
@@ -5619,11 +6752,28 @@ gint preview_area_resize_handler(GtkWidget *widget, GdkEvent *event, gpointer da
}
/* ---------------------------------------------------------------------------------------------------------------------- */
-#if 0
+
void preview_update_maximum_output_size(Preview *p)
{
+ float xxx = 0.0;
+ float yyy = 0.0;
+ float dxmin = 0;
+ float dymin = 0;
+ float dxmax = 0;
+ float dymax = 0;
+
+ int paper_orientation = 0;
+
+ if (p->block_update_maximum_output_size_clipping)
+ {
+ DBG(DBG_info, "preview_update_maximum_output_size: blocked\n");
+ return;
+ }
+
DBG(DBG_proc, "preview_update_maximum_output_size\n");
+ p->block_update_maximum_output_size_clipping = TRUE;
+
if ( (p->maximum_output_width >= INF) || (p->maximum_output_height >= INF) )
{
if (p->selection_maximum.active)
@@ -5631,127 +6781,384 @@ void preview_update_maximum_output_size(Preview *p)
p->selection_maximum.active = FALSE;
}
}
- else
+ else /* we have a maximum output size definition */
{
p->previous_selection_maximum = p->selection_maximum;
-
p->selection_maximum.active = TRUE;
- p->selection_maximum.coordinate[0] = (p->selection.coordinate[0] + p->selection.coordinate[2] - p->maximum_output_width )/2.0;
- p->selection_maximum.coordinate[1] = (p->selection.coordinate[1] + p->selection.coordinate[3] - p->maximum_output_height)/2.0;
- p->selection_maximum.coordinate[2] = (p->selection.coordinate[0] + p->selection.coordinate[2] + p->maximum_output_width )/2.0;
- p->selection_maximum.coordinate[3] = (p->selection.coordinate[1] + p->selection.coordinate[3] + p->maximum_output_height)/2.0;
- if (p->selection_maximum.coordinate[0] < p->max_scanner_surface[0])
+ if (p->paper_orientation & 4) /* center? */
{
- p->selection_maximum.coordinate[0] = p->max_scanner_surface[0];
+ paper_orientation = p->paper_orientation;
}
-
- if (p->selection_maximum.coordinate[1] < p->max_scanner_surface[1])
+ else /* not in center */
{
- p->selection_maximum.coordinate[1] = p->max_scanner_surface[1];
- }
+ switch (p->rotation)
+ {
+ default:
+ case 0: /* 0 degree */
+ paper_orientation = p->paper_orientation & 3;
+ break;
- if (p->selection_maximum.coordinate[2] > p->max_scanner_surface[2])
- {
- p->selection_maximum.coordinate[2] = p->max_scanner_surface[2];
+ case 1: /* 90 degree */
+ paper_orientation = (1 - p->paper_orientation) & 3;
+ break;
+
+ case 2: /* 180 degree */
+ paper_orientation = (2 + p->paper_orientation) & 3;
+ break;
+
+ case 3: /* 270 degree */
+ paper_orientation = (3 - p->paper_orientation) & 3;
+ break;
+
+ case 4: /* 0 degree, x mirror */
+ paper_orientation = (1 - p->paper_orientation) & 3;
+ break;
+
+ case 5: /* 90 degree, x mirror */
+ paper_orientation = p->paper_orientation & 3;
+ break;
+
+ case 6: /* 180 degree, x mirror */
+ paper_orientation = (3 - p->paper_orientation) & 3;
+ break;
+
+ case 7: /* 270 degree, x mirror */
+ paper_orientation = (2 + p->paper_orientation) & 3;
+ break;
+ }
}
- if (p->selection_maximum.coordinate[3] > p->max_scanner_surface[3])
+ switch (paper_orientation)
{
- p->selection_maximum.coordinate[3] = p->max_scanner_surface[3];
+ default:
+ case 0: /* top left portrait */
+ case 8: /* top left landscape */
+ xxx = 0.0;
+ yyy = 0.0;
+ break;
+
+ case 1: /* top right portrait */
+ case 9: /* top right landscape */
+ xxx = 1.0;
+ yyy = 0.0;
+ break;
+
+ case 2: /* bottom right portrait */
+ case 10: /* bottom right landscape */
+ xxx = 1.0;
+ yyy = 1.0;
+ break;
+
+ case 3: /* bottom left portrait */
+ case 11: /* bottom left landscape */
+ xxx = 0.0;
+ yyy = 1.0;
+ break;
+
+ case 4: /* center portrait */
+ case 12: /* center landscape */
+ xxx = 0.5;
+ yyy = 0.5;
+ break;
}
- if ( (p->selection.coordinate[0] < p->selection_maximum.coordinate[0]) ||
- (p->selection.coordinate[1] < p->selection_maximum.coordinate[1]) ||
- (p->selection.coordinate[2] > p->selection_maximum.coordinate[2]) ||
- (p->selection.coordinate[3] > p->selection_maximum.coordinate[3]) )
+ p->selection_maximum.coordinate[p->index_xmin] = p->selection.coordinate[p->index_xmin] + xxx *(-p->selection.coordinate[p->index_xmin] + p->selection.coordinate[p->index_xmax]) - p->maximum_output_width * xxx - dxmin;
+ p->selection_maximum.coordinate[p->index_ymin] = p->selection.coordinate[p->index_ymin] + yyy *(-p->selection.coordinate[p->index_ymin] + p->selection.coordinate[p->index_ymax]) - p->maximum_output_height * yyy - dymin;
+ p->selection_maximum.coordinate[p->index_xmax] = p->selection.coordinate[p->index_xmin] + xxx *(-p->selection.coordinate[p->index_xmin] + p->selection.coordinate[p->index_xmax]) + p->maximum_output_width * (1.0 - xxx) + dxmax;
+ p->selection_maximum.coordinate[p->index_ymax] = p->selection.coordinate[p->index_ymin] + yyy *(-p->selection.coordinate[p->index_ymin] + p->selection.coordinate[p->index_ymax]) + p->maximum_output_height * (1.0 - yyy) + dymax;
+
+
+ if ( (p->selection.coordinate[p->index_xmin] < p->selection_maximum.coordinate[p->index_xmin]) ||
+ (p->selection.coordinate[p->index_ymin] < p->selection_maximum.coordinate[p->index_ymin]) ||
+ (p->selection.coordinate[p->index_xmax] > p->selection_maximum.coordinate[p->index_xmax]) ||
+ (p->selection.coordinate[p->index_ymax] > p->selection_maximum.coordinate[p->index_ymax]) )
{
- if (p->selection.coordinate[0] < p->selection_maximum.coordinate[0])
+ int selection_changed = FALSE;
+
+ if (p->selection.coordinate[p->index_xmin] < p->selection_maximum.coordinate[p->index_xmin])
{
- p->selection.coordinate[0] = p->selection_maximum.coordinate[0];
+ p->selection.coordinate[p->index_xmin] = p->selection_maximum.coordinate[p->index_xmin];
+ selection_changed = TRUE;
}
- if (p->selection.coordinate[1] < p->selection_maximum.coordinate[1])
+ if (p->selection.coordinate[p->index_ymin] < p->selection_maximum.coordinate[p->index_ymin])
{
- p->selection.coordinate[1] = p->selection_maximum.coordinate[1];
+ p->selection.coordinate[p->index_ymin] = p->selection_maximum.coordinate[p->index_ymin];
+ selection_changed = TRUE;
}
- if (p->selection.coordinate[2] > p->selection_maximum.coordinate[2])
+ if (p->selection.coordinate[p->index_xmax] > p->selection_maximum.coordinate[p->index_xmax])
{
- p->selection.coordinate[2] = p->selection_maximum.coordinate[2];
+ p->selection.coordinate[p->index_xmax] = p->selection_maximum.coordinate[p->index_xmax];
+ selection_changed = TRUE;
}
- if (p->selection.coordinate[3] > p->selection_maximum.coordinate[3])
+ if (p->selection.coordinate[p->index_ymax] > p->selection_maximum.coordinate[p->index_ymax])
{
- p->selection.coordinate[3] = p->selection_maximum.coordinate[3];
+ p->selection.coordinate[p->index_ymax] = p->selection_maximum.coordinate[p->index_ymax];
+ selection_changed = TRUE;
}
+
preview_draw_selection(p);
- preview_establish_selection(p);
+
+ if (selection_changed)
+ {
+ preview_establish_selection(p);
+ }
}
}
+
+ p->block_update_maximum_output_size_clipping=FALSE;
}
-#endif
+/* ---------------------------------------------------------------------------------------------------------------------- */
-void preview_update_maximum_output_size(Preview *p)
+void preview_set_maximum_output_size(Preview *p, float width, float height, int paper_orientation)
{
- if ( (p->maximum_output_width >= INF) || (p->maximum_output_height >= INF) )
+ /* witdh and height in device units */
+ DBG(DBG_proc, "preview_set_maximum_output_size\n");
+
+ p->maximum_output_width = width;
+ p->maximum_output_height = height;
+ p->paper_orientation = paper_orientation;
+
+ preview_update_maximum_output_size(p);
+ preview_draw_selection(p);
+}
+
+/* ---------------------------------------------------------------------------------------------------------------------- */
+#define AUTORAISE_ERROR 30
+void preview_autoraise_scanarea(Preview *p, int preview_x, int preview_y, float *autoselect_coord)
+{
+ int x, y;
+ int image_x, image_y;
+ int offset;
+ float average_color_r, average_color_g, average_color_b;
+ int count;
+ float error;
+ int top, bottom, left, right;
+ int top_ok, bottom_ok, left_ok, right_ok;
+ float xscale, yscale;
+
+ DBG(DBG_proc, "preview_autoraise_scanarea\n");
+
+ preview_transform_coordinate_window_to_image(p, preview_x, preview_y, &image_x, &image_y);
+
+ top_ok = FALSE;
+ bottom_ok = FALSE;
+ left_ok = FALSE;
+ right_ok = FALSE;
+
+ top = image_y - 5;
+ bottom = image_y + 5;
+ left = image_x - 5;
+ right = image_x + 5;
+
+
+ while (!(top_ok && bottom_ok && left_ok && right_ok))
{
- if (p->selection_maximum.active)
+ /* search top */
+ if (!top_ok)
{
- p->selection_maximum.active = FALSE;
+ top--;
}
- }
- else
- {
- p->previous_selection_maximum = p->selection_maximum;
- p->selection_maximum.active = TRUE;
- p->selection_maximum.coordinate[p->index_xmin] = p->selection.coordinate[p->index_xmin];
- p->selection_maximum.coordinate[p->index_ymin] = p->selection.coordinate[p->index_ymin];
- p->selection_maximum.coordinate[p->index_xmax] = p->selection.coordinate[p->index_xmin] + p->maximum_output_width;
- p->selection_maximum.coordinate[p->index_ymax] = p->selection.coordinate[p->index_ymin] + p->maximum_output_height;
+ top_ok = TRUE;
- if (p->selection_maximum.coordinate[p->index_xmax] > p->max_scanner_surface[p->index_xmax])
+ if (top <= 0)
{
- p->selection_maximum.coordinate[p->index_xmax] = p->max_scanner_surface[p->index_xmax];
+ top = 0;
+ }
+ else
+ {
+ average_color_r = average_color_g = average_color_b = 0;
+ count = 0;
+
+ for (x = left; x < right; x++)
+ {
+ offset = 3 * (top * p->image_width + x);
+ average_color_r += p->image_data_enh[offset + 0];
+ average_color_g += p->image_data_enh[offset + 1];
+ average_color_b += p->image_data_enh[offset + 2];
+ count++;
+ }
+
+ average_color_r /= count;
+ average_color_g /= count;
+ average_color_b /= count;
+
+ for (x = left; x < right; x++)
+ {
+ offset = 3 * (top * p->image_width + x);
+
+ error = fabs(p->image_data_enh[offset + 0] - average_color_r) +
+ fabs(p->image_data_enh[offset + 1] - average_color_g) +
+ fabs(p->image_data_enh[offset + 2] - average_color_b);
+
+ if (error > AUTORAISE_ERROR)
+ {
+ top_ok = FALSE;
+ break;
+ }
+ }
}
- if (p->selection_maximum.coordinate[p->index_ymax] > p->max_scanner_surface[p->index_ymax])
+ /* search bottom */
+ if (!bottom_ok)
{
- p->selection_maximum.coordinate[p->index_ymax] = p->max_scanner_surface[p->index_ymax];
+ bottom++;
}
- if ( (p->selection.coordinate[p->index_xmin] < p->selection_maximum.coordinate[p->index_xmin]) ||
- (p->selection.coordinate[p->index_ymin] < p->selection_maximum.coordinate[p->index_ymin]) ||
- (p->selection.coordinate[p->index_xmax] > p->selection_maximum.coordinate[p->index_xmax]) ||
- (p->selection.coordinate[p->index_ymax] > p->selection_maximum.coordinate[p->index_ymax]) )
+ bottom_ok = TRUE;
+
+ if (bottom >= p->image_height-1)
{
- if (p->selection.coordinate[p->index_xmax] > p->selection_maximum.coordinate[p->index_xmax])
+ bottom = p->image_height-1;
+ }
+ else
+ {
+ average_color_r = average_color_g = average_color_b = 0;
+ count = 0;
+
+ for (x = left; x < right; x++)
{
- p->selection.coordinate[p->index_xmax] = p->selection_maximum.coordinate[p->index_xmax];
+ offset = 3 * (bottom * p->image_width + x);
+ average_color_r += p->image_data_enh[offset + 0];
+ average_color_g += p->image_data_enh[offset + 1];
+ average_color_b += p->image_data_enh[offset + 2];
+ count++;
}
- if (p->selection.coordinate[p->index_ymax] > p->selection_maximum.coordinate[p->index_ymax])
+ average_color_r /= count;
+ average_color_g /= count;
+ average_color_b /= count;
+
+ for (x = left; x < right; x++)
{
- p->selection.coordinate[p->index_ymax] = p->selection_maximum.coordinate[p->index_ymax];
+ offset = 3 * (bottom * p->image_width + x);
+
+ error = fabs(p->image_data_enh[offset + 0] - average_color_r) +
+ fabs(p->image_data_enh[offset + 1] - average_color_g) +
+ fabs(p->image_data_enh[offset + 2] - average_color_b);
+
+ if (error > AUTORAISE_ERROR)
+ {
+ bottom_ok = FALSE;
+ break;
+ }
+ }
+ }
+
+ /* search left */
+ if (!left_ok)
+ {
+ left--;
+ }
+
+ left_ok = TRUE;
+
+ if (left <= 0)
+ {
+ left = 0;
+ }
+ else
+ {
+ average_color_r = average_color_g = average_color_b = 0;
+ count = 0;
+
+ for (y = top; y < bottom; y++)
+ {
+ offset = 3 * (left + y * p->image_width);
+ average_color_r += p->image_data_enh[offset + 0];
+ average_color_g += p->image_data_enh[offset + 1];
+ average_color_b += p->image_data_enh[offset + 2];
+ count++;
+ }
+
+ average_color_r /= count;
+ average_color_g /= count;
+ average_color_b /= count;
+
+ for (y = top; y < bottom; y++)
+ {
+ offset = 3 * (left + y * p->image_width);
+
+ error = fabs(p->image_data_enh[offset + 0] - average_color_r) +
+ fabs(p->image_data_enh[offset + 1] - average_color_g) +
+ fabs(p->image_data_enh[offset + 2] - average_color_b);
+
+ if (error > AUTORAISE_ERROR)
+ {
+ left_ok = FALSE;
+ break;
+ }
+ }
+ }
+
+ /* search right */
+ if (!right_ok)
+ {
+ right++;
+ }
+
+ right_ok = TRUE;
+
+ if (right >= p->image_width-1)
+ {
+ right = p->image_width-1;
+ }
+ else
+ {
+ average_color_r = average_color_g = average_color_b = 0;
+ count = 0;
+
+ for (y = top; y < bottom; y++)
+ {
+ offset = 3 * (right + y * p->image_width);
+ average_color_r += p->image_data_enh[offset + 0];
+ average_color_g += p->image_data_enh[offset + 1];
+ average_color_b += p->image_data_enh[offset + 2];
+ count++;
+ }
+
+ average_color_r /= count;
+ average_color_g /= count;
+ average_color_b /= count;
+
+ for (y = top; y < bottom; y++)
+ {
+ offset = 3 * (right + y * p->image_width);
+
+ error = fabs(p->image_data_enh[offset + 0] - average_color_r) +
+ fabs(p->image_data_enh[offset + 1] - average_color_g) +
+ fabs(p->image_data_enh[offset + 2] - average_color_b);
+
+ if (error > AUTORAISE_ERROR)
+ {
+ right_ok = FALSE;
+ break;
+ }
}
- preview_draw_selection(p);
- preview_establish_selection(p);
}
}
-}
-/* ---------------------------------------------------------------------------------------------------------------------- */
-void preview_set_maximum_output_size(Preview *p, float width, float height)
-{
- /* witdh and height in device units */
- DBG(DBG_proc, "preview_set_maximum_output_size\n");
- p->maximum_output_width = width;
- p->maximum_output_height = height;
+ preview_get_scale_device_to_image(p, &xscale, &yscale);
- preview_update_maximum_output_size(p);
- preview_draw_selection(p);
+ if (((p->rotation & 3) == 0) || ((p->rotation & 3) == 2)) /* 0 or 180 degree */
+ {
+ *(autoselect_coord+0) = p->image_surface[0] + left / xscale;
+ *(autoselect_coord+2) = p->image_surface[0] + right / xscale;
+ *(autoselect_coord+1) = p->image_surface[1] + top / yscale;
+ *(autoselect_coord+3) = p->image_surface[1] + bottom / yscale;
+ }
+ else /* 90 or 270 degree */
+ {
+ *(autoselect_coord+1) = p->image_surface[1] + left / xscale;
+ *(autoselect_coord+3) = p->image_surface[1] + right / xscale;
+ *(autoselect_coord+0) = p->image_surface[0] + top / yscale;
+ *(autoselect_coord+2) = p->image_surface[0] + bottom / yscale;
+ }
}
/* ---------------------------------------------------------------------------------------------------------------------- */
@@ -5932,6 +7339,15 @@ void preview_autoselect_scanarea(Preview *p, float *autoselect_coord)
}
}
+ if ( (top >= bottom) || (right <= left) ) /* empty selection: use complete image */
+ {
+ DBG(DBG_info, "autoselect_scanarea: empty selection: using complete area\n");
+ top = 0;
+ bottom = p->image_height -1;
+ left = 0;
+ right = p->image_width -1;
+ }
+
preview_get_scale_device_to_image(p, &xscale, &yscale);
if (((p->rotation & 3) == 0) || ((p->rotation & 3) == 2)) /* 0 or 180 degree */
diff --git a/src/xsane-preview.h b/src/xsane-preview.h
index ba1321c..d57870e 100644
--- a/src/xsane-preview.h
+++ b/src/xsane-preview.h
@@ -3,7 +3,7 @@
xsane-preview.h
Oliver Rauch <Oliver.Rauch@rauch-domain.de>
- Copyright (C) 1998-2002 Oliver Rauch
+ Copyright (C) 1998-2005 Oliver Rauch
This file is part of the XSANE package.
This program is free software; you can redistribute it and/or modify
@@ -29,6 +29,7 @@
#include <sys/types.h>
#include <sane/sane.h>
+#include "xsane-batch-scan.h"
#define SELECTION_RANGE_IN 4
#define SELECTION_RANGE_OUT 8
@@ -41,16 +42,20 @@ enum
MODE_NORMAL,
MODE_PIPETTE_WHITE,
MODE_PIPETTE_GRAY,
- MODE_PIPETTE_BLACK
+ MODE_PIPETTE_BLACK,
+ MODE_AUTORAISE_SCANAREA,
+ MODE_ZOOM_IN
};
/* ------------------------------------------------------------------------------------------------------ */
+#if 0
typedef struct Batch_selection
{
float coordinate[4]; /* batch selection coordinate (device coord) */
struct Batch_selection *next;
} Batch_selection;
+#endif
typedef struct
{
@@ -85,6 +90,8 @@ typedef struct
float maximum_output_width; /* maximum output width (photocopy) */
float maximum_output_height; /* maximum output height (photocopy) */
+ int paper_orientation; /* orientation of the paper (photocopy) */
+ int block_update_maximum_output_size_clipping; /* do not clip maximum output size */
int index_xmin, index_xmax, index_ymin, index_ymax; /* index numbers in dependance of p->rotation */
@@ -111,6 +118,8 @@ typedef struct
u_char *preview_row;
int scanning;
+ int read_offset_16;
+ char last_offset_16_byte;
int scan_incomplete;
int invalid;
int preview_colors;
@@ -135,6 +144,7 @@ typedef struct
int selection_ypos;
int selection_xedge;
int selection_yedge;
+ float ratio;
Tselection selection; /* selected area to scan */
Tselection previous_selection; /* previous ... */
@@ -143,7 +153,9 @@ typedef struct
int show_selection;
+#if 0
Batch_selection *batch_selection;
+#endif
GtkWidget *top; /* top-level widget */
GtkWidget *unit_label;
@@ -153,23 +165,30 @@ typedef struct
GtkWidget *window; /* the preview window */
GtkWidget *start; /* the start button */
GtkWidget *cancel; /* the cancel button */
+ GtkWidget *zoom; /* the zoom */
- GtkWidget *button_box; /* hbox for the following buttons */
+ GtkWidget *menu_box; /* the bottom menu box */
+ GtkWidget *button_box; /* the bottom button box */
+ GtkWidget *add_batch; /* add batch button */
GtkWidget *pipette_white; /* pipette white button */
GtkWidget *pipette_gray; /* pipette gray button */
GtkWidget *pipette_black; /* pipette black button */
GtkWidget *zoom_not; /* zoom not button */
GtkWidget *zoom_out; /* zoom out button */
GtkWidget *zoom_in; /* zoom in button */
+ GtkWidget *zoom_area; /* zoom area button */
GtkWidget *zoom_undo; /* zoom undo button */
GtkWidget *full_area; /* select full scanarea */
+ GtkWidget *autoraise; /* autoraise scanarea */
GtkWidget *autoselect; /* autoselect scanarea */
GtkWidget *preset_area_option_menu; /* menu for selection of preview area */
GtkWidget *rotation_option_menu; /* menu for selection of rotation */
+ GtkWidget *ratio_option_menu; /* menu for selection of ratio */
GtkWidget *scanning_pixmap; /* pixmap that shows preview is in scanning progress */
GtkWidget *valid_pixmap; /* pixmap that shows preview is valid */
GtkWidget *invalid_pixmap; /* pixmap that shows preview is invalid */
GtkWidget *incomplete_pixmap; /* pixmap that shows preview is incomplete */
+ GtkWidget *rgb_label; /* label to show RGB values */
}
Preview;
@@ -193,9 +212,10 @@ extern void preview_calculate_raw_histogram(Preview *p, SANE_Int *count_raw, SAN
extern void preview_calculate_enh_histogram(Preview *p, SANE_Int *count, SANE_Int *count_red, SANE_Int *count_green, SANE_Int *count_blue);
extern void preview_area_resize(Preview *p); /* redraw preview rulers */
-extern void preview_set_maximum_output_size(Preview *p, float width, float height); /* set maximum outut size */
+extern void preview_set_maximum_output_size(Preview *p, float width, float height, int paper_orientation); /* set maximum outut size */
extern void preview_select_full_preview_area(Preview *p);
extern void preview_display_valid(Preview *p);
+extern void preview_create_batch_icon(Preview *p, Batch_Scan_Parameters *parameters);
/* ------------------------------------------------------------------------------------------------------ */
diff --git a/src/xsane-rc-io.c b/src/xsane-rc-io.c
index 9fe991c..4a0af86 100644
--- a/src/xsane-rc-io.c
+++ b/src/xsane-rc-io.c
@@ -3,7 +3,7 @@
xsane-rc-io.c
Oliver Rauch <Oliver.Rauch@rauch-domain.de>
- Copyright (C) 1998-2002 Oliver Rauch
+ Copyright (C) 1998-2005 Oliver Rauch
This file is part of the XSANE package.
This program is free software; you can redistribute it and/or modify
@@ -24,13 +24,8 @@
#include "xsane.h"
-#include <errno.h>
-#include <stdlib.h>
-#include <string.h>
-#include <sys/types.h>
#include <sane/sane.h>
#include <ctype.h>
-#include <unistd.h>
#ifdef HAVE_LIBC_H
# include <libc.h> /* NeXTStep/OpenStep */
@@ -722,12 +717,18 @@ void xsane_rc_io_w_string(Wire *w, SANE_String *s)
}
else
{
+#if 0
xsane_rc_io_w_space(w, 5);
*w->buffer.curr++ = '(';
*w->buffer.curr++ = 'n';
*w->buffer.curr++ = 'i';
*w->buffer.curr++ = 'l';
*w->buffer.curr++ = ')';
+#else
+ xsane_rc_io_w_space(w, 2);
+ *w->buffer.curr++ = '"';
+ *w->buffer.curr++ = '"';
+#endif
}
xsane_rc_io_w_space(w, 1);
@@ -804,12 +805,14 @@ void xsane_rc_io_w_string(Wire *w, SANE_String *s)
if (*s == 0)
{
/* Malloc failed, so return an error. */
+ DBG(DBG_wire, "xsane_rc_io_w_string: out of memory\n");
w->status = ENOMEM;
return;
}
}
else /* string does not begin with a " */
{
+ DBG(DBG_wire, "xsane_rc_io_w_string: not a string\n");
w->status = EINVAL;
*s = 0; /* make sure pointer does not point to an invalid address */
return;
diff --git a/src/xsane-rc-io.h b/src/xsane-rc-io.h
index 14c2443..dab2555 100644
--- a/src/xsane-rc-io.h
+++ b/src/xsane-rc-io.h
@@ -3,7 +3,7 @@
xsane-rc-io.h
Oliver Rauch <Oliver.Rauch@rauch-domain.de>
- Copyright (C) 1998-2002 Oliver Rauch
+ Copyright (C) 1998-2005 Oliver Rauch
This file is part of the XSANE package.
This program is free software; you can redistribute it and/or modify
diff --git a/src/xsane-save.c b/src/xsane-save.c
index 3c78354..e9020e0 100644
--- a/src/xsane-save.c
+++ b/src/xsane-save.c
@@ -3,7 +3,7 @@
xsane-save.c
Oliver Rauch <Oliver.Rauch@rauch-domain.de>
- Copyright (C) 1998-2002 Oliver Rauch
+ Copyright (C) 1998-2005 Oliver Rauch
This file is part of the XSANE package.
This program is free software; you can redistribute it and/or modify
@@ -23,13 +23,18 @@
/* ---------------------------------------------------------------------------------------------------------------------- */
#include "xsane.h"
-#include "xsane-preview.h"
#include "xsane-back-gtk.h"
#include "xsane-front-gtk.h"
+#include <sys/wait.h>
-#include <sys/socket.h>
-#include <netinet/in.h>
-#include <netdb.h>
+/* the following test is always false */
+#ifdef _native_WIN32
+# include <winsock.h>
+#else
+# include <sys/socket.h>
+# include <netinet/in.h>
+# include <netdb.h>
+#endif
#ifdef HAVE_LIBJPEG
#include <jpeglib.h>
@@ -48,18 +53,25 @@
#endif
#ifdef HAVE_MMAP
-#include <unistd.h>
#include <sys/mman.h>
#endif
+#ifdef HAVE_OS2_H
+#include <process.h>
+#endif
+
/* ---------------------------------------------------------------------------------------------------------------------- */
-#ifdef HAVE_LIBGIMP_GIMP_H
+#ifdef HAVE_ANY_GIMP
#include <libgimp/gimp.h>
static void xsane_gimp_query(void);
-static void xsane_gimp_run(char *name, int nparams, GimpParam * param, int *nreturn_vals, GimpParam ** return_vals);
+#ifdef HAVE_GIMP_2
+static void xsane_gimp_run(const gchar *name, gint nparams, const GimpParam *param, gint *nreturn_vals, GimpParam **return_vals);
+#else
+static void xsane_gimp_run(char *name, int nparams, GimpParam *param, int *nreturn_vals, GimpParam **return_vals);
+#endif
GimpPlugInInfo PLUG_IN_INFO =
{
@@ -75,7 +87,7 @@ char *buf);
static int xsane_encode_devname(const char *devname, int n, char *buf);
void null_print_func(gchar *msg);
-#endif /* HAVE_LIBGIMP_GIMP_H */
+#endif /* HAVE_ANY_GIMP */
/* ---------------------------------------------------------------------------------------------------------------------- */
/* why this routine ?
@@ -237,6 +249,68 @@ void xsane_convert_text_to_filename(char **text)
/* ---------------------------------------------------------------------------------------------------------------------- */
+int xsane_get_filesize(char *filename)
+{
+ FILE *infile;
+ int pos;
+ int size;
+
+ infile = fopen(filename, "rb"); /* read binary (b for win32) */
+ if (infile == NULL)
+ {
+ return 0;
+ }
+
+ pos = ftell(infile);
+ fseek(infile, 0, SEEK_END); /* get size */
+ size = ftell(infile);
+ fseek(infile, pos, SEEK_SET); /* go to previous position */
+
+ fclose(infile);
+
+ return size;
+}
+
+/* ---------------------------------------------------------------------------------------------------------------------- */
+
+void xsane_ensure_counter_in_filename(char **filename, int counter_len)
+{
+ char *position_point = NULL;
+ char *position;
+ int counter = 1;
+
+ DBG(DBG_proc, "xsane_ensure_counter_in_filename\n");
+
+ if (!counter_len)
+ {
+ counter_len = 1;
+ }
+
+ position_point = strrchr(*filename, '.');
+
+ if (!position_point) /* nothing usable ? */
+ {
+ position_point = *filename + strlen(*filename); /* position_point - 1 is last character */
+ }
+
+ if (position_point)
+ {
+ position = position_point-1;
+ if ( (position < *filename) || (*position < '0') || (*position >'9') ) /* we have no counter */
+ {
+ char buf[PATH_MAX];
+ int len;
+
+ len = position_point - (*filename); /* length until "." or end of string */
+ strncpy(buf, *filename, len);
+ snprintf(buf+len, sizeof(buf)-len, "-%0*d%s", counter_len, counter, position_point);
+ *filename = strdup(buf);
+ }
+ }
+}
+
+/* ---------------------------------------------------------------------------------------------------------------------- */
+
void xsane_update_counter_in_filename(char **filename, int skip, int step, int min_counter_len)
{
FILE *testfile;
@@ -249,12 +323,14 @@ void xsane_update_counter_in_filename(char **filename, int skip, int step, int m
DBG(DBG_proc, "xsane_update_counter_in_filename\n");
- while (1) /* may be we have to skip existing files */
+ if ( (!step) && (!min_counter_len) )
{
- if (!xsane.filetype) /* no filetype: serach "." */
- {
- position_point = strrchr(*filename, '.');
- }
+ return; /* do not touch counter */
+ }
+
+ while (1) /* loop because we may have to skip existing files */
+ {
+ position_point = strrchr(*filename, '.');
if (!position_point) /* nothing usable ? */
{
@@ -278,7 +354,7 @@ void xsane_update_counter_in_filename(char **filename, int skip, int step, int m
if (counter_len) /* we have a counter */
{
sscanf(position_counter, "%d", &counter);
- counter += step; /* update counter */
+ counter = counter + step; /* update counter */
if (counter < 0)
{
@@ -303,9 +379,9 @@ void xsane_update_counter_in_filename(char **filename, int skip, int step, int m
if (skip) /* test if filename already used */
{
- if (xsane.filetype) /* add filetype to filename */
+ if (preferences.filetype) /* add filetype to filename */
{
- snprintf(buf, sizeof(buf), "%s%s", *filename, xsane.filetype);
+ snprintf(buf, sizeof(buf), "%s%s", *filename, preferences.filetype);
testfile = fopen(buf, "rb"); /* read binary (b for win32) */
}
else /* filetype in filename */
@@ -337,12 +413,12 @@ void xsane_update_counter_in_filename(char **filename, int skip, int step, int m
/* ---------------------------------------------------------------------------------------------------------------------- */
-void xsane_read_pnm_header(FILE *infile, Image_info *image_info)
+void xsane_read_pnm_header(FILE *file, Image_info *image_info)
{
int max_val, filetype_nr;
char buf[256];
- fgets(buf, sizeof(buf)-1, infile);
+ fgets(buf, sizeof(buf)-1, file);
DBG(DBG_info, "filetype header :%s", buf);
if (buf[0] == 'P')
@@ -351,28 +427,73 @@ void xsane_read_pnm_header(FILE *infile, Image_info *image_info)
image_info->resolution_x = 72.0;
image_info->resolution_y = 72.0;
+ image_info->reduce_to_lineart = FALSE;
while (strcmp(buf, "# XSANE data follows\n"))
{
- fgets(buf, sizeof(buf)-1, infile);
+ fgets(buf, sizeof(buf)-1, file);
- if (!strncmp(buf, "# resolution_x =", 17))
+ if (!strncmp(buf, "# resolution_x =", 20))
+ {
+ sscanf(buf+20, "%lf", &image_info->resolution_x);
+ }
+ else if (!strncmp(buf, "# resolution_y =", 20))
+ {
+ sscanf(buf+20, "%lf", &image_info->resolution_y);
+ }
+ else if (!strncmp(buf, "# threshold =", 20))
+ {
+ sscanf(buf+20, "%lf", &image_info->threshold);
+ }
+ else if (!strncmp(buf, "# gamma =", 20))
+ {
+ sscanf(buf+20, "%lf", &image_info->gamma);
+ }
+ else if (!strncmp(buf, "# gamma IRGB =", 20))
+ {
+ sscanf(buf+20, "%lf %lf %lf %lf",
+ &image_info->gamma,
+ &image_info->gamma_red,
+ &image_info->gamma_green,
+ &image_info->gamma_blue);
+ }
+ else if (!strncmp(buf, "# brightness =", 20))
+ {
+ sscanf(buf+20, "%lf", &image_info->brightness);
+ }
+ else if (!strncmp(buf, "# brightness IRGB =", 20))
+ {
+ sscanf(buf+20, "%lf %lf %lf %lf",
+ &image_info->brightness,
+ &image_info->brightness_red,
+ &image_info->brightness_green,
+ &image_info->brightness_blue);
+ }
+ else if (!strncmp(buf, "# contrast =", 20))
+ {
+ sscanf(buf+20, "%lf", &image_info->contrast);
+ }
+ else if (!strncmp(buf, "# contrast IRGB =", 20))
{
- sscanf(buf+17, "%lf", &image_info->resolution_x);
+ sscanf(buf+20, "%lf %lf %lf %lf",
+ &image_info->contrast,
+ &image_info->contrast_red,
+ &image_info->contrast_green,
+ &image_info->contrast_blue);
}
- else if (!strncmp(buf, "# resolution_y =", 17))
+ else if (!strncmp(buf, "# reduce to lineart", 20))
{
- sscanf(buf+17, "%lf", &image_info->resolution_y);
+ image_info->reduce_to_lineart = TRUE;
}
}
- fscanf(infile, "%d %d", &image_info->image_width, &image_info->image_height);
+ fscanf(file, "%d %d", &image_info->image_width, &image_info->image_height);
image_info->depth = 1;
if (filetype_nr != 4) /* P4 = lineart */
{
- fscanf(infile, "%d", &max_val);
+ fscanf(file, "%d", &max_val);
if (max_val == 255)
{
@@ -384,7 +505,7 @@ void xsane_read_pnm_header(FILE *infile, Image_info *image_info)
}
}
- fgetc(infile); /* read exactly one newline character */
+ fgetc(file); /* read exactly one newline character */
image_info->colors = 1;
@@ -397,8 +518,8 @@ void xsane_read_pnm_header(FILE *infile, Image_info *image_info)
#ifdef SUPPORT_RGBA
else if (buf[0] == 'S') /* RGBA format */
{
- fscanf(infile, "%d %d\n%d", &image_info->image_width, &image_info->image_height, &max_val);
- fgetc(infile); /* read exactly one newline character */
+ fscanf(file, "%d %d\n%d", &image_info->image_width, &image_info->image_height, &max_val);
+ fgetc(file); /* read exactly one newline character */
image_info->depth = 1;
@@ -422,133 +543,239 @@ void xsane_read_pnm_header(FILE *infile, Image_info *image_info)
/* ---------------------------------------------------------------------------------------------------------------------- */
-void xsane_write_pnm_header(FILE *outfile, Image_info *image_info)
+void xsane_write_pnm_header(FILE *file, Image_info *image_info, int save_pnm16_as_ascii)
{
- fflush(outfile);
- rewind(outfile);
+ int maxval;
+ int magic;
+ fflush(file);
+ rewind(file);
- if (image_info->colors == 1)
+ if (image_info->depth > 8)
{
- switch (image_info->depth)
- {
- case 1: /* 1 bit lineart mode, write pbm header */
- fprintf(outfile, "P4\n"
- "# XSane settings:\n"
- "# resolution_x = %6.1f\n"
- "# resolution_y = %6.1f\n"
- "# threshold = %4.1f\n"
- "# XSANE data follows\n"
- "%05d %05d\n",
- image_info->resolution_x,
- image_info->resolution_y,
- image_info->threshold,
- image_info->image_width, image_info->image_height);
- break;
+ maxval = 65535;
- case 8: /* 8 bit grayscale mode, write pgm header */
- fprintf(outfile, "P5\n"
- "# XSane settings:\n"
- "# resolution_x = %6.1f\n"
- "# resolution_y = %6.1f\n"
- "# gamma = %3.2f\n"
- "# brightness = %4.1f\n"
- "# contrast = %4.1f\n"
- "# XSANE data follows\n"
- "%05d %05d\n"
- "255\n",
- image_info->resolution_x,
- image_info->resolution_y,
- image_info->gamma,
- image_info->brightness,
- image_info->contrast,
- image_info->image_width, image_info->image_height);
- break;
-
- default: /* grayscale mode but not 1 or 8 bit, write as raw data because this is not defined in pnm */
- fprintf(outfile, "P5\n"
- "# This file is in a not public defined data format.\n"
- "# It is a 16 bit gray binary format.\n"
- "# Some programs can read this as pnm/pgm format.\n"
- "# XSane settings:\n"
- "# resolution_x = %6.1f\n"
- "# resolution_y = %6.1f\n"
- "# gamma = %3.2f\n"
- "# brightness = %4.1f\n"
- "# contrast = %4.1f\n"
- "# XSANE data follows\n"
- "%05d %05d\n"
- "65535\n",
- image_info->resolution_x,
- image_info->resolution_y,
- image_info->gamma,
- image_info->brightness,
- image_info->contrast,
- image_info->image_width, image_info->image_height);
- break;
+ if (save_pnm16_as_ascii)
+ {
+ magic = 2; /* thats the magic number for grayscale ascii, 3 = color ascii */
+ }
+ else /* save pnm as binary */
+ {
+ magic = 5; /* that is the magic number for grayscake binary, 6 = color binary */
}
}
- else if (image_info->colors == 3)
+ else
{
- switch (image_info->depth)
- {
- case 8: /* color 8 bit mode, write ppm header */
- fprintf(outfile, "P6\n"
- "# XSane settings:\n"
- "# resolution_x = %6.1f\n"
- "# resolution_y = %6.1f\n"
- "# gamma IRGB = %3.2f %3.2f %3.2f %3.2f\n"
- "# brightness IRGB = %4.1f %4.1f %4.1f %4.1f\n"
- "# contrast IRGB = %4.1f %4.1f %4.1f %4.1f\n"
- "# XSANE data follows\n"
- "%05d %05d\n255\n",
- image_info->resolution_x,
- image_info->resolution_y,
- image_info->gamma, image_info->gamma_red, image_info->gamma_green, image_info->gamma_blue,
- image_info->brightness, image_info->brightness_red, image_info->brightness_green, image_info->brightness_blue,
- image_info->contrast, image_info->contrast_red, image_info->contrast_green, image_info->contrast_blue,
- image_info->image_width, image_info->image_height);
- break;
+ maxval = 255;
+ magic = 5; /* 8 bit images are always saved in binary mode */
+ }
- default: /* color, but not 8 bit mode, write as raw data because this is not defined in pnm */
- fprintf(outfile, "P6\n"
- "# This file is in a not public defined data format.\n"
- "# It is a 16 bit RGB binary format.\n"
- "# Some programs can read this as pnm/ppm format.\n"
- "# File created by XSane.\n"
- "# XSane settings:\n"
- "# resolution_x = %6.1f\n"
- "# resolution_y = %6.1f\n"
- "# gamma IRGB = %3.2f %3.2f %3.2f %3.2f\n"
- "# brightness IRGB = %4.1f %4.1f %4.1f %4.1f\n"
- "# contrast IRGB = %4.1f %4.1f %4.1f %4.1f\n"
- "# XSANE data follows\n"
- "%05d %05d\n"
- "65535\n",
- image_info->resolution_x,
- image_info->resolution_y,
- image_info->gamma, image_info->gamma_red, image_info->gamma_green, image_info->gamma_blue,
- image_info->brightness, image_info->brightness_red, image_info->brightness_green, image_info->brightness_blue,
- image_info->contrast, image_info->contrast_red, image_info->contrast_green, image_info->contrast_blue,
- image_info->image_width, image_info->image_height);
- break;
+
+ if (image_info->colors == 1)
+ {
+ if (image_info->depth == 1)
+ {
+ /* do not touch the texts and length here, the reading routine needs to know the exact texts */
+ fprintf(file, "P4\n"
+ "# XSane settings:\n"
+ "# resolution_x = %6.1f\n"
+ "# resolution_y = %6.1f\n"
+ "# threshold = %4.1f\n"
+ "# XSANE data follows\n"
+ "%05d %05d\n",
+ image_info->resolution_x,
+ image_info->resolution_y,
+ image_info->threshold,
+ image_info->image_width, image_info->image_height);
+ }
+ else if (image_info->reduce_to_lineart)
+ {
+ /* do not touch the texts and length here, the reading routine needs to know the exact texts */
+ fprintf(file, "P%d\n"
+ "# XSane settings:\n"
+ "# resolution_x = %6.1f\n"
+ "# resolution_y = %6.1f\n"
+ "# threshold = %4.1f\n"
+ "# reduce to lineart\n"
+ "# XSANE data follows\n"
+ "%05d %05d\n"
+ "%d\n",
+ magic, /* P5 for binary, P2 for ascii */
+ image_info->resolution_x,
+ image_info->resolution_y,
+ image_info->threshold,
+ image_info->image_width, image_info->image_height,
+ maxval);
+ }
+ else
+ {
+ fprintf(file, "P%d\n"
+ "# XSane settings:\n"
+ "# resolution_x = %6.1f\n"
+ "# resolution_y = %6.1f\n"
+ "# gamma = %3.2f\n"
+ "# brightness = %4.1f\n"
+ "# contrast = %4.1f\n"
+ "# XSANE data follows\n"
+ "%05d %05d\n"
+ "%d\n",
+ magic, /* P5 for binary, P2 for ascii */
+ image_info->resolution_x,
+ image_info->resolution_y,
+ image_info->gamma,
+ image_info->brightness,
+ image_info->contrast,
+ image_info->image_width, image_info->image_height,
+ maxval);
}
}
+ else if (image_info->colors == 3)
+ {
+ fprintf(file, "P%d\n"
+ "# XSane settings:\n"
+ "# resolution_x = %6.1f\n"
+ "# resolution_y = %6.1f\n"
+ "# gamma IRGB = %3.2f %3.2f %3.2f %3.2f\n"
+ "# brightness IRGB = %4.1f %4.1f %4.1f %4.1f\n"
+ "# contrast IRGB = %4.1f %4.1f %4.1f %4.1f\n"
+ "# XSANE data follows\n"
+ "%05d %05d\n" \
+ "%d\n",
+ magic+1, /* P6 for binary, P3 for ascii */
+ image_info->resolution_x,
+ image_info->resolution_y,
+ image_info->gamma, image_info->gamma_red, image_info->gamma_green, image_info->gamma_blue,
+ image_info->brightness, image_info->brightness_red, image_info->brightness_green, image_info->brightness_blue,
+ image_info->contrast, image_info->contrast_red, image_info->contrast_green, image_info->contrast_blue,
+ image_info->image_width, image_info->image_height,
+ maxval);
+ }
#ifdef SUPPORT_RGBA
else if (image_info->colors == 4)
{
- switch (image_info->depth)
+ fprintf(file, "SANE_RGBA\n" \
+ "%d %d\n" \
+ "%d\n",
+ image_info->image_width, image_info->image_height, maxval);
+ }
+#endif
+}
+
+/* ---------------------------------------------------------------------------------------------------------------------- */
+
+int xsane_copy_file(FILE *outfile, FILE *infile, GtkProgressBar *progress_bar, int *cancel_save)
+{
+ int size;
+ int bytes;
+ int bytes_sum = 0;
+ char buf[65536];
+
+ DBG(DBG_proc, "copying file\n");
+
+ fseek(infile, 0, SEEK_END);
+ size = ftell(infile);
+ fseek(infile, 0, SEEK_SET);
+
+ gtk_progress_bar_update(GTK_PROGRESS_BAR(progress_bar), 0.0);
+
+ while (gtk_events_pending())
+ {
+ gtk_main_iteration();
+ }
+
+ while (!feof(infile))
+ {
+ bytes = fread(buf, 1, sizeof(buf), infile);
+ if (bytes > 0)
{
- case 8: /* 8 bit RGBA mode */
- fprintf(outfile, "SANE_RGBA\n%d %d\n255\n", image_info->image_width, image_info->image_height);
- break;
+ fwrite(buf, 1, bytes, outfile);
+ bytes_sum += bytes;
+ }
- default: /* 16 bit RGBA mode */
- fprintf(outfile, "SANE_RGBA\n%d %d\n65535\n", image_info->image_width, image_info->image_height);
- break;
+ gtk_progress_bar_update(progress_bar, (float) bytes_sum / size); /* update progress bar */
+
+ while (gtk_events_pending())
+ {
+ gtk_main_iteration();
+ }
+
+ if (ferror(outfile))
+ {
+ char buf[255];
+
+ snprintf(buf, sizeof(buf), "%s %s", ERR_DURING_SAVE, strerror(errno));
+ DBG(DBG_error, "%s\n", buf);
+ xsane_back_gtk_decision(ERR_HEADER_ERROR, (gchar **) error_xpm, buf, BUTTON_OK, NULL, TRUE /* wait */);
+ *cancel_save = 1;
+ break;
+ }
+
+ if (*cancel_save)
+ {
+ break;
}
}
-#endif
+
+ fflush(outfile);
+
+ if (size != bytes_sum)
+ {
+ DBG(DBG_info, "copy errro, not complete, %d bytes of %d bytes copied\n", bytes_sum, size);
+ *cancel_save = 1;
+ return (*cancel_save);
+ }
+
+ DBG(DBG_info, "copy complete, %d bytes copied\n", bytes_sum);
+
+ return (*cancel_save);
+}
+
+/* ---------------------------------------------------------------------------------------------------------------------- */
+
+int xsane_copy_file_by_name(char *output_filename, char *input_filename, GtkProgressBar *progress_bar, int *cancel_save)
+{
+ FILE *infile;
+ FILE *outfile;
+
+ DBG(DBG_proc, "copying file %s to %s\n", input_filename, output_filename);
+
+ outfile = fopen(output_filename, "wb"); /* b = binary mode for win32 */
+
+ if (outfile == 0)
+ {
+ char buf[255];
+
+ snprintf(buf, sizeof(buf), "%s `%s': %s", ERR_OPEN_FAILED, output_filename, strerror(errno));
+ xsane_back_gtk_error(buf, TRUE);
+ return -2;
+ }
+
+ infile = fopen(input_filename, "rb"); /* read binary (b for win32) */
+ if (infile == 0)
+ {
+ char buf[256];
+ snprintf(buf, sizeof(buf), "%s `%s': %s", ERR_OPEN_FAILED, input_filename, strerror(errno));
+ xsane_back_gtk_error(buf, TRUE);
+
+ fclose(outfile);
+ remove(output_filename); /* remove already created output file */
+ return -1;
+ }
+
+ xsane_copy_file(outfile, infile, progress_bar, cancel_save);
+
+ fclose(infile);
+ fclose(outfile);
+
+ gtk_progress_set_format_string(GTK_PROGRESS(progress_bar), "");
+ gtk_progress_bar_update(GTK_PROGRESS_BAR(progress_bar), 0.0);
+
+ while (gtk_events_pending())
+ {
+ gtk_main_iteration();
+ }
+
+ return (*cancel_save);
}
/* ---------------------------------------------------------------------------------------------------------------------- */
@@ -561,11 +788,8 @@ int xsane_save_grayscale_image_as_lineart(FILE *outfile, FILE *imagefile, Image_
*cancel_save = 0;
image_info->depth = 1;
-#if 0
- xsane.depth = 1; /* our new depth is 1 bit/pixel */
-#endif
- xsane_write_pnm_header(outfile, image_info);
+ xsane_write_pnm_header(outfile, image_info, 0);
for (y = 0; y < image_info->image_height; y++)
{
@@ -600,6 +824,18 @@ int xsane_save_grayscale_image_as_lineart(FILE *outfile, FILE *imagefile, Image_
packed = 0;
}
+ if (ferror(outfile))
+ {
+ char buf[255];
+
+ snprintf(buf, sizeof(buf), "%s %s", ERR_DURING_SAVE, strerror(errno));
+ DBG(DBG_error, "%s\n", buf);
+ xsane_back_gtk_decision(ERR_HEADER_ERROR, (gchar **) error_xpm, buf, BUTTON_OK, NULL, TRUE /* wait */);
+ *cancel_save = 1;
+ break;
+ }
+
+
gtk_progress_bar_update(progress_bar, (float) y / image_info->image_height); /* update progress bar */
while (gtk_events_pending()) /* give gtk the chance to display the changes */
{
@@ -619,6 +855,229 @@ int xsane_save_grayscale_image_as_lineart(FILE *outfile, FILE *imagefile, Image_
int xsane_save_scaled_image(FILE *outfile, FILE *imagefile, Image_info *image_info, float x_scale, float y_scale, GtkProgressBar *progress_bar, int *cancel_save)
{
+ int original_image_width = image_info->image_width;
+ int original_image_height = image_info->image_height;
+ int new_image_width = image_info->image_width * x_scale + 0.5;
+ int new_image_height = image_info->image_height * y_scale + 0.5;
+ unsigned char *original_line;
+ guint16 *original_line16 = NULL;
+ unsigned char *new_line;
+ float *pixel_val;
+ float *pixel_norm;
+ int bytespp = 1;
+ float x, y;
+ int c;
+ int oldy;
+ int x_new, y_new;
+ float x_go, y_go;
+ float factor, x_factor, y_factor;
+ guint16 color;
+ int read_line;
+
+ DBG(DBG_proc, "xsane_save_scaled_image\n");
+
+ *cancel_save = 0;
+
+ if (image_info->depth > 8)
+ {
+ bytespp = 2;
+ }
+
+ image_info->image_width = new_image_width;
+ image_info->image_height = new_image_height;
+ image_info->resolution_x *= x_scale;
+ image_info->resolution_y *= y_scale;
+
+ original_line = malloc(original_image_width * image_info->colors * bytespp);
+ if (!original_line)
+ {
+ DBG(DBG_error, "xsane_save_scaled_image: out of memory\n");
+ return -1;
+ }
+
+ new_line = malloc(new_image_width * image_info->colors * bytespp);
+ if (!new_line)
+ {
+ free(original_line);
+ DBG(DBG_error, "xsane_save_scaled_image: out of memory\n");
+ return -1;
+ }
+
+ pixel_val = malloc(new_image_width * image_info->colors * sizeof(float));
+ if (!pixel_val)
+ {
+ free(original_line);
+ free(new_line);
+ DBG(DBG_error, "xsane_save_scaled_image: out of memory\n");
+ return -1;
+ }
+
+ pixel_norm = malloc(new_image_width * image_info->colors * sizeof(float));
+ if (!pixel_norm)
+ {
+ free(original_line);
+ free(new_line);
+ free(pixel_val);
+ DBG(DBG_error, "xsane_save_scaled_image: out of memory\n");
+ return -1;
+ }
+
+ xsane_write_pnm_header(outfile, image_info, 0);
+
+ read_line = TRUE;
+
+ memset(pixel_val, 0, new_image_width * image_info->colors * sizeof(float));
+ memset(pixel_norm, 0, new_image_width * image_info->colors * sizeof(float));
+
+ y_new = 0;
+ y_go = 1.0 / y_scale;
+ y_factor = 1.0;
+ y = 0.0;
+
+ while (y < original_image_height)
+ {
+ DBG(DBG_info2, "xsane_save_scaled_image: original line %d, new line %d\n", (int) y, y_new);
+
+ gtk_progress_bar_update(progress_bar, (float) y / original_image_height);
+ while (gtk_events_pending())
+ {
+ gtk_main_iteration();
+ }
+
+ if (read_line)
+ {
+ DBG(DBG_info, "xsane_save_scaled_image: reading original line %d\n", (int) y);
+ fread(original_line, original_image_width, image_info->colors * bytespp, imagefile); /* read one line */
+ original_line16 = (guint16 *) original_line;
+ }
+
+ x_new = 0;
+ x_go = 1.0 / x_scale;
+ x = 0.0;
+ x_factor = 1.0;
+
+ while ( (x < original_image_width) && (x_new < new_image_width) ) /* add this line to anti aliasing buffer */
+
+ {
+ factor = x_factor * y_factor;
+
+ for (c = 0; c < image_info->colors; c++)
+ {
+ if (bytespp == 1)
+ {
+ color = original_line[((int) x) * image_info->colors + c];
+ }
+ else /* bytespp == 2 */
+ {
+ color = original_line16[((int) x) * image_info->colors + c];
+ }
+
+ pixel_val [x_new * image_info->colors + c] += factor * color;
+ pixel_norm[x_new * image_info->colors + c] += factor;
+ }
+
+ x_go -= x_factor;
+
+ if (x_go <= 0.0) /* change of pixel in new image */
+ {
+ x_new++;
+ x_go = 1.0 / x_scale;
+
+ x_factor = x - (int) x; /* use pixel rest */
+ if (x_factor > x_go)
+ {
+ x_factor = x_go;
+ }
+ }
+ else
+ {
+ x_factor = x_go;
+ }
+
+ if (x_factor > 1.0)
+ {
+ x_factor = 1.0;
+ }
+
+ x += x_factor;
+ }
+
+ y_go -= y_factor;
+
+ if (y_go <= 0.0) /* normalize one line and write to destination image file */
+ {
+ DBG(DBG_info2, "xsane_save_scaled_image: writing new line %d\n", y_new);
+
+ if (bytespp == 1)
+ {
+ for (x_new = 0; x_new < new_image_width * image_info->colors; x_new++)
+ {
+ new_line[x_new] = (int) (pixel_val[x_new] / pixel_norm[x_new]);
+ }
+ }
+ else /* bytespp == 2 */
+ {
+ guint16 *new_line16 = (guint16 *) new_line;
+
+ for (x_new = 0; x_new < new_image_width * image_info->colors; x_new++)
+ {
+ new_line16[x_new] = (int) (pixel_val[x_new] / pixel_norm[x_new]);
+ }
+ }
+
+ fwrite(new_line, new_image_width, image_info->colors * bytespp, outfile); /* write one line */
+
+ if (ferror(outfile))
+ {
+ char buf[255];
+
+ snprintf(buf, sizeof(buf), "%s %s", ERR_DURING_SAVE, strerror(errno));
+ DBG(DBG_error, "%s\n", buf);
+ xsane_back_gtk_decision(ERR_HEADER_ERROR, (gchar **) error_xpm, buf, BUTTON_OK, NULL, TRUE /* wait */);
+ *cancel_save = 1;
+ break;
+ }
+
+ /* reset values and norm factors */
+ memset(pixel_val, 0, new_image_width * image_info->colors * sizeof(float));
+ memset(pixel_norm, 0, new_image_width * image_info->colors * sizeof(float));
+
+ y_new++;
+ y_go = 1.0 / y_scale;
+
+ y_factor = y - (int) y;
+ if (y_factor > y_go)
+ {
+ y_factor = y_go;
+ }
+ }
+ else
+ {
+ y_factor = y_go;
+ }
+
+ if (y_factor > 1.0)
+ {
+ y_factor = 1.0;
+ }
+
+ oldy = (int) y;
+ y += y_factor;
+ read_line = (oldy != (int) y);
+ }
+
+ free(original_line);
+ free(new_line);
+ free(pixel_val);
+ free(pixel_norm);
+
+ return (*cancel_save);
+}
+
+/* ---------------------------------------------------------------------------------------------------------------------- */
+#if 0
+int xsane_save_scaled_image(FILE *outfile, FILE *imagefile, Image_info *image_info, float x_scale, float y_scale, GtkProgressBar *progress_bar, int *cancel_save)
+{
float original_y;
int old_original_y;
int x, y, i;
@@ -656,7 +1115,7 @@ int xsane_save_scaled_image(FILE *outfile, FILE *imagefile, Image_info *image_in
return -1;
}
- xsane_write_pnm_header(outfile, image_info);
+ xsane_write_pnm_header(outfile, image_info, 0);
original_y = 0.0;
old_original_y = -1;
@@ -699,6 +1158,7 @@ int xsane_save_scaled_image(FILE *outfile, FILE *imagefile, Image_info *image_in
return (*cancel_save);
}
+#endif
/* ---------------------------------------------------------------------------------------------------------------------- */
@@ -707,24 +1167,30 @@ int xsane_save_despeckle_image(FILE *outfile, FILE *imagefile, Image_info *image
int x, y, sx, sy, i;
int xmin, xmax;
int ymin, ymax;
- int pos0;
int count;
unsigned char *line_cache;
unsigned char *line_cache_ptr;
guint16 *color_cache;
guint16 *color_cache_ptr;
int bytespp = 1;
- int color_radius = radius * image_info->colors;
+ int color_radius;
int color_width = image_info->image_width * image_info->colors;
+ radius--; /* correct radius : 1 means nothing happens */
+
+ if (radius < 1)
+ {
+ radius = 1;
+ }
+
+ color_radius = radius * image_info->colors;
+
if (image_info->depth > 8)
{
bytespp = 2;
}
- pos0 = ftell(imagefile); /* mark position to skip header */
-
- xsane_write_pnm_header(outfile, image_info);
+ xsane_write_pnm_header(outfile, image_info, 0);
line_cache = malloc(color_width * bytespp * (2 * radius + 1));
if (!line_cache)
@@ -871,6 +1337,17 @@ int xsane_save_despeckle_image(FILE *outfile, FILE *imagefile, Image_info *image
}
}
+ if (ferror(outfile))
+ {
+ char buf[255];
+
+ snprintf(buf, sizeof(buf), "%s %s", ERR_DURING_SAVE, strerror(errno));
+ DBG(DBG_error, "%s\n", buf);
+ xsane_back_gtk_decision(ERR_HEADER_ERROR, (gchar **) error_xpm, buf, BUTTON_OK, NULL, TRUE /* wait */);
+ *cancel_save = 1;
+ break;
+ }
+
if ((y > radius) && (y < image_info->image_height - radius))
{
memcpy(line_cache, line_cache + color_width * bytespp,
@@ -890,6 +1367,224 @@ int xsane_save_despeckle_image(FILE *outfile, FILE *imagefile, Image_info *image
/* ---------------------------------------------------------------------------------------------------------------------- */
+int xsane_save_blur_image(FILE *outfile, FILE *imagefile, Image_info *image_info, float radius, GtkProgressBar *progress_bar, int *cancel_save)
+{
+ int x, y, sx, sy;
+ int xmin, xmax;
+ int ymin, ymax;
+ float val, norm;
+ unsigned char *line_cache;
+ int bytespp = 1;
+ int intradius;
+ float outer_factor;
+ int xmin_flag;
+ int xmax_flag;
+ int ymin_flag;
+ int ymax_flag;
+
+ *cancel_save = 0;
+
+ intradius = (int) radius;
+
+ outer_factor = radius - (int) radius;
+
+ if (image_info->depth > 8)
+ {
+ bytespp = 2;
+ }
+
+ xsane_write_pnm_header(outfile, image_info, 0);
+
+ line_cache = malloc(image_info->image_width * image_info->colors * bytespp * (2 * intradius + 1));
+ if (!line_cache)
+ {
+ DBG(DBG_error, "xsane_blur_image: out of memory\n");
+ return -1;
+ }
+
+ fread(line_cache, image_info->image_width * image_info->colors * bytespp, (2 * intradius + 1), imagefile);
+
+ for (y = 0; y < image_info->image_height; y++)
+ {
+ gtk_progress_bar_update(progress_bar, (float) y / image_info->image_height);
+ while (gtk_events_pending())
+ {
+ gtk_main_iteration();
+ }
+
+ for (x = 0; x < image_info->image_width * image_info->colors; x++)
+ {
+ xmin_flag = xmax_flag = ymin_flag = ymax_flag = TRUE;
+
+ xmin = x - intradius * image_info->colors;
+ xmax = x + intradius * image_info->colors;
+
+ if (xmin < 0)
+ {
+ xmin = x % image_info->colors;
+ xmin_flag = FALSE;
+ }
+
+ if (xmax > image_info->image_width * image_info->colors)
+ {
+ xmax = image_info->image_width * image_info->colors;
+ xmax_flag = FALSE;
+ }
+
+ ymin = y - intradius;
+ ymax = y + intradius;
+
+ if (ymin < 0)
+ {
+ ymin = 0;
+ ymin_flag = FALSE;
+ }
+
+ if (ymax > image_info->image_height)
+ {
+ ymax = image_info->image_height;
+ ymax_flag = FALSE;
+ }
+
+ val = 0.0;
+ norm = 0.0;
+
+ if (bytespp == 1)
+ {
+ if (xmin_flag) /* integrate over left margin */
+ {
+ for (sy = ymin+1; sy <= ymax-1 ; sy++)
+ {
+ val += outer_factor * line_cache[(sy-ymin) * image_info->image_width * image_info->colors + xmin];
+ norm += outer_factor;
+ }
+ }
+
+ if (xmax_flag) /* integrate over right margin */
+ {
+ for (sy = ymin+1; sy <= ymax-1 ; sy++)
+ {
+ val += outer_factor * line_cache[(sy-ymin) * image_info->image_width * image_info->colors + xmax];
+ norm += outer_factor;
+ }
+ }
+
+ if (ymin_flag) /* integrate over top margin */
+ {
+ for (sx = xmin+image_info->colors; sx <= xmax-image_info->colors ; sx += image_info->colors)
+ {
+ val += outer_factor * line_cache[sx];
+ norm += outer_factor;
+ }
+ }
+
+ if (ymax_flag) /* integrate over bottom margin */
+ {
+ for (sx = xmin+image_info->colors; sx <= xmax-image_info->colors ; sx += image_info->colors)
+ {
+ val += outer_factor * line_cache[(ymax-ymin) * image_info->image_width * image_info->colors + sx];
+ norm += outer_factor;
+ }
+ }
+
+ for (sy = ymin+1; sy <= ymax-1; sy++) /* integrate internal square */
+ {
+ for (sx = xmin+image_info->colors; sx <= xmax-image_info->colors; sx+=image_info->colors)
+ {
+ val += line_cache[(sy-ymin) * image_info->image_width * image_info->colors + sx];
+ norm += 1.0;
+ }
+ }
+ fputc((char) ((int) (val/norm)), outfile);
+ }
+ else
+ {
+ guint16 *line_cache16 = (guint16 *) line_cache;
+ guint16 val16;
+ char *bytes16 = (char *) &val16;
+
+ if (xmin_flag) /* integrate over left margin */
+ {
+ for (sy = ymin+1; sy <= ymax-1 ; sy++)
+ {
+ val += outer_factor * line_cache16[(sy-ymin) * image_info->image_width * image_info->colors + xmin];
+ norm += outer_factor;
+ }
+ }
+
+ if (xmax_flag) /* integrate over right margin */
+ {
+ for (sy = ymin+1; sy <= ymax-1 ; sy++)
+ {
+ val += outer_factor * line_cache16[(sy-ymin) * image_info->image_width * image_info->colors + xmax];
+ norm += outer_factor;
+ }
+ }
+
+ if (ymin_flag) /* integrate over top margin */
+ {
+ for (sx = xmin+image_info->colors; sx <= xmax-image_info->colors ; sx += image_info->colors)
+ {
+ val += outer_factor * line_cache16[sx];
+ norm += outer_factor;
+ }
+ }
+
+ if (ymax_flag) /* integrate over bottom margin */
+ {
+ for (sx = xmin+image_info->colors; sx <= xmax-image_info->colors ; sx += image_info->colors)
+ {
+ val += outer_factor * line_cache16[(ymax-ymin) * image_info->image_width * image_info->colors + sx];
+ norm += outer_factor;
+ }
+ }
+
+ for (sy = ymin; sy <= ymax; sy++) /* integrate internal square */
+ {
+ for (sx = xmin; sx <= xmax; sx+=image_info->colors)
+ {
+ val += line_cache16[(sy-ymin) * image_info->image_width * image_info->colors + sx];
+ norm += 1.0;
+ }
+ }
+
+ val16 = val / norm;
+ fputc(bytes16[0], outfile); /* write bytes in machine byte order */
+ fputc(bytes16[1], outfile);
+ }
+ }
+
+ if (ferror(outfile))
+ {
+ char buf[255];
+
+ snprintf(buf, sizeof(buf), "%s %s", ERR_DURING_SAVE, strerror(errno));
+ DBG(DBG_error, "%s\n", buf);
+ xsane_back_gtk_decision(ERR_HEADER_ERROR, (gchar **) error_xpm, buf, BUTTON_OK, NULL, TRUE /* wait */);
+ *cancel_save = 1;
+ break;
+ }
+
+ /* reset values and norm factors */
+
+ if ((y > intradius) && (y < image_info->image_height - intradius))
+ {
+ memcpy(line_cache, line_cache + image_info->image_width * image_info->colors * bytespp,
+ image_info->image_width * image_info->colors * bytespp * 2 * intradius);
+ fread(line_cache + image_info->image_width * image_info->colors * bytespp * 2 * intradius,
+ image_info->image_width * image_info->colors * bytespp, 1, imagefile);
+ }
+ }
+
+ fflush(outfile);
+ free(line_cache);
+
+ return 0;
+}
+
+/* ---------------------------------------------------------------------------------------------------------------------- */
+
+#if 0
int xsane_save_blur_image(FILE *outfile, FILE *imagefile, Image_info *image_info, int radius, GtkProgressBar *progress_bar)
{
int x, y, sx, sy;
@@ -907,7 +1602,7 @@ int xsane_save_blur_image(FILE *outfile, FILE *imagefile, Image_info *image_info
pos0 = ftell(imagefile); /* mark position to skip header */
- xsane_write_pnm_header(outfile, image_info);
+ xsane_write_pnm_header(outfile, image_info, 0);
line_cache = malloc(image_info->image_width * image_info->colors * bytespp * (2 * radius + 1));
if (!line_cache)
@@ -1004,6 +1699,7 @@ int xsane_save_blur_image(FILE *outfile, FILE *imagefile, Image_info *image_info
return 0;
}
+#endif
/* ---------------------------------------------------------------------------------------------------------------------- */
@@ -1040,7 +1736,7 @@ int xsane_save_rotate_image(FILE *outfile, FILE *imagefile, Image_info *image_in
#ifdef HAVE_MMAP
mmaped_imagefile = mmap(NULL, pixel_width * pixel_height * bytespp + pos0, PROT_READ, MAP_PRIVATE, fileno(imagefile), 0);
- if (mmaped_imagefile == (void *) -1) /* mmap failed */
+ if (mmaped_imagefile == (char *) -1) /* mmap failed */
{
DBG(DBG_info, "xsane_save_rotate_image: unable to memory map image file, using standard file access\n");
mmaped_imagefile = NULL;
@@ -1057,7 +1753,7 @@ int xsane_save_rotate_image(FILE *outfile, FILE *imagefile, Image_info *image_in
break;
case 0: /* 0 degree */
- xsane_write_pnm_header(outfile, image_info);
+ xsane_write_pnm_header(outfile, image_info, 0);
for (y = 0; y < pixel_height; y++)
{
@@ -1089,6 +1785,17 @@ int xsane_save_rotate_image(FILE *outfile, FILE *imagefile, Image_info *image_in
}
}
+ if (ferror(outfile))
+ {
+ char buf[255];
+
+ snprintf(buf, sizeof(buf), "%s %s", ERR_DURING_SAVE, strerror(errno));
+ DBG(DBG_error, "%s\n", buf);
+ xsane_back_gtk_decision(ERR_HEADER_ERROR, (gchar **) error_xpm, buf, BUTTON_OK, NULL, TRUE /* wait */);
+ *cancel_save = 1;
+ break;
+ }
+
if (*cancel_save)
{
break;
@@ -1103,7 +1810,7 @@ int xsane_save_rotate_image(FILE *outfile, FILE *imagefile, Image_info *image_in
image_info->resolution_x = resolution_y;
image_info->resolution_y = resolution_x;
- xsane_write_pnm_header(outfile, image_info);
+ xsane_write_pnm_header(outfile, image_info, 0);
for (x=0; x<pixel_width; x++)
{
@@ -1136,6 +1843,18 @@ int xsane_save_rotate_image(FILE *outfile, FILE *imagefile, Image_info *image_in
}
}
+
+ if (ferror(outfile))
+ {
+ char buf[255];
+
+ snprintf(buf, sizeof(buf), "%s %s", ERR_DURING_SAVE, strerror(errno));
+ DBG(DBG_error, "%s\n", buf);
+ xsane_back_gtk_decision(ERR_HEADER_ERROR, (gchar **) error_xpm, buf, BUTTON_OK, NULL, TRUE /* wait */);
+ *cancel_save = 1;
+ break;
+ }
+
if (*cancel_save)
{
break;
@@ -1145,7 +1864,7 @@ int xsane_save_rotate_image(FILE *outfile, FILE *imagefile, Image_info *image_in
break;
case 2: /* 180 degree */
- xsane_write_pnm_header(outfile, image_info);
+ xsane_write_pnm_header(outfile, image_info, 0);
for (y = pixel_height-1; y >= 0; y--)
{
@@ -1178,6 +1897,18 @@ int xsane_save_rotate_image(FILE *outfile, FILE *imagefile, Image_info *image_in
}
}
+
+ if (ferror(outfile))
+ {
+ char buf[255];
+
+ snprintf(buf, sizeof(buf), "%s %s", ERR_DURING_SAVE, strerror(errno));
+ DBG(DBG_error, "%s\n", buf);
+ xsane_back_gtk_decision(ERR_HEADER_ERROR, (gchar **) error_xpm, buf, BUTTON_OK, NULL, TRUE /* wait */);
+ *cancel_save = 1;
+ break;
+ }
+
if (*cancel_save)
{
break;
@@ -1192,7 +1923,7 @@ int xsane_save_rotate_image(FILE *outfile, FILE *imagefile, Image_info *image_in
image_info->resolution_x = resolution_y;
image_info->resolution_y = resolution_x;
- xsane_write_pnm_header(outfile, image_info);
+ xsane_write_pnm_header(outfile, image_info, 0);
for (x = pixel_width-1; x >= 0; x--)
{
@@ -1225,6 +1956,18 @@ int xsane_save_rotate_image(FILE *outfile, FILE *imagefile, Image_info *image_in
}
}
+
+ if (ferror(outfile))
+ {
+ char buf[255];
+
+ snprintf(buf, sizeof(buf), "%s %s", ERR_DURING_SAVE, strerror(errno));
+ DBG(DBG_error, "%s\n", buf);
+ xsane_back_gtk_decision(ERR_HEADER_ERROR, (gchar **) error_xpm, buf, BUTTON_OK, NULL, TRUE /* wait */);
+ *cancel_save = 1;
+ break;
+ }
+
if (*cancel_save)
{
break;
@@ -1233,7 +1976,7 @@ int xsane_save_rotate_image(FILE *outfile, FILE *imagefile, Image_info *image_in
break;
case 4: /* 0 degree, x mirror */
- xsane_write_pnm_header(outfile, image_info);
+ xsane_write_pnm_header(outfile, image_info, 0);
for (y = 0; y < pixel_height; y++)
{
@@ -1266,6 +2009,18 @@ int xsane_save_rotate_image(FILE *outfile, FILE *imagefile, Image_info *image_in
}
}
+
+ if (ferror(outfile))
+ {
+ char buf[255];
+
+ snprintf(buf, sizeof(buf), "%s %s", ERR_DURING_SAVE, strerror(errno));
+ DBG(DBG_error, "%s\n", buf);
+ xsane_back_gtk_decision(ERR_HEADER_ERROR, (gchar **) error_xpm, buf, BUTTON_OK, NULL, TRUE /* wait */);
+ *cancel_save = 1;
+ break;
+ }
+
if (*cancel_save)
{
break;
@@ -1280,7 +2035,7 @@ int xsane_save_rotate_image(FILE *outfile, FILE *imagefile, Image_info *image_in
image_info->resolution_x = resolution_y;
image_info->resolution_y = resolution_x;
- xsane_write_pnm_header(outfile, image_info);
+ xsane_write_pnm_header(outfile, image_info, 0);
for (x = 0; x < pixel_width; x++)
{
@@ -1313,6 +2068,18 @@ int xsane_save_rotate_image(FILE *outfile, FILE *imagefile, Image_info *image_in
}
}
+
+ if (ferror(outfile))
+ {
+ char buf[255];
+
+ snprintf(buf, sizeof(buf), "%s %s", ERR_DURING_SAVE, strerror(errno));
+ DBG(DBG_error, "%s\n", buf);
+ xsane_back_gtk_decision(ERR_HEADER_ERROR, (gchar **) error_xpm, buf, BUTTON_OK, NULL, TRUE /* wait */);
+ *cancel_save = 1;
+ break;
+ }
+
if (*cancel_save)
{
break;
@@ -1322,7 +2089,7 @@ int xsane_save_rotate_image(FILE *outfile, FILE *imagefile, Image_info *image_in
break;
case 6: /* 180 degree, x mirror */
- xsane_write_pnm_header(outfile, image_info);
+ xsane_write_pnm_header(outfile, image_info, 0);
for (y = pixel_height-1; y >= 0; y--)
{
@@ -1355,6 +2122,18 @@ int xsane_save_rotate_image(FILE *outfile, FILE *imagefile, Image_info *image_in
}
}
+
+ if (ferror(outfile))
+ {
+ char buf[255];
+
+ snprintf(buf, sizeof(buf), "%s %s", ERR_DURING_SAVE, strerror(errno));
+ DBG(DBG_error, "%s\n", buf);
+ xsane_back_gtk_decision(ERR_HEADER_ERROR, (gchar **) error_xpm, buf, BUTTON_OK, NULL, TRUE /* wait */);
+ *cancel_save = 1;
+ break;
+ }
+
if (*cancel_save)
{
break;
@@ -1369,7 +2148,7 @@ int xsane_save_rotate_image(FILE *outfile, FILE *imagefile, Image_info *image_in
image_info->resolution_x = resolution_y;
image_info->resolution_y = resolution_x;
- xsane_write_pnm_header(outfile, image_info);
+ xsane_write_pnm_header(outfile, image_info, 0);
for (x = pixel_width-1; x >= 0; x--)
{
@@ -1402,6 +2181,18 @@ int xsane_save_rotate_image(FILE *outfile, FILE *imagefile, Image_info *image_in
}
}
+
+ if (ferror(outfile))
+ {
+ char buf[255];
+
+ snprintf(buf, sizeof(buf), "%s %s", ERR_DURING_SAVE, strerror(errno));
+ DBG(DBG_error, "%s\n", buf);
+ xsane_back_gtk_decision(ERR_HEADER_ERROR, (gchar **) error_xpm, buf, BUTTON_OK, NULL, TRUE /* wait */);
+ *cancel_save = 1;
+ break;
+ }
+
if (*cancel_save)
{
break;
@@ -1425,50 +2216,114 @@ int xsane_save_rotate_image(FILE *outfile, FILE *imagefile, Image_info *image_in
/* ---------------------------------------------------------------------------------------------------------------------- */
static void xsane_save_ps_create_header(FILE *outfile, Image_info *image_info,
- int left, int bottom, float width, float height,
- int paperwidth, int paperheight, int rotate,
+ float width, float height,
+ int paper_left_margin, int paper_bottom_margin,
+ int paper_width, int paper_height,
+ int paper_orientation,
GtkProgressBar *progress_bar)
{
- int degree, position_left, position_bottom, box_left, box_bottom, box_right, box_top;
+ int degree, position_left, position_bottom, box_left, box_bottom, box_right, box_top, depth;
+ int left, bottom;
DBG(DBG_proc, "xsane_save_ps_create_header\n");
- if (rotate) /* rotate with 90 degrees - eg for landscape mode */
+ switch (paper_orientation)
+ {
+ default:
+ case 0: /* top left portrait */
+ left = 0.0;
+ bottom = paper_height - height;
+ break;
+
+ case 1: /* top right portrait */
+ left = paper_width - width;
+ bottom = paper_height - height;
+ break;
+
+ case 2: /* bottom right portrait */
+ left = paper_width - width;
+ bottom = 0.0;
+ break;
+
+ case 3: /* bottom left portrait */
+ left = 0.0;
+ bottom = 0.0;
+ break;
+
+ case 4: /* center portrait */
+ left = paper_width / 2.0 - width / 2.0;
+ bottom = paper_height / 2.0 - height / 2.0;
+ break;
+
+
+ case 8: /* top left landscape */
+ left = 0.0;
+ bottom = paper_width - height;
+ break;
+
+ case 9: /* top right landscape */
+ left = paper_height - width;
+ bottom = paper_width - height;
+ break;
+
+ case 10: /* bottom right landscape */
+ left = paper_height - width;
+ bottom = 0.0;
+ break;
+
+ case 11: /* bottom left landscape */
+ left = 0.0;
+ bottom = 0.0;
+ break;
+
+ case 12: /* center landscape */
+ left = paper_height / 2.0 - width / 2.0;
+ bottom = paper_width / 2.0 - height / 2.0;
+ break;
+ }
+
+
+ if (paper_orientation >= 8) /* rotate with 90 degrees - landscape mode */
{
degree = 90;
- position_left = left;
- position_bottom = bottom - paperwidth;
- box_left = paperwidth - bottom - height * 72.0;
- box_bottom = left;
- box_right = (int) (box_left + height * 72.0);
- box_top = (int) (box_bottom + width * 72.0);
+ position_left = left + paper_bottom_margin;
+ position_bottom = bottom - paper_width - paper_left_margin;
+ box_left = paper_width - paper_left_margin - bottom - height;
+ box_bottom = left + paper_bottom_margin;
+ box_right = box_left + ceil(height);
+ box_top = box_bottom + ceil(width);
}
- else /* do not rotate, eg for portrait mode */
+ else /* do not rotate, portrait mode */
{
degree = 0;
- position_left = left;
- position_bottom = bottom;
- box_left = left;
- box_bottom = bottom;
- box_right = (int) (box_left + width * 72.0);
- box_top = (int) (box_bottom + height * 72.0);
+ position_left = left + paper_left_margin;
+ position_bottom = bottom + paper_bottom_margin;
+ box_left = left + paper_left_margin;
+ box_bottom = bottom + paper_bottom_margin;
+ box_right = box_left + ceil(width);
+ box_top = box_bottom + ceil(height);
}
- if (image_info->depth == 16)
+ depth = image_info->depth;
+
+ if (depth > 8)
{
- image_info->depth = 8; /* 16 bits/color are already reduced to 8 bits/color */
+ depth = 8;
}
- fprintf(outfile, "%%!PS-Adobe-2.0 EPSF-2.0\n");
- fprintf(outfile, "%%%%Creator: xsane version %s (sane %d.%d)\n", VERSION,
- SANE_VERSION_MAJOR(xsane.sane_backend_versioncode),
- SANE_VERSION_MINOR(xsane.sane_backend_versioncode));
+ fprintf(outfile, "%%!PS-Adobe-3.0\n");
+ fprintf(outfile, "%%%%Creator: XSane version %s (sane %d.%d) - by Oliver Rauch\n", VERSION,
+ SANE_VERSION_MAJOR(xsane.sane_backend_versioncode),
+ SANE_VERSION_MINOR(xsane.sane_backend_versioncode));
+ fprintf(outfile, "%%%%DocumentData: Clean7Bit\n");
+ fprintf(outfile, "%%%%Pages: 1\n");
fprintf(outfile, "%%%%BoundingBox: %d %d %d %d\n", box_left, box_bottom, box_right, box_top);
- fprintf(outfile, "%%\n");
+ fprintf(outfile, "%%%%EndComments\n");
fprintf(outfile, "/origstate save def\n");
fprintf(outfile, "20 dict begin\n");
+ fprintf(outfile, "%%%%Page: 1 1\n");
- if (image_info->depth == 1)
+ if (depth == 1)
{
fprintf(outfile, "/pix %d string def\n", (image_info->image_width+7)/8);
fprintf(outfile, "/grays %d string def\n", image_info->image_width);
@@ -1483,9 +2338,9 @@ static void xsane_save_ps_create_header(FILE *outfile, Image_info *image_info,
fprintf(outfile, "%d rotate\n", degree);
fprintf(outfile, "%d %d translate\n", position_left, position_bottom);
- fprintf(outfile, "%f %f scale\n", width * 72.0, height * 72.0);
- fprintf(outfile, "%d %d %d\n", image_info->image_width, image_info->image_height, image_info->depth);
- fprintf(outfile, "[%d %d %d %d %d %d]\n", image_info->image_width, 0, 0, -image_info->image_height, 0 , image_info->image_height);
+ fprintf(outfile, "%f %f scale\n", width, height);
+ fprintf(outfile, "%d %d %d\n", image_info->image_width, image_info->image_height, depth);
+ fprintf(outfile, "[%d %d %d %d %d %d]\n", image_info->image_width, 0, 0, -image_info->image_height, 0, image_info->image_height);
fprintf(outfile, "{currentfile pix readhexstring pop}\n");
if (image_info->colors == 3) /* what about RGBA here ? */
@@ -1531,6 +2386,18 @@ static int xsane_save_ps_bw(FILE *outfile, FILE *imagefile, Image_info *image_in
}
fprintf(outfile, "\n");
+
+ if (ferror(outfile))
+ {
+ char buf[255];
+
+ snprintf(buf, sizeof(buf), "%s %s", ERR_DURING_SAVE, strerror(errno));
+ DBG(DBG_error, "%s\n", buf);
+ xsane_back_gtk_decision(ERR_HEADER_ERROR, (gchar **) error_xpm, buf, BUTTON_OK, NULL, TRUE /* wait */);
+ *cancel_save = 1;
+ break;
+ }
+
count = 0;
if (*cancel_save)
{
@@ -1554,16 +2421,48 @@ static int xsane_save_ps_gray(FILE *outfile, FILE *imagefile, Image_info *image_
count = 0;
for (y = 0; y < image_info->image_height; y++)
{
- for (x = 0; x < image_info->image_width; x++)
+ if (image_info->depth > 8) /* reduce 16 bit images */
{
- fprintf(outfile, "%02x", fgetc(imagefile));
- if (++count >=40)
+ guint16 val;
+
+ for (x = 0; x < image_info->image_width; x++)
{
- fprintf(outfile, "\n");
- count = 0;
+ fread(&val, 2, 1, imagefile);
+ fprintf(outfile, "%02x", val/256);
+
+ if (++count >= 40)
+ {
+ fprintf(outfile, "\n");
+ count = 0;
+ }
}
}
+ else /* 8 bits/sample */
+ {
+ for (x = 0; x < image_info->image_width; x++)
+ {
+ fprintf(outfile, "%02x", fgetc(imagefile));
+ if (++count >= 40)
+ {
+ fprintf(outfile, "\n");
+ count = 0;
+ }
+ }
+ }
+
fprintf(outfile, "\n");
+
+ if (ferror(outfile))
+ {
+ char buf[255];
+
+ snprintf(buf, sizeof(buf), "%s %s", ERR_DURING_SAVE, strerror(errno));
+ DBG(DBG_error, "%s\n", buf);
+ xsane_back_gtk_decision(ERR_HEADER_ERROR, (gchar **) error_xpm, buf, BUTTON_OK, NULL, TRUE /* wait */);
+ *cancel_save = 1;
+ break;
+ }
+
count = 0;
gtk_progress_bar_update(progress_bar, (float) y / image_info->image_height);
while (gtk_events_pending())
@@ -1598,18 +2497,54 @@ static int xsane_save_ps_color(FILE *outfile, FILE *imagefile, Image_info *image
gtk_main_iteration();
}
- for (x = 0; x < image_info->image_width; x++)
+ if (image_info->depth > 8) /* reduce 16 bit images */
{
- fprintf(outfile, "%02x", fgetc(imagefile));
- fprintf(outfile, "%02x", fgetc(imagefile));
- fprintf(outfile, "%02x", fgetc(imagefile));
- if (++count >=10)
+ guint16 val;
+
+ for (x = 0; x < image_info->image_width; x++)
{
- fprintf(outfile, "\n");
- count = 0;
+ fread(&val, 2, 1, imagefile);
+ fprintf(outfile, "%02x", val/256);
+ fread(&val, 2, 1, imagefile);
+ fprintf(outfile, "%02x", val/256);
+ fread(&val, 2, 1, imagefile);
+ fprintf(outfile, "%02x", val/256);
+
+ if (++count >= 10)
+ {
+ fprintf(outfile, "\n");
+ count = 0;
+ }
+ }
+ }
+ else /* 8 bits/sample */
+ {
+ for (x = 0; x < image_info->image_width; x++)
+ {
+ fprintf(outfile, "%02x", fgetc(imagefile));
+ fprintf(outfile, "%02x", fgetc(imagefile));
+ fprintf(outfile, "%02x", fgetc(imagefile));
+
+ if (++count >= 10)
+ {
+ fprintf(outfile, "\n");
+ count = 0;
+ }
}
}
fprintf(outfile, "\n");
+
+ if (ferror(outfile))
+ {
+ char buf[255];
+
+ snprintf(buf, sizeof(buf), "%s %s", ERR_DURING_SAVE, strerror(errno));
+ DBG(DBG_error, "%s\n", buf);
+ xsane_back_gtk_decision(ERR_HEADER_ERROR, (gchar **) error_xpm, buf, BUTTON_OK, NULL, TRUE /* wait */);
+ *cancel_save = 1;
+ break;
+ }
+
count = 0;
if (*cancel_save)
@@ -1623,13 +2558,17 @@ static int xsane_save_ps_color(FILE *outfile, FILE *imagefile, Image_info *image
/* ---------------------------------------------------------------------------------------------------------------------- */
-int xsane_save_ps(FILE *outfile, FILE *imagefile, Image_info *image_info, int left, int bottom, float width, float height,
- int paperheight, int paperwidth, int rotate, GtkProgressBar *progress_bar, int *cancel_save)
+int xsane_save_ps(FILE *outfile, FILE *imagefile, Image_info *image_info, float width, float height,
+ int paper_left_margin, int paper_bottom_margin, int paperheight, int paperwidth, int paper_orientation,
+ GtkProgressBar *progress_bar, int *cancel_save)
{
DBG(DBG_proc, "xsane_save_ps\n");
- xsane_save_ps_create_header(outfile, image_info,
- left, bottom, width, height, paperheight, paperwidth, rotate, progress_bar);
+ *cancel_save = 0;
+
+ xsane_save_ps_create_header(outfile, image_info, width, height,
+ paper_left_margin, paper_bottom_margin, paperheight, paperwidth, paper_orientation,
+ progress_bar);
if (image_info->colors == 1) /* lineart, halftone, grayscale */
{
@@ -1651,22 +2590,61 @@ int xsane_save_ps(FILE *outfile, FILE *imagefile, Image_info *image_info, int le
fprintf(outfile, "showpage\n");
fprintf(outfile, "end\n");
fprintf(outfile, "origstate restore\n");
+ fprintf(outfile, "%%%%EOF\n");
fprintf(outfile, "\n");
+ if (ferror(outfile))
+ {
+ char buf[255];
+
+ snprintf(buf, sizeof(buf), "%s %s", ERR_DURING_SAVE, strerror(errno));
+ DBG(DBG_error, "%s\n", buf);
+ xsane_back_gtk_decision(ERR_HEADER_ERROR, (gchar **) error_xpm, buf, BUTTON_OK, NULL, TRUE /* wait */);
+ *cancel_save = 1;
+ }
+
return (*cancel_save);
}
/* ---------------------------------------------------------------------------------------------------------------------- */
-
#ifdef HAVE_LIBJPEG
+
+typedef struct
+{
+ struct jpeg_error_mgr pub;/* "public" fields */
+ int *cancel_save;
+} xsane_jpeg_error_mgr;
+
+typedef xsane_jpeg_error_mgr *xsane_jpeg_error_mgr_ptr;
+
+static void xsane_jpeg_error_exit(j_common_ptr cinfo)
+{
+ char buf[256];
+
+ /* cinfo->err points to a xsane_jpeg_error_mgr struct */
+ xsane_jpeg_error_mgr_ptr xsane_jpeg_error_mgr_data = (xsane_jpeg_error_mgr_ptr) cinfo->err;
+
+
+ if (!*xsane_jpeg_error_mgr_data->cancel_save)
+ {
+ /* output original error message */
+ (*cinfo->err->output_message) (cinfo);
+ snprintf(buf, sizeof(buf), "%s %s", ERR_DURING_SAVE, ERR_LIBJPEG);
+ xsane_back_gtk_error(buf, TRUE);
+ }
+
+ *xsane_jpeg_error_mgr_data->cancel_save = 1;
+}
+
int xsane_save_jpeg(FILE *outfile, FILE *imagefile, Image_info *image_info, int quality, GtkProgressBar *progress_bar, int *cancel_save)
{
unsigned char *data;
char buf[256];
- int x,y;
int components = 1;
+ int x,y;
+ int bytespp = 1;
struct jpeg_compress_struct cinfo;
- struct jpeg_error_mgr jerr;
+ xsane_jpeg_error_mgr jerr;
JSAMPROW row_pointer[1];
DBG(DBG_proc, "xsane_save_jpeg\n");
@@ -1678,7 +2656,12 @@ int xsane_save_jpeg(FILE *outfile, FILE *imagefile, Image_info *image_info, int
components = 3;
}
- data = malloc(image_info->image_width * components);
+ if (image_info->depth > 8)
+ {
+ bytespp = 2;
+ }
+
+ data = malloc(image_info->image_width * components * bytespp);
if (!data)
{
@@ -1687,7 +2670,10 @@ int xsane_save_jpeg(FILE *outfile, FILE *imagefile, Image_info *image_info, int
return -1; /* error */
}
- cinfo.err = jpeg_std_error(&jerr);
+ cinfo.err = jpeg_std_error(&jerr.pub);
+ jerr.pub.error_exit = xsane_jpeg_error_exit;
+ jerr.cancel_save = cancel_save;
+
jpeg_create_compress(&cinfo);
jpeg_stdio_dest(&cinfo, outfile);
cinfo.image_width = image_info->image_width;
@@ -1744,7 +2730,17 @@ int xsane_save_jpeg(FILE *outfile, FILE *imagefile, Image_info *image_info, int
mask >>= 1;
}
}
- else
+ else if (image_info->depth > 8) /* jpeg does not support 16 bits/sample, so we reduce it at first */
+ {
+ guint16 *data16 = (guint16 *) data;
+ fread(data, components * 2, image_info->image_width, imagefile);
+ for (x = 0; x < image_info->image_width * components; x++)
+ {
+ data[x] = data16[x] / 256;
+ }
+
+ }
+ else /* 8 bits/sample */
{
fread(data, components, image_info->image_width, imagefile);
}
@@ -1842,7 +2838,7 @@ int xsane_save_tiff(const char *outfilename, FILE *imagefile, Image_info *image_
{
snprintf(buf, sizeof(buf), "%s %s", ERR_DURING_SAVE, ERR_NO_MEM);
xsane_back_gtk_error(buf, TRUE);
- return -1; /* error */
+ return -1; /* error */
}
TIFFSetField(tiffile, TIFFTAG_IMAGEWIDTH, image_info->image_width);
@@ -1899,7 +2895,16 @@ int xsane_save_tiff(const char *outfilename, FILE *imagefile, Image_info *image_
fread(data, 1, w, imagefile);
- TIFFWriteScanline(tiffile, data, y, 0);
+ if (TIFFWriteScanline(tiffile, data, y, 0) != 1)
+ {
+ char buf[255];
+
+ snprintf(buf, sizeof(buf), "%s", ERR_DURING_SAVE);
+ DBG(DBG_error, "%s\n", buf);
+ xsane_back_gtk_decision(ERR_HEADER_ERROR, (gchar **) error_xpm, buf, BUTTON_OK, NULL, TRUE /* wait */);
+ *cancel_save = 1;
+ break;
+ }
if (*cancel_save)
{
@@ -1939,7 +2944,7 @@ int xsane_save_png(FILE *outfile, FILE *imagefile, Image_info *image_info, int c
png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, 0, 0, 0);
if (!png_ptr)
{
- snprintf(buf, sizeof(buf), "%s %s", ERR_DURING_SAVE, ERR_LIBTIFF);
+ snprintf(buf, sizeof(buf), "%s %s", ERR_DURING_SAVE, ERR_LIBPNG);
xsane_back_gtk_error(buf, TRUE);
return -1; /* error */
}
@@ -2036,7 +3041,8 @@ int xsane_save_png(FILE *outfile, FILE *imagefile, Image_info *image_info, int c
fread(data, components, byte_width, imagefile);
row_ptr = data;
- png_write_rows(png_ptr, &row_ptr, 1);
+ png_write_rows(png_ptr, &row_ptr, 1); /* errors are caught by test sor setjmp(...) */
+
if (*cancel_save)
{
break;
@@ -2149,7 +3155,7 @@ int xsane_save_png_16(FILE *outfile, FILE *imagefile, Image_info *image_info, in
for (x = 0; x < image_info->image_width * components; x++) /* this must be changed in dependance of endianess */
{
fread(&val, 2, 1, imagefile); /* get data in machine order */
- data[x*2+0] = val/256; /* write data in network order (MSB first) */
+ data[x*2+0] = val / 256; /* write data in network order (MSB first) */
data[x*2+1] = val & 255;
}
@@ -2172,19 +3178,16 @@ int xsane_save_png_16(FILE *outfile, FILE *imagefile, Image_info *image_info, in
/* ---------------------------------------------------------------------------------------------------------------------- */
-int xsane_save_pnm_16_gray(FILE *outfile, FILE *imagefile, Image_info *image_info, GtkProgressBar *progress_bar, int *cancel_save)
+static int xsane_save_pnm_16_ascii_gray(FILE *outfile, FILE *imagefile, Image_info *image_info, GtkProgressBar *progress_bar, int *cancel_save)
{
int x,y;
guint16 val;
int count = 0;
- DBG(DBG_proc, "xsane_save_pnm_16_gray\n");
+ DBG(DBG_proc, "xsane_save_pnm_16_ascii_gray\n");
*cancel_save = 0;
- /* write pgm ascii > 8 bpp */
- fprintf(outfile, "P2\n# SANE data follows\n%d %d\n65535\n", image_info->image_width, image_info->image_height);
-
for (y = 0; y < image_info->image_height; y++)
{
for (x = 0; x < image_info->image_width; x++)
@@ -2199,6 +3202,18 @@ int xsane_save_pnm_16_gray(FILE *outfile, FILE *imagefile, Image_info *image_inf
}
}
fprintf(outfile, "\n");
+
+ if (ferror(outfile))
+ {
+ char buf[255];
+
+ snprintf(buf, sizeof(buf), "%s %s", ERR_DURING_SAVE, strerror(errno));
+ DBG(DBG_error, "%s\n", buf);
+ xsane_back_gtk_decision(ERR_HEADER_ERROR, (gchar **) error_xpm, buf, BUTTON_OK, NULL, TRUE /* wait */);
+ *cancel_save = 1;
+ break;
+ }
+
count = 0;
gtk_progress_bar_update(progress_bar, (float) y / image_info->image_height);
@@ -2217,27 +3232,18 @@ int xsane_save_pnm_16_gray(FILE *outfile, FILE *imagefile, Image_info *image_inf
/* ---------------------------------------------------------------------------------------------------------------------- */
-int xsane_save_pnm_16_color(FILE *outfile, FILE *imagefile, Image_info *image_info, GtkProgressBar *progress_bar, int *cancel_save)
+static int xsane_save_pnm_16_ascii_color(FILE *outfile, FILE *imagefile, Image_info *image_info, GtkProgressBar *progress_bar, int *cancel_save)
{
int x,y;
guint16 val;
int count = 0;
- DBG(DBG_proc, "xsane_save_pnm_16_color\n");
+ DBG(DBG_proc, "xsane_save_pnm_16_ascii_color\n");
*cancel_save = 0;
- /* write ppm ascii > 8 bpp */
- fprintf(outfile, "P3\n# SANE data follows\n%d %d\n65535\n", image_info->image_width, image_info->image_height);
-
for (y = 0; y < image_info->image_height; y++)
{
- gtk_progress_bar_update(progress_bar, (float) y / image_info->image_height);
- while (gtk_events_pending())
- {
- gtk_main_iteration();
- }
-
for (x = 0; x < image_info->image_width; x++)
{
fread(&val, 2, 1, imagefile); /* get data in machine order */
@@ -2256,8 +3262,130 @@ int xsane_save_pnm_16_color(FILE *outfile, FILE *imagefile, Image_info *image_in
}
}
fprintf(outfile, "\n");
+
+ if (ferror(outfile))
+ {
+ char buf[255];
+
+ snprintf(buf, sizeof(buf), "%s %s", ERR_DURING_SAVE, strerror(errno));
+ DBG(DBG_error, "%s\n", buf);
+ xsane_back_gtk_decision(ERR_HEADER_ERROR, (gchar **) error_xpm, buf, BUTTON_OK, NULL, TRUE /* wait */);
+ *cancel_save = 1;
+ break;
+ }
+
count = 0;
+ gtk_progress_bar_update(progress_bar, (float) y / image_info->image_height);
+ while (gtk_events_pending())
+ {
+ gtk_main_iteration();
+ }
+
+ if (*cancel_save)
+ {
+ break;
+ }
+ }
+
+ return (*cancel_save);
+}
+
+/* ---------------------------------------------------------------------------------------------------------------------- */
+
+static int xsane_save_pnm_16_binary_gray(FILE *outfile, FILE *imagefile, Image_info *image_info, GtkProgressBar *progress_bar, int *cancel_save)
+{
+ int x,y;
+ guint16 val;
+
+ DBG(DBG_proc, "xsane_save_pnm_16_binary_gray\n");
+
+ *cancel_save = 0;
+
+ for (y = 0; y < image_info->image_height; y++)
+ {
+ for (x = 0; x < image_info->image_width; x++)
+ {
+ fread(&val, 2, 1, imagefile); /* get data in machine order */
+ fputc(val / 256, outfile); /* MSB fist */
+ fputc(val & 255, outfile); /* LSB */
+ }
+
+ gtk_progress_bar_update(progress_bar, (float) y / image_info->image_height);
+ while (gtk_events_pending())
+ {
+ gtk_main_iteration();
+ }
+
+ if (ferror(outfile))
+ {
+ char buf[255];
+
+ snprintf(buf, sizeof(buf), "%s %s", ERR_DURING_SAVE, strerror(errno));
+ DBG(DBG_error, "%s\n", buf);
+ xsane_back_gtk_decision(ERR_HEADER_ERROR, (gchar **) error_xpm, buf, BUTTON_OK, NULL, TRUE /* wait */);
+ *cancel_save = 1;
+ break;
+ }
+
+ if (*cancel_save)
+ {
+ break;
+ }
+ }
+
+ return (*cancel_save);
+}
+
+/* ---------------------------------------------------------------------------------------------------------------------- */
+
+static int xsane_save_pnm_16_binary_color(FILE *outfile, FILE *imagefile, Image_info *image_info, GtkProgressBar *progress_bar, int *cancel_save)
+{
+ int x,y;
+ guint16 val;
+
+ DBG(DBG_proc, "xsane_save_pnm_16_binary_color\n");
+
+ *cancel_save = 0;
+
+ for (y = 0; y < image_info->image_height; y++)
+ {
+ for (x = 0; x < image_info->image_width; x++)
+ {
+ /* red */
+ fread(&val, 2, 1, imagefile); /* get data in machine order */
+ fputc(val / 256, outfile); /* MSB fist */
+ fputc(val & 255, outfile); /* LSB */
+
+ /* green */
+ fread(&val, 2, 1, imagefile); /* get data in machine order */
+ fputc(val / 256, outfile); /* MSB fist */
+ fputc(val & 255, outfile); /* LSB */
+
+ /* blue */
+ fread(&val, 2, 1, imagefile); /* get data in machine order */
+ fputc(val / 256, outfile); /* MSB fist */
+ fputc(val & 255, outfile); /* LSB */
+ }
+
+ gtk_progress_bar_update(progress_bar, (float) y / image_info->image_height);
+ while (gtk_events_pending())
+ {
+ gtk_main_iteration();
+ }
+
+
+ if (ferror(outfile))
+ {
+ char buf[255];
+
+ snprintf(buf, sizeof(buf), "%s %s", ERR_DURING_SAVE, strerror(errno));
+ DBG(DBG_error, "%s\n", buf);
+ xsane_back_gtk_decision(ERR_HEADER_ERROR, (gchar **) error_xpm, buf, BUTTON_OK, NULL, TRUE /* wait */);
+ *cancel_save = 1;
+ break;
+ }
+
if (*cancel_save)
{
break;
@@ -2273,13 +3401,31 @@ int xsane_save_pnm_16(FILE *outfile, FILE *imagefile, Image_info *image_info, Gt
{
DBG(DBG_proc, "xsane_save_pnm_16\n");
+ *cancel_save = 0;
+
+ xsane_write_pnm_header(outfile, image_info, preferences.save_pnm16_as_ascii);
+
if (image_info->colors > 1)
{
- xsane_save_pnm_16_color(outfile, imagefile, image_info, progress_bar, cancel_save);
+ if (preferences.save_pnm16_as_ascii)
+ {
+ xsane_save_pnm_16_ascii_color(outfile, imagefile, image_info, progress_bar, cancel_save);
+ }
+ else
+ {
+ xsane_save_pnm_16_binary_color(outfile, imagefile, image_info, progress_bar, cancel_save);
+ }
}
else
{
- xsane_save_pnm_16_gray(outfile, imagefile, image_info, progress_bar, cancel_save);
+ if (preferences.save_pnm16_as_ascii)
+ {
+ xsane_save_pnm_16_ascii_gray(outfile, imagefile, image_info, progress_bar, cancel_save);
+ }
+ else
+ {
+ xsane_save_pnm_16_binary_gray(outfile, imagefile, image_info, progress_bar, cancel_save);
+ }
}
return (*cancel_save);
@@ -2289,7 +3435,7 @@ int xsane_save_pnm_16(FILE *outfile, FILE *imagefile, Image_info *image_info, Gt
/* ---------------------------------------------------------------------------------------------------------------------- */
/* 0=ok, <0=error, 1=canceled */
-int xsane_save_image_as_lineart(char *input_filename, char *output_filename, GtkProgressBar *progress_bar, int *cancel_save)
+int xsane_save_image_as_lineart(char *output_filename, char *input_filename, GtkProgressBar *progress_bar, int *cancel_save)
{
FILE *outfile;
FILE *infile;
@@ -2335,14 +3481,194 @@ int xsane_save_image_as_lineart(char *input_filename, char *output_filename, Gtk
}
/* ---------------------------------------------------------------------------------------------------------------------- */
+
+int xsane_save_image_as_text(char *output_filename, char *input_filename, GtkProgressBar *progress_bar, int *cancel_save)
+{
+ char *arg[1000];
+ char buf[256];
+ int argnr;
+ pid_t pid;
+ int i;
+ int pipefd[2]; /* for progress communication with gocr */
+ FILE *ocr_progress = NULL;
+
+ DBG(DBG_proc, "xsane_save_image_as_text\n");
+
+ argnr = xsane_parse_options(preferences.ocr_command, arg);
+
+ arg[argnr++] = strdup(preferences.ocr_inputfile_option);
+ arg[argnr++] = strdup(input_filename);
+
+ arg[argnr++] = strdup(preferences.ocr_outputfile_option);
+ arg[argnr++] = strdup(output_filename);
+
+ if (preferences.ocr_use_gui_pipe)
+ {
+ if (!pipe(pipefd)) /* success */
+ {
+ DBG(DBG_info, "xsane_save_image_as_text: created pipe for progress communication\n");
+
+ arg[argnr++] = strdup(preferences.ocr_gui_outfd_option);
+
+ snprintf(buf, sizeof(buf),"%d", pipefd[1]);
+ arg[argnr++] = strdup(buf);
+ }
+ else
+ {
+ DBG(DBG_info, "xsane_save_image_as_text: could not create pipe for progress communication\n");
+ pipefd[0] = 0;
+ pipefd[1] = 0;
+ }
+ }
+ else
+ {
+ DBG(DBG_info, "xsane_save_image_as_text: no pipe for progress communication requested\n");
+ pipefd[0] = 0;
+ pipefd[1] = 0;
+ }
+
+ arg[argnr] = 0;
+
+#ifndef HAVE_OS2_H
+ pid = fork();
+
+ if (pid == 0) /* new process */
+ {
+ FILE *ipc_file = NULL;
+
+ if (xsane.ipc_pipefd[0]) /* did we create the progress pipe? */
+ {
+ close(xsane.ipc_pipefd[0]); /* close reading end of pipe */
+ ipc_file = fdopen(xsane.ipc_pipefd[1], "w");
+ }
+
+ if (pipefd[0]) /* did we create the progress pipe? */
+ {
+ close(pipefd[0]); /* close reading end of pipe */
+ }
+
+ DBG(DBG_info, "trying to change user id for new subprocess:\n");
+ DBG(DBG_info, "old effective uid = %d\n", (int) geteuid());
+ setuid(getuid());
+ DBG(DBG_info, "new effective uid = %d\n", (int) geteuid());
+
+
+ execvp(arg[0], arg); /* does not return if successfully */
+ DBG(DBG_error, "%s %s\n", ERR_FAILED_EXEC_OCR_CMD, preferences.ocr_command);
+
+ /* send error message via IPC pipe to parent process */
+ if (ipc_file)
+ {
+ fprintf(ipc_file, "%s %s:\n%s", ERR_FAILED_EXEC_OCR_CMD, preferences.ocr_command, strerror(errno));
+ fflush(ipc_file); /* make sure message is displayed */
+ fclose(ipc_file);
+ }
+
+ _exit(0); /* do not use exit() here! otherwise gtk gets in trouble */
+ }
+
+#else
+ pid = spawnvp(P_NOWAIT, arg[0], arg);
+ if (pid == -1)
+ {
+ DBG(DBG_error, "%s %s\n", ERR_FAILED_EXEC_OCR_CMD, preferences.ocr_command);
+ }
+#endif
+
+ if (pipefd[1])
+ {
+ close(pipefd[1]); /* close writing end of pipe */
+ ocr_progress = fdopen(pipefd[0], "r"); /* open reading end of pipe as file */
+ }
+
+ for (i=0; i<argnr; i++)
+ {
+ free(arg[i]);
+ }
+
+ if (ocr_progress) /* pipe available */
+ {
+ gtk_progress_bar_update(GTK_PROGRESS_BAR(progress_bar), 0.0);
+
+ while (!feof(ocr_progress))
+ {
+ int progress, subprogress;
+ float fprogress;
+
+ fgets(buf, sizeof(buf), ocr_progress);
+
+ if (!strncmp(preferences.ocr_progress_keyword, buf, strlen(preferences.ocr_progress_keyword)))
+ {
+ sscanf(buf + strlen(preferences.ocr_progress_keyword), "%d %d", &progress, &subprogress);
+
+ snprintf(buf, sizeof(buf), "%s (%d:%d)", PROGRESS_OCR, progress, subprogress);
+ gtk_progress_set_format_string(GTK_PROGRESS(progress_bar), buf);
+
+ fprogress = progress / 100.0;
+
+ if (fprogress < 0.0)
+ {
+ fprogress = 0.0;
+ }
+
+ if (fprogress > 11.0)
+ {
+ fprogress = 1.0;
+ }
+
+ gtk_progress_bar_update(GTK_PROGRESS_BAR(progress_bar), fprogress);
+ }
+
+ while (gtk_events_pending())
+ {
+ gtk_main_iteration();
+ }
+ }
+
+ gtk_progress_set_format_string(GTK_PROGRESS(progress_bar), "");
+ gtk_progress_bar_update(GTK_PROGRESS_BAR(progress_bar), 0.0);
+ }
+ else /* no pipe available */
+ {
+ while (pid)
+ {
+ int status = 0;
+ pid_t pid_status = waitpid(pid, &status, WNOHANG);
+
+ if (pid == pid_status)
+ {
+ pid = 0; /* ok, child process has terminated */
+ }
+
+ while (gtk_events_pending())
+ {
+ gtk_main_iteration();
+ }
+ }
+ }
+
+ if (pipefd[0])
+ {
+ fclose(ocr_progress); /* close reading end of pipe */
+ }
+ return (*cancel_save);
+}
+/* ---------------------------------------------------------------------------------------------------------------------- */
-int xsane_save_image_as(char *input_filename, char *output_filename, int output_format, GtkProgressBar *progress_bar, int *cancel_save)
+/* save image in destination file format. lineart images that are stored as grayscale image are reduced to lineart! */
+int xsane_save_image_as(char *output_filename, char *input_filename, int output_format, GtkProgressBar *progress_bar, int *cancel_save)
{
FILE *outfile;
FILE *infile;
char buf[256];
Image_info image_info;
+ char lineart_filename[PATH_MAX];
+ int remove_input_file = FALSE;
+
+ DBG(DBG_proc, "xsane_save_image_as(output_file=%s, input_file=%s, type=%d)\n", output_filename, input_filename, output_format);
+
+ *cancel_save = 0;
infile = fopen(input_filename, "rb"); /* read binary (b for win32) */
if (infile == 0)
@@ -2356,6 +3682,51 @@ int xsane_save_image_as(char *input_filename, char *output_filename, int output_
xsane_read_pnm_header(infile, &image_info);
+ if ((image_info.reduce_to_lineart) && (output_format != XSANE_PNM))
+ {
+ DBG(DBG_info, "original image is a lineart => reduce to lineart\n");
+ fclose(infile);
+ xsane_back_gtk_make_path(sizeof(lineart_filename), lineart_filename, 0, 0, "xsane-conversion-", xsane.dev_name, ".pbm", XSANE_PATH_TMP);
+
+ snprintf(buf, sizeof(buf), "%s: %s", PROGRESS_PACKING_DATA, output_filename);
+
+ gtk_progress_set_format_string(GTK_PROGRESS(progress_bar), buf);
+ gtk_progress_bar_update(GTK_PROGRESS_BAR(progress_bar), 0.0);
+
+ while (gtk_events_pending())
+ {
+ gtk_main_iteration();
+ }
+
+ xsane_save_image_as_lineart(lineart_filename, input_filename, progress_bar, cancel_save);
+
+ input_filename = lineart_filename;
+ remove_input_file = TRUE;
+
+ infile = fopen(input_filename, "rb"); /* read binary (b for win32) */
+ if (infile == 0)
+ {
+ char buf[256];
+ snprintf(buf, sizeof(buf), "%s `%s': %s", ERR_OPEN_FAILED, input_filename, strerror(errno));
+ xsane_back_gtk_error(buf, TRUE);
+
+ return -1;
+ }
+
+ xsane_read_pnm_header(infile, &image_info);
+ }
+
+ snprintf(buf, sizeof(buf), "%s: %s", PROGRESS_SAVING_DATA, output_filename);
+
+ gtk_progress_set_format_string(GTK_PROGRESS(progress_bar), buf);
+ gtk_progress_bar_update(GTK_PROGRESS_BAR(progress_bar), 0.0);
+
+ while (gtk_events_pending())
+ {
+ gtk_main_iteration();
+ }
+
+
#ifdef HAVE_LIBTIFF
if (output_format == XSANE_TIFF) /* routines that want to have filename for saving */
{
@@ -2378,7 +3749,14 @@ int xsane_save_image_as(char *input_filename, char *output_filename, int output_
switch(output_format)
{
case XSANE_PNM:
- xsane_save_rotate_image(outfile, infile, &image_info, 0, progress_bar, cancel_save);
+ if (image_info.reduce_to_lineart)
+ {
+ xsane_save_grayscale_image_as_lineart(outfile, infile, &image_info, progress_bar, cancel_save);
+ }
+ else
+ {
+ xsane_copy_file(outfile, infile, progress_bar, cancel_save);
+ }
break;
#ifdef HAVE_LIBJPEG
@@ -2410,22 +3788,27 @@ int xsane_save_image_as(char *input_filename, char *output_filename, int output_
{
float imagewidth, imageheight;
- imagewidth = image_info.image_width/image_info.resolution_x; /* width in inch */
- imageheight = image_info.image_height/image_info.resolution_y; /* height in inch */
+ imagewidth = 72.0 * image_info.image_width/image_info.resolution_x; /* width in 1/72 inch */
+ imageheight = 72.0 * image_info.image_height/image_info.resolution_y; /* height in 1/72 inch */
xsane_save_ps(outfile, infile,
&image_info,
- 0.0, /* left edge */
- 0.0, /* botoom edge */
imagewidth, imageheight,
- 0.0, /* paperwidth */
- 0.0, /* paperheight */
- 0 /* portrait */,
+ 0, /* paper_left_margin */
+ 0, /* paper_bottom_margin */
+ (int) imagewidth, /* paper_width */
+ (int) imageheight, /* paper_height */
+ 0 /* portrait top left */,
progress_bar,
cancel_save);
}
break; /* switch format == XSANE_PS */
+ case XSANE_TEXT: /* save as text using ocr program like gocr/jocr */
+ {
+ xsane_save_image_as_text(output_filename, input_filename, progress_bar, cancel_save);
+ }
+ break; /* switch format == XSANE_TEXT */
default:
snprintf(buf, sizeof(buf),"%s", ERR_UNKNOWN_SAVING_FORMAT);
@@ -2436,6 +3819,19 @@ int xsane_save_image_as(char *input_filename, char *output_filename, int output_
remove(output_filename); /* no usable output: remove output file */
+ if (remove_input_file)
+ {
+ remove(input_filename); /* remove lineart pbm file */
+ }
+
+ gtk_progress_set_format_string(GTK_PROGRESS(progress_bar), "");
+ gtk_progress_bar_update(GTK_PROGRESS_BAR(progress_bar), 0.0);
+
+ while (gtk_events_pending())
+ {
+ gtk_main_iteration();
+ }
+
return -2;
break; /* switch format == default */
}
@@ -2447,24 +3843,53 @@ int xsane_save_image_as(char *input_filename, char *output_filename, int output_
xsane_back_gtk_error(buf, TRUE);
fclose(infile);
+
+ if (remove_input_file)
+ {
+ remove(input_filename); /* remove lineart pbm file */
+ }
+
+ gtk_progress_set_format_string(GTK_PROGRESS(progress_bar), "");
+ gtk_progress_bar_update(GTK_PROGRESS_BAR(progress_bar), 0.0);
+
+ while (gtk_events_pending())
+ {
+ gtk_main_iteration();
+ }
+
return -2;
}
}
fclose (infile);
+ if (remove_input_file)
+ {
+ remove(input_filename); /* remove lineart pbm file */
+ }
+
if (*cancel_save) /* remove output file if saving has been canceled */
{
remove(output_filename);
}
+ gtk_progress_set_format_string(GTK_PROGRESS(progress_bar), "");
+ gtk_progress_bar_update(GTK_PROGRESS_BAR(progress_bar), 0.0);
+
+ while (gtk_events_pending())
+ {
+ gtk_main_iteration();
+ }
+
return (*cancel_save);
}
/* ---------------------------------------------------------------------------------------------------------------------- */
/* ---------------------------------------------------------------------------------------------------------------------- */
+/* ---------------------------------------------------------------------------------------------------------------------- */
+/* ---------------------------------------------------------------------------------------------------------------------- */
-#ifdef HAVE_LIBGIMP_GIMP_H
+#ifdef HAVE_ANY_GIMP
static int xsane_decode_devname(const char *encoded_devname, int n, char *buf)
{
char *dst, *limit;
@@ -2695,10 +4120,17 @@ static void xsane_gimp_query(void)
/* ---------------------------------------------------------------------------------------------------------------------- */
-static void xsane_gimp_run(char *name, int nparams, GimpParam * param, int *nreturn_vals, GimpParam ** return_vals)
+#ifdef HAVE_GIMP_2
+static void xsane_gimp_run(const gchar *name, gint nparams, const GimpParam *param, gint *nreturn_vals, GimpParam **return_vals)
+{
+ GimpRunMode run_mode;
+#else /* GIMP-1.x */
+static void xsane_gimp_run(char *name, int nparams, GimpParam *param, int *nreturn_vals, GimpParam **return_vals)
{
- static GimpParam values[2];
GimpRunModeType run_mode;
+#endif
+
+ static GimpParam values[2];
char devname[1024];
char *args[2];
int nargs;
@@ -2731,6 +4163,9 @@ static void xsane_gimp_run(char *name, int nparams, GimpParam * param, int *nret
switch (run_mode)
{
case GIMP_RUN_INTERACTIVE:
+#ifdef HAVE_GIMP_2
+ gimp_extension_ack();
+#endif
xsane_interface(nargs, args);
values[0].data.d_status = GIMP_PDB_SUCCESS;
break;
@@ -2957,22 +4392,22 @@ int xsane_transfer_to_gimp(char *input_filename, GtkProgressBar *progress_bar, i
}
}
#ifdef SUPPORT_RGBA
- else if (colors == 4) /* RGBA */
+ else if (image_info.colors == 4) /* RGBA */
{
int i;
- switch (bits)
+ switch (image_info.depth)
{
case 8: /* 8 bit RGBA */
case 16: /* 16 bit RGBA already has been reduced to 8 bit */
- for (i = 0; i < pixel_width*pixel_height*4; ++i)
+ for (i = 0; i < image_info.image_width * image_info.image_height * 4; ++i)
{
tile[tile_offset++] = fgetc(imagefile);
if (tile_offset % 4 == 0)
{
x++;
- if (x >= pixel_width)
+ if (x >= image_info.image_width)
{
int tile_height = gimp_tile_height();
@@ -2981,11 +4416,11 @@ int xsane_transfer_to_gimp(char *input_filename, GtkProgressBar *progress_bar, i
if (y % tile_height == 0)
{
- gimp_pixel_rgn_set_rect(&region, tile, 0, y - tile_height, pixel_width, tile_height);
+ gimp_pixel_rgn_set_rect(&region, tile, 0, y - tile_height, image_info.image_width, tile_height);
tile_offset = 0;
}
- gtk_progress_bar_update(progress_bar, (float) y / pixel_height); /* update progress bar */
+ gtk_progress_bar_update(progress_bar, (float) y / image_info.image_height); /* update progress bar */
while (gtk_events_pending())
{
gtk_main_iteration();
@@ -3029,9 +4464,13 @@ int xsane_transfer_to_gimp(char *input_filename, GtkProgressBar *progress_bar, i
return 0;
}
-#endif /* HAVE_LIBGIMP_GIMP_H */
+#endif /* HAVE_ANY_GIMP */
/* ---------------------------------------------------------------------------------------------------------------------- */
+/* ---------------------------------------------------------------------------------------------------------------------- */
+/* ---------------------------------------------------------------------------------------------------------------------- */
+/* ---------------------------------------------------------------------------------------------------------------------- */
+
#ifdef XSANE_ACTIVATE_MAIL
/* character base of base64 coding */
@@ -3070,7 +4509,7 @@ static void write_3chars_as_base64(unsigned char c1, unsigned char c2, unsigned
void write_base64(int fd_socket, FILE *infile)
{
int c1, c2, c3;
- int pos=0;
+ int pos = 0;
while ((c1 = getc(infile)) != EOF)
{
@@ -3099,12 +4538,22 @@ void write_base64(int fd_socket, FILE *infile)
pos = 0;
}
+
+ xsane.mail_progress_bytes += 3;
+ if ((int) ((xsane.mail_progress_bytes * 100) / xsane.mail_progress_size) != (int) (xsane.mail_progress_val * 100))
+ {
+ xsane.mail_progress_val = (float) xsane.mail_progress_bytes / xsane.mail_progress_size;
+ xsane_front_gtk_mail_project_update_lockfile_status();
+ }
}
if (pos)
{
write(fd_socket, "\n", 1);
}
+
+ xsane.mail_progress_val = 1.0;
+ xsane_front_gtk_mail_project_update_lockfile_status();
}
/* ---------------------------------------------------------------------------------------------------------------------- */
@@ -3199,14 +4648,14 @@ void write_mail_mime_html(int fd_socket, char *boundary)
/* ---------------------------------------------------------------------------------------------------------------------- */
-void write_mail_attach_image_png(int fd_socket, char *boundary, char *content_id, FILE *infile, char *filename)
+void write_mail_attach_image(int fd_socket, char *boundary, char *content_id, char *content_type, FILE *infile, char *filename)
{
char buf[1024];
snprintf(buf, sizeof(buf), "--%s\n", boundary);
write(fd_socket, buf, strlen(buf));
- snprintf(buf, sizeof(buf), "Content-Type: image/png\n");
+ snprintf(buf, sizeof(buf), "Content-Type: %s\n", content_type);
write(fd_socket, buf, strlen(buf));
if (content_id)
@@ -3376,6 +4825,7 @@ int pop3_login(int fd_socket, char *user, char *passwd)
/* ---------------------------------------------------------------------------------------------------------------------- */
/* not only a write routine, also reads data */
+/* returns -1 on error, 0 when ok */
int write_smtp_header(int fd_socket, char *from, char *to)
{
char buf[1024];
@@ -3398,6 +4848,19 @@ int write_smtp_header(int fd_socket, char *from, char *to)
}
DBG(DBG_info2, "< %s\n", buf);
+ if (buf[0] != '2')
+ {
+ DBG(DBG_info, "=> error\n");
+
+ if (xsane.mail_status)
+ {
+ free(xsane.mail_status);
+ }
+ xsane.mail_status = strdup(TEXT_MAIL_STATUS_SMTP_CONNECTION_FAILED);
+ xsane_front_gtk_mail_project_update_lockfile_status();
+ return -1;
+ }
+
snprintf(buf, sizeof(buf), "MAIL FROM: %s\r\n", from);
DBG(DBG_info2, "> %s", buf);
write(fd_socket, buf, strlen(buf));
@@ -3408,6 +4871,20 @@ int write_smtp_header(int fd_socket, char *from, char *to)
}
DBG(DBG_info2, "< %s\n", buf);
+ if (buf[0] != '2')
+ {
+ DBG(DBG_info, "=> error\n");
+
+ if (xsane.mail_status)
+ {
+ free(xsane.mail_status);
+ }
+ xsane.mail_status = strdup(TEXT_MAIL_STATUS_SMTP_ERR_FROM);
+ xsane_front_gtk_mail_project_update_lockfile_status();
+ return -1;
+ }
+
+
snprintf(buf, sizeof(buf), "RCPT TO: %s\r\n", to);
DBG(DBG_info2, "> %s", buf);
write(fd_socket, buf, strlen(buf));
@@ -3418,6 +4895,19 @@ int write_smtp_header(int fd_socket, char *from, char *to)
}
DBG(DBG_info2, "< %s\n", buf);
+ if (buf[0] != '2')
+ {
+ DBG(DBG_info, "=> error\n");
+
+ if (xsane.mail_status)
+ {
+ free(xsane.mail_status);
+ }
+ xsane.mail_status = strdup(TEXT_MAIL_STATUS_SMTP_ERR_RCPT);
+ xsane_front_gtk_mail_project_update_lockfile_status();
+ return -1;
+ }
+
snprintf(buf, sizeof(buf), "DATA\r\n");
DBG(DBG_info2, "> %s", buf);
write(fd_socket, buf, strlen(buf));
@@ -3428,6 +4918,19 @@ int write_smtp_header(int fd_socket, char *from, char *to)
}
DBG(DBG_info2, "< %s\n", buf);
+ if ((buf[0] != '2') && (buf[0] != '3'))
+ {
+ DBG(DBG_info, "=> error\n");
+
+ if (xsane.mail_status)
+ {
+ free(xsane.mail_status);
+ }
+ xsane.mail_status = strdup(TEXT_MAIL_STATUS_SMTP_ERR_DATA);
+ xsane_front_gtk_mail_project_update_lockfile_status();
+ return -1;
+ }
+
return 0;
}
@@ -3439,7 +4942,7 @@ int write_smtp_footer(int fd_socket)
char buf[1024];
int len;
- snprintf(buf, sizeof(buf), ".\r\n");
+ snprintf(buf, sizeof(buf), "\r\n.\r\n");
DBG(DBG_info2, "> %s", buf);
write(fd_socket, buf, strlen(buf));
len = read(fd_socket, buf, sizeof(buf));
diff --git a/src/xsane-save.h b/src/xsane-save.h
index ad30dba..ae8e9a4 100644
--- a/src/xsane-save.h
+++ b/src/xsane-save.h
@@ -3,7 +3,7 @@
xsane-save.h
Oliver Rauch <Oliver.Rauch@rauch-domain.de>
- Copyright (C) 1998-2002 Oliver Rauch
+ Copyright (C) 1998-2005 Oliver Rauch
This file is part of the XSANE package.
This program is free software; you can redistribute it and/or modify
@@ -25,26 +25,31 @@
extern int xsane_create_secure_file(const char *filename);
extern void xsane_cancel_save();
extern void xsane_convert_text_to_filename(char **filename);
+extern int xsane_get_filesize(char *filename);
+extern void xsane_ensure_counter_in_filename(char **filename, int counter_len);
extern void xsane_update_counter_in_filename(char **filename, int skip, int step, int min_counter_len);
extern void xsane_increase_counter_in_filename(char *filename, int skip);
-extern void xsane_read_pnm_header(FILE *infile, Image_info *image_info);
-extern void xsane_write_pnm_header(FILE *outfile, Image_info *image_info);
+extern void xsane_read_pnm_header(FILE *file, Image_info *image_info);
+extern void xsane_write_pnm_header(FILE *file, Image_info *image_info, int save_pnm16_as_ascii);
+extern int xsane_copy_file(FILE *outfile, FILE *infile, GtkProgressBar *progress_bar, int *cancel_save);
+extern int xsane_copy_file_by_name(char *output_filename, char *input_filename, GtkProgressBar *progress_bar, int *cancel_save);
extern int xsane_save_grayscale_image_as_lineart(FILE *outfile, FILE *imagefile, Image_info *image_info, GtkProgressBar *progress_bar, int *cancel_save);
extern int xsane_save_scaled_image(FILE *outfile, FILE *imagefile, Image_info *image_info, float x_scale, float y_scale, GtkProgressBar *progress_bar, int *cancel_save);
extern int xsane_save_despeckle_image(FILE *outfile, FILE *imagefile, Image_info *image_info, int radius, GtkProgressBar *progress_bar, int *cancel_save);
-extern int xsane_save_blur_image(FILE *outfile, FILE *imagefile, Image_info *image_info, int radius, GtkProgressBar *progress_bar, int *cancel_save);
+extern int xsane_save_blur_image(FILE *outfile, FILE *imagefile, Image_info *image_info, float radius, GtkProgressBar *progress_bar, int *cancel_save);
extern int xsane_save_rotate_image(FILE *outfile, FILE *imagefile, Image_info *image_info, int rotation, GtkProgressBar *progress_bar, int *cancel_save);
extern void xsane_save_ps(FILE *outfile, FILE *imagefile, Image_info *image_info,
- int left, int bottom, float width, float height,
- int paperwidth, int paperheight, int landscape,
+ float width, float height,
+ int paper_left_margin, int paper_bottom_margin, int paperwidth, int paperheight, int paper_orientation,
GtkProgressBar *progress_bar, int *cancel_save);
extern void xsane_save_jpeg(FILE *outfile, FILE *imagefile, Image_info *image_info, int quality, GtkProgressBar *progress_bar, int *cancel_save);
extern void xsane_save_tiff(const char *outfilename, FILE *imagefile, Image_info *image_info, int quality, GtkProgressBar *progress_bar, int *cancel_save);
extern void xsane_save_png(FILE *outfile, FILE *imagefile, Image_info *image_info, int compression, GtkProgressBar *progress_bar, int *cancel_save);
extern void xsane_save_png_16(FILE *outfile, FILE *imagefile, Image_info *image_info, int compression, GtkProgressBar *progress_bar, int *cancel_save);
extern void xsane_save_pnm_16(FILE *outfile, FILE *imagefile, Image_info *image_info, GtkProgressBar *progress_bar, int *cancel_save);
-extern int xsane_save_image_as_lineart(char *input_filename, char *output_filename, GtkProgressBar *progress_bar, int *cancel_save);
-extern int xsane_save_image_as(char *input_filename, char *output_filename, int output_format, GtkProgressBar *progress_bar, int *cancel_save);
+extern int xsane_save_image_as_lineart(char *output_filename, char *input_filename, GtkProgressBar *progress_bar, int *cancel_save);
+extern int xsane_save_image_as_text(char *output_filename, char *input_filename, GtkProgressBar *progress_bar, int *cancel_save);
+extern int xsane_save_image_as(char *output_filename, char *input_filename, int output_format, GtkProgressBar *progress_bar, int *cancel_save);
extern void null_print_func(gchar *msg);
extern int xsane_transfer_to_gimp(char *input_filename, GtkProgressBar *progress_bar, int *cancel_save);
extern void write_base64(int fd_socket, FILE *infile);
@@ -52,11 +57,12 @@ extern void write_mail_header(int fd_socket, char *from, char *reply_to, char *t
extern void write_mail_footer(int fd_socket, char *boundary);
extern void write_mail_mime_ascii(int fd_socket, char *boundary);
extern void write_mail_mime_html(int fd_socket, char *boundary);
-extern void write_mail_attach_image_png(int fd_socket, char *boundary, char *content_id, FILE *infile, char *filename);
+extern void write_mail_attach_image(int fd_socket, char *boundary, char *content_id, char *content_type, FILE *infile, char *filename);
extern void write_mail_attach_file(int fd_socket, char *boundary, FILE *infile, char *filename);
extern int open_socket(char *server, int port);
extern int pop3_login(int fd_socket, char *user, char *passwd);
extern int write_smtp_header(int fd_socket, char *from, char *to);
extern int write_smtp_footer(int fd_socket);
+
/* ---------------------------------------------------------------------------------------------------------------------- */
diff --git a/src/xsane-scan.c b/src/xsane-scan.c
index a724e3e..ee0542c 100644
--- a/src/xsane-scan.c
+++ b/src/xsane-scan.c
@@ -3,7 +3,7 @@
xsane-scan.c
Oliver Rauch <Oliver.Rauch@rauch-domain.de>
- Copyright (C) 1998-2002 Oliver Rauch
+ Copyright (C) 1998-2005 Oliver Rauch
This file is part of the XSANE package.
This program is free software; you can redistribute it and/or modify
@@ -50,7 +50,7 @@ static int xsane_test_multi_scan(void);
void xsane_scan_done(SANE_Status status);
void xsane_cancel(void);
static void xsane_start_scan(void);
-void xsane_scan_dialog(GtkWidget * widget, gpointer call_data);
+void xsane_scan_dialog(void);
static void xsane_create_internal_gamma_tables(void);
/* ---------------------------------------------------------------------------------------------------------------------- */
@@ -71,7 +71,7 @@ static int xsane_generate_dummy_filename(int conversion_level)
free(xsane.dummy_filename);
}
- if ( (conversion_level == 0) && (xsane.preview->rotation) ) /* scan level with rotation */
+ if ( (conversion_level == 0) && (xsane.scan_rotation) ) /* scan level with rotation */
{
tempfile = TRUE;
}
@@ -81,24 +81,38 @@ static int xsane_generate_dummy_filename(int conversion_level)
tempfile = TRUE;
}
- if ( (xsane.xsane_mode == XSANE_COPY) ||
- (xsane.xsane_mode == XSANE_FAX) ||
- (xsane.xsane_mode == XSANE_MAIL) ||
+ if ( (xsane.mode == XSANE_GIMP_EXTENSION) ||
+ (xsane.xsane_mode == XSANE_COPY) ||
(xsane.xsane_mode == XSANE_VIEWER) ||
- ( (xsane.xsane_mode == XSANE_SAVE) && (xsane.xsane_output_format != XSANE_PNM) &&
- (xsane.xsane_output_format != XSANE_RAW16) && (xsane.xsane_output_format != XSANE_RGBA) ) )
+ ( (xsane.xsane_mode == XSANE_SAVE) &&
+ (xsane.xsane_output_format != XSANE_PNM) &&
+ (xsane.xsane_output_format != XSANE_RGBA) ) )
{
tempfile = TRUE;
}
if (tempfile) /* save to temporary file */
{
- xsane_back_gtk_make_path(sizeof(filename), filename, 0, 0, "conversion-", xsane.dev_name, ".ppm", XSANE_PATH_TMP);
+ xsane_back_gtk_make_path(sizeof(filename), filename, 0, 0, "xsane-conversion-", xsane.dev_name, ".ppm", XSANE_PATH_TMP);
xsane.dummy_filename = strdup(filename);
DBG(DBG_info, "xsane.dummy_filename = %s\n", xsane.dummy_filename);
return TRUE;
}
+ else if (xsane.xsane_mode == XSANE_FAX) /* no conversion following, save directly to the selected filename */
+ {
+ xsane.dummy_filename = strdup(xsane.fax_filename);
+ DBG(DBG_info, "xsane.dummy_filename = %s\n", xsane.dummy_filename);
+
+ return FALSE;
+ }
+ else if (xsane.xsane_mode == XSANE_MAIL) /* no conversion following, save directly to the selected filename */
+ {
+ xsane.dummy_filename = strdup(xsane.mail_filename);
+ DBG(DBG_info, "xsane.dummy_filename = %s\n", xsane.dummy_filename);
+
+ return FALSE;
+ }
else /* no conversion following, save directly to the selected filename */
{
xsane.dummy_filename = strdup(xsane.output_filename);
@@ -178,14 +192,26 @@ static void xsane_read_image_data(gpointer data, gint source, GdkInputCondition
if (!len) /* nothing read */
{
- break; /* out of data for now, leave while loop */
+ if (xsane.input_tag >= 0)
+ {
+ break; /* leave xsane_read_image_data, will be called by gdk when select_fd event occurs */
+ }
+ else /* no select fd available */
+ {
+ while (gtk_events_pending())
+ {
+ DBG(DBG_info, "calling gtk_main_iteration\n");
+ gtk_main_iteration();
+ }
+ continue; /* we have to keep this loop running because it will never be called again */
+ }
}
xsane.bytes_read += len;
xsane_progress_update(xsane.bytes_read / (gfloat) xsane.num_bytes);
/* it is not allowed to call gtk_main_iteration when we have gdk_input active */
- /* because xsan_read_image_data will be called several times */
+ /* because xsane_read_image_data will be called several times */
if (xsane.input_tag < 0)
{
while (gtk_events_pending())
@@ -245,10 +271,17 @@ static void xsane_read_image_data(gpointer data, gint source, GdkInputCondition
{
*expanded_buf8ptr = (val & (1 << j)) ? 0x00 : 0xff;
expanded_buf8ptr++;
+
+ xsane.lineart_to_grayscale_x--;
+ if (xsane.lineart_to_grayscale_x <= 0)
+ {
+ xsane.lineart_to_grayscale_x = xsane.param.pixels_per_line;
+ break;
+ }
}
buf8ptr++;
}
- fwrite(expanded_buf8, 1, len*8, xsane.out);
+ fwrite(expanded_buf8, 1, (size_t) (expanded_buf8ptr - expanded_buf8), xsane.out);
free(expanded_buf8);
}
else /* save direct to the file */
@@ -301,11 +334,13 @@ static void xsane_read_image_data(gpointer data, gint source, GdkInputCondition
case SANE_FRAME_GREEN:
case SANE_FRAME_BLUE:
{
+ unsigned char rgbbuf[3 * XSANE_3PASS_BUFFER_RGB_SIZE];
+ int pos;
+
DBG(DBG_info, "3 pass color\n");
if (!xsane.scanner_gamma_color) /* gamma correction by xsane */
{
- char val;
SANE_Int *gamma;
if (xsane.param.format == SANE_FRAME_RED)
@@ -323,19 +358,51 @@ static void xsane_read_image_data(gpointer data, gint source, GdkInputCondition
for (i = 0; i < len; ++i)
{
- val = gamma[(int) buf8[i]];
- fputc(val, xsane.out);
- fseek(xsane.out, 2, SEEK_CUR);
+ buf8[i] = gamma[(int) buf8[i]];
}
}
- else /* gamma correction by scanner */
+
+ buf8ptr = buf8;
+ pos = 0;
+
+ while(pos < len)
{
- for (i = 0; i < len; ++i)
+ int cnt, bytes;
+
+ cnt = len - pos;
+
+ if (cnt > XSANE_3PASS_BUFFER_RGB_SIZE)
{
- fputc(buf8[i], xsane.out);
- fseek(xsane.out, 2, SEEK_CUR);
+ cnt = XSANE_3PASS_BUFFER_RGB_SIZE;
}
- }
+
+ bytes = 3 * cnt - 2;
+
+ /* if there already is data: read block of already scanned colors */
+ if( (xsane.param.format > SANE_FRAME_RED) && (cnt > 1) )
+ {
+ long fpos = ftell(xsane.out);
+
+ fseek(xsane.out, 0, SEEK_CUR); /* sync between write and read */
+ fread(rgbbuf, 1, bytes - 1, xsane.out);
+ fseek(xsane.out, fpos, SEEK_SET);
+ }
+
+ /* add just scanned color to block */
+ for(j = 0; j < cnt; j++)
+ {
+ rgbbuf[3 * j] = buf8ptr[j];
+ }
+
+ /* write block back to disk */
+ fwrite(rgbbuf, 1, bytes, xsane.out);
+
+ pos += cnt;
+ buf8ptr += cnt;
+
+ /* skip the bytes for the two other colors */
+ fseek(xsane.out, 2, SEEK_CUR);
+ } /* while(pos < len) */
}
break;
@@ -404,8 +471,6 @@ static void xsane_read_image_data(gpointer data, gint source, GdkInputCondition
unsigned char *buf8 = (unsigned char *) buf16;
unsigned char *buf8ptr;
char buf[255];
- char last = 0;
- int offset = 0;
DBG(DBG_info, "depth = 16 bit\n");
@@ -416,9 +481,9 @@ static void xsane_read_image_data(gpointer data, gint source, GdkInputCondition
break; /* leave while loop */
}
- if (offset) /* if we have had an odd number of bytes */
+ if (xsane.read_offset_16) /* if we have had an odd number of bytes */
{
- buf16[0] = last; /* ATTENTION: that is wrong! */
+ buf8[0] = xsane.last_offset_16_byte;
status = sane_read(dev, ((SANE_Byte *) buf16) + 1, sizeof(buf16) - 1, &len);
if (len)
{
@@ -440,12 +505,12 @@ static void xsane_read_image_data(gpointer data, gint source, GdkInputCondition
if (len % 2) /* odd number of bytes */
{
len--;
- last = buf16[len];
- offset = 1;
+ xsane.last_offset_16_byte = buf16[len];
+ xsane.read_offset_16 = 1;
}
else /* even number of bytes */
{
- offset = 0;
+ xsane.read_offset_16 = 0;
}
if (status == SANE_STATUS_EOF)
@@ -484,7 +549,19 @@ static void xsane_read_image_data(gpointer data, gint source, GdkInputCondition
if (!len) /* nothing read */
{
- break; /* out of data for now, leave while loop */
+ if (xsane.input_tag >= 0)
+ {
+ break; /* leave xsane_read_image_data, will be called by gdk when select_fd event occurs */
+ }
+ else /* no select fd available */
+ {
+ while (gtk_events_pending())
+ {
+ DBG(DBG_info, "calling gtk_main_iteration\n");
+ gtk_main_iteration();
+ }
+ continue; /* we have to keep this loop running because it will never be called again */
+ }
}
xsane.bytes_read += len;
@@ -660,7 +737,7 @@ static void xsane_read_image_data(gpointer data, gint source, GdkInputCondition
{
for (i = 0; i < len/2; ++i)
{
- fwrite(buf16 + i*2, 2, 1, xsane.out);
+ fwrite(buf16 + i, 2, 1, xsane.out);
fseek(xsane.out, 4, SEEK_CUR);
}
}
@@ -896,7 +973,7 @@ static int xsane_reduce_to_lineart()
if (!abort)
{
- abort = xsane_save_image_as_lineart(old_dummy_filename, xsane.dummy_filename, xsane.progress_bar, &xsane.cancel_save);
+ abort = xsane_save_image_as_lineart(xsane.dummy_filename, old_dummy_filename, xsane.progress_bar, &xsane.cancel_save);
}
if (abort)
@@ -981,33 +1058,34 @@ void xsane_scan_done(SANE_Status status)
DBG(DBG_info, "correcting image height to %d lines\n", pixel_height);
xsane.param.lines = pixel_height;
- image_info.image_width = xsane.param.pixels_per_line;
- image_info.image_height = pixel_height;
- image_info.depth = xsane.depth;
- image_info.colors = xsane.xsane_colors;
+ image_info.image_width = xsane.param.pixels_per_line;
+ image_info.image_height = pixel_height;
+ image_info.depth = xsane.depth;
+ image_info.colors = xsane.xsane_colors;
- image_info.resolution_x = xsane.resolution_x;
- image_info.resolution_y = xsane.resolution_y;
+ image_info.resolution_x = xsane.resolution_x;
+ image_info.resolution_y = xsane.resolution_y;
- image_info.gamma = xsane.gamma;
- image_info.gamma_red = xsane.gamma_red;
- image_info.gamma_green = xsane.gamma_green;
- image_info.gamma_blue = xsane.gamma_blue;
+ image_info.gamma = xsane.gamma;
+ image_info.gamma_red = xsane.gamma_red;
+ image_info.gamma_green = xsane.gamma_green;
+ image_info.gamma_blue = xsane.gamma_blue;
- image_info.brightness = xsane.brightness;
- image_info.brightness_red = xsane.brightness_red;
- image_info.brightness_green = xsane.brightness_green;
- image_info.brightness_blue = xsane.brightness_blue;
+ image_info.brightness = xsane.brightness;
+ image_info.brightness_red = xsane.brightness_red;
+ image_info.brightness_green = xsane.brightness_green;
+ image_info.brightness_blue = xsane.brightness_blue;
- image_info.contrast = xsane.contrast;
- image_info.contrast_red = xsane.contrast_red;
- image_info.contrast_green = xsane.contrast_green;
- image_info.contrast_blue = xsane.contrast_blue;
+ image_info.contrast = xsane.contrast;
+ image_info.contrast_red = xsane.contrast_red;
+ image_info.contrast_green = xsane.contrast_green;
+ image_info.contrast_blue = xsane.contrast_blue;
- image_info.threshold = xsane.threshold;
+ image_info.threshold = xsane.threshold;
+ image_info.reduce_to_lineart = xsane.expand_lineart_to_grayscale;
- xsane_write_pnm_header(xsane.out, &image_info);
+ xsane_write_pnm_header(xsane.out, &image_info, 0);
}
DBG(DBG_info, "closing output file\n");
@@ -1020,7 +1098,7 @@ void xsane_scan_done(SANE_Status status)
if ( (status == SANE_STATUS_GOOD) || (status == SANE_STATUS_EOF) ) /* no error, do conversion etc. */
{
/* do we have to rotate the image ? */
- if (xsane.preview->rotation)
+ if (xsane.scan_rotation)
{
char *old_dummy_filename;
int abort = 0;
@@ -1064,7 +1142,7 @@ void xsane_scan_done(SANE_Status status)
if (outfile)
{
- if (xsane_save_rotate_image(outfile, infile, &image_info, xsane.preview->rotation, xsane.progress_bar, &xsane.cancel_save))
+ if (xsane_save_rotate_image(outfile, infile, &image_info, xsane.scan_rotation, xsane.progress_bar, &xsane.cancel_save))
{
abort = 1;
}
@@ -1109,7 +1187,12 @@ void xsane_scan_done(SANE_Status status)
if (xsane.xsane_mode == XSANE_VIEWER)
{
- xsane_viewer_new(xsane.dummy_filename, xsane.expand_lineart_to_grayscale, 0);
+ xsane_viewer_new(xsane.dummy_filename, TRUE, NULL, VIEWER_FULL_MODIFICATION);
+ xsane.expand_lineart_to_grayscale = 0;
+ }
+
+ if ((xsane.xsane_mode == XSANE_FAX) || (xsane.xsane_mode == XSANE_MAIL))
+ {
xsane.expand_lineart_to_grayscale = 0;
}
@@ -1143,7 +1226,6 @@ void xsane_scan_done(SANE_Status status)
}
if ( ( (xsane.xsane_output_format != XSANE_PNM) && /* these files do not need any transformation */
- (xsane.xsane_output_format != XSANE_RAW16) &&
(xsane.xsane_output_format != XSANE_RGBA) ) ||
(xsane.mode == XSANE_GIMP_EXTENSION) )
{ /* ok, we have to do a transformation */
@@ -1156,15 +1238,15 @@ void xsane_scan_done(SANE_Status status)
}
-#ifdef HAVE_LIBGIMP_GIMP_H
+#ifdef HAVE_ANY_GIMP
if (xsane.mode == XSANE_GIMP_EXTENSION) /* xsane runs as gimp plugin */
{
xsane_transfer_to_gimp(xsane.dummy_filename, xsane.progress_bar, &xsane.cancel_save);
}
else
-#endif /* HAVE_LIBGIMP_GIMP_H */
+#endif /* HAVE_ANY_GIMP */
{
- xsane_save_image_as(xsane.dummy_filename, xsane.output_filename, xsane.xsane_output_format, xsane.progress_bar, &xsane.cancel_save);
+ xsane_save_image_as(xsane.output_filename, xsane.dummy_filename, xsane.xsane_output_format, xsane.progress_bar, &xsane.cancel_save);
}
xsane_progress_clear();
@@ -1206,14 +1288,13 @@ void xsane_scan_done(SANE_Status status)
preferences.printer[preferences.printernr]->copy_number_option,
xsane.copy_number);
outfile = popen(buf, "w");
-/* outfile = popen(preferences.printer[preferences.printernr]->command, "w"); */
if ((outfile != 0) && (infile != 0)) /* copy mode, use zoom size */
{
struct SIGACTION act;
float imagewidth, imageheight;
int printer_resolution;
- switch (xsane.param.format)
+ switch (xsane.param.format)
{
case SANE_FRAME_GRAY:
if (xsane.depth == 1)
@@ -1237,48 +1318,26 @@ void xsane_scan_done(SANE_Status status)
xsane_read_pnm_header(infile, &image_info);
- imagewidth = image_info.image_width/(float)printer_resolution; /* width in inch */
- imageheight = image_info.image_height/(float)printer_resolution; /* height in inch */
+ imagewidth = 72.0 * image_info.image_width/(float)printer_resolution; /* width in 1/72 inch */
+ imageheight = 72.0 * image_info.image_height/(float)printer_resolution; /* height in 1/72 inch */
memset (&act, 0, sizeof (act)); /* define broken pipe handler */
act.sa_handler = xsane_sigpipe_handler;
sigaction (SIGPIPE, &act, 0);
-
- if (preferences.psrotate) /* rotate: landscape */
- {
- xsane_save_ps(outfile, infile,
- &image_info,
- (preferences.printer[preferences.printernr]->bottomoffset +
- preferences.printer[preferences.printernr]->height) * 36.0/MM_PER_INCH - imagewidth * 36.0, /* left edge */
- (preferences.printer[preferences.printernr]->leftoffset +
- preferences.printer[preferences.printernr]->width) * 36.0/MM_PER_INCH - imageheight * 36.0, /* bottom edge */
- imagewidth, imageheight,
- (preferences.printer[preferences.printernr]->leftoffset +
- preferences.printer[preferences.printernr]->width ) * 72.0/MM_PER_INCH, /* paperwidth */
- (preferences.printer[preferences.printernr]->bottomoffset +
- preferences.printer[preferences.printernr]->height) * 72.0/MM_PER_INCH, /* paperheight */
- 1 /* landscape */,
- xsane.progress_bar,
- &xsane.cancel_save);
- }
- else /* do not rotate: portrait */
- {
- xsane_save_ps(outfile, infile,
- &image_info,
- (preferences.printer[preferences.printernr]->leftoffset +
- preferences.printer[preferences.printernr]->width) * 36.0/MM_PER_INCH - imagewidth * 36.0, /* left edge */
- (preferences.printer[preferences.printernr]->bottomoffset +
- preferences.printer[preferences.printernr]->height) * 36.0/MM_PER_INCH - imageheight * 36.0, /* bottom edge */
- imagewidth, imageheight,
- (preferences.printer[preferences.printernr]->leftoffset +
- preferences.printer[preferences.printernr]->width ) * 72.0/MM_PER_INCH, /* paperwidth */
- (preferences.printer[preferences.printernr]->bottomoffset +
- preferences.printer[preferences.printernr]->height) * 72.0/MM_PER_INCH, /* paperheight */
- 0 /* portrait */,
- xsane.progress_bar,
- &xsane.cancel_save);
- }
+ DBG(DBG_info, "imagewidth = %f\n 1/72 inch", imagewidth);
+ DBG(DBG_info, "imageheight = %f\n 1/72 inch", imageheight);
+
+ xsane_save_ps(outfile, infile,
+ &image_info,
+ imagewidth, imageheight,
+ preferences.printer[preferences.printernr]->leftoffset * 72.0/MM_PER_INCH, /* paper_left_margin */
+ preferences.printer[preferences.printernr]->bottomoffset * 72.0/MM_PER_INCH, /* paper_bottom_margin */
+ preferences.printer[preferences.printernr]->width * 72.0/MM_PER_INCH, /* usable paperwidth */
+ preferences.printer[preferences.printernr]->height * 72.0/MM_PER_INCH, /* usable paperheight */
+ preferences.paper_orientation,
+ xsane.progress_bar,
+ &xsane.cancel_save);
}
else
{
@@ -1318,120 +1377,6 @@ void xsane_scan_done(SANE_Status status)
pclose(outfile);
}
}
- else if (xsane.xsane_mode == XSANE_FAX)
- {
- FILE *outfile;
- FILE *infile;
-
- /* open progressbar */
- xsane_progress_new(PROGRESS_CONVERTING_DATA, PROGRESS_TRANSFERING_DATA, (GtkSignalFunc) xsane_cancel_save, &xsane.cancel_save);
-
- while (gtk_events_pending())
- {
- gtk_main_iteration();
- }
-
- infile = fopen(xsane.dummy_filename, "rb"); /* read binary (b for win32) */
- if (infile != 0)
- {
- xsane_read_pnm_header(infile, &image_info);
-
- umask((mode_t) preferences.image_umask); /* define image file permissions */
- outfile = fopen(xsane.fax_filename, "wb"); /* b = binary mode for win32 */
- umask(XSANE_DEFAULT_UMASK); /* define new file permissions */
- if (outfile != 0)
- {
- float imagewidth, imageheight;
-
- imagewidth = image_info.image_width/xsane.resolution_x; /* width in inch */
- imageheight = image_info.image_height/xsane.resolution_y; /* height in inch */
-
- DBG(DBG_info, "imagewidth = %f\n", imagewidth);
- DBG(DBG_info, "imageheight = %f\n", imageheight);
-
- xsane_save_ps(outfile, infile,
- &image_info,
- (preferences.fax_leftoffset + preferences.fax_width) * 36.0/MM_PER_INCH - imagewidth * 36.0,
- (preferences.fax_bottomoffset + preferences.fax_height) * 36.0/MM_PER_INCH - imageheight * 36.0,
- imagewidth, imageheight,
- (preferences.fax_leftoffset + preferences.fax_width ) * 72.0/MM_PER_INCH, /* paperwidth */
- (preferences.fax_bottomoffset + preferences.fax_height) * 72.0/MM_PER_INCH, /* paperheight */
- 0 /* portrait */,
- xsane.progress_bar,
- &xsane.cancel_save);
- fclose(outfile);
- }
- else
- {
- char buf[256];
-
- DBG(DBG_info, "open of faxfile `%s'failed : %s\n", xsane.fax_filename, strerror(errno));
-
- snprintf(buf, sizeof(buf), "%s `%s': %s", ERR_OPEN_FAILED, xsane.fax_filename, strerror(errno));
- xsane_back_gtk_error(buf, TRUE);
- }
-
- fclose(infile);
- remove(xsane.dummy_filename);
- }
- else
- {
- char buf[256];
-
- DBG(DBG_info, "open of faxfile `%s'failed : %s\n", xsane.fax_filename, strerror(errno));
-
- snprintf(buf, sizeof(buf), "%s `%s': %s", ERR_OPEN_FAILED, xsane.fax_filename, strerror(errno));
- xsane_back_gtk_error(buf, TRUE);
- }
- xsane_progress_clear();
-
- while (gtk_events_pending())
- {
- DBG(DBG_info, "calling gtk_main_iteration");
- gtk_main_iteration();
- }
- }
-#ifdef XSANE_ACTIVATE_MAIL
- else if (xsane.xsane_mode == XSANE_MAIL)
- {
- FILE *infile;
-
- /* open progressbar */
- xsane_progress_new(PROGRESS_CONVERTING_DATA, PROGRESS_TRANSFERING_DATA, (GtkSignalFunc) xsane_cancel_save, &xsane.cancel_save);
-
- while (gtk_events_pending())
- {
- gtk_main_iteration();
- }
-
- infile = fopen(xsane.dummy_filename, "rb"); /* read binary (b for win32) */
- if (infile != 0)
- {
- xsane_read_pnm_header(infile, &image_info);
-
- xsane_save_image_as(xsane.dummy_filename, xsane.mail_filename, XSANE_PNG, xsane.progress_bar, &xsane.cancel_save);
-
- fclose(infile);
- remove(xsane.dummy_filename);
- }
- else
- {
- char buf[256];
-
- DBG(DBG_info, "open of mailfile `%s'failed : %s\n", xsane.dummy_filename, strerror(errno));
-
- snprintf(buf, sizeof(buf), "%s `%s': %s", ERR_OPEN_FAILED, xsane.dummy_filename, strerror(errno));
- xsane_back_gtk_error(buf, TRUE);
- }
- xsane_progress_clear();
-
- while (gtk_events_pending())
- {
- DBG(DBG_info, "calling gtk_main_iteration");
- gtk_main_iteration();
- }
- }
-#endif
if ( (xsane.xsane_mode == XSANE_SAVE) && (xsane.mode == XSANE_STANDALONE) )
{
@@ -1441,7 +1386,7 @@ void xsane_scan_done(SANE_Status status)
{
xsane_update_counter_in_filename(&preferences.filename, preferences.skip_existing_numbers,
preferences.filename_counter_step, preferences.filename_counter_len);
- gtk_entry_set_text(GTK_ENTRY(xsane.outputfilename_entry), (char *) preferences.filename); /* update filename in entry */
+ xsane_set_filename(preferences.filename); /* update filename in entry */
gtk_entry_set_position(GTK_ENTRY(xsane.outputfilename_entry), strlen(preferences.filename)); /* set cursor to right position of filename */
}
}
@@ -1454,44 +1399,84 @@ void xsane_scan_done(SANE_Status status)
{
GtkWidget *list_item;
char *page;
+ char *type;
char *extension;
page = strdup(strrchr(xsane.fax_filename,'/')+1);
extension = strrchr(page, '.');
if (extension)
{
+ type = strdup(extension);
*extension = 0;
}
+ else
+ {
+ type = "";
+ }
+
list_item = gtk_list_item_new_with_label(page);
gtk_object_set_data(GTK_OBJECT(list_item), "list_item_data", strdup(page));
+ gtk_object_set_data(GTK_OBJECT(list_item), "list_item_type", strdup(type));
gtk_container_add(GTK_CONTAINER(xsane.fax_list), list_item);
gtk_widget_show(list_item);
xsane_update_counter_in_filename(&xsane.fax_filename, TRUE, 1, preferences.filename_counter_len);
xsane_fax_project_save();
free(page);
+ free(type);
+
+ if (xsane.fax_status)
+ {
+ free(xsane.fax_status);
+ }
+ xsane.fax_status = strdup(TEXT_FAX_STATUS_CHANGED);
+
+ xsane_fax_project_save();
+
+ gtk_progress_set_format_string(GTK_PROGRESS(xsane.fax_progress_bar), _(xsane.fax_status));
+ gtk_progress_bar_update(GTK_PROGRESS_BAR(xsane.fax_progress_bar), 0.0);
}
#ifdef XSANE_ACTIVATE_MAIL
else if (xsane.xsane_mode == XSANE_MAIL)
{
GtkWidget *list_item;
- char *image;
+ char *page;
+ char *type;
char *extension;
- image = strdup(strrchr(xsane.mail_filename,'/')+1);
- extension = strrchr(image, '.');
+ page = strdup(strrchr(xsane.mail_filename,'/')+1);
+ extension = strrchr(page, '.');
if (extension)
{
+ type = strdup(extension);
*extension = 0;
}
- list_item = gtk_list_item_new_with_label(image);
- gtk_object_set_data(GTK_OBJECT(list_item), "list_item_data", strdup(image));
+ else
+ {
+ type = "";
+ }
+
+ list_item = gtk_list_item_new_with_label(page);
+ gtk_object_set_data(GTK_OBJECT(list_item), "list_item_data", strdup(page));
+ gtk_object_set_data(GTK_OBJECT(list_item), "list_item_type", strdup(type));
gtk_container_add(GTK_CONTAINER(xsane.mail_list), list_item);
gtk_widget_show(list_item);
xsane_update_counter_in_filename(&xsane.mail_filename, TRUE, 1, preferences.filename_counter_len);
xsane_mail_project_save();
- free(image);
+ free(page);
+ free(type);
+
+ if (xsane.mail_status)
+ {
+ free(xsane.mail_status);
+ }
+ xsane.mail_status = strdup(TEXT_MAIL_STATUS_CHANGED);
+
+ xsane_mail_project_save();
+
+ gtk_progress_set_format_string(GTK_PROGRESS(xsane.mail_progress_bar), _(xsane.mail_status));
+ gtk_progress_bar_update(GTK_PROGRESS_BAR(xsane.mail_progress_bar), 0.0);
}
#endif
}
@@ -1522,16 +1507,26 @@ void xsane_scan_done(SANE_Status status)
/* b) sane_start returns SANE_STATUS_NO_DOCS */
/* c) an error occurs */
+ DBG(DBG_info, "ADF mode end of scan: increment page counter and restart scan\n");
xsane.adf_page_counter += 1;
- gtk_signal_emit_by_name(xsane.start_button, "clicked"); /* press START button */
+ g_signal_emit_by_name(xsane.start_button, "clicked"); /* press START button */
+ }
+ else if ( ( (status == SANE_STATUS_GOOD) || (status == SANE_STATUS_EOF) ) && (xsane.batch_loop) )
+ {
+ /* batch scan loop, this is not the last scan */
+ DBG(DBG_info, "Batch mode end of scan\n");
+ sane_cancel(xsane.dev); /* we have to call sane_cancel otherwise we are not able to set new parameters */
}
- else /* last scan: update histogram */
+ else if ( ( (status != SANE_STATUS_GOOD) && (status != SANE_STATUS_EOF) ) || (!xsane.batch_loop) ) /* last scan: update histogram */
{
+ DBG(DBG_info, "Normal end of scan\n");
xsane_set_sensitivity(TRUE); /* reactivate buttons etc */
sane_cancel(xsane.dev); /* stop scanning */
xsane_update_histogram(TRUE /* update raw */);
xsane_update_param(0);
}
+
+ xsane.status_of_last_scan = status;
}
/* ---------------------------------------------------------------------------------------------------------------------- */
@@ -1581,6 +1576,8 @@ static void xsane_start_scan(void)
gtk_main_iteration();
}
+ xsane.read_offset_16 = 0; /* no last byte of old 16 bit data */
+
status = sane_start(dev);
DBG(DBG_info, "sane_start returned with status %s\n", XSANE_STRSTATUS(status));
@@ -1630,14 +1627,16 @@ static void xsane_start_scan(void)
default: frame_type = "unknown"; break;
}
- if ( (xsane.param.depth == 1) && (xsane.preview->rotation) )
+ if ((xsane.param.depth == 1) && ((xsane.scan_rotation) ||
+ (xsane.xsane_mode == XSANE_VIEWER) ||
+ (xsane.xsane_mode == XSANE_FAX) ||
+ (xsane.xsane_mode == XSANE_MAIL))
+ ) /* We want to do a transformation with a lineart scan */
+ /* or use the viewer to display a lineart scan, */
+ /* so we save it as grayscale */
{
- xsane.expand_lineart_to_grayscale = 1; /* We want to do transformation with lineart scan, so we save it as grayscale */
- }
-
- if ((xsane.xsane_mode == XSANE_VIEWER) && (xsane.param.depth == 1))
- {
- xsane.expand_lineart_to_grayscale = 1; /* we are using the viewer, lineart is not supported, so create grayscale */
+ DBG(DBG_proc, "lineart scan will be expanded to grayscale\n");
+ xsane.expand_lineart_to_grayscale = 1;
}
if (!xsane.header_size) /* first pass of multi pass scan or single pass scan */
@@ -1657,7 +1656,8 @@ static void xsane_start_scan(void)
}
}
- xsane.out = fopen(xsane.dummy_filename, "wb"); /* b = binary mode for win32 */
+ /* create file: + = also allow read for blocked rgb multiplexing, b = binary mode for win32 */
+ xsane.out = fopen(xsane.dummy_filename, "wb+");
if (!xsane.out) /* error while opening the dummy_file for writing */
{
@@ -1698,7 +1698,9 @@ static void xsane_start_scan(void)
image_info.threshold = xsane.threshold;
- xsane_write_pnm_header(xsane.out, &image_info);
+ image_info.reduce_to_lineart = xsane.expand_lineart_to_grayscale;
+
+ xsane_write_pnm_header(xsane.out, &image_info, 0);
fflush(xsane.out);
xsane.header_size = ftell(xsane.out); /* store header size for 3 pass scan */
@@ -1722,17 +1724,14 @@ static void xsane_start_scan(void)
xsane.input_tag = -1;
+ xsane.lineart_to_grayscale_x = xsane.param.pixels_per_line;
#ifndef BUGGY_GDK_INPUT_EXCEPTION
- /* for unix */
if ((sane_set_io_mode(dev, SANE_TRUE) == SANE_STATUS_GOOD) && (sane_get_select_fd(dev, &fd) == SANE_STATUS_GOOD))
{
DBG(DBG_info, "gdk_input_add\n");
xsane.input_tag = gdk_input_add(fd, GDK_INPUT_READ | GDK_INPUT_EXCEPTION, xsane_read_image_data, 0);
}
else
-#else
- /* for win32 */
- sane_set_io_mode(dev, SANE_FALSE);
#endif
{
xsane_read_image_data(0, -1, GDK_INPUT_READ);
@@ -1743,13 +1742,15 @@ static void xsane_start_scan(void)
/* Invoked when the scan button is pressed */
/* or by scan_done if automatic document feeder is selected */
-void xsane_scan_dialog(GtkWidget * widget, gpointer call_data)
+void xsane_scan_dialog(void)
{
char buf[256];
const SANE_Option_Descriptor *opt;
DBG(DBG_proc, "xsane_scan_dialog\n");
+ xsane_set_sensitivity(FALSE);
+
xsane.reduce_16bit_to_8bit = preferences.reduce_16bit_to_8bit; /* reduce 16 bit image to 8 bit ? */
sane_get_parameters(xsane.dev, &xsane.param); /* update xsane.param */
@@ -1759,8 +1760,12 @@ void xsane_scan_dialog(GtkWidget * widget, gpointer call_data)
/* correct length of filename counter if it is shorter than minimum length */
if (!xsane.force_filename)
{
+ if (xsane.batch_loop) /* we are doing a batch scan, so we need a counter in the filename */
+ {
+ xsane_ensure_counter_in_filename(&preferences.filename, preferences.filename_counter_len);
+ }
xsane_update_counter_in_filename(&preferences.filename, FALSE, 0, preferences.filename_counter_len);
- gtk_entry_set_text(GTK_ENTRY(xsane.outputfilename_entry), preferences.filename);
+ xsane_set_filename(preferences.filename);
}
}
@@ -1781,15 +1786,17 @@ void xsane_scan_dialog(GtkWidget * widget, gpointer call_data)
char buf[256];
fclose(testfile);
+
snprintf(buf, sizeof(buf), WARN_FILE_EXISTS, xsane.output_filename);
if (xsane_back_gtk_decision(ERR_HEADER_WARNING, (gchar **) warning_xpm, buf, BUTTON_OVERWRITE, BUTTON_CANCEL, TRUE /* wait */) == FALSE)
{
+ xsane_set_sensitivity(TRUE);
return;
}
}
}
- xsane.xsane_output_format = xsane_identify_output_format(xsane.output_filename, &extension);
+ xsane.xsane_output_format = xsane_identify_output_format(xsane.output_filename, preferences.filetype, &extension);
if (xsane.xsane_mode == XSANE_SAVE)
{
@@ -1804,8 +1811,10 @@ void xsane_scan_dialog(GtkWidget * widget, gpointer call_data)
snprintf(buf, sizeof(buf), "%s", ERR_NO_OUTPUT_FORMAT);
}
xsane_back_gtk_error(buf, TRUE);
- return;
+ xsane_set_sensitivity(TRUE);
+ return;
}
+#if 0 /* this is not necessary any more because the saving routines do the conversion */
else if ( ( ( (xsane.xsane_output_format == XSANE_JPEG) && xsane.param.depth == 16) ||
( (xsane.xsane_output_format == XSANE_PS) && xsane.param.depth == 16) ) &&
( !xsane.reduce_16bit_to_8bit) )
@@ -1814,17 +1823,20 @@ void xsane_scan_dialog(GtkWidget * widget, gpointer call_data)
snprintf(buf, sizeof(buf), TEXT_REDUCE_16BIT_TO_8BIT);
if (xsane_back_gtk_decision(ERR_HEADER_INFO, (gchar **) info_xpm, buf, BUTTON_REDUCE, BUTTON_CANCEL, TRUE /* wait */) == FALSE)
{
- return;
+ xsane_set_sensitivity(TRUE);
+ return;
}
xsane.reduce_16bit_to_8bit = TRUE;
}
+#endif
#ifdef SUPPORT_RGBA
else if ((xsane.xsane_output_format == XSANE_RGBA) && (xsane.param.format != SANE_FRAME_RGBA))
{
snprintf(buf, sizeof(buf), "No RGBA data format !!!"); /* user selected output format RGBA, scanner uses other format */
xsane_back_gtk_error(buf, TRUE);
- return;
+ xsane_set_sensitivity(TRUE);
+ return;
}
#endif
}
@@ -1833,7 +1845,8 @@ void xsane_scan_dialog(GtkWidget * widget, gpointer call_data)
{
snprintf(buf, sizeof(buf), "Special format RGBA only supported in scan mode !!!");
xsane_back_gtk_error(buf, TRUE);
- return;
+ xsane_set_sensitivity(TRUE);
+ return;
}
#endif
@@ -1844,7 +1857,8 @@ void xsane_scan_dialog(GtkWidget * widget, gpointer call_data)
{
snprintf(buf, sizeof(buf), "Image data of type SANE_FRAME_RGBA\ncan only be saved in rgba or png format");
xsane_back_gtk_error(buf, TRUE);
- return;
+ xsane_set_sensitivity(TRUE);
+ return;
}
}
#endif
@@ -1859,7 +1873,7 @@ void xsane_scan_dialog(GtkWidget * widget, gpointer call_data)
free(extension);
}
}
-#ifdef HAVE_LIBGIMP_GIMP_H
+#ifdef HAVE_ANY_GIMP
else /* We are running in gimp mode */
{
if ((xsane.param.depth != 1) && (xsane.param.depth != 8)) /* not support bit depth ? */
@@ -1871,7 +1885,8 @@ void xsane_scan_dialog(GtkWidget * widget, gpointer call_data)
snprintf(buf, sizeof(buf), TEXT_GIMP_REDUCE_16BIT_TO_8BIT);
if (xsane_back_gtk_decision(ERR_HEADER_INFO, (gchar **) info_xpm, buf, BUTTON_REDUCE, BUTTON_CANCEL, TRUE /* wait */) == FALSE)
{
- return;
+ xsane_set_sensitivity(TRUE);
+ return;
}
xsane.reduce_16bit_to_8bit = TRUE;
}
@@ -1879,6 +1894,7 @@ void xsane_scan_dialog(GtkWidget * widget, gpointer call_data)
{
snprintf(buf, sizeof(buf), ERR_GIMP_BAD_DEPTH, xsane.param.depth);
xsane_back_gtk_error(buf, TRUE);
+ xsane_set_sensitivity(TRUE);
return;
}
}
@@ -2028,9 +2044,11 @@ void xsane_scan_dialog(GtkWidget * widget, gpointer call_data)
xsane.gamma_data = 0;
}
+#if 0
xsane_clear_histogram(&xsane.histogram_raw);
xsane_clear_histogram(&xsane.histogram_enh);
xsane_set_sensitivity(FALSE);
+#endif
while (gtk_events_pending())
{
diff --git a/src/xsane-scan.h b/src/xsane-scan.h
index db2259c..3cacb55 100644
--- a/src/xsane-scan.h
+++ b/src/xsane-scan.h
@@ -3,7 +3,7 @@
xsane-scan.h
Oliver Rauch <Oliver.Rauch@rauch-domain.de>
- Copyright (C) 1998-2002 Oliver Rauch
+ Copyright (C) 1998-2005 Oliver Rauch
This file is part of the XSANE package.
This program is free software; you can redistribute it and/or modify
@@ -28,6 +28,6 @@
extern void xsane_scan_done(SANE_Status status);
extern void xsane_cancel(void);
-extern void xsane_scan_dialog(GtkWidget * widget, gpointer call_data);
+extern void xsane_scan_dialog(void);
/* ---------------------------------------------------------------------------------------------------------------------- */
diff --git a/src/xsane-setup.c b/src/xsane-setup.c
index be15672..b420643 100644
--- a/src/xsane-setup.c
+++ b/src/xsane-setup.c
@@ -3,7 +3,7 @@
xsane-setup.c
Oliver Rauch <Oliver.Rauch@rauch-domain.de>
- Copyright (C) 1998-2002 Oliver Rauch
+ Copyright (C) 1998-2005 Oliver Rauch
This file is part of the XSANE package.
This program is free software; you can redistribute it and/or modify
@@ -30,6 +30,7 @@
#include "xsane-preview.h"
#include "xsane-save.h"
#include "xsane-gamma.h"
+#include "xsane-batch-scan.h"
#ifdef HAVE_LIBPNG
#ifdef HAVE_LIBZ
@@ -86,6 +87,7 @@ static void xsane_mail_notebook(GtkWidget *notebook);
#endif
static void xsane_display_notebook(GtkWidget *notebook);
static void xsane_enhance_notebook_sensitivity(int lineart_mode);
+static void xsane_setup_show_range_mode_callback(GtkWidget *widget, gpointer data);
static void xsane_setup_lineart_mode_callback(GtkWidget *widget, gpointer data);
static void xsane_enhance_notebook(GtkWidget *notebook);
@@ -147,7 +149,8 @@ void xsane_new_printer(void)
void xsane_update_int(GtkWidget *widget, int *val)
{
- char *start, *end;
+ const char *start;
+ char *end;
int v;
DBG(DBG_proc, "xsane_update_init\n");
@@ -185,7 +188,8 @@ static void xsane_update_scale(GtkWidget *widget, double *val)
static void xsane_update_geometry_double(GtkWidget *widget, double *val, double length_multiplier)
{
- char *start, *end;
+ const char *start;
+ char *end;
double v;
DBG(DBG_proc, "xsane_update_geometry_double\n");
@@ -208,7 +212,8 @@ static void xsane_update_geometry_double(GtkWidget *widget, double *val, double
/* returns 0 if value is unchaned */
static int xsane_update_double(GtkWidget *widget, double *val)
{
- char *start, *end;
+ const char *start;
+ char *end;
double v;
int value_changed = 0;
@@ -294,7 +299,7 @@ static void xsane_setup_printer_menu_build(GtkWidget *option_menu)
{
printer_item = gtk_menu_item_new_with_label(preferences.printer[i]->name);
gtk_container_add(GTK_CONTAINER(printer_menu), printer_item);
- gtk_signal_connect(GTK_OBJECT(printer_item), "activate", (GtkSignalFunc) xsane_setup_printer_callback, (void *) i);
+ g_signal_connect(GTK_OBJECT(printer_item), "activate", (GtkSignalFunc) xsane_setup_printer_callback, (void *) i);
gtk_widget_show(printer_item);
}
@@ -445,6 +450,8 @@ static void xsane_setup_display_apply_changes(GtkWidget *widget, gpointer data)
xsane_update_bool(xsane_setup.main_window_fixed_button, &preferences.main_window_fixed);
xsane_update_bool(xsane_setup.preview_own_cmap_button, &preferences.preview_own_cmap);
+ preferences.show_range_mode = xsane_setup.show_range_mode;
+
xsane_update_double(xsane_setup.preview_gamma_entry, &preferences.preview_gamma);
xsane_update_double(xsane_setup.preview_gamma_red_entry, &preferences.preview_gamma_red);
xsane_update_double(xsane_setup.preview_gamma_green_entry, &preferences.preview_gamma_green);
@@ -453,13 +460,15 @@ static void xsane_setup_display_apply_changes(GtkWidget *widget, gpointer data)
xsane_update_double(xsane_setup.preview_oversampling_entry, &preferences.preview_oversampling);
- if (preferences.doc_viewer)
+ if (preferences.browser)
{
- free((void *) preferences.doc_viewer);
+ free((void *) preferences.browser);
}
- preferences.doc_viewer = strdup(gtk_entry_get_text(GTK_ENTRY(xsane_setup.doc_viewer_entry)));
+ preferences.browser = strdup(gtk_entry_get_text(GTK_ENTRY(xsane_setup.browser_entry)));
xsane_update_gamma_curve(TRUE /* update raw */);
+
+ xsane_batch_scan_update_icon_list(); /* update gamma of batch scan icons */
}
/* ---------------------------------------------------------------------------------------------------------------------- */
@@ -598,6 +607,7 @@ static void xsane_setup_image_apply_changes(GtkWidget *widget, gpointer data)
preferences.tiff_compression1_nr = xsane_setup.tiff_compression1_nr;
#endif
+ xsane_update_bool(xsane_setup.save_pnm16_as_ascii_button, &preferences.save_pnm16_as_ascii);
xsane_update_bool(xsane_setup.reduce_16bit_to_8bit_button, &preferences.reduce_16bit_to_8bit);
xsane_define_maximum_output_size();
@@ -681,6 +691,20 @@ static void xsane_setup_ocr_apply_changes(GtkWidget *widget, gpointer data)
free((void *) preferences.ocr_outputfile_option);
}
preferences.ocr_outputfile_option = strdup(gtk_entry_get_text(GTK_ENTRY(xsane_setup.ocr_outputfile_option_entry)));
+
+ xsane_update_bool(xsane_setup.ocr_use_gui_pipe_entry, &preferences.ocr_use_gui_pipe);
+
+ if (preferences.ocr_gui_outfd_option)
+ {
+ free((void *) preferences.ocr_gui_outfd_option);
+ }
+ preferences.ocr_gui_outfd_option = strdup(gtk_entry_get_text(GTK_ENTRY(xsane_setup.ocr_gui_outfd_option_entry)));
+
+ if (preferences.ocr_progress_keyword)
+ {
+ free((void *) preferences.ocr_progress_keyword);
+ }
+ preferences.ocr_progress_keyword = strdup(gtk_entry_get_text(GTK_ENTRY(xsane_setup.ocr_progress_keyword_entry)));
}
/* ---------------------------------------------------------------------------------------------------------------------- */
@@ -754,7 +778,7 @@ static void xsane_permission_toggled(GtkWidget *widget, gpointer data)
{
int mask = (int) data;
int *permission = 0;
- gchar *name = gtk_widget_get_name(widget);
+ const gchar *name = gtk_widget_get_name(widget);
DBG(DBG_proc, "xsane_permission_toggled\n");
@@ -795,17 +819,17 @@ static void xsane_permission_box(GtkWidget *parent, gchar *name, gchar *descript
gtk_box_pack_start(GTK_BOX(parent), hbox, FALSE, FALSE, 2);
label = gtk_label_new(TEXT_SETUP_PERMISSION_USER);
- gtk_widget_set_usize(label, 75, 0);
+ gtk_widget_set_size_request(label, 75, -1);
gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 2);
gtk_widget_show(label);
label = gtk_label_new(TEXT_SETUP_PERMISSION_GROUP);
- gtk_widget_set_usize(label, 75, 0);
+ gtk_widget_set_size_request(label, 75, -1);
gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 2);
gtk_widget_show(label);
label = gtk_label_new(TEXT_SETUP_PERMISSION_ALL);
- gtk_widget_set_usize(label, 75, 0);
+ gtk_widget_set_size_request(label, 75, -1);
gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 2);
gtk_widget_show(label);
@@ -819,9 +843,9 @@ static void xsane_permission_box(GtkWidget *parent, gchar *name, gchar *descript
button = gtk_toggle_button_new_with_label("r");
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button), *permission & 256 );
xsane_back_gtk_set_tooltip(xsane.tooltips, button, DESC_PERMISSION_READ);
- gtk_widget_set_usize(button, 21, 0);
+ gtk_widget_set_size_request(button, 21, -1);
gtk_widget_set_name(button, name);
- gtk_signal_connect(GTK_OBJECT(button), "toggled", (GtkSignalFunc) xsane_permission_toggled, (void *) 256);
+ g_signal_connect(GTK_OBJECT(button), "toggled", (GtkSignalFunc) xsane_permission_toggled, (void *) 256);
gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 1);
gtk_widget_show(button);
gtk_widget_set_sensitive(button, user_sensitivity);
@@ -829,9 +853,9 @@ static void xsane_permission_box(GtkWidget *parent, gchar *name, gchar *descript
button = gtk_toggle_button_new_with_label("w");
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button), *permission & 128 );
xsane_back_gtk_set_tooltip(xsane.tooltips, button, DESC_PERMISSION_WRITE);
- gtk_widget_set_usize(button, 21, 0);
+ gtk_widget_set_size_request(button, 21, -1);
gtk_widget_set_name(button, name);
- gtk_signal_connect(GTK_OBJECT(button), "toggled", (GtkSignalFunc) xsane_permission_toggled, (void *) 128);
+ g_signal_connect(GTK_OBJECT(button), "toggled", (GtkSignalFunc) xsane_permission_toggled, (void *) 128);
gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 1);
gtk_widget_show(button);
gtk_widget_set_sensitive(button, user_sensitivity);
@@ -839,9 +863,9 @@ static void xsane_permission_box(GtkWidget *parent, gchar *name, gchar *descript
button = gtk_toggle_button_new_with_label("x");
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button), *permission & 64 );
xsane_back_gtk_set_tooltip(xsane.tooltips, button, DESC_PERMISSION_EXECUTE);
- gtk_widget_set_usize(button, 21, 0);
+ gtk_widget_set_size_request(button, 21, -1);
gtk_widget_set_name(button, name);
- gtk_signal_connect(GTK_OBJECT(button), "toggled", (GtkSignalFunc) xsane_permission_toggled, (void *) 64);
+ g_signal_connect(GTK_OBJECT(button), "toggled", (GtkSignalFunc) xsane_permission_toggled, (void *) 64);
gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 1);
gtk_widget_show(button);
gtk_widget_set_sensitive(button, x_sensitivity & user_sensitivity);
@@ -857,27 +881,27 @@ static void xsane_permission_box(GtkWidget *parent, gchar *name, gchar *descript
button = gtk_toggle_button_new_with_label("r");
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button), *permission & 32 );
xsane_back_gtk_set_tooltip(xsane.tooltips, button, DESC_PERMISSION_READ);
- gtk_widget_set_usize(button, 21, 0);
+ gtk_widget_set_size_request(button, 21, -1);
gtk_widget_set_name(button, name);
- gtk_signal_connect(GTK_OBJECT(button), "toggled", (GtkSignalFunc) xsane_permission_toggled, (void *) 32);
+ g_signal_connect(GTK_OBJECT(button), "toggled", (GtkSignalFunc) xsane_permission_toggled, (void *) 32);
gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 1);
gtk_widget_show(button);
button = gtk_toggle_button_new_with_label("w");
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button), *permission & 16 );
xsane_back_gtk_set_tooltip(xsane.tooltips, button, DESC_PERMISSION_WRITE);
- gtk_widget_set_usize(button, 21, 0);
+ gtk_widget_set_size_request(button, 21, -1);
gtk_widget_set_name(button, name);
- gtk_signal_connect(GTK_OBJECT(button), "toggled", (GtkSignalFunc) xsane_permission_toggled, (void *) 16);
+ g_signal_connect(GTK_OBJECT(button), "toggled", (GtkSignalFunc) xsane_permission_toggled, (void *) 16);
gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 1);
gtk_widget_show(button);
button = gtk_toggle_button_new_with_label("x");
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button), *permission & 8 );
xsane_back_gtk_set_tooltip(xsane.tooltips, button, DESC_PERMISSION_EXECUTE);
- gtk_widget_set_usize(button, 21, 0);
+ gtk_widget_set_size_request(button, 21, -1);
gtk_widget_set_name(button, name);
- gtk_signal_connect(GTK_OBJECT(button), "toggled", (GtkSignalFunc) xsane_permission_toggled, (void *) 8);
+ g_signal_connect(GTK_OBJECT(button), "toggled", (GtkSignalFunc) xsane_permission_toggled, (void *) 8);
gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 1);
gtk_widget_show(button);
gtk_widget_set_sensitive(button, x_sensitivity);
@@ -893,27 +917,27 @@ static void xsane_permission_box(GtkWidget *parent, gchar *name, gchar *descript
button = gtk_toggle_button_new_with_label("r");
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button), *permission & 4 );
xsane_back_gtk_set_tooltip(xsane.tooltips, button, DESC_PERMISSION_READ);
- gtk_widget_set_usize(button, 21, 0);
+ gtk_widget_set_size_request(button, 21, -1);
gtk_widget_set_name(button, name);
- gtk_signal_connect(GTK_OBJECT(button), "toggled", (GtkSignalFunc) xsane_permission_toggled, (void *) 4);
+ g_signal_connect(GTK_OBJECT(button), "toggled", (GtkSignalFunc) xsane_permission_toggled, (void *) 4);
gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 1);
gtk_widget_show(button);
button = gtk_toggle_button_new_with_label("w");
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button), *permission & 2 );
xsane_back_gtk_set_tooltip(xsane.tooltips, button, DESC_PERMISSION_WRITE);
- gtk_widget_set_usize(button, 21, 0);
+ gtk_widget_set_size_request(button, 21, -1);
gtk_widget_set_name(button, name);
- gtk_signal_connect(GTK_OBJECT(button), "toggled", (GtkSignalFunc) xsane_permission_toggled, (void *) 2);
+ g_signal_connect(GTK_OBJECT(button), "toggled", (GtkSignalFunc) xsane_permission_toggled, (void *) 2);
gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 1);
gtk_widget_show(button);
button = gtk_toggle_button_new_with_label("x");
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button), *permission & 1 );
xsane_back_gtk_set_tooltip(xsane.tooltips, button, DESC_PERMISSION_EXECUTE);
- gtk_widget_set_usize(button, 21, 0);
+ gtk_widget_set_size_request(button, 21, -1);
gtk_widget_set_name(button, name);
- gtk_signal_connect(GTK_OBJECT(button), "toggled", (GtkSignalFunc) xsane_permission_toggled, (void *) 1);
+ g_signal_connect(GTK_OBJECT(button), "toggled", (GtkSignalFunc) xsane_permission_toggled, (void *) 1);
gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 1);
gtk_widget_show(button);
gtk_widget_set_sensitive(button, x_sensitivity);
@@ -952,7 +976,7 @@ static void xsane_printer_notebook(GtkWidget *notebook)
gtk_widget_show(setup_vbox);
frame = gtk_frame_new(0);
- gtk_container_set_border_width(GTK_CONTAINER(frame), 4);
+ gtk_container_set_border_width(GTK_CONTAINER(frame), 7);
gtk_frame_set_shadow_type(GTK_FRAME(frame), GTK_SHADOW_ETCHED_IN);
gtk_box_pack_start(GTK_BOX(setup_vbox), frame, TRUE, TRUE, 0); /* sizeable framehight */
gtk_widget_show(frame);
@@ -990,7 +1014,7 @@ static void xsane_printer_notebook(GtkWidget *notebook)
text = gtk_entry_new();
xsane_back_gtk_set_tooltip(xsane.tooltips, text, DESC_PRINTER_NAME);
- gtk_widget_set_usize(text, 250, 0);
+ gtk_widget_set_size_request(text, 250, -1);
gtk_entry_set_text(GTK_ENTRY(text), (char *) preferences.printer[preferences.printernr]->name);
gtk_box_pack_end(GTK_BOX(hbox), text, FALSE, FALSE, 2);
gtk_widget_show(text);
@@ -1008,7 +1032,7 @@ static void xsane_printer_notebook(GtkWidget *notebook)
text = gtk_entry_new();
xsane_back_gtk_set_tooltip(xsane.tooltips, text, DESC_PRINTER_COMMAND);
- gtk_widget_set_usize(text, 250, 0);
+ gtk_widget_set_size_request(text, 250, -1);
gtk_entry_set_text(GTK_ENTRY(text), (char *) preferences.printer[preferences.printernr]->command);
gtk_box_pack_end(GTK_BOX(hbox), text, FALSE, FALSE, 2);
gtk_widget_show(text);
@@ -1026,7 +1050,7 @@ static void xsane_printer_notebook(GtkWidget *notebook)
text = gtk_entry_new();
xsane_back_gtk_set_tooltip(xsane.tooltips, text, DESC_COPY_NUMBER_OPTION);
- gtk_widget_set_usize(text, 250, 0);
+ gtk_widget_set_size_request(text, 250, -1);
gtk_entry_set_text(GTK_ENTRY(text), (char *) preferences.printer[preferences.printernr]->copy_number_option);
gtk_box_pack_end(GTK_BOX(hbox), text, FALSE, FALSE, 2);
gtk_widget_show(text);
@@ -1048,7 +1072,7 @@ static void xsane_printer_notebook(GtkWidget *notebook)
text = gtk_entry_new();
xsane_back_gtk_set_tooltip(xsane.tooltips, text, DESC_PRINTER_LINEART_RESOLUTION);
- gtk_widget_set_usize(text, 80, 0);
+ gtk_widget_set_size_request(text, 80, -1);
snprintf(buf, sizeof(buf), "%d", preferences.printer[preferences.printernr]->lineart_resolution);
gtk_entry_set_text(GTK_ENTRY(text), (char *) buf);
gtk_box_pack_end(GTK_BOX(hbox), text, FALSE, FALSE, 2);
@@ -1068,7 +1092,7 @@ static void xsane_printer_notebook(GtkWidget *notebook)
text = gtk_entry_new();
xsane_back_gtk_set_tooltip(xsane.tooltips, text, DESC_PRINTER_GRAYSCALE_RESOLUTION);
- gtk_widget_set_usize(text, 80, 0);
+ gtk_widget_set_size_request(text, 80, -1);
snprintf(buf, sizeof(buf), "%d", preferences.printer[preferences.printernr]->grayscale_resolution);
gtk_entry_set_text(GTK_ENTRY(text), (char *) buf);
gtk_box_pack_end(GTK_BOX(hbox), text, FALSE, FALSE, 2);
@@ -1088,7 +1112,7 @@ static void xsane_printer_notebook(GtkWidget *notebook)
text = gtk_entry_new();
xsane_back_gtk_set_tooltip(xsane.tooltips, text, DESC_PRINTER_COLOR_RESOLUTION);
- gtk_widget_set_usize(text, 80, 0);
+ gtk_widget_set_size_request(text, 80, -1);
snprintf(buf, sizeof(buf), "%d", preferences.printer[preferences.printernr]->color_resolution);
gtk_entry_set_text(GTK_ENTRY(text), (char *) buf);
gtk_box_pack_end(GTK_BOX(hbox), text, FALSE, FALSE, 2);
@@ -1112,7 +1136,7 @@ static void xsane_printer_notebook(GtkWidget *notebook)
text = gtk_entry_new();
xsane_back_gtk_set_tooltip(xsane.tooltips, text, DESC_PRINTER_WIDTH);
- gtk_widget_set_usize(text, 80, 0);
+ gtk_widget_set_size_request(text, 80, -1);
snprintf(buf, sizeof(buf), "%4.3f", preferences.printer[preferences.printernr]->width / preferences.length_unit);
gtk_entry_set_text(GTK_ENTRY(text), (char *) buf);
gtk_box_pack_end(GTK_BOX(hbox), text, FALSE, FALSE, 2);
@@ -1132,7 +1156,7 @@ static void xsane_printer_notebook(GtkWidget *notebook)
text = gtk_entry_new();
xsane_back_gtk_set_tooltip(xsane.tooltips, text, DESC_PRINTER_HEIGHT);
- gtk_widget_set_usize(text, 80, 0);
+ gtk_widget_set_size_request(text, 80, -1);
snprintf(buf, sizeof(buf), "%4.3f", preferences.printer[preferences.printernr]->height / preferences.length_unit);
gtk_entry_set_text(GTK_ENTRY(text), (char *) buf);
gtk_box_pack_end(GTK_BOX(hbox), text, FALSE, FALSE, 2);
@@ -1152,7 +1176,7 @@ static void xsane_printer_notebook(GtkWidget *notebook)
text = gtk_entry_new();
xsane_back_gtk_set_tooltip(xsane.tooltips, text, DESC_PRINTER_LEFTOFFSET);
- gtk_widget_set_usize(text, 80, 0);
+ gtk_widget_set_size_request(text, 80, -1);
snprintf(buf, sizeof(buf), "%4.3f", preferences.printer[preferences.printernr]->leftoffset / preferences.length_unit);
gtk_entry_set_text(GTK_ENTRY(text), (char *) buf);
gtk_box_pack_end(GTK_BOX(hbox), text, FALSE, FALSE, 2);
@@ -1172,7 +1196,7 @@ static void xsane_printer_notebook(GtkWidget *notebook)
text = gtk_entry_new();
xsane_back_gtk_set_tooltip(xsane.tooltips, text, DESC_PRINTER_BOTTOMOFFSET);
- gtk_widget_set_usize(text, 80, 0);
+ gtk_widget_set_size_request(text, 80, -1);
snprintf(buf, sizeof(buf), "%4.3f", preferences.printer[preferences.printernr]->bottomoffset / preferences.length_unit);
gtk_entry_set_text(GTK_ENTRY(text), (char *) buf);
gtk_box_pack_end(GTK_BOX(hbox), text, FALSE, FALSE, 2);
@@ -1195,7 +1219,7 @@ static void xsane_printer_notebook(GtkWidget *notebook)
text = gtk_entry_new();
xsane_back_gtk_set_tooltip(xsane.tooltips, text, DESC_PRINTER_GAMMA);
- gtk_widget_set_usize(text, 80, 0);
+ gtk_widget_set_size_request(text, 80, -1);
snprintf(buf, sizeof(buf), "%1.2f", preferences.printer[preferences.printernr]->gamma);
gtk_entry_set_text(GTK_ENTRY(text), (char *) buf);
gtk_box_pack_end(GTK_BOX(hbox), text, FALSE, FALSE, 2);
@@ -1214,7 +1238,7 @@ static void xsane_printer_notebook(GtkWidget *notebook)
text = gtk_entry_new();
xsane_back_gtk_set_tooltip(xsane.tooltips, text, DESC_PRINTER_GAMMA_RED);
- gtk_widget_set_usize(text, 80, 0);
+ gtk_widget_set_size_request(text, 80, -1);
snprintf(buf, sizeof(buf), "%1.2f", preferences.printer[preferences.printernr]->gamma_red);
gtk_entry_set_text(GTK_ENTRY(text), (char *) buf);
gtk_box_pack_end(GTK_BOX(hbox), text, FALSE, FALSE, 2);
@@ -1233,7 +1257,7 @@ static void xsane_printer_notebook(GtkWidget *notebook)
text = gtk_entry_new();
xsane_back_gtk_set_tooltip(xsane.tooltips, text, DESC_PRINTER_GAMMA_GREEN);
- gtk_widget_set_usize(text, 80, 0);
+ gtk_widget_set_size_request(text, 80, -1);
snprintf(buf, sizeof(buf), "%1.2f", preferences.printer[preferences.printernr]->gamma_green);
gtk_entry_set_text(GTK_ENTRY(text), (char *) buf);
gtk_box_pack_end(GTK_BOX(hbox), text, FALSE, FALSE, 2);
@@ -1252,7 +1276,7 @@ static void xsane_printer_notebook(GtkWidget *notebook)
text = gtk_entry_new();
xsane_back_gtk_set_tooltip(xsane.tooltips, text, DESC_PRINTER_GAMMA_BLUE);
- gtk_widget_set_usize(text, 80, 0);
+ gtk_widget_set_size_request(text, 80, -1);
snprintf(buf, sizeof(buf), "%1.2f", preferences.printer[preferences.printernr]->gamma_blue);
gtk_entry_set_text(GTK_ENTRY(text), (char *) buf);
gtk_box_pack_end(GTK_BOX(hbox), text, FALSE, FALSE, 2);
@@ -1268,18 +1292,22 @@ static void xsane_printer_notebook(GtkWidget *notebook)
hbox = gtk_hbox_new(/* homogeneous */ FALSE, 0);
gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 2);
+#ifdef HAVE_GTK2
+ button = gtk_button_new_from_stock(GTK_STOCK_APPLY);
+#else
button = gtk_button_new_with_label(BUTTON_APPLY);
- gtk_signal_connect(GTK_OBJECT(button), "clicked", (GtkSignalFunc) xsane_setup_printer_apply_changes, printer_option_menu);
+#endif
+ g_signal_connect(GTK_OBJECT(button), "clicked", (GtkSignalFunc) xsane_setup_printer_apply_changes, printer_option_menu);
gtk_box_pack_start(GTK_BOX(hbox), button, TRUE, TRUE, 0);
gtk_widget_show(button);
button = gtk_button_new_with_label(BUTTON_ADD_PRINTER);
- gtk_signal_connect(GTK_OBJECT(button), "clicked", (GtkSignalFunc) xsane_setup_printer_new, printer_option_menu);
+ g_signal_connect(GTK_OBJECT(button), "clicked", (GtkSignalFunc) xsane_setup_printer_new, printer_option_menu);
gtk_box_pack_start(GTK_BOX(hbox), button, TRUE, TRUE, 0);
gtk_widget_show(button);
button = gtk_button_new_with_label(BUTTON_DELETE_PRINTER);
- gtk_signal_connect(GTK_OBJECT(button), "clicked", (GtkSignalFunc) xsane_setup_printer_delete, printer_option_menu);
+ g_signal_connect(GTK_OBJECT(button), "clicked", (GtkSignalFunc) xsane_setup_printer_delete, printer_option_menu);
gtk_box_pack_start(GTK_BOX(hbox), button, TRUE, TRUE, 0);
gtk_widget_show(button);
@@ -1290,7 +1318,7 @@ static void xsane_printer_notebook(GtkWidget *notebook)
static void xsane_setup_browse_tmp_path_callback(GtkWidget *widget, gpointer data)
{
- gchar *old_tmp_path;
+ const gchar *old_tmp_path;
char tmp_path[256];
char windowname[256];
@@ -1300,7 +1328,7 @@ static void xsane_setup_browse_tmp_path_callback(GtkWidget *widget, gpointer dat
strncpy(tmp_path, old_tmp_path, sizeof(tmp_path));
snprintf(windowname, sizeof(windowname), "%s %s", xsane.prog_name, WINDOW_TMP_PATH);
- xsane_back_gtk_get_filename(windowname, tmp_path, sizeof(tmp_path), tmp_path, TRUE, FALSE, TRUE);
+ xsane_back_gtk_get_filename(windowname, tmp_path, sizeof(tmp_path), tmp_path, NULL, TRUE, FALSE, TRUE, FALSE);
gtk_entry_set_text(GTK_ENTRY(xsane_setup.tmp_path_entry), tmp_path);
}
@@ -1324,7 +1352,7 @@ static void xsane_saving_notebook(GtkWidget *notebook)
gtk_widget_show(setup_vbox);
frame = gtk_frame_new(0);
- gtk_container_set_border_width(GTK_CONTAINER(frame), 4);
+ gtk_container_set_border_width(GTK_CONTAINER(frame), 7);
gtk_frame_set_shadow_type(GTK_FRAME(frame), GTK_SHADOW_ETCHED_IN);
gtk_box_pack_start(GTK_BOX(setup_vbox), frame, TRUE, TRUE, 0); /* sizeable framehight */
gtk_widget_show(frame);
@@ -1344,7 +1372,7 @@ static void xsane_saving_notebook(GtkWidget *notebook)
gtk_widget_show(label);
text = gtk_entry_new_with_max_length(255);
- gtk_widget_set_usize(text, 70, 0); /* set minimum size */
+ gtk_widget_set_size_request(text, 70, -1); /* set minimum size */
xsane_back_gtk_set_tooltip(xsane.tooltips, text, DESC_TMP_PATH);
gtk_entry_set_text(GTK_ENTRY(text), (char *) preferences.tmp_path);
gtk_box_pack_start(GTK_BOX(hbox), text, TRUE, TRUE, 4);
@@ -1352,7 +1380,7 @@ static void xsane_saving_notebook(GtkWidget *notebook)
xsane_setup.tmp_path_entry = text;
button = gtk_button_new_with_label(BUTTON_BROWSE);
- gtk_signal_connect(GTK_OBJECT(button), "clicked", (GtkSignalFunc) xsane_setup_browse_tmp_path_callback, NULL);
+ g_signal_connect(GTK_OBJECT(button), "clicked", (GtkSignalFunc) xsane_setup_browse_tmp_path_callback, NULL);
gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 2);
xsane_back_gtk_set_tooltip(xsane.tooltips, button, DESC_BUTTON_TMP_PATH_BROWSE);
gtk_widget_show(button);
@@ -1414,7 +1442,7 @@ static void xsane_saving_notebook(GtkWidget *notebook)
filename_counter_len_menu = gtk_menu_new();
- for (i=0; i <= 10; i++)
+ for (i=0; i <= 9; i++)
{
if (i)
{
@@ -1426,8 +1454,7 @@ static void xsane_saving_notebook(GtkWidget *notebook)
}
filename_counter_len_item = gtk_menu_item_new_with_label(buf);
gtk_container_add(GTK_CONTAINER(filename_counter_len_menu), filename_counter_len_item);
- gtk_signal_connect(GTK_OBJECT(filename_counter_len_item), "activate",
- (GtkSignalFunc) xsane_setup_filename_counter_len_callback, (void *) i);
+ g_signal_connect(GTK_OBJECT(filename_counter_len_item), "activate", (GtkSignalFunc) xsane_setup_filename_counter_len_callback, (void *) i);
gtk_widget_show(filename_counter_len_item);
if (preferences.filename_counter_len == i)
{
@@ -1465,8 +1492,12 @@ static void xsane_saving_notebook(GtkWidget *notebook)
hbox = gtk_hbox_new(/* homogeneous */ FALSE, 0);
gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 2);
+#ifdef HAVE_GTK2
+ button = gtk_button_new_from_stock(GTK_STOCK_APPLY);
+#else
button = gtk_button_new_with_label(BUTTON_APPLY);
- gtk_signal_connect(GTK_OBJECT(button), "clicked", (GtkSignalFunc) xsane_setup_saving_apply_changes, NULL);
+#endif
+ g_signal_connect(GTK_OBJECT(button), "clicked", (GtkSignalFunc) xsane_setup_saving_apply_changes, NULL);
gtk_box_pack_start(GTK_BOX(hbox), button, TRUE, TRUE, 0);
gtk_widget_show(button);
@@ -1534,7 +1565,7 @@ static void xsane_image_notebook(GtkWidget *notebook)
gtk_widget_show(setup_vbox);
frame = gtk_frame_new(0);
- gtk_container_set_border_width(GTK_CONTAINER(frame), 4);
+ gtk_container_set_border_width(GTK_CONTAINER(frame), 7);
gtk_frame_set_shadow_type(GTK_FRAME(frame), GTK_SHADOW_ETCHED_IN);
gtk_box_pack_start(GTK_BOX(setup_vbox), frame, TRUE, TRUE, 0); /* sizeable framehight */
gtk_widget_show(frame);
@@ -1544,6 +1575,17 @@ static void xsane_image_notebook(GtkWidget *notebook)
gtk_widget_show(vbox);
+ /* save pnm16 as ascii */
+ hbox = gtk_hbox_new(/* homogeneous */ FALSE, 0);
+ gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 2);
+ button = gtk_check_button_new_with_label(RADIO_BUTTON_SAVE_PNM16_AS_ASCII);
+ xsane_back_gtk_set_tooltip(xsane.tooltips, button, DESC_SAVE_PNM16_AS_ASCII);
+ gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button), preferences.save_pnm16_as_ascii);
+ gtk_box_pack_start(GTK_BOX(hbox), button, TRUE, TRUE, 2);
+ gtk_widget_show(button);
+ gtk_widget_show(hbox);
+ xsane_setup.save_pnm16_as_ascii_button = button;
+
/* reduce 16bit to 8bit */
hbox = gtk_hbox_new(/* homogeneous */ FALSE, 0);
gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 2);
@@ -1571,18 +1613,18 @@ static void xsane_image_notebook(GtkWidget *notebook)
#endif
#ifdef HAVE_LIBJPEG
- xsane_scale_new(GTK_BOX(vbox), TEXT_SETUP_JPEG_QUALITY, DESC_JPEG_QUALITY, 0.0, 100.0, 1.0, 10.0, 0.0, 0,
+ xsane_range_new(GTK_BOX(vbox), TEXT_SETUP_JPEG_QUALITY, DESC_JPEG_QUALITY, 0.0, 100.0, 1.0, 10.0, 0,
&preferences.jpeg_quality, (GtkObject **) &xsane_setup.jpeg_image_quality_scale, 0, TRUE);
#else
#ifdef HAVE_LIBTIFF
- xsane_scale_new(GTK_BOX(vbox), TEXT_SETUP_JPEG_QUALITY, DESC_JPEG_QUALITY, 0.0, 100.0, 1.0, 10.0, 0.0, 0,
+ xsane_range_new(GTK_BOX(vbox), TEXT_SETUP_JPEG_QUALITY, DESC_JPEG_QUALITY, 0.0, 100.0, 1.0, 10.0, 0,
&preferences.jpeg_quality, (GtkObject **) &xsane_setup.jpeg_image_quality_scale, 0, TRUE);
#endif
#endif
#ifdef HAVE_LIBPNG
#ifdef HAVE_LIBZ
- xsane_scale_new(GTK_BOX(vbox), TEXT_SETUP_PNG_COMPRESSION, DESC_PNG_COMPRESSION, 0.0, Z_BEST_COMPRESSION, 1.0, 10.0, 0.0, 0,
+ xsane_range_new(GTK_BOX(vbox), TEXT_SETUP_PNG_COMPRESSION, DESC_PNG_COMPRESSION, 0.0, Z_BEST_COMPRESSION, 1.0, 10.0, 0,
&preferences.png_compression, (GtkObject **) &xsane_setup.pnm_image_compression_scale, 0, TRUE);
#endif
#endif
@@ -1610,8 +1652,7 @@ static void xsane_image_notebook(GtkWidget *notebook)
{
tiff_compression_item = gtk_menu_item_new_with_label(tiff_compression16_strings[i-1].name);
gtk_container_add(GTK_CONTAINER(tiff_compression_menu), tiff_compression_item);
- gtk_signal_connect(GTK_OBJECT(tiff_compression_item), "activate",
- (GtkSignalFunc) xsane_setup_tiff_compression16_callback, (void *) tiff_compression16_strings[i-1].number);
+ g_signal_connect(GTK_OBJECT(tiff_compression_item), "activate", (GtkSignalFunc) xsane_setup_tiff_compression16_callback, (void *) tiff_compression16_strings[i-1].number);
gtk_widget_show(tiff_compression_item);
if (tiff_compression16_strings[i-1].number == preferences.tiff_compression16_nr)
{
@@ -1646,8 +1687,7 @@ static void xsane_image_notebook(GtkWidget *notebook)
{
tiff_compression_item = gtk_menu_item_new_with_label(tiff_compression8_strings[i-1].name);
gtk_container_add(GTK_CONTAINER(tiff_compression_menu), tiff_compression_item);
- gtk_signal_connect(GTK_OBJECT(tiff_compression_item), "activate",
- (GtkSignalFunc) xsane_setup_tiff_compression8_callback, (void *) tiff_compression8_strings[i-1].number);
+ g_signal_connect(GTK_OBJECT(tiff_compression_item), "activate", (GtkSignalFunc) xsane_setup_tiff_compression8_callback, (void *) tiff_compression8_strings[i-1].number);
gtk_widget_show(tiff_compression_item);
if (tiff_compression8_strings[i-1].number == preferences.tiff_compression8_nr)
{
@@ -1683,8 +1723,7 @@ static void xsane_image_notebook(GtkWidget *notebook)
{
tiff_compression_item = gtk_menu_item_new_with_label(tiff_compression1_strings[i-1].name);
gtk_container_add(GTK_CONTAINER(tiff_compression_menu), tiff_compression_item);
- gtk_signal_connect(GTK_OBJECT(tiff_compression_item), "activate",
- (GtkSignalFunc) xsane_setup_tiff_compression1_callback, (void *) tiff_compression1_strings[i-1].number);
+ g_signal_connect(GTK_OBJECT(tiff_compression_item), "activate", (GtkSignalFunc) xsane_setup_tiff_compression1_callback, (void *) tiff_compression1_strings[i-1].number);
gtk_widget_show(tiff_compression_item);
if (tiff_compression1_strings[i-1].number == preferences.tiff_compression1_nr)
{
@@ -1707,8 +1746,12 @@ static void xsane_image_notebook(GtkWidget *notebook)
hbox = gtk_hbox_new(/* homogeneous */ FALSE, 0);
gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 2);
+#ifdef HAVE_GTK2
+ button = gtk_button_new_from_stock(GTK_STOCK_APPLY);
+#else
button = gtk_button_new_with_label(BUTTON_APPLY);
- gtk_signal_connect(GTK_OBJECT(button), "clicked", (GtkSignalFunc) xsane_setup_image_apply_changes, NULL);
+#endif
+ g_signal_connect(GTK_OBJECT(button), "clicked", (GtkSignalFunc) xsane_setup_image_apply_changes, NULL);
gtk_box_pack_start(GTK_BOX(hbox), button, TRUE, TRUE, 0);
gtk_widget_show(button);
@@ -1717,10 +1760,39 @@ static void xsane_image_notebook(GtkWidget *notebook)
/* ---------------------------------------------------------------------------------------------------------------------- */
+typedef struct
+{
+ char *identifier;
+ char *fax_command;
+ char *fax_receiver_option;
+ char *fax_postscript_option;
+ char *fax_normal_option;
+ char *fax_fine_option;
+} fax_program_options_type;
+
+fax_program_options_type fax_program[] =
+{
+ {" hylafax ", "sendfax", "-d", "", "-l", "-m"},
+ {" mgetty+sendfax ", "faxspool", "", "", "-n", ""},
+ {" efax ", "fax send", "", "", "-l", ""},
+};
+
+static void xsane_fax_notebook_set_faxprogram_default_callback(GtkWidget *widget, int program_number)
+{
+ gtk_entry_set_text(GTK_ENTRY(xsane_setup.fax_command_entry), (char *) fax_program[program_number].fax_command);
+ gtk_entry_set_text(GTK_ENTRY(xsane_setup.fax_receiver_option_entry), (char *) fax_program[program_number].fax_receiver_option);
+ gtk_entry_set_text(GTK_ENTRY(xsane_setup.fax_postscript_option_entry), (char *) fax_program[program_number].fax_postscript_option);
+ gtk_entry_set_text(GTK_ENTRY(xsane_setup.fax_normal_option_entry), (char *) fax_program[program_number].fax_normal_option);
+ gtk_entry_set_text(GTK_ENTRY(xsane_setup.fax_fine_option_entry), (char *) fax_program[program_number].fax_fine_option);
+}
+
+/* ---------------------------------------------------------------------------------------------------------------------- */
+
static void xsane_fax_notebook(GtkWidget *notebook)
{
GtkWidget *setup_vbox, *vbox, *hbox, *button, *label, *text, *frame;
char buf[64];
+ int i;
DBG(DBG_proc, "xsane_fax_notebook\n");
@@ -1733,7 +1805,7 @@ static void xsane_fax_notebook(GtkWidget *notebook)
gtk_widget_show(setup_vbox);
frame = gtk_frame_new(0);
- gtk_container_set_border_width(GTK_CONTAINER(frame), 4);
+ gtk_container_set_border_width(GTK_CONTAINER(frame), 7);
gtk_frame_set_shadow_type(GTK_FRAME(frame), GTK_SHADOW_ETCHED_IN);
gtk_box_pack_start(GTK_BOX(setup_vbox), frame, TRUE, TRUE, 0); /* sizeable framehight */
gtk_widget_show(frame);
@@ -1753,7 +1825,7 @@ static void xsane_fax_notebook(GtkWidget *notebook)
text = gtk_entry_new();
xsane_back_gtk_set_tooltip(xsane.tooltips, text, DESC_FAX_COMMAND);
- gtk_widget_set_usize(text, 250, 0);
+ gtk_widget_set_size_request(text, 250, -1);
gtk_entry_set_text(GTK_ENTRY(text), (char *) preferences.fax_command);
gtk_box_pack_end(GTK_BOX(hbox), text, FALSE, FALSE, 2);
gtk_widget_show(text);
@@ -1772,7 +1844,7 @@ static void xsane_fax_notebook(GtkWidget *notebook)
text = gtk_entry_new();
xsane_back_gtk_set_tooltip(xsane.tooltips, text, DESC_FAX_RECEIVER_OPT);
- gtk_widget_set_usize(text, 80, 0);
+ gtk_widget_set_size_request(text, 80, -1);
gtk_entry_set_text(GTK_ENTRY(text), (char *) preferences.fax_receiver_option);
gtk_box_pack_end(GTK_BOX(hbox), text, FALSE, FALSE, 2);
gtk_widget_show(text);
@@ -1791,7 +1863,7 @@ static void xsane_fax_notebook(GtkWidget *notebook)
text = gtk_entry_new();
xsane_back_gtk_set_tooltip(xsane.tooltips, text, DESC_FAX_POSTSCRIPT_OPT);
- gtk_widget_set_usize(text, 80, 0);
+ gtk_widget_set_size_request(text, 80, -1);
gtk_entry_set_text(GTK_ENTRY(text), (char *) preferences.fax_postscript_option);
gtk_box_pack_end(GTK_BOX(hbox), text, FALSE, FALSE, 2);
gtk_widget_show(text);
@@ -1810,7 +1882,7 @@ static void xsane_fax_notebook(GtkWidget *notebook)
text = gtk_entry_new();
xsane_back_gtk_set_tooltip(xsane.tooltips, text, DESC_FAX_NORMAL_OPT);
- gtk_widget_set_usize(text, 80, 0);
+ gtk_widget_set_size_request(text, 80, -1);
gtk_entry_set_text(GTK_ENTRY(text), (char *) preferences.fax_normal_option);
gtk_box_pack_end(GTK_BOX(hbox), text, FALSE, FALSE, 2);
gtk_widget_show(text);
@@ -1829,7 +1901,7 @@ static void xsane_fax_notebook(GtkWidget *notebook)
text = gtk_entry_new();
xsane_back_gtk_set_tooltip(xsane.tooltips, text, DESC_FAX_FINE_OPT);
- gtk_widget_set_usize(text, 80, 0);
+ gtk_widget_set_size_request(text, 80, -1);
gtk_entry_set_text(GTK_ENTRY(text), (char *) preferences.fax_fine_option);
gtk_box_pack_end(GTK_BOX(hbox), text, FALSE, FALSE, 2);
gtk_widget_show(text);
@@ -1837,6 +1909,26 @@ static void xsane_fax_notebook(GtkWidget *notebook)
xsane_setup.fax_fine_option_entry = text;
+ /* fax set program default options : */
+
+ hbox = gtk_hbox_new(/* homogeneous */ FALSE, 0);
+ gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 2);
+
+ label = gtk_label_new(TEXT_SETUP_FAX_PROGRAM_DEFAULTS);
+ gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);
+ gtk_widget_show(label);
+
+ for (i=0; i < sizeof(fax_program)/sizeof(fax_program_options_type); i++)
+ {
+ button = gtk_button_new_with_label(fax_program[i].identifier);
+ g_signal_connect(GTK_OBJECT(button), "clicked", (GtkSignalFunc) xsane_fax_notebook_set_faxprogram_default_callback, (void *) i);
+ gtk_box_pack_end(GTK_BOX(hbox), button, FALSE, FALSE, 10);
+ gtk_widget_show(button);
+ }
+
+ gtk_widget_show(hbox);
+
+
xsane_separator_new(vbox, 2);
@@ -1851,7 +1943,7 @@ static void xsane_fax_notebook(GtkWidget *notebook)
text = gtk_entry_new();
xsane_back_gtk_set_tooltip(xsane.tooltips, text, DESC_FAX_VIEWER);
- gtk_widget_set_usize(text, 250, 0);
+ gtk_widget_set_size_request(text, 250, -1);
gtk_entry_set_text(GTK_ENTRY(text), (char *) preferences.fax_viewer);
gtk_box_pack_end(GTK_BOX(hbox), text, FALSE, FALSE, 2);
gtk_widget_show(text);
@@ -1873,7 +1965,7 @@ static void xsane_fax_notebook(GtkWidget *notebook)
text = gtk_entry_new();
xsane_back_gtk_set_tooltip(xsane.tooltips, text, DESC_FAX_WIDTH);
- gtk_widget_set_usize(text, 80, 0);
+ gtk_widget_set_size_request(text, 80, -1);
snprintf(buf, sizeof(buf), "%4.3f", preferences.fax_width / preferences.length_unit);
gtk_entry_set_text(GTK_ENTRY(text), (char *) buf);
gtk_box_pack_end(GTK_BOX(hbox), text, FALSE, FALSE, 2);
@@ -1893,7 +1985,7 @@ static void xsane_fax_notebook(GtkWidget *notebook)
text = gtk_entry_new();
xsane_back_gtk_set_tooltip(xsane.tooltips, text, DESC_FAX_HEIGHT);
- gtk_widget_set_usize(text, 80, 0);
+ gtk_widget_set_size_request(text, 80, -1);
snprintf(buf, sizeof(buf), "%4.3f", preferences.fax_height / preferences.length_unit);
gtk_entry_set_text(GTK_ENTRY(text), (char *) buf);
gtk_box_pack_end(GTK_BOX(hbox), text, FALSE, FALSE, 2);
@@ -1913,7 +2005,7 @@ static void xsane_fax_notebook(GtkWidget *notebook)
text = gtk_entry_new();
xsane_back_gtk_set_tooltip(xsane.tooltips, text, DESC_FAX_LEFTOFFSET);
- gtk_widget_set_usize(text, 80, 0);
+ gtk_widget_set_size_request(text, 80, -1);
snprintf(buf, sizeof(buf), "%4.3f", preferences.fax_leftoffset / preferences.length_unit);
gtk_entry_set_text(GTK_ENTRY(text), (char *) buf);
gtk_box_pack_end(GTK_BOX(hbox), text, FALSE, FALSE, 2);
@@ -1933,7 +2025,7 @@ static void xsane_fax_notebook(GtkWidget *notebook)
text = gtk_entry_new();
xsane_back_gtk_set_tooltip(xsane.tooltips, text, DESC_FAX_BOTTOMOFFSET);
- gtk_widget_set_usize(text, 80, 0);
+ gtk_widget_set_size_request(text, 80, -1);
snprintf(buf, sizeof(buf), "%4.3f", preferences.fax_bottomoffset / preferences.length_unit);
gtk_entry_set_text(GTK_ENTRY(text), (char *) buf);
gtk_box_pack_end(GTK_BOX(hbox), text, FALSE, FALSE, 2);
@@ -1948,8 +2040,12 @@ static void xsane_fax_notebook(GtkWidget *notebook)
hbox = gtk_hbox_new(/* homogeneous */ FALSE, 0);
gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 2);
+#ifdef HAVE_GTK2
+ button = gtk_button_new_from_stock(GTK_STOCK_APPLY);
+#else
button = gtk_button_new_with_label(BUTTON_APPLY);
- gtk_signal_connect(GTK_OBJECT(button), "clicked", (GtkSignalFunc) xsane_setup_fax_apply_changes, NULL);
+#endif
+ g_signal_connect(GTK_OBJECT(button), "clicked", (GtkSignalFunc) xsane_setup_fax_apply_changes, NULL);
gtk_box_pack_start(GTK_BOX(hbox), button, TRUE, TRUE, 0);
gtk_widget_show(button);
@@ -1986,7 +2082,7 @@ static void xsane_mail_notebook(GtkWidget *notebook)
gtk_widget_show(setup_vbox);
frame = gtk_frame_new(0);
- gtk_container_set_border_width(GTK_CONTAINER(frame), 4);
+ gtk_container_set_border_width(GTK_CONTAINER(frame), 7);
gtk_frame_set_shadow_type(GTK_FRAME(frame), GTK_SHADOW_ETCHED_IN);
gtk_box_pack_start(GTK_BOX(setup_vbox), frame, TRUE, TRUE, 0); /* sizeable framehight */
gtk_widget_show(frame);
@@ -2006,7 +2102,7 @@ static void xsane_mail_notebook(GtkWidget *notebook)
text = gtk_entry_new();
xsane_back_gtk_set_tooltip(xsane.tooltips, text, DESC_MAIL_FROM);
- gtk_widget_set_usize(text, 250, 0);
+ gtk_widget_set_size_request(text, 250, -1);
gtk_entry_set_text(GTK_ENTRY(text), (char *) preferences.mail_from);
gtk_box_pack_end(GTK_BOX(hbox), text, FALSE, FALSE, 2);
gtk_widget_show(text);
@@ -2024,7 +2120,7 @@ static void xsane_mail_notebook(GtkWidget *notebook)
text = gtk_entry_new();
xsane_back_gtk_set_tooltip(xsane.tooltips, text, DESC_MAIL_REPLY_TO);
- gtk_widget_set_usize(text, 250, 0);
+ gtk_widget_set_size_request(text, 250, -1);
gtk_entry_set_text(GTK_ENTRY(text), (char *) preferences.mail_reply_to);
gtk_box_pack_end(GTK_BOX(hbox), text, FALSE, FALSE, 2);
gtk_widget_show(text);
@@ -2045,7 +2141,7 @@ static void xsane_mail_notebook(GtkWidget *notebook)
text = gtk_entry_new();
xsane_back_gtk_set_tooltip(xsane.tooltips, text, DESC_SMTP_SERVER);
- gtk_widget_set_usize(text, 250, 0);
+ gtk_widget_set_size_request(text, 250, -1);
gtk_entry_set_text(GTK_ENTRY(text), (char *) preferences.mail_smtp_server);
gtk_box_pack_end(GTK_BOX(hbox), text, FALSE, FALSE, 2);
gtk_widget_show(text);
@@ -2063,7 +2159,7 @@ static void xsane_mail_notebook(GtkWidget *notebook)
text = gtk_entry_new();
xsane_back_gtk_set_tooltip(xsane.tooltips, text, DESC_SMTP_PORT);
- gtk_widget_set_usize(text, 50, 0);
+ gtk_widget_set_size_request(text, 50, -1);
snprintf(buf, sizeof(buf), "%d", preferences.mail_smtp_port);
gtk_entry_set_text(GTK_ENTRY(text), (char *) buf);
gtk_box_pack_end(GTK_BOX(hbox), text, FALSE, FALSE, 2);
@@ -2083,7 +2179,7 @@ static void xsane_mail_notebook(GtkWidget *notebook)
hbox = gtk_hbox_new(/* homogeneous */ FALSE, 0);
gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 2);
button = gtk_check_button_new_with_label(RADIO_BUTTON_POP3_AUTHENTIFICATION);
- gtk_signal_connect(GTK_OBJECT(button), "toggled", (GtkSignalFunc) xsane_setup_pop3_authentification_callback, (void *) pop3_vbox);
+ g_signal_connect(GTK_OBJECT(button), "toggled", (GtkSignalFunc) xsane_setup_pop3_authentification_callback, (void *) pop3_vbox);
xsane_back_gtk_set_tooltip(xsane.tooltips, button, DESC_POP3_AUTHENTIFICATION);
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button), preferences.mail_pop3_authentification);
gtk_box_pack_start(GTK_BOX(hbox), button, TRUE, TRUE, 2);
@@ -2105,7 +2201,7 @@ static void xsane_mail_notebook(GtkWidget *notebook)
text = gtk_entry_new();
xsane_back_gtk_set_tooltip(xsane.tooltips, text, DESC_POP3_SERVER);
- gtk_widget_set_usize(text, 250, 0);
+ gtk_widget_set_size_request(text, 250, -1);
gtk_entry_set_text(GTK_ENTRY(text), (char *) preferences.mail_pop3_server);
gtk_box_pack_end(GTK_BOX(hbox), text, FALSE, FALSE, 2);
gtk_widget_show(text);
@@ -2123,7 +2219,7 @@ static void xsane_mail_notebook(GtkWidget *notebook)
text = gtk_entry_new();
xsane_back_gtk_set_tooltip(xsane.tooltips, text, DESC_POP3_PORT);
- gtk_widget_set_usize(text, 50, 0);
+ gtk_widget_set_size_request(text, 50, -1);
snprintf(buf, sizeof(buf), "%d", preferences.mail_pop3_port);
gtk_entry_set_text(GTK_ENTRY(text), (char *) buf);
gtk_box_pack_end(GTK_BOX(hbox), text, FALSE, FALSE, 2);
@@ -2142,7 +2238,7 @@ static void xsane_mail_notebook(GtkWidget *notebook)
text = gtk_entry_new();
xsane_back_gtk_set_tooltip(xsane.tooltips, text, DESC_POP3_USER);
- gtk_widget_set_usize(text, 250, 0);
+ gtk_widget_set_size_request(text, 250, -1);
gtk_entry_set_text(GTK_ENTRY(text), (char *) preferences.mail_pop3_user);
gtk_box_pack_end(GTK_BOX(hbox), text, FALSE, FALSE, 2);
gtk_widget_show(text);
@@ -2167,7 +2263,7 @@ static void xsane_mail_notebook(GtkWidget *notebook)
text = gtk_entry_new();
xsane_back_gtk_set_tooltip(xsane.tooltips, text, DESC_POP3_PASS);
- gtk_widget_set_usize(text, 250, 0);
+ gtk_widget_set_size_request(text, 250, -1);
gtk_entry_set_text(GTK_ENTRY(text), (char *) password);
gtk_entry_set_visibility(GTK_ENTRY(text), 0);
gtk_box_pack_end(GTK_BOX(hbox), text, FALSE, FALSE, 2);
@@ -2191,7 +2287,7 @@ static void xsane_mail_notebook(GtkWidget *notebook)
text = gtk_entry_new();
xsane_back_gtk_set_tooltip(xsane.tooltips, text, DESC_MAIL_VIEWER);
- gtk_widget_set_usize(text, 250, 0);
+ gtk_widget_set_size_request(text, 250, -1);
gtk_entry_set_text(GTK_ENTRY(text), (char *) preferences.mail_viewer);
gtk_box_pack_end(GTK_BOX(hbox), text, FALSE, FALSE, 2);
gtk_widget_show(text);
@@ -2206,8 +2302,12 @@ static void xsane_mail_notebook(GtkWidget *notebook)
hbox = gtk_hbox_new(/* homogeneous */ FALSE, 0);
gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 2);
+#ifdef HAVE_GTK2
+ button = gtk_button_new_from_stock(GTK_STOCK_APPLY);
+#else
button = gtk_button_new_with_label(BUTTON_APPLY);
- gtk_signal_connect(GTK_OBJECT(button), "clicked", (GtkSignalFunc) xsane_setup_mail_apply_changes, NULL);
+#endif
+ g_signal_connect(GTK_OBJECT(button), "clicked", (GtkSignalFunc) xsane_setup_mail_apply_changes, NULL);
gtk_box_pack_start(GTK_BOX(hbox), button, TRUE, TRUE, 0);
gtk_widget_show(button);
@@ -2219,7 +2319,7 @@ static void xsane_mail_notebook(GtkWidget *notebook)
static void xsane_ocr_notebook(GtkWidget *notebook)
{
- GtkWidget *setup_vbox, *vbox, *hbox, *label, *text, *frame;
+ GtkWidget *setup_vbox, *vbox, *hbox, *label, *text, *frame, *button;
DBG(DBG_proc, "xsane_ocr_notebook\n");
@@ -2232,7 +2332,7 @@ static void xsane_ocr_notebook(GtkWidget *notebook)
gtk_widget_show(setup_vbox);
frame = gtk_frame_new(0);
- gtk_container_set_border_width(GTK_CONTAINER(frame), 4);
+ gtk_container_set_border_width(GTK_CONTAINER(frame), 7);
gtk_frame_set_shadow_type(GTK_FRAME(frame), GTK_SHADOW_ETCHED_IN);
gtk_box_pack_start(GTK_BOX(setup_vbox), frame, TRUE, TRUE, 0); /* sizeable framehight */
gtk_widget_show(frame);
@@ -2241,7 +2341,7 @@ static void xsane_ocr_notebook(GtkWidget *notebook)
gtk_container_add(GTK_CONTAINER(frame), vbox);
gtk_widget_show(vbox);
- /* ocrcommand : */
+ /* ocr command : */
hbox = gtk_hbox_new(/* homogeneous */ FALSE, 0);
gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 2);
@@ -2252,7 +2352,7 @@ static void xsane_ocr_notebook(GtkWidget *notebook)
text = gtk_entry_new();
xsane_back_gtk_set_tooltip(xsane.tooltips, text, DESC_OCR_COMMAND);
- gtk_widget_set_usize(text, 250, 0);
+ gtk_widget_set_size_request(text, 250, -1);
gtk_entry_set_text(GTK_ENTRY(text), (char *) preferences.ocr_command);
gtk_box_pack_end(GTK_BOX(hbox), text, FALSE, FALSE, 2);
gtk_widget_show(text);
@@ -2260,7 +2360,7 @@ static void xsane_ocr_notebook(GtkWidget *notebook)
xsane_setup.ocr_command_entry = text;
- /* ocrinputfileoption : */
+ /* ocr inputfile option : */
hbox = gtk_hbox_new(/* homogeneous */ FALSE, 0);
gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 2);
@@ -2271,7 +2371,7 @@ static void xsane_ocr_notebook(GtkWidget *notebook)
text = gtk_entry_new();
xsane_back_gtk_set_tooltip(xsane.tooltips, text, DESC_OCR_INPUTFILE_OPT);
- gtk_widget_set_usize(text, 250, 0);
+ gtk_widget_set_size_request(text, 250, -1);
gtk_entry_set_text(GTK_ENTRY(text), (char *) preferences.ocr_inputfile_option);
gtk_box_pack_end(GTK_BOX(hbox), text, FALSE, FALSE, 2);
gtk_widget_show(text);
@@ -2279,7 +2379,7 @@ static void xsane_ocr_notebook(GtkWidget *notebook)
xsane_setup.ocr_inputfile_option_entry = text;
- /* ocroutputfileoption : */
+ /* ocr outputfile option : */
hbox = gtk_hbox_new(/* homogeneous */ FALSE, 0);
gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 2);
@@ -2290,12 +2390,79 @@ static void xsane_ocr_notebook(GtkWidget *notebook)
text = gtk_entry_new();
xsane_back_gtk_set_tooltip(xsane.tooltips, text, DESC_OCR_OUTPUTFILE_OPT);
- gtk_widget_set_usize(text, 250, 0);
+ gtk_widget_set_size_request(text, 250, -1);
gtk_entry_set_text(GTK_ENTRY(text), (char *) preferences.ocr_outputfile_option);
gtk_box_pack_end(GTK_BOX(hbox), text, FALSE, FALSE, 2);
gtk_widget_show(text);
gtk_widget_show(hbox);
xsane_setup.ocr_outputfile_option_entry = text;
+
+
+ /* ocr use gui pipe button */
+ hbox = gtk_hbox_new(/* homogeneous */ FALSE, 0);
+ gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 2);
+ button = gtk_check_button_new_with_label(RADIO_BUTTON_OCR_USE_GUI_PIPE);
+ xsane_back_gtk_set_tooltip(xsane.tooltips, button, DESC_OCR_USE_GUI_PIPE_OPT);
+ gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button), preferences.ocr_use_gui_pipe);
+ gtk_box_pack_start(GTK_BOX(hbox), button, TRUE, TRUE, 2);
+ gtk_widget_show(button);
+ gtk_widget_show(hbox);
+ xsane_setup.ocr_use_gui_pipe_entry = button;
+
+
+ /* ocr gui outfd option : */
+
+ hbox = gtk_hbox_new(/* homogeneous */ FALSE, 0);
+ gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 2);
+
+ label = gtk_label_new(TEXT_SETUP_OCR_OUTFD_OPT);
+ gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 2);
+ gtk_widget_show(label);
+
+ text = gtk_entry_new();
+ xsane_back_gtk_set_tooltip(xsane.tooltips, text, DESC_OCR_OUTFD_OPT);
+ gtk_widget_set_size_request(text, 250, -1);
+ gtk_entry_set_text(GTK_ENTRY(text), (char *) preferences.ocr_gui_outfd_option);
+ gtk_box_pack_end(GTK_BOX(hbox), text, FALSE, FALSE, 2);
+ gtk_widget_show(text);
+ gtk_widget_show(hbox);
+ xsane_setup.ocr_gui_outfd_option_entry = text;
+
+
+ /* ocr progress keyword : */
+
+ hbox = gtk_hbox_new(/* homogeneous */ FALSE, 0);
+ gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 2);
+
+ label = gtk_label_new(TEXT_SETUP_OCR_PROGRESS_KEYWORD);
+ gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 2);
+ gtk_widget_show(label);
+
+ text = gtk_entry_new();
+ xsane_back_gtk_set_tooltip(xsane.tooltips, text, DESC_OCR_PROGRESS_KEYWORD);
+ gtk_widget_set_size_request(text, 250, -1);
+ gtk_entry_set_text(GTK_ENTRY(text), (char *) preferences.ocr_progress_keyword);
+ gtk_box_pack_end(GTK_BOX(hbox), text, FALSE, FALSE, 2);
+ gtk_widget_show(text);
+ gtk_widget_show(hbox);
+ xsane_setup.ocr_progress_keyword_entry = text;
+
+ xsane_separator_new(vbox, 4);
+
+ /* apply button */
+
+ hbox = gtk_hbox_new(/* homogeneous */ FALSE, 0);
+ gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 2);
+
+#ifdef HAVE_GTK2
+ button = gtk_button_new_from_stock(GTK_STOCK_APPLY);
+#else
+ button = gtk_button_new_with_label(BUTTON_APPLY);
+#endif
+ g_signal_connect(GTK_OBJECT(button), "clicked", (GtkSignalFunc) xsane_setup_ocr_apply_changes, NULL);
+ gtk_box_pack_start(GTK_BOX(hbox), button, TRUE, TRUE, 0);
+ gtk_widget_show(button);
+ gtk_widget_show(hbox);
}
/* ---------------------------------------------------------------------------------------------------------------------- */
@@ -2303,7 +2470,18 @@ static void xsane_ocr_notebook(GtkWidget *notebook)
static void xsane_display_notebook(GtkWidget *notebook)
{
GtkWidget *setup_vbox, *vbox, *hbox, *button, *label, *text, *frame;
+ GtkWidget *show_range_mode_option_menu, *show_range_mode_menu, *show_range_mode_item;
char buf[64];
+ int i, select = 1;
+
+ typedef struct show_range_mode_t
+ {
+ char *name;
+ int number;
+ } show_range_mode;
+
+#define SHOW_RANGE_MODE_NUMBER 5
+ show_range_mode show_range_mode_strings[SHOW_RANGE_MODE_NUMBER];
DBG(DBG_proc, "xsane_display_notebook\n");
@@ -2316,7 +2494,7 @@ static void xsane_display_notebook(GtkWidget *notebook)
gtk_widget_show(setup_vbox);
frame = gtk_frame_new(0);
- gtk_container_set_border_width(GTK_CONTAINER(frame), 4);
+ gtk_container_set_border_width(GTK_CONTAINER(frame), 7);
gtk_frame_set_shadow_type(GTK_FRAME(frame), GTK_SHADOW_ETCHED_IN);
gtk_box_pack_start(GTK_BOX(setup_vbox), frame, TRUE, TRUE, 0); /* sizeable framehight */
gtk_widget_show(frame);
@@ -2352,7 +2530,59 @@ static void xsane_display_notebook(GtkWidget *notebook)
xsane_separator_new(vbox, 2);
+
+ /* show range type menu */
+ /* bit 0 (val 1) : show scale */
+ /* bit 1 (val 2) : show scrollbar */
+ /* bit 2 (val 4) : show spinbutton */
+ /* bit 3 (val 8) : show scale val */
+ show_range_mode_strings[0].name = MENU_ITEM_RANGE_SCALE;
+ show_range_mode_strings[0].number = 9; /* 1 + 8 = scale + value */
+ show_range_mode_strings[1].name = MENU_ITEM_RANGE_SCROLLBAR;
+ show_range_mode_strings[1].number = 10; /* 2 + 4 = scrollbar + value */
+ show_range_mode_strings[2].name = MENU_ITEM_RANGE_SPINBUTTON;
+ show_range_mode_strings[2].number = 4;
+ show_range_mode_strings[3].name = MENU_ITEM_RANGE_SCALE_SPIN;
+ show_range_mode_strings[3].number = 5; /* 1 + 4 = scale + spinbutton */
+ show_range_mode_strings[4].name = MENU_ITEM_RANGE_SCROLL_SPIN;
+ show_range_mode_strings[4].number = 6; /* 2 + 4 = scrollbar + spinbutton */
+
+ hbox = gtk_hbox_new(FALSE, 2);
+ gtk_container_set_border_width(GTK_CONTAINER(hbox), 2);
+ gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
+
+ label = gtk_label_new(TEXT_SETUP_SHOW_RANGE_MODE);
+ gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 2);
+ gtk_widget_show(label);
+
+ show_range_mode_option_menu = gtk_option_menu_new();
+ xsane_back_gtk_set_tooltip(xsane.tooltips, show_range_mode_option_menu, DESC_SHOW_RANGE_MODE);
+ gtk_box_pack_end(GTK_BOX(hbox), show_range_mode_option_menu, FALSE, FALSE, 2);
+ gtk_widget_show(show_range_mode_option_menu);
+ gtk_widget_show(hbox);
+
+ show_range_mode_menu = gtk_menu_new();
+
+ for (i=1; i <= SHOW_RANGE_MODE_NUMBER; i++)
+ {
+ show_range_mode_item = gtk_menu_item_new_with_label(show_range_mode_strings[i-1].name);
+ gtk_container_add(GTK_CONTAINER(show_range_mode_menu), show_range_mode_item);
+ g_signal_connect(GTK_OBJECT(show_range_mode_item), "activate", (GtkSignalFunc) xsane_setup_show_range_mode_callback, (void *) show_range_mode_strings[i-1].number);
+ gtk_widget_show(show_range_mode_item);
+ if (show_range_mode_strings[i-1].number == preferences.show_range_mode)
+ {
+ select = i-1;
+ }
+ }
+
+ gtk_option_menu_set_menu(GTK_OPTION_MENU(show_range_mode_option_menu), show_range_mode_menu);
+ gtk_option_menu_set_history(GTK_OPTION_MENU(show_range_mode_option_menu), select);
+ xsane_setup.show_range_mode = preferences.show_range_mode;
+
+ xsane_separator_new(vbox, 2);
+
+
/* preview oversampling value: */
hbox = gtk_hbox_new(/* homogeneous */ FALSE, 0);
@@ -2366,7 +2596,7 @@ static void xsane_display_notebook(GtkWidget *notebook)
snprintf(buf, sizeof(buf), "%1.2f", preferences.preview_oversampling);
text = gtk_entry_new();
xsane_back_gtk_set_tooltip(xsane.tooltips, text, DESC_PREVIEW_OVERSAMPLING);
- gtk_widget_set_usize(text, 80, 0);
+ gtk_widget_set_size_request(text, 80, -1);
gtk_entry_set_text(GTK_ENTRY(text), buf);
gtk_box_pack_end(GTK_BOX(hbox), text, FALSE, FALSE, 2);
gtk_widget_show(text);
@@ -2389,7 +2619,7 @@ static void xsane_display_notebook(GtkWidget *notebook)
snprintf(buf, sizeof(buf), "%1.2f", preferences.preview_gamma);
text = gtk_entry_new();
xsane_back_gtk_set_tooltip(xsane.tooltips, text, DESC_PREVIEW_GAMMA);
- gtk_widget_set_usize(text, 80, 0);
+ gtk_widget_set_size_request(text, 80, -1);
gtk_entry_set_text(GTK_ENTRY(text), buf);
gtk_box_pack_end(GTK_BOX(hbox), text, FALSE, FALSE, 2);
gtk_widget_show(text);
@@ -2408,7 +2638,7 @@ static void xsane_display_notebook(GtkWidget *notebook)
snprintf(buf, sizeof(buf), "%1.2f", preferences.preview_gamma_red);
text = gtk_entry_new();
xsane_back_gtk_set_tooltip(xsane.tooltips, text, DESC_PREVIEW_GAMMA_RED);
- gtk_widget_set_usize(text, 80, 0);
+ gtk_widget_set_size_request(text, 80, -1);
gtk_entry_set_text(GTK_ENTRY(text), buf);
gtk_box_pack_end(GTK_BOX(hbox), text, FALSE, FALSE, 2);
gtk_widget_show(text);
@@ -2427,7 +2657,7 @@ static void xsane_display_notebook(GtkWidget *notebook)
snprintf(buf, sizeof(buf), "%1.2f", preferences.preview_gamma_green);
text = gtk_entry_new();
xsane_back_gtk_set_tooltip(xsane.tooltips, text, DESC_PREVIEW_GAMMA_GREEN);
- gtk_widget_set_usize(text, 80, 0);
+ gtk_widget_set_size_request(text, 80, -1);
gtk_entry_set_text(GTK_ENTRY(text), buf);
gtk_box_pack_end(GTK_BOX(hbox), text, FALSE, FALSE, 2);
gtk_widget_show(text);
@@ -2446,7 +2676,7 @@ static void xsane_display_notebook(GtkWidget *notebook)
snprintf(buf, sizeof(buf), "%1.2f", preferences.preview_gamma_blue);
text = gtk_entry_new();
xsane_back_gtk_set_tooltip(xsane.tooltips, text, DESC_PREVIEW_GAMMA_BLUE);
- gtk_widget_set_usize(text, 80, 0);
+ gtk_widget_set_size_request(text, 80, -1);
gtk_entry_set_text(GTK_ENTRY(text), buf);
gtk_box_pack_end(GTK_BOX(hbox), text, FALSE, FALSE, 2);
gtk_widget_show(text);
@@ -2479,12 +2709,12 @@ static void xsane_display_notebook(GtkWidget *notebook)
text = gtk_entry_new();
xsane_back_gtk_set_tooltip(xsane.tooltips, text, DESC_DOC_VIEWER);
- gtk_widget_set_usize(text, 250, 0);
- gtk_entry_set_text(GTK_ENTRY(text), (char *) preferences.doc_viewer);
+ gtk_widget_set_size_request(text, 250, -1);
+ gtk_entry_set_text(GTK_ENTRY(text), (char *) preferences.browser);
gtk_box_pack_end(GTK_BOX(hbox), text, FALSE, FALSE, 2);
gtk_widget_show(text);
gtk_widget_show(hbox);
- xsane_setup.doc_viewer_entry = text;
+ xsane_setup.browser_entry = text;
xsane_separator_new(vbox, 4);
@@ -2495,8 +2725,12 @@ static void xsane_display_notebook(GtkWidget *notebook)
hbox = gtk_hbox_new(/* homogeneous */ FALSE, 0);
gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 2);
+#ifdef HAVE_GTK2
+ button = gtk_button_new_from_stock(GTK_STOCK_APPLY);
+#else
button = gtk_button_new_with_label(BUTTON_APPLY);
- gtk_signal_connect(GTK_OBJECT(button), "clicked", (GtkSignalFunc) xsane_setup_display_apply_changes, NULL);
+#endif
+ g_signal_connect(GTK_OBJECT(button), "clicked", (GtkSignalFunc) xsane_setup_display_apply_changes, NULL);
gtk_box_pack_start(GTK_BOX(hbox), button, TRUE, TRUE, 0);
gtk_widget_show(button);
@@ -2534,6 +2768,13 @@ static void xsane_enhance_notebook_sensitivity(int lineart_mode)
/* ---------------------------------------------------------------------------------------------------------------------- */
+static void xsane_setup_show_range_mode_callback(GtkWidget *widget, gpointer data)
+{
+ xsane_setup.show_range_mode = (int) data;
+}
+
+/* ---------------------------------------------------------------------------------------------------------------------- */
+
static void xsane_setup_lineart_mode_callback(GtkWidget *widget, gpointer data)
{
xsane_setup.lineart_mode = (int) data;
@@ -2611,7 +2852,7 @@ static void xsane_enhance_notebook(GtkWidget *notebook)
gtk_widget_show(setup_vbox);
frame = gtk_frame_new(0);
- gtk_container_set_border_width(GTK_CONTAINER(frame), 4);
+ gtk_container_set_border_width(GTK_CONTAINER(frame), 7);
gtk_frame_set_shadow_type(GTK_FRAME(frame), GTK_SHADOW_ETCHED_IN);
gtk_box_pack_start(GTK_BOX(setup_vbox), frame, TRUE, TRUE, 0); /* sizeable framehight */
gtk_widget_show(frame);
@@ -2648,8 +2889,7 @@ static void xsane_enhance_notebook(GtkWidget *notebook)
{
lineart_mode_item = gtk_menu_item_new_with_label(lineart_mode_strings[i-1].name);
gtk_container_add(GTK_CONTAINER(lineart_mode_menu), lineart_mode_item);
- gtk_signal_connect(GTK_OBJECT(lineart_mode_item), "activate",
- (GtkSignalFunc) xsane_setup_lineart_mode_callback, (void *) lineart_mode_strings[i-1].number);
+ g_signal_connect(GTK_OBJECT(lineart_mode_item), "activate", (GtkSignalFunc) xsane_setup_lineart_mode_callback, (void *) lineart_mode_strings[i-1].number);
gtk_widget_show(lineart_mode_item);
if (lineart_mode_strings[i-1].number == xsane.lineart_mode)
{
@@ -2675,7 +2915,7 @@ static void xsane_enhance_notebook(GtkWidget *notebook)
snprintf(buf, sizeof(buf), "%1.2f", xsane.threshold_min);
text = gtk_entry_new();
xsane_back_gtk_set_tooltip(xsane.tooltips, text, DESC_PREVIEW_THRESHOLD_MIN);
- gtk_widget_set_usize(text, 80, 0);
+ gtk_widget_set_size_request(text, 80, -1);
gtk_entry_set_text(GTK_ENTRY(text), buf);
gtk_box_pack_end(GTK_BOX(hbox), text, FALSE, FALSE, 2);
gtk_widget_show(text);
@@ -2695,7 +2935,7 @@ static void xsane_enhance_notebook(GtkWidget *notebook)
snprintf(buf, sizeof(buf), "%1.2f", xsane.threshold_max);
text = gtk_entry_new();
xsane_back_gtk_set_tooltip(xsane.tooltips, text, DESC_PREVIEW_THRESHOLD_MAX);
- gtk_widget_set_usize(text, 80, 0);
+ gtk_widget_set_size_request(text, 80, -1);
gtk_entry_set_text(GTK_ENTRY(text), buf);
gtk_box_pack_end(GTK_BOX(hbox), text, FALSE, FALSE, 2);
gtk_widget_show(text);
@@ -2715,7 +2955,7 @@ static void xsane_enhance_notebook(GtkWidget *notebook)
snprintf(buf, sizeof(buf), "%1.2f", xsane.threshold_mul);
text = gtk_entry_new();
xsane_back_gtk_set_tooltip(xsane.tooltips, text, DESC_PREVIEW_THRESHOLD_MUL);
- gtk_widget_set_usize(text, 80, 0);
+ gtk_widget_set_size_request(text, 80, -1);
gtk_entry_set_text(GTK_ENTRY(text), buf);
gtk_box_pack_end(GTK_BOX(hbox), text, FALSE, FALSE, 2);
gtk_widget_show(text);
@@ -2735,7 +2975,7 @@ static void xsane_enhance_notebook(GtkWidget *notebook)
snprintf(buf, sizeof(buf), "%1.2f", xsane.threshold_off);
text = gtk_entry_new();
xsane_back_gtk_set_tooltip(xsane.tooltips, text, DESC_PREVIEW_THRESHOLD_OFF);
- gtk_widget_set_usize(text, 80, 0);
+ gtk_widget_set_size_request(text, 80, -1);
gtk_entry_set_text(GTK_ENTRY(text), buf);
gtk_box_pack_end(GTK_BOX(hbox), text, FALSE, FALSE, 2);
gtk_widget_show(text);
@@ -2783,7 +3023,7 @@ static void xsane_enhance_notebook(GtkWidget *notebook)
{
gray_item = gtk_menu_item_new_with_label(_BGT(opt->constraint.string_list[i]));
gtk_container_add(GTK_CONTAINER(gray_menu), gray_item);
- gtk_signal_connect(GTK_OBJECT(gray_item), "activate", (GtkSignalFunc) xsane_setup_grayscale_mode_callback, (void *) opt->constraint.string_list[i]);
+ g_signal_connect(GTK_OBJECT(gray_item), "activate", (GtkSignalFunc) xsane_setup_grayscale_mode_callback, (void *) opt->constraint.string_list[i]);
gtk_widget_show(gray_item);
if (xsane.grayscale_scanmode)
@@ -2873,8 +3113,7 @@ static void xsane_enhance_notebook(GtkWidget *notebook)
snprintf(buf, sizeof(buf), "%d x %d pixel", j, j);
preview_pipette_range_item = gtk_menu_item_new_with_label(buf);
gtk_container_add(GTK_CONTAINER(preview_pipette_range_menu), preview_pipette_range_item);
- gtk_signal_connect(GTK_OBJECT(preview_pipette_range_item), "activate",
- (GtkSignalFunc) xsane_setup_preview_pipette_range_callback, (void *) j);
+ g_signal_connect(GTK_OBJECT(preview_pipette_range_item), "activate", (GtkSignalFunc) xsane_setup_preview_pipette_range_callback, (void *) j);
gtk_widget_show(preview_pipette_range_item);
if (preferences.preview_pipette_range == j)
{
@@ -2915,7 +3154,7 @@ static void xsane_enhance_notebook(GtkWidget *notebook)
adf_item = gtk_menu_item_new_with_label(MENU_ITEM_SELECTION_NONE);
gtk_container_add(GTK_CONTAINER(adf_menu), adf_item);
- gtk_signal_connect(GTK_OBJECT(adf_item), "activate", (GtkSignalFunc) xsane_setup_adf_mode_callback, NULL);
+ g_signal_connect(GTK_OBJECT(adf_item), "activate", (GtkSignalFunc) xsane_setup_adf_mode_callback, NULL);
gtk_widget_show(adf_item);
opt = xsane_get_option_descriptor(xsane.dev, xsane.well_known.scansource);
@@ -2938,7 +3177,7 @@ static void xsane_enhance_notebook(GtkWidget *notebook)
{
adf_item = gtk_menu_item_new_with_label(_BGT(opt->constraint.string_list[i]));
gtk_container_add(GTK_CONTAINER(adf_menu), adf_item);
- gtk_signal_connect(GTK_OBJECT(adf_item), "activate", (GtkSignalFunc) xsane_setup_adf_mode_callback, (void *) opt->constraint.string_list[i]);
+ g_signal_connect(GTK_OBJECT(adf_item), "activate", (GtkSignalFunc) xsane_setup_adf_mode_callback, (void *) opt->constraint.string_list[i]);
gtk_widget_show(adf_item);
@@ -2977,8 +3216,12 @@ static void xsane_enhance_notebook(GtkWidget *notebook)
hbox = gtk_hbox_new(/* homogeneous */ FALSE, 0);
gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 2);
+#ifdef HAVE_GTK2
+ button = gtk_button_new_from_stock(GTK_STOCK_APPLY);
+#else
button = gtk_button_new_with_label(BUTTON_APPLY);
- gtk_signal_connect(GTK_OBJECT(button), "clicked", (GtkSignalFunc) xsane_setup_enhance_apply_changes, NULL);
+#endif
+ g_signal_connect(GTK_OBJECT(button), "clicked", (GtkSignalFunc) xsane_setup_enhance_apply_changes, NULL);
gtk_box_pack_start(GTK_BOX(hbox), button, TRUE, TRUE, 0);
gtk_widget_show(button);
@@ -2998,18 +3241,16 @@ void xsane_setup_dialog(GtkWidget *widget, gpointer data)
device_options_changed = 0;
- xsane_clear_histogram(&xsane.histogram_raw);
- xsane_clear_histogram(&xsane.histogram_enh);
xsane_set_sensitivity(FALSE);
xsane.preview->calibration = 1; /* show monitor calibration image */
- setup_dialog = gtk_window_new(GTK_WINDOW_DIALOG);
+ setup_dialog = gtk_window_new(GTK_WINDOW_TOPLEVEL);
gtk_window_set_position(GTK_WINDOW(setup_dialog), GTK_WIN_POS_MOUSE);
snprintf(buf, sizeof(buf), "%s %s", xsane.prog_name, WINDOW_SETUP);
gtk_window_set_title(GTK_WINDOW(setup_dialog), buf);
- gtk_signal_connect(GTK_OBJECT(setup_dialog), "destroy", (GtkSignalFunc) xsane_destroy_setup_dialog_callback, setup_dialog);
+ g_signal_connect(GTK_OBJECT(setup_dialog), "destroy", (GtkSignalFunc) xsane_destroy_setup_dialog_callback, setup_dialog);
xsane_set_window_icon(setup_dialog, 0);
/* set the main vbox */
@@ -3043,16 +3284,23 @@ void xsane_setup_dialog(GtkWidget *widget, gpointer data)
gtk_container_set_border_width(GTK_CONTAINER(hbox), 5);
gtk_widget_show(hbox);
-
+#ifdef HAVE_GTK2
+ button = gtk_button_new_from_stock(GTK_STOCK_OK);
+#else
button = gtk_button_new_with_label(BUTTON_OK);
+#endif
GTK_WIDGET_SET_FLAGS(button, GTK_CAN_DEFAULT);
- gtk_signal_connect(GTK_OBJECT(button), "clicked", (GtkSignalFunc) xsane_setup_options_ok_callback, setup_dialog);
+ g_signal_connect(GTK_OBJECT(button), "clicked", (GtkSignalFunc) xsane_setup_options_ok_callback, setup_dialog);
gtk_box_pack_start(GTK_BOX(hbox), button, TRUE, TRUE, 0);
gtk_widget_grab_default(button);
gtk_widget_show(button);
+#ifdef HAVE_GTK2
+ button = gtk_button_new_from_stock(GTK_STOCK_CANCEL);
+#else
button = gtk_button_new_with_label(BUTTON_CANCEL);
- gtk_signal_connect(GTK_OBJECT(button), "clicked", (GtkSignalFunc) xsane_close_setup_dialog_callback, setup_dialog);
+#endif
+ g_signal_connect(GTK_OBJECT(button), "clicked", (GtkSignalFunc) xsane_close_setup_dialog_callback, setup_dialog);
gtk_box_pack_start(GTK_BOX(hbox), button, TRUE, TRUE, 0);
gtk_widget_show(button);
diff --git a/src/xsane-setup.h b/src/xsane-setup.h
index efb17f9..06e2949 100644
--- a/src/xsane-setup.h
+++ b/src/xsane-setup.h
@@ -3,7 +3,7 @@
xsane-setup.h
Oliver Rauch <Oliver.Rauch@rauch-domain.de>
- Copyright (C) 1998-2002 Oliver Rauch
+ Copyright (C) 1998-2005 Oliver Rauch
This file is part of the XSANE package.
This program is free software; you can redistribute it and/or modify
diff --git a/src/xsane-text.h b/src/xsane-text.h
index 1ca47ad..c36a73a 100644
--- a/src/xsane-text.h
+++ b/src/xsane-text.h
@@ -3,7 +3,7 @@
xsane-text.h
Oliver Rauch <Oliver.Rauch@rauch-domain.de>
- Copyright (C) 1998-2002 Oliver Rauch
+ Copyright (C) 1998-2005 Oliver Rauch
This file is part of the XSANE package.
This program is free software; you can redistribute it and/or modify
@@ -29,16 +29,22 @@
#define XSANE_LANGUAGE_DIR _("language_dir")
#define XSANE_STRSTATUS(status) _(sane_strstatus(status))
-#define _BGT(text) dgettext(xsane.backend, text)
+#define _BGT(text) dgettext(xsane.backend_translation, text)
#define XSANE_COPYRIGHT_SIGN _("(c)") /* can be translated with \251 */
+#define FILENAME_PREFIX_CLONE_OF _("clone-of-")
+
#define WINDOW_ABOUT_XSANE _("About")
#define WINDOW_ABOUT_TRANSLATION _("About translation")
#define WINDOW_AUTHORIZE _("authorization")
-#define WINDOW_LICENSE _("license")
+#define WINDOW_GPL _("GPL - the license")
+#define WINDOW_EULA _("End User License Agreement")
#define WINDOW_INFO _("info")
+#define WINDOW_LOAD_BATCH_LIST _("load batch list")
+#define WINDOW_SAVE_BATCH_LIST _("save batch list")
#define WINDOW_BATCH_SCAN _("batch scan")
+#define WINDOW_BATCH_RENAME _("rename batch area")
#define WINDOW_FAX_PROJECT _("fax project")
#define WINDOW_FAX_RENAME _("rename fax page")
#define WINDOW_FAX_INSERT _("insert ps-file into fax")
@@ -46,6 +52,9 @@
#define WINDOW_MAIL_RENAME _("rename mail image")
#define WINDOW_MAIL_INSERT _("insert file into mail")
#define WINDOW_PRESET_AREA_RENAME _("rename preset area")
+#define WINDOW_PRESET_AREA_ADD _("add preset area")
+#define WINDOW_MEDIUM_RENAME _("rename medium")
+#define WINDOW_MEDIUM_ADD _("add new medium")
#define WINDOW_SETUP _("setup")
#define WINDOW_HISTOGRAM _("Histogram")
#define WINDOW_GAMMA _("Gamma curve")
@@ -65,12 +74,16 @@
#define WINDOW_DESPECKLE _("Despeckle image")
#define WINDOW_BLUR _("Blur image")
#define WINDOW_STORE_MEDIUM _("Store medium definition")
+#define WINDOW_NO_DEVICES _("No devices available")
#define MENU_FILE _("File")
#define MENU_PREFERENCES _("Preferences")
#define MENU_VIEW _("View")
+#define MENU_WINDOW _("Window")
#define MENU_HELP _("Help")
+#define MENU_EDIT _("Edit")
#define MENU_FILTERS _("Filters")
+#define MENU_GEOMETRY _("Geometry")
#define MENU_ITEM_ABOUT_XSANE _("About XSane")
#define MENU_ITEM_ABOUT_TRANSLATION _("About translation")
@@ -78,17 +91,26 @@
#define MENU_ITEM_QUIT _("Quit")
#define MENU_ITEM_SAVE_IMAGE _("Save image")
-#define MENU_ITEM_CLOSE _("Close")
-
+#define MENU_ITEM_OCR _("OCR - save as text")
#define MENU_ITEM_CLONE _("Clone")
#define MENU_ITEM_SCALE _("Scale")
+#define MENU_ITEM_CLOSE _("Close")
+
+#define MENU_ITEM_UNDO _("Undo")
+
#define MENU_ITEM_DESPECKLE _("Despeckle")
#define MENU_ITEM_BLUR _("Blur")
+#define MENU_ITEM_ROTATE90 _("Rotate 90")
+#define MENU_ITEM_ROTATE180 _("Rotate 180")
+#define MENU_ITEM_ROTATE270 _("Rotate 270")
+#define MENU_ITEM_MIRROR_X _("Mirror |")
+#define MENU_ITEM_MIRROR_Y _("Mirror -")
+
#define FRAME_RAW_IMAGE _("Raw image")
#define FRAME_ENHANCED_IMAGE _("Enhanced image")
-#define BUTTON_START _("Start")
+#define BUTTON_SCAN _("Scan")
#define BUTTON_OK _("Ok")
#define BUTTON_ACCEPT _("Accept")
#define BUTTON_NOT_ACCEPT _("Not accept")
@@ -98,13 +120,16 @@
#define BUTTON_CONT_AT_OWN_RISK _("Continue at your own risk")
#define BUTTON_BROWSE _("Browse")
#define BUTTON_CLOSE _("Close")
+#define BUTTON_HELP _("Help")
#define BUTTON_OVERWRITE _("Overwrite")
-#define BUTTON_ADD_AREA _("Add area")
+#define BUTTON_BATCH_LIST_SCAN _("Scan batch list")
+#define BUTTON_BATCH_AREA_SCAN _("Scan selected area")
#define BUTTON_PAGE_DELETE _("Delete page")
#define BUTTON_PAGE_SHOW _("Show page")
#define BUTTON_PAGE_RENAME _("Rename page")
#define BUTTON_IMAGE_DELETE _("Delete image")
#define BUTTON_IMAGE_SHOW _("Show image")
+#define BUTTON_IMAGE_EDIT _("Edit image")
#define BUTTON_IMAGE_RENAME _("Rename image")
#define BUTTON_FILE_INSERT _("Insert file")
#define BUTTON_CREATE_PROJECT _("Create project")
@@ -124,6 +149,7 @@
#define RADIO_BUTTON_SAVE_DEVPREFS_AT_EXIT _("Save device preferences at exit")
#define RADIO_BUTTON_OVERWRITE_WARNING _("Overwrite warning")
#define RADIO_BUTTON_SKIP_EXISTING_NRS _("Skip existing filenames")
+#define RADIO_BUTTON_SAVE_PNM16_AS_ASCII _("Save 16bit pnm in ascii format")
#define RADIO_BUTTON_REDUCE_16BIT_TO_8BIT _("Reduce 16 bit image to 8 bit")
#define RADIO_BUTTON_WINDOW_FIXED _("Main window size fixed")
#define RADIO_BUTTON_DISABLE_GIMP_PREVIEW_GAMMA _("Disable gimp preview gamma")
@@ -132,6 +158,7 @@
#define RADIO_BUTTON_PRESELECT_SCANAREA _("Preselect scanarea")
#define RADIO_BUTTON_AUTOCORRECT_COLORS _("Autocorrect colors")
#define RADIO_BUTTON_POP3_AUTHENTIFICATION _("POP3 authentification")
+#define RADIO_BUTTON_OCR_USE_GUI_PIPE _("Use GUI progress pipe")
#define TEXT_SCANNING_DEVICES _("scanning for devices")
#define TEXT_AVAILABLE_DEVICES _("Available devices:")
@@ -174,6 +201,17 @@
#define TEXT_GTK_VERSION _("compiled with GTK-")
#define TEXT_GIMP_VERSION _("compiled with GIMP-")
#define TEXT_UNKNOWN _("unknown")
+#define TEXT_EULA _( "XSane is distributed under the terms of the GNU General Public License\n" \
+ "as published by the Free Software Foundation; either version 2 of the\n" \
+ "License, or (at your option) any later version.\n" \
+ "\n" \
+ "This program is distributed in the hope that it will be useful, but\n" \
+ "WITHOUT ANY WARRANTY; without even the implied warranty of\n" \
+ "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n" \
+ "Should the program prove defective, you assume the cost of all\n" \
+ "necessary servicing, repair or correction. To use this program you\n" \
+ "have to read, understand and accept the following\n" \
+ "\"NO WARRANTY\" agreement.\n")
#define TEXT_GPL _("XSane is distributed under the terms of the GNU General Public License\n" \
"as published by the Free Software Foundation; either version 2 of the\n" \
"License, or (at your option) any later version.\n" \
@@ -201,14 +239,21 @@
#define TEXT_MAIL_TEXT _("Email text:")
#define TEXT_ATTACHMENTS _("Attachments:")
#define TEXT_MAIL_STATUS _("Project status:")
+#define TEXT_MAIL_FILETYPE _("Mail image filetype:")
#define TEXT_MEDIUM_DEFINITION_NAME _("Medium Name:")
#define TEXT_VIEWER_IMAGE_INFO _("Size %d x %d pixel, %d bit/color, %d colors, %1.0f dpi x %1.0f dpi, %1.1f %s")
-#define TEXT_X_SCALE_FACTOR _("X-Scale factor:")
-#define TEXT_Y_SCALE_FACTOR _("Y-Scale factor:")
#define TEXT_DESPECKLE_RADIUS _("Despeckle radius:")
#define TEXT_BLUR_RADIUS _("Blur radius:")
+#define TEXT_BATCH_AREA_DEFAULT_NAME _("(no name)")
+#define TEXT_BATCH_LIST_AREANAME _("Area name:")
+#define TEXT_BATCH_LIST_SCANMODE _("Scanmode:")
+#define TEXT_BATCH_LIST_GEOMETRY_TL _("Top left:")
+#define TEXT_BATCH_LIST_GEOMETRY_SIZE _("Size:")
+#define TEXT_BATCH_LIST_RESOLUTION _("Resolution:")
+#define TEXT_BATCH_LIST_BIT_DEPTH _("Bit depth:")
+#define TEXT_BATCH_LIST_BY_GUI _("as selected")
#define TEXT_SETUP_PRINTER_SEL _("Printer selection:")
#define TEXT_SETUP_PRINTER_NAME _("Name:")
@@ -234,6 +279,7 @@
#define TEXT_SETUP_TIFF_COMPRESSION_16 _("TIFF 16 bit image compression")
#define TEXT_SETUP_TIFF_COMPRESSION_8 _("TIFF 8 bit image compression")
#define TEXT_SETUP_TIFF_COMPRESSION_1 _("TIFF lineart image compression")
+#define TEXT_SETUP_SHOW_RANGE_MODE _("Show range as:")
#define TEXT_SETUP_PREVIEW_OVERSAMPLING _("Preview oversampling:")
#define TEXT_SETUP_PREVIEW_GAMMA _("Preview gamma:")
#define TEXT_SETUP_PREVIEW_GAMMA_RED _("Preview gamma red:")
@@ -253,6 +299,7 @@
#define TEXT_SETUP_FAX_POSTSCRIPT_OPT _("Postscriptfile option:")
#define TEXT_SETUP_FAX_NORMAL_MODE_OPT _("Normal mode option:")
#define TEXT_SETUP_FAX_FINE_MODE_OPT _("Fine mode option:")
+#define TEXT_SETUP_FAX_PROGRAM_DEFAULTS _("Set program defaults for:")
#define TEXT_SETUP_FAX_VIEWER _("Viewer (Postscript):")
#define TEXT_SETUP_FAX_WIDTH _("Width")
#define TEXT_SETUP_FAX_HEIGHT _("Height")
@@ -270,9 +317,13 @@
#define TEXT_SETUP_OCR_COMMAND _("OCR Command:")
#define TEXT_SETUP_OCR_INPUTFILE_OPT _("Inputfile option:")
#define TEXT_SETUP_OCR_OUTPUTFILE_OPT _("Outputfile option:")
+#define TEXT_SETUP_OCR_USE_GUI_PIPE_OPT _("Use GUI progress pipe:")
+#define TEXT_SETUP_OCR_OUTFD_OPT _("GUI output-fd option:")
+#define TEXT_SETUP_OCR_PROGRESS_KEYWORD _("Progress keyword:")
#define TEXT_SETUP_PERMISSION_USER _("user")
#define TEXT_SETUP_PERMISSION_GROUP _("group")
#define TEXT_SETUP_PERMISSION_ALL _("all")
+#define TEXT_NEW_MEDIA_NAME _("new media")
#define NOTEBOOK_SAVING_OPTIONS _("Save")
#define NOTEBOOK_IMAGE_OPTIONS _("Image")
@@ -293,6 +344,7 @@
#define MENU_ITEM_SHOW_PREVIEW _("Show preview")
#define MENU_ITEM_SHOW_HISTOGRAM _("Show histogram")
#define MENU_ITEM_SHOW_GAMMA _("Show gamma curve")
+#define MENU_ITEM_SHOW_BATCH_SCAN _("Show batch scan")
#define MENU_ITEM_SHOW_STANDARDOPTIONS _("Show standard options")
#define MENU_ITEM_SHOW_ADVANCEDOPTIONS _("Show advanced options")
@@ -307,11 +359,13 @@
#define SUBMENU_ITEM_POLICY_DELAYED _("delayed")
#define MENU_ITEM_SHOW_RESOLUTIONLIST _("Show resolution list")
#define MENU_ITEM_PAGE_ROTATE _("Rotate postscript")
+#define MENU_ITEM_EDIT_MEDIUM_DEF _("Edit medium definition")
#define MENU_ITEM_SAVE_DEVICE_SETTINGS _("Save device settings")
#define MENU_ITEM_LOAD_DEVICE_SETTINGS _("Load device settings")
#define MENU_ITEM_CHANGE_WORKING_DIR _("Change directory")
-#define MENU_ITEM_XSANE_LICENSE _("License")
+#define MENU_ITEM_XSANE_EULA _("Show EULA")
+#define MENU_ITEM_XSANE_GPL _("Show license (GPL)")
#define MENU_ITEM_XSANE_DOC _("XSane doc")
#define MENU_ITEM_BACKEND_DOC _("Backend doc")
#define MENU_ITEM_AVAILABLE_BACKENDS _("Available backends")
@@ -326,6 +380,12 @@
#define MENU_ITEM_TIFF_COMP_JPEG _("JPEG DCT compression")
#define MENU_ITEM_TIFF_COMP_PACKBITS _("pack bits")
+#define MENU_ITEM_RANGE_SCALE _("Slider (Scale)")
+#define MENU_ITEM_RANGE_SCROLLBAR _("Slider (Scrollbar)")
+#define MENU_ITEM_RANGE_SPINBUTTON _("Spinbutton")
+#define MENU_ITEM_RANGE_SCALE_SPIN _("Scale and Spinbutton")
+#define MENU_ITEM_RANGE_SCROLL_SPIN _("Scrollbar and Spinbutton")
+
#define MENU_ITEM_LINEART_MODE_STANDARD _("Standard options window (lineart)")
#define MENU_ITEM_LINEART_MODE_XSANE _("XSane main window (lineart)")
#define MENU_ITEM_LINEART_MODE_GRAY _("XSane main window (grayscale->lineart)")
@@ -334,10 +394,12 @@
#define MENU_ITEM_FILETYPE_BY_EXT _("by ext")
#define MENU_ITEM_PRESET_AREA_ADD_SEL _("Add selection to list")
-#define MENU_ITEM_PRESET_AREA_RENAME _("Rename definiton")
-#define MENU_ITEM_PRESET_AREA_DELETE _("Delete definition")
-#define MENU_OTEM_PRESET_AREA_MOVE_UP _("Move up")
-#define MENU_OTEM_PRESET_AREA_MOVE_DWN _("Move down")
+#define MENU_ITEM_MEDIUM_ADD _("Add medium definition")
+
+#define MENU_ITEM_RENAME _("Rename item")
+#define MENU_ITEM_DELETE _("Delete item")
+#define MENU_ITEM_MOVE_UP _("Move item up")
+#define MENU_ITEM_MOVE_DWN _("Move item down")
#define PROGRESS_SCANNING _("Scanning")
#define PROGRESS_RECEIVING_FRAME_DATA _("Receiving %s data")
@@ -352,6 +414,7 @@
#define PROGRESS_SCALING_DATA _("Scaling image")
#define PROGRESS_DESPECKLING_DATA _("Despeckling image")
#define PROGRESS_BLURING_DATA _("Bluring image")
+#define PROGRESS_OCR _("OCR in progress")
#define DESC_SCAN_START _("Start scan <Ctrl-Enter>")
#define DESC_SCAN_CANCEL _("Cancel scan <ESC>")
@@ -359,7 +422,9 @@
#define DESC_PREVIEW_CANCEL _("Cancel preview scan <Alt-ESC>")
#define DESC_XSANE_MODE _("save-<Ctrl-s>, view-<Ctrl-v>, photocopy-<Ctrl-c>, " \
"fax-<Ctrl-f> or mail-<Ctrl-m>")
-#define DESC_XSANE_MEDIUM _("Select source medium type")
+#define DESC_XSANE_MEDIUM _("Select source medium type.\n" \
+ "To rename, reorder or delete an entry use context menu (right mouse button).\n"\
+ "To create a medium enable the option edit medium definition in preferences menu.")
#define DESC_FILENAME_COUNTER_STEP _("Value that is added to filenamecounter after scan")
#define DESC_BROWSE_FILENAME _("Browse for image filename")
@@ -372,7 +437,11 @@
#define DESC_MAILIMAGENAME _("Enter new name for mail image")
#define DESC_MAILRECEIVER _("Enter email address")
#define DESC_MAILSUBJECT _("Enter subject of email")
-#define DESC_PRESET_AREA_NAME _("Enter new name for preset area")
+#define DESC_MAIL_FILETYPE _("Select filetype for image attachments")
+#define DESC_PRESET_AREA_RENAME _("Enter new name for preset area")
+#define DESC_PRESET_AREA_ADD _("Enter name for new preset area")
+#define DESC_MEDIUM_RENAME _("Enter new name for medium definition")
+#define DESC_MEDIUM_ADD _("Enter name for new medium definition")
#define DESC_PRINTER_SELECT _("Select printerdefinition <Shift-F1/F2/...>")
@@ -384,7 +453,7 @@
#define DESC_ZOOM_Y _("Set zoomfactor for y direction")
#define DESC_COPY_NUMBER _("Set number of copies")
-#define DESC_NEGATIVE _("Negative: Invert colors for scanning negatives <Shift-n>")
+#define DESC_NEGATIVE _("Negative: Invert colors for scanning negatives <Ctrl-n>")
#define DESC_GAMMA _("Set gamma value")
#define DESC_GAMMA_R _("Set gamma value for red component")
@@ -404,18 +473,18 @@
#define DESC_THRESHOLD _("Set threshold")
#define DESC_RGB_DEFAULT _("RGB default: Set enhancement values for red, " \
- "green and blue to default values <Shift-b>:\n" \
+ "green and blue to default values <Ctrl-b>:\n" \
" gamma = 1.0\n" \
" brightness = 0\n" \
" contrast = 0")
-#define DESC_ENH_AUTO _("Autoadjust gamma, brightness and contrast <Shift-e>")
-#define DESC_ENH_DEFAULT _("Set default enhancement values <Shift-d>:\n" \
+#define DESC_ENH_AUTO _("Autoadjust gamma, brightness and contrast <Ctrl-e>")
+#define DESC_ENH_DEFAULT _("Set default enhancement values <Ctrl-0>:\n" \
"gamma = 1.0\n" \
"brightness = 0\n" \
"contrast = 0")
-#define DESC_ENH_RESTORE _("Restore enhancement values from preferences <Shift-r>")
-#define DESC_ENH_STORE _("Store active enhancement values to preferences <Shift-m>")
+#define DESC_ENH_RESTORE _("Restore enhancement values from preferences <Ctrl-r>")
+#define DESC_ENH_STORE _("Store active enhancement values to preferences <Ctrl-+>")
#define DESC_HIST_INTENSITY _("Show histogram of intensity/gray <Alt-i>")
#define DESC_HIST_RED _("Show histogram of red component <Alt-r>")
@@ -450,6 +519,10 @@
#define DESC_SAVE_DEVPREFS_AT_EXIT _("Save device dependant preferences in default file at exit of xsane")
#define DESC_OVERWRITE_WARNING _("Warn before overwriting an existing file")
#define DESC_SKIP_EXISTING _("If filename counter is automatically increased, used numbers are skipped")
+#define DESC_SAVE_PNM16_AS_ASCII _("When a 16 bit image shall be saved in pnm format then use ascii format " \
+ "instead of binary format. The binary format is a new format that is not " \
+ "supported by all programs. The ascii format is supported by more programs " \
+ "but it produces really huge files!!!")
#define DESC_REDUCE_16BIT_TO_8BIT _("If scanner sends image with 16 bits/color save image with 8 bits/color")
#define DESC_PSFILE_WIDTH _("Width of paper for postscript files")
#define DESC_PSFILE_HEIGHT _("Height of paper for postscript files")
@@ -458,6 +531,7 @@
#define DESC_MAIN_WINDOW_FIXED _("Use fixed main window size or scrolled, resizable main window")
#define DESC_DISABLE_GIMP_PREVIEW_GAMMA _("Disable preview gamma when XSane runs as gimp plugin")
#define DESC_PREVIEW_COLORMAP _("Use an own colormap for preview if display depth is 8 bpp")
+#define DESC_SHOW_RANGE_MODE _("Select how a range is displayed")
#define DESC_PREVIEW_OVERSAMPLING _("Value with that the calculated preview resolution is multiplied")
#define DESC_PREVIEW_GAMMA _("Set gamma correction value for preview image")
#define DESC_PREVIEW_GAMMA_RED _("Set gamma correction value for red component of preview image")
@@ -500,45 +574,67 @@
#define DESC_POP3_USER _("user name for POP3 server")
#define DESC_POP3_PASS _("password for POP3 server")
#define DESC_MAIL_VIEWER _("Enter command to be executed to view a mail image")
-#define DESC_HTML_MAIL _("Mail is sent in html mode, images are displayed directly")
+#define DESC_HTML_MAIL _("Mail is sent in html mode, place image with: <IMAGE>")
#define DESC_OCR_COMMAND _("Enter command to start ocr program")
#define DESC_OCR_INPUTFILE_OPT _("Enter option of the ocr program to define input file")
#define DESC_OCR_OUTPUTFILE_OPT _("Enter option of the ocr program to define output file")
+#define DESC_OCR_USE_GUI_PIPE_OPT _("Define if the ocr program supports gui progress pipe")
+#define DESC_OCR_OUTFD_OPT _("Enter option of the ocr program to define output filedescripor in GUI mode")
+#define DESC_OCR_PROGRESS_KEYWORD _("Define Keyword that is used to mark progress information")
#define DESC_PERMISSION_READ _("read")
#define DESC_PERMISSION_WRITE _("write")
#define DESC_PERMISSION_EXECUTE _("execute")
+#define DESC_ADD_BATCH _("Add selection for batch scan")
#define DESC_PIPETTE_WHITE _("Pick white point")
#define DESC_PIPETTE_GRAY _("Pick gray point")
#define DESC_PIPETTE_BLACK _("Pick black point")
#define DESC_ZOOM_FULL _("Use full scanarea")
#define DESC_ZOOM_OUT _("Zoom 20% out")
-#define DESC_ZOOM_IN _("Zoom into selected area")
+#define DESC_ZOOM_IN _("Click at position to zoom to")
+#define DESC_ZOOM_AREA _("Zoom into selected area")
#define DESC_ZOOM_UNDO _("Undo last zoom")
#define DESC_FULL_PREVIEW_AREA _("Select visible area")
#define DESC_AUTOSELECT_SCANAREA _("Autoselect scanarea")
+#define DESC_AUTORAISE_SCANAREA _("Autoraise scanarea")
#define DESC_DELETE_IMAGES _("Delete preview image cache")
-#define DESC_PRESET_AREA _("Preset area")
+#define DESC_PRESET_AREA _("Preset area:\n" \
+ "To add new area or edit an existing area use contect menu (right mouse button).")
#define DESC_ROTATION _("Rotate preview and scan")
+#define DESC_RATIO _("Aspect ratio of selection")
+#define DESC_PAPER_ORIENTATION _("Define image position for printing")
#define DESC_VIEWER_SAVE _("Save image")
#define DESC_VIEWER_OCR _("Optical Character Recognition")
+#define DESC_VIEWER_UNDO _("Undo last change")
#define DESC_VIEWER_CLONE _("Clone image")
#define DESC_VIEWER_SCALE _("Scale image")
#define DESC_VIEWER_DESPECKLE _("Despeckle image")
#define DESC_VIEWER_BLUR _("Blur image")
-#define DESC_VIEWER_ROTATE90 _("Rotate image 90 degree")
-#define DESC_VIEWER_ROTATE180 _("Rotate image 180 degree")
-#define DESC_VIEWER_ROTATE270 _("Rotate image 270 degree")
-#define DESC_VIEWER_MIRROR_X _("Mirror image at vertical axis")
-#define DESC_VIEWER_MIRROR_Y _("Mirror image at horizontal axis")
+#define DESC_ROTATE90 _("Rotate image 90 degree")
+#define DESC_ROTATE180 _("Rotate image 180 degree")
+#define DESC_ROTATE270 _("Rotate image 270 degree")
+#define DESC_MIRROR_X _("Mirror image at vertical axis")
+#define DESC_MIRROR_Y _("Mirror image at horizontal axis")
#define DESC_VIEWER_ZOOM _("Zoom image")
#define DESC_STORE_MEDIUM _("Store medium")
#define DESC_DELETE_MEDIUM _("Delete active medium")
+#define DESC_SCALE_FACTOR _("Scale factor")
+#define DESC_X_SCALE_FACTOR _("X-Scale factor")
+#define DESC_Y_SCALE_FACTOR _("Y-Scale factor")
+#define DESC_SCALE_WIDTH _("Scale image to width [in pixel]")
+#define DESC_SCALE_HEIGHT _("Scale image to height [in pixel]")
+#define DESC_BATCH_LIST_EMPTY _("Empty batch list")
+#define DESC_BATCH_LIST_SAVE _("Save batch list")
+#define DESC_BATCH_LIST_LOAD _("Load batch list")
+#define DESC_BATCH_RENAME _("Rename area")
+#define DESC_BATCH_ADD _("Add selected preview area to batch list")
+#define DESC_BATCH_DEL _("Delete selected area from batch list")
+#define DESC_AUTOMATIC _("Turns on automatic mode")
#define ERR_HOME_DIR _("Failed to determine home directory:")
#define ERR_CHANGE_WORKING_DIR _("Failed to change working directory to")
@@ -565,8 +661,11 @@
#define ERR_TOO_MUCH_DATA _("Backend sends more image data than it defined in parameters")
#define ERR_LIBTIFF _("LIBTIFF reports error")
#define ERR_LIBPNG _("LIBPNG reports error")
+#define ERR_LIBJPEG _("LIBJPEG reports error")
#define ERR_UNKNOWN_TYPE _("unknown type")
#define ERR_UNKNOWN_CONSTRAINT_TYPE _("unknown constraint type")
+#define ERR_OPTION_NAME_NULL _("Option has empty name (NULL).")
+#define ERR_BACKEND_BUG _("This is a backend bug. Please inform the author of the backend!")
#define ERR_FAILED_EXEC_DOC_VIEWER _("Failed to execute documentation viewer:")
#define ERR_FAILED_EXEC_FAX_VIEWER _("Failed to execute fax viewer:")
#define ERR_FAILED_EXEC_FAX_CMD _("Failed to execute fax command:")
@@ -602,6 +701,7 @@ YOU ARE ALONE!\
#define ERR_HEADER_ERROR _("Error")
#define ERR_HEADER_WARNING _("Warning")
#define ERR_HEADER_INFO _("Information")
+#define ERR_HEADER_CHILD_PROCESS_ERROR _("Child process error")
#define ERR_FAILED_CREATE_FILE _("Failed to create file:")
#define ERR_LOAD_DEVICE_SETTINGS _("Error while loading device settings:")
@@ -641,8 +741,6 @@ The format of [DEVICE] is backendname:devicefile (e.g. umax:/dev/scanner).\n\
-m, --mail start with mail-mode active\n\
-n, --no-mode-selection disable menu for XSane mode selection\n\
\n\
- -M, --Medium-calibration enable medium calibration mode\n\
-\n\
-F, --Fixed fixed main window size (overwrite preferences value)\n\
-R, --Resizeable resizable, scrolled main window (overwrite preferences value)\n\
\n\
@@ -665,6 +763,14 @@ The format of [DEVICE] is backendname:devicefile (e.g. umax:/dev/scanner).\n\
#define XSANE_GIMP_MENU_DIALOG_OLD _("<Toolbox>/Xtns/XSane/Device dialog...")
#define XSANE_GIMP_MENU_OLD _("<Toolbox>/Xtns/XSane/")
+#define HELP_NO_DEVICES _("Possible reasons:\n" \
+ "1) There really is no device that is supported by SANE\n" \
+ "2) Supported devices are busy\n" \
+ "3) The permissions for the device file do not allow you to use it - try as root\n" \
+ "4) The backend is not loaded by SANE (man sane-dll)\n" \
+ "5) The backend is not configured correct (man sane-\"backendname\")\n" \
+ "6) Possibly there is more than one SANE version installed" )
+
/* strings that are used in structures, so it is not allowed to use _()/gettext() here */
/* gettext_noop does mark these texts but does not change the string */
@@ -686,7 +792,7 @@ The format of [DEVICE] is backendname:devicefile (e.g. umax:/dev/scanner).\n\
#define MENU_ITEM_SURFACE_letter_P N_("letter port.")
#define MENU_ITEM_SURFACE_letter_L N_("letter land.")
-#define MENU_ITEM_MEDIUM_FULL_RANGE N_("Full range")
+#define MENU_ITEM_MEDIUM_FULL_COLOR_RANGE N_("Full color range")
#define MENU_ITEM_MEDIUM_SLIDE N_("Slide")
#define MENU_ITEM_MEDIUM_STANDARD_NEG N_("Standard negative")
#define MENU_ITEM_MEDIUM_AGFA_NEG N_("Agfa negative")
@@ -698,4 +804,22 @@ The format of [DEVICE] is backendname:devicefile (e.g. umax:/dev/scanner).\n\
#define MENU_ITEM_MEDIUM_KONICA_NEG_VX_100 N_("Konica negative VX 100")
#define MENU_ITEM_MEDIUM_ROSSMANN_NEG_HR_100 N_("Rossmann negative HR 100")
+#define TEXT_MAIL_STATUS_NOT_CREATED N_("Mail project not created")
+#define TEXT_MAIL_STATUS_CREATED N_("Mail project created")
+#define TEXT_MAIL_STATUS_CHANGED N_("Mail project changed")
+#define TEXT_MAIL_STATUS_ERR_READ_PROJECT N_("Error reading mailproject")
+#define TEXT_MAIL_STATUS_POP3_CONNECTION_FAILED N_("POP3 connection failed")
+#define TEXT_MAIL_STATUS_POP3_LOGIN_FAILED N_("POP3 login failed")
+#define TEXT_MAIL_STATUS_SMTP_CONNECTION_FAILED N_("SMTP connection failed")
+#define TEXT_MAIL_STATUS_SMTP_ERR_FROM N_("From entry not accepted")
+#define TEXT_MAIL_STATUS_SMTP_ERR_RCPT N_("Receiver entry not accepted")
+#define TEXT_MAIL_STATUS_SMTP_ERR_DATA N_("Mail data not accepted")
+#define TEXT_MAIL_STATUS_SENDING N_("Sending mail")
+#define TEXT_MAIL_STATUS_SENT N_("Mail has been sent")
+
+#define TEXT_FAX_STATUS_NOT_CREATED N_("Fax project not created")
+#define TEXT_FAX_STATUS_CREATED N_("Fax project created")
+#define TEXT_FAX_STATUS_CHANGED N_("Fax project changed")
+#define TEXT_FAX_STATUS_QUEUEING_FAX N_("Queueing Fax")
+#define TEXT_FAX_STATUS_FAX_QUEUED N_("Fax is queued")
#endif
diff --git a/src/xsane-viewer.c b/src/xsane-viewer.c
index e9a8dd9..9fcae69 100644
--- a/src/xsane-viewer.c
+++ b/src/xsane-viewer.c
@@ -3,7 +3,7 @@
xsane-viewer.c
Oliver Rauch <Oliver.Rauch@rauch-domain.de>
- Copyright (C) 1998-2002 Oliver Rauch
+ Copyright (C) 1998-2005 Oliver Rauch
This file is part of the XSANE package.
This program is free software; you can redistribute it and/or modify
@@ -23,7 +23,6 @@
/* ---------------------------------------------------------------------------------------------------------------------- */
#include "xsane.h"
-/* #include <sys/param.h> */
#include "xsane-back-gtk.h"
#include "xsane-front-gtk.h"
#include "xsane-preferences.h"
@@ -41,11 +40,11 @@
/* ---------------------------------------------------------------------------------------------------------------------- */
-static int xsane_viewer_zoom[] = {35, 50, 71, 100, 141, 200, 282, 400 };
-#define XSANE_VIEWER_ZOOM_ITEMS 8
+static int xsane_viewer_zoom[] = {9, 13, 18, 25, 35, 50, 71, 100, 141, 200, 282, 400 };
/* ---------------------------------------------------------------------------------------------------------------------- */
+static void xsane_viewer_set_sensitivity(Viewer *v, int sensitivity);
static gint xsane_viewer_close_callback(GtkWidget *window, gpointer data);
static void xsane_viewer_dialog_cancel(GtkWidget *window, gpointer data);
static void xsane_viewer_save_callback(GtkWidget *window, gpointer data);
@@ -62,10 +61,87 @@ static void xsane_viewer_rotate180_callback(GtkWidget *window, gpointer data);
static void xsane_viewer_rotate270_callback(GtkWidget *window, gpointer data);
static void xsane_viewer_mirror_x_callback(GtkWidget *window, gpointer data);
static void xsane_viewer_mirror_y_callback(GtkWidget *window, gpointer data);
-static GtkWidget *xsane_viewer_files_build_menu(Viewer *v);
+static GtkWidget *xsane_viewer_file_build_menu(Viewer *v);
+static GtkWidget *xsane_viewer_edit_build_menu(Viewer *v);
static GtkWidget *xsane_viewer_filters_build_menu(Viewer *v);
static int xsane_viewer_read_image(Viewer *v);
-Viewer *xsane_viewer_new(char *filename, int reduce_to_lineart, char *output_filename);
+Viewer *xsane_viewer_new(char *filename, int allow_reduction_to_lineart, char *output_filename, viewer_modification allow_modification);
+
+/* ---------------------------------------------------------------------------------------------------------------------- */
+
+static void xsane_viewer_set_sensitivity(Viewer *v, int sensitivity)
+{
+ if (sensitivity)
+ {
+ v->block_actions = FALSE;
+ gtk_widget_set_sensitive(GTK_WIDGET(v->file_menu), TRUE);
+ gtk_widget_set_sensitive(GTK_WIDGET(v->button_box), TRUE);
+
+ switch (v->allow_modification)
+ {
+ case VIEWER_NO_MODIFICATION:
+ gtk_widget_set_sensitive(GTK_WIDGET(v->save_menu_item), FALSE);
+ gtk_widget_set_sensitive(GTK_WIDGET(v->ocr_menu_item), FALSE);
+ gtk_widget_set_sensitive(GTK_WIDGET(v->clone_menu_item), FALSE);
+ gtk_widget_set_sensitive(GTK_WIDGET(v->edit_menu), FALSE);
+ gtk_widget_set_sensitive(GTK_WIDGET(v->filters_menu), FALSE);
+ gtk_widget_set_sensitive(GTK_WIDGET(v->geometry_menu), FALSE);
+
+ gtk_widget_set_sensitive(GTK_WIDGET(v->save), FALSE);
+ gtk_widget_set_sensitive(GTK_WIDGET(v->ocr), FALSE);
+ gtk_widget_set_sensitive(GTK_WIDGET(v->clone), FALSE);
+ gtk_widget_set_sensitive(GTK_WIDGET(v->edit_button_box), FALSE);
+ gtk_widget_set_sensitive(GTK_WIDGET(v->filters_button_box), FALSE);
+ gtk_widget_set_sensitive(GTK_WIDGET(v->geometry_button_box), FALSE);
+ break;
+
+ case VIEWER_NO_NAME_AND_SIZE_MODIFICATION:
+ gtk_widget_set_sensitive(GTK_WIDGET(v->save_menu_item), TRUE);
+ gtk_widget_set_sensitive(GTK_WIDGET(v->ocr_menu_item), FALSE);
+ gtk_widget_set_sensitive(GTK_WIDGET(v->clone_menu_item), FALSE);
+ gtk_widget_set_sensitive(GTK_WIDGET(v->edit_menu), TRUE);
+ gtk_widget_set_sensitive(GTK_WIDGET(v->filters_menu), TRUE);
+ gtk_widget_set_sensitive(GTK_WIDGET(v->geometry_menu), FALSE);
+
+ gtk_widget_set_sensitive(GTK_WIDGET(v->save), TRUE);
+ gtk_widget_set_sensitive(GTK_WIDGET(v->ocr), FALSE);
+ gtk_widget_set_sensitive(GTK_WIDGET(v->clone), FALSE);
+ gtk_widget_set_sensitive(GTK_WIDGET(v->edit_button_box), TRUE);
+ gtk_widget_set_sensitive(GTK_WIDGET(v->filters_button_box), TRUE);
+ gtk_widget_set_sensitive(GTK_WIDGET(v->geometry_button_box), FALSE);
+ break;
+
+ case VIEWER_NO_NAME_MODIFICATION:
+ gtk_widget_set_sensitive(GTK_WIDGET(v->ocr_menu_item), FALSE);
+ gtk_widget_set_sensitive(GTK_WIDGET(v->clone_menu_item), FALSE);
+ gtk_widget_set_sensitive(GTK_WIDGET(v->ocr), FALSE);
+ gtk_widget_set_sensitive(GTK_WIDGET(v->clone), FALSE);
+ /* fall through */
+
+ case VIEWER_FULL_MODIFICATION:
+ default:
+ gtk_widget_set_sensitive(GTK_WIDGET(v->save_menu_item), TRUE);
+ gtk_widget_set_sensitive(GTK_WIDGET(v->edit_menu), TRUE);
+ gtk_widget_set_sensitive(GTK_WIDGET(v->filters_menu), TRUE);
+ gtk_widget_set_sensitive(GTK_WIDGET(v->geometry_menu), TRUE);
+
+ gtk_widget_set_sensitive(GTK_WIDGET(v->save), TRUE);
+ gtk_widget_set_sensitive(GTK_WIDGET(v->edit_button_box), TRUE);
+ gtk_widget_set_sensitive(GTK_WIDGET(v->filters_button_box), TRUE);
+ gtk_widget_set_sensitive(GTK_WIDGET(v->geometry_button_box), TRUE);
+ break;
+ }
+ }
+ else
+ {
+ v->block_actions = TRUE;
+ gtk_widget_set_sensitive(GTK_WIDGET(v->file_menu), FALSE);
+ gtk_widget_set_sensitive(GTK_WIDGET(v->edit_menu), FALSE);
+ gtk_widget_set_sensitive(GTK_WIDGET(v->filters_menu), FALSE);
+ gtk_widget_set_sensitive(GTK_WIDGET(v->geometry_menu), FALSE);
+ gtk_widget_set_sensitive(GTK_WIDGET(v->button_box), FALSE);
+ }
+}
/* ---------------------------------------------------------------------------------------------------------------------- */
@@ -73,22 +149,41 @@ static gint xsane_viewer_close_callback(GtkWidget *widget, gpointer data)
{
Viewer *v, *list, **prev_list;
+ DBG(DBG_proc, "xsane_viewer_close_callback\n");
+
v = (Viewer*) gtk_object_get_data(GTK_OBJECT(widget), "Viewer");
- DBG(DBG_proc, "xsane_viewer_close_callback\n");
+ if (v->block_actions) /* actions blocked: return */
+ {
+ gdk_beep();
+ DBG(DBG_info, "xsane_viewer_close_callback: actions are blocked\n");
+ return TRUE;
+ }
if (!v->image_saved)
{
char buf[256];
snprintf(buf, sizeof(buf), WARN_VIEWER_IMAGE_NOT_SAVED);
+ xsane_viewer_set_sensitivity(v, FALSE);
if (xsane_back_gtk_decision(ERR_HEADER_WARNING, (gchar **) warning_xpm, buf, BUTTON_DO_NOT_CLOSE, BUTTON_DISCARD_IMAGE, TRUE /* wait */))
{
+ xsane_viewer_set_sensitivity(v, TRUE);
return TRUE;
}
}
- remove(v->filename);
+ /* when no modification is allowed then we work with the original file */
+ /* so we should not erase it */
+ if (v->allow_modification != VIEWER_NO_MODIFICATION)
+ {
+ remove(v->filename);
+ }
+
+ if (v->undo_filename)
+ {
+ remove(v->undo_filename);
+ }
gtk_widget_destroy(v->top);
@@ -109,6 +204,31 @@ static gint xsane_viewer_close_callback(GtkWidget *widget, gpointer data)
list = list->next_viewer;
}
+ if (v->active_dialog)
+ {
+ gtk_widget_destroy(v->active_dialog);
+ }
+
+ if (v->filename)
+ {
+ free(v->filename);
+ }
+
+ if (v->undo_filename)
+ {
+ free(v->undo_filename);
+ }
+
+ if (v->output_filename)
+ {
+ free(v->output_filename);
+ }
+
+ if (v->last_saved_filename)
+ {
+ free(v->last_saved_filename);
+ }
+
free(v);
return TRUE;
@@ -120,7 +240,8 @@ static void xsane_viewer_dialog_cancel(GtkWidget *window, gpointer data)
{
Viewer *v = (Viewer *) data;
- gtk_widget_set_sensitive(GTK_WIDGET(v->button_box), TRUE);
+ xsane_viewer_set_sensitivity(v, TRUE);
+ v->active_dialog = NULL;
}
/* ---------------------------------------------------------------------------------------------------------------------- */
@@ -132,10 +253,20 @@ static void xsane_viewer_save_callback(GtkWidget *window, gpointer data)
char *inputfilename;
char windowname[256];
int output_format;
+ char *filetype = NULL;
+ int abort = 0;
+ char buf[256];
+
+ if (v->block_actions) /* actions blocked: return */
+ {
+ gdk_beep();
+ DBG(DBG_info, "xsane_viewer_save_callback: actions are blocked\n");
+ return;
+ }
DBG(DBG_proc, "xsane_viewer_save_callback\n");
- gtk_widget_set_sensitive(GTK_WIDGET(v->button_box), FALSE);
+ xsane_viewer_set_sensitivity(v, FALSE);
if (v->output_filename)
{
@@ -143,37 +274,46 @@ static void xsane_viewer_save_callback(GtkWidget *window, gpointer data)
}
else
{
- int abort = 0;
+ strncpy(outputfilename, preferences.filename, sizeof(outputfilename));
+ }
- strcpy(outputfilename, preferences.filename);
-
+ if (v->allow_modification == VIEWER_FULL_MODIFICATION) /* it is allowed to rename the image */
+ {
snprintf(windowname, sizeof(windowname), "%s %s %s", xsane.prog_name, WINDOW_VIEWER_OUTPUT_FILENAME, xsane.device_text);
umask((mode_t) preferences.directory_umask); /* define new file permissions */
- abort = xsane_back_gtk_get_filename(windowname, outputfilename, sizeof(outputfilename), outputfilename, TRUE, TRUE, FALSE);
+ abort = xsane_back_gtk_get_filename(windowname, outputfilename, sizeof(outputfilename), outputfilename, &filetype, TRUE, TRUE, FALSE, TRUE);
umask(XSANE_DEFAULT_UMASK); /* define new file permissions */
if (abort)
{
- gtk_widget_set_sensitive(GTK_WIDGET(v->button_box), TRUE);
+ xsane_viewer_set_sensitivity(v, TRUE);
return;
}
}
+ if (v->output_filename)
+ {
+ free(v->output_filename);
+ }
+
+ v->output_filename = strdup(outputfilename);
+ xsane_update_counter_in_filename(&v->output_filename, FALSE, 0, preferences.filename_counter_len); /* set correct counter length */
+
if (preferences.overwrite_warning) /* test if filename already used */
{
FILE *testfile;
- testfile = fopen(outputfilename, "rb"); /* read binary (b for win32) */
+ testfile = fopen(v->output_filename, "rb"); /* read binary (b for win32) */
if (testfile) /* filename used: skip */
{
char buf[256];
fclose(testfile);
- snprintf(buf, sizeof(buf), WARN_FILE_EXISTS, outputfilename);
+ snprintf(buf, sizeof(buf), WARN_FILE_EXISTS, v->output_filename);
if (xsane_back_gtk_decision(ERR_HEADER_WARNING, (gchar **) warning_xpm, buf, BUTTON_OVERWRITE, BUTTON_CANCEL, TRUE /* wait */) == FALSE)
{
- gtk_widget_set_sensitive(GTK_WIDGET(v->button_box), TRUE);
+ xsane_viewer_set_sensitivity(v, TRUE);
return;
}
}
@@ -181,56 +321,41 @@ static void xsane_viewer_save_callback(GtkWidget *window, gpointer data)
inputfilename = strdup(v->filename);
- output_format = xsane_identify_output_format(outputfilename, 0);
+ output_format = xsane_identify_output_format(v->output_filename, filetype, 0);
- if (v->reduce_to_lineart) /* reduce grayscale image to lineart before saving */
+ if ((!v->allow_reduction_to_lineart) && (output_format == XSANE_PNM)) /* save PNM but do not reduce to lineart (if lineart) */
{
- char dummyfilename[1024];
-
- if (output_format != XSANE_PNM)
+ if (xsane_create_secure_file(v->output_filename)) /* remove possibly existing symbolic links for security */
{
- xsane_back_gtk_make_path(sizeof(dummyfilename), dummyfilename, 0, 0, "xsane-viewer-", xsane.dev_name, ".ppm", XSANE_PATH_TMP);
- }
- else /* pbm: no further conversion, we save to destination filename */
- {
- snprintf(dummyfilename, sizeof(dummyfilename), "%s", outputfilename);
- if (xsane_create_secure_file(dummyfilename)) /* remove possibly existing symbolic links for security */
- {
- char buf[256];
+ char buf[256];
- snprintf(buf, sizeof(buf), "%s %s %s\n", ERR_DURING_SAVE, ERR_CREATE_SECURE_FILE, dummyfilename);
- xsane_back_gtk_error(buf, TRUE);
- return; /* error */
- }
+ snprintf(buf, sizeof(buf), "%s %s %s\n", ERR_DURING_SAVE, ERR_CREATE_SECURE_FILE, v->output_filename);
+ xsane_back_gtk_error(buf, TRUE);
+ xsane_viewer_set_sensitivity(v, TRUE);
+ return; /* error */
}
- gtk_progress_set_format_string(GTK_PROGRESS(v->progress_bar), PROGRESS_PACKING_DATA);
- gtk_progress_bar_update(GTK_PROGRESS_BAR(v->progress_bar), 0.0);
+ snprintf(buf, sizeof(buf), "%s: %s", PROGRESS_SAVING_DATA, v->output_filename);
+ gtk_progress_set_format_string(GTK_PROGRESS(v->progress_bar), buf);
- /* the outputfile always is a temporary file, so we do not have to care about symlinks here */
- xsane_save_image_as_lineart(v->filename, dummyfilename, v->progress_bar, &v->cancel_save);
-
- free(inputfilename);
- inputfilename = strdup(dummyfilename);
+ xsane_copy_file_by_name(v->output_filename, v->filename, v->progress_bar, &v->cancel_save);
}
-
-
- if ((!v->reduce_to_lineart) || (output_format != XSANE_PNM)) /* pbm already is saved above, otherwise save now */
+ else
{
- gtk_progress_set_format_string(GTK_PROGRESS(v->progress_bar), PROGRESS_SAVING_DATA);
- gtk_progress_bar_update(GTK_PROGRESS_BAR(v->progress_bar), 0.0);
-
- xsane_save_image_as(inputfilename, outputfilename, output_format, v->progress_bar, &v->cancel_save);
-
- gtk_progress_set_format_string(GTK_PROGRESS(v->progress_bar), "");
- gtk_progress_bar_update(GTK_PROGRESS_BAR(v->progress_bar), 0.0);
+ xsane_save_image_as(v->output_filename, inputfilename, output_format, v->progress_bar, &v->cancel_save);
}
free(inputfilename);
v->image_saved = TRUE;
- gtk_widget_set_sensitive(GTK_WIDGET(v->button_box), TRUE);
+ v->last_saved_filename = strdup(v->output_filename);
+ snprintf(buf, sizeof(buf), "%s %s - %s", WINDOW_VIEWER, v->last_saved_filename, xsane.device_text);
+ gtk_window_set_title(GTK_WINDOW(v->top), buf);
+
+ xsane_update_counter_in_filename(&v->output_filename, preferences.skip_existing_numbers, 1, preferences.filename_counter_len);
+
+ xsane_viewer_set_sensitivity(v, TRUE);
}
/* ---------------------------------------------------------------------------------------------------------------------- */
@@ -241,15 +366,18 @@ static void xsane_viewer_ocr_callback(GtkWidget *window, gpointer data)
char outputfilename[1024];
char *extensionptr;
char windowname[256];
- char *arg[1000];
- int argnr;
- pid_t pid;
int abort = 0;
- int i;
+
+ if (v->block_actions) /* actions blocked: return */
+ {
+ gdk_beep();
+ DBG(DBG_info, "xsane_viewer_ocr_callback: actions are blocked\n");
+ return;
+ }
DBG(DBG_proc, "xsane_viewer_ocr_callback\n");
- gtk_widget_set_sensitive(GTK_WIDGET(v->button_box), FALSE);
+ xsane_viewer_set_sensitivity(v, FALSE);
strncpy(outputfilename, preferences.filename, sizeof(outputfilename)-5);
@@ -263,133 +391,153 @@ static void xsane_viewer_ocr_callback(GtkWidget *window, gpointer data)
snprintf(windowname, sizeof(windowname), "%s %s %s", xsane.prog_name, WINDOW_OCR_OUTPUT_FILENAME, xsane.device_text);
umask((mode_t) preferences.directory_umask); /* define new file permissions */
- abort = xsane_back_gtk_get_filename(windowname, outputfilename, sizeof(outputfilename), outputfilename, TRUE, TRUE, FALSE);
+ abort = xsane_back_gtk_get_filename(windowname, outputfilename, sizeof(outputfilename), outputfilename, NULL, TRUE, TRUE, FALSE, FALSE);
umask(XSANE_DEFAULT_UMASK); /* define new file permissions */
if (abort)
{
- gtk_widget_set_sensitive(GTK_WIDGET(v->button_box), TRUE);
+ xsane_viewer_set_sensitivity(v, TRUE);
return;
}
- argnr = xsane_parse_options(preferences.ocr_command, arg);
+ while (gtk_events_pending()) /* give gtk the chance to remove the file selection dialog */
+ {
+ gtk_main_iteration();
+ }
- arg[argnr++] = strdup(preferences.ocr_inputfile_option);
- arg[argnr++] = strdup(v->filename);
+ xsane_save_image_as_text(outputfilename, v->filename, v->progress_bar, &v->cancel_save);
- arg[argnr++] = strdup(preferences.ocr_outputfile_option);
- arg[argnr++] = strdup(outputfilename);
+ xsane_viewer_set_sensitivity(v, TRUE);
+}
- arg[argnr] = 0;
+/* ---------------------------------------------------------------------------------------------------------------------- */
- pid = fork();
+static void xsane_viewer_clone_callback(GtkWidget *window, gpointer data)
+{
+ Viewer *v = (Viewer *) data;
+ char outfilename[256];
- if (pid == 0) /* new process */
+ if (v->block_actions) /* actions blocked: return */
{
- DBG(DBG_info, "trying to change user id fo new subprocess:\n");
- DBG(DBG_info, "old effective uid = %d\n", geteuid());
- setuid(getuid());
- DBG(DBG_info, "new effective uid = %d\n", geteuid());
-
- execvp(arg[0], arg); /* does not return if successfully */
- DBG(DBG_error, "%s %s\n", ERR_FAILED_EXEC_OCR_CMD, preferences.ocr_command);
- _exit(0); /* do not use exit() here! otherwise gtk gets in trouble */
+ gdk_beep();
+ DBG(DBG_info, "xsane_viewer_clone_callback: actions are blocked\n");
+ return;
}
- for (i=0; i<argnr; i++)
+ DBG(DBG_proc, "xsane_viewer_clone_callback\n");
+
+ xsane_viewer_set_sensitivity(v, FALSE);
+
+ xsane_back_gtk_make_path(sizeof(outfilename), outfilename, 0, 0, "xsane-viewer-", xsane.dev_name, ".ppm", XSANE_PATH_TMP);
+ gtk_progress_set_format_string(GTK_PROGRESS(v->progress_bar), PROGRESS_CLONING_DATA);
+ xsane_copy_file_by_name(outfilename, v->filename, v->progress_bar, &v->cancel_save);
+
+ xsane_viewer_set_sensitivity(v, TRUE);
+
+ if (v->last_saved_filename)
{
- free(arg[i]);
+ char buf[256];
+ snprintf(buf, sizeof(buf), "%s%s", FILENAME_PREFIX_CLONE_OF, v->last_saved_filename);
+ xsane_viewer_new(outfilename, v->allow_reduction_to_lineart, buf, v->allow_modification);
}
-
- while (pid)
+ else
{
- int status = 0;
- pid_t pid_status = waitpid(pid, &status, WNOHANG);
-
- if (pid == pid_status)
- {
- pid = 0; /* ok, child process has terminated */
- }
-
- while (gtk_events_pending())
- {
- gtk_main_iteration();
- }
- }
-
- gtk_widget_set_sensitive(GTK_WIDGET(v->button_box), TRUE);
+ xsane_viewer_new(outfilename, v->allow_reduction_to_lineart, NULL, v->allow_modification);
+ }
}
/* ---------------------------------------------------------------------------------------------------------------------- */
-static void xsane_viewer_clone_callback(GtkWidget *window, gpointer data)
+static void xsane_viewer_adjustment_float_changed(GtkAdjustment *adj_data, float *val)
{
- Viewer *v = (Viewer *) data;
- FILE *outfile;
- FILE *infile;
- char outfilename[256];
- Image_info image_info;
+ *val = (float) adj_data->value;
+}
- DBG(DBG_proc, "xsane_viewer_clone_callback\n");
+/* ---------------------------------------------------------------------------------------------------------------------- */
- gtk_widget_set_sensitive(GTK_WIDGET(v->button_box), FALSE);
+static void xsane_viewer_adjustment_int_changed(GtkAdjustment *adj_data, int *val)
+{
+ *val = (int) adj_data->value;
+}
- infile = fopen(v->filename, "rb");
- if (!infile)
- {
- DBG(DBG_error, "could not load file %s\n", v->filename);
- gtk_widget_set_sensitive(GTK_WIDGET(v->button_box), TRUE);
+/* ---------------------------------------------------------------------------------------------------------------------- */
- return;
- }
+static void xsane_viewer_button_changed(GtkWidget *button, int *val)
+{
+ *val = GTK_TOGGLE_BUTTON(button)->active;
+}
- xsane_read_pnm_header(infile, &image_info);
+/* ---------------------------------------------------------------------------------------------------------------------- */
- DBG(DBG_info, "cloning image %s with geometry: %d x %d x %d, %d colors\n", v->filename, image_info.image_width, image_info.image_height, image_info.depth, image_info.colors);
+static void xsane_viewer_scale_set_scale_value_and_adjustments(GtkAdjustment *adj_data, double *scale_val)
+{
+ GtkAdjustment *adj;
+ int image_width, image_height;
- xsane_back_gtk_make_path(sizeof(outfilename), outfilename, 0, 0, "xsane-viewer-", xsane.dev_name, ".ppm", XSANE_PATH_TMP);
+ *scale_val = adj_data->value;
- outfile = fopen(outfilename, "wb");
- if (!outfile)
+ image_width = (int) gtk_object_get_data(GTK_OBJECT(adj_data), "image_width");
+ image_height = (int) gtk_object_get_data(GTK_OBJECT(adj_data), "image_height");
+
+ adj = (GtkAdjustment*) gtk_object_get_data(GTK_OBJECT(adj_data), "size-x-adjustment");
+ if ((adj) && (image_width))
{
- DBG(DBG_error, "could not save file %s\n", outfilename);
- gtk_widget_set_sensitive(GTK_WIDGET(v->button_box), TRUE);
+ gtk_adjustment_set_value(adj, (*scale_val) * image_width);
+ }
- return;
+ adj = (GtkAdjustment*) gtk_object_get_data(GTK_OBJECT(adj_data), "size-y-adjustment");
+ if ((adj) && (image_height))
+ {
+ gtk_adjustment_set_value(adj, (*scale_val) * image_height);
}
+}
- gtk_progress_set_format_string(GTK_PROGRESS(v->progress_bar), PROGRESS_CLONING_DATA);
- gtk_progress_bar_update(GTK_PROGRESS_BAR(v->progress_bar), 0.0);
+/* ---------------------------------------------------------------------------------------------------------------------- */
- xsane_save_rotate_image(outfile, infile, &image_info, 0, v->progress_bar, &v->cancel_save);
+static void xsane_viewer_scale_set_size_x_value_and_adjustments(GtkAdjustment *adj_data, double *scale_val)
+{
+ GtkAdjustment *adj;
+ int image_width, image_height;
- fclose(infile);
- fclose(outfile);
+ image_width = (int) gtk_object_get_data(GTK_OBJECT(adj_data), "image_width");
+ image_height = (int) gtk_object_get_data(GTK_OBJECT(adj_data), "image_height");
- gtk_progress_set_format_string(GTK_PROGRESS(v->progress_bar), "");
- gtk_progress_bar_update(GTK_PROGRESS_BAR(v->progress_bar), 0.0);
+ if (!image_width)
+ {
+ return; /* we are not able to calulate the scale value */
+ }
- gtk_widget_set_sensitive(GTK_WIDGET(v->button_box), TRUE);
+ *scale_val = adj_data->value / image_width;
- xsane_viewer_new(outfilename, v->reduce_to_lineart, NULL);
+ adj = (GtkAdjustment*) gtk_object_get_data(GTK_OBJECT(adj_data), "scale-adjustment");
+ if (adj)
+ {
+ gtk_adjustment_set_value(adj, *scale_val);
+ }
}
/* ---------------------------------------------------------------------------------------------------------------------- */
-static void xsane_viewer_spinbutton_float_changed(GtkWidget *spinbutton, gpointer data)
+static void xsane_viewer_scale_set_size_y_value_and_adjustments(GtkAdjustment *adj_data, double *scale_val)
{
- float *val = (float *) data;
+ GtkAdjustment *adj;
+ int image_width, image_height;
- *val = gtk_spin_button_get_value_as_float((GtkSpinButton *) spinbutton);
-}
+ image_width = (int) gtk_object_get_data(GTK_OBJECT(adj_data), "image_width");
+ image_height = (int) gtk_object_get_data(GTK_OBJECT(adj_data), "image_height");
-/* ---------------------------------------------------------------------------------------------------------------------- */
+ if (!image_height)
+ {
+ return; /* we are not able to calulate the scale value */
+ }
-static void xsane_viewer_spinbutton_int_changed(GtkWidget *spinbutton, gpointer data)
-{
- int *val = (int *) data;
+ *scale_val = adj_data->value / image_height;
- *val = gtk_spin_button_get_value_as_int((GtkSpinButton *) spinbutton);
+ adj = (GtkAdjustment*) gtk_object_get_data(GTK_OBJECT(adj_data), "scale-adjustment");
+ if (adj)
+ {
+ gtk_adjustment_set_value(adj, *scale_val);
+ }
}
/* ---------------------------------------------------------------------------------------------------------------------- */
@@ -398,14 +546,44 @@ static void xsane_viewer_scale_callback(GtkWidget *window, gpointer data)
{
Viewer *v = (Viewer *) data;
GtkWidget *selection_dialog;
+ GtkWidget *frame;
GtkWidget *hbox, *vbox;
- GtkWidget *label, *spinbutton, *button;
- GtkAdjustment *adjustment;
+ GtkWidget *button;
+ GtkObject *scale_widget, *scalex_widget, *scaley_widget;
+ GtkAdjustment *adjustment_size_x;
+ GtkAdjustment *adjustment_size_y;
+ GtkWidget *spinbutton;
+ GdkPixmap *pixmap;
+ GdkBitmap *mask;
+ GtkWidget *pixmapwidget;
char buf[256];
+ FILE *infile;
+ Image_info image_info;
+
+ if (v->block_actions == TRUE) /* actions blocked: return */
+ {
+ gdk_beep();
+ DBG(DBG_info, "xsane_viewer_scale_callback: actions are blocked\n");
+ return;
+ }
DBG(DBG_proc, "xsane_viewer_scale_callback\n");
- gtk_widget_set_sensitive(GTK_WIDGET(v->button_box), FALSE);
+ xsane_viewer_set_sensitivity(v, FALSE);
+ v->block_actions = 2; /* do not set it to TRUE because we have to recall this dialog! */
+
+ infile = fopen(v->filename, "rb");
+ if (!infile)
+ {
+ DBG(DBG_error, "could not load file %s\n", v->filename);
+ xsane_viewer_set_sensitivity(v, TRUE);
+ return;
+ }
+
+ xsane_read_pnm_header(infile, &image_info);
+
+ fclose(infile);
+
if (v->output_filename)
{
@@ -416,65 +594,187 @@ static void xsane_viewer_scale_callback(GtkWidget *window, gpointer data)
snprintf(buf, sizeof(buf), WINDOW_SCALE);
}
- selection_dialog = gtk_window_new(GTK_WINDOW_DIALOG);
- gtk_window_set_position(GTK_WINDOW(selection_dialog), GTK_WIN_POS_MOUSE);
- gtk_window_set_title(GTK_WINDOW(selection_dialog), buf);
- xsane_set_window_icon(selection_dialog, 0);
+ if (v->active_dialog) /* use active dialog */
+ {
+ selection_dialog = v->active_dialog;
+ gtk_container_foreach(GTK_CONTAINER(selection_dialog), (GtkCallback) gtk_widget_destroy, NULL);
+ if (!v->bind_scale)
+ {
+ v->y_scale_factor = v->x_scale_factor;
+ }
+ }
+ else /* first time the dialog is opened */
+ {
+ selection_dialog = gtk_window_new(GTK_WINDOW_TOPLEVEL);
+ gtk_window_set_resizable(GTK_WINDOW(selection_dialog), FALSE);
+ gtk_window_set_position(GTK_WINDOW(selection_dialog), GTK_WIN_POS_MOUSE);
+ gtk_window_set_title(GTK_WINDOW(selection_dialog), buf);
+ xsane_set_window_icon(selection_dialog, 0);
+ g_signal_connect(GTK_OBJECT(selection_dialog), "destroy", (GtkSignalFunc) xsane_viewer_dialog_cancel, (void *) v);
+
+ v->active_dialog = selection_dialog;
+ v->x_scale_factor = 1.0;
+ v->y_scale_factor = 1.0;
+ v->bind_scale = TRUE;
+ }
- v->active_dialog = selection_dialog;
+ frame = gtk_frame_new(0);
+ gtk_container_set_border_width(GTK_CONTAINER(frame), 4);
+ gtk_frame_set_shadow_type(GTK_FRAME(frame), GTK_SHADOW_ETCHED_IN);
+ gtk_container_add(GTK_CONTAINER(selection_dialog), frame);
+ gtk_widget_show(frame);
vbox = gtk_vbox_new(FALSE, 5);
- gtk_container_add(GTK_CONTAINER(selection_dialog), vbox);
+ gtk_container_set_border_width(GTK_CONTAINER(vbox), 4);
+ gtk_container_add(GTK_CONTAINER(frame), vbox);
gtk_widget_show(vbox);
-#if 0
/* bind scale */
-
button = gtk_check_button_new_with_label(BUTTON_SCALE_BIND);
gtk_box_pack_start(GTK_BOX(vbox), button, FALSE, FALSE, 5);
- gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button), TRUE);
+ gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button), v->bind_scale);
+ g_signal_connect(GTK_OBJECT(button), "toggled", (GtkSignalFunc) xsane_viewer_button_changed, (void *) &v->bind_scale);
+ g_signal_connect_after(GTK_OBJECT(button), "toggled", (GtkSignalFunc) xsane_viewer_scale_callback, (void *) v);
gtk_widget_show(button);
-#endif
-
- /* x_scale factor: <-> */
-
- v->x_scale_factor = 1.0;
- hbox = gtk_hbox_new(FALSE, 2);
- gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 5);
- gtk_widget_show(hbox);
-
- label = gtk_label_new(TEXT_X_SCALE_FACTOR);
- gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 10);
- gtk_widget_show(label);
-
- adjustment = (GtkAdjustment *) gtk_adjustment_new(1.0, 0.01, 2.0, 0.01, 0.1, 0.0);
- spinbutton = gtk_spin_button_new(adjustment, 0, 2);
- gtk_signal_connect(GTK_OBJECT(spinbutton), "changed", (GtkSignalFunc) xsane_viewer_spinbutton_float_changed, (void *) &v->x_scale_factor);
- gtk_spin_button_set_wrap(GTK_SPIN_BUTTON(spinbutton), TRUE);
- gtk_spin_button_set_shadow_type(GTK_SPIN_BUTTON(spinbutton), GTK_SHADOW_OUT);
- gtk_box_pack_end(GTK_BOX(hbox), spinbutton, FALSE, FALSE, 10);
- gtk_widget_show(spinbutton);
-
- /* y_scale factor: <-> */
-
- v->y_scale_factor = 1.0;
-
- hbox = gtk_hbox_new(FALSE, 2);
- gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 5);
- gtk_widget_show(hbox);
-
- label = gtk_label_new(TEXT_Y_SCALE_FACTOR);
- gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 10);
- gtk_widget_show(label);
-
- adjustment = (GtkAdjustment *) gtk_adjustment_new(1.0, 0.01, 2.0, 0.01, 0.1, 0.0);
- spinbutton = gtk_spin_button_new(adjustment, 0, 2);
- gtk_signal_connect(GTK_OBJECT(spinbutton), "changed", (GtkSignalFunc) xsane_viewer_spinbutton_float_changed, (void *) &v->y_scale_factor);
- gtk_spin_button_set_wrap(GTK_SPIN_BUTTON(spinbutton), TRUE);
- gtk_spin_button_set_shadow_type(GTK_SPIN_BUTTON(spinbutton), GTK_SHADOW_OUT);
- gtk_box_pack_end(GTK_BOX(hbox), spinbutton, FALSE, FALSE, 10);
- gtk_widget_show(spinbutton);
+ if (v->bind_scale)
+ {
+ hbox = gtk_hbox_new(FALSE, 0);
+ gtk_container_set_border_width(GTK_CONTAINER(hbox), 4);
+ gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 2);
+ gtk_widget_show(hbox);
+
+ /* scale factor: <-> */
+ xsane_range_new_with_pixmap(xsane.xsane_window->window, GTK_BOX(hbox), zoom_xpm,
+ DESC_SCALE_FACTOR,
+ 0.01, 4.0, 0.01, 0.1, 2, &v->x_scale_factor, &scale_widget,
+ 0, xsane_viewer_scale_set_scale_value_and_adjustments,
+ TRUE);
+
+ /* x-size */
+ pixmap = gdk_pixmap_create_from_xpm_d(selection_dialog->window, &mask, xsane.bg_trans, (gchar **) size_x_xpm);
+ pixmapwidget = gtk_image_new_from_pixmap(pixmap, mask);
+ gtk_box_pack_start(GTK_BOX(hbox), pixmapwidget, FALSE, FALSE, 20);
+ gtk_widget_show(pixmapwidget);
+ gdk_drawable_unref(pixmap);
+
+ adjustment_size_x = (GtkAdjustment *) gtk_adjustment_new(v->x_scale_factor * image_info.image_width , 0.01 * image_info.image_width, 4.0 * image_info.image_width, 1.0, 5.0, 0.0);
+ spinbutton = gtk_spin_button_new(adjustment_size_x, 0, 0);
+ g_signal_connect(GTK_OBJECT(adjustment_size_x), "value_changed", (GtkSignalFunc) xsane_viewer_scale_set_size_x_value_and_adjustments, (void *) &v->x_scale_factor);
+ gtk_spin_button_set_wrap(GTK_SPIN_BUTTON(spinbutton), FALSE);
+ gtk_widget_set_size_request(spinbutton, 80, -1);
+ gtk_box_pack_start(GTK_BOX(hbox), spinbutton, FALSE, FALSE, 0);
+ gtk_widget_show(spinbutton);
+ xsane_back_gtk_set_tooltip(xsane.tooltips, spinbutton, DESC_SCALE_WIDTH);
+
+ /* y-size */
+ pixmap = gdk_pixmap_create_from_xpm_d(selection_dialog->window, &mask, xsane.bg_trans, (gchar **) size_y_xpm);
+ pixmapwidget = gtk_image_new_from_pixmap(pixmap, mask);
+ gtk_box_pack_start(GTK_BOX(hbox), pixmapwidget, FALSE, FALSE, 20);
+ gtk_widget_show(pixmapwidget);
+ gdk_drawable_unref(pixmap);
+
+ adjustment_size_y = (GtkAdjustment *) gtk_adjustment_new(v->x_scale_factor * image_info.image_height , 0.01 * image_info.image_height, 4.0 * image_info.image_height, 1.0, 5.0, 0.0);
+ spinbutton = gtk_spin_button_new(adjustment_size_y, 0, 0);
+ g_signal_connect(GTK_OBJECT(adjustment_size_y), "value_changed", (GtkSignalFunc) xsane_viewer_scale_set_size_y_value_and_adjustments, (void *) &v->x_scale_factor);
+ gtk_spin_button_set_wrap(GTK_SPIN_BUTTON(spinbutton), FALSE);
+ gtk_widget_set_size_request(spinbutton, 80, -1);
+ gtk_box_pack_start(GTK_BOX(hbox), spinbutton, FALSE, FALSE, 0);
+ gtk_widget_show(spinbutton);
+ xsane_back_gtk_set_tooltip(xsane.tooltips, spinbutton, DESC_SCALE_HEIGHT);
+
+ gtk_object_set_data(GTK_OBJECT(scale_widget), "size-x-adjustment", (void *) adjustment_size_x);
+ gtk_object_set_data(GTK_OBJECT(scale_widget), "size-y-adjustment", (void *) adjustment_size_y);
+ gtk_object_set_data(GTK_OBJECT(scale_widget), "image_width", (void *) image_info.image_width);
+ gtk_object_set_data(GTK_OBJECT(scale_widget), "image_height", (void *) image_info.image_height);
+
+ gtk_object_set_data(GTK_OBJECT(adjustment_size_x), "scale-adjustment", (void *) scale_widget);
+ gtk_object_set_data(GTK_OBJECT(adjustment_size_x), "size-y-adjustment", (void *) adjustment_size_y);
+ gtk_object_set_data(GTK_OBJECT(adjustment_size_x), "image_width", (void *) image_info.image_width);
+ gtk_object_set_data(GTK_OBJECT(adjustment_size_x), "image_height", (void *) image_info.image_height);
+
+ gtk_object_set_data(GTK_OBJECT(adjustment_size_y), "scale-adjustment", (void *) scale_widget);
+ gtk_object_set_data(GTK_OBJECT(adjustment_size_y), "size-x-adjustment", (void *) adjustment_size_x);
+ gtk_object_set_data(GTK_OBJECT(adjustment_size_y), "image_width", (void *) image_info.image_width);
+ gtk_object_set_data(GTK_OBJECT(adjustment_size_y), "image_height", (void *) image_info.image_height);
+ }
+ else
+ {
+ /* X */
+ hbox = gtk_hbox_new(FALSE, 0);
+ gtk_container_set_border_width(GTK_CONTAINER(hbox), 4);
+ gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 2);
+ gtk_widget_show(hbox);
+
+ /* x_scale factor: <-> */
+ xsane_range_new_with_pixmap(xsane.xsane_window->window, GTK_BOX(hbox), zoom_x_xpm,
+ DESC_X_SCALE_FACTOR,
+ 0.01, 4.0, 0.01, 0.1, 2, &v->x_scale_factor, &scalex_widget,
+ 0, xsane_viewer_scale_set_scale_value_and_adjustments,
+ TRUE);
+
+ /* x-size */
+ pixmap = gdk_pixmap_create_from_xpm_d(selection_dialog->window, &mask, xsane.bg_trans, (gchar **) size_x_xpm);
+ pixmapwidget = gtk_image_new_from_pixmap(pixmap, mask);
+ gtk_box_pack_start(GTK_BOX(hbox), pixmapwidget, FALSE, FALSE, 20);
+ gtk_widget_show(pixmapwidget);
+ gdk_drawable_unref(pixmap);
+
+ adjustment_size_x = (GtkAdjustment *) gtk_adjustment_new(v->x_scale_factor * image_info.image_width , 0.01 * image_info.image_width, 4.0 * image_info.image_width, 1.0, 5.0, 0.0);
+ spinbutton = gtk_spin_button_new(adjustment_size_x, 0, 0);
+ g_signal_connect(GTK_OBJECT(adjustment_size_x), "value_changed", (GtkSignalFunc) xsane_viewer_scale_set_size_x_value_and_adjustments, (void *) &v->x_scale_factor);
+ gtk_spin_button_set_wrap(GTK_SPIN_BUTTON(spinbutton), FALSE);
+ gtk_widget_set_size_request(spinbutton, 80, -1);
+ gtk_box_pack_start(GTK_BOX(hbox), spinbutton, FALSE, FALSE, 0);
+ gtk_widget_show(spinbutton);
+ xsane_back_gtk_set_tooltip(xsane.tooltips, spinbutton, DESC_SCALE_WIDTH);
+
+ gtk_object_set_data(GTK_OBJECT(scalex_widget), "size-x-adjustment", (void *) adjustment_size_x);
+ gtk_object_set_data(GTK_OBJECT(scalex_widget), "image_width", (void *) image_info.image_width);
+ gtk_object_set_data(GTK_OBJECT(scalex_widget), "image_height", (void *) image_info.image_height);
+
+ gtk_object_set_data(GTK_OBJECT(adjustment_size_x), "scale-adjustment", (void *) scalex_widget);
+ gtk_object_set_data(GTK_OBJECT(adjustment_size_x), "image_width", (void *) image_info.image_width);
+ gtk_object_set_data(GTK_OBJECT(adjustment_size_x), "image_height", (void *) image_info.image_height);
+
+
+ /* Y */
+ hbox = gtk_hbox_new(FALSE, 0);
+ gtk_container_set_border_width(GTK_CONTAINER(hbox), 4);
+ gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 2);
+ gtk_widget_show(hbox);
+
+ /* y_scale factor: <-> */
+ xsane_range_new_with_pixmap(xsane.xsane_window->window, GTK_BOX(hbox), zoom_y_xpm,
+ DESC_Y_SCALE_FACTOR,
+ 0.01, 4.0, 0.01, 0.1, 2, &v->y_scale_factor, &scaley_widget,
+ 0, xsane_viewer_scale_set_scale_value_and_adjustments,
+ TRUE);
+
+ /* y-size */
+ pixmap = gdk_pixmap_create_from_xpm_d(selection_dialog->window, &mask, xsane.bg_trans, (gchar **) size_y_xpm);
+ pixmapwidget = gtk_image_new_from_pixmap(pixmap, mask);
+ gtk_box_pack_start(GTK_BOX(hbox), pixmapwidget, FALSE, FALSE, 20);
+ gtk_widget_show(pixmapwidget);
+ gdk_drawable_unref(pixmap);
+
+ adjustment_size_y = (GtkAdjustment *) gtk_adjustment_new(v->y_scale_factor * image_info.image_height , 0.01 * image_info.image_height, 4.0 * image_info.image_height, 1.0, 5.0, 0.0);
+ spinbutton = gtk_spin_button_new(adjustment_size_y, 0, 0);
+ g_signal_connect(GTK_OBJECT(adjustment_size_y), "value_changed", (GtkSignalFunc) xsane_viewer_scale_set_size_y_value_and_adjustments, (void *) &v->y_scale_factor);
+ gtk_spin_button_set_wrap(GTK_SPIN_BUTTON(spinbutton), FALSE);
+ gtk_widget_set_size_request(spinbutton, 80, -1);
+ gtk_box_pack_start(GTK_BOX(hbox), spinbutton, FALSE, FALSE, 0);
+ gtk_widget_show(spinbutton);
+ xsane_back_gtk_set_tooltip(xsane.tooltips, spinbutton, DESC_SCALE_HEIGHT);
+
+ gtk_object_set_data(GTK_OBJECT(scaley_widget), "size-y-adjustment", (void *) adjustment_size_y);
+ gtk_object_set_data(GTK_OBJECT(scaley_widget), "image_width", (void *) image_info.image_width);
+ gtk_object_set_data(GTK_OBJECT(scaley_widget), "image_height", (void *) image_info.image_height);
+
+ gtk_object_set_data(GTK_OBJECT(adjustment_size_y), "scale-adjustment", (void *) scaley_widget);
+ gtk_object_set_data(GTK_OBJECT(adjustment_size_y), "image_width", (void *) image_info.image_width);
+ gtk_object_set_data(GTK_OBJECT(adjustment_size_y), "image_height", (void *) image_info.image_height);
+ }
/* Apply Cancel */
@@ -485,15 +785,16 @@ static void xsane_viewer_scale_callback(GtkWidget *window, gpointer data)
button = gtk_button_new_with_label(BUTTON_APPLY);
GTK_WIDGET_SET_FLAGS(button, GTK_CAN_DEFAULT);
- gtk_signal_connect(GTK_OBJECT(button), "clicked", (GtkSignalFunc) xsane_viewer_scale_image, (void *) v);
- gtk_signal_connect_object(GTK_OBJECT(button), "clicked", (GtkSignalFunc) gtk_widget_destroy, (GtkObject *) selection_dialog);
+ g_signal_connect(GTK_OBJECT(button), "clicked", (GtkSignalFunc) xsane_viewer_scale_image, (void *) v);
+ g_signal_connect_swapped(GTK_OBJECT(button), "clicked", (GtkSignalFunc) gtk_widget_destroy, (GtkObject *) selection_dialog);
+
gtk_container_add(GTK_CONTAINER(hbox), button);
gtk_widget_grab_default(button);
gtk_widget_show(button);
button = gtk_button_new_with_label(BUTTON_CANCEL);
- gtk_signal_connect(GTK_OBJECT(button), "clicked", (GtkSignalFunc) xsane_viewer_dialog_cancel, (void *) v);
- gtk_signal_connect_object(GTK_OBJECT(button), "clicked", (GtkSignalFunc) gtk_widget_destroy, (GtkObject *) selection_dialog);
+ g_signal_connect(GTK_OBJECT(button), "clicked", (GtkSignalFunc) xsane_viewer_dialog_cancel, (void *) v);
+ g_signal_connect_swapped(GTK_OBJECT(button), "clicked", (GtkSignalFunc) gtk_widget_destroy, (GtkObject *) selection_dialog);
gtk_container_add(GTK_CONTAINER(hbox), button);
gtk_widget_show(button);
@@ -506,14 +807,22 @@ static void xsane_viewer_despeckle_callback(GtkWidget *window, gpointer data)
{
Viewer *v = (Viewer *) data;
GtkWidget *selection_dialog;
+ GtkWidget *frame;
GtkWidget *hbox, *vbox;
GtkWidget *label, *spinbutton, *button;
GtkAdjustment *adjustment;
char buf[256];
+ if (v->block_actions) /* actions blocked: return */
+ {
+ gdk_beep();
+ DBG(DBG_info, "xsane_viewer_despeckle_callback: actions are blocked\n");
+ return;
+ }
+
DBG(DBG_proc, "xsane_viewer_despeckle_callback\n");
- gtk_widget_set_sensitive(GTK_WIDGET(v->button_box), FALSE);
+ xsane_viewer_set_sensitivity(v, FALSE);
if (v->output_filename)
{
@@ -524,20 +833,28 @@ static void xsane_viewer_despeckle_callback(GtkWidget *window, gpointer data)
snprintf(buf, sizeof(buf), WINDOW_DESPECKLE);
}
- selection_dialog = gtk_window_new(GTK_WINDOW_DIALOG);
+ selection_dialog = gtk_window_new(GTK_WINDOW_TOPLEVEL);
gtk_window_set_position(GTK_WINDOW(selection_dialog), GTK_WIN_POS_MOUSE);
gtk_window_set_title(GTK_WINDOW(selection_dialog), buf);
xsane_set_window_icon(selection_dialog, 0);
+ g_signal_connect(GTK_OBJECT(selection_dialog), "destroy", (GtkSignalFunc) xsane_viewer_dialog_cancel, (void *) v);
v->active_dialog = selection_dialog;
+ frame = gtk_frame_new(0);
+ gtk_container_set_border_width(GTK_CONTAINER(frame), 4);
+ gtk_frame_set_shadow_type(GTK_FRAME(frame), GTK_SHADOW_ETCHED_IN);
+ gtk_container_add(GTK_CONTAINER(selection_dialog), frame);
+ gtk_widget_show(frame);
+
vbox = gtk_vbox_new(FALSE, 5);
- gtk_container_add(GTK_CONTAINER(selection_dialog), vbox);
+ gtk_container_set_border_width(GTK_CONTAINER(vbox), 4);
+ gtk_container_add(GTK_CONTAINER(frame), vbox);
gtk_widget_show(vbox);
/* Despeckle radius: <-> */
- v->filter_radius = 2;
+ v->despeckle_radius = 2;
hbox = gtk_hbox_new(FALSE, 2);
gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 5);
@@ -549,9 +866,8 @@ static void xsane_viewer_despeckle_callback(GtkWidget *window, gpointer data)
adjustment = (GtkAdjustment *) gtk_adjustment_new(2.0, 2.0, 10.0, 1.0, 5.0, 0.0);
spinbutton = gtk_spin_button_new(adjustment, 0, 0);
- gtk_signal_connect(GTK_OBJECT(spinbutton), "changed", (GtkSignalFunc) xsane_viewer_spinbutton_int_changed, (void *) &v->filter_radius);
+ g_signal_connect(GTK_OBJECT(adjustment), "value_changed", (GtkSignalFunc) xsane_viewer_adjustment_int_changed, (void *) &v->despeckle_radius);
gtk_spin_button_set_wrap(GTK_SPIN_BUTTON(spinbutton), TRUE);
- gtk_spin_button_set_shadow_type(GTK_SPIN_BUTTON(spinbutton), GTK_SHADOW_OUT);
gtk_box_pack_end(GTK_BOX(hbox), spinbutton, FALSE, FALSE, 10);
gtk_widget_show(spinbutton);
@@ -564,15 +880,15 @@ static void xsane_viewer_despeckle_callback(GtkWidget *window, gpointer data)
button = gtk_button_new_with_label(BUTTON_APPLY);
GTK_WIDGET_SET_FLAGS(button, GTK_CAN_DEFAULT);
- gtk_signal_connect(GTK_OBJECT(button), "clicked", (GtkSignalFunc) xsane_viewer_despeckle_image, (void *) v);
- gtk_signal_connect_object(GTK_OBJECT(button), "clicked", (GtkSignalFunc) gtk_widget_destroy, (GtkObject *) selection_dialog);
+ g_signal_connect(GTK_OBJECT(button), "clicked", (GtkSignalFunc) xsane_viewer_despeckle_image, (void *) v);
+ g_signal_connect_swapped(GTK_OBJECT(button), "clicked", (GtkSignalFunc) gtk_widget_destroy, (GtkObject *) selection_dialog);
gtk_container_add(GTK_CONTAINER(hbox), button);
gtk_widget_grab_default(button);
gtk_widget_show(button);
button = gtk_button_new_with_label(BUTTON_CANCEL);
- gtk_signal_connect(GTK_OBJECT(button), "clicked", (GtkSignalFunc) xsane_viewer_dialog_cancel, (void *) v);
- gtk_signal_connect_object(GTK_OBJECT(button), "clicked", (GtkSignalFunc) gtk_widget_destroy, (GtkObject *) selection_dialog);
+ g_signal_connect(GTK_OBJECT(button), "clicked", (GtkSignalFunc) xsane_viewer_dialog_cancel, (void *) v);
+ g_signal_connect_swapped(GTK_OBJECT(button), "clicked", (GtkSignalFunc) gtk_widget_destroy, (GtkObject *) selection_dialog);
gtk_container_add(GTK_CONTAINER(hbox), button);
gtk_widget_show(button);
@@ -585,14 +901,22 @@ static void xsane_viewer_blur_callback(GtkWidget *window, gpointer data)
{
Viewer *v = (Viewer *) data;
GtkWidget *selection_dialog;
+ GtkWidget *frame;
GtkWidget *hbox, *vbox;
GtkWidget *label, *spinbutton, *button;
GtkAdjustment *adjustment;
char buf[256];
+ if (v->block_actions) /* actions blocked: return */
+ {
+ gdk_beep();
+ DBG(DBG_info, "xsane_viewer_blur_callback: actions are blocked\n");
+ return;
+ }
+
DBG(DBG_proc, "xsane_viewer_blur_callback\n");
- gtk_widget_set_sensitive(GTK_WIDGET(v->button_box), FALSE);
+ xsane_viewer_set_sensitivity(v, FALSE);
if (v->output_filename)
{
@@ -603,21 +927,29 @@ static void xsane_viewer_blur_callback(GtkWidget *window, gpointer data)
snprintf(buf, sizeof(buf), WINDOW_BLUR);
}
- selection_dialog = gtk_window_new(GTK_WINDOW_DIALOG);
+ selection_dialog = gtk_window_new(GTK_WINDOW_TOPLEVEL);
gtk_window_set_position(GTK_WINDOW(selection_dialog), GTK_WIN_POS_MOUSE);
gtk_window_set_title(GTK_WINDOW(selection_dialog), buf);
xsane_set_window_icon(selection_dialog, 0);
+ g_signal_connect(GTK_OBJECT(selection_dialog), "destroy", (GtkSignalFunc) xsane_viewer_dialog_cancel, (void *) v);
v->active_dialog = selection_dialog;
+ frame = gtk_frame_new(0);
+ gtk_container_set_border_width(GTK_CONTAINER(frame), 4);
+ gtk_frame_set_shadow_type(GTK_FRAME(frame), GTK_SHADOW_ETCHED_IN);
+ gtk_container_add(GTK_CONTAINER(selection_dialog), frame);
+ gtk_widget_show(frame);
+
vbox = gtk_vbox_new(FALSE, 5);
gtk_container_set_border_width(GTK_CONTAINER(vbox), 4);
- gtk_container_add(GTK_CONTAINER(selection_dialog), vbox);
+ gtk_container_add(GTK_CONTAINER(frame), vbox);
gtk_widget_show(vbox);
+
/* Blur radius: <-> */
- v->filter_radius = 2;
+ v->blur_radius = 1.0;
hbox = gtk_hbox_new(FALSE, 2);
gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 5);
@@ -627,11 +959,10 @@ static void xsane_viewer_blur_callback(GtkWidget *window, gpointer data)
gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 10);
gtk_widget_show(label);
- adjustment = (GtkAdjustment *) gtk_adjustment_new(2.0, 2.0, 20.0, 1.0, 5.0, 0.0);
- spinbutton = gtk_spin_button_new(adjustment, 0, 0);
- gtk_signal_connect(GTK_OBJECT(spinbutton), "changed", (GtkSignalFunc) xsane_viewer_spinbutton_int_changed, (void *) &v->filter_radius);
+ adjustment = (GtkAdjustment *) gtk_adjustment_new(1.0, 1.0, 20.0, 0.1, 1.0, 0.0);
+ spinbutton = gtk_spin_button_new(adjustment, 0, 2);
+ g_signal_connect(GTK_OBJECT(adjustment), "value_changed", (GtkSignalFunc) xsane_viewer_adjustment_float_changed, (void *) &v->blur_radius);
gtk_spin_button_set_wrap(GTK_SPIN_BUTTON(spinbutton), TRUE);
- gtk_spin_button_set_shadow_type(GTK_SPIN_BUTTON(spinbutton), GTK_SHADOW_OUT);
gtk_box_pack_end(GTK_BOX(hbox), spinbutton, FALSE, FALSE, 10);
gtk_widget_show(spinbutton);
@@ -644,14 +975,14 @@ static void xsane_viewer_blur_callback(GtkWidget *window, gpointer data)
button = gtk_button_new_with_label(BUTTON_APPLY);
GTK_WIDGET_SET_FLAGS(button, GTK_CAN_DEFAULT);
- gtk_signal_connect(GTK_OBJECT(button), "clicked", (GtkSignalFunc) xsane_viewer_blur_image, (void *) v);
+ g_signal_connect(GTK_OBJECT(button), "clicked", (GtkSignalFunc) xsane_viewer_blur_image, (void *) v);
gtk_container_add(GTK_CONTAINER(hbox), button);
gtk_widget_grab_default(button);
gtk_widget_show(button);
button = gtk_button_new_with_label(BUTTON_CANCEL);
- gtk_signal_connect(GTK_OBJECT(button), "clicked", (GtkSignalFunc) xsane_viewer_dialog_cancel, (void *) v);
- gtk_signal_connect_object(GTK_OBJECT(button), "clicked", (GtkSignalFunc) gtk_widget_destroy, (GtkObject *) selection_dialog);
+ g_signal_connect(GTK_OBJECT(button), "clicked", (GtkSignalFunc) xsane_viewer_dialog_cancel, (void *) v);
+ g_signal_connect_swapped(GTK_OBJECT(button), "clicked", (GtkSignalFunc) gtk_widget_destroy, (GtkObject *) selection_dialog);
gtk_container_add(GTK_CONTAINER(hbox), button);
gtk_widget_show(button);
@@ -660,6 +991,42 @@ static void xsane_viewer_blur_callback(GtkWidget *window, gpointer data)
/* ---------------------------------------------------------------------------------------------------------------------- */
+static void xsane_viewer_undo_callback(GtkWidget *window, gpointer data)
+{
+ Viewer *v = (Viewer *) data;
+
+ DBG(DBG_proc, "xsane_viewer_undo_callback\n");
+
+ if (!v->undo_filename)
+ {
+ DBG(DBG_info, "no undo file\n");
+ return;
+ }
+
+ DBG(DBG_info, "removing file %s\n", v->filename);
+ remove(v->filename);
+
+ DBG(DBG_info, "using undo file %s\n", v->undo_filename);
+ v->filename = v->undo_filename;
+
+ v->undo_filename = NULL;
+ v->image_saved = FALSE;
+
+ xsane_viewer_read_image(v);
+
+ if (v->last_saved_filename)
+ {
+ char buf[256];
+ snprintf(buf, sizeof(buf), "%s (%s) - %s", WINDOW_VIEWER, v->last_saved_filename, xsane.device_text);
+ gtk_window_set_title(GTK_WINDOW(v->top), buf);
+ }
+
+ gtk_widget_set_sensitive(GTK_WIDGET(v->undo), FALSE);
+ gtk_widget_set_sensitive(GTK_WIDGET(v->undo_menu_item), FALSE);
+}
+
+/* ---------------------------------------------------------------------------------------------------------------------- */
+
static void xsane_viewer_scale_image(GtkWidget *window, gpointer data)
{
FILE *outfile;
@@ -672,14 +1039,13 @@ static void xsane_viewer_scale_image(GtkWidget *window, gpointer data)
gtk_widget_destroy(v->active_dialog);
- gtk_widget_set_sensitive(GTK_WIDGET(v->button_box), FALSE);
+ xsane_viewer_set_sensitivity(v, FALSE);
infile = fopen(v->filename, "rb");
if (!infile)
{
DBG(DBG_error, "could not load file %s\n", v->filename);
- gtk_widget_set_sensitive(GTK_WIDGET(v->button_box), TRUE);
-
+ xsane_viewer_set_sensitivity(v, TRUE);
return;
}
@@ -693,8 +1059,7 @@ static void xsane_viewer_scale_image(GtkWidget *window, gpointer data)
if (!outfile)
{
DBG(DBG_error, "could not save file %s\n", outfilename);
- gtk_widget_set_sensitive(GTK_WIDGET(v->button_box), TRUE);
-
+ xsane_viewer_set_sensitivity(v, TRUE);
return;
}
@@ -702,6 +1067,11 @@ static void xsane_viewer_scale_image(GtkWidget *window, gpointer data)
gtk_progress_bar_update(GTK_PROGRESS_BAR(v->progress_bar), 0.0);
+ if (v->bind_scale)
+ {
+ v->y_scale_factor = v->x_scale_factor;
+ }
+
xsane_save_scaled_image(outfile, infile, &image_info, v->x_scale_factor, v->y_scale_factor, v->progress_bar, &v->cancel_save);
fclose(infile);
@@ -710,16 +1080,31 @@ static void xsane_viewer_scale_image(GtkWidget *window, gpointer data)
gtk_progress_set_format_string(GTK_PROGRESS(v->progress_bar), "");
gtk_progress_bar_update(GTK_PROGRESS_BAR(v->progress_bar), 0.0);
- DBG(DBG_info, "removing file %s\n", v->filename);
- remove(v->filename);
- free(v->filename);
+ if (v->undo_filename)
+ {
+ DBG(DBG_info, "removing file %s\n", v->undo_filename);
+ remove(v->undo_filename);
+ free(v->undo_filename);
+ }
+
+ v->undo_filename = v->filename;
+ DBG(DBG_info, "undo file is %s\n", v->undo_filename);
+ gtk_widget_set_sensitive(GTK_WIDGET(v->undo), TRUE);
+ gtk_widget_set_sensitive(GTK_WIDGET(v->undo_menu_item), TRUE);
v->filename = strdup(outfilename);
v->image_saved = FALSE;
xsane_viewer_read_image(v);
- gtk_widget_set_sensitive(GTK_WIDGET(v->button_box), TRUE);
+ if (v->last_saved_filename)
+ {
+ char buf[256];
+ snprintf(buf, sizeof(buf), "%s (%s) - %s", WINDOW_VIEWER, v->last_saved_filename, xsane.device_text);
+ gtk_window_set_title(GTK_WINDOW(v->top), buf);
+ }
+
+ xsane_viewer_set_sensitivity(v, TRUE);
}
/* ---------------------------------------------------------------------------------------------------------------------- */
@@ -736,14 +1121,13 @@ static void xsane_viewer_despeckle_image(GtkWidget *window, gpointer data)
gtk_widget_destroy(v->active_dialog);
- gtk_widget_set_sensitive(GTK_WIDGET(v->button_box), FALSE);
+ xsane_viewer_set_sensitivity(v, FALSE);
infile = fopen(v->filename, "rb");
if (!infile)
{
DBG(DBG_error, "could not load file %s\n", v->filename);
- gtk_widget_set_sensitive(GTK_WIDGET(v->button_box), TRUE);
-
+ xsane_viewer_set_sensitivity(v, TRUE);
return;
}
@@ -757,8 +1141,7 @@ static void xsane_viewer_despeckle_image(GtkWidget *window, gpointer data)
if (!outfile)
{
DBG(DBG_error, "could not save file %s\n", outfilename);
- gtk_widget_set_sensitive(GTK_WIDGET(v->button_box), TRUE);
-
+ xsane_viewer_set_sensitivity(v, TRUE);
return;
}
@@ -766,7 +1149,7 @@ static void xsane_viewer_despeckle_image(GtkWidget *window, gpointer data)
gtk_progress_bar_update(GTK_PROGRESS_BAR(v->progress_bar), 0.0);
- xsane_save_despeckle_image(outfile, infile, &image_info, v->filter_radius, v->progress_bar, &v->cancel_save);
+ xsane_save_despeckle_image(outfile, infile, &image_info, v->despeckle_radius, v->progress_bar, &v->cancel_save);
fclose(infile);
fclose(outfile);
@@ -774,16 +1157,31 @@ static void xsane_viewer_despeckle_image(GtkWidget *window, gpointer data)
gtk_progress_set_format_string(GTK_PROGRESS(v->progress_bar), "");
gtk_progress_bar_update(GTK_PROGRESS_BAR(v->progress_bar), 0.0);
- DBG(DBG_info, "removing file %s\n", v->filename);
- remove(v->filename);
- free(v->filename);
+ if (v->undo_filename)
+ {
+ DBG(DBG_info, "removing file %s\n", v->undo_filename);
+ remove(v->undo_filename);
+ free(v->undo_filename);
+ }
+
+ v->undo_filename = v->filename;
+ DBG(DBG_info, "undo file is %s\n", v->undo_filename);
+ gtk_widget_set_sensitive(GTK_WIDGET(v->undo), TRUE);
+ gtk_widget_set_sensitive(GTK_WIDGET(v->undo_menu_item), TRUE);
v->filename = strdup(outfilename);
v->image_saved = FALSE;
xsane_viewer_read_image(v);
- gtk_widget_set_sensitive(GTK_WIDGET(v->button_box), TRUE);
+ if (v->last_saved_filename)
+ {
+ char buf[256];
+ snprintf(buf, sizeof(buf), "%s (%s) - %s", WINDOW_VIEWER, v->last_saved_filename, xsane.device_text);
+ gtk_window_set_title(GTK_WINDOW(v->top), buf);
+ }
+
+ xsane_viewer_set_sensitivity(v, TRUE);
}
/* ---------------------------------------------------------------------------------------------------------------------- */
@@ -800,14 +1198,13 @@ static void xsane_viewer_blur_image(GtkWidget *window, gpointer data)
gtk_widget_destroy(v->active_dialog);
- gtk_widget_set_sensitive(GTK_WIDGET(v->button_box), FALSE);
+ xsane_viewer_set_sensitivity(v, FALSE);
infile = fopen(v->filename, "rb");
if (!infile)
{
DBG(DBG_error, "could not load file %s\n", v->filename);
- gtk_widget_set_sensitive(GTK_WIDGET(v->button_box), TRUE);
-
+ xsane_viewer_set_sensitivity(v, TRUE);
return;
}
@@ -821,8 +1218,7 @@ static void xsane_viewer_blur_image(GtkWidget *window, gpointer data)
if (!outfile)
{
DBG(DBG_error, "could not save file %s\n", outfilename);
- gtk_widget_set_sensitive(GTK_WIDGET(v->button_box), TRUE);
-
+ xsane_viewer_set_sensitivity(v, TRUE);
return;
}
@@ -830,7 +1226,7 @@ static void xsane_viewer_blur_image(GtkWidget *window, gpointer data)
gtk_progress_bar_update(GTK_PROGRESS_BAR(v->progress_bar), 0.0);
- xsane_save_blur_image(outfile, infile, &image_info, v->filter_radius, v->progress_bar, &v->cancel_save);
+ xsane_save_blur_image(outfile, infile, &image_info, v->blur_radius, v->progress_bar, &v->cancel_save);
fclose(infile);
fclose(outfile);
@@ -838,16 +1234,31 @@ static void xsane_viewer_blur_image(GtkWidget *window, gpointer data)
gtk_progress_set_format_string(GTK_PROGRESS(v->progress_bar), "");
gtk_progress_bar_update(GTK_PROGRESS_BAR(v->progress_bar), 0.0);
- DBG(DBG_info, "removing file %s\n", v->filename);
- remove(v->filename);
- free(v->filename);
+ if (v->undo_filename)
+ {
+ DBG(DBG_info, "removing file %s\n", v->undo_filename);
+ remove(v->undo_filename);
+ free(v->undo_filename);
+ }
+
+ v->undo_filename = v->filename;
+ DBG(DBG_info, "undo file is %s\n", v->undo_filename);
+ gtk_widget_set_sensitive(GTK_WIDGET(v->undo), TRUE);
+ gtk_widget_set_sensitive(GTK_WIDGET(v->undo_menu_item), TRUE);
v->filename = strdup(outfilename);
v->image_saved = FALSE;
xsane_viewer_read_image(v);
- gtk_widget_set_sensitive(GTK_WIDGET(v->button_box), TRUE);
+ if (v->last_saved_filename)
+ {
+ char buf[256];
+ snprintf(buf, sizeof(buf), "%s (%s) - %s", WINDOW_VIEWER, v->last_saved_filename, xsane.device_text);
+ gtk_window_set_title(GTK_WINDOW(v->top), buf);
+ }
+
+ xsane_viewer_set_sensitivity(v, TRUE);
}
/* ---------------------------------------------------------------------------------------------------------------------- */
@@ -859,15 +1270,22 @@ static void xsane_viewer_rotate(Viewer *v, int rotation)
char outfilename[256];
Image_info image_info;
+ if (v->block_actions) /* actions blocked: return */
+ {
+ gdk_beep();
+ DBG(DBG_info, "xsane_viewer_rotate: actions are blocked\n");
+ return;
+ }
+
DBG(DBG_proc, "xsane_viewer_rotate(%d)\n", rotation);
- gtk_widget_set_sensitive(GTK_WIDGET(v->button_box), FALSE);
+ xsane_viewer_set_sensitivity(v, FALSE);
infile = fopen(v->filename, "rb");
if (!infile)
{
DBG(DBG_error, "could not load file %s\n", v->filename);
- gtk_widget_set_sensitive(GTK_WIDGET(v->button_box), TRUE);
+ xsane_viewer_set_sensitivity(v, TRUE);
return;
}
@@ -882,7 +1300,7 @@ static void xsane_viewer_rotate(Viewer *v, int rotation)
if (!outfile)
{
DBG(DBG_error, "could not save file %s\n", outfilename);
- gtk_widget_set_sensitive(GTK_WIDGET(v->button_box), TRUE);
+ xsane_viewer_set_sensitivity(v, TRUE);
return;
}
@@ -906,16 +1324,31 @@ static void xsane_viewer_rotate(Viewer *v, int rotation)
gtk_progress_set_format_string(GTK_PROGRESS(v->progress_bar), "");
gtk_progress_bar_update(GTK_PROGRESS_BAR(v->progress_bar), 0.0);
- DBG(DBG_info, "removing file %s\n", v->filename);
- remove(v->filename);
- free(v->filename);
+ if (v->undo_filename)
+ {
+ DBG(DBG_info, "removing file %s\n", v->undo_filename);
+ remove(v->undo_filename);
+ free(v->undo_filename);
+ }
+
+ v->undo_filename = v->filename;
+ DBG(DBG_info, "undo file is %s\n", v->undo_filename);
+ gtk_widget_set_sensitive(GTK_WIDGET(v->undo), TRUE);
+ gtk_widget_set_sensitive(GTK_WIDGET(v->undo_menu_item), TRUE);
v->filename = strdup(outfilename);
v->image_saved = FALSE;
xsane_viewer_read_image(v);
- gtk_widget_set_sensitive(GTK_WIDGET(v->button_box), TRUE);
+ if (v->last_saved_filename)
+ {
+ char buf[256];
+ snprintf(buf, sizeof(buf), "%s (%s) - %s", WINDOW_VIEWER, v->last_saved_filename, xsane.device_text);
+ gtk_window_set_title(GTK_WINDOW(v->top), buf);
+ }
+
+ xsane_viewer_set_sensitivity(v, TRUE);
}
/* ---------------------------------------------------------------------------------------------------------------------- */
@@ -985,57 +1418,58 @@ static void xsane_viewer_zoom_callback(GtkWidget *widget, gpointer data)
/* ---------------------------------------------------------------------------------------------------------------------- */
-static GtkWidget *xsane_viewer_files_build_menu(Viewer *v)
+static GtkWidget *xsane_viewer_file_build_menu(Viewer *v)
{
GtkWidget *menu, *item;
- DBG(DBG_proc, "xsane_viewer_files_build_menu\n");
+ DBG(DBG_proc, "xsane_viewer_file_build_menu\n");
menu = gtk_menu_new();
- gtk_accel_group_attach(xsane.accelerator_group, GTK_OBJECT(menu));
+ gtk_menu_set_accel_group(GTK_MENU(menu), xsane.accelerator_group);
/* XSane save dialog */
item = gtk_menu_item_new_with_label(MENU_ITEM_SAVE_IMAGE);
#if 0
- gtk_widget_add_accelerator(item, "activate", xsane.accelerator_group, GDK_I, GDK_CONTROL_MASK, GTK_ACCEL_VISIBLE | GTK_ACCEL_LOCKED);
+ gtk_widget_add_accelerator(item, "activate", xsane.accelerator_group, GDK_I, GDK_CONTROL_MASK, GTK_ACCEL_VISIBLE | DEF_GTK_ACCEL_LOCKED);
#endif
gtk_menu_append(GTK_MENU(menu), item);
- gtk_signal_connect(GTK_OBJECT(item), "activate", (GtkSignalFunc) xsane_viewer_save_callback, v);
+ g_signal_connect(GTK_OBJECT(item), "activate", (GtkSignalFunc) xsane_viewer_save_callback, v);
gtk_widget_show(item);
+ v->save_menu_item = item;
+ /* XSane save as text (ocr) */
- /* Clone */
-
- item = gtk_menu_item_new_with_label(MENU_ITEM_CLONE);
+ item = gtk_menu_item_new_with_label(MENU_ITEM_OCR);
#if 0
- gtk_widget_add_accelerator(item, "activate", xsane.accelerator_group, GDK_I, GDK_CONTROL_MASK, GTK_ACCEL_VISIBLE | GTK_ACCEL_LOCKED);
+ gtk_widget_add_accelerator(item, "activate", xsane.accelerator_group, GDK_I, GDK_CONTROL_MASK, GTK_ACCEL_VISIBLE | DEF_GTK_ACCEL_LOCKED);
#endif
gtk_menu_append(GTK_MENU(menu), item);
- gtk_signal_connect(GTK_OBJECT(item), "activate", (GtkSignalFunc) xsane_viewer_clone_callback, v);
+ g_signal_connect(GTK_OBJECT(item), "activate", (GtkSignalFunc) xsane_viewer_ocr_callback, v);
gtk_widget_show(item);
+ v->ocr_menu_item = item;
-
- /* Scale */
+ /* Clone */
- item = gtk_menu_item_new_with_label(MENU_ITEM_SCALE);
+ item = gtk_menu_item_new_with_label(MENU_ITEM_CLONE);
#if 0
- gtk_widget_add_accelerator(item, "activate", xsane.accelerator_group, GDK_I, GDK_CONTROL_MASK, GTK_ACCEL_VISIBLE | GTK_ACCEL_LOCKED);
+ gtk_widget_add_accelerator(item, "activate", xsane.accelerator_group, GDK_I, GDK_CONTROL_MASK, GTK_ACCEL_VISIBLE | DEF_GTK_ACCEL_LOCKED);
#endif
gtk_menu_append(GTK_MENU(menu), item);
- gtk_signal_connect(GTK_OBJECT(item), "activate", (GtkSignalFunc) xsane_viewer_scale_callback, v);
+ g_signal_connect(GTK_OBJECT(item), "activate", (GtkSignalFunc) xsane_viewer_clone_callback, v);
gtk_widget_show(item);
+ v->clone_menu_item = item;
/* Close */
item = gtk_menu_item_new_with_label(MENU_ITEM_CLOSE);
#if 0
- gtk_widget_add_accelerator(item, "activate", xsane.accelerator_group, GDK_Q, GDK_CONTROL_MASK, GTK_ACCEL_VISIBLE | GTK_ACCEL_LOCKED);
+ gtk_widget_add_accelerator(item, "activate", xsane.accelerator_group, GDK_Q, GDK_CONTROL_MASK, GTK_ACCEL_VISIBLE | DEF_GTK_ACCEL_LOCKED);
#endif
gtk_container_add(GTK_CONTAINER(menu), item);
gtk_object_set_data(GTK_OBJECT(item), "Viewer", (void *) v);
- gtk_signal_connect(GTK_OBJECT(item), "activate", (GtkSignalFunc) xsane_viewer_close_callback, v);
+ g_signal_connect(GTK_OBJECT(item), "activate", (GtkSignalFunc) xsane_viewer_close_callback, v);
gtk_widget_show(item);
return menu;
@@ -1043,6 +1477,31 @@ static GtkWidget *xsane_viewer_files_build_menu(Viewer *v)
/* ---------------------------------------------------------------------------------------------------------------------- */
+static GtkWidget *xsane_viewer_edit_build_menu(Viewer *v)
+{
+ GtkWidget *menu, *item;
+
+ DBG(DBG_proc, "xsane_viewer_edit_build_menu\n");
+
+ menu = gtk_menu_new();
+ gtk_menu_set_accel_group(GTK_MENU(menu), xsane.accelerator_group);
+
+ /* undo */
+
+ item = gtk_menu_item_new_with_label(MENU_ITEM_UNDO);
+#if 0
+ gtk_widget_add_accelerator(item, "activate", xsane.accelerator_group, GDK_I, GDK_CONTROL_MASK, GTK_ACCEL_VISIBLE | DEF_GTK_ACCEL_LOCKED);
+#endif
+ gtk_menu_append(GTK_MENU(menu), item);
+ g_signal_connect(GTK_OBJECT(item), "activate", (GtkSignalFunc) xsane_viewer_undo_callback, v);
+ gtk_widget_show(item);
+ v->undo_menu_item = item;
+
+ return menu;
+}
+
+/* ---------------------------------------------------------------------------------------------------------------------- */
+
static GtkWidget *xsane_viewer_filters_build_menu(Viewer *v)
{
GtkWidget *menu, *item;
@@ -1050,30 +1509,127 @@ static GtkWidget *xsane_viewer_filters_build_menu(Viewer *v)
DBG(DBG_proc, "xsane_viewer_filters_build_menu\n");
menu = gtk_menu_new();
- gtk_accel_group_attach(xsane.accelerator_group, GTK_OBJECT(menu));
+ gtk_menu_set_accel_group(GTK_MENU(menu), xsane.accelerator_group);
/* Despeckle */
item = gtk_menu_item_new_with_label(MENU_ITEM_DESPECKLE);
#if 0
- gtk_widget_add_accelerator(item, "activate", xsane.accelerator_group, GDK_I, GDK_CONTROL_MASK, GTK_ACCEL_VISIBLE | GTK_ACCEL_LOCKED);
+ gtk_widget_add_accelerator(item, "activate", xsane.accelerator_group, GDK_I, GDK_CONTROL_MASK, GTK_ACCEL_VISIBLE | DEF_GTK_ACCEL_LOCKED);
#endif
gtk_menu_append(GTK_MENU(menu), item);
- gtk_signal_connect(GTK_OBJECT(item), "activate", (GtkSignalFunc) xsane_viewer_despeckle_callback, v);
+ g_signal_connect(GTK_OBJECT(item), "activate", (GtkSignalFunc) xsane_viewer_despeckle_callback, v);
gtk_widget_show(item);
+ v->despeckle_menu_item = item;
/* Blur */
item = gtk_menu_item_new_with_label(MENU_ITEM_BLUR);
#if 0
- gtk_widget_add_accelerator(item, "activate", xsane.accelerator_group, GDK_Q, GDK_CONTROL_MASK, GTK_ACCEL_VISIBLE | GTK_ACCEL_LOCKED);
+ gtk_widget_add_accelerator(item, "activate", xsane.accelerator_group, GDK_Q, GDK_CONTROL_MASK, GTK_ACCEL_VISIBLE | DEF_GTK_ACCEL_LOCKED);
#endif
gtk_container_add(GTK_CONTAINER(menu), item);
- gtk_signal_connect(GTK_OBJECT(item), "activate", (GtkSignalFunc) xsane_viewer_blur_callback, v);
+ g_signal_connect(GTK_OBJECT(item), "activate", (GtkSignalFunc) xsane_viewer_blur_callback, v);
gtk_widget_show(item);
+ v->blur_menu_item = item;
- return menu;
+ return menu;
+}
+
+/* ---------------------------------------------------------------------------------------------------------------------- */
+
+static GtkWidget *xsane_viewer_geometry_build_menu(Viewer *v)
+{
+ GtkWidget *menu, *item;
+
+ DBG(DBG_proc, "xsane_viewer_geometry_build_menu\n");
+
+ menu = gtk_menu_new();
+ gtk_menu_set_accel_group(GTK_MENU(menu), xsane.accelerator_group);
+
+
+ /* Scale */
+
+ item = gtk_menu_item_new_with_label(MENU_ITEM_SCALE);
+#if 0
+ gtk_widget_add_accelerator(item, "activate", xsane.accelerator_group, GDK_I, GDK_CONTROL_MASK, GTK_ACCEL_VISIBLE | DEF_GTK_ACCEL_LOCKED);
+#endif
+ gtk_menu_append(GTK_MENU(menu), item);
+ g_signal_connect(GTK_OBJECT(item), "activate", (GtkSignalFunc) xsane_viewer_scale_callback, v);
+ gtk_widget_show(item);
+
+
+ /* insert separator: */
+
+ item = gtk_menu_item_new();
+ gtk_menu_append(GTK_MENU(menu), item);
+ gtk_widget_show(item);
+
+
+ /* rotate90 */
+
+ item = gtk_menu_item_new_with_label(MENU_ITEM_ROTATE90);
+#if 0
+ gtk_widget_add_accelerator(item, "activate", xsane.accelerator_group, GDK_1, GDK_CONTROL_MASK, GTK_ACCEL_VISIBLE | DEF_GTK_ACCEL_LOCKED);
+#endif
+ gtk_menu_append(GTK_MENU(menu), item);
+ g_signal_connect(GTK_OBJECT(item), "activate", (GtkSignalFunc) xsane_viewer_rotate90_callback, v);
+ gtk_widget_show(item);
+
+
+ /* rotate180 */
+
+ item = gtk_menu_item_new_with_label(MENU_ITEM_ROTATE180);
+#if 0
+ gtk_widget_add_accelerator(item, "activate", xsane.accelerator_group, GDK_2, GDK_CONTROL_MASK, GTK_ACCEL_VISIBLE | DEF_GTK_ACCEL_LOCKED);
+#endif
+ gtk_container_add(GTK_CONTAINER(menu), item);
+ g_signal_connect(GTK_OBJECT(item), "activate", (GtkSignalFunc) xsane_viewer_rotate180_callback, v);
+ gtk_widget_show(item);
+
+
+ /* rotate270 */
+
+ item = gtk_menu_item_new_with_label(MENU_ITEM_ROTATE270);
+#if 0
+ gtk_widget_add_accelerator(item, "activate", xsane.accelerator_group, GDK_3, GDK_CONTROL_MASK, GTK_ACCEL_VISIBLE | DEF_GTK_ACCEL_LOCKED);
+#endif
+ gtk_container_add(GTK_CONTAINER(menu), item);
+ g_signal_connect(GTK_OBJECT(item), "activate", (GtkSignalFunc) xsane_viewer_rotate270_callback, v);
+ gtk_widget_show(item);
+
+
+ /* insert separator: */
+
+ item = gtk_menu_item_new();
+ gtk_menu_append(GTK_MENU(menu), item);
+ gtk_widget_show(item);
+
+
+ /* mirror_x */
+
+ item = gtk_menu_item_new_with_label(MENU_ITEM_MIRROR_X);
+#if 0
+ gtk_widget_add_accelerator(item, "activate", xsane.accelerator_group, GDK_X, GDK_CONTROL_MASK, GTK_ACCEL_VISIBLE | DEF_GTK_ACCEL_LOCKED);
+#endif
+ gtk_container_add(GTK_CONTAINER(menu), item);
+ g_signal_connect(GTK_OBJECT(item), "activate", (GtkSignalFunc) xsane_viewer_mirror_x_callback, v);
+ gtk_widget_show(item);
+
+
+ /* mirror_y */
+
+ item = gtk_menu_item_new_with_label(MENU_ITEM_MIRROR_Y);
+#if 0
+ gtk_widget_add_accelerator(item, "activate", xsane.accelerator_group, GDK_Y, GDK_CONTROL_MASK, GTK_ACCEL_VISIBLE | DEF_GTK_ACCEL_LOCKED);
+#endif
+ gtk_container_add(GTK_CONTAINER(menu), item);
+ g_signal_connect(GTK_OBJECT(item), "activate", (GtkSignalFunc) xsane_viewer_mirror_y_callback, v);
+ gtk_widget_show(item);
+
+
+ return menu;
}
/* ---------------------------------------------------------------------------------------------------------------------- */
@@ -1241,7 +1797,7 @@ static int xsane_viewer_read_image(Viewer *v)
size_unit = "KB";
}
- if (v->reduce_to_lineart)
+ if (v->allow_reduction_to_lineart)
{
snprintf(buf, sizeof(buf), TEXT_VIEWER_IMAGE_INFO, image_info.image_width, image_info.image_height, 1, image_info.colors,
image_info.resolution_x, image_info.resolution_y, size, size_unit);
@@ -1266,7 +1822,16 @@ static int xsane_viewer_read_image(Viewer *v)
height = gdk_screen_height();
}
- gtk_window_set_default_size(GTK_WINDOW(v->top), width, height);
+#ifdef HAVE_GTK2
+ if (GTK_WIDGET_REALIZED(v->top))
+ {
+ gtk_window_resize(GTK_WINDOW(v->top), width, height);
+ }
+ else
+#endif
+ {
+ gtk_window_set_default_size(GTK_WINDOW(v->top), width, height);
+ }
free(row);
free(src_row);
@@ -1277,7 +1842,7 @@ static int xsane_viewer_read_image(Viewer *v)
/* ---------------------------------------------------------------------------------------------------------------------- */
-Viewer *xsane_viewer_new(char *filename, int reduce_to_lineart, char *output_filename)
+Viewer *xsane_viewer_new(char *filename, int allow_reduction_to_lineart, char *output_filename, viewer_modification allow_modification)
{
char buf[256];
Viewer *v;
@@ -1299,16 +1864,32 @@ Viewer *xsane_viewer_new(char *filename, int reduce_to_lineart, char *output_fil
memset(v, 0, sizeof(*v));
v->filename = strdup(filename);
- v->reduce_to_lineart = reduce_to_lineart;
+ v->undo_filename = NULL;
+ v->allow_reduction_to_lineart = allow_reduction_to_lineart;
v->zoom = 1.0;
v->image_saved = FALSE;
+ v->allow_modification = allow_modification;
v->next_viewer = xsane.viewer_list;
xsane.viewer_list = v;
+ if (v->allow_modification == VIEWER_NO_MODIFICATION)
+ {
+ v->image_saved = TRUE;
+ }
+
if (output_filename)
{
v->output_filename = strdup(output_filename);
- snprintf(buf, sizeof(buf), "%s %s - %s", WINDOW_VIEWER, v->output_filename, xsane.device_text);
+
+ if (v->image_saved)
+ {
+ snprintf(buf, sizeof(buf), "%s %s - %s", WINDOW_VIEWER, v->output_filename, xsane.device_text);
+ }
+ else
+ {
+ /* add brackets around filename because file is not saved */
+ snprintf(buf, sizeof(buf), "%s (%s) - %s", WINDOW_VIEWER, v->output_filename, xsane.device_text);
+ }
}
else
{
@@ -1318,9 +1899,9 @@ Viewer *xsane_viewer_new(char *filename, int reduce_to_lineart, char *output_fil
v->top = gtk_window_new(GTK_WINDOW_TOPLEVEL);
gtk_window_set_title(GTK_WINDOW(v->top), buf);
xsane_set_window_icon(v->top, 0);
- gtk_accel_group_attach(xsane.accelerator_group, GTK_OBJECT(v->top));
+ gtk_window_add_accel_group(GTK_WINDOW(v->top), xsane.accelerator_group);
gtk_object_set_data(GTK_OBJECT(v->top), "Viewer", (void *) v);
- gtk_signal_connect(GTK_OBJECT(v->top), "delete_event", GTK_SIGNAL_FUNC(xsane_viewer_close_callback), NULL);
+ g_signal_connect(GTK_OBJECT(v->top), "delete_event", GTK_SIGNAL_FUNC(xsane_viewer_close_callback), NULL);
/* set the main vbox */
vbox = gtk_vbox_new(FALSE, 0);
@@ -1333,19 +1914,37 @@ Viewer *xsane_viewer_new(char *filename, int reduce_to_lineart, char *output_fil
menubar = gtk_menu_bar_new();
gtk_box_pack_start(GTK_BOX(vbox), menubar, FALSE, FALSE, 0);
- /* "Files" submenu: */
+ /* "File" submenu: */
menubar_item = gtk_menu_item_new_with_label(MENU_FILE);
gtk_container_add(GTK_CONTAINER(menubar), menubar_item);
- gtk_menu_item_set_submenu(GTK_MENU_ITEM(menubar_item), xsane_viewer_files_build_menu(v));
-/* gtk_widget_add_accelerator(menubar_item, "select", xsane.accelerator_group, GDK_F, 0, GTK_ACCEL_VISIBLE | GTK_ACCEL_LOCKED); */
+ gtk_menu_item_set_submenu(GTK_MENU_ITEM(menubar_item), xsane_viewer_file_build_menu(v));
+/* gtk_widget_add_accelerator(menubar_item, "select", xsane.accelerator_group, GDK_F, 0, GTK_ACCEL_VISIBLE | DEF_GTK_ACCEL_LOCKED); */
+ gtk_widget_show(menubar_item);
+ v->file_menu = menubar_item;
+
+ /* "Edit" submenu: */
+ menubar_item = gtk_menu_item_new_with_label(MENU_EDIT);
+ gtk_container_add(GTK_CONTAINER(menubar), menubar_item);
+ gtk_menu_item_set_submenu(GTK_MENU_ITEM(menubar_item), xsane_viewer_edit_build_menu(v));
+/* gtk_widget_add_accelerator(menubar_item, "select", xsane.accelerator_group, GDK_F, 0, GTK_ACCEL_VISIBLE | DEF_GTK_ACCEL_LOCKED); */
gtk_widget_show(menubar_item);
+ v->edit_menu = menubar_item;
/* "Filters" submenu: */
menubar_item = gtk_menu_item_new_with_label(MENU_FILTERS);
gtk_container_add(GTK_CONTAINER(menubar), menubar_item);
gtk_menu_item_set_submenu(GTK_MENU_ITEM(menubar_item), xsane_viewer_filters_build_menu(v));
-/* gtk_widget_add_accelerator(menubar_item, "select", xsane.accelerator_group, GDK_F, 0, GTK_ACCEL_VISIBLE | GTK_ACCEL_LOCKED); */
+/* gtk_widget_add_accelerator(menubar_item, "select", xsane.accelerator_group, GDK_F, 0, GTK_ACCEL_VISIBLE | DEF_GTK_ACCEL_LOCKED); */
gtk_widget_show(menubar_item);
+ v->filters_menu = menubar_item;
+
+ /* "Geometry" submenu: */
+ menubar_item = gtk_menu_item_new_with_label(MENU_GEOMETRY);
+ gtk_container_add(GTK_CONTAINER(menubar), menubar_item);
+ gtk_menu_item_set_submenu(GTK_MENU_ITEM(menubar_item), xsane_viewer_geometry_build_menu(v));
+/* gtk_widget_add_accelerator(menubar_item, "select", xsane.accelerator_group, GDK_F, 0, GTK_ACCEL_VISIBLE | DEF_GTK_ACCEL_LOCKED); */
+ gtk_widget_show(menubar_item);
+ v->geometry_menu = menubar_item;
gtk_widget_show(menubar);
@@ -1363,17 +1962,49 @@ Viewer *xsane_viewer_new(char *filename, int reduce_to_lineart, char *output_fil
gtk_box_pack_start(GTK_BOX(vbox), v->button_box, FALSE, FALSE, 0);
gtk_widget_show(v->button_box);
- v->save = xsane_button_new_with_pixmap(v->top->window, v->button_box, file_xpm, DESC_VIEWER_SAVE, (GtkSignalFunc) xsane_viewer_save_callback, v);
- v->ocr = xsane_button_new_with_pixmap(v->top->window, v->button_box, ocr_xpm, DESC_VIEWER_OCR, (GtkSignalFunc) xsane_viewer_ocr_callback, v);
+
+ /* top hbox for file icons */
+ v->file_button_box = gtk_hbox_new(FALSE, 0);
+ gtk_container_set_border_width(GTK_CONTAINER(v->file_button_box), 0);
+ gtk_box_pack_start(GTK_BOX(v->button_box), v->file_button_box, FALSE, FALSE, 0);
+ gtk_widget_show(v->file_button_box);
+
+ v->save = xsane_button_new_with_pixmap(v->top->window, v->file_button_box, save_xpm, DESC_VIEWER_SAVE, (GtkSignalFunc) xsane_viewer_save_callback, v);
+ v->ocr = xsane_button_new_with_pixmap(v->top->window, v->file_button_box, ocr_xpm, DESC_VIEWER_OCR, (GtkSignalFunc) xsane_viewer_ocr_callback, v);
v->clone = xsane_button_new_with_pixmap(v->top->window, v->button_box, clone_xpm, DESC_VIEWER_CLONE, (GtkSignalFunc) xsane_viewer_clone_callback, v);
- v->scale = xsane_button_new_with_pixmap(v->top->window, v->button_box, scale_xpm, DESC_VIEWER_SCALE, (GtkSignalFunc) xsane_viewer_scale_callback, v);
- v->despeckle = xsane_button_new_with_pixmap(v->top->window, v->button_box, despeckle_xpm, DESC_VIEWER_DESPECKLE, (GtkSignalFunc) xsane_viewer_despeckle_callback, v);
- v->blur = xsane_button_new_with_pixmap(v->top->window, v->button_box, blur_xpm, DESC_VIEWER_BLUR, (GtkSignalFunc) xsane_viewer_blur_callback, v);
- v->rotate90 = xsane_button_new_with_pixmap(v->top->window, v->button_box, rotate90_xpm, DESC_VIEWER_ROTATE90, (GtkSignalFunc) xsane_viewer_rotate90_callback, v);
- v->rotate180 = xsane_button_new_with_pixmap(v->top->window, v->button_box, rotate180_xpm, DESC_VIEWER_ROTATE180, (GtkSignalFunc) xsane_viewer_rotate180_callback, v);
- v->rotate270 = xsane_button_new_with_pixmap(v->top->window, v->button_box, rotate270_xpm, DESC_VIEWER_ROTATE270, (GtkSignalFunc) xsane_viewer_rotate270_callback, v);
- v->mirror_x = xsane_button_new_with_pixmap(v->top->window, v->button_box, mirror_x_xpm, DESC_VIEWER_MIRROR_X, (GtkSignalFunc) xsane_viewer_mirror_x_callback, v);
- v->mirror_y = xsane_button_new_with_pixmap(v->top->window, v->button_box, mirror_y_xpm, DESC_VIEWER_MIRROR_Y, (GtkSignalFunc) xsane_viewer_mirror_y_callback, v);
+
+
+ /* top hbox for edit icons */
+ v->edit_button_box = gtk_hbox_new(FALSE, 0);
+ gtk_container_set_border_width(GTK_CONTAINER(v->edit_button_box), 0);
+ gtk_box_pack_start(GTK_BOX(v->button_box), v->edit_button_box, FALSE, FALSE, 0);
+ gtk_widget_show(v->edit_button_box);
+
+ v->undo = xsane_button_new_with_pixmap(v->top->window, v->edit_button_box, undo_xpm, DESC_VIEWER_UNDO, (GtkSignalFunc) xsane_viewer_undo_callback, v);
+
+
+ /* top hbox for filter icons */
+ v->filters_button_box = gtk_hbox_new(FALSE, 0);
+ gtk_container_set_border_width(GTK_CONTAINER(v->filters_button_box), 0);
+ gtk_box_pack_start(GTK_BOX(v->button_box), v->filters_button_box, FALSE, FALSE, 0);
+ gtk_widget_show(v->filters_button_box);
+
+ v->despeckle = xsane_button_new_with_pixmap(v->top->window, v->filters_button_box, despeckle_xpm, DESC_VIEWER_DESPECKLE, (GtkSignalFunc) xsane_viewer_despeckle_callback, v);
+ v->blur = xsane_button_new_with_pixmap(v->top->window, v->filters_button_box, blur_xpm, DESC_VIEWER_BLUR, (GtkSignalFunc) xsane_viewer_blur_callback, v);
+
+
+ /* top hbox for geometry icons */
+ v->geometry_button_box = gtk_hbox_new(FALSE, 0);
+ gtk_container_set_border_width(GTK_CONTAINER(v->geometry_button_box), 0);
+ gtk_box_pack_start(GTK_BOX(v->button_box), v->geometry_button_box, FALSE, FALSE, 0);
+ gtk_widget_show(v->geometry_button_box);
+
+ xsane_button_new_with_pixmap(v->top->window, v->geometry_button_box, scale_xpm, DESC_VIEWER_SCALE, (GtkSignalFunc) xsane_viewer_scale_callback, v);
+ xsane_button_new_with_pixmap(v->top->window, v->geometry_button_box, rotate90_xpm, DESC_ROTATE90, (GtkSignalFunc) xsane_viewer_rotate90_callback, v);
+ xsane_button_new_with_pixmap(v->top->window, v->geometry_button_box, rotate180_xpm, DESC_ROTATE180, (GtkSignalFunc) xsane_viewer_rotate180_callback, v);
+ xsane_button_new_with_pixmap(v->top->window, v->geometry_button_box, rotate270_xpm, DESC_ROTATE270, (GtkSignalFunc) xsane_viewer_rotate270_callback, v);
+ xsane_button_new_with_pixmap(v->top->window, v->geometry_button_box, mirror_x_xpm, DESC_MIRROR_X, (GtkSignalFunc) xsane_viewer_mirror_x_callback, v);
+ xsane_button_new_with_pixmap(v->top->window, v->geometry_button_box, mirror_y_xpm, DESC_MIRROR_Y, (GtkSignalFunc) xsane_viewer_mirror_y_callback, v);
/* "Zoom" submenu: */
@@ -1384,12 +2015,13 @@ Viewer *xsane_viewer_new(char *filename, int reduce_to_lineart, char *output_fil
zoom_menu = gtk_menu_new();
selection = 0;
- for (i = 0; i < XSANE_VIEWER_ZOOM_ITEMS; i++)
+
+ for (i = 0; i < sizeof(xsane_viewer_zoom) / sizeof(int); i++)
{
snprintf(buf, sizeof(buf), "%d %%", xsane_viewer_zoom[i]);
zoom_menu_item = gtk_menu_item_new_with_label(buf);
gtk_menu_append(GTK_MENU(zoom_menu), zoom_menu_item);
- gtk_signal_connect(GTK_OBJECT(zoom_menu_item), "activate", (GtkSignalFunc) xsane_viewer_zoom_callback, v);
+ g_signal_connect(GTK_OBJECT(zoom_menu_item), "activate", (GtkSignalFunc) xsane_viewer_zoom_callback, v);
gtk_object_set_data(GTK_OBJECT(zoom_menu_item), "Selection", (void *) xsane_viewer_zoom[i]);
gtk_widget_show(zoom_menu_item);
if (v->zoom*100 == xsane_viewer_zoom[i])
@@ -1399,13 +2031,13 @@ Viewer *xsane_viewer_new(char *filename, int reduce_to_lineart, char *output_fil
}
gtk_option_menu_set_menu(GTK_OPTION_MENU(zoom_option_menu), zoom_menu);
gtk_option_menu_set_history(GTK_OPTION_MENU(zoom_option_menu), selection);
-/* gtk_widget_add_accelerator(menubar_item, "select", xsane.accelerator_group, GDK_F, 0, GTK_ACCEL_VISIBLE | GTK_ACCEL_LOCKED); */
+/* gtk_widget_add_accelerator(menubar_item, "select", xsane.accelerator_group, GDK_F, 0, GTK_ACCEL_VISIBLE | DEF_GTK_ACCEL_LOCKED); */
gtk_widget_show(zoom_menu);
scrolled_window = gtk_scrolled_window_new(NULL, NULL);
- gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_window), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
+ gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolled_window), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
gtk_box_pack_start(GTK_BOX(vbox), scrolled_window, TRUE, TRUE, 0);
gtk_widget_show(scrolled_window);
@@ -1426,23 +2058,27 @@ Viewer *xsane_viewer_new(char *filename, int reduce_to_lineart, char *output_fil
gtk_box_pack_start(GTK_BOX(hbox), v->image_info_label, FALSE, FALSE, 2);
gtk_widget_show(v->image_info_label);
- gtk_widget_show(v->top);
if (xsane_viewer_read_image(v)) /* read image and add preview to the viewport */
{
/* error */
}
+ gtk_widget_show(v->top);
v->progress_bar = (GtkProgressBar *) gtk_progress_bar_new();
#if 0
- gtk_widget_set_usize(v->progress_bar, 0, 25);
+ gtk_widget_set_size_request(v->progress_bar, 0, 25);
#endif
gtk_box_pack_start(GTK_BOX(vbox), (GtkWidget *) v->progress_bar, FALSE, FALSE, 0);
gtk_progress_set_show_text(GTK_PROGRESS(v->progress_bar), TRUE);
gtk_progress_set_format_string(GTK_PROGRESS(v->progress_bar), "");
gtk_widget_show(GTK_WIDGET(v->progress_bar));
+ xsane_viewer_set_sensitivity(v, TRUE);
+
+ gtk_widget_set_sensitive(GTK_WIDGET(v->undo), FALSE);
+ gtk_widget_set_sensitive(GTK_WIDGET(v->undo_menu_item), FALSE);
+
return v;
}
-
diff --git a/src/xsane-viewer.h b/src/xsane-viewer.h
index 885466b..31d87bc 100644
--- a/src/xsane-viewer.h
+++ b/src/xsane-viewer.h
@@ -3,7 +3,7 @@
xsane-viewer.h
Oliver Rauch <Oliver.Rauch@rauch-domain.de>
- Copyright (C) 2001-2002 Oliver Rauch
+ Copyright (C) 2001-2005 Oliver Rauch
This file is part of the XSANE package.
This program is free software; you can redistribute it and/or modify
@@ -29,51 +29,79 @@
#include <gdk/gdk.h>
#include <gtk/gtk.h>
+typedef enum
+{
+ VIEWER_NO_MODIFICATION = 0,
+ VIEWER_NO_NAME_AND_SIZE_MODIFICATION,
+ VIEWER_NO_NAME_MODIFICATION,
+ VIEWER_FULL_MODIFICATION
+} viewer_modification;
+
typedef struct Viewer
{
struct Viewer *next_viewer;
char *filename;
char *output_filename;
+ char *last_saved_filename;
+ char *undo_filename;
- int reduce_to_lineart;
+ int allow_reduction_to_lineart;
float zoom;
int image_saved;
int cancel_save;
+ viewer_modification allow_modification;
+
+ int despeckle_radius;
+ float blur_radius;
- int filter_radius;
- float x_scale_factor;
- float y_scale_factor;
+ int bind_scale;
+ double x_scale_factor;
+ double y_scale_factor;
GtkWidget *top;
GtkWidget *button_box;
+ GtkWidget *file_button_box;
+ GtkWidget *edit_button_box;
+ GtkWidget *filters_button_box;
+ GtkWidget *geometry_button_box;
+
+ GtkWidget *file_menu;
+ GtkWidget *edit_menu;
+ GtkWidget *filters_menu;
+ GtkWidget *geometry_menu;
+
GtkWidget *viewport;
GtkWidget *window;
+ GtkWidget *save_menu_item;
+ GtkWidget *ocr_menu_item;
+ GtkWidget *clone_menu_item;
+
+ GtkWidget *undo_menu_item;
+
+ GtkWidget *despeckle_menu_item;
+ GtkWidget *blur_menu_item;
+
GtkWidget *save;
GtkWidget *ocr;
+ GtkWidget *undo;
GtkWidget *clone;
- GtkWidget *scale;
GtkWidget *despeckle;
GtkWidget *blur;
- GtkWidget *rotate90;
- GtkWidget *rotate180;
- GtkWidget *rotate270;
-
- GtkWidget *mirror_x;
- GtkWidget *mirror_y;
-
GtkWidget *image_info_label;
GtkProgressBar *progress_bar;
GtkWidget *active_dialog;
+
+ int block_actions;
}
Viewer;
-extern Viewer *xsane_viewer_new(char *filename, int reduce_to_lineart, char *output_filename);
+extern Viewer *xsane_viewer_new(char *filename, int reduce_to_lineart, char *output_filename, viewer_modification allow_modification);
#endif
diff --git a/src/xsane.c b/src/xsane.c
index ae07b8c..9ef109f 100644
--- a/src/xsane.c
+++ b/src/xsane.c
@@ -3,7 +3,7 @@
xsane.c
Oliver Rauch <Oliver.Rauch@rauch-domain.de>
- Copyright (C) 1998-2002 Oliver Rauch
+ Copyright (C) 1998-2005 Oliver Rauch
This file is part of the XSANE package.
This program is free software; you can redistribute it and/or modify
@@ -34,6 +34,7 @@
#include "xsane-device-preferences.h"
#include "xsane-preferences.h"
#include "xsane-icons.h"
+#include "xsane-batch-scan.h"
#ifdef HAVE_LIBPNG
#ifdef HAVE_LIBZ
@@ -42,7 +43,6 @@
#endif
#endif
-#include <sys/types.h>
#include <sys/wait.h>
/* ---------------------------------------------------------------------------------------------------------------------- */
@@ -65,7 +65,6 @@ struct option long_options[] =
{"Resizeable", no_argument, 0, 'R'},
{"print-filenames", no_argument, 0, 'p'},
{"force-filename", required_argument, 0, 'N'},
- {"Medium-calibration", no_argument, 0, 'M'},
{0, }
};
@@ -98,8 +97,8 @@ static const Preferences_medium_t pref_default_medium[]=
{
/* medium shadow highlight gamma negative */
/* name gray red green blue gray red green blue gray red gren blue */
- { MENU_ITEM_MEDIUM_FULL_RANGE, 0.0, 0.0, 0.0, 0.0, 100.0,100.0,100.0,100.0, 1.00, 1.00, 1.00, 1.00 , 0},
- { MENU_ITEM_MEDIUM_SLIDE, 0.0, 0.0, 0.0, 0.0, 30.0, 30.0, 30.0, 30.0, 1.00, 1.00, 1.00, 1.00 , 0},
+ { MENU_ITEM_MEDIUM_FULL_COLOR_RANGE, 0.0, 0.0, 0.0, 0.0, 100.0,100.0,100.0,100.0, 1.00, 1.00, 1.00, 1.00 , 0},
+ { MENU_ITEM_MEDIUM_SLIDE, 0.0, 0.0, 0.0, 0.0, 40.0, 40.0, 40.0, 40.0, 1.00, 1.00, 1.00, 1.00 , 0},
{ MENU_ITEM_MEDIUM_STANDARD_NEG, 0.0, 7.0, 1.0, 0.0, 66.0, 66.0, 33.0, 16.0, 1.00, 1.00, 1.00, 1.00 , 1},
{ MENU_ITEM_MEDIUM_AGFA_NEG, 0.0, 6.0, 2.0, 0.0, 31.0, 61.0, 24.0, 13.0, 1.00, 1.00, 1.00, 1.00 , 1},
{ MENU_ITEM_MEDIUM_AGFA_NEG_XRG200_4, 0.0, 12.0, 2.0, 1.6, 35.0, 61.5, 21.5, 14.5, 1.00, 0.80, 0.67, 0.60 , 1},
@@ -114,6 +113,8 @@ static const Preferences_medium_t pref_default_medium[]=
/* ---------------------------------------------------------------------------------------------------------------------- */
int DBG_LEVEL = 0;
+static guint xsane_resolution_timer = 0;
+static guint xsane_mail_send_timer = 0;
/* ---------------------------------------------------------------------------------------------------------------------- */
@@ -144,11 +145,6 @@ static void xsane_threshold_changed(void);
static void xsane_gamma_changed(GtkAdjustment *adj_data, double *val);
static void xsane_set_modus_defaults(void);
static void xsane_modus_callback(GtkWidget *xsane_parent, int *num);
-static void xsane_filename_counter_step_callback(GtkWidget *widget, gpointer data);
-static void xsane_filetype_callback(GtkWidget *widget, gpointer data);
-static void xsane_outputfilename_changed_callback(GtkWidget *widget, gpointer data);
-static void xsane_browse_filename_callback(GtkWidget *widget, gpointer data);
-static void xsane_outputfilename_new(GtkWidget *vbox);
static void xsane_enhancement_rgb_default_callback(GtkWidget *widget);
static void xsane_enhancement_negative_callback(GtkWidget *widget);
static void xsane_auto_enhancement_callback(GtkWidget *widget);
@@ -158,10 +154,14 @@ static void xsane_show_histogram_callback(GtkWidget *widget);
#ifdef HAVE_WORKING_GTK_GAMMACURVE
static void xsane_show_gamma_callback(GtkWidget *widget);
#endif
+static void xsane_show_batch_scan_callback(GtkWidget *widget);
static void xsane_printer_callback(GtkWidget *widget, gpointer data);
void xsane_pref_save(void);
static int xsane_pref_restore(void);
+static void xsane_pref_save_media(void);
+static void xsane_pref_restore_media(void);
static RETSIGTYPE xsane_quit_handler(int signal);
+static RETSIGTYPE xsane_sigchld_handler(int signal);
static void xsane_quit(void);
static void xsane_exit(void);
static gint xsane_standard_option_win_delete(GtkWidget *widget, gpointer data);
@@ -170,24 +170,22 @@ static gint xsane_scan_win_delete(GtkWidget *w, gpointer data);
static gint xsane_preview_window_destroyed(GtkWidget *widget, gpointer call_data);
static void xsane_show_preview_callback(GtkWidget * widget, gpointer call_data);
static GtkWidget *xsane_files_build_menu(void);
+static gint xsane_medium_context_menu_callback(GtkWidget *widget, GdkEvent *event);
static void xsane_set_medium_callback(GtkWidget *widget, gpointer data);
static void xsane_set_pref_unit_callback(GtkWidget *widget, gpointer data);
+static void xsane_edit_medium_definition_callback(GtkWidget *widget, gpointer data);
static void xsane_set_update_policy_callback(GtkWidget *widget, gpointer data);
static gint xsane_close_info_callback(GtkWidget *widget, gpointer data);
static void xsane_info_dialog(GtkWidget *widget, gpointer data);
static void xsane_about_dialog(GtkWidget *widget, gpointer data);
static void xsane_about_translation_dialog(GtkWidget *widget, gpointer data);
-static SANE_Status xsane_get_area_value(int option, float *val, SANE_Int *unit);
-#ifdef XSANE_TEST
-static void xsane_batch_scan_delete_callback(GtkWidget *widget, gpointer list);
-static void xsane_batch_scan_add_callback(GtkWidget *widget, gpointer list);
-static void xsane_batch_scan_dialog(GtkWidget *widget, gpointer data);
-#endif
+static gint xsane_fax_dialog_delete();
static void xsane_fax_dialog(void);
static void xsane_fax_dialog_close(void);
static void xsane_fax_receiver_changed_callback(GtkWidget *widget, gpointer data);
static void xsane_fax_project_changed_callback(GtkWidget *widget, gpointer data);
static void xsane_fax_fine_mode_callback(GtkWidget *widget);
+static void xsane_fax_project_update_project_status();
void xsane_fax_project_save(void);
static void xsane_fax_project_load(void);
static void xsane_fax_project_delete(void);
@@ -201,6 +199,8 @@ static void xsane_fax_entry_delete_callback(GtkWidget *widget, gpointer list);
static void xsane_fax_show_callback(GtkWidget *widget, gpointer data);
static void xsane_fax_send(void);
#ifdef XSANE_ACTIVATE_MAIL
+static gint xsane_mail_dialog_delete();
+static void xsane_mail_filetype_callback(GtkWidget *filetype_option_menu, char *filetype);
static void xsane_mail_dialog(void);
static void xsane_mail_dialog_close(void);
static void xsane_mail_receiver_changed_callback(GtkWidget *widget, gpointer data);
@@ -208,28 +208,34 @@ static void xsane_mail_subject_changed_callback(GtkWidget *widget, gpointer data
static void xsane_mail_project_changed_callback(GtkWidget *widget, gpointer data);
static void xsane_mail_html_mode_callback(GtkWidget *widget);
void xsane_mail_project_save(void);
+static void xsane_mail_project_display_status(void);
static void xsane_mail_project_load(void);
static void xsane_mail_project_delete(void);
+static void xsane_mail_project_update_project_status();
static void xsane_mail_project_create(void);
static void xsane_mail_entry_move_up_callback(GtkWidget *widget, gpointer list);
static void xsane_mail_entry_move_down_callback(GtkWidget *widget, gpointer list);
static void xsane_mail_entry_rename_callback(GtkWidget *widget, gpointer list);
static void xsane_mail_entry_delete_callback(GtkWidget *widget, gpointer list);
static void xsane_mail_show_callback(GtkWidget *widget, gpointer data);
-static void xsane_mail_send(void);
+#if 0
+static void xsane_mail_edit_callback(GtkWidget *widget, gpointer data);
#endif
-static void xsane_pref_toggle_tooltips(GtkWidget *widget, gpointer data);
static void xsane_mail_send_process(void);
static void xsane_mail_send(void);
-static void xsane_show_license(GtkWidget *widget, gpointer data);
+#endif
+static void xsane_pref_toggle_tooltips(GtkWidget *widget, gpointer data);
+static void xsane_show_eula(GtkWidget *widget, gpointer data);
+static void xsane_show_gpl(GtkWidget *widget, gpointer data);
static void xsane_show_doc(GtkWidget *widget, gpointer data);
static GtkWidget *xsane_view_build_menu(void);
-static GtkWidget *xsane_pref_build_menu(void);
+static GtkWidget *xsane_window_build_menu(void);
+static GtkWidget *xsane_preferences_build_menu(void);
static GtkWidget *xsane_help_build_menu(void);
static void xsane_device_dialog(void);
static void xsane_choose_dialog_ok_callback(void);
static void xsane_select_device_by_key_callback(GtkWidget * widget, gpointer data);
-static void xsane_select_device_by_mouse_callback(GtkWidget * widget, GdkEventButton *event, gpointer data);
+static int xsane_select_device_by_mouse_callback(GtkWidget * widget, GdkEventButton *event, gpointer data);
static void xsane_choose_device(void);
static void xsane_usage(void);
static int xsane_init(int argc, char **argv);
@@ -254,191 +260,6 @@ void xsane_debug_message(int level, const char *fmt, ...)
/* ---------------------------------------------------------------------------------------------------------------------- */
-static void xsane_add_medium_definition(char *definition_name)
-{
- int i;
-
- DBG(DBG_proc, "xsane_add_new_medium_definition\n");
-
- i = preferences.medium_definitions;
-
- preferences.medium_definitions++;
- preferences.medium = realloc( preferences.medium, preferences.medium_definitions * sizeof(void *));
-
- if (xsane.negative == xsane.medium_negative) /* result is positive */
- {
- preferences.medium[i] = calloc(sizeof(Preferences_medium_t), 1);
- preferences.medium[i]->name = strdup(definition_name);
- preferences.medium[i]->shadow_gray = xsane.medium_shadow_gray + (xsane.medium_highlight_gray - xsane.medium_shadow_gray) * xsane.slider_gray.value[0] / 100.0;
- preferences.medium[i]->shadow_red = xsane.medium_shadow_red + (xsane.medium_highlight_red - xsane.medium_shadow_red) * xsane.slider_red.value[0] / 100.0;
- preferences.medium[i]->shadow_green = xsane.medium_shadow_green + (xsane.medium_highlight_green - xsane.medium_shadow_green) * xsane.slider_green.value[0] / 100.0;
- preferences.medium[i]->shadow_blue = xsane.medium_shadow_blue + (xsane.medium_highlight_blue - xsane.medium_shadow_blue) * xsane.slider_blue.value[0] / 100.0;
- preferences.medium[i]->highlight_gray = xsane.medium_shadow_gray + (xsane.medium_highlight_gray - xsane.medium_shadow_gray) * xsane.slider_gray.value[2] / 100.0;
- preferences.medium[i]->highlight_red = xsane.medium_shadow_red + (xsane.medium_highlight_red - xsane.medium_shadow_red) * xsane.slider_red.value[2] / 100.0;
- preferences.medium[i]->highlight_green = xsane.medium_shadow_green + (xsane.medium_highlight_green - xsane.medium_shadow_green) * xsane.slider_green.value[2] / 100.0;
- preferences.medium[i]->highlight_blue = xsane.medium_shadow_blue + (xsane.medium_highlight_blue - xsane.medium_shadow_blue) * xsane.slider_blue.value[2] / 100.0;
- preferences.medium[i]->gamma_gray = xsane.gamma;
- preferences.medium[i]->gamma_red = xsane.gamma * xsane.gamma_red * xsane.medium_gamma_red;
- preferences.medium[i]->gamma_green = xsane.gamma * xsane.gamma_green * xsane.medium_gamma_green;
- preferences.medium[i]->gamma_blue = xsane.gamma * xsane.gamma_blue * xsane.medium_gamma_blue;
- preferences.medium[i]->negative = 0;
- }
- else /* result is negative */
- {
- preferences.medium[i] = calloc(sizeof(Preferences_medium_t), 1);
- preferences.medium[i]->name = strdup(definition_name);
- preferences.medium[i]->shadow_gray = xsane.medium_shadow_gray + (xsane.medium_highlight_gray - xsane.medium_shadow_gray) * (1.0 - xsane.slider_gray.value[2] / 100.0);
- preferences.medium[i]->shadow_red = xsane.medium_shadow_red + (xsane.medium_highlight_red - xsane.medium_shadow_red) * (1.0 - xsane.slider_red.value[2] / 100.0);
- preferences.medium[i]->shadow_green = xsane.medium_shadow_green + (xsane.medium_highlight_green - xsane.medium_shadow_green) * (1.0 - xsane.slider_green.value[2] / 100.0);
- preferences.medium[i]->shadow_blue = xsane.medium_shadow_blue + (xsane.medium_highlight_blue - xsane.medium_shadow_blue) * (1.0 - xsane.slider_blue.value[2] / 100.0);
- preferences.medium[i]->highlight_gray = xsane.medium_shadow_gray + (xsane.medium_highlight_gray - xsane.medium_shadow_gray) * (1.0 - xsane.slider_gray.value[0] / 100.0);
- preferences.medium[i]->highlight_red = xsane.medium_shadow_red + (xsane.medium_highlight_red - xsane.medium_shadow_red) * (1.0 - xsane.slider_red.value[0] / 100.0);
- preferences.medium[i]->highlight_green = xsane.medium_shadow_green + (xsane.medium_highlight_green - xsane.medium_shadow_green) * (1.0 - xsane.slider_green.value[0] / 100.0);
- preferences.medium[i]->highlight_blue = xsane.medium_shadow_blue + (xsane.medium_highlight_blue - xsane.medium_shadow_blue) * (1.0 - xsane.slider_blue.value[0] / 100.0);
- preferences.medium[i]->gamma_gray = xsane.gamma;
- preferences.medium[i]->gamma_red = xsane.gamma * xsane.gamma_red * xsane.medium_gamma_red;
- preferences.medium[i]->gamma_green = xsane.gamma * xsane.gamma_green * xsane.medium_gamma_green;
- preferences.medium[i]->gamma_blue = xsane.gamma * xsane.gamma_blue * xsane.medium_gamma_blue;
- preferences.medium[i]->negative = 1;
- }
-
- xsane_back_gtk_refresh_dialog();
-}
-
-/* ---------------------------------------------------------------------------------------------------------------------- */
-
-int xsane_add_medium_definition_flag;
-
-static void xsane_add_medium_definition_button_callback(GtkWidget *widget, gpointer data)
-{
- DBG(DBG_proc, "xsane_add_medium_definiton_button_callback\n");
-
- xsane_add_medium_definition_flag = (int) data;
-}
-
-/* ---------------------------------------------------------------------------------------------------------------------- */
-
-static void xsane_add_medium_definition_callback()
-{
- GtkWidget *add_medium_dialog;
- GtkWidget *hbox, *vbox, *button, *text, *label;
-
- xsane_set_sensitivity(FALSE);
-
- /* set add medium dialog */
- add_medium_dialog = gtk_window_new(GTK_WINDOW_DIALOG);
- gtk_window_set_position(GTK_WINDOW(add_medium_dialog), GTK_WIN_POS_MOUSE);
- gtk_window_set_title(GTK_WINDOW(add_medium_dialog), WINDOW_STORE_MEDIUM);
- xsane_set_window_icon(add_medium_dialog, 0);
- gtk_signal_connect_object(GTK_OBJECT(add_medium_dialog), "delete_event", (GtkSignalFunc) xsane_add_medium_definition_button_callback, (GtkObject *) -1);
-
- /* set the main vbox */
- vbox = gtk_vbox_new(FALSE, 0);
- gtk_container_set_border_width(GTK_CONTAINER(vbox), 0);
- gtk_container_add(GTK_CONTAINER(add_medium_dialog), vbox);
- gtk_widget_show(vbox);
-
- /* set the main hbox */
- hbox = gtk_hbox_new(FALSE, 0);
- xsane_separator_new(vbox, 2);
- gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 5);
- gtk_container_set_border_width(GTK_CONTAINER(hbox), 5);
- gtk_widget_show(hbox);
-
- label = gtk_label_new(TEXT_MEDIUM_DEFINITION_NAME);
- gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 2);
- gtk_widget_show(label);
-
- text = gtk_entry_new_with_max_length(64);
- xsane_back_gtk_set_tooltip(xsane.tooltips, text, DESC_PRESET_AREA_NAME);
- gtk_entry_set_text(GTK_ENTRY(text), "");
- gtk_widget_set_usize(text, 300, 0);
- gtk_box_pack_start(GTK_BOX(hbox), text, TRUE, TRUE, 4);
- gtk_widget_show(text);
-
- /* set the main hbox */
- hbox = gtk_hbox_new(FALSE, 0);
- xsane_separator_new(vbox, 2);
- gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 5);
- gtk_container_set_border_width(GTK_CONTAINER(hbox), 5);
- gtk_widget_show(hbox);
-
- label = gtk_label_new(TEXT_MEDIUM_DEFINITION_NAME);
- gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 2);
-
-
- button = gtk_button_new_with_label("OK");
- gtk_signal_connect(GTK_OBJECT(button), "clicked", (GtkSignalFunc) xsane_add_medium_definition_button_callback, (void *) 1);
- gtk_box_pack_start(GTK_BOX(hbox), button, TRUE, TRUE, 0);
- gtk_widget_show(button);
-
- button = gtk_button_new_with_label("Cancel");
- gtk_signal_connect(GTK_OBJECT(button), "clicked", (GtkSignalFunc) xsane_add_medium_definition_button_callback, (void *) -1);
- gtk_box_pack_start(GTK_BOX(hbox), button, TRUE, TRUE, 0);
- gtk_widget_show(button);
-
- gtk_widget_show(add_medium_dialog);
-
- xsane_add_medium_definition_flag = 0;
-
- while (xsane_add_medium_definition_flag == 0)
- {
- while (gtk_events_pending())
- {
- DBG(DBG_info, "xsane_add_medium_definition_callback: calling gtk_main_iteration\n");
- gtk_main_iteration();
- }
- }
-
- if (xsane_add_medium_definition_flag == 1)
- {
- xsane_add_medium_definition(gtk_entry_get_text(GTK_ENTRY(text)));
- }
-
- gtk_widget_destroy(add_medium_dialog);
-
- xsane_set_sensitivity(TRUE);
-}
-
-/* ---------------------------------------------------------------------------------------------------------------------- */
-
-static void xsane_delete_medium_definition_callback()
-{
- int i;
-
- if (xsane.medium_nr == 0) /* do not allow to delete "full range" */
- {
- return;
- }
-
- free(preferences.medium[xsane.medium_nr]);
-
- preferences.medium_definitions--;
-
- for (i = xsane.medium_nr; i < preferences.medium_definitions; i++)
- {
- preferences.medium[i] = preferences.medium[i+1];
- }
-
- if (xsane.medium_nr > 0)
- {
- xsane.medium_nr--;
- }
-
- xsane.medium_changed = TRUE;
-
- xsane_set_medium(preferences.medium[xsane.medium_nr]);
-
- xsane_update_gamma_curve(TRUE); /* if necessary update preview gamma */
-
- preview_display_valid(xsane.preview); /* update valid status of preview image */
- /* the valid status depends on gamma handling an medium change */
-
- xsane_back_gtk_refresh_dialog(); /* update menu */
-}
-
-/* ---------------------------------------------------------------------------------------------------------------------- */
-
static int xsane_option_defined(char *string)
{
if (string)
@@ -493,9 +314,12 @@ static void xsane_gamma_changed(GtkAdjustment *adj_data, double *val)
DBG(DBG_proc, "xsane_gamma_changed\n");
*val = adj_data->value;
- xsane_enhancement_by_gamma();
- xsane_threshold_changed();
+ if (!xsane.block_enhancement_update)
+ {
+ xsane_enhancement_by_gamma();
+ xsane_threshold_changed();
+ }
}
/* ---------------------------------------------------------------------------------------------------------------------- */
@@ -574,17 +398,6 @@ static void xsane_modus_callback(GtkWidget *xsane_parent, int *num)
{
DBG(DBG_proc, "xsane_modus_callback\n");
- if (xsane.filetype) /* add extension to filename */
- {
- char buffer[256];
-
- snprintf(buffer, sizeof(buffer), "%s%s", preferences.filename, xsane.filetype);
- free(preferences.filename);
- free(xsane.filetype);
- xsane.filetype = NULL;
- preferences.filename = strdup(buffer);
- }
-
xsane.xsane_mode = *num;
xsane_set_modus_defaults(); /* set defaults and maximum output size */
@@ -612,331 +425,12 @@ static void xsane_modus_callback(GtkWidget *xsane_parent, int *num)
xsane_mail_dialog_close();
}
#endif
-}
-
-/* ---------------------------------------------------------------------------------------------------------------------- */
-
-static void xsane_filename_counter_step_callback(GtkWidget *widget, gpointer data)
-{
- DBG(DBG_proc, "xsane_filename_counter_step_callback\n");
-
- preferences.filename_counter_step = (int) data;
-}
-
-/* ---------------------------------------------------------------------------------------------------------------------- */
-
-static void xsane_filetype_callback(GtkWidget *widget, gpointer data)
-{
- DBG(DBG_proc, "xsane_filetype_callback\n");
-
- if (data)
- {
- char *extension, *filename;
-
- extension = strrchr(preferences.filename, '.');
-
- if ((extension) && (extension != preferences.filename))
- {
- if ( (!strcasecmp(extension, ".pnm")) || (!strcasecmp(extension, ".raw"))
- || (!strcasecmp(extension, ".png")) || (!strcasecmp(extension, ".ps"))
- || (!strcasecmp(extension, ".rgba"))
- || (!strcasecmp(extension, ".tiff")) || (!strcasecmp(extension, ".tif"))
- || (!strcasecmp(extension, ".jpg")) || (!strcasecmp(extension, ".jpeg"))
- ) /* remove filetype extension */
- {
- filename = preferences.filename;
- *extension = 0; /* remove extension */
- preferences.filename = strdup(filename); /* filename without extension */
- free(filename); /* free unused memory */
- }
- }
- }
- else if (xsane.filetype)
- {
- char buffer[256];
-
- snprintf(buffer, sizeof(buffer), "%s%s", preferences.filename, xsane.filetype);
- free(preferences.filename);
- free(xsane.filetype);
- xsane.filetype = NULL;
- preferences.filename = strdup(buffer);
- }
-
- if (data)
- {
- xsane.filetype = strdup((char *) data); /* set extension for filename */
- }
-
- /* correct length of filename counter if it is shorter than minimum length */
- xsane_update_counter_in_filename(&preferences.filename, FALSE, 0, preferences.filename_counter_len);
- gtk_entry_set_text(GTK_ENTRY(xsane.outputfilename_entry), preferences.filename);
- xsane_define_maximum_output_size(); /* is necessary in postscript mode */
-}
-
-/* ---------------------------------------------------------------------------------------------------------------------- */
-
-static void xsane_outputfilename_changed_callback(GtkWidget *widget, gpointer data)
-{
- DBG(DBG_proc, "xsane_outputfilename_changed_callback\n");
-
- if (preferences.filename)
- {
- free((void *) preferences.filename);
- }
- preferences.filename = strdup(gtk_entry_get_text(GTK_ENTRY(widget)));
-
- xsane_define_maximum_output_size(); /* is necessary in postscript mode */
-}
-
-/* ----------------------------------------------------------------------------------------------------------------- */
-
-static void xsane_browse_filename_callback(GtkWidget *widget, gpointer data)
-{
- char filename[1024];
- char windowname[256];
-
- DBG(DBG_proc, "xsane_browse_filename_callback\n");
-
- xsane_set_sensitivity(FALSE);
-
- if (xsane.filetype) /* set filetype to "by ext." */
- {
- char buffer[256];
-
- snprintf(buffer, sizeof(buffer), "%s%s", preferences.filename, xsane.filetype);
- free(preferences.filename);
- free(xsane.filetype);
- xsane.filetype = NULL;
- preferences.filename = strdup(buffer);
- }
-
- if (preferences.filename) /* make sure a correct filename is defined */
- {
- strncpy(filename, preferences.filename, sizeof(filename));
- filename[sizeof(filename) - 1] = '\0';
- }
- else /* no filename given, take standard filename */
- {
- strcpy(filename, OUT_FILENAME);
- }
-
- snprintf(windowname, sizeof(windowname), "%s %s %s", xsane.prog_name, WINDOW_OUTPUT_FILENAME, xsane.device_text);
-
- umask((mode_t) preferences.directory_umask); /* define new file permissions */
- xsane_back_gtk_get_filename(windowname, filename, sizeof(filename), filename, TRUE, TRUE, FALSE);
- umask(XSANE_DEFAULT_UMASK); /* define new file permissions */
-
- if (preferences.filename)
- {
- free((void *) preferences.filename);
- }
-
- xsane_set_sensitivity(TRUE);
-
- preferences.filename = strdup(filename);
-
- /* correct length of filename counter if it is shorter than minimum length */
- xsane_update_counter_in_filename(&preferences.filename, FALSE, 0, preferences.filename_counter_len);
-
- gtk_entry_set_text(GTK_ENTRY(xsane.outputfilename_entry), preferences.filename);
-
- gtk_option_menu_set_history(GTK_OPTION_MENU(xsane.filetype_option_menu), 0); /* set menu to "by ext" */
- xsane_define_maximum_output_size(); /* is necessary in postscript mode */
-}
-
-/* ---------------------------------------------------------------------------------------------------------------------- */
-
-static void xsane_outputfilename_new(GtkWidget *vbox)
-{
- GtkWidget *hbox;
- GtkWidget *text;
- GtkWidget *button;
- GtkWidget *xsane_filetype_menu, *xsane_filetype_item;
- GtkWidget *xsane_filename_counter_step_option_menu;
- GtkWidget *xsane_filename_counter_step_menu;
- GtkWidget *xsane_filename_counter_step_item;
- GtkWidget *xsane_label;
- gchar buf[200];
- int i,j;
- int filetype_nr;
- int select_item = 0;
-
- DBG(DBG_proc, "xsane_outputfilename_new\n");
-
- /* first line: disk icon, filename box */
-
- hbox = gtk_hbox_new(FALSE, 2);
- gtk_container_set_border_width(GTK_CONTAINER(hbox), 2);
- gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 2);
-
- button = xsane_button_new_with_pixmap(xsane.xsane_window->window, hbox, file_xpm, DESC_BROWSE_FILENAME,
- (GtkSignalFunc) xsane_browse_filename_callback, NULL);
- gtk_widget_add_accelerator(button, "clicked", xsane.accelerator_group, GDK_B, GDK_CONTROL_MASK, GTK_ACCEL_LOCKED);
-
- text = gtk_entry_new_with_max_length(255);
- gtk_widget_set_usize(text, 80, 0); /* set minimum size */
- xsane_back_gtk_set_tooltip(xsane.tooltips, text, DESC_FILENAME);
- gtk_entry_set_text(GTK_ENTRY(text), (char *) preferences.filename);
- gtk_box_pack_start(GTK_BOX(hbox), text, TRUE, TRUE, 4);
- gtk_signal_connect(GTK_OBJECT(text), "changed", (GtkSignalFunc) xsane_outputfilename_changed_callback, NULL);
-
- xsane.outputfilename_entry = text;
-
- gtk_widget_show(text);
- gtk_widget_show(hbox);
-
-
- /* second line: Step, Type */
-
- hbox = gtk_hbox_new(FALSE, 2);
- gtk_container_set_border_width(GTK_CONTAINER(hbox), 2);
- gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 2);
-
- /* filename counter step */
-
- xsane_label = gtk_label_new(TEXT_FILENAME_COUNTER_STEP);
- gtk_box_pack_start(GTK_BOX(hbox), xsane_label, FALSE, FALSE, 2);
- gtk_widget_show(xsane_label);
-
- xsane_filename_counter_step_option_menu = gtk_option_menu_new();
- xsane_back_gtk_set_tooltip(xsane.tooltips, xsane_filename_counter_step_option_menu, DESC_FILENAME_COUNTER_STEP);
- gtk_box_pack_start(GTK_BOX(hbox), xsane_filename_counter_step_option_menu, FALSE, FALSE, 2);
- gtk_widget_show(xsane_filename_counter_step_option_menu);
- gtk_widget_show(hbox);
-
- xsane_filename_counter_step_menu = gtk_menu_new();
-
- select_item = 0;
- j = -2;
- for (i=0; i < 5; i++)
- {
- snprintf(buf, sizeof(buf), "%+d", j);
- xsane_filename_counter_step_item = gtk_menu_item_new_with_label(buf);
- gtk_container_add(GTK_CONTAINER(xsane_filename_counter_step_menu), xsane_filename_counter_step_item);
- gtk_signal_connect(GTK_OBJECT(xsane_filename_counter_step_item), "activate",
- (GtkSignalFunc) xsane_filename_counter_step_callback, (void *) j);
- gtk_widget_show(xsane_filename_counter_step_item);
- if (preferences.filename_counter_step == j++)
- {
- select_item = i;
- }
- }
-
- gtk_option_menu_set_menu(GTK_OPTION_MENU(xsane_filename_counter_step_option_menu), xsane_filename_counter_step_menu);
- gtk_option_menu_set_history(GTK_OPTION_MENU(xsane_filename_counter_step_option_menu), select_item);
-
- /* filetype */
-
- xsane_filetype_menu = gtk_menu_new();
-
- xsane_filetype_item = gtk_menu_item_new_with_label(MENU_ITEM_FILETYPE_BY_EXT);
- gtk_container_add(GTK_CONTAINER(xsane_filetype_menu), xsane_filetype_item);
- gtk_signal_connect(GTK_OBJECT(xsane_filetype_item), "activate",
- (GtkSignalFunc) xsane_filetype_callback, NULL);
- gtk_widget_show(xsane_filetype_item);
- filetype_nr = 0;
- select_item = 0;
-
-#ifdef HAVE_LIBJPEG
- xsane_filetype_item = gtk_menu_item_new_with_label(MENU_ITEM_FILETYPE_JPEG);
- gtk_container_add(GTK_CONTAINER(xsane_filetype_menu), xsane_filetype_item);
- gtk_signal_connect(GTK_OBJECT(xsane_filetype_item), "activate",
- (GtkSignalFunc) xsane_filetype_callback, XSANE_FILETYPE_JPEG);
- gtk_widget_show(xsane_filetype_item);
- filetype_nr++;
- if ( (xsane.filetype) && (!strcasecmp(xsane.filetype, XSANE_FILETYPE_JPEG)) )
- {
- select_item = filetype_nr;
- }
-#endif
-
-#ifdef HAVE_LIBPNG
-#ifdef HAVE_LIBZ
- xsane_filetype_item = gtk_menu_item_new_with_label(MENU_ITEM_FILETYPE_PNG);
- gtk_container_add(GTK_CONTAINER(xsane_filetype_menu), xsane_filetype_item);
- gtk_signal_connect(GTK_OBJECT(xsane_filetype_item), "activate",
- (GtkSignalFunc) xsane_filetype_callback, XSANE_FILETYPE_PNG);
- gtk_widget_show(xsane_filetype_item);
- filetype_nr++;
- if ( (xsane.filetype) && (!strcasecmp(xsane.filetype, XSANE_FILETYPE_PNG)) )
- {
- select_item = filetype_nr;
- }
-#endif
-#endif
- xsane_filetype_item = gtk_menu_item_new_with_label(MENU_ITEM_FILETYPE_PNM);
- gtk_container_add(GTK_CONTAINER(xsane_filetype_menu), xsane_filetype_item);
- gtk_signal_connect(GTK_OBJECT(xsane_filetype_item), "activate",
- (GtkSignalFunc) xsane_filetype_callback, XSANE_FILETYPE_PNM);
- gtk_widget_show(xsane_filetype_item);
- filetype_nr++;
- if ( (xsane.filetype) && (!strcasecmp(xsane.filetype, XSANE_FILETYPE_PNM)) )
- {
- select_item = filetype_nr;
- }
-
- xsane_filetype_item = gtk_menu_item_new_with_label(MENU_ITEM_FILETYPE_PS);
- gtk_container_add(GTK_CONTAINER(xsane_filetype_menu), xsane_filetype_item);
- gtk_signal_connect(GTK_OBJECT(xsane_filetype_item), "activate",
- (GtkSignalFunc) xsane_filetype_callback, XSANE_FILETYPE_PS);
- gtk_widget_show(xsane_filetype_item);
- filetype_nr++;
- if ( (xsane.filetype) && (!strcasecmp(xsane.filetype, XSANE_FILETYPE_PS)) )
- {
- select_item = filetype_nr;
- }
-
- xsane_filetype_item = gtk_menu_item_new_with_label(MENU_ITEM_FILETYPE_RAW);
- gtk_container_add(GTK_CONTAINER(xsane_filetype_menu), xsane_filetype_item);
- gtk_signal_connect(GTK_OBJECT(xsane_filetype_item), "activate",
- (GtkSignalFunc) xsane_filetype_callback, XSANE_FILETYPE_RAW);
- gtk_widget_show(xsane_filetype_item);
- filetype_nr++;
- if ( (xsane.filetype) && (!strcasecmp(xsane.filetype, XSANE_FILETYPE_RAW)) )
- {
- select_item = filetype_nr;
- }
-
-#ifdef SUPPORT_RGBA
- xsane_filetype_item = gtk_menu_item_new_with_label(MENU_ITEM_FILETYPE_RGBA);
- gtk_container_add(GTK_CONTAINER(xsane_filetype_menu), xsane_filetype_item);
- gtk_signal_connect(GTK_OBJECT(xsane_filetype_item), "activate",
- (GtkSignalFunc) xsane_filetype_callback, XSANE_FILETYPE_RGBA);
- gtk_widget_show(xsane_filetype_item);
- filetype_nr++;
- if ( (xsane.filetype) && (!strcasecmp(xsane.filetype, XSANE_FILETYPE_RGBA)) )
- {
- select_item = filetype_nr;
- }
-#endif
-
-#ifdef HAVE_LIBTIFF
- xsane_filetype_item = gtk_menu_item_new_with_label(MENU_ITEM_FILETYPE_TIFF);
- gtk_container_add(GTK_CONTAINER(xsane_filetype_menu), xsane_filetype_item);
- gtk_signal_connect(GTK_OBJECT(xsane_filetype_item), "activate",
- (GtkSignalFunc) xsane_filetype_callback, XSANE_FILETYPE_TIFF);
- gtk_widget_show(xsane_filetype_item);
- filetype_nr++;
- if ( (xsane.filetype) && (!strcasecmp(xsane.filetype, XSANE_FILETYPE_TIFF)) )
+ /* make sure dialogs are rebuild, otherwise we can get in trouble */
+ while (gtk_events_pending())
{
- select_item = filetype_nr;
+ gtk_main_iteration();
}
-#endif
-
- xsane.filetype_option_menu = gtk_option_menu_new();
- xsane_back_gtk_set_tooltip(xsane.tooltips, xsane.filetype_option_menu, DESC_FILETYPE);
- gtk_box_pack_end(GTK_BOX(hbox), xsane.filetype_option_menu, FALSE, FALSE, 2);
- gtk_option_menu_set_menu(GTK_OPTION_MENU(xsane.filetype_option_menu), xsane_filetype_menu);
- gtk_option_menu_set_history(GTK_OPTION_MENU(xsane.filetype_option_menu), select_item);
- gtk_widget_show(xsane.filetype_option_menu);
-
- xsane_label = gtk_label_new(TEXT_FILETYPE); /* opposite order because of box_pack_end */
- gtk_box_pack_end(GTK_BOX(hbox), xsane_label, FALSE, FALSE, 2);
- gtk_widget_show(xsane_label);
-
- gtk_widget_show(text);
- gtk_widget_show(hbox);
}
/* ---------------------------------------------------------------------------------------------------------------------- */
@@ -1088,17 +582,8 @@ static void xsane_show_resolution_list_callback(GtkWidget *widget)
DBG(DBG_proc, "xsane_show_resolution_list_callback\n");
preferences.show_resolution_list = (GTK_CHECK_MENU_ITEM(widget)->active != 0);
- xsane_refresh_dialog();
-}
-
-/* ---------------------------------------------------------------------------------------------------------------------- */
-static void xsane_page_rotate_callback(GtkWidget *widget)
-{
- DBG(DBG_proc, "xsane_page_rotate_callback\n");
-
- preferences.psrotate = (GTK_CHECK_MENU_ITEM(widget)->active != 0);
- xsane_define_maximum_output_size();
+ xsane_refresh_dialog();
}
/* ---------------------------------------------------------------------------------------------------------------------- */
@@ -1141,6 +626,35 @@ static void xsane_show_gamma_callback(GtkWidget *widget)
/* ---------------------------------------------------------------------------------------------------------------------- */
+static void xsane_show_batch_scan_callback(GtkWidget * widget)
+{
+ DBG(DBG_proc, "xsane_show_batch_scan_callback\n");
+
+ preferences.show_batch_scan = (GTK_CHECK_MENU_ITEM(widget)->active != 0);
+ if (preferences.show_batch_scan)
+ {
+ gtk_widget_show(xsane.batch_scan_dialog);
+ }
+ else
+ {
+ gtk_widget_hide(xsane.batch_scan_dialog);
+ }
+}
+
+/* ---------------------------------------------------------------------------------------------------------------------- */
+
+static void xsane_paper_orientation_callback(GtkWidget *widget, gpointer data)
+{
+ int pos = (int) data;
+
+ DBG(DBG_proc, "xsane_paper_orientation_callback\n");
+
+ preferences.paper_orientation = pos;
+ xsane_define_maximum_output_size();
+}
+
+/* ---------------------------------------------------------------------------------------------------------------------- */
+
static void xsane_printer_callback(GtkWidget *widget, gpointer data)
{
int printer_resolution;
@@ -1182,32 +696,58 @@ static void xsane_printer_callback(GtkWidget *widget, gpointer data)
/* ---------------------------------------------------------------------------------------------------------------------- */
-static void xsane_resolution_scale_update(GtkAdjustment *adj_data, double *val)
+static gint xsane_resolution_timer_callback(GtkAdjustment *adj)
+{
+ if ((adj) && (!preferences.show_resolution_list)) /* make sure adjustment is valid */
+ {
+ float val = adj->value;
+
+ adj->value += 1.0; /* we need this to make sure that set_value really redraws the widgets */
+ gtk_adjustment_set_value(adj, val);
+ }
+
+ gtk_timeout_remove(xsane_resolution_timer);
+ xsane_resolution_timer = 0;
+
+ return 0; /* stop timeout */
+}
+
+/* ---------------------------------------------------------------------------------------------------------------------- */
+
+static void xsane_resolution_scale_update(GtkAdjustment *adj, double *val)
{
int printer_resolution;
-#if 1
/* gtk does not make sure that the value is quantisized correct */
float diff, old, new, quant;
DBG(DBG_proc, "xsane_resolution_scale_update\n");
- quant = adj_data->step_increment;
+ quant = adj->step_increment;
if (quant != 0)
{
- new = adj_data->value;
+ new = adj->value;
old = *val;
diff = quant*((int) ((new - old)/quant));
*val = old + diff;
- adj_data->value = *val;
- }
-#else
- DBG(DBG_proc, "xsane_resolution_scale_update\n");
+ adj->value = *val;
- *val = adj_data->value;
+#ifndef _WIN32
+ /* the resolution slider gets almost unusable when we do this with win32 */
+ if (xsane_resolution_timer)
+ {
+ gtk_timeout_remove(xsane_resolution_timer);
+ xsane_resolution_timer = 0;
+ }
+ xsane_resolution_timer = gtk_timeout_add(XSANE_HOLD_TIME, (GtkFunction) xsane_resolution_timer_callback, (gpointer) adj);
#endif
+ }
+ else
+ {
+ *val = adj->value;
+ }
switch (xsane.param.format)
{
@@ -1243,9 +783,9 @@ static void xsane_resolution_scale_update(GtkAdjustment *adj_data, double *val)
static void xsane_resolution_list_callback(GtkWidget *widget, gpointer data)
{
- GSGMenuItem *menu_item = data;
+ MenuItem *menu_item = data;
SANE_Word val;
- gchar *name = gtk_widget_get_name(widget->parent);
+ const gchar *name = gtk_widget_get_name(widget->parent);
int printer_resolution;
DBG(DBG_proc, "xsane_resolution_list_callback\n");
@@ -1367,8 +907,8 @@ static int xsane_resolution_widget_new(GtkWidget *parent, int well_known_option,
if (!preferences.show_resolution_list) /* user wants slider */
{
- xsane_scale_new_with_pixmap(xsane.xsane_window->window, GTK_BOX(parent), image_xpm, desc,
- min, max, quant, quant*10, 0, 0, resolution, &resolution_widget,
+ xsane_range_new_with_pixmap(xsane.xsane_window->window, GTK_BOX(parent), image_xpm, desc,
+ min, max, quant, quant*10, 0, resolution, &resolution_widget,
well_known_option, xsane_resolution_scale_update, SANE_OPTION_IS_SETTABLE(opt->cap));
}
else /* user wants list instead of slider */
@@ -1466,6 +1006,7 @@ static int xsane_resolution_widget_new(GtkWidget *parent, int well_known_option,
}
str_list[j] = 0;
xsane_control_option(xsane.dev, well_known_option, SANE_ACTION_GET_VALUE, &val, 0);
+ val = xsane_find_best_resolution(well_known_option, val); /* when backends uses default value not in list or range */
sprintf(str, "%d", (int) val);
break;
@@ -1477,6 +1018,7 @@ static int xsane_resolution_widget_new(GtkWidget *parent, int well_known_option,
}
str_list[j] = 0;
xsane_control_option(xsane.dev, well_known_option, SANE_ACTION_GET_VALUE, &val, 0);
+ val = xsane_find_best_resolution(well_known_option, val); /* when backends uses default value not in list or range */
sprintf(str, "%d", (int) SANE_UNFIX(val));
break;
@@ -1507,13 +1049,13 @@ static int xsane_resolution_widget_new(GtkWidget *parent, int well_known_option,
/* ---------------------------------------------------------------------------------------------------------------------- */
-static void xsane_zoom_update(GtkAdjustment *adj_data, double *val)
+static void xsane_zoom_update(GtkAdjustment *adj, double *val)
{
int printer_resolution;
DBG(DBG_proc, "xsane_zoom_update\n");
- *val=adj_data->value;
+ *val=adj->value;
switch (xsane.param.format)
{
@@ -1634,7 +1176,7 @@ static int xsane_zoom_widget_new(GtkWidget *parent, int well_known_option, doubl
*zoom = resolution / printer_resolution;
- xsane_scale_new_with_pixmap(xsane.xsane_window->window, GTK_BOX(parent), image_xpm, desc, min, max, 0.01, 0.1, 0.1, 2,
+ xsane_range_new_with_pixmap(xsane.xsane_window->window, GTK_BOX(parent), image_xpm, desc, min, max, 0.01, 0.1, 2,
zoom, &xsane.zoom_widget, well_known_option, xsane_zoom_update,
SANE_OPTION_IS_SETTABLE(opt->cap));
@@ -1647,8 +1189,8 @@ static int xsane_zoom_widget_new(GtkWidget *parent, int well_known_option, doubl
static void xsane_scanmode_menu_callback(GtkWidget *widget, gpointer data)
{
- GSGMenuItem *menu_item = data;
- GSGDialogElement *elem = menu_item->elem;
+ MenuItem *menu_item = data;
+ DialogElement *elem = menu_item->elem;
const SANE_Option_Descriptor *opt;
int opt_num;
int printer_resolution;
@@ -1713,7 +1255,7 @@ GtkWidget *xsane_update_xsane_callback() /* creates the XSane option window */
GtkWidget *xsane_hbox_xsane_enhancement;
GtkWidget *xsane_frame;
GtkWidget *button;
- gchar buf[200];
+ gchar buf[256];
DBG(DBG_proc, "xsane_update_xsane_callback\n");
@@ -1758,41 +1300,35 @@ GtkWidget *xsane_update_xsane_callback() /* creates the XSane option window */
xsane_modus_item = gtk_menu_item_new_with_label(MENU_ITEM_VIEWER);
- gtk_widget_add_accelerator(xsane_modus_item, "activate", xsane.accelerator_group, GDK_V, GDK_CONTROL_MASK, GTK_ACCEL_LOCKED);
- gtk_widget_lock_accelerators(xsane_modus_item);
- gtk_widget_set_usize(xsane_modus_item, 60, 0);
+ gtk_widget_add_accelerator(xsane_modus_item, "activate", xsane.accelerator_group, GDK_V, GDK_CONTROL_MASK, DEF_GTK_MENU_ACCEL_VISIBLE | DEF_GTK_ACCEL_LOCKED);
+ gtk_widget_set_size_request(xsane_modus_item, 60, -1);
gtk_container_add(GTK_CONTAINER(xsane_modus_menu), xsane_modus_item);
- gtk_signal_connect(GTK_OBJECT(xsane_modus_item), "activate",
- (GtkSignalFunc) xsane_modus_callback, &xsane_scanmode_number[XSANE_VIEWER]);
+ g_signal_connect(GTK_OBJECT(xsane_modus_item), "activate", (GtkSignalFunc) xsane_modus_callback, &xsane_scanmode_number[XSANE_VIEWER]);
gtk_widget_show(xsane_modus_item);
xsane_modus_item = gtk_menu_item_new_with_label(MENU_ITEM_SAVE);
- gtk_widget_add_accelerator(xsane_modus_item, "activate", xsane.accelerator_group, GDK_S, GDK_CONTROL_MASK, GTK_ACCEL_LOCKED);
+ gtk_widget_add_accelerator(xsane_modus_item, "activate", xsane.accelerator_group, GDK_S, GDK_CONTROL_MASK, DEF_GTK_MENU_ACCEL_VISIBLE | DEF_GTK_ACCEL_LOCKED);
gtk_container_add(GTK_CONTAINER(xsane_modus_menu), xsane_modus_item);
- gtk_signal_connect(GTK_OBJECT(xsane_modus_item), "activate",
- (GtkSignalFunc) xsane_modus_callback, &xsane_scanmode_number[XSANE_SAVE]);
+ g_signal_connect(GTK_OBJECT(xsane_modus_item), "activate", (GtkSignalFunc) xsane_modus_callback, &xsane_scanmode_number[XSANE_SAVE]);
gtk_widget_show(xsane_modus_item);
xsane_modus_item = gtk_menu_item_new_with_label(MENU_ITEM_COPY);
- gtk_widget_add_accelerator(xsane_modus_item, "activate", xsane.accelerator_group, GDK_C, GDK_CONTROL_MASK, GTK_ACCEL_LOCKED);
+ gtk_widget_add_accelerator(xsane_modus_item, "activate", xsane.accelerator_group, GDK_C, GDK_CONTROL_MASK, DEF_GTK_MENU_ACCEL_VISIBLE | DEF_GTK_ACCEL_LOCKED);
gtk_container_add(GTK_CONTAINER(xsane_modus_menu), xsane_modus_item);
- gtk_signal_connect(GTK_OBJECT(xsane_modus_item), "activate",
- (GtkSignalFunc) xsane_modus_callback, &xsane_scanmode_number[XSANE_COPY]);
+ g_signal_connect(GTK_OBJECT(xsane_modus_item), "activate", (GtkSignalFunc) xsane_modus_callback, &xsane_scanmode_number[XSANE_COPY]);
gtk_widget_show(xsane_modus_item);
xsane_modus_item = gtk_menu_item_new_with_label(MENU_ITEM_FAX);
- gtk_widget_add_accelerator(xsane_modus_item, "activate", xsane.accelerator_group, GDK_F, GDK_CONTROL_MASK, GTK_ACCEL_LOCKED);
+ gtk_widget_add_accelerator(xsane_modus_item, "activate", xsane.accelerator_group, GDK_F, GDK_CONTROL_MASK, DEF_GTK_MENU_ACCEL_VISIBLE | DEF_GTK_ACCEL_LOCKED);
gtk_container_add(GTK_CONTAINER(xsane_modus_menu), xsane_modus_item);
- gtk_signal_connect(GTK_OBJECT(xsane_modus_item), "activate",
- (GtkSignalFunc) xsane_modus_callback, &xsane_scanmode_number[XSANE_FAX]);
+ g_signal_connect(GTK_OBJECT(xsane_modus_item), "activate", (GtkSignalFunc) xsane_modus_callback, &xsane_scanmode_number[XSANE_FAX]);
gtk_widget_show(xsane_modus_item);
#ifdef XSANE_ACTIVATE_MAIL
xsane_modus_item = gtk_menu_item_new_with_label(MENU_ITEM_MAIL);
- gtk_widget_add_accelerator(xsane_modus_item, "activate", xsane.accelerator_group, GDK_M, GDK_CONTROL_MASK, GTK_ACCEL_LOCKED);
+ gtk_widget_add_accelerator(xsane_modus_item, "activate", xsane.accelerator_group, GDK_M, GDK_CONTROL_MASK, DEF_GTK_MENU_ACCEL_VISIBLE | DEF_GTK_ACCEL_LOCKED);
gtk_container_add(GTK_CONTAINER(xsane_modus_menu), xsane_modus_item);
- gtk_signal_connect(GTK_OBJECT(xsane_modus_item), "activate",
- (GtkSignalFunc) xsane_modus_callback, &xsane_scanmode_number[XSANE_MAIL]);
+ g_signal_connect(GTK_OBJECT(xsane_modus_item), "activate", (GtkSignalFunc) xsane_modus_callback, &xsane_scanmode_number[XSANE_MAIL]);
gtk_widget_show(xsane_modus_item);
#endif
@@ -1828,9 +1364,9 @@ GtkWidget *xsane_update_xsane_callback() /* creates the XSane option window */
gtk_box_pack_start(GTK_BOX(xsane_vbox_xsane_modus), hbox, FALSE, FALSE, 2);
pixmap = gdk_pixmap_create_from_xpm_d(xsane.histogram_dialog->window, &mask, xsane.bg_trans, (gchar **) colormode_xpm);
- pixmapwidget = gtk_pixmap_new(pixmap, mask);
+ pixmapwidget = gtk_image_new_from_pixmap(pixmap, mask);
gtk_box_pack_start(GTK_BOX(hbox), pixmapwidget, FALSE, FALSE, 2);
- gdk_pixmap_unref(pixmap);
+ gdk_drawable_unref(pixmap);
gtk_widget_show(pixmapwidget);
switch (opt->constraint_type)
@@ -1868,9 +1404,9 @@ GtkWidget *xsane_update_xsane_callback() /* creates the XSane option window */
gtk_box_pack_start(GTK_BOX(xsane_vbox_xsane_modus), hbox, FALSE, FALSE, 2);
pixmap = gdk_pixmap_create_from_xpm_d(xsane.histogram_dialog->window, &mask, xsane.bg_trans, (gchar **) scanner_xpm);
- pixmapwidget = gtk_pixmap_new(pixmap, mask);
+ pixmapwidget = gtk_image_new_from_pixmap(pixmap, mask);
gtk_box_pack_start(GTK_BOX(hbox), pixmapwidget, FALSE, FALSE, 2);
- gdk_pixmap_unref(pixmap);
+ gdk_drawable_unref(pixmap);
gtk_widget_show(pixmapwidget);
switch (opt->constraint_type)
@@ -1904,10 +1440,17 @@ GtkWidget *xsane_update_xsane_callback() /* creates the XSane option window */
gtk_container_set_border_width(GTK_CONTAINER(hbox), 2);
gtk_box_pack_start(GTK_BOX(xsane_vbox_xsane_modus), hbox, FALSE, FALSE, 2);
- pixmap = gdk_pixmap_create_from_xpm_d(xsane.histogram_dialog->window, &mask, xsane.bg_trans, (gchar **) medium_xpm);
- pixmapwidget = gtk_pixmap_new(pixmap, mask);
+ if (xsane.medium_calibration)
+ {
+ pixmap = gdk_pixmap_create_from_xpm_d(xsane.histogram_dialog->window, &mask, xsane.bg_trans, (gchar **) medium_edit_xpm);
+ }
+ else
+ {
+ pixmap = gdk_pixmap_create_from_xpm_d(xsane.histogram_dialog->window, &mask, xsane.bg_trans, (gchar **) medium_xpm);
+ }
+ pixmapwidget = gtk_image_new_from_pixmap(pixmap, mask);
gtk_box_pack_start(GTK_BOX(hbox), pixmapwidget, FALSE, FALSE, 2);
- gdk_pixmap_unref(pixmap);
+ gdk_drawable_unref(pixmap);
gtk_widget_show(pixmapwidget);
xsane_medium_menu = gtk_menu_new();
@@ -1916,7 +1459,10 @@ GtkWidget *xsane_update_xsane_callback() /* creates the XSane option window */
{
xsane_medium_item = gtk_menu_item_new_with_label(preferences.medium[i]->name);
gtk_menu_append(GTK_MENU(xsane_medium_menu), xsane_medium_item);
- gtk_signal_connect(GTK_OBJECT(xsane_medium_item), "activate", (GtkSignalFunc) xsane_set_medium_callback, (void *)i);
+ g_signal_connect(GTK_OBJECT(xsane_medium_item), "button_press_event", (GtkSignalFunc) xsane_medium_context_menu_callback, (void *) i);
+ g_signal_connect(GTK_OBJECT(xsane_medium_item), "activate", (GtkSignalFunc) xsane_set_medium_callback, (void *) i);
+ gtk_object_set_data(GTK_OBJECT(xsane_medium_item), "Selection", (void *) i);
+
gtk_widget_show(xsane_medium_item);
}
@@ -1932,7 +1478,15 @@ GtkWidget *xsane_update_xsane_callback() /* creates the XSane option window */
xsane.medium_widget = xsane_medium_option_menu;
- xsane_set_medium(preferences.medium[xsane.medium_nr]); /* set selected medium */
+ if (xsane.medium_calibration) /* are we running in medium calibration mode? */
+ {
+ xsane_apply_medium_definition_as_enhancement(preferences.medium[xsane.medium_nr]);
+ xsane_set_medium(NULL);
+ }
+ else
+ {
+ xsane_set_medium(preferences.medium[xsane.medium_nr]);
+ }
}
else /* no medium selextion for lineart mode: use Full range gamma curve */
{
@@ -1971,6 +1525,7 @@ GtkWidget *xsane_update_xsane_callback() /* creates the XSane option window */
GtkWidget *pixmapwidget, *hbox, *xsane_printer_option_menu, *xsane_printer_menu, *xsane_printer_item;
GdkBitmap *mask;
GdkPixmap *pixmap;
+ GtkWidget *paper_orientation_option_menu, *paper_orientation_menu, *paper_orientation_item;
int i;
hbox = gtk_hbox_new(FALSE, 2);
@@ -1978,11 +1533,102 @@ GtkWidget *xsane_update_xsane_callback() /* creates the XSane option window */
gtk_box_pack_start(GTK_BOX(xsane_vbox_xsane_modus), hbox, FALSE, FALSE, 2);
pixmap = gdk_pixmap_create_from_xpm_d(xsane.histogram_dialog->window, &mask, xsane.bg_trans, (gchar **) printer_xpm);
- pixmapwidget = gtk_pixmap_new(pixmap, mask);
+ pixmapwidget = gtk_image_new_from_pixmap(pixmap, mask);
gtk_box_pack_start(GTK_BOX(hbox), pixmapwidget, FALSE, FALSE, 2);
- gdk_pixmap_unref(pixmap);
+ gdk_drawable_unref(pixmap);
gtk_widget_show(pixmapwidget);
+
+ /* printer position */
+ paper_orientation_menu = gtk_menu_new();
+
+ for (i = 0; i <= 12; ++i)
+ {
+ gchar **xpm_d;
+
+ if (i == 5) /* 5, 6, 7 are not used */
+ {
+ i = 8;
+ }
+
+ switch (i)
+ {
+ /* portrait */
+ default:
+ case 0:
+ xpm_d = (gchar **) paper_orientation_portrait_top_left_xpm;
+ break;
+
+ case 1:
+ xpm_d = (gchar **) paper_orientation_portrait_top_right_xpm;
+ break;
+
+ case 2:
+ xpm_d = (gchar **) paper_orientation_portrait_bottom_right_xpm;
+ break;
+
+ case 3:
+ xpm_d = (gchar **) paper_orientation_portrait_bottom_left_xpm;
+ break;
+
+ case 4:
+ xpm_d = (gchar **) paper_orientation_portrait_center_xpm;
+ break;
+
+ /* landscape */
+ case 8:
+ xpm_d = (gchar **) paper_orientation_landscape_top_left_xpm;
+ break;
+
+ case 9:
+ xpm_d = (gchar **) paper_orientation_landscape_top_right_xpm;
+ break;
+
+ case 10:
+ xpm_d = (gchar **) paper_orientation_landscape_bottom_right_xpm;
+ break;
+
+ case 11:
+ xpm_d = (gchar **) paper_orientation_landscape_bottom_left_xpm;
+ break;
+
+ case 12:
+ xpm_d = (gchar **) paper_orientation_landscape_center_xpm;
+ break;
+ }
+
+ paper_orientation_item = gtk_menu_item_new();
+ pixmap = gdk_pixmap_create_from_xpm_d(xsane.histogram_dialog->window, &mask, xsane.bg_trans, xpm_d);
+ pixmapwidget = gtk_image_new_from_pixmap(pixmap, mask);
+ gtk_container_add(GTK_CONTAINER(paper_orientation_item), pixmapwidget);
+ gtk_widget_show(pixmapwidget);
+ gdk_drawable_unref(pixmap);
+
+
+ gtk_container_add(GTK_CONTAINER(paper_orientation_menu), paper_orientation_item);
+ g_signal_connect(GTK_OBJECT(paper_orientation_item), "activate", (GtkSignalFunc) xsane_paper_orientation_callback, (void *) i);
+
+ gtk_widget_show(paper_orientation_item);
+ }
+
+ paper_orientation_option_menu = gtk_option_menu_new();
+ xsane_back_gtk_set_tooltip(xsane.tooltips, paper_orientation_option_menu, DESC_PAPER_ORIENTATION);
+ gtk_box_pack_end(GTK_BOX(hbox), paper_orientation_option_menu, FALSE, FALSE, 0);
+ gtk_option_menu_set_menu(GTK_OPTION_MENU(paper_orientation_option_menu), paper_orientation_menu);
+
+ /* set default selection */
+ if (preferences.paper_orientation < 8) /* portrai number is correct */
+ {
+ gtk_option_menu_set_history(GTK_OPTION_MENU(paper_orientation_option_menu), preferences.paper_orientation);
+ }
+ else /* numbers 5, 6, 7 are unused, so we have to substract 3 for landscape mode */
+ {
+ gtk_option_menu_set_history(GTK_OPTION_MENU(paper_orientation_option_menu), preferences.paper_orientation-3);
+ }
+
+ gtk_widget_show(paper_orientation_option_menu);
+
+
xsane_printer_menu = gtk_menu_new();
for (i=0; i < preferences.printerdefinitions; i++)
@@ -1991,10 +1637,10 @@ GtkWidget *xsane_update_xsane_callback() /* creates the XSane option window */
if (i<12)
{
gtk_widget_add_accelerator(xsane_printer_item, "activate", xsane.accelerator_group,
- GDK_F1+i, GDK_SHIFT_MASK, GTK_ACCEL_LOCKED);
+ GDK_F1+i, GDK_SHIFT_MASK, DEF_GTK_MENU_ACCEL_VISIBLE | DEF_GTK_ACCEL_LOCKED);
}
gtk_container_add(GTK_CONTAINER(xsane_printer_menu), xsane_printer_item);
- gtk_signal_connect(GTK_OBJECT(xsane_printer_item), "activate", (GtkSignalFunc) xsane_printer_callback, (void *) i);
+ g_signal_connect(GTK_OBJECT(xsane_printer_item), "activate", (GtkSignalFunc) xsane_printer_callback, (void *) i);
gtk_widget_show(xsane_printer_item);
}
@@ -2010,7 +1656,7 @@ GtkWidget *xsane_update_xsane_callback() /* creates the XSane option window */
/* number of copies */
xsane_text = gtk_entry_new();
xsane_back_gtk_set_tooltip(xsane.tooltips, xsane_text, DESC_COPY_NUMBER);
- gtk_widget_set_usize(xsane_text, 25, 0);
+ gtk_widget_set_size_request(xsane_text, 25, -1);
snprintf(buf, sizeof(buf), "%d", xsane.copy_number);
gtk_entry_set_text(GTK_ENTRY(xsane_text), (char *) buf);
gtk_box_pack_end(GTK_BOX(hbox), xsane_text, FALSE, FALSE, 10);
@@ -2107,8 +1753,8 @@ GtkWidget *xsane_update_xsane_callback() /* creates the XSane option window */
case XSANE_LINEART_XSANE:
if (xsane.well_known.threshold > 0)
{
- xsane_scale_new_with_pixmap(xsane.xsane_window->window, GTK_BOX(xsane_vbox_xsane_modus), threshold_xpm, DESC_THRESHOLD,
- xsane.threshold_min, xsane.threshold_max, 1.0, 10.0, 0.0, 0,
+ xsane_range_new_with_pixmap(xsane.xsane_window->window, GTK_BOX(xsane_vbox_xsane_modus), threshold_xpm, DESC_THRESHOLD,
+ xsane.threshold_min, xsane.threshold_max, 1.0, 10.0, 0,
&xsane.threshold, &xsane.threshold_widget, 0, xsane_gamma_changed, TRUE);
xsane_threshold_changed();
}
@@ -2128,55 +1774,55 @@ GtkWidget *xsane_update_xsane_callback() /* creates the XSane option window */
xsane_separator_new(xsane_vbox_xsane_modus, 2);
}
- xsane_scale_new_with_pixmap(xsane.xsane_window->window, GTK_BOX(xsane_vbox_xsane_modus), Gamma_xpm, DESC_GAMMA,
- XSANE_GAMMA_MIN, XSANE_GAMMA_MAX, 0.01, 0.1, 0.0, 2,
+ xsane_range_new_with_pixmap(xsane.xsane_window->window, GTK_BOX(xsane_vbox_xsane_modus), Gamma_xpm, DESC_GAMMA,
+ XSANE_GAMMA_MIN, XSANE_GAMMA_MAX, 0.01, 0.1, 2,
&xsane.gamma, &xsane.gamma_widget, 0, xsane_gamma_changed, TRUE);
if ( (xsane.xsane_colors > 1) && (!xsane.enhancement_rgb_default) )
{
- xsane_scale_new_with_pixmap(xsane.xsane_window->window, GTK_BOX(xsane_vbox_xsane_modus), Gamma_red_xpm, DESC_GAMMA_R,
- XSANE_GAMMA_MIN, XSANE_GAMMA_MAX, 0.01, 0.1, 0.0, 2,
+ xsane_range_new_with_pixmap(xsane.xsane_window->window, GTK_BOX(xsane_vbox_xsane_modus), Gamma_red_xpm, DESC_GAMMA_R,
+ XSANE_GAMMA_MIN, XSANE_GAMMA_MAX, 0.01, 0.1, 2,
&xsane.gamma_red , &xsane.gamma_red_widget, 0, xsane_gamma_changed, TRUE);
- xsane_scale_new_with_pixmap(xsane.xsane_window->window, GTK_BOX(xsane_vbox_xsane_modus), Gamma_green_xpm, DESC_GAMMA_G,
- XSANE_GAMMA_MIN, XSANE_GAMMA_MAX, 0.01, 0.1, 0.0, 2,
+ xsane_range_new_with_pixmap(xsane.xsane_window->window, GTK_BOX(xsane_vbox_xsane_modus), Gamma_green_xpm, DESC_GAMMA_G,
+ XSANE_GAMMA_MIN, XSANE_GAMMA_MAX, 0.01, 0.1, 2,
&xsane.gamma_green, &xsane.gamma_green_widget, 0, xsane_gamma_changed, TRUE);
- xsane_scale_new_with_pixmap(xsane.xsane_window->window, GTK_BOX(xsane_vbox_xsane_modus), Gamma_blue_xpm, DESC_GAMMA_B,
- XSANE_GAMMA_MIN, XSANE_GAMMA_MAX, 0.01, 0.1, 0.0, 2,
+ xsane_range_new_with_pixmap(xsane.xsane_window->window, GTK_BOX(xsane_vbox_xsane_modus), Gamma_blue_xpm, DESC_GAMMA_B,
+ XSANE_GAMMA_MIN, XSANE_GAMMA_MAX, 0.01, 0.1, 2,
&xsane.gamma_blue , &xsane.gamma_blue_widget, 0, xsane_gamma_changed, TRUE);
xsane_separator_new(xsane_vbox_xsane_modus, 2);
}
- xsane_scale_new_with_pixmap(xsane.xsane_window->window, GTK_BOX(xsane_vbox_xsane_modus), brightness_xpm, DESC_BRIGHTNESS,
- xsane.brightness_min, xsane.brightness_max, 1.0, 10.0, 0.0, 0,
+ xsane_range_new_with_pixmap(xsane.xsane_window->window, GTK_BOX(xsane_vbox_xsane_modus), brightness_xpm, DESC_BRIGHTNESS,
+ xsane.brightness_min, xsane.brightness_max, 0.1, 1.0, 1,
&xsane.brightness, &xsane.brightness_widget, 0, xsane_gamma_changed, TRUE);
if ( (xsane.xsane_colors > 1) && (!xsane.enhancement_rgb_default) )
{
- xsane_scale_new_with_pixmap(xsane.xsane_window->window, GTK_BOX(xsane_vbox_xsane_modus), brightness_red_xpm, DESC_BRIGHTNESS_R,
- xsane.brightness_min, xsane.brightness_max, 1.0, 10.0, 0.0, 0,
+ xsane_range_new_with_pixmap(xsane.xsane_window->window, GTK_BOX(xsane_vbox_xsane_modus), brightness_red_xpm, DESC_BRIGHTNESS_R,
+ xsane.brightness_min, xsane.brightness_max, 0.1, 1.0, 1,
&xsane.brightness_red , &xsane.brightness_red_widget, 0, xsane_gamma_changed, TRUE);
- xsane_scale_new_with_pixmap(xsane.xsane_window->window, GTK_BOX(xsane_vbox_xsane_modus), brightness_green_xpm, DESC_BRIGHTNESS_G,
- xsane.brightness_min, xsane.brightness_max, 1.0, 10.0, 0.0, 0,
+ xsane_range_new_with_pixmap(xsane.xsane_window->window, GTK_BOX(xsane_vbox_xsane_modus), brightness_green_xpm, DESC_BRIGHTNESS_G,
+ xsane.brightness_min, xsane.brightness_max, 0.1, 1.0, 1,
&xsane.brightness_green, &xsane.brightness_green_widget, 0, xsane_gamma_changed, TRUE);
- xsane_scale_new_with_pixmap(xsane.xsane_window->window, GTK_BOX(xsane_vbox_xsane_modus), brightness_blue_xpm, DESC_BRIGHTNESS_B,
- xsane.brightness_min, xsane.brightness_max, 1.0, 10.0, 0.0, 0,
+ xsane_range_new_with_pixmap(xsane.xsane_window->window, GTK_BOX(xsane_vbox_xsane_modus), brightness_blue_xpm, DESC_BRIGHTNESS_B,
+ xsane.brightness_min, xsane.brightness_max, 0.1, 1.0, 1,
&xsane.brightness_blue, &xsane.brightness_blue_widget, 0, xsane_gamma_changed, TRUE);
xsane_separator_new(xsane_vbox_xsane_modus, 2);
}
- xsane_scale_new_with_pixmap(xsane.xsane_window->window, GTK_BOX(xsane_vbox_xsane_modus), contrast_xpm, DESC_CONTRAST,
- xsane.contrast_gray_min, xsane.contrast_max, 1.0, 10.0, 0.0, 0,
+ xsane_range_new_with_pixmap(xsane.xsane_window->window, GTK_BOX(xsane_vbox_xsane_modus), contrast_xpm, DESC_CONTRAST,
+ xsane.contrast_gray_min, xsane.contrast_max, 0.1, 1.0, 1,
&xsane.contrast, &xsane.contrast_widget, 0, xsane_gamma_changed, TRUE);
if ( (xsane.xsane_colors > 1) && (!xsane.enhancement_rgb_default) )
{
- xsane_scale_new_with_pixmap(xsane.xsane_window->window, GTK_BOX(xsane_vbox_xsane_modus), contrast_red_xpm, DESC_CONTRAST_R,
- xsane.contrast_min, xsane.contrast_max, 1.0, 10.0, 0.0, 0,
+ xsane_range_new_with_pixmap(xsane.xsane_window->window, GTK_BOX(xsane_vbox_xsane_modus), contrast_red_xpm, DESC_CONTRAST_R,
+ xsane.contrast_min, xsane.contrast_max, 0.1, 1.0, 1,
&xsane.contrast_red , &xsane.contrast_red_widget, 0, xsane_gamma_changed, TRUE);
- xsane_scale_new_with_pixmap(xsane.xsane_window->window, GTK_BOX(xsane_vbox_xsane_modus), contrast_green_xpm, DESC_CONTRAST_G,
- xsane.contrast_min, xsane.contrast_max, 1.0, 10.0, 0.0, 0,
+ xsane_range_new_with_pixmap(xsane.xsane_window->window, GTK_BOX(xsane_vbox_xsane_modus), contrast_green_xpm, DESC_CONTRAST_G,
+ xsane.contrast_min, xsane.contrast_max, 0.1, 1.0, 1,
&xsane.contrast_green, &xsane.contrast_green_widget, 0, xsane_gamma_changed, TRUE);
- xsane_scale_new_with_pixmap(xsane.xsane_window->window, GTK_BOX(xsane_vbox_xsane_modus), contrast_blue_xpm, DESC_CONTRAST_B,
- xsane.contrast_min, xsane.contrast_max, 1.0, 10.0, 0.0, 0,
+ xsane_range_new_with_pixmap(xsane.xsane_window->window, GTK_BOX(xsane_vbox_xsane_modus), contrast_blue_xpm, DESC_CONTRAST_B,
+ xsane.contrast_min, xsane.contrast_max, 0.1, 1.0, 1,
&xsane.contrast_blue, &xsane.contrast_blue_widget, 0, xsane_gamma_changed, TRUE);
}
@@ -2192,36 +1838,31 @@ GtkWidget *xsane_update_xsane_callback() /* creates the XSane option window */
{
button = xsane_toggle_button_new_with_pixmap(xsane.xsane_window->window, xsane_hbox_xsane_enhancement, rgb_default_xpm, DESC_RGB_DEFAULT,
&xsane.enhancement_rgb_default, xsane_enhancement_rgb_default_callback);
- gtk_widget_add_accelerator(button, "clicked", xsane.accelerator_group, GDK_B, GDK_SHIFT_MASK, GTK_ACCEL_LOCKED);
+ gtk_widget_add_accelerator(button, "clicked", xsane.accelerator_group, GDK_B, GDK_CONTROL_MASK, DEF_GTK_ACCEL_LOCKED);
}
button = xsane_toggle_button_new_with_pixmap(xsane.xsane_window->window, xsane_hbox_xsane_enhancement, negative_xpm, DESC_NEGATIVE,
&xsane.negative, xsane_enhancement_negative_callback);
- gtk_widget_add_accelerator(button, "clicked", xsane.accelerator_group, GDK_N, GDK_SHIFT_MASK, GTK_ACCEL_LOCKED);
+ gtk_widget_add_accelerator(button, "clicked", xsane.accelerator_group, GDK_N, GDK_CONTROL_MASK, DEF_GTK_ACCEL_LOCKED);
button = xsane_button_new_with_pixmap(xsane.xsane_window->window, xsane_hbox_xsane_enhancement, enhance_xpm, DESC_ENH_AUTO,
xsane_auto_enhancement_callback, NULL);
- gtk_widget_add_accelerator(button, "clicked", xsane.accelerator_group, GDK_E, GDK_SHIFT_MASK, GTK_ACCEL_LOCKED);
+ gtk_widget_add_accelerator(button, "clicked", xsane.accelerator_group, GDK_E, GDK_CONTROL_MASK, DEF_GTK_ACCEL_LOCKED);
button = xsane_button_new_with_pixmap(xsane.xsane_window->window, xsane_hbox_xsane_enhancement, default_enhancement_xpm, DESC_ENH_DEFAULT,
xsane_enhancement_restore_default, NULL);
- gtk_widget_add_accelerator(button, "clicked", xsane.accelerator_group, GDK_D, GDK_SHIFT_MASK, GTK_ACCEL_LOCKED);
-
- button = xsane_button_new_with_pixmap(xsane.xsane_window->window, xsane_hbox_xsane_enhancement, restore_enhancement_xpm, DESC_ENH_RESTORE,
- xsane_enhancement_restore, NULL);
- gtk_widget_add_accelerator(button, "clicked", xsane.accelerator_group, GDK_R, GDK_SHIFT_MASK, GTK_ACCEL_LOCKED);
+ gtk_widget_add_accelerator(button, "clicked", xsane.accelerator_group, GDK_0, GDK_CONTROL_MASK, DEF_GTK_ACCEL_LOCKED);
- button = xsane_button_new_with_pixmap(xsane.xsane_window->window, xsane_hbox_xsane_enhancement, store_enhancement_xpm, DESC_ENH_STORE,
- xsane_enhancement_store, NULL);
- gtk_widget_add_accelerator(button, "clicked", xsane.accelerator_group, GDK_M, GDK_SHIFT_MASK, GTK_ACCEL_LOCKED);
- if (xsane.medium_calibration) /* are we running in medium calibration mode? */
+ if (!xsane.medium_calibration) /* do not display "M R" when we are we running in medium calibration mode */
{
- button = xsane_button_new_with_pixmap(xsane.xsane_window->window, xsane_hbox_xsane_enhancement, medium_xpm, DESC_STORE_MEDIUM,
- xsane_add_medium_definition_callback, NULL);
+ button = xsane_button_new_with_pixmap(xsane.xsane_window->window, xsane_hbox_xsane_enhancement, restore_enhancement_xpm, DESC_ENH_RESTORE,
+ xsane_enhancement_restore, NULL);
+ gtk_widget_add_accelerator(button, "clicked", xsane.accelerator_group, GDK_R, GDK_CONTROL_MASK, DEF_GTK_ACCEL_LOCKED);
- button = xsane_button_new_with_pixmap(xsane.xsane_window->window, xsane_hbox_xsane_enhancement, medium_delete_xpm, DESC_DELETE_MEDIUM,
- xsane_delete_medium_definition_callback, NULL);
+ button = xsane_button_new_with_pixmap(xsane.xsane_window->window, xsane_hbox_xsane_enhancement, store_enhancement_xpm, DESC_ENH_STORE,
+ xsane_enhancement_store, NULL);
+ gtk_widget_add_accelerator(button, "clicked", xsane.accelerator_group, GDK_plus, GDK_CONTROL_MASK, DEF_GTK_ACCEL_LOCKED);
}
xsane_update_histogram(TRUE /* update raw */);
@@ -2321,33 +1962,6 @@ static int xsane_pref_restore(void)
}
}
- if (!preferences.medium_definitions)
- {
- DBG(DBG_info, "no medium definitions in preferences file, using predefined list\n");
-
- preferences.medium_definitions = sizeof(pref_default_medium)/sizeof(Preferences_medium_t);
- preferences.medium = calloc(preferences.medium_definitions, sizeof(void *));
-
- for (i=0; i<preferences.medium_definitions; i++)
- {
- preferences.medium[i] = calloc(sizeof(Preferences_medium_t), 1);
- preferences.medium[i]->name = strdup(_(pref_default_medium[i].name));
- preferences.medium[i]->shadow_gray = pref_default_medium[i].shadow_gray;
- preferences.medium[i]->shadow_red = pref_default_medium[i].shadow_red;
- preferences.medium[i]->shadow_green = pref_default_medium[i].shadow_green;
- preferences.medium[i]->shadow_blue = pref_default_medium[i].shadow_blue;
- preferences.medium[i]->highlight_gray = pref_default_medium[i].highlight_gray;
- preferences.medium[i]->highlight_red = pref_default_medium[i].highlight_red;
- preferences.medium[i]->highlight_green = pref_default_medium[i].highlight_green;
- preferences.medium[i]->highlight_blue = pref_default_medium[i].highlight_blue;
- preferences.medium[i]->gamma_gray = pref_default_medium[i].gamma_gray;
- preferences.medium[i]->gamma_red = pref_default_medium[i].gamma_red;
- preferences.medium[i]->gamma_green = pref_default_medium[i].gamma_green;
- preferences.medium[i]->gamma_blue = pref_default_medium[i].gamma_blue;
- preferences.medium[i]->negative = pref_default_medium[i].negative;
- }
- }
-
if (preferences.xsane_version_str)
{
free(preferences.xsane_version_str);
@@ -2369,11 +1983,30 @@ static int xsane_pref_restore(void)
}
}
+ if (!preferences.working_directory)
+ {
+ char filename[PATH_MAX];
+
+ if (getcwd(filename, sizeof(filename)))
+ {
+ preferences.working_directory = strdup(filename); /* set current working directory */
+ }
+ }
+ else
+ {
+ chdir(preferences.working_directory); /* set working directory */
+ }
+
if (!preferences.filename)
{
preferences.filename = strdup(OUT_FILENAME);
}
+ if (!preferences.filetype)
+ {
+ preferences.filetype = strdup(XSANE_FILETYPE_BY_EXT);
+ }
+
if (preferences.printerdefinitions == 0)
{
xsane_new_printer();
@@ -2414,7 +2047,6 @@ static int xsane_pref_restore(void)
preferences.fax_viewer = strdup(FAXVIEWER);
}
-
#ifdef XSANE_ACTIVATE_MAIL
if (!preferences.mail_smtp_server)
{
@@ -2455,6 +2087,11 @@ static int xsane_pref_restore(void)
{
preferences.mail_viewer = strdup(MAILVIEWER);
}
+
+ if (!preferences.mail_filetype)
+ {
+ preferences.mail_filetype = strdup(XSANE_DEFAULT_MAILTYPE);
+ }
#endif
if (!preferences.ocr_command)
@@ -2472,9 +2109,26 @@ static int xsane_pref_restore(void)
preferences.ocr_outputfile_option = strdup(OCROUTPUTFILEOPT);
}
- if (!preferences.doc_viewer)
+ if (!preferences.ocr_gui_outfd_option)
{
- preferences.doc_viewer = strdup(DOCVIEWER);
+ preferences.ocr_gui_outfd_option = strdup(OCROUTFDOPT);
+ }
+
+ if (!preferences.ocr_progress_keyword)
+ {
+ preferences.ocr_progress_keyword = strdup(OCRPROGRESSKEY);
+ }
+
+ if (!preferences.browser)
+ {
+ if (getenv(STRINGIFY(ENVIRONMENT_BROWSER_NAME)))
+ {
+ preferences.browser = getenv(STRINGIFY(ENVIRONMENT_BROWSER_NAME));
+ }
+ else
+ {
+ preferences.browser = strdup(DEFAULT_BROWSER);
+ }
}
return result;
@@ -2482,6 +2136,82 @@ static int xsane_pref_restore(void)
/* ---------------------------------------------------------------------------------------------------------------------- */
+void xsane_pref_save_media(void)
+{
+ char filename[PATH_MAX];
+ int fd;
+
+ DBG(DBG_proc, "xsane_pref_save_media\n");
+
+ xsane_back_gtk_make_path(sizeof(filename), filename, "xsane", NULL, "xsane", NULL, ".mdf", XSANE_PATH_LOCAL_SANE);
+
+ DBG(DBG_info2, "saving media to \"%s\"\n", filename);
+
+ umask(XSANE_DEFAULT_UMASK); /* define new file permissions */
+ fd = open(filename, O_WRONLY | O_CREAT | O_TRUNC, 0600); /* rw- --- --- */
+
+ if (fd < 0)
+ {
+ char buf[256];
+
+ snprintf(buf, sizeof(buf), "%s %s.", ERR_FAILED_CREATE_FILE, strerror(errno));
+ xsane_back_gtk_error(buf, TRUE);
+ return;
+ }
+ preferences_save_media(fd);
+ close(fd);
+}
+/* ---------------------------------------------------------------------------------------------------------------------- */
+
+static void xsane_pref_restore_media(void)
+{
+ char filename[PATH_MAX];
+ int fd;
+ int i;
+
+ DBG(DBG_proc, "xsane_pref_restore_media\n");
+
+ preferences.medium_definitions = 0;
+
+ xsane_back_gtk_make_path(sizeof(filename), filename, "xsane", NULL, "xsane", NULL, ".mdf", XSANE_PATH_LOCAL_SANE);
+ fd = open(filename, O_RDONLY);
+
+ if (fd >= 0)
+ {
+ preferences_restore_media(fd);
+ close(fd);
+ }
+
+ if (!preferences.medium_definitions)
+ {
+ DBG(DBG_info, "no medium definitions found, using predefined list\n");
+
+ preferences.medium_definitions = sizeof(pref_default_medium)/sizeof(Preferences_medium_t);
+ preferences.medium = calloc(preferences.medium_definitions, sizeof(void *));
+
+ for (i=0; i<preferences.medium_definitions; i++)
+ {
+ preferences.medium[i] = calloc(sizeof(Preferences_medium_t), 1);
+ preferences.medium[i]->name = strdup(_(pref_default_medium[i].name));
+ preferences.medium[i]->shadow_gray = pref_default_medium[i].shadow_gray;
+ preferences.medium[i]->shadow_red = pref_default_medium[i].shadow_red;
+ preferences.medium[i]->shadow_green = pref_default_medium[i].shadow_green;
+ preferences.medium[i]->shadow_blue = pref_default_medium[i].shadow_blue;
+ preferences.medium[i]->highlight_gray = pref_default_medium[i].highlight_gray;
+ preferences.medium[i]->highlight_red = pref_default_medium[i].highlight_red;
+ preferences.medium[i]->highlight_green = pref_default_medium[i].highlight_green;
+ preferences.medium[i]->highlight_blue = pref_default_medium[i].highlight_blue;
+ preferences.medium[i]->gamma_gray = pref_default_medium[i].gamma_gray;
+ preferences.medium[i]->gamma_red = pref_default_medium[i].gamma_red;
+ preferences.medium[i]->gamma_green = pref_default_medium[i].gamma_green;
+ preferences.medium[i]->gamma_blue = pref_default_medium[i].gamma_blue;
+ preferences.medium[i]->negative = pref_default_medium[i].negative;
+ }
+ }
+}
+
+/* ---------------------------------------------------------------------------------------------------------------------- */
+
static RETSIGTYPE xsane_quit_handler(int signal)
{
DBG(DBG_proc, "xsane_quit_handler\n");
@@ -2489,6 +2219,60 @@ static RETSIGTYPE xsane_quit_handler(int signal)
xsane_quit();
}
+/* ---------------------------------------------------------------------------------------------------------------------- */
+
+void xsane_add_process_to_list(pid_t pid)
+{
+ XsaneChildprocess *newprocess;
+
+ DBG(DBG_proc, "xsane_add_process_to_list(%d)\n", pid);
+
+ newprocess = malloc(sizeof(XsaneChildprocess));
+ newprocess->pid = pid;
+ newprocess->next = xsane.childprocess_list;
+ xsane.childprocess_list = newprocess;
+}
+
+/* ---------------------------------------------------------------------------------------------------------------------- */
+
+static RETSIGTYPE xsane_sigchld_handler(int signal)
+{
+ int status;
+ XsaneChildprocess **childprocess_listptr = &xsane.childprocess_list;
+ XsaneChildprocess *childprocess = xsane.childprocess_list;
+
+ DBG(DBG_proc, "xsane_sigchld_handler\n");
+
+ /* normally we would do a wait(&status); here, but some backends fork() a reader
+ process and test the return status of waitpid() that returns with an error
+ when we get the signal at first and clean up the process with wait().
+ A backend should not handle this as error but some do and so we have to handle this */
+
+ while (childprocess)
+ {
+ XsaneChildprocess *nextprocess;
+ pid_t pid;
+
+ pid = waitpid(childprocess->pid, &status, WNOHANG);
+ if ( (WIFEXITED(status)) && (pid == childprocess->pid) )
+ {
+ DBG(DBG_info, "deleteing pid %d from list\n", childprocess->pid);
+
+ nextprocess = childprocess->next;
+ free(childprocess); /* free memory of element */
+ childprocess = nextprocess; /* go to next element */
+ *childprocess_listptr = childprocess; /* remove element from list */
+ /* childprocess_listptr keeps the same !!! */
+ }
+ else
+ {
+ DBG(DBG_info, "keeping pid %d in list\n", childprocess->pid);
+
+ childprocess_listptr = &childprocess->next; /* set pointer to next element */
+ childprocess = childprocess->next; /* go to next element */
+ }
+ }
+}
/* ---------------------------------------------------------------------------------------------------------------------- */
@@ -2548,7 +2332,7 @@ static void xsane_quit(void)
xsane.preview_gamma_data_blue = 0;
}
-#ifdef HAVE_LIBGIMP_GIMP_H
+#ifdef HAVE_ANY_GIMP
if (xsane.mode == XSANE_GIMP_EXTENSION)
{
gimp_quit();
@@ -2577,7 +2361,7 @@ static void xsane_exit(void) /* this is called when xsane exits before gtk_main
sane_exit();
-#ifdef HAVE_LIBGIMP_GIMP_H
+#ifdef HAVE_ANY_GIMP
if (xsane.mode == XSANE_GIMP_EXTENSION)
{
gimp_quit();
@@ -2642,18 +2426,8 @@ static gint xsane_scan_win_delete(GtkWidget *w, gpointer data)
}
}
- if (xsane.filetype) /* add extension to filename */
- {
- char buffer[256];
-
- snprintf(buffer, sizeof(buffer), "%s%s", preferences.filename, xsane.filetype);
- free(preferences.filename);
- free(xsane.filetype);
- xsane.filetype = 0;
- preferences.filename = strdup(buffer);
- }
-
xsane_pref_save();
+ xsane_pref_save_media();
if (preferences.save_devprefs_at_exit)
{
@@ -2703,23 +2477,23 @@ static GtkWidget *xsane_files_build_menu(void)
DBG(DBG_proc, "xsane_files_build_menu\n");
menu = gtk_menu_new();
- gtk_accel_group_attach(xsane.accelerator_group, GTK_OBJECT(menu));
+ gtk_menu_set_accel_group(GTK_MENU(menu), xsane.accelerator_group);
/* XSane info dialog */
item = gtk_menu_item_new_with_label(MENU_ITEM_INFO);
- gtk_widget_add_accelerator(item, "activate", xsane.accelerator_group, GDK_I, GDK_CONTROL_MASK, GTK_ACCEL_VISIBLE | GTK_ACCEL_LOCKED);
+ gtk_widget_add_accelerator(item, "activate", xsane.accelerator_group, GDK_I, GDK_CONTROL_MASK, GTK_ACCEL_VISIBLE | DEF_GTK_ACCEL_LOCKED);
gtk_menu_append(GTK_MENU(menu), item);
- gtk_signal_connect(GTK_OBJECT(item), "activate", (GtkSignalFunc) xsane_info_dialog, NULL);
+ g_signal_connect(GTK_OBJECT(item), "activate", (GtkSignalFunc) xsane_info_dialog, NULL);
gtk_widget_show(item);
/* Quit */
item = gtk_menu_item_new_with_label(MENU_ITEM_QUIT);
- gtk_widget_add_accelerator(item, "activate", xsane.accelerator_group, GDK_Q, GDK_CONTROL_MASK, GTK_ACCEL_VISIBLE | GTK_ACCEL_LOCKED);
+ gtk_widget_add_accelerator(item, "activate", xsane.accelerator_group, GDK_Q, GDK_CONTROL_MASK, GTK_ACCEL_VISIBLE | DEF_GTK_ACCEL_LOCKED);
gtk_container_add(GTK_CONTAINER(menu), item);
- gtk_signal_connect(GTK_OBJECT(item), "activate", (GtkSignalFunc) xsane_scan_win_delete, NULL);
+ g_signal_connect(GTK_OBJECT(item), "activate", (GtkSignalFunc) xsane_scan_win_delete, NULL);
gtk_widget_show(item);
return menu;
@@ -2727,6 +2501,334 @@ static GtkWidget *xsane_files_build_menu(void)
/* ---------------------------------------------------------------------------------------------------------------------- */
+static gint xsane_medium_move_up_callback(GtkWidget *widget, GtkWidget *medium_widget)
+{
+ int selection;
+
+ DBG(DBG_proc, "xsane_medium_move_up_callback\n");
+
+ selection = (int) gtk_object_get_data(GTK_OBJECT(medium_widget), "Selection");
+
+ if (selection > 1) /* make sure "full range" stays at top */
+ {
+ Preferences_medium_t *help_medium;
+
+ DBG(DBG_info ,"moving up %s\n", preferences.medium[selection]->name);
+
+ help_medium = preferences.medium[selection-1];
+ preferences.medium[selection-1] = preferences.medium[selection];
+ preferences.medium[selection] = help_medium;
+
+ if (xsane.medium_nr == selection)
+ {
+ xsane.medium_nr--;
+ }
+ else if (xsane.medium_nr == selection-1)
+ {
+ xsane.medium_nr++;
+ }
+
+ xsane_back_gtk_refresh_dialog(); /* brute-force: update menu */
+ }
+
+ return TRUE; /* event is handled */
+}
+
+/* ---------------------------------------------------------------------------------------------------------------------- */
+
+static gint xsane_medium_move_down_callback(GtkWidget *widget, GtkWidget *medium_widget)
+{
+ int selection;
+
+ DBG(DBG_proc, "xsane_medium_move_up_callback\n");
+
+ selection = (int) gtk_object_get_data(GTK_OBJECT(medium_widget), "Selection");
+
+ if ((selection) && (selection < preferences.medium_definitions-1))
+ {
+ Preferences_medium_t *help_medium;
+
+ DBG(DBG_info ,"moving down %s\n", preferences.medium[selection]->name);
+
+ help_medium = preferences.medium[selection];
+ preferences.medium[selection] = preferences.medium[selection+1];
+ preferences.medium[selection+1] = help_medium;
+
+ if (xsane.medium_nr == selection)
+ {
+ xsane.medium_nr++;
+ }
+ else if (xsane.medium_nr == selection+1)
+ {
+ xsane.medium_nr--;
+ }
+
+ xsane_back_gtk_refresh_dialog(); /* brute-force: update menu */
+ }
+
+ return TRUE; /* event is handled */
+}
+
+/* ---------------------------------------------------------------------------------------------------------------------- */
+
+static gint xsane_medium_rename_callback(GtkWidget *widget, GtkWidget *medium_widget)
+{
+ int selection;
+ char *oldname;
+ char *newname;
+ GtkWidget *old_medium_menu;
+ int old_selection;
+
+ DBG(DBG_proc, "xsane_medium_rename_callback\n");
+
+ selection = (int) gtk_object_get_data(GTK_OBJECT(medium_widget), "Selection");
+
+ oldname = strdup(preferences.medium[selection]->name);
+
+ DBG(DBG_info ,"rename %s\n", oldname);
+
+ /* set menu in correct state, is a bit strange this way but I do not have a better idea */
+ old_medium_menu = gtk_option_menu_get_menu(GTK_OPTION_MENU(xsane.medium_widget));
+ old_selection = (int) gtk_object_get_data(GTK_OBJECT(gtk_menu_get_active(GTK_MENU(old_medium_menu))), "Selection");
+ gtk_menu_popdown(GTK_MENU(old_medium_menu));
+ gtk_option_menu_set_history(GTK_OPTION_MENU(xsane.medium_widget), old_selection);
+
+ if (!xsane_front_gtk_getname_dialog(WINDOW_MEDIUM_RENAME, DESC_MEDIUM_RENAME, oldname, &newname))
+ {
+ free(preferences.medium[selection]->name);
+ preferences.medium[selection]->name = strdup(newname);
+ DBG(DBG_info, "renaming %s to %s\n", oldname, newname);
+
+ xsane_back_gtk_refresh_dialog(); /* update menu */
+ }
+
+ free(oldname);
+ free(newname);
+
+ xsane_set_sensitivity(TRUE);
+
+ return TRUE; /* event is handled */
+}
+
+/* ---------------------------------------------------------------------------------------------------------------------- */
+
+static gint xsane_medium_add_callback(GtkWidget *widget, GtkWidget *medium_widget)
+{
+ int selection;
+ char *oldname;
+ char *newname;
+ GtkWidget *old_medium_menu;
+ int old_selection;
+ int i;
+
+ DBG(DBG_proc, "xsane_medium_add_callback\n");
+
+ /* add new item after selected item */
+ selection = 1 + (int) gtk_object_get_data(GTK_OBJECT(medium_widget), "Selection");
+
+ oldname = strdup(TEXT_NEW_MEDIA_NAME);
+
+ /* set menu in correct state, is a bit strange this way but I do not have a better idea */
+ old_medium_menu = gtk_option_menu_get_menu(GTK_OPTION_MENU(xsane.medium_widget));
+ old_selection = (int) gtk_object_get_data(GTK_OBJECT(gtk_menu_get_active(GTK_MENU(old_medium_menu))), "Selection");
+ gtk_menu_popdown(GTK_MENU(old_medium_menu));
+ gtk_option_menu_set_history(GTK_OPTION_MENU(xsane.medium_widget), old_selection);
+
+ if (!xsane_front_gtk_getname_dialog(WINDOW_MEDIUM_ADD, DESC_MEDIUM_ADD, oldname, &newname))
+ {
+ preferences.medium_definitions++;
+ preferences.medium = realloc(preferences.medium, preferences.medium_definitions * sizeof(void *));
+
+ for (i = preferences.medium_definitions-1; i > selection; i--)
+ {
+ preferences.medium[i] = preferences.medium[i-1];
+ }
+
+ DBG(DBG_info, "adding new media %s\n", newname);
+
+ if (xsane.negative)
+ {
+ preferences.medium[selection] = calloc(sizeof(Preferences_medium_t), 1);
+ preferences.medium[selection]->name = strdup(newname);
+ preferences.medium[selection]->shadow_gray = 100.0 - xsane.slider_gray.value[2];
+ preferences.medium[selection]->shadow_red = 100.0 - xsane.slider_red.value[2];
+ preferences.medium[selection]->shadow_green = 100.0 - xsane.slider_green.value[2];
+ preferences.medium[selection]->shadow_blue = 100.0 - xsane.slider_blue.value[2];
+ preferences.medium[selection]->highlight_gray = 100.0 - xsane.slider_gray.value[0];
+ preferences.medium[selection]->highlight_red = 100.0 - xsane.slider_red.value[0];
+ preferences.medium[selection]->highlight_green = 100.0 - xsane.slider_green.value[0];
+ preferences.medium[selection]->highlight_blue = 100.0 - xsane.slider_blue.value[0];
+ preferences.medium[selection]->gamma_gray = xsane.gamma;
+ preferences.medium[selection]->gamma_red = xsane.gamma * xsane.gamma_red;
+ preferences.medium[selection]->gamma_green = xsane.gamma * xsane.gamma_green;
+ preferences.medium[selection]->gamma_blue = xsane.gamma * xsane.gamma_blue;
+ preferences.medium[selection]->negative = xsane.negative;
+ }
+ else
+ {
+ preferences.medium[selection] = calloc(sizeof(Preferences_medium_t), 1);
+ preferences.medium[selection]->name = strdup(newname);
+ preferences.medium[selection]->shadow_gray = xsane.slider_gray.value[0];
+ preferences.medium[selection]->shadow_red = xsane.slider_red.value[0];
+ preferences.medium[selection]->shadow_green = xsane.slider_green.value[0];
+ preferences.medium[selection]->shadow_blue = xsane.slider_blue.value[0];
+ preferences.medium[selection]->highlight_gray = xsane.slider_gray.value[2];
+ preferences.medium[selection]->highlight_red = xsane.slider_red.value[2];
+ preferences.medium[selection]->highlight_green = xsane.slider_green.value[2];
+ preferences.medium[selection]->highlight_blue = xsane.slider_blue.value[2];
+ preferences.medium[selection]->gamma_gray = xsane.gamma;
+ preferences.medium[selection]->gamma_red = xsane.gamma * xsane.gamma_red;
+ preferences.medium[selection]->gamma_green = xsane.gamma * xsane.gamma_green;
+ preferences.medium[selection]->gamma_blue = xsane.gamma * xsane.gamma_blue;
+ preferences.medium[selection]->negative = xsane.negative;
+ }
+
+ xsane.medium_nr = selection; /* activate new created medium */
+
+ xsane_back_gtk_refresh_dialog(); /* update menu */
+ xsane_enhancement_by_gamma(); /* update sliders */
+ }
+
+ free(oldname);
+ free(newname);
+
+ xsane_set_sensitivity(TRUE);
+
+ return TRUE; /* event is handled */
+}
+
+/* ---------------------------------------------------------------------------------------------------------------------- */
+
+static gint xsane_medium_delete_callback(GtkWidget *widget, GtkWidget *medium_widget)
+{
+ int selection, i;
+
+ DBG(DBG_proc, "xsane_medium_delete_callback\n");
+
+ selection = (int) gtk_object_get_data(GTK_OBJECT(medium_widget), "Selection");
+
+ if (selection) /* full range can not be deleted */
+ {
+ DBG(DBG_info ,"deleting %s\n", preferences.medium[selection]->name);
+
+ free(preferences.medium[selection]);
+
+ preferences.medium_definitions--;
+
+ for (i = selection; i < preferences.medium_definitions; i++)
+ {
+ preferences.medium[i] = preferences.medium[i+1];
+ }
+
+ if (xsane.medium_nr == selection)
+ {
+ xsane.medium_nr--;
+ xsane.medium_changed = TRUE;
+
+ if (xsane.medium_calibration) /* are we running in medium calibration mode? */
+ {
+ xsane_apply_medium_definition_as_enhancement(preferences.medium[xsane.medium_nr]);
+ xsane_set_medium(NULL);
+ }
+ else
+ {
+ xsane_set_medium(preferences.medium[xsane.medium_nr]);
+ }
+
+ xsane_enhancement_by_gamma(); /* update sliders */
+ }
+
+ xsane_back_gtk_refresh_dialog(); /* update menu */
+
+ xsane_update_gamma_curve(TRUE); /* if necessary update preview gamma */
+
+ preview_display_valid(xsane.preview); /* update valid status of preview image */
+ /* the valid status depends on gamma handling an medium change */
+ }
+
+ return TRUE; /* event is handled */
+}
+
+/* ---------------------------------------------------------------------------------------------------------------------- */
+
+static gint xsane_medium_context_menu_callback(GtkWidget *widget, GdkEvent *event)
+{
+ GtkWidget *menu;
+ GtkWidget *menu_item;
+ GdkEventButton *event_button;
+ int selection;
+
+ DBG(DBG_proc, "xsane_medium_context_menu_callback\n");
+
+ selection = (int) gtk_object_get_data(GTK_OBJECT(widget), "Selection");
+
+ if (event->type == GDK_BUTTON_PRESS)
+ {
+ event_button = (GdkEventButton *) event;
+
+ if (event_button->button == 3)
+ {
+ char buf[256];
+
+ menu = gtk_menu_new();
+
+ if (xsane.medium_calibration) /* are we running in medium calibration mode? */
+ {
+ /* add medium */
+ menu_item = gtk_menu_item_new_with_label(MENU_ITEM_MEDIUM_ADD);
+ gtk_widget_show(menu_item);
+ gtk_container_add(GTK_CONTAINER(menu), menu_item);
+ g_signal_connect(GTK_OBJECT(menu_item), "activate", (GtkSignalFunc) xsane_medium_add_callback, widget);
+ }
+
+ /* rename medium */
+ snprintf(buf, sizeof(buf), "%s: %s", preferences.medium[selection]->name, MENU_ITEM_RENAME);
+ menu_item = gtk_menu_item_new_with_label(buf);
+ gtk_widget_show(menu_item);
+ gtk_container_add(GTK_CONTAINER(menu), menu_item);
+ g_signal_connect(GTK_OBJECT(menu_item), "activate", (GtkSignalFunc) xsane_medium_rename_callback, widget);
+
+ if (selection) /* not available for "full area" */
+ {
+ /* delete medium */
+ snprintf(buf, sizeof(buf), "%s: %s", preferences.medium[selection]->name, MENU_ITEM_DELETE);
+ menu_item = gtk_menu_item_new_with_label(buf);
+ gtk_widget_show(menu_item);
+ gtk_container_add(GTK_CONTAINER(menu), menu_item);
+ g_signal_connect(GTK_OBJECT(menu_item), "activate", (GtkSignalFunc) xsane_medium_delete_callback, widget);
+ }
+
+ if (selection>1) /* available from 3rd item */
+ {
+ /* move up */
+ snprintf(buf, sizeof(buf), "%s: %s", preferences.medium[selection]->name, MENU_ITEM_MOVE_UP);
+ menu_item = gtk_menu_item_new_with_label(buf);
+ gtk_widget_show(menu_item);
+ gtk_container_add(GTK_CONTAINER(menu), menu_item);
+ g_signal_connect(GTK_OBJECT(menu_item), "activate", (GtkSignalFunc) xsane_medium_move_up_callback, widget);
+ }
+
+ if ((selection) && (selection < preferences.medium_definitions-1))
+ {
+ /* move down */
+ snprintf(buf, sizeof(buf), "%s: %s", preferences.medium[selection]->name, MENU_ITEM_MOVE_DWN);
+ menu_item = gtk_menu_item_new_with_label(buf);
+ gtk_widget_show(menu_item);
+ gtk_container_add(GTK_CONTAINER(menu), menu_item);
+ g_signal_connect(GTK_OBJECT(menu_item), "activate", (GtkSignalFunc) xsane_medium_move_down_callback, widget);
+ }
+
+ gtk_menu_popup(GTK_MENU(menu), NULL, NULL, NULL, NULL, event_button->button, event_button->time);
+
+ return TRUE; /* event is handled */
+ }
+ }
+
+ return FALSE;
+}
+
+/* ---------------------------------------------------------------------------------------------------------------------- */
+
static void xsane_set_medium_callback(GtkWidget *widget, gpointer data)
{
int medium_nr = (int) data;
@@ -2738,7 +2840,18 @@ static void xsane_set_medium_callback(GtkWidget *widget, gpointer data)
xsane.medium_nr = medium_nr;
- xsane_set_medium(preferences.medium[medium_nr]);
+ if (xsane.medium_calibration) /* are we running in medium calibration mode? */
+ {
+ xsane_apply_medium_definition_as_enhancement(preferences.medium[xsane.medium_nr]);
+ xsane_set_medium(NULL);
+ }
+ else
+ {
+ xsane_set_medium(preferences.medium[xsane.medium_nr]);
+ }
+
+ xsane_enhancement_by_gamma(); /* update sliders */
+ xsane_back_gtk_refresh_dialog(); /* update menu */
xsane_update_gamma_curve(TRUE); /* if necessary update preview gamma */
@@ -2755,9 +2868,9 @@ static void xsane_set_pref_unit_callback(GtkWidget *widget, gpointer data)
DBG(DBG_proc, "xsane_set_pref_unit_callback\n");
- gtk_signal_handler_block_by_func(GTK_OBJECT(xsane.length_unit_mm), (GtkSignalFunc) xsane_set_pref_unit_callback, "mm");
- gtk_signal_handler_block_by_func(GTK_OBJECT(xsane.length_unit_cm), (GtkSignalFunc) xsane_set_pref_unit_callback, "cm");
- gtk_signal_handler_block_by_func(GTK_OBJECT(xsane.length_unit_in), (GtkSignalFunc) xsane_set_pref_unit_callback, "in");
+ g_signal_handlers_block_by_func(GTK_OBJECT(xsane.length_unit_mm), (GtkSignalFunc) xsane_set_pref_unit_callback, "mm");
+ g_signal_handlers_block_by_func(GTK_OBJECT(xsane.length_unit_cm), (GtkSignalFunc) xsane_set_pref_unit_callback, "cm");
+ g_signal_handlers_block_by_func(GTK_OBJECT(xsane.length_unit_in), (GtkSignalFunc) xsane_set_pref_unit_callback, "in");
if (strcmp(unit, "mm") == 0)
{
@@ -2780,34 +2893,82 @@ static void xsane_set_pref_unit_callback(GtkWidget *widget, gpointer data)
gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(xsane.length_unit_in), TRUE);
}
- gtk_signal_handler_unblock_by_func(GTK_OBJECT(xsane.length_unit_mm), (GtkSignalFunc) xsane_set_pref_unit_callback, "mm");
- gtk_signal_handler_unblock_by_func(GTK_OBJECT(xsane.length_unit_cm), (GtkSignalFunc) xsane_set_pref_unit_callback, "cm");
- gtk_signal_handler_unblock_by_func(GTK_OBJECT(xsane.length_unit_in), (GtkSignalFunc) xsane_set_pref_unit_callback, "in");
+ g_signal_handlers_unblock_by_func(GTK_OBJECT(xsane.length_unit_mm), (GtkSignalFunc) xsane_set_pref_unit_callback, "mm");
+ g_signal_handlers_unblock_by_func(GTK_OBJECT(xsane.length_unit_cm), (GtkSignalFunc) xsane_set_pref_unit_callback, "cm");
+ g_signal_handlers_unblock_by_func(GTK_OBJECT(xsane.length_unit_in), (GtkSignalFunc) xsane_set_pref_unit_callback, "in");
preferences.length_unit = unit_conversion_factor;
xsane_refresh_dialog();
+
if (xsane.preview)
{
preview_area_resize(xsane.preview); /* redraw rulers */
}
+ xsane_batch_scan_update_label_list(); /* update units in batch scan list */
+
xsane_pref_save();
}
/* ---------------------------------------------------------------------------------------------------------------------- */
+static void xsane_edit_medium_definition_callback(GtkWidget *widget, gpointer data)
+{
+ DBG(DBG_proc, "xsane_edit_medium_definition_callback\n");
+
+ if (GTK_CHECK_MENU_ITEM(widget)->active) /* enable edit mode */
+ {
+ DBG(DBG_info2, "enabling edit mode\n");
+
+ xsane.medium_calibration = TRUE;
+ xsane.no_preview_medium_gamma = TRUE;
+
+ xsane.brightness_min = XSANE_MEDIUM_CALIB_BRIGHTNESS_MIN;
+ xsane.brightness_max = XSANE_MEDIUM_CALIB_BRIGHTNESS_MAX;
+ xsane.contrast_gray_min = XSANE_CONTRAST_GRAY_MIN;
+ xsane.contrast_min = XSANE_MEDIUM_CALIB_CONTRAST_MIN;
+ xsane.contrast_max = XSANE_MEDIUM_CALIB_CONTRAST_MAX;
+
+ xsane_apply_medium_definition_as_enhancement(preferences.medium[xsane.medium_nr]);
+ xsane_set_medium(NULL);
+ }
+ else /* disable edit mode */
+ {
+ DBG(DBG_info2, "disabling edit mode\n");
+
+ xsane.medium_calibration = FALSE;
+ xsane.no_preview_medium_gamma = FALSE;
+
+ xsane.brightness_min = XSANE_BRIGHTNESS_MIN;
+ xsane.brightness_max = XSANE_BRIGHTNESS_MAX;
+ xsane.contrast_gray_min = XSANE_CONTRAST_GRAY_MIN;
+ xsane.contrast_min = XSANE_CONTRAST_MIN;
+ xsane.contrast_max = XSANE_CONTRAST_MAX;
+
+ xsane_apply_medium_definition_as_enhancement(preferences.medium[0]);
+ xsane_set_medium(preferences.medium[xsane.medium_nr]);
+ }
+
+ xsane_enhancement_by_gamma(); /* update sliders */
+ xsane_back_gtk_refresh_dialog(); /* update dialog */
+
+ xsane_update_gamma_curve(TRUE); /* if necessary update preview gamma */
+}
+
+/* ---------------------------------------------------------------------------------------------------------------------- */
+
static void xsane_set_update_policy_callback(GtkWidget *widget, gpointer data)
{
GtkUpdateType policy = (GtkUpdateType) data;
DBG(DBG_proc, "xsane_set_update_policy_callback\n");
- gtk_signal_handler_block_by_func(GTK_OBJECT(xsane.update_policy_continu), (GtkSignalFunc) xsane_set_update_policy_callback,
+ g_signal_handlers_block_by_func(GTK_OBJECT(xsane.update_policy_continu), (GtkSignalFunc) xsane_set_update_policy_callback,
(void *) GTK_UPDATE_CONTINUOUS);
- gtk_signal_handler_block_by_func(GTK_OBJECT(xsane.update_policy_discont), (GtkSignalFunc) xsane_set_update_policy_callback,
+ g_signal_handlers_block_by_func(GTK_OBJECT(xsane.update_policy_discont), (GtkSignalFunc) xsane_set_update_policy_callback,
(void *) GTK_UPDATE_DISCONTINUOUS);
- gtk_signal_handler_block_by_func(GTK_OBJECT(xsane.update_policy_delayed), (GtkSignalFunc) xsane_set_update_policy_callback,
+ g_signal_handlers_block_by_func(GTK_OBJECT(xsane.update_policy_delayed), (GtkSignalFunc) xsane_set_update_policy_callback,
(void *) GTK_UPDATE_DELAYED);
if (policy == GTK_UPDATE_CONTINUOUS)
@@ -2829,11 +2990,11 @@ static void xsane_set_update_policy_callback(GtkWidget *widget, gpointer data)
gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(xsane.update_policy_delayed), TRUE);
}
- gtk_signal_handler_unblock_by_func(GTK_OBJECT(xsane.update_policy_continu), (GtkSignalFunc) xsane_set_update_policy_callback,
+ g_signal_handlers_unblock_by_func(GTK_OBJECT(xsane.update_policy_continu), (GtkSignalFunc) xsane_set_update_policy_callback,
(void *) GTK_UPDATE_CONTINUOUS);
- gtk_signal_handler_unblock_by_func(GTK_OBJECT(xsane.update_policy_discont), (GtkSignalFunc) xsane_set_update_policy_callback,
+ g_signal_handlers_unblock_by_func(GTK_OBJECT(xsane.update_policy_discont), (GtkSignalFunc) xsane_set_update_policy_callback,
(void *) GTK_UPDATE_DISCONTINUOUS);
- gtk_signal_handler_unblock_by_func(GTK_OBJECT(xsane.update_policy_delayed), (GtkSignalFunc) xsane_set_update_policy_callback,
+ g_signal_handlers_unblock_by_func(GTK_OBJECT(xsane.update_policy_delayed), (GtkSignalFunc) xsane_set_update_policy_callback,
(void *) GTK_UPDATE_DELAYED);
preferences.gtk_update_policy = policy;
@@ -2854,11 +3015,6 @@ static gint xsane_close_info_callback(GtkWidget *widget, gpointer data)
xsane_set_sensitivity(TRUE);
- xsane_update_histogram(TRUE /* update raw */);
-#ifdef HAVE_WORKING_GTK_GAMMACURVE
- xsane_update_gamma_dialog();
-#endif
-
return FALSE;
}
@@ -2875,15 +3031,16 @@ static void xsane_info_dialog(GtkWidget *widget, gpointer data)
sane_get_parameters(xsane.dev, &xsane.param); /* update xsane.param */
- info_dialog = gtk_window_new(GTK_WINDOW_DIALOG);
+ info_dialog = gtk_window_new(GTK_WINDOW_TOPLEVEL);
gtk_window_set_position(GTK_WINDOW(info_dialog), GTK_WIN_POS_CENTER);
- gtk_window_set_policy(GTK_WINDOW(info_dialog), FALSE, FALSE, FALSE);
- gtk_signal_connect(GTK_OBJECT(info_dialog), "destroy", GTK_SIGNAL_FUNC(xsane_close_info_callback), info_dialog);
+ gtk_window_set_resizable(GTK_WINDOW(info_dialog), FALSE);
+ g_signal_connect(GTK_OBJECT(info_dialog), "destroy", GTK_SIGNAL_FUNC(xsane_close_info_callback), info_dialog);
snprintf(buf, sizeof(buf), "%s %s %s", xsane.prog_name, WINDOW_INFO, xsane.device_text);
gtk_window_set_title(GTK_WINDOW(info_dialog), buf);
+ gtk_container_set_border_width(GTK_CONTAINER(info_dialog), 5);
accelerator_group = gtk_accel_group_new();
- gtk_accel_group_attach(accelerator_group, GTK_OBJECT(info_dialog));
+ gtk_window_add_accel_group(GTK_WINDOW(info_dialog), accelerator_group);
xsane_set_window_icon(info_dialog, 0);
@@ -3104,6 +3261,9 @@ static void xsane_info_dialog(GtkWidget *widget, gpointer data)
bufptr += strlen(bufptr);
#endif
+ sprintf(bufptr, "TXT, ");
+ bufptr += strlen(bufptr);
+
bufptr--;
bufptr--;
*bufptr = 0; /* erase last comma */
@@ -3125,9 +3285,6 @@ static void xsane_info_dialog(GtkWidget *widget, gpointer data)
sprintf(bufptr, "PNM, ");
bufptr += strlen(bufptr);
- sprintf(bufptr, "RAW, ");
- bufptr += strlen(bufptr);
-
#ifdef SUPPORT_RGBA
sprintf(bufptr, "RGBA, ");
bufptr += strlen(bufptr);
@@ -3146,19 +3303,20 @@ static void xsane_info_dialog(GtkWidget *widget, gpointer data)
/* gtk_label_set((GtkLabel *)label, "HALLO"); */
+#ifdef HAVE_GTK2
+ button = gtk_button_new_from_stock(GTK_STOCK_CLOSE);
+#else
button = gtk_button_new_with_label(BUTTON_CLOSE);
- gtk_widget_add_accelerator(button, "clicked", accelerator_group, GDK_Escape, 0, GTK_ACCEL_LOCKED);
+#endif
+ gtk_widget_add_accelerator(button, "clicked", accelerator_group, GDK_Escape, 0, DEF_GTK_ACCEL_LOCKED);
GTK_WIDGET_SET_FLAGS(button, GTK_CAN_DEFAULT);
- gtk_signal_connect(GTK_OBJECT(button), "clicked", (GtkSignalFunc) xsane_close_info_callback, info_dialog);
+ g_signal_connect(GTK_OBJECT(button), "clicked", (GtkSignalFunc) xsane_close_info_callback, info_dialog);
gtk_box_pack_start(GTK_BOX(vbox), button, FALSE, FALSE, 0);
gtk_widget_grab_default(button);
gtk_widget_show(button);
gtk_widget_show(info_dialog);
- xsane_clear_histogram(&xsane.histogram_raw);
- xsane_clear_histogram(&xsane.histogram_enh);
-
xsane_set_sensitivity(FALSE);
}
@@ -3197,15 +3355,16 @@ static void xsane_about_dialog(GtkWidget *widget, gpointer data)
return;
}
- about_dialog = gtk_window_new(GTK_WINDOW_DIALOG);
+ about_dialog = gtk_window_new(GTK_WINDOW_TOPLEVEL);
gtk_window_set_position(GTK_WINDOW(about_dialog), GTK_WIN_POS_CENTER);
- gtk_window_set_policy(GTK_WINDOW(about_dialog), FALSE, FALSE, FALSE);
- gtk_signal_connect(GTK_OBJECT(about_dialog), "destroy", GTK_SIGNAL_FUNC(xsane_close_about_dialog_callback), NULL);
+ gtk_window_set_resizable(GTK_WINDOW(about_dialog), FALSE);
+ g_signal_connect(GTK_OBJECT(about_dialog), "destroy", GTK_SIGNAL_FUNC(xsane_close_about_dialog_callback), NULL);
snprintf(buf, sizeof(buf), "%s %s", WINDOW_ABOUT_XSANE, xsane.prog_name);
gtk_window_set_title(GTK_WINDOW(about_dialog), buf);
+ gtk_container_set_border_width(GTK_CONTAINER(about_dialog), 5);
accelerator_group = gtk_accel_group_new();
- gtk_accel_group_attach(accelerator_group, GTK_OBJECT(about_dialog));
+ gtk_window_add_accel_group(GTK_WINDOW(about_dialog), accelerator_group);
xsane_set_window_icon(about_dialog, 0);
@@ -3226,10 +3385,10 @@ static void xsane_about_dialog(GtkWidget *widget, gpointer data)
xsane_back_gtk_make_path(sizeof(filename), filename, "xsane", 0, "xsane-logo", 0, ".xpm", XSANE_PATH_SYSTEM);
pixmap = gdk_pixmap_create_from_xpm(about_dialog->window, &mask, bg_trans, filename);
- pixmapwidget = gtk_pixmap_new(pixmap, mask);
+ pixmapwidget = gtk_image_new_from_pixmap(pixmap, mask);
gtk_box_pack_start(GTK_BOX(vbox), pixmapwidget, FALSE, FALSE, 2);
gtk_widget_show(pixmapwidget);
- gdk_pixmap_unref(pixmap);
+ gdk_drawable_unref(pixmap);
xsane_separator_new(vbox, 5);
@@ -3250,10 +3409,14 @@ static void xsane_about_dialog(GtkWidget *widget, gpointer data)
gtk_widget_show(label);
+#ifdef HAVE_GTK2
+ button = gtk_button_new_from_stock(GTK_STOCK_CLOSE);
+#else
button = gtk_button_new_with_label(BUTTON_CLOSE);
- gtk_widget_add_accelerator(button, "clicked", accelerator_group, GDK_Escape, 0, GTK_ACCEL_LOCKED);
+#endif
+ gtk_widget_add_accelerator(button, "clicked", accelerator_group, GDK_Escape, 0, DEF_GTK_ACCEL_LOCKED);
GTK_WIDGET_SET_FLAGS(button, GTK_CAN_DEFAULT);
- gtk_signal_connect(GTK_OBJECT(button), "clicked", (GtkSignalFunc) xsane_close_about_dialog_callback, NULL);
+ g_signal_connect(GTK_OBJECT(button), "clicked", (GtkSignalFunc) xsane_close_about_dialog_callback, NULL);
gtk_box_pack_start(GTK_BOX(vbox), button, FALSE, FALSE, 0);
gtk_widget_grab_default(button);
gtk_widget_show(button);
@@ -3280,7 +3443,7 @@ static int xsane_close_about_translation_dialog_callback(GtkWidget *widget, gpoi
static void xsane_about_translation_dialog(GtkWidget *widget, gpointer data)
{
GtkWidget *vbox, *hbox, *button, *label;
- char buf[512];
+ char buf[1024];
char filename[PATH_MAX];
GtkWidget *pixmapwidget;
GdkBitmap *mask;
@@ -3296,15 +3459,16 @@ static void xsane_about_translation_dialog(GtkWidget *widget, gpointer data)
return;
}
- about_translation_dialog = gtk_window_new(GTK_WINDOW_DIALOG);
+ about_translation_dialog = gtk_window_new(GTK_WINDOW_TOPLEVEL);
gtk_window_set_position(GTK_WINDOW(about_translation_dialog), GTK_WIN_POS_CENTER);
- gtk_window_set_policy(GTK_WINDOW(about_translation_dialog), FALSE, FALSE, FALSE);
- gtk_signal_connect(GTK_OBJECT(about_translation_dialog), "destroy", GTK_SIGNAL_FUNC(xsane_close_about_translation_dialog_callback), NULL);
+ gtk_window_set_resizable(GTK_WINDOW(about_translation_dialog), FALSE);
+ g_signal_connect(GTK_OBJECT(about_translation_dialog), "destroy", GTK_SIGNAL_FUNC(xsane_close_about_translation_dialog_callback), NULL);
snprintf(buf, sizeof(buf), "%s %s", WINDOW_ABOUT_TRANSLATION, xsane.prog_name);
gtk_window_set_title(GTK_WINDOW(about_translation_dialog), buf);
+ gtk_container_set_border_width(GTK_CONTAINER(about_translation_dialog), 5);
accelerator_group = gtk_accel_group_new();
- gtk_accel_group_attach(accelerator_group, GTK_OBJECT(about_translation_dialog));
+ gtk_window_add_accel_group(GTK_WINDOW(about_translation_dialog), accelerator_group);
xsane_set_window_icon(about_translation_dialog, 0);
@@ -3325,10 +3489,10 @@ static void xsane_about_translation_dialog(GtkWidget *widget, gpointer data)
xsane_back_gtk_make_path(sizeof(filename), filename, "xsane", 0, "xsane-logo", 0, ".xpm", XSANE_PATH_SYSTEM);
pixmap = gdk_pixmap_create_from_xpm(about_translation_dialog->window, &mask, bg_trans, filename);
- pixmapwidget = gtk_pixmap_new(pixmap, mask);
+ pixmapwidget = gtk_image_new_from_pixmap(pixmap, mask);
gtk_box_pack_start(GTK_BOX(vbox), pixmapwidget, FALSE, FALSE, 2);
gtk_widget_show(pixmapwidget);
- gdk_pixmap_unref(pixmap);
+ gdk_drawable_unref(pixmap);
xsane_separator_new(vbox, 5);
@@ -3343,10 +3507,14 @@ static void xsane_about_translation_dialog(GtkWidget *widget, gpointer data)
gtk_widget_show(label);
+#ifdef HAVE_GTK2
+ button = gtk_button_new_from_stock(GTK_STOCK_CLOSE);
+#else
button = gtk_button_new_with_label(BUTTON_CLOSE);
- gtk_widget_add_accelerator(button, "clicked", accelerator_group, GDK_Escape, 0, GTK_ACCEL_LOCKED);
+#endif
+ gtk_widget_add_accelerator(button, "clicked", accelerator_group, GDK_Escape, 0, DEF_GTK_ACCEL_LOCKED);
GTK_WIDGET_SET_FLAGS(button, GTK_CAN_DEFAULT);
- gtk_signal_connect(GTK_OBJECT(button), "clicked", (GtkSignalFunc) xsane_close_about_translation_dialog_callback, NULL);
+ g_signal_connect(GTK_OBJECT(button), "clicked", (GtkSignalFunc) xsane_close_about_translation_dialog_callback, NULL);
gtk_box_pack_start(GTK_BOX(vbox), button, FALSE, FALSE, 0);
gtk_widget_grab_default(button);
gtk_widget_show(button);
@@ -3356,154 +3524,9 @@ static void xsane_about_translation_dialog(GtkWidget *widget, gpointer data)
/* ---------------------------------------------------------------------------------------------------------------------- */
-static SANE_Status xsane_get_area_value(int option, float *val, SANE_Int *unit)
-{
- const SANE_Option_Descriptor *opt;
- SANE_Handle dev;
- SANE_Word word;
-
- DBG(DBG_proc, "xsane_get_area_value\n");
-
- if (option <= 0)
- {
- return -1;
- }
-
- if (xsane_control_option(xsane.dev, option, SANE_ACTION_GET_VALUE, &word, 0) == SANE_STATUS_GOOD)
- {
- dev = xsane.dev;
- opt = xsane_get_option_descriptor(dev, option);
-
- if (unit)
- {
- *unit = opt->unit;
- }
-
- if (val)
- {
- if (opt->type == SANE_TYPE_FIXED)
- {
- *val = (float) word / 65536.0;
- }
- else
- {
- *val = (float) word;
- }
- }
-
- return 0;
- }
- else if (val)
- {
- *val = 0;
- }
- return -2;
-}
-
-/* ---------------------------------------------------------------------------------------------------------------------- */
-
-#ifdef XSANE_TEST
-static void xsane_batch_scan_delete_callback(GtkWidget *widget, gpointer list)
-{
- gtk_list_remove_items(GTK_LIST(list), GTK_LIST(list)->selection);
-}
-
-/* ---------------------------------------------------------------------------------------------------------------------- */
-
-static void xsane_batch_scan_add_callback(GtkWidget *widget, gpointer list)
-{
- GtkWidget *list_item;
- float tlx, tly, brx, bry;
- SANE_Int unit;
- char buf[255];
-
- DBG(DBG_proc, "xsane_batch_scan_add_callback\n");
-
- xsane_get_area_value(xsane.well_known.coord[0], &tlx, &unit);
- xsane_get_area_value(xsane.well_known.coord[1], &tly, &unit);
- xsane_get_area_value(xsane.well_known.coord[2], &brx, &unit);
- xsane_get_area_value(xsane.well_known.coord[3], &bry, &unit);
-
- if (unit == SANE_UNIT_MM)
- {
- snprintf(buf, sizeof(buf), " top left (%7.2fmm, %7.2fmm), bottom right (%7.2fmm, %7.2fmm)", tlx, tly, brx, bry);
- }
- else
- {
- snprintf(buf, sizeof(buf), " top left (%5.0fpx, %5.0fpx), bottom right (%5.0fpx, %5.0fpx)", tlx, tly, brx, bry);
- }
-
- list_item = gtk_list_item_new_with_label(buf);
- gtk_object_set_data(GTK_OBJECT(list_item), "list_item_data", strdup(buf));
- gtk_container_add(GTK_CONTAINER(list), list_item);
- gtk_widget_show(list_item);
-}
-
-/* ---------------------------------------------------------------------------------------------------------------------- */
-
-static void xsane_batch_scan_dialog(GtkWidget *widget, gpointer data)
-{
- GtkWidget *batch_scan_dialog, *batch_scan_vbox, *hbox, *button, *scrolled_window, *list;
- char buf[64];
-
- DBG(DBG_proc, "xsane_batch_scan_dialog\n");
-
- batch_scan_dialog = gtk_window_new(GTK_WINDOW_DIALOG);
- xsane_set_window_icon(batch_scan_dialog, 0);
-
- snprintf(buf, sizeof(buf), "%s %s", xsane.prog_name, WINDOW_BATCH_SCAN);
- gtk_window_set_title(GTK_WINDOW(batch_scan_dialog), buf);
-
- /* set the main vbox */
- batch_scan_vbox = gtk_vbox_new(FALSE, 0);
- gtk_container_set_border_width(GTK_CONTAINER(batch_scan_vbox), 0);
- gtk_container_add(GTK_CONTAINER(batch_scan_dialog), batch_scan_vbox);
- gtk_widget_show(batch_scan_vbox);
-
- /* set the main hbox */
- hbox = gtk_hbox_new(FALSE, 0);
- xsane_separator_new(vbox, 2);
- gtk_box_pack_end(GTK_BOX(batch_scan_vbox), hbox, FALSE, FALSE, 5);
- gtk_container_set_border_width(GTK_CONTAINER(hbox), 5);
- gtk_widget_show(hbox);
-
- scrolled_window = gtk_scrolled_window_new(0, 0);
- gtk_widget_set_usize(scrolled_window, 400, 200);
- gtk_container_add(GTK_CONTAINER(batch_scan_vbox), scrolled_window);
- gtk_widget_show(scrolled_window);
-
- list = gtk_list_new();
-
- gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(scrolled_window), list);
-
- gtk_widget_show(list);
-
-
- button = gtk_button_new_with_label(BUTTON_OK);
- GTK_WIDGET_SET_FLAGS(button, GTK_CAN_DEFAULT);
- gtk_signal_connect(GTK_OBJECT(button), "clicked", (GtkSignalFunc) xsane_close_dialog_callback, batch_scan_dialog);
- gtk_box_pack_start(GTK_BOX(hbox), button, TRUE, TRUE, 0);
- gtk_widget_grab_default(button);
- gtk_widget_show(button);
-
- button = gtk_button_new_with_label(BUTTON_ADD_AREA);
- gtk_signal_connect(GTK_OBJECT(button), "clicked", (GtkSignalFunc) xsane_batch_scan_add_callback, list);
- gtk_box_pack_start(GTK_BOX(hbox), button, TRUE, TRUE, 0);
- gtk_widget_show(button);
-
- button = gtk_button_new_with_label(BUTTON_DELETE);
- gtk_signal_connect(GTK_OBJECT(button), "clicked", (GtkSignalFunc) xsane_batch_scan_delete_callback, list);
- gtk_box_pack_start(GTK_BOX(hbox), button, TRUE, TRUE, 0);
- gtk_widget_show(button);
-
- gtk_widget_show(batch_scan_dialog);
-}
-#endif
-
-/* ---------------------------------------------------------------------------------------------------------------------- */
-
-static void xsane_fax_dialog_delete()
+static gint xsane_fax_dialog_delete()
{
+ return TRUE;
}
/* ---------------------------------------------------------------------------------------------------------------------- */
@@ -3524,15 +3547,14 @@ static void xsane_fax_dialog()
return; /* window already is open */
}
- /* GTK_WINDOW_DIALOG looks better but does not place it nice*/
+ /* GTK_WINDOW_TOPLEVEL looks better but does not place it nice*/
fax_dialog = gtk_window_new(GTK_WINDOW_TOPLEVEL);
- gtk_window_set_title(GTK_WINDOW(fax_dialog), buf);
snprintf(buf, sizeof(buf), "%s %s", xsane.prog_name, WINDOW_FAX_PROJECT);
gtk_window_set_title(GTK_WINDOW(fax_dialog), buf);
- gtk_signal_connect(GTK_OBJECT(fax_dialog), "delete_event", (GtkSignalFunc) xsane_fax_dialog_delete, NULL);
+ g_signal_connect(GTK_OBJECT(fax_dialog), "delete_event", (GtkSignalFunc) xsane_fax_dialog_delete, NULL);
xsane_set_window_icon(fax_dialog, 0);
- gtk_accel_group_attach(xsane.accelerator_group, GTK_OBJECT(fax_dialog));
+ gtk_window_add_accel_group(GTK_WINDOW(fax_dialog), xsane.accelerator_group);
/* set the main vbox */
fax_scan_vbox = gtk_vbox_new(FALSE, 0);
@@ -3547,17 +3569,19 @@ static void xsane_fax_dialog()
gtk_box_pack_start(GTK_BOX(fax_scan_vbox), hbox, FALSE, FALSE, 2);
pixmap = gdk_pixmap_create_from_xpm_d(xsane.shell->window, &mask, xsane.bg_trans, (gchar **) fax_xpm);
- pixmapwidget = gtk_pixmap_new(pixmap, mask);
+ pixmapwidget = gtk_image_new_from_pixmap(pixmap, mask);
gtk_box_pack_start(GTK_BOX(hbox), pixmapwidget, FALSE, FALSE, 2);
- gdk_pixmap_unref(pixmap);
+ gdk_drawable_unref(pixmap);
- text = gtk_entry_new_with_max_length(128);
+ text = gtk_entry_new();
xsane_back_gtk_set_tooltip(xsane.tooltips, text, DESC_FAXPROJECT);
+ gtk_entry_set_max_length(GTK_ENTRY(text), 128);
gtk_entry_set_text(GTK_ENTRY(text), (char *) preferences.fax_project);
gtk_box_pack_start(GTK_BOX(hbox), text, TRUE, TRUE, 4);
- gtk_signal_connect(GTK_OBJECT(text), "changed", (GtkSignalFunc) xsane_fax_project_changed_callback, NULL);
+ g_signal_connect(GTK_OBJECT(text), "changed", (GtkSignalFunc) xsane_fax_project_changed_callback, NULL);
xsane.fax_project_entry = text;
+ xsane.fax_project_entry_box = hbox;
gtk_widget_show(pixmapwidget);
gtk_widget_show(text);
@@ -3576,14 +3600,15 @@ static void xsane_fax_dialog()
gtk_widget_realize(fax_dialog);
pixmap = gdk_pixmap_create_from_xpm_d(fax_dialog->window, &mask, xsane.bg_trans, (gchar **) faxreceiver_xpm);
- pixmapwidget = gtk_pixmap_new(pixmap, mask);
+ pixmapwidget = gtk_image_new_from_pixmap(pixmap, mask);
gtk_box_pack_start(GTK_BOX(hbox), pixmapwidget, FALSE, FALSE, 2);
- gdk_pixmap_unref(pixmap);
+ gdk_drawable_unref(pixmap);
- text = gtk_entry_new_with_max_length(128);
+ text = gtk_entry_new();
xsane_back_gtk_set_tooltip(xsane.tooltips, text, DESC_FAXRECEIVER);
+ gtk_entry_set_max_length(GTK_ENTRY(text), 128);
gtk_box_pack_start(GTK_BOX(hbox), text, TRUE, TRUE, 4);
- gtk_signal_connect(GTK_OBJECT(text), "changed", (GtkSignalFunc) xsane_fax_receiver_changed_callback, NULL);
+ g_signal_connect(GTK_OBJECT(text), "changed", (GtkSignalFunc) xsane_fax_receiver_changed_callback, NULL);
xsane.fax_receiver_entry = text;
@@ -3594,14 +3619,14 @@ static void xsane_fax_dialog()
/* fine mode */
button = gtk_check_button_new_with_label(RADIO_BUTTON_FINE_MODE);
xsane_back_gtk_set_tooltip(xsane.tooltips, button, DESC_FAX_FINE_MODE);
- gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button), xsane.fax_fine_mode);
+ gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button), preferences.fax_fine_mode);
gtk_box_pack_start(GTK_BOX(fax_project_vbox), button, FALSE, FALSE, 2);
gtk_widget_show(button);
- gtk_signal_connect(GTK_OBJECT(button), "clicked", (GtkSignalFunc) xsane_fax_fine_mode_callback, NULL);
+ g_signal_connect(GTK_OBJECT(button), "clicked", (GtkSignalFunc) xsane_fax_fine_mode_callback, NULL);
scrolled_window = gtk_scrolled_window_new(0, 0);
- gtk_widget_set_usize(scrolled_window, 200, 100);
+ gtk_widget_set_size_request(scrolled_window, 200, 100);
gtk_container_add(GTK_CONTAINER(fax_project_vbox), scrolled_window);
gtk_widget_show(scrolled_window);
@@ -3620,22 +3645,22 @@ static void xsane_fax_dialog()
gtk_box_pack_start(GTK_BOX(fax_project_vbox), hbox, FALSE, FALSE, 2);
button = gtk_button_new_with_label(BUTTON_FILE_INSERT);
- gtk_signal_connect(GTK_OBJECT(button), "clicked", (GtkSignalFunc) xsane_fax_entry_insert_callback, list);
+ g_signal_connect(GTK_OBJECT(button), "clicked", (GtkSignalFunc) xsane_fax_entry_insert_callback, list);
gtk_box_pack_start(GTK_BOX(hbox), button, TRUE, TRUE, 0);
gtk_widget_show(button);
button = gtk_button_new_with_label(BUTTON_PAGE_SHOW);
- gtk_signal_connect(GTK_OBJECT(button), "clicked", (GtkSignalFunc) xsane_fax_show_callback, list);
+ g_signal_connect(GTK_OBJECT(button), "clicked", (GtkSignalFunc) xsane_fax_show_callback, list);
gtk_box_pack_start(GTK_BOX(hbox), button, TRUE, TRUE, 0);
gtk_widget_show(button);
button = gtk_button_new_with_label(BUTTON_PAGE_RENAME);
- gtk_signal_connect(GTK_OBJECT(button), "clicked", (GtkSignalFunc) xsane_fax_entry_rename_callback, list);
+ g_signal_connect(GTK_OBJECT(button), "clicked", (GtkSignalFunc) xsane_fax_entry_rename_callback, list);
gtk_box_pack_start(GTK_BOX(hbox), button, TRUE, TRUE, 0);
gtk_widget_show(button);
button = gtk_button_new_with_label(BUTTON_PAGE_DELETE);
- gtk_signal_connect(GTK_OBJECT(button), "clicked", (GtkSignalFunc) xsane_fax_entry_delete_callback, list);
+ g_signal_connect(GTK_OBJECT(button), "clicked", (GtkSignalFunc) xsane_fax_entry_delete_callback, list);
gtk_box_pack_start(GTK_BOX(hbox), button, TRUE, TRUE, 0);
gtk_widget_show(button);
@@ -3658,12 +3683,12 @@ static void xsane_fax_dialog()
gtk_box_pack_start(GTK_BOX(hbox), fax_project_exists_hbox, TRUE, TRUE, 0);
button = gtk_button_new_with_label(BUTTON_SEND_PROJECT);
- gtk_signal_connect(GTK_OBJECT(button), "clicked", (GtkSignalFunc) xsane_fax_send, NULL);
+ g_signal_connect(GTK_OBJECT(button), "clicked", (GtkSignalFunc) xsane_fax_send, NULL);
gtk_box_pack_start(GTK_BOX(fax_project_exists_hbox), button, TRUE, TRUE, 0);
gtk_widget_show(button);
button = gtk_button_new_with_label(BUTTON_DELETE_PROJECT);
- gtk_signal_connect(GTK_OBJECT(button), "clicked", (GtkSignalFunc) xsane_fax_project_delete, NULL);
+ g_signal_connect(GTK_OBJECT(button), "clicked", (GtkSignalFunc) xsane_fax_project_delete, NULL);
gtk_box_pack_start(GTK_BOX(fax_project_exists_hbox), button, TRUE, TRUE, 0);
gtk_widget_show(button);
@@ -3671,10 +3696,18 @@ static void xsane_fax_dialog()
xsane.fax_project_exists = fax_project_exists_hbox;
button = gtk_button_new_with_label(BUTTON_CREATE_PROJECT);
- gtk_signal_connect(GTK_OBJECT(button), "clicked", (GtkSignalFunc) xsane_fax_project_create, NULL);
+ g_signal_connect(GTK_OBJECT(button), "clicked", (GtkSignalFunc) xsane_fax_project_create, NULL);
gtk_box_pack_start(GTK_BOX(hbox), button, TRUE, TRUE, 0);
xsane.fax_project_not_exists = button;
+ /* progress bar */
+ xsane.fax_progress_bar = (GtkProgressBar *) gtk_progress_bar_new();
+ gtk_box_pack_start(GTK_BOX(fax_scan_vbox), (GtkWidget *) xsane.fax_progress_bar, FALSE, FALSE, 0);
+ gtk_progress_set_show_text(GTK_PROGRESS(xsane.fax_progress_bar), TRUE);
+ gtk_progress_set_format_string(GTK_PROGRESS(xsane.fax_progress_bar), "");
+ gtk_widget_show(GTK_WIDGET(xsane.fax_progress_bar));
+
+
xsane.fax_dialog = fax_dialog;
xsane_fax_project_load();
@@ -3693,7 +3726,6 @@ static void xsane_fax_dialog_close()
return;
}
- gtk_accel_group_detach(xsane.accelerator_group, GTK_OBJECT(xsane.fax_dialog));
gtk_widget_destroy(xsane.fax_dialog);
xsane.fax_dialog = NULL;
@@ -3706,23 +3738,37 @@ static void xsane_fax_project_load()
{
FILE *projectfile;
char page[256];
- char buf[256];
+ char filename[PATH_MAX];
GtkWidget *list_item;
int i;
- char c;
+ int c;
DBG(DBG_proc, "xsane_fax_project_load\n");
- gtk_signal_disconnect_by_func(GTK_OBJECT(xsane.fax_receiver_entry), GTK_SIGNAL_FUNC(xsane_fax_receiver_changed_callback), 0);
+ if (xsane.fax_status)
+ {
+ free(xsane.fax_status);
+ xsane.fax_status = NULL;
+ }
+
+ if (xsane.fax_receiver)
+ {
+ free(xsane.fax_receiver);
+ xsane.fax_receiver = NULL;
+ }
+
+ g_signal_handlers_disconnect_by_func(GTK_OBJECT(xsane.fax_receiver_entry), GTK_SIGNAL_FUNC(xsane_fax_receiver_changed_callback), 0);
gtk_list_remove_items(GTK_LIST(xsane.fax_list), GTK_LIST(xsane.fax_list)->children);
- snprintf(buf, sizeof(buf), "%s/xsane-fax-list", preferences.fax_project);
- projectfile = fopen(buf, "rb"); /* read binary (b for win32) */
+ snprintf(filename, sizeof(filename), "%s/xsane-fax-list", preferences.fax_project);
+ projectfile = fopen(filename, "rb"); /* read binary (b for win32) */
if ((!projectfile) || (feof(projectfile)))
{
- snprintf(buf, sizeof(buf), "%s/page-1.ps", preferences.fax_project);
- xsane.fax_filename=strdup(buf);
+ xsane.fax_status=strdup(TEXT_FAX_STATUS_NOT_CREATED);
+
+ snprintf(filename, sizeof(filename), "%s/page-1.pnm", preferences.fax_project);
+ xsane.fax_filename=strdup(filename);
xsane_update_counter_in_filename(&xsane.fax_filename, FALSE, 0, preferences.filename_counter_len); /* correct counter len */
xsane.fax_receiver=strdup("");
@@ -3743,6 +3789,20 @@ static void xsane_fax_project_load()
page[i++] = c;
}
page[i-1] = 0;
+ if (strchr(page, '@'))
+ {
+ *strchr(page, '@') = 0;
+ }
+ xsane.fax_status = strdup(page);
+
+ i=0;
+ c=0;
+ while ((i<255) && (c != 10) && (c != EOF)) /* first line is receiver phone number or address */
+ {
+ c = fgetc(projectfile);
+ page[i++] = c;
+ }
+ page[i-1] = 0;
xsane.fax_receiver=strdup(page);
gtk_entry_set_text(GTK_ENTRY(xsane.fax_receiver_entry), (char *) xsane.fax_receiver);
@@ -3757,8 +3817,8 @@ static void xsane_fax_project_load()
}
page[i-1] = 0;
- snprintf(buf, sizeof(buf), "%s/%s", preferences.fax_project, page);
- xsane.fax_filename=strdup(buf);
+ snprintf(filename, sizeof(filename), "%s/%s", preferences.fax_project, page);
+ xsane.fax_filename=strdup(filename);
while (!feof(projectfile))
{
@@ -3774,8 +3834,23 @@ static void xsane_fax_project_load()
if (c > 1)
{
+ char *type;
+ char *extension;
+
+ extension = strrchr(page, '.');
+ if (extension)
+ {
+ type = strdup(extension);
+ *extension = 0;
+ }
+ else
+ {
+ type = strdup("");
+ }
+
list_item = gtk_list_item_new_with_label(page);
gtk_object_set_data(GTK_OBJECT(list_item), "list_item_data", strdup(page));
+ gtk_object_set_data(GTK_OBJECT(list_item), "list_item_type", strdup(type));
gtk_container_add(GTK_CONTAINER(xsane.fax_list), list_item);
gtk_widget_show(list_item);
}
@@ -3791,7 +3866,10 @@ static void xsane_fax_project_load()
fclose(projectfile);
}
- gtk_signal_connect(GTK_OBJECT(xsane.fax_receiver_entry), "changed", (GtkSignalFunc) xsane_fax_receiver_changed_callback, NULL);
+ g_signal_connect(GTK_OBJECT(xsane.fax_receiver_entry), "changed", (GtkSignalFunc) xsane_fax_receiver_changed_callback, NULL);
+
+ gtk_progress_set_format_string(GTK_PROGRESS(xsane.fax_progress_bar), _(xsane.fax_status));
+ gtk_progress_bar_update(GTK_PROGRESS_BAR(xsane.fax_progress_bar), 0.0);
}
/* ---------------------------------------------------------------------------------------------------------------------- */
@@ -3810,7 +3888,7 @@ static void xsane_fax_project_delete()
list_item = GTK_OBJECT(list->data);
page = strdup((char *) gtk_object_get_data(list_item, "list_item_data"));
xsane_convert_text_to_filename(&page);
- snprintf(file, sizeof(file), "%s/%s.ps", preferences.fax_project, page);
+ snprintf(file, sizeof(file), "%s/%s.pnm", preferences.fax_project, page);
free(page);
remove(file);
list = list->next;
@@ -3825,10 +3903,28 @@ static void xsane_fax_project_delete()
/* ---------------------------------------------------------------------------------------------------------------------- */
+static void xsane_fax_project_update_project_status()
+{
+ FILE *projectfile;
+ char filename[PATH_MAX];
+ char buf[256];
+
+ snprintf(filename, sizeof(filename), "%s/xsane-fax-list", preferences.fax_project);
+ projectfile = fopen(filename, "r+b"); /* r+ = read and write, position = start of file */
+
+ snprintf(buf, 32, "%s@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@", xsane.fax_status); /* fill 32 characters status line */
+ fprintf(projectfile, "%s\n", buf); /* first line is status of mail */
+
+ fclose(projectfile);
+}
+
+/* ---------------------------------------------------------------------------------------------------------------------- */
+
void xsane_fax_project_save()
{
FILE *projectfile;
char *page;
+ char *type;
char filename[256];
GList *list = (GList *) GTK_LIST(xsane.fax_list)->children;
GtkObject *list_item;
@@ -3858,6 +3954,22 @@ void xsane_fax_project_save()
return;
}
+ if (xsane.fax_status)
+ {
+ char buf[256];
+
+ snprintf(buf, 32, "%s@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@", xsane.fax_status); /* fill 32 characters status line */
+ fprintf(projectfile, "%s\n", buf); /* first line is status of mail */
+ gtk_progress_set_format_string(GTK_PROGRESS(xsane.fax_progress_bar), _(xsane.fax_status));
+ gtk_progress_bar_update(GTK_PROGRESS_BAR(xsane.fax_progress_bar), 0.0);
+ }
+ else
+ {
+ fprintf(projectfile, " \n"); /* no mail status */
+ gtk_progress_set_format_string(GTK_PROGRESS(xsane.fax_progress_bar), "");
+ gtk_progress_bar_update(GTK_PROGRESS_BAR(xsane.fax_progress_bar), 0.0);
+ }
+
if (xsane.fax_receiver)
{
fprintf(projectfile, "%s\n", xsane.fax_receiver); /* first line is receiver phone number or address */
@@ -3881,7 +3993,8 @@ void xsane_fax_project_save()
{
list_item = GTK_OBJECT(list->data);
page = (char *) gtk_object_get_data(list_item, "list_item_data");
- fprintf(projectfile, "%s\n", page);
+ type = (char *) gtk_object_get_data(list_item, "list_item_type");
+ fprintf(projectfile, "%s%s\n", page, type);
list = list->next;
}
fclose(projectfile);
@@ -3895,6 +4008,11 @@ static void xsane_fax_project_create()
if (strlen(preferences.fax_project))
{
+ if (xsane.fax_status)
+ {
+ free(xsane.fax_status);
+ }
+ xsane.fax_status = strdup(TEXT_FAX_STATUS_CREATED);
xsane_fax_project_save();
xsane_fax_project_load();
}
@@ -3906,6 +4024,12 @@ static void xsane_fax_receiver_changed_callback(GtkWidget *widget, gpointer data
{
DBG(DBG_proc, "xsane_fax_receiver_changed_callback\n");
+ if (xsane.fax_status)
+ {
+ free(xsane.fax_status);
+ }
+ xsane.fax_status = strdup(TEXT_FAX_STATUS_CHANGED);
+
if (xsane.fax_receiver)
{
free((void *) xsane.fax_receiver);
@@ -3913,6 +4037,9 @@ static void xsane_fax_receiver_changed_callback(GtkWidget *widget, gpointer data
xsane.fax_receiver = strdup(gtk_entry_get_text(GTK_ENTRY(widget)));
xsane_fax_project_save();
+
+ gtk_progress_set_format_string(GTK_PROGRESS(xsane.fax_progress_bar), _(xsane.fax_status));
+ gtk_progress_bar_update(GTK_PROGRESS_BAR(xsane.fax_progress_bar), 0.0);
}
/* ---------------------------------------------------------------------------------------------------------------------- */
@@ -3936,25 +4063,31 @@ static void xsane_fax_fine_mode_callback(GtkWidget * widget)
{
DBG(DBG_proc, "xsane_fax_fine_mode_callback\n");
- xsane.fax_fine_mode = (GTK_TOGGLE_BUTTON(widget)->active != 0);
+ preferences.fax_fine_mode = (GTK_TOGGLE_BUTTON(widget)->active != 0);
}
/* ---------------------------------------------------------------------------------------------------------------------- */
static void xsane_list_entrys_swap(GtkWidget *list_item_1, GtkWidget *list_item_2)
{
- char *text1;
- char *text2;
+ char *page1;
+ char *page2;
+ char *type1;
+ char *type2;
DBG(DBG_proc, "xsane_list_entrys_swap\n");
- text1 = (char *) gtk_object_get_data(GTK_OBJECT(list_item_1), "list_item_data");
- text2 = (char *) gtk_object_get_data(GTK_OBJECT(list_item_2), "list_item_data");
-
- gtk_label_set(GTK_LABEL(gtk_container_children(GTK_CONTAINER(list_item_1))->data), text2);
- gtk_label_set(GTK_LABEL(gtk_container_children(GTK_CONTAINER(list_item_2))->data), text1);
- gtk_object_set_data(GTK_OBJECT(list_item_1), "list_item_data", text2);
- gtk_object_set_data(GTK_OBJECT(list_item_2), "list_item_data", text1);
+ page1 = (char *) gtk_object_get_data(GTK_OBJECT(list_item_1), "list_item_data");
+ type1 = (char *) gtk_object_get_data(GTK_OBJECT(list_item_1), "list_item_type");
+ page2 = (char *) gtk_object_get_data(GTK_OBJECT(list_item_2), "list_item_data");
+ type2 = (char *) gtk_object_get_data(GTK_OBJECT(list_item_2), "list_item_type");
+
+ gtk_label_set(GTK_LABEL(gtk_container_children(GTK_CONTAINER(list_item_1))->data), page2);
+ gtk_label_set(GTK_LABEL(gtk_container_children(GTK_CONTAINER(list_item_2))->data), page1);
+ gtk_object_set_data(GTK_OBJECT(list_item_1), "list_item_data", page2);
+ gtk_object_set_data(GTK_OBJECT(list_item_1), "list_item_type", type2);
+ gtk_object_set_data(GTK_OBJECT(list_item_2), "list_item_data", page1);
+ gtk_object_set_data(GTK_OBJECT(list_item_2), "list_item_type", type1);
}
/* ---------------------------------------------------------------------------------------------------------------------- */
@@ -4058,6 +4191,7 @@ static void xsane_fax_entry_rename_callback(GtkWidget *widget, gpointer list)
GList *select;
char *oldpage;
char *newpage;
+ char *type;
char oldfile[256];
char newfile[256];
@@ -4070,14 +4204,15 @@ static void xsane_fax_entry_rename_callback(GtkWidget *widget, gpointer list)
GtkWidget *text;
GtkWidget *button;
GtkWidget *vbox, *hbox;
- char buf[256];
+ char filename[PATH_MAX];
list_item = select->data;
oldpage = strdup((char *) gtk_object_get_data(GTK_OBJECT(list_item), "list_item_data"));
+ type = strdup((char *) gtk_object_get_data(GTK_OBJECT(list_item), "list_item_type"));
xsane_set_sensitivity(FALSE);
- rename_dialog = gtk_window_new(GTK_WINDOW_DIALOG);
+ rename_dialog = gtk_window_new(GTK_WINDOW_TOPLEVEL);
xsane_set_window_icon(rename_dialog, 0);
/* set the main vbox */
@@ -4094,27 +4229,36 @@ static void xsane_fax_entry_rename_callback(GtkWidget *widget, gpointer list)
gtk_widget_show(hbox);
gtk_window_set_position(GTK_WINDOW(rename_dialog), GTK_WIN_POS_CENTER);
- gtk_window_set_policy(GTK_WINDOW(rename_dialog), FALSE, FALSE, FALSE);
- snprintf(buf, sizeof(buf), "%s %s", xsane.prog_name, WINDOW_FAX_RENAME);
- gtk_window_set_title(GTK_WINDOW(rename_dialog), buf);
- gtk_signal_connect(GTK_OBJECT(rename_dialog), "delete_event", (GtkSignalFunc) xsane_fax_entry_rename_button_callback, (void *) -1);
+ gtk_window_set_resizable(GTK_WINDOW(rename_dialog), FALSE);
+ snprintf(filename, sizeof(filename), "%s %s", xsane.prog_name, WINDOW_FAX_RENAME);
+ gtk_window_set_title(GTK_WINDOW(rename_dialog), filename);
+ g_signal_connect(GTK_OBJECT(rename_dialog), "delete_event", (GtkSignalFunc) xsane_fax_entry_rename_button_callback,(void *) -1);
gtk_widget_show(rename_dialog);
- text = gtk_entry_new_with_max_length(64);
+ text = gtk_entry_new();
xsane_back_gtk_set_tooltip(xsane.tooltips, text, DESC_FAXPAGENAME);
+ gtk_entry_set_max_length(GTK_ENTRY(text), 64);
gtk_entry_set_text(GTK_ENTRY(text), oldpage);
- gtk_widget_set_usize(text, 300, 0);
+ gtk_widget_set_size_request(text, 300, -1);
gtk_box_pack_start(GTK_BOX(vbox), text, TRUE, TRUE, 4);
gtk_widget_show(text);
- button = gtk_button_new_with_label("OK");
- gtk_signal_connect(GTK_OBJECT(button), "clicked", (GtkSignalFunc) xsane_fax_entry_rename_button_callback, (void *) 1);
+#ifdef HAVE_GTK2
+ button = gtk_button_new_from_stock(GTK_STOCK_OK);
+#else
+ button = gtk_button_new_with_label(BUTTON_OK);
+#endif
+ g_signal_connect(GTK_OBJECT(button), "clicked", (GtkSignalFunc) xsane_fax_entry_rename_button_callback, (void *) 1);
gtk_box_pack_start(GTK_BOX(hbox), button, TRUE, TRUE, 0);
gtk_widget_show(button);
- button = gtk_button_new_with_label("Cancel");
- gtk_signal_connect(GTK_OBJECT(button), "clicked", (GtkSignalFunc) xsane_fax_entry_rename_button_callback, (void *) -1);
+#ifdef HAVE_GTK2
+ button = gtk_button_new_from_stock(GTK_STOCK_CANCEL);
+#else
+ button = gtk_button_new_with_label(BUTTON_CANCEL);
+#endif
+ g_signal_connect(GTK_OBJECT(button), "clicked", (GtkSignalFunc) xsane_fax_entry_rename_button_callback, (void *) -1);
gtk_box_pack_start(GTK_BOX(hbox), button, TRUE, TRUE, 0);
gtk_widget_show(button);
@@ -4138,8 +4282,8 @@ static void xsane_fax_entry_rename_callback(GtkWidget *widget, gpointer list)
xsane_convert_text_to_filename(&oldpage);
xsane_convert_text_to_filename(&newpage);
- snprintf(oldfile, sizeof(oldfile), "%s/%s.ps", preferences.fax_project, oldpage);
- snprintf(newfile, sizeof(newfile), "%s/%s.ps", preferences.fax_project, newpage);
+ snprintf(oldfile, sizeof(oldfile), "%s/%s%s", preferences.fax_project, oldpage, type);
+ snprintf(newfile, sizeof(newfile), "%s/%s%s", preferences.fax_project, newpage, type);
rename(oldfile, newfile);
@@ -4148,6 +4292,7 @@ static void xsane_fax_entry_rename_callback(GtkWidget *widget, gpointer list)
free(oldpage);
free(newpage);
+ free(type);
gtk_widget_destroy(rename_dialog);
@@ -4160,14 +4305,11 @@ static void xsane_fax_entry_rename_callback(GtkWidget *widget, gpointer list)
static void xsane_fax_entry_insert_callback(GtkWidget *widget, gpointer list)
{
GtkWidget *list_item;
- char filename[1024];
+ char filename[PATH_MAX];
char windowname[255];
DBG(DBG_proc, "xsane_fax_entry_insert_callback\n");
- xsane_clear_histogram(&xsane.histogram_raw);
- xsane_clear_histogram(&xsane.histogram_enh);
-
xsane_set_sensitivity(FALSE);
snprintf(windowname, sizeof(windowname), "%s %s %s", xsane.prog_name, WINDOW_FAX_INSERT, preferences.fax_project);
@@ -4175,7 +4317,7 @@ static void xsane_fax_entry_insert_callback(GtkWidget *widget, gpointer list)
umask((mode_t) preferences.directory_umask); /* define new file permissions */
- if (!xsane_back_gtk_get_filename(windowname, filename, sizeof(filename), filename, TRUE, FALSE, FALSE)) /* filename is selected */
+ if (!xsane_back_gtk_get_filename(windowname, filename, sizeof(filename), filename, NULL, TRUE, FALSE, FALSE, FALSE)) /* filename is selected */
{
FILE *sourcefile;
@@ -4184,34 +4326,48 @@ static void xsane_fax_entry_insert_callback(GtkWidget *widget, gpointer list)
{
char buf[1024];
- fgets(buf, 1024, sourcefile);
+ fgets(buf, sizeof(buf), sourcefile);
if (!strncmp("%!PS", buf, 4))
{
FILE *destfile;
-
+ char destpath[PATH_MAX];
+ char *destfilename;
+ char *destfiletype;
+ char *extension;
+
+ destfilename = strdup(strrchr(filename, '/')+1);
+ extension = strrchr(destfilename, '.');
+ if (extension)
+ {
+ destfiletype = strdup(extension);
+ *extension = 0;
+ }
+ else
+ {
+ destfiletype = strdup("");
+ }
+
+ snprintf(destpath, sizeof(destpath), "%s/%s%s", preferences.fax_project, destfilename, destfiletype);
/* copy file to project directory */
- if (xsane_create_secure_file(xsane.fax_filename)) /* remove possibly existing symbolic links for security
+ if (xsane_create_secure_file(destpath)) /* remove possibly existing symbolic links for security
*/
{
fclose(sourcefile);
- snprintf(buf, sizeof(buf), "%s %s %s\n", ERR_DURING_SAVE, ERR_CREATE_SECURE_FILE, xsane.fax_filename);
+ snprintf(buf, sizeof(buf), "%s %s %s\n", ERR_DURING_SAVE, ERR_CREATE_SECURE_FILE, destpath);
xsane_back_gtk_error(buf, TRUE);
return; /* error */
}
- destfile = fopen(xsane.fax_filename, "wb"); /* write binary (b for win32) */
+ destfile = fopen(destpath, "wb"); /* write binary (b for win32) */
if (destfile) /* file is created */
{
- char *extension;
- char *page;
-
fprintf(destfile, "%s\n", buf);
while (!feof(sourcefile))
{
- fgets(buf, 1024, sourcefile);
+ fgets(buf, sizeof(buf), sourcefile);
fprintf(destfile, "%s", buf);
}
@@ -4219,21 +4375,15 @@ static void xsane_fax_entry_insert_callback(GtkWidget *widget, gpointer list)
/* add filename to fax page list */
- page = strdup(strrchr(xsane.fax_filename,'/')+1);
- extension = strrchr(page, '.');
- if (extension)
- {
- *extension = 0;
- }
-
- list_item = gtk_list_item_new_with_label(page);
- gtk_object_set_data(GTK_OBJECT(list_item), "list_item_data", strdup(page));
+ list_item = gtk_list_item_new_with_label(destfilename);
+ gtk_object_set_data(GTK_OBJECT(list_item), "list_item_data", strdup(destfilename));
+ gtk_object_set_data(GTK_OBJECT(list_item), "list_item_type", strdup(destfiletype));
gtk_container_add(GTK_CONTAINER(xsane.fax_list), list_item);
gtk_widget_show(list_item);
xsane_update_counter_in_filename(&xsane.fax_filename, TRUE, 1, preferences.filename_counter_len);
xsane_fax_project_save();
- free(page);
+ free(destfilename);
}
else /* file could not be created */
{
@@ -4260,7 +4410,6 @@ static void xsane_fax_entry_insert_callback(GtkWidget *widget, gpointer list)
umask(XSANE_DEFAULT_UMASK); /* define new file permissions */
xsane_set_sensitivity(TRUE);
- xsane_update_histogram(TRUE /* update raw */);
}
/* ---------------------------------------------------------------------------------------------------------------------- */
@@ -4270,7 +4419,8 @@ static void xsane_fax_entry_delete_callback(GtkWidget *widget, gpointer list)
GtkObject *list_item;
GList *select;
char *page;
- char file[256];
+ char *type;
+ char filename[PATH_MAX];
DBG(DBG_proc, "xsane_fax_entry_delete_callback\n");
@@ -4279,10 +4429,12 @@ static void xsane_fax_entry_delete_callback(GtkWidget *widget, gpointer list)
{
list_item = GTK_OBJECT(select->data);
page = strdup((char *) gtk_object_get_data(list_item, "list_item_data"));
+ type = strdup((char *) gtk_object_get_data(list_item, "list_item_type"));
xsane_convert_text_to_filename(&page);
- snprintf(file, sizeof(file), "%s/%s.ps", preferences.fax_project, page);
+ snprintf(filename, sizeof(filename), "%s/%s%s", preferences.fax_project, page, type);
free(page);
- remove(file);
+ free(type);
+ remove(filename);
gtk_widget_destroy(GTK_WIDGET(list_item));
xsane_fax_project_save();
}
@@ -4294,42 +4446,162 @@ static void xsane_fax_show_callback(GtkWidget *widget, gpointer list)
{
GtkObject *list_item;
GList *select;
- pid_t pid;
- char *arg[100];
char *page;
- char buf[256];
- int argnr;
+ char *type;
+ char filename[256];
DBG(DBG_proc, "xsane_fax_entry_show_callback\n");
select = GTK_LIST(list)->selection;
if (select)
{
- argnr = xsane_parse_options(preferences.fax_viewer, arg);
-
list_item = GTK_OBJECT(select->data);
- page = (char *) gtk_object_get_data(list_item, "list_item_data");
- page = strdup(page);
+ page = strdup((char *) gtk_object_get_data(list_item, "list_item_data"));
+ type = strdup((char *) gtk_object_get_data(list_item, "list_item_type"));
xsane_convert_text_to_filename(&page);
- snprintf(buf, sizeof(buf), "%s/%s.ps", preferences.fax_project, page);
+ snprintf(filename, sizeof(filename), "%s/%s%s", preferences.fax_project, page, type);
+
+ if (!strncmp(type, ".pnm", 4))
+ {
+ /* when we do not allow any modification then we can work with the original file */
+ /* so we do not have to copy the image into a dummy file here! */
+
+ xsane_viewer_new(filename, FALSE, filename, VIEWER_NO_MODIFICATION);
+ }
+ else if (!strncmp(type, ".ps", 3))
+ {
+ char *arg[100];
+ int argnr;
+ pid_t pid;
+
+ argnr = xsane_parse_options(preferences.fax_viewer, arg);
+ arg[argnr++] = filename;
+ arg[argnr] = 0;
+
+ pid = fork();
+
+ if (pid == 0) /* new process */
+ {
+ FILE *ipc_file = NULL;
+
+ if (xsane.ipc_pipefd[0])
+ {
+ close(xsane.ipc_pipefd[0]); /* close reading end of pipe */
+ ipc_file = fdopen(xsane.ipc_pipefd[1], "w");
+ }
+
+ DBG(DBG_info, "trying to change user id fo new subprocess:\n");
+ DBG(DBG_info, "old effective uid = %d\n", (int) geteuid());
+ setuid(getuid());
+ DBG(DBG_info, "new effective uid = %d\n", (int) geteuid());
+
+ execvp(arg[0], arg); /* does not return if successfully */
+ DBG(DBG_error, "%s %s\n", ERR_FAILED_EXEC_FAX_VIEWER, preferences.fax_viewer);
+
+ /* send error message via IPC pipe to parent process */
+ if (ipc_file)
+ {
+ fprintf(ipc_file, "%s %s:\n%s", ERR_FAILED_EXEC_FAX_VIEWER, preferences.fax_viewer, strerror(errno));
+ fflush(ipc_file); /* make sure message is displayed */
+ fclose(ipc_file);
+ }
+
+ _exit(0); /* do not use exit() here! otherwise gtk gets in trouble */
+ }
+ else /* parent process */
+ {
+ xsane_add_process_to_list(pid); /* add pid to child process list */
+ }
+ }
+
free(page);
- arg[argnr++] = buf;
- arg[argnr] = 0;
+ free(type);
+ }
+}
- pid = fork();
+/* ---------------------------------------------------------------------------------------------------------------------- */
- if (pid == 0) /* new process */
+static int xsane_fax_convert_pnm_to_ps(char *source_filename, char *fax_filename)
+{
+ FILE *outfile;
+ FILE *infile;
+ Image_info image_info;
+ char buf[256];
+ int cancel_save;
+
+ /* open progressbar */
+ snprintf(buf, sizeof(buf), "%s - %s", PROGRESS_CONVERTING_DATA, source_filename);
+ gtk_progress_set_format_string(GTK_PROGRESS(xsane.fax_progress_bar), buf);
+ gtk_progress_bar_update(GTK_PROGRESS_BAR(xsane.fax_progress_bar), 0.0);
+
+ while (gtk_events_pending())
+ {
+ DBG(DBG_info, "calling gtk_main_iteration\n");
+ gtk_main_iteration();
+ }
+
+ infile = fopen(source_filename, "rb"); /* read binary (b for win32) */
+ if (infile != 0)
+ {
+ xsane_read_pnm_header(infile, &image_info);
+
+ umask((mode_t) preferences.image_umask); /* define image file permissions */
+ outfile = fopen(fax_filename, "wb"); /* b = binary mode for win32 */
+ umask(XSANE_DEFAULT_UMASK); /* define new file permissions */
+ if (outfile != 0)
{
- DBG(DBG_info, "trying to change user id fo new subprocess:\n");
- DBG(DBG_info, "old effective uid = %d\n", geteuid());
- setuid(getuid());
- DBG(DBG_info, "new effective uid = %d\n", geteuid());
+ float imagewidth, imageheight;
+
+ imagewidth = 72.0 * image_info.image_width /image_info.resolution_x; /* width in 1/72 inch */
+ imageheight = 72.0 * image_info.image_height/image_info.resolution_y; /* height in 1/72 inch */
+
+ DBG(DBG_info, "imagewidth = %f 1/72 inch\n", imagewidth);
+ DBG(DBG_info, "imageheight = %f 1/72 inch\n", imageheight);
+
+ xsane_save_ps(outfile, infile,
+ &image_info,
+ imagewidth, imageheight,
+ preferences.fax_leftoffset * 72.0/MM_PER_INCH, /* paper_left_margin */
+ preferences.fax_bottomoffset * 72.0/MM_PER_INCH, /* paper_bottom_margin */
+ preferences.fax_width * 72.0/MM_PER_INCH, /* paper_width */
+ preferences.fax_height * 72.0/MM_PER_INCH, /* paper_height */
+ 0 /* portrait top left */,
+ xsane.fax_progress_bar,
+ &cancel_save);
+ fclose(outfile);
+ }
+ else
+ {
+ char buf[256];
- execvp(arg[0], arg); /* does not return if successfully */
- DBG(DBG_error, "%s %s\n", ERR_FAILED_EXEC_FAX_VIEWER, preferences.fax_viewer);
- _exit(0); /* do not use exit() here! otherwise gtk gets in trouble */
+ DBG(DBG_info, "open of faxfile `%s'failed : %s\n", fax_filename, strerror(errno));
+
+ snprintf(buf, sizeof(buf), "%s `%s': %s", ERR_OPEN_FAILED, fax_filename, strerror(errno));
+ xsane_back_gtk_error(buf, TRUE);
}
+
+ fclose(infile);
}
+ else
+ {
+ char buf[256];
+
+ DBG(DBG_info, "open of faxfile `%s'failed : %s\n", source_filename, strerror(errno));
+
+ snprintf(buf, sizeof(buf), "%s `%s': %s", ERR_OPEN_FAILED, source_filename, strerror(errno));
+ xsane_back_gtk_error(buf, TRUE);
+ }
+
+ gtk_progress_set_format_string(GTK_PROGRESS(xsane.fax_progress_bar), "");
+ gtk_progress_bar_update(GTK_PROGRESS_BAR(xsane.fax_progress_bar), 0.0);
+
+ while (gtk_events_pending())
+ {
+ DBG(DBG_info, "calling gtk_main_iteration\n");
+ gtk_main_iteration();
+ }
+
+ return 0;
}
/* ---------------------------------------------------------------------------------------------------------------------- */
@@ -4337,11 +4609,15 @@ static void xsane_fax_show_callback(GtkWidget *widget, gpointer list)
static void xsane_fax_send()
{
char *page;
+ char *type;
+ char *fax_type=".ps";
GList *list = (GList *) GTK_LIST(xsane.fax_list)->children;
GtkObject *list_item;
pid_t pid;
char *arg[1000];
char buf[256];
+ char source_filename[PATH_MAX];
+ char fax_filename[PATH_MAX];
int argnr = 0;
int i;
@@ -4356,14 +4632,12 @@ static void xsane_fax_send()
return;
}
- xsane_clear_histogram(&xsane.histogram_raw);
- xsane_clear_histogram(&xsane.histogram_enh);
-
xsane_set_sensitivity(FALSE);
+ /* gtk_widget_set_sensitive(xsane.fax_dialog, FALSE); */
argnr = xsane_parse_options(preferences.fax_command, arg);
- if (xsane.fax_fine_mode) /* fine mode */
+ if (preferences.fax_fine_mode) /* fine mode */
{
if (xsane_option_defined(preferences.fax_fine_option))
{
@@ -4393,11 +4667,33 @@ static void xsane_fax_send()
{
list_item = GTK_OBJECT(list->data);
page = strdup((char *) gtk_object_get_data(list_item, "list_item_data"));
+ type = strdup((char *) gtk_object_get_data(list_item, "list_item_type"));
xsane_convert_text_to_filename(&page);
- snprintf(buf, sizeof(buf), "%s/%s.ps", preferences.fax_project, page);
- free(page);
- arg[argnr++] = strdup(buf);
+ snprintf(source_filename, sizeof(source_filename), "%s/%s%s", preferences.fax_project, page, type);
+ snprintf(fax_filename, sizeof(fax_filename), "%s/%s-fax%s", preferences.fax_project, page, fax_type);
+ if (xsane_create_secure_file(fax_filename)) /* remove possibly existing symbolic links for security */
+ {
+ char buf[256];
+
+ snprintf(buf, sizeof(buf), "%s %s %s\n", ERR_DURING_SAVE, ERR_CREATE_SECURE_FILE, fax_filename);
+ xsane_back_gtk_error(buf, TRUE);
+ return; /* error */
+ }
+
+ if (!strncmp(type, ".pnm", 4))
+ {
+ DBG(DBG_info, "converting %s to %s\n", source_filename, fax_filename);
+ xsane_fax_convert_pnm_to_ps(source_filename, fax_filename);
+ }
+ else if (!strncmp(type, ".ps", 3))
+ {
+ int cancel_save = 0;
+ xsane_copy_file_by_name(fax_filename, source_filename, xsane.fax_progress_bar, &cancel_save);
+ }
+ arg[argnr++] = strdup(fax_filename);
list = list->next;
+ free(page);
+ free(type);
}
arg[argnr] = 0;
@@ -4406,27 +4702,57 @@ static void xsane_fax_send()
if (pid == 0) /* new process */
{
- DBG(DBG_info, "trying to change user id fo new subprocess:\n");
- DBG(DBG_info, "old effective uid = %d\n", geteuid());
+ FILE *ipc_file = NULL;
+
+ if (xsane.ipc_pipefd[0])
+ {
+ close(xsane.ipc_pipefd[0]); /* close reading end of pipe */
+ ipc_file = fdopen(xsane.ipc_pipefd[1], "w");
+ }
+
+ DBG(DBG_info, "trying to change user id for new subprocess:\n");
+ DBG(DBG_info, "old effective uid = %d\n", (int) geteuid());
setuid(getuid());
- DBG(DBG_info, "new effective uid = %d\n", geteuid());
+ DBG(DBG_info, "new effective uid = %d\n", (int) geteuid());
execvp(arg[0], arg); /* does not return if successfully */
DBG(DBG_error, "%s %s\n", ERR_FAILED_EXEC_FAX_CMD, preferences.fax_command);
+
+ /* send error message via IPC pipe to parent process */
+ if (ipc_file)
+ {
+ fprintf(ipc_file, "%s %s:\n%s", ERR_FAILED_EXEC_FAX_CMD, preferences.fax_command, strerror(errno));
+ fflush(ipc_file); /* make sure message is displayed */
+ fclose(ipc_file);
+ }
+
_exit(0); /* do not use exit() here! otherwise gtk gets in trouble */
}
+ else /* parent process */
+ {
+ xsane_add_process_to_list(pid); /* add pid to child process list */
+ }
for (i=0; i<argnr; i++)
{
free(arg[i]);
}
+ if (xsane.fax_status)
+ {
+ free(xsane.fax_status);
+ }
+ xsane.fax_status = strdup(TEXT_FAX_STATUS_QUEUEING_FAX);
+ xsane_fax_project_update_project_status();
+ gtk_progress_set_format_string(GTK_PROGRESS(xsane.fax_progress_bar), _(xsane.fax_status));
+ gtk_progress_bar_update(GTK_PROGRESS_BAR(xsane.fax_progress_bar), 0.0);
+
while (pid)
{
int status = 0;
pid_t pid_status = waitpid(pid, &status, WNOHANG);
- if (pid == pid_status)
+ if ( (pid_status < 0 ) || (pid == pid_status) )
{
pid = 0; /* ok, child process has terminated */
}
@@ -4437,16 +4763,54 @@ static void xsane_fax_send()
}
}
+ /* delete created fax files */
+ list = (GList *) GTK_LIST(xsane.fax_list)->children;
+ while (list)
+ {
+ list_item = GTK_OBJECT(list->data);
+ page = strdup((char *) gtk_object_get_data(list_item, "list_item_data"));
+ xsane_convert_text_to_filename(&page);
+ snprintf(fax_filename, sizeof(fax_filename), "%s/%s-fax%s", preferences.fax_project, page, fax_type);
+ free(page);
+
+ DBG(DBG_info, "removing %s\n", fax_filename);
+ remove(fax_filename);
+
+ list = list->next;
+ }
+
+ xsane.fax_status = strdup(TEXT_FAX_STATUS_FAX_QUEUED);
+ xsane_fax_project_update_project_status();
+ gtk_progress_set_format_string(GTK_PROGRESS(xsane.fax_progress_bar), _(xsane.fax_status));
+ gtk_progress_bar_update(GTK_PROGRESS_BAR(xsane.fax_progress_bar), 0.0);
+
xsane_set_sensitivity(TRUE);
- xsane_update_histogram(TRUE /* update raw */);
+
+ /* gtk_widget_set_sensitive(xsane.fax_dialog, TRUE); */
}
+
+ DBG(DBG_info, "xsane_fax_send: done\n");
}
/* ---------------------------------------------------------------------------------------------------------------------- */
#ifdef XSANE_ACTIVATE_MAIL
-static void xsane_mail_dialog_delete()
+static gint xsane_mail_dialog_delete()
{
+ return TRUE;
+}
+
+/* ---------------------------------------------------------------------------------------------------------------------- */
+
+static void xsane_mail_filetype_callback(GtkWidget *filetype_option_menu, char *filetype)
+{
+ DBG(DBG_proc, "xsane_mail_filetype_callback(%s)\n", filetype);
+
+ if (preferences.mail_filetype)
+ {
+ free(preferences.mail_filetype);
+ }
+ preferences.mail_filetype = strdup(filetype);
}
/* ---------------------------------------------------------------------------------------------------------------------- */
@@ -4458,12 +4822,15 @@ static void xsane_mail_dialog()
GtkWidget *hbox;
GtkWidget *scrolled_window, *list;
GtkWidget *pixmapwidget, *text;
- GtkWidget *vscrollbar;
GtkWidget *attachment_frame, *text_frame;
GtkWidget *label;
+ GtkWidget *filetype_menu, *filetype_item;
+ GtkWidget *filetype_option_menu;
GdkPixmap *pixmap;
GdkBitmap *mask;
char buf[64];
+ int filetype_nr;
+ int select_item;
DBG(DBG_proc, "xsane_mail_dialog\n");
@@ -4472,15 +4839,14 @@ static void xsane_mail_dialog()
return; /* window already is open */
}
- /* GTK_WINDOW_DIALOG looks better but does not place it nice*/
+ /* GTK_WINDOW_TOPLEVEL looks better but does not place it nice*/
mail_dialog = gtk_window_new(GTK_WINDOW_TOPLEVEL);
- gtk_window_set_title(GTK_WINDOW(mail_dialog), buf);
snprintf(buf, sizeof(buf), "%s %s", xsane.prog_name, WINDOW_MAIL_PROJECT);
gtk_window_set_title(GTK_WINDOW(mail_dialog), buf);
- gtk_signal_connect(GTK_OBJECT(mail_dialog), "delete_event", (GtkSignalFunc) xsane_mail_dialog_delete, NULL);
+ g_signal_connect(GTK_OBJECT(mail_dialog), "delete_event", (GtkSignalFunc) xsane_mail_dialog_delete, NULL);
xsane_set_window_icon(mail_dialog, 0);
- gtk_accel_group_attach(xsane.accelerator_group, GTK_OBJECT(mail_dialog));
+ gtk_window_add_accel_group(GTK_WINDOW(mail_dialog), xsane.accelerator_group);
/* set the main vbox */
mail_scan_vbox = gtk_vbox_new(FALSE, 0);
@@ -4495,17 +4861,19 @@ static void xsane_mail_dialog()
gtk_box_pack_start(GTK_BOX(mail_scan_vbox), hbox, FALSE, FALSE, 2);
pixmap = gdk_pixmap_create_from_xpm_d(xsane.shell->window, &mask, xsane.bg_trans, (gchar **) mail_xpm);
- pixmapwidget = gtk_pixmap_new(pixmap, mask);
+ pixmapwidget = gtk_image_new_from_pixmap(pixmap, mask);
gtk_box_pack_start(GTK_BOX(hbox), pixmapwidget, FALSE, FALSE, 2);
- gdk_pixmap_unref(pixmap);
+ gdk_drawable_unref(pixmap);
- text = gtk_entry_new_with_max_length(128);
+ text = gtk_entry_new();
xsane_back_gtk_set_tooltip(xsane.tooltips, text, DESC_MAILPROJECT);
+ gtk_entry_set_max_length(GTK_ENTRY(text), 128);
gtk_entry_set_text(GTK_ENTRY(text), (char *) preferences.mail_project);
gtk_box_pack_start(GTK_BOX(hbox), text, TRUE, TRUE, 4);
- gtk_signal_connect(GTK_OBJECT(text), "changed", (GtkSignalFunc) xsane_mail_project_changed_callback, NULL);
+ g_signal_connect(GTK_OBJECT(text), "changed", (GtkSignalFunc) xsane_mail_project_changed_callback, NULL);
xsane.mail_project_entry = text;
+ xsane.mail_project_entry_box = hbox;
gtk_widget_show(pixmapwidget);
gtk_widget_show(text);
@@ -4524,14 +4892,15 @@ static void xsane_mail_dialog()
gtk_widget_realize(mail_dialog);
pixmap = gdk_pixmap_create_from_xpm_d(mail_dialog->window, &mask, xsane.bg_trans, (gchar **) mailreceiver_xpm);
- pixmapwidget = gtk_pixmap_new(pixmap, mask);
+ pixmapwidget = gtk_image_new_from_pixmap(pixmap, mask);
gtk_box_pack_start(GTK_BOX(hbox), pixmapwidget, FALSE, FALSE, 2);
- gdk_pixmap_unref(pixmap);
+ gdk_drawable_unref(pixmap);
- text = gtk_entry_new_with_max_length(128);
+ text = gtk_entry_new();
+ gtk_entry_set_max_length(GTK_ENTRY(text), 128);
xsane_back_gtk_set_tooltip(xsane.tooltips, text, DESC_MAILRECEIVER);
gtk_box_pack_start(GTK_BOX(hbox), text, TRUE, TRUE, 4);
- gtk_signal_connect(GTK_OBJECT(text), "changed", (GtkSignalFunc) xsane_mail_receiver_changed_callback, NULL);
+ g_signal_connect(GTK_OBJECT(text), "changed", (GtkSignalFunc) xsane_mail_receiver_changed_callback, NULL);
xsane.mail_receiver_entry = text;
@@ -4548,14 +4917,15 @@ static void xsane_mail_dialog()
gtk_widget_realize(mail_dialog);
pixmap = gdk_pixmap_create_from_xpm_d(mail_dialog->window, &mask, xsane.bg_trans, (gchar **) subject_xpm);
- pixmapwidget = gtk_pixmap_new(pixmap, mask);
+ pixmapwidget = gtk_image_new_from_pixmap(pixmap, mask);
gtk_box_pack_start(GTK_BOX(hbox), pixmapwidget, FALSE, FALSE, 2);
- gdk_pixmap_unref(pixmap);
+ gdk_drawable_unref(pixmap);
- text = gtk_entry_new_with_max_length(128);
+ text = gtk_entry_new();
xsane_back_gtk_set_tooltip(xsane.tooltips, text, DESC_MAILSUBJECT);
+ gtk_entry_set_max_length(GTK_ENTRY(text), 128);
gtk_box_pack_start(GTK_BOX(hbox), text, TRUE, TRUE, 4);
- gtk_signal_connect(GTK_OBJECT(text), "changed", (GtkSignalFunc) xsane_mail_subject_changed_callback, NULL);
+ g_signal_connect(GTK_OBJECT(text), "changed", (GtkSignalFunc) xsane_mail_subject_changed_callback, NULL);
xsane.mail_subject_entry = text;
@@ -4574,19 +4944,47 @@ static void xsane_mail_dialog()
gtk_container_set_border_width(GTK_CONTAINER(hbox), 4);
gtk_container_add(GTK_CONTAINER(text_frame), hbox);
gtk_widget_show(hbox);
+
+#ifdef HAVE_GTK_TEXT_VIEW_H
+ {
+ GtkWidget *scrolled_window, *text_view, *text_buffer;
- /* Create the GtkText widget */
- text = gtk_text_new(NULL, NULL);
- gtk_text_set_editable(GTK_TEXT(text), TRUE); /* text is editable */
- gtk_text_set_word_wrap(GTK_TEXT(text), TRUE); /* wrap complete words */
- gtk_box_pack_start(GTK_BOX(hbox), text, TRUE, TRUE, 0);
- gtk_widget_show(text);
- xsane.mail_text_widget = text;
+ /* create a scrolled window to get a vertical scrollbar */
+ scrolled_window = gtk_scrolled_window_new(NULL, NULL);
+ gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolled_window), GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
+ gtk_container_add(GTK_CONTAINER(hbox), scrolled_window);
+ gtk_widget_show(scrolled_window);
+
+ /* create the gtk_text_view widget */
+ text_view = gtk_text_view_new();
+ gtk_text_view_set_editable(GTK_TEXT_VIEW(text_view), TRUE);
+ gtk_text_view_set_wrap_mode(GTK_TEXT_VIEW(text_view), GTK_WRAP_WORD);
+ gtk_container_add(GTK_CONTAINER(scrolled_window), text_view);
+ gtk_widget_show(text_view);
- /* Add a vertical scrollbar to the GtkText widget */
- vscrollbar = gtk_vscrollbar_new(GTK_TEXT(text)->vadj);
- gtk_box_pack_start(GTK_BOX(hbox), vscrollbar, FALSE, FALSE, 0);
- gtk_widget_show(vscrollbar);
+ /* get the text_buffer widget and insert the text from file */
+ text_buffer = (GtkWidget *) gtk_text_view_get_buffer(GTK_TEXT_VIEW(text_view));
+
+ xsane.mail_text_widget = text_buffer;
+ }
+#else
+ {
+ GtkWidget *vscrollbar;
+
+ /* Create the GtkText widget */
+ text = gtk_text_new(NULL, NULL);
+ gtk_text_set_editable(GTK_TEXT(text), TRUE); /* text is editable */
+ gtk_text_set_word_wrap(GTK_TEXT(text), TRUE); /* wrap complete words */
+ gtk_box_pack_start(GTK_BOX(hbox), text, TRUE, TRUE, 0);
+ gtk_widget_show(text);
+ xsane.mail_text_widget = text;
+
+ /* Add a vertical scrollbar to the GtkText widget */
+ vscrollbar = gtk_vscrollbar_new(GTK_TEXT(text)->vadj);
+ gtk_box_pack_start(GTK_BOX(hbox), vscrollbar, FALSE, FALSE, 0);
+ gtk_widget_show(vscrollbar);
+ }
+#endif
/* html mail */
@@ -4595,9 +4993,80 @@ static void xsane_mail_dialog()
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button), xsane.mail_html_mode);
gtk_box_pack_start(GTK_BOX(mail_project_vbox), button, FALSE, FALSE, 2);
gtk_widget_show(button);
- gtk_signal_connect(GTK_OBJECT(button), "clicked", (GtkSignalFunc) xsane_mail_html_mode_callback, NULL);
+ g_signal_connect(GTK_OBJECT(button), "clicked", (GtkSignalFunc) xsane_mail_html_mode_callback, NULL);
xsane.mail_html_mode_widget = button;
+ xsane_separator_new(mail_scan_vbox, 2);
+
+ /* FILETYPE MENU */
+ /* button box, active when project exists */
+ hbox = gtk_hbox_new(FALSE, 2);
+ gtk_container_set_border_width(GTK_CONTAINER(hbox), 2);
+ gtk_box_pack_start(GTK_BOX(mail_project_vbox), hbox, FALSE, FALSE, 2);
+ gtk_widget_show(hbox);
+
+ filetype_menu = gtk_menu_new();
+
+ filetype_nr = -1;
+ select_item = 0;
+
+
+#ifdef HAVE_LIBJPEG
+ filetype_item = gtk_menu_item_new_with_label(MENU_ITEM_FILETYPE_JPEG);
+ gtk_container_add(GTK_CONTAINER(filetype_menu), filetype_item);
+ g_signal_connect(GTK_OBJECT(filetype_item), "activate", (GtkSignalFunc) xsane_mail_filetype_callback, (void *) XSANE_FILETYPE_JPEG);
+ gtk_widget_show(filetype_item);
+ filetype_nr++;
+ if ( (preferences.mail_filetype) && (!strcasecmp(preferences.mail_filetype, XSANE_FILETYPE_JPEG)) )
+ {
+ select_item = filetype_nr;
+ }
+#endif
+
+
+#ifdef HAVE_LIBPNG
+#ifdef HAVE_LIBZ
+ filetype_item = gtk_menu_item_new_with_label(MENU_ITEM_FILETYPE_PNG);
+ gtk_container_add(GTK_CONTAINER(filetype_menu), filetype_item);
+ g_signal_connect(GTK_OBJECT(filetype_item), "activate", (GtkSignalFunc) xsane_mail_filetype_callback, (void *) XSANE_FILETYPE_PNG);
+ gtk_widget_show(filetype_item);
+ filetype_nr++;
+ if ( (preferences.mail_filetype) && (!strcasecmp(preferences.mail_filetype, XSANE_FILETYPE_PNG)) )
+ {
+ select_item = filetype_nr;
+ }
+#endif
+#endif
+
+
+#ifdef HAVE_LIBTIFF
+ filetype_item = gtk_menu_item_new_with_label(MENU_ITEM_FILETYPE_TIFF);
+ gtk_container_add(GTK_CONTAINER(filetype_menu), filetype_item);
+ g_signal_connect(GTK_OBJECT(filetype_item), "activate", (GtkSignalFunc) xsane_mail_filetype_callback, (void *) XSANE_FILETYPE_TIFF);
+ gtk_widget_show(filetype_item);
+ filetype_nr++;
+ if ( (preferences.mail_filetype) && (!strcasecmp(preferences.mail_filetype, XSANE_FILETYPE_TIFF)) )
+ {
+ select_item = filetype_nr;
+ }
+#endif
+
+ label = gtk_label_new(TEXT_MAIL_FILETYPE);
+ gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 2);
+ gtk_widget_show(label);
+
+ filetype_option_menu = gtk_option_menu_new();
+ xsane_back_gtk_set_tooltip(xsane.tooltips, filetype_option_menu, DESC_MAIL_FILETYPE);
+ gtk_option_menu_set_menu(GTK_OPTION_MENU(filetype_option_menu), filetype_menu);
+ if (select_item >= 0)
+ {
+ gtk_option_menu_set_history(GTK_OPTION_MENU(filetype_option_menu), select_item);
+ }
+ gtk_box_pack_end(GTK_BOX(hbox), filetype_option_menu, FALSE, FALSE, 2);
+ gtk_widget_show(filetype_menu);
+ gtk_widget_show(filetype_option_menu);
+
+
/* attachment frame */
attachment_frame = gtk_frame_new(TEXT_ATTACHMENTS);
gtk_box_pack_start(GTK_BOX(mail_project_vbox), attachment_frame, FALSE, FALSE, 2);
@@ -4605,7 +5074,7 @@ static void xsane_mail_dialog()
/* attachment list */
scrolled_window = gtk_scrolled_window_new(0, 0);
- gtk_widget_set_usize(scrolled_window, 200, 100);
+ gtk_widget_set_size_request(scrolled_window, 200, 100);
gtk_container_add(GTK_CONTAINER(attachment_frame), scrolled_window);
gtk_widget_show(scrolled_window);
@@ -4623,17 +5092,26 @@ static void xsane_mail_dialog()
gtk_box_pack_start(GTK_BOX(mail_project_vbox), hbox, FALSE, FALSE, 2);
button = gtk_button_new_with_label(BUTTON_IMAGE_SHOW);
- gtk_signal_connect(GTK_OBJECT(button), "clicked", (GtkSignalFunc) xsane_mail_show_callback, list);
+ g_signal_connect(GTK_OBJECT(button), "clicked", (GtkSignalFunc) xsane_mail_show_callback, list);
gtk_box_pack_start(GTK_BOX(hbox), button, TRUE, TRUE, 0);
gtk_widget_show(button);
+#if 0
+ /* before we enable the edit function we have to make sure that the rename function
+ does also rename the image name of the opened viewer */
+ button = gtk_button_new_with_label(BUTTON_IMAGE_EDIT);
+ g_signal_connect(GTK_OBJECT(button), "clicked", (GtkSignalFunc) xsane_mail_edit_callback, list);
+ gtk_box_pack_start(GTK_BOX(hbox), button, TRUE, TRUE, 0);
+ gtk_widget_show(button);
+#endif
+
button = gtk_button_new_with_label(BUTTON_IMAGE_RENAME);
- gtk_signal_connect(GTK_OBJECT(button), "clicked", (GtkSignalFunc) xsane_mail_entry_rename_callback, list);
+ g_signal_connect(GTK_OBJECT(button), "clicked", (GtkSignalFunc) xsane_mail_entry_rename_callback, list);
gtk_box_pack_start(GTK_BOX(hbox), button, TRUE, TRUE, 0);
gtk_widget_show(button);
button = gtk_button_new_with_label(BUTTON_IMAGE_DELETE);
- gtk_signal_connect(GTK_OBJECT(button), "clicked", (GtkSignalFunc) xsane_mail_entry_delete_callback, list);
+ g_signal_connect(GTK_OBJECT(button), "clicked", (GtkSignalFunc) xsane_mail_entry_delete_callback, list);
gtk_box_pack_start(GTK_BOX(hbox), button, TRUE, TRUE, 0);
gtk_widget_show(button);
@@ -4644,22 +5122,6 @@ static void xsane_mail_dialog()
xsane.mail_project_box = mail_project_vbox;
-
- /* status info */
- hbox = gtk_hbox_new(FALSE, 2);
- gtk_container_set_border_width(GTK_CONTAINER(hbox), 2);
- gtk_box_pack_start(GTK_BOX(mail_scan_vbox), hbox, FALSE, FALSE, 2);
- gtk_widget_show(hbox);
-
- label = gtk_label_new(TEXT_MAIL_STATUS);
- gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);
- gtk_widget_show(label);
-
- label = gtk_label_new("");
- gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);
- gtk_widget_show(label);
- xsane.mail_status_label = label;
-
xsane_separator_new(mail_scan_vbox, 2);
@@ -4675,12 +5137,12 @@ static void xsane_mail_dialog()
gtk_box_pack_start(GTK_BOX(hbox), mail_project_exists_hbox, TRUE, TRUE, 0);
button = gtk_button_new_with_label(BUTTON_SEND_PROJECT);
- gtk_signal_connect(GTK_OBJECT(button), "clicked", (GtkSignalFunc) xsane_mail_send, NULL);
+ g_signal_connect(GTK_OBJECT(button), "clicked", (GtkSignalFunc) xsane_mail_send, NULL);
gtk_box_pack_start(GTK_BOX(mail_project_exists_hbox), button, TRUE, TRUE, 0);
gtk_widget_show(button);
button = gtk_button_new_with_label(BUTTON_DELETE_PROJECT);
- gtk_signal_connect(GTK_OBJECT(button), "clicked", (GtkSignalFunc) xsane_mail_project_delete, NULL);
+ g_signal_connect(GTK_OBJECT(button), "clicked", (GtkSignalFunc) xsane_mail_project_delete, NULL);
gtk_box_pack_start(GTK_BOX(mail_project_exists_hbox), button, TRUE, TRUE, 0);
gtk_widget_show(button);
@@ -4688,10 +5150,18 @@ static void xsane_mail_dialog()
xsane.mail_project_exists = mail_project_exists_hbox;
button = gtk_button_new_with_label(BUTTON_CREATE_PROJECT);
- gtk_signal_connect(GTK_OBJECT(button), "clicked", (GtkSignalFunc) xsane_mail_project_create, NULL);
+ g_signal_connect(GTK_OBJECT(button), "clicked", (GtkSignalFunc) xsane_mail_project_create, NULL);
gtk_box_pack_start(GTK_BOX(hbox), button, TRUE, TRUE, 0);
xsane.mail_project_not_exists = button;
+ /* progress bar */
+ xsane.mail_progress_bar = (GtkProgressBar *) gtk_progress_bar_new();
+ gtk_box_pack_start(GTK_BOX(mail_scan_vbox), (GtkWidget *) xsane.mail_progress_bar, FALSE, FALSE, 0);
+ gtk_progress_set_show_text(GTK_PROGRESS(xsane.mail_progress_bar), TRUE);
+ gtk_progress_set_format_string(GTK_PROGRESS(xsane.mail_progress_bar), "");
+ gtk_widget_show(GTK_WIDGET(xsane.mail_progress_bar));
+
+
xsane.mail_dialog = mail_dialog;
xsane_mail_project_load();
@@ -4710,11 +5180,135 @@ static void xsane_mail_dialog_close()
return;
}
- gtk_accel_group_detach(xsane.accelerator_group, GTK_OBJECT(xsane.mail_dialog));
gtk_widget_destroy(xsane.mail_dialog);
xsane.mail_dialog = NULL;
xsane.mail_list = NULL;
+ xsane.mail_progress_bar = NULL;
+}
+
+/* ---------------------------------------------------------------------------------------------------------------------- */
+
+static void xsane_mail_project_set_sensitive(int sensitive)
+{
+ gtk_widget_set_sensitive(xsane.mail_project_box, sensitive);
+ gtk_widget_set_sensitive(xsane.mail_project_exists, sensitive);
+}
+
+/* ---------------------------------------------------------------------------------------------------------------------- */
+
+static void xsane_mail_project_display_status()
+{
+ FILE *lockfile;
+ char buf[256];
+ char filename[PATH_MAX];
+ int val;
+ int i, c;
+
+ DBG(DBG_proc, "xsane_mail_project_display_status\n");
+
+ snprintf(filename, sizeof(filename), "%s/lockfile", preferences.mail_project);
+ lockfile = fopen(filename, "rb"); /* read binary (b for win32) */
+
+ if (lockfile)
+ {
+ i=0;
+ c=0;
+ while ((i<255) && (c != 10) && (c != EOF)) /* first line is mail status */
+ {
+ c = fgetc(lockfile);
+ buf[i++] = c;
+ }
+ buf[i-1] = 0;
+
+ fscanf(lockfile, "%d\n", &val);
+
+ fclose(lockfile);
+
+ if ( (!strcmp(buf, TEXT_MAIL_STATUS_SENDING)) ||
+ (!strcmp(buf, TEXT_MAIL_STATUS_SENT)) ||
+ (!strcmp(buf, TEXT_MAIL_STATUS_ERR_READ_PROJECT)) ||
+ (!strcmp(buf, TEXT_MAIL_STATUS_POP3_CONNECTION_FAILED)) ||
+ (!strcmp(buf, TEXT_MAIL_STATUS_POP3_LOGIN_FAILED)) ||
+ (!strcmp(buf, TEXT_MAIL_STATUS_SMTP_CONNECTION_FAILED)) ||
+ (!strcmp(buf, TEXT_MAIL_STATUS_SMTP_ERR_FROM)) ||
+ (!strcmp(buf, TEXT_MAIL_STATUS_SMTP_ERR_RCPT)) ||
+ (!strcmp(buf, TEXT_MAIL_STATUS_SMTP_ERR_DATA)) ||
+ (!strcmp(buf, TEXT_MAIL_STATUS_SENT)) )
+ {
+ if (strcmp(xsane.mail_status, buf))
+ {
+ if (xsane.mail_status)
+ {
+ free(xsane.mail_status);
+ }
+ xsane.mail_status = strdup(buf);
+
+ if (xsane.mail_progress_bar)
+ {
+ gtk_progress_set_format_string(GTK_PROGRESS(xsane.mail_progress_bar), _(xsane.mail_status));
+ }
+ }
+
+ xsane.mail_progress_val = val / 100.0;
+ if (xsane.mail_progress_bar)
+ {
+ gtk_progress_bar_update(GTK_PROGRESS_BAR(xsane.mail_progress_bar), xsane.mail_progress_val);
+ }
+
+ DBG(DBG_info, "reading from lockfile: mail_status %s, mail_progress_val %1.3f\n" , xsane.mail_status, xsane.mail_progress_val);
+
+ if (strcmp(xsane.mail_status, TEXT_MAIL_STATUS_SENDING)) /* not sending */
+ {
+ DBG(DBG_info, "removing %s\n", filename);
+ remove(filename); /* remove lockfile */
+
+ xsane.mail_progress_val = 0.0;
+
+ xsane_mail_project_update_project_status();
+
+ if (xsane.mail_dialog)
+ {
+ xsane_mail_project_load();
+
+ xsane_mail_project_set_sensitive(TRUE);
+ gtk_widget_set_sensitive(GTK_WIDGET(xsane.start_button), TRUE);
+ }
+ }
+ }
+ }
+ else
+ {
+ DBG(DBG_info, "no lockfile present\n");
+ if (xsane.mail_progress_bar)
+ {
+ gtk_progress_set_format_string(GTK_PROGRESS(xsane.mail_progress_bar), _(xsane.mail_status));
+ gtk_progress_bar_update(GTK_PROGRESS_BAR(xsane.mail_progress_bar), xsane.mail_progress_val);
+ }
+
+ while (gtk_events_pending())
+ {
+ gtk_main_iteration();
+ }
+ }
+}
+
+/* ---------------------------------------------------------------------------------------------------------------------- */
+
+static gint xsane_mail_send_timer_callback(gpointer data)
+{
+ xsane_mail_project_display_status();
+
+ if (strcmp(xsane.mail_status, TEXT_MAIL_STATUS_SENDING)) /* not sending */
+ {
+ if (xsane_mail_send_timer)
+ {
+ DBG(DBG_info, "disabling mail send timer\n");
+ xsane_mail_send_timer = 0;
+ }
+ }
+
+ return xsane_mail_send_timer;
}
/* ---------------------------------------------------------------------------------------------------------------------- */
@@ -4723,10 +5317,13 @@ static void xsane_mail_project_load()
{
FILE *projectfile;
char page[256];
+ char *type;
+ char *extension;
char buf[256];
+ char filename[PATH_MAX];
GtkWidget *list_item;
int i;
- char c;
+ int c;
DBG(DBG_proc, "xsane_mail_project_load\n");
@@ -4754,25 +5351,29 @@ static void xsane_mail_project_load()
xsane.mail_subject = NULL;
}
- gtk_signal_disconnect_by_func(GTK_OBJECT(xsane.mail_receiver_entry), GTK_SIGNAL_FUNC(xsane_mail_receiver_changed_callback), 0);
- gtk_signal_disconnect_by_func(GTK_OBJECT(xsane.mail_subject_entry), GTK_SIGNAL_FUNC(xsane_mail_subject_changed_callback), 0);
- gtk_signal_disconnect_by_func(GTK_OBJECT(xsane.mail_html_mode_widget), GTK_SIGNAL_FUNC(xsane_mail_html_mode_callback), 0);
+ g_signal_handlers_disconnect_by_func(GTK_OBJECT(xsane.mail_receiver_entry), GTK_SIGNAL_FUNC(xsane_mail_receiver_changed_callback), 0);
+ g_signal_handlers_disconnect_by_func(GTK_OBJECT(xsane.mail_subject_entry), GTK_SIGNAL_FUNC(xsane_mail_subject_changed_callback), 0);
+ g_signal_handlers_disconnect_by_func(GTK_OBJECT(xsane.mail_html_mode_widget), GTK_SIGNAL_FUNC(xsane_mail_html_mode_callback), 0);
+#ifdef HAVE_GTK_TEXT_VIEW_H
+ gtk_text_buffer_set_text(GTK_TEXT_BUFFER(xsane.mail_text_widget), "", 0);
+#else
gtk_text_set_point(GTK_TEXT(xsane.mail_text_widget), 0);
gtk_text_forward_delete(GTK_TEXT(xsane.mail_text_widget), gtk_text_get_length(GTK_TEXT(xsane.mail_text_widget)));
+#endif
gtk_list_remove_items(GTK_LIST(xsane.mail_list), GTK_LIST(xsane.mail_list)->children);
- snprintf(buf, sizeof(buf), "%s/xsane-mail-list", preferences.mail_project);
- projectfile = fopen(buf, "rb"); /* read binary (b for win32) */
+ snprintf(filename, sizeof(filename), "%s/xsane-mail-list", preferences.mail_project);
+ projectfile = fopen(filename, "rb"); /* read binary (b for win32) */
if ((!projectfile) || (feof(projectfile)))
{
- snprintf(buf, sizeof(buf), "%s/page-1.png", preferences.mail_project);
- xsane.mail_filename=strdup(buf);
+ snprintf(filename, sizeof(filename), "%s/image-1.pnm", preferences.mail_project);
+ xsane.mail_filename=strdup(filename);
xsane_update_counter_in_filename(&xsane.mail_filename, FALSE, 0, preferences.filename_counter_len); /* correct counter len */
- xsane.mail_status=strdup("not existant");
- gtk_label_set(GTK_LABEL(xsane.mail_status_label), _(xsane.mail_status));
+ xsane.mail_status=strdup(TEXT_MAIL_STATUS_NOT_CREATED);
+ xsane.mail_progress_val = 0.0;
xsane.mail_receiver=strdup("");
gtk_entry_set_text(GTK_ENTRY(xsane.mail_receiver_entry), (char *) xsane.mail_receiver);
@@ -4780,9 +5381,12 @@ static void xsane_mail_project_load()
xsane.mail_subject=strdup("");
gtk_entry_set_text(GTK_ENTRY(xsane.mail_subject_entry), (char *) xsane.mail_subject);
- gtk_widget_set_sensitive(xsane.mail_project_box, FALSE);
gtk_widget_hide(xsane.mail_project_exists);
gtk_widget_show(xsane.mail_project_not_exists);
+
+ gtk_widget_set_sensitive(xsane.mail_project_box, FALSE);
+ gtk_widget_set_sensitive(xsane.mail_project_exists, FALSE);
+ /* do not change sensitivity of mail_project_entry_box here !!! */
gtk_widget_set_sensitive(GTK_WIDGET(xsane.start_button), FALSE);
xsane.mail_project_save = 0;
@@ -4797,13 +5401,17 @@ static void xsane_mail_project_load()
page[i++] = c;
}
page[i-1] = 0;
+ if (strchr(page, '@'))
+ {
+ *strchr(page, '@') = 0;
+ }
if (xsane.mail_status)
{
free(xsane.mail_status);
}
xsane.mail_status = strdup(page);
- gtk_label_set(GTK_LABEL(xsane.mail_status_label), _(xsane.mail_status));
+ xsane.mail_progress_val = 0.0;
i=0;
@@ -4828,8 +5436,8 @@ static void xsane_mail_project_load()
}
page[i-1] = 0;
- snprintf(buf, sizeof(buf), "%s/%s", preferences.mail_project, page);
- xsane.mail_filename=strdup(buf);
+ snprintf(filename, sizeof(filename), "%s/%s", preferences.mail_project, page);
+ xsane.mail_filename=strdup(filename);
i=0;
@@ -4883,10 +5491,22 @@ static void xsane_mail_project_load()
break; /* mailtext follows */
}
+ extension = strrchr(page, '.');
+ if (extension)
+ {
+ type = strdup(extension);
+ *extension = 0;
+ }
+ else
+ {
+ type = strdup("");
+ }
+
if (c > 1)
{
list_item = gtk_list_item_new_with_label(page);
gtk_object_set_data(GTK_OBJECT(list_item), "list_item_data", strdup(page));
+ gtk_object_set_data(GTK_OBJECT(list_item), "list_item_type", strdup(type));
gtk_container_add(GTK_CONTAINER(xsane.mail_list), list_item);
gtk_widget_show(list_item);
}
@@ -4895,22 +5515,35 @@ static void xsane_mail_project_load()
while (!feof(projectfile))
{
i = fread(buf, 1, sizeof(buf), projectfile);
+#ifdef HAVE_GTK_TEXT_VIEW_H
+ gtk_text_buffer_insert_at_cursor(GTK_TEXT_BUFFER(xsane.mail_text_widget), buf, i);
+#else
gtk_text_insert(GTK_TEXT(xsane.mail_text_widget), NULL, NULL, NULL, buf, i);
+#endif
}
- if (xsane.mail_status[0] == '*') /* mail project is locked (sending) */
+ if (!strcmp(xsane.mail_status, TEXT_MAIL_STATUS_SENDING)) /* mail project is locked (sending) */
{
- gtk_widget_set_sensitive(xsane.mail_project_box, FALSE);
+ xsane_mail_project_set_sensitive(FALSE);
+ gtk_widget_set_sensitive(xsane.mail_project_entry_box, TRUE);
gtk_widget_set_sensitive(GTK_WIDGET(xsane.start_button), FALSE);
+
+ if (xsane_mail_send_timer == 0)
+ {
+ xsane_mail_send_timer = gtk_timeout_add(100, (GtkFunction) xsane_mail_send_timer_callback, NULL);
+ DBG(DBG_info, "enabling mail send timer (%d)\n", xsane_mail_send_timer);
+ }
}
else
{
- gtk_widget_set_sensitive(xsane.mail_project_box, TRUE);
- gtk_widget_show(xsane.mail_project_exists);
- gtk_widget_hide(xsane.mail_project_not_exists);
+ xsane_mail_project_set_sensitive(TRUE);
+ gtk_widget_set_sensitive(xsane.mail_project_entry_box, TRUE);
gtk_widget_set_sensitive(GTK_WIDGET(xsane.start_button), TRUE);
}
+ gtk_widget_show(xsane.mail_project_exists);
+ gtk_widget_hide(xsane.mail_project_not_exists);
+
xsane.mail_project_save = 1;
}
@@ -4919,9 +5552,14 @@ static void xsane_mail_project_load()
fclose(projectfile);
}
- gtk_signal_connect(GTK_OBJECT(xsane.mail_html_mode_widget), "clicked", (GtkSignalFunc) xsane_mail_html_mode_callback, NULL);
- gtk_signal_connect(GTK_OBJECT(xsane.mail_receiver_entry), "changed", (GtkSignalFunc) xsane_mail_receiver_changed_callback, NULL);
- gtk_signal_connect(GTK_OBJECT(xsane.mail_subject_entry), "changed", (GtkSignalFunc) xsane_mail_subject_changed_callback, NULL);
+ gtk_progress_set_format_string(GTK_PROGRESS(xsane.mail_progress_bar), _(xsane.mail_status));
+ gtk_progress_bar_update(GTK_PROGRESS_BAR(xsane.mail_progress_bar), xsane.mail_progress_val);
+
+ xsane_mail_project_display_status();
+
+ g_signal_connect(GTK_OBJECT(xsane.mail_html_mode_widget), "clicked", (GtkSignalFunc) xsane_mail_html_mode_callback, NULL);
+ g_signal_connect(GTK_OBJECT(xsane.mail_receiver_entry), "changed", (GtkSignalFunc) xsane_mail_receiver_changed_callback, NULL);
+ g_signal_connect(GTK_OBJECT(xsane.mail_subject_entry), "changed", (GtkSignalFunc) xsane_mail_subject_changed_callback, NULL);
}
/* ---------------------------------------------------------------------------------------------------------------------- */
@@ -4929,6 +5567,7 @@ static void xsane_mail_project_load()
static void xsane_mail_project_delete()
{
char *page;
+ char *type;
char file[256];
GList *list = (GList *) GTK_LIST(xsane.mail_list)->children;
GtkObject *list_item;
@@ -4939,9 +5578,11 @@ static void xsane_mail_project_delete()
{
list_item = GTK_OBJECT(list->data);
page = strdup((char *) gtk_object_get_data(list_item, "list_item_data"));
+ type = strdup((char *) gtk_object_get_data(list_item, "list_item_type"));
xsane_convert_text_to_filename(&page);
- snprintf(file, sizeof(file), "%s/%s.png", preferences.mail_project, page);
+ snprintf(file, sizeof(file), "%s/%s%s", preferences.mail_project, page, type);
free(page);
+ free(type);
remove(file);
list = list->next;
}
@@ -4955,15 +5596,18 @@ static void xsane_mail_project_delete()
/* ---------------------------------------------------------------------------------------------------------------------- */
-void xsane_mail_project_update_status()
+static void xsane_mail_project_update_project_status()
{
FILE *projectfile;
+ char filename[PATH_MAX];
char buf[256];
- snprintf(buf, sizeof(buf), "%s/xsane-mail-list", preferences.mail_project);
- projectfile = fopen(buf, "r+b"); /* r+ = read and write, position = start of file */
- snprintf(buf, 32, "%s ", xsane.mail_status); /* fill 32 characters status line */
+ snprintf(filename, sizeof(filename), "%s/xsane-mail-list", preferences.mail_project);
+ projectfile = fopen(filename, "r+b"); /* r+ = read and write, position = start of file */
+
+ snprintf(buf, 32, "%s@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@", xsane.mail_status); /* fill 32 characters status line */
fprintf(projectfile, "%s\n", buf); /* first line is status of mail */
+
fclose(projectfile);
}
@@ -4974,7 +5618,8 @@ void xsane_mail_project_save()
FILE *projectfile;
GList *list = (GList *) GTK_LIST(xsane.mail_list)->children;
GtkObject *list_item;
- char *image;
+ char *page;
+ char *type;
gchar *mail_text;
char filename[256];
@@ -4985,14 +5630,6 @@ void xsane_mail_project_save()
snprintf(filename, sizeof(filename), "%s/xsane-mail-list", preferences.mail_project);
- if (xsane.mail_status)
- {
- if (xsane.mail_status[0] == '?')
- {
- return;
- }
- }
-
if (xsane_create_secure_file(filename)) /* remove possibly existing symbolic links for security */
{
char buf[256];
@@ -5006,14 +5643,18 @@ void xsane_mail_project_save()
if (xsane.mail_status)
{
- snprintf(filename, 32, "%s ", xsane.mail_status); /* fill 32 characters status line */
- fprintf(projectfile, "%s\n", filename); /* first line is status of mail */
- gtk_label_set(GTK_LABEL(xsane.mail_status_label), _(xsane.mail_status));
+ char buf[256];
+
+ snprintf(buf, 32, "%s@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@", xsane.mail_status); /* fill 32 characters status line */
+ fprintf(projectfile, "%s\n", buf); /* first line is status of mail */
+ gtk_progress_set_format_string(GTK_PROGRESS(xsane.mail_progress_bar), _(xsane.mail_status));
+ gtk_progress_bar_update(GTK_PROGRESS_BAR(xsane.mail_progress_bar), 0.0);
}
else
{
fprintf(projectfile, " \n"); /* no mail status */
- gtk_label_set(GTK_LABEL(xsane.mail_status_label), "");
+ gtk_progress_set_format_string(GTK_PROGRESS(xsane.mail_progress_bar), "");
+ gtk_progress_bar_update(GTK_PROGRESS_BAR(xsane.mail_progress_bar), 0.0);
}
if (xsane.mail_receiver)
@@ -5056,14 +5697,25 @@ void xsane_mail_project_save()
while (list)
{
list_item = GTK_OBJECT(list->data);
- image = (char *) gtk_object_get_data(list_item, "list_item_data");
- fprintf(projectfile, "%s\n", image);
+ page = (char *) gtk_object_get_data(list_item, "list_item_data");
+ type = (char *) gtk_object_get_data(list_item, "list_item_type");
+ fprintf(projectfile, "%s%s\n", page, type);
list = list->next;
}
/* save mail text */
fprintf(projectfile, "mailtext:\n");
+#ifdef HAVE_GTK_TEXT_VIEW_H
+ {
+ GtkTextIter start, end;
+
+ gtk_text_buffer_get_start_iter(GTK_TEXT_BUFFER(xsane.mail_text_widget), &start);
+ gtk_text_buffer_get_end_iter(GTK_TEXT_BUFFER(xsane.mail_text_widget), &end);
+ mail_text = gtk_text_buffer_get_text(GTK_TEXT_BUFFER(xsane.mail_text_widget), &start, &end, FALSE);
+ }
+#else
mail_text = gtk_editable_get_chars(GTK_EDITABLE(xsane.mail_text_widget), 0, -1);
+#endif
fprintf(projectfile, "%s", mail_text);
fclose(projectfile);
@@ -5081,7 +5733,7 @@ static void xsane_mail_project_create()
{
free(xsane.mail_status);
}
- xsane.mail_status = strdup("created");
+ xsane.mail_status = strdup(TEXT_MAIL_STATUS_CREATED);
xsane_mail_project_save();
xsane_mail_project_load();
}
@@ -5103,8 +5755,9 @@ static void xsane_mail_receiver_changed_callback(GtkWidget *widget, gpointer dat
{
free(xsane.mail_status);
}
- xsane.mail_status = strdup("changed");
- xsane_mail_project_save();
+ xsane.mail_status = strdup(TEXT_MAIL_STATUS_CHANGED);
+ xsane.mail_project_save = 1;
+ xsane_mail_project_display_status();
}
/* ---------------------------------------------------------------------------------------------------------------------- */
@@ -5123,8 +5776,9 @@ static void xsane_mail_subject_changed_callback(GtkWidget *widget, gpointer data
{
free(xsane.mail_status);
}
- xsane.mail_status = strdup("changed");
- xsane_mail_project_save();
+ xsane.mail_status = strdup(TEXT_MAIL_STATUS_CHANGED);
+ xsane.mail_project_save = 1;
+ xsane_mail_project_display_status();
}
/* ---------------------------------------------------------------------------------------------------------------------- */
@@ -5161,8 +5815,9 @@ static void xsane_mail_html_mode_callback(GtkWidget * widget)
{
free(xsane.mail_status);
}
- xsane.mail_status = strdup("changed");
- xsane_mail_project_save();
+ xsane.mail_status = strdup(TEXT_MAIL_STATUS_CHANGED);
+ xsane.mail_project_save = 1;
+ xsane_mail_project_display_status();
}
/* ---------------------------------------------------------------------------------------------------------------------- */
@@ -5205,7 +5860,7 @@ static void xsane_mail_entry_move_up_callback(GtkWidget *widget, gpointer list)
{
free(xsane.mail_status);
}
- xsane.mail_status = strdup("changed");
+ xsane.mail_status = strdup(TEXT_MAIL_STATUS_CHANGED);
xsane_mail_project_save();
}
}
@@ -5252,7 +5907,7 @@ static void xsane_mail_entry_move_down_callback(GtkWidget *widget, gpointer list
{
free(xsane.mail_status);
}
- xsane.mail_status = strdup("changed");
+ xsane.mail_status = strdup(TEXT_MAIL_STATUS_CHANGED);
xsane_mail_project_save();
}
}
@@ -5278,6 +5933,7 @@ static void xsane_mail_entry_rename_callback(GtkWidget *widget, gpointer list)
GList *select;
char *oldpage;
char *newpage;
+ char *type;
char oldfile[256];
char newfile[256];
@@ -5290,14 +5946,15 @@ static void xsane_mail_entry_rename_callback(GtkWidget *widget, gpointer list)
GtkWidget *text;
GtkWidget *button;
GtkWidget *vbox, *hbox;
- char buf[256];
+ char filename[PATH_MAX];
list_item = select->data;
oldpage = strdup((char *) gtk_object_get_data(GTK_OBJECT(list_item), "list_item_data"));
+ type = strdup((char *) gtk_object_get_data(GTK_OBJECT(list_item), "list_item_type"));
xsane_set_sensitivity(FALSE);
- rename_dialog = gtk_window_new(GTK_WINDOW_DIALOG);
+ rename_dialog = gtk_window_new(GTK_WINDOW_TOPLEVEL);
xsane_set_window_icon(rename_dialog, 0);
/* set the main vbox */
@@ -5314,27 +5971,36 @@ static void xsane_mail_entry_rename_callback(GtkWidget *widget, gpointer list)
gtk_widget_show(hbox);
gtk_window_set_position(GTK_WINDOW(rename_dialog), GTK_WIN_POS_CENTER);
- gtk_window_set_policy(GTK_WINDOW(rename_dialog), FALSE, FALSE, FALSE);
- snprintf(buf, sizeof(buf), "%s %s", xsane.prog_name, WINDOW_MAIL_RENAME);
- gtk_window_set_title(GTK_WINDOW(rename_dialog), buf);
- gtk_signal_connect(GTK_OBJECT(rename_dialog), "delete_event", (GtkSignalFunc) xsane_mail_entry_rename_button_callback, (void *) -1);
+ gtk_window_set_resizable(GTK_WINDOW(rename_dialog), FALSE);
+ snprintf(filename, sizeof(filename), "%s %s", xsane.prog_name, WINDOW_MAIL_RENAME);
+ gtk_window_set_title(GTK_WINDOW(rename_dialog), filename);
+ g_signal_connect(GTK_OBJECT(rename_dialog), "delete_event", (GtkSignalFunc) xsane_mail_entry_rename_button_callback, (void *) -1);
gtk_widget_show(rename_dialog);
- text = gtk_entry_new_with_max_length(64);
+ text = gtk_entry_new();
xsane_back_gtk_set_tooltip(xsane.tooltips, text, DESC_MAILIMAGENAME);
+ gtk_entry_set_max_length(GTK_ENTRY(text), 64);
gtk_entry_set_text(GTK_ENTRY(text), oldpage);
- gtk_widget_set_usize(text, 300, 0);
+ gtk_widget_set_size_request(text, 300, -1);
gtk_box_pack_start(GTK_BOX(vbox), text, TRUE, TRUE, 4);
gtk_widget_show(text);
- button = gtk_button_new_with_label("OK");
- gtk_signal_connect(GTK_OBJECT(button), "clicked", (GtkSignalFunc) xsane_mail_entry_rename_button_callback, (void *) 1);
+#ifdef HAVE_GTK2
+ button = gtk_button_new_from_stock(GTK_STOCK_OK);
+#else
+ button = gtk_button_new_with_label(BUTTON_OK);
+#endif
+ g_signal_connect(GTK_OBJECT(button), "clicked", (GtkSignalFunc) xsane_mail_entry_rename_button_callback, (void *) 1);
gtk_box_pack_start(GTK_BOX(hbox), button, TRUE, TRUE, 0);
gtk_widget_show(button);
- button = gtk_button_new_with_label("Cancel");
- gtk_signal_connect(GTK_OBJECT(button), "clicked", (GtkSignalFunc) xsane_mail_entry_rename_button_callback, (void *) -1);
+#ifdef HAVE_GTK2
+ button = gtk_button_new_from_stock(GTK_STOCK_CANCEL);
+#else
+ button = gtk_button_new_with_label(BUTTON_CANCEL);
+#endif
+ g_signal_connect(GTK_OBJECT(button), "clicked", (GtkSignalFunc) xsane_mail_entry_rename_button_callback,(void *) -1);
gtk_box_pack_start(GTK_BOX(hbox), button, TRUE, TRUE, 0);
gtk_widget_show(button);
@@ -5358,8 +6024,8 @@ static void xsane_mail_entry_rename_callback(GtkWidget *widget, gpointer list)
xsane_convert_text_to_filename(&oldpage);
xsane_convert_text_to_filename(&newpage);
- snprintf(oldfile, sizeof(oldfile), "%s/%s.png", preferences.mail_project, oldpage);
- snprintf(newfile, sizeof(newfile), "%s/%s.png", preferences.mail_project, newpage);
+ snprintf(oldfile, sizeof(oldfile), "%s/%s%s", preferences.mail_project, oldpage, type);
+ snprintf(newfile, sizeof(newfile), "%s/%s%s", preferences.mail_project, newpage, type);
rename(oldfile, newfile);
@@ -5367,7 +6033,7 @@ static void xsane_mail_entry_rename_callback(GtkWidget *widget, gpointer list)
{
free(xsane.mail_status);
}
- xsane.mail_status = strdup("changed");
+ xsane.mail_status = strdup(TEXT_MAIL_STATUS_CHANGED);
xsane_mail_project_save();
}
@@ -5387,6 +6053,7 @@ static void xsane_mail_entry_delete_callback(GtkWidget *widget, gpointer list)
GtkObject *list_item;
GList *select;
char *page;
+ char *type;
char file[256];
DBG(DBG_proc, "xsane_mail_entry_delete_callback\n");
@@ -5396,9 +6063,11 @@ static void xsane_mail_entry_delete_callback(GtkWidget *widget, gpointer list)
{
list_item = GTK_OBJECT(select->data);
page = strdup((char *) gtk_object_get_data(list_item, "list_item_data"));
+ type = strdup((char *) gtk_object_get_data(list_item, "list_item_type"));
xsane_convert_text_to_filename(&page);
- snprintf(file, sizeof(file), "%s/%s.png", preferences.mail_project, page);
+ snprintf(file, sizeof(file), "%s/%s%s", preferences.mail_project, page, type);
free(page);
+ free(type);
remove(file);
gtk_widget_destroy(GTK_WIDGET(list_item));
@@ -5406,7 +6075,7 @@ static void xsane_mail_entry_delete_callback(GtkWidget *widget, gpointer list)
{
free(xsane.mail_status);
}
- xsane.mail_status = strdup("changed");
+ xsane.mail_status = strdup(TEXT_MAIL_STATUS_CHANGED);
xsane_mail_project_save();
}
}
@@ -5417,43 +6086,92 @@ static void xsane_mail_show_callback(GtkWidget *widget, gpointer list)
{
GtkObject *list_item;
GList *select;
- pid_t pid;
- char *arg[100];
char *page;
- char buf[256];
- int argnr;
+ char *type;
+ char filename[256];
DBG(DBG_proc, "xsane_mail_entry_show_callback\n");
select = GTK_LIST(list)->selection;
if (select)
{
- argnr = xsane_parse_options(preferences.mail_viewer, arg);
+ list_item = GTK_OBJECT(select->data);
+ page = strdup((char *) gtk_object_get_data(list_item, "list_item_data"));
+ type = strdup((char *) gtk_object_get_data(list_item, "list_item_type"));
+ xsane_convert_text_to_filename(&page);
+ snprintf(filename, sizeof(filename), "%s/%s%s", preferences.mail_project, page, type);
+ free(page);
+ free(type);
+
+ xsane_viewer_new(filename, FALSE, filename, VIEWER_NO_MODIFICATION);
+ }
+}
+
+/* ---------------------------------------------------------------------------------------------------------------------- */
+#if 0
+static void xsane_mail_edit_callback(GtkWidget *widget, gpointer list)
+{
+ GtkObject *list_item;
+ GList *select;
+ char *page;
+ char *type;
+ char filename[256];
+ FILE *outfile;
+ FILE *infile;
+ char outfilename[256];
+ Image_info image_info;
+ int cancel_save;
+
+ DBG(DBG_proc, "xsane_mail_entry_show_callback\n");
+
+ select = GTK_LIST(list)->selection;
+ if (select)
+ {
list_item = GTK_OBJECT(select->data);
- page = (char *) gtk_object_get_data(list_item, "list_item_data");
- page = strdup(page);
+ page = strdup((char *) gtk_object_get_data(list_item, "list_item_data"));
+ type = strdup((char *) gtk_object_get_data(list_item, "list_item_type"));
xsane_convert_text_to_filename(&page);
- snprintf(buf, sizeof(buf), "%s/%s.png", preferences.mail_project, page);
+ snprintf(filename, sizeof(filename), "%s/%s%s", preferences.mail_project, page, type);
free(page);
- arg[argnr++] = buf;
- arg[argnr] = 0;
+ free(type);
- pid = fork();
- if (pid == 0) /* new process */
+ infile = fopen(filename, "rb");
+ if (!infile)
{
- DBG(DBG_info, "trying to change user id fo new subprocess:\n");
- DBG(DBG_info, "old effective uid = %d\n", geteuid());
- setuid(getuid());
- DBG(DBG_info, "new effective uid = %d\n", geteuid());
+ DBG(DBG_error, "could not load file %s\n", filename);
+ return;
+ }
- execvp(arg[0], arg); /* does not return if successfully */
- DBG(DBG_error, "%s %s\n", ERR_FAILED_EXEC_MAIL_VIEWER, preferences.mail_viewer);
- _exit(0); /* do not use exit() here! otherwise gtk gets in trouble */
+ xsane_read_pnm_header(infile, &image_info);
+
+ DBG(DBG_info, "copying image %s with geometry: %d x %d x %d, %d colors\n", filename, image_info.image_width, image_info.image_height, image_info.depth, image_info.colors);
+
+ xsane_back_gtk_make_path(sizeof(outfilename), outfilename, 0, 0, "xsane-viewer-", xsane.dev_name, ".pnm", XSANE_PATH_TMP);
+
+ outfile = fopen(outfilename, "wb");
+ if (!outfile)
+ {
+ DBG(DBG_error, "could not save file %s\n", outfilename);
+ return;
}
+
+ gtk_progress_set_format_string(GTK_PROGRESS(xsane.mail_progress_bar), PROGRESS_CLONING_DATA);
+ gtk_progress_bar_update(GTK_PROGRESS_BAR(xsane.mail_progress_bar), 0.0);
+
+ xsane_save_rotate_image(outfile, infile, &image_info, 0, xsane.mail_progress_bar, &cancel_save);
+
+ fclose(infile);
+ fclose(outfile);
+
+ gtk_progress_set_format_string(GTK_PROGRESS(xsane.mail_progress_bar), "");
+ gtk_progress_bar_update(GTK_PROGRESS_BAR(xsane.mail_progress_bar), 0.0);
+
+ xsane_viewer_new(outfilename, FALSE, filename, VIEWER_NO_NAME_MODIFICATION);
}
}
+#endif
/* ---------------------------------------------------------------------------------------------------------------------- */
@@ -5466,29 +6184,32 @@ static void xsane_create_mail(int fd)
char *mail_text = NULL;
char *mail_text_pos = NULL;
char **attachment_filename = NULL;
- char c;
char buf[256];
char filename[256];
char content_id[256];
char image[256];
int i, j;
+ int c;
int attachments = 0;
int use_attachment = 0;
int mail_text_size = 0;
- snprintf(buf, sizeof(buf), "%s/xsane-mail-list", preferences.mail_project);
- projectfile = fopen(buf, "rb"); /* read binary (b for win32) */
+ DBG(DBG_proc, "xsane_create_mail\n");
+
+ snprintf(filename, sizeof(filename), "%s/xsane-mail-list", preferences.mail_project);
+ projectfile = fopen(filename, "rb"); /* read binary (b for win32) */
if ((!projectfile) || (feof(projectfile)))
{
- DBG(DBG_error, "could not open mail project file %s\n", buf);
+ DBG(DBG_error, "could not open mail project file %s\n", filename);
if (xsane.mail_status)
{
free(xsane.mail_status);
}
- xsane.mail_status = strdup("could not read mailproject");
- xsane_mail_project_update_status();
+ xsane.mail_status = strdup(TEXT_MAIL_STATUS_ERR_READ_PROJECT);
+ xsane.mail_progress_val = 0.0;
+ xsane_front_gtk_mail_project_update_lockfile_status();
return;
}
@@ -5520,9 +6241,24 @@ static void xsane_create_mail(int fd)
if (strcmp("mailtext:", image) && (c > 1))
{
+ char imagename[256];
+ char *filename;
+ char *extension;
+
DBG(DBG_info, " - %s\n", image);
+
+ extension = strrchr(image, '.');
+ if (extension)
+ {
+ *extension = 0;
+ }
+
+ snprintf(imagename, sizeof(imagename), "%s%s", image, preferences.mail_filetype);
+ filename=strdup(imagename);
+ xsane_convert_text_to_filename(&filename);
attachment_filename = realloc(attachment_filename, (attachments+1)*sizeof(void *));
- attachment_filename[attachments++] = strdup(image);
+ attachment_filename[attachments++] = strdup(filename);
+ free(filename);
}
else
{
@@ -5533,11 +6269,12 @@ static void xsane_create_mail(int fd)
/* read mail text */
while (!feof(projectfile))
{
- mail_text = realloc(mail_text, mail_text_size+1024); /* increase mail_text by 1KB */
+ mail_text = realloc(mail_text, mail_text_size+1025); /* increase mail_text by 1KB */
mail_text_size += fread(mail_text+mail_text_size, 1, 1024, projectfile); /* read next KB */
}
DBG(DBG_info, "%d bytes mailtext read\n", mail_text_size);
+ *(mail_text + mail_text_size) = 0; /* set end of text marker */
mail_text_pos = mail_text;
if (xsane.mail_html_mode) /* create html mail */
@@ -5556,13 +6293,11 @@ static void xsane_create_mail(int fd)
if (use_attachment < attachments)
{
- image_filename = strdup(attachment_filename[use_attachment++]);
- xsane_convert_text_to_filename(&image_filename);
+ image_filename = attachment_filename[use_attachment++];
DBG(DBG_info, "inserting image cid for %s\n", image_filename);
snprintf(content_id, sizeof(content_id), "%s", image_filename); /* content_id */
snprintf(buf, sizeof(buf), "<p><img SRC=\"cid:%s\">\n", content_id);
write(fd, buf, strlen(buf));
- free(image_filename);
}
else /* more images selected than available */
{
@@ -5582,13 +6317,11 @@ static void xsane_create_mail(int fd)
while (use_attachment < attachments) /* append not already referenced images */
{
- image_filename = strdup(attachment_filename[use_attachment++]);
- xsane_convert_text_to_filename(&image_filename);
+ image_filename = attachment_filename[use_attachment++];
DBG(DBG_info, "appending image cid for %s\n", image_filename);
snprintf(content_id, sizeof(content_id), "%s", image_filename); /* content_id */
snprintf(buf, sizeof(buf), "<p><img SRC=\"cid:%s\">\n", content_id);
write(fd, buf, strlen(buf));
- free(image_filename);
}
snprintf(buf, sizeof(buf), "</html>\n");
@@ -5597,25 +6330,35 @@ static void xsane_create_mail(int fd)
for (i=0; i<attachments; i++)
{
- image_filename = strdup(attachment_filename[i]);
- snprintf(filename, sizeof(filename), "%s.png", image_filename);
-
- xsane_convert_text_to_filename(&image_filename);
+ image_filename = attachment_filename[i];
snprintf(content_id, sizeof(content_id), "%s", image_filename); /* content_id */
- snprintf(buf, sizeof(buf), "%s/%s.png", preferences.mail_project, image_filename);
- attachment_file = fopen(buf, "rb"); /* read, b=binary for win32 */
+ snprintf(filename, sizeof(filename), "%s/mail-%s", preferences.mail_project, image_filename);
+ attachment_file = fopen(filename, "rb"); /* read, b=binary for win32 */
if (attachment_file)
{
- DBG(DBG_info, "attaching png file \"%s\"\n", image_filename);
- write_mail_attach_image_png(fd, boundary, content_id, attachment_file, filename);
+ DBG(DBG_info, "attaching png file \"%s\"\n", filename);
+
+ if (!strcmp(preferences.mail_filetype, XSANE_FILETYPE_PNG))
+ {
+ write_mail_attach_image(fd, boundary, content_id, "image/png", attachment_file, image_filename);
+ }
+ else if (!strcmp(preferences.mail_filetype, XSANE_FILETYPE_JPEG))
+ {
+ write_mail_attach_image(fd, boundary, content_id, "image/jpeg", attachment_file, image_filename);
+ }
+ else if (!strcmp(preferences.mail_filetype, XSANE_FILETYPE_TIFF))
+ {
+ write_mail_attach_image(fd, boundary, content_id, "image/tiff", attachment_file, image_filename);
+ }
+
+ remove(filename);
}
else /* could not open attachment file */
{
- DBG(DBG_error, "could not oppen attachment png file \"%s\"\n", image_filename);
+ DBG(DBG_error, "could not oppen attachment png file \"%s\"\n", filename);
}
- free(image_filename);
free(attachment_filename[i]);
}
free(attachment_filename);
@@ -5635,21 +6378,32 @@ static void xsane_create_mail(int fd)
for (i=0; i<attachments; i++)
{
image_filename = strdup(attachment_filename[i]);
- snprintf(filename, sizeof(filename), "%s.png", image_filename);
-
- xsane_convert_text_to_filename(&image_filename);
snprintf(content_id, sizeof(content_id), "%s", image_filename); /* content_id */
- snprintf(buf, sizeof(buf), "%s/%s.png", preferences.mail_project, image_filename);
- attachment_file = fopen(buf, "rb"); /* read, b=binary for win32 */
+ snprintf(filename, sizeof(filename), "%s/mail-%s", preferences.mail_project, image_filename);
+ attachment_file = fopen(filename, "rb"); /* read, b=binary for win32 */
if (attachment_file)
{
DBG(DBG_info, "attaching png file \"%s\"\n", image_filename);
- write_mail_attach_image_png(fd, boundary, content_id, attachment_file, filename);
+
+ if (!strcmp(preferences.mail_filetype, XSANE_FILETYPE_PNG))
+ {
+ write_mail_attach_image(fd, boundary, content_id, "image/png", attachment_file, image_filename);
+ }
+ else if (!strcmp(preferences.mail_filetype, XSANE_FILETYPE_JPEG))
+ {
+ write_mail_attach_image(fd, boundary, content_id, "image/jpeg", attachment_file, image_filename);
+ }
+ else if (!strcmp(preferences.mail_filetype, XSANE_FILETYPE_TIFF))
+ {
+ write_mail_attach_image(fd, boundary, content_id, "image/tiff", attachment_file, image_filename);
+ }
+
+ remove(filename);
}
else /* could not open attachment file */
{
- DBG(DBG_error, "could not oppen attachment png file \"%s\"\n", image_filename);
+ DBG(DBG_error, "could not oppen attachment png file \"%s\"\n", filename);
}
free(image_filename);
@@ -5691,8 +6445,9 @@ static void xsane_mail_send_process()
{
free(xsane.mail_status);
}
- xsane.mail_status = strdup("pop3 connection failed");
- xsane_mail_project_update_status();
+ xsane.mail_status = strdup(TEXT_MAIL_STATUS_POP3_CONNECTION_FAILED);
+ xsane.mail_progress_val = 0.0;
+ xsane_front_gtk_mail_project_update_lockfile_status();
return;
}
@@ -5716,13 +6471,16 @@ static void xsane_mail_send_process()
{
free(xsane.mail_status);
}
- xsane.mail_status = strdup("pop3 login failed");
- xsane_mail_project_update_status();
+ xsane.mail_status = strdup(TEXT_MAIL_STATUS_POP3_LOGIN_FAILED);
+ xsane.mail_progress_val = 0.0;
+ xsane_front_gtk_mail_project_update_lockfile_status();
return;
}
}
+ DBG(DBG_info, "POP3 authentification done\n");
+
/* smtp mail */
fd_socket = open_socket(preferences.mail_smtp_server, preferences.mail_smtp_port);
@@ -5733,13 +6491,18 @@ static void xsane_mail_send_process()
{
free(xsane.mail_status);
}
- xsane.mail_status = strdup("smtp connection failed");
- xsane_mail_project_update_status();
+ xsane.mail_status = strdup(TEXT_MAIL_STATUS_SMTP_CONNECTION_FAILED);
+ xsane.mail_progress_val = 0.0;
+ xsane_front_gtk_mail_project_update_lockfile_status();
return;
}
- write_smtp_header(fd_socket, preferences.mail_from, xsane.mail_receiver);
+ status = write_smtp_header(fd_socket, preferences.mail_from, xsane.mail_receiver);
+ if (status == -1)
+ {
+ return;
+ }
xsane_create_mail(fd_socket); /* create mail and write to socket */
@@ -5751,68 +6514,108 @@ static void xsane_mail_send_process()
{
free(xsane.mail_status);
}
- xsane.mail_status = strdup("sent");
- xsane_mail_project_update_status();
+ xsane.mail_status = strdup(TEXT_MAIL_STATUS_SENT);
+ xsane.mail_progress_val = 1.0;
+ xsane_front_gtk_mail_project_update_lockfile_status();
_exit(0);
}
/* ---------------------------------------------------------------------------------------------------------------------- */
-static RETSIGTYPE xsane_mail_send_process_exited()
-{
- if (xsane.xsane_mode == XSANE_MAIL) /* make sure we still are in email mode */
- {
- xsane_mail_project_load(); /* update status of mail project */
- }
-}
-
-/* ---------------------------------------------------------------------------------------------------------------------- */
-
static void xsane_mail_send()
{
pid_t pid;
- struct SIGACTION act;
+ char *image;
+ char *type;
+ GList *list = (GList *) GTK_LIST(xsane.mail_list)->children;
+ GtkObject *list_item;
+ char source_filename[PATH_MAX];
+ char mail_filename[PATH_MAX];
+ int output_format;
+ int cancel_save = 0;
DBG(DBG_proc, "xsane_mail_send\n");
- gtk_widget_set_sensitive(xsane.mail_project_box, FALSE);
- gtk_widget_set_sensitive(GTK_WIDGET(xsane.start_button), FALSE);
+ xsane_set_sensitivity(FALSE); /* do not allow changing xsane mode */
while (gtk_events_pending())
{
+ DBG(DBG_info, "calling gtk_main_iteration\n");
gtk_main_iteration();
}
+ if (xsane.mail_project_save)
+ {
+ xsane.mail_project_save = 0;
+ xsane_mail_project_save();
+ }
+
+ xsane.mail_progress_size = 0;
+ xsane.mail_progress_bytes = 0;
+
+ while (list)
+ {
+ list_item = GTK_OBJECT(list->data);
+ image = strdup((char *) gtk_object_get_data(list_item, "list_item_data"));
+ type = strdup((char *) gtk_object_get_data(list_item, "list_item_type"));
+ xsane_convert_text_to_filename(&image);
+ snprintf(source_filename, sizeof(source_filename), "%s/%s%s", preferences.mail_project, image, type);
+ snprintf(mail_filename, sizeof(mail_filename), "%s/mail-%s%s", preferences.mail_project, image, preferences.mail_filetype);
+ free(image);
+ free(type);
+ DBG(DBG_info, "converting %s to %s\n", source_filename, mail_filename);
+ output_format = xsane_identify_output_format(mail_filename, NULL, NULL);
+ xsane_save_image_as(mail_filename, source_filename, output_format, xsane.mail_progress_bar, &cancel_save);
+ list = list->next;
+ xsane.mail_progress_size += xsane_get_filesize(mail_filename);
+ }
+
+
if (xsane.mail_status)
{
free(xsane.mail_status);
}
- xsane.mail_status = strdup("* sending");
- xsane_mail_project_save();
+ xsane.mail_status = strdup(TEXT_MAIL_STATUS_SENDING);
+ xsane.mail_progress_val = 0.0;
+ xsane_mail_project_display_status(); /* display status before creating lockfile! */
+ xsane_front_gtk_mail_project_update_lockfile_status(); /* create lockfile and update status */
pid = fork();
if (pid == 0) /* new process */
{
- DBG(DBG_info, "trying to change user id fo new subprocess:\n");
- DBG(DBG_info, "old effective uid = %d\n", geteuid());
+ FILE *ipc_file = NULL;
+
+ if (xsane.ipc_pipefd[0])
+ {
+ close(xsane.ipc_pipefd[0]); /* close reading end of pipe */
+ ipc_file = fdopen(xsane.ipc_pipefd[1], "w");
+ }
+
+ DBG(DBG_info, "trying to change user id for new subprocess:\n");
+ DBG(DBG_info, "old effective uid = %d\n", (int) geteuid());
setuid(getuid());
- DBG(DBG_info, "new effective uid = %d\n", geteuid());
+ DBG(DBG_info, "new effective uid = %d\n", (int) geteuid());
xsane_mail_send_process();
_exit(0); /* do not use exit() here! otherwise gtk gets in trouble */
}
-
- memset (&act, 0, sizeof (act));
- act.sa_handler = xsane_mail_send_process_exited;
- sigaction (SIGCHLD, &act, 0);
-
- if (xsane.mail_status)
+ else /* parent process */
{
- free(xsane.mail_status);
+ xsane_add_process_to_list(pid); /* add pid to child process list */
}
- xsane.mail_status = strdup("?");
+
+ xsane_mail_send_timer = gtk_timeout_add(100, (GtkFunction) xsane_mail_send_timer_callback, NULL);
+ DBG(DBG_info, "enabling mail send timer (%d)\n", xsane_mail_send_timer);
+
+ xsane_set_sensitivity(TRUE); /* allow changing xsane mode */
+#if 0
+ gtk_widget_set_sensitive(xsane.mail_project_entry_box, TRUE);
+ gtk_widget_set_sensitive(GTK_WIDGET(xsane.start_button), FALSE);
+ gtk_widget_set_sensitive(xsane.mail_project_box, FALSE);
+#endif
+ xsane_mail_project_set_sensitive(FALSE);
}
#endif
@@ -5829,9 +6632,16 @@ static void xsane_pref_toggle_tooltips(GtkWidget *widget, gpointer data)
/* ---------------------------------------------------------------------------------------------------------------------- */
-static void xsane_show_license(GtkWidget *widget, gpointer data)
+static void xsane_show_eula(GtkWidget *widget, gpointer data)
{
- xsane_display_license(0);
+ xsane_display_eula(0);
+}
+
+/* ---------------------------------------------------------------------------------------------------------------------- */
+
+static void xsane_show_gpl(GtkWidget *widget, gpointer data)
+{
+ xsane_display_gpl();
}
/* ---------------------------------------------------------------------------------------------------------------------- */
@@ -5847,6 +6657,7 @@ static void xsane_show_doc_via_nsr(GtkWidget *widget, gpointer data) /* show via
DBG(DBG_proc, "xsane_show_doc_via_nsr(%s)\n", name);
+
/* at first we have to test if netscape is running */
/* a simple way is to take a look at ~/.netscape/lock */
/* when this is a link we can assume that netscape is running */
@@ -5879,15 +6690,36 @@ static void xsane_show_doc_via_nsr(GtkWidget *widget, gpointer data) /* show via
if (pid == 0) /* new process */
{
- DBG(DBG_info, "trying to change user id fo new subprocess:\n");
- DBG(DBG_info, "old effective uid = %d\n", geteuid());
+ FILE *ipc_file = NULL;
+
+ if (xsane.ipc_pipefd[0])
+ {
+ close(xsane.ipc_pipefd[0]); /* close reading end of pipe */
+ ipc_file = fdopen(xsane.ipc_pipefd[1], "w");
+ }
+
+ DBG(DBG_info, "trying to change user id for new subprocess:\n");
+ DBG(DBG_info, "old effective uid = %d\n", (int) geteuid());
setuid(getuid());
- DBG(DBG_info, "new effective uid = %d\n", geteuid());
+ DBG(DBG_info, "new effective uid = %d\n", (int) geteuid());
execvp(arg[0], arg); /* does not return if successfully */
- DBG(DBG_error, "%s %s\n", ERR_FAILED_EXEC_DOC_VIEWER, preferences.doc_viewer);
+ DBG(DBG_error, "%s %s\n", ERR_FAILED_EXEC_DOC_VIEWER, preferences.browser);
+
+ /* send error message via IPC pipe to parent process */
+ if (ipc_file)
+ {
+ fprintf(ipc_file, "%s %s:\n%s", ERR_FAILED_EXEC_DOC_VIEWER, preferences.browser, strerror(errno));
+ fflush(ipc_file); /* make sure message is displayed */
+ fclose(ipc_file);
+ }
+
_exit(0); /* do not use exit() here! otherwise gtk gets in trouble */
}
+ else /* parent process */
+ {
+ xsane_add_process_to_list(pid); /* add pid to child process list */
+ }
}
else /* netscape not running */
{
@@ -5900,15 +6732,36 @@ static void xsane_show_doc_via_nsr(GtkWidget *widget, gpointer data) /* show via
if (pid == 0) /* new process */
{
- DBG(DBG_info, "trying to change user id fo new subprocess:\n");
- DBG(DBG_info, "old effective uid = %d\n", geteuid());
+ FILE *ipc_file = NULL;
+
+ if (xsane.ipc_pipefd[0])
+ {
+ close(xsane.ipc_pipefd[0]); /* close reading end of pipe */
+ ipc_file = fdopen(xsane.ipc_pipefd[1], "w");
+ }
+
+ DBG(DBG_info, "trying to change user id for new subprocess:\n");
+ DBG(DBG_info, "old effective uid = %d\n", (int) geteuid());
setuid(getuid());
- DBG(DBG_info, "new effective uid = %d\n", geteuid());
+ DBG(DBG_info, "new effective uid = %d\n", (int) geteuid());
execvp(arg[0], arg); /* does not return if successfully */
- DBG(DBG_error, "%s %s\n", ERR_FAILED_EXEC_DOC_VIEWER, preferences.doc_viewer);
+ DBG(DBG_error, "%s %s\n", ERR_FAILED_EXEC_DOC_VIEWER, preferences.browser);
+
+ /* send error message via IPC pipe to parent process */
+ if (ipc_file)
+ {
+ fprintf(ipc_file, "%s %s:\n%s", ERR_FAILED_EXEC_DOC_VIEWER, preferences.browser, strerror(errno));
+ fflush(ipc_file); /* make sure message is displayed */
+ fclose(ipc_file);
+ }
+
_exit(0); /* do not use exit() here! otherwise gtk gets in trouble */
}
+ else /* parent process */
+ {
+ xsane_add_process_to_list(pid); /* add pid to child process list */
+ }
}
while (gtk_events_pending())
@@ -5918,6 +6771,54 @@ static void xsane_show_doc_via_nsr(GtkWidget *widget, gpointer data) /* show via
}
/* ---------------------------------------------------------------------------------------------------------------------- */
+#if 0
+/* may be used to parse command lines for execvp like popen does */
+static char **xsane_parse_command(char *command_line, char *url)
+{
+ char **argv = NULL;
+ //char *command = strdup(command_line);
+ char command[1024];
+ char *command_pos = command;
+ char *arg_end;
+ int size = 0;
+
+ snprintf(command, sizeof(command), command_line, url);
+
+ argv = malloc(sizeof(char *) * 2);
+
+ while (command_pos)
+ {
+ argv = realloc(argv, sizeof(char *) * (size+2));
+
+ arg_end = strchr(command_pos, ' ');
+ if (arg_end)
+ {
+ *arg_end = 0;
+ }
+
+ argv[size] = strdup(command_pos);
+
+ if (arg_end)
+ {
+ command_pos = arg_end + 1;
+ }
+ else
+ {
+ command_pos = NULL;
+ }
+
+ size++;
+ }
+
+ argv[size] = NULL;
+
+ free(command);
+
+ return (argv);
+}
+#endif
+
+/* ---------------------------------------------------------------------------------------------------------------------- */
static void xsane_show_doc(GtkWidget *widget, gpointer data)
{
@@ -5939,53 +6840,81 @@ static void xsane_show_doc(GtkWidget *widget, gpointer data)
snprintf(path, sizeof(path), "%s/%s-doc.html", STRINGIFY(PATH_XSANE_DOC_DIR), name); /* no, we use original doc */
}
- if (!strcmp(preferences.doc_viewer, DOCVIEWER_NETSCAPE))
+ if (!strcmp(preferences.browser, BROWSER_NETSCAPE))
{
xsane_show_doc_via_nsr(widget, (void *) path);
}
else
{
- arg[0] = preferences.doc_viewer;
+ arg[0] = preferences.browser;
arg[1] = path;
arg[2] = 0;
pid = fork();
if (pid == 0) /* new process */
- {
- DBG(DBG_info, "trying to change user id fo new subprocess:\n");
- DBG(DBG_info, "old effective uid = %d\n", geteuid());
+ {
+ FILE *ipc_file = NULL;
+
+ if (xsane.ipc_pipefd[0])
+ {
+ close(xsane.ipc_pipefd[0]); /* close reading end of pipe */
+ ipc_file = fdopen(xsane.ipc_pipefd[1], "w");
+ }
+
+ DBG(DBG_info, "trying to change user id for new subprocess:\n");
+ DBG(DBG_info, "old effective uid = %d\n", (int) geteuid());
setuid(getuid());
- DBG(DBG_info, "new effective uid = %d\n", geteuid());
+ DBG(DBG_info, "new effective uid = %d\n", (int) geteuid());
DBG(DBG_info, "executing %s %s\n", arg[0], arg[1]);
execvp(arg[0], arg); /* does not return if successfully */
- DBG(DBG_error, "%s %s\n", ERR_FAILED_EXEC_DOC_VIEWER, preferences.doc_viewer);
+ DBG(DBG_error, "%s %s\n", ERR_FAILED_EXEC_DOC_VIEWER, preferences.browser);
+
+ /* send error message via IPC pipe to parent process */
+ if (ipc_file)
+ {
+ fprintf(ipc_file, "%s %s:\n%s", ERR_FAILED_EXEC_DOC_VIEWER, preferences.browser, strerror(errno));
+ fflush(ipc_file); /* make sure message is displayed */
+ fclose(ipc_file);
+ }
+
_exit(0); /* do not use exit() here! otherwise gtk gets in trouble */
}
+ else /* parent process */
+ {
+ xsane_add_process_to_list(pid); /* add pid to child process list */
+ }
}
}
/* ---------------------------------------------------------------------------------------------------------------------- */
+static void xsane_scan_callback(void)
+{
+ xsane.scan_rotation = xsane.preview->rotation;
+ xsane_scan_dialog();
+}
+
+/* ---------------------------------------------------------------------------------------------------------------------- */
+
static GtkWidget *xsane_view_build_menu(void)
{
- GtkWidget *menu, *item;
+ GtkWidget *menu, *item, *submenu, *subitem;
DBG(DBG_proc, "xsane_view_build_menu\n");
menu = gtk_menu_new();
- gtk_accel_group_attach(xsane.accelerator_group, GTK_OBJECT(menu));
- /* gtk_menu_set_accel_group(GTK_MENU(menu), xsane.accelerator_group); */
+ gtk_menu_set_accel_group(GTK_MENU(menu), xsane.accelerator_group);
/* show tooltips */
item = gtk_check_menu_item_new_with_label(MENU_ITEM_SHOW_TOOLTIPS);
- gtk_widget_add_accelerator(item, "activate", xsane.accelerator_group, GDK_1, GDK_CONTROL_MASK, GTK_ACCEL_VISIBLE | GTK_ACCEL_LOCKED);
+ gtk_widget_add_accelerator(item, "activate", xsane.accelerator_group, GDK_T, GDK_CONTROL_MASK, GTK_ACCEL_VISIBLE | DEF_GTK_ACCEL_LOCKED);
gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(item), preferences.tooltips_enabled);
gtk_menu_append(GTK_MENU(menu), item);
gtk_widget_show(item);
- gtk_signal_connect(GTK_OBJECT(item), "toggled", (GtkSignalFunc) xsane_pref_toggle_tooltips, NULL);
+ g_signal_connect(GTK_OBJECT(item), "toggled", (GtkSignalFunc) xsane_pref_toggle_tooltips, NULL);
/* insert separator: */
@@ -5995,207 +6924,205 @@ static GtkWidget *xsane_view_build_menu(void)
gtk_widget_show(item);
- /* show preview */
-
- xsane.show_preview_widget = gtk_check_menu_item_new_with_label(MENU_ITEM_SHOW_PREVIEW);
- gtk_widget_add_accelerator(xsane.show_preview_widget, "activate", xsane.accelerator_group, GDK_2, GDK_CONTROL_MASK, GTK_ACCEL_VISIBLE | GTK_ACCEL_LOCKED);
- gtk_menu_append(GTK_MENU(menu), xsane.show_preview_widget);
- gtk_widget_show(xsane.show_preview_widget);
- gtk_signal_connect(GTK_OBJECT(xsane.show_preview_widget), "toggled", (GtkSignalFunc) xsane_show_preview_callback, NULL);
-
- /* show histogram */
-
- xsane.show_histogram_widget = gtk_check_menu_item_new_with_label(MENU_ITEM_SHOW_HISTOGRAM);
- gtk_widget_add_accelerator(xsane.show_histogram_widget, "activate", xsane.accelerator_group, GDK_3, GDK_CONTROL_MASK, GTK_ACCEL_VISIBLE | GTK_ACCEL_LOCKED);
- gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(xsane.show_histogram_widget), preferences.show_histogram);
- gtk_menu_append(GTK_MENU(menu), xsane.show_histogram_widget);
- gtk_widget_show(xsane.show_histogram_widget);
- gtk_signal_connect(GTK_OBJECT(xsane.show_histogram_widget), "toggled", (GtkSignalFunc) xsane_show_histogram_callback, NULL);
-
-
-#ifdef HAVE_WORKING_GTK_GAMMACURVE
- /* show gamma */
-
- xsane.show_gamma_widget = gtk_check_menu_item_new_with_label(MENU_ITEM_SHOW_GAMMA);
- gtk_widget_add_accelerator(xsane.show_gamma_widget, "activate", xsane.accelerator_group, GDK_4, GDK_CONTROL_MASK, GTK_ACCEL_VISIBLE | GTK_ACCEL_LOCKED);
- gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(xsane.show_gamma_widget), preferences.show_gamma);
- gtk_menu_append(GTK_MENU(menu), xsane.show_gamma_widget);
- gtk_widget_show(xsane.show_gamma_widget);
- gtk_signal_connect(GTK_OBJECT(xsane.show_gamma_widget), "toggled", (GtkSignalFunc) xsane_show_gamma_callback, NULL);
-#endif
-
-
- /* show standard options */
-
- xsane.show_standard_options_widget = gtk_check_menu_item_new_with_label(MENU_ITEM_SHOW_STANDARDOPTIONS);
- gtk_widget_add_accelerator(xsane.show_standard_options_widget, "activate", xsane.accelerator_group, GDK_5, GDK_CONTROL_MASK, GTK_ACCEL_VISIBLE | GTK_ACCEL_LOCKED);
- gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(xsane.show_standard_options_widget), preferences.show_standard_options);
- gtk_menu_append(GTK_MENU(menu), xsane.show_standard_options_widget);
- gtk_widget_show(xsane.show_standard_options_widget);
- gtk_signal_connect(GTK_OBJECT(xsane.show_standard_options_widget), "toggled",
- (GtkSignalFunc) xsane_show_standard_options_callback, NULL);
-
-
- /* show advanced options */
-
- xsane.show_advanced_options_widget = gtk_check_menu_item_new_with_label(MENU_ITEM_SHOW_ADVANCEDOPTIONS);
- gtk_widget_add_accelerator(xsane.show_advanced_options_widget, "activate", xsane.accelerator_group, GDK_6, GDK_CONTROL_MASK, GTK_ACCEL_VISIBLE | GTK_ACCEL_LOCKED);
- gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(xsane.show_advanced_options_widget), preferences.show_advanced_options);
- gtk_menu_append(GTK_MENU(menu), xsane.show_advanced_options_widget);
- gtk_widget_show(xsane.show_advanced_options_widget);
- gtk_signal_connect(GTK_OBJECT(xsane.show_advanced_options_widget), "toggled",
- (GtkSignalFunc) xsane_show_advanced_options_callback, NULL);
-
- return menu;
-}
-
-/* ---------------------------------------------------------------------------------------------------------------------- */
-
-static GtkWidget *xsane_pref_build_menu(void)
-{
- GtkWidget *menu, *item, *submenu, *subitem;
-
- DBG(DBG_proc, "xsane_pref_build_menu\n");
-
- menu = gtk_menu_new();
- gtk_accel_group_attach(xsane.accelerator_group, GTK_OBJECT(menu));
-
-
- /* XSane setup dialog */
-
- item = gtk_menu_item_new_with_label(MENU_ITEM_SETUP);
- gtk_widget_add_accelerator(item, "activate", xsane.accelerator_group, GDK_S, GDK_SHIFT_MASK, GTK_ACCEL_VISIBLE | GTK_ACCEL_LOCKED);
- gtk_menu_append(GTK_MENU(menu), item);
- gtk_signal_connect(GTK_OBJECT(item), "activate", (GtkSignalFunc) xsane_setup_dialog, NULL);
- gtk_widget_show(item);
-
- /* insert separator: */
-
- item = gtk_menu_item_new();
- gtk_menu_append(GTK_MENU(menu), item);
- gtk_widget_show(item);
-
+ /* show resolution list */
-#ifdef XSANE_TEST
- /* XSane batch scan dialog */
+ xsane.show_resolution_list_widget = gtk_check_menu_item_new_with_label(MENU_ITEM_SHOW_RESOLUTIONLIST);
+ gtk_widget_add_accelerator(xsane.show_resolution_list_widget, "activate", xsane.accelerator_group, GDK_L, GDK_CONTROL_MASK, GTK_ACCEL_VISIBLE | DEF_GTK_ACCEL_LOCKED);
+ gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(xsane.show_resolution_list_widget), preferences.show_resolution_list);
+ gtk_menu_append(GTK_MENU(menu), xsane.show_resolution_list_widget);
+ gtk_widget_show(xsane.show_resolution_list_widget);
+ g_signal_connect(GTK_OBJECT(xsane.show_resolution_list_widget), "toggled", (GtkSignalFunc) xsane_show_resolution_list_callback, NULL);
- item = gtk_menu_item_new_with_label("Batch scan");
- gtk_menu_append(GTK_MENU(menu), item);
- gtk_signal_connect(GTK_OBJECT(item), "activate", (GtkSignalFunc) xsane_batch_scan_dialog, NULL);
- gtk_widget_show(item);
/* insert separator: */
item = gtk_menu_item_new();
gtk_menu_append(GTK_MENU(menu), item);
gtk_widget_show(item);
-#endif
- /* length unit */
+ /* update policy */
- item = gtk_menu_item_new_with_label(MENU_ITEM_LENGTH_UNIT);
+ item = gtk_menu_item_new_with_label(MENU_ITEM_UPDATE_POLICY);
gtk_menu_append(GTK_MENU(menu), item);
gtk_widget_show(item);
submenu = gtk_menu_new();
- subitem = gtk_check_menu_item_new_with_label(SUBMENU_ITEM_LENGTH_MILLIMETERS);
+ subitem = gtk_check_menu_item_new_with_label(SUBMENU_ITEM_POLICY_CONTINUOUS);
gtk_menu_append(GTK_MENU(submenu), subitem);
- if ( (preferences.length_unit > 0.9) && (preferences.length_unit < 1.1))
+ if (preferences.gtk_update_policy == GTK_UPDATE_CONTINUOUS)
{
gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(subitem), TRUE);
}
- gtk_signal_connect(GTK_OBJECT(subitem), "activate", (GtkSignalFunc) xsane_set_pref_unit_callback, "mm");
+ g_signal_connect(GTK_OBJECT(subitem), "toggled", (GtkSignalFunc) xsane_set_update_policy_callback, (void *) GTK_UPDATE_CONTINUOUS);
gtk_widget_show(subitem);
- xsane.length_unit_mm = subitem;
+ xsane.update_policy_continu = subitem;
- subitem = gtk_check_menu_item_new_with_label(SUBMENU_ITEM_LENGTH_CENTIMETERS);
+ subitem = gtk_check_menu_item_new_with_label(SUBMENU_ITEM_POLICY_DISCONTINU);
gtk_menu_append(GTK_MENU(submenu), subitem);
- if ( (preferences.length_unit > 9.9) && (preferences.length_unit < 10.1))
+ if (preferences.gtk_update_policy == GTK_UPDATE_DISCONTINUOUS)
{
gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(subitem), TRUE);
}
- gtk_signal_connect(GTK_OBJECT(subitem), "activate", (GtkSignalFunc) xsane_set_pref_unit_callback, "cm");
+ g_signal_connect(GTK_OBJECT(subitem), "toggled", (GtkSignalFunc) xsane_set_update_policy_callback, (void *) GTK_UPDATE_DISCONTINUOUS);
gtk_widget_show(subitem);
- xsane.length_unit_cm = subitem;
+ xsane.update_policy_discont = subitem;
- subitem = gtk_check_menu_item_new_with_label(SUBMENU_ITEM_LENGTH_INCHES);
+ subitem = gtk_check_menu_item_new_with_label(SUBMENU_ITEM_POLICY_DELAYED);
gtk_menu_append(GTK_MENU(submenu), subitem);
- if ( (preferences.length_unit > 25.3) && (preferences.length_unit < 25.5))
+ if (preferences.gtk_update_policy == GTK_UPDATE_DELAYED)
{
gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(subitem), TRUE);
}
- gtk_signal_connect(GTK_OBJECT(subitem), "activate", (GtkSignalFunc) xsane_set_pref_unit_callback, "in");
+ g_signal_connect(GTK_OBJECT(subitem), "toggled", (GtkSignalFunc) xsane_set_update_policy_callback, (void *) GTK_UPDATE_DELAYED);
gtk_widget_show(subitem);
- xsane.length_unit_in = subitem;
+ xsane.update_policy_delayed = subitem;
gtk_menu_item_set_submenu(GTK_MENU_ITEM(item), submenu);
+
/* insert separator: */
item = gtk_menu_item_new();
gtk_menu_append(GTK_MENU(menu), item);
gtk_widget_show(item);
- /* update policy */
- item = gtk_menu_item_new_with_label(MENU_ITEM_UPDATE_POLICY);
+ /* length unit */
+
+ item = gtk_menu_item_new_with_label(MENU_ITEM_LENGTH_UNIT);
gtk_menu_append(GTK_MENU(menu), item);
gtk_widget_show(item);
submenu = gtk_menu_new();
- subitem = gtk_check_menu_item_new_with_label(SUBMENU_ITEM_POLICY_CONTINUOUS);
+ subitem = gtk_check_menu_item_new_with_label(SUBMENU_ITEM_LENGTH_MILLIMETERS);
gtk_menu_append(GTK_MENU(submenu), subitem);
- if (preferences.gtk_update_policy == GTK_UPDATE_CONTINUOUS)
+ if ( (preferences.length_unit > 0.9) && (preferences.length_unit < 1.1))
{
gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(subitem), TRUE);
}
- gtk_signal_connect(GTK_OBJECT(subitem), "activate", (GtkSignalFunc) xsane_set_update_policy_callback, (void *) GTK_UPDATE_CONTINUOUS);
+ g_signal_connect(GTK_OBJECT(subitem), "toggled", (GtkSignalFunc) xsane_set_pref_unit_callback, "mm");
gtk_widget_show(subitem);
- xsane.update_policy_continu = subitem;
+ xsane.length_unit_mm = subitem;
- subitem = gtk_check_menu_item_new_with_label(SUBMENU_ITEM_POLICY_DISCONTINU);
+ subitem = gtk_check_menu_item_new_with_label(SUBMENU_ITEM_LENGTH_CENTIMETERS);
gtk_menu_append(GTK_MENU(submenu), subitem);
- if (preferences.gtk_update_policy == GTK_UPDATE_DISCONTINUOUS)
+ if ( (preferences.length_unit > 9.9) && (preferences.length_unit < 10.1))
{
gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(subitem), TRUE);
}
- gtk_signal_connect(GTK_OBJECT(subitem), "activate", (GtkSignalFunc) xsane_set_update_policy_callback, (void *) GTK_UPDATE_DISCONTINUOUS);
+ g_signal_connect(GTK_OBJECT(subitem), "toggled", (GtkSignalFunc) xsane_set_pref_unit_callback, "cm");
gtk_widget_show(subitem);
- xsane.update_policy_discont = subitem;
+ xsane.length_unit_cm = subitem;
- subitem = gtk_check_menu_item_new_with_label(SUBMENU_ITEM_POLICY_DELAYED);
+ subitem = gtk_check_menu_item_new_with_label(SUBMENU_ITEM_LENGTH_INCHES);
gtk_menu_append(GTK_MENU(submenu), subitem);
- if (preferences.gtk_update_policy == GTK_UPDATE_DELAYED)
+ if ( (preferences.length_unit > 25.3) && (preferences.length_unit < 25.5))
{
gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(subitem), TRUE);
}
- gtk_signal_connect(GTK_OBJECT(subitem), "activate", (GtkSignalFunc) xsane_set_update_policy_callback, (void *) GTK_UPDATE_DELAYED);
+ g_signal_connect(GTK_OBJECT(subitem), "toggled", (GtkSignalFunc) xsane_set_pref_unit_callback, "in");
gtk_widget_show(subitem);
- xsane.update_policy_delayed = subitem;
+ xsane.length_unit_in = subitem;
gtk_menu_item_set_submenu(GTK_MENU_ITEM(item), submenu);
+ return menu;
+}
+
+/* ---------------------------------------------------------------------------------------------------------------------- */
- /* insert separator: */
+static GtkWidget *xsane_window_build_menu(void)
+{
+ GtkWidget *menu;
- item = gtk_menu_item_new();
- gtk_menu_append(GTK_MENU(menu), item);
- gtk_widget_show(item);
+ DBG(DBG_proc, "xsane_window_build_menu\n");
+ menu = gtk_menu_new();
+ gtk_menu_set_accel_group(GTK_MENU(menu), xsane.accelerator_group);
- /* show resolution list */
- xsane.show_resolution_list_widget = gtk_check_menu_item_new_with_label(MENU_ITEM_SHOW_RESOLUTIONLIST);
- gtk_widget_add_accelerator(xsane.show_resolution_list_widget, "activate", xsane.accelerator_group, GDK_L, GDK_CONTROL_MASK, GTK_ACCEL_VISIBLE | GTK_ACCEL_LOCKED);
- gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(xsane.show_resolution_list_widget), preferences.show_resolution_list);
- gtk_menu_append(GTK_MENU(menu), xsane.show_resolution_list_widget);
- gtk_widget_show(xsane.show_resolution_list_widget);
- gtk_signal_connect(GTK_OBJECT(xsane.show_resolution_list_widget), "toggled",
- (GtkSignalFunc) xsane_show_resolution_list_callback, NULL);
+ /* show preview */
+
+ xsane.show_preview_widget = gtk_check_menu_item_new_with_label(MENU_ITEM_SHOW_PREVIEW);
+ gtk_widget_add_accelerator(xsane.show_preview_widget, "activate", xsane.accelerator_group, GDK_1, GDK_CONTROL_MASK, GTK_ACCEL_VISIBLE | DEF_GTK_ACCEL_LOCKED);
+ gtk_menu_append(GTK_MENU(menu), xsane.show_preview_widget);
+ gtk_widget_show(xsane.show_preview_widget);
+ g_signal_connect(GTK_OBJECT(xsane.show_preview_widget), "toggled", (GtkSignalFunc) xsane_show_preview_callback, NULL);
+
+ /* show histogram */
+
+ xsane.show_histogram_widget = gtk_check_menu_item_new_with_label(MENU_ITEM_SHOW_HISTOGRAM);
+ gtk_widget_add_accelerator(xsane.show_histogram_widget, "activate", xsane.accelerator_group, GDK_2, GDK_CONTROL_MASK, GTK_ACCEL_VISIBLE | DEF_GTK_ACCEL_LOCKED);
+ gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(xsane.show_histogram_widget), preferences.show_histogram);
+ gtk_menu_append(GTK_MENU(menu), xsane.show_histogram_widget);
+ gtk_widget_show(xsane.show_histogram_widget);
+ g_signal_connect(GTK_OBJECT(xsane.show_histogram_widget), "toggled", (GtkSignalFunc) xsane_show_histogram_callback, NULL);
+
+
+#ifdef HAVE_WORKING_GTK_GAMMACURVE
+ /* show gamma */
+
+ xsane.show_gamma_widget = gtk_check_menu_item_new_with_label(MENU_ITEM_SHOW_GAMMA);
+ gtk_widget_add_accelerator(xsane.show_gamma_widget, "activate", xsane.accelerator_group, GDK_3, GDK_CONTROL_MASK, GTK_ACCEL_VISIBLE | DEF_GTK_ACCEL_LOCKED);
+ gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(xsane.show_gamma_widget), preferences.show_gamma);
+ gtk_menu_append(GTK_MENU(menu), xsane.show_gamma_widget);
+ gtk_widget_show(xsane.show_gamma_widget);
+ g_signal_connect(GTK_OBJECT(xsane.show_gamma_widget), "toggled", (GtkSignalFunc) xsane_show_gamma_callback, NULL);
+#endif
+
+ /* show batch_scan */
+
+ xsane.show_batch_scan_widget = gtk_check_menu_item_new_with_label(MENU_ITEM_SHOW_BATCH_SCAN);
+ gtk_widget_add_accelerator(xsane.show_batch_scan_widget, "activate", xsane.accelerator_group, GDK_4, GDK_CONTROL_MASK, GTK_ACCEL_VISIBLE | DEF_GTK_ACCEL_LOCKED);
+ gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(xsane.show_batch_scan_widget), preferences.show_batch_scan);
+ gtk_menu_append(GTK_MENU(menu), xsane.show_batch_scan_widget);
+ gtk_widget_show(xsane.show_batch_scan_widget);
+ g_signal_connect(GTK_OBJECT(xsane.show_batch_scan_widget), "toggled", (GtkSignalFunc) xsane_show_batch_scan_callback, NULL);
+
+ /* show standard options */
+
+ xsane.show_standard_options_widget = gtk_check_menu_item_new_with_label(MENU_ITEM_SHOW_STANDARDOPTIONS);
+ gtk_widget_add_accelerator(xsane.show_standard_options_widget, "activate", xsane.accelerator_group, GDK_5, GDK_CONTROL_MASK, GTK_ACCEL_VISIBLE | DEF_GTK_ACCEL_LOCKED);
+ gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(xsane.show_standard_options_widget), preferences.show_standard_options);
+ gtk_menu_append(GTK_MENU(menu), xsane.show_standard_options_widget);
+ gtk_widget_show(xsane.show_standard_options_widget);
+ g_signal_connect(GTK_OBJECT(xsane.show_standard_options_widget), "toggled", (GtkSignalFunc) xsane_show_standard_options_callback, NULL);
+
+ /* show advanced options */
+
+ xsane.show_advanced_options_widget = gtk_check_menu_item_new_with_label(MENU_ITEM_SHOW_ADVANCEDOPTIONS);
+ gtk_widget_add_accelerator(xsane.show_advanced_options_widget, "activate", xsane.accelerator_group, GDK_6, GDK_CONTROL_MASK, GTK_ACCEL_VISIBLE | DEF_GTK_ACCEL_LOCKED);
+ gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(xsane.show_advanced_options_widget), preferences.show_advanced_options);
+ gtk_menu_append(GTK_MENU(menu), xsane.show_advanced_options_widget);
+ gtk_widget_show(xsane.show_advanced_options_widget);
+ g_signal_connect(GTK_OBJECT(xsane.show_advanced_options_widget), "toggled", (GtkSignalFunc) xsane_show_advanced_options_callback, NULL);
+
+ return menu;
+}
+
+/* ---------------------------------------------------------------------------------------------------------------------- */
+
+static GtkWidget *xsane_preferences_build_menu(void)
+{
+ GtkWidget *menu, *item;
+
+ DBG(DBG_proc, "xsane_preferences_build_menu\n");
+
+ menu = gtk_menu_new();
+ gtk_menu_set_accel_group(GTK_MENU(menu), xsane.accelerator_group);
+
+
+ /* XSane setup dialog */
+
+ item = gtk_menu_item_new_with_label(MENU_ITEM_SETUP);
+ gtk_widget_add_accelerator(item, "activate", xsane.accelerator_group, GDK_S, GDK_MOD1_MASK, GTK_ACCEL_VISIBLE | DEF_GTK_ACCEL_LOCKED);
+ gtk_menu_append(GTK_MENU(menu), item);
+ g_signal_connect(GTK_OBJECT(item), "activate", (GtkSignalFunc) xsane_setup_dialog, NULL);
+ gtk_widget_show(item);
/* insert separator: */
@@ -6204,16 +7131,14 @@ static GtkWidget *xsane_pref_build_menu(void)
gtk_widget_show(item);
- /* page orientation */
- item = gtk_check_menu_item_new_with_label(MENU_ITEM_PAGE_ROTATE);
- gtk_widget_add_accelerator(item, "activate", xsane.accelerator_group, GDK_R, GDK_CONTROL_MASK, GTK_ACCEL_VISIBLE | GTK_ACCEL_LOCKED);
- gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(item), preferences.psrotate);
+ /* change working directory */
+
+ item = gtk_menu_item_new_with_label(MENU_ITEM_CHANGE_WORKING_DIR);
+ gtk_widget_add_accelerator(item, "activate", xsane.accelerator_group, GDK_D, GDK_CONTROL_MASK, GTK_ACCEL_VISIBLE | DEF_GTK_ACCEL_LOCKED);
gtk_menu_append(GTK_MENU(menu), item);
+ g_signal_connect(GTK_OBJECT(item), "activate", (GtkSignalFunc) xsane_change_working_directory, NULL);
gtk_widget_show(item);
- gtk_signal_connect(GTK_OBJECT(item), "toggled", (GtkSignalFunc) xsane_page_rotate_callback, NULL);
-
-
/* insert separator: */
@@ -6221,34 +7146,33 @@ static GtkWidget *xsane_pref_build_menu(void)
gtk_menu_append(GTK_MENU(menu), item);
gtk_widget_show(item);
- /* Save device setting */
+ /* edit medium definitions */
- item = gtk_menu_item_new_with_label(MENU_ITEM_SAVE_DEVICE_SETTINGS);
- gtk_widget_add_accelerator(item, "activate", xsane.accelerator_group, GDK_P, GDK_CONTROL_MASK, GTK_ACCEL_VISIBLE | GTK_ACCEL_LOCKED);
+ item = gtk_check_menu_item_new_with_label(MENU_ITEM_EDIT_MEDIUM_DEF);
+ g_signal_connect(GTK_OBJECT(item), "toggled", (GtkSignalFunc) xsane_edit_medium_definition_callback, NULL);
gtk_menu_append(GTK_MENU(menu), item);
- gtk_signal_connect(GTK_OBJECT(item), "activate", (GtkSignalFunc) xsane_device_preferences_save, NULL);
gtk_widget_show(item);
- /* Load device setting */
+ /* insert separator: */
- item = gtk_menu_item_new_with_label(MENU_ITEM_LOAD_DEVICE_SETTINGS);
- gtk_widget_add_accelerator(item, "activate", xsane.accelerator_group, GDK_G, GDK_CONTROL_MASK, GTK_ACCEL_VISIBLE | GTK_ACCEL_LOCKED);
+ item = gtk_menu_item_new();
gtk_menu_append(GTK_MENU(menu), item);
- gtk_signal_connect(GTK_OBJECT(item), "activate", (GtkSignalFunc) xsane_device_preferences_load, NULL);
gtk_widget_show(item);
- /* insert separator: */
+ /* Save device setting */
- item = gtk_menu_item_new();
+ item = gtk_menu_item_new_with_label(MENU_ITEM_SAVE_DEVICE_SETTINGS);
+ gtk_widget_add_accelerator(item, "activate", xsane.accelerator_group, GDK_P, GDK_CONTROL_MASK, GTK_ACCEL_VISIBLE | DEF_GTK_ACCEL_LOCKED);
gtk_menu_append(GTK_MENU(menu), item);
+ g_signal_connect(GTK_OBJECT(item), "activate", (GtkSignalFunc) xsane_device_preferences_save, NULL);
gtk_widget_show(item);
- /* change working directory */
+ /* Load device setting */
- item = gtk_menu_item_new_with_label(MENU_ITEM_CHANGE_WORKING_DIR);
- gtk_widget_add_accelerator(item, "activate", xsane.accelerator_group, GDK_D, GDK_CONTROL_MASK, GTK_ACCEL_VISIBLE | GTK_ACCEL_LOCKED);
+ item = gtk_menu_item_new_with_label(MENU_ITEM_LOAD_DEVICE_SETTINGS);
+ gtk_widget_add_accelerator(item, "activate", xsane.accelerator_group, GDK_G, GDK_CONTROL_MASK, GTK_ACCEL_VISIBLE | DEF_GTK_ACCEL_LOCKED);
gtk_menu_append(GTK_MENU(menu), item);
- gtk_signal_connect(GTK_OBJECT(item), "activate", (GtkSignalFunc) xsane_change_working_directory, NULL);
+ g_signal_connect(GTK_OBJECT(item), "activate", (GtkSignalFunc) xsane_device_preferences_load, NULL);
gtk_widget_show(item);
return menu;
@@ -6263,23 +7187,16 @@ static GtkWidget *xsane_help_build_menu(void)
DBG(DBG_proc, "xsane_help_build_menu\n");
menu = gtk_menu_new();
- gtk_accel_group_attach(xsane.accelerator_group, GTK_OBJECT(menu));
-
+ gtk_menu_set_accel_group(GTK_MENU(menu), xsane.accelerator_group);
- /* XSane about dialog */
- item = gtk_menu_item_new_with_label(MENU_ITEM_ABOUT_XSANE);
- gtk_menu_append(GTK_MENU(menu), item);
- gtk_signal_connect(GTK_OBJECT(item), "activate", (GtkSignalFunc) xsane_about_dialog, NULL);
- gtk_widget_add_accelerator(item, "activate", xsane.accelerator_group, GDK_F6, 0, GTK_ACCEL_VISIBLE | GTK_ACCEL_LOCKED);
- gtk_widget_show(item);
- /* XSane about translation dialog */
+ /* XSane doc -> html viewer */
- item = gtk_menu_item_new_with_label(MENU_ITEM_ABOUT_TRANSLATION);
+ item = gtk_menu_item_new_with_label(MENU_ITEM_XSANE_DOC);
gtk_menu_append(GTK_MENU(menu), item);
- gtk_signal_connect(GTK_OBJECT(item), "activate", (GtkSignalFunc) xsane_about_translation_dialog, NULL);
- gtk_widget_add_accelerator(item, "activate", xsane.accelerator_group, GDK_F7, 0, GTK_ACCEL_VISIBLE | GTK_ACCEL_LOCKED);
+ g_signal_connect(GTK_OBJECT(item), "activate", (GtkSignalFunc) xsane_show_doc, (void *) "sane-xsane");
+ gtk_widget_add_accelerator(item, "activate", xsane.accelerator_group, GDK_F1, 0, GTK_ACCEL_VISIBLE | DEF_GTK_ACCEL_LOCKED);
gtk_widget_show(item);
@@ -6290,28 +7207,46 @@ static GtkWidget *xsane_help_build_menu(void)
gtk_widget_show(item);
- /* XSane license */
+ /* Backend doc -> html viewer */
+
+ if (xsane.backend)
+ {
+ item = gtk_menu_item_new_with_label(MENU_ITEM_BACKEND_DOC);
+ gtk_menu_append(GTK_MENU(menu), item);
+ g_signal_connect(GTK_OBJECT(item), "activate", (GtkSignalFunc) xsane_show_doc, (void *) xsane.backend);
+ gtk_widget_add_accelerator(item, "activate", xsane.accelerator_group, GDK_F2, 0, GTK_ACCEL_VISIBLE | DEF_GTK_ACCEL_LOCKED);
+ gtk_widget_show(item);
+ }
+
+
+ /* available backends -> html viewer */
- item = gtk_menu_item_new_with_label(MENU_ITEM_XSANE_LICENSE);
+ item = gtk_menu_item_new_with_label(MENU_ITEM_AVAILABLE_BACKENDS);
gtk_menu_append(GTK_MENU(menu), item);
- gtk_signal_connect(GTK_OBJECT(item), "activate", (GtkSignalFunc) xsane_show_license, NULL);
- gtk_widget_add_accelerator(item, "activate", xsane.accelerator_group, GDK_F8, 0, GTK_ACCEL_VISIBLE | GTK_ACCEL_LOCKED);
+ g_signal_connect(GTK_OBJECT(item), "activate", (GtkSignalFunc) xsane_show_doc, (void *) "sane-backends");
+ gtk_widget_add_accelerator(item, "activate", xsane.accelerator_group, GDK_F3, 0, GTK_ACCEL_VISIBLE | DEF_GTK_ACCEL_LOCKED);
gtk_widget_show(item);
+
+ /* problems -> html viewer */
- /* separator */
+ item = gtk_menu_item_new_with_label(MENU_ITEM_PROBLEMS);
+ gtk_menu_append(GTK_MENU(menu), item);
+ g_signal_connect(GTK_OBJECT(item), "activate", (GtkSignalFunc) xsane_show_doc, (void *) "sane-problems");
+ gtk_widget_add_accelerator(item, "activate", xsane.accelerator_group, GDK_F4, 0, GTK_ACCEL_VISIBLE | DEF_GTK_ACCEL_LOCKED);
+ gtk_widget_show(item);
item = gtk_menu_item_new();
gtk_menu_append(GTK_MENU(menu), item);
gtk_widget_show(item);
- /* XSane doc -> html viewer */
+ /* scantips -> html viewer */
- item = gtk_menu_item_new_with_label(MENU_ITEM_XSANE_DOC);
+ item = gtk_menu_item_new_with_label(MENU_ITEM_SCANTIPS);
gtk_menu_append(GTK_MENU(menu), item);
- gtk_signal_connect(GTK_OBJECT(item), "activate", (GtkSignalFunc) xsane_show_doc, (void *) "sane-xsane");
- gtk_widget_add_accelerator(item, "activate", xsane.accelerator_group, GDK_F1, 0, GTK_ACCEL_VISIBLE | GTK_ACCEL_LOCKED);
+ g_signal_connect(GTK_OBJECT(item), "activate", (GtkSignalFunc) xsane_show_doc, (void *) "sane-scantips");
+ gtk_widget_add_accelerator(item, "activate", xsane.accelerator_group, GDK_F5, 0, GTK_ACCEL_VISIBLE | DEF_GTK_ACCEL_LOCKED);
gtk_widget_show(item);
@@ -6322,48 +7257,47 @@ static GtkWidget *xsane_help_build_menu(void)
gtk_widget_show(item);
- /* Backend doc -> html viewer */
-
- if (xsane.backend)
- {
- item = gtk_menu_item_new_with_label(MENU_ITEM_BACKEND_DOC);
- gtk_menu_append(GTK_MENU(menu), item);
- gtk_signal_connect(GTK_OBJECT(item), "activate", (GtkSignalFunc) xsane_show_doc, (void *) xsane.backend);
- gtk_widget_add_accelerator(item, "activate", xsane.accelerator_group, GDK_F2, 0, GTK_ACCEL_VISIBLE | GTK_ACCEL_LOCKED);
- gtk_widget_show(item);
- }
-
-
- /* available backends -> html viewer */
+ /* XSane about dialog */
- item = gtk_menu_item_new_with_label(MENU_ITEM_AVAILABLE_BACKENDS);
+ item = gtk_menu_item_new_with_label(MENU_ITEM_ABOUT_XSANE);
gtk_menu_append(GTK_MENU(menu), item);
- gtk_signal_connect(GTK_OBJECT(item), "activate", (GtkSignalFunc) xsane_show_doc, (void *) "sane-backends");
- gtk_widget_add_accelerator(item, "activate", xsane.accelerator_group, GDK_F3, 0, GTK_ACCEL_VISIBLE | GTK_ACCEL_LOCKED);
+ g_signal_connect(GTK_OBJECT(item), "activate", (GtkSignalFunc) xsane_about_dialog, NULL);
+ gtk_widget_add_accelerator(item, "activate", xsane.accelerator_group, GDK_F6, 0, GTK_ACCEL_VISIBLE | DEF_GTK_ACCEL_LOCKED);
gtk_widget_show(item);
-
- /* problems -> html viewer */
+ /* XSane about translation dialog */
- item = gtk_menu_item_new_with_label(MENU_ITEM_PROBLEMS);
+ item = gtk_menu_item_new_with_label(MENU_ITEM_ABOUT_TRANSLATION);
gtk_menu_append(GTK_MENU(menu), item);
- gtk_signal_connect(GTK_OBJECT(item), "activate", (GtkSignalFunc) xsane_show_doc, (void *) "sane-problems");
- gtk_widget_add_accelerator(item, "activate", xsane.accelerator_group, GDK_F4, 0, GTK_ACCEL_VISIBLE | GTK_ACCEL_LOCKED);
+ g_signal_connect(GTK_OBJECT(item), "activate", (GtkSignalFunc) xsane_about_translation_dialog, NULL);
+ gtk_widget_add_accelerator(item, "activate", xsane.accelerator_group, GDK_F7, 0, GTK_ACCEL_VISIBLE | DEF_GTK_ACCEL_LOCKED);
gtk_widget_show(item);
+
+ /* separator */
+
item = gtk_menu_item_new();
gtk_menu_append(GTK_MENU(menu), item);
gtk_widget_show(item);
- /* scantips -> html viewer */
+ /* XSane eula */
- item = gtk_menu_item_new_with_label(MENU_ITEM_SCANTIPS);
+ item = gtk_menu_item_new_with_label(MENU_ITEM_XSANE_EULA);
gtk_menu_append(GTK_MENU(menu), item);
- gtk_signal_connect(GTK_OBJECT(item), "activate", (GtkSignalFunc) xsane_show_doc, (void *) "sane-scantips");
- gtk_widget_add_accelerator(item, "activate", xsane.accelerator_group, GDK_F5, 0, GTK_ACCEL_VISIBLE | GTK_ACCEL_LOCKED);
+ g_signal_connect(GTK_OBJECT(item), "activate", (GtkSignalFunc) xsane_show_eula, NULL);
+ gtk_widget_add_accelerator(item, "activate", xsane.accelerator_group, GDK_F8, 0, GTK_ACCEL_VISIBLE | DEF_GTK_ACCEL_LOCKED);
gtk_widget_show(item);
+ /* gpl */
+
+ item = gtk_menu_item_new_with_label(MENU_ITEM_XSANE_GPL);
+ gtk_menu_append(GTK_MENU(menu), item);
+ g_signal_connect(GTK_OBJECT(item), "activate", (GtkSignalFunc) xsane_show_gpl, NULL);
+ gtk_widget_add_accelerator(item, "activate", xsane.accelerator_group, GDK_F9, 0, GTK_ACCEL_VISIBLE | DEF_GTK_ACCEL_LOCKED);
+ gtk_widget_show(item);
+
+
return menu;
}
@@ -6373,12 +7307,14 @@ void xsane_panel_build()
{
GtkWidget *standard_vbox;
GtkWidget *advanced_vbox;
- GtkWidget *parent, *vbox, *button, *label;
+ GtkWidget *standard_parent;
+ GtkWidget *advanced_parent;
+ GtkWidget *parent, *button, *label;
const SANE_Option_Descriptor *opt;
SANE_Handle dev = xsane.dev;
double dval, dmin, dmax, dquant;
char *buf, str[16], title[256];
- GSGDialogElement *elem;
+ DialogElement *elem;
SANE_Word quant, val;
SANE_Status status;
SANE_Int num_words;
@@ -6414,6 +7350,10 @@ void xsane_panel_build()
xsane.well_known.highlight_r = -1;
xsane.well_known.highlight_g = -1;
xsane.well_known.highlight_b = -1;
+ xsane.well_known.batch_scan_start = -1;
+ xsane.well_known.batch_scan_loop = -1;
+ xsane.well_known.batch_scan_end = -1;
+ xsane.well_known.batch_scan_next_tl_y = -1;
/* standard options */
@@ -6444,97 +7384,142 @@ void xsane_panel_build()
vector_opts = alloca(xsane.num_elements * sizeof (int));
- parent = standard_vbox;
+ standard_parent = standard_vbox;
+ advanced_parent = advanced_vbox;
for (i = 1; i < xsane.num_elements; ++i)
+ {
+ opt = xsane_get_option_descriptor(dev, i);
+ if (!SANE_OPTION_IS_ACTIVE(opt->cap))
+ {
+ continue;
+ }
+
+ /* pick up well-known options as we go: */
+ if (opt->name)
{
- opt = xsane_get_option_descriptor(dev, i);
- if (!SANE_OPTION_IS_ACTIVE(opt->cap))
+ if (strcmp(opt->name, SANE_NAME_PREVIEW) == 0 && opt->type == SANE_TYPE_BOOL)
+ {
+ xsane.well_known.preview = i;
continue;
+ }
+ else if (strcmp(opt->name, SANE_NAME_SCAN_RESOLUTION) == 0
+ && opt->unit == SANE_UNIT_DPI && (opt->type == SANE_TYPE_INT || opt->type == SANE_TYPE_FIXED))
+ xsane.well_known.dpi = i;
+ else if (strcmp(opt->name, SANE_NAME_SCAN_X_RESOLUTION) == 0
+ && opt->unit == SANE_UNIT_DPI && (opt->type == SANE_TYPE_INT || opt->type == SANE_TYPE_FIXED))
+ xsane.well_known.dpi_x = i;
+ else if (strcmp(opt->name, SANE_NAME_SCAN_Y_RESOLUTION) == 0
+ && opt->unit == SANE_UNIT_DPI && (opt->type == SANE_TYPE_INT || opt->type == SANE_TYPE_FIXED))
+ xsane.well_known.dpi_y = i;
+ else if (strcmp (opt->name, SANE_NAME_SCAN_MODE) == 0)
+ xsane.well_known.scanmode = i;
+ else if (strcmp (opt->name, SANE_NAME_SCAN_SOURCE) == 0)
+ xsane.well_known.scansource = i;
+ else if (strcmp (opt->name, SANE_NAME_SCAN_TL_X) == 0)
+ xsane.well_known.coord[xsane_back_gtk_TL_X] = i;
+ else if (strcmp (opt->name, SANE_NAME_SCAN_TL_Y) == 0)
+ xsane.well_known.coord[xsane_back_gtk_TL_Y] = i;
+ else if (strcmp (opt->name, SANE_NAME_SCAN_BR_X) == 0)
+ xsane.well_known.coord[xsane_back_gtk_BR_X] = i;
+ else if (strcmp (opt->name, SANE_NAME_SCAN_BR_Y) == 0)
+ xsane.well_known.coord[xsane_back_gtk_BR_Y] = i;
+ else if (strcmp (opt->name, SANE_NAME_GAMMA_VECTOR) == 0)
+ xsane.well_known.gamma_vector = i;
+ else if (strcmp (opt->name, SANE_NAME_GAMMA_VECTOR_R) == 0)
+ xsane.well_known.gamma_vector_r = i;
+ else if (strcmp (opt->name, SANE_NAME_GAMMA_VECTOR_G) == 0)
+ xsane.well_known.gamma_vector_g = i;
+ else if (strcmp (opt->name, SANE_NAME_GAMMA_VECTOR_B) == 0)
+ xsane.well_known.gamma_vector_b = i;
+ else if (strcmp (opt->name, SANE_NAME_BIT_DEPTH) == 0)
+ xsane.well_known.bit_depth = i;
+ else if (strcmp (opt->name, SANE_NAME_THRESHOLD) == 0)
+ xsane.well_known.threshold = i;
+ else if (strcmp (opt->name, SANE_NAME_HIGHLIGHT) == 0)
+ xsane.well_known.highlight = i;
+ else if (strcmp (opt->name, SANE_NAME_HIGHLIGHT_R) == 0)
+ xsane.well_known.highlight_r = i;
+ else if (strcmp (opt->name, SANE_NAME_HIGHLIGHT_G) == 0)
+ xsane.well_known.highlight_g = i;
+ else if (strcmp (opt->name, SANE_NAME_HIGHLIGHT_B) == 0)
+ xsane.well_known.highlight_b = i;
+ else if (strcmp (opt->name, SANE_NAME_SHADOW) == 0)
+ xsane.well_known.shadow = i;
+ else if (strcmp (opt->name, SANE_NAME_SHADOW_R) == 0)
+ xsane.well_known.shadow_r = i;
+ else if (strcmp (opt->name, SANE_NAME_SHADOW_G) == 0)
+ xsane.well_known.shadow_g = i;
+ else if (strcmp (opt->name, SANE_NAME_SHADOW_B) == 0)
+ xsane.well_known.shadow_b = i;
+ else if (strcmp (opt->name, SANE_NAME_BATCH_SCAN_START) == 0)
+ xsane.well_known.batch_scan_start = i;
+ else if (strcmp (opt->name, SANE_NAME_BATCH_SCAN_LOOP) == 0)
+ xsane.well_known.batch_scan_loop = i;
+ else if (strcmp (opt->name, SANE_NAME_BATCH_SCAN_END) == 0)
+ xsane.well_known.batch_scan_end = i;
+ else if (strcmp (opt->name, SANE_NAME_BATCH_SCAN_NEXT_TL_Y) == 0)
+ xsane.well_known.batch_scan_next_tl_y = i;
+ }
+
+ elem = xsane.element + i;
+
+ if (opt->unit == SANE_UNIT_NONE)
+ {
+ snprintf(title, sizeof(title), "%s", _BGT(opt->title));
+ }
+ else
+ {
+ snprintf(title, sizeof(title), "%s [%s]", _BGT(opt->title), xsane_back_gtk_unit_string(opt->unit));
+ }
+
+ if (opt->cap & SANE_CAP_ADVANCED)
+ {
+ parent = advanced_parent;
+ }
+ else
+ {
+ parent = standard_parent;
+ }
- /* pick up well-known options as we go: */
- if (opt->name)
+ switch (opt->type)
+ {
+ case SANE_TYPE_GROUP:
+ /* group a set of options */
+ if (opt->cap & SANE_CAP_ADVANCED)
{
- if (strcmp(opt->name, SANE_NAME_PREVIEW) == 0 && opt->type == SANE_TYPE_BOOL)
- {
- xsane.well_known.preview = i;
- continue;
- }
- else if (strcmp(opt->name, SANE_NAME_SCAN_RESOLUTION) == 0
- && opt->unit == SANE_UNIT_DPI && (opt->type == SANE_TYPE_INT || opt->type == SANE_TYPE_FIXED))
- xsane.well_known.dpi = i;
- else if (strcmp(opt->name, SANE_NAME_SCAN_X_RESOLUTION) == 0
- && opt->unit == SANE_UNIT_DPI && (opt->type == SANE_TYPE_INT || opt->type == SANE_TYPE_FIXED))
- xsane.well_known.dpi_x = i;
- else if (strcmp(opt->name, SANE_NAME_SCAN_Y_RESOLUTION) == 0
- && opt->unit == SANE_UNIT_DPI && (opt->type == SANE_TYPE_INT || opt->type == SANE_TYPE_FIXED))
- xsane.well_known.dpi_y = i;
- else if (strcmp (opt->name, SANE_NAME_SCAN_MODE) == 0)
- xsane.well_known.scanmode = i;
- else if (strcmp (opt->name, SANE_NAME_SCAN_SOURCE) == 0)
- xsane.well_known.scansource = i;
- else if (strcmp (opt->name, SANE_NAME_SCAN_TL_X) == 0)
- xsane.well_known.coord[xsane_back_gtk_TL_X] = i;
- else if (strcmp (opt->name, SANE_NAME_SCAN_TL_Y) == 0)
- xsane.well_known.coord[xsane_back_gtk_TL_Y] = i;
- else if (strcmp (opt->name, SANE_NAME_SCAN_BR_X) == 0)
- xsane.well_known.coord[xsane_back_gtk_BR_X] = i;
- else if (strcmp (opt->name, SANE_NAME_SCAN_BR_Y) == 0)
- xsane.well_known.coord[xsane_back_gtk_BR_Y] = i;
- else if (strcmp (opt->name, SANE_NAME_GAMMA_VECTOR) == 0)
- xsane.well_known.gamma_vector = i;
- else if (strcmp (opt->name, SANE_NAME_GAMMA_VECTOR_R) == 0)
- xsane.well_known.gamma_vector_r = i;
- else if (strcmp (opt->name, SANE_NAME_GAMMA_VECTOR_G) == 0)
- xsane.well_known.gamma_vector_g = i;
- else if (strcmp (opt->name, SANE_NAME_GAMMA_VECTOR_B) == 0)
- xsane.well_known.gamma_vector_b = i;
- else if (strcmp (opt->name, SANE_NAME_BIT_DEPTH) == 0)
- xsane.well_known.bit_depth = i;
- else if (strcmp (opt->name, SANE_NAME_THRESHOLD) == 0)
- xsane.well_known.threshold = i;
- else if (strcmp (opt->name, SANE_NAME_HIGHLIGHT) == 0)
- xsane.well_known.highlight = i;
- else if (strcmp (opt->name, SANE_NAME_HIGHLIGHT_R) == 0)
- xsane.well_known.highlight_r = i;
- else if (strcmp (opt->name, SANE_NAME_HIGHLIGHT_G) == 0)
- xsane.well_known.highlight_g = i;
- else if (strcmp (opt->name, SANE_NAME_HIGHLIGHT_B) == 0)
- xsane.well_known.highlight_b = i;
- else if (strcmp (opt->name, SANE_NAME_SHADOW) == 0)
- xsane.well_known.shadow = i;
- else if (strcmp (opt->name, SANE_NAME_SHADOW_R) == 0)
- xsane.well_known.shadow_r = i;
- else if (strcmp (opt->name, SANE_NAME_SHADOW_G) == 0)
- xsane.well_known.shadow_g = i;
- else if (strcmp (opt->name, SANE_NAME_SHADOW_B) == 0)
- xsane.well_known.shadow_b = i;
+ /* advanced group: put all options to the advanced options window */
+ standard_parent = xsane_back_gtk_group_new(advanced_vbox, title);
+ advanced_parent = standard_parent;
+ elem->widget = standard_parent;
}
+ else
+ {
+ /* we create the group twice. if no option is defined in one of this groups */
+ /* then the group is not shown */
- elem = xsane.element + i;
+ /* standard group: put standard options to the standard options window */
+ standard_parent = xsane_back_gtk_group_new(standard_vbox, title);
+ elem->widget = standard_parent;
- if (opt->unit == SANE_UNIT_NONE)
- {
- snprintf(title, sizeof(title), "%s", _BGT(opt->title));
- }
- else
- {
- snprintf(title, sizeof(title), "%s [%s]", _BGT(opt->title), xsane_back_gtk_unit_string(opt->unit));
- }
+ /* standard group: put advanced options to the advanced options window */
+ advanced_parent = xsane_back_gtk_group_new(advanced_vbox, title);
+ elem->widget2 = advanced_parent;
+ }
+ break;
- switch (opt->type)
- {
- case SANE_TYPE_GROUP:
- /* group a set of options */
- vbox = standard_vbox;
- if (opt->cap & SANE_CAP_ADVANCED)
- {
- vbox = advanced_vbox;
- }
- parent = xsane_back_gtk_group_new(vbox, title);
- elem->widget = parent;
- break;
+ case SANE_TYPE_BOOL:
+ if (!opt->name)
+ {
+ DBG(DBG_error, "xsane_panel_build: Option %d, type SANE_TYPE_BOOL\n", i);
+ DBG(DBG_error, "=> %s\n", ERR_OPTION_NAME_NULL);
+ DBG(DBG_error, "=> %s\n", ERR_BACKEND_BUG);
+ break;
+ }
- case SANE_TYPE_BOOL:
+ if ( (strcmp(opt->name, SANE_NAME_BATCH_SCAN_START) ) && /* do not show batch scan options */
+ (strcmp(opt->name, SANE_NAME_BATCH_SCAN_LOOP) ) &&
+ (strcmp(opt->name, SANE_NAME_BATCH_SCAN_END) ) )
+ {
assert(opt->size == sizeof(SANE_Word));
status = xsane_control_option(xsane.dev, i, SANE_ACTION_GET_VALUE, &val, 0);
if (status != SANE_STATUS_GOOD)
@@ -6543,209 +7528,266 @@ void xsane_panel_build()
}
xsane_back_gtk_button_new(parent, title, val, elem, xsane.tooltips, _BGT(opt->desc), SANE_OPTION_IS_SETTABLE(opt->cap));
gtk_widget_show(parent->parent);
+ }
+ break;
+
+ case SANE_TYPE_INT:
+ if (!opt->name)
+ {
+ DBG(DBG_error, "xsane_panel_build: Option %d, type SANE_TYPE_INT\n", i);
+ DBG(DBG_error, "=> %s\n", ERR_OPTION_NAME_NULL);
+ DBG(DBG_error, "=> %s\n", ERR_BACKEND_BUG);
+ break;
+ }
+
+ if (opt->size != sizeof(SANE_Word))
+ {
+ vector_opts[num_vector_opts++] = i;
break;
+ }
- case SANE_TYPE_INT:
- if (opt->size != sizeof(SANE_Word))
- {
- vector_opts[num_vector_opts++] = i;
- break;
- }
- status = xsane_control_option(xsane.dev, i, SANE_ACTION_GET_VALUE, &val, 0);
- if (status != SANE_STATUS_GOOD)
- {
- goto get_value_failed;
- }
+ status = xsane_control_option(xsane.dev, i, SANE_ACTION_GET_VALUE, &val, 0);
+ if (status != SANE_STATUS_GOOD)
+ {
+ goto get_value_failed;
+ }
- switch (opt->constraint_type)
- {
- case SANE_CONSTRAINT_RANGE:
- if ( (strcmp(opt->name, SANE_NAME_SCAN_RESOLUTION) ) && /* do not show resolution */
- (strcmp(opt->name, SANE_NAME_SCAN_X_RESOLUTION)) && /* do not show x-resolution */
- (strcmp(opt->name, SANE_NAME_SCAN_Y_RESOLUTION)) ) /* do not show y-resolution */
- {
- /* use a scale */
- quant = opt->constraint.range->quant;
- if (quant == 0)
- {
- quant = 1; /* we have integers */
- }
+ switch (opt->constraint_type)
+ {
+ case SANE_CONSTRAINT_NONE:
+ xsane_back_gtk_value_new(parent, title, val, 1,
+ (opt->cap & SANE_CAP_AUTOMATIC), elem, xsane.tooltips, _BGT(opt->desc), SANE_OPTION_IS_SETTABLE(opt->cap));
+ gtk_widget_show(parent->parent);
+ break;
- xsane_back_gtk_scale_new(parent, title, val, opt->constraint.range->min, opt->constraint.range->max, quant,
- (opt->cap & SANE_CAP_AUTOMATIC), elem, xsane.tooltips, _BGT(opt->desc), SANE_OPTION_IS_SETTABLE(opt->cap));
- gtk_widget_show(parent->parent);
+ case SANE_CONSTRAINT_RANGE:
+ if ( (strcmp(opt->name, SANE_NAME_SCAN_RESOLUTION) ) && /* do not show resolution */
+ (strcmp(opt->name, SANE_NAME_SCAN_X_RESOLUTION)) && /* do not show x-resolution */
+ (strcmp(opt->name, SANE_NAME_SCAN_Y_RESOLUTION)) ) /* do not show y-resolution */
+ {
+ /* use a scale */
+ quant = opt->constraint.range->quant;
+ if (quant == 0)
+ {
+ quant = 1; /* we have integers */
}
- break;
- case SANE_CONSTRAINT_WORD_LIST:
- if ( (strcmp(opt->name, SANE_NAME_SCAN_RESOLUTION) ) && /* do not show resolution */
- (strcmp(opt->name, SANE_NAME_SCAN_X_RESOLUTION)) && /* do not show x-resolution */
- (strcmp(opt->name, SANE_NAME_SCAN_Y_RESOLUTION)) ) /* do not show y-resolution */
+ xsane_back_gtk_range_new(parent, title, val, opt->constraint.range->min, opt->constraint.range->max, quant,
+ (opt->cap & SANE_CAP_AUTOMATIC), elem, xsane.tooltips, _BGT(opt->desc), SANE_OPTION_IS_SETTABLE(opt->cap));
+ gtk_widget_show(parent->parent);
+ }
+ break;
+
+ case SANE_CONSTRAINT_WORD_LIST:
+ if ( (strcmp(opt->name, SANE_NAME_SCAN_RESOLUTION) ) && /* do not show resolution */
+ (strcmp(opt->name, SANE_NAME_SCAN_X_RESOLUTION)) && /* do not show x-resolution */
+ (strcmp(opt->name, SANE_NAME_SCAN_Y_RESOLUTION)) ) /* do not show y-resolution */
+ {
+ /* use a "list-selection" widget */
+ num_words = opt->constraint.word_list[0];
+ str_list = malloc((num_words + 1) * sizeof(str_list[0]));
+ for (j = 0; j < num_words; ++j)
{
- /* use a "list-selection" widget */
- num_words = opt->constraint.word_list[0];
- str_list = malloc((num_words + 1) * sizeof(str_list[0]));
- for (j = 0; j < num_words; ++j)
- {
- sprintf(str, "%d", opt->constraint.word_list[j + 1]);
- str_list[j] = strdup(str);
- }
- str_list[j] = 0;
- sprintf(str, "%d", val);
- xsane_back_gtk_option_menu_new(parent, title, str_list, str, elem, xsane.tooltips, _BGT(opt->desc),
- SANE_OPTION_IS_SETTABLE(opt->cap));
- free(str_list);
- gtk_widget_show(parent->parent);
+ sprintf(str, "%d", opt->constraint.word_list[j + 1]);
+ str_list[j] = strdup(str);
}
- break;
+ str_list[j] = 0;
+ sprintf(str, "%d", val);
+ xsane_back_gtk_option_menu_new(parent, title, str_list, str, elem, xsane.tooltips, _BGT(opt->desc),
+ SANE_OPTION_IS_SETTABLE(opt->cap));
+ free(str_list);
+ gtk_widget_show(parent->parent);
+ }
+ break;
- default:
- DBG(DBG_error, "xsane_panel_build: %s %d!\n", ERR_UNKNOWN_CONSTRAINT_TYPE, opt->constraint_type);
- break;
- }
+ default:
+ DBG(DBG_error, "xsane_panel_build: Option %d, type SANE_TYPE_INT\n", i);
+ DBG(DBG_error, "=> %s %d!\n", ERR_UNKNOWN_CONSTRAINT_TYPE, opt->constraint_type);
+ break;
+ }
+ break;
+
+ case SANE_TYPE_FIXED:
+ if (!opt->name)
+ {
+ DBG(DBG_error, "xsane_panel_build: Option %d, type SANE_TYPE_FIXED\n", i);
+ DBG(DBG_error, "=> %s\n", ERR_OPTION_NAME_NULL);
+ DBG(DBG_error, "=> %s\n", ERR_BACKEND_BUG);
+ break;
+ }
+
+ if (opt->size != sizeof (SANE_Word))
+ {
+ vector_opts[num_vector_opts++] = i;
break;
+ }
+ status = xsane_control_option(xsane.dev, i, SANE_ACTION_GET_VALUE, &val, 0);
+ if (status != SANE_STATUS_GOOD)
+ {
+ goto get_value_failed;
+ }
- case SANE_TYPE_FIXED:
- if (opt->size != sizeof (SANE_Word))
- {
- vector_opts[num_vector_opts++] = i;
- break;
- }
- status = xsane_control_option(xsane.dev, i, SANE_ACTION_GET_VALUE, &val, 0);
- if (status != SANE_STATUS_GOOD)
- {
- goto get_value_failed;
- }
+ switch (opt->constraint_type)
+ {
+ case SANE_CONSTRAINT_NONE:
+ dval = SANE_UNFIX(val);
- switch (opt->constraint_type)
- {
- case SANE_CONSTRAINT_RANGE:
- if ( (strcmp(opt->name, SANE_NAME_SCAN_RESOLUTION) ) && /* do not show resolution */
- (strcmp(opt->name, SANE_NAME_SCAN_X_RESOLUTION)) && /* do not show x-resolution */
- (strcmp(opt->name, SANE_NAME_SCAN_Y_RESOLUTION)) && /* do not show y-resolution */
- ((strcmp(opt->name, SANE_NAME_THRESHOLD) || (xsane.lineart_mode == XSANE_LINEART_STANDARD)))
- /* do not show threshold if user wants the slider in the xsane main window */
- )
- {
- /* use a scale */
- dval = SANE_UNFIX(val);
- dmin = SANE_UNFIX(opt->constraint.range->min);
- dmax = SANE_UNFIX(opt->constraint.range->max);
- dquant = SANE_UNFIX(quant = opt->constraint.range->quant);
+ if (opt->unit == SANE_UNIT_MM)
+ {
+ dval /= preferences.length_unit;
+ }
- if (opt->unit == SANE_UNIT_MM)
- {
- dval /= preferences.length_unit;
- dmin /= preferences.length_unit;
- dmax /= preferences.length_unit;
- dquant /= preferences.length_unit;
- }
+ xsane_back_gtk_value_new(parent, title, dval, 0.001, (opt->cap & SANE_CAP_AUTOMATIC), elem,
+ xsane.tooltips, _BGT(opt->desc), SANE_OPTION_IS_SETTABLE(opt->cap));
+ gtk_widget_show(parent->parent);
+ break;
- if (dquant == 0) /* no quantization specified */
- {
- dquant = 0.01; /* display x.2 digits */
- }
+ case SANE_CONSTRAINT_RANGE:
+ if ( (strcmp(opt->name, SANE_NAME_SCAN_RESOLUTION) ) && /* do not show resolution */
+ (strcmp(opt->name, SANE_NAME_SCAN_X_RESOLUTION)) && /* do not show x-resolution */
+ (strcmp(opt->name, SANE_NAME_SCAN_Y_RESOLUTION)) && /* do not show y-resolution */
+ ((strcmp(opt->name, SANE_NAME_THRESHOLD) || (xsane.lineart_mode == XSANE_LINEART_STANDARD))) &&
+ /* do not show threshold if user wants the slider in the xsane main window */
+ (strcmp(opt->name, SANE_NAME_BATCH_SCAN_NEXT_TL_Y) ) /* do not show batch scan options */
+ )
+ {
+ /* use a scale */
+ dval = SANE_UNFIX(val);
+ dmin = SANE_UNFIX(opt->constraint.range->min);
+ dmax = SANE_UNFIX(opt->constraint.range->max);
+ dquant = SANE_UNFIX(quant = opt->constraint.range->quant);
- xsane_back_gtk_scale_new(parent, title, dval, dmin, dmax, dquant, (opt->cap & SANE_CAP_AUTOMATIC), elem,
- xsane.tooltips, _BGT(opt->desc), SANE_OPTION_IS_SETTABLE(opt->cap));
- gtk_widget_show(parent->parent);
+ if (opt->unit == SANE_UNIT_MM)
+ {
+ dval /= preferences.length_unit;
+ dmin /= preferences.length_unit;
+ dmax /= preferences.length_unit;
+ dquant /= preferences.length_unit;
}
- break;
- case SANE_CONSTRAINT_WORD_LIST:
- if ( (strcmp(opt->name, SANE_NAME_SCAN_RESOLUTION) ) && /* do not show resolution */
- (strcmp(opt->name, SANE_NAME_SCAN_X_RESOLUTION)) && /* do not show x-resolution */
- (strcmp(opt->name, SANE_NAME_SCAN_Y_RESOLUTION)) ) /* do not show y-resolution */
+ if (dquant == 0) /* no quantization specified */
{
- /* use a "list-selection" widget */
- num_words = opt->constraint.word_list[0];
- str_list = malloc ((num_words + 1) * sizeof (str_list[0]));
- for (j = 0; j < num_words; ++j)
- {
- sprintf(str, "%g", SANE_UNFIX(opt->constraint.word_list[j + 1]));
- str_list[j] = strdup(str);
- }
- str_list[j] = 0;
- sprintf(str, "%g", SANE_UNFIX(val));
- xsane_back_gtk_option_menu_new(parent, title, str_list, str, elem, xsane.tooltips, _BGT(opt->desc), SANE_OPTION_IS_SETTABLE(opt->cap));
- free (str_list);
- gtk_widget_show(parent->parent);
+ dquant = 0.001; /* display x.3 digits */
}
- break;
-
- default:
- DBG(DBG_error, "xsane_panel_build: %s %d!\n", ERR_UNKNOWN_CONSTRAINT_TYPE, opt->constraint_type);
- break;
- }
- break;
- case SANE_TYPE_STRING:
- buf = malloc (opt->size);
- status = xsane_control_option(xsane.dev, i, SANE_ACTION_GET_VALUE, buf, 0);
- if (status != SANE_STATUS_GOOD)
- {
- free (buf);
- goto get_value_failed;
- }
+ xsane_back_gtk_range_new(parent, title, dval, dmin, dmax, dquant, (opt->cap & SANE_CAP_AUTOMATIC), elem,
+ xsane.tooltips, _BGT(opt->desc), SANE_OPTION_IS_SETTABLE(opt->cap));
+ gtk_widget_show(parent->parent);
+ }
+ break;
- switch (opt->constraint_type)
- {
- case SANE_CONSTRAINT_STRING_LIST:
- if ( (strcmp (opt->name, SANE_NAME_SCAN_MODE) != 0) && /* do not show scanmode */
- (strcmp (opt->name, SANE_NAME_SCAN_SOURCE) != 0) ) /* do not show scansource */
+ case SANE_CONSTRAINT_WORD_LIST:
+ if ( (strcmp(opt->name, SANE_NAME_SCAN_RESOLUTION) ) && /* do not show resolution */
+ (strcmp(opt->name, SANE_NAME_SCAN_X_RESOLUTION)) && /* do not show x-resolution */
+ (strcmp(opt->name, SANE_NAME_SCAN_Y_RESOLUTION)) ) /* do not show y-resolution */
+ {
+ /* use a "list-selection" widget */
+ num_words = opt->constraint.word_list[0];
+ str_list = malloc ((num_words + 1) * sizeof (str_list[0]));
+ for (j = 0; j < num_words; ++j)
{
- /* use a "list-selection" widget */
- xsane_back_gtk_option_menu_new(parent, title, (char **) opt->constraint.string_list, buf,
- elem, xsane.tooltips, _BGT(opt->desc), SANE_OPTION_IS_SETTABLE(opt->cap));
- gtk_widget_show (parent->parent);
+ sprintf(str, "%g", SANE_UNFIX(opt->constraint.word_list[j + 1]));
+ str_list[j] = strdup(str);
}
- break;
+ str_list[j] = 0;
+ sprintf(str, "%g", SANE_UNFIX(val));
+ xsane_back_gtk_option_menu_new(parent, title, str_list, str, elem, xsane.tooltips, _BGT(opt->desc), SANE_OPTION_IS_SETTABLE(opt->cap));
+ free (str_list);
+ gtk_widget_show(parent->parent);
+ }
+ break;
+
+ default:
+ DBG(DBG_error, "xsane_panel_build: Option %d, type SANE_TYPE_FIXED\n", i);
+ DBG(DBG_error, "=> %s %d!\n", ERR_UNKNOWN_CONSTRAINT_TYPE, opt->constraint_type);
+ break;
+ }
+ break;
+
+ case SANE_TYPE_STRING:
+ if (!opt->name)
+ {
+ DBG(DBG_error, "xsane_panel_build: Option %d, type SANE_TYPE_STRING\n", i);
+ DBG(DBG_error, "=> %s\n", ERR_OPTION_NAME_NULL);
+ DBG(DBG_error, "=> %s\n", ERR_BACKEND_BUG);
+ break;
+ }
+
+ buf = malloc(opt->size);
+ status = xsane_control_option(xsane.dev, i, SANE_ACTION_GET_VALUE, buf, 0);
+ if (status != SANE_STATUS_GOOD)
+ {
+ free(buf);
+ goto get_value_failed;
+ }
- case SANE_CONSTRAINT_NONE:
- xsane_back_gtk_text_entry_new(parent, title, buf, elem, xsane.tooltips, _BGT(opt->desc), SANE_OPTION_IS_SETTABLE(opt->cap));
+ switch (opt->constraint_type)
+ {
+ case SANE_CONSTRAINT_STRING_LIST:
+ if ( (strcmp (opt->name, SANE_NAME_SCAN_MODE) != 0) && /* do not show scanmode */
+ (strcmp (opt->name, SANE_NAME_SCAN_SOURCE) != 0) ) /* do not show scansource */
+ {
+ /* use a "list-selection" widget */
+ xsane_back_gtk_option_menu_new(parent, title, (char **) opt->constraint.string_list, buf,
+ elem, xsane.tooltips, _BGT(opt->desc), SANE_OPTION_IS_SETTABLE(opt->cap));
gtk_widget_show (parent->parent);
- break;
+ }
+ break;
- default:
- DBG(DBG_error, "xsane_panel_build: %s %d!\n", ERR_UNKNOWN_CONSTRAINT_TYPE, opt->constraint_type);
- break;
- }
- free (buf);
- break;
+ case SANE_CONSTRAINT_NONE:
+ xsane_back_gtk_text_entry_new(parent, title, buf, elem, xsane.tooltips, _BGT(opt->desc), SANE_OPTION_IS_SETTABLE(opt->cap));
+ gtk_widget_show (parent->parent);
+ break;
- case SANE_TYPE_BUTTON:
- button = gtk_button_new();
- gtk_signal_connect(GTK_OBJECT (button), "clicked", (GtkSignalFunc) xsane_back_gtk_push_button_callback, elem);
- xsane_back_gtk_set_tooltip(xsane.tooltips, button, _BGT(opt->desc));
+ default:
+ DBG(DBG_error, "xsane_panel_build: Option %d, type SANE_TYPE_STRING\n", i);
+ DBG(DBG_error, "=> %s %d!\n", ERR_UNKNOWN_CONSTRAINT_TYPE, opt->constraint_type);
+ break;
+ }
+ free(buf);
+ break;
- label = gtk_label_new(title);
- gtk_container_add(GTK_CONTAINER (button), label);
+ case SANE_TYPE_BUTTON:
+ if (!opt->name)
+ {
+ DBG(DBG_error, "xsane_panel_build: Option %d, type SANE_TYPE_BUTTON\n", i);
+ DBG(DBG_error, "=> %s\n", ERR_OPTION_NAME_NULL);
+ DBG(DBG_error, "=> %s\n", ERR_BACKEND_BUG);
+ break;
+ }
- gtk_box_pack_start(GTK_BOX (parent), button, FALSE, TRUE, 0);
+ button = gtk_button_new();
+ g_signal_connect(GTK_OBJECT(button), "clicked", (GtkSignalFunc) xsane_back_gtk_push_button_callback, elem);
+ xsane_back_gtk_set_tooltip(xsane.tooltips, button, _BGT(opt->desc));
- gtk_widget_show(label);
- gtk_widget_show(button);
+ label = gtk_label_new(title);
+ gtk_container_add(GTK_CONTAINER (button), label);
- gtk_widget_set_sensitive(button, SANE_OPTION_IS_SETTABLE(opt->cap));
+ gtk_box_pack_start(GTK_BOX (parent), button, FALSE, TRUE, 0);
- elem->widget = button;
- gtk_widget_show(parent->parent);
- break;
+ gtk_widget_show(label);
+ gtk_widget_show(button);
- default:
- DBG(DBG_error, "xsane_panel_build: %s %d\n", ERR_UNKNOWN_TYPE, opt->type);
- break;
- }
- continue;
+ gtk_widget_set_sensitive(button, SANE_OPTION_IS_SETTABLE(opt->cap));
+
+ elem->widget = button;
+ gtk_widget_show(parent->parent);
+ break;
+
+ default:
+ DBG(DBG_error, "xsane_panel_build: %s %d\n", ERR_UNKNOWN_TYPE, opt->type);
+ break;
+ }
+ continue;
get_value_failed:
- {
- char msg[256];
+ {
+ char msg[256];
- sprintf(msg, "%s %s: %s.", ERR_GET_OPTION, opt->name, XSANE_STRSTATUS(status));
- xsane_back_gtk_error(msg, TRUE);
- }
+ sprintf(msg, "%s %s: %s.", ERR_GET_OPTION, opt->name, XSANE_STRSTATUS(status));
+ xsane_back_gtk_error(msg, TRUE);
}
+ }
if ((xsane.well_known.dpi_x == -1) && (xsane.well_known.dpi_y != -1))
{
@@ -6777,6 +7819,7 @@ void xsane_panel_build()
- create tooltip style
- create dialog xsane.histogram_dialog
- create dialog xsane.gamma_dialog
+ - create dialog xsane.batch_scan
- panel_build()
- create dialog xsane.preview
*/
@@ -6785,6 +7828,7 @@ static void xsane_device_dialog(void)
{
GtkWidget *vbox, *hbox, *button, *frame, *infobox;
GtkWidget *menubar, *menubar_item;
+ GtkStyle *current_style;
const gchar *devname;
char buf[256];
char windowname[255];
@@ -6810,7 +7854,7 @@ static void xsane_device_dialog(void)
/* will never come to here */
}
- if (xsane_control_option(xsane.dev, 0, SANE_ACTION_GET_VALUE, &xsane.num_elements, 0) != SANE_STATUS_GOOD)
+ if (sane_control_option(xsane.dev, 0, SANE_ACTION_GET_VALUE, &xsane.num_elements, 0) != SANE_STATUS_GOOD)
{
xsane_back_gtk_error(ERR_OPTION_COUNT, TRUE);
sane_close(xsane.dev);
@@ -6835,11 +7879,39 @@ static void xsane_device_dialog(void)
xsane.backend = malloc(strlen(textptr)+6);
sprintf(xsane.backend, "sane-%s", textptr); /* add "sane-" */
+ DBG(DBG_info, "Setting backend name \"%s\"\n", xsane.backend);
+
+ xsane.backend_translation = xsane.backend;
+ bindtextdomain(xsane.backend_translation, STRINGIFY(LOCALEDIR)); /* set path for backend translation texts */
+#ifdef HAVE_GTK2
+ bind_textdomain_codeset(xsane.backend_translation, "UTF-8");
+#endif
+
+ if (!strlen(dgettext(xsane.backend_translation, ""))) /* translation not valid, use general translation table */
+ {
+ xsane.backend_translation = "sane-backends";
+ DBG(DBG_info, "Setting general translation table \"sane-backends\" with localedir: %s\n", STRINGIFY(LOCALEDIR));
+ }
+ else /* we have a valid table for the backend */
+ {
+ DBG(DBG_info, "Setting backend translation table \"%s\" with localedir: %s\n", xsane.backend_translation, STRINGIFY(LOCALEDIR));
+ }
+ }
+ else /* use general backend name "sane-backends" for sane */
+ {
+ xsane.backend = strdup("sane-backends");
+ DBG(DBG_info, "Setting general backend name \"%s\"\n", xsane.backend);
- DBG(DBG_info, "Setting backend \"%s\" localedir: %s\n", xsane.backend, STRINGIFY(LOCALEDIR));
- bindtextdomain(xsane.backend, STRINGIFY(LOCALEDIR)); /* set path for backend translation texts */
+ xsane.backend_translation = xsane.backend;
+ DBG(DBG_info, "Setting general translation table \"sane-backends\" with localedir: %s\n", STRINGIFY(LOCALEDIR));
}
+ bindtextdomain("sane-backends", STRINGIFY(LOCALEDIR)); /* set path for backend translation texts */
+#ifdef HAVE_GTK2
+ bind_textdomain_codeset(xsane.backend_translation, "UTF-8");
+#endif
+
+
/* create device-text for window titles */
snprintf(devicetext, sizeof(devicetext), "%s", xsane.devlist[xsane.selected_dev]->model);
@@ -6890,16 +7962,16 @@ static void xsane_device_dialog(void)
/* create the xsane dialog box */
xsane.shell = gtk_window_new(GTK_WINDOW_TOPLEVEL);
- gtk_widget_set_uposition(xsane.shell, XSANE_SHELL_POS_X, XSANE_SHELL_POS_Y);
+ gtk_window_move(GTK_WINDOW(xsane.shell), XSANE_SHELL_POS_X, XSANE_SHELL_POS_Y);
sprintf(windowname, "%s %s %s", xsane.prog_name, XSANE_VERSION, xsane.device_text);
gtk_window_set_title(GTK_WINDOW(xsane.shell), (char *) windowname);
- gtk_signal_connect(GTK_OBJECT(xsane.shell), "delete_event", GTK_SIGNAL_FUNC(xsane_scan_win_delete), NULL);
+ g_signal_connect(GTK_OBJECT(xsane.shell), "delete_event", GTK_SIGNAL_FUNC(xsane_scan_win_delete), NULL);
xsane_set_window_icon(xsane.shell, 0);
/* create the xsane main window accelerator table */
xsane.accelerator_group = gtk_accel_group_new();
- gtk_accel_group_attach(xsane.accelerator_group, GTK_OBJECT(xsane.shell));
+ gtk_window_add_accel_group(GTK_WINDOW(xsane.shell), xsane.accelerator_group);
/* set the main vbox */
@@ -6916,21 +7988,29 @@ static void xsane_device_dialog(void)
menubar_item = gtk_menu_item_new_with_label(MENU_FILE);
gtk_container_add(GTK_CONTAINER(menubar), menubar_item);
gtk_menu_item_set_submenu(GTK_MENU_ITEM(menubar_item), xsane_files_build_menu());
-/* gtk_widget_add_accelerator(menubar_item, "select", xsane.accelerator_group, GDK_F, 0, GTK_ACCEL_VISIBLE | GTK_ACCEL_LOCKED); */
+/* gtk_widget_add_accelerator(menubar_item, "select", xsane.accelerator_group, GDK_F, 0, GTK_ACCEL_VISIBLE | DEF_GTK_ACCEL_LOCKED); */
gtk_widget_show(menubar_item);
/* "Preferences" submenu: */
menubar_item = gtk_menu_item_new_with_label(MENU_PREFERENCES);
gtk_container_add(GTK_CONTAINER(menubar), menubar_item);
- gtk_menu_item_set_submenu(GTK_MENU_ITEM(menubar_item), xsane_pref_build_menu());
-/* gtk_widget_add_accelerator(menubar_item, "select", xsane.accelerator_group, GDK_P, 0, GTK_ACCEL_VISIBLE | GTK_ACCEL_LOCKED); */
+ gtk_menu_item_set_submenu(GTK_MENU_ITEM(menubar_item), xsane_preferences_build_menu());
+/* gtk_widget_add_accelerator(menubar_item, "select", xsane.accelerator_group, GDK_P, 0, GTK_ACCEL_VISIBLE | DEF_GTK_ACCEL_LOCKED); */
gtk_widget_show(menubar_item);
/* "View" submenu: */
menubar_item = gtk_menu_item_new_with_label(MENU_VIEW);
gtk_container_add(GTK_CONTAINER(menubar), menubar_item);
gtk_menu_item_set_submenu(GTK_MENU_ITEM(menubar_item), xsane_view_build_menu());
-/* gtk_widget_add_accelerator(menubar_item, "select", xsane.accelerator_group, GDK_V, 0, GTK_ACCEL_VISIBLE | GTK_ACCEL_LOCKED); */
+/* gtk_widget_add_accelerator(menubar_item, "select", xsane.accelerator_group, GDK_V, 0, GTK_ACCEL_VISIBLE | DEF_GTK_ACCEL_LOCKED); */
+ gtk_widget_show(menubar_item);
+
+
+ /* "Window" submenu: */
+ menubar_item = gtk_menu_item_new_with_label(MENU_WINDOW);
+ gtk_container_add(GTK_CONTAINER(menubar), menubar_item);
+ gtk_menu_item_set_submenu(GTK_MENU_ITEM(menubar_item), xsane_window_build_menu());
+/* gtk_widget_add_accelerator(menubar_item, "select", xsane.accelerator_group, GDK_V, 0, GTK_ACCEL_VISIBLE | DEF_GTK_ACCEL_LOCKED); */
gtk_widget_show(menubar_item);
@@ -6939,7 +8019,7 @@ static void xsane_device_dialog(void)
gtk_container_add(GTK_CONTAINER(menubar), menubar_item);
gtk_menu_item_right_justify((GtkMenuItem *) menubar_item);
gtk_menu_item_set_submenu(GTK_MENU_ITEM(menubar_item), xsane_help_build_menu());
-/* gtk_widget_add_accelerator(menubar_item, "select", xsane.accelerator_group, GDK_H, 0, GTK_ACCEL_VISIBLE | GTK_ACCEL_LOCKED); */
+/* gtk_widget_add_accelerator(menubar_item, "select", xsane.accelerator_group, GDK_H, 0, GTK_ACCEL_VISIBLE | DEF_GTK_ACCEL_LOCKED); */
gtk_widget_show(menubar_item);
gtk_widget_show(menubar);
@@ -6949,7 +8029,7 @@ static void xsane_device_dialog(void)
if (xsane.main_window_fixed) /* fixed window: use it like it is */
{
/* shrink grow auto_shrink */
- gtk_window_set_policy(GTK_WINDOW(xsane.shell), FALSE, FALSE, TRUE); /* auto size */
+ gtk_window_set_resizable(GTK_WINDOW(xsane.shell), FALSE);
xsane_vbox_main = gtk_vbox_new(TRUE, 5); /* we need this to set the wanted borders */
gtk_container_set_border_width(GTK_CONTAINER(xsane_vbox_main), 5);
@@ -6960,11 +8040,10 @@ static void xsane_device_dialog(void)
gtk_window_set_default_size(GTK_WINDOW(xsane.shell), XSANE_SHELL_WIDTH, XSANE_SHELL_HEIGHT); /* set default size */
/* shrink grow auto_shrink */
- gtk_window_set_policy(GTK_WINDOW(xsane.shell), TRUE, TRUE, FALSE); /* allow resizing */
+ gtk_window_set_resizable(GTK_WINDOW(xsane.shell), TRUE); /* allow resizing */
xsane.main_dialog_scrolled = gtk_scrolled_window_new(0, 0);
- gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(xsane.main_dialog_scrolled),
- GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
+ gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(xsane.main_dialog_scrolled), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
gtk_container_add(GTK_CONTAINER(xsane_window), xsane.main_dialog_scrolled);
gtk_widget_show(xsane.main_dialog_scrolled);
@@ -6982,32 +8061,30 @@ static void xsane_device_dialog(void)
gtk_widget_show(xsane_vbox_main);
#if 0
- /* add vendor´s logo */
+ /* add vendor`s logo */
xsane_vendor_pixmap_new(xsane.shell->window, xsane_window);
#endif
/* create the scanner standard options dialog box */
- xsane.standard_options_shell = gtk_window_new(GTK_WINDOW_DIALOG);
- gtk_widget_set_uposition(xsane.standard_options_shell, XSANE_STD_OPTIONS_POS_X, XSANE_STD_OPTIONS_POS_Y);
+ xsane.standard_options_shell = gtk_window_new(GTK_WINDOW_TOPLEVEL);
+ gtk_window_move(GTK_WINDOW(xsane.standard_options_shell), XSANE_STD_OPTIONS_POS_X, XSANE_STD_OPTIONS_POS_Y);
sprintf(windowname, "%s %s", WINDOW_STANDARD_OPTIONS, xsane.device_text);
gtk_window_set_title(GTK_WINDOW(xsane.standard_options_shell), (char *) windowname);
- /* shrink grow auto_shrink */
- gtk_window_set_policy(GTK_WINDOW(xsane.standard_options_shell), FALSE, FALSE, TRUE);
- gtk_signal_connect(GTK_OBJECT(xsane.standard_options_shell), "delete_event",
- GTK_SIGNAL_FUNC(xsane_standard_option_win_delete), NULL);
+ gtk_window_set_resizable(GTK_WINDOW(xsane.standard_options_shell), FALSE);
+ g_signal_connect(GTK_OBJECT(xsane.standard_options_shell), "delete_event", GTK_SIGNAL_FUNC(xsane_standard_option_win_delete), NULL);
xsane_set_window_icon(xsane.standard_options_shell, 0);
- gtk_accel_group_attach(xsane.accelerator_group, GTK_OBJECT(xsane.standard_options_shell));
+ gtk_window_add_accel_group(GTK_WINDOW(xsane.standard_options_shell), xsane.accelerator_group);
xsane_vbox_standard = gtk_vbox_new(FALSE, 5); /* has been TRUE before I added backend pixmap */
gtk_container_set_border_width(GTK_CONTAINER(xsane_vbox_standard), 5);
gtk_container_add(GTK_CONTAINER(xsane.standard_options_shell), xsane_vbox_standard);
gtk_widget_show(xsane_vbox_standard);
- /* add vendor´s logo */
+ /* add vendor`s logo */
xsane_vendor_pixmap_new(xsane.standard_options_shell->window, xsane_vbox_standard);
/* create a subwindow so the standard dialog keeps its position on rebuilds: */
@@ -7018,18 +8095,16 @@ static void xsane_device_dialog(void)
/* create the scanner advanced options dialog box */
- xsane.advanced_options_shell = gtk_window_new(GTK_WINDOW_DIALOG);
- gtk_widget_set_uposition(xsane.advanced_options_shell, XSANE_ADV_OPTIONS_POS_X, XSANE_ADV_OPTIONS_POS_Y);
+ xsane.advanced_options_shell = gtk_window_new(GTK_WINDOW_TOPLEVEL);
+ gtk_window_move(GTK_WINDOW(xsane.advanced_options_shell), XSANE_ADV_OPTIONS_POS_X, XSANE_ADV_OPTIONS_POS_Y);
sprintf(windowname, "%s %s",WINDOW_ADVANCED_OPTIONS, xsane.device_text);
gtk_window_set_title(GTK_WINDOW(xsane.advanced_options_shell), (char *) windowname);
- /* shrink grow auto_shrink */
- gtk_window_set_policy(GTK_WINDOW(xsane.advanced_options_shell), FALSE, FALSE, TRUE);
- gtk_signal_connect(GTK_OBJECT(xsane.advanced_options_shell), "delete_event",
- GTK_SIGNAL_FUNC(xsane_advanced_option_win_delete), NULL);
+ gtk_window_set_resizable(GTK_WINDOW(xsane.advanced_options_shell), FALSE);
+ g_signal_connect(GTK_OBJECT(xsane.advanced_options_shell), "delete_event", GTK_SIGNAL_FUNC(xsane_advanced_option_win_delete), NULL);
xsane_set_window_icon(xsane.advanced_options_shell, 0);
- gtk_accel_group_attach(xsane.accelerator_group, GTK_OBJECT(xsane.advanced_options_shell));
+ gtk_window_add_accel_group(GTK_WINDOW(xsane.advanced_options_shell), xsane.accelerator_group);
xsane_vbox_advanced = gtk_vbox_new(FALSE, 5); /* has been TRUE before I added backend pixmap */
gtk_container_set_border_width(GTK_CONTAINER(xsane_vbox_advanced), 5);
@@ -7073,10 +8148,8 @@ static void xsane_device_dialog(void)
/* define tooltips colors */
xsane.tooltips = gtk_tooltips_new();
- colormap = gdk_window_get_colormap(xsane.shell->window);
+ colormap = gdk_drawable_get_colormap(xsane.shell->window);
-/* I don`t know why the following does not work with gtk-1.2.x */
-/* but the gimp has the same problems ;-) */
/* use black as foreground: */
xsane.tooltips_fg.red = 0;
xsane.tooltips_fg.green = 0;
@@ -7089,21 +8162,14 @@ static void xsane_device_dialog(void)
xsane.tooltips_bg.blue = 35979;
gdk_color_alloc(colormap, &xsane.tooltips_bg);
-/* as long as gtk_tooltips_set_colors() does not work : */
-#ifdef BUGGY_GTK_TOOLTIPS_SET_COLORS
gtk_tooltips_force_window(xsane.tooltips);
- {
- GtkStyle *current_style = gtk_style_copy(gtk_widget_get_style(xsane.tooltips->tip_window));
- current_style->bg[GTK_STATE_NORMAL] = xsane.tooltips_bg;
- current_style->fg[GTK_STATE_NORMAL] = xsane.tooltips_fg;
- gtk_widget_set_style(xsane.tooltips->tip_window, current_style);
- }
-#else
- gtk_tooltips_set_colors(xsane.tooltips, &xsane.tooltips_bg, &xsane.tooltips_fg);
-#endif
- xsane_back_gtk_set_tooltips(preferences.tooltips_enabled);
+ current_style = gtk_style_copy(gtk_widget_get_style(xsane.tooltips->tip_window));
+ current_style->bg[GTK_STATE_NORMAL] = xsane.tooltips_bg;
+ current_style->fg[GTK_STATE_NORMAL] = xsane.tooltips_fg;
+ gtk_widget_set_style(xsane.tooltips->tip_window, current_style);
+ xsane_back_gtk_set_tooltips(preferences.tooltips_enabled);
/* create histogram dialog and set colors */
@@ -7114,17 +8180,19 @@ static void xsane_device_dialog(void)
xsane_create_gamma_dialog(xsane.device_text); /* create the free gamma curve dialog */
#endif
+ /* create batch_scan dialog */
+ xsane_create_batch_scan_dialog(xsane.device_text);
+
/* The bottom area: info frame, progress bar, start and cancel button */
- xsane_separator_new(xsane_window, 2);
- hbox = gtk_hbox_new(FALSE, 5);
- gtk_box_pack_end(GTK_BOX(xsane_window), hbox, FALSE, FALSE, 5);
- gtk_container_set_border_width(GTK_CONTAINER(hbox), 5);
+ hbox = gtk_hbox_new(FALSE, 3);
+ gtk_box_pack_end(GTK_BOX(xsane_window), hbox, FALSE, FALSE, 0);
+ gtk_container_set_border_width(GTK_CONTAINER(hbox), 3);
gtk_widget_show(hbox);
/* vertical box for info frame and progress bar */
- vbox = gtk_vbox_new(FALSE, 5);
- gtk_box_pack_start(GTK_BOX(hbox), vbox, TRUE, TRUE, 0);
+ vbox = gtk_vbox_new(FALSE, 3);
+ gtk_box_pack_start(GTK_BOX(hbox), vbox, TRUE, TRUE, 5);
gtk_widget_show(vbox);
@@ -7135,7 +8203,7 @@ static void xsane_device_dialog(void)
gtk_widget_show(frame);
infobox = gtk_hbox_new(FALSE, 5);
- gtk_container_set_border_width(GTK_CONTAINER(infobox), 2);
+ gtk_container_set_border_width(GTK_CONTAINER(infobox), 4);
gtk_container_add(GTK_CONTAINER(frame), infobox);
gtk_widget_show(infobox);
@@ -7152,24 +8220,28 @@ static void xsane_device_dialog(void)
/* vertical box for scan and cancel button */
- vbox = gtk_vbox_new(FALSE, 5);
+ vbox = gtk_vbox_new(FALSE, 3);
gtk_box_pack_start(GTK_BOX(hbox), vbox, TRUE, TRUE, 0);
gtk_widget_show(vbox);
/* The Scan button */
- button = gtk_button_new_with_label(BUTTON_START);
+ button = gtk_button_new_with_label(BUTTON_SCAN);
xsane_back_gtk_set_tooltip(xsane.tooltips, button, DESC_SCAN_START);
- gtk_widget_add_accelerator(button, "clicked", xsane.accelerator_group, GDK_Return, GDK_CONTROL_MASK, GTK_ACCEL_VISIBLE | GTK_ACCEL_LOCKED);
- gtk_signal_connect(GTK_OBJECT(button), "clicked", (GtkSignalFunc) xsane_scan_dialog, NULL);
- gtk_box_pack_start(GTK_BOX(vbox), button, FALSE, FALSE, 0);
+ gtk_widget_add_accelerator(button, "clicked", xsane.accelerator_group, GDK_Return, GDK_CONTROL_MASK, GTK_ACCEL_VISIBLE | DEF_GTK_ACCEL_LOCKED);
+ g_signal_connect(GTK_OBJECT(button), "clicked", (GtkSignalFunc) xsane_scan_callback, NULL);
+ gtk_box_pack_start(GTK_BOX(vbox), button, TRUE, TRUE, 0);
gtk_widget_show(button);
xsane.start_button = GTK_OBJECT(button);
/* The Cancel button */
+#ifdef HAVE_GTK2
+ button = gtk_button_new_from_stock(GTK_STOCK_CANCEL);
+#else
button = gtk_button_new_with_label(BUTTON_CANCEL);
+#endif
xsane_back_gtk_set_tooltip(xsane.tooltips, button, DESC_SCAN_CANCEL);
- gtk_widget_add_accelerator(button, "clicked", xsane.accelerator_group, GDK_Escape, 0, GTK_ACCEL_VISIBLE | GTK_ACCEL_LOCKED);
- gtk_box_pack_start(GTK_BOX(vbox), button, FALSE, FALSE, 0);
+ gtk_widget_add_accelerator(button, "clicked", xsane.accelerator_group, GDK_Escape, 0, GTK_ACCEL_VISIBLE | DEF_GTK_ACCEL_LOCKED);
+ gtk_box_pack_start(GTK_BOX(vbox), button, TRUE, TRUE, 0);
gtk_widget_show(button);
gtk_widget_set_sensitive(GTK_WIDGET(button), FALSE);
xsane.cancel_button = GTK_OBJECT(button);
@@ -7181,7 +8253,7 @@ static void xsane_device_dialog(void)
/* create preview dialog */
xsane.preview = preview_new();
- gtk_signal_connect(GTK_OBJECT(xsane.preview->top), "delete_event", GTK_SIGNAL_FUNC(xsane_preview_window_destroyed), NULL);
+ g_signal_connect(GTK_OBJECT(xsane.preview->top), "delete_event", GTK_SIGNAL_FUNC(xsane_preview_window_destroyed), NULL);
xsane_device_preferences_restore(); /* restore device-settings */
xsane_set_modus_defaults();
@@ -7201,6 +8273,11 @@ static void xsane_device_dialog(void)
gtk_widget_show(xsane.advanced_options_shell);
}
+ if (preferences.show_batch_scan)
+ {
+ gtk_widget_show(xsane.batch_scan_dialog);
+ }
+
gtk_widget_show(xsane.shell); /* call as last so focus is on it */
while (gtk_events_pending())
@@ -7220,9 +8297,20 @@ static void xsane_device_dialog(void)
}
gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(xsane.show_preview_widget), xsane.show_preview);
- xsane_set_all_resolutions(); /* make sure resolution, resolution_x and resolution_y are up to date */
xsane_define_maximum_output_size(); /* draw maximum output frame in preview window if necessary */
xsane_refresh_dialog();
+ xsane_set_all_resolutions(); /* make sure resolution, resolution_x and resolution_y are up to date */
+
+ if (xsane.batch_scan_load_default_list)
+ {
+ char filename[PATH_MAX];
+
+ DBG(DBG_proc, "batch_scan:load default list\n");
+ xsane_back_gtk_make_path(sizeof(filename), filename, "xsane", "batch-lists", 0, "default", ".xbl", XSANE_PATH_LOCAL_SANE);
+ xsane_batch_scan_load_list_from_file(filename);
+
+ xsane.batch_scan_load_default_list = 0; /* mark list is loaded, we only want to load the list at program startup */
+ }
}
/* ---------------------------------------------------------------------------------------------------------------------- */
@@ -7231,7 +8319,7 @@ static void xsane_choose_dialog_ok_callback(void)
{
DBG(DBG_proc, "xsane_choose_dialog_ok_callback\n");
- gtk_signal_disconnect_by_func(GTK_OBJECT(xsane.choose_device_dialog), GTK_SIGNAL_FUNC(xsane_exit), 0);
+ g_signal_handlers_disconnect_by_func(GTK_OBJECT(xsane.choose_device_dialog), GTK_SIGNAL_FUNC(xsane_exit), 0);
gtk_widget_destroy(xsane.choose_device_dialog);
xsane_device_dialog();
}
@@ -7247,7 +8335,7 @@ static void xsane_select_device_by_key_callback(GtkWidget * widget, gpointer dat
/* ---------------------------------------------------------------------------------------------------------------------- */
-static void xsane_select_device_by_mouse_callback(GtkWidget * widget, GdkEventButton *event, gpointer data)
+static int xsane_select_device_by_mouse_callback(GtkWidget * widget, GdkEventButton *event, gpointer data)
{
DBG(DBG_proc, "xsane_select_device_by_mouse_callback\n");
@@ -7256,6 +8344,8 @@ static void xsane_select_device_by_mouse_callback(GtkWidget * widget, GdkEventBu
{
xsane_choose_dialog_ok_callback();
}
+
+ return 0;
}
/* ---------------------------------------------------------------------------------------------------------------------- */
@@ -7263,8 +8353,8 @@ static void xsane_select_device_by_mouse_callback(GtkWidget * widget, GdkEventBu
static void xsane_choose_device(void)
{
GtkWidget *main_vbox, *vbox, *hbox, *button, *device_frame, *device_vbox, *pixmapwidget, *label;
- GdkBitmap *mask;
- GdkPixmap *pixmap;
+ GdkBitmap *mask = NULL;
+ GdkPixmap *pixmap = NULL;
GtkStyle *style;
GdkColor *bg_trans;
GSList *owner;
@@ -7272,7 +8362,7 @@ static void xsane_choose_device(void)
gint i;
const SANE_Device *adev;
char buf[256];
- char vendor[9];
+ char vendor[12];
char model[17];
char type[20];
char filename[PATH_MAX];
@@ -7299,15 +8389,15 @@ static void xsane_choose_device(void)
}
}
- xsane.choose_device_dialog = gtk_window_new(GTK_WINDOW_DIALOG);
+ xsane.choose_device_dialog = gtk_window_new(GTK_WINDOW_TOPLEVEL);
gtk_window_set_position(GTK_WINDOW(xsane.choose_device_dialog), GTK_WIN_POS_CENTER);
- gtk_window_set_policy(GTK_WINDOW(xsane.choose_device_dialog), FALSE, FALSE, FALSE);
- gtk_signal_connect(GTK_OBJECT(xsane.choose_device_dialog), "destroy", GTK_SIGNAL_FUNC(xsane_exit), NULL);
+ gtk_window_set_resizable(GTK_WINDOW(xsane.choose_device_dialog), FALSE);
+ g_signal_connect(GTK_OBJECT(xsane.choose_device_dialog), "destroy", GTK_SIGNAL_FUNC(xsane_exit), NULL);
snprintf(buf, sizeof(buf), "%s %s %s", xsane.prog_name, XSANE_VERSION, WINDOW_DEVICE_SELECTION);
gtk_window_set_title(GTK_WINDOW(xsane.choose_device_dialog), buf);
device_selection_accelerator_group = gtk_accel_group_new(); /* do we have to delete it when dialog is closed ? */
- gtk_accel_group_attach(device_selection_accelerator_group, GTK_OBJECT(xsane.choose_device_dialog));
+ gtk_window_add_accel_group(GTK_WINDOW(xsane.choose_device_dialog), device_selection_accelerator_group);
main_vbox = gtk_vbox_new(FALSE, 0);
gtk_container_set_border_width(GTK_CONTAINER(main_vbox), 0);
@@ -7327,10 +8417,10 @@ static void xsane_choose_device(void)
xsane_back_gtk_make_path(sizeof(filename), filename, "xsane", 0, "xsane-logo", 0, ".xpm", XSANE_PATH_SYSTEM);
pixmap = gdk_pixmap_create_from_xpm(xsane.choose_device_dialog->window, &mask, bg_trans, filename);
- pixmapwidget = gtk_pixmap_new(pixmap, mask);
+ pixmapwidget = gtk_image_new_from_pixmap(pixmap, mask);
gtk_box_pack_start(GTK_BOX(vbox), pixmapwidget, FALSE, FALSE, 2);
gtk_widget_show(pixmapwidget);
- gdk_pixmap_unref(pixmap);
+ gdk_drawable_unref(pixmap);
xsane_set_window_icon(xsane.choose_device_dialog, (gchar **) 0);
@@ -7339,11 +8429,10 @@ static void xsane_choose_device(void)
gtk_widget_show(label);
gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 2);
- xsane_separator_new(vbox, 5);
-
/* list the drivers with radiobuttons */
device_frame = gtk_frame_new(TEXT_AVAILABLE_DEVICES);
+ gtk_container_set_border_width(GTK_CONTAINER(device_frame), 4);
gtk_box_pack_start(GTK_BOX(vbox), device_frame, FALSE, FALSE, 2);
gtk_widget_show(device_frame);
@@ -7406,13 +8495,11 @@ static void xsane_choose_device(void)
if (i<12)
{
- gtk_widget_add_accelerator(button, "clicked", device_selection_accelerator_group, GDK_F1+i, 0, GTK_ACCEL_LOCKED);
+ gtk_widget_add_accelerator(button, "clicked", device_selection_accelerator_group, GDK_F1+i, 0, DEF_GTK_ACCEL_LOCKED);
}
- gtk_signal_connect(GTK_OBJECT(button), "button_press_event",
- (GtkSignalFunc) xsane_select_device_by_mouse_callback, (void *) (long) i);
- gtk_signal_connect(GTK_OBJECT(button), "clicked",
- (GtkSignalFunc) xsane_select_device_by_key_callback, (void *) (long) i);
+ g_signal_connect(GTK_OBJECT(button), "button_press_event", (GtkSignalFunc) xsane_select_device_by_mouse_callback, (void *) (long) i);
+ g_signal_connect(GTK_OBJECT(button), "clicked", (GtkSignalFunc) xsane_select_device_by_key_callback, (void *) (long) i);
gtk_box_pack_start(GTK_BOX(device_vbox), button, TRUE, TRUE, 0);
gtk_widget_show(button);
owner = gtk_radio_button_group(GTK_RADIO_BUTTON(button));;
@@ -7432,17 +8519,25 @@ static void xsane_choose_device(void)
gtk_widget_show(hbox);
/* The OK button */
+#ifdef HAVE_GTK2
+ button = gtk_button_new_from_stock(GTK_STOCK_OK);
+#else
button = gtk_button_new_with_label(BUTTON_OK);
+#endif
GTK_WIDGET_SET_FLAGS(button, GTK_CAN_DEFAULT);
- gtk_signal_connect(GTK_OBJECT(button), "clicked", (GtkSignalFunc) xsane_choose_dialog_ok_callback, NULL);
+ g_signal_connect(GTK_OBJECT(button), "clicked", (GtkSignalFunc) xsane_choose_dialog_ok_callback, NULL);
gtk_box_pack_start(GTK_BOX(hbox), button, TRUE, TRUE, 0);
gtk_widget_grab_default(button);
gtk_widget_show(button);
/* The Cancel button */
+#ifdef HAVE_GTK2
+ button = gtk_button_new_from_stock(GTK_STOCK_CANCEL);
+#else
button = gtk_button_new_with_label(BUTTON_CANCEL);
- gtk_widget_add_accelerator(button, "clicked", device_selection_accelerator_group, GDK_Escape, 0, GTK_ACCEL_LOCKED);
- gtk_signal_connect(GTK_OBJECT(button), "clicked", (GtkSignalFunc) xsane_exit, NULL);
+#endif
+ gtk_widget_add_accelerator(button, "clicked", device_selection_accelerator_group, GDK_Escape, 0, DEF_GTK_ACCEL_LOCKED);
+ g_signal_connect(GTK_OBJECT(button), "clicked", (GtkSignalFunc) xsane_exit, NULL);
gtk_box_pack_start(GTK_BOX(hbox), button, TRUE, TRUE, 0);
gtk_widget_show(button);
@@ -7468,8 +8563,12 @@ static int xsane_init(int argc, char **argv)
3 - if wrong sane major version was found */
{
GtkWidget *device_scanning_dialog;
- GtkWidget *main_vbox;
+ GtkWidget *main_vbox, *hbox;
+ GdkPixmap *pixmap;
+ GdkBitmap *mask;
+ GtkWidget *pixmapwidget;
GtkWidget *label;
+ GtkWidget *frame;
struct stat st;
char filename[PATH_MAX];
char buf[256];
@@ -7482,10 +8581,15 @@ static int xsane_init(int argc, char **argv)
gtk_init(&argc, &argv);
setlocale(LC_NUMERIC, "C");
-#ifdef HAVE_LIBGIMP_GIMP_H
+#ifdef HAVE_ANY_GIMP
gtk_rc_parse(gimp_gtkrc());
+# ifdef HAVE_GIMP_2
+ gdk_set_use_xshm(TRUE);
+# else
gdk_set_use_xshm(gimp_use_xshm());
+# endif
+
#endif
/* before we open any windows we have to read the style file */
@@ -7509,7 +8613,7 @@ static int xsane_init(int argc, char **argv)
{
int ch;
- while((ch = getopt_long(argc, argv, "cd:fghlmnpsvFMN:RV", long_options, 0)) != EOF)
+ while((ch = getopt_long(argc, argv, "cd:fghlmnpsvFN:RV", long_options, 0)) != EOF)
{
switch(ch)
{
@@ -7517,7 +8621,7 @@ static int xsane_init(int argc, char **argv)
/* GIMP. If xsane is compiled without GIMP support */
/* then you get the error message when GIMP does */
/* query or tries to start the xsane plugin! */
-#ifndef HAVE_LIBGIMP_GIMP_H
+#ifndef HAVE_ANY_GIMP
printf("%s: %s\n", argv[0], ERR_GIMP_SUPPORT_MISSING);
exit(0);
#endif
@@ -7526,10 +8630,10 @@ static int xsane_init(int argc, char **argv)
case 'v': /* --version */
printf("%s-%s %s %s\n", xsane.prog_name, XSANE_VERSION, XSANE_COPYRIGHT_SIGN, XSANE_COPYRIGHT_TXT);
printf(" %s %s\n", TEXT_EMAIL, XSANE_EMAIL);
- printf(" %s %s\n", TEXT_PACKAGE, PACKAGE_VERSION);
+ printf(" %s %s\n", TEXT_PACKAGE, XSANE_PACKAGE_VERSION);
printf(" %s%d.%d.%d\n", TEXT_GTK_VERSION, GTK_MAJOR_VERSION, GTK_MINOR_VERSION, GTK_MICRO_VERSION);
-#ifdef HAVE_LIBGIMP_GIMP_H
+#ifdef HAVE_ANY_GIMP
printf(" %s, %s%s\n", TEXT_WITH_GIMP_SUPPORT, TEXT_GIMP_VERSION, GIMP_VERSION);
#else
printf(" %s\n", TEXT_WITHOUT_GIMP_SUPPORT);
@@ -7548,8 +8652,7 @@ static int xsane_init(int argc, char **argv)
#endif
printf("pnm, ");
- printf("ps, ");
- printf("raw");
+ printf("ps");
#ifdef SUPPORT_RGBA
printf(", rgba");
@@ -7558,6 +8661,9 @@ static int xsane_init(int argc, char **argv)
#ifdef HAVE_LIBTIFF
printf(", tiff");
#endif
+
+ printf(", txt");
+
printf("\n");
exit(0);
break;
@@ -7613,17 +8719,6 @@ static int xsane_init(int argc, char **argv)
xsane.print_filenames = TRUE;
break;
- case 'M': /* --Medium-calibration */
- xsane.medium_calibration = TRUE;
- xsane.no_preview_medium_gamma = TRUE;
-
- xsane.brightness_min = XSANE_MEDIUM_CALIB_BRIGHTNESS_MIN;
- xsane.brightness_max = XSANE_MEDIUM_CALIB_BRIGHTNESS_MAX;
- xsane.contrast_gray_min = XSANE_MEDIUM_CALIB_CONTRAST_MIN;
- xsane.contrast_min = XSANE_MEDIUM_CALIB_CONTRAST_MIN;
- xsane.contrast_max = XSANE_MEDIUM_CALIB_CONTRAST_MAX;
- break;
-
case 'h': /* --help */
default:
xsane_usage();
@@ -7634,13 +8729,15 @@ static int xsane_init(int argc, char **argv)
if (xsane_pref_restore()) /* restore preferences, returns TRUE if license is not accpted yet */
{
- if (xsane_display_license(1)) /* show license and ask for accept/not accept */
+ if (xsane_display_eula(1)) /* show license and ask for accept/not accept */
{
- DBG(DBG_info, "user did not accept license, we abort\n");
- return 1; /* User did not accept license */
+ DBG(DBG_info, "user did not accept eula, we abort\n");
+ return 1; /* User did not accept eula */
}
}
+ xsane_pref_restore_media();
+
#ifndef HAVE_OS2_H
if (!getuid()) /* root ? */
{
@@ -7670,27 +8767,53 @@ static int xsane_init(int argc, char **argv)
return 3;
}
- device_scanning_dialog = gtk_window_new(GTK_WINDOW_DIALOG);
+ device_scanning_dialog = gtk_window_new(GTK_WINDOW_TOPLEVEL);
gtk_window_set_position(GTK_WINDOW(device_scanning_dialog), GTK_WIN_POS_CENTER);
- gtk_window_set_policy(GTK_WINDOW(device_scanning_dialog), FALSE, FALSE, FALSE);
+ gtk_window_set_resizable(GTK_WINDOW(device_scanning_dialog), FALSE);
snprintf(buf, sizeof(buf), "%s %s", xsane.prog_name, XSANE_VERSION);
gtk_window_set_title(GTK_WINDOW(device_scanning_dialog), buf);
+ g_signal_connect(GTK_OBJECT(device_scanning_dialog), "delete_event", GTK_SIGNAL_FUNC(xsane_quit), NULL);
+ xsane_set_window_icon(device_scanning_dialog, 0);
+
+ frame = gtk_frame_new(NULL);
+ gtk_container_set_border_width(GTK_CONTAINER(frame), 10);
+ gtk_frame_set_shadow_type(GTK_FRAME(frame), GTK_SHADOW_ETCHED_IN);
+ gtk_container_add(GTK_CONTAINER(device_scanning_dialog), frame);
+ gtk_widget_show(frame);
main_vbox = gtk_vbox_new(FALSE, 0);
gtk_container_set_border_width(GTK_CONTAINER(main_vbox), 20);
- gtk_container_add(GTK_CONTAINER(device_scanning_dialog), main_vbox);
+ gtk_container_add(GTK_CONTAINER(frame), main_vbox);
gtk_widget_show(main_vbox);
+ hbox = gtk_hbox_new(FALSE, 0);
+ gtk_box_pack_start(GTK_BOX(main_vbox), hbox, FALSE, FALSE, 2);
+ gtk_widget_show(hbox);
+
+ /* add device icon */
+ pixmap = gdk_pixmap_create_from_xpm_d(device_scanning_dialog->window, &mask, xsane.bg_trans, (gchar **) device_xpm);
+ pixmapwidget = gtk_image_new_from_pixmap(pixmap, mask);
+ gtk_box_pack_start(GTK_BOX(hbox), pixmapwidget, FALSE, FALSE, 10);
+ gtk_widget_show(pixmapwidget);
+ gdk_drawable_unref(pixmap);
+
+ /* add text */
snprintf(buf, sizeof(buf), " %s ", TEXT_SCANNING_DEVICES);
label = gtk_label_new(buf);
- gtk_box_pack_start(GTK_BOX(main_vbox), label, FALSE, FALSE, 2);
+ gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 2);
gtk_widget_show(label);
- xsane_set_window_icon(device_scanning_dialog, 0);
-
gtk_widget_show(device_scanning_dialog);
+ /* wait 100 ms to make sure window is displayed */
+ usleep(100000); /* this makes sure that the text "scanning for devices" is displayed */
+
+ while (gtk_events_pending())
+ {
+ gtk_main_iteration();
+ }
+
xsane_widget_test_uposition(device_scanning_dialog);
/* wait 100 ms to make sure window is displayed */
@@ -7746,6 +8869,16 @@ static int xsane_init(int argc, char **argv)
/* ---------------------------------------------------------------------------------------------------------------------- */
+static void xsane_help_no_devices(void)
+{
+ char buf[512];
+
+ snprintf(buf, sizeof(buf), "%s\n\n%s", ERR_NO_DEVICES, HELP_NO_DEVICES);
+ xsane_back_gtk_decision(WINDOW_NO_DEVICES, (gchar**) no_device_xpm, buf, BUTTON_CLOSE, NULL, TRUE);
+}
+
+/* ---------------------------------------------------------------------------------------------------------------------- */
+
void xsane_interface(int argc, char **argv)
{
struct SIGACTION act;
@@ -7783,17 +8916,28 @@ void xsane_interface(int argc, char **argv)
{
char buf[256];
- snprintf(buf, sizeof(buf), "%s: %s\n", xsane.prog_name, ERR_NO_DEVICES);
- xsane_back_gtk_error(buf, TRUE);
+ snprintf(buf, sizeof(buf), "%s\n", ERR_NO_DEVICES);
+
+ if (xsane_back_gtk_decision(WINDOW_NO_DEVICES, (gchar**) no_device_xpm, buf, BUTTON_HELP, BUTTON_CLOSE, TRUE))
+ {
+ xsane_help_no_devices();
+ }
xsane_exit();
}
}
- /* define SIGTERM-handler to make sure that e.g. all temporary files are deleted */
- /* when xsane gets a SIGTERM signal */
+ /* define SIGTERM, SIGINT, SIGHUP-handler to make sure that e.g. all temporary files are deleted */
+ /* when xsane gets such a signal */
memset(&act, 0, sizeof(act));
act.sa_handler = xsane_quit_handler;
sigaction(SIGTERM, &act, 0);
+ sigaction(SIGINT, &act, 0);
+ sigaction(SIGHUP, &act, 0);
+
+ /* add a signal handler that cleans up zombie child processes */
+ memset(&act, 0, sizeof(act));
+ act.sa_handler = xsane_sigchld_handler;
+ sigaction(SIGCHLD, &act, 0);
gtk_main();
sane_exit();
@@ -7817,8 +8961,6 @@ int main(int argc, char **argv)
xsane.main_window_fixed = -1; /* no command line option given, use preferences or fixed */
- xsane.get_deskrelative_origin = 0;
-
xsane.mode = XSANE_STANDALONE;
xsane.xsane_mode = XSANE_VIEWER;
xsane.lineart_mode = XSANE_LINEART_STANDARD;
@@ -7904,6 +9046,8 @@ int main(int argc, char **argv)
xsane.print_filenames = FALSE;
xsane.force_filename = FALSE;
+ xsane.batch_scan_load_default_list = TRUE; /* load default batch scan list at program startup */
+
xsane.prog_name = strrchr(argv[0], '/');
if (xsane.prog_name)
{
@@ -7914,16 +9058,36 @@ int main(int argc, char **argv)
xsane.prog_name = argv[0];
}
+ if (!pipe(xsane.ipc_pipefd)) /* success */
+ {
+ DBG(DBG_info, "created ipc_pipefd for inter progress communication\n");
+#ifndef BUGGY_GDK_INPUT_EXCEPTION
+ gdk_input_add(xsane.ipc_pipefd[0], GDK_INPUT_READ | GDK_INPUT_EXCEPTION, xsane_back_gtk_ipc_dialog_callback, 0);
+#endif
+ }
+ else
+ {
+ DBG(DBG_info, "could not create pipe for inter progress communication\n");
+ xsane.ipc_pipefd[0] = 0;
+ xsane.ipc_pipefd[1] = 0;
+ }
+
#if 0
bindtextdomain(PACKAGE, STRINGIFY(LOCALEDIR));
textdomain(PACKAGE);
+#ifdef HAVE_GTK2
+ bind_textdomain_codeset(PACKAGE, "UTF-8");
+#endif
#else
- DBG(DBG_info, "Setting xsane localedir: %s\n", STRINGIFY(LOCALEDIR));
+ DBG(DBG_info, "Setting xsane translation table with localedir: %s\n", STRINGIFY(LOCALEDIR));
bindtextdomain(xsane.prog_name, STRINGIFY(LOCALEDIR));
textdomain(xsane.prog_name);
+#ifdef HAVE_GTK2
+ bind_textdomain_codeset(xsane.prog_name, "UTF-8");
+#endif
#endif
-#ifdef HAVE_LIBGIMP_GIMP_H
+#ifdef HAVE_ANY_GIMP
{
GPrintFunc old_print_func;
GPrintFunc old_printerr_func;
@@ -7945,8 +9109,14 @@ int main(int argc, char **argv)
/* don`t know why, but os2 does need this one, a bit different to WIN32 */
set_gimp_PLUG_IN_INFO(&PLUG_IN_INFO);
#endif
+
+#ifdef HAVE_GIMP_2
+ /* gimp_main() returns 1 if xsane wasn't invoked by GIMP */
+ result = gimp_main(&PLUG_IN_INFO, argc, argv);
+#else
/* gimp_main() returns 1 if xsane wasn't invoked by GIMP */
result = gimp_main(argc, argv);
+#endif
#if 0
/* this is the old version that seems to use the compatibility functions */
diff --git a/src/xsane.h b/src/xsane.h
index 579bb0c..b54ee50 100644
--- a/src/xsane.h
+++ b/src/xsane.h
@@ -3,7 +3,7 @@
xsane.h
Oliver Rauch <Oliver.Rauch@rauch-domain.de>
- Copyright (C) 1998-2002 Oliver Rauch
+ Copyright (C) 1998-2005 Oliver Rauch
This file is part of the XSANE package.
This program is free software; you can redistribute it and/or modify
@@ -27,53 +27,13 @@
/* ---------------------------------------------------------------------------------------------------------------------- */
-/* #define XSANE_TEST */
-/* #define SUPPORT_RGBA */
-
-/* ---------------------------------------------------------------------------------------------------------------------- */
-
-#define XSANE_VERSION "0.84"
-#define XSANE_AUTHOR "Oliver Rauch"
-#define XSANE_COPYRIGHT "Oliver Rauch"
-#define XSANE_DATE "1998-2002"
-#define XSANE_EMAIL "Oliver.Rauch@xsane.org"
-#define XSANE_HOMEPAGE "http://www.xsane.org"
-#define XSANE_COPYRIGHT_TXT XSANE_DATE " " XSANE_COPYRIGHT
-
-/* ---------------------------------------------------------------------------------------------------------------------- */
-
-#define XSANE_DEBUG_ENVIRONMENT "XSANE_DEBUG"
-
-#define XSANE_DEFAULT_UMASK 0007
-#define XSANE_HOLD_TIME 200
-#define XSANE_CONTINUOUS_HOLD_TIME 10
-#define XSANE_DEFAULT_DEVICE "SANE_DEFAULT_DEVICE"
-
-#ifndef SLASH
-# define SLASH '/'
-#endif
-
-#ifndef XSANE_FIXED_HOME_PATH
-# define XSANE_FIXED_HOME_PATH /tmp
-#endif
-
-#ifndef ENVIRONMENT_HOME_DIR_NAME
-# define ENVIRONMENT_HOME_DIR_NAME HOME
-#endif
-
-#ifndef ENVIRONMENT_TEMP_DIR_NAME
-# define ENVIRONMENT_TEMP_DIR_NAME TMP
-#endif
-
-/* ---------------------------------------------------------------------------------------------------------------------- */
-
/* needed for most of the xsane sources: */
#ifdef _AIX
# include <lalloca.h>
#endif
-#ifdef __hpux
+#if defined(__hpux) || defined(__sgi)
# include <alloca.h>
#endif
@@ -92,25 +52,213 @@
#include <getopt.h>
#include <time.h>
-#include <sys/stat.h>
+/* OS/2 want sys/types before sys/stat */
#include <sys/types.h>
+#include <sys/stat.h>
#include <locale.h>
#include <sane/sane.h>
#include <sane/saneopts.h>
+#include "xsaneopts.h"
#include "../include/config.h"
#include "../include/sanei_signal.h"
+#include <gdk/gdkkeysyms.h>
+#include <gdk/gdk.h>
+#include <gtk/gtk.h>
+
+/* ---------------------------------------------------------------------------------------------------------------------- */
+
+#if 0
+#define DEF_GTK_ACCEL_LOCKED 0
+#else
+#define DEF_GTK_ACCEL_LOCKED GTK_ACCEL_LOCKED
+#endif
+
+/* ---------------------------------------------------------------------------------------------------------------------- */
+
+/* #define XSANE_TEST */
+/* #define SUPPORT_RGBA */
+/* #define HAVE_WORKING_GTK_GAMMACURVE */
+
+/* ---------------------------------------------------------------------------------------------------------------------- */
+
+#define XSANE_VERSION "0.97"
+#define XSANE_AUTHOR "Oliver Rauch"
+#define XSANE_COPYRIGHT "Oliver Rauch"
+#define XSANE_DATE "1998-2005"
+#define XSANE_EMAIL "Oliver.Rauch@xsane.org"
+#define XSANE_HOMEPAGE "http://www.xsane.org"
+#define XSANE_COPYRIGHT_TXT XSANE_DATE " " XSANE_COPYRIGHT
+
+/* ---------------------------------------------------------------------------------------------------------------------- */
+
+#define XSANE_DEBUG_ENVIRONMENT "XSANE_DEBUG"
+
+#define XSANE_DEFAULT_UMASK 0007
+#define XSANE_HOLD_TIME 200
+#define XSANE_CONTINUOUS_HOLD_TIME 10
+#define XSANE_DEFAULT_DEVICE "SANE_DEFAULT_DEVICE"
+#define XSANE_3PASS_BUFFER_RGB_SIZE 1024
+
+#ifdef HAVE_WINDOWS_H
+# define BUGGY_GDK_INPUT_EXCEPTION
+# define _WIN32
+#endif
+
+#ifdef HAVE_LIBPNG
+#ifdef HAVE_LIBZ
+# define XSANE_DEFAULT_MAILTYPE XSANE_FILETYPE_PNG
+# define XSANE_ACTIVATE_MAIL
+#endif
+#endif
+
+#ifndef XSANE_DEFAULT_MAILTYPE
+#ifdef HAVE_LIBJPEG
+# define XSANE_DEFAULT_MAILTYPE XSANE_FILETYPE_JPEG
+# define XSANE_ACTIVATE_MAIL
+#endif
+#endif
+
+#ifndef XSANE_DEFAULT_MAILTYPE
+#ifdef HAVE_LIBTIFF
+# define XSANE_DEFAULT_MAILTYPE XSANE_FILETYPE_TIFF
+# define XSANE_ACTIVATE_MAIL
+#endif
+#endif
+
+#ifndef XSANE_DEFAULT_MAILTYPE
+# define XSANE_DEFAULT_MAILTYPE XSANE_FILETYPE_PNM
+#endif
+
+
+/* ---------------------------------------------------------------------------------------------------------------------- */
+
+#ifndef SLASH
+# ifdef _WIN32
+# define SLASH '\\'
+# elif defined(HAVE_OS2_H)
+# define SLASH '\\'
+# else
+# define SLASH '/'
+# endif
+#endif
+
+/* *** NOT USED IN THE MOMENT. MAY BE USED LATER *** */
+/* ************************************************* */
+#ifndef XSANE_FIXED_HOME_DIR
+# ifdef _WIN32
+# define XSANE_FIXED_HOME_DIR c:\\SANE-Images
+# elif defined(HAVE_OS2_H)
+# define XSANE_FIXED_HOME_DIR c:\\SANE-Images
+# else
+# define XSANE_FIXED_HOME_DIR /tmp
+# endif
+#endif
+
+/* *** FIXED_APPDATA_DIR is used when the environment variable *** */
+/* *** ENVIRONMENT_APPDATA_DIR_NAME does not exist. It is used *** */
+/* *** to store the configuration files of xsane. *** */
+/* *************************************************************** */
+#ifndef XSANE_FIXED_APPDATA_DIR
+# ifdef _WIN32
+# define XSANE_FIXED_APPDATA_DIR c:\\SANE
+# elif defined(HAVE_OS2_H)
+# define XSANE_FIXED_APPDATA_DIR c:\\SANE
+# else
+# define XSANE_FIXED_APPDATA_DIR /tmp
+# endif
+#endif
+
+/* *** NOT USED IN THE MOMENT. MAY BE USED LATER *** */
+/* ************************************************* */
+#ifndef ENVIRONMENT_HOME_DIR_NAME
+# ifdef _WIN32
+# define ENVIRONMENT_HOME_DIR_NAME HOME
+# elif defined(HAVE_OS2_H)
+# define ENVIRONMENT_HOME_DIR_NAME HOME
+# else
+# define ENVIRONMENT_HOME_DIR_NAME HOME
+# endif
+#endif
+
+/* *** ENVIRONMENT_APPDATA_DIR_NAME is used to store the *** */
+/* *** configuration files of xsane. *** */
+/* *************************************************************** */
+#ifndef ENVIRONMENT_APPDATA_DIR_NAME
+# ifdef _WIN32
+# define ENVIRONMENT_APPDATA_DIR_NAME APPDATA
+# elif defined(HAVE_OS2_H)
+# define ENVIRONMENT_APPDATA_DIR_NAME HOME
+# else
+# define ENVIRONMENT_APPDATA_DIR_NAME HOME
+# endif
+#endif
+
+/* *** NOT USED IN THE MOMENT. MAY BE USED LATER *** */
+/* ************************************************* */
+#ifndef ENVIRONMENT_SYSTEMROOT_DIR_NAME
+# ifdef _WIN32
+/* SYSTEMROOT is used on WIN2K and WINXP */
+# define ENVIRONMENT_SYSTEMROOT_DIR_NAME_1 SYSTEMROOT
+# define ENVIRONMENT_SYSTEMROOT_DIR_NAME_2 WINDIR
+/* WINDIR is used on WIN98 and WINME */
+# elif defined(HAVE_OS2_H)
+# define ENVIRONMENT_SYSTEMROOT_DIR_NAME_1 NONE
+# define ENVIRONMENT_SYSTEMROOT_DIR_NAME_2 NONE
+# else
+# define ENVIRONMENT_SYSTEMROOT_DIR_NAME_1 NONE
+# define ENVIRONMENT_SYSTEMROOT_DIR_NAME_2 NONE
+# endif
+#endif
+
+#ifndef ENVIRONMENT_TEMP_DIR_NAME
+# define ENVIRONMENT_TEMP_DIR_NAME TMP
+#endif
+
+#ifndef ENVIRONMENT_BROWSER_NAME
+# define ENVIRONMENT_BROWSER_NAME BROWSER
+#endif
+
+/* *** DEFAULT_BROWSER is used when environment variable *** */
+/* *** BROWSER is not defined at first startup of xsane. *** */
+/* *************************************************************** */
+#ifndef DEFAULT_BROWSER
+# ifdef _WIN32
+# define DEFAULT_BROWSER "iexplore.exe"
+# elif defined(HAVE_OS2_H)
+# define DEFAULT_BROWSER "netscape"
+# else
+# define DEFAULT_BROWSER "netscape"
+# endif
+#endif
+
+/* ---------------------------------------------------------------------------------------------------------------------- */
+
#include "xsane-text.h"
#include "xsane-fixedtext.h"
#include "xsane-icons.h"
#include "xsane-viewer.h"
-#include <gdk/gdkkeysyms.h>
-#include <gdk/gdk.h>
-#include <gtk/gtk.h>
+/* ---------------------------------------------------------------------------------------------------------------------- */
+
+#if GTK_MAJOR_VERSION == 2
+# define HAVE_GTK2
+# ifndef _WIN32
+# define USE_GTK2_WINDOW_GET_POSITION
+# endif
+#endif
+
+#ifdef HAVE_GTK2
+# define HAVE_GTK_TEXT_VIEW_H
+# define DEF_GTK_MENU_ACCEL_VISIBLE GTK_ACCEL_VISIBLE
+#else /* we don't have gtk+-2.0 */
+# include "xsane-gtk-1_x-compat.h"
+#endif
+
+/* ---------------------------------------------------------------------------------------------------------------------- */
#ifdef ENABLE_NLS
# include <libintl.h>
@@ -133,14 +281,8 @@
/* ---------------------------------------------------------------------------------------------------------------------- */
-#ifdef HAVE_LIBPNG
-#ifdef HAVE_LIBZ
-# define XSANE_ACTIVATE_MAIL
-#endif
-#endif
-
-#ifdef _WIN32
-# define BUGGY_GTK_TOOLTIPS_SET_COLORS
+#ifdef HAVE_OS2_H
+# define strcasecmp stricmp
#endif
/* ---------------------------------------------------------------------------------------------------------------------- */
@@ -164,6 +306,7 @@ typedef struct
} pref_default_preset_area_t;
/* ---------------------------------------------------------------------------------------------------------------------- */
+
typedef struct
{
/* The option number of the well-known options. Each of these may
@@ -189,30 +332,34 @@ typedef struct
int shadow_r;
int shadow_g;
int shadow_b;
+ int batch_scan_start;
+ int batch_scan_loop;
+ int batch_scan_end;
+ int batch_scan_next_tl_y;
}
-GSGWellKnownOptions;
+WellKnownOptions;
/* ---------------------------------------------------------------------------------------------------------------------- */
typedef struct
{
gchar *label;
- struct GSGDialogElement *elem;
+ struct DialogElement *elem;
gint index;
}
-GSGMenuItem;
+MenuItem;
/* ---------------------------------------------------------------------------------------------------------------------- */
-typedef struct GSGDialogElement
+typedef struct DialogElement
{
- GtkWidget *automatic; /* auto button for options that support this */
GtkWidget *widget;
+ GtkWidget *widget2;
GtkObject *data;
int menu_size; /* # of items in menu (if any) */
- GSGMenuItem *menu;
+ MenuItem *menu;
}
-GSGDialogElement;
+DialogElement;
/* ---------------------------------------------------------------------------------------------------------------------- */
@@ -243,6 +390,8 @@ typedef struct Image_info
double contrast_blue;
double threshold;
+
+ int reduce_to_lineart;
}
Image_info;
@@ -252,30 +401,34 @@ Image_info;
/* ---------------------------------------------------------------------------------------------------------------------- */
-#ifdef HAVE_LIBGIMP_GIMP_H
+#ifdef HAVE_ANY_GIMP
# include <libgimp/gimp.h>
-# ifdef HAVE_LIBGIMP_GIMPFEATURES_H
-# include <libgimp/gimpfeatures.h>
+# ifdef HAVE_GIMP_2
+# define GIMP_HAVE_RESOLUTION_INFO
# else
-# define GIMP_CHECK_VERSION(major, minor, micro) 0
-# endif /* HAVE_LIBGIMP_GIMPFEATURES_H */
+# ifdef HAVE_LIBGIMP_GIMPFEATURES_H
+# include <libgimp/gimpfeatures.h>
+# else
+# define GIMP_CHECK_VERSION(major, minor, micro) 0
+# endif /* HAVE_LIBGIMP_GIMPFEATURES_H */
+# endif
# ifdef GIMP_CHECK_VERSION
# if GIMP_CHECK_VERSION(1,1,25)
-/* ok, we have the new gimp interface */
+/* ok, we have the gimp-1.2 or gimp-2.0 interface */
# else
-/* we have the old gimp interface and need the compatibility header file */
+/* we have the gimp-1.0 interface and need the compatibility header file */
# include "xsane-gimp-1_0-compat.h"
# endif
# else
-/* we have the old gimp interface and need the compatibility header file */
+/* we have the gimp-1.0 interface and need the compatibility header file */
# include "xsane-gimp-1_0-compat.h"
# endif
extern GimpPlugInInfo PLUG_IN_INFO; /* needed for win32 */
-#endif /* HAVE_LIBGIMP_GIMP_H */
+#endif /* HAVE_ANY_GIMP */
/* ---------------------------------------------------------------------------------------------------------------------- */
@@ -288,6 +441,7 @@ extern void xsane_pref_save(void);
extern void xsane_interface(int argc, char **argv);
extern void xsane_fax_project_save(void);
extern void xsane_mail_project_save(void);
+extern void xsane_batch_scan_add(void);
/* ---------------------------------------------------------------------------------------------------------------------- */
@@ -311,18 +465,20 @@ extern void xsane_mail_project_save(void);
#define FAXNORMALOPT "-l"
#define FAXFINEOPT "-m"
#define FAXVIEWER "gv"
+#define FAXCONVERTPSTOPNM "gs -dNOPAUSE -dBATCH -q -r204 -sDEVICE=pnm -sOutputFile="
#define MAILPROJECT "mailproject"
#define MAILCOMMAND "sendmail"
#define MAILVIEWER "xv"
#define OCRCOMMAND "gocr"
#define OCRINPUTFILEOPT "-i"
#define OCROUTPUTFILEOPT "-o"
-#define DOCVIEWER_NETSCAPE "netscape"
-#define DOCVIEWER DOCVIEWER_NETSCAPE
+#define OCROUTFDOPT "-x"
+#define OCRPROGRESSKEY ""
+#define BROWSER_NETSCAPE "netscape"
#define XSANE_MEDIUM_CALIB_BRIGHTNESS_MIN -1000.0
#define XSANE_MEDIUM_CALIB_BRIGHTNESS_MAX 1000.0
-#define XSANE_MEDIUM_CALIB_CONTRAST_MIN 0.0
+#define XSANE_MEDIUM_CALIB_CONTRAST_MIN -1000.0
#define XSANE_MEDIUM_CALIB_CONTRAST_MAX 1000.0
#define XSANE_BRIGHTNESS_MIN -100.0
@@ -344,6 +500,8 @@ extern void xsane_mail_project_save(void);
#define XSANE_HISTOGRAM_POS_Y 50
#define XSANE_GAMMA_POS_X 280
#define XSANE_GAMMA_POS_Y 420
+#define XSANE_BATCH_POS_X 480
+#define XSANE_BATCH_POS_Y 420
#define XSANE_STD_OPTIONS_POS_X 1
#define XSANE_STD_OPTIONS_POS_Y 400
#define XSANE_ADV_OPTIONS_POS_X 280
@@ -376,7 +534,7 @@ extern void xsane_mail_project_save(void);
enum
{
XSANE_UNKNOWN, XSANE_PNM, XSANE_JPEG, XSANE_PNG, XSANE_PS, XSANE_TIFF, XSANE_RGBA,
- XSANE_RAW16, XSANE_PNM16
+ XSANE_RAW16, XSANE_PNM16, XSANE_TEXT
};
/* ---------------------------------------------------------------------------------------------------------------------- */
@@ -409,12 +567,20 @@ typedef struct XsaneSlider
/* ---------------------------------------------------------------------------------------------------------------------- */
+typedef struct XsaneChildprocess
+{
+ pid_t pid;
+ struct XsaneChildprocess *next;
+} XsaneChildprocess;
+
+/* ---------------------------------------------------------------------------------------------------------------------- */
+
typedef struct Xsane
{
SANE_Int sane_backend_versioncode;
char *backend;
+ char *backend_translation;
char *device_set_filename;
- char *filetype;
char *output_filename;
char *dummy_filename;
@@ -436,15 +602,22 @@ typedef struct Xsane
SANE_Handle *dev;
const char *dev_name;
- GSGWellKnownOptions well_known;
+ WellKnownOptions well_known;
int num_elements;
- GSGDialogElement *element;
+ DialogElement *element;
u_int rebuild : 1;
int pixelcolor;
int scanning;
int reading_data;
int cancel_scan;
+ int batch_scan_load_default_list; /* load default list at program startup flag */
+ int batch_loop; /* is set when batch scanning and not last scan */
+ int batch_scan_use_stored_scanmode;
+ int batch_scan_use_stored_resolution;
+ int batch_scan_use_stored_bit_depth;
+ SANE_Status status_of_last_scan;
+
/* free gamma curve widgets */
GtkWidget *gamma_curve_gray;
GtkWidget *gamma_curve_red;
@@ -470,13 +643,21 @@ typedef struct Xsane
GtkWidget *histogram_dialog;
GtkWidget *gamma_dialog;
+ GtkWidget *batch_scan_dialog;
+ GtkWidget *batch_scan_button_box;
+ GtkWidget *batch_scan_action_box;
+ GtkWidget *batch_scan_list;
+ GtkAdjustment *batch_scan_vadjustment;
+
GtkWidget *fax_dialog;
GtkWidget *fax_list;
GtkWidget *fax_project_box;
GtkWidget *fax_project_exists;
GtkWidget *fax_project_not_exists;
GtkWidget *fax_project_entry;
+ GtkWidget *fax_project_entry_box;
GtkWidget *fax_receiver_entry;
+ GtkProgressBar *fax_progress_bar;
GtkWidget *mail_dialog;
GtkWidget *mail_list;
@@ -484,11 +665,12 @@ typedef struct Xsane
GtkWidget *mail_project_exists;
GtkWidget *mail_project_not_exists;
GtkWidget *mail_project_entry;
+ GtkWidget *mail_project_entry_box;
GtkWidget *mail_receiver_entry;
GtkWidget *mail_subject_entry;
GtkWidget *mail_text_widget;
GtkWidget *mail_html_mode_widget;
- GtkWidget *mail_status_label;
+ GtkProgressBar *mail_progress_bar;
GdkPixmap *window_icon_pixmap;
GdkBitmap *window_icon_mask;
@@ -508,16 +690,22 @@ typedef struct Xsane
int main_window_fixed;
int mode_selection;
+#ifndef USE_GTK2_WINDOW_GET_POSITION
int get_deskrelative_origin;
+#endif
/* various scanning related state: */
SANE_Int depth;
size_t num_bytes;
size_t bytes_read;
+ int read_offset_16;
+ char last_offset_16_byte;
+ int lineart_to_grayscale_x;
GtkProgressBar *progress_bar;
int input_tag;
SANE_Parameters param;
int adf_page_counter;
+ int scan_rotation;
/* for standalone mode: */
GtkWidget *filename_entry;
@@ -539,6 +727,7 @@ typedef struct Xsane
struct XsaneSlider slider_red;
struct XsaneSlider slider_green;
struct XsaneSlider slider_blue;
+ guint batch_scan_gamma_timer; /* has to be guint */
guint slider_timer; /* has to be guint */
int slider_timer_restart;
@@ -597,6 +786,7 @@ typedef struct Xsane
GtkWidget *show_preview_widget;
GtkWidget *show_histogram_widget;
GtkWidget *show_gamma_widget;
+ GtkWidget *show_batch_scan_widget;
GtkWidget *show_standard_options_widget;
GtkWidget *show_advanced_options_widget;
GtkWidget *show_resolution_list_widget;
@@ -619,7 +809,6 @@ typedef struct Xsane
SANE_Bool scanner_gamma_color;
SANE_Bool scanner_gamma_gray;
- int fax_fine_mode;
int mail_project_save;
int mail_html_mode;
@@ -632,15 +821,20 @@ typedef struct Xsane
u_char *histogram_gamma_data_red, *histogram_gamma_data_green, *histogram_gamma_data_blue;
u_char *histogram_medium_gamma_data_red, *histogram_medium_gamma_data_green, *histogram_medium_gamma_data_blue;
+ char *fax_status;
char *fax_filename;
char *fax_receiver;
+ float mail_progress_val;
+ int mail_progress_size;
+ int mail_progress_bytes;
char *mail_status;
char *mail_filename;
char *mail_receiver;
char *mail_subject;
int block_update_param;
+ int block_enhancement_update;
int broken_pipe; /* for printercommand pipe */
@@ -667,6 +861,8 @@ typedef struct Xsane
int histogram_dialog_posy;
int gamma_dialog_posx;
int gamma_dialog_posy;
+ int batch_dialog_posx;
+ int batch_dialog_posy;
int preview_dialog_posx;
int preview_dialog_posy;
int preview_dialog_width;
@@ -724,6 +920,9 @@ typedef struct Xsane
/* -------------------------------------------------- */
+ int ipc_pipefd[2]; /* for inter process communication error messages */
+ XsaneChildprocess *childprocess_list;
+
} Xsane;
extern struct Xsane xsane;
@@ -753,6 +952,7 @@ typedef struct XsaneSetup
GtkWidget *overwrite_warning_button;
GtkWidget *increase_filename_counter_button;
GtkWidget *skip_existing_numbers_button;
+ GtkWidget *save_pnm16_as_ascii_button;
GtkWidget *reduce_16bit_to_8bit_button;
GtkWidget *main_window_fixed_button;
@@ -773,7 +973,7 @@ typedef struct XsaneSetup
GtkWidget *disable_gimp_preview_gamma_button;
GtkWidget *preview_oversampling_entry;
GtkWidget *preview_own_cmap_button;
- GtkWidget *doc_viewer_entry;
+ GtkWidget *browser_entry;
GtkWidget *fax_command_entry;
GtkWidget *fax_receiver_option_entry;
@@ -801,6 +1001,9 @@ typedef struct XsaneSetup
GtkWidget *ocr_command_entry;
GtkWidget *ocr_inputfile_option_entry;
GtkWidget *ocr_outputfile_option_entry;
+ GtkWidget *ocr_use_gui_pipe_entry;
+ GtkWidget *ocr_gui_outfd_option_entry;
+ GtkWidget *ocr_progress_keyword_entry;
int filename_counter_len;
@@ -808,6 +1011,7 @@ typedef struct XsaneSetup
int tiff_compression8_nr;
int tiff_compression1_nr;
+ int show_range_mode;
int lineart_mode;
int image_permissions;
diff --git a/src/xsaneopts.h b/src/xsaneopts.h
new file mode 100644
index 0000000..8dbd655
--- /dev/null
+++ b/src/xsaneopts.h
@@ -0,0 +1,52 @@
+/* xsane -- a graphical (X11, gtk) scanner-oriented SANE frontend
+
+ xsaneopts.h
+
+ Oliver Rauch <Oliver.Rauch@rauch-domain.de>
+ Copyright (C) 1998-2005 Oliver Rauch
+ This file is part of the XSANE package.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
+
+/* ---------------------------------------------------------------------------------------------------------------------- */
+
+#include <sane/saneopts.h>
+
+/* ---------------------------------------------------------------------------------------------------------------------- */
+
+#ifndef XSANEOPTS_H
+#define XSANEOPTS_H
+
+/* ---------------------------------------------------------------------------------------------------------------------- */
+
+#ifndef SANE_NAME_BATCH_SCAN_START
+# define SANE_NAME_BATCH_SCAN_START "batch-scan-start"
+#endif
+
+#ifndef SANE_NAME_BATCH_SCAN_LOOP
+# define SANE_NAME_BATCH_SCAN_LOOP "batch-scan-loop"
+#endif
+
+#ifndef SANE_NAME_BATCH_SCAN_END
+# define SANE_NAME_BATCH_SCAN_END "batch-scan-end"
+#endif
+
+#ifndef SANE_NAME_BATCH_SCAN_NEXT_TL_Y
+# define SANE_NAME_BATCH_SCAN_NEXT_TL_Y "batch-scan-next-tl-y"
+#endif
+
+/* ---------------------------------------------------------------------------------------------------------------------- */
+
+#endif /* XSANEOPTS_H */