diff options
Diffstat (limited to 'apps/root_menu.c')
-rw-r--r-- | apps/root_menu.c | 133 |
1 files changed, 100 insertions, 33 deletions
diff --git a/apps/root_menu.c b/apps/root_menu.c index e4020ae6c7..e606d5cd68 100644 --- a/apps/root_menu.c +++ b/apps/root_menu.c @@ -107,7 +107,7 @@ static void rootmenu_track_changed_callback(unsigned short id, void* param) { (void)id; struct mp3entry *id3 = ((struct track_event *)param)->id3; - strlcpy(current_track_path, id3->path, MAX_PATH); + strmemccpy(current_track_path, id3->path, MAX_PATH); } static int browser(void* param) { @@ -115,14 +115,13 @@ static int browser(void* param) #ifdef HAVE_TAGCACHE struct tree_context* tc = tree_get_context(); #endif - struct browse_context browse; 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 */ #ifdef HAVE_TAGCACHE - static int last_db_dirlevel = 0, last_db_selection = 0; + static int last_db_dirlevel = 0, last_db_selection = 0, last_ft_dirlevel = 0; #endif switch ((intptr_t)param) @@ -241,15 +240,19 @@ static int browser(void* param) { if (lang_is_rtl()) { - splashf(0, "[%d/%d] %s", stat->commit_step, - tagcache_get_max_commit_step(), - str(LANG_TAGCACHE_INIT)); + splash_progress(stat->commit_step, + tagcache_get_max_commit_step(), + "[%d/%d] %s", stat->commit_step, + tagcache_get_max_commit_step(), + str(LANG_TAGCACHE_INIT)); } else { - splashf(0, "%s [%d/%d]", str(LANG_TAGCACHE_INIT), - stat->commit_step, - tagcache_get_max_commit_step()); + splash_progress(stat->commit_step, + tagcache_get_max_commit_step(), + "%s [%d/%d]", str(LANG_TAGCACHE_INIT), + stat->commit_step, + tagcache_get_max_commit_step()); } } else @@ -262,6 +265,7 @@ static int browser(void* param) if (!tagcache_is_usable()) return GO_TO_PREVIOUS; filter = SHOW_ID3DB; + last_ft_dirlevel = tc->dirlevel; tc->dirlevel = last_db_dirlevel; tc->selected_item = last_db_selection; push_current_activity(ACTIVITY_DATABASEBROWSER); @@ -269,9 +273,21 @@ static int browser(void* param) #endif /*HAVE_TAGCACHE*/ } - browse_context_init(&browse, filter, 0, NULL, NOICON, folder, NULL); + struct browse_context browse = { + .dirfilter = filter, + .icon = Icon_NOICON, + .root = folder, + }; + ret_val = rockbox_browse(&browse); - pop_current_activity(); + + if (ret_val == GO_TO_WPS + || ret_val == GO_TO_PREVIOUS_MUSIC + || ret_val == GO_TO_PLUGIN) + pop_current_activity_without_refresh(); + else + pop_current_activity(); + switch ((intptr_t)param) { case GO_TO_FILEBROWSER: @@ -287,6 +303,7 @@ static int browser(void* param) case GO_TO_DBBROWSER: last_db_dirlevel = tc->dirlevel; last_db_selection = tc->selected_item; + tc->dirlevel = last_ft_dirlevel; break; #endif } @@ -313,7 +330,7 @@ static int wpsscrn(void* param) } else if ( global_status.resume_index != -1 ) { - DEBUGF("Resume index %X crc32 %lX offset %lX\n", + DEBUGF("Resume index %d crc32 %lX offset %lX\n", global_status.resume_index, (unsigned long)global_status.resume_crc32, (unsigned long)global_status.resume_offset); @@ -330,7 +347,23 @@ static int wpsscrn(void* param) { splash(HZ*2, ID2P(LANG_NOTHING_TO_RESUME)); } - pop_current_activity(); + + if (ret_val == GO_TO_PLAYLIST_VIEWER + || ret_val == GO_TO_PLUGIN + || ret_val == GO_TO_WPS + || ret_val == GO_TO_PREVIOUS_MUSIC + || ret_val == GO_TO_PREVIOUS_BROWSER + || (ret_val == GO_TO_PREVIOUS + && (last_screen == GO_TO_MAINMENU /* Settings */ + || last_screen == GO_TO_BROWSEPLUGINS + || last_screen == GO_TO_SYSTEM_SCREEN + || last_screen == GO_TO_PLAYLISTS_SCREEN))) + { + pop_current_activity_without_refresh(); + } + else + pop_current_activity(); + return ret_val; } #if CONFIG_TUNER @@ -351,6 +384,7 @@ static int miscscrn(void * param) case GO_TO_PLUGIN: case GO_TO_PLAYLIST_VIEWER: case GO_TO_WPS: + case GO_TO_PREVIOUS_MUSIC: return result; default: return GO_TO_ROOT; @@ -360,15 +394,17 @@ static int miscscrn(void * param) static int playlist_view_catalog(void * param) { - /* kludge untill catalog_view_playlists() returns something useful */ - int old_playstatus = audio_status(); (void)param; push_current_activity(ACTIVITY_PLAYLISTBROWSER); - catalog_view_playlists(); - pop_current_activity(); - if (!old_playstatus && audio_status()) + bool item_was_selected = catalog_view_playlists(); + + if (item_was_selected) + { + pop_current_activity_without_refresh(); return GO_TO_WPS; - return GO_TO_PREVIOUS; + } + pop_current_activity(); + return GO_TO_ROOT; } static int playlist_view(void * param) @@ -376,9 +412,7 @@ static int playlist_view(void * param) (void)param; int val; - push_current_activity(ACTIVITY_PLAYLISTVIEWER); val = playlist_viewer(); - pop_current_activity(); switch (val) { case PLAYLIST_VIEWER_MAINMENU: @@ -677,7 +711,18 @@ static inline int load_screen(int screen) ret_val = items[screen].function(items[screen].param); if (activity != ACTIVITY_UNKNOWN) - pop_current_activity(); + { + if (ret_val == GO_TO_PLUGIN + || ret_val == GO_TO_WPS + || ret_val == GO_TO_PREVIOUS_MUSIC + || ret_val == GO_TO_PREVIOUS_BROWSER + || ret_val == GO_TO_FILEBROWSER) + { + pop_current_activity_without_refresh(); + } + else + pop_current_activity(); + } last_screen = screen; if (ret_val == GO_TO_PREVIOUS) @@ -719,12 +764,14 @@ static int load_plugin_screen(char *key) while(loops-- > 0) /* just to keep things from getting out of hand */ { - int opret = open_plugin_get_entry(key, &open_plugin_entry); - char *path = open_plugin_entry.path; - char *param = open_plugin_entry.param; + int opret = open_plugin_load_entry(key); + struct open_plugin_entry_t *op_entry = open_plugin_get_entry(); + char *path = op_entry->path; + char *param = op_entry->param; if (param[0] == '\0') param = NULL; - + if (path[0] == '\0' && key) + path = P2STR((unsigned char *)key); int ret = plugin_load(path, param); if (ret == PLUGIN_USB_CONNECTED || ret == PLUGIN_ERROR) @@ -732,13 +779,19 @@ static int load_plugin_screen(char *key) else if (ret == PLUGIN_GOTO_WPS) ret_val = GO_TO_WPS; else if (ret == PLUGIN_GOTO_PLUGIN) + { + if (key == (char*)LANG_SHORTCUTS && op_entry->lang_id == LANG_OPEN_PLUGIN) + { + op_entry->lang_id = LANG_SHORTCUTS; + } continue; + } else { + ret_val = GO_TO_PREVIOUS; /* Prevents infinite loop with WPS, Plugins, Previous Screen*/ if (ret == PLUGIN_OK && old_global == GO_TO_WPS && !audio_status()) ret_val = GO_TO_ROOT; - ret_val = GO_TO_PREVIOUS; last_screen = (old_previous == next_screen || old_global == GO_TO_ROOT) ? GO_TO_ROOT : old_previous; if (last_screen == GO_TO_ROOT) @@ -749,8 +802,8 @@ static int load_plugin_screen(char *key) if (opret != OPEN_PLUGIN_NEEDS_FLUSHED || last_screen != GO_TO_WPS) { /* Keep the entry in case of GO_TO_PREVIOUS */ - open_plugin_entry.hash = 0; /*remove hash -- prevents flush to disk */ - open_plugin_entry.lang_id = LANG_PREVIOUS_SCREEN; + op_entry->hash = 0; /*remove hash -- prevents flush to disk */ + op_entry->lang_id = LANG_PREVIOUS_SCREEN; /*open_plugin_add_path(NULL, NULL, NULL);// clear entry */ } break; @@ -898,6 +951,8 @@ void root_menu(void) next_screen = last_screen; if (last_screen == GO_TO_PLUGIN)/* for WPS */ last_screen = GO_TO_PREVIOUS; + else if (last_screen == GO_TO_PREVIOUS) + next_screen = GO_TO_ROOT; break; } @@ -917,8 +972,9 @@ void root_menu(void) char *key; if (global_status.last_screen == GO_TO_SHORTCUTMENU) { - if (open_plugin_entry.lang_id == LANG_OPEN_PLUGIN) - open_plugin_entry.lang_id = LANG_SHORTCUTS; + struct open_plugin_entry_t *op_entry = open_plugin_get_entry(); + if (op_entry->lang_id == LANG_OPEN_PLUGIN) + op_entry->lang_id = LANG_SHORTCUTS; shortcut_origin = last_screen; key = ID2P(LANG_SHORTCUTS); } @@ -944,13 +1000,24 @@ void root_menu(void) } } - next_screen = load_plugin_screen(key); + + push_activity_without_refresh(ACTIVITY_UNKNOWN); /* prevent plugin_load */ + next_screen = load_plugin_screen(key); /* from flashing root */ + pop_current_activity_without_refresh(); /* menu activity */ if (next_screen == GO_TO_PREVIOUS) { /* shortcuts may take several trips through the GO_TO_PLUGIN case make sure we preserve and restore the origin */ - if (shortcut_origin != GO_TO_ROOT) + if(tree_get_context()->out_of_tree > 0) /* a shortcut has been selected */ + { + next_screen = GO_TO_FILEBROWSER; + shortcut_origin = GO_TO_ROOT; + /* note in some cases there is a screen to return to + but the history is rewritten as if you browsed here + from the root so return there when finished */ + } + else if (shortcut_origin != GO_TO_ROOT) { if (shortcut_origin != GO_TO_WPS) next_screen = shortcut_origin; |