kopia lustrzana https://gitlab.com/sane-project/frontends
Gtk3
rodzic
2e93f931df
commit
0b8907221d
|
@ -33,7 +33,7 @@ INSTALL_DATA = @INSTALL_DATA@
|
|||
|
||||
@SET_MAKE@
|
||||
|
||||
SUBDIRS = include sanei src doc
|
||||
SUBDIRS = include libgtk sanei src doc
|
||||
|
||||
DISTFILES = AUTHORS COPYING Changelog INSTALL Makefile.in NEWS PROBLEMS \
|
||||
README acinclude.m4 aclocal.m4 config.guess config.sub configure \
|
||||
|
|
Plik diff jest za duży
Load Diff
Plik diff jest za duży
Load Diff
Plik diff jest za duży
Load Diff
Plik diff jest za duży
Load Diff
55
configure.in
55
configure.in
|
@ -7,8 +7,8 @@ AC_CONFIG_HEADER(include/sane/config.h)
|
|||
# version code:
|
||||
V_MAJOR=1
|
||||
V_MINOR=0
|
||||
V_BUILD=15
|
||||
V_EXTRA=git
|
||||
V_BUILD=14
|
||||
V_EXTRA=-68-g61dd774-dirty
|
||||
|
||||
PACKAGE=sane-frontends
|
||||
|
||||
|
@ -32,21 +32,15 @@ AC_SUBST(SANE_MAJOR)
|
|||
dnl Check if GUIs shall be compiled
|
||||
AC_ARG_ENABLE(guis, [ --disable-guis do not compile graphical user interfaces (GUIs)], USE_GUI=$enableval, USE_GUI=yes)
|
||||
|
||||
dnl Check if GTK2 support is wanted
|
||||
AC_ARG_ENABLE(gtk2, [ --disable-gtk2 do not use GTK2], USE_GTK2=$enableval, USE_GTK2=yes)
|
||||
dnl Check if GTK3 support is wanted
|
||||
AC_ARG_ENABLE(gtk3, [ --disable-gtk3 do not use GTK3], USE_GTK3=$enableval, USE_GTK3=yes)
|
||||
|
||||
dnl Check for gimp plugin support
|
||||
AC_MSG_CHECKING([whether GIMP plugin is requested])
|
||||
dnl Default is enabled GIMP plugin
|
||||
AC_ARG_ENABLE(gimp, [ --disable-gimp do not include GIMP plugin mode], USE_GIMP=$enableval, USE_GIMP=yes)
|
||||
AC_ARG_ENABLE(gimp12, [ --enable-gimp12 include GIMP 1.2 plugin mode (this enables GIMP =< 1.2 plugin, defaults to GIMP 2.0)], USE_GIMP12=$enableval, USE_GIMP12="no")
|
||||
if test "${USE_GIMP12}" = "yes"; then
|
||||
AC_MSG_RESULT([yes, GIMP 1.2])
|
||||
USE_GIMP="no"
|
||||
USE_GTK2="no"
|
||||
else
|
||||
AC_MSG_RESULT([$USE_GIMP, GIMP 2.0])
|
||||
fi
|
||||
|
||||
AC_MSG_RESULT([$USE_GIMP, GIMP 2.0])
|
||||
|
||||
dnl Checks for programs.
|
||||
AC_PROG_CC
|
||||
|
@ -112,7 +106,9 @@ fi
|
|||
|
||||
AC_CHECK_TOOL(RANLIB, ranlib, :)
|
||||
|
||||
AM_PATH_SANE(1.0.10, HAVE_SANE=yes, )
|
||||
PKG_CHECK_MODULES([SANE], [sane-backends >= 1.0.0], HAVE_SANE=yes)
|
||||
PKG_CHECK_VAR([SANE_PREFIX], [sane-backends >= 1.0.0], [prefix])
|
||||
PKG_CHECK_VAR([SANE_LDFLAGS], [sane-backends >= 1.0.0], [ldflags])
|
||||
dnl Print error message if sane is missing
|
||||
if test "x${HAVE_SANE}" = "x"; then
|
||||
echo "**********************************************************************"
|
||||
|
@ -128,34 +124,21 @@ if test "x${HAVE_SANE}" = "x"; then
|
|||
exit
|
||||
fi
|
||||
|
||||
# check for GTK2 or GTK >= 0.99.13
|
||||
# check for GTK3
|
||||
if test "${USE_GUI}" = "yes"; then
|
||||
|
||||
if test "${USE_GTK2}" = "yes" || test "${USE_GIMP}" = "yes"; then
|
||||
AM_PATH_GTK_2_0(2.0.0, HAVE_GTK=yes, [
|
||||
if test "${USE_GTK3}" = "yes" || test "${USE_GIMP}" = "yes"; then
|
||||
PKG_CHECK_MODULES([GTK], [gtk+-3.0], HAVE_GTK=yes, [
|
||||
if test "${USE_GIMP}" = "yes"; then
|
||||
AC_MSG_WARN([*** GIMP 2.0 plugin requested, but GTK+ 2.0 not found, falling back to GIMP/GTK+ < 2.0 if possible ***])
|
||||
AC_MSG_WARN([*** GIMP 2.0 plugin requested, but GTK+ 3.0 not found, falling back to GIMP/GTK+ < 3.0 if possible ***])
|
||||
USE_GIMP=no
|
||||
USE_GIMP12=yes
|
||||
else
|
||||
AC_MSG_WARN([*** GTK+ 2.0 not found, falling back to GTK+ < 2.0 if possible ***])
|
||||
AC_MSG_WARN([*** GTK+ 3.0 not found, falling back to GTK+ < 3.0 if possible ***])
|
||||
fi])
|
||||
fi
|
||||
|
||||
# fallback to GTK < 2 if GTK2 isn't available
|
||||
if test "${HAVE_GTK}" != "yes"; then
|
||||
AM_PATH_GTK(0.99.13, HAVE_GTK=yes, )
|
||||
fi
|
||||
|
||||
if test "${USE_GIMP12}" = "yes"; then
|
||||
AM_PATH_GIMP(1.0.0, HAVE_GIMP=yes)
|
||||
if test "${HAVE_GIMP}" = "yes"; then
|
||||
AC_DEFINE([ENABLE_GIMP_1_2], 1, [Define to 1 if GIMP 1.2 support wanted])
|
||||
fi
|
||||
fi
|
||||
|
||||
if test "${USE_GIMP}" = "yes"; then
|
||||
AM_PATH_GIMP_2_0(1.3.23, HAVE_GIMP=yes)
|
||||
PKG_CHECK_MODULES([GIMP], [gimp-2.0], HAVE_GIMP=yes)
|
||||
if test "${HAVE_GIMP}" = "yes"; then
|
||||
AC_DEFINE([HAVE_LIBGIMP_GIMP_H], 1, [Define to 1 if you have the <libgimp/gimp.h> header file.])
|
||||
fi
|
||||
|
@ -176,10 +159,16 @@ if test "${USE_GUI}" = "yes"; then
|
|||
fi
|
||||
fi
|
||||
|
||||
AC_DEFINE([HAVE_LIBGIMP_GIMP_H], 1, [Define to 1 if you have the <libgimp/gimp.h> header file.])
|
||||
|
||||
BINPROGS=${BINPROGS}" "${GUIPROGS}
|
||||
|
||||
AC_SUBST(INCLUDES)
|
||||
AC_SUBST(BINPROGS)
|
||||
AC_SUBST(GTK_CFLAGS)
|
||||
AC_SUBST(GTK_LIBS)
|
||||
AC_SUBST(GIMP_CFLAGS)
|
||||
AC_SUBST(GIMP_LIBS)
|
||||
CPPFLAGS="${CPPFLAGS} \
|
||||
-DPATH_SANE_DATA_DIR=\$(sanedatadir) \
|
||||
-DV_MAJOR=${V_MAJOR} -DV_MINOR=${V_MINOR} -DV_BUILD=${V_BUILD} -DSANE_V_MAJOR=${SANE_V_MAJOR}"
|
||||
|
@ -199,7 +188,7 @@ AC_ARG_ENABLE(foo2, [
|
|||
To add include or library paths call:
|
||||
[env] CPPFLAGS=\"-I/path/to/foo/include\" LDFLAGS=\"-L/path/to/foo/libs\" ./configure])
|
||||
|
||||
AC_OUTPUT([Makefile src/Makefile sanei/Makefile doc/Makefile
|
||||
AC_OUTPUT([Makefile libgtk/Makefile src/Makefile sanei/Makefile doc/Makefile
|
||||
include/Makefile],)
|
||||
|
||||
echo "****************************************************************"
|
||||
|
|
|
@ -1,21 +1,12 @@
|
|||
/* include/sane/config.h.in. Generated from configure.in by autoheader. */
|
||||
|
||||
/* Define to one of `_getb67', `GETB67', `getb67' for Cray-2 and Cray-YMP
|
||||
systems. This function is required for `alloca.c' support on those systems.
|
||||
*/
|
||||
#undef CRAY_STACKSEG_END
|
||||
|
||||
/* Define to 1 if using `alloca.c'. */
|
||||
/* Define to 1 if using 'alloca.c'. */
|
||||
#undef C_ALLOCA
|
||||
|
||||
/* Define to 1 if GIMP 1.2 support wanted */
|
||||
#undef ENABLE_GIMP_1_2
|
||||
|
||||
/* Define to 1 if you have `alloca', as a function or macro. */
|
||||
/* Define to 1 if you have 'alloca', as a function or macro. */
|
||||
#undef HAVE_ALLOCA
|
||||
|
||||
/* Define to 1 if you have <alloca.h> and it should be used (not on Ultrix).
|
||||
*/
|
||||
/* Define to 1 if <alloca.h> works. */
|
||||
#undef HAVE_ALLOCA_H
|
||||
|
||||
/* Define to 1 if you have the `atexit' function. */
|
||||
|
@ -39,9 +30,6 @@
|
|||
/* Define to 1 if you have the <libc.h> header file. */
|
||||
#undef HAVE_LIBC_H
|
||||
|
||||
/* Define to 1 if you have the <libgimp/gimpfeatures.h> header file. */
|
||||
#undef HAVE_LIBGIMP_GIMPFEATURES_H
|
||||
|
||||
/* Define to 1 if you have the <libgimp/gimp.h> header file. */
|
||||
#undef HAVE_LIBGIMP_GIMP_H
|
||||
|
||||
|
@ -54,8 +42,8 @@
|
|||
/* Define to 1 if you have the `syslog' library (-lsyslog). */
|
||||
#undef HAVE_LIBSYSLOG
|
||||
|
||||
/* Define to 1 if you have the <memory.h> header file. */
|
||||
#undef HAVE_MEMORY_H
|
||||
/* Define to 1 if you have the <minix/config.h> header file. */
|
||||
#undef HAVE_MINIX_CONFIG_H
|
||||
|
||||
/* Define to 1 if you have the `mkdir' function. */
|
||||
#undef HAVE_MKDIR
|
||||
|
@ -75,6 +63,9 @@
|
|||
/* Define to 1 if you have the <stdint.h> header file. */
|
||||
#undef HAVE_STDINT_H
|
||||
|
||||
/* Define to 1 if you have the <stdio.h> header file. */
|
||||
#undef HAVE_STDIO_H
|
||||
|
||||
/* Define to 1 if you have the <stdlib.h> header file. */
|
||||
#undef HAVE_STDLIB_H
|
||||
|
||||
|
@ -108,6 +99,9 @@
|
|||
/* Define to 1 if you have the `strtod' function. */
|
||||
#undef HAVE_STRTOD
|
||||
|
||||
/* Define to 1 if you have the <sys/param.h> header file. */
|
||||
#undef HAVE_SYS_PARAM_H
|
||||
|
||||
/* Define to 1 if you have the <sys/socket.h> header file. */
|
||||
#undef HAVE_SYS_SOCKET_H
|
||||
|
||||
|
@ -129,6 +123,9 @@
|
|||
/* Define to 1 if you have the `vsyslog' function. */
|
||||
#undef HAVE_VSYSLOG
|
||||
|
||||
/* Define to 1 if you have the <wchar.h> header file. */
|
||||
#undef HAVE_WCHAR_H
|
||||
|
||||
/* Define to the name of the distribution. */
|
||||
#undef PACKAGE
|
||||
|
||||
|
@ -144,6 +141,9 @@
|
|||
/* Define to the one symbol short name of this package. */
|
||||
#undef PACKAGE_TARNAME
|
||||
|
||||
/* Define to the home page for this package. */
|
||||
#undef PACKAGE_URL
|
||||
|
||||
/* Define to the name and the version of the distribution. */
|
||||
#undef PACKAGE_VERSION
|
||||
|
||||
|
@ -152,46 +152,121 @@
|
|||
|
||||
/* If using the C implementation of alloca, define if you know the
|
||||
direction of stack growth for your system; otherwise it will be
|
||||
automatically deduced at run-time.
|
||||
STACK_DIRECTION > 0 => grows toward higher addresses
|
||||
STACK_DIRECTION < 0 => grows toward lower addresses
|
||||
STACK_DIRECTION = 0 => direction of growth unknown */
|
||||
automatically deduced at runtime.
|
||||
STACK_DIRECTION > 0 => grows toward higher addresses
|
||||
STACK_DIRECTION < 0 => grows toward lower addresses
|
||||
STACK_DIRECTION = 0 => direction of growth unknown */
|
||||
#undef STACK_DIRECTION
|
||||
|
||||
/* Define to 1 if you have the ANSI C header files. */
|
||||
/* Define to 1 if all of the C90 standard headers exist (not just the ones
|
||||
required in a freestanding environment). This macro is provided for
|
||||
backward compatibility; new code need not use it. */
|
||||
#undef STDC_HEADERS
|
||||
|
||||
/* Enable extensions on AIX 3, Interix. */
|
||||
#ifndef _ALL_SOURCE
|
||||
# undef _ALL_SOURCE
|
||||
#endif
|
||||
/* Enable general extensions on macOS. */
|
||||
#ifndef _DARWIN_C_SOURCE
|
||||
# undef _DARWIN_C_SOURCE
|
||||
#endif
|
||||
/* Enable general extensions on Solaris. */
|
||||
#ifndef __EXTENSIONS__
|
||||
# undef __EXTENSIONS__
|
||||
#endif
|
||||
/* Enable GNU extensions on systems that have them. */
|
||||
#ifndef _GNU_SOURCE
|
||||
# undef _GNU_SOURCE
|
||||
#endif
|
||||
/* Enable X/Open compliant socket functions that do not require linking
|
||||
with -lxnet on HP-UX 11.11. */
|
||||
#ifndef _HPUX_ALT_XOPEN_SOCKET_API
|
||||
# undef _HPUX_ALT_XOPEN_SOCKET_API
|
||||
#endif
|
||||
/* Identify the host operating system as Minix.
|
||||
This macro does not affect the system headers' behavior.
|
||||
A future release of Autoconf may stop defining this macro. */
|
||||
#ifndef _MINIX
|
||||
# undef _MINIX
|
||||
#endif
|
||||
/* Enable general extensions on NetBSD.
|
||||
Enable NetBSD compatibility extensions on Minix. */
|
||||
#ifndef _NETBSD_SOURCE
|
||||
# undef _NETBSD_SOURCE
|
||||
#endif
|
||||
/* Enable OpenBSD compatibility extensions on NetBSD.
|
||||
Oddly enough, this does nothing on OpenBSD. */
|
||||
#ifndef _OPENBSD_SOURCE
|
||||
# undef _OPENBSD_SOURCE
|
||||
#endif
|
||||
/* Define to 1 if needed for POSIX-compatible behavior. */
|
||||
#ifndef _POSIX_SOURCE
|
||||
# undef _POSIX_SOURCE
|
||||
#endif
|
||||
/* Define to 2 if needed for POSIX-compatible behavior. */
|
||||
#ifndef _POSIX_1_SOURCE
|
||||
# undef _POSIX_1_SOURCE
|
||||
#endif
|
||||
/* Enable POSIX-compatible threading on Solaris. */
|
||||
#ifndef _POSIX_PTHREAD_SEMANTICS
|
||||
# undef _POSIX_PTHREAD_SEMANTICS
|
||||
#endif
|
||||
/* Enable extensions specified by ISO/IEC TS 18661-5:2014. */
|
||||
#ifndef __STDC_WANT_IEC_60559_ATTRIBS_EXT__
|
||||
# undef __STDC_WANT_IEC_60559_ATTRIBS_EXT__
|
||||
#endif
|
||||
/* Enable extensions specified by ISO/IEC TS 18661-1:2014. */
|
||||
#ifndef __STDC_WANT_IEC_60559_BFP_EXT__
|
||||
# undef __STDC_WANT_IEC_60559_BFP_EXT__
|
||||
#endif
|
||||
/* Enable extensions specified by ISO/IEC TS 18661-2:2015. */
|
||||
#ifndef __STDC_WANT_IEC_60559_DFP_EXT__
|
||||
# undef __STDC_WANT_IEC_60559_DFP_EXT__
|
||||
#endif
|
||||
/* Enable extensions specified by ISO/IEC TS 18661-4:2015. */
|
||||
#ifndef __STDC_WANT_IEC_60559_FUNCS_EXT__
|
||||
# undef __STDC_WANT_IEC_60559_FUNCS_EXT__
|
||||
#endif
|
||||
/* Enable extensions specified by ISO/IEC TS 18661-3:2015. */
|
||||
#ifndef __STDC_WANT_IEC_60559_TYPES_EXT__
|
||||
# undef __STDC_WANT_IEC_60559_TYPES_EXT__
|
||||
#endif
|
||||
/* Enable extensions specified by ISO/IEC TR 24731-2:2010. */
|
||||
#ifndef __STDC_WANT_LIB_EXT2__
|
||||
# undef __STDC_WANT_LIB_EXT2__
|
||||
#endif
|
||||
/* Enable extensions specified by ISO/IEC 24747:2009. */
|
||||
#ifndef __STDC_WANT_MATH_SPEC_FUNCS__
|
||||
# undef __STDC_WANT_MATH_SPEC_FUNCS__
|
||||
#endif
|
||||
/* Enable extensions on HP NonStop. */
|
||||
#ifndef _TANDEM_SOURCE
|
||||
# undef _TANDEM_SOURCE
|
||||
#endif
|
||||
/* Enable X/Open extensions. Define to 500 only if necessary
|
||||
to make mbstate_t available. */
|
||||
#ifndef _XOPEN_SOURCE
|
||||
# undef _XOPEN_SOURCE
|
||||
#endif
|
||||
|
||||
|
||||
/* Define to the version of the distribution. */
|
||||
#undef VERSION
|
||||
|
||||
/* Define to 1 if on AIX 3.
|
||||
System headers sometimes define this.
|
||||
We just want to avoid a redefinition error message. */
|
||||
#ifndef _ALL_SOURCE
|
||||
# undef _ALL_SOURCE
|
||||
#endif
|
||||
|
||||
/* Define to 1 if on MINIX. */
|
||||
#undef _MINIX
|
||||
|
||||
/* Define to 2 if the system does not provide POSIX.1 features except with
|
||||
this defined. */
|
||||
#undef _POSIX_1_SOURCE
|
||||
|
||||
/* Define to 1 if you need to in order for `stat' and other things to work. */
|
||||
#undef _POSIX_SOURCE
|
||||
|
||||
/* Define to empty if `const' does not conform to ANSI C. */
|
||||
#undef const
|
||||
|
||||
/* Define as `__inline' if that's what the C compiler calls it, or to nothing
|
||||
if it is not supported. */
|
||||
/* Define to `__inline__' or `__inline' if that's what the C compiler
|
||||
calls it, or to nothing if 'inline' is not supported under any name. */
|
||||
#ifndef __cplusplus
|
||||
#undef inline
|
||||
#endif
|
||||
|
||||
/* Define to `int' if <sys/types.h> does not define. */
|
||||
/* Define as a signed integer type capable of holding a process identifier. */
|
||||
#undef pid_t
|
||||
|
||||
/* Define to `unsigned' if <sys/types.h> does not define. */
|
||||
/* Define to `unsigned int' if <sys/types.h> does not define. */
|
||||
#undef size_t
|
||||
|
||||
/* Define to `long' if <sys/types.h> does not define. */
|
||||
|
|
715
install-sh
715
install-sh
|
@ -1,250 +1,541 @@
|
|||
#! /bin/sh
|
||||
#
|
||||
#!/bin/sh
|
||||
# install - install a program, script, or datafile
|
||||
# This comes from X11R5 (mit/util/scripts/install.sh).
|
||||
|
||||
scriptversion=2020-11-14.01; # UTC
|
||||
|
||||
# This originates from X11R5 (mit/util/scripts/install.sh), which was
|
||||
# later released in X11R6 (xc/config/util/install.sh) with the
|
||||
# following copyright and license.
|
||||
#
|
||||
# Copyright (C) 1994 X Consortium
|
||||
#
|
||||
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
# of this software and associated documentation files (the "Software"), to
|
||||
# deal in the Software without restriction, including without limitation the
|
||||
# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
||||
# sell copies of the Software, and to permit persons to whom the Software is
|
||||
# furnished to do so, subject to the following conditions:
|
||||
#
|
||||
# The above copyright notice and this permission notice shall be included in
|
||||
# all copies or substantial portions of the Software.
|
||||
#
|
||||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
# X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
|
||||
# AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNEC-
|
||||
# TION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
#
|
||||
# Except as contained in this notice, the name of the X Consortium shall not
|
||||
# be used in advertising or otherwise to promote the sale, use or other deal-
|
||||
# ings in this Software without prior written authorization from the X Consor-
|
||||
# tium.
|
||||
#
|
||||
#
|
||||
# FSF changes to this file are in the public domain.
|
||||
#
|
||||
# Calling this script install-sh is preferred over install.sh, to prevent
|
||||
# `make' implicit rules from creating a file called install from it
|
||||
# 'make' implicit rules from creating a file called install from it
|
||||
# when there is no Makefile.
|
||||
#
|
||||
# Copyright 1991 by the Massachusetts Institute of Technology
|
||||
#
|
||||
# Permission to use, copy, modify, distribute, and sell this software and its
|
||||
# documentation for any purpose is hereby granted without fee, provided that
|
||||
# the above copyright notice appear in all copies and that both that
|
||||
# copyright notice and this permission notice appear in supporting
|
||||
# documentation, and that the name of M.I.T. not be used in advertising or
|
||||
# publicity pertaining to distribution of the software without specific,
|
||||
# written prior permission. M.I.T. makes no representations about the
|
||||
# suitability of this software for any purpose. It is provided "as is"
|
||||
# without express or implied warranty.
|
||||
#
|
||||
# This script is compatible with the BSD install script, but was written
|
||||
# from scratch.
|
||||
#
|
||||
|
||||
|
||||
# set DOITPROG to echo to test this script
|
||||
|
||||
# Don't use :- since 4.3BSD and earlier shells don't like it.
|
||||
doit="${DOITPROG-}"
|
||||
|
||||
|
||||
# put in absolute paths if you don't have them in your path; or use env. vars.
|
||||
|
||||
mvprog="${MVPROG-mv}"
|
||||
cpprog="${CPPROG-cp}"
|
||||
chmodprog="${CHMODPROG-chmod}"
|
||||
chownprog="${CHOWNPROG-chown}"
|
||||
chgrpprog="${CHGRPPROG-chgrp}"
|
||||
stripprog="${STRIPPROG-strip}"
|
||||
rmprog="${RMPROG-rm}"
|
||||
mkdirprog="${MKDIRPROG-mkdir}"
|
||||
|
||||
transformbasename=""
|
||||
transform_arg=""
|
||||
instcmd="$mvprog"
|
||||
chmodcmd="$chmodprog 0755"
|
||||
chowncmd=""
|
||||
chgrpcmd=""
|
||||
stripcmd=""
|
||||
rmcmd="$rmprog -f"
|
||||
mvcmd="$mvprog"
|
||||
src=""
|
||||
dst=""
|
||||
dir_arg=""
|
||||
|
||||
while [ x"$1" != x ]; do
|
||||
case $1 in
|
||||
-c) instcmd="$cpprog"
|
||||
shift
|
||||
continue;;
|
||||
|
||||
-d) dir_arg=true
|
||||
shift
|
||||
continue;;
|
||||
|
||||
-m) chmodcmd="$chmodprog $2"
|
||||
shift
|
||||
shift
|
||||
continue;;
|
||||
|
||||
-o) chowncmd="$chownprog $2"
|
||||
shift
|
||||
shift
|
||||
continue;;
|
||||
|
||||
-g) chgrpcmd="$chgrpprog $2"
|
||||
shift
|
||||
shift
|
||||
continue;;
|
||||
|
||||
-s) stripcmd="$stripprog"
|
||||
shift
|
||||
continue;;
|
||||
|
||||
-t=*) transformarg=`echo $1 | sed 's/-t=//'`
|
||||
shift
|
||||
continue;;
|
||||
|
||||
-b=*) transformbasename=`echo $1 | sed 's/-b=//'`
|
||||
shift
|
||||
continue;;
|
||||
|
||||
*) if [ x"$src" = x ]
|
||||
then
|
||||
src=$1
|
||||
else
|
||||
# this colon is to work around a 386BSD /bin/sh bug
|
||||
:
|
||||
dst=$1
|
||||
fi
|
||||
shift
|
||||
continue;;
|
||||
esac
|
||||
done
|
||||
|
||||
if [ x"$src" = x ]
|
||||
then
|
||||
echo "install: no input file specified"
|
||||
exit 1
|
||||
else
|
||||
true
|
||||
fi
|
||||
|
||||
if [ x"$dir_arg" != x ]; then
|
||||
dst=$src
|
||||
src=""
|
||||
|
||||
if [ -d $dst ]; then
|
||||
instcmd=:
|
||||
else
|
||||
instcmd=mkdir
|
||||
fi
|
||||
else
|
||||
|
||||
# Waiting for this to be detected by the "$instcmd $src $dsttmp" command
|
||||
# might cause directories to be created, which would be especially bad
|
||||
# if $src (and thus $dsttmp) contains '*'.
|
||||
|
||||
if [ -f $src -o -d $src ]
|
||||
then
|
||||
true
|
||||
else
|
||||
echo "install: $src does not exist"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ x"$dst" = x ]
|
||||
then
|
||||
echo "install: no destination specified"
|
||||
exit 1
|
||||
else
|
||||
true
|
||||
fi
|
||||
|
||||
# If destination is a directory, append the input filename; if your system
|
||||
# does not like double slashes in filenames, you may need to add some logic
|
||||
|
||||
if [ -d $dst ]
|
||||
then
|
||||
dst="$dst"/`basename $src`
|
||||
else
|
||||
true
|
||||
fi
|
||||
fi
|
||||
|
||||
## this sed command emulates the dirname command
|
||||
dstdir=`echo $dst | sed -e 's,[^/]*$,,;s,/$,,;s,^$,.,'`
|
||||
|
||||
# Make sure that the destination directory exists.
|
||||
# this part is taken from Noah Friedman's mkinstalldirs script
|
||||
|
||||
# Skip lots of stat calls in the usual case.
|
||||
if [ ! -d "$dstdir" ]; then
|
||||
defaultIFS='
|
||||
tab=' '
|
||||
nl='
|
||||
'
|
||||
IFS="${IFS-${defaultIFS}}"
|
||||
IFS=" $tab$nl"
|
||||
|
||||
oIFS="${IFS}"
|
||||
# Some sh's can't handle IFS=/ for some reason.
|
||||
IFS='%'
|
||||
set - `echo ${dstdir} | sed -e 's@/@%@g' -e 's@^%@/@'`
|
||||
IFS="${oIFS}"
|
||||
# Set DOITPROG to "echo" to test this script.
|
||||
|
||||
pathcomp=''
|
||||
doit=${DOITPROG-}
|
||||
doit_exec=${doit:-exec}
|
||||
|
||||
while [ $# -ne 0 ] ; do
|
||||
pathcomp="${pathcomp}${1}"
|
||||
shift
|
||||
# Put in absolute file names if you don't have them in your path;
|
||||
# or use environment vars.
|
||||
|
||||
if [ ! -d "${pathcomp}" ] ;
|
||||
then
|
||||
$mkdirprog "${pathcomp}"
|
||||
else
|
||||
true
|
||||
fi
|
||||
chgrpprog=${CHGRPPROG-chgrp}
|
||||
chmodprog=${CHMODPROG-chmod}
|
||||
chownprog=${CHOWNPROG-chown}
|
||||
cmpprog=${CMPPROG-cmp}
|
||||
cpprog=${CPPROG-cp}
|
||||
mkdirprog=${MKDIRPROG-mkdir}
|
||||
mvprog=${MVPROG-mv}
|
||||
rmprog=${RMPROG-rm}
|
||||
stripprog=${STRIPPROG-strip}
|
||||
|
||||
pathcomp="${pathcomp}/"
|
||||
posix_mkdir=
|
||||
|
||||
# Desired mode of installed file.
|
||||
mode=0755
|
||||
|
||||
# Create dirs (including intermediate dirs) using mode 755.
|
||||
# This is like GNU 'install' as of coreutils 8.32 (2020).
|
||||
mkdir_umask=22
|
||||
|
||||
backupsuffix=
|
||||
chgrpcmd=
|
||||
chmodcmd=$chmodprog
|
||||
chowncmd=
|
||||
mvcmd=$mvprog
|
||||
rmcmd="$rmprog -f"
|
||||
stripcmd=
|
||||
|
||||
src=
|
||||
dst=
|
||||
dir_arg=
|
||||
dst_arg=
|
||||
|
||||
copy_on_change=false
|
||||
is_target_a_directory=possibly
|
||||
|
||||
usage="\
|
||||
Usage: $0 [OPTION]... [-T] SRCFILE DSTFILE
|
||||
or: $0 [OPTION]... SRCFILES... DIRECTORY
|
||||
or: $0 [OPTION]... -t DIRECTORY SRCFILES...
|
||||
or: $0 [OPTION]... -d DIRECTORIES...
|
||||
|
||||
In the 1st form, copy SRCFILE to DSTFILE.
|
||||
In the 2nd and 3rd, copy all SRCFILES to DIRECTORY.
|
||||
In the 4th, create DIRECTORIES.
|
||||
|
||||
Options:
|
||||
--help display this help and exit.
|
||||
--version display version info and exit.
|
||||
|
||||
-c (ignored)
|
||||
-C install only if different (preserve data modification time)
|
||||
-d create directories instead of installing files.
|
||||
-g GROUP $chgrpprog installed files to GROUP.
|
||||
-m MODE $chmodprog installed files to MODE.
|
||||
-o USER $chownprog installed files to USER.
|
||||
-p pass -p to $cpprog.
|
||||
-s $stripprog installed files.
|
||||
-S SUFFIX attempt to back up existing files, with suffix SUFFIX.
|
||||
-t DIRECTORY install into DIRECTORY.
|
||||
-T report an error if DSTFILE is a directory.
|
||||
|
||||
Environment variables override the default commands:
|
||||
CHGRPPROG CHMODPROG CHOWNPROG CMPPROG CPPROG MKDIRPROG MVPROG
|
||||
RMPROG STRIPPROG
|
||||
|
||||
By default, rm is invoked with -f; when overridden with RMPROG,
|
||||
it's up to you to specify -f if you want it.
|
||||
|
||||
If -S is not specified, no backups are attempted.
|
||||
|
||||
Email bug reports to bug-automake@gnu.org.
|
||||
Automake home page: https://www.gnu.org/software/automake/
|
||||
"
|
||||
|
||||
while test $# -ne 0; do
|
||||
case $1 in
|
||||
-c) ;;
|
||||
|
||||
-C) copy_on_change=true;;
|
||||
|
||||
-d) dir_arg=true;;
|
||||
|
||||
-g) chgrpcmd="$chgrpprog $2"
|
||||
shift;;
|
||||
|
||||
--help) echo "$usage"; exit $?;;
|
||||
|
||||
-m) mode=$2
|
||||
case $mode in
|
||||
*' '* | *"$tab"* | *"$nl"* | *'*'* | *'?'* | *'['*)
|
||||
echo "$0: invalid mode: $mode" >&2
|
||||
exit 1;;
|
||||
esac
|
||||
shift;;
|
||||
|
||||
-o) chowncmd="$chownprog $2"
|
||||
shift;;
|
||||
|
||||
-p) cpprog="$cpprog -p";;
|
||||
|
||||
-s) stripcmd=$stripprog;;
|
||||
|
||||
-S) backupsuffix="$2"
|
||||
shift;;
|
||||
|
||||
-t)
|
||||
is_target_a_directory=always
|
||||
dst_arg=$2
|
||||
# Protect names problematic for 'test' and other utilities.
|
||||
case $dst_arg in
|
||||
-* | [=\(\)!]) dst_arg=./$dst_arg;;
|
||||
esac
|
||||
shift;;
|
||||
|
||||
-T) is_target_a_directory=never;;
|
||||
|
||||
--version) echo "$0 $scriptversion"; exit $?;;
|
||||
|
||||
--) shift
|
||||
break;;
|
||||
|
||||
-*) echo "$0: invalid option: $1" >&2
|
||||
exit 1;;
|
||||
|
||||
*) break;;
|
||||
esac
|
||||
shift
|
||||
done
|
||||
|
||||
# We allow the use of options -d and -T together, by making -d
|
||||
# take the precedence; this is for compatibility with GNU install.
|
||||
|
||||
if test -n "$dir_arg"; then
|
||||
if test -n "$dst_arg"; then
|
||||
echo "$0: target directory not allowed when installing a directory." >&2
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ x"$dir_arg" != x ]
|
||||
then
|
||||
$doit $instcmd $dst &&
|
||||
if test $# -ne 0 && test -z "$dir_arg$dst_arg"; then
|
||||
# When -d is used, all remaining arguments are directories to create.
|
||||
# When -t is used, the destination is already specified.
|
||||
# Otherwise, the last argument is the destination. Remove it from $@.
|
||||
for arg
|
||||
do
|
||||
if test -n "$dst_arg"; then
|
||||
# $@ is not empty: it contains at least $arg.
|
||||
set fnord "$@" "$dst_arg"
|
||||
shift # fnord
|
||||
fi
|
||||
shift # arg
|
||||
dst_arg=$arg
|
||||
# Protect names problematic for 'test' and other utilities.
|
||||
case $dst_arg in
|
||||
-* | [=\(\)!]) dst_arg=./$dst_arg;;
|
||||
esac
|
||||
done
|
||||
fi
|
||||
|
||||
if [ x"$chowncmd" != x ]; then $doit $chowncmd $dst; else true ; fi &&
|
||||
if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dst; else true ; fi &&
|
||||
if [ x"$stripcmd" != x ]; then $doit $stripcmd $dst; else true ; fi &&
|
||||
if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dst; else true ; fi
|
||||
else
|
||||
if test $# -eq 0; then
|
||||
if test -z "$dir_arg"; then
|
||||
echo "$0: no input file specified." >&2
|
||||
exit 1
|
||||
fi
|
||||
# It's OK to call 'install-sh -d' without argument.
|
||||
# This can happen when creating conditional directories.
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# If we're going to rename the final executable, determine the name now.
|
||||
if test -z "$dir_arg"; then
|
||||
if test $# -gt 1 || test "$is_target_a_directory" = always; then
|
||||
if test ! -d "$dst_arg"; then
|
||||
echo "$0: $dst_arg: Is not a directory." >&2
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ x"$transformarg" = x ]
|
||||
if test -z "$dir_arg"; then
|
||||
do_exit='(exit $ret); exit $ret'
|
||||
trap "ret=129; $do_exit" 1
|
||||
trap "ret=130; $do_exit" 2
|
||||
trap "ret=141; $do_exit" 13
|
||||
trap "ret=143; $do_exit" 15
|
||||
|
||||
# Set umask so as not to create temps with too-generous modes.
|
||||
# However, 'strip' requires both read and write access to temps.
|
||||
case $mode in
|
||||
# Optimize common cases.
|
||||
*644) cp_umask=133;;
|
||||
*755) cp_umask=22;;
|
||||
|
||||
*[0-7])
|
||||
if test -z "$stripcmd"; then
|
||||
u_plus_rw=
|
||||
else
|
||||
u_plus_rw='% 200'
|
||||
fi
|
||||
cp_umask=`expr '(' 777 - $mode % 1000 ')' $u_plus_rw`;;
|
||||
*)
|
||||
if test -z "$stripcmd"; then
|
||||
u_plus_rw=
|
||||
else
|
||||
u_plus_rw=,u+rw
|
||||
fi
|
||||
cp_umask=$mode$u_plus_rw;;
|
||||
esac
|
||||
fi
|
||||
|
||||
for src
|
||||
do
|
||||
# Protect names problematic for 'test' and other utilities.
|
||||
case $src in
|
||||
-* | [=\(\)!]) src=./$src;;
|
||||
esac
|
||||
|
||||
if test -n "$dir_arg"; then
|
||||
dst=$src
|
||||
dstdir=$dst
|
||||
test -d "$dstdir"
|
||||
dstdir_status=$?
|
||||
# Don't chown directories that already exist.
|
||||
if test $dstdir_status = 0; then
|
||||
chowncmd=""
|
||||
fi
|
||||
else
|
||||
|
||||
# Waiting for this to be detected by the "$cpprog $src $dsttmp" command
|
||||
# might cause directories to be created, which would be especially bad
|
||||
# if $src (and thus $dsttmp) contains '*'.
|
||||
if test ! -f "$src" && test ! -d "$src"; then
|
||||
echo "$0: $src does not exist." >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if test -z "$dst_arg"; then
|
||||
echo "$0: no destination specified." >&2
|
||||
exit 1
|
||||
fi
|
||||
dst=$dst_arg
|
||||
|
||||
# If destination is a directory, append the input filename.
|
||||
if test -d "$dst"; then
|
||||
if test "$is_target_a_directory" = never; then
|
||||
echo "$0: $dst_arg: Is a directory" >&2
|
||||
exit 1
|
||||
fi
|
||||
dstdir=$dst
|
||||
dstbase=`basename "$src"`
|
||||
case $dst in
|
||||
*/) dst=$dst$dstbase;;
|
||||
*) dst=$dst/$dstbase;;
|
||||
esac
|
||||
dstdir_status=0
|
||||
else
|
||||
dstdir=`dirname "$dst"`
|
||||
test -d "$dstdir"
|
||||
dstdir_status=$?
|
||||
fi
|
||||
fi
|
||||
|
||||
case $dstdir in
|
||||
*/) dstdirslash=$dstdir;;
|
||||
*) dstdirslash=$dstdir/;;
|
||||
esac
|
||||
|
||||
obsolete_mkdir_used=false
|
||||
|
||||
if test $dstdir_status != 0; then
|
||||
case $posix_mkdir in
|
||||
'')
|
||||
# With -d, create the new directory with the user-specified mode.
|
||||
# Otherwise, rely on $mkdir_umask.
|
||||
if test -n "$dir_arg"; then
|
||||
mkdir_mode=-m$mode
|
||||
else
|
||||
mkdir_mode=
|
||||
fi
|
||||
|
||||
posix_mkdir=false
|
||||
# The $RANDOM variable is not portable (e.g., dash). Use it
|
||||
# here however when possible just to lower collision chance.
|
||||
tmpdir=${TMPDIR-/tmp}/ins$RANDOM-$$
|
||||
|
||||
trap '
|
||||
ret=$?
|
||||
rmdir "$tmpdir/a/b" "$tmpdir/a" "$tmpdir" 2>/dev/null
|
||||
exit $ret
|
||||
' 0
|
||||
|
||||
# Because "mkdir -p" follows existing symlinks and we likely work
|
||||
# directly in world-writeable /tmp, make sure that the '$tmpdir'
|
||||
# directory is successfully created first before we actually test
|
||||
# 'mkdir -p'.
|
||||
if (umask $mkdir_umask &&
|
||||
$mkdirprog $mkdir_mode "$tmpdir" &&
|
||||
exec $mkdirprog $mkdir_mode -p -- "$tmpdir/a/b") >/dev/null 2>&1
|
||||
then
|
||||
dstfile=`basename $dst`
|
||||
if test -z "$dir_arg" || {
|
||||
# Check for POSIX incompatibilities with -m.
|
||||
# HP-UX 11.23 and IRIX 6.5 mkdir -m -p sets group- or
|
||||
# other-writable bit of parent directory when it shouldn't.
|
||||
# FreeBSD 6.1 mkdir -m -p sets mode of existing directory.
|
||||
test_tmpdir="$tmpdir/a"
|
||||
ls_ld_tmpdir=`ls -ld "$test_tmpdir"`
|
||||
case $ls_ld_tmpdir in
|
||||
d????-?r-*) different_mode=700;;
|
||||
d????-?--*) different_mode=755;;
|
||||
*) false;;
|
||||
esac &&
|
||||
$mkdirprog -m$different_mode -p -- "$test_tmpdir" && {
|
||||
ls_ld_tmpdir_1=`ls -ld "$test_tmpdir"`
|
||||
test "$ls_ld_tmpdir" = "$ls_ld_tmpdir_1"
|
||||
}
|
||||
}
|
||||
then posix_mkdir=:
|
||||
fi
|
||||
rmdir "$tmpdir/a/b" "$tmpdir/a" "$tmpdir"
|
||||
else
|
||||
dstfile=`basename $dst $transformbasename |
|
||||
sed $transformarg`$transformbasename
|
||||
# Remove any dirs left behind by ancient mkdir implementations.
|
||||
rmdir ./$mkdir_mode ./-p ./-- "$tmpdir" 2>/dev/null
|
||||
fi
|
||||
trap '' 0;;
|
||||
esac
|
||||
|
||||
# don't allow the sed command to completely eliminate the filename
|
||||
if
|
||||
$posix_mkdir && (
|
||||
umask $mkdir_umask &&
|
||||
$doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir"
|
||||
)
|
||||
then :
|
||||
else
|
||||
|
||||
if [ x"$dstfile" = x ]
|
||||
then
|
||||
dstfile=`basename $dst`
|
||||
else
|
||||
true
|
||||
fi
|
||||
# mkdir does not conform to POSIX,
|
||||
# or it failed possibly due to a race condition. Create the
|
||||
# directory the slow way, step by step, checking for races as we go.
|
||||
|
||||
# Make a temp file name in the proper directory.
|
||||
case $dstdir in
|
||||
/*) prefix='/';;
|
||||
[-=\(\)!]*) prefix='./';;
|
||||
*) prefix='';;
|
||||
esac
|
||||
|
||||
dsttmp=$dstdir/#inst.$$#
|
||||
oIFS=$IFS
|
||||
IFS=/
|
||||
set -f
|
||||
set fnord $dstdir
|
||||
shift
|
||||
set +f
|
||||
IFS=$oIFS
|
||||
|
||||
# Move or copy the file name to the temp name
|
||||
prefixes=
|
||||
|
||||
$doit $instcmd $src $dsttmp &&
|
||||
for d
|
||||
do
|
||||
test X"$d" = X && continue
|
||||
|
||||
trap "rm -f ${dsttmp}" 0 &&
|
||||
prefix=$prefix$d
|
||||
if test -d "$prefix"; then
|
||||
prefixes=
|
||||
else
|
||||
if $posix_mkdir; then
|
||||
(umask $mkdir_umask &&
|
||||
$doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir") && break
|
||||
# Don't fail if two instances are running concurrently.
|
||||
test -d "$prefix" || exit 1
|
||||
else
|
||||
case $prefix in
|
||||
*\'*) qprefix=`echo "$prefix" | sed "s/'/'\\\\\\\\''/g"`;;
|
||||
*) qprefix=$prefix;;
|
||||
esac
|
||||
prefixes="$prefixes '$qprefix'"
|
||||
fi
|
||||
fi
|
||||
prefix=$prefix/
|
||||
done
|
||||
|
||||
# and set any options; do chmod last to preserve setuid bits
|
||||
if test -n "$prefixes"; then
|
||||
# Don't fail if two instances are running concurrently.
|
||||
(umask $mkdir_umask &&
|
||||
eval "\$doit_exec \$mkdirprog $prefixes") ||
|
||||
test -d "$dstdir" || exit 1
|
||||
obsolete_mkdir_used=true
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
# If any of these fail, we abort the whole thing. If we want to
|
||||
# ignore errors from any of these, just make sure not to ignore
|
||||
# errors from the above "$doit $instcmd $src $dsttmp" command.
|
||||
if test -n "$dir_arg"; then
|
||||
{ test -z "$chowncmd" || $doit $chowncmd "$dst"; } &&
|
||||
{ test -z "$chgrpcmd" || $doit $chgrpcmd "$dst"; } &&
|
||||
{ test "$obsolete_mkdir_used$chowncmd$chgrpcmd" = false ||
|
||||
test -z "$chmodcmd" || $doit $chmodcmd $mode "$dst"; } || exit 1
|
||||
else
|
||||
|
||||
if [ x"$chowncmd" != x ]; then $doit $chowncmd $dsttmp; else true;fi &&
|
||||
if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dsttmp; else true;fi &&
|
||||
if [ x"$stripcmd" != x ]; then $doit $stripcmd $dsttmp; else true;fi &&
|
||||
if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dsttmp; else true;fi &&
|
||||
# Make a couple of temp file names in the proper directory.
|
||||
dsttmp=${dstdirslash}_inst.$$_
|
||||
rmtmp=${dstdirslash}_rm.$$_
|
||||
|
||||
# Now rename the file to the real destination.
|
||||
# Trap to clean up those temp files at exit.
|
||||
trap 'ret=$?; rm -f "$dsttmp" "$rmtmp" && exit $ret' 0
|
||||
|
||||
$doit $rmcmd -f $dstdir/$dstfile &&
|
||||
$doit $mvcmd $dsttmp $dstdir/$dstfile
|
||||
# Copy the file name to the temp name.
|
||||
(umask $cp_umask &&
|
||||
{ test -z "$stripcmd" || {
|
||||
# Create $dsttmp read-write so that cp doesn't create it read-only,
|
||||
# which would cause strip to fail.
|
||||
if test -z "$doit"; then
|
||||
: >"$dsttmp" # No need to fork-exec 'touch'.
|
||||
else
|
||||
$doit touch "$dsttmp"
|
||||
fi
|
||||
}
|
||||
} &&
|
||||
$doit_exec $cpprog "$src" "$dsttmp") &&
|
||||
|
||||
fi &&
|
||||
# and set any options; do chmod last to preserve setuid bits.
|
||||
#
|
||||
# If any of these fail, we abort the whole thing. If we want to
|
||||
# ignore errors from any of these, just make sure not to ignore
|
||||
# errors from the above "$doit $cpprog $src $dsttmp" command.
|
||||
#
|
||||
{ test -z "$chowncmd" || $doit $chowncmd "$dsttmp"; } &&
|
||||
{ test -z "$chgrpcmd" || $doit $chgrpcmd "$dsttmp"; } &&
|
||||
{ test -z "$stripcmd" || $doit $stripcmd "$dsttmp"; } &&
|
||||
{ test -z "$chmodcmd" || $doit $chmodcmd $mode "$dsttmp"; } &&
|
||||
|
||||
# If -C, don't bother to copy if it wouldn't change the file.
|
||||
if $copy_on_change &&
|
||||
old=`LC_ALL=C ls -dlL "$dst" 2>/dev/null` &&
|
||||
new=`LC_ALL=C ls -dlL "$dsttmp" 2>/dev/null` &&
|
||||
set -f &&
|
||||
set X $old && old=:$2:$4:$5:$6 &&
|
||||
set X $new && new=:$2:$4:$5:$6 &&
|
||||
set +f &&
|
||||
test "$old" = "$new" &&
|
||||
$cmpprog "$dst" "$dsttmp" >/dev/null 2>&1
|
||||
then
|
||||
rm -f "$dsttmp"
|
||||
else
|
||||
# If $backupsuffix is set, and the file being installed
|
||||
# already exists, attempt a backup. Don't worry if it fails,
|
||||
# e.g., if mv doesn't support -f.
|
||||
if test -n "$backupsuffix" && test -f "$dst"; then
|
||||
$doit $mvcmd -f "$dst" "$dst$backupsuffix" 2>/dev/null
|
||||
fi
|
||||
|
||||
exit 0
|
||||
# Rename the file to the real destination.
|
||||
$doit $mvcmd -f "$dsttmp" "$dst" 2>/dev/null ||
|
||||
|
||||
# The rename failed, perhaps because mv can't rename something else
|
||||
# to itself, or perhaps because mv is so ancient that it does not
|
||||
# support -f.
|
||||
{
|
||||
# Now remove or move aside any old file at destination location.
|
||||
# We try this two ways since rm can't unlink itself on some
|
||||
# systems and the destination file might be busy for other
|
||||
# reasons. In this case, the final cleanup might fail but the new
|
||||
# file should still install successfully.
|
||||
{
|
||||
test ! -f "$dst" ||
|
||||
$doit $rmcmd "$dst" 2>/dev/null ||
|
||||
{ $doit $mvcmd -f "$dst" "$rmtmp" 2>/dev/null &&
|
||||
{ $doit $rmcmd "$rmtmp" 2>/dev/null; :; }
|
||||
} ||
|
||||
{ echo "$0: cannot unlink or rename $dst" >&2
|
||||
(exit 1); exit 1
|
||||
}
|
||||
} &&
|
||||
|
||||
# Now rename the file to the real destination.
|
||||
$doit $mvcmd "$dsttmp" "$dst"
|
||||
}
|
||||
fi || exit 1
|
||||
|
||||
trap '' 0
|
||||
fi
|
||||
done
|
||||
|
||||
# Local variables:
|
||||
# eval: (add-hook 'before-save-hook 'time-stamp)
|
||||
# time-stamp-start: "scriptversion="
|
||||
# time-stamp-format: "%:y-%02m-%02d.%02H"
|
||||
# time-stamp-time-zone: "UTC0"
|
||||
# time-stamp-end: "; # UTC"
|
||||
# End:
|
||||
|
|
|
@ -0,0 +1,100 @@
|
|||
SHELL = /bin/sh
|
||||
|
||||
VPATH = @srcdir@
|
||||
srcdir = @srcdir@
|
||||
top_srcdir = @top_srcdir@
|
||||
top_builddir = ..
|
||||
|
||||
PACKAGE = @PACKAGE@
|
||||
VERSION = @VERSION@
|
||||
distdir = $(top_srcdir)/$(PACKAGE)-$(VERSION)
|
||||
|
||||
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@
|
||||
|
||||
INSTALL = @INSTALL@
|
||||
INSTALL_PROGRAM = @INSTALL_PROGRAM@
|
||||
INSTALL_DATA = @INSTALL_DATA@
|
||||
|
||||
RANLIB = @RANLIB@
|
||||
|
||||
CC = @CC@
|
||||
INCLUDES = -I.
|
||||
CPPFLAGS = @CPPFLAGS@
|
||||
CFLAGS = @CFLAGS@
|
||||
LDFLAGS = @LDFLAGS@
|
||||
LIBS = @LIBS@
|
||||
DEFS = @DEFS@
|
||||
|
||||
DEFS = @DEFS@
|
||||
CPPFLAGS = @CPPFLAGS@
|
||||
CFLAGS = @CFLAGS@
|
||||
LDFLAGS = @LDFLAGS@
|
||||
LIBS = @LIBS@
|
||||
GTK_LIBS = @GTK_LIBS@
|
||||
GTK_CFLAGS = @GTK_CFLAGS@
|
||||
|
||||
BINPROGS = @BINPROGS@
|
||||
|
||||
COMPILE = $(CC) -c $(DEFS) $(INCLUDES) $(CPPFLAGS) $(CFLAGS) $(GTK_CFLAGS)
|
||||
|
||||
@SET_MAKE@
|
||||
|
||||
LIBGTKSANE_OBJS = gtk3curve.o gtk3gamma.o gtk3ruler.o utils-gtk.o
|
||||
LIBGTKSANE_LTOBJS = gtk3curve.lo gtk3gamma.lo gtk3ruler.lo utils-gtk.lo
|
||||
|
||||
TARGETS = $(LIBGTKSANE_OBJS) $(GTK_LIBS)
|
||||
TARGETS = libgtksane.a
|
||||
|
||||
DISTFILES = Makefile.in gtk3curve.c gtk3curve.h \
|
||||
gtk3gamma.c gtk3gamma.h gtk3ruler.c \
|
||||
gtk3ruler.h utils-gtk.c utils-gtk.h
|
||||
# gtk3gamma.c gtk3gamma.h gtkpreview.c gtkpreview.h gimpruler.c \
|
||||
|
||||
|
||||
.PHONY: all check clean depend dist distclean install uninstall
|
||||
|
||||
.SUFFIXES:
|
||||
.SUFFIXES: .c .o
|
||||
.c.o:
|
||||
$(COMPILE) $<
|
||||
@test -f $@ || $(COMPILE) $<
|
||||
|
||||
all: $(TARGETS)
|
||||
|
||||
libgtksane.a: $(LIBGTKSANE_OBJS)
|
||||
ar r $@ $(LIBGTKSANE_OBJS)
|
||||
$(RANLIB) $@
|
||||
|
||||
install: all
|
||||
|
||||
uninstall:
|
||||
|
||||
check:
|
||||
|
||||
depend:
|
||||
makedepend -I. *.c
|
||||
|
||||
clean:
|
||||
rm -f *.out *.o *.lo *~ *.a *.bak $(TESTPROGRAMS)
|
||||
rm -rf .libs
|
||||
|
||||
distclean: clean
|
||||
rm -f Makefile
|
||||
|
||||
dist: $(DISTFILES)
|
||||
for file in $(DISTFILES); do \
|
||||
ln $$file $(distdir)/libgtk 2> /dev/null \
|
||||
|| cp -p -r $$file $(distdir)/libgtk ; \
|
||||
done
|
Plik diff jest za duży
Load Diff
|
@ -0,0 +1,174 @@
|
|||
/* Copyright (C) 2016 Benoit Touchette
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation version
|
||||
* 2.1 of the License.
|
||||
*
|
||||
* This library 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
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef __GTK3_CURVE__H__
|
||||
#define __GTK3_CURVE__H__
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
#define GTK3_TYPE_CURVE (gtk3_curve_get_type ())
|
||||
#define GTK3_CURVE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK3_TYPE_CURVE, Gtk3Curve))
|
||||
#define GTK3_IS_CURVE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK3_TYPE_CURVE))
|
||||
#define GTK3_CURVE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GTK3_TYPE_CURVE, Gtk3CurveClass))
|
||||
#define GTK3_IS_CURVE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK3_TYPE_CURVE))
|
||||
#define GTK3_CURVE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK3_TYPE_CURVE, Gtk3CurveClass))
|
||||
|
||||
#define GTK3_TYPE_CURVE_TYPE (gtk3_curve_type_get_type ())
|
||||
|
||||
typedef enum
|
||||
{
|
||||
GTK3_CURVE_GRID_MICRO,
|
||||
GTK3_CURVE_GRID_SMALL,
|
||||
GTK3_CURVE_GRID_MEDIUM,
|
||||
GTK3_CURVE_GRID_LARGE,
|
||||
GTK3_CURVE_GRID_XLARGE
|
||||
} Gtk3CurveGridSize;
|
||||
|
||||
|
||||
typedef enum
|
||||
{
|
||||
GTK3_CURVE_TYPE_LINEAR, /* linear interpolation */
|
||||
GTK3_CURVE_TYPE_SPLINE, /* spline interpolation */
|
||||
GTK3_CURVE_TYPE_FREE /* free form curve */
|
||||
} Gtk3CurveType;
|
||||
|
||||
typedef struct _Gtk3Curve Gtk3Curve;
|
||||
typedef struct _Gtk3CurveClass Gtk3CurveClass;
|
||||
typedef struct _Gtk3CurvePrivate Gtk3CurvePrivate;
|
||||
typedef struct _Gtk3CurveColor Gtk3CurveColor;
|
||||
typedef struct _Gtk3CurveData Gtk3CurveData;
|
||||
typedef struct _Gtk3CurveVector Gtk3CurveVector;
|
||||
typedef struct _Gtk3CurvePoint Gtk3CurvePoint;
|
||||
|
||||
struct _Gtk3CurvePoint
|
||||
{
|
||||
gint x;
|
||||
gint y;
|
||||
};
|
||||
|
||||
struct _Gtk3CurveColor
|
||||
{
|
||||
gfloat red;
|
||||
gfloat green;
|
||||
gfloat blue;
|
||||
gfloat alpha;
|
||||
};
|
||||
|
||||
struct _Gtk3CurveVector
|
||||
{
|
||||
gfloat x;
|
||||
gfloat y;
|
||||
};
|
||||
|
||||
struct _Gtk3CurveData
|
||||
{
|
||||
gchar *description;
|
||||
|
||||
Gtk3CurveType curve_type;
|
||||
|
||||
gint n_points;
|
||||
Gtk3CurvePoint *d_point;
|
||||
|
||||
gint n_cpoints;
|
||||
Gtk3CurveVector *d_cpoints;
|
||||
};
|
||||
|
||||
struct _Gtk3Curve
|
||||
{
|
||||
GtkWidget widget;
|
||||
Gtk3CurvePrivate *priv;
|
||||
};
|
||||
|
||||
struct _Gtk3CurveClass
|
||||
{
|
||||
GtkWidgetClass parent_class;
|
||||
|
||||
void (* curve_type_changed) (Gtk3Curve *curve);
|
||||
|
||||
/* Padding for future expansion */
|
||||
void (*_gtk_reserved1) (void);
|
||||
void (*_gtk_reserved2) (void);
|
||||
void (*_gtk_reserved3) (void);
|
||||
void (*_gtk_reserved4) (void);
|
||||
};
|
||||
|
||||
GType gtk3_curve_type_get_type (void);
|
||||
GType gtk3_curve_get_type (void) G_GNUC_CONST;
|
||||
GtkWidget* gtk3_curve_new (void);
|
||||
|
||||
void gtk3_curve_reset (GtkWidget *widget);
|
||||
void gtk3_curve_set_gamma (GtkWidget *widget,
|
||||
gfloat gamma_);
|
||||
void gtk3_curve_set_range (GtkWidget *widget,
|
||||
gfloat min_x,
|
||||
gfloat max_x,
|
||||
gfloat min_y,
|
||||
gfloat max_y);
|
||||
void gtk3_curve_get_vector (GtkWidget *widget,
|
||||
gint veclen,
|
||||
gfloat vector[]);
|
||||
void gtk3_curve_set_vector (GtkWidget *widget,
|
||||
gint veclen,
|
||||
gfloat vector[]);
|
||||
void gtk3_curve_set_curve_type (GtkWidget *widget,
|
||||
Gtk3CurveType type);
|
||||
|
||||
void gtk3_curve_set_color_background (GtkWidget *widget,
|
||||
Gtk3CurveColor color);
|
||||
void gtk3_curve_set_color_grid (GtkWidget *widget,
|
||||
Gtk3CurveColor color);
|
||||
void gtk3_curve_set_color_curve (GtkWidget *widget,
|
||||
Gtk3CurveColor color);
|
||||
void gtk3_curve_set_color_cpoint (GtkWidget *widget,
|
||||
Gtk3CurveColor color);
|
||||
|
||||
void gtk3_curve_set_color_background_rgba (GtkWidget *widget,
|
||||
gfloat r,
|
||||
gfloat g,
|
||||
gfloat b,
|
||||
gfloat a);
|
||||
void gtk3_curve_set_color_grid_rgba (GtkWidget *widget,
|
||||
gfloat r,
|
||||
gfloat g,
|
||||
gfloat b,
|
||||
gfloat a);
|
||||
void gtk3_curve_set_color_curve_rgba (GtkWidget *widget,
|
||||
gfloat r,
|
||||
gfloat g,
|
||||
gfloat b,
|
||||
gfloat a);
|
||||
void gtk3_curve_set_color_cpoint_rgba (GtkWidget *widget,
|
||||
gfloat r,
|
||||
gfloat g,
|
||||
gfloat b,
|
||||
gfloat a);
|
||||
|
||||
Gtk3CurveType gtk3_curve_get_curve_type (GtkWidget *widget);
|
||||
Gtk3CurveColor gtk3_curve_get_color_background (GtkWidget *widget);
|
||||
Gtk3CurveColor gtk3_curve_get_color_grid (GtkWidget *widget);
|
||||
Gtk3CurveColor gtk3_curve_get_color_curve (GtkWidget *widget);
|
||||
Gtk3CurveColor gtk3_curve_get_color_cpoint (GtkWidget *widget);
|
||||
|
||||
void gtk3_curve_set_use_theme_background (GtkWidget *widget,
|
||||
gboolean use);
|
||||
gboolean gtk3_curve_get_use_theme_background (GtkWidget *widget);
|
||||
void gtk3_curve_set_grid_size (GtkWidget *widget,
|
||||
Gtk3CurveGridSize size);
|
||||
Gtk3CurveGridSize gtk3_curve_get_grid_size (GtkWidget *widget);
|
||||
void gtk3_curve_save (Gtk3CurveData *data,
|
||||
gchar *filename);
|
||||
|
||||
#endif /* __GTK3_CURVE__H__ */
|
|
@ -0,0 +1,432 @@
|
|||
/* GTK - The GIMP Toolkit
|
||||
* Copyright (C) 1997 David Mosberger
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library 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
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Modified by the GTK+ Team and others 1997-2000. See the AUTHORS
|
||||
* file for a list of people on the GTK+ Team. See the ChangeLog
|
||||
* files for a list of changes. These files are distributed with
|
||||
* GTK+ at ftp://ftp.gtk.org/pub/gtk/.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <math.h>
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include "gtk3gamma.h"
|
||||
|
||||
|
||||
/* forward declarations: */
|
||||
static void gtk3_gamma_curve_destroy (GtkWidget *object);
|
||||
|
||||
static void curve_type_changed_callback (GtkWidget *w, gpointer data);
|
||||
static void button_realize_callback (GtkWidget *w);
|
||||
static void button_toggled_callback (GtkWidget *w, gpointer data);
|
||||
static void button_clicked_callback (GtkWidget *w, gpointer data);
|
||||
|
||||
/* XPM */
|
||||
static const char * spline_xpm[] = {
|
||||
"16 16 5 1",
|
||||
" c None",
|
||||
". c #000000",
|
||||
"+ c #824141",
|
||||
"@ c #FF0000",
|
||||
"# c #7F7F7F",
|
||||
" ..",
|
||||
" +.",
|
||||
" @ ",
|
||||
" @ ",
|
||||
" @ ",
|
||||
" #.# @ ",
|
||||
" ... @ ",
|
||||
" +.+ @ ",
|
||||
" @ @ @ ",
|
||||
" @ @ @ ",
|
||||
" @ @ @ ",
|
||||
" @ @.+ ",
|
||||
" @ ... ",
|
||||
" @ #.# ",
|
||||
".+ ",
|
||||
".. "};
|
||||
|
||||
/* XPM */
|
||||
static const char * lineart_xpm[] = {
|
||||
"16 16 4 1",
|
||||
" c None",
|
||||
". c #000000",
|
||||
"+ c #FF0000",
|
||||
"@ c #BC2D2D",
|
||||
" ..",
|
||||
" ++++++.",
|
||||
" ++ ",
|
||||
" .@ ",
|
||||
" ... ",
|
||||
" @. ",
|
||||
" + ",
|
||||
" + ",
|
||||
" + ",
|
||||
" + ",
|
||||
" + ",
|
||||
" + ",
|
||||
" + ",
|
||||
" + ",
|
||||
".@ ",
|
||||
".. "};
|
||||
|
||||
/* XPM */
|
||||
static const char * free_xpm[] = {
|
||||
"16 16 2 1",
|
||||
" c None",
|
||||
". c #FF0000",
|
||||
" ",
|
||||
" ",
|
||||
" . ",
|
||||
" . ",
|
||||
" . ",
|
||||
" . ",
|
||||
" . ",
|
||||
" . ",
|
||||
" . ",
|
||||
" . ",
|
||||
" . . .....",
|
||||
" . . ",
|
||||
" . . ",
|
||||
" . . ",
|
||||
" . . ",
|
||||
". "};
|
||||
|
||||
/* XPM */
|
||||
static const char * gamma_xpm[] = {
|
||||
"16 16 10 1",
|
||||
" c None",
|
||||
". c #000000",
|
||||
"+ c #5E5E5E",
|
||||
"@ c #8C8C8C",
|
||||
"# c #464646",
|
||||
"$ c #171717",
|
||||
"% c #BBBBBB",
|
||||
"& c #757575",
|
||||
"* c #A4A4A4",
|
||||
"= c #2F2F2F",
|
||||
" ",
|
||||
" ",
|
||||
" ",
|
||||
" .+ @.@ ",
|
||||
" #$% &$* ",
|
||||
" &@ ## ",
|
||||
" . .@ ",
|
||||
" # # ",
|
||||
" #$@ ",
|
||||
" *. ",
|
||||
" &+ ",
|
||||
" =. ",
|
||||
" .. ",
|
||||
" .= ",
|
||||
" ",
|
||||
" "};
|
||||
|
||||
/* XPM */
|
||||
static const char * reset_xpm[] = {
|
||||
"16 16 4 1",
|
||||
" c None",
|
||||
". c #000000",
|
||||
"+ c #824141",
|
||||
"@ c #FF0000",
|
||||
" ..",
|
||||
" +.",
|
||||
" @ ",
|
||||
" @ ",
|
||||
" @ ",
|
||||
" @ ",
|
||||
" @ ",
|
||||
" @ ",
|
||||
" @ ",
|
||||
" @ ",
|
||||
" @ ",
|
||||
" @ ",
|
||||
" @ ",
|
||||
" @ ",
|
||||
".+ ",
|
||||
".. "};
|
||||
|
||||
|
||||
static const gchar ** button_images[] = {
|
||||
spline_xpm,
|
||||
lineart_xpm,
|
||||
free_xpm,
|
||||
gamma_xpm,
|
||||
reset_xpm
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
LINEAR = 0,
|
||||
SPLINE,
|
||||
FREE,
|
||||
GAMMA,
|
||||
RESET,
|
||||
NUM_XPMS
|
||||
};
|
||||
|
||||
G_DEFINE_TYPE (Gtk3GammaCurve, gtk3_gamma_curve, GTK_TYPE_BOX)
|
||||
|
||||
static void
|
||||
gtk3_gamma_curve_class_init (Gtk3GammaCurveClass *class)
|
||||
{
|
||||
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (class);
|
||||
|
||||
widget_class->destroy = gtk3_gamma_curve_destroy;
|
||||
}
|
||||
|
||||
static void
|
||||
gtk3_gamma_curve_init (Gtk3GammaCurve *curve)
|
||||
{
|
||||
GtkWidget *image = NULL;
|
||||
GdkPixbuf *pixbuf = NULL;
|
||||
GtkWidget *vbox;
|
||||
int i;
|
||||
|
||||
gtk_orientable_set_orientation (GTK_ORIENTABLE (curve), GTK_ORIENTATION_VERTICAL);
|
||||
|
||||
curve->gamma = 1.0;
|
||||
|
||||
curve->table = gtk_grid_new ();
|
||||
gtk_grid_set_column_homogeneous (GTK_GRID (curve->table), FALSE);
|
||||
gtk_grid_set_row_homogeneous (GTK_GRID (curve->table), FALSE);
|
||||
|
||||
gtk_container_add (GTK_CONTAINER (curve), curve->table);
|
||||
|
||||
curve->curve = gtk3_curve_new ();
|
||||
g_signal_connect (curve->curve, "curve-type-changed",
|
||||
G_CALLBACK (curve_type_changed_callback), curve);
|
||||
gtk_grid_attach (GTK_GRID (curve->table), curve->curve, 0, 0 , 1, 1);
|
||||
|
||||
vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, /* spacing */ 3);
|
||||
gtk_box_set_homogeneous (GTK_BOX (vbox), FALSE);
|
||||
|
||||
gtk_grid_attach (GTK_GRID (curve->table), vbox, 1, 0 , 1, 1);
|
||||
|
||||
/* toggle buttons: */
|
||||
for (i = 0; i < 3; ++i)
|
||||
{
|
||||
curve->button[i] = gtk_toggle_button_new ();
|
||||
pixbuf = gdk_pixbuf_new_from_xpm_data(button_images[i]);
|
||||
image = gtk_image_new_from_pixbuf(pixbuf);
|
||||
|
||||
gtk_button_set_image (GTK_BUTTON (curve->button[i]), image);
|
||||
|
||||
g_object_set_data (G_OBJECT (curve->button[i]), "_Gtk3GammaCurveIndex",
|
||||
GINT_TO_POINTER (i));
|
||||
gtk_container_add (GTK_CONTAINER (vbox), curve->button[i]);
|
||||
g_signal_connect (G_OBJECT (curve->button[i]), "toggled",
|
||||
G_CALLBACK (button_toggled_callback), curve);
|
||||
gtk_widget_show (curve->button[i]);
|
||||
}
|
||||
|
||||
/* push buttons: */
|
||||
for (i = 3; i < 5; ++i)
|
||||
{
|
||||
curve->button[i] = gtk_button_new ();
|
||||
|
||||
pixbuf = gdk_pixbuf_new_from_xpm_data(button_images[i]);
|
||||
image = gtk_image_new_from_pixbuf(pixbuf);
|
||||
gtk_button_set_image (GTK_BUTTON (curve->button[i]), image);
|
||||
|
||||
g_object_set_data (G_OBJECT (curve->button[i]), "_Gtk3GammaCurveIndex",
|
||||
GINT_TO_POINTER (i));
|
||||
gtk_container_add (GTK_CONTAINER (vbox), curve->button[i]);
|
||||
g_signal_connect (G_OBJECT (curve->button[i]), "clicked",
|
||||
G_CALLBACK (button_clicked_callback), curve);
|
||||
gtk_widget_show (curve->button[i]);
|
||||
}
|
||||
|
||||
gtk_widget_show (vbox);
|
||||
gtk_widget_show (curve->table);
|
||||
gtk_widget_show (curve->curve);
|
||||
}
|
||||
|
||||
static void
|
||||
button_toggled_callback (GtkWidget *w, gpointer data)
|
||||
{
|
||||
Gtk3GammaCurve *c = data;
|
||||
Gtk3CurveType type;
|
||||
int active, i;
|
||||
|
||||
if (!gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (w)))
|
||||
return;
|
||||
|
||||
active = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (w), "_Gtk3GammaCurveIndex"));
|
||||
|
||||
for (i = 0; i < 3; ++i)
|
||||
if ((i != active) && gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (c->button[i])))
|
||||
break;
|
||||
|
||||
if (i < 3)
|
||||
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (c->button[i]), FALSE);
|
||||
|
||||
switch (active)
|
||||
{
|
||||
case 0: type = GTK3_CURVE_TYPE_SPLINE; break;
|
||||
case 1: type = GTK3_CURVE_TYPE_LINEAR; break;
|
||||
default: type = GTK3_CURVE_TYPE_FREE; break;
|
||||
}
|
||||
gtk3_curve_set_curve_type (c->curve, type);
|
||||
}
|
||||
|
||||
static void
|
||||
gamma_cancel_callback (GtkWidget *w, gpointer data)
|
||||
{
|
||||
Gtk3GammaCurve *c = data;
|
||||
|
||||
gtk_widget_destroy (c->gamma_dialog);
|
||||
c->gamma_dialog = NULL;
|
||||
}
|
||||
|
||||
static void
|
||||
gamma_response_callback (GtkWidget *w,
|
||||
gint response_id,
|
||||
gpointer data)
|
||||
{
|
||||
if (response_id == GTK_RESPONSE_OK)
|
||||
{
|
||||
Gtk3GammaCurve *c = data;
|
||||
const gchar *start;
|
||||
gchar *end;
|
||||
gfloat v;
|
||||
|
||||
start = gtk_entry_get_text (GTK_ENTRY (c->gamma_text));
|
||||
// GTK 4 => start = gtk_editable_get_text (GTK_EDITABLE (c->gamma_text));
|
||||
if (start)
|
||||
{
|
||||
v = g_strtod (start, &end);
|
||||
if (end > start && v > 0.0)
|
||||
c->gamma = v;
|
||||
}
|
||||
gtk3_curve_set_gamma (c->curve, c->gamma);
|
||||
}
|
||||
gamma_cancel_callback (w, data);
|
||||
}
|
||||
|
||||
static void
|
||||
button_clicked_callback (GtkWidget *w, gpointer data)
|
||||
{
|
||||
Gtk3GammaCurve *c = data;
|
||||
int active;
|
||||
|
||||
active = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (w), "_Gtk3GammaCurveIndex"));
|
||||
if (active == 3)
|
||||
{
|
||||
/* set gamma */
|
||||
if (c->gamma_dialog)
|
||||
return;
|
||||
else
|
||||
{
|
||||
GtkWidget *vbox, *hbox, *label;
|
||||
gchar buf[64];
|
||||
|
||||
c->gamma_dialog = gtk_dialog_new_with_buttons ("Gamma",
|
||||
GTK_WINDOW (w),
|
||||
GTK_DIALOG_DESTROY_WITH_PARENT,
|
||||
"Ok", GTK_RESPONSE_OK,
|
||||
"Cancel", GTK_RESPONSE_CANCEL,
|
||||
NULL);
|
||||
|
||||
g_object_add_weak_pointer (G_OBJECT (c->gamma_dialog),
|
||||
(gpointer *)&c->gamma_dialog);
|
||||
|
||||
vbox =gtk_dialog_get_content_area (GTK_DIALOG (c->gamma_dialog));
|
||||
|
||||
hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, /* spacing */ 0);
|
||||
gtk_box_set_homogeneous (GTK_BOX (hbox), FALSE);
|
||||
|
||||
gtk_box_pack_start (GTK_BOX (vbox), hbox, TRUE, TRUE, 2);
|
||||
// GTK4 => gtk_box_append (GTK_BOX (vbox), hbox);
|
||||
gtk_widget_show (hbox);
|
||||
|
||||
label = gtk_label_new_with_mnemonic ("_Gamma value");
|
||||
gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 2);
|
||||
// GTK4 => gtk_box_append (GTK_BOX (hbox), label);
|
||||
gtk_widget_show (label);
|
||||
|
||||
sprintf (buf, "%g", c->gamma);
|
||||
c->gamma_text = gtk_entry_new ();
|
||||
gtk_label_set_mnemonic_widget (GTK_LABEL (label), c->gamma_text);
|
||||
gtk_entry_set_text (GTK_ENTRY (c->gamma_text), buf);
|
||||
// GTK4 => gtk_editable_set_text (GTK_EDITABLE (c->gamma_text), buf);
|
||||
gtk_box_pack_start (GTK_BOX (hbox), c->gamma_text, TRUE, TRUE, 2);
|
||||
// GTK4 => gtk_box_append (GTK_BOX (hbox), c->gamma_text);
|
||||
gtk_widget_show (c->gamma_text);
|
||||
|
||||
/* fill in action area: */
|
||||
g_signal_connect (c->gamma_dialog,
|
||||
"response",
|
||||
G_CALLBACK (gamma_response_callback),
|
||||
c);
|
||||
gtk_widget_show (c->gamma_dialog);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/* reset */
|
||||
gtk3_curve_reset (c->curve);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
curve_type_changed_callback (GtkWidget *w, gpointer data)
|
||||
{
|
||||
Gtk3GammaCurve *c = data;
|
||||
Gtk3CurveType new_type;
|
||||
int active;
|
||||
|
||||
new_type = gtk3_curve_get_curve_type (w);
|
||||
switch (new_type)
|
||||
{
|
||||
case GTK3_CURVE_TYPE_SPLINE: active = 0; break;
|
||||
case GTK3_CURVE_TYPE_LINEAR: active = 1; break;
|
||||
default: active = 2; break;
|
||||
}
|
||||
if (!gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (c->button[active])))
|
||||
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (c->button[active]), TRUE);
|
||||
}
|
||||
|
||||
GtkWidget*
|
||||
gtk3_gamma_curve_new (void)
|
||||
{
|
||||
return g_object_new (GTK3_TYPE_GAMMA_CURVE, NULL);
|
||||
|
||||
}
|
||||
|
||||
static void
|
||||
gtk3_gamma_curve_destroy (GtkWidget *object)
|
||||
{
|
||||
Gtk3GammaCurve *c = GTK3_GAMMA_CURVE (object);
|
||||
|
||||
if (c->gamma_dialog)
|
||||
gtk_widget_destroy (c->gamma_dialog);
|
||||
|
||||
// G_OBJECT_CLASS (gtk3_gamma_curve_parent_class)->destroy (object);
|
||||
}
|
||||
|
|
@ -0,0 +1,74 @@
|
|||
/* GTK - The GIMP Toolkit
|
||||
* Copyright (C) 1997 David Mosberger
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library 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
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Modified by the GTK+ Team and others 1997-2000. See the AUTHORS
|
||||
* file for a list of people on the GTK+ Team. See the ChangeLog
|
||||
* files for a list of changes. These files are distributed with
|
||||
* GTK+ at ftp://ftp.gtk.org/pub/gtk/.
|
||||
*/
|
||||
|
||||
#ifndef __GTK3_GAMMA_CURVE_H__
|
||||
#define __GTK3_GAMMA_CURVE_H__
|
||||
|
||||
#include "gtk3curve.h"
|
||||
|
||||
|
||||
#define GTK3_TYPE_GAMMA_CURVE (gtk3_gamma_curve_get_type ())
|
||||
#define GTK3_GAMMA_CURVE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK3_TYPE_GAMMA_CURVE, Gtk3GammaCurve))
|
||||
#define GTK3_GAMMA_CURVE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GTK3_TYPE_GAMMA_CURVE, Gtk3GammaCurveClass))
|
||||
#define GTK3_IS_GAMMA_CURVE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK3_TYPE_GAMMA_CURVE))
|
||||
#define GTK3_IS_GAMMA_CURVE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK3_TYPE_GAMMA_CURVE))
|
||||
#define GTK3_GAMMA_CURVE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK3_TYPE_GAMMA_CURVE, Gtk3GammaCurveClass))
|
||||
|
||||
typedef struct _Gtk3GammaCurve Gtk3GammaCurve;
|
||||
typedef struct _Gtk3GammaCurveClass Gtk3GammaCurveClass;
|
||||
|
||||
|
||||
struct _Gtk3GammaCurve
|
||||
{
|
||||
GtkBox vbox;
|
||||
|
||||
GtkWidget *table;
|
||||
GtkWidget *curve;
|
||||
GtkWidget *button[5]; /* spline, linear, free, gamma, reset */
|
||||
|
||||
gfloat gamma;
|
||||
GtkWidget *gamma_dialog;
|
||||
GtkWidget *gamma_text;
|
||||
};
|
||||
|
||||
struct _Gtk3GammaCurveClass
|
||||
{
|
||||
GtkBoxClass parent_class;
|
||||
|
||||
/* Padding for future expansion */
|
||||
void (*_gtk_reserved1) (void);
|
||||
void (*_gtk_reserved2) (void);
|
||||
void (*_gtk_reserved3) (void);
|
||||
void (*_gtk_reserved4) (void);
|
||||
};
|
||||
|
||||
|
||||
GType gtk3_gamma_curve_get_type (void) G_GNUC_CONST;
|
||||
GtkWidget* gtk3_gamma_curve_new (void);
|
||||
|
||||
|
||||
#endif /* __GTK3_GAMMA_CURVE_H__ */
|
||||
|
Plik diff jest za duży
Load Diff
|
@ -0,0 +1,78 @@
|
|||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
#ifndef __GTK3_RULER_H__
|
||||
#define __GTK3_RULER_H__
|
||||
|
||||
/*
|
||||
* Customized ruler class for inkscape
|
||||
*
|
||||
* Authors:
|
||||
* Lauris Kaplinski <lauris@kaplinski.com>
|
||||
* Frank Felfe <innerspace@iname.com>
|
||||
*
|
||||
* Copyright (C) 1999-2002 authors
|
||||
*
|
||||
* Released under GNU GPL v2+, read the file 'COPYING' for more information.
|
||||
*/
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
#include <glib.h>
|
||||
|
||||
#define GTK3_TYPE_RULER (gtk3_ruler_get_type ())
|
||||
#define GTK3_RULER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK3_TYPE_RULER, Gtk3Ruler))
|
||||
#define GTK3_RULER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GTK3_TYPE_RULER, Gtk3RulerClass))
|
||||
#define GTK3_IS_RULER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK3_TYPE_RULER))
|
||||
#define GTK3_IS_RULER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK3_TYPE_RULER))
|
||||
#define GTK3_RULER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK3_TYPE_RULER, Gtk3RulerClass))
|
||||
|
||||
typedef struct _Gtk3Ruler Gtk3Ruler;
|
||||
typedef struct _Gtk3RulerClass Gtk3RulerClass;
|
||||
typedef struct _Gtk3RulerPrivate Gtk3RulerPrivate;
|
||||
|
||||
struct _Gtk3Ruler
|
||||
{
|
||||
GtkWidget parent_instance;
|
||||
Gtk3RulerPrivate *priv;
|
||||
};
|
||||
|
||||
struct _Gtk3RulerClass
|
||||
{
|
||||
GtkWidgetClass parent_class;
|
||||
};
|
||||
|
||||
typedef enum
|
||||
{
|
||||
GTK3_RULER_METRIC_DECIMAL = 0,
|
||||
GTK3_RULER_METRIC_INCHES,
|
||||
#if 0
|
||||
GTK3_RULER_METRIC_FEET,
|
||||
GTK3_RULER_METRIC_YARDS,
|
||||
#endif
|
||||
} Gtk3RulerMetricUnit;
|
||||
|
||||
GType gtk3_ruler_get_type (void) G_GNUC_CONST;
|
||||
|
||||
GtkWidget* gtk3_ruler_new (GtkOrientation orientation);
|
||||
|
||||
void gtk3_ruler_add_track_widget (Gtk3Ruler *ruler,
|
||||
GtkWidget *widget);
|
||||
void gtk3_ruler_remove_track_widget (Gtk3Ruler *ruler,
|
||||
GtkWidget *widget);
|
||||
|
||||
void gtk3_ruler_set_unit (Gtk3Ruler *ruler,
|
||||
Gtk3RulerMetricUnit unit);
|
||||
Gtk3RulerMetricUnit gtk3_ruler_get_unit (Gtk3Ruler *ruler);
|
||||
void gtk3_ruler_set_position (Gtk3Ruler *ruler,
|
||||
gdouble set_position);
|
||||
gdouble gtk3_ruler_get_position (Gtk3Ruler *ruler);
|
||||
void gtk3_ruler_set_range (Gtk3Ruler *ruler,
|
||||
gdouble lower,
|
||||
gdouble upper,
|
||||
gdouble max_size);
|
||||
void gtk3_ruler_get_range (Gtk3Ruler *ruler,
|
||||
gdouble *lower,
|
||||
gdouble *upper,
|
||||
gdouble *max_size);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __GTK3_RULER_H__ */
|
|
@ -0,0 +1,36 @@
|
|||
/* reloaded - Linux VeeJay
|
||||
* (C) 2002-2019 Niels Elburg <nwelburg@gmail.com>
|
||||
* (C) 2019 Jerome Blanchi <d.j.a.y@free.fr>
|
||||
|
||||
*
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
Utils for gtk
|
||||
*/
|
||||
|
||||
#include "utils-gtk.h"
|
||||
|
||||
void vj_gtk_context_get_color (GtkStyleContext *context, const gchar *property, GtkStateFlags state, GdkRGBA *color)
|
||||
{
|
||||
GdkRGBA *c;
|
||||
gtk_style_context_save (context);
|
||||
gtk_style_context_get (context, state, property, &c, NULL);
|
||||
*color = *c;
|
||||
gdk_rgba_free (c);
|
||||
gtk_style_context_restore (context);
|
||||
}
|
|
@ -0,0 +1,28 @@
|
|||
/* reloaded - Linux VeeJay
|
||||
* (C) 2002-2019 Niels Elburg <nwelburg@gmail.com>
|
||||
* (C) 2019 Jerome Blanchi <d.j.a.y@free.fr>
|
||||
*
|
||||
*
|
||||
* 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 VJUTILSGTK_H
|
||||
#define VJUTILSGTK_H
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
void vj_gtk_context_get_color (GtkStyleContext *context, const gchar *property, GtkStateFlags state, GdkRGBA *color);
|
||||
|
||||
#endif
|
|
@ -163,7 +163,7 @@ sanei_thread_begin( int (*func)(void *args), void* args )
|
|||
DBG( 1, "_beginthread() failed\n" );
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
DBG( 2, "_beginthread() created thread %d\n", pid );
|
||||
return pid;
|
||||
}
|
||||
|
@ -249,7 +249,7 @@ restore_sigpipe( void )
|
|||
sigemptyset( &act.sa_mask );
|
||||
act.sa_flags = 0;
|
||||
act.sa_handler = SIG_DFL;
|
||||
|
||||
|
||||
DBG( 2, "restoring SIGPIPE to SIG_DFL\n" );
|
||||
sigaction( SIGPIPE, &act, NULL );
|
||||
}
|
||||
|
@ -327,7 +327,7 @@ sanei_thread_begin( int (func)(void *args), void* args )
|
|||
|
||||
/* run in child context... */
|
||||
int status = func( args );
|
||||
|
||||
|
||||
/* don't use exit() since that would run the atexit() handlers */
|
||||
_exit( status );
|
||||
}
|
||||
|
@ -375,7 +375,7 @@ sanei_thread_waitpid( int pid, int *status )
|
|||
DBG(2, "* result = %d (%p)\n", stat, (void*)status );
|
||||
result = pid;
|
||||
}
|
||||
/* call detach in any case to make sure that the thread resources
|
||||
/* call detach in any case to make sure that the thread resources
|
||||
* will be freed, when the thread has terminated
|
||||
*/
|
||||
DBG(2, "* detaching thread(%d)\n", pid );
|
||||
|
|
|
@ -67,7 +67,7 @@ sanei_w_space (Wire * w, size_t howmuch)
|
|||
|
||||
if (w->status != 0)
|
||||
{
|
||||
DBG (1, "sanei_w_space: wire is in invalid state %d\n",
|
||||
DBG (1, "sanei_w_space: wire is in invalid state %d\n",
|
||||
w->status);
|
||||
return;
|
||||
}
|
||||
|
@ -81,7 +81,7 @@ sanei_w_space (Wire * w, size_t howmuch)
|
|||
case WIRE_ENCODE:
|
||||
nbytes = w->buffer.curr - w->buffer.start;
|
||||
w->buffer.curr = w->buffer.start;
|
||||
DBG (4, "sanei_w_space: ENCODE: sending %lu bytes\n",
|
||||
DBG (4, "sanei_w_space: ENCODE: sending %lu bytes\n",
|
||||
(u_long) nbytes);
|
||||
while (nbytes > 0)
|
||||
{
|
||||
|
@ -184,7 +184,7 @@ sanei_w_array (Wire * w, SANE_Word * len_ptr, void **v,
|
|||
else
|
||||
DBG (1, "sanei_w_array: FREE: tried to free array but *len_ptr or *v "
|
||||
"was NULL\n");
|
||||
|
||||
|
||||
DBG (4, "sanei_w_array: FREE: done\n");
|
||||
return;
|
||||
}
|
||||
|
@ -200,14 +200,14 @@ sanei_w_array (Wire * w, SANE_Word * len_ptr, void **v,
|
|||
return;
|
||||
}
|
||||
DBG (4, "sanei_w_array: array has %d elements\n", len);
|
||||
|
||||
|
||||
if (w->direction == WIRE_DECODE)
|
||||
{
|
||||
*len_ptr = len;
|
||||
if (len)
|
||||
{
|
||||
if (((unsigned int) len) > MAX_MEM
|
||||
|| ((unsigned int) len * element_size) > MAX_MEM
|
||||
if (((unsigned int) len) > MAX_MEM
|
||||
|| ((unsigned int) len * element_size) > MAX_MEM
|
||||
|| (w->allocated_memory + len * element_size) > MAX_MEM)
|
||||
{
|
||||
DBG (0, "sanei_w_array: DECODE: maximum amount of allocated memory "
|
||||
|
@ -579,8 +579,8 @@ flush (Wire * w)
|
|||
void
|
||||
sanei_w_set_dir (Wire * w, WireDirection dir)
|
||||
{
|
||||
DBG (3, "sanei_w_set_dir: wire %d, old direction WIRE_%s\n", w->io.fd,
|
||||
w->direction == WIRE_ENCODE ? "ENCODE" :
|
||||
DBG (3, "sanei_w_set_dir: wire %d, old direction WIRE_%s\n", w->io.fd,
|
||||
w->direction == WIRE_ENCODE ? "ENCODE" :
|
||||
(w->direction == WIRE_DECODE ? "DECODE" : "FREE"));
|
||||
if (w->direction == WIRE_DECODE && w->buffer.curr != w->buffer.end)
|
||||
DBG (1, "sanei_w_set_dir: WARNING: will delete %lu bytes from buffer\n",
|
||||
|
@ -589,8 +589,8 @@ sanei_w_set_dir (Wire * w, WireDirection dir)
|
|||
w->direction = dir;
|
||||
DBG (4, "sanei_w_set_dir: direction changed\n");
|
||||
flush (w);
|
||||
DBG (3, "sanei_w_set_dir: wire %d, new direction WIRE_%s\n", w->io.fd,
|
||||
dir == WIRE_ENCODE ? "ENCODE" :
|
||||
DBG (3, "sanei_w_set_dir: wire %d, new direction WIRE_%s\n", w->io.fd,
|
||||
dir == WIRE_ENCODE ? "ENCODE" :
|
||||
(dir == WIRE_DECODE ? "DECODE" : "FREE"));
|
||||
}
|
||||
|
||||
|
@ -654,13 +654,13 @@ void
|
|||
sanei_w_init (Wire * w, void (*codec_init_func) (Wire *))
|
||||
{
|
||||
DBG_INIT ();
|
||||
|
||||
|
||||
DBG (3, "sanei_w_init: initializing\n");
|
||||
w->status = 0;
|
||||
w->direction = WIRE_ENCODE;
|
||||
w->buffer.size = 8192;
|
||||
w->buffer.start = malloc (w->buffer.size);
|
||||
|
||||
|
||||
if (w->buffer.start == 0)
|
||||
{
|
||||
/* Malloc failed, so return an error. */
|
||||
|
|
|
@ -33,6 +33,7 @@ INSTALL_DATA = @INSTALL_DATA@
|
|||
|
||||
CC = @CC@
|
||||
INCLUDES = -I. -I$(srcdir) -I$(top_builddir)/include -I$(top_srcdir)/include \
|
||||
-I$(top_builddir)/libgtksane -I$(src_builddir)/libgtksane \
|
||||
@INCLUDES@ @GTK_CFLAGS@ @GIMP_CFLAGS@
|
||||
DEFS = @DEFS@
|
||||
CPPFLAGS = @CPPFLAGS@
|
||||
|
@ -51,6 +52,7 @@ LINK = $(CC) $(LDFLAGS) -o $@
|
|||
@SET_MAKE@
|
||||
|
||||
PROGRAMS = $(BINPROGS)
|
||||
LIBGTKSANE = ../libgtk/libgtksane.a
|
||||
LIBSANEI = ../sanei/libsanei.a
|
||||
|
||||
XSCANIMAGE_OBJS = xscanimage.o progress.o preview.o preferences.o gtkglue.o
|
||||
|
@ -58,8 +60,8 @@ XCAM_OBJS = xcam.o preferences.o gtkglue.o
|
|||
SCANADF_OBJS = scanadf.o
|
||||
|
||||
DISTFILES = Makefile.in gtkglue.c gtkglue.h preferences.c preferences.h \
|
||||
preview.c preview.h progress.c progress.h sane-style.rc xcam.c \
|
||||
xscanimage-gimp-1_0-compat.h xscanimage.c scanadf.c font_6x11.h
|
||||
preview.c preview.h progress.c progress.h sane-style.rc xcam.c \
|
||||
xscanimage-gimp-1_0-compat.h xscanimage.c scanadf.c font_6x11.h
|
||||
|
||||
.PHONY: all clean depend dist distclean install uninstall
|
||||
|
||||
|
@ -91,13 +93,13 @@ uninstall:
|
|||
done
|
||||
rm -f $(sanedatadir)/sane-style.rc
|
||||
|
||||
xscanimage: $(XSCANIMAGE_OBJS) $(LIBSANEI)
|
||||
xscanimage: $(XSCANIMAGE_OBJS) $(LIBSANEI) $(LIBGTKSANE)
|
||||
$(LINK) $(XSCANIMAGE_OBJS) $(LIBSANEI) \
|
||||
$(GIMP_LIBS) $(GTK_LIBS) $(LIBS)
|
||||
$(LIBGTKSANE) $(GIMP_LIBS) $(GTK_LIBS) $(LIBS)
|
||||
|
||||
xcam: $(XCAM_OBJS) $(LIBSANEI)
|
||||
xcam: $(XCAM_OBJS) $(LIBSANEI) $(LIBGTKSANE)
|
||||
$(LINK) $(XCAM_OBJS) $(LIBSANEI) \
|
||||
$(GTK_LIBS) $(LIBS)
|
||||
$(LIBGTKSANE) $(GTK_LIBS) $(LIBS)
|
||||
|
||||
scanadf: $(SCANADF_OBJS)
|
||||
$(LINK) $(SCANADF_OBJS) $(LIBS)
|
||||
|
|
422
src/gtkglue.c
422
src/gtkglue.c
|
@ -36,7 +36,8 @@
|
|||
#include <sys/stat.h>
|
||||
|
||||
#include "gtkglue.h"
|
||||
|
||||
#include "../libgtk/gtk3curve.h"
|
||||
#include "../libgtk/gtk3gamma.h"
|
||||
#include "preferences.h"
|
||||
#include <sane/sane.h>
|
||||
#include <sane/saneopts.h>
|
||||
|
@ -85,16 +86,29 @@ unit_string (SANE_Unit unit)
|
|||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
gsg_widget_placement(GtkWidget *w,
|
||||
GtkAlign halign,
|
||||
GtkAlign valign,
|
||||
int top,
|
||||
int start,
|
||||
int end,
|
||||
int bottom)
|
||||
{
|
||||
gtk_widget_set_halign(w, halign);
|
||||
gtk_widget_set_valign(w, valign);
|
||||
gtk_widget_set_margin_top (w, top);
|
||||
gtk_widget_set_margin_start (w, start);
|
||||
gtk_widget_set_margin_end (w, end);
|
||||
gtk_widget_set_margin_bottom (w, bottom);
|
||||
}
|
||||
|
||||
static void
|
||||
set_tooltip (GtkTooltips * tooltips, GtkWidget * widget, const char *desc)
|
||||
set_tooltip (GtkWidget * widget, const char *desc)
|
||||
{
|
||||
if (desc && desc[0])
|
||||
#ifdef HAVE_GTK_TOOLTIPS_SET_TIPS
|
||||
/* pre 0.99.4: */
|
||||
gtk_tooltips_set_tips (tooltips, widget, (char *) desc);
|
||||
#else
|
||||
gtk_tooltips_set_tip (tooltips, widget, desc, 0);
|
||||
#endif
|
||||
gtk_widget_set_tooltip_text (widget, desc);
|
||||
|
||||
}
|
||||
|
||||
int
|
||||
|
@ -247,12 +261,13 @@ gsg_message (gchar * title, gchar * message)
|
|||
}
|
||||
gsg_message_dialog_active = 1;
|
||||
message_dialog = gtk_window_new (GTK_WINDOW_TOPLEVEL);
|
||||
gtk_window_position (GTK_WINDOW (message_dialog), GTK_WIN_POS_MOUSE);
|
||||
gtk_window_set_position (GTK_WINDOW (message_dialog), GTK_WIN_POS_MOUSE);
|
||||
gtk_window_set_title (GTK_WINDOW (message_dialog), title);
|
||||
|
||||
/* create the main vbox */
|
||||
main_vbox = gtk_vbox_new (TRUE, 5);
|
||||
gtk_container_border_width (GTK_CONTAINER (main_vbox), 5);
|
||||
main_vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 5);
|
||||
gtk_box_set_homogeneous (GTK_BOX (main_vbox), TRUE);
|
||||
gtk_container_set_border_width (GTK_CONTAINER (main_vbox), 5);
|
||||
gtk_widget_show (main_vbox);
|
||||
|
||||
gtk_container_add (GTK_CONTAINER (message_dialog), main_vbox);
|
||||
|
@ -264,8 +279,8 @@ gsg_message (gchar * title, gchar * message)
|
|||
|
||||
/* the confirmation button */
|
||||
button = gtk_button_new_with_label ("OK");
|
||||
gtk_signal_connect (GTK_OBJECT (button), "clicked",
|
||||
(GtkSignalFunc) gsg_close_dialog_callback,
|
||||
g_signal_connect (G_OBJECT (button), "clicked",
|
||||
G_CALLBACK (gsg_close_dialog_callback),
|
||||
message_dialog);
|
||||
gtk_container_add (GTK_CONTAINER (main_vbox), button);
|
||||
|
||||
|
@ -285,57 +300,38 @@ gsg_warning (gchar * warning)
|
|||
gsg_message ("Warning", warning);
|
||||
}
|
||||
|
||||
static void
|
||||
get_filename_button_clicked (GtkWidget * w, gpointer data)
|
||||
{
|
||||
int *clicked = data;
|
||||
*clicked = 1;
|
||||
}
|
||||
|
||||
int
|
||||
gsg_get_filename (const char *label, const char *default_name,
|
||||
size_t max_len, char *filename)
|
||||
{
|
||||
int cancel = 0, ok = 0;
|
||||
int cancel = 0;
|
||||
GtkWidget *filesel;
|
||||
|
||||
filesel = gtk_file_selection_new ((char *) label);
|
||||
filesel = gtk_file_chooser_dialog_new ((char*) label, NULL, GTK_FILE_CHOOSER_ACTION_SAVE,
|
||||
"Ok", GTK_RESPONSE_ACCEPT,
|
||||
"Cancel", GTK_RESPONSE_CANCEL,
|
||||
NULL);
|
||||
|
||||
gtk_window_set_modal (GTK_WINDOW (filesel), TRUE);
|
||||
|
||||
gtk_signal_connect (GTK_OBJECT
|
||||
(GTK_FILE_SELECTION (filesel)->cancel_button),
|
||||
"clicked", (GtkSignalFunc) get_filename_button_clicked,
|
||||
&cancel);
|
||||
gtk_signal_connect (GTK_OBJECT (GTK_FILE_SELECTION (filesel)->ok_button),
|
||||
"clicked", (GtkSignalFunc) get_filename_button_clicked,
|
||||
&ok);
|
||||
if (default_name)
|
||||
gtk_file_selection_set_filename (GTK_FILE_SELECTION (filesel),
|
||||
(char *) default_name);
|
||||
gtk_file_chooser_set_filename (GTK_FILE_CHOOSER (filesel),
|
||||
(char *) default_name);
|
||||
|
||||
gtk_widget_show (filesel);
|
||||
|
||||
while (!cancel && !ok)
|
||||
{
|
||||
if (!gtk_events_pending ())
|
||||
usleep (100000);
|
||||
gtk_main_iteration ();
|
||||
}
|
||||
|
||||
if (ok)
|
||||
if (gtk_dialog_run (GTK_DIALOG (filesel)) == GTK_RESPONSE_ACCEPT)
|
||||
{
|
||||
size_t len, cwd_len;
|
||||
char *cwd;
|
||||
|
||||
strncpy (filename,
|
||||
gtk_file_selection_get_filename (GTK_FILE_SELECTION (filesel)),
|
||||
gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (filesel)),
|
||||
max_len - 1);
|
||||
filename[max_len - 1] = '\0';
|
||||
|
||||
len = strlen (filename);
|
||||
cwd = alloca (len + 2);
|
||||
getcwd (cwd, len + 1);
|
||||
if (getcwd (cwd, len + 1) == NULL)
|
||||
return -1;
|
||||
cwd_len = strlen (cwd);
|
||||
cwd[cwd_len++] = '/';
|
||||
cwd[cwd_len] = '\0';
|
||||
|
@ -350,17 +346,23 @@ static gint
|
|||
autobutton_update (GtkWidget * widget, GSGDialogElement * elem)
|
||||
{
|
||||
GSGDialog *dialog = elem->dialog;
|
||||
GtkWidget *scale;
|
||||
int opt_num = elem - dialog->element;
|
||||
const SANE_Option_Descriptor *opt;
|
||||
SANE_Status status;
|
||||
SANE_Word val;
|
||||
char buf[256];
|
||||
|
||||
scale = g_object_get_data(G_OBJECT(widget), "scale");
|
||||
opt = sane_get_option_descriptor (dialog->dev, opt_num);
|
||||
if (GTK_TOGGLE_BUTTON (widget)->active)
|
||||
set_option (dialog, opt_num, 0, SANE_ACTION_SET_AUTO);
|
||||
if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget)))
|
||||
{
|
||||
set_option (dialog, opt_num, 0, SANE_ACTION_SET_AUTO);
|
||||
gtk_widget_set_sensitive(GTK_WIDGET (scale), FALSE);
|
||||
}
|
||||
else
|
||||
{
|
||||
gtk_widget_set_sensitive(GTK_WIDGET (scale), TRUE);
|
||||
status = sane_control_option (dialog->dev, opt_num,
|
||||
SANE_ACTION_GET_VALUE, &val, 0);
|
||||
if (status != SANE_STATUS_GOOD)
|
||||
|
@ -372,29 +374,27 @@ autobutton_update (GtkWidget * widget, GSGDialogElement * elem)
|
|||
}
|
||||
set_option (dialog, opt_num, &val, SANE_ACTION_SET_VALUE);
|
||||
}
|
||||
g_signal_emit_by_name (G_OBJECT (elem->data), "value_changed");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static void
|
||||
autobutton_new (GtkWidget * parent, GSGDialogElement * elem,
|
||||
GtkWidget * label, GtkTooltips * tooltips)
|
||||
GtkWidget * label)
|
||||
{
|
||||
GtkWidget *button, *alignment;
|
||||
GtkWidget *button;
|
||||
|
||||
button = gtk_check_button_new ();
|
||||
gtk_container_border_width (GTK_CONTAINER (button), 0);
|
||||
gtk_widget_set_usize (button, 20, 20);
|
||||
gtk_signal_connect (GTK_OBJECT (button), "toggled",
|
||||
(GtkSignalFunc) autobutton_update, elem);
|
||||
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);
|
||||
g_object_set_data(G_OBJECT(button), "scale", label);
|
||||
gtk_container_set_border_width (GTK_CONTAINER (button), 0);
|
||||
gtk_widget_set_size_request (button, 20, 20);
|
||||
g_signal_connect (G_OBJECT (button), "toggled",
|
||||
G_CALLBACK (autobutton_update), elem);
|
||||
set_tooltip (button, "Turns on automatic mode.");
|
||||
|
||||
gtk_box_pack_end (GTK_BOX (parent), label, FALSE, FALSE, 0);
|
||||
gtk_box_pack_end (GTK_BOX (parent), alignment, FALSE, FALSE, 2);
|
||||
gtk_box_pack_end (GTK_BOX (parent), button, FALSE, FALSE, 2);
|
||||
|
||||
gtk_widget_show (alignment);
|
||||
gtk_widget_show (button);
|
||||
}
|
||||
|
||||
|
@ -403,11 +403,9 @@ button_update (GtkWidget * widget, GSGDialogElement * elem)
|
|||
{
|
||||
GSGDialog *dialog = elem->dialog;
|
||||
int opt_num = elem - dialog->element;
|
||||
// const SANE_Option_Descriptor *opt;
|
||||
SANE_Word val = SANE_FALSE;
|
||||
|
||||
// opt = sane_get_option_descriptor (dialog->dev, opt_num);
|
||||
if (GTK_TOGGLE_BUTTON (widget)->active)
|
||||
if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget)))
|
||||
val = SANE_TRUE;
|
||||
set_option (dialog, opt_num, &val, SANE_ACTION_SET_VALUE);
|
||||
return FALSE;
|
||||
|
@ -415,20 +413,20 @@ button_update (GtkWidget * widget, GSGDialogElement * elem)
|
|||
|
||||
static void
|
||||
button_new (GtkWidget * parent, const char *name, SANE_Word val,
|
||||
GSGDialogElement * elem, GtkTooltips * tooltips, const char *desc,
|
||||
GSGDialogElement * elem, GtkTooltip * tooltips, const char *desc,
|
||||
gint is_settable)
|
||||
{
|
||||
GtkWidget *button;
|
||||
|
||||
button = gtk_check_button_new_with_label ((char *) name);
|
||||
gtk_toggle_button_set_state (GTK_TOGGLE_BUTTON (button), val);
|
||||
gtk_signal_connect (GTK_OBJECT (button), "toggled",
|
||||
(GtkSignalFunc) button_update, elem);
|
||||
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), val);
|
||||
g_signal_connect (G_OBJECT (button), "toggled",
|
||||
G_CALLBACK (button_update), elem);
|
||||
gtk_box_pack_start (GTK_BOX (parent), button, FALSE, TRUE, 0);
|
||||
if (!is_settable)
|
||||
gtk_widget_set_sensitive (GTK_WIDGET (button), FALSE);
|
||||
gtk_widget_show (button);
|
||||
set_tooltip (tooltips, button, desc);
|
||||
set_tooltip (button, desc);
|
||||
|
||||
elem->widget = button;
|
||||
}
|
||||
|
@ -453,11 +451,11 @@ scale_update (GtkAdjustment * adj_data, GSGDialogElement * elem)
|
|||
switch (opt->type)
|
||||
{
|
||||
case SANE_TYPE_INT:
|
||||
val = adj_data->value + 0.5;
|
||||
val = gtk_adjustment_get_value (adj_data) + 0.5;
|
||||
break;
|
||||
|
||||
case SANE_TYPE_FIXED:
|
||||
d = adj_data->value;
|
||||
d = gtk_adjustment_get_value (adj_data);
|
||||
if (opt->unit == SANE_UNIT_MM)
|
||||
d *= preferences.length_unit;
|
||||
val = SANE_FIX (d);
|
||||
|
@ -489,14 +487,14 @@ value_changed:
|
|||
switch (opt->type)
|
||||
{
|
||||
case SANE_TYPE_INT:
|
||||
adj_data->value = val;
|
||||
gtk_adjustment_set_value (adj_data, val);
|
||||
break;
|
||||
|
||||
case SANE_TYPE_FIXED:
|
||||
d = SANE_UNFIX (val);
|
||||
if (opt->unit == SANE_UNIT_MM)
|
||||
d /= preferences.length_unit;
|
||||
adj_data->value = d;
|
||||
gtk_adjustment_set_value (adj_data, d);
|
||||
break;
|
||||
|
||||
default:
|
||||
|
@ -505,36 +503,41 @@ value_changed:
|
|||
/* 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");
|
||||
g_signal_emit_by_name (G_OBJECT (adj_data), "value_changed", 0);
|
||||
return;
|
||||
}
|
||||
|
||||
static void
|
||||
scale_new (GtkWidget * parent, const char *name, gfloat val,
|
||||
gfloat min, gfloat max, gfloat quant, int automatic,
|
||||
GSGDialogElement * elem, GtkTooltips * tooltips, const char *desc,
|
||||
GSGDialogElement * elem, const char *desc,
|
||||
gint is_settable)
|
||||
{
|
||||
GtkWidget *hbox, *label, *scale;
|
||||
|
||||
hbox = gtk_hbox_new (FALSE, 2);
|
||||
gtk_container_border_width (GTK_CONTAINER (hbox), 0);
|
||||
hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 5);
|
||||
gtk_box_set_homogeneous (GTK_BOX (hbox), FALSE);
|
||||
gtk_container_set_border_width (GTK_CONTAINER (hbox), 0);
|
||||
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, 1.0, 0.0);
|
||||
scale = gtk_hscale_new (GTK_ADJUSTMENT (elem->data));
|
||||
set_tooltip (tooltips, scale, desc);
|
||||
gtk_widget_set_usize (scale, 200, 0);
|
||||
scale = gtk_scale_new (GTK_ORIENTATION_HORIZONTAL, GTK_ADJUSTMENT(elem->data));
|
||||
/*
|
||||
scale = gtk_scale_new_with_range (GTK_ORIENTATION_HORIZONTAL, min, max, quant);
|
||||
elem->data = gtk_range_get_adjustment (GTK_RANGE (scale));
|
||||
*/
|
||||
gtk_adjustment_set_value (GTK_ADJUSTMENT(elem->data), val);
|
||||
set_tooltip (scale, desc);
|
||||
gtk_widget_set_size_request (scale, 200, 0);
|
||||
|
||||
if (automatic)
|
||||
autobutton_new (hbox, elem, scale, tooltips);
|
||||
autobutton_new (hbox, elem, scale);
|
||||
else
|
||||
gtk_box_pack_end (GTK_BOX (hbox), scale, FALSE, FALSE, 0);
|
||||
|
||||
gtk_range_set_update_policy (GTK_RANGE (scale), GTK_UPDATE_CONTINUOUS);
|
||||
gtk_scale_set_value_pos (GTK_SCALE (scale), GTK_POS_TOP);
|
||||
if (quant - (int) quant == 0.0)
|
||||
gtk_scale_set_digits (GTK_SCALE (scale), 0);
|
||||
|
@ -542,13 +545,13 @@ scale_new (GtkWidget * parent, const char *name, gfloat val,
|
|||
/* one place behind decimal point */
|
||||
gtk_scale_set_digits (GTK_SCALE (scale), 1);
|
||||
|
||||
gtk_signal_connect (elem->data, "value_changed",
|
||||
(GtkSignalFunc) scale_update, elem);
|
||||
g_signal_connect (G_OBJECT (elem->data), "value_changed",
|
||||
G_CALLBACK (scale_update), elem);
|
||||
|
||||
gtk_widget_show (label);
|
||||
gtk_widget_show (scale);
|
||||
if (!is_settable)
|
||||
gtk_widget_set_sensitive (GTK_WIDGET (hbox), FALSE);
|
||||
gtk_widget_set_sensitive (GTK_WIDGET (hbox), FALSE);
|
||||
|
||||
gtk_widget_show (hbox);
|
||||
|
||||
|
@ -578,8 +581,8 @@ option_menu_lookup (GSGMenuItem menu_items[], const char *string)
|
|||
static void
|
||||
option_menu_callback (GtkWidget * widget, gpointer data)
|
||||
{
|
||||
GSGMenuItem *menu_item = data;
|
||||
GSGDialogElement *elem = menu_item->elem;
|
||||
GSGDialogElement *elem = data;
|
||||
// GSGMenuItem *menu_item;
|
||||
const SANE_Option_Descriptor *opt;
|
||||
GSGDialog *dialog = elem->dialog;
|
||||
int opt_num;
|
||||
|
@ -587,21 +590,23 @@ option_menu_callback (GtkWidget * widget, gpointer data)
|
|||
SANE_Word val;
|
||||
void *valp = &val;
|
||||
|
||||
gchar *label = gtk_combo_box_text_get_active_text (GTK_COMBO_BOX_TEXT (widget));
|
||||
|
||||
opt_num = elem - dialog->element;
|
||||
opt = sane_get_option_descriptor (dialog->dev, opt_num);
|
||||
switch (opt->type)
|
||||
{
|
||||
case SANE_TYPE_INT:
|
||||
sscanf (menu_item->label, "%d", &val);
|
||||
sscanf (label, "%d", &val);
|
||||
break;
|
||||
|
||||
case SANE_TYPE_FIXED:
|
||||
sscanf (menu_item->label, "%lg", &dval);
|
||||
sscanf (label, "%lg", &dval);
|
||||
val = SANE_FIX (dval);
|
||||
break;
|
||||
|
||||
case SANE_TYPE_STRING:
|
||||
valp = menu_item->label;
|
||||
valp = label;
|
||||
break;
|
||||
|
||||
default:
|
||||
|
@ -614,15 +619,15 @@ option_menu_callback (GtkWidget * widget, gpointer data)
|
|||
|
||||
static void
|
||||
option_menu_new (GtkWidget * parent, const char *name, char *str_list[],
|
||||
const char *val, GSGDialogElement * elem,
|
||||
GtkTooltips * tooltips, const char *desc, gint is_settable)
|
||||
const char *val, GSGDialogElement * elem,
|
||||
const char *desc, gint is_settable)
|
||||
{
|
||||
GtkWidget *hbox, *label, *option_menu, *menu, *item;
|
||||
GtkWidget *hbox, *label, *option_menu;
|
||||
GSGMenuItem *menu_items;
|
||||
int i, num_items;
|
||||
int i, num_items, selected = 0;
|
||||
|
||||
hbox = gtk_hbox_new (FALSE, 2);
|
||||
gtk_container_border_width (GTK_CONTAINER (hbox), 0);
|
||||
hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 2);
|
||||
gtk_box_set_homogeneous (GTK_BOX (hbox), FALSE);
|
||||
gtk_box_pack_start (GTK_BOX (parent), hbox, FALSE, FALSE, 0);
|
||||
|
||||
label = gtk_label_new ((char *) name);
|
||||
|
@ -631,35 +636,28 @@ option_menu_new (GtkWidget * parent, const char *name, char *str_list[],
|
|||
for (num_items = 0; str_list[num_items]; ++num_items);
|
||||
menu_items = malloc (num_items * sizeof (menu_items[0]));
|
||||
|
||||
menu = gtk_menu_new ();
|
||||
option_menu = gtk_combo_box_text_new ();
|
||||
for (i = 0; i < num_items; ++i)
|
||||
{
|
||||
item = gtk_menu_item_new_with_label (str_list[i]);
|
||||
gtk_container_add (GTK_CONTAINER (menu), item);
|
||||
gtk_signal_connect (GTK_OBJECT (item), "activate",
|
||||
(GtkSignalFunc) option_menu_callback,
|
||||
menu_items + i);
|
||||
{
|
||||
gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (option_menu), str_list[i]);
|
||||
|
||||
gtk_widget_show (item);
|
||||
|
||||
menu_items[i].label = str_list[i];
|
||||
menu_items[i].elem = elem;
|
||||
menu_items[i].index = i;
|
||||
}
|
||||
|
||||
option_menu = gtk_option_menu_new ();
|
||||
menu_items[i].label = str_list[i];
|
||||
menu_items[i].elem = elem;
|
||||
menu_items[i].index = i;
|
||||
if (val && !strcmp(str_list[i], val))
|
||||
selected = i;
|
||||
}
|
||||
gtk_box_pack_end (GTK_BOX (hbox), option_menu, FALSE, FALSE, 2);
|
||||
gtk_option_menu_set_menu (GTK_OPTION_MENU (option_menu), menu);
|
||||
gtk_option_menu_set_history (GTK_OPTION_MENU (option_menu),
|
||||
option_menu_lookup (menu_items, val));
|
||||
set_tooltip (tooltips, option_menu, desc);
|
||||
|
||||
gtk_combo_box_set_active (GTK_COMBO_BOX (option_menu), selected);
|
||||
set_tooltip (option_menu, desc);
|
||||
gtk_widget_show (label);
|
||||
gtk_widget_show (option_menu);
|
||||
if (!is_settable)
|
||||
gtk_widget_set_sensitive (GTK_WIDGET (hbox), FALSE);
|
||||
gtk_widget_set_sensitive (GTK_WIDGET (hbox), FALSE);
|
||||
gtk_widget_show (hbox);
|
||||
|
||||
g_signal_connect(option_menu, "changed", G_CALLBACK(option_menu_callback), elem);
|
||||
|
||||
elem->widget = option_menu;
|
||||
elem->menu_size = num_items;
|
||||
elem->menu = menu_items;
|
||||
|
@ -696,12 +694,12 @@ text_entry_callback (GtkWidget * w, gpointer data)
|
|||
static void
|
||||
text_entry_new (GtkWidget * parent, const char *name, const char *val,
|
||||
GSGDialogElement * elem,
|
||||
GtkTooltips * tooltips, const char *desc, gint is_settable)
|
||||
const char *desc, gint is_settable)
|
||||
{
|
||||
GtkWidget *hbox, *text, *label;
|
||||
|
||||
hbox = gtk_hbox_new (FALSE, 2);
|
||||
gtk_container_border_width (GTK_CONTAINER (hbox), 0);
|
||||
hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 2);
|
||||
gtk_box_set_homogeneous (GTK_BOX (hbox), FALSE);
|
||||
gtk_box_pack_start (GTK_BOX (parent), hbox, FALSE, FALSE, 0);
|
||||
|
||||
label = gtk_label_new ((char *) name);
|
||||
|
@ -710,9 +708,9 @@ text_entry_new (GtkWidget * parent, const char *name, const char *val,
|
|||
text = gtk_entry_new ();
|
||||
gtk_entry_set_text (GTK_ENTRY (text), (char *) val);
|
||||
gtk_box_pack_start (GTK_BOX (hbox), text, FALSE, TRUE, 0);
|
||||
gtk_signal_connect (GTK_OBJECT (text), "changed",
|
||||
(GtkSignalFunc) text_entry_callback, elem);
|
||||
set_tooltip (tooltips, text, desc);
|
||||
g_signal_connect (G_OBJECT (text), "changed",
|
||||
G_CALLBACK (text_entry_callback), elem);
|
||||
set_tooltip (text, desc);
|
||||
|
||||
gtk_widget_show (hbox);
|
||||
if (!is_settable)
|
||||
|
@ -729,12 +727,13 @@ group_new (GtkWidget * parent, const char *title)
|
|||
GtkWidget *frame, *vbox;
|
||||
|
||||
frame = gtk_frame_new ((char *) title);
|
||||
gtk_container_border_width (GTK_CONTAINER (frame), 4);
|
||||
gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_ETCHED_IN);
|
||||
gtk_container_set_border_width (GTK_CONTAINER (frame), 4);
|
||||
|
||||
gtk_box_pack_start (GTK_BOX (parent), frame, FALSE, FALSE, 0);
|
||||
|
||||
vbox = gtk_vbox_new (FALSE, 4);
|
||||
gtk_container_border_width (GTK_CONTAINER (vbox), 2);
|
||||
vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 4);
|
||||
gtk_box_set_homogeneous (GTK_BOX (vbox), FALSE);
|
||||
|
||||
gtk_container_add (GTK_CONTAINER (frame), vbox);
|
||||
gtk_widget_show (vbox);
|
||||
return vbox;
|
||||
|
@ -751,8 +750,16 @@ curve_new (GSGDialog * dialog, int optnum)
|
|||
SANE_Handle dev;
|
||||
int i, optlen;
|
||||
|
||||
gamma = gtk_gamma_curve_new ();
|
||||
curve = GTK_GAMMA_CURVE (gamma)->curve;
|
||||
gamma = gtk3_gamma_curve_new ();
|
||||
curve = GTK3_GAMMA_CURVE (gamma)->curve;
|
||||
gtk3_curve_set_color_background_rgba (curve, 0.8, 0.8, 0.8, 0.5);
|
||||
gtk3_curve_set_color_grid_rgba (curve, 0.0, 0.0, 0.0, 0.5);
|
||||
gtk3_curve_set_color_curve_rgba (curve, 1.0, 1.0, 1.0, 1.0);
|
||||
gtk3_curve_set_color_cpoint_rgba (curve, 0.8, 0.3, 0.3, 1.0);
|
||||
|
||||
gtk3_curve_set_use_theme_background(curve, FALSE);
|
||||
gtk3_curve_set_grid_size (curve, GTK3_CURVE_GRID_SMALL);
|
||||
// gtk3_curve_set_range (da, 0, WINDOW_WIDTH, 0, WINDOW_HEIGHT);
|
||||
dev = dialog->dev;
|
||||
|
||||
opt = sane_get_option_descriptor (dev, optnum);
|
||||
|
@ -803,7 +810,10 @@ curve_new (GSGDialog * dialog, int optnum)
|
|||
fmin = min;
|
||||
fmax = max;
|
||||
}
|
||||
gtk_curve_set_range (GTK_CURVE (curve), 0, optlen - 1, fmin, fmax);
|
||||
// gtk_widget_set_size_request (curve, optlen-1, fmax);
|
||||
gtk_widget_set_size_request (curve, 200, 200);
|
||||
gtk3_curve_set_range (GTK_WIDGET (curve), 0, optlen - 1, fmin, fmax);
|
||||
// gtk3_curve_set_range (da, 0, WINDOW_WIDTH, 0, WINDOW_HEIGHT);
|
||||
|
||||
status = sane_control_option (dev, optnum, SANE_ACTION_GET_VALUE,
|
||||
optval, 0);
|
||||
|
@ -817,7 +827,7 @@ curve_new (GSGDialog * dialog, int optnum)
|
|||
val = optval[i];
|
||||
vector[i] = val;
|
||||
}
|
||||
gtk_curve_set_vector (GTK_CURVE (curve), optlen, vector);
|
||||
gtk3_curve_set_vector (GTK_WIDGET (curve), optlen, vector);
|
||||
}
|
||||
else
|
||||
gtk_widget_set_sensitive (gamma, FALSE);
|
||||
|
@ -828,12 +838,11 @@ curve_new (GSGDialog * dialog, int optnum)
|
|||
static void
|
||||
vector_new (GSGDialog * dialog, GtkWidget * vbox, int num_vopts, int *vopts)
|
||||
{
|
||||
GtkWidget *notebook, *label, *curve;
|
||||
GtkWidget *notebook, *label, *curve = NULL;
|
||||
const SANE_Option_Descriptor *opt;
|
||||
int i;
|
||||
|
||||
notebook = gtk_notebook_new ();
|
||||
gtk_container_border_width (GTK_CONTAINER (notebook), 4);
|
||||
gtk_box_pack_start (GTK_BOX (vbox), notebook, TRUE, TRUE, 0);
|
||||
|
||||
for (i = 0; i < num_vopts; ++i)
|
||||
|
@ -841,14 +850,15 @@ vector_new (GSGDialog * dialog, GtkWidget * vbox, int num_vopts, int *vopts)
|
|||
opt = sane_get_option_descriptor (dialog->dev, vopts[i]);
|
||||
|
||||
label = gtk_label_new ((char *) opt->title);
|
||||
vbox = gtk_vbox_new ( /* homogeneous */ FALSE, 0);
|
||||
vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
|
||||
gtk_box_set_homogeneous (GTK_BOX (vbox), FALSE);
|
||||
gtk_notebook_append_page (GTK_NOTEBOOK (notebook), vbox, label);
|
||||
gtk_widget_show (vbox);
|
||||
gtk_widget_show (label);
|
||||
|
||||
curve = curve_new (dialog, vopts[i]);
|
||||
gtk_container_border_width (GTK_CONTAINER (curve), 4);
|
||||
gtk_box_pack_start (GTK_BOX (vbox), curve, TRUE, TRUE, 0);
|
||||
if (curve)
|
||||
gtk_box_pack_start (GTK_BOX (vbox), curve, TRUE, TRUE, 0);
|
||||
gtk_widget_show (curve);
|
||||
|
||||
dialog->element[vopts[i]].widget = curve;
|
||||
|
@ -863,16 +873,6 @@ panel_destroy (GSGDialog * dialog)
|
|||
GSGDialogElement *elem;
|
||||
int i, j;
|
||||
|
||||
#ifdef HAVE_GTK_TOOLTIPS_SET_TIPS
|
||||
/* pre 0.99.4: */
|
||||
gtk_tooltips_unref (dialog->tooltips);
|
||||
#else
|
||||
# if GTK_MAJOR_VERSION == 2
|
||||
gtk_object_sink (GTK_OBJECT (dialog->tooltips));
|
||||
# else
|
||||
gtk_object_unref (GTK_OBJECT (dialog->tooltips));
|
||||
# endif /* GTK_MAJOR_VERSION == 2 */
|
||||
#endif
|
||||
gtk_widget_destroy (dialog->main_hbox);
|
||||
|
||||
/* free the menu labels of integer/fix-point word-lists: */
|
||||
|
@ -905,7 +905,7 @@ panel_build (GSGDialog * dialog)
|
|||
const SANE_Option_Descriptor *opt;
|
||||
SANE_Handle dev = dialog->dev;
|
||||
double dval, dmin, dmax, dquant;
|
||||
char *buf, str[16], title[256];
|
||||
char *buf, str[16], title[256] = { 0 };
|
||||
GSGDialogElement *elem;
|
||||
SANE_Word quant, val;
|
||||
SANE_Status status;
|
||||
|
@ -915,50 +915,36 @@ panel_build (GSGDialog * dialog)
|
|||
int num_vector_opts = 0, *vector_opts;
|
||||
SANE_Bool val_in_list;
|
||||
|
||||
main_hbox = gtk_hbox_new (FALSE, 2);
|
||||
main_hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 2);
|
||||
gtk_box_set_homogeneous (GTK_BOX (main_hbox), FALSE);
|
||||
|
||||
if (dialog->twocolumn)
|
||||
{
|
||||
option_vbox = gtk_hbox_new (FALSE, 2); /* two column display */
|
||||
option_vbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 2); /* two column display */
|
||||
}
|
||||
else
|
||||
{
|
||||
option_vbox = gtk_vbox_new (FALSE, 2); /* one column display */
|
||||
option_vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 2); /* one column display */
|
||||
}
|
||||
gtk_box_set_homogeneous (GTK_BOX (option_vbox), FALSE);
|
||||
|
||||
gtk_box_pack_start (GTK_BOX (main_hbox), option_vbox, FALSE, FALSE, 0);
|
||||
gtk_widget_show (option_vbox);
|
||||
|
||||
/* standard options vbox */
|
||||
|
||||
standard_vbox = gtk_vbox_new ( /* homogeneous */ FALSE, 0);
|
||||
standard_vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 2); /* one column display */
|
||||
gtk_box_set_homogeneous (GTK_BOX (standard_vbox), FALSE);
|
||||
gtk_widget_show (standard_vbox);
|
||||
gtk_box_pack_start (GTK_BOX (option_vbox), standard_vbox, FALSE, FALSE, 0);
|
||||
|
||||
/* advanced options page */
|
||||
|
||||
advanced_vbox = gtk_vbox_new ( /* homogeneous */ FALSE, 0);
|
||||
advanced_vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
|
||||
gtk_box_set_homogeneous (GTK_BOX (advanced_vbox), FALSE);
|
||||
gtk_box_pack_start (GTK_BOX (option_vbox), advanced_vbox, TRUE, TRUE, 0);
|
||||
|
||||
/* use black as foreground: */
|
||||
dialog->tooltips = gtk_tooltips_new ();
|
||||
dialog->tooltips_fg.red = 0;
|
||||
dialog->tooltips_fg.green = 0;
|
||||
dialog->tooltips_fg.blue = 0;
|
||||
/* postit yellow (khaki) as background: */
|
||||
gdk_color_alloc (gtk_widget_get_colormap (main_hbox), &dialog->tooltips_fg);
|
||||
dialog->tooltips_bg.red = 61669;
|
||||
dialog->tooltips_bg.green = 59113;
|
||||
dialog->tooltips_bg.blue = 35979;
|
||||
gdk_color_alloc (gtk_widget_get_colormap (main_hbox), &dialog->tooltips_bg);
|
||||
|
||||
/* GTK2 doesn't have the function (seems like it's not needed with GTK2 anyway) */
|
||||
#if GTK_MAJOR_VERSION < 2
|
||||
gtk_tooltips_set_colors (dialog->tooltips,
|
||||
&dialog->tooltips_bg, &dialog->tooltips_fg);
|
||||
#endif /* GTK_MAJOR_VERSION < 2 */
|
||||
|
||||
gsg_set_tooltips (dialog, preferences.tooltips_enabled);
|
||||
gsg_set_tooltips (preferences.tooltips_enabled);
|
||||
|
||||
gtk_container_add (GTK_CONTAINER (dialog->window), main_hbox);
|
||||
dialog->main_hbox = main_hbox;
|
||||
|
@ -1008,7 +994,7 @@ panel_build (GSGDialog * dialog)
|
|||
elem->dialog = dialog;
|
||||
|
||||
if (opt->unit == SANE_UNIT_NONE)
|
||||
strncpy (title, opt->title, sizeof (title));
|
||||
snprintf (title, sizeof (title), "%s", opt->title);
|
||||
else
|
||||
snprintf (title, sizeof (title),
|
||||
"%s [%s]", opt->title, unit_string (opt->unit));
|
||||
|
@ -1037,7 +1023,7 @@ panel_build (GSGDialog * dialog)
|
|||
|
||||
button_new (parent, title, val, elem, dialog->tooltips, opt->desc,
|
||||
SANE_OPTION_IS_SETTABLE (opt->cap));
|
||||
gtk_widget_show (parent->parent);
|
||||
gtk_widget_show (gtk_widget_get_parent (parent));
|
||||
break;
|
||||
|
||||
case SANE_TYPE_INT:
|
||||
|
@ -1066,9 +1052,9 @@ panel_build (GSGDialog * dialog)
|
|||
opt->constraint.range->min,
|
||||
opt->constraint.range->max, quant,
|
||||
(opt->cap & SANE_CAP_AUTOMATIC), elem,
|
||||
dialog->tooltips, opt->desc,
|
||||
opt->desc,
|
||||
SANE_OPTION_IS_SETTABLE (opt->cap));
|
||||
gtk_widget_show (parent->parent);
|
||||
gtk_widget_show (gtk_widget_get_parent (parent));
|
||||
break;
|
||||
|
||||
case SANE_CONSTRAINT_WORD_LIST:
|
||||
|
@ -1093,10 +1079,10 @@ panel_build (GSGDialog * dialog)
|
|||
val = opt->constraint.word_list[1];
|
||||
sprintf (str, "%d", val);
|
||||
option_menu_new (parent, title, str_list, str, elem,
|
||||
dialog->tooltips, opt->desc,
|
||||
opt->desc,
|
||||
SANE_OPTION_IS_SETTABLE (opt->cap));
|
||||
free (str_list);
|
||||
gtk_widget_show (parent->parent);
|
||||
gtk_widget_show (gtk_widget_get_parent (parent));
|
||||
break;
|
||||
|
||||
case SANE_CONSTRAINT_NONE:
|
||||
|
@ -1146,9 +1132,9 @@ panel_build (GSGDialog * dialog)
|
|||
}
|
||||
scale_new (parent, title, dval, dmin, dmax, dquant,
|
||||
(opt->cap & SANE_CAP_AUTOMATIC), elem,
|
||||
dialog->tooltips, opt->desc,
|
||||
opt->desc,
|
||||
SANE_OPTION_IS_SETTABLE (opt->cap));
|
||||
gtk_widget_show (parent->parent);
|
||||
gtk_widget_show (gtk_widget_get_parent (parent));
|
||||
break;
|
||||
|
||||
case SANE_CONSTRAINT_WORD_LIST:
|
||||
|
@ -1164,10 +1150,10 @@ panel_build (GSGDialog * dialog)
|
|||
str_list[j] = 0;
|
||||
sprintf (str, "%g", SANE_UNFIX (val));
|
||||
option_menu_new (parent, title, str_list, str, elem,
|
||||
dialog->tooltips, opt->desc,
|
||||
opt->desc,
|
||||
SANE_OPTION_IS_SETTABLE (opt->cap));
|
||||
free (str_list);
|
||||
gtk_widget_show (parent->parent);
|
||||
gtk_widget_show (gtk_widget_get_parent (parent));
|
||||
break;
|
||||
|
||||
case SANE_CONSTRAINT_NONE:
|
||||
|
@ -1202,16 +1188,16 @@ panel_build (GSGDialog * dialog)
|
|||
/* use a "list-selection" widget */
|
||||
option_menu_new (parent, title,
|
||||
(char **) opt->constraint.string_list, buf,
|
||||
elem, dialog->tooltips, opt->desc,
|
||||
elem, opt->desc,
|
||||
SANE_OPTION_IS_SETTABLE (opt->cap));
|
||||
gtk_widget_show (parent->parent);
|
||||
gtk_widget_show (gtk_widget_get_parent (parent));
|
||||
break;
|
||||
|
||||
case SANE_CONSTRAINT_NONE:
|
||||
text_entry_new (parent, title, buf, elem,
|
||||
dialog->tooltips, opt->desc,
|
||||
opt->desc,
|
||||
SANE_OPTION_IS_SETTABLE (opt->cap));
|
||||
gtk_widget_show (parent->parent);
|
||||
gtk_widget_show (gtk_widget_get_parent (parent));
|
||||
break;
|
||||
|
||||
default:
|
||||
|
@ -1226,9 +1212,11 @@ panel_build (GSGDialog * dialog)
|
|||
if ((opt->cap & SANE_CAP_ADVANCED) && !dialog->advanced)
|
||||
break;
|
||||
button = gtk_button_new ();
|
||||
gtk_signal_connect (GTK_OBJECT (button), "clicked",
|
||||
(GtkSignalFunc) push_button_callback, elem);
|
||||
set_tooltip (dialog->tooltips, button, opt->desc);
|
||||
g_signal_connect (G_OBJECT (button),
|
||||
"clicked",
|
||||
G_CALLBACK (push_button_callback),
|
||||
elem);
|
||||
set_tooltip (button, opt->desc);
|
||||
|
||||
label = gtk_label_new (title);
|
||||
gtk_container_add (GTK_CONTAINER (button), label);
|
||||
|
@ -1239,7 +1227,7 @@ panel_build (GSGDialog * dialog)
|
|||
gtk_widget_show (button);
|
||||
|
||||
elem->widget = button;
|
||||
gtk_widget_show (parent->parent);
|
||||
gtk_widget_show (gtk_widget_get_parent (parent));
|
||||
break;
|
||||
|
||||
default:
|
||||
|
@ -1316,7 +1304,7 @@ gsg_create_dialog (GtkWidget * window, const char *device_name,
|
|||
|
||||
dialog->window = window;
|
||||
dialog->dev = dev;
|
||||
dialog->dev_name = strdup (device_name);
|
||||
dialog->dev_name = g_strdup (device_name);
|
||||
dialog->num_elements = num_elements;
|
||||
dialog->option_reload_callback = option_reload_callback;
|
||||
dialog->option_reload_arg = option_reload_arg;
|
||||
|
@ -1368,20 +1356,21 @@ gsg_update_scan_window (GSGDialog * dialog)
|
|||
case SANE_CONSTRAINT_RANGE:
|
||||
if (opt->type == SANE_TYPE_INT)
|
||||
{
|
||||
old_val = GTK_ADJUSTMENT (elem->data)->value;
|
||||
old_val = gtk_adjustment_get_value (elem->data);
|
||||
new_val = word;
|
||||
GTK_ADJUSTMENT (elem->data)->value = new_val;
|
||||
gtk_adjustment_set_value (elem->data, new_val);
|
||||
}
|
||||
else
|
||||
{
|
||||
old_val = GTK_ADJUSTMENT (elem->data)->value;
|
||||
old_val = gtk_adjustment_get_value (elem->data);
|
||||
new_val = word;
|
||||
new_val = SANE_UNFIX (word);
|
||||
if (opt->unit == SANE_UNIT_MM)
|
||||
new_val /= preferences.length_unit;
|
||||
GTK_ADJUSTMENT (elem->data)->value = new_val;
|
||||
gtk_adjustment_set_value (elem->data, new_val);
|
||||
}
|
||||
if (old_val != new_val)
|
||||
gtk_signal_emit_by_name (GTK_OBJECT (elem->data),
|
||||
g_signal_emit_by_name (G_OBJECT (elem->data),
|
||||
"value_changed");
|
||||
break;
|
||||
|
||||
|
@ -1391,9 +1380,9 @@ gsg_update_scan_window (GSGDialog * dialog)
|
|||
else
|
||||
sprintf (str, "%g", SANE_UNFIX (word));
|
||||
/* XXX maybe we should call this only when the value changes... */
|
||||
gtk_option_menu_set_history (GTK_OPTION_MENU (elem->widget),
|
||||
option_menu_lookup (elem->menu,
|
||||
str));
|
||||
gtk_combo_box_set_active (GTK_COMBO_BOX (elem->widget),
|
||||
option_menu_lookup (elem->menu,
|
||||
str));
|
||||
break;
|
||||
|
||||
default:
|
||||
|
@ -1420,24 +1409,25 @@ gsg_sync (GSGDialog * dialog)
|
|||
if (!SANE_OPTION_IS_ACTIVE (opt->cap))
|
||||
continue;
|
||||
|
||||
if ((opt->type != SANE_TYPE_INT) && (opt->type != SANE_TYPE_FIXED))
|
||||
if (opt->type != SANE_TYPE_INT && opt->type != SANE_TYPE_FIXED)
|
||||
continue;
|
||||
|
||||
if (opt->size == sizeof (SANE_Word))
|
||||
continue;
|
||||
|
||||
|
||||
// If curves is hidden (advanced option perhaps) then nothing to do.
|
||||
if (!dialog->element[i].widget)
|
||||
continue;
|
||||
|
||||
/* ok, we're dealing with an active vector */
|
||||
// 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 (dialog->element[i].widget)->curve;
|
||||
gtk_curve_get_vector (GTK_CURVE (curve), optlen, vector);
|
||||
curve = GTK3_GAMMA_CURVE (dialog->element[i].widget)->curve;
|
||||
gtk3_curve_get_vector (GTK_WIDGET (curve), optlen, vector);
|
||||
for (j = 0; j < optlen; ++j)
|
||||
{
|
||||
val = vector[j];
|
||||
|
@ -1458,16 +1448,38 @@ gsg_set_advanced (GSGDialog * dialog, int advanced)
|
|||
panel_rebuild (dialog);
|
||||
}
|
||||
|
||||
void
|
||||
gsg_set_tooltips (GSGDialog * dialog, int enable)
|
||||
{
|
||||
if (!dialog->tooltips)
|
||||
return;
|
||||
|
||||
static GtkCssProvider *css_prov = NULL;
|
||||
|
||||
void
|
||||
gsg_set_tooltips (int enable)
|
||||
{
|
||||
if (enable)
|
||||
gtk_tooltips_enable (dialog->tooltips);
|
||||
{
|
||||
if (css_prov) {
|
||||
gtk_style_context_remove_provider_for_screen(gdk_screen_get_default(), GTK_STYLE_PROVIDER(css_prov));
|
||||
g_object_unref(css_prov);
|
||||
}
|
||||
css_prov = gtk_css_provider_new();
|
||||
const gchar style[] = "tooltip {opacity:1;}";
|
||||
gtk_css_provider_load_from_data(css_prov, style, -1, NULL);
|
||||
gtk_style_context_add_provider_for_screen(gdk_screen_get_default(), GTK_STYLE_PROVIDER(css_prov),
|
||||
GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
|
||||
}
|
||||
else
|
||||
gtk_tooltips_disable (dialog->tooltips);
|
||||
{
|
||||
if (css_prov) {
|
||||
gtk_style_context_remove_provider_for_screen(gdk_screen_get_default(), GTK_STYLE_PROVIDER(css_prov));
|
||||
g_object_unref(css_prov);
|
||||
}
|
||||
css_prov = gtk_css_provider_new();
|
||||
const gchar style[] = "tooltip {opacity:0;}";
|
||||
gtk_css_provider_load_from_data(css_prov, style, -1, NULL);
|
||||
gtk_style_context_add_provider_for_screen(gdk_screen_get_default(), GTK_STYLE_PROVIDER(css_prov),
|
||||
GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#ifndef gtkglue_h
|
||||
#define gtkglue_h
|
||||
#ifndef __GTKGLUE_H__
|
||||
#define __GTKGLUE_H__
|
||||
|
||||
#include <sys/types.h>
|
||||
|
||||
|
@ -44,7 +44,7 @@ typedef struct GSGDialogElement
|
|||
struct GSGDialog *dialog; /* wasteful, but is there a better solution? */
|
||||
GtkWidget *automatic; /* auto button for options that support this */
|
||||
GtkWidget *widget;
|
||||
GtkObject *data;
|
||||
GtkAdjustment *data;
|
||||
int menu_size; /* # of items in menu (if any) */
|
||||
GSGMenuItem *menu;
|
||||
}
|
||||
|
@ -56,7 +56,7 @@ typedef struct GSGDialog
|
|||
GtkWidget *main_hbox;
|
||||
GtkWidget *advanced_vbox;
|
||||
int twocolumn;
|
||||
GtkTooltips *tooltips;
|
||||
GtkTooltip *tooltips;
|
||||
GdkColor tooltips_fg;
|
||||
GdkColor tooltips_bg;
|
||||
SANE_Handle *dev;
|
||||
|
@ -111,11 +111,18 @@ extern void gsg_sync (GSGDialog *dialog);
|
|||
extern void gsg_refresh_dialog (GSGDialog *dialog);
|
||||
extern void gsg_update_scan_window (GSGDialog *dialog);
|
||||
extern void gsg_set_advanced (GSGDialog *dialog, int advanced);
|
||||
extern void gsg_set_tooltips (GSGDialog *dialog, int enable);
|
||||
extern void gsg_set_tooltips (int enable);
|
||||
extern void gsg_set_twocolumn (GSGDialog *dialog, int enable);
|
||||
extern void gsg_set_sensitivity (GSGDialog *dialog, int sensitive);
|
||||
extern void gsg_destroy_dialog (GSGDialog * dialog);
|
||||
|
||||
void gsg_widget_placement(GtkWidget *w,
|
||||
GtkAlign halign,
|
||||
GtkAlign valign,
|
||||
int top,
|
||||
int start,
|
||||
int end,
|
||||
int bottom);
|
||||
#define gsg_dialog_get_device(dialog) ((dialog)->dev)
|
||||
|
||||
#endif /* gtkglue_h */
|
||||
|
|
505
src/preview.c
505
src/preview.c
|
@ -86,6 +86,9 @@
|
|||
#define DBG_warning 2
|
||||
#define DBG_info 3
|
||||
#define DBG_debug 4
|
||||
#define DBG_proc 5
|
||||
#define DBG_proc2 50
|
||||
#define DBG_proc3 100
|
||||
|
||||
#define BACKEND_NAME preview
|
||||
#include "../include/sane/sanei_debug.h"
|
||||
|
@ -115,10 +118,45 @@
|
|||
static void scan_start (Preview * p);
|
||||
static void scan_done (Preview * p);
|
||||
|
||||
static void
|
||||
draw_rect (GdkWindow * win, GdkGC * gc, int coord[4])
|
||||
static gboolean
|
||||
_last_call_time_check(unsigned long interval)
|
||||
{
|
||||
gint x, y, w, h;
|
||||
struct timeval t;
|
||||
unsigned long utime;
|
||||
static unsigned long last_call = 0;
|
||||
|
||||
gettimeofday(&t,NULL);
|
||||
utime = 1000000 * t.tv_sec + t.tv_usec;
|
||||
|
||||
if ((utime - last_call) < interval)
|
||||
return FALSE;
|
||||
|
||||
last_call = utime;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
screen_size_get_dimensions (gint *width, gint *height)
|
||||
{
|
||||
GdkScreen *screen;
|
||||
GdkWindow *window;
|
||||
gint scale;
|
||||
|
||||
screen = gdk_screen_get_default ();
|
||||
window = gdk_screen_get_root_window (screen);
|
||||
|
||||
scale = gdk_window_get_scale_factor (window);
|
||||
|
||||
*width = gdk_window_get_width (window) / scale;
|
||||
*height = gdk_window_get_height (window) / scale;
|
||||
}
|
||||
|
||||
static void
|
||||
draw_rect(cairo_t *cr, double coord[4])
|
||||
{
|
||||
double x, y, w, h;
|
||||
|
||||
x = coord[0];
|
||||
y = coord[1];
|
||||
|
@ -134,21 +172,30 @@ draw_rect (GdkWindow * win, GdkGC * gc, int coord[4])
|
|||
y = coord[3];
|
||||
h = -h;
|
||||
}
|
||||
gdk_draw_rectangle (win, gc, FALSE, x, y, w + 1, h + 1);
|
||||
cairo_set_line_width(cr, 1.5);
|
||||
const double dashes1[2] = {4.0, 4.0};
|
||||
cairo_set_source_rgb (cr, 0, 0, 0);
|
||||
cairo_set_dash(cr, dashes1, sizeof(dashes1)/sizeof(dashes1[0]), 0);
|
||||
cairo_set_operator(cr, CAIRO_OPERATOR_SOURCE);
|
||||
cairo_set_source_rgb(cr, 0.0, 0.0, 0.0);
|
||||
cairo_rectangle(cr, x, y, w + 1, h + 1);
|
||||
cairo_stroke(cr);
|
||||
cairo_set_source_rgb(cr, 1.0, 1.0, 1.0);
|
||||
const double dashes2[4] = {0.0, 4.0, 4.0, 0.0};
|
||||
cairo_set_dash(cr, dashes2, sizeof(dashes2)/sizeof(dashes2[0]), 0);
|
||||
cairo_set_source_rgb(cr, 1.0, 1.0, 1.0);
|
||||
cairo_rectangle(cr, x, y, w + 1, h + 1);
|
||||
cairo_stroke(cr);
|
||||
}
|
||||
|
||||
static void
|
||||
draw_selection (Preview * p)
|
||||
draw_selection (Preview * p, cairo_t *cr)
|
||||
{
|
||||
if (!p->gc)
|
||||
/* window isn't mapped yet */
|
||||
return;
|
||||
|
||||
if (p->previous_selection.active)
|
||||
draw_rect (p->window->window, p->gc, p->previous_selection.coord);
|
||||
draw_rect (cr, p->previous_selection.coord);
|
||||
|
||||
if (p->selection.active)
|
||||
draw_rect (p->window->window, p->gc, p->selection.coord);
|
||||
draw_rect (cr, p->selection.coord);
|
||||
|
||||
p->previous_selection = p->selection;
|
||||
}
|
||||
|
@ -199,7 +246,6 @@ update_selection (Preview * p)
|
|||
if (p->selection.coord[i + 2] < p->selection.coord[i])
|
||||
p->selection.coord[i + 2] = p->selection.coord[i];
|
||||
}
|
||||
draw_selection (p);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -249,7 +295,17 @@ paint_image (Preview * p)
|
|||
|
||||
get_image_scale (p, &xscale, &yscale);
|
||||
|
||||
if (p->preview_row == NULL)
|
||||
p->preview_row = malloc (3 * gwidth);
|
||||
else
|
||||
p->preview_row = realloc (p->preview_row, 3 * gwidth);
|
||||
memset (p->preview_row, 0xff, 3 * gwidth);
|
||||
if (p->preview_data == NULL)
|
||||
p->preview_data = malloc (3 * gwidth * gheight);
|
||||
else
|
||||
p->preview_data = realloc (p->preview_data, 3 * gwidth * gheight);
|
||||
memset (p->preview_data, 0xff, 3 * gwidth * gheight);
|
||||
gtk_widget_queue_draw (p->window);
|
||||
|
||||
/* don't draw last line unless it's complete: */
|
||||
height = p->image_y;
|
||||
|
@ -281,29 +337,19 @@ paint_image (Preview * p)
|
|||
p->image_data[src_offset + 3 * x + 2];
|
||||
src_x += xscale;
|
||||
}
|
||||
gtk_preview_draw_row (GTK_PREVIEW (p->window), p->preview_row,
|
||||
0, dst_y, gwidth);
|
||||
memcpy(p->preview_data + (size_t) dst_y * (size_t) gwidth * 3, p->preview_row, (size_t) gwidth * 3);
|
||||
src_x = 0.0;
|
||||
src_y += yscale;
|
||||
}
|
||||
gtk_widget_queue_draw (p->window);
|
||||
}
|
||||
|
||||
static void
|
||||
display_partial_image (Preview * p)
|
||||
{
|
||||
paint_image (p);
|
||||
DBG(DBG_proc, "preview_display_partial_image\n");
|
||||
|
||||
if (GTK_WIDGET_DRAWABLE (p->window))
|
||||
{
|
||||
GtkPreview *preview = GTK_PREVIEW (p->window);
|
||||
int src_x, src_y;
|
||||
|
||||
src_x = (p->window->allocation.width - preview->buffer_width) / 2;
|
||||
src_y = (p->window->allocation.height - preview->buffer_height) / 2;
|
||||
gtk_preview_put (preview, p->window->window, p->window->style->black_gc,
|
||||
src_x, src_y,
|
||||
0, 0, p->preview_width, p->preview_height);
|
||||
}
|
||||
paint_image(p);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -328,21 +374,27 @@ display_image (Preview * p)
|
|||
p->image_data = realloc (p->image_data,
|
||||
3 * p->image_width * p->image_height);
|
||||
assert (p->image_data);
|
||||
p->preview_data = realloc (p->preview_data,
|
||||
3 * p->image_width * p->image_height);
|
||||
}
|
||||
display_partial_image (p);
|
||||
scan_done (p);
|
||||
}
|
||||
|
||||
static void
|
||||
preview_area_resize (GtkWidget * widget)
|
||||
preview_area_resize (GtkWidget * widget, GdkEventConfigure *event, gpointer data)
|
||||
{
|
||||
float min_x, max_x, min_y, max_y, xscale, yscale, f;
|
||||
Preview *p;
|
||||
GtkAllocation alloc;
|
||||
Preview *p = data;
|
||||
|
||||
p = gtk_object_get_data (GTK_OBJECT (widget), "PreviewPointer");
|
||||
/*if (!_last_call_time_check(1000000))
|
||||
return;
|
||||
*/
|
||||
gtk_widget_get_allocated_size (widget, &alloc, NULL);
|
||||
|
||||
p->preview_width = widget->allocation.width;
|
||||
p->preview_height = widget->allocation.height;
|
||||
p->preview_width = alloc.width;
|
||||
p->preview_height = alloc.height;
|
||||
|
||||
if (p->preview_row)
|
||||
p->preview_row = realloc (p->preview_row, 3 * p->preview_width);
|
||||
|
@ -386,8 +438,12 @@ preview_area_resize (GtkWidget * widget)
|
|||
f = xscale * p->preview_width / p->image_width;
|
||||
else
|
||||
f = 1.0;
|
||||
gtk_ruler_set_range (GTK_RULER (p->hruler), f * min_x, f * max_x, f * min_x,
|
||||
/* max_size */ 20);
|
||||
|
||||
gtk3_ruler_set_range (GTK3_RULER (p->hruler),
|
||||
f * min_x,
|
||||
f * max_x,
|
||||
// f * min_x,
|
||||
20); // max_size
|
||||
|
||||
if (p->surface_unit == SANE_UNIT_PIXEL)
|
||||
f = 1.0 / yscale;
|
||||
|
@ -395,11 +451,16 @@ preview_area_resize (GtkWidget * widget)
|
|||
f = yscale * p->preview_height / p->image_height;
|
||||
else
|
||||
f = 1.0;
|
||||
gtk_ruler_set_range (GTK_RULER (p->vruler), f * min_y, f * max_y, f * min_y,
|
||||
/* max_size */ 20);
|
||||
|
||||
paint_image (p);
|
||||
gtk3_ruler_set_range (GTK3_RULER (p->vruler),
|
||||
f * min_y,
|
||||
f * max_y,
|
||||
// f * min_y,
|
||||
20); // max_size
|
||||
|
||||
update_selection (p);
|
||||
paint_image (p);
|
||||
//gtk_widget_queue_draw (p->window);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -545,6 +606,7 @@ increment_image_y (Preview * p)
|
|||
extra_size = 3 * 32 * p->image_width;
|
||||
p->image_height += 32;
|
||||
p->image_data = realloc (p->image_data, offset + extra_size);
|
||||
p->preview_data = realloc (p->preview_data, offset + extra_size);
|
||||
if (!p->image_data)
|
||||
{
|
||||
snprintf (buf, sizeof (buf),
|
||||
|
@ -555,12 +617,13 @@ increment_image_y (Preview * p)
|
|||
return -1;
|
||||
}
|
||||
memset (p->image_data + offset, 0xff, extra_size);
|
||||
memset (p->preview_data + offset, 0xff, extra_size);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void
|
||||
input_available (gpointer data, gint source, GdkInputCondition cond)
|
||||
static gboolean
|
||||
input_available (gint source, GIOCondition cond, gpointer data)
|
||||
{
|
||||
SANE_Status status;
|
||||
Preview *p = data;
|
||||
|
@ -589,11 +652,14 @@ input_available (gpointer data, gint source, GdkInputCondition cond)
|
|||
{
|
||||
display_maybe (p);
|
||||
while (gtk_events_pending ())
|
||||
gtk_main_iteration ();
|
||||
{
|
||||
gtk_widget_queue_draw(p->window);
|
||||
gtk_main_iteration ();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
gdk_input_remove (p->input_tag);
|
||||
g_source_remove (p->input_tag);
|
||||
p->input_tag = -1;
|
||||
}
|
||||
scan_start (p);
|
||||
|
@ -602,12 +668,13 @@ input_available (gpointer data, gint source, GdkInputCondition cond)
|
|||
}
|
||||
else
|
||||
{
|
||||
snprintf (buf, sizeof (buf), "Error during read: %s.",
|
||||
char errbuf[100];
|
||||
snprintf (errbuf, sizeof (errbuf), "Error during read: %s.",
|
||||
sane_strstatus (status));
|
||||
gsg_error (buf);
|
||||
gsg_error (errbuf);
|
||||
}
|
||||
scan_done (p);
|
||||
return;
|
||||
return TRUE;
|
||||
}
|
||||
if (!len) /* out of data for now */
|
||||
{
|
||||
|
@ -615,7 +682,10 @@ input_available (gpointer data, gint source, GdkInputCondition cond)
|
|||
{
|
||||
display_maybe (p);
|
||||
while (gtk_events_pending ())
|
||||
gtk_main_iteration ();
|
||||
{
|
||||
gtk_widget_queue_draw(p->window);
|
||||
gtk_main_iteration ();
|
||||
}
|
||||
continue;
|
||||
}
|
||||
else
|
||||
|
@ -651,7 +721,7 @@ input_available (gpointer data, gint source, GdkInputCondition cond)
|
|||
if (++p->image_x >= p->image_width)
|
||||
{
|
||||
if (increment_image_y (p) < 0)
|
||||
return;
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -666,7 +736,7 @@ input_available (gpointer data, gint source, GdkInputCondition cond)
|
|||
{
|
||||
if (++p->image_x >= p->image_width
|
||||
&& increment_image_y (p) < 0)
|
||||
return;
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
@ -680,7 +750,7 @@ input_available (gpointer data, gint source, GdkInputCondition cond)
|
|||
{
|
||||
if (++p->image_x >= p->image_width
|
||||
&& increment_image_y (p) < 0)
|
||||
return;
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
@ -706,7 +776,7 @@ input_available (gpointer data, gint source, GdkInputCondition cond)
|
|||
if (++p->image_x >= p->image_width)
|
||||
{
|
||||
if (increment_image_y (p) < 0)
|
||||
return;
|
||||
return FALSE;
|
||||
break; /* skip padding bits */
|
||||
}
|
||||
}
|
||||
|
@ -722,7 +792,7 @@ input_available (gpointer data, gint source, GdkInputCondition cond)
|
|||
p->image_data[p->image_offset++] = gl;
|
||||
if (++p->image_x >= p->image_width
|
||||
&& increment_image_y (p) < 0)
|
||||
return;
|
||||
return FALSE;
|
||||
}
|
||||
break;
|
||||
case 16:
|
||||
|
@ -739,7 +809,7 @@ input_available (gpointer data, gint source, GdkInputCondition cond)
|
|||
{
|
||||
if (++p->image_x >= p->image_width
|
||||
&& increment_image_y (p) < 0)
|
||||
return;
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
@ -766,7 +836,7 @@ input_available (gpointer data, gint source, GdkInputCondition cond)
|
|||
p->image_offset += 3;
|
||||
if (++p->image_x >= p->image_width
|
||||
&& increment_image_y (p) < 0)
|
||||
return;
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
@ -778,7 +848,7 @@ input_available (gpointer data, gint source, GdkInputCondition cond)
|
|||
p->image_offset += 3;
|
||||
if (++p->image_x >= p->image_width
|
||||
&& increment_image_y (p) < 0)
|
||||
return;
|
||||
return FALSE;
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -795,7 +865,7 @@ input_available (gpointer data, gint source, GdkInputCondition cond)
|
|||
{
|
||||
if (++p->image_x >= p->image_width
|
||||
&& increment_image_y (p) < 0)
|
||||
return;
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
@ -809,24 +879,32 @@ input_available (gpointer data, gint source, GdkInputCondition cond)
|
|||
fprintf (stderr, "preview.input_available: bad frame format %d\n",
|
||||
p->params.format);
|
||||
scan_done (p);
|
||||
return;
|
||||
return FALSE;
|
||||
}
|
||||
if (p->input_tag < 0)
|
||||
{
|
||||
display_maybe (p);
|
||||
while (gtk_events_pending ())
|
||||
gtk_main_iteration ();
|
||||
{
|
||||
gtk_widget_queue_draw(p->window);
|
||||
gtk_main_iteration ();
|
||||
}
|
||||
}
|
||||
}
|
||||
display_maybe (p);
|
||||
return;
|
||||
p->scanning = FALSE;
|
||||
return TRUE;
|
||||
|
||||
bad_depth:
|
||||
snprintf (buf, sizeof (buf), "Preview cannot handle depth %d.",
|
||||
p->params.depth);
|
||||
gsg_error (buf);
|
||||
{
|
||||
char errbuf[100];
|
||||
|
||||
snprintf (errbuf, sizeof (errbuf), "Preview cannot handle depth %d.",
|
||||
p->params.depth);
|
||||
gsg_error (errbuf);
|
||||
}
|
||||
scan_done (p);
|
||||
return;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -837,7 +915,7 @@ scan_done (Preview * p)
|
|||
p->scanning = FALSE;
|
||||
if (p->input_tag >= 0)
|
||||
{
|
||||
gdk_input_remove (p->input_tag);
|
||||
g_source_remove (p->input_tag);
|
||||
p->input_tag = -1;
|
||||
}
|
||||
sane_cancel (p->dialog->dev);
|
||||
|
@ -852,7 +930,7 @@ scan_done (Preview * p)
|
|||
gtk_widget_set_sensitive (p->cancel, FALSE);
|
||||
gtk_widget_set_sensitive (p->preview, TRUE);
|
||||
gsg_set_sensitivity (p->dialog, TRUE);
|
||||
gtk_widget_set_sensitive (p->dialog->window->parent->parent->parent, TRUE);
|
||||
// gtk_widget_set_sensitive (p->dialog->window->parent->parent->parent, TRUE);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -861,51 +939,61 @@ scan_start (Preview * p)
|
|||
SANE_Handle dev = p->dialog->dev;
|
||||
SANE_Status status;
|
||||
char buf[256];
|
||||
int fd, y;
|
||||
Progress_t *progress;
|
||||
#ifdef HAVE_SYS_TIME_H
|
||||
struct timeval start, current;
|
||||
#endif
|
||||
int fd;
|
||||
|
||||
p->scanning = TRUE;
|
||||
gtk_widget_set_sensitive (p->cancel, TRUE);
|
||||
gtk_widget_set_sensitive (p->preview, FALSE);
|
||||
gsg_set_sensitivity (p->dialog, FALSE);
|
||||
gtk_widget_set_sensitive (p->dialog->window->parent->parent->parent, FALSE);
|
||||
// gtk_widget_set_sensitive (p->dialog->window->parent->parent->parent, FALSE);
|
||||
|
||||
if (p->preview_data == NULL)
|
||||
p->preview_data = malloc (p->image_width * p->image_height * 3);
|
||||
else
|
||||
p->preview_data = realloc (p->preview_data, 3 * p->image_width * p->image_height);
|
||||
/* clear old preview: */
|
||||
memset (p->preview_row, 0xff, 3 * p->preview_width);
|
||||
for (y = 0; y < p->preview_height; ++y)
|
||||
gtk_preview_draw_row (GTK_PREVIEW (p->window), p->preview_row,
|
||||
0, y, p->preview_width);
|
||||
memset (p->preview_data, 0xff, 3 * p->image_width * p->image_height);
|
||||
gtk_widget_queue_draw (p->window);
|
||||
|
||||
if (p->input_tag >= 0)
|
||||
{
|
||||
gdk_input_remove (p->input_tag);
|
||||
g_source_remove (p->input_tag);
|
||||
p->input_tag = -1;
|
||||
}
|
||||
|
||||
gsg_sync (p->dialog);
|
||||
|
||||
status = sane_start (dev);
|
||||
|
||||
#ifdef SANE_STATUS_WARMING_UP
|
||||
Progress_t *progress;
|
||||
|
||||
if (status == SANE_STATUS_WARMING_UP)
|
||||
{
|
||||
snprintf (buf, sizeof (buf), "Scanner is warming up.");
|
||||
progress =
|
||||
progress_new ("Warming up ...", buf, GTK_WINDOW(p->top), NULL, 0);
|
||||
#ifdef HAVE_SYS_TIME_H
|
||||
|
||||
# ifdef HAVE_SYS_TIME_H
|
||||
struct timeval start, current;
|
||||
gettimeofday (&start, NULL);
|
||||
#endif
|
||||
# endif
|
||||
|
||||
while (status == SANE_STATUS_WARMING_UP)
|
||||
{
|
||||
#ifdef HAVE_SYS_TIME_H
|
||||
|
||||
# ifdef HAVE_SYS_TIME_H
|
||||
gettimeofday (¤t, NULL);
|
||||
/* we assume that warming up won't exceed 60 seconds */
|
||||
progress_update (progress,
|
||||
(current.tv_sec - start.tv_sec) / (gfloat) 60);
|
||||
#endif
|
||||
# endif
|
||||
|
||||
while (gtk_events_pending ())
|
||||
gtk_main_iteration ();
|
||||
{
|
||||
gtk_widget_queue_draw(p->window);
|
||||
gtk_main_iteration ();
|
||||
}
|
||||
status = sane_start (dev);
|
||||
}
|
||||
progress_free (progress);
|
||||
|
@ -960,6 +1048,7 @@ scan_start (Preview * p)
|
|||
p->image_height = 32; /* may have to adjust as we go... */
|
||||
|
||||
p->image_data = malloc (p->image_width * p->image_height * 3);
|
||||
p->preview_data = malloc (p->preview_width * p->image_height * 3);
|
||||
if (!p->image_data)
|
||||
{
|
||||
snprintf (buf, sizeof (buf),
|
||||
|
@ -975,17 +1064,21 @@ scan_start (Preview * p)
|
|||
{
|
||||
p->previous_selection = p->selection;
|
||||
p->selection.active = FALSE;
|
||||
draw_selection (p);
|
||||
gtk_widget_queue_draw (p->window);
|
||||
}
|
||||
p->scanning = TRUE;
|
||||
|
||||
if (sane_set_io_mode (dev, SANE_TRUE) == SANE_STATUS_GOOD
|
||||
&& sane_get_select_fd (dev, &fd) == SANE_STATUS_GOOD)
|
||||
{
|
||||
GIOChannel *chan = g_io_channel_unix_new (fd);
|
||||
p->input_tag =
|
||||
gdk_input_add (fd, GDK_INPUT_READ | GDK_INPUT_EXCEPTION,
|
||||
input_available, p);
|
||||
g_io_add_watch (chan, G_IO_IN | G_IO_HUP | G_IO_ERR | G_IO_PRI,
|
||||
(GIOFunc) input_available, p);
|
||||
g_io_channel_unref(chan);
|
||||
}
|
||||
else
|
||||
input_available (p, -1, GDK_INPUT_READ);
|
||||
input_available (-1, G_IO_IN, p);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -1065,6 +1158,7 @@ restore_preview_image (Preview * p)
|
|||
if ((width == 0) || (height == 0))
|
||||
return;
|
||||
p->image_data = malloc (3 * width * height);
|
||||
p->preview_data = malloc (3 * width * height);
|
||||
if (!p->image_data)
|
||||
return;
|
||||
|
||||
|
@ -1076,53 +1170,49 @@ restore_preview_image (Preview * p)
|
|||
|
||||
/* This is executed _after_ the gtkpreview's expose routine. */
|
||||
static gint
|
||||
expose_handler (GtkWidget * window, GdkEvent * event, gpointer data)
|
||||
expose_handler (GtkWidget * window, cairo_t *cr, gpointer data)
|
||||
{
|
||||
Preview *p = data;
|
||||
|
||||
p->selection.active = FALSE;
|
||||
if (p->preview_data == NULL) return FALSE;
|
||||
|
||||
GdkPixbuf* pixbuf = gdk_pixbuf_new_from_data(p->preview_data, GDK_COLORSPACE_RGB, FALSE, 8, p->preview_width,
|
||||
p->preview_height, p->preview_width * 3, NULL/*preview_pixbuf_data_destroy*/, NULL);
|
||||
gdk_cairo_set_source_pixbuf (cr, pixbuf, 0, 0);
|
||||
cairo_paint(cr);
|
||||
g_object_unref(pixbuf);
|
||||
|
||||
update_selection (p);
|
||||
draw_selection (p, cr);
|
||||
|
||||
p->selection.active = FALSE;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static gint
|
||||
event_handler (GtkWidget * window, GdkEvent * event, gpointer data)
|
||||
static gboolean
|
||||
button_press_handler(GtkWidget *window,
|
||||
GdkEvent *event, gpointer data)
|
||||
{
|
||||
Preview *p = data;
|
||||
int i, tmp;
|
||||
|
||||
if (event->type == GDK_EXPOSE)
|
||||
{
|
||||
if (!p->gc)
|
||||
{
|
||||
p->gc = gdk_gc_new (p->window->window);
|
||||
gdk_gc_set_function (p->gc, GDK_INVERT);
|
||||
gdk_gc_set_line_attributes (p->gc, 1, GDK_LINE_ON_OFF_DASH,
|
||||
GDK_CAP_BUTT, GDK_JOIN_MITER);
|
||||
paint_image (p);
|
||||
}
|
||||
else
|
||||
{
|
||||
p->selection.active = FALSE;
|
||||
draw_selection (p);
|
||||
}
|
||||
}
|
||||
else if (!p->scanning)
|
||||
switch (event->type)
|
||||
{
|
||||
case GDK_UNMAP:
|
||||
case GDK_MAP:
|
||||
break;
|
||||
|
||||
case GDK_BUTTON_PRESS:
|
||||
Preview *p = data;
|
||||
if (p->scanning)
|
||||
return FALSE;
|
||||
p->selection.coord[0] = event->button.x;
|
||||
p->selection.coord[1] = event->button.y;
|
||||
p->selection_drag = TRUE;
|
||||
break;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
case GDK_BUTTON_RELEASE:
|
||||
if (!p->selection_drag)
|
||||
break;
|
||||
static gboolean
|
||||
button_release_handler (GtkWidget *window,
|
||||
GdkEvent *event, gpointer data)
|
||||
{
|
||||
Preview *p = data;
|
||||
int i, tmp;
|
||||
|
||||
if (p->scanning == TRUE)
|
||||
return FALSE;
|
||||
if (p->selection_drag == FALSE)
|
||||
return FALSE;
|
||||
p->selection_drag = FALSE;
|
||||
|
||||
p->selection.coord[2] = event->button.x;
|
||||
|
@ -1149,28 +1239,25 @@ event_handler (GtkWidget * window, GdkEvent * event, gpointer data)
|
|||
if (p->selection.coord[3] >= p->preview_height)
|
||||
p->selection.coord[3] = p->preview_height - 1;
|
||||
}
|
||||
draw_selection (p);
|
||||
establish_selection (p);
|
||||
break;
|
||||
gtk_widget_queue_draw (p->window);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
case GDK_MOTION_NOTIFY:
|
||||
if (p->selection_drag)
|
||||
static gboolean
|
||||
motion_handler (GtkWidget *window,
|
||||
GdkEvent *event, gpointer data)
|
||||
{
|
||||
Preview *p = data;
|
||||
if (p->scanning == TRUE) return FALSE;
|
||||
if (p->selection_drag == TRUE)
|
||||
{
|
||||
p->selection.active = TRUE;
|
||||
p->selection.coord[2] = event->motion.x;
|
||||
p->selection.coord[3] = event->motion.y;
|
||||
draw_selection (p);
|
||||
gtk_widget_queue_draw (p->window);
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
#if 0
|
||||
fprintf (stderr, "event_handler: unhandled event type %d\n",
|
||||
event->type);
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
return FALSE;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -1198,9 +1285,7 @@ preview_new (GSGDialog * dialog)
|
|||
{
|
||||
static int first_time = 1;
|
||||
GtkWidget *table, *frame;
|
||||
GtkSignalFunc signal_func;
|
||||
GtkWidgetClass *class;
|
||||
GtkBox *vbox, *hbox;
|
||||
GtkBox *vbox;
|
||||
Preview *p;
|
||||
|
||||
p = malloc (sizeof (*p));
|
||||
|
@ -1209,113 +1294,99 @@ preview_new (GSGDialog * dialog)
|
|||
memset (p, 0, sizeof (*p));
|
||||
|
||||
p->dialog = dialog;
|
||||
p->surface_unit = SANE_UNIT_MM;
|
||||
p->input_tag = -1;
|
||||
p->image_data = NULL;
|
||||
p->preview_data = NULL;
|
||||
p->preview_row = NULL;
|
||||
p->top = NULL;
|
||||
p->scanning = FALSE;
|
||||
|
||||
if (first_time)
|
||||
{
|
||||
first_time = 0;
|
||||
gtk_preview_set_gamma (preferences.preview_gamma);
|
||||
gtk_preview_set_install_cmap (preferences.preview_own_cmap);
|
||||
// gtk_preview_set_gamma (preferences.preview_gamma);
|
||||
// gtk_preview_set_install_cmap (preferences.preview_own_cmap);
|
||||
}
|
||||
|
||||
#ifndef XSERVER_WITH_BUGGY_VISUALS
|
||||
gtk_widget_push_visual (gtk_preview_get_visual ());
|
||||
#endif
|
||||
gtk_widget_push_colormap (gtk_preview_get_cmap ());
|
||||
|
||||
p->top = gtk_dialog_new ();
|
||||
gtk_signal_connect (GTK_OBJECT (p->top), "destroy",
|
||||
GTK_SIGNAL_FUNC (top_destroyed), p);
|
||||
g_signal_connect (G_OBJECT (p->top), "destroy",
|
||||
G_CALLBACK (top_destroyed), p);
|
||||
gtk_window_set_title (GTK_WINDOW (p->top), "xscanimage preview");
|
||||
vbox = GTK_BOX (GTK_DIALOG (p->top)->vbox);
|
||||
hbox = GTK_BOX (GTK_DIALOG (p->top)->action_area);
|
||||
vbox = GTK_BOX (gtk_dialog_get_content_area(GTK_DIALOG (p->top)));
|
||||
|
||||
/* 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_border_width (GTK_CONTAINER (table), 2);
|
||||
gtk_box_pack_start (vbox, table, /* expand */ TRUE, /* fill */ TRUE,
|
||||
/* padding */ 0);
|
||||
// construct the preview area (table with sliders & preview window)
|
||||
table = gtk_grid_new ();
|
||||
gtk_grid_set_column_spacing (GTK_GRID (table), 1);
|
||||
gtk_grid_set_row_spacing (GTK_GRID (table), 1);
|
||||
gtk_container_set_border_width (GTK_CONTAINER (table), 2);
|
||||
gtk_box_pack_start (vbox, table, TRUE, TRUE, 0);
|
||||
|
||||
/* 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_grid_attach (GTK_GRID (table), frame, 0, 0, 1, 1);
|
||||
|
||||
/* 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);
|
||||
p->hruler = gtk3_ruler_new (GTK_ORIENTATION_HORIZONTAL);
|
||||
gtk_grid_attach (GTK_GRID (table), p->hruler, 1, 0, 1, 1);
|
||||
gsg_widget_placement(GTK_WIDGET (p->hruler), GTK_ALIGN_FILL, GTK_ALIGN_CENTER, 0, 0, 0, 0);
|
||||
|
||||
/* 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);
|
||||
p->vruler = gtk3_ruler_new (GTK_ORIENTATION_VERTICAL);
|
||||
gtk_grid_attach (GTK_GRID (table), p->vruler, 0, 1, 1, 1);
|
||||
gsg_widget_placement(GTK_WIDGET (p->vruler), GTK_ALIGN_CENTER, GTK_ALIGN_FILL, 0, 0, 0, 0);
|
||||
|
||||
/* the preview area */
|
||||
p->window = gtk_drawing_area_new ();
|
||||
gtk_widget_set_app_paintable(p->window, TRUE);
|
||||
gsg_widget_placement(GTK_WIDGET (p->window), GTK_ALIGN_FILL, GTK_ALIGN_FILL, 0, 0, 0, 0);
|
||||
|
||||
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);
|
||||
gtk_signal_connect (GTK_OBJECT (p->window), "event",
|
||||
(GtkSignalFunc) event_handler, p);
|
||||
gtk_signal_connect_after (GTK_OBJECT (p->window), "expose_event",
|
||||
(GtkSignalFunc) expose_handler, p);
|
||||
gtk_signal_connect_after (GTK_OBJECT (p->window), "size_allocate",
|
||||
(GtkSignalFunc) preview_area_resize, 0);
|
||||
gtk_object_set_data (GTK_OBJECT (p->window), "PreviewPointer", p);
|
||||
GDK_BUTTON_PRESS_MASK |
|
||||
GDK_BUTTON_RELEASE_MASK);
|
||||
|
||||
/* Connect the motion-notify events of the preview area with the
|
||||
rulers. Nifty stuff! */
|
||||
g_signal_connect_after (G_OBJECT (p->window), "draw",
|
||||
G_CALLBACK(expose_handler), p);
|
||||
|
||||
#if GTK_MAJOR_VERSION == 2
|
||||
class = GTK_WIDGET_CLASS (GTK_OBJECT_GET_CLASS (GTK_OBJECT (p->hruler)));
|
||||
#else
|
||||
class = GTK_WIDGET_CLASS (GTK_OBJECT (p->hruler)->klass);
|
||||
#endif /* GTK_MAJOR_VERSION == 2 */
|
||||
signal_func = (GtkSignalFunc) class->motion_notify_event;
|
||||
gtk_signal_connect_object (GTK_OBJECT (p->window), "motion_notify_event",
|
||||
signal_func, GTK_OBJECT (p->hruler));
|
||||
g_signal_connect(G_OBJECT(p->window), "button_press_event",
|
||||
G_CALLBACK(button_press_handler), p);
|
||||
g_signal_connect(G_OBJECT(p->window), "motion_notify_event",
|
||||
G_CALLBACK(motion_handler), p);
|
||||
g_signal_connect(G_OBJECT(p->window), "button_release_event",
|
||||
G_CALLBACK(button_release_handler), p);
|
||||
g_signal_connect (p->window ,"configure-event",
|
||||
G_CALLBACK(preview_area_resize), p);
|
||||
|
||||
#if GTK_MAJOR_VERSION == 2
|
||||
class = GTK_WIDGET_CLASS (GTK_OBJECT_GET_CLASS (GTK_OBJECT (p->vruler)));
|
||||
#else
|
||||
class = GTK_WIDGET_CLASS (GTK_OBJECT (p->vruler)->klass);
|
||||
#endif /* GTK_MAJOR_VERSION == 2 */
|
||||
signal_func = (GtkSignalFunc) class->motion_notify_event;
|
||||
gtk_signal_connect_object (GTK_OBJECT (p->window), "motion_notify_event",
|
||||
signal_func, GTK_OBJECT (p->vruler));
|
||||
gtk3_ruler_add_track_widget (GTK3_RULER (p->hruler), p->window);
|
||||
gtk3_ruler_add_track_widget (GTK3_RULER (p->vruler), p->window);
|
||||
|
||||
p->viewport = gtk_frame_new ( /* label */ 0);
|
||||
p->viewport = gtk_frame_new ( 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);
|
||||
gtk_grid_attach (GTK_GRID (table), p->viewport, 1, 1, 1, 1);
|
||||
gsg_widget_placement(GTK_WIDGET (p->viewport), GTK_ALIGN_FILL, GTK_ALIGN_FILL, 0, 0, 0, 0);
|
||||
gtk_widget_set_vexpand (GTK_WIDGET (p->viewport),TRUE);
|
||||
gtk_widget_set_hexpand (GTK_WIDGET (p->viewport),TRUE);
|
||||
|
||||
preview_update (p);
|
||||
|
||||
/* fill in action area: */
|
||||
|
||||
/* Preview button */
|
||||
p->preview = gtk_button_new_with_label ("Acquire Preview");
|
||||
gtk_signal_connect (GTK_OBJECT (p->preview), "clicked",
|
||||
(GtkSignalFunc) start_button_clicked, p);
|
||||
gtk_box_pack_start (GTK_BOX (hbox), p->preview, TRUE, TRUE, 0);
|
||||
p->preview = gtk_dialog_add_button (GTK_DIALOG (p->top), "Acquire Preview",GTK_RESPONSE_OK);
|
||||
g_signal_connect (G_OBJECT (p->preview), "clicked",
|
||||
G_CALLBACK (start_button_clicked), p);
|
||||
gtk_widget_show (p->preview);
|
||||
|
||||
/* Cancel button */
|
||||
p->cancel = gtk_button_new_with_label ("Cancel Preview");
|
||||
gtk_signal_connect (GTK_OBJECT (p->cancel), "clicked",
|
||||
(GtkSignalFunc) cancel_button_clicked, p);
|
||||
gtk_box_pack_start (GTK_BOX (hbox), p->cancel, TRUE, TRUE, 0);
|
||||
p->cancel = gtk_dialog_add_button (GTK_DIALOG (p->top), "Cancel Preview", GTK_RESPONSE_CANCEL);
|
||||
g_signal_connect (G_OBJECT (p->cancel), "clicked",
|
||||
G_CALLBACK (cancel_button_clicked), p);
|
||||
gtk_widget_set_sensitive (p->cancel, FALSE);
|
||||
|
||||
gtk_widget_show (p->cancel);
|
||||
|
@ -1327,10 +1398,6 @@ preview_new (GSGDialog * dialog)
|
|||
gtk_widget_show (table);
|
||||
gtk_widget_show (p->top);
|
||||
|
||||
gtk_widget_pop_colormap ();
|
||||
#ifndef XSERVER_WITH_BUGGY_VISUALS
|
||||
gtk_widget_pop_visual ();
|
||||
#endif
|
||||
return p;
|
||||
}
|
||||
|
||||
|
@ -1383,7 +1450,9 @@ preview_update (Preview * p)
|
|||
if (surface_changed && p->image_data)
|
||||
{
|
||||
free (p->image_data);
|
||||
free (p->preview_data);
|
||||
p->image_data = 0;
|
||||
p->preview_data = 0;
|
||||
p->image_width = 0;
|
||||
p->image_height = 0;
|
||||
}
|
||||
|
@ -1412,13 +1481,17 @@ preview_update (Preview * p)
|
|||
|
||||
if (surface_changed)
|
||||
{
|
||||
max_width = 0.5 * gdk_screen_width ();
|
||||
max_height = 0.5 * gdk_screen_height ();
|
||||
int width, height;
|
||||
screen_size_get_dimensions (&width, &height);
|
||||
max_width = 0.5 * (double)width;
|
||||
max_height = 0.5 * (double)height;
|
||||
}
|
||||
else
|
||||
{
|
||||
max_width = p->window->allocation.width;
|
||||
max_height = p->window->allocation.height;
|
||||
GtkAllocation alloc;
|
||||
gtk_widget_get_allocated_size (p->window, &alloc, NULL);
|
||||
max_width = alloc.width;
|
||||
max_height = alloc.height;
|
||||
}
|
||||
|
||||
if (p->surface_unit != SANE_UNIT_PIXEL)
|
||||
|
@ -1454,15 +1527,16 @@ preview_update (Preview * p)
|
|||
p->preview_height = height + 0.5;
|
||||
if (surface_changed)
|
||||
{
|
||||
gtk_widget_set_usize (GTK_WIDGET (p->window),
|
||||
gtk_widget_set_size_request (GTK_WIDGET (p->window),
|
||||
p->preview_width, p->preview_height);
|
||||
if (GTK_WIDGET_DRAWABLE (p->window))
|
||||
preview_area_resize (p->window);
|
||||
if (gtk_widget_is_drawable(GTK_WIDGET(p->window)))
|
||||
preview_area_resize (p->window, NULL, p);
|
||||
|
||||
if (preferences.preserve_preview)
|
||||
restore_preview_image (p);
|
||||
}
|
||||
update_selection (p);
|
||||
gtk_widget_queue_draw (p->window);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -1556,10 +1630,13 @@ preview_destroy (Preview * p)
|
|||
}
|
||||
if (p->image_data)
|
||||
free (p->image_data);
|
||||
p->image_data = NULL;
|
||||
if (p->preview_data)
|
||||
free (p->preview_data);
|
||||
p->preview_data = NULL;
|
||||
if (p->preview_row)
|
||||
free (p->preview_row);
|
||||
if (p->gc)
|
||||
gdk_gc_destroy (p->gc);
|
||||
p->preview_row = NULL;
|
||||
if (p->top)
|
||||
gtk_widget_destroy (p->top);
|
||||
free (p);
|
||||
|
|
|
@ -21,8 +21,18 @@
|
|||
#include <sys/types.h>
|
||||
|
||||
#include "../include/sane/config.h"
|
||||
#include "../libgtk/gtk3ruler.h"
|
||||
#include <sane/sane.h>
|
||||
|
||||
/*
|
||||
#ifndef SANE_STATUS_WARMING_UP
|
||||
#define SANE_STATUS_WARMING_UP 12 // lamp not ready, please retry
|
||||
#endif
|
||||
#ifndef SANE_STATUS_HW_LOCKED
|
||||
#define SANE_STATUS_HW_LOCKED 13 // scanner mechanism locked for transport
|
||||
#endif
|
||||
*/
|
||||
|
||||
typedef struct
|
||||
{
|
||||
GSGDialog *dialog; /* the dialog for this preview */
|
||||
|
@ -52,13 +62,13 @@ typedef struct
|
|||
int image_width;
|
||||
int image_height;
|
||||
u_char *image_data; /* 3 * image_width * image_height bytes */
|
||||
u_char *preview_data; /* 3 * image_width * image_height bytes */
|
||||
|
||||
GdkGC *gc;
|
||||
int selection_drag;
|
||||
struct
|
||||
{
|
||||
int active;
|
||||
int coord[4];
|
||||
double coord[4];
|
||||
}
|
||||
selection, previous_selection;
|
||||
|
||||
|
@ -69,6 +79,9 @@ typedef struct
|
|||
GtkWidget *window; /* the preview window */
|
||||
GtkWidget *cancel; /* the cancel button */
|
||||
GtkWidget *preview; /* the preview button */
|
||||
|
||||
cairo_surface_t *surface_cairo;
|
||||
gboolean drawable;
|
||||
}
|
||||
Preview;
|
||||
|
||||
|
|
|
@ -37,10 +37,10 @@ progress_cancel (GtkWidget * widget, gpointer data)
|
|||
|
||||
Progress_t *
|
||||
progress_new (char *title, char *text, GtkWindow * parent,
|
||||
GtkSignalFunc callback, gpointer callback_data)
|
||||
GCallback callback, gpointer callback_data)
|
||||
{
|
||||
GtkWidget *button, *label;
|
||||
GtkBox *vbox, *hbox;
|
||||
GtkBox *vbox;
|
||||
Progress_t *p;
|
||||
#if GTK_MAJOR_VERSION < 2
|
||||
gint x, y;
|
||||
|
@ -51,39 +51,34 @@ progress_new (char *title, char *text, GtkWindow * parent,
|
|||
p->firstTime = 0;
|
||||
|
||||
p->shell = gtk_dialog_new ();
|
||||
#if GTK_MAJOR_VERSION < 2
|
||||
gtk_window_get_position (GTK_WINDOW (parent), &x, &y);
|
||||
gtk_widget_set_uposition (p->shell, x, y);
|
||||
#else
|
||||
gtk_window_set_transient_for (GTK_WINDOW (p->shell), parent);
|
||||
#endif
|
||||
gtk_window_set_title (GTK_WINDOW (p->shell), title);
|
||||
vbox = GTK_BOX (GTK_DIALOG (p->shell)->vbox);
|
||||
hbox = GTK_BOX (GTK_DIALOG (p->shell)->action_area);
|
||||
vbox = GTK_BOX (gtk_dialog_get_content_area(GTK_DIALOG (p->shell)));
|
||||
|
||||
gtk_container_border_width (GTK_CONTAINER (vbox), 7);
|
||||
gtk_container_set_border_width (GTK_CONTAINER (vbox), 7);
|
||||
|
||||
label = gtk_label_new (text);
|
||||
gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
|
||||
gtk_label_set_xalign(GTK_LABEL(label), 0.0);
|
||||
gtk_label_set_yalign(GTK_LABEL(label), 0.5);
|
||||
gtk_box_pack_start (vbox, label, FALSE, TRUE, 0);
|
||||
|
||||
p->pbar = gtk_progress_bar_new ();
|
||||
gtk_widget_set_usize (p->pbar, 200, 20);
|
||||
gtk_widget_set_size_request (p->pbar, 200, 20);
|
||||
gtk_box_pack_start (vbox, p->pbar, TRUE, TRUE, 0);
|
||||
|
||||
#ifdef HAVE_SYS_TIME_H
|
||||
p->etaIndicator = gtk_label_new (ETA_LABEL ": ?");
|
||||
gtk_misc_set_alignment (GTK_MISC (p->etaIndicator), 0.0, 0.5);
|
||||
gtk_label_set_xalign(GTK_LABEL(p->etaIndicator), 0.0);
|
||||
gtk_label_set_yalign(GTK_LABEL(p->etaIndicator), 0.5);
|
||||
gtk_box_pack_start (vbox, p->etaIndicator, FALSE, TRUE, 0);
|
||||
#endif
|
||||
|
||||
/* no cancel button if no callback */
|
||||
if (callback != NULL)
|
||||
{
|
||||
button = gtk_toggle_button_new_with_label ("Cancel");
|
||||
gtk_signal_connect (GTK_OBJECT (button), "clicked",
|
||||
(GtkSignalFunc) progress_cancel, p);
|
||||
gtk_box_pack_start (hbox, button, TRUE, TRUE, 0);
|
||||
button = gtk_dialog_add_button (GTK_DIALOG (p->shell), "Cancel", GTK_RESPONSE_CANCEL);
|
||||
g_signal_connect (G_OBJECT (button), "clicked",
|
||||
G_CALLBACK (progress_cancel), p);
|
||||
}
|
||||
|
||||
gtk_widget_show (label);
|
||||
|
@ -94,7 +89,7 @@ progress_new (char *title, char *text, GtkWindow * parent,
|
|||
if (callback != NULL)
|
||||
gtk_widget_show (button);
|
||||
gtk_widget_show (GTK_WIDGET (p->shell));
|
||||
gtk_progress_bar_update (GTK_PROGRESS_BAR (p->pbar), 0);
|
||||
gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR (p->pbar), 0.0);
|
||||
return p;
|
||||
}
|
||||
|
||||
|
@ -114,7 +109,7 @@ progress_update (Progress_t * p, gfloat newval)
|
|||
#ifdef HAVE_SYS_TIME_H
|
||||
struct timeval tv;
|
||||
int now;
|
||||
char buff[40];
|
||||
char buff[100];
|
||||
int remaining;
|
||||
#endif
|
||||
|
||||
|
@ -123,9 +118,10 @@ progress_update (Progress_t * p, gfloat newval)
|
|||
return;
|
||||
}
|
||||
|
||||
gtk_progress_bar_update (GTK_PROGRESS_BAR (p->pbar), newval);
|
||||
gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR (p->pbar), newval);
|
||||
|
||||
#ifdef HAVE_SYS_TIME_H
|
||||
|
||||
gettimeofday (&tv, NULL);
|
||||
now = tv.tv_sec * 1000 + tv.tv_usec / 1000;
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
|
||||
typedef struct Progress_t
|
||||
{
|
||||
GtkSignalFunc callback;
|
||||
GCallback callback;
|
||||
gpointer callback_data;
|
||||
GtkWidget *shell;
|
||||
GtkWidget *pbar;
|
||||
|
@ -34,7 +34,7 @@ typedef struct Progress_t
|
|||
Progress_t;
|
||||
|
||||
extern Progress_t * progress_new (char *title, char *text, GtkWindow *parent,
|
||||
GtkSignalFunc callback, gpointer callback_data);
|
||||
GCallback callback, gpointer callback_data);
|
||||
extern void progress_free (Progress_t *p);
|
||||
extern void progress_update (Progress_t *p, gfloat newval);
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/* saneadf - a SANE front end for document scanning
|
||||
/* saneadf - a SANE front end for document scanning
|
||||
based on
|
||||
bnhscan by tummy.com and
|
||||
bnhscan by tummy.com and
|
||||
scanimage by Andreas Beck and David Mosberger
|
||||
|
||||
Copyright (C) 1999 Tom Martone
|
||||
|
@ -123,7 +123,7 @@ static struct option basic_options[] =
|
|||
{"help", no_argument, NULL, 'h'},
|
||||
{"verbose", no_argument, NULL, 'v'},
|
||||
{"version", no_argument, NULL, 'V'},
|
||||
{"no-overwrite", no_argument, NULL, 'N'},
|
||||
{"no-overwrite", no_argument, NULL, 'N'},
|
||||
|
||||
{ "output-file", required_argument, 0, 'o' },
|
||||
{ "start-count", required_argument, 0, 's' },
|
||||
|
@ -299,9 +299,9 @@ print_option (SANE_Device *device, int opt_num, char short_name)
|
|||
break;
|
||||
}
|
||||
}
|
||||
if (opt->type == SANE_TYPE_STRING ||
|
||||
opt->type == SANE_TYPE_BOOL ||
|
||||
opt->type == SANE_TYPE_INT ||
|
||||
if (opt->type == SANE_TYPE_STRING ||
|
||||
opt->type == SANE_TYPE_BOOL ||
|
||||
opt->type == SANE_TYPE_INT ||
|
||||
opt->type == SANE_TYPE_FIXED)
|
||||
{
|
||||
/* print current option value */
|
||||
|
@ -705,8 +705,11 @@ scanadf_exit (int status)
|
|||
if (device)
|
||||
{
|
||||
if (verbose > 1)
|
||||
{
|
||||
fprintf (stderr, "Closing device\n");
|
||||
}
|
||||
sane_close (device);
|
||||
device = NULL;
|
||||
}
|
||||
if (verbose > 1)
|
||||
fprintf (stderr, "Calling sane_exit\n");
|
||||
|
@ -913,23 +916,23 @@ get_resolution(SANE_Device *device)
|
|||
{
|
||||
opt = sane_get_option_descriptor (device, resolution_opt);
|
||||
|
||||
sane_control_option (device, resolution_opt,
|
||||
sane_control_option (device, resolution_opt,
|
||||
SANE_ACTION_GET_VALUE, &val, 0);
|
||||
switch (opt->type)
|
||||
{
|
||||
case SANE_TYPE_INT:
|
||||
res = val;
|
||||
break;
|
||||
|
||||
|
||||
case SANE_TYPE_FIXED:
|
||||
res = (SANE_Int) SANE_UNFIX(val);
|
||||
break;
|
||||
|
||||
|
||||
case SANE_TYPE_STRING:
|
||||
case SANE_TYPE_BOOL:
|
||||
default:
|
||||
if (verbose)
|
||||
fprintf(stderr,
|
||||
fprintf(stderr,
|
||||
"Peculiar option data type for resolution, "
|
||||
"using default value.\n");
|
||||
break;
|
||||
|
@ -998,13 +1001,14 @@ exec_script (const char *script, const char* fname, SANE_Bool use_pipe,
|
|||
|
||||
if (use_pipe) {
|
||||
|
||||
pipe(pipefd);
|
||||
if (pipe(pipefd) != 0)
|
||||
use_pipe = 0;
|
||||
}
|
||||
|
||||
/*signal(SIGCHLD, SIG_IGN);*/
|
||||
switch ((pid = fork()))
|
||||
switch ((pid = fork()))
|
||||
{
|
||||
case -1:
|
||||
case -1:
|
||||
/* fork failed */
|
||||
fprintf(stderr, "Error forking: %s (%d)\n", strerror(errno), errno);
|
||||
break;
|
||||
|
@ -1017,9 +1021,9 @@ exec_script (const char *script, const char* fname, SANE_Bool use_pipe,
|
|||
sprintf(cmd, "%s '%s'", script, fname);
|
||||
execle(script, script, fname, NULL, environ);
|
||||
exit(0);
|
||||
|
||||
|
||||
default:
|
||||
if (verbose)
|
||||
if (verbose)
|
||||
fprintf(stderr, "Started script `%s' as pid=%d\n", script, pid);
|
||||
break;
|
||||
}
|
||||
|
@ -1149,7 +1153,7 @@ scan_it_raw (const char *fname, SANE_Bool raw, const char *script,
|
|||
}
|
||||
else
|
||||
{
|
||||
write_pnm_header_to_file (fp, parm.format,
|
||||
write_pnm_header_to_file (fp, parm.format,
|
||||
parm.pixels_per_line,
|
||||
parm.lines, parm.depth);
|
||||
}
|
||||
|
@ -1174,7 +1178,7 @@ scan_it_raw (const char *fname, SANE_Bool raw, const char *script,
|
|||
#endif
|
||||
|
||||
default:
|
||||
/* Default action for unknown frametypes; write them out
|
||||
/* Default action for unknown frametypes; write them out
|
||||
* without a header; issue a warning in verbose mode.
|
||||
* Since we're not writing a header, there's no need to
|
||||
* buffer.
|
||||
|
@ -1210,7 +1214,7 @@ scan_it_raw (const char *fname, SANE_Bool raw, const char *script,
|
|||
else
|
||||
image.height = 0;
|
||||
image.Bpp = 3;
|
||||
if (parm.format == SANE_FRAME_GRAY ||
|
||||
if (parm.format == SANE_FRAME_GRAY ||
|
||||
!sane_isbasicframe(parm.format))
|
||||
image.Bpp = 1;
|
||||
image.x = image.width - 1;
|
||||
|
@ -1226,7 +1230,7 @@ scan_it_raw (const char *fname, SANE_Bool raw, const char *script,
|
|||
offset = parm.format - SANE_FRAME_RED;
|
||||
image.x = image.y = 0;
|
||||
}
|
||||
|
||||
|
||||
while (1)
|
||||
{
|
||||
status = sane_read (device, buffer, sizeof (buffer), &len);
|
||||
|
@ -1309,13 +1313,13 @@ scan_it_raw (const char *fname, SANE_Bool raw, const char *script,
|
|||
if (raw == SANE_FALSE)
|
||||
{
|
||||
/* if we're writing raw, we skip the header */
|
||||
write_pnm_header_to_file (fp, parm.format, image.width,
|
||||
write_pnm_header_to_file (fp, parm.format, image.width,
|
||||
image.height, parm.depth);
|
||||
}
|
||||
fwrite (image.data, image.Bpp, image.height * image.width, fp);
|
||||
}
|
||||
|
||||
if (fp)
|
||||
if (fp)
|
||||
{
|
||||
fclose(fp);
|
||||
fp = NULL;
|
||||
|
@ -1340,7 +1344,7 @@ cleanup:
|
|||
return status;
|
||||
}
|
||||
|
||||
static SANE_Int
|
||||
static SANE_Int
|
||||
scan_docs (int start, int end, int no_overwrite, SANE_Bool raw,
|
||||
const char *outfmt, const char *script, SANE_Bool use_pipe)
|
||||
{
|
||||
|
@ -1350,27 +1354,27 @@ scan_docs (int start, int end, int no_overwrite, SANE_Bool raw,
|
|||
struct stat statbuf;
|
||||
int res;
|
||||
|
||||
while (end < 0 || start <= end)
|
||||
while (end < 0 || start <= end)
|
||||
{
|
||||
snprintf(fname, sizeof (fname), outfmt, start);
|
||||
|
||||
/* does the filename already exist? */
|
||||
if (no_overwrite)
|
||||
if (no_overwrite)
|
||||
{
|
||||
res = stat (fname, &statbuf);
|
||||
if (res == 0)
|
||||
if (res == 0)
|
||||
{
|
||||
status = SANE_STATUS_INVAL;
|
||||
fprintf (stderr, "Filename %s already exists; will not overwrite\n", fname);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Scan the document */
|
||||
if (status == SANE_STATUS_GOOD)
|
||||
if (status == SANE_STATUS_GOOD)
|
||||
status = scan_it_raw(fname, raw, script, use_pipe);
|
||||
|
||||
/* Any scan errors? */
|
||||
if (status == SANE_STATUS_NO_DOCS)
|
||||
if (status == SANE_STATUS_NO_DOCS)
|
||||
{
|
||||
/* out of paper in the hopper; this is our normal exit */
|
||||
status = SANE_STATUS_GOOD;
|
||||
|
@ -1384,7 +1388,7 @@ scan_docs (int start, int end, int no_overwrite, SANE_Bool raw,
|
|||
scannedPages++;
|
||||
start++;
|
||||
}
|
||||
else
|
||||
else
|
||||
{
|
||||
/* unexpected error */
|
||||
fprintf(stderr, "%s\n", sane_strstatus(status));
|
||||
|
@ -1712,11 +1716,10 @@ List of available devices:", prog_name);
|
|||
|
||||
sane_cancel (device);
|
||||
sane_close (device);
|
||||
sane_exit();
|
||||
device = NULL;
|
||||
|
||||
if (scriptWait)
|
||||
while (wait(NULL) != -1);
|
||||
|
||||
return (status == SANE_STATUS_GOOD) ? 0 : 1;
|
||||
}
|
||||
|
||||
|
|
394
src/xcam.c
394
src/xcam.c
|
@ -1,9 +1,9 @@
|
|||
/* xcam -- X-based camera frontend
|
||||
Uses the SANE library.
|
||||
Copyright (C) 1997 David Mosberger and Tristan Tarrant
|
||||
|
||||
|
||||
Update 2005 Gerard Klaver
|
||||
The add_text routine and font_6x11.h file are taken from the (GPLed)
|
||||
The add_text routine and font_6x11.h file are taken from the (GPLed)
|
||||
webcam.c file, part of xawtv, (c) 1998-2002 Gerd Knorr.
|
||||
add_text was modified for this program (xcam_add_text).
|
||||
Update 2008 Gerard Klaver
|
||||
|
@ -72,11 +72,9 @@
|
|||
typedef struct Canvas
|
||||
{
|
||||
GtkWidget *preview;
|
||||
GdkGC *gc;
|
||||
GdkImage *gdk_image;
|
||||
GdkColormap *graylevel_cmap; /* for 8 bit displays */
|
||||
cairo_surface_t *surface;
|
||||
GdkPixbuf *gdk_image;
|
||||
guint32 graylevel[MAX_LUM]; /* graylevel pixels */
|
||||
GdkColormap *cube_cmap;
|
||||
GdkColor cube_colors[5 * 6 * 5];
|
||||
}
|
||||
Canvas;
|
||||
|
@ -166,7 +164,7 @@ static struct option long_options[] = {
|
|||
};
|
||||
|
||||
/* Test if this machine is little endian (from coolscan.c) */
|
||||
/* static gboolean
|
||||
static gboolean
|
||||
calc_little_endian (void)
|
||||
{
|
||||
SANE_Int testvalue = 255;
|
||||
|
@ -175,7 +173,7 @@ calc_little_endian (void)
|
|||
if (*firstbyte == 255)
|
||||
return TRUE;
|
||||
return FALSE;
|
||||
} */
|
||||
}
|
||||
|
||||
#define CANVAS_EVENT_MASK GDK_BUTTON1_MOTION_MASK | \
|
||||
GDK_EXPOSURE_MASK | \
|
||||
|
@ -187,16 +185,17 @@ display_image (Canvas * canvas)
|
|||
{
|
||||
if (canvas->gdk_image)
|
||||
{
|
||||
gdk_draw_image (canvas->preview->window, canvas->gc, canvas->gdk_image,
|
||||
0, 0, 0, 0,
|
||||
canvas->gdk_image->width, canvas->gdk_image->height);
|
||||
gdk_flush ();
|
||||
cairo_t *cr = cairo_create (canvas->surface);
|
||||
gdk_cairo_set_source_pixbuf (cr, canvas->gdk_image, 0, 0);
|
||||
cairo_paint (cr);
|
||||
cairo_destroy (cr);
|
||||
}
|
||||
}
|
||||
|
||||
static gint
|
||||
canvas_events (GtkWidget * widget, GdkEvent * event)
|
||||
{
|
||||
GdkWindow *window = NULL;
|
||||
Canvas *canvas = &win.canvas;
|
||||
if (!canvas)
|
||||
return FALSE;
|
||||
|
@ -204,8 +203,15 @@ canvas_events (GtkWidget * widget, GdkEvent * event)
|
|||
switch (event->type)
|
||||
{
|
||||
case GDK_EXPOSE:
|
||||
if (!canvas->gc)
|
||||
canvas->gc = gdk_gc_new (canvas->preview->window);
|
||||
if (!canvas->surface)
|
||||
{
|
||||
window = gtk_widget_get_window (canvas->preview);
|
||||
canvas->surface = gdk_window_create_similar_surface (
|
||||
window,
|
||||
CAIRO_CONTENT_COLOR,
|
||||
gdk_window_get_width(window),
|
||||
gdk_window_get_height(window));
|
||||
}
|
||||
display_image (canvas);
|
||||
break;
|
||||
|
||||
|
@ -240,15 +246,15 @@ stop_camera (void)
|
|||
sane_cancel (gsg_dialog_get_device (dialog));
|
||||
if (win.gdk_input_tag >= 0)
|
||||
{
|
||||
gdk_input_remove (win.gdk_input_tag);
|
||||
g_source_remove (win.gdk_input_tag);
|
||||
}
|
||||
else
|
||||
win.playing = FALSE;
|
||||
win.gdk_input_tag = -1;
|
||||
if (!win.playing)
|
||||
gtk_label_set (GTK_LABEL (win.play_stop_label), " Play ");
|
||||
gtk_label_set_text (GTK_LABEL (win.play_stop_label), " Play ");
|
||||
else
|
||||
gtk_label_set (GTK_LABEL (win.play_stop_label), " Stop ");
|
||||
gtk_label_set_text (GTK_LABEL (win.play_stop_label), " Stop ");
|
||||
|
||||
DBG (DBG_debug, "xcam: stop_camera: exit\n");
|
||||
}
|
||||
|
@ -274,7 +280,7 @@ switch_device (const SANE_Device * dev)
|
|||
|
||||
if (dialog)
|
||||
sprintf (buf, "%s %s %s", dev->vendor, dev->model, dev->type);
|
||||
gtk_label_set (GTK_LABEL (win.device_info_label), buf);
|
||||
gtk_label_set_text (GTK_LABEL (win.device_info_label), buf);
|
||||
DBG (DBG_debug, "xcam: switch_device: exit\n");
|
||||
}
|
||||
|
||||
|
@ -318,17 +324,19 @@ save_settings (const char *filename)
|
|||
gsg_error (buf);
|
||||
return;
|
||||
}
|
||||
write (fd, dialog->dev_name, strlen (dialog->dev_name));
|
||||
write (fd, "\n", 1);
|
||||
if (write (fd, dialog->dev_name, strlen (dialog->dev_name)) == -1)
|
||||
DBG (DBG_debug, "xcam: save_settings: error write line %d\n", __LINE__);
|
||||
if (write (fd, "\n", 1) == -1)
|
||||
DBG (DBG_debug, "xcam: save_settings: error write line %d\n", __LINE__);
|
||||
sanei_save_values (fd, dialog->dev);
|
||||
close (fd);
|
||||
DBG (DBG_debug, "xcam: save_settings: exit\n");
|
||||
}
|
||||
|
||||
#define MSG_MAXLEN 45
|
||||
#define CHAR_HEIGHT 11
|
||||
#define CHAR_WIDTH 6
|
||||
#define CHAR_START 4
|
||||
#define TEXT_HEIGHT 11
|
||||
#define TEXT_WIDTH 6
|
||||
#define TEXT_START 4
|
||||
|
||||
static SANE_Status
|
||||
xcam_add_text (SANE_Byte * image, int width, int height, char *txt)
|
||||
|
@ -359,16 +367,16 @@ xcam_add_text (SANE_Byte * image, int width, int height, char *txt)
|
|||
{
|
||||
case SANE_FRAME_RGB:
|
||||
|
||||
for (y = 0; y < CHAR_HEIGHT; y++)
|
||||
for (y = 0; y < TEXT_HEIGHT; y++)
|
||||
{
|
||||
ptr = image + 3 * width * (height - CHAR_HEIGHT - 2 + y) + 12;
|
||||
ptr = image + 3 * width * (height - TEXT_HEIGHT - 2 + y) + 12;
|
||||
|
||||
for (x = 0; x < len; x++)
|
||||
{
|
||||
f = fontdata[line[x] * CHAR_HEIGHT + y];
|
||||
for (i = CHAR_WIDTH - 1; i >= 0; i--)
|
||||
f = fontdata[line[x] * TEXT_HEIGHT + y];
|
||||
for (i = TEXT_WIDTH - 1; i >= 0; i--)
|
||||
{
|
||||
if (f & (CHAR_START << i))
|
||||
if (f & (TEXT_START << i))
|
||||
{
|
||||
ptr[0] = 255;
|
||||
ptr[1] = 255;
|
||||
|
@ -381,29 +389,32 @@ xcam_add_text (SANE_Byte * image, int width, int height, char *txt)
|
|||
break;
|
||||
case SANE_FRAME_GRAY:
|
||||
|
||||
for (y = 0; y < CHAR_HEIGHT; y++)
|
||||
for (y = 0; y < TEXT_HEIGHT; y++)
|
||||
{
|
||||
ptr = image + width * (height - CHAR_HEIGHT - 2 + y) + 12;
|
||||
ptr = image + width * (height - TEXT_HEIGHT - 2 + y) + 12;
|
||||
|
||||
for (x = 0; x < len; x++)
|
||||
{
|
||||
f = fontdata[line[x] * CHAR_HEIGHT + y];
|
||||
for (i = CHAR_WIDTH - 1; i >= 0; i--)
|
||||
f = fontdata[line[x] * TEXT_HEIGHT + y];
|
||||
for (i = TEXT_WIDTH - 1; i >= 0; i--)
|
||||
{
|
||||
if (f & (CHAR_START << i))
|
||||
if (f & (TEXT_START << i))
|
||||
{
|
||||
ptr[0] = 255;
|
||||
}
|
||||
ptr += 1;
|
||||
} /* for i */
|
||||
} /* for x */
|
||||
} /* for y */
|
||||
} /* for y */
|
||||
break;
|
||||
|
||||
case SANE_FRAME_RED:
|
||||
case SANE_FRAME_GREEN:
|
||||
case SANE_FRAME_BLUE:
|
||||
snprintf (buf, sizeof (buf),
|
||||
"Time stamp for separate channel transfers are not supported");
|
||||
break;
|
||||
|
||||
default:
|
||||
snprintf (buf, sizeof (buf),
|
||||
"Unsupported image format %d", win.params.format);
|
||||
|
@ -468,7 +479,7 @@ update_param (GSGDialog * dialog, void *arg)
|
|||
}
|
||||
else
|
||||
snprintf (buf, sizeof (buf), "Invalid parameters.");
|
||||
gtk_label_set (GTK_LABEL (win.info_label), buf);
|
||||
gtk_label_set_text (GTK_LABEL (win.info_label), buf);
|
||||
|
||||
DBG (DBG_debug, "xcam: update_param: exit\n");
|
||||
}
|
||||
|
@ -539,7 +550,8 @@ load_settings (const char *filename, int silent)
|
|||
}
|
||||
|
||||
/* first, read off the devicename that these settings are for: */
|
||||
read (fd, buf, sizeof (buf));
|
||||
if (read (fd, buf, sizeof (buf)) == -1)
|
||||
DBG (DBG_debug, "xcam: load_settings: error read\n");
|
||||
buf[sizeof (buf) - 1] = '\0';
|
||||
end = strchr (buf, '\n');
|
||||
if (!end)
|
||||
|
@ -616,15 +628,17 @@ prompt_for_device_name (GtkWidget * widget, gpointer data)
|
|||
DBG (DBG_debug, "xcam: prompt_for_device_name: enter\n");
|
||||
|
||||
dialog = gtk_window_new (GTK_WINDOW_TOPLEVEL);
|
||||
gtk_window_position (GTK_WINDOW (dialog), GTK_WIN_POS_MOUSE);
|
||||
gtk_window_set_position (GTK_WINDOW (dialog), GTK_WIN_POS_MOUSE);
|
||||
gtk_window_set_title (GTK_WINDOW (dialog), "Device name");
|
||||
|
||||
/* create the main vbox */
|
||||
vbox = gtk_vbox_new (TRUE, 5);
|
||||
gtk_container_border_width (GTK_CONTAINER (vbox), 5);
|
||||
vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 5);
|
||||
gtk_box_set_homogeneous (GTK_BOX (vbox), TRUE);
|
||||
gtk_container_set_border_width (GTK_CONTAINER (vbox), 5);
|
||||
gtk_container_add (GTK_CONTAINER (dialog), vbox);
|
||||
|
||||
hbox = gtk_hbox_new (FALSE, 0);
|
||||
hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
|
||||
gtk_box_set_homogeneous (GTK_BOX (hbox), FALSE);
|
||||
gtk_container_add (GTK_CONTAINER (vbox), hbox);
|
||||
|
||||
label = gtk_label_new ("Device name:");
|
||||
|
@ -637,20 +651,21 @@ prompt_for_device_name (GtkWidget * widget, gpointer data)
|
|||
gtk_widget_show (hbox);
|
||||
|
||||
/* the confirmation button */
|
||||
hbox = gtk_hbox_new (FALSE, 0);
|
||||
vbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
|
||||
gtk_box_set_homogeneous (GTK_BOX (hbox), TRUE);
|
||||
gtk_container_add (GTK_CONTAINER (vbox), hbox);
|
||||
|
||||
button = gtk_button_new_with_label ("OK");
|
||||
GTK_WIDGET_SET_FLAGS (button, GTK_CAN_DEFAULT);
|
||||
gtk_signal_connect (GTK_OBJECT (button), "clicked",
|
||||
(GtkSignalFunc) device_name_dialog_ok, text);
|
||||
gtk_widget_set_can_default (button, TRUE);
|
||||
g_signal_connect (G_OBJECT (button), "clicked",
|
||||
G_CALLBACK (device_name_dialog_ok), text);
|
||||
gtk_box_pack_start (GTK_BOX (hbox), button, TRUE, TRUE, 5);
|
||||
gtk_widget_grab_default (button);
|
||||
gtk_widget_show (button);
|
||||
|
||||
button = gtk_button_new_with_label ("Cancel");
|
||||
gtk_signal_connect (GTK_OBJECT (button), "clicked",
|
||||
(GtkSignalFunc) device_name_dialog_cancel, dialog);
|
||||
g_signal_connect (G_OBJECT (button), "clicked",
|
||||
G_CALLBACK (device_name_dialog_cancel), dialog);
|
||||
gtk_box_pack_start (GTK_BOX (hbox), button, TRUE, TRUE, 5);
|
||||
gtk_widget_show (button);
|
||||
|
||||
|
@ -751,15 +766,15 @@ build_files_menu (void)
|
|||
|
||||
item = gtk_menu_item_new_with_label ("Exit");
|
||||
gtk_container_add (GTK_CONTAINER (menu), item);
|
||||
gtk_signal_connect (GTK_OBJECT (item), "activate",
|
||||
(GtkSignalFunc) exit_callback, 0);
|
||||
g_signal_connect (G_OBJECT (item), "activate",
|
||||
G_CALLBACK (exit_callback), 0);
|
||||
gtk_widget_show (item);
|
||||
|
||||
DBG (DBG_debug, "xcam: build_files_menu: exit\n");
|
||||
return menu;
|
||||
}
|
||||
|
||||
static gint
|
||||
static gboolean
|
||||
delayed_switch (gpointer data)
|
||||
{
|
||||
switch_device (data);
|
||||
|
@ -770,7 +785,7 @@ delayed_switch (gpointer data)
|
|||
static void
|
||||
device_activate_callback (GtkWidget * widget, gpointer data)
|
||||
{
|
||||
gtk_idle_add (delayed_switch, data);
|
||||
g_idle_add (delayed_switch, data);
|
||||
}
|
||||
|
||||
static GtkWidget *
|
||||
|
@ -793,8 +808,8 @@ build_device_menu (void)
|
|||
{
|
||||
item = gtk_menu_item_new_with_label ((char *) device[i]->name);
|
||||
gtk_container_add (GTK_CONTAINER (menu), item);
|
||||
gtk_signal_connect (GTK_OBJECT (item), "activate",
|
||||
(GtkSignalFunc) device_activate_callback,
|
||||
g_signal_connect (G_OBJECT (item), "activate",
|
||||
G_CALLBACK (device_activate_callback),
|
||||
(gpointer) device[i]);
|
||||
gtk_widget_show (item);
|
||||
}
|
||||
|
@ -804,14 +819,14 @@ build_device_menu (void)
|
|||
gtk_widget_show (item);
|
||||
|
||||
item = gtk_menu_item_new_with_label ("Refresh device list...");
|
||||
gtk_signal_connect (GTK_OBJECT (item), "activate",
|
||||
(GtkSignalFunc) rescan_devices, 0);
|
||||
g_signal_connect (G_OBJECT (item), "activate",
|
||||
G_CALLBACK (rescan_devices), 0);
|
||||
gtk_container_add (GTK_CONTAINER (menu), item);
|
||||
gtk_widget_show (item);
|
||||
|
||||
item = gtk_menu_item_new_with_label ("Specify device name...");
|
||||
gtk_signal_connect (GTK_OBJECT (item), "activate",
|
||||
(GtkSignalFunc) prompt_for_device_name, 0);
|
||||
g_signal_connect (G_OBJECT (item), "activate",
|
||||
G_CALLBACK (prompt_for_device_name), 0);
|
||||
gtk_container_add (GTK_CONTAINER (menu), item);
|
||||
gtk_widget_show (item);
|
||||
|
||||
|
@ -821,7 +836,7 @@ build_device_menu (void)
|
|||
static void
|
||||
pref_toggle_advanced (GtkWidget * widget, gpointer data)
|
||||
{
|
||||
preferences.advanced = (GTK_CHECK_MENU_ITEM (widget)->active != 0);
|
||||
preferences.advanced = (gtk_check_menu_item_get_active (GTK_CHECK_MENU_ITEM (widget)) != 0);
|
||||
gsg_set_advanced (dialog, preferences.advanced);
|
||||
pref_xcam_save ();
|
||||
}
|
||||
|
@ -829,15 +844,15 @@ pref_toggle_advanced (GtkWidget * widget, gpointer data)
|
|||
static void
|
||||
pref_toggle_tooltips (GtkWidget * widget, gpointer data)
|
||||
{
|
||||
preferences.tooltips_enabled = (GTK_CHECK_MENU_ITEM (widget)->active != 0);
|
||||
gsg_set_tooltips (dialog, preferences.tooltips_enabled);
|
||||
preferences.tooltips_enabled = (gtk_check_menu_item_get_active (GTK_CHECK_MENU_ITEM (widget)) != 0);
|
||||
gsg_set_tooltips (preferences.tooltips_enabled);
|
||||
pref_xcam_save ();
|
||||
}
|
||||
|
||||
static void
|
||||
pref_toggle_twocolumn (GtkWidget * widget, gpointer data)
|
||||
{
|
||||
preferences.twocolumn_enabled = (GTK_CHECK_MENU_ITEM (widget)->active != 0);
|
||||
preferences.twocolumn_enabled = (gtk_check_menu_item_get_active (GTK_CHECK_MENU_ITEM (widget)) != 0);
|
||||
gsg_set_twocolumn (dialog, preferences.twocolumn_enabled);
|
||||
pref_xcam_save ();
|
||||
}
|
||||
|
@ -851,32 +866,32 @@ build_preferences_menu (GSGDialog * dialog)
|
|||
|
||||
/* advanced user option: */
|
||||
item = gtk_check_menu_item_new_with_label ("Show advanced options");
|
||||
gtk_check_menu_item_set_state (GTK_CHECK_MENU_ITEM (item),
|
||||
gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (item),
|
||||
preferences.advanced);
|
||||
gtk_menu_append (GTK_MENU (menu), item);
|
||||
gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
|
||||
gtk_widget_show (item);
|
||||
gtk_signal_connect (GTK_OBJECT (item), "toggled",
|
||||
(GtkSignalFunc) pref_toggle_advanced, 0);
|
||||
g_signal_connect (G_OBJECT (item), "toggled",
|
||||
G_CALLBACK (pref_toggle_advanced), 0);
|
||||
|
||||
/* tooltips submenu: */
|
||||
|
||||
item = gtk_check_menu_item_new_with_label ("Show tooltips");
|
||||
gtk_check_menu_item_set_state (GTK_CHECK_MENU_ITEM (item),
|
||||
gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (item),
|
||||
preferences.tooltips_enabled);
|
||||
gtk_menu_append (GTK_MENU (menu), item);
|
||||
gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
|
||||
gtk_widget_show (item);
|
||||
gtk_signal_connect (GTK_OBJECT (item), "toggled",
|
||||
(GtkSignalFunc) pref_toggle_tooltips, 0);
|
||||
g_signal_connect (G_OBJECT (item), "toggled",
|
||||
G_CALLBACK (pref_toggle_tooltips), 0);
|
||||
|
||||
/* twocolumn submenu: */
|
||||
|
||||
item = gtk_check_menu_item_new_with_label ("Show two column display");
|
||||
gtk_check_menu_item_set_state (GTK_CHECK_MENU_ITEM (item),
|
||||
gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (item),
|
||||
preferences.twocolumn_enabled);
|
||||
gtk_menu_append (GTK_MENU (menu), item);
|
||||
gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
|
||||
gtk_widget_show (item);
|
||||
gtk_signal_connect (GTK_OBJECT (item), "toggled",
|
||||
(GtkSignalFunc) pref_toggle_twocolumn, 0);
|
||||
g_signal_connect (G_OBJECT (item), "toggled",
|
||||
G_CALLBACK (pref_toggle_twocolumn), 0);
|
||||
|
||||
item = gtk_menu_item_new ();
|
||||
gtk_container_add (GTK_CONTAINER (menu), item);
|
||||
|
@ -884,14 +899,14 @@ build_preferences_menu (GSGDialog * dialog)
|
|||
|
||||
item = gtk_menu_item_new_with_label ("Save as default settings");
|
||||
gtk_container_add (GTK_CONTAINER (menu), item);
|
||||
gtk_signal_connect (GTK_OBJECT (item), "activate",
|
||||
(GtkSignalFunc) save_defaults_callback, 0);
|
||||
g_signal_connect (G_OBJECT (item), "activate",
|
||||
G_CALLBACK (save_defaults_callback), 0);
|
||||
gtk_widget_show (item);
|
||||
|
||||
item = gtk_menu_item_new_with_label ("Load default settings");
|
||||
gtk_container_add (GTK_CONTAINER (menu), item);
|
||||
gtk_signal_connect (GTK_OBJECT (item), "activate",
|
||||
(GtkSignalFunc) load_defaults_callback, 0);
|
||||
g_signal_connect (G_OBJECT (item), "activate",
|
||||
G_CALLBACK (load_defaults_callback), 0);
|
||||
gtk_widget_show (item);
|
||||
|
||||
item = gtk_menu_item_new ();
|
||||
|
@ -900,14 +915,14 @@ build_preferences_menu (GSGDialog * dialog)
|
|||
|
||||
item = gtk_menu_item_new_with_label ("Save settings as...");
|
||||
gtk_container_add (GTK_CONTAINER (menu), item);
|
||||
gtk_signal_connect (GTK_OBJECT (item), "activate",
|
||||
(GtkSignalFunc) save_as_callback, 0);
|
||||
g_signal_connect (G_OBJECT (item), "activate",
|
||||
G_CALLBACK (save_as_callback), 0);
|
||||
gtk_widget_show (item);
|
||||
|
||||
item = gtk_menu_item_new_with_label ("Load settings from...");
|
||||
gtk_container_add (GTK_CONTAINER (menu), item);
|
||||
gtk_signal_connect (GTK_OBJECT (item), "activate",
|
||||
(GtkSignalFunc) load_from_callback, 0);
|
||||
g_signal_connect (G_OBJECT (item), "activate",
|
||||
G_CALLBACK (load_from_callback), 0);
|
||||
gtk_widget_show (item);
|
||||
|
||||
return menu;
|
||||
|
@ -1039,8 +1054,8 @@ rescan_devices (GtkWidget * widget, gpointer client_data, gpointer call_data)
|
|||
} \
|
||||
else \
|
||||
{ \
|
||||
if ( ((endian) == GDK_LSB_FIRST && r_shift == 0) \
|
||||
|| ((endian) == GDK_MSB_FIRST && b_shift == 0)) \
|
||||
if ( ((endian) == G_BIG_ENDIAN && r_shift == 0) \
|
||||
|| ((endian) == G_LITTLE_ENDIAN && b_shift == 0)) \
|
||||
{ \
|
||||
buf[0] = (r) >> 8; buf[1] = (g) >> 8; buf[2] = (b) >> 8; \
|
||||
} \
|
||||
|
@ -1054,15 +1069,15 @@ rescan_devices (GtkWidget * widget, gpointer client_data, gpointer call_data)
|
|||
} \
|
||||
}
|
||||
|
||||
static void
|
||||
input_available (gpointer ignore, gint source, GdkInputCondition cond)
|
||||
static gboolean
|
||||
input_available (gpointer data, gint source, GIOCondition cond)
|
||||
{
|
||||
int x, pixels_per_line, bytes_per_line, dst_depth, src_depth;
|
||||
guint32 r = 0, g = 0, b = 0, lum, rgb, src_mask, dst_mask;
|
||||
gint r_shift, b_shift, g_shift;
|
||||
size_t buf_size, remaining = win.remaining;
|
||||
SANE_Byte *src, *src_end;
|
||||
GdkByteOrder byte_order;
|
||||
u_long byte_order;
|
||||
u_long bytes_per_pixel;
|
||||
SANE_Frame format;
|
||||
SANE_Status status;
|
||||
|
@ -1071,6 +1086,7 @@ input_available (gpointer ignore, gint source, GdkInputCondition cond)
|
|||
|
||||
double max_value = 60; /* min. 1 frame per min. */
|
||||
double frame_time = 50; /* dummy value */
|
||||
GdkVisual *visual = NULL;
|
||||
|
||||
DBG (DBG_debug, "xcam: input available: enter\n");
|
||||
|
||||
|
@ -1078,23 +1094,24 @@ input_available (gpointer ignore, gint source, GdkInputCondition cond)
|
|||
/* looks like we got cancelled */
|
||||
goto stop_and_exit;
|
||||
|
||||
visual = gdk_window_get_visual (gtk_widget_get_window (win.canvas.preview));
|
||||
buf_size = win.buf_backend_size;
|
||||
format = win.params.format;
|
||||
src_depth = win.params.depth;
|
||||
dst_depth = win.canvas.gdk_image->depth;
|
||||
dst_depth = 8;
|
||||
pixels_per_line = win.params.pixels_per_line;
|
||||
bytes_per_line = win.canvas.gdk_image->bpl;
|
||||
bytes_per_pixel = win.canvas.gdk_image->bpp;
|
||||
byte_order = win.canvas.gdk_image->byte_order;
|
||||
bytes_per_line = gdk_pixbuf_get_bits_per_sample (win.canvas.gdk_image);
|
||||
bytes_per_pixel = 24;
|
||||
byte_order = (calc_little_endian () ? G_LITTLE_ENDIAN : G_BIG_ENDIAN);
|
||||
|
||||
x = win.x;
|
||||
dst = win.data;
|
||||
src_mask = 0x80; /* SANE has left most bit is most significant bit */
|
||||
src_mask = 0x80; /* SANE has left most bit is most significant bit */
|
||||
dst_mask = 0x01;
|
||||
|
||||
r_shift = win.canvas.gdk_image->visual->red_shift;
|
||||
g_shift = win.canvas.gdk_image->visual->green_shift;
|
||||
b_shift = win.canvas.gdk_image->visual->blue_shift;
|
||||
gdk_visual_get_red_pixel_details (visual, NULL, &r_shift, NULL);
|
||||
gdk_visual_get_green_pixel_details (visual, NULL, &g_shift, NULL);
|
||||
gdk_visual_get_blue_pixel_details (visual, NULL, &b_shift, NULL);
|
||||
|
||||
while (1)
|
||||
{
|
||||
|
@ -1110,7 +1127,7 @@ input_available (gpointer ignore, gint source, GdkInputCondition cond)
|
|||
if (win.playing)
|
||||
{
|
||||
next_frame (); /* arrange for next frame */
|
||||
return;
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -1122,7 +1139,7 @@ input_available (gpointer ignore, gint source, GdkInputCondition cond)
|
|||
}
|
||||
win.playing = FALSE;
|
||||
stop_camera ();
|
||||
return;
|
||||
return FALSE;
|
||||
}
|
||||
win.f_count++;
|
||||
update_param (dialog, 0);
|
||||
|
@ -1168,7 +1185,7 @@ input_available (gpointer ignore, gint source, GdkInputCondition cond)
|
|||
if (status != SANE_STATUS_GOOD)
|
||||
{
|
||||
DBG (DBG_info, "xcam: input available status NOK\n");
|
||||
return;
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1200,13 +1217,13 @@ input_available (gpointer ignore, gint source, GdkInputCondition cond)
|
|||
win.x = x;
|
||||
win.remaining = remaining;
|
||||
DBG (DBG_debug, "xcam: input available: exit\n");
|
||||
return;
|
||||
return TRUE;
|
||||
|
||||
stop_and_exit:
|
||||
win.playing = FALSE;
|
||||
stop_camera ();
|
||||
DBG (DBG_debug, "xcam: input available: stop and exit\n");
|
||||
return;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -1250,27 +1267,33 @@ next_frame (void)
|
|||
}
|
||||
|
||||
if (!win.canvas.gdk_image
|
||||
|| win.canvas.gdk_image->width != win.params.pixels_per_line
|
||||
|| win.canvas.gdk_image->height != win.params.lines)
|
||||
|| gdk_pixbuf_get_width (win.canvas.gdk_image) != win.params.pixels_per_line
|
||||
|| gdk_pixbuf_get_height (win.canvas.gdk_image) != win.params.lines)
|
||||
{
|
||||
GdkImageType image_type = GDK_IMAGE_FASTEST;
|
||||
// GdkImageType image_type = GDK_IMAGE_FASTEST;
|
||||
|
||||
if (win.canvas.gdk_image)
|
||||
gdk_image_destroy (win.canvas.gdk_image);
|
||||
g_object_unref (win.canvas.gdk_image);
|
||||
/*
|
||||
#ifdef __alpha__
|
||||
/* Some X servers seem to have a problem with shared images that
|
||||
have a width that is not a multiple of 8. Duh... ;-( */
|
||||
// Some X servers seem to have a problem with shared images that
|
||||
// have a width that is not a multiple of 8. Duh... ;-(
|
||||
if (win.params.pixels_per_line % 8)
|
||||
image_type = GDK_IMAGE_NORMAL;
|
||||
#endif
|
||||
*/
|
||||
win.canvas.gdk_image =
|
||||
gdk_image_new (image_type,
|
||||
gdk_window_get_visual (win.canvas.preview->window),
|
||||
win.params.pixels_per_line, win.params.lines);
|
||||
gtk_widget_set_usize (win.canvas.preview,
|
||||
gdk_pixbuf_new (
|
||||
GDK_COLORSPACE_RGB,
|
||||
TRUE,
|
||||
8,
|
||||
win.params.pixels_per_line,
|
||||
win.params.lines);
|
||||
|
||||
gtk_widget_set_size_request (win.canvas.preview,
|
||||
win.params.pixels_per_line, win.params.lines);
|
||||
}
|
||||
win.data = win.canvas.gdk_image->mem;
|
||||
win.data = gdk_pixbuf_get_pixels (win.canvas.gdk_image);
|
||||
win.x = 0;
|
||||
win.remaining = 0;
|
||||
|
||||
|
@ -1281,8 +1304,12 @@ next_frame (void)
|
|||
== SANE_STATUS_GOOD
|
||||
&& sane_get_select_fd (gsg_dialog_get_device (dialog), &fd)
|
||||
== SANE_STATUS_GOOD)
|
||||
win.gdk_input_tag =
|
||||
gdk_input_add (fd, GDK_INPUT_READ, input_available, 0);
|
||||
{
|
||||
GIOChannel *chan = g_io_channel_unix_new (fd);
|
||||
win.gdk_input_tag =
|
||||
g_io_add_watch (chan, G_IO_IN, (GIOFunc) input_available, 0);
|
||||
g_io_channel_unref(chan);
|
||||
}
|
||||
else
|
||||
input_available (0, -1, 0);
|
||||
|
||||
|
@ -1300,13 +1327,13 @@ play_stop_button (GtkWidget * widget, gpointer client_data,
|
|||
if (win.playing)
|
||||
{
|
||||
win.playing = FALSE;
|
||||
gtk_label_set (GTK_LABEL (win.play_stop_label), " Play ");
|
||||
gtk_label_set_text (GTK_LABEL (win.play_stop_label), " Play ");
|
||||
DBG (DBG_debug, "xcam: wait for play button to be pushed\n");
|
||||
}
|
||||
else if (win.gdk_input_tag < 0)
|
||||
{
|
||||
win.playing = TRUE;
|
||||
gtk_label_set (GTK_LABEL (win.play_stop_label), " Stop ");
|
||||
gtk_label_set_text (GTK_LABEL (win.play_stop_label), " Stop ");
|
||||
DBG (DBG_debug, "xcam: wait for stop button to be pushed\n");
|
||||
next_frame ();
|
||||
}
|
||||
|
@ -1330,7 +1357,7 @@ save_frame_button (GtkWidget * widget, gpointer client_data,
|
|||
else if (win.gdk_input_tag < 0)
|
||||
{
|
||||
win.saving = TRUE;
|
||||
gtk_label_set (GTK_LABEL (win.save_frame_label), "Saving started");
|
||||
gtk_label_set_text (GTK_LABEL (win.save_frame_label), "Saving started");
|
||||
/* ------------------------------------------ */
|
||||
|
||||
/* test for pnm formats */
|
||||
|
@ -1365,7 +1392,7 @@ save_frame_button (GtkWidget * widget, gpointer client_data,
|
|||
save_frame ();
|
||||
buttons_enable ();
|
||||
gsg_sync (dialog);
|
||||
gtk_label_set (GTK_LABEL (win.save_frame_label), "Save\nFrame");
|
||||
gtk_label_set_text (GTK_LABEL (win.save_frame_label), "Save\nFrame");
|
||||
DBG (DBG_debug, "xcam: save_frame_button: exit\n");
|
||||
}
|
||||
|
||||
|
@ -1381,12 +1408,12 @@ txt_button (GtkWidget * widget, gpointer client_data, gpointer call_data)
|
|||
{
|
||||
win.saving = FALSE;
|
||||
win.value_txt = 0;
|
||||
gtk_label_set (GTK_LABEL (win.txt_label), " TXT \n OFF ");
|
||||
gtk_label_set_text (GTK_LABEL (win.txt_label), " TXT \n OFF ");
|
||||
}
|
||||
else if (win.gdk_input_tag < 0)
|
||||
{
|
||||
win.saving = TRUE;
|
||||
gtk_label_set (GTK_LABEL (win.txt_label), " TXT \n ON ");
|
||||
gtk_label_set_text (GTK_LABEL (win.txt_label), " TXT \n ON ");
|
||||
win.value_txt = 1;
|
||||
}
|
||||
gsg_sync (dialog);
|
||||
|
@ -1405,12 +1432,12 @@ rgb_bgr_button (GtkWidget * widget, gpointer client_data, gpointer call_data)
|
|||
{
|
||||
win.saving = FALSE;
|
||||
win.value_rgb = 0;
|
||||
gtk_label_set (GTK_LABEL (win.rgb_bgr_label), "RGB");
|
||||
gtk_label_set_text (GTK_LABEL (win.rgb_bgr_label), "RGB");
|
||||
}
|
||||
else if (win.gdk_input_tag < 0)
|
||||
{
|
||||
win.saving = TRUE;
|
||||
gtk_label_set (GTK_LABEL (win.rgb_bgr_label), "BGR");
|
||||
gtk_label_set_text (GTK_LABEL (win.rgb_bgr_label), "BGR");
|
||||
win.value_rgb = 1;
|
||||
}
|
||||
gsg_sync (dialog);
|
||||
|
@ -1509,13 +1536,18 @@ save_frame (void)
|
|||
win.input_tag = -1;
|
||||
if (sane_set_io_mode (dev, SANE_TRUE) == SANE_STATUS_GOOD
|
||||
&& sane_get_select_fd (dev, &fd) == SANE_STATUS_GOOD)
|
||||
win.input_tag = gdk_input_add (fd, GDK_INPUT_READ | GDK_INPUT_EXCEPTION,
|
||||
input_available, 0);
|
||||
{
|
||||
GIOChannel *chan = g_io_channel_unix_new (fd);
|
||||
win.input_tag =
|
||||
g_io_add_watch (chan, G_IO_IN | G_IO_HUP | G_IO_ERR | G_IO_PRI,
|
||||
(GIOFunc) input_available, 0);
|
||||
g_io_channel_unref(chan);
|
||||
}
|
||||
else
|
||||
{
|
||||
while (gtk_events_pending ())
|
||||
gtk_main_iteration ();
|
||||
input_available (0, -1, GDK_INPUT_READ);
|
||||
input_available (0, -1, G_IO_IN);
|
||||
}
|
||||
|
||||
DBG (DBG_debug, "xcam: save_frame: exit\n");
|
||||
|
@ -1534,7 +1566,7 @@ xcam_exit (void)
|
|||
pref_xcam_save ();
|
||||
sane_exit ();
|
||||
/* this has the habit of calling exit itself: */
|
||||
gtk_exit (0);
|
||||
gtk_main_quit ();
|
||||
DBG (DBG_debug, "xcam: xcam_exit: exit\n");
|
||||
}
|
||||
|
||||
|
@ -1597,9 +1629,8 @@ int
|
|||
main (int argc, char **argv)
|
||||
{
|
||||
GtkWidget *menu, *menu_bar, *menu_bar_item, *preview_vbox;
|
||||
GtkWidget *hbox, *vbox, *button, *alignment, *frame, *label, *text,
|
||||
GtkWidget *hbox, *vbox, *button, *frame, *label, *text,
|
||||
*scrolled_window;
|
||||
int i;
|
||||
int ch;
|
||||
SANE_Status status;
|
||||
|
||||
|
@ -1665,11 +1696,12 @@ main (int argc, char **argv)
|
|||
win.gdk_input_tag = -1;
|
||||
win.shell = gtk_window_new (GTK_WINDOW_TOPLEVEL);
|
||||
gtk_window_set_title (GTK_WINDOW (win.shell), (char *) prog_name);
|
||||
gtk_signal_connect (GTK_OBJECT (win.shell), "delete_event",
|
||||
GTK_SIGNAL_FUNC (xcam_win_delete), NULL);
|
||||
g_signal_connect (G_OBJECT (win.shell), "delete_event",
|
||||
G_CALLBACK (xcam_win_delete), NULL);
|
||||
|
||||
vbox = gtk_vbox_new (FALSE, 0);
|
||||
gtk_container_border_width (GTK_CONTAINER (vbox), 0);
|
||||
vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
|
||||
gtk_box_set_homogeneous (GTK_BOX (vbox), FALSE);
|
||||
gtk_container_set_border_width (GTK_CONTAINER (vbox), 0);
|
||||
gtk_container_add (GTK_CONTAINER (win.shell), vbox);
|
||||
gtk_widget_show (vbox);
|
||||
|
||||
|
@ -1703,7 +1735,7 @@ main (int argc, char **argv)
|
|||
|
||||
/* add device info at top: */
|
||||
frame = gtk_frame_new (0);
|
||||
gtk_container_border_width (GTK_CONTAINER (frame), 8);
|
||||
gtk_container_set_border_width (GTK_CONTAINER (frame), 8);
|
||||
gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_ETCHED_IN);
|
||||
gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0);
|
||||
gtk_widget_show (frame);
|
||||
|
@ -1712,66 +1744,38 @@ main (int argc, char **argv)
|
|||
gtk_widget_show (win.device_info_label);
|
||||
gtk_container_add (GTK_CONTAINER (frame), win.device_info_label);
|
||||
|
||||
hbox = gtk_hbox_new (FALSE, 0);
|
||||
hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
|
||||
gtk_box_set_homogeneous (GTK_BOX (hbox), FALSE);
|
||||
gtk_container_add (GTK_CONTAINER (vbox), hbox);
|
||||
gtk_widget_show (hbox);
|
||||
|
||||
/* create the device dialog box: */
|
||||
win.dialog_box = gtk_vbox_new (FALSE, 0);
|
||||
win.dialog_box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
|
||||
gtk_box_set_homogeneous (GTK_BOX (win.dialog_box), FALSE);
|
||||
gtk_widget_show (win.dialog_box);
|
||||
|
||||
DBG (DBG_debug, "xcam main, preview vbox on the left hand side \n");
|
||||
/* the preview vbox on the left hand side: */
|
||||
preview_vbox = gtk_vbox_new (FALSE, 0);
|
||||
preview_vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
|
||||
gtk_box_set_homogeneous (GTK_BOX (preview_vbox), FALSE);
|
||||
gtk_box_pack_start (GTK_BOX (hbox), preview_vbox, TRUE, TRUE, 0);
|
||||
|
||||
frame = gtk_frame_new ("Image view");
|
||||
gtk_container_border_width (GTK_CONTAINER (frame), 8);
|
||||
gtk_container_set_border_width (GTK_CONTAINER (frame), 8);
|
||||
gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_ETCHED_IN);
|
||||
gtk_container_add (GTK_CONTAINER (preview_vbox), frame);
|
||||
|
||||
alignment = gtk_alignment_new (0, 0.5, 1.0, 1.0);
|
||||
gtk_box_pack_start (GTK_BOX (preview_vbox), alignment, TRUE, TRUE, 0);
|
||||
|
||||
win.canvas.preview = gtk_drawing_area_new ();
|
||||
gtk_drawing_area_size (GTK_DRAWING_AREA (win.canvas.preview), 320, 200);
|
||||
gtk_widget_set_size_request (GTK_WIDGET (win.canvas.preview), 320, 200);
|
||||
gtk_widget_set_events (win.canvas.preview, CANVAS_EVENT_MASK);
|
||||
gtk_signal_connect (GTK_OBJECT (win.canvas.preview), "event",
|
||||
(GtkSignalFunc) canvas_events, 0);
|
||||
g_signal_connect (G_OBJECT (win.canvas.preview), "event",
|
||||
G_CALLBACK (canvas_events), 0);
|
||||
gtk_container_add (GTK_CONTAINER (frame), win.canvas.preview);
|
||||
|
||||
gtk_widget_show (win.canvas.preview);
|
||||
gtk_widget_show (alignment);
|
||||
gtk_widget_show (frame);
|
||||
gtk_widget_show (preview_vbox);
|
||||
|
||||
win.canvas.graylevel_cmap = gdk_colormap_get_system ();
|
||||
for (i = 0; i < NELEMS (win.canvas.graylevel); ++i)
|
||||
{
|
||||
GdkColor color;
|
||||
color.red = color.green = color.blue =
|
||||
i * 0xffff / (NELEMS (win.canvas.graylevel) - 1);
|
||||
gdk_color_alloc (win.canvas.graylevel_cmap, &color);
|
||||
win.canvas.graylevel[i] = color.pixel;
|
||||
}
|
||||
|
||||
#if 0
|
||||
{
|
||||
win.canvas.cube_cmap
|
||||
= gdk_colormap_new (win.canvas.preview->window->visual, 1);
|
||||
for (i = 0; i < NELEMS (win.canvas.cube_colors); ++i)
|
||||
{
|
||||
win.canvas.cube_colors[i].pixel = i;
|
||||
win.canvas.cube_colors[i].red = ((i / 30) % 5) * 0xffff / 4;
|
||||
win.canvas.cube_colors[i].green = ((i / 5) % 6) * 0xffff / 5;
|
||||
win.canvas.cube_colors[i].blue = ((i % 5)) * 0xffff / 4;
|
||||
}
|
||||
gdk_colors_store (win.canvas.cube_cmap, win.canvas.cube_colors,
|
||||
NELEMS (win.canvas.cube_colors));
|
||||
gdk_window_set_colormap (win.shell->window, win.canvas.cube_cmap);
|
||||
}
|
||||
#endif
|
||||
|
||||
DBG (DBG_debug, "xcam main, use a scrolled window \n");
|
||||
|
||||
/* use a scrolled window to show the device options, as in xscanimage */
|
||||
|
@ -1780,8 +1784,7 @@ main (int argc, char **argv)
|
|||
GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
|
||||
gtk_scrolled_window_set_placement (GTK_SCROLLED_WINDOW (scrolled_window),
|
||||
GTK_CORNER_TOP_RIGHT);
|
||||
gtk_scrolled_window_add_with_viewport (GTK_SCROLLED_WINDOW
|
||||
(scrolled_window), win.dialog_box);
|
||||
gtk_container_add (GTK_CONTAINER (scrolled_window), win.dialog_box);
|
||||
gtk_container_add (GTK_CONTAINER (hbox), scrolled_window);
|
||||
|
||||
gtk_widget_show (GTK_WIDGET (scrolled_window));
|
||||
|
@ -1806,7 +1809,7 @@ main (int argc, char **argv)
|
|||
&& (sane_get_parameters (gsg_dialog_get_device (dialog), &win.params)
|
||||
== SANE_STATUS_GOOD))
|
||||
{
|
||||
gtk_widget_set_usize (win.canvas.preview,
|
||||
gtk_widget_set_size_request (win.canvas.preview,
|
||||
win.params.pixels_per_line, win.params.lines);
|
||||
}
|
||||
|
||||
|
@ -1815,8 +1818,9 @@ main (int argc, char **argv)
|
|||
DBG (DBG_debug, "xcam main, button row: info\n");
|
||||
|
||||
/* The info row */
|
||||
hbox = gtk_hbox_new (FALSE, 5);
|
||||
gtk_container_border_width (GTK_CONTAINER (hbox), 3);
|
||||
hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 5);
|
||||
gtk_box_set_homogeneous (GTK_BOX (hbox), FALSE);
|
||||
gtk_container_set_border_width (GTK_CONTAINER (hbox), 3);
|
||||
gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
|
||||
gtk_widget_show (hbox);
|
||||
|
||||
|
@ -1825,8 +1829,9 @@ main (int argc, char **argv)
|
|||
gtk_box_pack_start (GTK_BOX (hbox), frame, FALSE, FALSE, 0);
|
||||
gtk_widget_show (frame);
|
||||
|
||||
hbox = gtk_hbox_new (FALSE, 5);
|
||||
gtk_container_border_width (GTK_CONTAINER (hbox), 2);
|
||||
hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 5);
|
||||
gtk_box_set_homogeneous (GTK_BOX (hbox), FALSE);
|
||||
gtk_container_set_border_width (GTK_CONTAINER (hbox), 2);
|
||||
gtk_container_add (GTK_CONTAINER (frame), hbox);
|
||||
gtk_widget_show (hbox);
|
||||
|
||||
|
@ -1846,18 +1851,18 @@ main (int argc, char **argv)
|
|||
|
||||
/* The TXT button */
|
||||
button = gtk_button_new_with_label (" TXT ");
|
||||
win.txt_label = GTK_BIN (button)->child;
|
||||
gtk_signal_connect (GTK_OBJECT (button), "clicked",
|
||||
(GtkSignalFunc) txt_button, dialog);
|
||||
win.txt_label = gtk_bin_get_child (GTK_BIN (button));
|
||||
g_signal_connect (G_OBJECT (button), "clicked",
|
||||
G_CALLBACK (txt_button), dialog);
|
||||
gtk_box_pack_start (GTK_BOX (hbox), button, FALSE, FALSE, 0);
|
||||
gtk_widget_show (button);
|
||||
DBG (DBG_debug, "xcam main, bottom row: txt button\n");
|
||||
|
||||
/* The RGB-BGR button */
|
||||
button = gtk_button_new_with_label ("RGB");
|
||||
win.rgb_bgr_label = GTK_BIN (button)->child;
|
||||
gtk_signal_connect (GTK_OBJECT (button), "clicked",
|
||||
(GtkSignalFunc) rgb_bgr_button, dialog);
|
||||
win.rgb_bgr_label = gtk_bin_get_child (GTK_BIN (button));
|
||||
g_signal_connect (G_OBJECT (button), "clicked",
|
||||
G_CALLBACK (rgb_bgr_button), dialog);
|
||||
gtk_box_pack_start (GTK_BOX (hbox), button, FALSE, FALSE, 0);
|
||||
gtk_widget_show (button);
|
||||
|
||||
|
@ -1865,9 +1870,9 @@ main (int argc, char **argv)
|
|||
|
||||
/* The Play button */
|
||||
button = gtk_button_new_with_label (" Play ");
|
||||
win.play_stop_label = GTK_BIN (button)->child;
|
||||
gtk_signal_connect (GTK_OBJECT (button), "clicked",
|
||||
(GtkSignalFunc) play_stop_button, dialog);
|
||||
win.play_stop_label = gtk_bin_get_child (GTK_BIN (button));
|
||||
g_signal_connect (G_OBJECT (button), "clicked",
|
||||
G_CALLBACK (play_stop_button), dialog);
|
||||
gtk_box_pack_start (GTK_BOX (hbox), button, FALSE, FALSE, 0);
|
||||
gtk_widget_show (button);
|
||||
|
||||
|
@ -1875,9 +1880,9 @@ main (int argc, char **argv)
|
|||
|
||||
/* The Save Frame button */
|
||||
button = gtk_button_new_with_label ("Save\nFrame");
|
||||
win.save_frame_label = GTK_BIN (button)->child;
|
||||
gtk_signal_connect (GTK_OBJECT (button), "clicked",
|
||||
(GtkSignalFunc) save_frame_button, dialog);
|
||||
win.save_frame_label = gtk_bin_get_child (GTK_BIN (button));
|
||||
g_signal_connect (G_OBJECT (button), "clicked",
|
||||
G_CALLBACK (save_frame_button), dialog);
|
||||
gtk_box_pack_start (GTK_BOX (hbox), button, FALSE, FALSE, 0);
|
||||
gtk_widget_show (button);
|
||||
|
||||
|
@ -1885,12 +1890,13 @@ main (int argc, char **argv)
|
|||
|
||||
/* output filename part */
|
||||
frame = gtk_frame_new ("Output");
|
||||
gtk_container_border_width (GTK_CONTAINER (frame), 4);
|
||||
gtk_container_set_border_width (GTK_CONTAINER (frame), 4);
|
||||
gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_ETCHED_IN);
|
||||
gtk_box_pack_start (GTK_BOX (hbox), frame, FALSE, FALSE, 0);
|
||||
|
||||
hbox = gtk_hbox_new (FALSE, 2);
|
||||
gtk_container_border_width (GTK_CONTAINER (hbox), 2);
|
||||
hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 2);
|
||||
gtk_box_set_homogeneous (GTK_BOX (hbox), FALSE);
|
||||
gtk_container_set_border_width (GTK_CONTAINER (hbox), 2);
|
||||
gtk_container_add (GTK_CONTAINER (frame), hbox);
|
||||
|
||||
label = gtk_label_new ("Filename");
|
||||
|
@ -1899,15 +1905,15 @@ main (int argc, char **argv)
|
|||
text = gtk_entry_new ();
|
||||
gtk_entry_set_text (GTK_ENTRY (text), (char *) preferences.filename);
|
||||
gtk_box_pack_start (GTK_BOX (hbox), text, TRUE, TRUE, 2);
|
||||
gtk_signal_connect (GTK_OBJECT (text), "changed",
|
||||
(GtkSignalFunc) filename_changed_callback, 0);
|
||||
g_signal_connect (G_OBJECT (text), "changed",
|
||||
G_CALLBACK (filename_changed_callback), 0);
|
||||
|
||||
win.filename_entry = text;
|
||||
|
||||
button = gtk_button_new_with_label ("Browse");
|
||||
gtk_box_pack_start (GTK_BOX (hbox), button, FALSE, FALSE, 2);
|
||||
gtk_signal_connect (GTK_OBJECT (button), "clicked",
|
||||
(GtkSignalFunc) browse_filename_callback, 0);
|
||||
g_signal_connect (G_OBJECT (button), "clicked",
|
||||
G_CALLBACK (browse_filename_callback), 0);
|
||||
|
||||
gtk_widget_show (button);
|
||||
gtk_widget_show (label);
|
||||
|
|
469
src/xscanimage.c
469
src/xscanimage.c
|
@ -39,7 +39,7 @@
|
|||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include <glib.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
#include <sane/sane.h>
|
||||
|
@ -116,7 +116,7 @@ enum
|
|||
STANDALONE, SANE_GIMP_EXTENSION
|
||||
};
|
||||
|
||||
static struct
|
||||
struct scan_win_t
|
||||
{
|
||||
GtkWidget *shell;
|
||||
GtkWidget *menubar;
|
||||
|
@ -143,6 +143,7 @@ static struct
|
|||
#ifdef HAVE_LIBGIMP_GIMP_H
|
||||
/* for GIMP mode: */
|
||||
gint32 image_ID;
|
||||
gint32 layer_ID;
|
||||
GimpDrawable *drawable;
|
||||
guchar *tile;
|
||||
unsigned tile_offset;
|
||||
|
@ -536,7 +537,7 @@ update_param (GSGDialog * dialog, void *arg)
|
|||
}
|
||||
else
|
||||
snprintf (buf, sizeof (buf), "Invalid parameters.");
|
||||
gtk_label_set (GTK_LABEL (scan_win.info_label), buf);
|
||||
gtk_label_set_text (GTK_LABEL (scan_win.info_label), buf);
|
||||
|
||||
if (scan_win.preview)
|
||||
preview_update (scan_win.preview);
|
||||
|
@ -597,6 +598,7 @@ quit_xscanimage (void)
|
|||
Preview *preview = scan_win.preview;
|
||||
scan_win.preview = 0;
|
||||
preview_destroy (preview);
|
||||
scan_win.preview = 0;
|
||||
}
|
||||
while (gsg_message_dialog_active)
|
||||
{
|
||||
|
@ -630,7 +632,7 @@ scan_win_delete (GtkWidget * w, gpointer data)
|
|||
static void
|
||||
preview_window_destroyed (GtkWidget * widget, gpointer call_data)
|
||||
{
|
||||
gtk_toggle_button_set_state (GTK_TOGGLE_BUTTON (call_data), FALSE);
|
||||
scan_win.preview = 0;
|
||||
}
|
||||
|
||||
/* Invoked when the preview button is pressed. */
|
||||
|
@ -638,33 +640,49 @@ preview_window_destroyed (GtkWidget * widget, gpointer call_data)
|
|||
static void
|
||||
scan_preview (GtkWidget * widget, gpointer call_data)
|
||||
{
|
||||
DBG (DBG_debug, "scan_preview\n");
|
||||
|
||||
if (GTK_TOGGLE_BUTTON (widget)->active)
|
||||
{
|
||||
if (!scan_win.preview)
|
||||
// GtkWidget *dlg = call_data;
|
||||
DBG (DBG_debug, "scan_preview\n");
|
||||
if (!scan_win.preview)
|
||||
{
|
||||
scan_win.preview = preview_new (dialog);
|
||||
if (scan_win.preview && scan_win.preview->top)
|
||||
gtk_signal_connect (GTK_OBJECT (scan_win.preview->top),
|
||||
"destroy",
|
||||
GTK_SIGNAL_FUNC (preview_window_destroyed),
|
||||
widget);
|
||||
else
|
||||
gtk_toggle_button_set_state (GTK_TOGGLE_BUTTON (widget), FALSE);
|
||||
if (scan_win.progress)
|
||||
gtk_widget_set_sensitive (scan_win.preview->preview, FALSE);
|
||||
scan_win.preview = preview_new (dialog);
|
||||
if (scan_win.preview && scan_win.preview->top)
|
||||
g_signal_connect (G_OBJECT (scan_win.preview->top),
|
||||
"destroy",
|
||||
G_CALLBACK (preview_window_destroyed),
|
||||
widget);
|
||||
if (scan_win.progress)
|
||||
gtk_widget_set_sensitive (scan_win.preview->preview, FALSE);
|
||||
}
|
||||
}
|
||||
else if (scan_win.preview)
|
||||
{
|
||||
preview_destroy (scan_win.preview);
|
||||
scan_win.preview = 0;
|
||||
}
|
||||
DBG (DBG_debug, "scan_preview: finished\n");
|
||||
else
|
||||
{
|
||||
preview_destroy (scan_win.preview);
|
||||
scan_win.preview = 0;
|
||||
}
|
||||
DBG (DBG_debug, "scan_preview: finished\n");
|
||||
}
|
||||
|
||||
#ifdef HAVE_LIBGIMP_GIMP_H
|
||||
|
||||
static const Babl*
|
||||
_gimp_babl_get_format (void)
|
||||
{
|
||||
if (gimp_drawable_is_rgb (scan_win.layer_ID))
|
||||
{
|
||||
if (gimp_drawable_has_alpha (scan_win.layer_ID))
|
||||
return babl_format ("R'G'B'A u8");
|
||||
else
|
||||
return babl_format ("R'G'B' u8");
|
||||
}
|
||||
else
|
||||
{
|
||||
if (gimp_drawable_has_alpha (scan_win.layer_ID))
|
||||
return babl_format ("Y'A u8");
|
||||
else
|
||||
return babl_format ("Y' u8");
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static void
|
||||
advance (void)
|
||||
{
|
||||
|
@ -678,10 +696,15 @@ advance (void)
|
|||
++scan_win.y;
|
||||
if (scan_win.y % tile_height == 0)
|
||||
{
|
||||
gimp_pixel_rgn_set_rect (&scan_win.region, scan_win.tile,
|
||||
0, scan_win.y - tile_height,
|
||||
scan_win.param.pixels_per_line,
|
||||
tile_height);
|
||||
GeglBuffer* buffer;
|
||||
const Babl *format;
|
||||
|
||||
buffer = gimp_drawable_get_buffer(scan_win.layer_ID);
|
||||
gegl_buffer_set(buffer,GEGL_RECTANGLE(0, scan_win.y - tile_height,
|
||||
scan_win.param.pixels_per_line,
|
||||
tile_height),
|
||||
0, NULL, scan_win.tile, GEGL_AUTO_ROWSTRIDE);
|
||||
g_object_unref(buffer);
|
||||
if (scan_win.param.format >= SANE_FRAME_RED
|
||||
&& scan_win.param.format <= SANE_FRAME_BLUE)
|
||||
{
|
||||
|
@ -694,10 +717,22 @@ advance (void)
|
|||
height = tile_height;
|
||||
if (scan_win.y + height >= scan_win.param.lines)
|
||||
height = scan_win.param.lines - scan_win.y;
|
||||
gimp_pixel_rgn_get_rect (&scan_win.region, scan_win.tile,
|
||||
0, scan_win.y,
|
||||
scan_win.param.pixels_per_line,
|
||||
height);
|
||||
|
||||
format = _gimp_babl_get_format ();
|
||||
if (format != NULL)
|
||||
{
|
||||
buffer = gimp_drawable_get_buffer (scan_win.layer_ID);
|
||||
gegl_buffer_get (buffer,
|
||||
GEGL_RECTANGLE (0,
|
||||
scan_win.y,
|
||||
scan_win.param.pixels_per_line,
|
||||
height),
|
||||
1.0,
|
||||
format,
|
||||
scan_win.tile,
|
||||
GEGL_AUTO_ROWSTRIDE, GEGL_ABYSS_NONE);
|
||||
g_object_unref (buffer);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -745,8 +780,8 @@ write_swapped_words (FILE * f, char *buf, guint len)
|
|||
DBG (DBG_debug, "write_swapped_words: finished\n");
|
||||
}
|
||||
|
||||
static void
|
||||
input_available (gpointer data, gint source, GdkInputCondition cond)
|
||||
static gboolean
|
||||
input_available (gpointer data, gint source, GIOCondition cond)
|
||||
{
|
||||
SANE_Handle dev = gsg_dialog_get_device (dialog);
|
||||
static char buf[32768];
|
||||
|
@ -771,7 +806,7 @@ input_available (gpointer data, gint source, GdkInputCondition cond)
|
|||
}
|
||||
else
|
||||
{
|
||||
gdk_input_remove (scan_win.input_tag);
|
||||
g_source_remove (scan_win.input_tag);
|
||||
scan_win.input_tag = -1;
|
||||
}
|
||||
scan_start ();
|
||||
|
@ -785,7 +820,7 @@ input_available (gpointer data, gint source, GdkInputCondition cond)
|
|||
gsg_error (buf);
|
||||
}
|
||||
scan_done ();
|
||||
return;
|
||||
return FALSE;
|
||||
}
|
||||
if (!len) /* out of data for now */
|
||||
{
|
||||
|
@ -955,11 +990,11 @@ input_available (gpointer data, gint source, GdkInputCondition cond)
|
|||
fprintf (stderr, "%s.input_available: bad frame format %d\n",
|
||||
prog_name, scan_win.param.format);
|
||||
scan_done ();
|
||||
return;
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
DBG (DBG_debug, "input_available: finished\n");
|
||||
return;
|
||||
return TRUE;
|
||||
|
||||
#ifdef HAVE_LIBGIMP_GIMP_H
|
||||
bad_depth:
|
||||
|
@ -967,7 +1002,7 @@ bad_depth:
|
|||
scan_win.param.depth);
|
||||
gsg_error (buf);
|
||||
scan_done ();
|
||||
return;
|
||||
return FALSE;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -983,7 +1018,7 @@ scan_done (void)
|
|||
|
||||
if (scan_win.input_tag >= 0)
|
||||
{
|
||||
gdk_input_remove (scan_win.input_tag);
|
||||
g_source_remove (scan_win.input_tag);
|
||||
scan_win.input_tag = -1;
|
||||
}
|
||||
|
||||
|
@ -1012,12 +1047,16 @@ scan_done (void)
|
|||
|
||||
remaining = scan_win.y % gimp_tile_height ();
|
||||
if (remaining)
|
||||
gimp_pixel_rgn_set_rect (&scan_win.region, scan_win.tile,
|
||||
0, scan_win.y - remaining,
|
||||
scan_win.param.pixels_per_line, remaining);
|
||||
gimp_drawable_flush (scan_win.drawable);
|
||||
{
|
||||
GeglBuffer* buffer;
|
||||
buffer = gimp_drawable_get_buffer(scan_win.layer_ID);
|
||||
gegl_buffer_set(buffer,GEGL_RECTANGLE(0, scan_win.y - remaining,
|
||||
scan_win.param.pixels_per_line,
|
||||
remaining),
|
||||
0, NULL, scan_win.tile, GEGL_AUTO_ROWSTRIDE);
|
||||
g_object_unref(buffer);
|
||||
}
|
||||
gimp_display_new (scan_win.image_ID);
|
||||
gimp_drawable_detach (scan_win.drawable);
|
||||
g_free (scan_win.tile);
|
||||
scan_win.tile = 0;
|
||||
}
|
||||
|
@ -1043,10 +1082,6 @@ scan_start (void)
|
|||
SANE_Word resolution;
|
||||
#endif /* HAVE_LIBGIMP_GIMP_H */
|
||||
|
||||
#ifdef HAVE_SYS_TIME_H
|
||||
struct timeval start, current;
|
||||
#endif
|
||||
|
||||
const char *frame_type = 0;
|
||||
char buf[256];
|
||||
int fd;
|
||||
|
@ -1062,6 +1097,8 @@ scan_start (void)
|
|||
#ifdef HAVE_LIBGIMP_GIMP_H
|
||||
if (scan_win.mode == SANE_GIMP_EXTENSION && scan_win.tile)
|
||||
{
|
||||
const Babl *format;
|
||||
GeglBuffer* buffer;
|
||||
int height, remaining;
|
||||
|
||||
/* write the last tile of the frame to the GIMP region: */
|
||||
|
@ -1071,17 +1108,42 @@ scan_start (void)
|
|||
|
||||
remaining = scan_win.y % gimp_tile_height ();
|
||||
if (remaining)
|
||||
gimp_pixel_rgn_set_rect (&scan_win.region, scan_win.tile,
|
||||
0, scan_win.y - remaining,
|
||||
scan_win.param.pixels_per_line, remaining);
|
||||
{
|
||||
buffer = gimp_drawable_get_buffer(scan_win.layer_ID);
|
||||
gegl_buffer_set(buffer,GEGL_RECTANGLE(0, scan_win.y - remaining,
|
||||
scan_win.param.pixels_per_line,
|
||||
remaining),
|
||||
0, NULL, scan_win.tile, GEGL_AUTO_ROWSTRIDE);
|
||||
g_object_unref(buffer);
|
||||
}
|
||||
|
||||
/* initialize the tile with the first tile of the GIMP region: */
|
||||
|
||||
height = gimp_tile_height ();
|
||||
if (height >= scan_win.param.lines)
|
||||
height = scan_win.param.lines;
|
||||
gimp_pixel_rgn_get_rect (&scan_win.region, scan_win.tile,
|
||||
0, 0, scan_win.param.pixels_per_line, height);
|
||||
|
||||
format = _gimp_babl_get_format ();
|
||||
if (format != NULL)
|
||||
{
|
||||
buffer = gimp_drawable_get_buffer (scan_win.layer_ID);
|
||||
gegl_buffer_get (buffer,
|
||||
GEGL_RECTANGLE (0,
|
||||
0,
|
||||
scan_win.param.pixels_per_line,
|
||||
height),
|
||||
1.0,
|
||||
format,
|
||||
scan_win.tile,
|
||||
GEGL_AUTO_ROWSTRIDE, GEGL_ABYSS_NONE);
|
||||
g_object_unref (buffer);
|
||||
}
|
||||
/*
|
||||
gegl_buffer_get (buffer,
|
||||
GEGL_RECTANGLE (0, 0, scan_win.param.pixels_per_line, height), 1.0,
|
||||
format, scan_win.tile,
|
||||
GEGL_AUTO_ROWSTRIDE, GEGL_ABYSS_NONE);
|
||||
*/
|
||||
}
|
||||
#endif /* HAVE_LIBGIMP_GIMP_H */
|
||||
|
||||
|
@ -1102,8 +1164,9 @@ scan_start (void)
|
|||
progress_free (scan_win.progress);
|
||||
snprintf (buf, sizeof (buf), "Scanner is warming up.");
|
||||
scan_win.progress = progress_new ("Warming up ...", buf, scan_win.shell,
|
||||
(GtkSignalFunc) cancel_action, NULL);
|
||||
G_CALLBACK (cancel_action), NULL);
|
||||
#ifdef HAVE_SYS_TIME_H
|
||||
struct timeval start, current;
|
||||
gettimeofday(&start,NULL);
|
||||
#endif
|
||||
while (status == SANE_STATUS_WARMING_UP)
|
||||
|
@ -1249,7 +1312,6 @@ scan_start (void)
|
|||
{
|
||||
GimpImageType image_type = GIMP_RGB;
|
||||
GimpImageType drawable_type = GIMP_RGB_IMAGE;
|
||||
gint32 layer_ID;
|
||||
|
||||
if (scan_win.param.format == SANE_FRAME_GRAY)
|
||||
{
|
||||
|
@ -1261,23 +1323,22 @@ scan_start (void)
|
|||
scan_win.param.lines,
|
||||
image_type);
|
||||
|
||||
/* the following is supported since gimp-1.1.0 */
|
||||
#ifdef GIMP_HAVE_RESOLUTION_INFO
|
||||
if (resolution > 0)
|
||||
gimp_image_set_resolution (scan_win.image_ID, resolution,
|
||||
resolution);
|
||||
#endif
|
||||
|
||||
layer_ID = gimp_layer_new (scan_win.image_ID, "Background",
|
||||
scan_win.layer_ID = gimp_layer_new (scan_win.image_ID, "Background",
|
||||
scan_win.param.pixels_per_line,
|
||||
scan_win.param.lines,
|
||||
drawable_type, 100, GIMP_NORMAL_MODE);
|
||||
gimp_image_add_layer (scan_win.image_ID, layer_ID, 0);
|
||||
|
||||
gimp_image_get_default_new_layer_mode (scan_win.image_ID);
|
||||
gimp_image_insert_layer (scan_win.image_ID, scan_win.layer_ID, -1, 0);
|
||||
/*
|
||||
scan_win.drawable = gimp_drawable_get (layer_ID);
|
||||
gimp_pixel_rgn_init (&scan_win.region, scan_win.drawable, 0, 0,
|
||||
scan_win.drawable->width,
|
||||
scan_win.drawable->height, TRUE, FALSE);
|
||||
*/
|
||||
scan_win.tile = g_new (guchar, tile_size);
|
||||
scan_win.first_frame = 1;
|
||||
}
|
||||
|
@ -1291,19 +1352,23 @@ scan_start (void)
|
|||
if (scan_win.progress)
|
||||
progress_free (scan_win.progress);
|
||||
scan_win.progress = progress_new ("Scanning", buf, GTK_WINDOW(scan_win.shell),
|
||||
(GtkSignalFunc) cancel_action, 0);
|
||||
G_CALLBACK (cancel_action), 0);
|
||||
|
||||
scan_win.input_tag = -1;
|
||||
if (sane_set_io_mode (dev, SANE_TRUE) == SANE_STATUS_GOOD
|
||||
&& sane_get_select_fd (dev, &fd) == SANE_STATUS_GOOD)
|
||||
{
|
||||
GIOChannel *chan = g_io_channel_unix_new (fd);
|
||||
scan_win.input_tag =
|
||||
gdk_input_add (fd, GDK_INPUT_READ | GDK_INPUT_EXCEPTION,
|
||||
input_available, 0);
|
||||
g_io_add_watch (chan, G_IO_IN | G_IO_HUP | G_IO_ERR | G_IO_PRI,
|
||||
(GIOFunc) input_available, 0);
|
||||
g_io_channel_unref(chan);
|
||||
}
|
||||
else
|
||||
{
|
||||
while (gtk_events_pending ())
|
||||
gtk_main_iteration ();
|
||||
input_available (0, -1, GDK_INPUT_READ);
|
||||
input_available (0, -1, G_IO_IN);
|
||||
}
|
||||
DBG (DBG_debug, "scan_start: finished\n");
|
||||
}
|
||||
|
@ -1400,8 +1465,8 @@ files_build_menu (void)
|
|||
|
||||
item = gtk_menu_item_new_with_label ("Exit");
|
||||
gtk_container_add (GTK_CONTAINER (menu), item);
|
||||
gtk_signal_connect (GTK_OBJECT (item), "activate",
|
||||
(GtkSignalFunc) files_exit_callback, 0);
|
||||
g_signal_connect (G_OBJECT (item), "activate",
|
||||
G_CALLBACK (files_exit_callback), 0);
|
||||
gtk_widget_show (item);
|
||||
|
||||
DBG (DBG_debug, "files_build_menu: finished\n");
|
||||
|
@ -1436,7 +1501,7 @@ update_int_callback (GtkWidget * widget, gpointer data)
|
|||
{
|
||||
int *valuep = data;
|
||||
|
||||
*valuep = (GTK_TOGGLE_BUTTON (widget)->active != 0);
|
||||
*valuep = (gtk_widget_get_sensitive ( widget) != 0);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -1505,17 +1570,18 @@ preview_options_dialog (GtkWidget * widget, gpointer data)
|
|||
sprintf (buf, "%s preview options", prog_name);
|
||||
gtk_window_set_title (GTK_WINDOW (dialog), buf);
|
||||
|
||||
vbox = GTK_DIALOG (dialog)->vbox;
|
||||
vbox = gtk_dialog_get_content_area(GTK_DIALOG (dialog));
|
||||
|
||||
/* preserve preview image: */
|
||||
|
||||
hbox = gtk_hbox_new ( /* homogeneous */ FALSE, 0);
|
||||
hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 2);
|
||||
gtk_box_set_homogeneous (GTK_BOX (hbox), FALSE);
|
||||
gtk_box_pack_start (GTK_BOX (vbox), hbox, TRUE, TRUE, 2);
|
||||
button = gtk_check_button_new_with_label ("Preserve preview image");
|
||||
gtk_signal_connect (GTK_OBJECT (button), "toggled",
|
||||
(GtkSignalFunc) update_int_callback,
|
||||
g_signal_connect (G_OBJECT (button), "toggled",
|
||||
G_CALLBACK (update_int_callback),
|
||||
&preferences.preserve_preview);
|
||||
gtk_toggle_button_set_state (GTK_TOGGLE_BUTTON (button),
|
||||
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button),
|
||||
preferences.preserve_preview);
|
||||
gtk_box_pack_start (GTK_BOX (hbox), button, TRUE, TRUE, 2);
|
||||
|
||||
|
@ -1524,13 +1590,14 @@ preview_options_dialog (GtkWidget * widget, gpointer data)
|
|||
|
||||
/* private colormap: */
|
||||
|
||||
hbox = gtk_hbox_new ( /* homogeneous */ FALSE, 0);
|
||||
hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 2);
|
||||
gtk_box_set_homogeneous (GTK_BOX (hbox), FALSE);
|
||||
gtk_box_pack_start (GTK_BOX (vbox), hbox, TRUE, TRUE, 2);
|
||||
button = gtk_check_button_new_with_label ("Use private colormap");
|
||||
gtk_signal_connect (GTK_OBJECT (button), "toggled",
|
||||
(GtkSignalFunc) update_int_callback,
|
||||
g_signal_connect (G_OBJECT (button), "toggled",
|
||||
G_CALLBACK (update_int_callback),
|
||||
&preferences.preview_own_cmap);
|
||||
gtk_toggle_button_set_state (GTK_TOGGLE_BUTTON (button),
|
||||
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button),
|
||||
preferences.preview_own_cmap);
|
||||
gtk_box_pack_start (GTK_BOX (hbox), button, TRUE, TRUE, 2);
|
||||
|
||||
|
@ -1539,7 +1606,8 @@ preview_options_dialog (GtkWidget * widget, gpointer data)
|
|||
|
||||
/* gamma correction value: */
|
||||
|
||||
hbox = gtk_hbox_new ( /* homogeneous */ FALSE, 0);
|
||||
hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 2);
|
||||
gtk_box_set_homogeneous (GTK_BOX (hbox), FALSE);
|
||||
gtk_box_pack_start (GTK_BOX (vbox), hbox, TRUE, TRUE, 2);
|
||||
gtk_widget_show (hbox);
|
||||
|
||||
|
@ -1551,27 +1619,24 @@ preview_options_dialog (GtkWidget * widget, gpointer data)
|
|||
text = gtk_entry_new ();
|
||||
gtk_entry_set_text (GTK_ENTRY (text), buf);
|
||||
gtk_box_pack_start (GTK_BOX (hbox), text, TRUE, TRUE, 2);
|
||||
gtk_signal_connect (GTK_OBJECT (text), "changed",
|
||||
(GtkSignalFunc) update_double_callback,
|
||||
g_signal_connect (G_OBJECT (text), "changed",
|
||||
G_CALLBACK (update_double_callback),
|
||||
&preferences.preview_gamma);
|
||||
gtk_widget_show (text);
|
||||
|
||||
/* fill in action area: */
|
||||
hbox = GTK_DIALOG (dialog)->action_area;
|
||||
button = gtk_dialog_add_button (GTK_DIALOG (dialog), "OK", GTK_RESPONSE_OK);
|
||||
gtk_widget_set_can_default (button, TRUE);
|
||||
g_signal_connect (G_OBJECT (button), "clicked",
|
||||
G_CALLBACK (preview_options_ok_callback), dialog);
|
||||
|
||||
button = gtk_button_new_with_label ("OK");
|
||||
GTK_WIDGET_SET_FLAGS (button, GTK_CAN_DEFAULT);
|
||||
gtk_signal_connect (GTK_OBJECT (button), "clicked",
|
||||
(GtkSignalFunc) preview_options_ok_callback, 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 ("Cancel");
|
||||
gtk_signal_connect (GTK_OBJECT (button), "clicked",
|
||||
(GtkSignalFunc) preview_options_cancel_callback,
|
||||
button = gtk_dialog_add_button (GTK_DIALOG (dialog), "Cancel", GTK_RESPONSE_CANCEL);
|
||||
g_signal_connect (G_OBJECT (button), "clicked",
|
||||
G_CALLBACK (preview_options_cancel_callback),
|
||||
dialog);
|
||||
gtk_box_pack_start (GTK_BOX (hbox), button, TRUE, TRUE, 0);
|
||||
gtk_widget_show (button);
|
||||
|
||||
gtk_widget_show (dialog);
|
||||
|
@ -1625,7 +1690,7 @@ pref_device_restore (void)
|
|||
static void
|
||||
pref_toggle_advanced (GtkWidget * widget, gpointer data)
|
||||
{
|
||||
preferences.advanced = (GTK_CHECK_MENU_ITEM (widget)->active != 0);
|
||||
preferences.advanced = gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM (widget));
|
||||
gsg_set_advanced (dialog, preferences.advanced);
|
||||
pref_xscanimage_save ();
|
||||
}
|
||||
|
@ -1633,15 +1698,15 @@ pref_toggle_advanced (GtkWidget * widget, gpointer data)
|
|||
static void
|
||||
pref_toggle_tooltips (GtkWidget * widget, gpointer data)
|
||||
{
|
||||
preferences.tooltips_enabled = (GTK_CHECK_MENU_ITEM (widget)->active != 0);
|
||||
gsg_set_tooltips (dialog, preferences.tooltips_enabled);
|
||||
preferences.tooltips_enabled = gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM (widget));
|
||||
gsg_set_tooltips (preferences.tooltips_enabled);
|
||||
pref_xscanimage_save ();
|
||||
}
|
||||
|
||||
static void
|
||||
pref_toggle_twocolumn (GtkWidget * widget, gpointer data)
|
||||
{
|
||||
preferences.twocolumn_enabled = (GTK_CHECK_MENU_ITEM (widget)->active != 0);
|
||||
preferences.twocolumn_enabled = gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM (widget));
|
||||
gsg_set_twocolumn (dialog, preferences.twocolumn_enabled);
|
||||
pref_xscanimage_save ();
|
||||
}
|
||||
|
@ -1659,53 +1724,53 @@ pref_build_menu (void)
|
|||
|
||||
/* advanced user option: */
|
||||
item = gtk_check_menu_item_new_with_label ("Show advanced options");
|
||||
gtk_check_menu_item_set_state (GTK_CHECK_MENU_ITEM (item),
|
||||
gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (item),
|
||||
preferences.advanced);
|
||||
gtk_menu_append (GTK_MENU (menu), item);
|
||||
gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
|
||||
gtk_widget_show (item);
|
||||
gtk_signal_connect (GTK_OBJECT (item), "toggled",
|
||||
(GtkSignalFunc) pref_toggle_advanced, 0);
|
||||
g_signal_connect (G_OBJECT (item), "toggled",
|
||||
G_CALLBACK (pref_toggle_advanced), 0);
|
||||
|
||||
/* tooltips submenu: */
|
||||
|
||||
item = gtk_check_menu_item_new_with_label ("Show tooltips");
|
||||
gtk_check_menu_item_set_state (GTK_CHECK_MENU_ITEM (item),
|
||||
gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (item),
|
||||
preferences.tooltips_enabled);
|
||||
gtk_menu_append (GTK_MENU (menu), item);
|
||||
gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
|
||||
gtk_widget_show (item);
|
||||
gtk_signal_connect (GTK_OBJECT (item), "toggled",
|
||||
(GtkSignalFunc) pref_toggle_tooltips, 0);
|
||||
g_signal_connect (G_OBJECT (item), "toggled",
|
||||
G_CALLBACK (pref_toggle_tooltips), 0);
|
||||
|
||||
/* two column submenu: */
|
||||
|
||||
item = gtk_check_menu_item_new_with_label ("Show two column display");
|
||||
gtk_check_menu_item_set_state (GTK_CHECK_MENU_ITEM (item),
|
||||
gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (item),
|
||||
preferences.twocolumn_enabled);
|
||||
gtk_menu_append (GTK_MENU (menu), item);
|
||||
gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
|
||||
gtk_widget_show (item);
|
||||
gtk_signal_connect (GTK_OBJECT (item), "toggled",
|
||||
(GtkSignalFunc) pref_toggle_twocolumn, 0);
|
||||
g_signal_connect (G_OBJECT (item), "toggled",
|
||||
G_CALLBACK (pref_toggle_twocolumn), 0);
|
||||
|
||||
/* length unit submenu: */
|
||||
|
||||
item = gtk_menu_item_new_with_label ("Length unit");
|
||||
gtk_menu_append (GTK_MENU (menu), item);
|
||||
gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
|
||||
gtk_widget_show (item);
|
||||
|
||||
submenu = gtk_menu_new ();
|
||||
|
||||
unit_mm = gtk_radio_menu_item_new_with_label (units_group, "millimeters");
|
||||
units_group = gtk_radio_menu_item_group (GTK_RADIO_MENU_ITEM (unit_mm));
|
||||
gtk_menu_append (GTK_MENU (submenu), unit_mm);
|
||||
units_group = gtk_radio_menu_item_get_group (GTK_RADIO_MENU_ITEM (unit_mm));
|
||||
gtk_menu_shell_append (GTK_MENU_SHELL (submenu), unit_mm);
|
||||
gtk_widget_show (unit_mm);
|
||||
|
||||
unit_cm = gtk_radio_menu_item_new_with_label (units_group, "centimeters");
|
||||
units_group = gtk_radio_menu_item_group (GTK_RADIO_MENU_ITEM (unit_cm));
|
||||
gtk_menu_append (GTK_MENU (submenu), unit_cm);
|
||||
units_group = gtk_radio_menu_item_get_group (GTK_RADIO_MENU_ITEM (unit_cm));
|
||||
gtk_menu_shell_append (GTK_MENU_SHELL (submenu), unit_cm);
|
||||
gtk_widget_show (unit_cm);
|
||||
|
||||
unit_in = gtk_radio_menu_item_new_with_label (units_group, "inches");
|
||||
gtk_menu_append (GTK_MENU (submenu), unit_in);
|
||||
gtk_menu_shell_append (GTK_MENU_SHELL (submenu), unit_in);
|
||||
gtk_widget_show (unit_in);
|
||||
|
||||
unit = preferences.length_unit;
|
||||
|
@ -1718,38 +1783,38 @@ pref_build_menu (void)
|
|||
gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (unit_mm), TRUE);
|
||||
preferences.length_unit = 1.0;
|
||||
}
|
||||
gtk_signal_connect (GTK_OBJECT (unit_mm), "toggled",
|
||||
(GtkSignalFunc) pref_set_unit_callback, "mm");
|
||||
gtk_signal_connect (GTK_OBJECT (unit_cm), "toggled",
|
||||
(GtkSignalFunc) pref_set_unit_callback, "cm");
|
||||
gtk_signal_connect (GTK_OBJECT (unit_in), "toggled",
|
||||
(GtkSignalFunc) pref_set_unit_callback, "in");
|
||||
g_signal_connect (G_OBJECT (unit_mm), "toggled",
|
||||
G_CALLBACK (pref_set_unit_callback), "mm");
|
||||
g_signal_connect (G_OBJECT (unit_cm), "toggled",
|
||||
G_CALLBACK (pref_set_unit_callback), "cm");
|
||||
g_signal_connect (G_OBJECT (unit_in), "toggled",
|
||||
G_CALLBACK (pref_set_unit_callback), "in");
|
||||
|
||||
gtk_menu_item_set_submenu (GTK_MENU_ITEM (item), submenu);
|
||||
|
||||
/* preview options: */
|
||||
|
||||
item = gtk_menu_item_new_with_label ("Preview options...");
|
||||
gtk_menu_append (GTK_MENU (menu), item);
|
||||
gtk_signal_connect (GTK_OBJECT (item), "activate",
|
||||
(GtkSignalFunc) preview_options_dialog, 0);
|
||||
gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
|
||||
g_signal_connect (G_OBJECT (item), "activate",
|
||||
G_CALLBACK (preview_options_dialog), 0);
|
||||
gtk_widget_show (item);
|
||||
|
||||
/* insert separator: */
|
||||
item = gtk_menu_item_new ();
|
||||
gtk_menu_append (GTK_MENU (menu), item);
|
||||
gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
|
||||
gtk_widget_show (item);
|
||||
|
||||
item = gtk_menu_item_new_with_label ("Save device settings");
|
||||
gtk_menu_append (GTK_MENU (menu), item);
|
||||
gtk_signal_connect (GTK_OBJECT (item), "activate",
|
||||
(GtkSignalFunc) pref_device_save, 0);
|
||||
gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
|
||||
g_signal_connect (G_OBJECT (item), "activate",
|
||||
G_CALLBACK (pref_device_save), 0);
|
||||
gtk_widget_show (item);
|
||||
|
||||
item = gtk_menu_item_new_with_label ("Restore device settings");
|
||||
gtk_menu_append (GTK_MENU (menu), item);
|
||||
gtk_signal_connect (GTK_OBJECT (item), "activate",
|
||||
(GtkSignalFunc) pref_device_restore, 0);
|
||||
gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
|
||||
g_signal_connect (G_OBJECT (item), "activate",
|
||||
G_CALLBACK (pref_device_restore), 0);
|
||||
gtk_widget_show (item);
|
||||
|
||||
DBG (DBG_debug, "pref_build_menu: finished\n");
|
||||
|
@ -1804,13 +1869,13 @@ device_dialog (void)
|
|||
/* create the dialog box */
|
||||
scan_win.shell = gtk_dialog_new ();
|
||||
gtk_window_set_title (GTK_WINDOW (scan_win.shell), (char *) devname);
|
||||
gtk_window_set_policy (GTK_WINDOW (scan_win.shell), FALSE, TRUE, TRUE);
|
||||
gtk_window_set_resizable (GTK_WINDOW (scan_win.shell), TRUE);
|
||||
gtk_window_set_default_size (GTK_WINDOW (scan_win.shell), 400, 400);
|
||||
gtk_signal_connect (GTK_OBJECT (scan_win.shell), "delete_event",
|
||||
GTK_SIGNAL_FUNC (scan_win_delete), NULL);
|
||||
g_signal_connect (G_OBJECT (scan_win.shell), "delete_event",
|
||||
G_CALLBACK (scan_win_delete), NULL);
|
||||
|
||||
/* create the main vbox */
|
||||
vbox = GTK_DIALOG (scan_win.shell)->vbox;
|
||||
vbox = gtk_dialog_get_content_area(GTK_DIALOG (scan_win.shell));
|
||||
|
||||
/* create the menubar */
|
||||
|
||||
|
@ -1837,12 +1902,13 @@ device_dialog (void)
|
|||
if (scan_win.mode == STANDALONE)
|
||||
{
|
||||
frame = gtk_frame_new ("Output");
|
||||
gtk_container_border_width (GTK_CONTAINER (frame), 4);
|
||||
gtk_container_set_border_width (GTK_CONTAINER (frame), 4);
|
||||
gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_ETCHED_IN);
|
||||
gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0);
|
||||
|
||||
hbox = gtk_hbox_new (FALSE, 2);
|
||||
gtk_container_border_width (GTK_CONTAINER (hbox), 2);
|
||||
hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 2);
|
||||
gtk_box_set_homogeneous (GTK_BOX (hbox), FALSE);
|
||||
gtk_container_set_border_width (GTK_CONTAINER (hbox), 2);
|
||||
gtk_container_add (GTK_CONTAINER (frame), hbox);
|
||||
|
||||
label = gtk_label_new ("Filename");
|
||||
|
@ -1851,15 +1917,15 @@ device_dialog (void)
|
|||
text = gtk_entry_new ();
|
||||
gtk_entry_set_text (GTK_ENTRY (text), (char *) preferences.filename);
|
||||
gtk_box_pack_start (GTK_BOX (hbox), text, TRUE, TRUE, 2);
|
||||
gtk_signal_connect (GTK_OBJECT (text), "changed",
|
||||
(GtkSignalFunc) filename_changed_callback, 0);
|
||||
g_signal_connect (G_OBJECT (text), "changed",
|
||||
G_CALLBACK (filename_changed_callback), 0);
|
||||
|
||||
scan_win.filename_entry = text;
|
||||
|
||||
button = gtk_button_new_with_label ("Browse");
|
||||
gtk_box_pack_start (GTK_BOX (hbox), button, FALSE, FALSE, 2);
|
||||
gtk_signal_connect (GTK_OBJECT (button), "clicked",
|
||||
(GtkSignalFunc) browse_filename_callback, 0);
|
||||
g_signal_connect (G_OBJECT (button), "clicked",
|
||||
G_CALLBACK (browse_filename_callback), 0);
|
||||
|
||||
gtk_widget_show (button);
|
||||
gtk_widget_show (label);
|
||||
|
@ -1874,8 +1940,9 @@ device_dialog (void)
|
|||
GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
|
||||
gtk_scrolled_window_set_placement (GTK_SCROLLED_WINDOW (scrolled_window),
|
||||
GTK_CORNER_TOP_RIGHT);
|
||||
dialog_window = gtk_hbox_new ( /* homogeneous */ FALSE, 0);
|
||||
gtk_scrolled_window_add_with_viewport (GTK_SCROLLED_WINDOW
|
||||
dialog_window = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
|
||||
gtk_box_set_homogeneous (GTK_BOX (dialog_window), FALSE);
|
||||
gtk_container_add (GTK_CONTAINER
|
||||
(scrolled_window), dialog_window);
|
||||
|
||||
gtk_box_pack_start (GTK_BOX (vbox), scrolled_window, TRUE, TRUE, 0);
|
||||
|
@ -1888,8 +1955,9 @@ device_dialog (void)
|
|||
return;
|
||||
|
||||
/* The info row */
|
||||
hbox = gtk_hbox_new (FALSE, 5);
|
||||
gtk_container_border_width (GTK_CONTAINER (hbox), 3);
|
||||
hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 3);
|
||||
gtk_box_set_homogeneous (GTK_BOX (hbox), FALSE);
|
||||
gtk_container_set_border_width (GTK_CONTAINER (hbox), 3);
|
||||
gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
|
||||
gtk_widget_show (hbox);
|
||||
|
||||
|
@ -1898,8 +1966,9 @@ device_dialog (void)
|
|||
gtk_box_pack_start (GTK_BOX (hbox), frame, FALSE, FALSE, 0);
|
||||
gtk_widget_show (frame);
|
||||
|
||||
hbox = gtk_hbox_new (FALSE, 5);
|
||||
gtk_container_border_width (GTK_CONTAINER (hbox), 2);
|
||||
hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 5);
|
||||
gtk_box_set_homogeneous (GTK_BOX (hbox), FALSE);
|
||||
gtk_container_set_border_width (GTK_CONTAINER (hbox), 2);
|
||||
gtk_container_add (GTK_CONTAINER (frame), hbox);
|
||||
gtk_widget_show (hbox);
|
||||
|
||||
|
@ -1909,37 +1978,30 @@ device_dialog (void)
|
|||
|
||||
update_param (dialog, 0);
|
||||
|
||||
/* The bottom row of buttons */
|
||||
hbox = GTK_DIALOG (scan_win.shell)->action_area;
|
||||
|
||||
/* The Scan button */
|
||||
scan_win.scan_button = gtk_button_new_with_label ("Scan");
|
||||
gtk_signal_connect (GTK_OBJECT (scan_win.scan_button), "clicked",
|
||||
(GtkSignalFunc) scan_dialog, NULL);
|
||||
gtk_box_pack_start (GTK_BOX (hbox), scan_win.scan_button, TRUE, TRUE, 0);
|
||||
scan_win.scan_button = gtk_dialog_add_button (GTK_DIALOG (scan_win.shell), "Scan", GTK_RESPONSE_OK);
|
||||
g_signal_connect (G_OBJECT (scan_win.scan_button), "clicked",
|
||||
G_CALLBACK (scan_dialog), scan_win.shell);
|
||||
gtk_widget_show (scan_win.scan_button);
|
||||
|
||||
/* The Preview button */
|
||||
scan_win.preview_button =
|
||||
gtk_toggle_button_new_with_label ("Preview Window");
|
||||
gtk_signal_connect (GTK_OBJECT (scan_win.preview_button), "clicked",
|
||||
(GtkSignalFunc) scan_preview, NULL);
|
||||
gtk_box_pack_start (GTK_BOX (hbox), scan_win.preview_button, TRUE, TRUE, 0);
|
||||
scan_win.preview_button = gtk_dialog_add_button (GTK_DIALOG (scan_win.shell), "Preview Window", GTK_RESPONSE_ACCEPT);
|
||||
g_signal_connect (G_OBJECT (scan_win.preview_button), "clicked",
|
||||
G_CALLBACK (scan_preview), scan_win.shell);
|
||||
gtk_widget_show (scan_win.preview_button);
|
||||
|
||||
#if 0
|
||||
/* The Zoom in button */
|
||||
button = gtk_button_new_with_label ("Zoom");
|
||||
gtk_signal_connect (GTK_OBJECT (button), "clicked",
|
||||
button = gtk_dialog_add_button (GTK_DIALOG (scan_win.shell), "Zoom", GTK_RESPONSE_YES);
|
||||
g_signal_connect (G_OBJECT (button), "clicked",
|
||||
(GtkSignalFunc) zoom_in_preview, NULL);
|
||||
gtk_box_pack_start (GTK_BOX (hbox), button, TRUE, TRUE, 0);
|
||||
gtk_widget_show (button);
|
||||
|
||||
/* The Zoom out button */
|
||||
button = gtk_button_new_with_label ("Zoom out");
|
||||
gtk_signal_connect (GTK_OBJECT (button), "clicked",
|
||||
button = gtk_dialog_add_button (GTK_DIALOG (scan_win.shell), "Zoom out", GTK_RESPONSE_APPLY);
|
||||
g_signal_connect (G_OBJECT (button), "clicked",
|
||||
(GtkSignalFunc) zoom_out_preview, NULL);
|
||||
gtk_box_pack_start (GTK_BOX (hbox), button, TRUE, TRUE, 0);
|
||||
gtk_widget_show (button);
|
||||
#endif
|
||||
|
||||
|
@ -1959,69 +2021,80 @@ static int
|
|||
select_device_callback (GtkWidget * widget, GdkEventButton * event,
|
||||
gpointer data)
|
||||
{
|
||||
seldev = (long) data;
|
||||
if (event->type == GDK_2BUTTON_PRESS && event->button == 1)
|
||||
ok_choose_dialog_callback ();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void
|
||||
group_change_callback (GtkToggleButton* button,
|
||||
gpointer data)
|
||||
{
|
||||
if (gtk_toggle_button_get_active(button))
|
||||
{
|
||||
seldev = (long) data;
|
||||
}
|
||||
}
|
||||
|
||||
static gint32
|
||||
choose_device (void)
|
||||
{
|
||||
GtkWidget *main_vbox, *vbox, *hbox, *button;
|
||||
GSList *owner;
|
||||
GtkWidget *main_vbox, *vbox, *button;
|
||||
const SANE_Device *adev;
|
||||
gint i;
|
||||
|
||||
DBG (DBG_debug, "choose_device\n");
|
||||
choose_device_dialog = gtk_dialog_new ();
|
||||
gtk_window_set_title (GTK_WINDOW (choose_device_dialog), "Select device");
|
||||
gtk_signal_connect (GTK_OBJECT (choose_device_dialog), "delete_event",
|
||||
GTK_SIGNAL_FUNC (files_exit_callback), NULL);
|
||||
g_signal_connect (G_OBJECT (choose_device_dialog), "delete_event",
|
||||
G_CALLBACK (files_exit_callback), NULL);
|
||||
|
||||
main_vbox = GTK_DIALOG (choose_device_dialog)->vbox;
|
||||
main_vbox = gtk_dialog_get_content_area(GTK_DIALOG (choose_device_dialog));
|
||||
|
||||
/* The list of drivers */
|
||||
vbox = gtk_vbox_new (FALSE, 5);
|
||||
gtk_container_border_width (GTK_CONTAINER (vbox), 3);
|
||||
vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 5);
|
||||
gtk_box_set_homogeneous (GTK_BOX (vbox), FALSE);
|
||||
gtk_container_set_border_width (GTK_CONTAINER (vbox), 3);
|
||||
gtk_box_pack_start (GTK_BOX (main_vbox), vbox, TRUE, TRUE, 0);
|
||||
gtk_widget_show (vbox);
|
||||
|
||||
/* The radio buttons */
|
||||
owner = NULL;
|
||||
button = NULL;
|
||||
for (i = 0; i < ndevs; i++)
|
||||
{
|
||||
adev = devlist[i];
|
||||
|
||||
button = gtk_radio_button_new_with_label (owner, (char *) adev->name);
|
||||
gtk_signal_connect (GTK_OBJECT (button), "button_press_event",
|
||||
(GtkSignalFunc) select_device_callback,
|
||||
if (button == NULL)
|
||||
{
|
||||
button = gtk_radio_button_new_with_label (NULL, (char *) adev->name);
|
||||
}
|
||||
else
|
||||
button = gtk_radio_button_new_with_label_from_widget( GTK_RADIO_BUTTON(button), adev->name );
|
||||
g_signal_connect (G_OBJECT (button), "button_press_event",
|
||||
G_CALLBACK (select_device_callback),
|
||||
(void *) (long) i);
|
||||
g_signal_connect (G_OBJECT (button), "toggled",
|
||||
G_CALLBACK (group_change_callback),
|
||||
(void *) (long) i);
|
||||
gtk_box_pack_start (GTK_BOX (vbox), button, TRUE, TRUE, 0);
|
||||
gtk_widget_show (button);
|
||||
owner = gtk_radio_button_group (GTK_RADIO_BUTTON (button));
|
||||
if (i == defdev)
|
||||
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), TRUE);
|
||||
}
|
||||
|
||||
/* The bottom row of buttons */
|
||||
hbox = GTK_DIALOG (choose_device_dialog)->action_area;
|
||||
|
||||
/* The OK button */
|
||||
button = gtk_button_new_with_label ("OK");
|
||||
GTK_WIDGET_SET_FLAGS (button, GTK_CAN_DEFAULT);
|
||||
gtk_signal_connect (GTK_OBJECT (button), "clicked",
|
||||
(GtkSignalFunc) ok_choose_dialog_callback, NULL);
|
||||
gtk_box_pack_start (GTK_BOX (hbox), button, TRUE, TRUE, 0);
|
||||
button = gtk_dialog_add_button (GTK_DIALOG (choose_device_dialog), "OK", GTK_RESPONSE_OK);
|
||||
gtk_widget_set_can_default (button, TRUE);
|
||||
g_signal_connect (G_OBJECT (button), "clicked",
|
||||
G_CALLBACK (ok_choose_dialog_callback), NULL);
|
||||
|
||||
gtk_widget_grab_default (button);
|
||||
gtk_widget_show (button);
|
||||
|
||||
/* The Cancel button */
|
||||
button = gtk_button_new_with_label ("Cancel");
|
||||
gtk_signal_connect (GTK_OBJECT (button), "clicked",
|
||||
(GtkSignalFunc) files_exit_callback, NULL);
|
||||
gtk_box_pack_start (GTK_BOX (hbox), button, TRUE, TRUE, 0);
|
||||
button = gtk_dialog_add_button (GTK_DIALOG (choose_device_dialog), "Cancel", GTK_RESPONSE_OK);
|
||||
g_signal_connect (G_OBJECT (button), "clicked",
|
||||
G_CALLBACK (files_exit_callback), NULL);
|
||||
gtk_widget_show (button);
|
||||
|
||||
gtk_widget_show (choose_device_dialog);
|
||||
|
@ -2044,24 +2117,18 @@ Easy) devices.\n\
|
|||
static void
|
||||
init (int argc, char **argv)
|
||||
{
|
||||
char filename[PATH_MAX];
|
||||
struct stat st;
|
||||
//char filename[PATH_MAX];
|
||||
//struct stat st;
|
||||
SANE_Status status;
|
||||
|
||||
DBG_INIT ();
|
||||
|
||||
DBG (DBG_debug, "init\n");
|
||||
gtk_init (&argc, &argv);
|
||||
/*
|
||||
#ifdef HAVE_LIBGIMP_GIMP_H
|
||||
gtk_rc_parse (gimp_gtkrc ());
|
||||
|
||||
# ifndef ENABLE_GIMP_1_2
|
||||
/* GIMP 2.0 defines gimp_use_xshm() as a macro always returning TRUE
|
||||
* (in the compat header) */
|
||||
gdk_set_use_xshm (TRUE);
|
||||
# else
|
||||
gdk_set_use_xshm (gimp_use_xshm ());
|
||||
# endif /* !ENABLE_GIMP_1_2 */
|
||||
#endif
|
||||
|
||||
gsg_make_path (sizeof (filename), filename, 0, "sane-style", 0, ".rc");
|
||||
|
@ -2075,7 +2142,7 @@ init (int argc, char **argv)
|
|||
if (stat (filename, &st) >= 0)
|
||||
gtk_rc_parse (filename);
|
||||
}
|
||||
|
||||
*/
|
||||
status = sane_init (0, 0);
|
||||
if (status != SANE_STATUS_GOOD)
|
||||
{
|
||||
|
|
Ładowanie…
Reference in New Issue