diff options
Diffstat (limited to 'apps/playlist_viewer.c')
-rw-r--r-- | apps/playlist_viewer.c | 86 |
1 files changed, 18 insertions, 68 deletions
diff --git a/apps/playlist_viewer.c b/apps/playlist_viewer.c index 1d066bbedb..d9de123831 100644 --- a/apps/playlist_viewer.c +++ b/apps/playlist_viewer.c | |||
@@ -125,10 +125,7 @@ static void format_line(const struct playlist_entry* track, char* str, | |||
125 | static bool update_playlist(bool force); | 125 | static bool update_playlist(bool force); |
126 | static int onplay_menu(int index); | 126 | static int onplay_menu(int index); |
127 | static bool viewer_menu(void); | 127 | static bool viewer_menu(void); |
128 | static bool show_icons(void); | 128 | static int save_playlist_func(void); |
129 | static bool show_indices(void); | ||
130 | static bool track_display(void); | ||
131 | static bool save_playlist(void); | ||
132 | 129 | ||
133 | static void playlist_buffer_init(struct playlist_buffer *pb, char *names_buffer, | 130 | static void playlist_buffer_init(struct playlist_buffer *pb, char *names_buffer, |
134 | int names_buffer_size) | 131 | int names_buffer_size) |
@@ -422,26 +419,15 @@ static bool update_playlist(bool force) | |||
422 | changed. */ | 419 | changed. */ |
423 | static int onplay_menu(int index) | 420 | static int onplay_menu(int index) |
424 | { | 421 | { |
425 | struct menu_item items[4]; /* increase this if you add entries! */ | 422 | int result, ret = 0; |
426 | int m, i=0, result, ret = 0; | ||
427 | struct playlist_entry * current_track= | 423 | struct playlist_entry * current_track= |
428 | playlist_buffer_get_track(&viewer.buffer, index); | 424 | playlist_buffer_get_track(&viewer.buffer, index); |
425 | MENUITEM_STRINGLIST(menu_items, ID2P(LANG_PLAYLIST_MENU), NULL, | ||
426 | ID2P(LANG_REMOVE), ID2P(LANG_MOVE), | ||
427 | ID2P(LANG_CATALOG_ADD_TO), ID2P(LANG_CATALOG_ADD_TO_NEW)); | ||
429 | bool current = (current_track->index == viewer.current_playing_track); | 428 | bool current = (current_track->index == viewer.current_playing_track); |
430 | 429 | ||
431 | items[i].desc = ID2P(LANG_REMOVE); | 430 | result = do_menu(&menu_items, NULL); |
432 | i++; | ||
433 | |||
434 | items[i].desc = ID2P(LANG_MOVE); | ||
435 | i++; | ||
436 | |||
437 | items[i].desc = ID2P(LANG_CATALOG_ADD_TO); | ||
438 | i++; | ||
439 | |||
440 | items[i].desc = ID2P(LANG_CATALOG_ADD_TO_NEW); | ||
441 | i++; | ||
442 | |||
443 | m = menu_init(items, i, NULL, str(LANG_PLAYLIST_MENU), NULL, NULL); | ||
444 | result = menu_show(m); | ||
445 | if (result == MENU_ATTACHED_USB) | 431 | if (result == MENU_ATTACHED_USB) |
446 | { | 432 | { |
447 | ret = -1; | 433 | ret = -1; |
@@ -493,65 +479,29 @@ static int onplay_menu(int index) | |||
493 | break; | 479 | break; |
494 | } | 480 | } |
495 | } | 481 | } |
496 | menu_exit(m); | ||
497 | return ret; | 482 | return ret; |
498 | } | 483 | } |
499 | 484 | ||
500 | /* Menu of viewer options. Invoked via F1(r) or Menu(p). */ | 485 | /* Menu of viewer options. Invoked via F1(r) or Menu(p). */ |
486 | MENUITEM_SETTING(show_icons, &global_settings.playlist_viewer_icons, NULL); | ||
487 | MENUITEM_SETTING(show_indices, &global_settings.playlist_viewer_indices, NULL); | ||
488 | MENUITEM_SETTING(track_display, | ||
489 | &global_settings.playlist_viewer_track_display, NULL); | ||
490 | MENUITEM_FUNCTION(save_playlist_item, 0, ID2P(LANG_SAVE_DYNAMIC_PLAYLIST), | ||
491 | save_playlist_func, 0, NULL, Icon_NOICON); | ||
492 | MAKE_MENU(viewer_settings_menu, ID2P(LANG_PLAYLISTVIEWER_SETTINGS), | ||
493 | NULL, Icon_Playlist, | ||
494 | &show_icons, &show_indices, &track_display, &save_playlist_item); | ||
501 | static bool viewer_menu(void) | 495 | static bool viewer_menu(void) |
502 | { | 496 | { |
503 | int m; | 497 | return do_menu(&viewer_settings_menu, NULL) == SYS_USB_CONNECTED; |
504 | bool result; | ||
505 | |||
506 | static const struct menu_item items[] = { | ||
507 | { ID2P(LANG_SHOW_ICONS), show_icons }, | ||
508 | { ID2P(LANG_SHOW_INDICES), show_indices }, | ||
509 | { ID2P(LANG_TRACK_DISPLAY), track_display }, | ||
510 | { ID2P(LANG_SAVE_DYNAMIC_PLAYLIST), save_playlist }, | ||
511 | }; | ||
512 | |||
513 | m=menu_init( items, sizeof(items) / sizeof(*items), NULL, | ||
514 | NULL, NULL, NULL ); | ||
515 | result = menu_run(m); | ||
516 | menu_exit(m); | ||
517 | |||
518 | settings_save(); | ||
519 | |||
520 | return result; | ||
521 | } | ||
522 | |||
523 | /* Show icons in viewer? */ | ||
524 | static bool show_icons(void) | ||
525 | { | ||
526 | return set_bool((char *)str(LANG_SHOW_ICONS), | ||
527 | &global_settings.playlist_viewer_icons); | ||
528 | } | ||
529 | |||
530 | /* Show indices of tracks? */ | ||
531 | static bool show_indices(void) | ||
532 | { | ||
533 | return set_bool((char *)str(LANG_SHOW_INDICES), | ||
534 | &global_settings.playlist_viewer_indices); | ||
535 | } | ||
536 | |||
537 | /* How to display a track */ | ||
538 | static bool track_display(void) | ||
539 | { | ||
540 | static const struct opt_items names[] = { | ||
541 | { STR(LANG_DISPLAY_TRACK_NAME_ONLY) }, | ||
542 | { STR(LANG_DISPLAY_FULL_PATH) } | ||
543 | }; | ||
544 | |||
545 | return set_option((char *)str(LANG_TRACK_DISPLAY), | ||
546 | &global_settings.playlist_viewer_track_display, INT, names, 2, | ||
547 | NULL); | ||
548 | } | 498 | } |
549 | 499 | ||
550 | /* Save playlist to disk */ | 500 | /* Save playlist to disk */ |
551 | static bool save_playlist(void) | 501 | static int save_playlist_func(void) |
552 | { | 502 | { |
553 | save_playlist_screen(viewer.playlist); | 503 | save_playlist_screen(viewer.playlist); |
554 | return false; | 504 | return 0; |
555 | } | 505 | } |
556 | 506 | ||
557 | /* View current playlist */ | 507 | /* View current playlist */ |