summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonathan Gordon <rockbox@jdgordon.info>2007-02-11 07:32:58 +0000
committerJonathan Gordon <rockbox@jdgordon.info>2007-02-11 07:32:58 +0000
commite84ff179cb315b4e9da0b4af1f6536a0886f3614 (patch)
tree359390486b2171a8834abbec73defa7776e278ad
parent26d8dce20a619275844d92fbcee04cda9b5dea3a (diff)
downloadrockbox-e84ff179cb315b4e9da0b4af1f6536a0886f3614.zip
rockbox-e84ff179cb315b4e9da0b4af1f6536a0886f3614.tar.gz
rockbox-e84ff179cb315b4e9da0b4af1f6536a0886f3614.tar.bz2
rockbox-e84ff179cb315b4e9da0b4af1f6536a0886f3614.tar.xz
Move the playlist menu to the new system
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@12268 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--apps/SOURCES1
-rw-r--r--apps/menus/playlist_menu.c53
-rw-r--r--apps/playlist_menu.c103
-rw-r--r--apps/settings_list.c5
4 files changed, 55 insertions, 107 deletions
diff --git a/apps/SOURCES b/apps/SOURCES
index d47e2bd..93f6d12 100644
--- a/apps/SOURCES
+++ b/apps/SOURCES
@@ -23,7 +23,6 @@ misc.c
onplay.c
playlist.c
playlist_catalog.c
-playlist_menu.c
playlist_viewer.c
plugin.c
screens.c
diff --git a/apps/menus/playlist_menu.c b/apps/menus/playlist_menu.c
index b38870e..78c926f 100644
--- a/apps/menus/playlist_menu.c
+++ b/apps/menus/playlist_menu.c
@@ -21,6 +21,7 @@
#include <stdbool.h>
#include <stddef.h>
#include <limits.h>
+#include <string.h>
#include "config.h"
#include "lang.h"
#include "action.h"
@@ -28,5 +29,55 @@
#include "menu.h"
#include "playlist_menu.h"
-MENUITEM_FUNCTION(playlist_menu_item, ID2P(LANG_PLAYLIST_MENU), (menu_function)playlist_menu, NULL);
+#include "menu.h"
+#include "file.h"
+#include "keyboard.h"
+#include "playlist.h"
+#include "tree.h"
+#include "playlist_viewer.h"
+#include "talk.h"
+#include "playlist_catalog.h"
+
+int save_playlist_screen(struct playlist_info* playlist)
+{
+ char temp[MAX_PATH+1];
+ int len;
+
+ playlist_get_name(playlist, temp, sizeof(temp));
+ len = strlen(temp);
+
+ if (len > 4 && !strcasecmp(&temp[len-4], ".m3u"))
+ strcat(temp, "8");
+
+ if (len <= 5 || strcasecmp(&temp[len-5], ".m3u8"))
+ strcpy(temp, DEFAULT_DYNAMIC_PLAYLIST_NAME);
+
+ if (!kbd_input(temp, sizeof(temp)))
+ {
+ playlist_save(playlist, temp);
+
+ /* reload in case playlist was saved to cwd */
+ reload_directory();
+ }
+
+ return 0;
+}
+MENUITEM_FUNCTION(create_playlist_item, ID2P(LANG_CREATE_PLAYLIST),
+ (int(*)(void))create_playlist, NULL);
+MENUITEM_FUNCTION(view_playlist, ID2P(LANG_VIEW_DYNAMIC_PLAYLIST),
+ (int(*)(void))playlist_viewer, NULL);
+MENUITEM_FUNCTION_WPARAM(save_playlist, ID2P(LANG_SAVE_DYNAMIC_PLAYLIST),
+ (int(*)(void*))save_playlist_screen, NULL, NULL);
+MENUITEM_FUNCTION(catalog, ID2P(LANG_CATALOG),
+ (int(*)(void))catalog_view_playlists, NULL);
+MENUITEM_SETTING(recursive_dir_insert, &global_settings.recursive_dir_insert, NULL);
+MENUITEM_SETTING(warn_on_erase, &global_settings.warnon_erase_dynplaylist, NULL);
+
+MAKE_MENU(playlist_menu_item, ID2P(LANG_PLAYLIST_MENU), NULL,
+ &create_playlist_item, &view_playlist, &save_playlist, &catalog,
+ &recursive_dir_insert, &warn_on_erase);
+bool playlist_menu(void)
+{
+ return do_menu(&playlist_menu_item);
+}
diff --git a/apps/playlist_menu.c b/apps/playlist_menu.c
deleted file mode 100644
index 2874c3b..0000000
--- a/apps/playlist_menu.c
+++ /dev/null
@@ -1,103 +0,0 @@
-/***************************************************************************
- * __________ __ ___.
- * Open \______ \ ____ ____ | | _\_ |__ _______ ___
- * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
- * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
- * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
- * \/ \/ \/ \/ \/
- * $Id$
- *
- * Copyright (C) 2002 Björn Stenberg
- *
- * All files in this archive are subject to the GNU General Public License.
- * See the file COPYING in the source tree root for full license agreement.
- *
- * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
- * KIND, either express or implied.
- *
- ****************************************************************************/
-
-#include <string.h>
-
-#include "menu.h"
-#include "file.h"
-#include "keyboard.h"
-#include "playlist.h"
-#include "tree.h"
-#include "settings.h"
-#include "playlist_viewer.h"
-#include "talk.h"
-#include "lang.h"
-#include "playlist_catalog.h"
-#include "playlist_menu.h"
-
-static bool save_playlist(void)
-{
- save_playlist_screen(NULL);
- return false;
-}
-
-static bool recurse_directory(void)
-{
- static const struct opt_items names[] = {
- { STR(LANG_OFF) },
- { STR(LANG_ON) },
- { STR(LANG_RESUME_SETTING_ASK)},
- };
-
- return set_option( (char *)str(LANG_RECURSE_DIRECTORY),
- &global_settings.recursive_dir_insert, INT, names, 3,
- 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;
- bool result;
-
- static const struct menu_item items[] = {
- { ID2P(LANG_CREATE_PLAYLIST), create_playlist },
- { ID2P(LANG_VIEW_DYNAMIC_PLAYLIST), playlist_viewer },
- { ID2P(LANG_SAVE_DYNAMIC_PLAYLIST), save_playlist },
- { ID2P(LANG_CATALOG), catalog_view_playlists },
- { ID2P(LANG_RECURSE_DIRECTORY), recurse_directory },
- { ID2P(LANG_WARN_ERASEDYNPLAYLIST_MENU), warnon_option },
- };
-
- m = menu_init( items, sizeof items / sizeof(struct menu_item), NULL,
- NULL, NULL, NULL );
- result = menu_run(m);
- menu_exit(m);
- return result;
-}
-
-int save_playlist_screen(struct playlist_info* playlist)
-{
- char temp[MAX_PATH+1];
- int len;
-
- playlist_get_name(playlist, temp, sizeof(temp));
- len = strlen(temp);
-
- if (len > 4 && !strcasecmp(&temp[len-4], ".m3u"))
- strcat(temp, "8");
-
- if (len <= 5 || strcasecmp(&temp[len-5], ".m3u8"))
- strcpy(temp, DEFAULT_DYNAMIC_PLAYLIST_NAME);
-
- if (!kbd_input(temp, sizeof(temp)))
- {
- playlist_save(playlist, temp);
-
- /* reload in case playlist was saved to cwd */
- reload_directory();
- }
-
- return 0;
-}
diff --git a/apps/settings_list.c b/apps/settings_list.c
index 894c724..dbb121e 100644
--- a/apps/settings_list.c
+++ b/apps/settings_list.c
@@ -398,8 +398,9 @@ const struct settings_list settings[] = {
"playlist viewer indices",NULL),
{F_T_INT,GS(playlist_viewer_track_display),LANG_TRACK_DISPLAY,
INT(0),"playlist viewer track display","track name,full path",UNUSED},
- {F_T_INT,GS(recursive_dir_insert),LANG_RECURSE_DIRECTORY, INT(RECURSE_OFF),
- "recursive directory insert",off_on_ask,UNUSED},
+ CHOICE_SETTING(0, recursive_dir_insert, LANG_RECURSE_DIRECTORY , RECURSE_OFF,
+ "recursive directory insert", off_on_ask, NULL , 3 ,
+ ID2P(LANG_OFF), ID2P(LANG_ON), ID2P(LANG_RESUME_SETTING_ASK)),
/* bookmarks */
{F_T_INT,GS(autocreatebookmark),LANG_BOOKMARK_SETTINGS_AUTOCREATE,
INT(BOOKMARK_NO),"autocreate bookmarks",