Index: apps/plugins/jpeg/jpeg.c =================================================================== --- apps/plugins/jpeg/jpeg.c (revision 21362) +++ apps/plugins/jpeg/jpeg.c (working copy) @@ -175,7 +175,7 @@ /* the current full file name */ static char np_file[MAX_PATH]; -static int curfile = 0, direction = DIR_NONE, entries = 0; +static int curfile = 0, direction = DIR_NONE, entries = 0, delcount = 0; /* list of the jpeg files */ static char **file_pt; @@ -232,9 +232,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) @@ -352,6 +355,7 @@ enum menu_id { MIID_RETURN = 0, + MIID_DELETE, MIID_TOGGLE_SS_MODE, MIID_CHANGE_SS_MODE, #if PLUGIN_BUFFER_SIZE >= MIN_MEM @@ -364,7 +368,7 @@ }; MENUITEM_STRINGLIST(menu, "Jpeg Menu", NULL, - "Return", "Toggle Slideshow Mode", + "Return", "Delete", "Toggle Slideshow Mode", "Change Slideshow Time", #if PLUGIN_BUFFER_SIZE >= MIN_MEM "Show Playback Menu", @@ -385,6 +389,9 @@ { case MIID_RETURN: break; + case MIID_DELETE: + return 2; + break; case MIID_TOGGLE_SS_MODE: rb->set_option("Toggle Slideshow", &slideshow_enabled, INT, slideshow , 2, NULL); @@ -589,10 +596,11 @@ } /* interactively scroll around the image */ -int scroll_bmp(struct t_disp* pdisp) +int scroll_bmp(struct t_disp* pdisp, char *filename) { int button; int lastbutton = 0; + int menu_return = 0; while (true) { @@ -681,9 +689,45 @@ #ifdef USEGSLIB grey_show(false); /* switch off greyscale 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 grey_show(true); /* switch on greyscale overlay */ #else @@ -925,7 +969,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)); @@ -1120,7 +1169,7 @@ */ while (1) { - status = scroll_bmp(p_disp); + status = scroll_bmp(p_disp, filename); if (status == ZOOM_IN) { if (ds > ds_min) @@ -1245,5 +1294,6 @@ grey_release(); /* deinitialize */ #endif + rb->set_current_file(np_file); return condition; }