Skip to content

Commit

Permalink
Minor thumbnail improvements
Browse files Browse the repository at this point in the history
- set standard name if only one entry is in the playlist
- use first database name for thumbnails if core has multiple
  • Loading branch information
zoltanvb committed Dec 31, 2023
1 parent ab376eb commit 3b2894f
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
17 changes: 13 additions & 4 deletions gfx/gfx_thumbnail_path.c
Original file line number Diff line number Diff line change
Expand Up @@ -500,10 +500,19 @@ bool gfx_thumbnail_set_content_playlist(
{
char *db_name_no_ext = NULL;
char tmp_buf[PATH_MAX_LENGTH];
/* Remove .lpl extension
* > path_remove_extension() requires a char * (not const)
* so have to use a temporary buffer... */
strlcpy(tmp_buf, db_name, sizeof(tmp_buf));
const char* pos = strchr(db_name, '|');

if (pos && (size_t) (pos - db_name)+1 < sizeof(tmp_buf)) {
/* If db_name comes from core info, and there are multiple
* databases mentioned separated by |, use only first one */
strlcpy(tmp_buf, db_name, (size_t) (pos - db_name)+1);
}
else {
/* Remove .lpl extension
* > path_remove_extension() requires a char * (not const)
* so have to use a temporary buffer... */
strlcpy(tmp_buf, db_name, sizeof(tmp_buf));
}
db_name_no_ext = path_remove_extension(tmp_buf);

if (!string_is_empty(db_name_no_ext))
Expand Down
5 changes: 5 additions & 0 deletions playlist.c
Original file line number Diff line number Diff line change
Expand Up @@ -1097,6 +1097,11 @@ enum playlist_thumbnail_name_flags playlist_get_next_thumbnail_name_flag(playlis
return PLAYLIST_THUMBNAIL_FLAG_SHORT_NAME;
if (entry->thumbnail_flags & PLAYLIST_THUMBNAIL_FLAG_FULL_NAME)
return PLAYLIST_THUMBNAIL_FLAG_STD_NAME;
/* Special case: only one entry in playlist, only one query is possible
* as flag swapping relies on going back and forth among entries
* so just use the most likely version here */
if (idx == 0 && RBUF_LEN(playlist->entries) == 1)
return PLAYLIST_THUMBNAIL_FLAG_STD_NAME;
return PLAYLIST_THUMBNAIL_FLAG_FULL_NAME;
}

Expand Down

0 comments on commit 3b2894f

Please sign in to comment.