From 40cc43a7b686b6225db5c55c496b80c9763d2d5d Mon Sep 17 00:00:00 2001 From: Kevin Ferrare Date: Tue, 22 Nov 2005 22:19:08 +0000 Subject: [PATCH] Commited George Styles's patch which added multi-screen support to the delete menu (gui_yesno) git-svn-id: svn://svn.rockbox.org/rockbox/trunk@8045 a1c6a512-1295-4272-9138-f99709370657 --- apps/gui/yesno.c | 2 +- apps/onplay.c | 69 ++++++++++++++++++------------------------------ 2 files changed, 26 insertions(+), 45 deletions(-) diff --git a/apps/gui/yesno.c b/apps/gui/yesno.c index 65f81aaf3e..220f1814dc 100644 --- a/apps/gui/yesno.c +++ b/apps/gui/yesno.c @@ -75,7 +75,7 @@ enum yesno_res gui_syncyesno_run(struct text_message * main_message, switch (button) { case YESNO_OK: -#ifdef TREE_RC_RUN +#ifdef YESNO_RC_OK case YESNO_RC_OK: #endif result=YESNO_YES; diff --git a/apps/onplay.c b/apps/onplay.c index df4ff15db9..8c22a58b3e 100644 --- a/apps/onplay.c +++ b/apps/onplay.c @@ -48,6 +48,8 @@ #include "bookmark.h" #include "action.h" #include "splash.h" +#include "yesno.h" + #ifdef HAVE_LCD_BITMAP #include "icons.h" #endif @@ -392,52 +394,31 @@ static int remove_dir(char* dirname, int len) /* share code for file and directory deletion, saves space */ static bool delete_handler(bool is_dir) { - bool exit = false; + char *lines[]={ + str(LANG_REALLY_DELETE), + selected_file + }; + char *yes_lines[]={ + str(LANG_DELETED), + selected_file + }; + + struct text_message message={lines, 2}; + struct text_message yes_message={yes_lines, 2}; + if(gui_syncyesno_run(&message, &yes_message, NULL)!=YESNO_YES) + return false; int res; + if (is_dir) + { + char pathname[MAX_PATH]; /* space to go deep */ + strncpy(pathname, selected_file, sizeof pathname); + res = remove_dir(pathname, sizeof(pathname)); + } + else + res = remove(selected_file); - lcd_clear_display(); - lcd_puts(0,0,str(LANG_REALLY_DELETE)); - lcd_puts_scroll(0,1,selected_file); - -#ifdef HAVE_LCD_BITMAP - lcd_puts(0,3,str(LANG_CONFIRM_WITH_PLAY_RECORDER)); - lcd_puts(0,4,str(LANG_CANCEL_WITH_ANY_RECORDER)); -#endif - - lcd_update(); - - while (!exit) { - int btn = button_get(true); - switch (btn) { - case SETTINGS_OK: - if (is_dir) - { - char pathname[MAX_PATH]; /* space to go deep */ - strncpy(pathname, selected_file, sizeof pathname); - res = remove_dir(pathname, sizeof(pathname)); - } - else - { - res = remove(selected_file); - } - - if (!res) { - onplay_result = ONPLAY_RELOAD_DIR; - lcd_clear_display(); - lcd_puts(0,0,str(LANG_DELETED)); - lcd_puts_scroll(0,1,selected_file); - lcd_update(); - sleep(HZ); - exit = true; - } - break; - - default: - /* ignore button releases */ - if (!(btn & BUTTON_REL)) - exit = true; - break; - } + if (!res) { + onplay_result = ONPLAY_RELOAD_DIR; } return false; }