--- orig/apps/bookmark.c 2004-03-17 19:43:32.475053400 +0100 +++ dev/apps/bookmark.c 2004-03-17 20:06:44.857200600 +0100 @@ -50,7 +50,6 @@ #define RECENT_BOOKMARK_FILE ROCKBOX_DIR "/most-recent.bmark" static bool add_bookmark(char* bookmark_file_name, char* bookmark); -static bool bookmark_load_menu(void); static bool check_bookmark(char* bookmark); static char* create_bookmark(void); static bool delete_bookmark(char* bookmark_file_name, int bookmark_id); @@ -84,38 +83,6 @@ static char global_bookmark[MAX_BOOKMARK_SIZE]; /* ----------------------------------------------------------------------- */ -/* Displays the bookmark menu options for the user to decide. This is an */ -/* interface function. */ -/* ----------------------------------------------------------------------- */ -bool bookmark_menu(void) -{ - int m; - bool result; - - struct menu_item items[] = { - { STR(LANG_BOOKMARK_MENU_CREATE), bookmark_create_menu}, - { STR(LANG_BOOKMARK_MENU_LIST), bookmark_load_menu}, - { STR(LANG_BOOKMARK_MENU_RECENT_BOOKMARKS), bookmark_mrb_load}, - }; - - m=menu_init( items, sizeof items / sizeof(struct menu_item), NULL, - NULL, NULL, NULL); - -#ifdef HAVE_LCD_CHARCELLS - status_set_param(true); -#endif - result = menu_run(m); -#ifdef HAVE_LCD_CHARCELLS - status_set_param(false); -#endif - menu_exit(m); - - settings_save(); - - return result; -} - -/* ----------------------------------------------------------------------- */ /* This is the interface function from the main menu. */ /* ----------------------------------------------------------------------- */ bool bookmark_create_menu(void) @@ -130,7 +97,7 @@ /* for the user. The user can then select a bookmark to load. */ /* If no file/directory is currently playing, the menu item does not work. */ /* ----------------------------------------------------------------------- */ -static bool bookmark_load_menu(void) +bool bookmark_load_menu(void) { bool success = true; int offset; --- orig/apps/bookmark.h 2004-03-17 19:43:32.515111000 +0100 +++ dev/apps/bookmark.h 2004-03-17 20:06:44.887243800 +0100 @@ -21,12 +21,12 @@ #include -bool bookmark_menu(void); bool bookmark_autobookmark(void); bool bookmark_create_menu(void); bool bookmark_mrb_load(void); bool bookmark_autoload(char* file); bool bookmark_load(char* file, bool autoload); +bool bookmark_load_menu(void); void bookmark_play(char* resume_file, int index, int offset, int seed); #endif /* __BOOKMARK_H__ */ --- orig/apps/main_menu.c 2004-03-17 19:43:32.555168600 +0100 +++ dev/apps/main_menu.c 2004-03-17 20:25:51.726317400 +0100 @@ -31,19 +31,16 @@ #include "debug_menu.h" #include "sprintf.h" #include -#include "playlist.h" #include "settings.h" #include "settings_menu.h" +#include "sleeptimer.h" #include "power.h" #include "powermgmt.h" #include "sound_menu.h" #include "status.h" #include "fat.h" -#include "bookmark.h" -#include "wps.h" #include "buffer.h" #include "screens.h" -#include "playlist_menu.h" #ifdef HAVE_FMRADIO #include "radio.h" #endif @@ -282,7 +279,6 @@ /* info menu */ struct menu_item items[] = { - { STR(LANG_MENU_SHOW_ID3_INFO), browse_id3 }, { STR(LANG_INFO_MENU), show_info }, { STR(LANG_VERSION), show_credits }, #ifndef SIMULATOR @@ -300,6 +296,83 @@ return result; } +static bool custom_cfg_browse(void) +{ + return rockbox_browse(ROCKBOX_DIR, SHOW_CFG); +} + +static bool firmware_browse(void) +{ + return rockbox_browse(ROCKBOX_DIR, SHOW_MOD); +} + +static bool reset_settings(void) +{ + bool done=false; + int line; + + lcd_clear_display(); + +#ifdef HAVE_LCD_CHARCELLS + line = 0; +#else + line = 1; + lcd_puts(0,0,str(LANG_RESET_ASK_RECORDER)); +#endif + lcd_puts(0,line,str(LANG_RESET_CONFIRM)); + lcd_puts(0,line+1,str(LANG_RESET_CANCEL)); + + lcd_update(); + + while(!done) { + switch(button_get(true)) { + case BUTTON_PLAY: + settings_reset(); + settings_apply(); + lcd_clear_display(); + lcd_puts(0,1,str(LANG_RESET_DONE_CLEAR)); + done = true; + break; + +#ifdef HAVE_RECORDER_KEYPAD + case BUTTON_OFF: +#else + case BUTTON_STOP: +#endif + lcd_clear_display(); + lcd_puts(0,1,str(LANG_RESET_DONE_CANCEL)); + done = true; + break; + + case SYS_USB_CONNECTED: + usb_screen(); + return true; + } + } + + lcd_puts(0,0,str(LANG_RESET_DONE_SETTING)); + lcd_update(); + sleep(HZ); + return false; +} + +static bool manage_settings_menu(void) +{ + int m; + bool result; + + struct menu_item items[] = { + { STR(LANG_CUSTOM_CFG), custom_cfg_browse }, + { STR(LANG_FIRMWARE), firmware_browse }, + { STR(LANG_RESET), reset_settings }, + { STR(LANG_SAVE_SETTINGS), settings_save_config }, + }; + + m=menu_init( items, sizeof(items) / sizeof(*items),NULL,NULL,NULL,NULL); + result = menu_run(m); + menu_exit(m); + return result; +} bool main_menu(void) { int m; @@ -309,10 +382,6 @@ /* main menu */ struct menu_item items[8]; - items[i].desc = str(LANG_BOOKMARK_MENU); - items[i].voice_id = LANG_BOOKMARK_MENU; - items[i++].function = bookmark_menu; - items[i].desc = str(LANG_SOUND_SETTINGS); items[i].voice_id = LANG_SOUND_SETTINGS; items[i++].function = sound_menu; @@ -335,18 +404,22 @@ items[i++].function = rec_menu; #endif - items[i].desc = str(LANG_PLAYLIST_MENU); - items[i].voice_id = LANG_PLAYLIST_MENU; - items[i++].function = playlist_menu; - items[i].desc = str(LANG_PLUGINS); items[i].voice_id = LANG_PLUGINS; items[i++].function = plugin_browse; + items[i].desc = str(LANG_MANAGE_MENU); + items[i].voice_id = LANG_MANAGE_MENU; + items[i++].function = manage_settings_menu; + items[i].desc = str(LANG_INFO); items[i].voice_id = LANG_INFO; items[i++].function = info_menu; + items[i].desc = str(LANG_SLEEP_TIMER); + items[i].voice_id = LANG_SLEEP_TIMER; + items[i++].function = sleeptimer_screen; + m=menu_init( items, i, NULL, NULL, NULL, NULL ); #ifdef HAVE_LCD_CHARCELLS status_set_param(true); --- orig/apps/onplay.c 2004-03-17 19:43:33.125989400 +0100 +++ dev/apps/onplay.c 2004-03-17 20:25:06.721603800 +0100 @@ -43,7 +43,16 @@ #include "playlist_viewer.h" #include "talk.h" #include "onplay.h" +#include "bookmark.h" +#include "wps.h" +#include "action.h" +#ifdef HAVE_LCD_BITMAP +#include "icons.h" +#endif + +#define DEFAULT_PLAYLIST_NAME "/dynamic.m3u" +static int context; static char* selected_file = NULL; static int selected_file_attr = 0; static int onplay_result = ONPLAY_OK; @@ -54,6 +63,80 @@ bool queue; }; +/* ----------------------------------------------------------------------- */ +/* Displays the bookmark menu options for the user to decide. This is an */ +/* interface function. */ +/* ----------------------------------------------------------------------- */ +bool bookmark_menu(void) +{ + int i,m; + bool result; + struct menu_item items[3]; + + i=0; + + if ((mpeg_status() & MPEG_STATUS_PLAY)) + { + items[i].desc = str(LANG_BOOKMARK_MENU_CREATE); + items[i].function = bookmark_create_menu; + i++; + } + + if (context == CONTEXT_WPS && (mpeg_status() & MPEG_STATUS_PLAY)) + { + items[i].desc = str(LANG_BOOKMARK_MENU_LIST); + items[i].function = bookmark_load_menu; + i++; + } + + items[i].desc = str(LANG_BOOKMARK_MENU_RECENT_BOOKMARKS); + items[i].function = bookmark_mrb_load; + i++; + + m=menu_init( items, i, NULL, NULL, NULL, NULL ); + +#ifdef HAVE_LCD_CHARCELLS + status_set_param(true); +#endif + result = menu_run(m); +#ifdef HAVE_LCD_CHARCELLS + status_set_param(false); +#endif + menu_exit(m); + + settings_save(); + + return result; +} + +static bool save_playlist(void) +{ + char filename[MAX_PATH+1]; + + strncpy(filename, DEFAULT_PLAYLIST_NAME, sizeof(filename)); + + if (!kbd_input(filename, sizeof(filename))) + { + playlist_save(NULL, filename); + + /* reload in case playlist was saved to cwd */ + reload_directory(); + } + + return false; +} + +static bool recurse_directory(void) +{ + struct opt_items names[] = { {STR(LANG_OFF)}, + {STR(LANG_ON)}, + {STR(LANG_RESUME_SETTING_ASK)} }; + + return set_option( str(LANG_RECURSE_DIRECTORY), + &global_settings.recursive_dir_insert, INT, names, 3, + NULL ); +} + static bool add_to_playlist(int position, bool queue) { bool new_playlist = !(mpeg_status() & MPEG_STATUS_PLAY); @@ -140,12 +223,13 @@ /* Sub-menu for playlist options */ static bool playlist_options(void) { - struct menu_item items[7]; - struct playlist_args args[7]; /* increase these 2 if you add entries! */ + struct menu_item items[10]; + struct playlist_args args[10]; /* increase these 2 if you add entries! */ int m, i=0, pstart=0, result; bool ret = false; - if ((selected_file_attr & TREE_ATTR_MASK) == TREE_ATTR_M3U) + if ((selected_file_attr & TREE_ATTR_MASK) == TREE_ATTR_M3U && + context == CONTEXT_TREE) { items[i].desc = str(LANG_VIEW); items[i].voice_id = LANG_VIEW; @@ -156,50 +240,80 @@ if (mpeg_status() & MPEG_STATUS_PLAY) { - items[i].desc = str(LANG_INSERT); - items[i].voice_id = LANG_INSERT; - args[i].position = PLAYLIST_INSERT; - args[i].queue = false; + items[i].desc = str(LANG_VIEW_DYNAMIC_PLAYLIST); + items[i].voice_id = LANG_VIEW_DYNAMIC_PLAYLIST; + items[i].function = playlist_viewer; i++; + pstart++; - items[i].desc = str(LANG_INSERT_FIRST); - items[i].voice_id = LANG_INSERT_FIRST; - args[i].position = PLAYLIST_INSERT_FIRST; - args[i].queue = false; + items[i].desc = str(LANG_SAVE_DYNAMIC_PLAYLIST); + items[i].voice_id = LANG_SAVE_DYNAMIC_PLAYLIST; + items[i].function = save_playlist; i++; + pstart++; + } - items[i].desc = str(LANG_INSERT_LAST); - items[i].voice_id = LANG_INSERT_LAST; - args[i].position = PLAYLIST_INSERT_LAST; - args[i].queue = false; + if (context == CONTEXT_TREE) + { + items[i].desc = str(LANG_CREATE_PLAYLIST); + items[i].voice_id = LANG_CREATE_PLAYLIST; + items[i].function = create_playlist; i++; + pstart++; - items[i].desc = str(LANG_QUEUE); - items[i].voice_id = LANG_QUEUE; - args[i].position = PLAYLIST_INSERT; - args[i].queue = true; - i++; + if (mpeg_status() & MPEG_STATUS_PLAY) + { + items[i].desc = str(LANG_RECURSE_DIRECTORY); + items[i].voice_id = LANG_RECURSE_DIRECTORY; + items[i].function = recurse_directory; + i++; + pstart++; - items[i].desc = str(LANG_QUEUE_FIRST); - items[i].voice_id = LANG_QUEUE_FIRST; - args[i].position = PLAYLIST_INSERT_FIRST; - args[i].queue = true; - i++; + items[i].desc = str(LANG_INSERT); + items[i].voice_id = LANG_INSERT; + args[i].position = PLAYLIST_INSERT; + args[i].queue = false; + i++; - items[i].desc = str(LANG_QUEUE_LAST); - items[i].voice_id = LANG_QUEUE_LAST; - args[i].position = PLAYLIST_INSERT_LAST; - args[i].queue = true; - i++; - } - else if (((selected_file_attr & TREE_ATTR_MASK) == TREE_ATTR_MPA) || - (selected_file_attr & ATTR_DIRECTORY)) - { - items[i].desc = str(LANG_INSERT); - items[i].voice_id = LANG_INSERT; - args[i].position = PLAYLIST_INSERT; - args[i].queue = false; - i++; + items[i].desc = str(LANG_INSERT_FIRST); + items[i].voice_id = LANG_INSERT_FIRST; + args[i].position = PLAYLIST_INSERT_FIRST; + args[i].queue = false; + i++; + + items[i].desc = str(LANG_INSERT_LAST); + items[i].voice_id = LANG_INSERT_LAST; + args[i].position = PLAYLIST_INSERT_LAST; + args[i].queue = false; + i++; + + items[i].desc = str(LANG_QUEUE); + items[i].voice_id = LANG_QUEUE; + args[i].position = PLAYLIST_INSERT; + args[i].queue = true; + i++; + + items[i].desc = str(LANG_QUEUE_FIRST); + items[i].voice_id = LANG_QUEUE_FIRST; + args[i].position = PLAYLIST_INSERT_FIRST; + args[i].queue = true; + i++; + + items[i].desc = str(LANG_QUEUE_LAST); + items[i].voice_id = LANG_QUEUE_LAST; + args[i].position = PLAYLIST_INSERT_LAST; + args[i].queue = true; + i++; + } + else if (((selected_file_attr & TREE_ATTR_MASK) == TREE_ATTR_MPA) || + (selected_file_attr & ATTR_DIRECTORY)) + { + items[i].desc = str(LANG_INSERT); + items[i].voice_id = LANG_INSERT; + args[i].position = PLAYLIST_INSERT; + args[i].queue = false; + i++; + } } m = menu_init( items, i, NULL, NULL, NULL, NULL ); @@ -548,34 +662,46 @@ return true; } -int onplay(char* file, int attr) +int onplay(char* file, int attr, int from) { - struct menu_item items[5]; /* increase this if you add entries! */ + struct menu_item items[7]; /* increase this if you add entries! */ int m, i=0, result; onplay_result = ONPLAY_OK; + context=from; + + items[i].desc = str(LANG_BOOKMARK_MENU); + items[i].voice_id = LANG_BOOKMARK_MENU; + items[i].function = bookmark_menu; + i++; + + items[i].desc = str(LANG_PLAYINDICES_PLAYLIST); + items[i].voice_id = LANG_PLAYINDICES_PLAYLIST; + items[i].function = playlist_options; + i++; if(file) { selected_file = file; selected_file_attr = attr; - if (((attr & TREE_ATTR_MASK) == TREE_ATTR_MPA) || - (attr & ATTR_DIRECTORY) || - ((attr & TREE_ATTR_MASK) == TREE_ATTR_M3U)) + if (context == CONTEXT_WPS) { - items[i].desc = str(LANG_PLAYINDICES_PLAYLIST); - items[i].voice_id = LANG_PLAYINDICES_PLAYLIST; - items[i].function = playlist_options; + items[i].desc = str(LANG_MENU_SHOW_ID3_INFO); + items[i].voice_id = LANG_MENU_SHOW_ID3_INFO; + items[i].function = browse_id3; i++; } - items[i].desc = str(LANG_RENAME); - items[i].voice_id = LANG_RENAME; - items[i].function = rename_file; - i++; + if (context == CONTEXT_TREE) + { + items[i].desc = str(LANG_RENAME); + items[i].voice_id = LANG_RENAME; + items[i].function = rename_file; + i++; + } - if (!(attr & ATTR_DIRECTORY)) + if (!(attr & ATTR_DIRECTORY) && context == CONTEXT_TREE) { items[i].desc = str(LANG_DELETE); items[i].voice_id = LANG_DELETE; @@ -583,7 +709,8 @@ i++; } - if ((attr & TREE_ATTR_MASK) == TREE_ATTR_MPA) + if (((attr & TREE_ATTR_MASK) == TREE_ATTR_MPA) && + context == CONTEXT_TREE) { items[i].desc = str(LANG_VBRFIX); items[i].voice_id = LANG_VBRFIX; @@ -592,10 +719,13 @@ } } - items[i].desc = str(LANG_CREATE_DIR); - items[i].voice_id = LANG_CREATE_DIR; - items[i].function = create_dir; - i++; + if (context == CONTEXT_TREE) + { + items[i].desc = str(LANG_CREATE_DIR); + items[i].voice_id = LANG_CREATE_DIR; + items[i].function = create_dir; + i++; + } /* DIY menu handling, since we want to exit after selection */ m = menu_init( items, i, NULL, NULL, NULL, NULL ); @@ -604,5 +734,12 @@ items[result].function(); menu_exit(m); +#ifdef HAVE_LCD_BITMAP + if (global_settings.statusbar) + lcd_setmargins(0, STATUSBAR_HEIGHT); + else + lcd_setmargins(0, 0); +#endif + return onplay_result; } --- orig/apps/onplay.h 2004-03-17 19:43:32.645298200 +0100 +++ dev/apps/onplay.h 2004-03-17 20:06:45.107560600 +0100 @@ -19,7 +19,7 @@ #ifndef _ONPLAY_H_ #define _ONPLAY_H_ -int onplay(char* file, int attr); +int onplay(char* file, int attr, int from_screen); enum { ONPLAY_OK, --- orig/apps/playlist_menu.c 2004-03-17 19:43:32.675341400 +0100 +++ dev/apps/playlist_menu.c 2004-03-17 20:06:45.127589400 +0100 @@ -17,6 +17,7 @@ * ****************************************************************************/ +#if 0 #include #include "menu.h" @@ -79,3 +80,4 @@ menu_exit(m); return result; } +#endif --- orig/apps/playlist_viewer.c 2004-03-17 19:43:32.715399000 +0100 +++ dev/apps/playlist_viewer.c 2004-03-17 20:06:45.167647000 +0100 @@ -31,6 +31,7 @@ #include "keyboard.h" #include "tree.h" #include "onplay.h" +#include "action.h" #ifdef HAVE_LCD_BITMAP #include "widgets.h" @@ -735,7 +736,7 @@ break; case 2: { - onplay(tracks[index].name, TREE_ATTR_MPA); + onplay(tracks[index].name, TREE_ATTR_MPA, CONTEXT_TREE); if (!viewer.playlist) ret = 1; --- orig/apps/screens.c 2004-03-17 19:43:32.775485400 +0100 +++ dev/apps/screens.c 2004-03-17 20:06:45.207704600 +0100 @@ -38,6 +38,9 @@ #include "powermgmt.h" #include "adc.h" #include "action.h" +#include "tree.h" +#include "id3.h" +#include "onplay.h" #ifdef HAVE_LCD_BITMAP #define BMPHEIGHT_usb_logo 32 @@ -298,6 +301,7 @@ static int pitch = 1000; bool exit = false; bool used = false; + static struct mp3entry* id3 = NULL; while (!exit) { @@ -358,7 +362,9 @@ break; case BUTTON_ON | BUTTON_PLAY: - mpeg_pause(); + id3 = mpeg_current_track(); + onplay(id3->path, TREE_ATTR_MPA, CONTEXT_WPS); + exit = true; used = true; break; @@ -420,6 +426,11 @@ } } + if (global_settings.statusbar) + lcd_setmargins(0, STATUSBAR_HEIGHT); + else + lcd_setmargins(0, 0); + lcd_setfont(FONT_UI); if ( used ) --- orig/apps/settings_menu.c 2004-03-17 19:43:33.326277400 +0100 +++ dev/apps/settings_menu.c 2004-03-17 20:07:46.355631000 +0100 @@ -34,7 +34,6 @@ #include "backlight.h" #include "playlist.h" /* for playlist_shuffle */ #include "fat.h" /* For dotfile settings */ -#include "sleeptimer.h" #include "powermgmt.h" #include "rtc.h" #include "ata.h" @@ -858,11 +857,6 @@ return rockbox_browse(ROCKBOX_DIR, SHOW_WPS); } -static bool custom_cfg_browse(void) -{ - return rockbox_browse(ROCKBOX_DIR, SHOW_CFG); -} - static bool language_browse(void) { return rockbox_browse(ROCKBOX_DIR LANG_DIR, SHOW_LNG); @@ -962,55 +956,6 @@ return result; } -static bool reset_settings(void) -{ - bool done=false; - int line; - - lcd_clear_display(); - -#ifdef HAVE_LCD_CHARCELLS - line = 0; -#else - line = 1; - lcd_puts(0,0,str(LANG_RESET_ASK_RECORDER)); -#endif - lcd_puts(0,line,str(LANG_RESET_CONFIRM)); - lcd_puts(0,line+1,str(LANG_RESET_CANCEL)); - - lcd_update(); - - while(!done) { - switch(button_get(true)) { - case BUTTON_PLAY: - settings_reset(); - settings_apply(); - lcd_clear_display(); - lcd_puts(0,1,str(LANG_RESET_DONE_CLEAR)); - done = true; - break; - -#ifdef HAVE_RECORDER_KEYPAD - case BUTTON_OFF: -#else - case BUTTON_STOP: -#endif - lcd_clear_display(); - lcd_puts(0,1,str(LANG_RESET_DONE_CANCEL)); - done = true; - break; - - case SYS_USB_CONNECTED: - usb_screen(); - return true; - } - } - - lcd_puts(0,0,str(LANG_RESET_DONE_SETTING)); - lcd_update(); - sleep(HZ); - return false; -} static bool fileview_settings_menu(void) { @@ -1129,12 +1074,6 @@ return result; } - -static bool firmware_browse(void) -{ - return rockbox_browse(ROCKBOX_DIR, SHOW_MOD); -} - static bool battery_settings_menu(void) { int m; @@ -1195,25 +1134,6 @@ } #endif -static bool manage_settings_menu(void) -{ - int m; - bool result; - - struct menu_item items[] = { - { STR(LANG_CUSTOM_CFG), custom_cfg_browse }, - { STR(LANG_FIRMWARE), firmware_browse }, - { STR(LANG_RESET), reset_settings }, - { STR(LANG_SAVE_SETTINGS), settings_save_config }, - }; - - m=menu_init( items, sizeof(items) / sizeof(*items), NULL, - NULL, NULL, NULL); - result = menu_run(m); - menu_exit(m); - return result; -} - static bool limits_settings_menu(void) { int m; @@ -1244,7 +1164,6 @@ { STR(LANG_TIME_MENU), time_settings_menu }, #endif { STR(LANG_POWEROFF_IDLE), poweroff_idle_timer }, - { STR(LANG_SLEEP_TIMER), sleeptimer_screen }, #ifdef HAVE_ALARM_MOD { STR(LANG_ALARM_MOD_ALARM_MENU), alarm_screen }, #endif @@ -1253,7 +1172,6 @@ { STR(LANG_LINE_IN), line_in }, #endif { STR(LANG_CAR_ADAPTER_MODE), car_adapter_mode }, - { STR(LANG_MANAGE_MENU), manage_settings_menu }, }; m=menu_init( items, sizeof(items) / sizeof(*items), NULL, --- orig/apps/tree.c 2004-03-17 19:43:34.047314200 +0100 +++ dev/apps/tree.c 2004-03-17 20:06:45.407992600 +0100 @@ -792,7 +792,7 @@ int onplay_result; if(!numentries) - onplay_result = onplay(NULL, 0); + onplay_result = onplay(NULL, 0, CONTEXT_TREE); else { if (currdir[1]) snprintf(buf, sizeof buf, "%s/%s", @@ -801,7 +801,7 @@ snprintf(buf, sizeof buf, "/%s", dircache[dircursor+dirstart].name); onplay_result = onplay(buf, - dircache[dircursor+dirstart].attr); + dircache[dircursor+dirstart].attr, CONTEXT_TREE); } switch (onplay_result)