iPod 5G: Split lcd_bcm_finishup() function into two halves, and incorporate into...
[Rockbox.git] / apps / playlist_menu.c
blobba4a4fe0d272d6df50c5503910bb2c2b829cfcf1
1 /***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
10 * Copyright (C) 2002 Björn Stenberg
12 * All files in this archive are subject to the GNU General Public License.
13 * See the file COPYING in the source tree root for full license agreement.
15 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
16 * KIND, either express or implied.
18 ****************************************************************************/
20 #include <string.h>
22 #include "menu.h"
23 #include "file.h"
24 #include "keyboard.h"
25 #include "playlist.h"
26 #include "tree.h"
27 #include "settings.h"
28 #include "playlist_viewer.h"
29 #include "talk.h"
30 #include "lang.h"
31 #include "playlist_menu.h"
33 static bool save_playlist(void)
35 save_playlist_screen(NULL);
36 return false;
39 static bool recurse_directory(void)
41 static const struct opt_items names[] = {
42 { STR(LANG_OFF) },
43 { STR(LANG_ON) },
44 { STR(LANG_RESUME_SETTING_ASK)},
47 return set_option( (char *)str(LANG_RECURSE_DIRECTORY),
48 &global_settings.recursive_dir_insert, INT, names, 3,
49 NULL );
52 static bool warnon_option(void)
54 return set_bool(str(LANG_WARN_ERASEDYNPLAYLIST_MENU),
55 &global_settings.warnon_erase_dynplaylist);
58 bool playlist_menu(void)
60 int m;
61 bool result;
63 static const struct menu_item items[] = {
64 { ID2P(LANG_CREATE_PLAYLIST), create_playlist },
65 { ID2P(LANG_VIEW_DYNAMIC_PLAYLIST), playlist_viewer },
66 { ID2P(LANG_SAVE_DYNAMIC_PLAYLIST), save_playlist },
67 { ID2P(LANG_RECURSE_DIRECTORY), recurse_directory },
68 { ID2P(LANG_WARN_ERASEDYNPLAYLIST_MENU), warnon_option},
71 m = menu_init( items, sizeof items / sizeof(struct menu_item), NULL,
72 NULL, NULL, NULL );
73 result = menu_run(m);
74 menu_exit(m);
75 return result;
78 int save_playlist_screen(struct playlist_info* playlist)
80 char* filename;
81 char temp[MAX_PATH+1];
82 int len;
84 filename = playlist_get_name(playlist, temp, sizeof(temp));
86 if (!filename || (len=strlen(filename)) <= 4 ||
87 strcasecmp(&filename[len-4], ".m3u"))
88 strcpy(filename, DEFAULT_DYNAMIC_PLAYLIST_NAME);
90 if (!kbd_input(filename, sizeof(temp)))
92 playlist_save(playlist, filename);
94 /* reload in case playlist was saved to cwd */
95 reload_directory();
98 return 0;