mirror of
https://github.com/Rockbox/rockbox.git
synced 2025-11-09 21:22:39 -05:00
Playlist Viewer: slight simplification
1) Don't re-initialize the Playlist Viewer before closing it, after making an on-disk playlist the current playlist. It's obviously wasteful and this seems to have only historical reasons that don't apply anymore. 2) Naming adjustments: - change "onplay" prefix to "context" (e.g. pv_context_result context_menu, instead of pv_onplay_result onplay_menu), since onplay requires being aware of the history for it to make any sense - rename update_lists to update_gui, to differentiate it from update_playlist - change update_viewer_with_changes to update_viewer 3) gui_synclist_del_item(playlist_lists) is not needed anymore after removing a track, because we already indiscriminately reset the synclist's number of items and reselect within the list's new bounds from update_viewer_with_changes. As a result, MODIFIED is applicable to both reshuffling and to removing a track, so ITEM_REMOVED can be eliminated as its own enum value. Plus, SAVED does not require a special case and can be renamed to PL_UPDATE, so it is usable when track display is adjusted, in order to force an update of the playlist buffer. Change-Id: Ic5202e03223a1ddbb9ff87e388a16ecde39165ef
This commit is contained in:
parent
6a865f2430
commit
00066a4927
1 changed files with 121 additions and 155 deletions
|
|
@ -71,7 +71,7 @@ struct playlist_entry {
|
||||||
char *name; /* track path */
|
char *name; /* track path */
|
||||||
int index; /* Playlist index */
|
int index; /* Playlist index */
|
||||||
int display_index; /* Display index */
|
int display_index; /* Display index */
|
||||||
int attr; /* Is track queued?; Is track marked as bad?*/
|
int attr; /* Is track queued?; Is track marked as bad? */
|
||||||
};
|
};
|
||||||
|
|
||||||
enum direction
|
enum direction
|
||||||
|
|
@ -80,15 +80,15 @@ enum direction
|
||||||
BACKWARD
|
BACKWARD
|
||||||
};
|
};
|
||||||
|
|
||||||
enum pv_onplay_result {
|
/* Describes possible outcomes from context (menu or hotkey) action */
|
||||||
PV_ONPLAY_USB,
|
enum pv_context_result {
|
||||||
PV_ONPLAY_USB_CLOSED,
|
PV_CONTEXT_CLOSED, /* Playlist Viewer has been closed */
|
||||||
PV_ONPLAY_WPS_CLOSED,
|
PV_CONTEXT_USB, /* USB-connection initiated */
|
||||||
PV_ONPLAY_CLOSED,
|
PV_CONTEXT_USB_CLOSED, /* USB-connection initiated (+viewer closed) */
|
||||||
PV_ONPLAY_ITEM_REMOVED,
|
PV_CONTEXT_WPS_CLOSED, /* WPS requested (+viewer closed) */
|
||||||
PV_ONPLAY_CHANGED,
|
PV_CONTEXT_MODIFIED, /* Playlist was modified in some way */
|
||||||
PV_ONPLAY_UNCHANGED,
|
PV_CONTEXT_UNCHANGED, /* No change to playlist, as far as we know */
|
||||||
PV_ONPLAY_SAVED,
|
PV_CONTEXT_PL_UPDATE, /* Playlist buffer requires reloading */
|
||||||
};
|
};
|
||||||
|
|
||||||
struct playlist_buffer
|
struct playlist_buffer
|
||||||
|
|
@ -104,7 +104,7 @@ struct playlist_buffer
|
||||||
enum direction direction; /* Direction of the buffer (if the buffer
|
enum direction direction; /* Direction of the buffer (if the buffer
|
||||||
was loaded BACKWARD, the last track in
|
was loaded BACKWARD, the last track in
|
||||||
the buffer has a real index < to the
|
the buffer has a real index < to the
|
||||||
real index of the the first track)*/
|
real index of the the first track) */
|
||||||
|
|
||||||
int num_loaded; /* Number of track entries loaded in buffer */
|
int num_loaded; /* Number of track entries loaded in buffer */
|
||||||
};
|
};
|
||||||
|
|
@ -401,8 +401,6 @@ static bool playlist_viewer_init(struct playlist_viewer * viewer,
|
||||||
if (!buffer || buffer_size <= MAX_PATH + id3_size)
|
if (!buffer || buffer_size <= MAX_PATH + id3_size)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
/* Index buffer is required, unless playback is stopped or we're
|
|
||||||
showing the current playlist (i.e. filename == NULL) */
|
|
||||||
if (require_index_buffer)
|
if (require_index_buffer)
|
||||||
index_buffer_size = playlist_get_index_bufsz(buffer_size - id3_size - (MAX_PATH + 1));
|
index_buffer_size = playlist_get_index_bufsz(buffer_size - id3_size - (MAX_PATH + 1));
|
||||||
|
|
||||||
|
|
@ -493,8 +491,9 @@ static void format_name(char* dest, const char* src, size_t bufsz)
|
||||||
switch (global_settings.playlist_viewer_track_display)
|
switch (global_settings.playlist_viewer_track_display)
|
||||||
{
|
{
|
||||||
case PLAYLIST_VIEWER_ENTRY_SHOW_FILE_NAME:
|
case PLAYLIST_VIEWER_ENTRY_SHOW_FILE_NAME:
|
||||||
case PLAYLIST_VIEWER_ENTRY_SHOW_ID3_TITLE_AND_ALBUM: /* If loading from tags failed, only display the file name */
|
/* If loading from tags failed, only display the file name */
|
||||||
case PLAYLIST_VIEWER_ENTRY_SHOW_ID3_TITLE: /* If loading from tags failed, only display the file name */
|
case PLAYLIST_VIEWER_ENTRY_SHOW_ID3_TITLE_AND_ALBUM:
|
||||||
|
case PLAYLIST_VIEWER_ENTRY_SHOW_ID3_TITLE:
|
||||||
default:
|
default:
|
||||||
{
|
{
|
||||||
/* Only display the filename */
|
/* Only display the filename */
|
||||||
|
|
@ -528,7 +527,8 @@ static void format_line(struct playlist_entry* track, char* str,
|
||||||
{
|
{
|
||||||
track->attr |= PLAYLIST_ATTR_RETRIEVE_ID3_ATTEMPTED;
|
track->attr |= PLAYLIST_ATTR_RETRIEVE_ID3_ATTEMPTED;
|
||||||
bool retrieve_success = retrieve_id3_tags(track->index, track->name,
|
bool retrieve_success = retrieve_id3_tags(track->index, track->name,
|
||||||
viewer.id3, METADATA_EXCLUDE_ID3_PATH);
|
viewer.id3,
|
||||||
|
METADATA_EXCLUDE_ID3_PATH);
|
||||||
if (retrieve_success)
|
if (retrieve_success)
|
||||||
{
|
{
|
||||||
if (!id3viewc)
|
if (!id3viewc)
|
||||||
|
|
@ -559,8 +559,10 @@ static void format_line(struct playlist_entry* track, char* str,
|
||||||
cur_str[2] = (char) ' ';
|
cur_str[2] = (char) ' ';
|
||||||
cur_str += 3;
|
cur_str += 3;
|
||||||
rem_space -= 3;
|
rem_space -= 3;
|
||||||
cur_str = strmemccpy(cur_str, pid3->album && pid3->album[0] != '\0' ?
|
cur_str = strmemccpy(cur_str, (pid3->album &&
|
||||||
pid3->album : (char*) str(LANG_TAGNAVI_UNTAGGED), rem_space);
|
pid3->album[0] != '\0') ? pid3->album :
|
||||||
|
(char*) str(LANG_TAGNAVI_UNTAGGED),
|
||||||
|
rem_space);
|
||||||
if (cur_str)
|
if (cur_str)
|
||||||
track->attr |= PLAYLIST_ATTR_RETRIEVE_ID3_SUCCEEDED;
|
track->attr |= PLAYLIST_ATTR_RETRIEVE_ID3_SUCCEEDED;
|
||||||
}
|
}
|
||||||
|
|
@ -571,10 +573,11 @@ static void format_line(struct playlist_entry* track, char* str,
|
||||||
{
|
{
|
||||||
/* Just the title */
|
/* Just the title */
|
||||||
if (pid3->title && pid3->title[0] != '\0' &&
|
if (pid3->title && pid3->title[0] != '\0' &&
|
||||||
strmemccpy(id3viewc, pid3->title, MAX_PATH)
|
strmemccpy(id3viewc, pid3->title, MAX_PATH))
|
||||||
)
|
{
|
||||||
track->attr |= PLAYLIST_ATTR_RETRIEVE_ID3_SUCCEEDED;
|
track->attr |= PLAYLIST_ATTR_RETRIEVE_ID3_SUCCEEDED;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
/* Yield to reduce as much as possible the perceived UI lag,
|
/* Yield to reduce as much as possible the perceived UI lag,
|
||||||
because retrieving id3 tags is an expensive operation */
|
because retrieving id3 tags is an expensive operation */
|
||||||
yield();
|
yield();
|
||||||
|
|
@ -617,7 +620,7 @@ static int view_text(const char *title, const char *text)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static enum pv_onplay_result show_track_info(const struct playlist_entry *current_track)
|
static enum pv_context_result show_track_info(const struct playlist_entry *current_track)
|
||||||
{
|
{
|
||||||
bool id3_retrieval_successful = retrieve_id3_tags(current_track->index,
|
bool id3_retrieval_successful = retrieve_id3_tags(current_track->index,
|
||||||
current_track->name,
|
current_track->name,
|
||||||
|
|
@ -627,7 +630,7 @@ static enum pv_onplay_result show_track_info(const struct playlist_entry *curren
|
||||||
browse_id3_ex(viewer.id3, viewer.playlist, current_track->display_index,
|
browse_id3_ex(viewer.id3, viewer.playlist, current_track->display_index,
|
||||||
viewer.num_tracks, NULL, 1,
|
viewer.num_tracks, NULL, 1,
|
||||||
viewer.allow_view_text_plugin ? NULL : &view_text)) ?
|
viewer.allow_view_text_plugin ? NULL : &view_text)) ?
|
||||||
PV_ONPLAY_USB : PV_ONPLAY_UNCHANGED;
|
PV_CONTEXT_USB : PV_CONTEXT_UNCHANGED;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void close_playlist_viewer(void)
|
static void close_playlist_viewer(void)
|
||||||
|
|
@ -651,7 +654,7 @@ static void close_playlist_viewer(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(HAVE_HOTKEY) || defined(HAVE_TAGCACHE)
|
#if defined(HAVE_HOTKEY) || defined(HAVE_TAGCACHE)
|
||||||
static enum pv_onplay_result
|
static enum pv_context_result
|
||||||
open_with_plugin(const struct playlist_entry *current_track,
|
open_with_plugin(const struct playlist_entry *current_track,
|
||||||
const char* plugin_name,
|
const char* plugin_name,
|
||||||
int (*loadplugin)(const char* plugin, const char* file))
|
int (*loadplugin)(const char* plugin, const char* file))
|
||||||
|
|
@ -667,11 +670,11 @@ static enum pv_onplay_result
|
||||||
switch (plugin_return)
|
switch (plugin_return)
|
||||||
{
|
{
|
||||||
case PLUGIN_USB_CONNECTED:
|
case PLUGIN_USB_CONNECTED:
|
||||||
return PV_ONPLAY_USB_CLOSED;
|
return PV_CONTEXT_USB_CLOSED;
|
||||||
case PLUGIN_GOTO_WPS:
|
case PLUGIN_GOTO_WPS:
|
||||||
return PV_ONPLAY_WPS_CLOSED;
|
return PV_CONTEXT_WPS_CLOSED;
|
||||||
default:
|
default:
|
||||||
return PV_ONPLAY_CLOSED;
|
return PV_CONTEXT_CLOSED;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -682,21 +685,21 @@ static int list_viewers(const char* plugin, const char* file)
|
||||||
(void)plugin;
|
(void)plugin;
|
||||||
return filetype_list_viewers(file);
|
return filetype_list_viewers(file);
|
||||||
}
|
}
|
||||||
static enum pv_onplay_result open_with(const struct playlist_entry *current_track)
|
static enum pv_context_result open_with(const struct playlist_entry *current_track)
|
||||||
{
|
{
|
||||||
return open_with_plugin(current_track, "", &list_viewers);
|
return open_with_plugin(current_track, "", &list_viewers);
|
||||||
}
|
}
|
||||||
#endif /* HAVE_HOTKEY */
|
#endif /* HAVE_HOTKEY */
|
||||||
|
|
||||||
#ifdef HAVE_TAGCACHE
|
#ifdef HAVE_TAGCACHE
|
||||||
static enum pv_onplay_result open_pictureflow(const struct playlist_entry *current_track)
|
static enum pv_context_result open_pictureflow(const struct playlist_entry *current_track)
|
||||||
{
|
{
|
||||||
return open_with_plugin(current_track, "pictureflow", &filetype_load_plugin);
|
return open_with_plugin(current_track, "pictureflow", &filetype_load_plugin);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#endif /*defined(HAVE_HOTKEY) || defined(HAVE_TAGCACHE)*/
|
#endif /*defined(HAVE_HOTKEY) || defined(HAVE_TAGCACHE)*/
|
||||||
|
|
||||||
static enum pv_onplay_result delete_track(int current_track_index,
|
static enum pv_context_result delete_track(int current_track_index,
|
||||||
int index, bool current_was_playing)
|
int index, bool current_was_playing)
|
||||||
{
|
{
|
||||||
playlist_delete(viewer.playlist, current_track_index);
|
playlist_delete(viewer.playlist, current_track_index);
|
||||||
|
|
@ -718,107 +721,80 @@ static enum pv_onplay_result delete_track(int current_track_index,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return PV_ONPLAY_ITEM_REMOVED;
|
return PV_CONTEXT_MODIFIED;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Menu of playlist commands. Invoked via ON+PLAY on main viewer screen. */
|
static enum pv_context_result context_menu(int index)
|
||||||
static enum pv_onplay_result onplay_menu(int index)
|
|
||||||
{
|
{
|
||||||
int result, ret = PV_ONPLAY_UNCHANGED;
|
struct playlist_entry *current_track = playlist_buffer_get_track(&viewer.buffer,
|
||||||
struct playlist_entry * current_track =
|
index);
|
||||||
playlist_buffer_get_track(&viewer.buffer, index);
|
bool current_was_playing = (current_track->index == viewer.current_playing_track);
|
||||||
|
|
||||||
MENUITEM_STRINGLIST(menu_items, ID2P(LANG_PLAYLIST), NULL,
|
MENUITEM_STRINGLIST(menu_items, ID2P(LANG_PLAYLIST), NULL,
|
||||||
ID2P(LANG_PLAYING_NEXT), ID2P(LANG_ADD_TO_PL),
|
ID2P(LANG_PLAYING_NEXT), ID2P(LANG_ADD_TO_PL),
|
||||||
ID2P(LANG_REMOVE), ID2P(LANG_MOVE), ID2P(LANG_MENU_SHOW_ID3_INFO),
|
ID2P(LANG_REMOVE), ID2P(LANG_MOVE),
|
||||||
ID2P(LANG_SHUFFLE),
|
ID2P(LANG_MENU_SHOW_ID3_INFO),
|
||||||
ID2P(LANG_SAVE),
|
ID2P(LANG_SHUFFLE), ID2P(LANG_SAVE),
|
||||||
ID2P(LANG_PLAYLISTVIEWER_SETTINGS)
|
ID2P(LANG_PLAYLISTVIEWER_SETTINGS)
|
||||||
#ifdef HAVE_TAGCACHE
|
#ifdef HAVE_TAGCACHE
|
||||||
,ID2P(LANG_ONPLAY_PICTUREFLOW)
|
,ID2P(LANG_ONPLAY_PICTUREFLOW)
|
||||||
#endif
|
#endif
|
||||||
);
|
);
|
||||||
|
int sel = do_menu(&menu_items, NULL, NULL, false);
|
||||||
bool current_was_playing = (current_track->index == viewer.current_playing_track);
|
if (sel == MENU_ATTACHED_USB)
|
||||||
|
return PV_CONTEXT_USB;
|
||||||
result = do_menu(&menu_items, NULL, NULL, false);
|
else if (sel >= 0)
|
||||||
if (result == MENU_ATTACHED_USB)
|
|
||||||
{
|
|
||||||
ret = PV_ONPLAY_USB;
|
|
||||||
}
|
|
||||||
else if (result >= 0)
|
|
||||||
{
|
{
|
||||||
/* Abort current move */
|
/* Abort current move */
|
||||||
viewer.moving_track = -1;
|
viewer.moving_track = -1;
|
||||||
viewer.moving_playlist_index = -1;
|
viewer.moving_playlist_index = -1;
|
||||||
|
|
||||||
switch (result)
|
switch (sel)
|
||||||
{
|
{
|
||||||
case 0:
|
case 0:
|
||||||
/* playlist */
|
/* Playing Next... menu */
|
||||||
onplay_show_playlist_menu(current_track->name, FILE_ATTR_AUDIO, NULL);
|
onplay_show_playlist_menu(current_track->name, FILE_ATTR_AUDIO, NULL);
|
||||||
ret = PV_ONPLAY_UNCHANGED;
|
return PV_CONTEXT_UNCHANGED;
|
||||||
break;
|
|
||||||
case 1:
|
case 1:
|
||||||
/* add to catalog */
|
/* Add to Playlist... menu */
|
||||||
onplay_show_playlist_cat_menu(current_track->name, FILE_ATTR_AUDIO, NULL);
|
onplay_show_playlist_cat_menu(current_track->name, FILE_ATTR_AUDIO, NULL);
|
||||||
ret = PV_ONPLAY_UNCHANGED;
|
return PV_CONTEXT_UNCHANGED;
|
||||||
break;
|
|
||||||
case 2:
|
case 2:
|
||||||
ret = delete_track(current_track->index, index, current_was_playing);
|
return delete_track(current_track->index, index, current_was_playing);
|
||||||
break;
|
|
||||||
case 3:
|
case 3:
|
||||||
/* move track */
|
/* move track */
|
||||||
viewer.moving_track = index;
|
viewer.moving_track = index;
|
||||||
viewer.moving_playlist_index = current_track->index;
|
viewer.moving_playlist_index = current_track->index;
|
||||||
ret = PV_ONPLAY_UNCHANGED;
|
return PV_CONTEXT_UNCHANGED;
|
||||||
break;
|
|
||||||
case 4:
|
case 4:
|
||||||
ret = show_track_info(current_track);
|
return show_track_info(current_track);
|
||||||
break;
|
|
||||||
case 5:
|
case 5:
|
||||||
/* shuffle */
|
/* shuffle */
|
||||||
playlist_sort(viewer.playlist, !viewer.playlist);
|
playlist_sort(viewer.playlist, !viewer.playlist);
|
||||||
playlist_randomise(viewer.playlist, current_tick, !viewer.playlist);
|
playlist_randomise(viewer.playlist, current_tick, !viewer.playlist);
|
||||||
viewer.selected_track = 0;
|
viewer.selected_track = 0;
|
||||||
ret = PV_ONPLAY_CHANGED;
|
return PV_CONTEXT_MODIFIED;
|
||||||
break;
|
|
||||||
case 6:
|
case 6:
|
||||||
save_playlist_screen(viewer.playlist);
|
save_playlist_screen(viewer.playlist);
|
||||||
/* playlist indices of current playlist may have changed */
|
/* playlist indices of current playlist may have changed */
|
||||||
ret = viewer.playlist ? PV_ONPLAY_UNCHANGED : PV_ONPLAY_SAVED;
|
return viewer.playlist ? PV_CONTEXT_UNCHANGED : PV_CONTEXT_PL_UPDATE;
|
||||||
break;
|
|
||||||
case 7:
|
case 7:
|
||||||
{
|
{
|
||||||
int last_display = global_settings.playlist_viewer_track_display;
|
|
||||||
/* playlist viewer settings */
|
/* playlist viewer settings */
|
||||||
result = do_menu(&viewer_settings_menu, NULL, NULL, false);
|
sel = global_settings.playlist_viewer_track_display;
|
||||||
|
if (MENU_ATTACHED_USB == do_menu(&viewer_settings_menu, NULL, NULL, false))
|
||||||
|
return PV_CONTEXT_USB;
|
||||||
if (result == MENU_ATTACHED_USB)
|
|
||||||
ret = PV_ONPLAY_USB;
|
|
||||||
else
|
else
|
||||||
{
|
return (sel == global_settings.playlist_viewer_track_display) ?
|
||||||
if (last_display != global_settings.playlist_viewer_track_display)
|
PV_CONTEXT_UNCHANGED : PV_CONTEXT_PL_UPDATE;
|
||||||
update_playlist(true);/* reload buffer */
|
|
||||||
|
|
||||||
ret = PV_ONPLAY_UNCHANGED;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
#ifdef HAVE_TAGCACHE
|
#ifdef HAVE_TAGCACHE
|
||||||
case 8:
|
case 8:
|
||||||
ret = open_pictureflow(current_track);
|
return open_pictureflow(current_track);
|
||||||
break;
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return ret;
|
return PV_CONTEXT_UNCHANGED;
|
||||||
}
|
|
||||||
|
|
||||||
/* View current playlist */
|
|
||||||
enum playlist_viewer_result playlist_viewer(void)
|
|
||||||
{
|
|
||||||
return playlist_viewer_ex(NULL, NULL);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int get_track_num(struct playlist_viewer *local_viewer,
|
static int get_track_num(struct playlist_viewer *local_viewer,
|
||||||
|
|
@ -928,7 +904,7 @@ static int playlist_callback_voice(int selected_item, void *data)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void update_lists(struct gui_synclist * playlist_lists, bool init)
|
static void update_gui(struct gui_synclist * playlist_lists, bool init)
|
||||||
{
|
{
|
||||||
if (init)
|
if (init)
|
||||||
gui_synclist_init(playlist_lists, playlist_callback_name,
|
gui_synclist_init(playlist_lists, playlist_callback_name,
|
||||||
|
|
@ -946,31 +922,22 @@ static void update_lists(struct gui_synclist * playlist_lists, bool init)
|
||||||
gui_synclist_speak_item(playlist_lists);
|
gui_synclist_speak_item(playlist_lists);
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool update_viewer_with_changes(struct gui_synclist *playlist_lists, enum pv_onplay_result res)
|
static bool update_viewer(struct gui_synclist *playlist_lists, enum pv_context_result res)
|
||||||
{
|
{
|
||||||
bool exit = false;
|
bool exit = false;
|
||||||
if (res == PV_ONPLAY_CHANGED ||
|
if (res == PV_CONTEXT_MODIFIED)
|
||||||
res == PV_ONPLAY_SAVED ||
|
|
||||||
res == PV_ONPLAY_ITEM_REMOVED)
|
|
||||||
{
|
|
||||||
if (res != PV_ONPLAY_SAVED)
|
|
||||||
playlist_set_modified(viewer.playlist, true);
|
playlist_set_modified(viewer.playlist, true);
|
||||||
|
|
||||||
if (res == PV_ONPLAY_ITEM_REMOVED)
|
if (res == PV_CONTEXT_MODIFIED || res == PV_CONTEXT_PL_UPDATE)
|
||||||
gui_synclist_del_item(playlist_lists);
|
{
|
||||||
|
|
||||||
update_playlist(true);
|
update_playlist(true);
|
||||||
|
|
||||||
if (viewer.num_tracks <= 0)
|
if (viewer.num_tracks <= 0)
|
||||||
exit = true;
|
exit = true;
|
||||||
|
|
||||||
if (viewer.selected_track >= viewer.num_tracks)
|
if (viewer.selected_track >= viewer.num_tracks)
|
||||||
viewer.selected_track = viewer.num_tracks-1;
|
viewer.selected_track = viewer.num_tracks-1;
|
||||||
}
|
}
|
||||||
|
update_gui(playlist_lists, false);
|
||||||
/* the show_icons option in the playlist viewer settings
|
|
||||||
* menu might have changed */
|
|
||||||
update_lists(playlist_lists, false);
|
|
||||||
return exit;
|
return exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -983,7 +950,7 @@ static bool open_playlist_viewer(const char* filename,
|
||||||
if (!playlist_viewer_init(&viewer, filename, reload, most_recent_selection))
|
if (!playlist_viewer_init(&viewer, filename, reload, most_recent_selection))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
update_lists(playlist_lists, true);
|
update_gui(playlist_lists, true);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
@ -1072,7 +1039,7 @@ enum playlist_viewer_result playlist_viewer_ex(const char* filename,
|
||||||
struct playlist_entry * current_track =
|
struct playlist_entry * current_track =
|
||||||
playlist_buffer_get_track(&viewer.buffer,
|
playlist_buffer_get_track(&viewer.buffer,
|
||||||
viewer.selected_track);
|
viewer.selected_track);
|
||||||
int ret_val;
|
int ret_val, start_index = current_track->index;
|
||||||
if (viewer.moving_track >= 0)
|
if (viewer.moving_track >= 0)
|
||||||
{
|
{
|
||||||
/* Move track */
|
/* Move track */
|
||||||
|
|
@ -1102,35 +1069,28 @@ enum playlist_viewer_result playlist_viewer_ex(const char* filename,
|
||||||
playlist_start(current_track->index, 0, 0);
|
playlist_start(current_track->index, 0, 0);
|
||||||
update_playlist(false);
|
update_playlist(false);
|
||||||
}
|
}
|
||||||
else
|
else if (warn_on_pl_erase())
|
||||||
{
|
{
|
||||||
int start_index = current_track->index;
|
/* Turn it into the current playlist */
|
||||||
if (!warn_on_pl_erase())
|
|
||||||
{
|
|
||||||
gui_synclist_set_title(&playlist_lists, playlist_lists.title, playlist_lists.title_icon);
|
|
||||||
gui_synclist_draw(&playlist_lists);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
/* New playlist */
|
|
||||||
ret_val = playlist_set_current(viewer.playlist);
|
ret_val = playlist_set_current(viewer.playlist);
|
||||||
|
|
||||||
/* Playlist effectively closed */
|
/* Previously loaded playlist is now effectively closed */
|
||||||
viewer.playlist = NULL;
|
viewer.playlist = NULL;
|
||||||
|
|
||||||
if (ret_val < 0)
|
if (!ret_val)
|
||||||
goto exit;
|
{
|
||||||
if (global_settings.playlist_shuffle)
|
if (global_settings.playlist_shuffle)
|
||||||
start_index = playlist_shuffle(current_tick, start_index);
|
start_index = playlist_shuffle(current_tick, start_index);
|
||||||
playlist_start(start_index, 0, 0);
|
playlist_start(start_index, 0, 0);
|
||||||
|
|
||||||
if (viewer.initial_selection)
|
if (viewer.initial_selection)
|
||||||
*(viewer.initial_selection) = viewer.selected_track;
|
*(viewer.initial_selection) = viewer.selected_track;
|
||||||
|
|
||||||
/* Our playlist is now the current list */
|
|
||||||
if (!playlist_viewer_init(&viewer, NULL, true, NULL))
|
|
||||||
goto exit;
|
|
||||||
exit = true;
|
|
||||||
}
|
}
|
||||||
|
goto exit;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
gui_synclist_set_title(&playlist_lists, playlist_lists.title,
|
||||||
|
playlist_lists.title_icon);
|
||||||
gui_synclist_draw(&playlist_lists);
|
gui_synclist_draw(&playlist_lists);
|
||||||
gui_synclist_speak_item(&playlist_lists);
|
gui_synclist_speak_item(&playlist_lists);
|
||||||
|
|
||||||
|
|
@ -1138,18 +1098,18 @@ enum playlist_viewer_result playlist_viewer_ex(const char* filename,
|
||||||
}
|
}
|
||||||
case ACTION_STD_CONTEXT:
|
case ACTION_STD_CONTEXT:
|
||||||
{
|
{
|
||||||
int pv_onplay_result = onplay_menu(viewer.selected_track);
|
int pv_context_result = context_menu(viewer.selected_track);
|
||||||
|
|
||||||
if (pv_onplay_result == PV_ONPLAY_USB)
|
if (pv_context_result == PV_CONTEXT_USB)
|
||||||
{
|
{
|
||||||
ret = PLAYLIST_VIEWER_USB;
|
ret = PLAYLIST_VIEWER_USB;
|
||||||
goto exit;
|
goto exit;
|
||||||
}
|
}
|
||||||
else if (pv_onplay_result == PV_ONPLAY_USB_CLOSED)
|
else if (pv_context_result == PV_CONTEXT_USB_CLOSED)
|
||||||
return PLAYLIST_VIEWER_USB;
|
return PLAYLIST_VIEWER_USB;
|
||||||
else if (pv_onplay_result == PV_ONPLAY_WPS_CLOSED)
|
else if (pv_context_result == PV_CONTEXT_WPS_CLOSED)
|
||||||
return PLAYLIST_VIEWER_OK;
|
return PLAYLIST_VIEWER_OK;
|
||||||
else if (pv_onplay_result == PV_ONPLAY_CLOSED)
|
else if (pv_context_result == PV_CONTEXT_CLOSED)
|
||||||
{
|
{
|
||||||
if (!open_playlist_viewer(filename, &playlist_lists, true, NULL))
|
if (!open_playlist_viewer(filename, &playlist_lists, true, NULL))
|
||||||
{
|
{
|
||||||
|
|
@ -1158,7 +1118,7 @@ enum playlist_viewer_result playlist_viewer_ex(const char* filename,
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (update_viewer_with_changes(&playlist_lists, pv_onplay_result))
|
if (update_viewer(&playlist_lists, pv_context_result))
|
||||||
{
|
{
|
||||||
exit = true;
|
exit = true;
|
||||||
ret = PLAYLIST_VIEWER_CANCEL;
|
ret = PLAYLIST_VIEWER_CANCEL;
|
||||||
|
|
@ -1181,7 +1141,7 @@ enum playlist_viewer_result playlist_viewer_ex(const char* filename,
|
||||||
skin_update(CUSTOM_STATUSBAR, i, SKIN_REFRESH_ALL);
|
skin_update(CUSTOM_STATUSBAR, i, SKIN_REFRESH_ALL);
|
||||||
}
|
}
|
||||||
update_playlist(true);
|
update_playlist(true);
|
||||||
update_lists(&playlist_lists, true);
|
update_gui(&playlist_lists, true);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
#endif
|
#endif
|
||||||
|
|
@ -1191,7 +1151,7 @@ enum playlist_viewer_result playlist_viewer_ex(const char* filename,
|
||||||
struct playlist_entry *current_track = playlist_buffer_get_track(
|
struct playlist_entry *current_track = playlist_buffer_get_track(
|
||||||
&viewer.buffer,
|
&viewer.buffer,
|
||||||
viewer.selected_track);
|
viewer.selected_track);
|
||||||
enum pv_onplay_result (*do_plugin)(const struct playlist_entry *) = NULL;
|
enum pv_context_result (*do_plugin)(const struct playlist_entry *) = NULL;
|
||||||
#ifdef HAVE_TAGCACHE
|
#ifdef HAVE_TAGCACHE
|
||||||
if (global_settings.hotkey_tree == HOTKEY_PICTUREFLOW)
|
if (global_settings.hotkey_tree == HOTKEY_PICTUREFLOW)
|
||||||
do_plugin = &open_pictureflow;
|
do_plugin = &open_pictureflow;
|
||||||
|
|
@ -1203,9 +1163,9 @@ enum playlist_viewer_result playlist_viewer_ex(const char* filename,
|
||||||
{
|
{
|
||||||
int plugin_result = do_plugin(current_track);
|
int plugin_result = do_plugin(current_track);
|
||||||
|
|
||||||
if (plugin_result == PV_ONPLAY_USB_CLOSED)
|
if (plugin_result == PV_CONTEXT_USB_CLOSED)
|
||||||
return PLAYLIST_VIEWER_USB;
|
return PLAYLIST_VIEWER_USB;
|
||||||
else if (plugin_result == PV_ONPLAY_WPS_CLOSED)
|
else if (plugin_result == PV_CONTEXT_WPS_CLOSED)
|
||||||
return PLAYLIST_VIEWER_OK;
|
return PLAYLIST_VIEWER_OK;
|
||||||
else if (!open_playlist_viewer(filename, &playlist_lists, true, NULL))
|
else if (!open_playlist_viewer(filename, &playlist_lists, true, NULL))
|
||||||
{
|
{
|
||||||
|
|
@ -1215,16 +1175,16 @@ enum playlist_viewer_result playlist_viewer_ex(const char* filename,
|
||||||
}
|
}
|
||||||
else if (global_settings.hotkey_tree == HOTKEY_PROPERTIES)
|
else if (global_settings.hotkey_tree == HOTKEY_PROPERTIES)
|
||||||
{
|
{
|
||||||
if (show_track_info(current_track) == PV_ONPLAY_USB)
|
if (show_track_info(current_track) == PV_CONTEXT_USB)
|
||||||
{
|
{
|
||||||
ret = PLAYLIST_VIEWER_USB;
|
ret = PLAYLIST_VIEWER_USB;
|
||||||
goto exit;
|
goto exit;
|
||||||
}
|
}
|
||||||
update_lists(&playlist_lists, false);
|
update_gui(&playlist_lists, false);
|
||||||
}
|
}
|
||||||
else if (global_settings.hotkey_tree == HOTKEY_DELETE)
|
else if (global_settings.hotkey_tree == HOTKEY_DELETE)
|
||||||
{
|
{
|
||||||
if (update_viewer_with_changes(&playlist_lists,
|
if (update_viewer(&playlist_lists,
|
||||||
delete_track(current_track->index,
|
delete_track(current_track->index,
|
||||||
viewer.selected_track,
|
viewer.selected_track,
|
||||||
(current_track->index == viewer.current_playing_track))))
|
(current_track->index == viewer.current_playing_track))))
|
||||||
|
|
@ -1254,6 +1214,12 @@ exit:
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* View current playlist */
|
||||||
|
enum playlist_viewer_result playlist_viewer(void)
|
||||||
|
{
|
||||||
|
return playlist_viewer_ex(NULL, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
static const char* playlist_search_callback_name(int selected_item, void * data,
|
static const char* playlist_search_callback_name(int selected_item, void * data,
|
||||||
char *buffer, size_t buffer_len)
|
char *buffer, size_t buffer_len)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue