Update several codec Makefiles so that the codec libs build again on Coldfire targets...
[Rockbox.git] / apps / playlist_menu.c
blobe23722160f97a046fbd6e0e74b0aa2c289141457
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_catalog.h"
32 #include "playlist_menu.h"
34 static bool save_playlist(void)
36 save_playlist_screen(NULL);
37 return false;
40 static bool recurse_directory(void)
42 static const struct opt_items names[] = {
43 { STR(LANG_OFF) },
44 { STR(LANG_ON) },
45 { STR(LANG_RESUME_SETTING_ASK)},
48 return set_option( (char *)str(LANG_RECURSE_DIRECTORY),
49 &global_settings.recursive_dir_insert, INT, names, 3,
50 NULL );
53 static bool warnon_option(void)
55 return set_bool(str(LANG_WARN_ERASEDYNPLAYLIST_MENU),
56 &global_settings.warnon_erase_dynplaylist);
59 bool playlist_menu(void)
61 int m;
62 bool result;
64 static const struct menu_item items[] = {
65 { ID2P(LANG_CREATE_PLAYLIST), create_playlist },
66 { ID2P(LANG_VIEW_DYNAMIC_PLAYLIST), playlist_viewer },
67 { ID2P(LANG_SAVE_DYNAMIC_PLAYLIST), save_playlist },
68 { ID2P(LANG_CATALOG), catalog_view_playlists },
69 { ID2P(LANG_RECURSE_DIRECTORY), recurse_directory },
70 { ID2P(LANG_WARN_ERASEDYNPLAYLIST_MENU), warnon_option },
73 m = menu_init( items, sizeof items / sizeof(struct menu_item), NULL,
74 NULL, NULL, NULL );
75 result = menu_run(m);
76 menu_exit(m);
77 return result;
80 int save_playlist_screen(struct playlist_info* playlist)
82 char* filename;
83 char temp[MAX_PATH+1];
84 int len;
86 filename = playlist_get_name(playlist, temp, sizeof(temp));
88 if (!filename || (len=strlen(filename)) <= 4 ||
89 strcasecmp(&filename[len-4], ".m3u"))
90 strcpy(filename, DEFAULT_DYNAMIC_PLAYLIST_NAME);
92 if (!kbd_input(filename, sizeof(temp)))
94 playlist_save(playlist, filename);
96 /* reload in case playlist was saved to cwd */
97 reload_directory();
100 return 0;