Index: apps/plugins/jpeg.c =================================================================== --- apps/plugins/jpeg.c (revision 14658) +++ apps/plugins/jpeg.c (working copy) @@ -1893,7 +1893,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; @@ -2325,9 +2325,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) @@ -2449,6 +2452,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 @@ -2465,6 +2469,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 }, @@ -2507,6 +2513,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); @@ -2572,9 +2581,10 @@ return 0; } /* interactively scroll around the image */ -int scroll_bmp(struct t_disp* pdisp) +int scroll_bmp(struct t_disp* pdisp, char *filename) { int lastbutton = 0; + int menu_return = 0; while (true) { @@ -2767,9 +2777,39 @@ #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_puts(0,8," >> to Delete"); + rb->lcd_puts_scroll(0,9,(char*)filename); + rb->lcd_puts(0,11," Any other Key to Abort"); + rb->lcd_update(); + button = rb->button_get(true); + switch(button) + { + case JPEG_RIGHT: + 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: + return change_filename(DIR_PREV); + break; + } + break; + } #ifdef USEGSLIB gray_show(true); /* switch on grayscale overlay */ #else @@ -3010,7 +3050,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)); @@ -3204,7 +3249,7 @@ */ while (1) { - status = scroll_bmp(p_disp); + status = scroll_bmp(p_disp, filename); if (status == ZOOM_IN) { if (ds > ds_min) @@ -3340,7 +3385,7 @@ #ifdef USEGSLIB gray_release(); /* deinitialize */ #endif - + rb->set_current_file(np_file); return condition; }