summaryrefslogtreecommitdiff
path: root/apps/playlist_menu.c
blob: 4223e3cf7285d096224820b8d6fde66a607486f6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
/***************************************************************************
 *             __________               __   ___.
 *   Open      \______   \ ____   ____ |  | _\_ |__   _______  ___
 *   Source     |       _//  _ \_/ ___\|  |/ /| __ \ /  _ \  \/  /
 *   Jukebox    |    |   (  <_> )  \___|    < | \_\ (  <_> > <  <
 *   Firmware   |____|_  /\____/ \___  >__|_ \|___  /\____/__/\_ \
 *                     \/            \/     \/    \/            \/
 * $Id$
 *
 * Copyright (C) 2002 Björn Stenberg
 *
 * All files in this archive are subject to the GNU General Public License.
 * See the file COPYING in the source tree root for full license agreement.
 *
 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
 * KIND, either express or implied.
 *
 ****************************************************************************/

#include <string.h>

#include "menu.h"
#include "file.h"
#include "keyboard.h"
#include "playlist.h"
#include "tree.h"
#include "settings.h"

#include "lang.h"

#define DEFAULT_PLAYLIST_NAME "/dynamic.m3u"

static bool save_playlist(void)
{
    char filename[MAX_PATH+1];

    strncpy(filename, DEFAULT_PLAYLIST_NAME, sizeof(filename));

    if (!kbd_input(filename, sizeof(filename)))
    {
        playlist_save(filename);
        
        /* reload in case playlist was saved to cwd */
        reload_directory();
    }

    return false;
}

static bool recurse_directory(void)
{
    char* names[] = { str(LANG_OFF), 
                      str(LANG_ON),
                      str(LANG_RESUME_SETTING_ASK) };

    return set_option( str(LANG_RECURSE_DIRECTORY),
                       &global_settings.recursive_dir_insert, INT, names, 3,
                       NULL );
}

bool playlist_menu(void)
{
    int m;
    bool result;

    struct menu_items items[] = {
        { str(LANG_CREATE_PLAYLIST),    create_playlist   },
        { str(LANG_SAVE_DYNAMIC_PLAYLIST), save_playlist  },
        { str(LANG_RECURSE_DIRECTORY), recurse_directory  },
    };
    
    m = menu_init( items, sizeof items / sizeof(struct menu_items) );
    result = menu_run(m);
    menu_exit(m);
    return result;
}