blob: 175ca19959305501459fac3077c37c047edc3f8a [file] [log] [blame]
Jonathan Gordon4718a1e2007-02-08 04:33:41 +00001/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
Jonathan Gordon4e73b532007-02-13 00:32:17 +00008 * $Id$
Jonathan Gordon4718a1e2007-02-08 04:33:41 +00009 *
10 * Copyright (C) 2007 Jonathan Gordon
11 *
Daniel Stenberg2acc0ac2008-06-28 18:10:04 +000012 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
Jonathan Gordon4718a1e2007-02-08 04:33:41 +000016 *
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
19 *
20 ****************************************************************************/
21
22#include <stdbool.h>
Jonathan Gordone84ff172007-02-11 07:32:58 +000023#include <string.h>
Jonathan Gordon97a4c1e2011-07-20 14:11:15 +000024#include <stdio.h>
Jonathan Gordon4718a1e2007-02-08 04:33:41 +000025#include "config.h"
26#include "lang.h"
27#include "action.h"
28#include "settings.h"
29#include "menu.h"
30#include "playlist_menu.h"
31
Jonathan Gordone84ff172007-02-11 07:32:58 +000032#include "file.h"
33#include "keyboard.h"
34#include "playlist.h"
35#include "tree.h"
36#include "playlist_viewer.h"
37#include "talk.h"
38#include "playlist_catalog.h"
Jonathan Gordon97a4c1e2011-07-20 14:11:15 +000039#include "splash.h"
Jonathan Gordon4718a1e2007-02-08 04:33:41 +000040
Jonathan Gordone84ff172007-02-11 07:32:58 +000041int save_playlist_screen(struct playlist_info* playlist)
42{
Jonathan Gordon97a4c1e2011-07-20 14:11:15 +000043 char temp[MAX_PATH+1], *dot;
Jonathan Gordone84ff172007-02-11 07:32:58 +000044 int len;
Jonathan Gordon97a4c1e2011-07-20 14:11:15 +000045
Nils Wallméniusf30add42010-08-21 16:14:18 +000046 playlist_get_name(playlist, temp, sizeof(temp)-1);
Jonathan Gordone84ff172007-02-11 07:32:58 +000047 len = strlen(temp);
48
Jonathan Gordon97a4c1e2011-07-20 14:11:15 +000049 dot = strrchr(temp, '.');
50 if (!dot)
51 {
52 /* folder of some type */
53 if (temp[1] != '\0')
54 strcpy(&temp[len-1], ".m3u8");
55 else
56 snprintf(temp, sizeof(temp), "%s%s",
57 catalog_get_directory(), DEFAULT_DYNAMIC_PLAYLIST_NAME);
58 }
59 else if (len > 4 && !strcasecmp(dot, ".m3u"))
Jonathan Gordone84ff172007-02-11 07:32:58 +000060 strcat(temp, "8");
Jonathan Gordone84ff172007-02-11 07:32:58 +000061
62 if (!kbd_input(temp, sizeof(temp)))
63 {
Thomas Martitzbebf71a2014-04-08 22:52:37 +020064 playlist_save(playlist, temp, NULL, 0);
Jonathan Gordone84ff172007-02-11 07:32:58 +000065
66 /* reload in case playlist was saved to cwd */
67 reload_directory();
68 }
69
70 return 0;
71}
Thomas Martitzc19e5362010-02-20 19:06:39 +000072
73static int playlist_view_(void)
74{
Jonathan Gordon97a4c1e2011-07-20 14:11:15 +000075 playlist_viewer_ex(NULL);
76 return 0;
Thomas Martitzc19e5362010-02-20 19:06:39 +000077}
Jonathan Gordondaf66942007-03-17 12:33:34 +000078MENUITEM_FUNCTION(create_playlist_item, 0, ID2P(LANG_CREATE_PLAYLIST),
William Wilgusdd40c462018-10-15 23:04:04 -040079 create_playlist, NULL, NULL, Icon_NOICON);
Jonathan Gordon97a4c1e2011-07-20 14:11:15 +000080MENUITEM_FUNCTION(view_cur_playlist, 0,
Jeffrey Goode16e0c572010-05-07 03:21:12 +000081 ID2P(LANG_VIEW_DYNAMIC_PLAYLIST),
William Wilgusdd40c462018-10-15 23:04:04 -040082 playlist_view_, NULL, NULL, Icon_NOICON);
Jonathan Gordondaf66942007-03-17 12:33:34 +000083MENUITEM_FUNCTION(save_playlist, MENU_FUNC_USEPARAM, ID2P(LANG_SAVE_DYNAMIC_PLAYLIST),
William Wilgusdd40c462018-10-15 23:04:04 -040084 save_playlist_screen, NULL, NULL, Icon_NOICON);
Jonathan Gordone84ff172007-02-11 07:32:58 +000085MENUITEM_SETTING(recursive_dir_insert, &global_settings.recursive_dir_insert, NULL);
86MENUITEM_SETTING(warn_on_erase, &global_settings.warnon_erase_dynplaylist, NULL);
Jonathan Gordon97a4c1e2011-07-20 14:11:15 +000087static int clear_catalog_directory(void)
88{
89 catalog_set_directory(NULL);
90 settings_save();
91 splash(HZ, ID2P(LANG_RESET_DONE_CLEAR));
92 return false;
93}
94MENUITEM_FUNCTION(clear_catalog_directory_item, 0, ID2P(LANG_RESET_PLAYLISTCAT_DIR),
95 clear_catalog_directory, NULL, NULL, Icon_file_view_menu);
96
97/* Playlist viewer settings submenu */
98MENUITEM_SETTING(show_icons, &global_settings.playlist_viewer_icons, NULL);
99MENUITEM_SETTING(show_indices, &global_settings.playlist_viewer_indices, NULL);
100MENUITEM_SETTING(track_display,
101 &global_settings.playlist_viewer_track_display, NULL);
102MAKE_MENU(viewer_settings_menu, ID2P(LANG_PLAYLISTVIEWER_SETTINGS),
103 NULL, Icon_Playlist,
104 &show_icons, &show_indices, &track_display);
105
Jonathan Gordone84ff172007-02-11 07:32:58 +0000106
Nils Wallméniusb3113672007-08-05 19:19:39 +0000107MAKE_MENU(playlist_settings, ID2P(LANG_PLAYLISTS), NULL,
Jonathan Gordon02a87172007-03-03 13:52:14 +0000108 Icon_Playlist,
Jonathan Gordon97a4c1e2011-07-20 14:11:15 +0000109 &viewer_settings_menu, &recursive_dir_insert, &warn_on_erase);
Nils Wallméniusb3113672007-08-05 19:19:39 +0000110MAKE_MENU(playlist_options, ID2P(LANG_PLAYLISTS), NULL,
Jonathan Gordon02a87172007-03-03 13:52:14 +0000111 Icon_Playlist,
Jonathan Gordon97a4c1e2011-07-20 14:11:15 +0000112 &create_playlist_item, &view_cur_playlist,
113 &save_playlist, &clear_catalog_directory_item);