2007-03-01 11:14:46 +00:00
|
|
|
/***************************************************************************
|
|
|
|
* __________ __ ___.
|
|
|
|
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
|
|
|
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
|
|
|
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
|
|
|
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
|
|
|
* \/ \/ \/ \/ \/
|
2007-03-29 22:51:03 +00:00
|
|
|
* $Id$
|
2007-03-01 11:14:46 +00:00
|
|
|
*
|
|
|
|
* Copyright (C) 2007 Jonathan Gordon
|
|
|
|
*
|
2008-06-28 18:10:04 +00:00
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
2007-03-01 11:14:46 +00:00
|
|
|
*
|
|
|
|
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
|
|
|
* KIND, either express or implied.
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <stdbool.h>
|
|
|
|
#include "config.h"
|
2009-01-11 04:03:17 +00:00
|
|
|
#include "appevents.h"
|
2007-03-01 11:14:46 +00:00
|
|
|
#include "menu.h"
|
|
|
|
#include "root_menu.h"
|
|
|
|
#include "lang.h"
|
|
|
|
#include "settings.h"
|
2007-04-09 13:39:37 +00:00
|
|
|
#include "screens.h"
|
2007-03-01 11:14:46 +00:00
|
|
|
#include "kernel.h"
|
|
|
|
#include "debug.h"
|
|
|
|
#include "misc.h"
|
|
|
|
#include "rolo.h"
|
2007-03-01 12:35:24 +00:00
|
|
|
#include "powermgmt.h"
|
2007-04-09 13:39:37 +00:00
|
|
|
#include "power.h"
|
2007-04-25 22:08:00 +00:00
|
|
|
#include "talk.h"
|
|
|
|
#include "audio.h"
|
2007-07-03 08:43:38 +00:00
|
|
|
#include "hotswap.h"
|
2007-03-01 11:14:46 +00:00
|
|
|
#include "backdrop.h"
|
|
|
|
|
|
|
|
/* gui api */
|
|
|
|
#include "list.h"
|
|
|
|
#include "statusbar.h"
|
|
|
|
#include "splash.h"
|
|
|
|
#include "action.h"
|
|
|
|
#include "yesno.h"
|
2008-12-31 05:59:26 +00:00
|
|
|
#include "viewport.h"
|
2007-03-01 11:14:46 +00:00
|
|
|
|
|
|
|
#include "tree.h"
|
2007-03-01 12:18:30 +00:00
|
|
|
#if CONFIG_TUNER
|
2007-03-01 11:14:46 +00:00
|
|
|
#include "radio.h"
|
2007-03-01 12:18:30 +00:00
|
|
|
#endif
|
2007-03-01 11:14:46 +00:00
|
|
|
#ifdef HAVE_RECORDING
|
|
|
|
#include "recording.h"
|
|
|
|
#endif
|
|
|
|
#include "gwps-common.h"
|
|
|
|
#include "bookmark.h"
|
2008-03-26 23:35:34 +00:00
|
|
|
#include "playlist.h"
|
2007-03-01 11:14:46 +00:00
|
|
|
#include "tagtree.h"
|
|
|
|
#include "menus/exported_menus.h"
|
2007-03-01 11:46:26 +00:00
|
|
|
#ifdef HAVE_RTC_ALARM
|
|
|
|
#include "rtc.h"
|
|
|
|
#endif
|
2007-03-07 19:56:15 +00:00
|
|
|
#ifdef HAVE_TAGCACHE
|
|
|
|
#include "tagcache.h"
|
|
|
|
#endif
|
2007-03-01 11:14:46 +00:00
|
|
|
|
|
|
|
struct root_items {
|
|
|
|
int (*function)(void* param);
|
|
|
|
void* param;
|
2007-04-12 15:28:51 +00:00
|
|
|
const struct menu_item_ex *context_menu;
|
2007-03-01 11:14:46 +00:00
|
|
|
};
|
|
|
|
static int last_screen = GO_TO_ROOT; /* unfortunatly needed so we can resume
|
|
|
|
or goto current track based on previous
|
|
|
|
screen */
|
2009-01-11 04:03:17 +00:00
|
|
|
static char current_track_path[MAX_PATH];
|
|
|
|
static void rootmenu_track_changed_callback(void* param)
|
|
|
|
{
|
|
|
|
struct mp3entry *id3 = (struct mp3entry *)param;
|
|
|
|
strncpy(current_track_path, id3->path, MAX_PATH);
|
|
|
|
}
|
2007-03-01 11:14:46 +00:00
|
|
|
static int browser(void* param)
|
|
|
|
{
|
|
|
|
int ret_val;
|
2007-03-07 04:36:02 +00:00
|
|
|
#ifdef HAVE_TAGCACHE
|
2007-03-01 11:14:46 +00:00
|
|
|
struct tree_context* tc = tree_get_context();
|
2007-03-07 04:36:02 +00:00
|
|
|
#endif
|
2007-03-01 11:14:46 +00:00
|
|
|
int filter = SHOW_SUPPORTED;
|
|
|
|
char folder[MAX_PATH] = "/";
|
|
|
|
/* stuff needed to remember position in file browser */
|
|
|
|
static char last_folder[MAX_PATH] = "/";
|
|
|
|
/* and stuff for the database browser */
|
2007-03-07 04:36:02 +00:00
|
|
|
#ifdef HAVE_TAGCACHE
|
2007-03-10 12:51:08 +00:00
|
|
|
static int last_db_dirlevel = 0, last_db_selection = 0;
|
2007-03-07 04:36:02 +00:00
|
|
|
#endif
|
2007-03-01 11:14:46 +00:00
|
|
|
|
2007-03-01 12:18:30 +00:00
|
|
|
switch ((intptr_t)param)
|
2007-03-01 11:14:46 +00:00
|
|
|
{
|
|
|
|
case GO_TO_FILEBROWSER:
|
|
|
|
filter = global_settings.dirfilter;
|
|
|
|
if (global_settings.browse_current &&
|
2008-02-09 15:20:15 +00:00
|
|
|
last_screen == GO_TO_WPS &&
|
2009-01-11 04:03:17 +00:00
|
|
|
current_track_path[0])
|
2007-03-01 11:14:46 +00:00
|
|
|
{
|
2009-01-11 04:03:17 +00:00
|
|
|
strcpy(folder, current_track_path);
|
2007-03-01 11:14:46 +00:00
|
|
|
}
|
2007-07-03 08:43:38 +00:00
|
|
|
#ifdef HAVE_HOTSWAP /* quick hack to stop crashing if you try entering
|
|
|
|
the browser from the menu when you were in the card
|
|
|
|
and it was removed */
|
|
|
|
else if (strchr(last_folder, '<') && (card_detect() == false))
|
|
|
|
strcpy(folder, "/");
|
|
|
|
#endif
|
2007-03-01 11:14:46 +00:00
|
|
|
else
|
2007-03-06 08:21:18 +00:00
|
|
|
strcpy(folder, last_folder);
|
2007-03-01 11:14:46 +00:00
|
|
|
break;
|
2007-03-07 04:36:02 +00:00
|
|
|
#ifdef HAVE_TAGCACHE
|
2007-03-01 11:14:46 +00:00
|
|
|
case GO_TO_DBBROWSER:
|
2007-03-07 19:56:15 +00:00
|
|
|
if (!tagcache_is_usable())
|
2007-03-01 11:14:46 +00:00
|
|
|
{
|
2007-03-08 08:20:30 +00:00
|
|
|
bool reinit_attempted = false;
|
2007-03-07 19:56:15 +00:00
|
|
|
|
|
|
|
/* Now display progress until it's ready or the user exits */
|
|
|
|
while(!tagcache_is_usable())
|
|
|
|
{
|
2007-03-08 08:20:30 +00:00
|
|
|
struct tagcache_stat *stat = tagcache_get_stat();
|
|
|
|
|
|
|
|
/* Allow user to exit */
|
|
|
|
if (action_userabort(HZ/2))
|
|
|
|
break;
|
2007-03-07 19:56:15 +00:00
|
|
|
|
|
|
|
/* Maybe just needs to reboot due to delayed commit */
|
|
|
|
if (stat->commit_delayed)
|
|
|
|
{
|
2008-08-15 08:27:39 +00:00
|
|
|
splash(HZ*2, ID2P(LANG_PLEASE_REBOOT));
|
2007-03-07 19:56:15 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2007-03-08 08:20:30 +00:00
|
|
|
/* Check if ready status is known */
|
|
|
|
if (!stat->readyvalid)
|
|
|
|
{
|
2008-08-15 08:27:39 +00:00
|
|
|
splash(0, str(LANG_TAGCACHE_BUSY));
|
2007-03-08 08:20:30 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Re-init if required */
|
|
|
|
if (!reinit_attempted && !stat->ready &&
|
|
|
|
stat->processed_entries == 0 && stat->commit_step == 0)
|
|
|
|
{
|
|
|
|
/* Prompt the user */
|
|
|
|
reinit_attempted = true;
|
2008-04-26 09:30:24 +00:00
|
|
|
static const char *lines[]={
|
|
|
|
ID2P(LANG_TAGCACHE_BUSY), ID2P(LANG_TAGCACHE_FORCE_UPDATE)};
|
|
|
|
static const struct text_message message={lines, 2};
|
2007-03-08 08:20:30 +00:00
|
|
|
if(gui_syncyesno_run(&message, NULL, NULL) == YESNO_NO)
|
|
|
|
break;
|
|
|
|
int i;
|
|
|
|
FOR_NB_SCREENS(i)
|
|
|
|
screens[i].clear_display();
|
|
|
|
|
|
|
|
/* Start initialisation */
|
|
|
|
tagcache_rebuild();
|
|
|
|
}
|
|
|
|
|
2007-03-07 19:56:15 +00:00
|
|
|
/* Display building progress */
|
2007-08-06 13:08:36 +00:00
|
|
|
static long talked_tick = 0;
|
2007-10-19 15:31:42 +00:00
|
|
|
if(global_settings.talk_menu &&
|
2007-08-06 13:08:36 +00:00
|
|
|
(talked_tick == 0
|
|
|
|
|| TIME_AFTER(current_tick, talked_tick+7*HZ)))
|
|
|
|
{
|
|
|
|
talked_tick = current_tick;
|
|
|
|
if (stat->commit_step > 0)
|
|
|
|
{
|
|
|
|
talk_id(LANG_TAGCACHE_INIT, false);
|
|
|
|
talk_number(stat->commit_step, true);
|
|
|
|
talk_id(VOICE_OF, true);
|
|
|
|
talk_number(tagcache_get_max_commit_step(), true);
|
|
|
|
} else if(stat->processed_entries)
|
|
|
|
{
|
|
|
|
talk_number(stat->processed_entries, false);
|
|
|
|
talk_id(LANG_BUILDING_DATABASE, true);
|
|
|
|
}
|
|
|
|
}
|
2007-03-07 19:56:15 +00:00
|
|
|
if (stat->commit_step > 0)
|
|
|
|
{
|
2008-08-15 08:27:39 +00:00
|
|
|
splashf(0, "%s [%d/%d]",
|
2007-03-07 19:56:15 +00:00
|
|
|
str(LANG_TAGCACHE_INIT), stat->commit_step,
|
|
|
|
tagcache_get_max_commit_step());
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2008-08-15 08:27:39 +00:00
|
|
|
splashf(0, str(LANG_BUILDING_DATABASE),
|
|
|
|
stat->processed_entries);
|
2007-03-07 19:56:15 +00:00
|
|
|
}
|
|
|
|
}
|
2007-03-01 11:14:46 +00:00
|
|
|
}
|
2007-03-07 19:56:15 +00:00
|
|
|
if (!tagcache_is_usable())
|
|
|
|
return GO_TO_PREVIOUS;
|
2007-03-01 11:14:46 +00:00
|
|
|
filter = SHOW_ID3DB;
|
|
|
|
tc->dirlevel = last_db_dirlevel;
|
2007-03-10 12:51:08 +00:00
|
|
|
tc->selected_item = last_db_selection;
|
2007-03-01 11:14:46 +00:00
|
|
|
break;
|
2007-03-07 04:36:02 +00:00
|
|
|
#endif
|
2007-03-01 11:14:46 +00:00
|
|
|
case GO_TO_BROWSEPLUGINS:
|
|
|
|
filter = SHOW_PLUGINS;
|
2008-09-24 20:03:53 +00:00
|
|
|
strncpy(folder, PLUGIN_DIR, MAX_PATH);
|
2007-03-01 11:14:46 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
ret_val = rockbox_browse(folder, filter);
|
2007-03-01 12:18:30 +00:00
|
|
|
switch ((intptr_t)param)
|
2007-03-01 11:14:46 +00:00
|
|
|
{
|
|
|
|
case GO_TO_FILEBROWSER:
|
2007-03-06 08:21:18 +00:00
|
|
|
get_current_file(last_folder, MAX_PATH);
|
2007-03-01 11:14:46 +00:00
|
|
|
break;
|
2007-03-07 04:36:02 +00:00
|
|
|
#ifdef HAVE_TAGCACHE
|
2007-03-01 11:14:46 +00:00
|
|
|
case GO_TO_DBBROWSER:
|
|
|
|
last_db_dirlevel = tc->dirlevel;
|
2007-03-10 12:51:08 +00:00
|
|
|
last_db_selection = tc->selected_item;
|
2007-03-01 11:14:46 +00:00
|
|
|
break;
|
2007-03-07 04:36:02 +00:00
|
|
|
#endif
|
2007-03-01 11:14:46 +00:00
|
|
|
}
|
|
|
|
return ret_val;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int menu(void* param)
|
|
|
|
{
|
|
|
|
(void)param;
|
2008-03-26 03:35:24 +00:00
|
|
|
return do_menu(NULL, 0, NULL, false);
|
2007-03-01 11:14:46 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
#ifdef HAVE_RECORDING
|
|
|
|
static int recscrn(void* param)
|
|
|
|
{
|
|
|
|
(void)param;
|
|
|
|
recording_screen(false);
|
|
|
|
return GO_TO_ROOT;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
static int wpsscrn(void* param)
|
|
|
|
{
|
|
|
|
int ret_val = GO_TO_PREVIOUS;
|
|
|
|
(void)param;
|
|
|
|
if (audio_status())
|
|
|
|
{
|
2007-10-19 15:31:42 +00:00
|
|
|
talk_shutup();
|
2007-03-01 11:14:46 +00:00
|
|
|
ret_val = gui_wps_show();
|
|
|
|
}
|
|
|
|
else if ( global_status.resume_index != -1 )
|
|
|
|
{
|
2007-03-17 09:54:28 +00:00
|
|
|
DEBUGF("Resume index %X offset %lX\n",
|
2007-03-01 11:14:46 +00:00
|
|
|
global_status.resume_index,
|
2007-03-17 10:50:58 +00:00
|
|
|
(unsigned long)global_status.resume_offset);
|
2007-03-01 11:14:46 +00:00
|
|
|
if (playlist_resume() != -1)
|
|
|
|
{
|
|
|
|
playlist_start(global_status.resume_index,
|
|
|
|
global_status.resume_offset);
|
|
|
|
ret_val = gui_wps_show();
|
|
|
|
}
|
|
|
|
}
|
2007-03-17 09:54:28 +00:00
|
|
|
else
|
2007-03-01 11:14:46 +00:00
|
|
|
{
|
2008-08-15 08:27:39 +00:00
|
|
|
splash(HZ*2, ID2P(LANG_NOTHING_TO_RESUME));
|
2007-03-01 11:14:46 +00:00
|
|
|
}
|
|
|
|
return ret_val;
|
|
|
|
}
|
|
|
|
#if CONFIG_TUNER
|
|
|
|
static int radio(void* param)
|
|
|
|
{
|
|
|
|
(void)param;
|
|
|
|
radio_screen();
|
|
|
|
return GO_TO_ROOT;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
static int load_bmarks(void* param)
|
|
|
|
{
|
|
|
|
(void)param;
|
2007-10-12 04:10:08 +00:00
|
|
|
if(bookmark_mrb_load())
|
|
|
|
return GO_TO_WPS;
|
2007-03-01 11:14:46 +00:00
|
|
|
return GO_TO_PREVIOUS;
|
|
|
|
}
|
2007-08-06 13:42:52 +00:00
|
|
|
static int plugins_menu(void* param)
|
|
|
|
{
|
|
|
|
(void)param;
|
|
|
|
MENUITEM_STRINGLIST(plugins_menu_items, ID2P(LANG_PLUGINS), NULL,
|
|
|
|
ID2P(LANG_PLUGIN_GAMES),
|
|
|
|
ID2P(LANG_PLUGIN_APPS), ID2P(LANG_PLUGIN_DEMOS));
|
|
|
|
char *folder;
|
|
|
|
int retval = GO_TO_PREVIOUS;
|
|
|
|
int selection = 0, current = 0;
|
|
|
|
while (retval == GO_TO_PREVIOUS)
|
|
|
|
{
|
2008-03-26 03:35:24 +00:00
|
|
|
selection = do_menu(&plugins_menu_items, ¤t, NULL, false);
|
2007-08-06 13:42:52 +00:00
|
|
|
switch (selection)
|
|
|
|
{
|
|
|
|
case 0:
|
|
|
|
folder = PLUGIN_GAMES_DIR;
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
folder = PLUGIN_APPS_DIR;
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
folder = PLUGIN_DEMOS_DIR;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return selection;
|
|
|
|
}
|
|
|
|
retval = rockbox_browse(folder, SHOW_PLUGINS);
|
|
|
|
}
|
|
|
|
return retval;
|
|
|
|
}
|
2008-12-01 09:28:14 +00:00
|
|
|
int time_screen(void* ignored);
|
2007-08-06 13:42:52 +00:00
|
|
|
|
2007-04-12 15:28:51 +00:00
|
|
|
/* These are all static const'd from apps/menus/ *.c
|
|
|
|
so little hack so we can use them */
|
|
|
|
extern struct menu_item_ex
|
|
|
|
file_menu,
|
2007-04-18 19:46:34 +00:00
|
|
|
#ifdef HAVE_TAGCACHE
|
2007-04-12 15:28:51 +00:00
|
|
|
tagcache_menu,
|
2007-04-18 19:46:34 +00:00
|
|
|
#endif
|
2007-04-12 15:28:51 +00:00
|
|
|
manage_settings,
|
2007-07-03 18:31:13 +00:00
|
|
|
recording_settings_menu,
|
|
|
|
radio_settings_menu,
|
2007-04-12 15:28:51 +00:00
|
|
|
bookmark_settings_menu,
|
|
|
|
system_menu;
|
2007-03-01 11:14:46 +00:00
|
|
|
static const struct root_items items[] = {
|
2007-04-12 15:28:51 +00:00
|
|
|
[GO_TO_FILEBROWSER] = { browser, (void*)GO_TO_FILEBROWSER, &file_menu},
|
2007-04-18 19:46:34 +00:00
|
|
|
#ifdef HAVE_TAGCACHE
|
2007-04-12 15:28:51 +00:00
|
|
|
[GO_TO_DBBROWSER] = { browser, (void*)GO_TO_DBBROWSER, &tagcache_menu },
|
2007-04-18 19:46:34 +00:00
|
|
|
#endif
|
2008-05-22 08:02:48 +00:00
|
|
|
[GO_TO_WPS] = { wpsscrn, NULL, &playback_settings },
|
2007-04-12 15:28:51 +00:00
|
|
|
[GO_TO_MAINMENU] = { menu, NULL, &manage_settings },
|
2007-03-01 11:14:46 +00:00
|
|
|
|
|
|
|
#ifdef HAVE_RECORDING
|
2007-07-03 18:31:13 +00:00
|
|
|
[GO_TO_RECSCREEN] = { recscrn, NULL, &recording_settings_menu },
|
2007-03-01 11:14:46 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#if CONFIG_TUNER
|
2007-07-03 18:31:13 +00:00
|
|
|
[GO_TO_FM] = { radio, NULL, &radio_settings_menu },
|
2007-03-01 11:14:46 +00:00
|
|
|
#endif
|
|
|
|
|
2007-04-12 15:28:51 +00:00
|
|
|
[GO_TO_RECENTBMARKS] = { load_bmarks, NULL, &bookmark_settings_menu },
|
2007-08-06 13:42:52 +00:00
|
|
|
[GO_TO_BROWSEPLUGINS] = { plugins_menu, NULL, NULL },
|
2007-03-01 11:14:46 +00:00
|
|
|
|
|
|
|
};
|
|
|
|
static const int nb_items = sizeof(items)/sizeof(*items);
|
|
|
|
|
2008-07-16 12:10:49 +00:00
|
|
|
static int item_callback(int action, const struct menu_item_ex *this_item) ;
|
2007-03-01 11:14:46 +00:00
|
|
|
|
|
|
|
MENUITEM_RETURNVALUE(file_browser, ID2P(LANG_DIR_BROWSER), GO_TO_FILEBROWSER,
|
2007-03-03 13:52:14 +00:00
|
|
|
NULL, Icon_file_view_menu);
|
2007-03-07 04:36:02 +00:00
|
|
|
#ifdef HAVE_TAGCACHE
|
2007-03-01 11:14:46 +00:00
|
|
|
MENUITEM_RETURNVALUE(db_browser, ID2P(LANG_TAGCACHE), GO_TO_DBBROWSER,
|
2007-03-03 13:52:14 +00:00
|
|
|
NULL, Icon_Audio);
|
2007-03-07 04:36:02 +00:00
|
|
|
#endif
|
2007-03-01 11:14:46 +00:00
|
|
|
MENUITEM_RETURNVALUE(rocks_browser, ID2P(LANG_PLUGINS), GO_TO_BROWSEPLUGINS,
|
2007-03-03 13:52:14 +00:00
|
|
|
NULL, Icon_Plugin);
|
2008-05-03 08:35:14 +00:00
|
|
|
static char *get_wps_item_name(int selected_item, void * data, char *buffer)
|
2007-03-01 11:14:46 +00:00
|
|
|
{
|
|
|
|
(void)selected_item; (void)data; (void)buffer;
|
|
|
|
if (audio_status())
|
2007-03-05 00:32:33 +00:00
|
|
|
return ID2P(LANG_NOW_PLAYING);
|
|
|
|
return ID2P(LANG_RESUME_PLAYBACK);
|
2007-03-01 11:14:46 +00:00
|
|
|
}
|
|
|
|
MENUITEM_RETURNVALUE_DYNTEXT(wps_item, GO_TO_WPS, NULL, get_wps_item_name,
|
2007-10-09 03:48:56 +00:00
|
|
|
NULL, NULL, Icon_Playback_menu);
|
2007-03-01 11:14:46 +00:00
|
|
|
#ifdef HAVE_RECORDING
|
2007-08-05 19:19:39 +00:00
|
|
|
MENUITEM_RETURNVALUE(rec, ID2P(LANG_RECORDING), GO_TO_RECSCREEN,
|
2007-03-03 13:52:14 +00:00
|
|
|
NULL, Icon_Recording);
|
2007-03-01 11:14:46 +00:00
|
|
|
#endif
|
|
|
|
#if CONFIG_TUNER
|
|
|
|
MENUITEM_RETURNVALUE(fm, ID2P(LANG_FM_RADIO), GO_TO_FM,
|
2007-03-03 13:52:14 +00:00
|
|
|
item_callback, Icon_Radio_screen);
|
2007-03-01 11:14:46 +00:00
|
|
|
#endif
|
2007-08-05 19:19:39 +00:00
|
|
|
MENUITEM_RETURNVALUE(menu_, ID2P(LANG_SETTINGS), GO_TO_MAINMENU,
|
2007-03-03 13:52:14 +00:00
|
|
|
NULL, Icon_Submenu_Entered);
|
2007-03-01 11:14:46 +00:00
|
|
|
MENUITEM_RETURNVALUE(bookmarks, ID2P(LANG_BOOKMARK_MENU_RECENT_BOOKMARKS),
|
|
|
|
GO_TO_RECENTBMARKS, item_callback,
|
2007-03-03 13:52:14 +00:00
|
|
|
Icon_Bookmark);
|
2007-03-01 11:14:46 +00:00
|
|
|
#ifdef HAVE_LCD_CHARCELLS
|
|
|
|
static int do_shutdown(void)
|
|
|
|
{
|
2007-04-09 13:54:38 +00:00
|
|
|
#if CONFIG_CHARGING
|
2007-04-09 13:39:37 +00:00
|
|
|
if (charger_inserted())
|
|
|
|
charging_splash();
|
|
|
|
else
|
2007-04-09 13:54:38 +00:00
|
|
|
#endif
|
2007-04-09 13:39:37 +00:00
|
|
|
sys_poweroff();
|
2007-03-01 11:14:46 +00:00
|
|
|
return 0;
|
|
|
|
}
|
2007-03-17 12:33:34 +00:00
|
|
|
MENUITEM_FUNCTION(do_shutdown_item, 0, ID2P(LANG_SHUTDOWN),
|
2007-03-18 07:25:01 +00:00
|
|
|
do_shutdown, NULL, NULL, Icon_NOICON);
|
2007-03-01 11:14:46 +00:00
|
|
|
#endif
|
|
|
|
MAKE_MENU(root_menu_, ID2P(LANG_ROCKBOX_TITLE),
|
2007-07-11 02:22:03 +00:00
|
|
|
item_callback, Icon_Rockbox,
|
2007-03-07 04:36:02 +00:00
|
|
|
&bookmarks, &file_browser,
|
|
|
|
#ifdef HAVE_TAGCACHE
|
|
|
|
&db_browser,
|
|
|
|
#endif
|
2007-03-01 11:14:46 +00:00
|
|
|
&wps_item, &menu_,
|
|
|
|
#ifdef HAVE_RECORDING
|
|
|
|
&rec,
|
|
|
|
#endif
|
|
|
|
#if CONFIG_TUNER
|
|
|
|
&fm,
|
|
|
|
#endif
|
|
|
|
&playlist_options, &rocks_browser, &info_menu
|
|
|
|
|
|
|
|
#ifdef HAVE_LCD_CHARCELLS
|
|
|
|
,&do_shutdown_item
|
|
|
|
#endif
|
|
|
|
);
|
|
|
|
|
2008-07-16 12:10:49 +00:00
|
|
|
static int item_callback(int action, const struct menu_item_ex *this_item)
|
2007-03-01 11:14:46 +00:00
|
|
|
{
|
|
|
|
switch (action)
|
|
|
|
{
|
2007-07-11 02:22:03 +00:00
|
|
|
case ACTION_TREE_STOP:
|
|
|
|
return ACTION_REDRAW;
|
2007-03-01 11:14:46 +00:00
|
|
|
case ACTION_REQUEST_MENUITEM:
|
|
|
|
#if CONFIG_TUNER
|
|
|
|
if (this_item == &fm)
|
|
|
|
{
|
|
|
|
if (radio_hardware_present() == 0)
|
|
|
|
return ACTION_EXIT_MENUITEM;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
#endif
|
|
|
|
if (this_item == &bookmarks)
|
|
|
|
{
|
|
|
|
if (global_settings.usemrb == 0)
|
|
|
|
return ACTION_EXIT_MENUITEM;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return action;
|
|
|
|
}
|
2007-03-05 13:36:00 +00:00
|
|
|
static int get_selection(int last_screen)
|
|
|
|
{
|
|
|
|
unsigned int i;
|
|
|
|
for(i=0; i< sizeof(root_menu__)/sizeof(*root_menu__); i++)
|
|
|
|
{
|
2007-04-25 10:41:17 +00:00
|
|
|
if (((root_menu__[i]->flags&MENU_TYPE_MASK) == MT_RETURN_VALUE) &&
|
2007-03-05 13:36:00 +00:00
|
|
|
(root_menu__[i]->value == last_screen))
|
|
|
|
{
|
|
|
|
return i;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
2007-03-01 11:14:46 +00:00
|
|
|
|
2007-03-29 14:19:28 +00:00
|
|
|
static inline int load_screen(int screen)
|
|
|
|
{
|
|
|
|
/* set the global_status.last_screen before entering,
|
|
|
|
if we dont we will always return to the wrong screen on boot */
|
|
|
|
int old_previous = last_screen;
|
|
|
|
int ret_val;
|
|
|
|
if (screen <= GO_TO_ROOT)
|
|
|
|
return screen;
|
|
|
|
if (screen == old_previous)
|
|
|
|
old_previous = GO_TO_ROOT;
|
|
|
|
global_status.last_screen = (char)screen;
|
|
|
|
status_save();
|
|
|
|
ret_val = items[screen].function(items[screen].param);
|
2007-03-31 21:59:57 +00:00
|
|
|
last_screen = screen;
|
2007-03-29 14:19:28 +00:00
|
|
|
if (ret_val == GO_TO_PREVIOUS)
|
|
|
|
last_screen = old_previous;
|
|
|
|
return ret_val;
|
|
|
|
}
|
2007-04-12 15:28:51 +00:00
|
|
|
static int load_context_screen(int selection)
|
|
|
|
{
|
|
|
|
const struct menu_item_ex *context_menu = NULL;
|
2007-04-25 10:41:17 +00:00
|
|
|
if ((root_menu__[selection]->flags&MENU_TYPE_MASK) == MT_RETURN_VALUE)
|
2007-04-12 15:28:51 +00:00
|
|
|
{
|
|
|
|
int item = root_menu__[selection]->value;
|
|
|
|
context_menu = items[item].context_menu;
|
|
|
|
}
|
|
|
|
/* special cases */
|
|
|
|
else if (root_menu__[selection] == &info_menu)
|
|
|
|
{
|
|
|
|
context_menu = &system_menu;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (context_menu)
|
2008-03-26 03:35:24 +00:00
|
|
|
return do_menu(context_menu, NULL, NULL, false);
|
2007-04-12 15:28:51 +00:00
|
|
|
else
|
|
|
|
return GO_TO_PREVIOUS;
|
|
|
|
}
|
2007-10-12 04:20:20 +00:00
|
|
|
|
|
|
|
static int previous_music = GO_TO_WPS;
|
|
|
|
|
|
|
|
void previous_music_is_wps(void)
|
|
|
|
{
|
|
|
|
previous_music = GO_TO_WPS;
|
|
|
|
}
|
|
|
|
|
2007-03-01 11:14:46 +00:00
|
|
|
void root_menu(void)
|
|
|
|
{
|
|
|
|
int previous_browser = GO_TO_FILEBROWSER;
|
2007-03-29 14:19:28 +00:00
|
|
|
int next_screen = GO_TO_ROOT;
|
2007-03-01 11:14:46 +00:00
|
|
|
int selected = 0;
|
|
|
|
|
|
|
|
if (global_settings.start_in_screen == 0)
|
2007-03-29 14:19:28 +00:00
|
|
|
next_screen = (int)global_status.last_screen;
|
|
|
|
else next_screen = global_settings.start_in_screen - 2;
|
2009-01-11 04:03:17 +00:00
|
|
|
add_event(PLAYBACK_EVENT_TRACK_CHANGE, false, rootmenu_track_changed_callback);
|
2007-03-07 01:16:25 +00:00
|
|
|
#ifdef HAVE_RTC_ALARM
|
|
|
|
if ( rtc_check_alarm_started(true) )
|
|
|
|
{
|
|
|
|
rtc_enable_alarm(false);
|
2007-03-29 14:19:28 +00:00
|
|
|
next_screen = GO_TO_WPS;
|
2007-03-07 01:16:25 +00:00
|
|
|
#if CONFIG_TUNER
|
|
|
|
if (global_settings.alarm_wake_up_screen == ALARM_START_FM)
|
2007-03-29 14:19:28 +00:00
|
|
|
next_screen = GO_TO_FM;
|
2007-03-07 01:16:25 +00:00
|
|
|
#endif
|
|
|
|
#ifdef HAVE_RECORDING
|
|
|
|
if (global_settings.alarm_wake_up_screen == ALARM_START_REC)
|
2007-03-07 01:59:29 +00:00
|
|
|
{
|
|
|
|
recording_start_automatic = true;
|
2007-03-29 14:19:28 +00:00
|
|
|
next_screen = GO_TO_RECSCREEN;
|
2007-03-07 01:59:29 +00:00
|
|
|
}
|
2007-03-07 01:16:25 +00:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
#endif /* HAVE_RTC_ALARM */
|
|
|
|
|
2007-03-08 00:37:58 +00:00
|
|
|
#ifdef HAVE_HEADPHONE_DETECTION
|
2007-03-29 14:19:28 +00:00
|
|
|
if (next_screen == GO_TO_WPS &&
|
2007-03-08 00:37:58 +00:00
|
|
|
(global_settings.unplug_autoresume && !headphones_inserted() ))
|
2007-03-29 14:19:28 +00:00
|
|
|
next_screen = GO_TO_ROOT;
|
2007-03-08 00:37:58 +00:00
|
|
|
#endif
|
|
|
|
|
2007-03-01 11:14:46 +00:00
|
|
|
while (true)
|
|
|
|
{
|
2007-03-29 14:19:28 +00:00
|
|
|
switch (next_screen)
|
2007-03-01 11:14:46 +00:00
|
|
|
{
|
2007-03-27 06:38:11 +00:00
|
|
|
case MENU_ATTACHED_USB:
|
|
|
|
case MENU_SELECTED_EXIT:
|
|
|
|
/* fall through */
|
2007-03-01 11:14:46 +00:00
|
|
|
case GO_TO_ROOT:
|
2007-03-07 10:13:07 +00:00
|
|
|
if (last_screen != GO_TO_ROOT)
|
|
|
|
selected = get_selection(last_screen);
|
2008-03-26 03:35:24 +00:00
|
|
|
next_screen = do_menu(&root_menu_, &selected, NULL, false);
|
2007-03-29 14:19:28 +00:00
|
|
|
if (next_screen != GO_TO_PREVIOUS)
|
|
|
|
last_screen = GO_TO_ROOT;
|
2007-03-01 11:14:46 +00:00
|
|
|
break;
|
2007-03-06 13:35:15 +00:00
|
|
|
|
2007-03-01 11:14:46 +00:00
|
|
|
case GO_TO_PREVIOUS:
|
2007-03-29 14:19:28 +00:00
|
|
|
next_screen = last_screen;
|
2007-03-01 11:14:46 +00:00
|
|
|
break;
|
2007-03-06 13:35:15 +00:00
|
|
|
|
2007-03-01 11:14:46 +00:00
|
|
|
case GO_TO_PREVIOUS_BROWSER:
|
2007-03-29 14:19:28 +00:00
|
|
|
next_screen = previous_browser;
|
2007-03-01 11:14:46 +00:00
|
|
|
break;
|
2007-03-06 13:35:15 +00:00
|
|
|
|
2007-03-01 11:14:46 +00:00
|
|
|
case GO_TO_PREVIOUS_MUSIC:
|
2007-03-29 14:19:28 +00:00
|
|
|
next_screen = previous_music;
|
2007-03-01 11:14:46 +00:00
|
|
|
break;
|
2007-04-12 15:28:51 +00:00
|
|
|
case GO_TO_ROOTITEM_CONTEXT:
|
|
|
|
next_screen = load_context_screen(selected);
|
|
|
|
break;
|
2007-03-29 14:19:28 +00:00
|
|
|
default:
|
|
|
|
if (next_screen == GO_TO_FILEBROWSER
|
2007-03-09 16:54:35 +00:00
|
|
|
#ifdef HAVE_TAGCACHE
|
2007-03-29 14:19:28 +00:00
|
|
|
|| next_screen == GO_TO_DBBROWSER
|
2007-03-09 16:54:35 +00:00
|
|
|
#endif
|
2007-03-29 14:19:28 +00:00
|
|
|
)
|
|
|
|
previous_browser = next_screen;
|
|
|
|
if (next_screen == GO_TO_WPS
|
2007-04-05 02:50:43 +00:00
|
|
|
#if CONFIG_TUNER
|
2007-03-29 14:19:28 +00:00
|
|
|
|| next_screen == GO_TO_FM
|
2007-03-09 16:54:35 +00:00
|
|
|
#endif
|
2007-03-29 14:19:28 +00:00
|
|
|
)
|
|
|
|
previous_music = next_screen;
|
|
|
|
next_screen = load_screen(next_screen);
|
|
|
|
break;
|
|
|
|
} /* switch() */
|
2007-03-01 11:14:46 +00:00
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|