Hide 'Add to Favorites' when viewing an entry of the favorites playlist

This commit is contained in:
jdgleaver 2021-07-02 16:29:11 +01:00
parent e1270742b9
commit 0e654c8e9e

View File

@ -2857,10 +2857,29 @@ static int menu_displaylist_parse_load_content_settings(
settings->bools.menu_content_show_favorites settings->bools.menu_content_show_favorites
) )
{ {
if (menu_entries_append_enum(list, bool add_to_favorites_enabled = true;
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_ADD_TO_FAVORITES),
msg_hash_to_str(MENU_ENUM_LABEL_ADD_TO_FAVORITES), /* Skip 'Add to Favourites' if we are currently
MENU_ENUM_LABEL_ADD_TO_FAVORITES, FILE_TYPE_PLAYLIST_ENTRY, 0, 0) ) * viewing an entry of the favourites playlist */
if (horizontal)
{
playlist_t *playlist = playlist_get_cached();
const char *playlist_path = playlist_get_conf_path(playlist);
const char *playlist_file = NULL;
if (!string_is_empty(playlist_path))
playlist_file = path_basename_nocompression(playlist_path);
if (!string_is_empty(playlist_file) &&
string_is_equal(playlist_file, FILE_PATH_CONTENT_FAVORITES))
add_to_favorites_enabled = false;
}
if (add_to_favorites_enabled &&
menu_entries_append_enum(list,
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_ADD_TO_FAVORITES),
msg_hash_to_str(MENU_ENUM_LABEL_ADD_TO_FAVORITES),
MENU_ENUM_LABEL_ADD_TO_FAVORITES, FILE_TYPE_PLAYLIST_ENTRY, 0, 0))
count++; count++;
} }
@ -3083,8 +3102,10 @@ static int menu_displaylist_parse_horizontal_content_actions(
} }
else else
{ {
const char *playlist_path = NULL;
const char *playlist_file = NULL;
#ifdef HAVE_AUDIOMIXER #ifdef HAVE_AUDIOMIXER
const char *ext = NULL; const char *ext = NULL;
if (entry && !string_is_empty(entry->path)) if (entry && !string_is_empty(entry->path))
ext = path_get_extension(entry->path); ext = path_get_extension(entry->path);
@ -3105,6 +3126,9 @@ static int menu_displaylist_parse_horizontal_content_actions(
FILE_TYPE_PLAYLIST_ENTRY, 0, idx); FILE_TYPE_PLAYLIST_ENTRY, 0, idx);
} }
#endif #endif
playlist_path = playlist_get_conf_path(playlist);
if (!string_is_empty(playlist_path))
playlist_file = path_basename_nocompression(playlist_path);
menu_entries_append_enum(info->list, menu_entries_append_enum(info->list,
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_RUN), msg_hash_to_str(MENU_ENUM_LABEL_VALUE_RUN),
@ -3147,19 +3171,11 @@ static int menu_displaylist_parse_horizontal_content_actions(
* This breaks the above 'remove_entry_enabled' check for the * This breaks the above 'remove_entry_enabled' check for the
* history and favorites playlists. We therefore have to check * history and favorites playlists. We therefore have to check
* the playlist file name as well... */ * the playlist file name as well... */
if (!remove_entry_enabled && settings->bools.quick_menu_show_information) if (!remove_entry_enabled &&
{ settings->bools.quick_menu_show_information &&
const char *playlist_path = playlist_get_conf_path(playlist); !string_is_empty(playlist_file))
remove_entry_enabled = string_is_equal(playlist_file, FILE_PATH_CONTENT_HISTORY) ||
if (!string_is_empty(playlist_path)) string_is_equal(playlist_file, FILE_PATH_CONTENT_FAVORITES);
{
const char *playlist_file = path_basename_nocompression(playlist_path);
if (!string_is_empty(playlist_file))
remove_entry_enabled = string_is_equal(playlist_file, FILE_PATH_CONTENT_HISTORY) ||
string_is_equal(playlist_file, FILE_PATH_CONTENT_FAVORITES);
}
}
} }
break; break;
} }
@ -3172,9 +3188,13 @@ static int menu_displaylist_parse_horizontal_content_actions(
MENU_SETTING_ACTION_DELETE_ENTRY, 0, 0); MENU_SETTING_ACTION_DELETE_ENTRY, 0, 0);
} }
/* Skip 'Add to Favourites' if we are currently
* viewing an entry of the favourites playlist */
if ( if (
settings->bools.quick_menu_show_add_to_favorites && settings->bools.quick_menu_show_add_to_favorites &&
settings->bools.menu_content_show_favorites settings->bools.menu_content_show_favorites &&
!(!string_is_empty(playlist_file) &&
string_is_equal(playlist_file, FILE_PATH_CONTENT_FAVORITES))
) )
{ {
menu_entries_append_enum(info->list, menu_entries_append_enum(info->list,