Fix FS#12279 - playback starts from the beginning when changing themes.
[maemo-rb.git] / apps / menus / playlist_menu.c
blobbe3ad307c42e853bf083a2e39910dd6941b25fbc
1 /***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
10 * Copyright (C) 2007 Jonathan Gordon
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.
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
20 ****************************************************************************/
22 #include <stdbool.h>
23 #include <string.h>
24 #include <stdio.h>
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"
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"
39 #include "splash.h"
41 int save_playlist_screen(struct playlist_info* playlist)
43 char temp[MAX_PATH+1], *dot;
44 int len;
46 playlist_get_name(playlist, temp, sizeof(temp)-1);
47 len = strlen(temp);
49 dot = strrchr(temp, '.');
50 if (!dot)
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);
59 else if (len > 4 && !strcasecmp(dot, ".m3u"))
60 strcat(temp, "8");
62 if (!kbd_input(temp, sizeof(temp)))
64 playlist_save(playlist, temp);
66 /* reload in case playlist was saved to cwd */
67 reload_directory();
70 return 0;
73 static int playlist_view_(void)
75 playlist_viewer_ex(NULL);
76 return 0;
79 MENUITEM_FUNCTION(create_playlist_item, 0, ID2P(LANG_CREATE_PLAYLIST),
80 (int(*)(void))create_playlist, NULL, NULL, Icon_NOICON);
81 MENUITEM_FUNCTION(view_cur_playlist, 0,
82 ID2P(LANG_VIEW_DYNAMIC_PLAYLIST),
83 (int(*)(void))playlist_view_, NULL, NULL, Icon_NOICON);
84 MENUITEM_FUNCTION(save_playlist, MENU_FUNC_USEPARAM, ID2P(LANG_SAVE_DYNAMIC_PLAYLIST),
85 (int(*)(void*))save_playlist_screen,
86 NULL, NULL, Icon_NOICON);
87 MENUITEM_SETTING(recursive_dir_insert, &global_settings.recursive_dir_insert, NULL);
88 MENUITEM_SETTING(warn_on_erase, &global_settings.warnon_erase_dynplaylist, NULL);
89 static int clear_catalog_directory(void)
91 catalog_set_directory(NULL);
92 settings_save();
93 splash(HZ, ID2P(LANG_RESET_DONE_CLEAR));
94 return false;
96 MENUITEM_FUNCTION(clear_catalog_directory_item, 0, ID2P(LANG_RESET_PLAYLISTCAT_DIR),
97 clear_catalog_directory, NULL, NULL, Icon_file_view_menu);
99 /* Playlist viewer settings submenu */
100 MENUITEM_SETTING(show_icons, &global_settings.playlist_viewer_icons, NULL);
101 MENUITEM_SETTING(show_indices, &global_settings.playlist_viewer_indices, NULL);
102 MENUITEM_SETTING(track_display,
103 &global_settings.playlist_viewer_track_display, NULL);
104 MAKE_MENU(viewer_settings_menu, ID2P(LANG_PLAYLISTVIEWER_SETTINGS),
105 NULL, Icon_Playlist,
106 &show_icons, &show_indices, &track_display);
109 MAKE_MENU(playlist_settings, ID2P(LANG_PLAYLISTS), NULL,
110 Icon_Playlist,
111 &viewer_settings_menu, &recursive_dir_insert, &warn_on_erase);
112 MAKE_MENU(playlist_options, ID2P(LANG_PLAYLISTS), NULL,
113 Icon_Playlist,
114 &create_playlist_item, &view_cur_playlist,
115 &save_playlist, &clear_catalog_directory_item);