Jonathan Gordon | 91cb68a | 2007-03-01 11:14:46 +0000 | [diff] [blame] | 1 | /*************************************************************************** |
| 2 | * __________ __ ___. |
| 3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ |
| 4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / |
| 5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < |
| 6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ |
| 7 | * \/ \/ \/ \/ \/ |
Peter D'Hoye | 4d28b2f | 2007-03-29 22:51:03 +0000 | [diff] [blame] | 8 | * $Id$ |
Jonathan Gordon | 91cb68a | 2007-03-01 11:14:46 +0000 | [diff] [blame] | 9 | * |
| 10 | * Copyright (C) 2007 Jonathan Gordon |
| 11 | * |
Daniel Stenberg | 2acc0ac | 2008-06-28 18:10:04 +0000 | [diff] [blame] | 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. |
Jonathan Gordon | 91cb68a | 2007-03-01 11:14:46 +0000 | [diff] [blame] | 16 | * |
| 17 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY |
| 18 | * KIND, either express or implied. |
| 19 | * |
| 20 | ****************************************************************************/ |
| 21 | #include <stdio.h> |
Jonathan Gordon | 91cb68a | 2007-03-01 11:14:46 +0000 | [diff] [blame] | 22 | #include <stdlib.h> |
| 23 | #include <stdbool.h> |
Thomas Martitz | 50a6ca3 | 2010-05-06 21:04:40 +0000 | [diff] [blame] | 24 | #include "string-extra.h" |
Jonathan Gordon | 91cb68a | 2007-03-01 11:14:46 +0000 | [diff] [blame] | 25 | #include "config.h" |
Jonathan Gordon | b84fe02 | 2009-01-11 04:03:17 +0000 | [diff] [blame] | 26 | #include "appevents.h" |
Jonathan Gordon | 91cb68a | 2007-03-01 11:14:46 +0000 | [diff] [blame] | 27 | #include "menu.h" |
| 28 | #include "root_menu.h" |
| 29 | #include "lang.h" |
| 30 | #include "settings.h" |
Jens Arnold | 178c565 | 2007-04-09 13:39:37 +0000 | [diff] [blame] | 31 | #include "screens.h" |
Jonathan Gordon | 91cb68a | 2007-03-01 11:14:46 +0000 | [diff] [blame] | 32 | #include "kernel.h" |
| 33 | #include "debug.h" |
| 34 | #include "misc.h" |
| 35 | #include "rolo.h" |
Jonathan Gordon | 5462a91 | 2007-03-01 12:35:24 +0000 | [diff] [blame] | 36 | #include "powermgmt.h" |
Jens Arnold | 178c565 | 2007-04-09 13:39:37 +0000 | [diff] [blame] | 37 | #include "power.h" |
Jonathan Gordon | 91cb68a | 2007-03-01 11:14:46 +0000 | [diff] [blame] | 38 | #include "talk.h" |
| 39 | #include "audio.h" |
Jonathan Gordon | 101693f | 2011-11-15 13:22:02 +0000 | [diff] [blame] | 40 | #include "shortcuts.h" |
Nicolas Pennequin | 1cf2ec3 | 2007-04-25 22:08:00 +0000 | [diff] [blame] | 41 | |
Thomas Martitz | 1ecb753 | 2009-11-26 00:37:27 +0000 | [diff] [blame] | 42 | #ifdef HAVE_HOTSWAP |
| 43 | #include "storage.h" |
Thomas Martitz | 706e6b7 | 2014-02-18 07:11:11 +0100 | [diff] [blame] | 44 | #include "mv.h" |
Thomas Martitz | 1ecb753 | 2009-11-26 00:37:27 +0000 | [diff] [blame] | 45 | #endif |
Jonathan Gordon | 91cb68a | 2007-03-01 11:14:46 +0000 | [diff] [blame] | 46 | /* gui api */ |
| 47 | #include "list.h" |
Jonathan Gordon | 91cb68a | 2007-03-01 11:14:46 +0000 | [diff] [blame] | 48 | #include "splash.h" |
Jonathan Gordon | 91cb68a | 2007-03-01 11:14:46 +0000 | [diff] [blame] | 49 | #include "action.h" |
| 50 | #include "yesno.h" |
Jonathan Gordon | e385ee1 | 2008-12-31 05:59:26 +0000 | [diff] [blame] | 51 | #include "viewport.h" |
Jonathan Gordon | 91cb68a | 2007-03-01 11:14:46 +0000 | [diff] [blame] | 52 | |
Jonathan Gordon | 91cb68a | 2007-03-01 11:14:46 +0000 | [diff] [blame] | 53 | #include "tree.h" |
Jonathan Gordon | 08575f0 | 2007-03-01 12:18:30 +0000 | [diff] [blame] | 54 | #if CONFIG_TUNER |
Jonathan Gordon | 91cb68a | 2007-03-01 11:14:46 +0000 | [diff] [blame] | 55 | #include "radio.h" |
Jonathan Gordon | 08575f0 | 2007-03-01 12:18:30 +0000 | [diff] [blame] | 56 | #endif |
Jonathan Gordon | 91cb68a | 2007-03-01 11:14:46 +0000 | [diff] [blame] | 57 | #ifdef HAVE_RECORDING |
| 58 | #include "recording.h" |
| 59 | #endif |
Jonathan Gordon | 3e7444f | 2009-08-03 04:43:34 +0000 | [diff] [blame] | 60 | #include "wps.h" |
Jonathan Gordon | 91cb68a | 2007-03-01 11:14:46 +0000 | [diff] [blame] | 61 | #include "bookmark.h" |
Dave Chapman | 78d29f5 | 2008-03-26 23:35:34 +0000 | [diff] [blame] | 62 | #include "playlist.h" |
Thomas Martitz | c19e536 | 2010-02-20 19:06:39 +0000 | [diff] [blame] | 63 | #include "playlist_viewer.h" |
Jonathan Gordon | 97a4c1e | 2011-07-20 14:11:15 +0000 | [diff] [blame] | 64 | #include "playlist_catalog.h" |
Jonathan Gordon | 91cb68a | 2007-03-01 11:14:46 +0000 | [diff] [blame] | 65 | #include "menus/exported_menus.h" |
Dan Everton | c423e87 | 2007-03-01 11:46:26 +0000 | [diff] [blame] | 66 | #ifdef HAVE_RTC_ALARM |
| 67 | #include "rtc.h" |
| 68 | #endif |
Steve Bavin | 8137489 | 2007-03-07 19:56:15 +0000 | [diff] [blame] | 69 | #ifdef HAVE_TAGCACHE |
| 70 | #include "tagcache.h" |
| 71 | #endif |
Tomer Shalev | d7cdd08 | 2009-10-08 22:40:38 +0000 | [diff] [blame] | 72 | #include "language.h" |
Jonathan Gordon | d871ff8 | 2010-06-09 04:25:41 +0000 | [diff] [blame] | 73 | #include "plugin.h" |
Amaury Pouly | 193753a | 2013-11-20 16:39:42 +0000 | [diff] [blame] | 74 | #include "disk.h" |
Jonathan Gordon | 91cb68a | 2007-03-01 11:14:46 +0000 | [diff] [blame] | 75 | |
| 76 | struct root_items { |
| 77 | int (*function)(void* param); |
| 78 | void* param; |
Jonathan Gordon | f9fb492 | 2007-04-12 15:28:51 +0000 | [diff] [blame] | 79 | const struct menu_item_ex *context_menu; |
Jonathan Gordon | 91cb68a | 2007-03-01 11:14:46 +0000 | [diff] [blame] | 80 | }; |
Thomas Martitz | a3f0a45 | 2009-10-16 19:14:46 +0000 | [diff] [blame] | 81 | static int next_screen = GO_TO_ROOT; /* holding info about the upcoming screen |
| 82 | * which is the current screen for the |
| 83 | * rest of the code after load_screen |
| 84 | * is called */ |
Jonathan Gordon | 91cb68a | 2007-03-01 11:14:46 +0000 | [diff] [blame] | 85 | static int last_screen = GO_TO_ROOT; /* unfortunatly needed so we can resume |
| 86 | or goto current track based on previous |
| 87 | screen */ |
Jonathan Gordon | 3ac7af9 | 2012-12-16 14:26:03 +1100 | [diff] [blame] | 88 | |
Thomas Martitz | 35b4ba8 | 2014-04-15 09:34:22 +0200 | [diff] [blame] | 89 | static int previous_music = GO_TO_WPS; /* Toggles behavior of the return-to |
| 90 | * playback-button depending |
| 91 | * on FM radio */ |
| 92 | |
| 93 | #if (CONFIG_TUNER) |
| 94 | static void rootmenu_start_playback_callback(unsigned short id, void *param) |
| 95 | { |
| 96 | (void) id; (void) param; |
| 97 | /* Cancel FM radio selection as previous music. For cases where we start |
| 98 | playback without going to the WPS, such as playlist insert or |
| 99 | playlist catalog. */ |
| 100 | previous_music = GO_TO_WPS; |
| 101 | } |
| 102 | #endif |
Thomas Martitz | 9072a45 | 2009-10-16 19:14:33 +0000 | [diff] [blame] | 103 | |
Jonathan Gordon | b84fe02 | 2009-01-11 04:03:17 +0000 | [diff] [blame] | 104 | static char current_track_path[MAX_PATH]; |
Thomas Martitz | 470989b | 2014-03-14 23:15:16 +0100 | [diff] [blame] | 105 | static void rootmenu_track_changed_callback(unsigned short id, void* param) |
Jonathan Gordon | b84fe02 | 2009-01-11 04:03:17 +0000 | [diff] [blame] | 106 | { |
Thomas Martitz | 470989b | 2014-03-14 23:15:16 +0100 | [diff] [blame] | 107 | (void)id; |
Michael Sevakis | 023f6b6 | 2013-07-12 12:06:38 -0400 | [diff] [blame] | 108 | struct mp3entry *id3 = ((struct track_event *)param)->id3; |
Nils Wallménius | 3d4701a | 2009-07-14 13:57:45 +0000 | [diff] [blame] | 109 | strlcpy(current_track_path, id3->path, MAX_PATH); |
Jonathan Gordon | b84fe02 | 2009-01-11 04:03:17 +0000 | [diff] [blame] | 110 | } |
Jonathan Gordon | 91cb68a | 2007-03-01 11:14:46 +0000 | [diff] [blame] | 111 | static int browser(void* param) |
| 112 | { |
| 113 | int ret_val; |
Jonathan Gordon | 798ddf2 | 2007-03-07 04:36:02 +0000 | [diff] [blame] | 114 | #ifdef HAVE_TAGCACHE |
Jonathan Gordon | 91cb68a | 2007-03-01 11:14:46 +0000 | [diff] [blame] | 115 | struct tree_context* tc = tree_get_context(); |
Jonathan Gordon | 798ddf2 | 2007-03-07 04:36:02 +0000 | [diff] [blame] | 116 | #endif |
Teruaki Kawashima | 08af5d8 | 2010-12-14 13:37:58 +0000 | [diff] [blame] | 117 | struct browse_context browse; |
Jonathan Gordon | 91cb68a | 2007-03-01 11:14:46 +0000 | [diff] [blame] | 118 | int filter = SHOW_SUPPORTED; |
| 119 | char folder[MAX_PATH] = "/"; |
| 120 | /* stuff needed to remember position in file browser */ |
| 121 | static char last_folder[MAX_PATH] = "/"; |
| 122 | /* and stuff for the database browser */ |
Jonathan Gordon | 798ddf2 | 2007-03-07 04:36:02 +0000 | [diff] [blame] | 123 | #ifdef HAVE_TAGCACHE |
Jonathan Gordon | fd30be5 | 2007-03-10 12:51:08 +0000 | [diff] [blame] | 124 | static int last_db_dirlevel = 0, last_db_selection = 0; |
Jonathan Gordon | 798ddf2 | 2007-03-07 04:36:02 +0000 | [diff] [blame] | 125 | #endif |
Teruaki Kawashima | 08af5d8 | 2010-12-14 13:37:58 +0000 | [diff] [blame] | 126 | |
Jonathan Gordon | 08575f0 | 2007-03-01 12:18:30 +0000 | [diff] [blame] | 127 | switch ((intptr_t)param) |
Jonathan Gordon | 91cb68a | 2007-03-01 11:14:46 +0000 | [diff] [blame] | 128 | { |
| 129 | case GO_TO_FILEBROWSER: |
| 130 | filter = global_settings.dirfilter; |
Jonathan Gordon | 3ac7af9 | 2012-12-16 14:26:03 +1100 | [diff] [blame] | 131 | if (global_settings.browse_current && |
Steve Bavin | 6cc3895 | 2008-02-09 15:20:15 +0000 | [diff] [blame] | 132 | last_screen == GO_TO_WPS && |
Jonathan Gordon | b84fe02 | 2009-01-11 04:03:17 +0000 | [diff] [blame] | 133 | current_track_path[0]) |
Jonathan Gordon | 91cb68a | 2007-03-01 11:14:46 +0000 | [diff] [blame] | 134 | { |
Jonathan Gordon | b84fe02 | 2009-01-11 04:03:17 +0000 | [diff] [blame] | 135 | strcpy(folder, current_track_path); |
Jonathan Gordon | 91cb68a | 2007-03-01 11:14:46 +0000 | [diff] [blame] | 136 | } |
Jonathan Gordon | efbcece | 2010-10-04 10:34:38 +0000 | [diff] [blame] | 137 | else if (!strcmp(last_folder, "/")) |
| 138 | { |
| 139 | strcpy(folder, global_settings.start_directory); |
| 140 | } |
Jonathan Gordon | 91cb68a | 2007-03-01 11:14:46 +0000 | [diff] [blame] | 141 | else |
Thomas Martitz | 1ecb753 | 2009-11-26 00:37:27 +0000 | [diff] [blame] | 142 | { |
| 143 | #ifdef HAVE_HOTSWAP |
| 144 | bool in_hotswap = false; |
| 145 | /* handle entering an ejected drive */ |
| 146 | int i; |
| 147 | for (i = 0; i < NUM_VOLUMES; i++) |
| 148 | { |
Michael Sevakis | 7d1a47c | 2013-08-05 22:02:45 -0400 | [diff] [blame] | 149 | char vol_string[VOL_MAX_LEN + 1]; |
Amaury Pouly | 193753a | 2013-11-20 16:39:42 +0000 | [diff] [blame] | 150 | if (!volume_removable(i)) |
Thomas Martitz | 1ecb753 | 2009-11-26 00:37:27 +0000 | [diff] [blame] | 151 | continue; |
Michael Sevakis | 7d1a47c | 2013-08-05 22:02:45 -0400 | [diff] [blame] | 152 | get_volume_name(i, vol_string); |
Thomas Martitz | 1ecb753 | 2009-11-26 00:37:27 +0000 | [diff] [blame] | 153 | /* test whether we would browse the external card */ |
Amaury Pouly | 193753a | 2013-11-20 16:39:42 +0000 | [diff] [blame] | 154 | if (!volume_present(i) && |
Thomas Martitz | 1ecb753 | 2009-11-26 00:37:27 +0000 | [diff] [blame] | 155 | (strstr(last_folder, vol_string) |
| 156 | #ifdef HAVE_HOTSWAP_STORAGE_AS_MAIN |
| 157 | || (i == 0) |
| 158 | #endif |
| 159 | )) |
| 160 | { /* leave folder as "/" to avoid crash when trying |
| 161 | * to access an ejected drive */ |
| 162 | strcpy(folder, "/"); |
| 163 | in_hotswap = true; |
| 164 | break; |
| 165 | } |
| 166 | } |
Jonathan Gordon | efbcece | 2010-10-04 10:34:38 +0000 | [diff] [blame] | 167 | if (!in_hotswap) |
Thomas Martitz | 1ecb753 | 2009-11-26 00:37:27 +0000 | [diff] [blame] | 168 | #endif |
Jonathan Gordon | efbcece | 2010-10-04 10:34:38 +0000 | [diff] [blame] | 169 | strcpy(folder, last_folder); |
Thomas Martitz | 1ecb753 | 2009-11-26 00:37:27 +0000 | [diff] [blame] | 170 | } |
Jonathan Gordon | b58d365 | 2011-06-01 14:41:49 +0000 | [diff] [blame] | 171 | push_current_activity(ACTIVITY_FILEBROWSER); |
Jonathan Gordon | 91cb68a | 2007-03-01 11:14:46 +0000 | [diff] [blame] | 172 | break; |
Jonathan Gordon | 798ddf2 | 2007-03-07 04:36:02 +0000 | [diff] [blame] | 173 | #ifdef HAVE_TAGCACHE |
Jonathan Gordon | 91cb68a | 2007-03-01 11:14:46 +0000 | [diff] [blame] | 174 | case GO_TO_DBBROWSER: |
Steve Bavin | 8137489 | 2007-03-07 19:56:15 +0000 | [diff] [blame] | 175 | if (!tagcache_is_usable()) |
Jonathan Gordon | 91cb68a | 2007-03-01 11:14:46 +0000 | [diff] [blame] | 176 | { |
Steve Bavin | 149bc03 | 2007-03-08 08:20:30 +0000 | [diff] [blame] | 177 | bool reinit_attempted = false; |
Steve Bavin | 8137489 | 2007-03-07 19:56:15 +0000 | [diff] [blame] | 178 | |
| 179 | /* Now display progress until it's ready or the user exits */ |
| 180 | while(!tagcache_is_usable()) |
| 181 | { |
Jonathan Gordon | 3ac7af9 | 2012-12-16 14:26:03 +1100 | [diff] [blame] | 182 | struct tagcache_stat *stat = tagcache_get_stat(); |
| 183 | |
Steve Bavin | 149bc03 | 2007-03-08 08:20:30 +0000 | [diff] [blame] | 184 | /* Allow user to exit */ |
| 185 | if (action_userabort(HZ/2)) |
| 186 | break; |
Steve Bavin | 8137489 | 2007-03-07 19:56:15 +0000 | [diff] [blame] | 187 | |
| 188 | /* Maybe just needs to reboot due to delayed commit */ |
| 189 | if (stat->commit_delayed) |
| 190 | { |
Nils Wallménius | 01729e7 | 2008-08-15 08:27:39 +0000 | [diff] [blame] | 191 | splash(HZ*2, ID2P(LANG_PLEASE_REBOOT)); |
Steve Bavin | 8137489 | 2007-03-07 19:56:15 +0000 | [diff] [blame] | 192 | break; |
| 193 | } |
| 194 | |
Steve Bavin | 149bc03 | 2007-03-08 08:20:30 +0000 | [diff] [blame] | 195 | /* Check if ready status is known */ |
| 196 | if (!stat->readyvalid) |
| 197 | { |
Solomon Peachy | c46147c | 2019-08-07 12:45:34 -0400 | [diff] [blame] | 198 | splash(0, ID2P(LANG_TAGCACHE_BUSY)); |
Steve Bavin | 149bc03 | 2007-03-08 08:20:30 +0000 | [diff] [blame] | 199 | continue; |
| 200 | } |
Jonathan Gordon | 3ac7af9 | 2012-12-16 14:26:03 +1100 | [diff] [blame] | 201 | |
Steve Bavin | 149bc03 | 2007-03-08 08:20:30 +0000 | [diff] [blame] | 202 | /* Re-init if required */ |
Jonathan Gordon | 3ac7af9 | 2012-12-16 14:26:03 +1100 | [diff] [blame] | 203 | if (!reinit_attempted && !stat->ready && |
Steve Bavin | 149bc03 | 2007-03-08 08:20:30 +0000 | [diff] [blame] | 204 | stat->processed_entries == 0 && stat->commit_step == 0) |
| 205 | { |
| 206 | /* Prompt the user */ |
| 207 | reinit_attempted = true; |
Nils Wallménius | 33c4446 | 2008-04-26 09:30:24 +0000 | [diff] [blame] | 208 | static const char *lines[]={ |
| 209 | ID2P(LANG_TAGCACHE_BUSY), ID2P(LANG_TAGCACHE_FORCE_UPDATE)}; |
| 210 | static const struct text_message message={lines, 2}; |
Steve Bavin | 149bc03 | 2007-03-08 08:20:30 +0000 | [diff] [blame] | 211 | if(gui_syncyesno_run(&message, NULL, NULL) == YESNO_NO) |
| 212 | break; |
Steve Bavin | 149bc03 | 2007-03-08 08:20:30 +0000 | [diff] [blame] | 213 | FOR_NB_SCREENS(i) |
| 214 | screens[i].clear_display(); |
| 215 | |
| 216 | /* Start initialisation */ |
| 217 | tagcache_rebuild(); |
| 218 | } |
| 219 | |
Steve Bavin | 8137489 | 2007-03-07 19:56:15 +0000 | [diff] [blame] | 220 | /* Display building progress */ |
Nils Wallménius | 5b76936 | 2007-08-06 13:08:36 +0000 | [diff] [blame] | 221 | static long talked_tick = 0; |
Steve Bavin | 32a9575 | 2007-10-19 15:31:42 +0000 | [diff] [blame] | 222 | if(global_settings.talk_menu && |
Nils Wallménius | 5b76936 | 2007-08-06 13:08:36 +0000 | [diff] [blame] | 223 | (talked_tick == 0 |
| 224 | || TIME_AFTER(current_tick, talked_tick+7*HZ))) |
| 225 | { |
| 226 | talked_tick = current_tick; |
| 227 | if (stat->commit_step > 0) |
| 228 | { |
| 229 | talk_id(LANG_TAGCACHE_INIT, false); |
| 230 | talk_number(stat->commit_step, true); |
| 231 | talk_id(VOICE_OF, true); |
| 232 | talk_number(tagcache_get_max_commit_step(), true); |
| 233 | } else if(stat->processed_entries) |
| 234 | { |
| 235 | talk_number(stat->processed_entries, false); |
| 236 | talk_id(LANG_BUILDING_DATABASE, true); |
| 237 | } |
| 238 | } |
Steve Bavin | 8137489 | 2007-03-07 19:56:15 +0000 | [diff] [blame] | 239 | if (stat->commit_step > 0) |
| 240 | { |
Tomer Shalev | d7cdd08 | 2009-10-08 22:40:38 +0000 | [diff] [blame] | 241 | if (lang_is_rtl()) |
| 242 | { |
| 243 | splashf(0, "[%d/%d] %s", stat->commit_step, |
| 244 | tagcache_get_max_commit_step(), |
| 245 | str(LANG_TAGCACHE_INIT)); |
| 246 | } |
| 247 | else |
| 248 | { |
| 249 | splashf(0, "%s [%d/%d]", str(LANG_TAGCACHE_INIT), |
| 250 | stat->commit_step, |
| 251 | tagcache_get_max_commit_step()); |
| 252 | } |
Steve Bavin | 8137489 | 2007-03-07 19:56:15 +0000 | [diff] [blame] | 253 | } |
| 254 | else |
| 255 | { |
Nils Wallménius | 01729e7 | 2008-08-15 08:27:39 +0000 | [diff] [blame] | 256 | splashf(0, str(LANG_BUILDING_DATABASE), |
| 257 | stat->processed_entries); |
Steve Bavin | 8137489 | 2007-03-07 19:56:15 +0000 | [diff] [blame] | 258 | } |
Steve Bavin | 8137489 | 2007-03-07 19:56:15 +0000 | [diff] [blame] | 259 | } |
Jonathan Gordon | 91cb68a | 2007-03-01 11:14:46 +0000 | [diff] [blame] | 260 | } |
Steve Bavin | 8137489 | 2007-03-07 19:56:15 +0000 | [diff] [blame] | 261 | if (!tagcache_is_usable()) |
| 262 | return GO_TO_PREVIOUS; |
Jonathan Gordon | 91cb68a | 2007-03-01 11:14:46 +0000 | [diff] [blame] | 263 | filter = SHOW_ID3DB; |
| 264 | tc->dirlevel = last_db_dirlevel; |
Jonathan Gordon | fd30be5 | 2007-03-10 12:51:08 +0000 | [diff] [blame] | 265 | tc->selected_item = last_db_selection; |
Jonathan Gordon | b58d365 | 2011-06-01 14:41:49 +0000 | [diff] [blame] | 266 | push_current_activity(ACTIVITY_DATABASEBROWSER); |
Jonathan Gordon | 91cb68a | 2007-03-01 11:14:46 +0000 | [diff] [blame] | 267 | break; |
Jonathan Gordon | 798ddf2 | 2007-03-07 04:36:02 +0000 | [diff] [blame] | 268 | #endif |
Jonathan Gordon | 91cb68a | 2007-03-01 11:14:46 +0000 | [diff] [blame] | 269 | } |
Teruaki Kawashima | 08af5d8 | 2010-12-14 13:37:58 +0000 | [diff] [blame] | 270 | |
| 271 | browse_context_init(&browse, filter, 0, NULL, NOICON, folder, NULL); |
| 272 | ret_val = rockbox_browse(&browse); |
Jonathan Gordon | b58d365 | 2011-06-01 14:41:49 +0000 | [diff] [blame] | 273 | pop_current_activity(); |
Jonathan Gordon | 08575f0 | 2007-03-01 12:18:30 +0000 | [diff] [blame] | 274 | switch ((intptr_t)param) |
Jonathan Gordon | 91cb68a | 2007-03-01 11:14:46 +0000 | [diff] [blame] | 275 | { |
| 276 | case GO_TO_FILEBROWSER: |
Jonathan Gordon | efbcece | 2010-10-04 10:34:38 +0000 | [diff] [blame] | 277 | if (!get_current_file(last_folder, MAX_PATH) || |
Teruaki Kawashima | 36cd720 | 2010-10-25 13:55:34 +0000 | [diff] [blame] | 278 | (!strchr(&last_folder[1], '/') && |
| 279 | global_settings.start_directory[1] != '\0')) |
Thomas Martitz | 79798ff | 2010-08-27 10:33:09 +0000 | [diff] [blame] | 280 | { |
| 281 | last_folder[0] = '/'; |
| 282 | last_folder[1] = '\0'; |
| 283 | } |
Jonathan Gordon | 91cb68a | 2007-03-01 11:14:46 +0000 | [diff] [blame] | 284 | break; |
Jonathan Gordon | 798ddf2 | 2007-03-07 04:36:02 +0000 | [diff] [blame] | 285 | #ifdef HAVE_TAGCACHE |
Jonathan Gordon | 91cb68a | 2007-03-01 11:14:46 +0000 | [diff] [blame] | 286 | case GO_TO_DBBROWSER: |
| 287 | last_db_dirlevel = tc->dirlevel; |
Jonathan Gordon | fd30be5 | 2007-03-10 12:51:08 +0000 | [diff] [blame] | 288 | last_db_selection = tc->selected_item; |
Jonathan Gordon | 91cb68a | 2007-03-01 11:14:46 +0000 | [diff] [blame] | 289 | break; |
Jonathan Gordon | 798ddf2 | 2007-03-07 04:36:02 +0000 | [diff] [blame] | 290 | #endif |
Jonathan Gordon | 91cb68a | 2007-03-01 11:14:46 +0000 | [diff] [blame] | 291 | } |
| 292 | return ret_val; |
Jonathan Gordon | 91cb68a | 2007-03-01 11:14:46 +0000 | [diff] [blame] | 293 | } |
Thomas Martitz | 89a4cf2 | 2011-01-29 01:01:12 +0000 | [diff] [blame] | 294 | |
Jonathan Gordon | 91cb68a | 2007-03-01 11:14:46 +0000 | [diff] [blame] | 295 | #ifdef HAVE_RECORDING |
| 296 | static int recscrn(void* param) |
| 297 | { |
| 298 | (void)param; |
| 299 | recording_screen(false); |
| 300 | return GO_TO_ROOT; |
| 301 | } |
| 302 | #endif |
| 303 | static int wpsscrn(void* param) |
| 304 | { |
| 305 | int ret_val = GO_TO_PREVIOUS; |
| 306 | (void)param; |
Jonathan Gordon | b58d365 | 2011-06-01 14:41:49 +0000 | [diff] [blame] | 307 | push_current_activity(ACTIVITY_WPS); |
Jonathan Gordon | 91cb68a | 2007-03-01 11:14:46 +0000 | [diff] [blame] | 308 | if (audio_status()) |
| 309 | { |
Steve Bavin | 32a9575 | 2007-10-19 15:31:42 +0000 | [diff] [blame] | 310 | talk_shutup(); |
Jonathan Gordon | 91cb68a | 2007-03-01 11:14:46 +0000 | [diff] [blame] | 311 | ret_val = gui_wps_show(); |
| 312 | } |
| 313 | else if ( global_status.resume_index != -1 ) |
| 314 | { |
Richard Quirk | 212e780 | 2012-12-09 21:04:17 +0100 | [diff] [blame] | 315 | DEBUGF("Resume index %X crc32 %lX offset %lX\n", |
Jonathan Gordon | 91cb68a | 2007-03-01 11:14:46 +0000 | [diff] [blame] | 316 | global_status.resume_index, |
Richard Quirk | 212e780 | 2012-12-09 21:04:17 +0100 | [diff] [blame] | 317 | (unsigned long)global_status.resume_crc32, |
Jens Arnold | bd5c0ad | 2007-03-17 10:50:58 +0000 | [diff] [blame] | 318 | (unsigned long)global_status.resume_offset); |
Jonathan Gordon | 91cb68a | 2007-03-01 11:14:46 +0000 | [diff] [blame] | 319 | if (playlist_resume() != -1) |
| 320 | { |
Richard Quirk | 212e780 | 2012-12-09 21:04:17 +0100 | [diff] [blame] | 321 | playlist_resume_track(global_status.resume_index, |
| 322 | global_status.resume_crc32, |
Michael Sevakis | 31b7122 | 2013-07-14 07:59:39 -0400 | [diff] [blame] | 323 | global_status.resume_elapsed, |
Jonathan Gordon | 91cb68a | 2007-03-01 11:14:46 +0000 | [diff] [blame] | 324 | global_status.resume_offset); |
| 325 | ret_val = gui_wps_show(); |
| 326 | } |
| 327 | } |
Jens Arnold | f68362a | 2007-03-17 09:54:28 +0000 | [diff] [blame] | 328 | else |
Jonathan Gordon | 91cb68a | 2007-03-01 11:14:46 +0000 | [diff] [blame] | 329 | { |
Nils Wallménius | 01729e7 | 2008-08-15 08:27:39 +0000 | [diff] [blame] | 330 | splash(HZ*2, ID2P(LANG_NOTHING_TO_RESUME)); |
Jonathan Gordon | 91cb68a | 2007-03-01 11:14:46 +0000 | [diff] [blame] | 331 | } |
Jonathan Gordon | b58d365 | 2011-06-01 14:41:49 +0000 | [diff] [blame] | 332 | pop_current_activity(); |
Jonathan Gordon | 91cb68a | 2007-03-01 11:14:46 +0000 | [diff] [blame] | 333 | return ret_val; |
| 334 | } |
| 335 | #if CONFIG_TUNER |
| 336 | static int radio(void* param) |
| 337 | { |
| 338 | (void)param; |
| 339 | radio_screen(); |
| 340 | return GO_TO_ROOT; |
| 341 | } |
| 342 | #endif |
| 343 | |
Thomas Martitz | 89a4cf2 | 2011-01-29 01:01:12 +0000 | [diff] [blame] | 344 | static int miscscrn(void * param) |
| 345 | { |
| 346 | const struct menu_item_ex *menu = (const struct menu_item_ex*)param; |
Thomas Martitz | f7da333 | 2011-01-29 11:50:38 +0000 | [diff] [blame] | 347 | int result = do_menu(menu, NULL, NULL, false); |
| 348 | switch (result) |
Thomas Martitz | 89a4cf2 | 2011-01-29 01:01:12 +0000 | [diff] [blame] | 349 | { |
| 350 | case GO_TO_PLAYLIST_VIEWER: |
Thomas Martitz | cbb68d4 | 2011-02-28 14:38:18 +0000 | [diff] [blame] | 351 | case GO_TO_WPS: |
| 352 | return result; |
Thomas Martitz | 89a4cf2 | 2011-01-29 01:01:12 +0000 | [diff] [blame] | 353 | default: |
| 354 | return GO_TO_ROOT; |
| 355 | } |
| 356 | } |
Jonathan Gordon | 97a4c1e | 2011-07-20 14:11:15 +0000 | [diff] [blame] | 357 | |
| 358 | |
| 359 | static int playlist_view_catalog(void * param) |
| 360 | { |
| 361 | /* kludge untill catalog_view_playlists() returns something useful */ |
| 362 | int old_playstatus = audio_status(); |
| 363 | (void)param; |
| 364 | push_current_activity(ACTIVITY_PLAYLISTBROWSER); |
| 365 | catalog_view_playlists(); |
| 366 | pop_current_activity(); |
| 367 | if (!old_playstatus && audio_status()) |
| 368 | return GO_TO_WPS; |
| 369 | return GO_TO_PREVIOUS; |
| 370 | } |
| 371 | |
Thomas Martitz | c19e536 | 2010-02-20 19:06:39 +0000 | [diff] [blame] | 372 | static int playlist_view(void * param) |
| 373 | { |
| 374 | (void)param; |
Jonathan Gordon | 038fc8a | 2011-06-13 07:33:20 +0000 | [diff] [blame] | 375 | int val; |
| 376 | |
| 377 | push_current_activity(ACTIVITY_PLAYLISTVIEWER); |
| 378 | val = playlist_viewer(); |
| 379 | pop_current_activity(); |
| 380 | switch (val) |
Thomas Martitz | c19e536 | 2010-02-20 19:06:39 +0000 | [diff] [blame] | 381 | { |
| 382 | case PLAYLIST_VIEWER_MAINMENU: |
| 383 | case PLAYLIST_VIEWER_USB: |
| 384 | return GO_TO_ROOT; |
| 385 | case PLAYLIST_VIEWER_OK: |
| 386 | return GO_TO_PREVIOUS; |
| 387 | } |
| 388 | return GO_TO_PREVIOUS; |
| 389 | } |
| 390 | |
Jonathan Gordon | 91cb68a | 2007-03-01 11:14:46 +0000 | [diff] [blame] | 391 | static int load_bmarks(void* param) |
| 392 | { |
| 393 | (void)param; |
Stéphane Doyon | 84ed3fd | 2007-10-12 04:10:08 +0000 | [diff] [blame] | 394 | if(bookmark_mrb_load()) |
| 395 | return GO_TO_WPS; |
Jonathan Gordon | 91cb68a | 2007-03-01 11:14:46 +0000 | [diff] [blame] | 396 | return GO_TO_PREVIOUS; |
| 397 | } |
Teruaki Kawashima | 08af5d8 | 2010-12-14 13:37:58 +0000 | [diff] [blame] | 398 | |
Jonathan Gordon | f9fb492 | 2007-04-12 15:28:51 +0000 | [diff] [blame] | 399 | /* These are all static const'd from apps/menus/ *.c |
| 400 | so little hack so we can use them */ |
Jonathan Gordon | 3ac7af9 | 2012-12-16 14:26:03 +1100 | [diff] [blame] | 401 | extern struct menu_item_ex |
| 402 | file_menu, |
Brandon Low | b44b660 | 2007-04-18 19:46:34 +0000 | [diff] [blame] | 403 | #ifdef HAVE_TAGCACHE |
Jonathan Gordon | f9fb492 | 2007-04-12 15:28:51 +0000 | [diff] [blame] | 404 | tagcache_menu, |
Brandon Low | b44b660 | 2007-04-18 19:46:34 +0000 | [diff] [blame] | 405 | #endif |
Thomas Martitz | 89a4cf2 | 2011-01-29 01:01:12 +0000 | [diff] [blame] | 406 | main_menu_, |
Jonathan Gordon | f9fb492 | 2007-04-12 15:28:51 +0000 | [diff] [blame] | 407 | manage_settings, |
Thomas Martitz | f7da333 | 2011-01-29 11:50:38 +0000 | [diff] [blame] | 408 | plugin_menu, |
Thomas Martitz | 89a4cf2 | 2011-01-29 01:01:12 +0000 | [diff] [blame] | 409 | playlist_options, |
| 410 | info_menu, |
Jonathan Gordon | f9fb492 | 2007-04-12 15:28:51 +0000 | [diff] [blame] | 411 | system_menu; |
Jonathan Gordon | 91cb68a | 2007-03-01 11:14:46 +0000 | [diff] [blame] | 412 | static const struct root_items items[] = { |
Jonathan Gordon | f9fb492 | 2007-04-12 15:28:51 +0000 | [diff] [blame] | 413 | [GO_TO_FILEBROWSER] = { browser, (void*)GO_TO_FILEBROWSER, &file_menu}, |
Brandon Low | b44b660 | 2007-04-18 19:46:34 +0000 | [diff] [blame] | 414 | #ifdef HAVE_TAGCACHE |
Jonathan Gordon | f9fb492 | 2007-04-12 15:28:51 +0000 | [diff] [blame] | 415 | [GO_TO_DBBROWSER] = { browser, (void*)GO_TO_DBBROWSER, &tagcache_menu }, |
Brandon Low | b44b660 | 2007-04-18 19:46:34 +0000 | [diff] [blame] | 416 | #endif |
Steve Bavin | 5f8bd63 | 2008-05-22 08:02:48 +0000 | [diff] [blame] | 417 | [GO_TO_WPS] = { wpsscrn, NULL, &playback_settings }, |
Thomas Martitz | 89a4cf2 | 2011-01-29 01:01:12 +0000 | [diff] [blame] | 418 | [GO_TO_MAINMENU] = { miscscrn, (struct menu_item_ex*)&main_menu_, |
| 419 | &manage_settings }, |
Jonathan Gordon | 3ac7af9 | 2012-12-16 14:26:03 +1100 | [diff] [blame] | 420 | |
Jonathan Gordon | 91cb68a | 2007-03-01 11:14:46 +0000 | [diff] [blame] | 421 | #ifdef HAVE_RECORDING |
Peter D'Hoye | 9337efd | 2007-07-03 18:31:13 +0000 | [diff] [blame] | 422 | [GO_TO_RECSCREEN] = { recscrn, NULL, &recording_settings_menu }, |
Jonathan Gordon | 91cb68a | 2007-03-01 11:14:46 +0000 | [diff] [blame] | 423 | #endif |
Jonathan Gordon | 3ac7af9 | 2012-12-16 14:26:03 +1100 | [diff] [blame] | 424 | |
Jonathan Gordon | 91cb68a | 2007-03-01 11:14:46 +0000 | [diff] [blame] | 425 | #if CONFIG_TUNER |
Peter D'Hoye | 9337efd | 2007-07-03 18:31:13 +0000 | [diff] [blame] | 426 | [GO_TO_FM] = { radio, NULL, &radio_settings_menu }, |
Jonathan Gordon | 91cb68a | 2007-03-01 11:14:46 +0000 | [diff] [blame] | 427 | #endif |
Jonathan Gordon | 3ac7af9 | 2012-12-16 14:26:03 +1100 | [diff] [blame] | 428 | |
| 429 | [GO_TO_RECENTBMARKS] = { load_bmarks, NULL, &bookmark_settings_menu }, |
Thomas Martitz | f7da333 | 2011-01-29 11:50:38 +0000 | [diff] [blame] | 430 | [GO_TO_BROWSEPLUGINS] = { miscscrn, &plugin_menu, NULL }, |
Jonathan Gordon | 97a4c1e | 2011-07-20 14:11:15 +0000 | [diff] [blame] | 431 | [GO_TO_PLAYLISTS_SCREEN] = { playlist_view_catalog, NULL, |
| 432 | &playlist_options }, |
| 433 | [GO_TO_PLAYLIST_VIEWER] = { playlist_view, NULL, &playlist_options }, |
Thomas Martitz | 89a4cf2 | 2011-01-29 01:01:12 +0000 | [diff] [blame] | 434 | [GO_TO_SYSTEM_SCREEN] = { miscscrn, &info_menu, &system_menu }, |
Jonathan Gordon | 101693f | 2011-11-15 13:22:02 +0000 | [diff] [blame] | 435 | [GO_TO_SHORTCUTMENU] = { do_shortcut_menu, NULL, NULL }, |
Jonathan Gordon | 3ac7af9 | 2012-12-16 14:26:03 +1100 | [diff] [blame] | 436 | |
Jonathan Gordon | 91cb68a | 2007-03-01 11:14:46 +0000 | [diff] [blame] | 437 | }; |
| 438 | static const int nb_items = sizeof(items)/sizeof(*items); |
| 439 | |
Bertrik Sikken | dff382c | 2008-07-16 12:10:49 +0000 | [diff] [blame] | 440 | static int item_callback(int action, const struct menu_item_ex *this_item) ; |
Jonathan Gordon | 91cb68a | 2007-03-01 11:14:46 +0000 | [diff] [blame] | 441 | |
Jonathan Gordon | 101693f | 2011-11-15 13:22:02 +0000 | [diff] [blame] | 442 | MENUITEM_RETURNVALUE(shortcut_menu, ID2P(LANG_SHORTCUTS), GO_TO_SHORTCUTMENU, |
| 443 | NULL, Icon_Bookmark); |
| 444 | |
Jonathan Gordon | 91cb68a | 2007-03-01 11:14:46 +0000 | [diff] [blame] | 445 | MENUITEM_RETURNVALUE(file_browser, ID2P(LANG_DIR_BROWSER), GO_TO_FILEBROWSER, |
Jonathan Gordon | 02a8717 | 2007-03-03 13:52:14 +0000 | [diff] [blame] | 446 | NULL, Icon_file_view_menu); |
Jonathan Gordon | 798ddf2 | 2007-03-07 04:36:02 +0000 | [diff] [blame] | 447 | #ifdef HAVE_TAGCACHE |
Jonathan Gordon | 3ac7af9 | 2012-12-16 14:26:03 +1100 | [diff] [blame] | 448 | MENUITEM_RETURNVALUE(db_browser, ID2P(LANG_TAGCACHE), GO_TO_DBBROWSER, |
Jonathan Gordon | 02a8717 | 2007-03-03 13:52:14 +0000 | [diff] [blame] | 449 | NULL, Icon_Audio); |
Jonathan Gordon | 798ddf2 | 2007-03-07 04:36:02 +0000 | [diff] [blame] | 450 | #endif |
Jonathan Gordon | 3ac7af9 | 2012-12-16 14:26:03 +1100 | [diff] [blame] | 451 | MENUITEM_RETURNVALUE(rocks_browser, ID2P(LANG_PLUGINS), GO_TO_BROWSEPLUGINS, |
Jonathan Gordon | 02a8717 | 2007-03-03 13:52:14 +0000 | [diff] [blame] | 452 | NULL, Icon_Plugin); |
Jonathan Gordon | 97a4c1e | 2011-07-20 14:11:15 +0000 | [diff] [blame] | 453 | |
Jonathan Gordon | 3ac7af9 | 2012-12-16 14:26:03 +1100 | [diff] [blame] | 454 | MENUITEM_RETURNVALUE(playlist_browser, ID2P(LANG_CATALOG), GO_TO_PLAYLIST_VIEWER, |
Jonathan Gordon | 97a4c1e | 2011-07-20 14:11:15 +0000 | [diff] [blame] | 455 | NULL, Icon_Playlist); |
| 456 | |
William Wilgus | 10e5e56 | 2019-09-20 03:07:29 -0500 | [diff] [blame] | 457 | static char *get_wps_item_name(int selected_item, void * data, |
| 458 | char *buffer, size_t buffer_len) |
Jonathan Gordon | 91cb68a | 2007-03-01 11:14:46 +0000 | [diff] [blame] | 459 | { |
William Wilgus | 10e5e56 | 2019-09-20 03:07:29 -0500 | [diff] [blame] | 460 | (void)selected_item; (void)data; (void)buffer; (void)buffer_len; |
Jonathan Gordon | 91cb68a | 2007-03-01 11:14:46 +0000 | [diff] [blame] | 461 | if (audio_status()) |
Linus Nielsen Feltzing | 298c2bb | 2007-03-05 00:32:33 +0000 | [diff] [blame] | 462 | return ID2P(LANG_NOW_PLAYING); |
| 463 | return ID2P(LANG_RESUME_PLAYBACK); |
Jonathan Gordon | 91cb68a | 2007-03-01 11:14:46 +0000 | [diff] [blame] | 464 | } |
Jonathan Gordon | 3ac7af9 | 2012-12-16 14:26:03 +1100 | [diff] [blame] | 465 | MENUITEM_RETURNVALUE_DYNTEXT(wps_item, GO_TO_WPS, NULL, get_wps_item_name, |
Stéphane Doyon | 5acf091 | 2007-10-09 03:48:56 +0000 | [diff] [blame] | 466 | NULL, NULL, Icon_Playback_menu); |
Jonathan Gordon | 91cb68a | 2007-03-01 11:14:46 +0000 | [diff] [blame] | 467 | #ifdef HAVE_RECORDING |
Jonathan Gordon | 3ac7af9 | 2012-12-16 14:26:03 +1100 | [diff] [blame] | 468 | MENUITEM_RETURNVALUE(rec, ID2P(LANG_RECORDING), GO_TO_RECSCREEN, |
Jonathan Gordon | 02a8717 | 2007-03-03 13:52:14 +0000 | [diff] [blame] | 469 | NULL, Icon_Recording); |
Jonathan Gordon | 91cb68a | 2007-03-01 11:14:46 +0000 | [diff] [blame] | 470 | #endif |
| 471 | #if CONFIG_TUNER |
Jonathan Gordon | 3ac7af9 | 2012-12-16 14:26:03 +1100 | [diff] [blame] | 472 | MENUITEM_RETURNVALUE(fm, ID2P(LANG_FM_RADIO), GO_TO_FM, |
Jonathan Gordon | 02a8717 | 2007-03-03 13:52:14 +0000 | [diff] [blame] | 473 | item_callback, Icon_Radio_screen); |
Jonathan Gordon | 91cb68a | 2007-03-01 11:14:46 +0000 | [diff] [blame] | 474 | #endif |
Jonathan Gordon | 3ac7af9 | 2012-12-16 14:26:03 +1100 | [diff] [blame] | 475 | MENUITEM_RETURNVALUE(menu_, ID2P(LANG_SETTINGS), GO_TO_MAINMENU, |
Jonathan Gordon | 02a8717 | 2007-03-03 13:52:14 +0000 | [diff] [blame] | 476 | NULL, Icon_Submenu_Entered); |
Jonathan Gordon | 91cb68a | 2007-03-01 11:14:46 +0000 | [diff] [blame] | 477 | MENUITEM_RETURNVALUE(bookmarks, ID2P(LANG_BOOKMARK_MENU_RECENT_BOOKMARKS), |
Jonathan Gordon | 3ac7af9 | 2012-12-16 14:26:03 +1100 | [diff] [blame] | 478 | GO_TO_RECENTBMARKS, item_callback, |
Jonathan Gordon | 02a8717 | 2007-03-03 13:52:14 +0000 | [diff] [blame] | 479 | Icon_Bookmark); |
Jonathan Gordon | 97a4c1e | 2011-07-20 14:11:15 +0000 | [diff] [blame] | 480 | MENUITEM_RETURNVALUE(playlists, ID2P(LANG_CATALOG), GO_TO_PLAYLISTS_SCREEN, |
Thomas Martitz | 89a4cf2 | 2011-01-29 01:01:12 +0000 | [diff] [blame] | 481 | NULL, Icon_Playlist); |
| 482 | MENUITEM_RETURNVALUE(system_menu_, ID2P(LANG_SYSTEM), GO_TO_SYSTEM_SCREEN, |
| 483 | NULL, Icon_System_menu); |
| 484 | |
Dave Chapman | 224c826 | 2011-02-28 12:14:34 +0000 | [diff] [blame] | 485 | #if CONFIG_KEYPAD == PLAYER_PAD |
Jonathan Gordon | 91cb68a | 2007-03-01 11:14:46 +0000 | [diff] [blame] | 486 | static int do_shutdown(void) |
| 487 | { |
Jens Arnold | 5764ff5 | 2007-04-09 13:54:38 +0000 | [diff] [blame] | 488 | #if CONFIG_CHARGING |
Jens Arnold | 178c565 | 2007-04-09 13:39:37 +0000 | [diff] [blame] | 489 | if (charger_inserted()) |
| 490 | charging_splash(); |
| 491 | else |
Jens Arnold | 5764ff5 | 2007-04-09 13:54:38 +0000 | [diff] [blame] | 492 | #endif |
Jens Arnold | 178c565 | 2007-04-09 13:39:37 +0000 | [diff] [blame] | 493 | sys_poweroff(); |
Jonathan Gordon | 91cb68a | 2007-03-01 11:14:46 +0000 | [diff] [blame] | 494 | return 0; |
| 495 | } |
Jonathan Gordon | daf6694 | 2007-03-17 12:33:34 +0000 | [diff] [blame] | 496 | MENUITEM_FUNCTION(do_shutdown_item, 0, ID2P(LANG_SHUTDOWN), |
Jonathan Gordon | 458648b | 2007-03-18 07:25:01 +0000 | [diff] [blame] | 497 | do_shutdown, NULL, NULL, Icon_NOICON); |
Jonathan Gordon | 91cb68a | 2007-03-01 11:14:46 +0000 | [diff] [blame] | 498 | #endif |
Jonathan Gordon | 13412f6 | 2012-02-09 21:21:40 +1100 | [diff] [blame] | 499 | |
| 500 | struct menu_item_ex root_menu_; |
| 501 | static struct menu_callback_with_desc root_menu_desc = { |
| 502 | item_callback, ID2P(LANG_ROCKBOX_TITLE), Icon_Rockbox }; |
Jonathan Gordon | 6dbfd44 | 2014-02-13 22:01:13 +1100 | [diff] [blame] | 503 | |
Jonathan Gordon | 13412f6 | 2012-02-09 21:21:40 +1100 | [diff] [blame] | 504 | static struct menu_table menu_table[] = { |
| 505 | /* Order here represents the default ordering */ |
| 506 | { "bookmarks", &bookmarks }, |
| 507 | { "files", &file_browser }, |
Jonathan Gordon | 798ddf2 | 2007-03-07 04:36:02 +0000 | [diff] [blame] | 508 | #ifdef HAVE_TAGCACHE |
Jonathan Gordon | 13412f6 | 2012-02-09 21:21:40 +1100 | [diff] [blame] | 509 | { "database", &db_browser }, |
Jonathan Gordon | 798ddf2 | 2007-03-07 04:36:02 +0000 | [diff] [blame] | 510 | #endif |
Jonathan Gordon | 13412f6 | 2012-02-09 21:21:40 +1100 | [diff] [blame] | 511 | { "wps", &wps_item }, |
Jonathan Gordon | 3ac7af9 | 2012-12-16 14:26:03 +1100 | [diff] [blame] | 512 | { "settings", &menu_ }, |
Jonathan Gordon | 91cb68a | 2007-03-01 11:14:46 +0000 | [diff] [blame] | 513 | #ifdef HAVE_RECORDING |
Jonathan Gordon | 3ac7af9 | 2012-12-16 14:26:03 +1100 | [diff] [blame] | 514 | { "recording", &rec }, |
Jonathan Gordon | 91cb68a | 2007-03-01 11:14:46 +0000 | [diff] [blame] | 515 | #endif |
| 516 | #if CONFIG_TUNER |
Jonathan Gordon | 13412f6 | 2012-02-09 21:21:40 +1100 | [diff] [blame] | 517 | { "radio", &fm }, |
Jonathan Gordon | 91cb68a | 2007-03-01 11:14:46 +0000 | [diff] [blame] | 518 | #endif |
Jonathan Gordon | 13412f6 | 2012-02-09 21:21:40 +1100 | [diff] [blame] | 519 | { "playlists", &playlists }, |
| 520 | { "plugins", &rocks_browser }, |
| 521 | { "system_menu", &system_menu_ }, |
Dave Chapman | 0269b27 | 2011-02-28 18:21:00 +0000 | [diff] [blame] | 522 | #if CONFIG_KEYPAD == PLAYER_PAD |
Jonathan Gordon | 13412f6 | 2012-02-09 21:21:40 +1100 | [diff] [blame] | 523 | { "shutdown", &do_shutdown_item }, |
Jonathan Gordon | 91cb68a | 2007-03-01 11:14:46 +0000 | [diff] [blame] | 524 | #endif |
Jonathan Gordon | 13412f6 | 2012-02-09 21:21:40 +1100 | [diff] [blame] | 525 | { "shortcuts", &shortcut_menu }, |
| 526 | }; |
| 527 | #define MAX_MENU_ITEMS (sizeof(menu_table) / sizeof(struct menu_table)) |
| 528 | static struct menu_item_ex *root_menu__[MAX_MENU_ITEMS]; |
| 529 | |
Jonathan Gordon | 6dbfd44 | 2014-02-13 22:01:13 +1100 | [diff] [blame] | 530 | struct menu_table *root_menu_get_options(int *nb_options) |
| 531 | { |
| 532 | *nb_options = MAX_MENU_ITEMS; |
| 533 | |
| 534 | return menu_table; |
| 535 | } |
| 536 | |
Jonathan Gordon | 13412f6 | 2012-02-09 21:21:40 +1100 | [diff] [blame] | 537 | void root_menu_load_from_cfg(void* setting, char *value) |
| 538 | { |
Jonathan Gordon | 3ac7af9 | 2012-12-16 14:26:03 +1100 | [diff] [blame] | 539 | char *next = value, *start, *end; |
Jonathan Gordon | 13412f6 | 2012-02-09 21:21:40 +1100 | [diff] [blame] | 540 | unsigned int menu_item_count = 0, i; |
| 541 | bool main_menu_added = false; |
| 542 | |
Jonathan Gordon | 9f48f5f | 2012-02-27 09:34:37 +1100 | [diff] [blame] | 543 | if (*value == '-') |
| 544 | { |
| 545 | root_menu_set_default(setting, NULL); |
| 546 | return; |
| 547 | } |
Jonathan Gordon | 13412f6 | 2012-02-09 21:21:40 +1100 | [diff] [blame] | 548 | root_menu_.flags = MENU_HAS_DESC | MT_MENU; |
| 549 | root_menu_.submenus = (const struct menu_item_ex **)&root_menu__; |
| 550 | root_menu_.callback_and_desc = &root_menu_desc; |
| 551 | |
| 552 | while (next && menu_item_count < MAX_MENU_ITEMS) |
| 553 | { |
| 554 | start = next; |
| 555 | next = strchr(next, ','); |
| 556 | if (next) |
| 557 | { |
| 558 | *next = '\0'; |
| 559 | next++; |
| 560 | } |
Jonathan Gordon | 3ac7af9 | 2012-12-16 14:26:03 +1100 | [diff] [blame] | 561 | start = skip_whitespace(start); |
| 562 | if ((end = strchr(start, ' '))) |
| 563 | *end = '\0'; |
Jonathan Gordon | 13412f6 | 2012-02-09 21:21:40 +1100 | [diff] [blame] | 564 | for (i=0; i<MAX_MENU_ITEMS; i++) |
| 565 | { |
| 566 | if (*start && !strcmp(start, menu_table[i].string)) |
| 567 | { |
| 568 | root_menu__[menu_item_count++] = (struct menu_item_ex *)menu_table[i].item; |
| 569 | if (menu_table[i].item == &menu_) |
| 570 | main_menu_added = true; |
| 571 | break; |
| 572 | } |
| 573 | } |
| 574 | } |
| 575 | if (!main_menu_added) |
| 576 | root_menu__[menu_item_count++] = (struct menu_item_ex *)&menu_; |
| 577 | root_menu_.flags |= MENU_ITEM_COUNT(menu_item_count); |
Alexander Levin | 7676dae | 2012-03-02 20:33:13 +0100 | [diff] [blame] | 578 | *(bool*)setting = true; |
Jonathan Gordon | 13412f6 | 2012-02-09 21:21:40 +1100 | [diff] [blame] | 579 | } |
| 580 | |
| 581 | char* root_menu_write_to_cfg(void* setting, char*buf, int buf_len) |
| 582 | { |
| 583 | (void)setting; |
| 584 | unsigned i, written, j; |
| 585 | for (i = 0; i < MENU_GET_COUNT(root_menu_.flags); i++) |
| 586 | { |
| 587 | for (j=0; j<MAX_MENU_ITEMS; j++) |
| 588 | { |
| 589 | if (menu_table[j].item == root_menu__[i]) |
| 590 | { |
Jonathan Gordon | 3ac7af9 | 2012-12-16 14:26:03 +1100 | [diff] [blame] | 591 | written = snprintf(buf, buf_len, "%s, ", menu_table[j].string); |
Jonathan Gordon | 13412f6 | 2012-02-09 21:21:40 +1100 | [diff] [blame] | 592 | buf_len -= written; |
| 593 | buf += written; |
| 594 | break; |
| 595 | } |
| 596 | } |
| 597 | } |
| 598 | return buf; |
| 599 | } |
| 600 | |
| 601 | void root_menu_set_default(void* setting, void* defaultval) |
| 602 | { |
| 603 | unsigned i; |
| 604 | (void)defaultval; |
| 605 | |
| 606 | root_menu_.flags = MENU_HAS_DESC | MT_MENU; |
| 607 | root_menu_.submenus = (const struct menu_item_ex **)&root_menu__; |
| 608 | root_menu_.callback_and_desc = &root_menu_desc; |
| 609 | |
| 610 | for (i=0; i<MAX_MENU_ITEMS; i++) |
| 611 | { |
| 612 | root_menu__[i] = (struct menu_item_ex *)menu_table[i].item; |
| 613 | } |
| 614 | root_menu_.flags |= MENU_ITEM_COUNT(MAX_MENU_ITEMS); |
Alexander Levin | 7676dae | 2012-03-02 20:33:13 +0100 | [diff] [blame] | 615 | *(bool*)setting = false; |
Jonathan Gordon | 13412f6 | 2012-02-09 21:21:40 +1100 | [diff] [blame] | 616 | } |
Jonathan Gordon | 3ac7af9 | 2012-12-16 14:26:03 +1100 | [diff] [blame] | 617 | |
Jonathan Gordon | 13412f6 | 2012-02-09 21:21:40 +1100 | [diff] [blame] | 618 | bool root_menu_is_changed(void* setting, void* defaultval) |
| 619 | { |
| 620 | (void)defaultval; |
Alexander Levin | 7676dae | 2012-03-02 20:33:13 +0100 | [diff] [blame] | 621 | return *(bool*)setting; |
Jonathan Gordon | 13412f6 | 2012-02-09 21:21:40 +1100 | [diff] [blame] | 622 | } |
Jonathan Gordon | 91cb68a | 2007-03-01 11:14:46 +0000 | [diff] [blame] | 623 | |
Jonathan Gordon | 3ac7af9 | 2012-12-16 14:26:03 +1100 | [diff] [blame] | 624 | static int item_callback(int action, const struct menu_item_ex *this_item) |
Jonathan Gordon | 91cb68a | 2007-03-01 11:14:46 +0000 | [diff] [blame] | 625 | { |
| 626 | switch (action) |
| 627 | { |
Jonathan Gordon | 411f3e2 | 2007-07-11 02:22:03 +0000 | [diff] [blame] | 628 | case ACTION_TREE_STOP: |
| 629 | return ACTION_REDRAW; |
Jonathan Gordon | 91cb68a | 2007-03-01 11:14:46 +0000 | [diff] [blame] | 630 | case ACTION_REQUEST_MENUITEM: |
| 631 | #if CONFIG_TUNER |
| 632 | if (this_item == &fm) |
| 633 | { |
| 634 | if (radio_hardware_present() == 0) |
| 635 | return ACTION_EXIT_MENUITEM; |
| 636 | } |
Jonathan Gordon | 3ac7af9 | 2012-12-16 14:26:03 +1100 | [diff] [blame] | 637 | else |
Jonathan Gordon | 91cb68a | 2007-03-01 11:14:46 +0000 | [diff] [blame] | 638 | #endif |
| 639 | if (this_item == &bookmarks) |
| 640 | { |
| 641 | if (global_settings.usemrb == 0) |
| 642 | return ACTION_EXIT_MENUITEM; |
| 643 | } |
| 644 | break; |
| 645 | } |
| 646 | return action; |
| 647 | } |
Jonathan Gordon | 6bb473d | 2007-03-05 13:36:00 +0000 | [diff] [blame] | 648 | static int get_selection(int last_screen) |
| 649 | { |
Thomas Martitz | 16a6453 | 2009-08-03 01:42:08 +0000 | [diff] [blame] | 650 | int i; |
| 651 | int len = ARRAYLEN(root_menu__); |
| 652 | for(i=0; i < len; i++) |
Jonathan Gordon | 6bb473d | 2007-03-05 13:36:00 +0000 | [diff] [blame] | 653 | { |
Jonathan Gordon | 3ac7af9 | 2012-12-16 14:26:03 +1100 | [diff] [blame] | 654 | if (((root_menu__[i]->flags&MENU_TYPE_MASK) == MT_RETURN_VALUE) && |
Jonathan Gordon | 6bb473d | 2007-03-05 13:36:00 +0000 | [diff] [blame] | 655 | (root_menu__[i]->value == last_screen)) |
| 656 | { |
| 657 | return i; |
| 658 | } |
| 659 | } |
| 660 | return 0; |
| 661 | } |
Jonathan Gordon | 91cb68a | 2007-03-01 11:14:46 +0000 | [diff] [blame] | 662 | |
Jonathan Gordon | 678705c | 2007-03-29 14:19:28 +0000 | [diff] [blame] | 663 | static inline int load_screen(int screen) |
| 664 | { |
| 665 | /* set the global_status.last_screen before entering, |
| 666 | if we dont we will always return to the wrong screen on boot */ |
| 667 | int old_previous = last_screen; |
| 668 | int ret_val; |
Jonathan Gordon | b58d365 | 2011-06-01 14:41:49 +0000 | [diff] [blame] | 669 | enum current_activity activity = ACTIVITY_UNKNOWN; |
Jonathan Gordon | 678705c | 2007-03-29 14:19:28 +0000 | [diff] [blame] | 670 | if (screen <= GO_TO_ROOT) |
| 671 | return screen; |
| 672 | if (screen == old_previous) |
| 673 | old_previous = GO_TO_ROOT; |
| 674 | global_status.last_screen = (char)screen; |
| 675 | status_save(); |
Jonathan Gordon | b58d365 | 2011-06-01 14:41:49 +0000 | [diff] [blame] | 676 | |
| 677 | if (screen == GO_TO_BROWSEPLUGINS) |
| 678 | activity = ACTIVITY_PLUGINBROWSER; |
| 679 | else if (screen == GO_TO_MAINMENU) |
| 680 | activity = ACTIVITY_SETTINGS; |
Jonathan Gordon | 835683b | 2011-08-07 08:39:56 +0000 | [diff] [blame] | 681 | else if (screen == GO_TO_SYSTEM_SCREEN) |
| 682 | activity = ACTIVITY_SYSTEMSCREEN; |
Jonathan Gordon | b58d365 | 2011-06-01 14:41:49 +0000 | [diff] [blame] | 683 | |
| 684 | if (activity != ACTIVITY_UNKNOWN) |
| 685 | push_current_activity(activity); |
| 686 | |
Jonathan Gordon | 678705c | 2007-03-29 14:19:28 +0000 | [diff] [blame] | 687 | ret_val = items[screen].function(items[screen].param); |
Jonathan Gordon | b58d365 | 2011-06-01 14:41:49 +0000 | [diff] [blame] | 688 | |
| 689 | if (activity != ACTIVITY_UNKNOWN) |
| 690 | pop_current_activity(); |
| 691 | |
Robert Kukla | 1f33735 | 2007-03-31 21:59:57 +0000 | [diff] [blame] | 692 | last_screen = screen; |
Jonathan Gordon | 678705c | 2007-03-29 14:19:28 +0000 | [diff] [blame] | 693 | if (ret_val == GO_TO_PREVIOUS) |
| 694 | last_screen = old_previous; |
| 695 | return ret_val; |
| 696 | } |
Jonathan Gordon | f9fb492 | 2007-04-12 15:28:51 +0000 | [diff] [blame] | 697 | static int load_context_screen(int selection) |
| 698 | { |
| 699 | const struct menu_item_ex *context_menu = NULL; |
Jonathan Gordon | 835683b | 2011-08-07 08:39:56 +0000 | [diff] [blame] | 700 | int retval = GO_TO_PREVIOUS; |
| 701 | push_current_activity(ACTIVITY_CONTEXTMENU); |
Jonathan Gordon | 680acbf | 2007-04-25 10:41:17 +0000 | [diff] [blame] | 702 | if ((root_menu__[selection]->flags&MENU_TYPE_MASK) == MT_RETURN_VALUE) |
Jonathan Gordon | f9fb492 | 2007-04-12 15:28:51 +0000 | [diff] [blame] | 703 | { |
| 704 | int item = root_menu__[selection]->value; |
| 705 | context_menu = items[item].context_menu; |
| 706 | } |
| 707 | /* special cases */ |
| 708 | else if (root_menu__[selection] == &info_menu) |
| 709 | { |
| 710 | context_menu = &system_menu; |
| 711 | } |
Jonathan Gordon | 3ac7af9 | 2012-12-16 14:26:03 +1100 | [diff] [blame] | 712 | |
Jonathan Gordon | f9fb492 | 2007-04-12 15:28:51 +0000 | [diff] [blame] | 713 | if (context_menu) |
Jonathan Gordon | 835683b | 2011-08-07 08:39:56 +0000 | [diff] [blame] | 714 | retval = do_menu(context_menu, NULL, NULL, false); |
| 715 | pop_current_activity(); |
| 716 | return retval; |
Jonathan Gordon | f9fb492 | 2007-04-12 15:28:51 +0000 | [diff] [blame] | 717 | } |
Stéphane Doyon | 6d08116 | 2007-10-12 04:20:20 +0000 | [diff] [blame] | 718 | |
Jonathan Gordon | 10e24d2 | 2010-06-09 08:51:29 +0000 | [diff] [blame] | 719 | #ifdef HAVE_PICTUREFLOW_INTEGRATION |
Jonathan Gordon | d871ff8 | 2010-06-09 04:25:41 +0000 | [diff] [blame] | 720 | static int load_plugin_screen(char *plug_path) |
| 721 | { |
| 722 | int ret_val; |
Jonathan Gordon | 3ac7af9 | 2012-12-16 14:26:03 +1100 | [diff] [blame] | 723 | int old_previous = last_screen; |
Jonathan Gordon | d871ff8 | 2010-06-09 04:25:41 +0000 | [diff] [blame] | 724 | last_screen = next_screen; |
| 725 | global_status.last_screen = (char)next_screen; |
| 726 | status_save(); |
Jonathan Gordon | 3ac7af9 | 2012-12-16 14:26:03 +1100 | [diff] [blame] | 727 | |
Rafaël Carré | 21c7b9d | 2010-09-01 14:12:14 +0000 | [diff] [blame] | 728 | switch (plugin_load(plug_path, NULL)) |
| 729 | { |
| 730 | case PLUGIN_GOTO_WPS: |
| 731 | ret_val = GO_TO_WPS; |
| 732 | break; |
| 733 | case PLUGIN_OK: |
Jonathan Gordon | c92b2cc | 2010-06-09 09:41:16 +0000 | [diff] [blame] | 734 | ret_val = audio_status() ? GO_TO_PREVIOUS : GO_TO_ROOT; |
Rafaël Carré | 21c7b9d | 2010-09-01 14:12:14 +0000 | [diff] [blame] | 735 | break; |
| 736 | default: |
| 737 | ret_val = GO_TO_PREVIOUS; |
| 738 | break; |
| 739 | } |
| 740 | |
Jonathan Gordon | d871ff8 | 2010-06-09 04:25:41 +0000 | [diff] [blame] | 741 | if (ret_val == GO_TO_PREVIOUS) |
| 742 | last_screen = (old_previous == next_screen) ? GO_TO_ROOT : old_previous; |
| 743 | return ret_val; |
| 744 | } |
Solomon Peachy | c46147c | 2019-08-07 12:45:34 -0400 | [diff] [blame] | 745 | |
| 746 | static bool check_database(void) |
| 747 | { |
| 748 | bool needwarn = true; |
| 749 | while ( !tagcache_is_usable() ) |
| 750 | { |
| 751 | if (needwarn) |
| 752 | splash(0, ID2P(LANG_TAGCACHE_BUSY)); |
| 753 | if ( action_userabort(HZ/5) ) |
| 754 | return false; |
| 755 | needwarn = false; |
| 756 | } |
| 757 | return true; |
| 758 | } |
Jonathan Gordon | d871ff8 | 2010-06-09 04:25:41 +0000 | [diff] [blame] | 759 | #endif |
| 760 | |
Jonathan Gordon | 91cb68a | 2007-03-01 11:14:46 +0000 | [diff] [blame] | 761 | void root_menu(void) |
| 762 | { |
| 763 | int previous_browser = GO_TO_FILEBROWSER; |
Jonathan Gordon | 91cb68a | 2007-03-01 11:14:46 +0000 | [diff] [blame] | 764 | int selected = 0; |
Jonathan Gordon | 3ac7af9 | 2012-12-16 14:26:03 +1100 | [diff] [blame] | 765 | |
Jonathan Gordon | b58d365 | 2011-06-01 14:41:49 +0000 | [diff] [blame] | 766 | push_current_activity(ACTIVITY_MAINMENU); |
Jonathan Gordon | 91cb68a | 2007-03-01 11:14:46 +0000 | [diff] [blame] | 767 | |
| 768 | if (global_settings.start_in_screen == 0) |
Jonathan Gordon | 678705c | 2007-03-29 14:19:28 +0000 | [diff] [blame] | 769 | next_screen = (int)global_status.last_screen; |
| 770 | else next_screen = global_settings.start_in_screen - 2; |
Thomas Martitz | 35b4ba8 | 2014-04-15 09:34:22 +0200 | [diff] [blame] | 771 | #if CONFIG_TUNER |
| 772 | add_event(PLAYBACK_EVENT_START_PLAYBACK, rootmenu_start_playback_callback); |
| 773 | #endif |
Thomas Martitz | 470989b | 2014-03-14 23:15:16 +0100 | [diff] [blame] | 774 | add_event(PLAYBACK_EVENT_TRACK_CHANGE, rootmenu_track_changed_callback); |
Jonathan Gordon | 9e554a8 | 2007-03-07 01:16:25 +0000 | [diff] [blame] | 775 | #ifdef HAVE_RTC_ALARM |
Jonathan Gordon | 3ac7af9 | 2012-12-16 14:26:03 +1100 | [diff] [blame] | 776 | if ( rtc_check_alarm_started(true) ) |
Jonathan Gordon | 9e554a8 | 2007-03-07 01:16:25 +0000 | [diff] [blame] | 777 | { |
| 778 | rtc_enable_alarm(false); |
Jonathan Gordon | 678705c | 2007-03-29 14:19:28 +0000 | [diff] [blame] | 779 | next_screen = GO_TO_WPS; |
Jonathan Gordon | 9e554a8 | 2007-03-07 01:16:25 +0000 | [diff] [blame] | 780 | #if CONFIG_TUNER |
| 781 | if (global_settings.alarm_wake_up_screen == ALARM_START_FM) |
Jonathan Gordon | 678705c | 2007-03-29 14:19:28 +0000 | [diff] [blame] | 782 | next_screen = GO_TO_FM; |
Jonathan Gordon | 9e554a8 | 2007-03-07 01:16:25 +0000 | [diff] [blame] | 783 | #endif |
| 784 | #ifdef HAVE_RECORDING |
| 785 | if (global_settings.alarm_wake_up_screen == ALARM_START_REC) |
Jonathan Gordon | e900a90 | 2007-03-07 01:59:29 +0000 | [diff] [blame] | 786 | { |
| 787 | recording_start_automatic = true; |
Jonathan Gordon | 678705c | 2007-03-29 14:19:28 +0000 | [diff] [blame] | 788 | next_screen = GO_TO_RECSCREEN; |
Jonathan Gordon | e900a90 | 2007-03-07 01:59:29 +0000 | [diff] [blame] | 789 | } |
Jonathan Gordon | 9e554a8 | 2007-03-07 01:16:25 +0000 | [diff] [blame] | 790 | #endif |
| 791 | } |
| 792 | #endif /* HAVE_RTC_ALARM */ |
| 793 | |
Jonathan Gordon | 7ce492e | 2007-03-08 00:37:58 +0000 | [diff] [blame] | 794 | #ifdef HAVE_HEADPHONE_DETECTION |
Jonathan Gordon | 3ac7af9 | 2012-12-16 14:26:03 +1100 | [diff] [blame] | 795 | if (next_screen == GO_TO_WPS && |
Jonathan Gordon | 7ce492e | 2007-03-08 00:37:58 +0000 | [diff] [blame] | 796 | (global_settings.unplug_autoresume && !headphones_inserted() )) |
Jonathan Gordon | 678705c | 2007-03-29 14:19:28 +0000 | [diff] [blame] | 797 | next_screen = GO_TO_ROOT; |
Jonathan Gordon | 7ce492e | 2007-03-08 00:37:58 +0000 | [diff] [blame] | 798 | #endif |
| 799 | |
Jonathan Gordon | 91cb68a | 2007-03-01 11:14:46 +0000 | [diff] [blame] | 800 | while (true) |
| 801 | { |
Jonathan Gordon | 678705c | 2007-03-29 14:19:28 +0000 | [diff] [blame] | 802 | switch (next_screen) |
Jonathan Gordon | 91cb68a | 2007-03-01 11:14:46 +0000 | [diff] [blame] | 803 | { |
Jonathan Gordon | 91e726a | 2007-03-27 06:38:11 +0000 | [diff] [blame] | 804 | case MENU_ATTACHED_USB: |
| 805 | case MENU_SELECTED_EXIT: |
Jonathan Gordon | 91e726a | 2007-03-27 06:38:11 +0000 | [diff] [blame] | 806 | /* fall through */ |
Jonathan Gordon | 91cb68a | 2007-03-01 11:14:46 +0000 | [diff] [blame] | 807 | case GO_TO_ROOT: |
Jonathan Gordon | 43b2d09 | 2007-03-07 10:13:07 +0000 | [diff] [blame] | 808 | if (last_screen != GO_TO_ROOT) |
| 809 | selected = get_selection(last_screen); |
Udo Schläpfer | dbabd0d | 2015-02-02 21:44:29 +0100 | [diff] [blame] | 810 | #if (CONFIG_PLATFORM&PLATFORM_ANDROID) |
Jonathan Gordon | a41041a | 2010-11-03 14:34:57 +0000 | [diff] [blame] | 811 | /* When we are in the main menu we want the hardware BACK |
| 812 | * button to be handled by Android instead of rockbox */ |
| 813 | android_ignore_back_button(true); |
| 814 | #endif |
Jonathan Gordon | 5ca1539 | 2008-03-26 03:35:24 +0000 | [diff] [blame] | 815 | next_screen = do_menu(&root_menu_, &selected, NULL, false); |
Udo Schläpfer | dbabd0d | 2015-02-02 21:44:29 +0100 | [diff] [blame] | 816 | #if (CONFIG_PLATFORM&PLATFORM_ANDROID) |
Jonathan Gordon | a41041a | 2010-11-03 14:34:57 +0000 | [diff] [blame] | 817 | android_ignore_back_button(false); |
| 818 | #endif |
Jonathan Gordon | 678705c | 2007-03-29 14:19:28 +0000 | [diff] [blame] | 819 | if (next_screen != GO_TO_PREVIOUS) |
| 820 | last_screen = GO_TO_ROOT; |
Jonathan Gordon | 91cb68a | 2007-03-01 11:14:46 +0000 | [diff] [blame] | 821 | break; |
Jonathan Gordon | a74eefe | 2007-03-06 13:35:15 +0000 | [diff] [blame] | 822 | |
Jonathan Gordon | 91cb68a | 2007-03-01 11:14:46 +0000 | [diff] [blame] | 823 | case GO_TO_PREVIOUS: |
Jonathan Gordon | 678705c | 2007-03-29 14:19:28 +0000 | [diff] [blame] | 824 | next_screen = last_screen; |
Jonathan Gordon | 91cb68a | 2007-03-01 11:14:46 +0000 | [diff] [blame] | 825 | break; |
Jonathan Gordon | a74eefe | 2007-03-06 13:35:15 +0000 | [diff] [blame] | 826 | |
Jonathan Gordon | 91cb68a | 2007-03-01 11:14:46 +0000 | [diff] [blame] | 827 | case GO_TO_PREVIOUS_BROWSER: |
Jonathan Gordon | 678705c | 2007-03-29 14:19:28 +0000 | [diff] [blame] | 828 | next_screen = previous_browser; |
Jonathan Gordon | 91cb68a | 2007-03-01 11:14:46 +0000 | [diff] [blame] | 829 | break; |
Jonathan Gordon | a74eefe | 2007-03-06 13:35:15 +0000 | [diff] [blame] | 830 | |
Jonathan Gordon | 91cb68a | 2007-03-01 11:14:46 +0000 | [diff] [blame] | 831 | case GO_TO_PREVIOUS_MUSIC: |
Jonathan Gordon | 678705c | 2007-03-29 14:19:28 +0000 | [diff] [blame] | 832 | next_screen = previous_music; |
Jonathan Gordon | 91cb68a | 2007-03-01 11:14:46 +0000 | [diff] [blame] | 833 | break; |
Jonathan Gordon | f9fb492 | 2007-04-12 15:28:51 +0000 | [diff] [blame] | 834 | case GO_TO_ROOTITEM_CONTEXT: |
| 835 | next_screen = load_context_screen(selected); |
| 836 | break; |
Jonathan Gordon | 3ac7af9 | 2012-12-16 14:26:03 +1100 | [diff] [blame] | 837 | #ifdef HAVE_PICTUREFLOW_INTEGRATION |
Jonathan Gordon | d871ff8 | 2010-06-09 04:25:41 +0000 | [diff] [blame] | 838 | case GO_TO_PICTUREFLOW: |
Solomon Peachy | c46147c | 2019-08-07 12:45:34 -0400 | [diff] [blame] | 839 | if (check_database()) |
Thomas Martitz | 9c0b247 | 2010-08-01 16:15:27 +0000 | [diff] [blame] | 840 | { |
| 841 | char pf_path[MAX_PATH]; |
| 842 | snprintf(pf_path, sizeof(pf_path), |
| 843 | "%s/pictureflow.rock", |
| 844 | PLUGIN_DEMOS_DIR); |
| 845 | next_screen = load_plugin_screen(pf_path); |
Solomon Peachy | c46147c | 2019-08-07 12:45:34 -0400 | [diff] [blame] | 846 | previous_browser = (next_screen != GO_TO_WPS) ? GO_TO_FILEBROWSER : GO_TO_PICTUREFLOW; |
Thomas Martitz | 9c0b247 | 2010-08-01 16:15:27 +0000 | [diff] [blame] | 847 | } |
Solomon Peachy | c46147c | 2019-08-07 12:45:34 -0400 | [diff] [blame] | 848 | else |
| 849 | next_screen = GO_TO_PREVIOUS; |
Jonathan Gordon | d871ff8 | 2010-06-09 04:25:41 +0000 | [diff] [blame] | 850 | break; |
Jonathan Gordon | 3ac7af9 | 2012-12-16 14:26:03 +1100 | [diff] [blame] | 851 | #endif |
Jonathan Gordon | 678705c | 2007-03-29 14:19:28 +0000 | [diff] [blame] | 852 | default: |
Steve Bavin | 888890a | 2007-03-09 16:54:35 +0000 | [diff] [blame] | 853 | #ifdef HAVE_TAGCACHE |
Thomas Martitz | 35b4ba8 | 2014-04-15 09:34:22 +0200 | [diff] [blame] | 854 | /* With !HAVE_TAGCACHE previous_browser is always GO_TO_FILEBROWSER */ |
| 855 | if (next_screen == GO_TO_FILEBROWSER || next_screen == GO_TO_DBBROWSER) |
Jonathan Gordon | 678705c | 2007-03-29 14:19:28 +0000 | [diff] [blame] | 856 | previous_browser = next_screen; |
Steve Bavin | 888890a | 2007-03-09 16:54:35 +0000 | [diff] [blame] | 857 | #endif |
Thomas Martitz | 35b4ba8 | 2014-04-15 09:34:22 +0200 | [diff] [blame] | 858 | #if CONFIG_TUNER |
| 859 | /* With !CONFIG_TUNER previous_music is always GO_TO_WPS */ |
| 860 | if (next_screen == GO_TO_WPS || next_screen == GO_TO_FM) |
Jonathan Gordon | 678705c | 2007-03-29 14:19:28 +0000 | [diff] [blame] | 861 | previous_music = next_screen; |
Thomas Martitz | 35b4ba8 | 2014-04-15 09:34:22 +0200 | [diff] [blame] | 862 | #endif |
Jonathan Gordon | 678705c | 2007-03-29 14:19:28 +0000 | [diff] [blame] | 863 | next_screen = load_screen(next_screen); |
| 864 | break; |
| 865 | } /* switch() */ |
Jonathan Gordon | 91cb68a | 2007-03-01 11:14:46 +0000 | [diff] [blame] | 866 | } |
Jonathan Gordon | 91cb68a | 2007-03-01 11:14:46 +0000 | [diff] [blame] | 867 | } |