summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonathan Gordon <rockbox@jdgordon.info>2012-02-09 21:21:40 +1100
committerJonathan Gordon <rockbox@jdgordon.info>2012-02-25 12:40:44 +0100
commit13412f67caebe2dc4b86d7f367eb1dce8609bde1 (patch)
tree9aeba92e3092dd17878ce8caefff35c3eba99d98
parent8125877f6091066d847cf4bb4b8dcf0925830875 (diff)
downloadrockbox-13412f67caebe2dc4b86d7f367eb1dce8609bde1.tar.gz
rockbox-13412f67caebe2dc4b86d7f367eb1dce8609bde1.zip
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:<items>" into your config.cfg <items> 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 <rockbox@jdgordon.info>
-rw-r--r--apps/root_menu.c116
-rw-r--r--apps/root_menu.h9
-rw-r--r--apps/settings.h2
-rw-r--r--apps/settings_list.c5
-rw-r--r--manual/advanced_topics/main.tex23
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)
477MENUITEM_FUNCTION(do_shutdown_item, 0, ID2P(LANG_SHUTDOWN), 477MENUITEM_FUNCTION(do_shutdown_item, 0, ID2P(LANG_SHUTDOWN),
478 do_shutdown, NULL, NULL, Icon_NOICON); 478 do_shutdown, NULL, NULL, Icon_NOICON);
479#endif 479#endif
480MAKE_MENU(root_menu_, ID2P(LANG_ROCKBOX_TITLE), 480
481 item_callback, Icon_Rockbox, 481struct menu_item_ex root_menu_;
482 &bookmarks, &file_browser, 482static struct menu_callback_with_desc root_menu_desc = {
483 item_callback, ID2P(LANG_ROCKBOX_TITLE), Icon_Rockbox };
484struct menu_table {
485 char *string;
486 const struct menu_item_ex *item;
487};
488static struct menu_table menu_table[] = {
489 /* Order here represents the default ordering */
490 { "bookmarks", &bookmarks },
491 { "files", &file_browser },
483#ifdef HAVE_TAGCACHE 492#ifdef HAVE_TAGCACHE
484 &db_browser, 493 { "database", &db_browser },
485#endif 494#endif
486 &wps_item, &menu_, 495 { "wps", &wps_item },
496 { "settings", &menu_ },
487#ifdef HAVE_RECORDING 497#ifdef HAVE_RECORDING
488 &rec, 498 { "recording", &rec },
489#endif 499#endif
490#if CONFIG_TUNER 500#if CONFIG_TUNER
491 &fm, 501 { "radio", &fm },
492#endif 502#endif
493 &playlists, &rocks_browser, &system_menu_ 503 { "playlists", &playlists },
494 504 { "plugins", &rocks_browser },
505 { "system_menu", &system_menu_ },
495#if CONFIG_KEYPAD == PLAYER_PAD 506#if CONFIG_KEYPAD == PLAYER_PAD
496 ,&do_shutdown_item 507 { "shutdown", &do_shutdown_item },
497#endif 508#endif
498 ,&shortcut_menu 509 { "shortcuts", &shortcut_menu },
499 ); 510};
511#define MAX_MENU_ITEMS (sizeof(menu_table) / sizeof(struct menu_table))
512static struct menu_item_ex *root_menu__[MAX_MENU_ITEMS];
513
514void root_menu_load_from_cfg(void* setting, char *value)
515{
516 char *next = value, *start;
517 unsigned int menu_item_count = 0, i;
518 bool main_menu_added = false;
519
520 root_menu_.flags = MENU_HAS_DESC | MT_MENU;
521 root_menu_.submenus = (const struct menu_item_ex **)&root_menu__;
522 root_menu_.callback_and_desc = &root_menu_desc;
523
524 while (next && menu_item_count < MAX_MENU_ITEMS)
525 {
526 start = next;
527 next = strchr(next, ',');
528 if (next)
529 {
530 *next = '\0';
531 next++;
532 }
533 for (i=0; i<MAX_MENU_ITEMS; i++)
534 {
535 if (*start && !strcmp(start, menu_table[i].string))
536 {
537 root_menu__[menu_item_count++] = (struct menu_item_ex *)menu_table[i].item;
538 if (menu_table[i].item == &menu_)
539 main_menu_added = true;
540 break;
541 }
542 }
543 }
544 if (!main_menu_added)
545 root_menu__[menu_item_count++] = (struct menu_item_ex *)&menu_;
546 root_menu_.flags |= MENU_ITEM_COUNT(menu_item_count);
547 *(int*)setting = 1;
548}
549
550char* root_menu_write_to_cfg(void* setting, char*buf, int buf_len)
551{
552 (void)setting;
553 unsigned i, written, j;
554 for (i = 0; i < MENU_GET_COUNT(root_menu_.flags); i++)
555 {
556 for (j=0; j<MAX_MENU_ITEMS; j++)
557 {
558 if (menu_table[j].item == root_menu__[i])
559 {
560 written = snprintf(buf, buf_len, "%s,", menu_table[j].string);
561 buf_len -= written;
562 buf += written;
563 break;
564 }
565 }
566 }
567 return buf;
568}
569
570void root_menu_set_default(void* setting, void* defaultval)
571{
572 unsigned i;
573 (void)defaultval;
574
575 root_menu_.flags = MENU_HAS_DESC | MT_MENU;
576 root_menu_.submenus = (const struct menu_item_ex **)&root_menu__;
577 root_menu_.callback_and_desc = &root_menu_desc;
578
579 for (i=0; i<MAX_MENU_ITEMS; i++)
580 {
581 root_menu__[i] = (struct menu_item_ex *)menu_table[i].item;
582 }
583 root_menu_.flags |= MENU_ITEM_COUNT(MAX_MENU_ITEMS);
584 *(int*)setting = 0;
585}
586
587bool root_menu_is_changed(void* setting, void* defaultval)
588{
589 (void)defaultval;
590 return *(int*)setting != 0;
591}
500 592
501static int item_callback(int action, const struct menu_item_ex *this_item) 593static int item_callback(int action, const struct menu_item_ex *this_item)
502{ 594{
diff --git a/apps/root_menu.h b/apps/root_menu.h
index 8d11d9b338..32385d9530 100644
--- a/apps/root_menu.h
+++ b/apps/root_menu.h
@@ -61,8 +61,15 @@ enum {
61 GO_TO_SHORTCUTMENU 61 GO_TO_SHORTCUTMENU
62}; 62};
63 63
64extern const struct menu_item_ex root_menu_; 64extern struct menu_item_ex root_menu_;
65 65
66extern void previous_music_is_wps(void); 66extern void previous_music_is_wps(void);
67 67
68void root_menu_load_from_cfg(void* setting, char *value);
69char* root_menu_write_to_cfg(void* setting, char*buf, int buf_len);
70void root_menu_set_default(void* setting, void* defaultval);
71bool root_menu_is_changed(void* setting, void* defaultval);
72
73
74
68#endif /* __ROOT_MENU_H__ */ 75#endif /* __ROOT_MENU_H__ */
diff --git a/apps/settings.h b/apps/settings.h
index 7a6fa55e79..ca0abaa202 100644
--- a/apps/settings.h
+++ b/apps/settings.h
@@ -844,6 +844,8 @@ struct user_settings
844#endif 844#endif
845 845
846 char start_directory[MAX_PATHNAME+1]; 846 char start_directory[MAX_PATHNAME+1];
847 /* status setting for the root menu customisability. 0 = default, 1 = loaded from cfg */
848 int root_menu;
847}; 849};
848 850
849/** global variables **/ 851/** global variables **/
diff --git a/apps/settings_list.c b/apps/settings_list.c
index 44295ac5aa..c4d4d27f45 100644
--- a/apps/settings_list.c
+++ b/apps/settings_list.c
@@ -1921,6 +1921,11 @@ const struct settings_list settings[] = {
1921 "resume rewind", UNIT_SEC, 0, 60, 5, 1921 "resume rewind", UNIT_SEC, 0, 60, 5,
1922 NULL, NULL, NULL), 1922 NULL, NULL, NULL),
1923#endif 1923#endif
1924 CUSTOM_SETTING(0, root_menu,
1925 LANG_ROCKBOX_TITLE, /* lang string here is never actually used */
1926 NULL, "root_menu_order",
1927 root_menu_load_from_cfg, root_menu_write_to_cfg,
1928 root_menu_is_changed, root_menu_set_default),
1924}; 1929};
1925 1930
1926const int nb_settings = sizeof(settings)/sizeof(*settings); 1931const int nb_settings = sizeof(settings)/sizeof(*settings);
diff --git a/manual/advanced_topics/main.tex b/manual/advanced_topics/main.tex
index 93d1935785..196053759b 100644
--- a/manual/advanced_topics/main.tex
+++ b/manual/advanced_topics/main.tex
@@ -2,6 +2,29 @@
2\chapter{Advanced Topics} 2\chapter{Advanced Topics}
3 3
4\section{\label{ref:CustomisingUI}Customising the User Interface} 4\section{\label{ref:CustomisingUI}Customising the User Interface}
5
6\subsection{\label{ref:CustomisingTheMainMenu}Customising The Main Menu}
7
8It is possible to customise the main menu, i.e. to reorder or to hide some
9of its items. To accomplish this, the file \fname{/.rockbox/config.cfg} must
10be edited (presumably on the computer while the \dap{} is connected to it
11via USB). There, the line starting with \config{root\_menu\_order:} must
12be edited (or created if it is not present yet).
13
14The line should look like \config{root\_menu\_order:items}, where ``items''
15is a comma separated list (no spaces around the commas!) of the following
16words: \config{bookmarks}, \config{files}, \opt{database}{\config{database}, }%
17\config{wps}, \config{settings}, \opt{recording}{\config{recording}, }%
18\opt{radio}{\config{radio}, }\config{playlists}, \config{plugins},
19\config{system\_menu}, \opt{PLAYER_PAD}{\config{shutdown}, }\config{shortcuts}.
20Each of the words, if it occurs in the list, activates the appropriate item
21in the main menu. The order of the items is given by the order of the words
22in the list. The items whose words do not occur in the list will be hidden,
23with one exception: the menu item ``Settings'' will be shown even if its word
24is not in the list (it is added as the last item then).
25
26Only the main menu can be customised this way, submenus can not.
27
5\opt{lcd_bitmap}{ 28\opt{lcd_bitmap}{
6\subsection{\label{ref:GettingExtras}Getting Extras} 29\subsection{\label{ref:GettingExtras}Getting Extras}
7 30