FS#9677 - Change the erase dynamic playlist warning to a menu with several options including a quick save

Attached to Project: Rockbox
Opened by Alex Bennee (ajb) - Friday, 19 December 2008, 10:26 GMT
Last edited by Nils Wallménius (nls) - Friday, 19 December 2008, 13:35 GMT
Task Type Patches
Category Playlists
Status Unconfirmed
Assigned To No-one
Operating System All players
Severity Low
Priority Normal
Reported Version Release 3.0
Due in Version Undecided
Due Date Undecided
Percent Complete 0%
Votes 0
Private No


As discussed on the mailing list this patch gets rid of the "About to Erase Dynamic Playlist" warning and replaces it with a menu option to save the current playlist under it's existing name.

The attached patch is a first cut for review as I'm just getting used to the menu system. If people think it's the right way to go I'll clean it up properly. Any suggestions for tweaks to the functionality also welcome.
This task depends upon

Comment by Steve Bavin (pondlife) - Friday, 19 December 2008, 10:56 GMT
I'd think that the warning/menu should be inside warn_on_pl_erase() (or it's replacement).

Also, this should be called just before each call to playlist_create() that refers to the current playlist - there may currently be paths through the code where the warning doesn't occur, yet the playlist is lost.

(Note the warning code can't be inside playlist._create() itself, as playlist.c shouldn't have any UI code at all.)
Comment by Marc Guay (Marc_Guay) - Friday, 19 December 2008, 13:48 GMT
The question "Erase dynamic playlist?" should also be reworded. The playlist is not always necessarily "dynamic" (if you've loaded a playlist file and simply made changes). Something akin to "Save changes to playlist?" could work.
Comment by Jonas Häggqvist (rasher) - Friday, 19 December 2008, 17:54 GMT
How about "Save current playlist?"?
Comment by Alex Bennee (ajb) - Tuesday, 23 December 2008, 17:52 GMT
Can you clarify what you mean by the menu being inside "warn_on_pl_erase() (or it's replacement). "?

I shall see where else playlist_create is called.
Comment by Alex Bennee (ajb) - Wednesday, 24 December 2008, 09:28 GMT
So far there are two functions which call playlist create which I
don't seem to be able to access via the menues. These are
onplay.c:add_to_playlist and playlist.c:create_and_play_dir. Any
pointers as to where I trigger them from?

Currently starting a bookmark will kill the current playlist via
bookmark_play which I shall endeavour to fix once I've decoded the logic.
Comment by Alex Bennee (ajb) - Thursday, 01 January 2009, 20:58 GMT
Latest version:

* Changed order of questions and tweaked phrasing
* Common name funging code: Only issue is it would be nicer to calculate the whole path once for the input to the menu and the actual write.
Comment by Bertrik Sikken (bertrik) - Sunday, 04 January 2009, 15:43 GMT
Does this patch add any new functionality, or is it basically a convenience?
What does "funge" mean?
I see you disable some old code with an "#if 0". IMO, if code is really no longer used, it should simply be removed instead of lingering on in an #if 0.
Comment by Alex Bennee (ajb) - Sunday, 04 January 2009, 18:10 GMT
Basically it saves you navigation key presses. If you want to save
your current playlist you can do that straight from the warning menu
rather than canceling and going to the save menu.

The option to save as the current playlist name is also better.

I shall find a better name for the funge function and remove the #if 0
code in the next version.
Comment by Alex Bennee (ajb) - Monday, 19 January 2009, 17:48 GMT

Re-factored to get rid of badly named "funge" function
Cleaned up commentary for menus
Removed unneeded passing of variables
Comment by Alex Bennee (ajb) - Monday, 19 January 2009, 18:52 GMT

Don't pass playlist * when we don't need to. It gets confusing otherwise.
Comment by Alex Bennee (ajb) - Sunday, 06 December 2009, 20:48 GMT
OK this patch has been sitting around for around a year now. If no one is interested in reviewing it I shan't bother pushing for inclusion and just carry it in my tree from now on.

The patch has been re-based and re-tested on the current SVN head.
Comment by Dominik Wenger (Domonoky) - Sunday, 06 December 2009, 21:34 GMT
I took a short look at this patch. I think the principle is nice, and should get commited.

a few remarks:
- playlist_maybe_save_current() sounds strange, maybe playlist_try_save_current() would sound better ? (not really important)
- You change some lang entrys (especially a id) instead of depreciating the old one, and adding new ones. I am not sure if its save to change .lang entry, it could break language tools and voicefiles.
- A Cancel action in the new menu would be nice.

Otherwise i am not sure if the code is ok, because i am not really a expert in this area.
Comment by Alex Bennee (ajb) - Sunday, 06 December 2009, 22:55 GMT
Updates following review:

* Made all use of LANG entries new (not re-using old IDs)
* Added Cancel option

I left the playlist_maybe_save_current() as I'm not sure playlist_try_save_current() is much better.
Comment by Alexander Levin (fml2) - Friday, 11 December 2009, 23:32 GMT
I also like the idea of this patch. I can't tell whether it's cleanly made since I don't know this code area, but if it works (who have tested it and on what players?) it should IMO be committed.
Comment by Alex Bennee (ajb) - Sunday, 13 December 2009, 17:02 GMT
As far as I know as the author I'm the only one who has tested it on my iPod 5.5G . However I've had it in my tree for almost a year without issue as well as smoketesting it with Valgrind on the simulator. I would welcome more people testing.