kopia lustrzana https://gitlab.com/sane-project/frontends
2001-04-27 Henning Meier-Geinitz <henning@meier-geinitz.de>
* doc/xscanimage.man src/xscanimage.c src/xscanimage-gimp-1_0-compat.h: Implemented (again) support for SANE_DEFAULT_DEVICE. If set, the suitable backend is preselected in the device dialog. Use new Gimp API, added compatibility file for old Gimp API (from xsane). * TODO: Removed entry about SANE_DEFAULT_DEVICE and new Gimp API.DEVEL_2_0_BRANCH-1
rodzic
5bfab6c747
commit
20a007a0a2
12
TODO
12
TODO
|
@ -33,21 +33,19 @@ TODO (2000-12-23)
|
|||
it announced by sane_get_parameters to avoid segfaults with bad
|
||||
backends?
|
||||
|
||||
* Adapt xscanimage to new GIMP API. Try to make it backwards compatible
|
||||
with old GIMP versions if possible. Maybe two source/header files
|
||||
for compatibility with old API?
|
||||
|
||||
* Test frontends on different os/platforms, fix possible compilation
|
||||
problems
|
||||
|
||||
* Add support for SANE_DEFAULT_DEVICE to xcam/xscanimage. Show the list
|
||||
of devices with the SANE_DEFAULT_DEVICE preselected.
|
||||
|
||||
* Add/improve debug output for xscanimage and xcam.
|
||||
|
||||
|
||||
******** done ********
|
||||
|
||||
* Adapt xscanimage to new GIMP API. Try to make it backwards compatible
|
||||
with old GIMP versions if possible. Maybe two source/header files
|
||||
for compatibility with old API?
|
||||
* Add support for SANE_DEFAULT_DEVICE to xcam/xscanimage. Show the list
|
||||
of devices with the SANE_DEFAULT_DEVICE preselected.
|
||||
* use g_free for memory allocated by g_new.
|
||||
* check configure.in/aclocal.m4: Compilation/link test for SANE doesn't
|
||||
work.
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
.TH xscanimage 1 "11 Apr 2001"
|
||||
.TH xscanimage 1 "27 Apr 2001"
|
||||
.IX xscanimage
|
||||
.SH NAME
|
||||
xscanimage - scan an image
|
||||
|
@ -30,10 +30,10 @@ Now Easy) interface. The list of available devices depends on
|
|||
installed hardware and configuration. When invoked without an
|
||||
explicit devicename argument,
|
||||
.B xscanimage
|
||||
presents a dialog listing of all known and available devices. To access an
|
||||
available device that is not known to the system, the devicename must be
|
||||
specified explicitly. Another way to select a device is to set the
|
||||
environment variable SANE_DEFAULT_DEVICE to devicename. The format of
|
||||
presents a dialog listing of all known and available devices. If the
|
||||
environment variable SANE_DEFAULT_DEVICE is set to the devicename the device
|
||||
is preselected in the dialog. To access an available device that is not known
|
||||
to the system, the devicename must be specified explicitly. The format of
|
||||
devicename is backendname:devicefile (e.g. umax:/dev/sga).
|
||||
.SH RUNNING UNDER THE GIMP
|
||||
To run
|
||||
|
@ -113,7 +113,6 @@ debugging purposes only.
|
|||
.TP
|
||||
.B SANE_DEFAULT_DEVICE
|
||||
The default device-name. Example: SANE_DEFAULT_DEVICE="hp:/dev/scanner".
|
||||
Not implemented yet.
|
||||
.TP
|
||||
.B SANE_DEBUG_XSCANIMAGE
|
||||
This environment variable controls the debug level xscanimage. Higher
|
||||
|
|
|
@ -0,0 +1,47 @@
|
|||
/* xscanimage-gimp-1_0-compat.h -- stay compatible with gimp 1.0
|
||||
|
||||
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.
|
||||
|
||||
Copied from xsane (written by Oliver Rauch)
|
||||
*/
|
||||
|
||||
#ifndef XSCANIMAGE_GIMP_1_0_COMPAT_H
|
||||
#define XSCANIMAGE_GIMP_1_0_COMPAT_H
|
||||
|
||||
#define GimpPlugInInfo GPlugInInfo
|
||||
#define GimpParam GParam
|
||||
#define GimpParamDef GParamDef
|
||||
#define GimpDrawable GDrawable
|
||||
#define GimpPixelRgn GPixelRgn
|
||||
#define GimpRunModeType GRunModeType
|
||||
#define GimpImageType GImageType
|
||||
|
||||
#define GIMP_PDB_INT32 PARAM_INT32
|
||||
#define GIMP_PDB_STATUS PARAM_STATUS
|
||||
#define GIMP_PDB_CALLING_ERROR STATUS_CALLING_ERROR
|
||||
#define GIMP_PDB_SUCCESS STATUS_SUCCESS
|
||||
#define GIMP_RUN_INTERACTIVE RUN_INTERACTIVE
|
||||
#define GIMP_RUN_NONINTERACTIVE RUN_NONINTERACTIVE
|
||||
#define GIMP_RUN_WITH_LAST_VALS RUN_WITH_LAST_VALS
|
||||
#define GIMP_EXTENSION PROC_EXTENSION
|
||||
#define GIMP_RGB RGB
|
||||
#define GIMP_RGB_IMAGE RGB_IMAGE
|
||||
#define GIMP_GRAY GRAY
|
||||
#define GIMP_GRAY_IMAGE GRAY_IMAGE
|
||||
#define GIMP_RGBA_IMAGE RGBA_IMAGE
|
||||
#define GIMP_NORMAL_MODE NORMAL_MODE
|
||||
|
||||
#endif
|
||||
|
103
src/xscanimage.c
103
src/xscanimage.c
|
@ -60,18 +60,31 @@
|
|||
|
||||
#ifdef HAVE_LIBGIMP_GIMP_H
|
||||
|
||||
/*
|
||||
* Enable old Gimp API. Eventually, we should rewrite this frontend
|
||||
* to use the new API. [pere 2000-10-29]
|
||||
*/
|
||||
#define GIMP_ENABLE_COMPAT_CRUFT
|
||||
# ifdef HAVE_LIBGIMP_GIMPFEATURES_H
|
||||
# include <libgimp/gimpfeatures.h>
|
||||
# else
|
||||
# define GIMP_CHECK_VERSION(major, minor, micro) 0
|
||||
# endif /* HAVE_LIBGIMP_GIMPFEATURES_H */
|
||||
|
||||
# ifdef GIMP_CHECK_VERSION
|
||||
# if GIMP_CHECK_VERSION(1,1,25)
|
||||
/* ok, we have the new gimp interface */
|
||||
# else
|
||||
/* we have the old gimp interface and need the compatibility header file */
|
||||
# include "xscanimage-gimp-1_0-compat.h"
|
||||
# endif
|
||||
# else
|
||||
/* we have the old gimp interface and need the compatibility header file */
|
||||
# include "xscanimage-gimp-1_0-compat.h"
|
||||
# endif
|
||||
|
||||
#include <libgimp/gimp.h>
|
||||
|
||||
static void query (void);
|
||||
static void run (char *name, int nparams, GParam * param,
|
||||
int *nreturn_vals, GParam ** return_vals);
|
||||
static void run (char *name, int nparams, GimpParam * param,
|
||||
int *nreturn_vals, GimpParam ** return_vals);
|
||||
|
||||
GPlugInInfo PLUG_IN_INFO =
|
||||
GimpPlugInInfo PLUG_IN_INFO =
|
||||
{
|
||||
NULL, /* init_proc */
|
||||
NULL, /* quit_proc */
|
||||
|
@ -114,10 +127,10 @@ static struct
|
|||
#ifdef HAVE_LIBGIMP_GIMP_H
|
||||
/* for GIMP mode: */
|
||||
gint32 image_ID;
|
||||
GDrawable *drawable;
|
||||
GimpDrawable *drawable;
|
||||
guchar *tile;
|
||||
unsigned tile_offset;
|
||||
GPixelRgn region;
|
||||
GimpPixelRgn region;
|
||||
int first_frame; /* used for RED/GREEN/BLUE frames */
|
||||
#endif
|
||||
}
|
||||
|
@ -128,6 +141,7 @@ static GtkWidget *choose_device_dialog;
|
|||
static GSGDialog *dialog;
|
||||
static const SANE_Device **devlist;
|
||||
static gint seldev = -1; /* The selected device */
|
||||
static gint defdev = -1; /* The default device */
|
||||
static gint ndevs; /* The number of available devices */
|
||||
static struct option long_options[] =
|
||||
{
|
||||
|
@ -248,11 +262,11 @@ decode_devname (const char *encoded_devname, int n, char *buf)
|
|||
static void
|
||||
query (void)
|
||||
{
|
||||
static GParamDef args[] =
|
||||
static GimpParamDef args[] =
|
||||
{
|
||||
{PARAM_INT32, "run_mode", "Interactive, non-interactive"},
|
||||
{GIMP_PDB_INT32, "run_mode", "Interactive, non-interactive"},
|
||||
};
|
||||
static GParamDef *return_vals = NULL;
|
||||
static GimpParamDef *return_vals = NULL;
|
||||
static int nargs = sizeof (args) / sizeof (args[0]);
|
||||
static int nreturn_vals = 0;
|
||||
char mpath[1024];
|
||||
|
@ -270,7 +284,7 @@ query (void)
|
|||
"8th June 1997",
|
||||
"<Toolbox>/Xtns/Acquire Image/Device dialog...",
|
||||
"RGB, GRAY",
|
||||
PROC_EXTENSION,
|
||||
GIMP_EXTENSION,
|
||||
nargs, nreturn_vals,
|
||||
args, return_vals);
|
||||
|
||||
|
@ -301,18 +315,18 @@ query (void)
|
|||
"interface.",
|
||||
"Andy Beck, Tristan Tarrant, and David Mosberger",
|
||||
"Andy Beck, Tristan Tarrant, and David Mosberger",
|
||||
"8th June 1997", mpath, "RGB, GRAY", PROC_EXTENSION,
|
||||
"8th June 1997", mpath, "RGB, GRAY", GIMP_EXTENSION,
|
||||
nargs, nreturn_vals, args, return_vals);
|
||||
}
|
||||
sane_exit ();
|
||||
}
|
||||
|
||||
static void
|
||||
run (char *name, int nparams, GParam * param,
|
||||
int *nreturn_vals, GParam ** return_vals)
|
||||
run (char *name, int nparams, GimpParam * param,
|
||||
int *nreturn_vals, GimpParam ** return_vals)
|
||||
{
|
||||
static GParam values[2];
|
||||
GRunModeType run_mode;
|
||||
static GimpParam values[2];
|
||||
GimpRunModeType run_mode;
|
||||
char devname[1024];
|
||||
char *args[2];
|
||||
int nargs;
|
||||
|
@ -323,8 +337,7 @@ run (char *name, int nparams, GParam * param,
|
|||
*nreturn_vals = 1;
|
||||
*return_vals = values;
|
||||
|
||||
values[0].type = PARAM_STATUS;
|
||||
values[0].data.d_status = STATUS_CALLING_ERROR;
|
||||
values[0].type = GIMP_PDB_STATUS;
|
||||
|
||||
nargs = 0;
|
||||
args[nargs++] = "xscanimage";
|
||||
|
@ -339,16 +352,16 @@ run (char *name, int nparams, GParam * param,
|
|||
|
||||
switch (run_mode)
|
||||
{
|
||||
case RUN_INTERACTIVE:
|
||||
case GIMP_RUN_INTERACTIVE:
|
||||
interface (nargs, args);
|
||||
values[0].data.d_status = STATUS_SUCCESS;
|
||||
values[0].data.d_status = GIMP_PDB_SUCCESS;
|
||||
break;
|
||||
|
||||
case RUN_NONINTERACTIVE:
|
||||
case GIMP_RUN_NONINTERACTIVE:
|
||||
/* Make sure all the arguments are there! */
|
||||
break;
|
||||
|
||||
case RUN_WITH_LAST_VALS:
|
||||
case GIMP_RUN_WITH_LAST_VALS:
|
||||
/* Possibly retrieve data */
|
||||
break;
|
||||
|
||||
|
@ -931,14 +944,14 @@ scan_start (void)
|
|||
scan_win.first_frame = 0;
|
||||
else
|
||||
{
|
||||
GImageType image_type = RGB;
|
||||
GDrawableType drawable_type = RGB_IMAGE;
|
||||
GimpImageType image_type = GIMP_RGB;
|
||||
GimpImageType drawable_type = GIMP_RGB_IMAGE;
|
||||
gint32 layer_ID;
|
||||
|
||||
if (scan_win.param.format == SANE_FRAME_GRAY)
|
||||
{
|
||||
image_type = GRAY;
|
||||
drawable_type = GRAY_IMAGE;
|
||||
image_type = GIMP_GRAY;
|
||||
drawable_type = GIMP_GRAY_IMAGE;
|
||||
}
|
||||
|
||||
scan_win.image_ID = gimp_image_new (scan_win.param.pixels_per_line,
|
||||
|
@ -946,7 +959,7 @@ scan_start (void)
|
|||
layer_ID = gimp_layer_new (scan_win.image_ID, "Background",
|
||||
scan_win.param.pixels_per_line,
|
||||
scan_win.param.lines,
|
||||
drawable_type, 100, NORMAL_MODE);
|
||||
drawable_type, 100, GIMP_NORMAL_MODE);
|
||||
gimp_image_add_layer (scan_win.image_ID, layer_ID, 0);
|
||||
|
||||
scan_win.drawable = gimp_drawable_get (layer_ID);
|
||||
|
@ -1568,7 +1581,9 @@ choose_device (void)
|
|||
(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));;
|
||||
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 */
|
||||
|
@ -1671,9 +1686,31 @@ init (int argc, char **argv)
|
|||
seldev = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (seldev < 0)
|
||||
sane_get_devices (&devlist, SANE_FALSE);
|
||||
{
|
||||
char * defdevname;
|
||||
|
||||
sane_get_devices (&devlist, SANE_FALSE);
|
||||
if ((defdevname = getenv("SANE_DEFAULT_DEVICE")) != NULL)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; devlist[i] != 0; i++)
|
||||
{
|
||||
if (strcmp (devlist[i]->name, defdevname) == 0)
|
||||
{
|
||||
defdev = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (defdev < 0)
|
||||
DBG (DBG_error, "default device is `%s' wasn't found by "
|
||||
"sane_get_devices() \n", defdevname);
|
||||
else
|
||||
DBG (DBG_info, "default device is `%s'\n", defdevname);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
Ładowanie…
Reference in New Issue