summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Soffke <christian.soffke@gmail.com>2023-09-21 07:45:13 +0200
committerChristian Soffke <christian.soffke@gmail.com>2023-10-10 12:03:52 -0400
commit75befe19ef1bea25f1eca9fd4884835dfd1694a2 (patch)
treea6b51c263a220cc58db96ecee6a0eb7980ffea8d
parenta0c29d8857ee3c697a9c7f8b396b3a25c88acab4 (diff)
downloadrockbox-75befe19ef1bea25f1eca9fd4884835dfd1694a2.tar.gz
rockbox-75befe19ef1bea25f1eca9fd4884835dfd1694a2.zip
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
-rw-r--r--apps/bookmark.c9
-rw-r--r--apps/playlist.c16
-rw-r--r--apps/playlist.h1
3 files changed, 23 insertions, 3 deletions
diff --git a/apps/bookmark.c b/apps/bookmark.c
index 0b468bdb76..3db049475d 100644
--- a/apps/bookmark.c
+++ b/apps/bookmark.c
@@ -1291,7 +1291,8 @@ bool bookmark_exists(void)
1291 1291
1292 char* name = playlist_get_name(NULL, global_temp_buffer, 1292 char* name = playlist_get_name(NULL, global_temp_buffer,
1293 sizeof(global_temp_buffer)); 1293 sizeof(global_temp_buffer));
1294 if (generate_bookmark_file_name(bm_filename, sizeof(bm_filename), name, -1)) 1294 if (!playlist_dynamic_only() &&
1295 generate_bookmark_file_name(bm_filename, sizeof(bm_filename), name, -1))
1295 { 1296 {
1296 exist = file_exists(bm_filename); 1297 exist = file_exists(bm_filename);
1297 } 1298 }
@@ -1311,8 +1312,10 @@ bool bookmark_is_bookmarkable_state(void)
1311 /* no track playing */ 1312 /* no track playing */
1312 (playlist_get_resume_info(&resume_index) == -1) || 1313 (playlist_get_resume_info(&resume_index) == -1) ||
1313 /* invalid queue info */ 1314 /* invalid queue info */
1314 (playlist_modified(NULL))) 1315 (playlist_modified(NULL)) ||
1315 /* can't bookmark while in the queue */ 1316 /* can't bookmark playlists modified by user */
1317 (playlist_dynamic_only()))
1318 /* can't bookmark playlists without associated folder or playlist file */
1316 { 1319 {
1317 return false; 1320 return false;
1318 } 1321 }
diff --git a/apps/playlist.c b/apps/playlist.c
index 554e1afd7e..4440c77dbf 100644
--- a/apps/playlist.c
+++ b/apps/playlist.c
@@ -2699,6 +2699,22 @@ bool playlist_allow_dirplay(const struct playlist_info *playlist)
2699} 2699}
2700 2700
2701/* 2701/*
2702 * Returns true if the current playlist is neither
2703 * associated with a folder nor with an on-disk playlist.
2704 */
2705bool playlist_dynamic_only(void)
2706{
2707 /* NOTE: New dynamic playlists currently use root dir ("/")
2708 * as their placeholder filename – this could change.
2709 */
2710 if (!strcmp(current_playlist.filename, "/") &&
2711 !(current_playlist.flags & PLAYLIST_FLAG_DIRPLAY))
2712 return true;
2713
2714 return false;
2715}
2716
2717/*
2702 * Move track at index to new_index. Tracks between the two are shifted 2718 * Move track at index to new_index. Tracks between the two are shifted
2703 * appropriately. Returns 0 on success and -1 on failure. 2719 * appropriately. Returns 0 on success and -1 on failure.
2704 */ 2720 */
diff --git a/apps/playlist.h b/apps/playlist.h
index 4c8800e594..101a3c1207 100644
--- a/apps/playlist.h
+++ b/apps/playlist.h
@@ -133,6 +133,7 @@ int playlist_get_display_index(void);
133int playlist_amount(void); 133int playlist_amount(void);
134void playlist_set_last_shuffled_start(void); 134void playlist_set_last_shuffled_start(void);
135struct playlist_info *playlist_get_current(void); 135struct playlist_info *playlist_get_current(void);
136bool playlist_dynamic_only(void);
136 137
137/* Exported functions for all playlists. Pass NULL for playlist_info 138/* Exported functions for all playlists. Pass NULL for playlist_info
138 structure to work with current playlist. */ 139 structure to work with current playlist. */