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
|
it announced by sane_get_parameters to avoid segfaults with bad
|
||||||
backends?
|
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
|
* Test frontends on different os/platforms, fix possible compilation
|
||||||
problems
|
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.
|
* Add/improve debug output for xscanimage and xcam.
|
||||||
|
|
||||||
|
|
||||||
******** done ********
|
******** 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.
|
* use g_free for memory allocated by g_new.
|
||||||
* check configure.in/aclocal.m4: Compilation/link test for SANE doesn't
|
* check configure.in/aclocal.m4: Compilation/link test for SANE doesn't
|
||||||
work.
|
work.
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
.TH xscanimage 1 "11 Apr 2001"
|
.TH xscanimage 1 "27 Apr 2001"
|
||||||
.IX xscanimage
|
.IX xscanimage
|
||||||
.SH NAME
|
.SH NAME
|
||||||
xscanimage - scan an image
|
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
|
installed hardware and configuration. When invoked without an
|
||||||
explicit devicename argument,
|
explicit devicename argument,
|
||||||
.B xscanimage
|
.B xscanimage
|
||||||
presents a dialog listing of all known and available devices. To access an
|
presents a dialog listing of all known and available devices. If the
|
||||||
available device that is not known to the system, the devicename must be
|
environment variable SANE_DEFAULT_DEVICE is set to the devicename the device
|
||||||
specified explicitly. Another way to select a device is to set the
|
is preselected in the dialog. To access an available device that is not known
|
||||||
environment variable SANE_DEFAULT_DEVICE to devicename. The format of
|
to the system, the devicename must be specified explicitly. The format of
|
||||||
devicename is backendname:devicefile (e.g. umax:/dev/sga).
|
devicename is backendname:devicefile (e.g. umax:/dev/sga).
|
||||||
.SH RUNNING UNDER THE GIMP
|
.SH RUNNING UNDER THE GIMP
|
||||||
To run
|
To run
|
||||||
|
@ -113,7 +113,6 @@ debugging purposes only.
|
||||||
.TP
|
.TP
|
||||||
.B SANE_DEFAULT_DEVICE
|
.B SANE_DEFAULT_DEVICE
|
||||||
The default device-name. Example: SANE_DEFAULT_DEVICE="hp:/dev/scanner".
|
The default device-name. Example: SANE_DEFAULT_DEVICE="hp:/dev/scanner".
|
||||||
Not implemented yet.
|
|
||||||
.TP
|
.TP
|
||||||
.B SANE_DEBUG_XSCANIMAGE
|
.B SANE_DEBUG_XSCANIMAGE
|
||||||
This environment variable controls the debug level xscanimage. Higher
|
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
|
#ifdef HAVE_LIBGIMP_GIMP_H
|
||||||
|
|
||||||
/*
|
# ifdef HAVE_LIBGIMP_GIMPFEATURES_H
|
||||||
* Enable old Gimp API. Eventually, we should rewrite this frontend
|
# include <libgimp/gimpfeatures.h>
|
||||||
* to use the new API. [pere 2000-10-29]
|
# else
|
||||||
*/
|
# define GIMP_CHECK_VERSION(major, minor, micro) 0
|
||||||
#define GIMP_ENABLE_COMPAT_CRUFT
|
# 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>
|
#include <libgimp/gimp.h>
|
||||||
|
|
||||||
static void query (void);
|
static void query (void);
|
||||||
static void run (char *name, int nparams, GParam * param,
|
static void run (char *name, int nparams, GimpParam * param,
|
||||||
int *nreturn_vals, GParam ** return_vals);
|
int *nreturn_vals, GimpParam ** return_vals);
|
||||||
|
|
||||||
GPlugInInfo PLUG_IN_INFO =
|
GimpPlugInInfo PLUG_IN_INFO =
|
||||||
{
|
{
|
||||||
NULL, /* init_proc */
|
NULL, /* init_proc */
|
||||||
NULL, /* quit_proc */
|
NULL, /* quit_proc */
|
||||||
|
@ -114,10 +127,10 @@ static struct
|
||||||
#ifdef HAVE_LIBGIMP_GIMP_H
|
#ifdef HAVE_LIBGIMP_GIMP_H
|
||||||
/* for GIMP mode: */
|
/* for GIMP mode: */
|
||||||
gint32 image_ID;
|
gint32 image_ID;
|
||||||
GDrawable *drawable;
|
GimpDrawable *drawable;
|
||||||
guchar *tile;
|
guchar *tile;
|
||||||
unsigned tile_offset;
|
unsigned tile_offset;
|
||||||
GPixelRgn region;
|
GimpPixelRgn region;
|
||||||
int first_frame; /* used for RED/GREEN/BLUE frames */
|
int first_frame; /* used for RED/GREEN/BLUE frames */
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
@ -128,6 +141,7 @@ static GtkWidget *choose_device_dialog;
|
||||||
static GSGDialog *dialog;
|
static GSGDialog *dialog;
|
||||||
static const SANE_Device **devlist;
|
static const SANE_Device **devlist;
|
||||||
static gint seldev = -1; /* The selected device */
|
static gint seldev = -1; /* The selected device */
|
||||||
|
static gint defdev = -1; /* The default device */
|
||||||
static gint ndevs; /* The number of available devices */
|
static gint ndevs; /* The number of available devices */
|
||||||
static struct option long_options[] =
|
static struct option long_options[] =
|
||||||
{
|
{
|
||||||
|
@ -248,11 +262,11 @@ decode_devname (const char *encoded_devname, int n, char *buf)
|
||||||
static void
|
static void
|
||||||
query (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 nargs = sizeof (args) / sizeof (args[0]);
|
||||||
static int nreturn_vals = 0;
|
static int nreturn_vals = 0;
|
||||||
char mpath[1024];
|
char mpath[1024];
|
||||||
|
@ -270,7 +284,7 @@ query (void)
|
||||||
"8th June 1997",
|
"8th June 1997",
|
||||||
"<Toolbox>/Xtns/Acquire Image/Device dialog...",
|
"<Toolbox>/Xtns/Acquire Image/Device dialog...",
|
||||||
"RGB, GRAY",
|
"RGB, GRAY",
|
||||||
PROC_EXTENSION,
|
GIMP_EXTENSION,
|
||||||
nargs, nreturn_vals,
|
nargs, nreturn_vals,
|
||||||
args, return_vals);
|
args, return_vals);
|
||||||
|
|
||||||
|
@ -301,18 +315,18 @@ query (void)
|
||||||
"interface.",
|
"interface.",
|
||||||
"Andy Beck, Tristan Tarrant, and David Mosberger",
|
"Andy Beck, Tristan Tarrant, and David Mosberger",
|
||||||
"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);
|
nargs, nreturn_vals, args, return_vals);
|
||||||
}
|
}
|
||||||
sane_exit ();
|
sane_exit ();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
run (char *name, int nparams, GParam * param,
|
run (char *name, int nparams, GimpParam * param,
|
||||||
int *nreturn_vals, GParam ** return_vals)
|
int *nreturn_vals, GimpParam ** return_vals)
|
||||||
{
|
{
|
||||||
static GParam values[2];
|
static GimpParam values[2];
|
||||||
GRunModeType run_mode;
|
GimpRunModeType run_mode;
|
||||||
char devname[1024];
|
char devname[1024];
|
||||||
char *args[2];
|
char *args[2];
|
||||||
int nargs;
|
int nargs;
|
||||||
|
@ -323,8 +337,7 @@ run (char *name, int nparams, GParam * param,
|
||||||
*nreturn_vals = 1;
|
*nreturn_vals = 1;
|
||||||
*return_vals = values;
|
*return_vals = values;
|
||||||
|
|
||||||
values[0].type = PARAM_STATUS;
|
values[0].type = GIMP_PDB_STATUS;
|
||||||
values[0].data.d_status = STATUS_CALLING_ERROR;
|
|
||||||
|
|
||||||
nargs = 0;
|
nargs = 0;
|
||||||
args[nargs++] = "xscanimage";
|
args[nargs++] = "xscanimage";
|
||||||
|
@ -339,16 +352,16 @@ run (char *name, int nparams, GParam * param,
|
||||||
|
|
||||||
switch (run_mode)
|
switch (run_mode)
|
||||||
{
|
{
|
||||||
case RUN_INTERACTIVE:
|
case GIMP_RUN_INTERACTIVE:
|
||||||
interface (nargs, args);
|
interface (nargs, args);
|
||||||
values[0].data.d_status = STATUS_SUCCESS;
|
values[0].data.d_status = GIMP_PDB_SUCCESS;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case RUN_NONINTERACTIVE:
|
case GIMP_RUN_NONINTERACTIVE:
|
||||||
/* Make sure all the arguments are there! */
|
/* Make sure all the arguments are there! */
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case RUN_WITH_LAST_VALS:
|
case GIMP_RUN_WITH_LAST_VALS:
|
||||||
/* Possibly retrieve data */
|
/* Possibly retrieve data */
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -931,14 +944,14 @@ scan_start (void)
|
||||||
scan_win.first_frame = 0;
|
scan_win.first_frame = 0;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
GImageType image_type = RGB;
|
GimpImageType image_type = GIMP_RGB;
|
||||||
GDrawableType drawable_type = RGB_IMAGE;
|
GimpImageType drawable_type = GIMP_RGB_IMAGE;
|
||||||
gint32 layer_ID;
|
gint32 layer_ID;
|
||||||
|
|
||||||
if (scan_win.param.format == SANE_FRAME_GRAY)
|
if (scan_win.param.format == SANE_FRAME_GRAY)
|
||||||
{
|
{
|
||||||
image_type = GRAY;
|
image_type = GIMP_GRAY;
|
||||||
drawable_type = GRAY_IMAGE;
|
drawable_type = GIMP_GRAY_IMAGE;
|
||||||
}
|
}
|
||||||
|
|
||||||
scan_win.image_ID = gimp_image_new (scan_win.param.pixels_per_line,
|
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",
|
layer_ID = gimp_layer_new (scan_win.image_ID, "Background",
|
||||||
scan_win.param.pixels_per_line,
|
scan_win.param.pixels_per_line,
|
||||||
scan_win.param.lines,
|
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);
|
gimp_image_add_layer (scan_win.image_ID, layer_ID, 0);
|
||||||
|
|
||||||
scan_win.drawable = gimp_drawable_get (layer_ID);
|
scan_win.drawable = gimp_drawable_get (layer_ID);
|
||||||
|
@ -1568,7 +1581,9 @@ choose_device (void)
|
||||||
(void *) (long) i);
|
(void *) (long) i);
|
||||||
gtk_box_pack_start (GTK_BOX (vbox), button, TRUE, TRUE, 0);
|
gtk_box_pack_start (GTK_BOX (vbox), button, TRUE, TRUE, 0);
|
||||||
gtk_widget_show (button);
|
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 */
|
/* The bottom row of buttons */
|
||||||
|
@ -1671,9 +1686,31 @@ init (int argc, char **argv)
|
||||||
seldev = 0;
|
seldev = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (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
|
static void
|
||||||
|
|
Ładowanie…
Reference in New Issue