[sane-devel] [BUG] xcanimage: some buttons have to be disabled while scanning

Aurelien Jarno ml at aurel32.net
Thu Oct 17 15:55:56 BST 2002


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi all !

I have found some bugs in xscanimage concerning buttons that aren't
disabled:

- - While scanning, it is possible to press the "Acquire Preview" button, or 
even the "Scan" button again. When doing a preview, it is also possible to
start a scan, or another preview. This causes a hangup of xscanimage. The
only way is to kill it. Then it is impossible to use the scanner again, until a 
reboot.

- - When acquiring a preview, if you press "Preview Window" in the main 
window, it causes a segfault of xscanimage.

- - While scanning some options are disabled (for example gamma), but if you
change something in the "Preferences" menu, they are enabled again.

The following patch correct some of this bugs, that is to say it disable 
"Scan" and "Acquire Preview" while scanning, and "Acquire Preview" while
acquiring a preview. However, it doesn't disable "Scan" and "Preview Window"
while acquiring a preview. I think implementing that needs bigger changes in
the source code.
Please feel free to include it or not.

Aurelien

Index: src/preview.c
===================================================================
RCS file: /cvsroot/external/sane/sane-frontends/src/preview.c,v
retrieving revision 1.11
diff -u -1 -b -p -u -r1.11 preview.c
- --- preview.c	2002/10/15 15:06:47	1.11
+++ preview.c	2002/10/17 14:36:35
@@ -812,2 +812,3 @@ scan_done (Preview *p)
   gtk_widget_set_sensitive (p->cancel, FALSE);
+  gtk_widget_set_sensitive (p->preview, TRUE);
   gsg_set_sensitivity (p->dialog, TRUE);
@@ -824,2 +825,3 @@ scan_start (Preview *p)
   gtk_widget_set_sensitive (p->cancel, TRUE);
+  gtk_widget_set_sensitive (p->preview, FALSE);
   gsg_set_sensitivity (p->dialog, FALSE);
@@ -1126,3 +1128,3 @@ preview_new (GSGDialog *dialog)
   static int first_time = 1;
- -  GtkWidget *table, *frame, *button;
+  GtkWidget *table, *frame;
   GtkSignalFunc signal_func;
@@ -1226,8 +1228,8 @@ preview_new (GSGDialog *dialog)
 
- -  /* Start button */
- -  button = gtk_button_new_with_label ("Acquire Preview");
- -  gtk_signal_connect (GTK_OBJECT (button), "clicked",
+  /* 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), button, TRUE, TRUE, 0);
- -  gtk_widget_show (button);
+  gtk_box_pack_start (GTK_BOX (hbox), p->preview, TRUE, TRUE, 0);
+  gtk_widget_show (p->preview);

Index: src/preview.h
===================================================================
RCS file: /cvsroot/external/sane/sane-frontends/src/preview.h,v
retrieving revision 1.2
diff -u -1 -b -p -u -r1.2 preview.h
- --- preview.h	2001/05/28 21:39:54	1.2
+++ preview.h	2002/10/17 14:36:35
@@ -70,2 +70,3 @@ typedef struct
     GtkWidget *cancel;	/* the cancel button */
+    GtkWidget *preview;	/* the preview button */
   }
Index: src/xscanimage.c
===================================================================
RCS file: /cvsroot/external/sane/sane-frontends/src/xscanimage.c,v
retrieving revision 1.16
diff -u -1 -b -p -u -r1.16 xscanimage.c
- --- xscanimage.c	2002/09/02 21:53:52	1.16
+++ xscanimage.c	2002/10/17 14:36:35
@@ -113,2 +113,4 @@ static struct
     GtkWidget *info_label;
+    GtkWidget *preview_button;
+    GtkWidget *scan_button;
     Preview *preview;
@@ -536,2 +538,4 @@ scan_preview (GtkWidget * widget, gpoint
 	    gtk_toggle_button_set_state (GTK_TOGGLE_BUTTON (widget), FALSE);
+	    if (scan_win.progress)
+              gtk_widget_set_sensitive (scan_win.preview->preview, FALSE);
 	}
@@ -804,2 +808,5 @@ scan_done (void)
   gsg_set_sensitivity (dialog, TRUE);
+  if (scan_win.preview)
+    gtk_widget_set_sensitive (scan_win.preview->preview, TRUE);
+  gtk_widget_set_sensitive (scan_win.scan_button, TRUE);

@@ -863,2 +870,5 @@ scan_start (void)
   gsg_set_sensitivity (dialog, FALSE);
+  if (scan_win.preview)
+    gtk_widget_set_sensitive (scan_win.preview->preview, FALSE);
+  gtk_widget_set_sensitive (scan_win.scan_button, FALSE);

@@ -1550,15 +1560,15 @@ device_dialog (void)
   /* The Scan button */
- -  button = gtk_button_new_with_label ("Scan");
- -  gtk_signal_connect (GTK_OBJECT (button), "clicked",
+  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), button, TRUE, TRUE, 0);
- -  gtk_widget_show (button);
+  gtk_box_pack_start (GTK_BOX (hbox), scan_win.scan_button, TRUE, TRUE, 0);
+  gtk_widget_show (scan_win.scan_button);
 
   /* The Preview button */
- -  button = gtk_toggle_button_new_with_label ("Preview Window");
- -  gtk_signal_connect (GTK_OBJECT (button), "clicked",
+  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), button, TRUE, TRUE, 0);
- -  gtk_widget_show (button);
+  gtk_box_pack_start (GTK_BOX (hbox), scan_win.preview_button, TRUE, TRUE, 0);
+  gtk_widget_show (scan_win.preview_button);

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.6 (GNU/Linux)
Comment: For info see http://www.gnupg.org

iD8DBQE9rs+Cw3ao2vG823MRAqrnAJ42W8RSBKme79s8WB+StUUMSRgzGgCeLD1O
bFKC1bCPer5RPeMQL9hMHO8=
=lJUN
-----END PGP SIGNATURE-----



More information about the sane-devel mailing list