Jonathan Gordon | 4718a1e | 2007-02-08 04:33:41 +0000 | [diff] [blame] | 1 | |
| 2 | /*************************************************************************** |
| 3 | * __________ __ ___. |
| 4 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ |
| 5 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / |
| 6 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < |
| 7 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ |
| 8 | * \/ \/ \/ \/ \/ |
Jonathan Gordon | 4e73b53 | 2007-02-13 00:32:17 +0000 | [diff] [blame] | 9 | * $Id$ |
Jonathan Gordon | 4718a1e | 2007-02-08 04:33:41 +0000 | [diff] [blame] | 10 | * |
| 11 | * Copyright (C) 2007 Jonathan Gordon |
| 12 | * |
Daniel Stenberg | 2acc0ac | 2008-06-28 18:10:04 +0000 | [diff] [blame^] | 13 | * This program is free software; you can redistribute it and/or |
| 14 | * modify it under the terms of the GNU General Public License |
| 15 | * as published by the Free Software Foundation; either version 2 |
| 16 | * of the License, or (at your option) any later version. |
Jonathan Gordon | 4718a1e | 2007-02-08 04:33:41 +0000 | [diff] [blame] | 17 | * |
| 18 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY |
| 19 | * KIND, either express or implied. |
| 20 | * |
| 21 | ****************************************************************************/ |
| 22 | |
| 23 | #include <stdbool.h> |
| 24 | #include <stddef.h> |
| 25 | #include <limits.h> |
Jonathan Gordon | e84ff17 | 2007-02-11 07:32:58 +0000 | [diff] [blame] | 26 | #include <string.h> |
Jonathan Gordon | 4718a1e | 2007-02-08 04:33:41 +0000 | [diff] [blame] | 27 | #include "config.h" |
| 28 | #include "lang.h" |
| 29 | #include "action.h" |
| 30 | #include "settings.h" |
| 31 | #include "menu.h" |
| 32 | #include "playlist_menu.h" |
| 33 | |
Jonathan Gordon | e84ff17 | 2007-02-11 07:32:58 +0000 | [diff] [blame] | 34 | #include "menu.h" |
| 35 | #include "file.h" |
| 36 | #include "keyboard.h" |
| 37 | #include "playlist.h" |
| 38 | #include "tree.h" |
| 39 | #include "playlist_viewer.h" |
| 40 | #include "talk.h" |
| 41 | #include "playlist_catalog.h" |
Jonathan Gordon | 4718a1e | 2007-02-08 04:33:41 +0000 | [diff] [blame] | 42 | |
Jonathan Gordon | e84ff17 | 2007-02-11 07:32:58 +0000 | [diff] [blame] | 43 | int save_playlist_screen(struct playlist_info* playlist) |
| 44 | { |
| 45 | char temp[MAX_PATH+1]; |
| 46 | int len; |
| 47 | |
| 48 | playlist_get_name(playlist, temp, sizeof(temp)); |
| 49 | len = strlen(temp); |
| 50 | |
| 51 | if (len > 4 && !strcasecmp(&temp[len-4], ".m3u")) |
| 52 | strcat(temp, "8"); |
| 53 | |
| 54 | if (len <= 5 || strcasecmp(&temp[len-5], ".m3u8")) |
| 55 | strcpy(temp, DEFAULT_DYNAMIC_PLAYLIST_NAME); |
| 56 | |
| 57 | if (!kbd_input(temp, sizeof(temp))) |
| 58 | { |
| 59 | playlist_save(playlist, temp); |
| 60 | |
| 61 | /* reload in case playlist was saved to cwd */ |
| 62 | reload_directory(); |
| 63 | } |
| 64 | |
| 65 | return 0; |
| 66 | } |
Jonathan Gordon | daf6694 | 2007-03-17 12:33:34 +0000 | [diff] [blame] | 67 | MENUITEM_FUNCTION(create_playlist_item, 0, ID2P(LANG_CREATE_PLAYLIST), |
Jonathan Gordon | e54d8e1 | 2007-03-18 07:03:43 +0000 | [diff] [blame] | 68 | (int(*)(void))create_playlist, NULL, NULL, Icon_NOICON); |
Jonathan Gordon | daf6694 | 2007-03-17 12:33:34 +0000 | [diff] [blame] | 69 | MENUITEM_FUNCTION(view_playlist, 0, ID2P(LANG_VIEW_DYNAMIC_PLAYLIST), |
Jonathan Gordon | e54d8e1 | 2007-03-18 07:03:43 +0000 | [diff] [blame] | 70 | (int(*)(void))playlist_viewer, NULL, NULL, Icon_NOICON); |
Jonathan Gordon | daf6694 | 2007-03-17 12:33:34 +0000 | [diff] [blame] | 71 | MENUITEM_FUNCTION(save_playlist, MENU_FUNC_USEPARAM, ID2P(LANG_SAVE_DYNAMIC_PLAYLIST), |
| 72 | (int(*)(void*))save_playlist_screen, |
Jonathan Gordon | e54d8e1 | 2007-03-18 07:03:43 +0000 | [diff] [blame] | 73 | NULL, NULL, Icon_NOICON); |
Jonathan Gordon | 9e23e9d | 2007-11-01 13:41:16 +0000 | [diff] [blame] | 74 | MENUITEM_FUNCTION(catalog, 0, ID2P(LANG_CATALOG_VIEW), |
Jonathan Gordon | daf6694 | 2007-03-17 12:33:34 +0000 | [diff] [blame] | 75 | (int(*)(void))catalog_view_playlists, |
Jonathan Gordon | e54d8e1 | 2007-03-18 07:03:43 +0000 | [diff] [blame] | 76 | NULL, NULL, Icon_NOICON); |
Jonathan Gordon | e84ff17 | 2007-02-11 07:32:58 +0000 | [diff] [blame] | 77 | MENUITEM_SETTING(recursive_dir_insert, &global_settings.recursive_dir_insert, NULL); |
| 78 | MENUITEM_SETTING(warn_on_erase, &global_settings.warnon_erase_dynplaylist, NULL); |
| 79 | |
Nils Wallménius | b311367 | 2007-08-05 19:19:39 +0000 | [diff] [blame] | 80 | MAKE_MENU(playlist_settings, ID2P(LANG_PLAYLISTS), NULL, |
Jonathan Gordon | 02a8717 | 2007-03-03 13:52:14 +0000 | [diff] [blame] | 81 | Icon_Playlist, |
Jonathan Gordon | e84ff17 | 2007-02-11 07:32:58 +0000 | [diff] [blame] | 82 | &recursive_dir_insert, &warn_on_erase); |
Nils Wallménius | b311367 | 2007-08-05 19:19:39 +0000 | [diff] [blame] | 83 | MAKE_MENU(playlist_options, ID2P(LANG_PLAYLISTS), NULL, |
Jonathan Gordon | 02a8717 | 2007-03-03 13:52:14 +0000 | [diff] [blame] | 84 | Icon_Playlist, |
Jonathan Gordon | 91cb68a | 2007-03-01 11:14:46 +0000 | [diff] [blame] | 85 | &create_playlist_item, &view_playlist, &save_playlist, &catalog); |
Jonathan Gordon | e84ff17 | 2007-02-11 07:32:58 +0000 | [diff] [blame] | 86 | |