Index: apps/plugins/jpeg.c =================================================================== --- apps/plugins/jpeg.c (revision 15062) +++ apps/plugins/jpeg.c (working copy) @@ -1908,7 +1908,7 @@ /* the current full file name */ static char np_file[MAX_PATH]; -int curfile = 0, direction = DIR_NONE, entries = 0; +int curfile = 0, direction = DIR_NONE, entries = 0, delcount = 0; /* list of the jpeg files */ char **file_pt; @@ -2340,9 +2340,12 @@ pname++; /* Find Selected File. */ - for(i = 0; i < entries; i++) - if(!rb->strcmp(file_pt[i], pname)) + for(i = 0; i < entries; i++){ + delcount++; + if(!rb->strcmp(file_pt[i], pname)){ curfile = i; + } + } } int change_filename(int direct) @@ -2464,6 +2467,7 @@ MIID_QUIT = 0, MIID_TOGGLE_SS_MODE, MIID_CHANGE_SS_MODE, + MIID_DELETE, #if PLUGIN_BUFFER_SIZE >= MIN_MEM MIID_SHOW_PLAYBACK_MENU, #endif @@ -2480,6 +2484,8 @@ { "Toggle Slideshow Mode", NULL }, [MIID_CHANGE_SS_MODE] = { "Change Slideshow Time", NULL }, + [MIID_DELETE]= + { "Delete Current File", NULL }, #if PLUGIN_BUFFER_SIZE >= MIN_MEM [MIID_SHOW_PLAYBACK_MENU] = { "Show Playback Menu", NULL }, @@ -2522,6 +2528,9 @@ menu_exit(m); return 1; break; + case MIID_DELETE: + return 2; + break; case MIID_TOGGLE_SS_MODE: rb->set_option("Toggle Slideshow", &slideshow_enabled, INT, slideshow , 2, NULL); @@ -2587,9 +2596,11 @@ return 0; } /* interactively scroll around the image */ -int scroll_bmp(struct t_disp* pdisp) +int scroll_bmp(struct t_disp* pdisp, char *filename) { + bool delete_y_n; int lastbutton = 0; + int menu_return = 0; while (true) { @@ -2782,9 +2793,45 @@ #ifdef USEGSLIB gray_show(false); /* switch off grayscale overlay */ #endif - if (show_menu() == 1) - return PLUGIN_OK; - + menu_return = show_menu(); + if (menu_return == 1) + { + return PLUGIN_OK; + } + if (menu_return == 2) + { + rb->lcd_clear_display(); + rb->lcd_puts(0,1,"Delete?"); + rb->lcd_puts_scroll(0,2,(char*)filename); + rb->lcd_puts(0,4,">> = Yes"); + rb->lcd_puts(0,5,"Any other = No"); + rb->lcd_update(); + button = rb->button_get(true); + switch(button) + { + case JPEG_RIGHT: + rb->lcd_clear_display(); + rb->lcd_puts(0,1,"Deleted"); + rb->lcd_puts_scroll(0,2,(char*)filename); + rb->remove(filename); + rb->button_clear_queue(); + delcount--; + if (delcount < 1){ + rb->splash(HZ, "No More Files."); + return 1; + break; + }else{ + file_pt[curfile] = '\0'; + return change_filename(DIR_NEXT); + break; + } + default: + rb->button_clear_queue(); + return change_filename(DIR_PREV); + break; + } + break; + } #ifdef USEGSLIB gray_show(true); /* switch on grayscale overlay */ #else @@ -3025,7 +3072,12 @@ { rb->snprintf(print,sizeof(print),"err opening %s:%d",filename,fd); rb->splash(HZ, print); - return PLUGIN_ERROR; + if (entries < 0){ + rb->splash(HZ, "No Files."); + return PLUGIN_ERROR; + }else{ + return change_filename(DIR_PREV); + } } filesize = rb->filesize(fd); rb->memset(&disp, 0, sizeof(disp)); @@ -3219,7 +3271,7 @@ */ while (1) { - status = scroll_bmp(p_disp); + status = scroll_bmp(p_disp, filename); if (status == ZOOM_IN) { if (ds > ds_min) @@ -3355,8 +3407,7 @@ #ifdef USEGSLIB gray_release(); /* deinitialize */ #endif - + rb->set_current_file(np_file); return condition; } - #endif /* HAVE_LCD_BITMAP */