From 941de8586c1d64742b5947cb4a49092478755eb5 Mon Sep 17 00:00:00 2001 From: Hardeep Sidhu Date: Sun, 5 Feb 2006 19:35:03 +0000 Subject: Patch #1260463 - Warn on erasing modified dynamic playlist by Craig (ctb311276) git-svn-id: svn://svn.rockbox.org/rockbox/trunk@8589 a1c6a512-1295-4272-9138-f99709370657 --- apps/filetree.c | 25 +++++++++++++++++++++++++ apps/lang/english.lang | 11 +++++++++++ apps/playlist_menu.c | 7 +++++++ apps/settings.c | 3 +++ apps/settings.h | 2 ++ 5 files changed, 48 insertions(+) (limited to 'apps') diff --git a/apps/filetree.c b/apps/filetree.c index cb21b71eec..b8f066745f 100644 --- a/apps/filetree.c +++ b/apps/filetree.c @@ -40,6 +40,7 @@ #include "sprintf.h" #include "dircache.h" #include "splash.h" +#include "yesno.h" #ifndef SIMULATOR static int boot_size = 0; @@ -346,6 +347,18 @@ int ft_enter(struct tree_context* c) if (bookmark_autoload(buf)) break; + /* about to create a new current playlist... + allow user to cancel the operation */ + if (global_settings.warnon_erase_dynplaylist && + playlist_modified(NULL)) + { + char *lines[]={str(LANG_WARN_ERASEDYNPLAYLIST_PROMPT)}; + struct text_message message={lines, 1}; + + if(gui_syncyesno_run(&message, NULL, NULL) != YESNO_YES) + break; + } + if (playlist_create(c->currdir, file->name) != -1) { if (global_settings.playlist_shuffle) @@ -360,6 +373,18 @@ int ft_enter(struct tree_context* c) if (bookmark_autoload(c->currdir)) break; + /* about to create a new current playlist... + allow user to cancel the operation */ + if (global_settings.warnon_erase_dynplaylist && + playlist_modified(NULL)) + { + char *lines[]={str(LANG_WARN_ERASEDYNPLAYLIST_PROMPT)}; + struct text_message message={lines, 1}; + + if(gui_syncyesno_run(&message, NULL, NULL) != YESNO_YES) + break; + } + if (playlist_create(c->currdir, NULL) != -1) { start_index = ft_build_playlist(c, c->selected_item); diff --git a/apps/lang/english.lang b/apps/lang/english.lang index a2803ad432..c3d458e84c 100644 --- a/apps/lang/english.lang +++ b/apps/lang/english.lang @@ -3599,3 +3599,14 @@ eng: "Backdrop failed" voice: "Backdrop failed" new: +id: LANG_WARN_ERASEDYNPLAYLIST_MENU +desc: in playlist options menu, option to warn when erasing dynamic playlist +eng: "Warn When Erasing Dynamic Playlist" +voice "" +new: + +id: LANG_WARN_ERASEDYNPLAYLIST_PROMPT +desc: prompt shown when about to erase a modified dynamic playlist +eng: "Erase dynamic playlist?" +voice "" +new: diff --git a/apps/playlist_menu.c b/apps/playlist_menu.c index d59661a96c..c70a510a6e 100644 --- a/apps/playlist_menu.c +++ b/apps/playlist_menu.c @@ -60,6 +60,12 @@ static bool recurse_directory(void) NULL ); } +static bool warnon_option(void) +{ + return set_bool(str(LANG_WARN_ERASEDYNPLAYLIST_MENU), + &global_settings.warnon_erase_dynplaylist); +} + bool playlist_menu(void) { int m; @@ -70,6 +76,7 @@ bool playlist_menu(void) { ID2P(LANG_VIEW_DYNAMIC_PLAYLIST), playlist_viewer }, { ID2P(LANG_SAVE_DYNAMIC_PLAYLIST), save_playlist }, { ID2P(LANG_RECURSE_DIRECTORY), recurse_directory }, + { ID2P(LANG_WARN_ERASEDYNPLAYLIST_MENU), warnon_option}, }; m = menu_init( items, sizeof items / sizeof(struct menu_item), NULL, diff --git a/apps/settings.c b/apps/settings.c index 07db21ef66..d13f56891e 100644 --- a/apps/settings.c +++ b/apps/settings.c @@ -508,6 +508,9 @@ static const struct bit_entry hd_bits[] = #endif #endif /* HAVE_LCD_BITMAP */ + {1, S_O(warnon_erase_dynplaylist), false, + "warn when erasing dynamic playlist", off_on }, + /* If values are just added to the end, no need to bump the version. */ /* new stuff to be added at the end */ diff --git a/apps/settings.h b/apps/settings.h index bb58336202..53dfde0c50 100644 --- a/apps/settings.h +++ b/apps/settings.h @@ -411,6 +411,8 @@ struct user_settings #ifdef HAVE_LCD_COLOR unsigned char backdrop_file[MAX_FILENAME+1]; /* backdrop bitmap file */ #endif + + bool warnon_erase_dynplaylist; /* warn when erasing dynamic playlist */ }; enum optiontype { INT, BOOL }; -- cgit v1.2.3