forked from len0rd/rockbox
Suggest numbered filename when saving untitled playlist
+ update misleading comment for catalog_add_to_a_playlist's m3u8name parameter (the keyboard picker will be shown even if it's not NULL) Change-Id: I7576a83fd40cdcdb7a912c90d8c1d9a8f25e277c
This commit is contained in:
parent
831faa3b82
commit
bdec7ed31b
4 changed files with 18 additions and 16 deletions
|
@ -39,6 +39,7 @@
|
|||
#include "playlist_catalog.h"
|
||||
#include "splash.h"
|
||||
#include "filetree.h"
|
||||
#include "general.h"
|
||||
|
||||
/* load a screen to save the playlist passed in (or current playlist if NULL is passed) */
|
||||
int save_playlist_screen(struct playlist_info* playlist)
|
||||
|
@ -54,29 +55,27 @@ int save_playlist_screen(struct playlist_info* playlist)
|
|||
char temp[MAX_PATH+1], *p;
|
||||
int len;
|
||||
|
||||
catalog_get_directory(directoryonly, sizeof(directoryonly));
|
||||
playlist_get_name(playlist, temp, sizeof(temp)-1);
|
||||
|
||||
len = strlen(temp);
|
||||
|
||||
if (len <= 1) /* root or dynamic playlist */
|
||||
{
|
||||
catalog_get_directory(temp, sizeof(temp));
|
||||
strlcat(temp, DEFAULT_DYNAMIC_PLAYLIST_NAME, sizeof(temp));
|
||||
}
|
||||
create_numbered_filename(temp, directoryonly, PLAYLIST_UNTITLED_PREFIX, ".m3u8",
|
||||
1 IF_CNFN_NUM_(, NULL));
|
||||
else if (!strcmp((temp + len - 1), "/")) /* dir playlists other than root */
|
||||
{
|
||||
temp[len - 1] = '\0';
|
||||
catalog_get_directory(directoryonly, sizeof(directoryonly));
|
||||
|
||||
if ((p = strrchr(temp, '/'))) /* use last path component as playlist name */
|
||||
{
|
||||
strlcat(directoryonly, p, sizeof(directoryonly));
|
||||
strlcat(directoryonly, ".m3u8", sizeof(directoryonly));
|
||||
strmemccpy(temp, directoryonly, sizeof(temp));
|
||||
}
|
||||
else
|
||||
strlcat(directoryonly, DEFAULT_DYNAMIC_PLAYLIST_NAME, sizeof(directoryonly));
|
||||
|
||||
strmemccpy(temp, directoryonly, sizeof(temp));
|
||||
create_numbered_filename(temp, directoryonly, PLAYLIST_UNTITLED_PREFIX, ".m3u8",
|
||||
1 IF_CNFN_NUM_(, NULL));
|
||||
}
|
||||
|
||||
if (catalog_pick_new_playlist_name(temp, sizeof(temp),
|
||||
|
|
|
@ -36,7 +36,7 @@
|
|||
|
||||
#define PLAYLIST_DISPLAY_COUNT 10
|
||||
|
||||
#define DEFAULT_DYNAMIC_PLAYLIST_NAME "/dynamic.m3u8"
|
||||
#define PLAYLIST_UNTITLED_PREFIX "Playlist "
|
||||
|
||||
#define PLAYLIST_FLAG_MODIFIED (1u << 0) /* playlist was manually modified */
|
||||
#define PLAYLIST_FLAG_DIRPLAY (1u << 1) /* enable directory skipping */
|
||||
|
|
|
@ -47,6 +47,7 @@
|
|||
#include "playlist_viewer.h"
|
||||
#include "bookmark.h"
|
||||
#include "root_menu.h"
|
||||
#include "general.h"
|
||||
|
||||
/* Use for recursive directory search */
|
||||
struct add_track_context {
|
||||
|
@ -464,14 +465,16 @@ bool catalog_add_to_a_playlist(const char* sel, int sel_attr,
|
|||
name = strrchr(sel, '/');
|
||||
|
||||
if (name == NULL || ((sel_attr & ATTR_DIRECTORY) != ATTR_DIRECTORY))
|
||||
name = "/";
|
||||
|
||||
create_numbered_filename(playlist, playlist, PLAYLIST_UNTITLED_PREFIX,
|
||||
".m3u8", 1 IF_CNFN_NUM_(, NULL));
|
||||
else
|
||||
{
|
||||
strlcat(playlist, name, sizeof(playlist));
|
||||
apply_playlist_extension(playlist, sizeof(playlist));
|
||||
}
|
||||
}
|
||||
else
|
||||
strmemccpy(playlist, m3u8name, MAX_PATH);
|
||||
|
||||
apply_playlist_extension(playlist, sizeof(playlist));
|
||||
strmemccpy(playlist, m3u8name, sizeof(playlist));
|
||||
|
||||
if (!catalog_pick_new_playlist_name(playlist, sizeof(playlist), NULL))
|
||||
return false;
|
||||
|
|
|
@ -43,7 +43,7 @@ bool catalog_pick_new_playlist_name(char *pl_name, size_t buf_size,
|
|||
* sel_attr : the attributes that tell what type of file we're adding
|
||||
* new_playlist : whether we want to create a new playlist or add to an
|
||||
* existing one.
|
||||
* m3u8name : filename to save the playlist to, NULL to show the keyboard
|
||||
* m3u8name : NULL, or filename to show in keyboard picker (include the extension!)
|
||||
* add_to_pl_cb : can be NULL, or a function responsible for handling the
|
||||
* insert operations itself, in case the caller wants full
|
||||
* control over how and what files are actually added.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue