Jonathan Gordon | 4718a1e | 2007-02-08 04:33:41 +0000 | [diff] [blame] | 1 | /*************************************************************************** |
| 2 | * __________ __ ___. |
| 3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ |
| 4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / |
| 5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < |
| 6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ |
| 7 | * \/ \/ \/ \/ \/ |
Jonathan Gordon | 4e73b53 | 2007-02-13 00:32:17 +0000 | [diff] [blame] | 8 | * $Id$ |
Jonathan Gordon | 4718a1e | 2007-02-08 04:33:41 +0000 | [diff] [blame] | 9 | * |
| 10 | * Copyright (C) 2007 Jonathan Gordon |
| 11 | * |
Daniel Stenberg | 2acc0ac | 2008-06-28 18:10:04 +0000 | [diff] [blame] | 12 | * 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 Gordon | 4718a1e | 2007-02-08 04:33:41 +0000 | [diff] [blame] | 16 | * |
| 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 Gordon | e84ff17 | 2007-02-11 07:32:58 +0000 | [diff] [blame] | 23 | #include <string.h> |
Jonathan Gordon | 97a4c1e | 2011-07-20 14:11:15 +0000 | [diff] [blame] | 24 | #include <stdio.h> |
Jonathan Gordon | 4718a1e | 2007-02-08 04:33:41 +0000 | [diff] [blame] | 25 | #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 Gordon | e84ff17 | 2007-02-11 07:32:58 +0000 | [diff] [blame] | 32 | #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 Gordon | 97a4c1e | 2011-07-20 14:11:15 +0000 | [diff] [blame] | 39 | #include "splash.h" |
Jonathan Gordon | 4718a1e | 2007-02-08 04:33:41 +0000 | [diff] [blame] | 40 | |
Jonathan Gordon | e84ff17 | 2007-02-11 07:32:58 +0000 | [diff] [blame] | 41 | int save_playlist_screen(struct playlist_info* playlist) |
| 42 | { |
Jonathan Gordon | 97a4c1e | 2011-07-20 14:11:15 +0000 | [diff] [blame] | 43 | char temp[MAX_PATH+1], *dot; |
Jonathan Gordon | e84ff17 | 2007-02-11 07:32:58 +0000 | [diff] [blame] | 44 | int len; |
Jonathan Gordon | 97a4c1e | 2011-07-20 14:11:15 +0000 | [diff] [blame] | 45 | |
Nils Wallménius | f30add4 | 2010-08-21 16:14:18 +0000 | [diff] [blame] | 46 | playlist_get_name(playlist, temp, sizeof(temp)-1); |
Jonathan Gordon | e84ff17 | 2007-02-11 07:32:58 +0000 | [diff] [blame] | 47 | len = strlen(temp); |
| 48 | |
Jonathan Gordon | 97a4c1e | 2011-07-20 14:11:15 +0000 | [diff] [blame] | 49 | 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 Gordon | e84ff17 | 2007-02-11 07:32:58 +0000 | [diff] [blame] | 60 | strcat(temp, "8"); |
Jonathan Gordon | e84ff17 | 2007-02-11 07:32:58 +0000 | [diff] [blame] | 61 | |
| 62 | if (!kbd_input(temp, sizeof(temp))) |
| 63 | { |
Thomas Martitz | bebf71a | 2014-04-08 22:52:37 +0200 | [diff] [blame] | 64 | playlist_save(playlist, temp, NULL, 0); |
Jonathan Gordon | e84ff17 | 2007-02-11 07:32:58 +0000 | [diff] [blame] | 65 | |
| 66 | /* reload in case playlist was saved to cwd */ |
| 67 | reload_directory(); |
| 68 | } |
| 69 | |
| 70 | return 0; |
| 71 | } |
Thomas Martitz | c19e536 | 2010-02-20 19:06:39 +0000 | [diff] [blame] | 72 | |
| 73 | static int playlist_view_(void) |
| 74 | { |
Jonathan Gordon | 97a4c1e | 2011-07-20 14:11:15 +0000 | [diff] [blame] | 75 | playlist_viewer_ex(NULL); |
| 76 | return 0; |
Thomas Martitz | c19e536 | 2010-02-20 19:06:39 +0000 | [diff] [blame] | 77 | } |
Jonathan Gordon | daf6694 | 2007-03-17 12:33:34 +0000 | [diff] [blame] | 78 | MENUITEM_FUNCTION(create_playlist_item, 0, ID2P(LANG_CREATE_PLAYLIST), |
William Wilgus | dd40c46 | 2018-10-15 23:04:04 -0400 | [diff] [blame] | 79 | create_playlist, NULL, NULL, Icon_NOICON); |
Jonathan Gordon | 97a4c1e | 2011-07-20 14:11:15 +0000 | [diff] [blame] | 80 | MENUITEM_FUNCTION(view_cur_playlist, 0, |
Jeffrey Goode | 16e0c57 | 2010-05-07 03:21:12 +0000 | [diff] [blame] | 81 | ID2P(LANG_VIEW_DYNAMIC_PLAYLIST), |
William Wilgus | dd40c46 | 2018-10-15 23:04:04 -0400 | [diff] [blame] | 82 | playlist_view_, NULL, NULL, Icon_NOICON); |
Jonathan Gordon | daf6694 | 2007-03-17 12:33:34 +0000 | [diff] [blame] | 83 | MENUITEM_FUNCTION(save_playlist, MENU_FUNC_USEPARAM, ID2P(LANG_SAVE_DYNAMIC_PLAYLIST), |
William Wilgus | dd40c46 | 2018-10-15 23:04:04 -0400 | [diff] [blame] | 84 | save_playlist_screen, NULL, NULL, Icon_NOICON); |
Jonathan Gordon | e84ff17 | 2007-02-11 07:32:58 +0000 | [diff] [blame] | 85 | MENUITEM_SETTING(recursive_dir_insert, &global_settings.recursive_dir_insert, NULL); |
| 86 | MENUITEM_SETTING(warn_on_erase, &global_settings.warnon_erase_dynplaylist, NULL); |
Jonathan Gordon | 97a4c1e | 2011-07-20 14:11:15 +0000 | [diff] [blame] | 87 | static 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 | } |
| 94 | MENUITEM_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 */ |
| 98 | MENUITEM_SETTING(show_icons, &global_settings.playlist_viewer_icons, NULL); |
| 99 | MENUITEM_SETTING(show_indices, &global_settings.playlist_viewer_indices, NULL); |
| 100 | MENUITEM_SETTING(track_display, |
| 101 | &global_settings.playlist_viewer_track_display, NULL); |
| 102 | MAKE_MENU(viewer_settings_menu, ID2P(LANG_PLAYLISTVIEWER_SETTINGS), |
| 103 | NULL, Icon_Playlist, |
| 104 | &show_icons, &show_indices, &track_display); |
| 105 | |
Jonathan Gordon | e84ff17 | 2007-02-11 07:32:58 +0000 | [diff] [blame] | 106 | |
Nils Wallménius | b311367 | 2007-08-05 19:19:39 +0000 | [diff] [blame] | 107 | MAKE_MENU(playlist_settings, ID2P(LANG_PLAYLISTS), NULL, |
Jonathan Gordon | 02a8717 | 2007-03-03 13:52:14 +0000 | [diff] [blame] | 108 | Icon_Playlist, |
Jonathan Gordon | 97a4c1e | 2011-07-20 14:11:15 +0000 | [diff] [blame] | 109 | &viewer_settings_menu, &recursive_dir_insert, &warn_on_erase); |
Nils Wallménius | b311367 | 2007-08-05 19:19:39 +0000 | [diff] [blame] | 110 | MAKE_MENU(playlist_options, ID2P(LANG_PLAYLISTS), NULL, |
Jonathan Gordon | 02a8717 | 2007-03-03 13:52:14 +0000 | [diff] [blame] | 111 | Icon_Playlist, |
Jonathan Gordon | 97a4c1e | 2011-07-20 14:11:15 +0000 | [diff] [blame] | 112 | &create_playlist_item, &view_cur_playlist, |
| 113 | &save_playlist, &clear_catalog_directory_item); |