summaryrefslogtreecommitdiff
path: root/apps
diff options
context:
space:
mode:
authorNils Wallménius <nils@rockbox.org>2008-05-01 10:13:12 +0000
committerNils Wallménius <nils@rockbox.org>2008-05-01 10:13:12 +0000
commitdabcb81e1380aeab8e50a64efcc1dc4a59145094 (patch)
tree6d7f5067169739faf7b4bb874386542f57abe768 /apps
parente02d031f4ce5da08770b784f17795e5f490d3481 (diff)
downloadrockbox-dabcb81e1380aeab8e50a64efcc1dc4a59145094.tar.gz
rockbox-dabcb81e1380aeab8e50a64efcc1dc4a59145094.zip
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
Diffstat (limited to 'apps')
-rw-r--r--apps/filetree.c24
-rw-r--r--apps/misc.c20
-rw-r--r--apps/misc.h4
-rw-r--r--apps/tagtree.c12
4 files changed, 31 insertions, 29 deletions
diff --git a/apps/filetree.c b/apps/filetree.c
index dd541fe0a2..64a12b5050 100644
--- a/apps/filetree.c
+++ b/apps/filetree.c
@@ -42,6 +42,7 @@
42#include "yesno.h" 42#include "yesno.h"
43#include "cuesheet.h" 43#include "cuesheet.h"
44#include "filetree.h" 44#include "filetree.h"
45#include "misc.h"
45#ifdef HAVE_LCD_BITMAP 46#ifdef HAVE_LCD_BITMAP
46#include "keyboard.h" 47#include "keyboard.h"
47#endif 48#endif
@@ -102,15 +103,8 @@ bool ft_play_playlist(char* pathname, char* dirname, char* filename)
102 103
103 /* about to create a new current playlist... 104 /* about to create a new current playlist...
104 allow user to cancel the operation */ 105 allow user to cancel the operation */
105 if (global_settings.warnon_erase_dynplaylist && 106 if (!warn_on_pl_erase())
106 playlist_modified(NULL)) 107 return false;
107 {
108 const char *lines[] = {ID2P(LANG_WARN_ERASEDYNPLAYLIST_PROMPT)};
109 struct text_message message = {lines, 1};
110
111 if (gui_syncyesno_run(&message, NULL, NULL) != YESNO_YES)
112 return false;
113 }
114 108
115 if (playlist_create(dirname, filename) != -1) 109 if (playlist_create(dirname, filename) != -1)
116 { 110 {
@@ -405,16 +399,8 @@ int ft_enter(struct tree_context* c)
405 399
406 /* about to create a new current playlist... 400 /* about to create a new current playlist...
407 allow user to cancel the operation */ 401 allow user to cancel the operation */
408 if (global_settings.warnon_erase_dynplaylist && 402 if (!warn_on_pl_erase())
409 !global_settings.party_mode && 403 break;
410 playlist_modified(NULL))
411 {
412 static const char *lines[]={ID2P(LANG_WARN_ERASEDYNPLAYLIST_PROMPT)};
413 static const struct text_message message={lines, 1};
414
415 if(gui_syncyesno_run(&message, NULL, NULL) != YESNO_YES)
416 break;
417 }
418 404
419 if (global_settings.party_mode) 405 if (global_settings.party_mode)
420 { 406 {
diff --git a/apps/misc.c b/apps/misc.c
index c97b9cf0f3..23341a82e8 100644
--- a/apps/misc.c
+++ b/apps/misc.c
@@ -50,6 +50,8 @@
50#include "tagcache.h" 50#include "tagcache.h"
51#include "scrobbler.h" 51#include "scrobbler.h"
52#include "sound.h" 52#include "sound.h"
53#include "playlist.h"
54#include "yesno.h"
53 55
54#ifdef HAVE_MMC 56#ifdef HAVE_MMC
55#include "ata_mmc.h" 57#include "ata_mmc.h"
@@ -244,6 +246,24 @@ char *create_datetime_filename(char *buffer, const char *path,
244} 246}
245#endif /* CONFIG_RTC */ 247#endif /* CONFIG_RTC */
246 248
249/* Ask the user if they really want to erase the current dynamic playlist
250 * returns true if the playlist should be replaced */
251bool warn_on_pl_erase(void)
252{
253 if (global_settings.warnon_erase_dynplaylist &&
254 !global_settings.party_mode &&
255 playlist_modified(NULL))
256 {
257 static const char *lines[] =
258 {ID2P(LANG_WARN_ERASEDYNPLAYLIST_PROMPT)};
259 static const struct text_message message={lines, 1};
260
261 return (gui_syncyesno_run(&message, NULL, NULL) == YESNO_YES);
262 }
263 else
264 return true;
265}
266
247/* Read (up to) a line of text from fd into buffer and return number of bytes 267/* Read (up to) a line of text from fd into buffer and return number of bytes
248 * read (which may be larger than the number of bytes stored in buffer). If 268 * read (which may be larger than the number of bytes stored in buffer). If
249 * an error occurs, -1 is returned (and buffer contains whatever could be 269 * an error occurs, -1 is returned (and buffer contains whatever could be
diff --git a/apps/misc.h b/apps/misc.h
index c6a91646b8..4d0226ae51 100644
--- a/apps/misc.h
+++ b/apps/misc.h
@@ -69,6 +69,10 @@ char *create_datetime_filename(char *buffer, const char *path,
69 bool unique_time); 69 bool unique_time);
70#endif /* CONFIG_RTC */ 70#endif /* CONFIG_RTC */
71 71
72/* Ask the user if they really want to erase the current dynamic playlist
73 * returns true if the playlist should be replaced */
74bool warn_on_pl_erase(void);
75
72/* Read (up to) a line of text from fd into buffer and return number of bytes 76/* Read (up to) a line of text from fd into buffer and return number of bytes
73 * read (which may be larger than the number of bytes stored in buffer). If 77 * read (which may be larger than the number of bytes stored in buffer). If
74 * an error occurs, -1 is returned (and buffer contains whatever could be 78 * an error occurs, -1 is returned (and buffer contains whatever could be
diff --git a/apps/tagtree.c b/apps/tagtree.c
index 627cad3817..3562a48a5a 100644
--- a/apps/tagtree.c
+++ b/apps/tagtree.c
@@ -1497,16 +1497,8 @@ int tagtree_enter(struct tree_context* c)
1497 c->dirlevel--; 1497 c->dirlevel--;
1498 /* about to create a new current playlist... 1498 /* about to create a new current playlist...
1499 allow user to cancel the operation */ 1499 allow user to cancel the operation */
1500 if (global_settings.warnon_erase_dynplaylist && 1500 if (!warn_on_pl_erase())
1501 !global_settings.party_mode && 1501 break;
1502 playlist_modified(NULL))
1503 {
1504 static const char *lines[]={ID2P(LANG_WARN_ERASEDYNPLAYLIST_PROMPT)};
1505 static const struct text_message message={lines, 1};
1506
1507 if (gui_syncyesno_run(&message, NULL, NULL) != YESNO_YES)
1508 break;
1509 }
1510 1502
1511 if (tagtree_play_folder(c) >= 0) 1503 if (tagtree_play_folder(c) >= 0)
1512 rc = 2; 1504 rc = 2;