summaryrefslogtreecommitdiffstats
path: root/apps/main_menu.c
blob: ec139466cb322f6e4f3bf7b9b01fe3adadf6337b (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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
/***************************************************************************
 *             __________               __   ___.
 *   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 <timefuncs.h>
#include "config.h"
#include "options.h"

#include "menu.h"
#include "tree.h"
#include "lcd.h"
#include "font.h"
#include "action.h"
#include "kernel.h"
#include "main_menu.h"
#include "debug_menu.h"
#include "sprintf.h"
#include <string.h>
#include "settings.h"
#include "settings_menu.h"
#include "power.h"
#include "powermgmt.h"
#include "sound_menu.h"
#include "status.h"
#include "fat.h"
#include "bookmark.h"
#include "buffer.h"
#include "screens.h"
#include "playlist_menu.h"
#include "talk.h"
#if CONFIG_TUNER
#include "radio.h"
#endif
#include "misc.h"
#include "lang.h"
#include "logfdisp.h"
#include "plugin.h"
#include "filetypes.h"
#include "splash.h"

#ifdef HAVE_RECORDING
#include "recording.h"
#endif

#ifdef HAVE_RECORDING

static bool rec_menu_recording_screen(void)
{
    return recording_screen(false);
}

static bool recording_settings(void)
{
    bool ret;
#ifdef HAVE_FMRADIO_IN
    int rec_source = global_settings.rec_source;
#endif

    ret = recording_menu(false);

#ifdef HAVE_FMRADIO_IN
    if (rec_source != global_settings.rec_source)
    {
        if (rec_source == AUDIO_SRC_FMRADIO)
            radio_stop();
        /* If AUDIO_SRC_FMRADIO was selected from something else,
           the recording screen will start the radio */       
    }
#endif

    return ret;
}

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

    /* recording menu */
    static const struct menu_item items[] = {
        { ID2P(LANG_RECORDING_MENU),     rec_menu_recording_screen  },
        { ID2P(LANG_RECORDING_SETTINGS), recording_settings},
    };

    m=menu_init( items, sizeof(items) / sizeof(*items), NULL,
                 NULL, NULL, NULL);
    result = menu_run(m);
    menu_exit(m);

    return result;
}
#endif


#if 0
#ifdef HAVE_LCD_CHARCELLS
static bool do_shutdown(void)
{
    sys_poweroff();
    return false;
}
#endif
bool main_menu(void)
{
    int m;
    bool result;
    int i = 0;
    static bool inside_menu = false;


    /* main menu */
    struct menu_item items[11];

    if(inside_menu) return false;
    inside_menu = true;

    items[i].desc = ID2P(LANG_SOUND_SETTINGS);
    items[i++].function = sound_menu;

    items[i].desc = ID2P(LANG_GENERAL_SETTINGS);
    items[i++].function = settings_menu;

    items[i].desc = ID2P(LANG_MANAGE_MENU);
    items[i++].function = manage_settings_menu;

    items[i].desc = ID2P(LANG_CUSTOM_THEME);
    items[i++].function = custom_theme_browse;

#if CONFIG_TUNER
    if(radio_hardware_present()) {
        items[i].desc = ID2P(LANG_FM_RADIO);
        items[i++].function = radio_screen;
    }
#endif

#ifdef HAVE_RECORDING
    items[i].desc = ID2P(LANG_RECORDING);
    items[i++].function = rec_menu;
#endif

    items[i].desc = ID2P(LANG_PLAYLIST_MENU);
    items[i++].function = playlist_menu;

    items[i].desc = ID2P(LANG_PLUGINS);
    items[i++].function = plugin_browse;

    items[i].desc = ID2P(LANG_INFO);
    items[i++].function = info_menu;

#ifdef HAVE_LCD_CHARCELLS
    items[i].desc = ID2P(LANG_SHUTDOWN);
    items[i++].function = do_shutdown;
#endif
    
    m=menu_init( items, i, NULL, NULL, NULL, NULL );
#ifdef HAVE_LCD_CHARCELLS
    status_set_param(true);
#endif
    result = menu_run(m);
#ifdef HAVE_LCD_CHARCELLS
    status_set_param(false);
#endif
    menu_exit(m);

    inside_menu = false;

    return result;
}
#endif
/* -----------------------------------------------------------------
 * vim: et sw=4 ts=8 sts=4 tw=78
 */