summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMagnus Holmgren <magnushol@gmail.com>2007-10-30 17:38:21 +0000
committerMagnus Holmgren <magnushol@gmail.com>2007-10-30 17:38:21 +0000
commitfabdd384e610e0b6d744eaea361c1045df390065 (patch)
tree76d25c468a2f93208c52eee2265af22db2bceeb2
parent09bce70f17614563df09dedd82cff31298fb1a09 (diff)
downloadrockbox-fabdd384e610e0b6d744eaea361c1045df390065.tar.gz
rockbox-fabdd384e610e0b6d744eaea361c1045df390065.zip
Make the playlist catalog use the following settings as appropriate: show filename extensions, load last bookmark, party mode and warn when erasing dynamic playlist.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@15378 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--apps/filetree.c80
-rw-r--r--apps/filetree.h1
-rw-r--r--apps/playlist_catalog.c28
3 files changed, 70 insertions, 39 deletions
diff --git a/apps/filetree.c b/apps/filetree.c
index 35be92e4b5..edd421cad9 100644
--- a/apps/filetree.c
+++ b/apps/filetree.c
@@ -79,6 +79,55 @@ int ft_build_playlist(struct tree_context* c, int start_index)
return start_index;
}
+/* Start playback of a playlist, checking for bookmark autoload, modified
+ * playlists, etc., as required. Returns false if playback wasn't started,
+ * or started via bookmark autoload, true otherwise.
+ *
+ * Pointers to both the full pathname and the separated parts needed to
+ * avoid allocating yet another path buffer on the stack (and save some
+ * code; the caller typically needs to create the full pathname anyway)...
+ */
+bool ft_play_playlist(char* pathname, char* dirname, char* filename)
+{
+ if (global_settings.party_mode)
+ {
+ gui_syncsplash(HZ, ID2P(LANG_PARTY_MODE));
+ return false;
+ }
+
+ if (bookmark_autoload(pathname))
+ {
+ return false;
+ }
+
+ gui_syncsplash(0, ID2P(LANG_WAIT));
+
+ /* about to create a new current playlist...
+ allow user to cancel the operation */
+ if (global_settings.warnon_erase_dynplaylist &&
+ playlist_modified(NULL))
+ {
+ char *lines[] = {ID2P(LANG_WARN_ERASEDYNPLAYLIST_PROMPT)};
+ struct text_message message = {lines, 1};
+
+ if (gui_syncyesno_run(&message, NULL, NULL) != YESNO_YES)
+ return false;
+ }
+
+ if (playlist_create(dirname, filename) != -1)
+ {
+ if (global_settings.playlist_shuffle)
+ {
+ playlist_shuffle(current_tick, -1);
+ }
+
+ playlist_start(0, 0);
+ return true;
+ }
+
+ return false;
+}
+
/* walk a directory and check all dircache entries if a .talk file exists */
static void check_file_thumbnails(struct tree_context* c)
{
@@ -341,36 +390,13 @@ int ft_enter(struct tree_context* c)
switch ( file->attr & FILE_ATTR_MASK ) {
case FILE_ATTR_M3U:
- if (global_settings.party_mode) {
- gui_syncsplash(HZ, ID2P(LANG_PARTY_MODE));
- break;
- }
-
- if (bookmark_autoload(buf))
- break;
-
- gui_syncsplash(0, ID2P(LANG_WAIT));
-
- /* about to create a new current playlist...
- allow user to cancel the operation */
- if (global_settings.warnon_erase_dynplaylist &&
- playlist_modified(NULL))
+ play = ft_play_playlist(buf, c->currdir, file->name);
+
+ if (play)
{
- char *lines[]={ID2P(LANG_WARN_ERASEDYNPLAYLIST_PROMPT)};
- struct text_message message={lines, 1};
-
- if(gui_syncyesno_run(&message, NULL, NULL) != YESNO_YES)
- break;
- }
-
- if (playlist_create(c->currdir, file->name) != -1)
- {
- if (global_settings.playlist_shuffle)
- playlist_shuffle(seed, -1);
start_index = 0;
- playlist_start(start_index,0);
- play = true;
}
+
break;
case FILE_ATTR_AUDIO:
diff --git a/apps/filetree.h b/apps/filetree.h
index 66fbbb579a..c9d1157fe9 100644
--- a/apps/filetree.h
+++ b/apps/filetree.h
@@ -24,5 +24,6 @@ int ft_load(struct tree_context* c, const char* tempdir);
int ft_enter(struct tree_context* c);
int ft_exit(struct tree_context* c);
int ft_build_playlist(struct tree_context* c, int start_index);
+bool ft_play_playlist(char* pathname, char* dirname, char* filename);
#endif
diff --git a/apps/playlist_catalog.c b/apps/playlist_catalog.c
index fda91bb1ee..f5c5bcb35b 100644
--- a/apps/playlist_catalog.c
+++ b/apps/playlist_catalog.c
@@ -38,6 +38,7 @@
#include "tree.h"
#include "yesno.h"
#include "filetypes.h"
+#include "debug.h"
#define PLAYLIST_CATALOG_CFG ROCKBOX_DIR "/playlist_catalog.config"
#define PLAYLIST_CATALOG_DEFAULT_DIR "/Playlists"
@@ -212,6 +213,18 @@ static char* playlist_callback_name(int selected_item, void* data,
strncpy(buffer, playlists[selected_item], MAX_PATH);
+ if (buffer[0] != '.' && !(global_settings.show_filename_ext == 1
+ || (global_settings.show_filename_ext == 3
+ && global_settings.dirfilter == 0)))
+ {
+ char* dot = strrchr(buffer, '.');
+
+ if (dot != NULL)
+ {
+ *dot = '\0';
+ }
+ }
+
return buffer;
}
@@ -260,21 +273,12 @@ static int display_playlists(char* playlist, bool view)
break;
case ACTION_STD_OK:
+ snprintf(playlist, MAX_PATH, "%s/%s", playlist_dir, sel_file);
+
if (view)
{
/* In view mode, selecting a playlist starts playback */
- if (playlist_create(playlist_dir, sel_file) != -1)
- {
- if (global_settings.playlist_shuffle)
- playlist_shuffle(current_tick, -1);
- playlist_start(0, 0);
- }
- }
- else
- {
- /* we found the playlist we want to add to */
- snprintf(playlist, MAX_PATH, "%s/%s", playlist_dir,
- sel_file);
+ ft_play_playlist(playlist, playlist_dir, sel_file);
}
result = 0;