From 13412f67caebe2dc4b86d7f367eb1dce8609bde1 Mon Sep 17 00:00:00 2001 From: Jonathan Gordon Date: Thu, 9 Feb 2012 21:21:40 +1100 Subject: [PATCH] main menu: Add the ability to hide and reorder the main menu items. To change the shown menu items add the line "root_menu_order:" into your config.cfg can be any of: bookmarks, files, database, wps, settings, recording, radio, playlists, plugins, system_menu, shortcuts Manual entry by Alexander Levin Change-Id: Ie7f4bfb0f795184de094d05fc341a6cedd1c0cde Reviewed-on: http://gerrit.rockbox.org/104 Reviewed-by: Jonathan Gordon --- apps/root_menu.c | 116 ++++++++++++++++++++++++++++---- apps/root_menu.h | 9 ++- apps/settings.h | 2 + apps/settings_list.c | 5 ++ manual/advanced_topics/main.tex | 23 +++++++ 5 files changed, 142 insertions(+), 13 deletions(-) diff --git a/apps/root_menu.c b/apps/root_menu.c index 747ba76c24..16665c1824 100644 --- a/apps/root_menu.c +++ b/apps/root_menu.c @@ -477,26 +477,118 @@ static int do_shutdown(void) MENUITEM_FUNCTION(do_shutdown_item, 0, ID2P(LANG_SHUTDOWN), do_shutdown, NULL, NULL, Icon_NOICON); #endif -MAKE_MENU(root_menu_, ID2P(LANG_ROCKBOX_TITLE), - item_callback, Icon_Rockbox, - &bookmarks, &file_browser, + +struct menu_item_ex root_menu_; +static struct menu_callback_with_desc root_menu_desc = { + item_callback, ID2P(LANG_ROCKBOX_TITLE), Icon_Rockbox }; +struct menu_table { + char *string; + const struct menu_item_ex *item; +}; +static struct menu_table menu_table[] = { + /* Order here represents the default ordering */ + { "bookmarks", &bookmarks }, + { "files", &file_browser }, #ifdef HAVE_TAGCACHE - &db_browser, + { "database", &db_browser }, #endif - &wps_item, &menu_, + { "wps", &wps_item }, + { "settings", &menu_ }, #ifdef HAVE_RECORDING - &rec, + { "recording", &rec }, #endif #if CONFIG_TUNER - &fm, + { "radio", &fm }, #endif - &playlists, &rocks_browser, &system_menu_ - + { "playlists", &playlists }, + { "plugins", &rocks_browser }, + { "system_menu", &system_menu_ }, #if CONFIG_KEYPAD == PLAYER_PAD - ,&do_shutdown_item + { "shutdown", &do_shutdown_item }, #endif - ,&shortcut_menu - ); + { "shortcuts", &shortcut_menu }, +}; +#define MAX_MENU_ITEMS (sizeof(menu_table) / sizeof(struct menu_table)) +static struct menu_item_ex *root_menu__[MAX_MENU_ITEMS]; + +void root_menu_load_from_cfg(void* setting, char *value) +{ + char *next = value, *start; + unsigned int menu_item_count = 0, i; + bool main_menu_added = false; + + root_menu_.flags = MENU_HAS_DESC | MT_MENU; + root_menu_.submenus = (const struct menu_item_ex **)&root_menu__; + root_menu_.callback_and_desc = &root_menu_desc; + + while (next && menu_item_count < MAX_MENU_ITEMS) + { + start = next; + next = strchr(next, ','); + if (next) + { + *next = '\0'; + next++; + } + for (i=0; i