summaryrefslogtreecommitdiff
path: root/apps
diff options
context:
space:
mode:
Diffstat (limited to 'apps')
-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
4 files changed, 119 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);