- switched to SANE 1.1

- handling of SANE_STATUS_WARMING_UP after sane_start() calls
	- xscanimage's progress dialog improvement
merge-requests/2/head
Stéphane Voltz 2008-06-06 04:29:44 +00:00
rodzic b011ab97f7
commit 5e96223e49
10 zmienionych plików z 132 dodań i 37 usunięć

Wyświetl plik

@ -1,3 +1,9 @@
2008-06-06 Stéphane Voltz <stef.dev@free.fr>
* src/gtkglue.c src/preview.c src/progress.c src/progress.h
src/scanadf.c src/xcam.c src/xscanimage.c configure.in configure:
change version to SANE 1.1, compile fixes for SANE 1.1, progress
dialog improvement and handling of SANE_STATUS_WRMING_UP
2008-04-30 Gerard Klaver <gerard at gkall dot hobby dot nl>
* src/xcam.c: For GRAY view mode added time stamp option,
removed compiler warning for DBG line

6
configure vendored
Wyświetl plik

@ -1324,8 +1324,8 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu
# version code:
V_MAJOR=1
V_MINOR=0
V_BUILD=14
V_MINOR=1
V_BUILD=0
V_EXTRA=-cvs
PACKAGE=sane-frontends
@ -6163,7 +6163,7 @@ else
echo "${ECHO_T}no" >&6
fi
min_sane_version=1.0.0
min_sane_version=1.1.0
echo "$as_me:$LINENO: checking for SANE - version >= $min_sane_version" >&5
echo $ECHO_N "checking for SANE - version >= $min_sane_version... $ECHO_C" >&6
no_sane=""

Wyświetl plik

@ -6,8 +6,8 @@ AC_CONFIG_HEADER(include/sane/config.h)
# version code:
V_MAJOR=1
V_MINOR=0
V_BUILD=14
V_MINOR=1
V_BUILD=0
V_EXTRA=-cvs
PACKAGE=sane-frontends
@ -112,7 +112,7 @@ fi
AC_CHECK_TOOL(RANLIB, ranlib, :)
AM_PATH_SANE(1.0.0, HAVE_SANE=yes, )
AM_PATH_SANE(1.1.0, HAVE_SANE=yes, )
dnl Print error message if sane is missing
if test "x${HAVE_SANE}" = "x"; then
echo "**********************************************************************"

Wyświetl plik

@ -1475,9 +1475,10 @@ gsg_set_sensitivity (GSGDialog * dialog, int sensitive)
if (!SANE_OPTION_IS_ACTIVE (opt->cap)
|| opt->type == SANE_TYPE_GROUP || !dialog->element[i].widget)
continue;
#ifdef SANE_CAP_ALWAYS_SETTABLE
if (!(opt->cap & SANE_CAP_ALWAYS_SETTABLE))
gtk_widget_set_sensitive (dialog->element[i].widget, sensitive);
#endif
}
}

Wyświetl plik

