diff --git a/apps/bookmark.c b/apps/bookmark.c index 0cc2807609..20841b4940 100644 --- a/apps/bookmark.c +++ b/apps/bookmark.c @@ -441,27 +441,31 @@ static char* create_bookmark() /* ----------------------------------------------------------------------- */ /* This function will determine if an autoload is necessary. This is an */ /* interface function. */ -/* Returns true on bookmark load or bookmark selection. */ +/* Returns */ +/* BOOKMARK_DO_RESUME on bookmark load or bookmark selection. */ +/* BOOKMARK_DONT_RESUME if we're not going to resume */ +/* BOOKMARK_CANCEL if user canceled */ /* ------------------------------------------------------------------------*/ -bool bookmark_autoload(const char* file) +int bookmark_autoload(const char* file) { char* bookmark; if(global_settings.autoloadbookmark == BOOKMARK_NO) - return false; + return BOOKMARK_DONT_RESUME; /*Checking to see if a bookmark file exists.*/ if(!generate_bookmark_file_name(file)) { - return false; + return BOOKMARK_DONT_RESUME; } if(!file_exists(global_bookmark_file_name)) - return false; + return BOOKMARK_DONT_RESUME; if(global_settings.autoloadbookmark == BOOKMARK_YES) { - return bookmark_load(global_bookmark_file_name, true); + return bookmark_load(global_bookmark_file_name, true) ? BOOKMARK_DO_RESUME : + BOOKMARK_DONT_RESUME; } else { @@ -478,10 +482,10 @@ bool bookmark_autoload(const char* file) /* Act as if autoload was done even if it failed, since the * user did make an active selection. */ - return true; + return BOOKMARK_DO_RESUME; } - return ret != BOOKMARK_SUCCESS; + return ret != BOOKMARK_SUCCESS ? BOOKMARK_CANCEL : BOOKMARK_DONT_RESUME; } } diff --git a/apps/bookmark.h b/apps/bookmark.h index ff7b87c1bf..192e577ce6 100644 --- a/apps/bookmark.h +++ b/apps/bookmark.h @@ -29,11 +29,17 @@ enum { BOOKMARK_USB_CONNECTED = 1 }; +enum { + BOOKMARK_CANCEL, + BOOKMARK_DONT_RESUME, + BOOKMARK_DO_RESUME +}; + int bookmark_load_menu(void); bool bookmark_autobookmark(bool prompt_ok); bool bookmark_create_menu(void); bool bookmark_mrb_load(void); -bool bookmark_autoload(const char* file); +int bookmark_autoload(const char* file); bool bookmark_load(const char* file, bool autoload); bool bookmark_exists(void); bool bookmark_is_bookmarkable_state(void); diff --git a/apps/filetree.c b/apps/filetree.c index 06d92bc944..dbdcef6820 100644 --- a/apps/filetree.c +++ b/apps/filetree.c @@ -100,7 +100,8 @@ bool ft_play_playlist(char* pathname, char* dirname, if (!skip_warn_and_bookmarks) { - if (bookmark_autoload(pathname) || !warn_on_pl_erase()) + int res = bookmark_autoload(pathname); + if (res == BOOKMARK_CANCEL || res == BOOKMARK_DO_RESUME || !warn_on_pl_erase()) return false; } @@ -481,7 +482,9 @@ int ft_enter(struct tree_context* c) break; case FILE_ATTR_AUDIO: - if (bookmark_autoload(c->currdir)) + { + int res = bookmark_autoload(c->currdir); + if (res == BOOKMARK_CANCEL || res == BOOKMARK_DO_RESUME) break; splash(0, ID2P(LANG_WAIT)); @@ -515,7 +518,7 @@ int ft_enter(struct tree_context* c) play = true; } break; - + } #if CONFIG_TUNER /* fmr preset file */ case FILE_ATTR_FMR: diff --git a/apps/onplay.c b/apps/onplay.c index 8507699bd3..0bb3b6ae3c 100644 --- a/apps/onplay.c +++ b/apps/onplay.c @@ -588,12 +588,11 @@ static int add_to_playlist(void* arg) static bool view_playlist(void) { - bool was_playing = audio_status() & AUDIO_STATUS_PLAY; bool result; result = playlist_viewer_ex(selected_file); - if (!was_playing && (audio_status() & AUDIO_STATUS_PLAY) && + if (result == PLAYLIST_VIEWER_OK && onplay_result == ONPLAY_OK) /* playlist was started from viewer */ onplay_result = ONPLAY_START_PLAY; diff --git a/apps/playlist_catalog.c b/apps/playlist_catalog.c index 0813db11c6..65a48611c0 100644 --- a/apps/playlist_catalog.c +++ b/apps/playlist_catalog.c @@ -46,6 +46,7 @@ #include "talk.h" #include "playlist_viewer.h" #include "bookmark.h" +#include "root_menu.h" /* Use for recursive directory search */ struct add_track_context { @@ -160,7 +161,8 @@ static int display_playlists(char* playlist, bool view) restart: browse.flags &= ~BROWSE_SELECTED; - rockbox_browse(&browse); + if (rockbox_browse(&browse) == GO_TO_WPS) + result = 0; if (browse.flags & BROWSE_SELECTED) { @@ -169,13 +171,24 @@ restart: if (view) { - - if (!bookmark_autoload(selected_playlist)) + + int res = bookmark_autoload(selected_playlist); + if (res == BOOKMARK_DO_RESUME) + result = 0; + else { - if (playlist_viewer_ex(selected_playlist) == PLAYLIST_VIEWER_CANCEL) - goto restart; + switch (playlist_viewer_ex(selected_playlist)) { + case PLAYLIST_VIEWER_OK: + result = 0; + break; + case PLAYLIST_VIEWER_CANCEL: + goto restart; + case PLAYLIST_VIEWER_USB: + case PLAYLIST_VIEWER_MAINMENU: + default: + break; + } } - result = 0; } else { diff --git a/apps/playlist_catalog.h b/apps/playlist_catalog.h index 2e317128b7..17efd0ea7e 100644 --- a/apps/playlist_catalog.h +++ b/apps/playlist_catalog.h @@ -29,7 +29,7 @@ void catalog_set_directory(const char* directory); /* * View list of playlists in catalog. - * ret : true if no error + * ret : true if item was selected */ bool catalog_view_playlists(void); diff --git a/apps/playlist_viewer.c b/apps/playlist_viewer.c index 6c80b373a9..e3faf4b68f 100644 --- a/apps/playlist_viewer.c +++ b/apps/playlist_viewer.c @@ -820,7 +820,10 @@ enum playlist_viewer_result playlist_viewer_ex(const char* filename) struct gui_synclist playlist_lists; if (!open_playlist_viewer(filename, &playlist_lists, false)) + { + ret = PLAYLIST_VIEWER_CANCEL; goto exit; + } while (!exit) { @@ -958,10 +961,17 @@ enum playlist_viewer_result playlist_viewer_ex(const char* filename) else if (pv_onplay_result == PV_ONPLAY_CLOSED) { if (!open_playlist_viewer(filename, &playlist_lists, true)) + { + ret = PLAYLIST_VIEWER_CANCEL; goto exit; + } break; } - exit = update_viewer_with_changes(&playlist_lists, pv_onplay_result); + if (update_viewer_with_changes(&playlist_lists, pv_onplay_result)) + { + exit = true; + ret = PLAYLIST_VIEWER_CANCEL; + } break; } case ACTION_STD_MENU: @@ -996,7 +1006,10 @@ enum playlist_viewer_result playlist_viewer_ex(const char* filename) if (do_plugin(current_track) == PV_ONPLAY_USB_CLOSED) return PLAYLIST_VIEWER_USB; else if (!open_playlist_viewer(filename, &playlist_lists, true)) + { + ret = PLAYLIST_VIEWER_CANCEL; goto exit; + } } else if (global_settings.hotkey_tree == HOTKEY_PROPERTIES) { @@ -1008,10 +1021,16 @@ enum playlist_viewer_result playlist_viewer_ex(const char* filename) update_lists(&playlist_lists); } else if (global_settings.hotkey_tree == HOTKEY_DELETE) - exit = update_viewer_with_changes(&playlist_lists, + { + if (update_viewer_with_changes(&playlist_lists, delete_track(current_track->index, viewer.selected_track, - (current_track->index == viewer.current_playing_track))); + (current_track->index == viewer.current_playing_track)))) + { + ret = PLAYLIST_VIEWER_CANCEL; + exit = true; + } + } else onplay(current_track->name, FILE_ATTR_AUDIO, CONTEXT_STD, true); break; diff --git a/apps/root_menu.c b/apps/root_menu.c index c70237fdf7..895d5a667b 100644 --- a/apps/root_menu.c +++ b/apps/root_menu.c @@ -366,13 +366,11 @@ static int miscscrn(void * param) static int playlist_view_catalog(void * param) { - /* kludge untill catalog_view_playlists() returns something useful */ - int old_playstatus = audio_status(); (void)param; push_current_activity(ACTIVITY_PLAYLISTBROWSER); - catalog_view_playlists(); + bool item_was_selected = catalog_view_playlists(); pop_current_activity(); - if (!old_playstatus && audio_status()) + if (item_was_selected) return GO_TO_WPS; return GO_TO_PREVIOUS; }