Introduce a small helper function that asks the user if the dynamic playlist should be erased to increase code re-use
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@17295 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
e02d031f4c
commit
dabcb81e13
4 changed files with 31 additions and 29 deletions
|
@ -42,6 +42,7 @@
|
|||
#include "yesno.h"
|
||||
#include "cuesheet.h"
|
||||
#include "filetree.h"
|
||||
#include "misc.h"
|
||||
#ifdef HAVE_LCD_BITMAP
|
||||
#include "keyboard.h"
|
||||
#endif
|
||||
|
@ -102,15 +103,8 @@ bool ft_play_playlist(char* pathname, char* dirname, char* filename)
|
|||
|
||||
/* about to create a new current playlist...
|
||||
allow user to cancel the operation */
|
||||
if (global_settings.warnon_erase_dynplaylist &&
|
||||
playlist_modified(NULL))
|
||||
{
|
||||
const char *lines[] = {ID2P(LANG_WARN_ERASEDYNPLAYLIST_PROMPT)};
|
||||
struct text_message message = {lines, 1};
|
||||
|
||||
if (gui_syncyesno_run(&message, NULL, NULL) != YESNO_YES)
|
||||
return false;
|
||||
}
|
||||
if (!warn_on_pl_erase())
|
||||
return false;
|
||||
|
||||
if (playlist_create(dirname, filename) != -1)
|
||||
{
|
||||
|
@ -405,16 +399,8 @@ int ft_enter(struct tree_context* c)
|
|||
|
||||
/* about to create a new current playlist...
|
||||
allow user to cancel the operation */
|
||||
if (global_settings.warnon_erase_dynplaylist &&
|
||||
!global_settings.party_mode &&
|
||||
playlist_modified(NULL))
|
||||
{
|
||||
static const char *lines[]={ID2P(LANG_WARN_ERASEDYNPLAYLIST_PROMPT)};
|
||||
static const struct text_message message={lines, 1};
|
||||
|
||||
if(gui_syncyesno_run(&message, NULL, NULL) != YESNO_YES)
|
||||
break;
|
||||
}
|
||||
if (!warn_on_pl_erase())
|
||||
break;
|
||||
|
||||
if (global_settings.party_mode)
|
||||
{
|
||||
|
|
20
apps/misc.c
20
apps/misc.c
|
@ -50,6 +50,8 @@
|
|||
#include "tagcache.h"
|
||||
#include "scrobbler.h"
|
||||
#include "sound.h"
|
||||
#include "playlist.h"
|
||||
#include "yesno.h"
|
||||
|
||||
#ifdef HAVE_MMC
|
||||
#include "ata_mmc.h"
|
||||
|
@ -244,6 +246,24 @@ char *create_datetime_filename(char *buffer, const char *path,
|
|||
}
|
||||
#endif /* CONFIG_RTC */
|
||||
|
||||
/* Ask the user if they really want to erase the current dynamic playlist
|
||||
* returns true if the playlist should be replaced */
|
||||
bool warn_on_pl_erase(void)
|
||||
{
|
||||
if (global_settings.warnon_erase_dynplaylist &&
|
||||
!global_settings.party_mode &&
|
||||
playlist_modified(NULL))
|
||||
{
|
||||
static const char *lines[] =
|
||||
{ID2P(LANG_WARN_ERASEDYNPLAYLIST_PROMPT)};
|
||||
static const struct text_message message={lines, 1};
|
||||
|
||||
return (gui_syncyesno_run(&message, NULL, NULL) == YESNO_YES);
|
||||
}
|
||||
else
|
||||
return true;
|
||||
}
|
||||
|
||||
/* Read (up to) a line of text from fd into buffer and return number of bytes
|
||||
* read (which may be larger than the number of bytes stored in buffer). If
|
||||
* an error occurs, -1 is returned (and buffer contains whatever could be
|
||||
|
|
|
@ -69,6 +69,10 @@ char *create_datetime_filename(char *buffer, const char *path,
|
|||
bool unique_time);
|
||||
#endif /* CONFIG_RTC */
|
||||
|
||||
/* Ask the user if they really want to erase the current dynamic playlist
|
||||
* returns true if the playlist should be replaced */
|
||||
bool warn_on_pl_erase(void);
|
||||
|
||||
/* Read (up to) a line of text from fd into buffer and return number of bytes
|
||||
* read (which may be larger than the number of bytes stored in buffer). If
|
||||
* an error occurs, -1 is returned (and buffer contains whatever could be
|
||||
|
|
|
@ -1497,16 +1497,8 @@ int tagtree_enter(struct tree_context* c)
|
|||
c->dirlevel--;
|
||||
/* about to create a new current playlist...
|
||||
allow user to cancel the operation */
|
||||
if (global_settings.warnon_erase_dynplaylist &&
|
||||
!global_settings.party_mode &&
|
||||
playlist_modified(NULL))
|
||||
{
|
||||
static const char *lines[]={ID2P(LANG_WARN_ERASEDYNPLAYLIST_PROMPT)};
|
||||
static const struct text_message message={lines, 1};
|
||||
|
||||
if (gui_syncyesno_run(&message, NULL, NULL) != YESNO_YES)
|
||||
break;
|
||||
}
|
||||
if (!warn_on_pl_erase())
|
||||
break;
|
||||
|
||||
if (tagtree_play_folder(c) >= 0)
|
||||
rc = 2;
|
||||
|
|
Loading…
Reference in a new issue