diff options
-rw-r--r-- | apps/root_menu.c | 85 |
1 files changed, 44 insertions, 41 deletions
diff --git a/apps/root_menu.c b/apps/root_menu.c index 3f2e933461..2c72cc47f7 100644 --- a/apps/root_menu.c +++ b/apps/root_menu.c | |||
@@ -84,7 +84,7 @@ static int next_screen = GO_TO_ROOT; /* holding info about the upcoming screen | |||
84 | static int last_screen = GO_TO_ROOT; /* unfortunatly needed so we can resume | 84 | static int last_screen = GO_TO_ROOT; /* unfortunatly needed so we can resume |
85 | or goto current track based on previous | 85 | or goto current track based on previous |
86 | screen */ | 86 | screen */ |
87 | 87 | ||
88 | 88 | ||
89 | static char current_track_path[MAX_PATH]; | 89 | static char current_track_path[MAX_PATH]; |
90 | static void rootmenu_track_changed_callback(void* param) | 90 | static void rootmenu_track_changed_callback(void* param) |
@@ -112,7 +112,7 @@ static int browser(void* param) | |||
112 | { | 112 | { |
113 | case GO_TO_FILEBROWSER: | 113 | case GO_TO_FILEBROWSER: |
114 | filter = global_settings.dirfilter; | 114 | filter = global_settings.dirfilter; |
115 | if (global_settings.browse_current && | 115 | if (global_settings.browse_current && |
116 | last_screen == GO_TO_WPS && | 116 | last_screen == GO_TO_WPS && |
117 | current_track_path[0]) | 117 | current_track_path[0]) |
118 | { | 118 | { |
@@ -164,8 +164,8 @@ static int browser(void* param) | |||
164 | /* Now display progress until it's ready or the user exits */ | 164 | /* Now display progress until it's ready or the user exits */ |
165 | while(!tagcache_is_usable()) | 165 | while(!tagcache_is_usable()) |
166 | { | 166 | { |
167 | struct tagcache_stat *stat = tagcache_get_stat(); | 167 | struct tagcache_stat *stat = tagcache_get_stat(); |
168 | 168 | ||
169 | /* Allow user to exit */ | 169 | /* Allow user to exit */ |
170 | if (action_userabort(HZ/2)) | 170 | if (action_userabort(HZ/2)) |
171 | break; | 171 | break; |
@@ -183,9 +183,9 @@ static int browser(void* param) | |||
183 | splash(0, str(LANG_TAGCACHE_BUSY)); | 183 | splash(0, str(LANG_TAGCACHE_BUSY)); |
184 | continue; | 184 | continue; |
185 | } | 185 | } |
186 | 186 | ||
187 | /* Re-init if required */ | 187 | /* Re-init if required */ |
188 | if (!reinit_attempted && !stat->ready && | 188 | if (!reinit_attempted && !stat->ready && |
189 | stat->processed_entries == 0 && stat->commit_step == 0) | 189 | stat->processed_entries == 0 && stat->commit_step == 0) |
190 | { | 190 | { |
191 | /* Prompt the user */ | 191 | /* Prompt the user */ |
@@ -380,8 +380,8 @@ static int load_bmarks(void* param) | |||
380 | 380 | ||
381 | /* These are all static const'd from apps/menus/ *.c | 381 | /* These are all static const'd from apps/menus/ *.c |
382 | so little hack so we can use them */ | 382 | so little hack so we can use them */ |
383 | extern struct menu_item_ex | 383 | extern struct menu_item_ex |
384 | file_menu, | 384 | file_menu, |
385 | #ifdef HAVE_TAGCACHE | 385 | #ifdef HAVE_TAGCACHE |
386 | tagcache_menu, | 386 | tagcache_menu, |
387 | #endif | 387 | #endif |
@@ -399,23 +399,23 @@ static const struct root_items items[] = { | |||
399 | [GO_TO_WPS] = { wpsscrn, NULL, &playback_settings }, | 399 | [GO_TO_WPS] = { wpsscrn, NULL, &playback_settings }, |
400 | [GO_TO_MAINMENU] = { miscscrn, (struct menu_item_ex*)&main_menu_, | 400 | [GO_TO_MAINMENU] = { miscscrn, (struct menu_item_ex*)&main_menu_, |
401 | &manage_settings }, | 401 | &manage_settings }, |
402 | 402 | ||
403 | #ifdef HAVE_RECORDING | 403 | #ifdef HAVE_RECORDING |
404 | [GO_TO_RECSCREEN] = { recscrn, NULL, &recording_settings_menu }, | 404 | [GO_TO_RECSCREEN] = { recscrn, NULL, &recording_settings_menu }, |
405 | #endif | 405 | #endif |
406 | 406 | ||
407 | #if CONFIG_TUNER | 407 | #if CONFIG_TUNER |
408 | [GO_TO_FM] = { radio, NULL, &radio_settings_menu }, | 408 | [GO_TO_FM] = { radio, NULL, &radio_settings_menu }, |
409 | #endif | 409 | #endif |
410 | 410 | ||
411 | [GO_TO_RECENTBMARKS] = { load_bmarks, NULL, &bookmark_settings_menu }, | 411 | [GO_TO_RECENTBMARKS] = { load_bmarks, NULL, &bookmark_settings_menu }, |
412 | [GO_TO_BROWSEPLUGINS] = { miscscrn, &plugin_menu, NULL }, | 412 | [GO_TO_BROWSEPLUGINS] = { miscscrn, &plugin_menu, NULL }, |
413 | [GO_TO_PLAYLISTS_SCREEN] = { playlist_view_catalog, NULL, | 413 | [GO_TO_PLAYLISTS_SCREEN] = { playlist_view_catalog, NULL, |
414 | &playlist_options }, | 414 | &playlist_options }, |
415 | [GO_TO_PLAYLIST_VIEWER] = { playlist_view, NULL, &playlist_options }, | 415 | [GO_TO_PLAYLIST_VIEWER] = { playlist_view, NULL, &playlist_options }, |
416 | [GO_TO_SYSTEM_SCREEN] = { miscscrn, &info_menu, &system_menu }, | 416 | [GO_TO_SYSTEM_SCREEN] = { miscscrn, &info_menu, &system_menu }, |
417 | [GO_TO_SHORTCUTMENU] = { do_shortcut_menu, NULL, NULL }, | 417 | [GO_TO_SHORTCUTMENU] = { do_shortcut_menu, NULL, NULL }, |
418 | 418 | ||
419 | }; | 419 | }; |
420 | static const int nb_items = sizeof(items)/sizeof(*items); | 420 | static const int nb_items = sizeof(items)/sizeof(*items); |
421 | 421 | ||
@@ -427,13 +427,13 @@ MENUITEM_RETURNVALUE(shortcut_menu, ID2P(LANG_SHORTCUTS), GO_TO_SHORTCUTMENU, | |||
427 | MENUITEM_RETURNVALUE(file_browser, ID2P(LANG_DIR_BROWSER), GO_TO_FILEBROWSER, | 427 | MENUITEM_RETURNVALUE(file_browser, ID2P(LANG_DIR_BROWSER), GO_TO_FILEBROWSER, |
428 | NULL, Icon_file_view_menu); | 428 | NULL, Icon_file_view_menu); |
429 | #ifdef HAVE_TAGCACHE | 429 | #ifdef HAVE_TAGCACHE |
430 | MENUITEM_RETURNVALUE(db_browser, ID2P(LANG_TAGCACHE), GO_TO_DBBROWSER, | 430 | MENUITEM_RETURNVALUE(db_browser, ID2P(LANG_TAGCACHE), GO_TO_DBBROWSER, |
431 | NULL, Icon_Audio); | 431 | NULL, Icon_Audio); |
432 | #endif | 432 | #endif |
433 | MENUITEM_RETURNVALUE(rocks_browser, ID2P(LANG_PLUGINS), GO_TO_BROWSEPLUGINS, | 433 | MENUITEM_RETURNVALUE(rocks_browser, ID2P(LANG_PLUGINS), GO_TO_BROWSEPLUGINS, |
434 | NULL, Icon_Plugin); | 434 | NULL, Icon_Plugin); |
435 | 435 | ||
436 | MENUITEM_RETURNVALUE(playlist_browser, ID2P(LANG_CATALOG), GO_TO_PLAYLIST_VIEWER, | 436 | MENUITEM_RETURNVALUE(playlist_browser, ID2P(LANG_CATALOG), GO_TO_PLAYLIST_VIEWER, |
437 | NULL, Icon_Playlist); | 437 | NULL, Icon_Playlist); |
438 | 438 | ||
439 | static char *get_wps_item_name(int selected_item, void * data, char *buffer) | 439 | static char *get_wps_item_name(int selected_item, void * data, char *buffer) |
@@ -443,20 +443,20 @@ static char *get_wps_item_name(int selected_item, void * data, char *buffer) | |||
443 | return ID2P(LANG_NOW_PLAYING); | 443 | return ID2P(LANG_NOW_PLAYING); |
444 | return ID2P(LANG_RESUME_PLAYBACK); | 444 | return ID2P(LANG_RESUME_PLAYBACK); |
445 | } | 445 | } |
446 | MENUITEM_RETURNVALUE_DYNTEXT(wps_item, GO_TO_WPS, NULL, get_wps_item_name, | 446 | MENUITEM_RETURNVALUE_DYNTEXT(wps_item, GO_TO_WPS, NULL, get_wps_item_name, |
447 | NULL, NULL, Icon_Playback_menu); | 447 | NULL, NULL, Icon_Playback_menu); |
448 | #ifdef HAVE_RECORDING | 448 | #ifdef HAVE_RECORDING |
449 | MENUITEM_RETURNVALUE(rec, ID2P(LANG_RECORDING), GO_TO_RECSCREEN, | 449 | MENUITEM_RETURNVALUE(rec, ID2P(LANG_RECORDING), GO_TO_RECSCREEN, |
450 | NULL, Icon_Recording); | 450 | NULL, Icon_Recording); |
451 | #endif | 451 | #endif |
452 | #if CONFIG_TUNER | 452 | #if CONFIG_TUNER |
453 | MENUITEM_RETURNVALUE(fm, ID2P(LANG_FM_RADIO), GO_TO_FM, | 453 | MENUITEM_RETURNVALUE(fm, ID2P(LANG_FM_RADIO), GO_TO_FM, |
454 | item_callback, Icon_Radio_screen); | 454 | item_callback, Icon_Radio_screen); |
455 | #endif | 455 | #endif |
456 | MENUITEM_RETURNVALUE(menu_, ID2P(LANG_SETTINGS), GO_TO_MAINMENU, | 456 | MENUITEM_RETURNVALUE(menu_, ID2P(LANG_SETTINGS), GO_TO_MAINMENU, |
457 | NULL, Icon_Submenu_Entered); | 457 | NULL, Icon_Submenu_Entered); |
458 | MENUITEM_RETURNVALUE(bookmarks, ID2P(LANG_BOOKMARK_MENU_RECENT_BOOKMARKS), | 458 | MENUITEM_RETURNVALUE(bookmarks, ID2P(LANG_BOOKMARK_MENU_RECENT_BOOKMARKS), |
459 | GO_TO_RECENTBMARKS, item_callback, | 459 | GO_TO_RECENTBMARKS, item_callback, |
460 | Icon_Bookmark); | 460 | Icon_Bookmark); |
461 | MENUITEM_RETURNVALUE(playlists, ID2P(LANG_CATALOG), GO_TO_PLAYLISTS_SCREEN, | 461 | MENUITEM_RETURNVALUE(playlists, ID2P(LANG_CATALOG), GO_TO_PLAYLISTS_SCREEN, |
462 | NULL, Icon_Playlist); | 462 | NULL, Icon_Playlist); |
@@ -493,9 +493,9 @@ static struct menu_table menu_table[] = { | |||
493 | { "database", &db_browser }, | 493 | { "database", &db_browser }, |
494 | #endif | 494 | #endif |
495 | { "wps", &wps_item }, | 495 | { "wps", &wps_item }, |
496 | { "settings", &menu_ }, | 496 | { "settings", &menu_ }, |
497 | #ifdef HAVE_RECORDING | 497 | #ifdef HAVE_RECORDING |
498 | { "recording", &rec }, | 498 | { "recording", &rec }, |
499 | #endif | 499 | #endif |
500 | #if CONFIG_TUNER | 500 | #if CONFIG_TUNER |
501 | { "radio", &fm }, | 501 | { "radio", &fm }, |
@@ -513,7 +513,7 @@ static struct menu_item_ex *root_menu__[MAX_MENU_ITEMS]; | |||
513 | 513 | ||
514 | void root_menu_load_from_cfg(void* setting, char *value) | 514 | void root_menu_load_from_cfg(void* setting, char *value) |
515 | { | 515 | { |
516 | char *next = value, *start; | 516 | char *next = value, *start, *end; |
517 | unsigned int menu_item_count = 0, i; | 517 | unsigned int menu_item_count = 0, i; |
518 | bool main_menu_added = false; | 518 | bool main_menu_added = false; |
519 | 519 | ||
@@ -535,6 +535,9 @@ void root_menu_load_from_cfg(void* setting, char *value) | |||
535 | *next = '\0'; | 535 | *next = '\0'; |
536 | next++; | 536 | next++; |
537 | } | 537 | } |
538 | start = skip_whitespace(start); | ||
539 | if ((end = strchr(start, ' '))) | ||
540 | *end = '\0'; | ||
538 | for (i=0; i<MAX_MENU_ITEMS; i++) | 541 | for (i=0; i<MAX_MENU_ITEMS; i++) |
539 | { | 542 | { |
540 | if (*start && !strcmp(start, menu_table[i].string)) | 543 | if (*start && !strcmp(start, menu_table[i].string)) |
@@ -562,7 +565,7 @@ char* root_menu_write_to_cfg(void* setting, char*buf, int buf_len) | |||
562 | { | 565 | { |
563 | if (menu_table[j].item == root_menu__[i]) | 566 | if (menu_table[j].item == root_menu__[i]) |
564 | { | 567 | { |
565 | written = snprintf(buf, buf_len, "%s,", menu_table[j].string); | 568 | written = snprintf(buf, buf_len, "%s, ", menu_table[j].string); |
566 | buf_len -= written; | 569 | buf_len -= written; |
567 | buf += written; | 570 | buf += written; |
568 | break; | 571 | break; |
@@ -588,14 +591,14 @@ void root_menu_set_default(void* setting, void* defaultval) | |||
588 | root_menu_.flags |= MENU_ITEM_COUNT(MAX_MENU_ITEMS); | 591 | root_menu_.flags |= MENU_ITEM_COUNT(MAX_MENU_ITEMS); |
589 | *(bool*)setting = false; | 592 | *(bool*)setting = false; |
590 | } | 593 | } |
591 | 594 | ||
592 | bool root_menu_is_changed(void* setting, void* defaultval) | 595 | bool root_menu_is_changed(void* setting, void* defaultval) |
593 | { | 596 | { |
594 | (void)defaultval; | 597 | (void)defaultval; |
595 | return *(bool*)setting; | 598 | return *(bool*)setting; |
596 | } | 599 | } |
597 | 600 | ||
598 | static int item_callback(int action, const struct menu_item_ex *this_item) | 601 | static int item_callback(int action, const struct menu_item_ex *this_item) |
599 | { | 602 | { |
600 | switch (action) | 603 | switch (action) |
601 | { | 604 | { |
@@ -608,7 +611,7 @@ static int item_callback(int action, const struct menu_item_ex *this_item) | |||
608 | if (radio_hardware_present() == 0) | 611 | if (radio_hardware_present() == 0) |
609 | return ACTION_EXIT_MENUITEM; | 612 | return ACTION_EXIT_MENUITEM; |
610 | } | 613 | } |
611 | else | 614 | else |
612 | #endif | 615 | #endif |
613 | if (this_item == &bookmarks) | 616 | if (this_item == &bookmarks) |
614 | { | 617 | { |
@@ -625,7 +628,7 @@ static int get_selection(int last_screen) | |||
625 | int len = ARRAYLEN(root_menu__); | 628 | int len = ARRAYLEN(root_menu__); |
626 | for(i=0; i < len; i++) | 629 | for(i=0; i < len; i++) |
627 | { | 630 | { |
628 | if (((root_menu__[i]->flags&MENU_TYPE_MASK) == MT_RETURN_VALUE) && | 631 | if (((root_menu__[i]->flags&MENU_TYPE_MASK) == MT_RETURN_VALUE) && |
629 | (root_menu__[i]->value == last_screen)) | 632 | (root_menu__[i]->value == last_screen)) |
630 | { | 633 | { |
631 | return i; | 634 | return i; |
@@ -683,7 +686,7 @@ static int load_context_screen(int selection) | |||
683 | { | 686 | { |
684 | context_menu = &system_menu; | 687 | context_menu = &system_menu; |
685 | } | 688 | } |
686 | 689 | ||
687 | if (context_menu) | 690 | if (context_menu) |
688 | retval = do_menu(context_menu, NULL, NULL, false); | 691 | retval = do_menu(context_menu, NULL, NULL, false); |
689 | pop_current_activity(); | 692 | pop_current_activity(); |
@@ -694,11 +697,11 @@ static int load_context_screen(int selection) | |||
694 | static int load_plugin_screen(char *plug_path) | 697 | static int load_plugin_screen(char *plug_path) |
695 | { | 698 | { |
696 | int ret_val; | 699 | int ret_val; |
697 | int old_previous = last_screen; | 700 | int old_previous = last_screen; |
698 | last_screen = next_screen; | 701 | last_screen = next_screen; |
699 | global_status.last_screen = (char)next_screen; | 702 | global_status.last_screen = (char)next_screen; |
700 | status_save(); | 703 | status_save(); |
701 | 704 | ||
702 | switch (plugin_load(plug_path, NULL)) | 705 | switch (plugin_load(plug_path, NULL)) |
703 | { | 706 | { |
704 | case PLUGIN_GOTO_WPS: | 707 | case PLUGIN_GOTO_WPS: |
@@ -729,7 +732,7 @@ void root_menu(void) | |||
729 | { | 732 | { |
730 | int previous_browser = GO_TO_FILEBROWSER; | 733 | int previous_browser = GO_TO_FILEBROWSER; |
731 | int selected = 0; | 734 | int selected = 0; |
732 | 735 | ||
733 | push_current_activity(ACTIVITY_MAINMENU); | 736 | push_current_activity(ACTIVITY_MAINMENU); |
734 | 737 | ||
735 | if (global_settings.start_in_screen == 0) | 738 | if (global_settings.start_in_screen == 0) |
@@ -737,7 +740,7 @@ void root_menu(void) | |||
737 | else next_screen = global_settings.start_in_screen - 2; | 740 | else next_screen = global_settings.start_in_screen - 2; |
738 | add_event(PLAYBACK_EVENT_TRACK_CHANGE, false, rootmenu_track_changed_callback); | 741 | add_event(PLAYBACK_EVENT_TRACK_CHANGE, false, rootmenu_track_changed_callback); |
739 | #ifdef HAVE_RTC_ALARM | 742 | #ifdef HAVE_RTC_ALARM |
740 | if ( rtc_check_alarm_started(true) ) | 743 | if ( rtc_check_alarm_started(true) ) |
741 | { | 744 | { |
742 | rtc_enable_alarm(false); | 745 | rtc_enable_alarm(false); |
743 | next_screen = GO_TO_WPS; | 746 | next_screen = GO_TO_WPS; |
@@ -756,7 +759,7 @@ void root_menu(void) | |||
756 | #endif /* HAVE_RTC_ALARM */ | 759 | #endif /* HAVE_RTC_ALARM */ |
757 | 760 | ||
758 | #ifdef HAVE_HEADPHONE_DETECTION | 761 | #ifdef HAVE_HEADPHONE_DETECTION |
759 | if (next_screen == GO_TO_WPS && | 762 | if (next_screen == GO_TO_WPS && |
760 | (global_settings.unplug_autoresume && !headphones_inserted() )) | 763 | (global_settings.unplug_autoresume && !headphones_inserted() )) |
761 | next_screen = GO_TO_ROOT; | 764 | next_screen = GO_TO_ROOT; |
762 | #endif | 765 | #endif |
@@ -798,12 +801,12 @@ void root_menu(void) | |||
798 | case GO_TO_ROOTITEM_CONTEXT: | 801 | case GO_TO_ROOTITEM_CONTEXT: |
799 | next_screen = load_context_screen(selected); | 802 | next_screen = load_context_screen(selected); |
800 | break; | 803 | break; |
801 | #ifdef HAVE_PICTUREFLOW_INTEGRATION | 804 | #ifdef HAVE_PICTUREFLOW_INTEGRATION |
802 | case GO_TO_PICTUREFLOW: | 805 | case GO_TO_PICTUREFLOW: |
803 | while ( !tagcache_is_usable() ) | 806 | while ( !tagcache_is_usable() ) |
804 | { | 807 | { |
805 | splash(0, str(LANG_TAGCACHE_BUSY)); | 808 | splash(0, str(LANG_TAGCACHE_BUSY)); |
806 | if ( action_userabort(HZ/5) ) | 809 | if ( action_userabort(HZ/5) ) |
807 | break; | 810 | break; |
808 | } | 811 | } |
809 | { | 812 | { |
@@ -815,15 +818,15 @@ void root_menu(void) | |||
815 | } | 818 | } |
816 | previous_browser = GO_TO_PICTUREFLOW; | 819 | previous_browser = GO_TO_PICTUREFLOW; |
817 | break; | 820 | break; |
818 | #endif | 821 | #endif |
819 | default: | 822 | default: |
820 | if (next_screen == GO_TO_FILEBROWSER | 823 | if (next_screen == GO_TO_FILEBROWSER |
821 | #ifdef HAVE_TAGCACHE | 824 | #ifdef HAVE_TAGCACHE |
822 | || next_screen == GO_TO_DBBROWSER | 825 | || next_screen == GO_TO_DBBROWSER |
823 | #endif | 826 | #endif |
824 | ) | 827 | ) |
825 | previous_browser = next_screen; | 828 | previous_browser = next_screen; |
826 | if (next_screen == GO_TO_WPS | 829 | if (next_screen == GO_TO_WPS |
827 | #if CONFIG_TUNER | 830 | #if CONFIG_TUNER |
828 | || next_screen == GO_TO_FM | 831 | || next_screen == GO_TO_FM |
829 | #endif | 832 | #endif |