summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian Soffke <christian.soffke@gmail.com>2023-10-14 18:40:04 +0200
committerChristian Soffke <christian.soffke@gmail.com>2023-10-28 18:24:00 -0400
commitbdec7ed31b4bef2189f7e4a59abda74166f562a5 (patch)
tree4fca81a1c8364257e46459c14df0356f70ab4dab
parent831faa3b82a8c3bfb3241e60641bf783adba4d4a (diff)
downloadrockbox-bdec7ed31b.tar.gz
rockbox-bdec7ed31b.zip
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
-rw-r--r--apps/menus/playlist_menu.c15
-rw-r--r--apps/playlist.h2
-rw-r--r--apps/playlist_catalog.c15
-rw-r--r--apps/playlist_catalog.h2
4 files changed, 18 insertions, 16 deletions
diff --git a/apps/menus/playlist_menu.c b/apps/menus/playlist_menu.c
index 87ed7428ea..e527e3ebef 100644
--- a/apps/menus/playlist_menu.c
+++ b/apps/menus/playlist_menu.c
@@ -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),
diff --git a/apps/playlist.h b/apps/playlist.h
index 0dc5148acd..c7b672a2ef 100644
--- a/apps/playlist.h
+++ b/apps/playlist.h
@@ -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 */
diff --git a/apps/playlist_catalog.c b/apps/playlist_catalog.c
index 0cf9d2e09d..1bd4b7ee13 100644
--- a/apps/playlist_catalog.c
+++ b/apps/playlist_catalog.c
@@ -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 = "/";
-
- strlcat(playlist, name, sizeof(playlist));
+ 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;
diff --git a/apps/playlist_catalog.h b/apps/playlist_catalog.h
index 756a1e1129..f455ef7ebc 100644
--- a/apps/playlist_catalog.h
+++ b/apps/playlist_catalog.h
@@ -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.