1
0
Fork 0
forked from len0rd/rockbox

Hide Bookmark menu for new dynamically generated playlists

The bookmark menu with the option to create a bookmark
was inadvertently displayed for new dynamic playlists,
that had no associated folder or playlist file on disk.
(e.g. after selecting some track from the database for
playback), until the playlist was modified by the user.

Change-Id: I9d6809e4d03603c651459415327f28e38162ad53
This commit is contained in:
Christian Soffke 2023-09-21 07:45:13 +02:00
parent a0c29d8857
commit 75befe19ef
3 changed files with 23 additions and 3 deletions

View file

@ -1291,7 +1291,8 @@ bool bookmark_exists(void)
char* name = playlist_get_name(NULL, global_temp_buffer, char* name = playlist_get_name(NULL, global_temp_buffer,
sizeof(global_temp_buffer)); sizeof(global_temp_buffer));
if (generate_bookmark_file_name(bm_filename, sizeof(bm_filename), name, -1)) if (!playlist_dynamic_only() &&
generate_bookmark_file_name(bm_filename, sizeof(bm_filename), name, -1))
{ {
exist = file_exists(bm_filename); exist = file_exists(bm_filename);
} }
@ -1311,8 +1312,10 @@ bool bookmark_is_bookmarkable_state(void)
/* no track playing */ /* no track playing */
(playlist_get_resume_info(&resume_index) == -1) || (playlist_get_resume_info(&resume_index) == -1) ||
/* invalid queue info */ /* invalid queue info */
(playlist_modified(NULL))) (playlist_modified(NULL)) ||
/* can't bookmark while in the queue */ /* can't bookmark playlists modified by user */
(playlist_dynamic_only()))
/* can't bookmark playlists without associated folder or playlist file */
{ {
return false; return false;
} }

View file

@ -2698,6 +2698,22 @@ bool playlist_allow_dirplay(const struct playlist_info *playlist)
return !!(playlist->flags & PLAYLIST_FLAG_DIRPLAY); return !!(playlist->flags & PLAYLIST_FLAG_DIRPLAY);
} }
/*
* Returns true if the current playlist is neither
* associated with a folder nor with an on-disk playlist.
*/
bool playlist_dynamic_only(void)
{
/* NOTE: New dynamic playlists currently use root dir ("/")
* as their placeholder filename this could change.
*/
if (!strcmp(current_playlist.filename, "/") &&
!(current_playlist.flags & PLAYLIST_FLAG_DIRPLAY))
return true;
return false;
}
/* /*
* Move track at index to new_index. Tracks between the two are shifted * Move track at index to new_index. Tracks between the two are shifted
* appropriately. Returns 0 on success and -1 on failure. * appropriately. Returns 0 on success and -1 on failure.

View file

@ -133,6 +133,7 @@ int playlist_get_display_index(void);
int playlist_amount(void); int playlist_amount(void);
void playlist_set_last_shuffled_start(void); void playlist_set_last_shuffled_start(void);
struct playlist_info *playlist_get_current(void); struct playlist_info *playlist_get_current(void);
bool playlist_dynamic_only(void);
/* Exported functions for all playlists. Pass NULL for playlist_info /* Exported functions for all playlists. Pass NULL for playlist_info
structure to work with current playlist. */ structure to work with current playlist. */