From dc24a18cef83d88f4e6ab657ca0adfccf1051474 Mon Sep 17 00:00:00 2001 From: William Wilgus Date: Fri, 22 Oct 2021 22:17:36 -0400 Subject: PLUGINBROWSER make resumable make the plugin browser remember the last item between invocations this has bugged me for the longest time dealing with the plugin_menu Fix a very old bug fix for reloading lang strings in the lang menu FS#8117, sending multiple ENTER_MENU_ITEM callbacks from different areas of the code makes it hard to keep track of where your callback is originating Change-Id: Ib0a61558c11ee4c772134378a7020ac0e10fc4ee --- apps/menus/plugin_menu.c | 30 +++++++++++++++++++++++++++--- 1 file changed, 27 insertions(+), 3 deletions(-) (limited to 'apps/menus/plugin_menu.c') diff --git a/apps/menus/plugin_menu.c b/apps/menus/plugin_menu.c index 055cfce140..7f29e61af4 100644 --- a/apps/menus/plugin_menu.c +++ b/apps/menus/plugin_menu.c @@ -24,11 +24,12 @@ #include "config.h" #include "lang.h" #include "menu.h" +#include "action.h" #include "settings.h" #include "rbpaths.h" #include "root_menu.h" #include "tree.h" - +static int reenter = 0; enum { GAMES, @@ -53,13 +54,36 @@ static int plugins_menu(void* param) browse_context_init(&browse, SHOW_PLUGINS, 0, str(items[item].id), Icon_Plugin, items[item].path, NULL); - + ret = rockbox_browse(&browse); + if (ret == GO_TO_PREVIOUS) return 0; + if (ret == GO_TO_PLUGIN) + reenter = 1; return ret; } +static int menu_callback(int action, + const struct menu_item_ex *this_item, + struct gui_synclist *this_list) +{ + (void)this_item; + static int selected = 0; + + if (action == ACTION_ENTER_MENUITEM) + { + this_list->selected_item = selected; + if (reenter-- > 0) + action = ACTION_STD_OK; + } + else if (action == ACTION_STD_OK) + { + selected = gui_synclist_get_sel_pos(this_list); + } + return action; +} + #define ITEM_FLAG (MENU_FUNC_USEPARAM|MENU_FUNC_CHECK_RETVAL) MENUITEM_FUNCTION(games_item, ITEM_FLAG, ID2P(LANG_PLUGIN_GAMES), @@ -69,6 +93,6 @@ MENUITEM_FUNCTION(apps_item, ITEM_FLAG, ID2P(LANG_PLUGIN_APPS), MENUITEM_FUNCTION(demos_item, ITEM_FLAG, ID2P(LANG_PLUGIN_DEMOS), plugins_menu, (void*)DEMOS, NULL, Icon_Folder); -MAKE_MENU(plugin_menu, ID2P(LANG_PLUGINS), NULL, +MAKE_MENU(plugin_menu, ID2P(LANG_PLUGINS), &menu_callback, Icon_Plugin, &games_item, &apps_item, &demos_item); -- cgit v1.2.3