diff -u --new-file --recursive --exclude-from=/tmp/cvs.exclude.gphoto gphoto.orig/photopc/eph_cmd.c gphoto/photopc/eph_cmd.c --- gphoto.orig/photopc/eph_cmd.c Wed Jul 5 13:07:49 2000 +++ gphoto/photopc/eph_cmd.c Mon Aug 7 17:34:16 2000 @@ -258,7 +259,7 @@ putpoint=buf; maywrite=sizeof(buf); pktsize=0; - (iob->runcb)(written); + (iob->runcb)(written,0); } if (length <= maywrite) { maywrite=length; @@ -295,6 +296,7 @@ char *ptr; char *tmpbuf=NULL; size_t tmpbufsize=0; + off_t total = *bufsize; if ((buffer == NULL) && (iob->storecb == NULL)) { eph_error(iob,ERR_BADARGS, @@ -361,7 +363,7 @@ if (pkt.seq == expect) { index+=readsize; expect++; - (iob->runcb)(index); + (iob->runcb)(index,total); if (buffer == NULL) { if (iob->debug) printf("storing %lu at %08lx\n", diff -u --new-file --recursive --exclude-from=/tmp/cvs.exclude.gphoto gphoto.orig/photopc/eph_io.c gphoto/photopc/eph_io.c --- gphoto.orig/photopc/eph_io.c Sun Jul 9 23:40:14 2000 +++ gphoto/photopc/eph_io.c Mon Aug 14 17:10:38 2000 @@ -364,14 +364,14 @@ int i,rc; if (camera_type == GPHOTO_CAMERA_USB) { - uint16 usbbuf_size=256; + uint16 usbbuf_size=2054; uint16 usb_read; - unsigned char usbbuf[256]; + unsigned char usbbuf[2054]; unsigned char *buffer_ptr; + unsigned char *buffer_ext; uint16 buffer_remaining; uint16 buffer_read; - buffer_ptr=buffer; buffer_read=0; usb_read=olympus_usb_read (gpdev,usbbuf,usbbuf_size); if (usb_read<4) { @@ -396,16 +396,32 @@ (unsigned long)length,(unsigned long)*bufsize); return -1; } + length+=2; /* frame length + 2bytes crc */ + buffer_ext = (iob->realloccb)(NULL,(size_t)length); + buffer_ptr = buffer_ext; + if (buffer_ext==0) { + eph_error(iob,ERR_DATA_TOO_LONG, + "could not malloc() %lu bytes",(unsigned long)length); + return -1; + } buffer_read=MIN (length,usb_read-4); memcpy (buffer_ptr,usbbuf+4,buffer_read); + for (i=0; i= 2. + */ + crc2=(buffer_ext[length-1]<<8)|buffer_ext[length-2]; + crc1-=buffer_ext[length-1]; + crc1-=buffer_ext[length-2]; + if (iob->debug) { + printf ("crc1=0x%04x\n",crc1); + printf ("crc2=0x%04x\n\n",crc2); + } + if (crc1 != crc2) { + if (iob->debug) + printf("crc %04x != %04x\n",crc1,crc2); + eph_error(iob,ERR_BADCRC, + "crc received=0x%04x counted=0x%04x", + crc2,crc1); + return -1; + } + /* + * copy the data to the buffer passed as argument, and + * exclude the final checksum + */ + memcpy (buffer,buffer_ext,length-2); + free (buffer_ext); + (*bufsize)=length-2; return 0; - } - - i=eph_readt(iob,buf,1,timeout_usec,&rc); - if (iob->debug > 1) - printf ("pktstart: i=%d rc=%d char=0x%02x\n",i,rc,*buf); - if (i < 0) { - eph_error(iob,ERRNO,"pkt start read error %s",strerror(ERRNO)); - return -1; - } else if ((i == 0) && (rc == 0)) { - eph_error(iob,ERR_TIMEOUT,"pkt start read timeout (%ld)", - timeout_usec); - return -2; - } else if (i != 1) { - eph_error(iob,ERR_BADREAD,"pkt start read %d, expected 1",i); - return -1; - } - pkthdr->typ=buf[0]; - if ((*buf != PKT_DATA) && (*buf != PKT_LAST)) { - if ((*buf != NAK) && (*buf != DC1)) - eph_error(iob,ERR_BADDATA,"pkt start got 0x%02x",*buf); - return *buf; - } - got=0; - while ((i=eph_readt(iob,buf+1+got,3-got,DATATIMEOUT,&rc)) > 0) { - got+=i; - } - if (got != 3) { - if (i < 0) { - eph_error(iob,ERRNO,"pkt hdr read error %s (got %d)", - strerror(ERRNO),got); - return -1; - } else if ((i == 0) && (rc == 0)) { - eph_error(iob,ERR_TIMEOUT,"pkt hdr read timeout (%ld)", - DATATIMEOUT); - return -2; - } else { - eph_error(iob,ERR_BADREAD,"pkt hdr read return %d rc %d", - i,rc); - return -1; - } - } - if (iob->debug > 1) printf("header: %02x %02x %02x %02x\n", - buf[0],buf[1],buf[2],buf[3]); - pkthdr->seq=buf[1]; - length=(buf[3]<<8)|buf[2]; - if (length > *bufsize) { - eph_error(iob,ERR_DATA_TOO_LONG, - "length in pkt header %lu bigger than buffer size %lu", - (unsigned long)length,(unsigned long)*bufsize); - return -1; - } - - got=0; - while ((i=eph_readt(iob,buffer+got,length-got,iob->timeout,&rc)) > 0) { - got+=i; - } - if (got != length) { + } else { + i=eph_readt(iob,buf,1,timeout_usec,&rc); + if (iob->debug > 1) + printf ("pktstart: i=%d rc=%d char=0x%02x\n",i,rc,*buf); if (i < 0) { - eph_error(iob,ERRNO,"pkt data read error %s",strerror(ERRNO)); + eph_error(iob,ERRNO, + "pkt start read error %s",strerror(ERRNO)); return -1; } else if ((i == 0) && (rc == 0)) { - eph_error(iob,ERR_TIMEOUT,"pkt data read timeout (%ld)", - iob->timeout); + eph_error(iob,ERR_TIMEOUT, + "pkt start read timeout (%ld)",timeout_usec); return -2; - } else { + } else if (i != 1) { eph_error(iob,ERR_BADREAD, - "pkt read return %d, rc %d",i,rc); + "pkt start read %d, expected 1",i); return -1; } - } - - for (i=0;i 0) { - got+=i; - } - if (iob->debug > 1) - printf ("crc: %02x %02x i=%d rc=%d\n",buf[0],buf[1],i,rc); - if (got != 2) { - if (i < 0) { - eph_error(iob,ERRNO,"pkt crc read error %s",strerror(ERRNO)); - return -1; - } else if ((i == 0) && (rc == 0)) { - eph_error(iob,ERR_TIMEOUT,"pkt crc read timeout (%ld)", - DATATIMEOUT); - return -2; - } else { - eph_error(iob,ERR_BADREAD,"pkt crc read return %d rc %d", - i,rc); - return -1; - } - } - - crc2=(buf[1]<<8)|buf[0]; - if (crc1 != crc2) { - if (iob->debug) printf("crc %04x != %04x\n",crc1,crc2); - eph_error(iob,ERR_BADCRC, - "crc received=0x%04x counted=0x%04x",crc2,crc1); - return -1; - } - if (iob->debug > 1) { - int j; - - printf("< %d,%d (%d)",pkthdr->typ,pkthdr->seq,length); - if (iob->debug > 2) for (j=0;jtyp,pkthdr->seq,length); - if (iob->debug > 2) for (j=0;j= ' ' && buffer[j] < 127) + pkthdr->typ=buf[0]; + if ((*buf != PKT_DATA) && (*buf != PKT_LAST)) { + if ((*buf != NAK) && (*buf != DC1)) + eph_error(iob,ERR_BADDATA, + "pkt start got 0x%02x",*buf); + return *buf; + } + got=0; + while ((i=eph_readt(iob,buf+1+got,3-got,DATATIMEOUT,&rc)) > 0) + got+=i; + if (got != 3) { + if (i < 0) { + eph_error(iob,ERRNO, + "pkt hdr read error %s (got %d)", + strerror(ERRNO),got); + return -1; + } else if ((i == 0) && (rc == 0)) { + eph_error(iob,ERR_TIMEOUT, + "pkt hdr read timeout (%ld)", + DATATIMEOUT); + return -2; + } else { + eph_error(iob,ERR_BADREAD, + "pkt hdr read return %d rc %d", + i,rc); + return -1; + } + } + if (iob->debug > 1) + printf("header: %02x %02x %02x %02x\n", + buf[0],buf[1],buf[2],buf[3]); + pkthdr->seq=buf[1]; + length=(buf[3]<<8)|buf[2]; + if (length > *bufsize) { + eph_error(iob,ERR_DATA_TOO_LONG, + "length in pkt header %lu " + "bigger than buffer size %lu", + (unsigned long)length, + (unsigned long)*bufsize); + return -1; + } + + got=0; + while ((i=eph_readt(iob,buffer+got, + length-got,iob->timeout,&rc)) > 0) + got+=i; + if (got != length) { + if (i < 0) { + eph_error(iob,ERRNO, + "pkt data read error %s", + strerror(ERRNO)); + return -1; + } else if ((i == 0) && (rc == 0)) { + eph_error(iob,ERR_TIMEOUT, + "pkt data read timeout (%ld)", + iob->timeout); + return -2; + } else { + eph_error(iob,ERR_BADREAD, + "pkt read return %d, rc %d",i,rc); + return -1; + } + } + + for (i=0;i 0) + got+=i; + if (iob->debug > 1) + printf ("crc: %02x %02x i=%d rc=%d\n", + buf[0],buf[1],i,rc); + if (got != 2) { + if (i < 0) { + eph_error(iob,ERRNO, + "pkt crc read error %s", + strerror(ERRNO)); + return -1; + } else if ((i == 0) && (rc == 0)) { + eph_error(iob,ERR_TIMEOUT, + "pkt crc read timeout (%ld)", + DATATIMEOUT); + return -2; + } else { + eph_error(iob,ERR_BADREAD, + "pkt crc read return %d rc %d", + i,rc); + return -1; + } + } + + crc2=(buf[1]<<8)|buf[0]; + if (crc1 != crc2) { + if (iob->debug) + printf("crc %04x != %04x\n",crc1,crc2); + eph_error(iob,ERR_BADCRC, + "crc received=0x%04x counted=0x%04x", + crc2,crc1); + return -1; + } + if (iob->debug > 1) { + int j; + + printf("< %d,%d (%d)",pkthdr->typ,pkthdr->seq,length); + if (iob->debug > 2) + for (j=0;jtyp,pkthdr->seq,length); + if (iob->debug > 2) + for (j=0;j= ' ' + && buffer[j] < 127) ? buffer[j] : '.'); - } else printf(" ..."); - printf("\n"); + } else + printf(" ..."); + printf("\n"); + } + (*bufsize)=length; + return 0; } - (*bufsize)=length; - return 0; } int diff -u --new-file --recursive --exclude-from=/tmp/cvs.exclude.gphoto gphoto.orig/photopc/eph_io.h gphoto/photopc/eph_io.h --- gphoto.orig/photopc/eph_io.h Wed Jul 5 13:07:49 2000 +++ gphoto/photopc/eph_io.h Sat Aug 5 11:49:46 2000 @@ -95,7 +95,7 @@ typedef struct _eph_iob { void (*errorcb)(int errcode,char *errstr); void *(*realloccb)(void *old,size_t length); - void (*runcb)(off_t count); + void (*runcb)(off_t count, off_t total); int (*storecb)(char *data,size_t size); int debug; #if defined(UNIX) @@ -119,7 +119,7 @@ eph_iob *eph_new(void (*errorcb)(int errcode,char *errstr), void *(*realloccb)(void *old,size_t length), - void (*runcb)(off_t count), + void (*runcb)(off_t count, off_t total), int (*storecb)(char *data,size_t size), int debug); int eph_open(eph_iob *iob,char *device_name,long speed, diff -u --new-file --recursive --exclude-from=/tmp/cvs.exclude.gphoto gphoto.orig/photopc/eph_iob.c gphoto/photopc/eph_iob.c --- gphoto.orig/photopc/eph_iob.c Wed Jul 5 13:07:49 2000 +++ gphoto/photopc/eph_iob.c Sat Aug 5 11:49:46 2000 @@ -78,7 +78,7 @@ } static void -defruncb(off_t count) +defruncb(off_t count, off_t total) { return; } @@ -86,7 +86,7 @@ eph_iob * eph_new(void (*errorcb)(int errcode,char *errstr), void *(*realloccb)(void *old,size_t length), - void (*runcb)(off_t count), + void (*runcb)(off_t count, off_t total), int (*storecb)(char *data,size_t size), int debug) { diff -u --new-file --recursive --exclude-from=/tmp/cvs.exclude.gphoto gphoto.orig/photopc/olympus.c gphoto/photopc/olympus.c --- gphoto.orig/photopc/olympus.c Wed Jul 5 13:07:49 2000 +++ gphoto/photopc/olympus.c Sat Aug 5 11:49:46 2000 @@ -19,9 +19,21 @@ eph_iob *iob; /* Olympus/photoPC io-buffer */ struct olympus_device *gpdev; -int oly_initialize () { +extern float progress_min; +extern float progress_max; + +static void +oly_update_progress (off_t count, off_t total) +{ + float percent = (float)count/(float)total; + if (total) + update_progress (progress_min+percent*(progress_max-progress_min)); +} - iob = eph_new(NULL, NULL, NULL, NULL, 0); +int +oly_initialize () { + + iob = eph_new(NULL, NULL, oly_update_progress, NULL, 0); return 1; } @@ -255,7 +280,6 @@ strcpy(im->image_type, "jpg"); oly_close_camera(); - update_progress(0); return (im); } diff -u --new-file --recursive --exclude-from=/tmp/cvs.exclude.gphoto gphoto.orig/src/callbacks.c gphoto/src/callbacks.c --- gphoto.orig/src/callbacks.c Thu Jul 6 20:08:15 2000 +++ gphoto/src/callbacks.c Fri Aug 4 12:36:49 2000 @@ -53,6 +54,10 @@ extern char *filesel_cwd; +extern float progress_min; +extern float progress_max; +extern int cam_busy; + /* Search the image_info tags for "name", return its value (string) */ char *find_tag(struct Image *im, char *name) { @@ -90,6 +96,7 @@ void set_camera(char *model) { int i; + int ret; for (i = 0; cameras[i].name; i++) { if (strcmp(model, cameras[i].name)) @@ -103,14 +110,29 @@ Camera = &cameras[i]; - if (Camera->ops->initialize() != 0) + if (cam_busy) { + error_dialog("Camera is already busy"); return; + } + cam_busy=1; + ret=Camera->ops->initialize(); + cam_busy=0; + if (ret) return; } } void configure_call(void) { - if (Camera->ops->configure() == 0) + int ret; + + if (cam_busy) { + error_dialog("Camera is already busy"); + return; + } + cam_busy=1; + ret=Camera->ops->configure(); + cam_busy=0; + if (ret == 0) error_dialog("No configuration options."); } @@ -126,7 +148,13 @@ update_status("Taking picture..."); + if (cam_busy) { + error_dialog("Camera is already busy"); + return; + } + cam_busy=1; picNum = Camera->ops->take_picture(); + cam_busy=0; if (!picNum) { error_dialog("Could not take a picture."); @@ -144,6 +172,11 @@ gint current, no_pics, i; char error[32]; + if (cam_busy) { + error_dialog("Camera is already busy"); + return; + } + cam_busy=1; no_pics = Camera->ops->number_of_pictures(); i = no_pics; @@ -166,6 +199,7 @@ update_status("Deleted all images."); update_progress(0); gtk_widget_destroy(dialog); + cam_busy=0; } void del_pics(GtkWidget *dialog, GtkObject *button) @@ -174,6 +208,11 @@ char error[32]; struct ImageMembers *node = &Thumbnails; + if (cam_busy) { + error_dialog("Camera is already busy"); + return; + } + cam_busy=1; gtk_widget_hide(dialog); update_status("Deleting selected pictures..."); @@ -196,6 +235,7 @@ } gtk_widget_destroy(dialog); update_status("Done."); + cam_busy=0; } void del_dialog(int type) @@ -282,7 +322,14 @@ } } - if ((im = Camera->ops->get_picture(picNum, thumbnail)) == 0) { + if (cam_busy) { + error_dialog("Camera is already busy"); + return; + } + cam_busy=1; + im = Camera->ops->get_picture(picNum, thumbnail); + cam_busy=0; + if (im == 0) { sprintf(error, "Could not save #%i", picNum); error_dialog(error); return; @@ -410,7 +458,14 @@ node->next = NULL; if (fromCamera) { - if ((im = Camera->ops->get_picture(picNum, thumbnail))==0) { + if (cam_busy) { + error_dialog("Camera is already busy"); + return; + } + cam_busy=1; + im = Camera->ops->get_picture(picNum, thumbnail); + cam_busy=0; + if (im == 0) { sprintf(error, "Could not retrieve #%i", picNum); error_dialog(error); return; @@ -1097,7 +1167,14 @@ sprintf(status, "Getting thumbnail %i...", i); update_status(status); - if ((im = Camera->ops->get_picture(i, 1))==0) { + if (cam_busy) { + error_dialog("Camera is already busy"); + return; + } + cam_busy=1; + im = Camera->ops->get_picture(i, 1); + cam_busy=0; + if (im==0) { sprintf(error, "Could not retrieve #%i", i); error_dialog(error); return; @@ -1123,6 +1200,11 @@ node->imlibimage = gdk_imlib_load_image_mem(im->image, im->image_size); free_image (im); + if (node->imlibimage==0) { + sprintf(error, "Could not load image #%i to memory", i); + error_dialog(error); + return; + } w = node->imlibimage->rgb_width; h = node->imlibimage->rgb_height; @@ -1196,8 +1278,14 @@ gtk_widget_show(index_frame); gtk_container_add(GTK_CONTAINER(index_vp), index_frame); + if (cam_busy) { + error_dialog("Camera is already busy"); + return; + } + cam_busy=1; num_pictures_taken = Camera->ops->number_of_pictures(); -fprintf(stderr, "num_pictures_taken is %d\n", num_pictures_taken); + cam_busy=0; + fprintf(stderr, "num_pictures_taken is %d\n", num_pictures_taken); if (num_pictures_taken == -1) { error_dialog("Could not get the number of pictures"); return; @@ -1259,6 +1344,8 @@ node->image=NULL; node->imlibimage=NULL; + progress_min=(float)i/(float)num_pictures_taken; + progress_max=(float)(i+1)/(float)num_pictures_taken; if (getthumbs) insert_thumbnail(node); @@ -1267,7 +1354,7 @@ node->button, i%6,i%6+1,i/6,i/6+1, GTK_FILL,GTK_FILL,5,5); - update_progress((float)i/(float)(num_pictures_taken - 1)); + update_progress(progress_max); } deactivate_button(stop_button); update_progress(0); @@ -1322,23 +1414,25 @@ node = node->next; i++; if (GTK_TOGGLE_BUTTON(node->button)->active) { + progress_min=(float)y/(float)x; + progress_max=(float)(y+1)/(float)x; y++; if ((strcmp("i", pictype) == 0) || (strcmp("ti", pictype) == 0)) { sprintf(status, "Getting Image #%03i...", i); update_status(status); appendpic(i, 0, TRUE, NULL); } if ((strcmp("t", pictype) == 0) || (strcmp("ti", pictype) == 0)) { appendpic(i, 1, TRUE, NULL); sprintf(status, "Getting Thumbnail #%03i...", i); update_status(status); } gtk_toggle_button_set_state( GTK_TOGGLE_BUTTON(node->button), FALSE); - update_progress((float)y/(float)x); + update_progress(progress_max); } } @@ -1826,7 +1920,14 @@ void summary_dialog(void) { - message_window("Camera Summary", Camera->ops->summary(), GTK_JUSTIFY_FILL); + if (cam_busy) { + error_dialog("Camera is already busy"); + return; + } + cam_busy=1; + message_window("Camera Summary", + Camera->ops->summary(), GTK_JUSTIFY_FILL); + cam_busy=0; } /* Decreases image size by factor n % */ diff -u --new-file --recursive --exclude-from=/tmp/cvs.exclude.gphoto gphoto.orig/src/gallery.c gphoto/src/gallery.c --- gphoto.orig/src/gallery.c Thu Jul 6 20:08:15 2000 +++ gphoto/src/gallery.c Sat Aug 5 11:49:46 2000 @@ -202,6 +202,7 @@ #include #include #include +#include extern GtkWidget *index_window; /* extern GtkWidget *browse_button; */ @@ -210,6 +211,9 @@ extern struct ImageMembers Images; extern struct Model *Camera; extern char *filesel_cwd; +extern float progress_min, progress_max; + +extern int cam_busy; /* initialize some tags */ char gallery_name[256]; @@ -323,7 +327,7 @@ char * cmd1, *cmd2, *cmd3, *cmd4, *cmd5, *cmd6, *cmd7, *cmd8, *cmd9, *cmd10, *cmd11; pid_t pid; - const char *argv [5]; + const char * argv [5]; cmd1 = gallery_make_sed_command ("s", "#GALLERY_NAME#", gallery_name); cmd2 = gallery_make_sed_command ("s", "#GALLERY_INDEX#", gallery_index); @@ -383,7 +387,7 @@ perror ("close"); } - execvp (argv [0], argv); + execvp (argv [0], (char * const *)argv); perror ("exec"); exit (1); } @@ -675,7 +712,18 @@ /* Get the current thumbnail */ sprintf(cp, "Getting Thumbnail #%i...", j+1); update_status(cp); - if ((im = Camera->ops->get_picture(j+1, 1))==0) { + if (cam_busy) { + error_dialog("Camera is already busy"); + if (GTK_IS_OBJECT(dialog)) + gtk_widget_destroy(dialog); + return; + } + progress_min=(float)(2*i)/(float)(num_selected*2); + progress_max=(float)(2*i+1)/(float)(num_selected*2); + cam_busy=1; + im = Camera->ops->get_picture(j+1, 1); + cam_busy=0; + if (im==0) { sprintf(error, "Could not retrieve #%i", j+1); error_dialog(error); @@ -699,7 +747,18 @@ sprintf(cp, "Getting Image #%i...", j+1); update_status(cp); - if ((im = Camera->ops->get_picture(j+1, 0))==0) { + if (cam_busy) { + error_dialog("Camera is already busy"); + if (GTK_IS_OBJECT(dialog)) + gtk_widget_destroy(dialog); + return; + } + progress_min=(float)(2*i+1)/(float)(num_selected*2); + progress_max=(float)(2*i+2)/(float)(num_selected*2); + cam_busy=1; + im = Camera->ops->get_picture(j+1, 0); + cam_busy=0; + if (im==0) { sprintf(error, "Could not retrieve #%i", j+1); error_dialog(error); sprintf(picture, "Not Available"); diff -u --new-file --recursive --exclude-from=/tmp/cvs.exclude.gphoto gphoto.orig/src/live.c gphoto/src/live.c --- gphoto.orig/src/live.c Thu Jul 6 20:08:15 2000 +++ gphoto/src/live.c Sat Aug 5 11:49:46 2000 @@ -10,6 +10,7 @@ */ extern struct Model *Camera; +extern int cam_busy; int live_video_mode = 0; @@ -22,22 +23,32 @@ struct Image *im; GList *child = gtk_container_children( - GTK_CONTAINER(GTK_DIALOG(dialog)->vbox)); + GTK_CONTAINER(GTK_DIALOG(dialog)->vbox)); GtkWidget *gpixmap = GTK_WIDGET(child->data); + if (cam_busy) { + error_dialog("Camera is already busy"); + return; + } update_status("Getting live image..."); + cam_busy=1; if ((im = Camera->ops->get_preview()) == 0) { error_dialog("Could not get preview"); return; } - imlibimage = gdk_imlib_load_image_mem(im->image, im->image_size); - free_image(im); - w = imlibimage->rgb_width; - h = imlibimage->rgb_height; - gdk_imlib_render(imlibimage, w, h); - pixmap = gdk_imlib_move_image(imlibimage); - gtk_pixmap_set(GTK_PIXMAP(gpixmap), pixmap, NULL); - update_status("Done."); + cam_busy=0; + if (im) { + imlibimage = gdk_imlib_load_image_mem(im->image, im->image_size); + free_image(im); + if (imlibimage) { + w = imlibimage->rgb_width; + h = imlibimage->rgb_height; + gdk_imlib_render(imlibimage, w, h); + pixmap = gdk_imlib_move_image(imlibimage); + gtk_pixmap_set(GTK_PIXMAP(gpixmap), pixmap, NULL); + update_status("Done."); + } + } } void live_video (GtkWidget *button, GtkWidget *dialog) { @@ -50,10 +61,16 @@ while (live_video_mode) { while (gtk_events_pending()) gtk_main_iteration(); - live_snapshot(dialog); + if (live_video_mode) + live_snapshot(dialog); } } +void live_close (GtkWidget *dialog) { + live_video_mode = 0; + gtk_widget_destroy (dialog); +} + void live_main () { int w, h; @@ -65,6 +82,10 @@ GdkImlibImage *imlibimage; struct Image *im; + if (cam_busy) { + error_dialog("Camera is already busy"); + return; + } update_status("Getting live image..."); dialog = gtk_dialog_new(); gtk_window_set_title(GTK_WINDOW(dialog), "Live Camera!"); @@ -103,12 +124,14 @@ cbutton); gtk_signal_connect_object(GTK_OBJECT(cbutton), "clicked", - GTK_SIGNAL_FUNC(gtk_widget_destroy), + GTK_SIGNAL_FUNC(live_close), GTK_OBJECT(dialog)); + cam_busy=1; if ((im = Camera->ops->get_preview()) == 0) { error_dialog("Could not get preview"); return; } + cam_busy=0; imlibimage = gdk_imlib_load_image_mem(im->image, im->image_size); free(im->image); free(im); diff -u --new-file --recursive --exclude-from=/tmp/cvs.exclude.gphoto gphoto.orig/src/main.c gphoto/src/main.c --- gphoto.orig/src/main.c Sun Jul 9 23:40:15 2000 +++ gphoto/src/main.c Fri Aug 4 12:30:06 2000 @@ -33,6 +35,10 @@ GtkWidget *index_vp; /* Viewport for above */ GtkWidget *index_window; /* Index Scrolled Window */ GtkWidget *progress; /* Progress bar */ + float progress_min; /* min and max values for */ + float progress_max; /* Progress Bar during download */ + int cam_busy; /* TRUE/FALSE to lock operation */ + /* with the camera */ int post_process; /* TRUE/FALSE to post-process */ char post_process_script[1024]; /* Full path/filename */