summaryrefslogtreecommitdiff
path: root/apps/root_menu.c
diff options
context:
space:
mode:
Diffstat (limited to 'apps/root_menu.c')
-rw-r--r--apps/root_menu.c116
1 files changed, 104 insertions, 12 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{