@ -73,11 +73,13 @@
#include <string.h>
#include <time.h>
#include <sys/time.h>
#include <sys/param.h>
#include "gtkglue.h"
#include "preview.h"
#include "preferences.h"
#include "progress.h"
#define DBG_fatal 0
#define DBG_error 1
@ -860,6 +862,10 @@ scan_start (Preview * p)
SANE_Status status;
char buf[256];
int fd, y;
Progress_t *progress;
#ifdef HAVE_SYS_TIME_H
struct timeval start, current;
#endif
gtk_widget_set_sensitive (p->cancel, TRUE);
gtk_widget_set_sensitive (p->preview, FALSE);
@ -881,6 +887,28 @@ scan_start (Preview * p)
gsg_sync (p->dialog);
status = sane_start (dev);
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
gettimeofday (&start, NULL);
#endif
while (status == SANE_STATUS_WARMING_UP)
{
#ifdef HAVE_SYS_TIME_H
gettimeofday (&current, NULL);
/* we assume that warming up won't exceed 60 seconds */
progress_update (progress,
(current.tv_sec - start.tv_sec) / (gfloat) 60);
#endif
while (gtk_events_pending ())
gtk_main_iteration ();
status = sane_start (dev);
}
progress_free (progress);
}
if (status != SANE_STATUS_GOOD)
{
snprintf (buf, sizeof (buf),

Wyświetl plik

@ -23,9 +23,6 @@
#include <gtk/gtk.h>
#include "progress.h"
static const int progress_x = 5;
static const int progress_y = 5;
void
progress_cancel (GtkWidget * widget, gpointer data)
{
@ -36,18 +33,26 @@ progress_cancel (GtkWidget * widget, gpointer data)
Progress_t *
progress_new (char *title, char *text,
progress_new (char *title, char *text, GtkWindow *parent,
GtkSignalFunc callback, gpointer callback_data)
{
GtkWidget *button, *label;
GtkBox *vbox, *hbox;
Progress_t *p;
#if GTK_MAJOR_VERSION < 2
gint x,y;
#endif
p = (Progress_t *) malloc (sizeof (Progress_t));
p->callback = callback;
p->shell = gtk_dialog_new ();
gtk_widget_set_uposition (p->shell, progress_x, progress_y);
#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);
@ -62,14 +67,19 @@ progress_new (char *title, char *text,
gtk_widget_set_usize (p->pbar, 200, 20);
gtk_box_pack_start (vbox, p->pbar, TRUE, TRUE, 0);
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);
/* 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);
}
gtk_widget_show (label);
gtk_widget_show (p->pbar);
gtk_widget_show (button);
if (callback != NULL)
gtk_widget_show (button);
gtk_widget_show (GTK_WIDGET (p->shell));
gtk_progress_bar_update (GTK_PROGRESS_BAR (p->pbar), 0);
return p;

Wyświetl plik

@ -19,16 +19,17 @@
#define progress_h
typedef struct Progress_t
{
GtkSignalFunc callback;
gpointer callback_data;
GtkWidget *shell;
GtkWidget *pbar;
}
{
GtkSignalFunc callback;
gpointer callback_data;
GtkWidget *shell;
GtkWidget *pbar;
}
Progress_t;
extern Progress_t *progress_new (char *, char *, GtkSignalFunc, void *);
extern void progress_free (Progress_t *);
extern void progress_update (Progress_t *, gfloat);
extern Progress_t * progress_new (char *title, char *text, GtkWindow *parent,
GtkSignalFunc callback, gpointer callback_data);
extern void progress_free (Progress_t *p);
extern void progress_update (Progress_t *p, gfloat newval);
#endif /* progress_h */

Wyświetl plik

@ -971,7 +971,10 @@ scan_it_raw (const char *fname, SANE_Bool raw, const char *script,
do
{
status = sane_start (device);
do
{
status = sane_start (device);
} while (status == SANE_STATUS_WARMING_UP);
if (status != SANE_STATUS_GOOD)
{
if (status != SANE_STATUS_NO_DOCS)

Wyświetl plik

@ -404,9 +404,15 @@ xcam_add_text (SANE_Byte * image, int width, int height, char *txt)
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);
DBG (DBG_error, "xcam_add_text: unsupported image format %d\n",
win.params.format);
status = SANE_STATUS_INVAL;
}
DBG (DBG_debug, "xcam_add_text: exit vw=%d, vh=%d\n", width, height);
status = (SANE_STATUS_GOOD);
status = SANE_STATUS_GOOD;
return status;
}
@ -1215,7 +1221,11 @@ next_frame (void)
DBG (DBG_debug, "xcam: next frame, start gsg_sync\n");
gsg_sync (dialog);
status = sane_start (gsg_dialog_get_device (dialog));
do
{
status = sane_start (gsg_dialog_get_device (dialog));
}
while (status == SANE_STATUS_WARMING_UP);
if (status != SANE_STATUS_GOOD)
{
sprintf (buf, "Failed to start webcam: %s.", sane_strstatus (status));
@ -1437,6 +1447,8 @@ save_frame (void)
case SANE_FRAME_GRAY:
frame_type = "gray";
break;
default:
frame_type = "RGB";
}
if (!win.header_size)
@ -1472,6 +1484,11 @@ save_frame (void)
win.params.pixels_per_line, win.params.lines,
(win.params.depth <= 8) ? 255 : 65535);
break;
default:
snprintf (buf, sizeof (buf),
"Unsupported image format %d", win.params.format);
DBG (DBG_error, "xcam_add_text: unsupported image format %d\n",
win.params.format);
}
win.header_size = ftell (win.out);
fwrite (win.buf, 1, win.num_bytes, win.out);

Wyświetl plik

@ -49,9 +49,9 @@
#define BACKEND_NAME xscanimage
#include "../include/sane/sanei_debug.h"
#include <progress.h>
#include <preferences.h>
#include <preview.h>
#include "progress.h"
#include "preferences.h"
#include "preview.h"
#ifndef PATH_MAX
# define PATH_MAX 1024
@ -1026,11 +1026,11 @@ scan_done (void)
}
static void
progress_cancel (void)
cancel_action (void)
{
DBG (DBG_debug, "progress_cancel\n");
DBG (DBG_debug, "cancel_action\n");
sane_cancel (gsg_dialog_get_device (dialog));
DBG (DBG_debug, "progress_cancel: done\n");
DBG (DBG_debug, "cancel_action: done\n");
}
static void
@ -1043,6 +1043,10 @@ 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;
@ -1089,7 +1093,32 @@ scan_start (void)
while (gtk_events_pending ())
gtk_main_iteration ();
status = sane_start (dev);
if (status == SANE_STATUS_WARMING_UP)
{
if (scan_win.progress)
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);
#ifdef HAVE_SYS_TIME_H
gettimeofday(&start,NULL);
#endif
while (status == SANE_STATUS_WARMING_UP)
{
#ifdef HAVE_SYS_TIME_H
gettimeofday(&current,NULL);
/* we assume that warming up won't exceed 60 seconds */
progress_update (scan_win.progress, (gfloat)(current.tv_sec - start.tv_sec) / (gfloat) 60);
#endif
while (gtk_events_pending ())
gtk_main_iteration ();
status = sane_start (dev);
}
progress_free (scan_win.progress);
scan_win.progress = 0;
}
if (status != SANE_STATUS_GOOD)
{
gsg_set_sensitivity (dialog, TRUE);
@ -1259,8 +1288,8 @@ scan_start (void)
#endif /* HAVE_LIBGIMP_GIMP_H */
if (scan_win.progress)
progress_free (scan_win.progress);
scan_win.progress = progress_new ("Scanning", buf,
(GtkSignalFunc) progress_cancel, 0);
scan_win.progress = progress_new ("Scanning", buf, GTK_WINDOW(scan_win.shell),
(GtkSignalFunc) cancel_action, 0);
scan_win.input_tag = -1;
if (sane_set_io_mode (dev, SANE_TRUE) == SANE_STATUS_GOOD