summaryrefslogtreecommitdiff
path: root/apps/root_menu.c
diff options
context:
space:
mode:
authorWilliam Wilgus <wilgus.william@gmail.com>2021-10-23 11:57:56 -0400
committerWilliam Wilgus <wilgus.william@gmail.com>2021-10-23 23:30:42 -0400
commit3e10ecb82a78edb1ea266bd491cce2504d52cbbd (patch)
tree3e0b04895bd8edad58ef7c75b3c630bca48a47c1 /apps/root_menu.c
parent36d319b084b7082f85196464959d0b9287967d6a (diff)
downloadrockbox-3e10ecb82a78edb1ea266bd491cce2504d52cbbd.tar.gz
rockbox-3e10ecb82a78edb1ea266bd491cce2504d52cbbd.zip
root_menu.c code clean up -- stir the ifdef mess?
Change-Id: Ia0a847b5552766e5c78dd2ab00d019e631d600aa
Diffstat (limited to 'apps/root_menu.c')
-rw-r--r--apps/root_menu.c138
1 files changed, 84 insertions, 54 deletions
diff --git a/apps/root_menu.c b/apps/root_menu.c
index a67bb41cde..c72aa07bfa 100644
--- a/apps/root_menu.c
+++ b/apps/root_menu.c
@@ -166,7 +166,7 @@ static int browser(void* param)
166 } 166 }
167 } 167 }
168 if (!in_hotswap) 168 if (!in_hotswap)
169#endif 169#endif /*HAVE_HOTSWAP*/
170 strcpy(folder, last_folder); 170 strcpy(folder, last_folder);
171 } 171 }
172 push_current_activity(ACTIVITY_FILEBROWSER); 172 push_current_activity(ACTIVITY_FILEBROWSER);
@@ -266,7 +266,7 @@ static int browser(void* param)
266 tc->selected_item = last_db_selection; 266 tc->selected_item = last_db_selection;
267 push_current_activity(ACTIVITY_DATABASEBROWSER); 267 push_current_activity(ACTIVITY_DATABASEBROWSER);
268 break; 268 break;
269#endif 269#endif /*HAVE_TAGCACHE*/
270 } 270 }
271 271
272 browse_context_init(&browse, filter, 0, NULL, NOICON, folder, NULL); 272 browse_context_init(&browse, filter, 0, NULL, NOICON, folder, NULL);
@@ -705,7 +705,7 @@ static int load_context_screen(int selection)
705 return retval; 705 return retval;
706} 706}
707 707
708static int load_plugin_screen(char *plug_path, void* plug_param) 708static int load_plugin_screen(char *key)
709{ 709{
710 int ret_val; 710 int ret_val;
711 int old_previous = last_screen; 711 int old_previous = last_screen;
@@ -713,7 +713,15 @@ static int load_plugin_screen(char *plug_path, void* plug_param)
713 global_status.last_screen = (char)next_screen; 713 global_status.last_screen = (char)next_screen;
714 status_save(); 714 status_save();
715 715
716 switch (plugin_load(plug_path, plug_param)) 716
717 int opret = open_plugin_get_entry(key, &open_plugin_entry);
718 bool flush = (opret == OPEN_PLUGIN_NEEDS_FLUSHED);
719 char *path = open_plugin_entry.path;
720 char *param = open_plugin_entry.param;
721 if (param[0] == '\0')
722 param = NULL;
723
724 switch (plugin_load(path, param))
717 { 725 {
718 case PLUGIN_GOTO_WPS: 726 case PLUGIN_GOTO_WPS:
719 ret_val = GO_TO_WPS; 727 ret_val = GO_TO_WPS;
@@ -729,22 +737,30 @@ static int load_plugin_screen(char *plug_path, void* plug_param)
729 break; 737 break;
730 } 738 }
731 739
740 if (!flush && ret_val != GO_TO_PLUGIN)
741 open_plugin_add_path(NULL, NULL, NULL);
742
732 if (ret_val == GO_TO_PREVIOUS) 743 if (ret_val == GO_TO_PREVIOUS)
733 last_screen = (old_previous == next_screen) ? GO_TO_ROOT : old_previous; 744 last_screen = (old_previous == next_screen) ? GO_TO_ROOT : old_previous;
734 return ret_val; 745 return ret_val;
735} 746}
736 747
737void root_menu(void) 748static void ignore_back_button_stub(bool ignore)
738{ 749{
739 int previous_browser = GO_TO_FILEBROWSER; 750#if (CONFIG_PLATFORM&PLATFORM_ANDROID)
740 int selected = 0; 751 /* BACK button to be handled by Android instead of rockbox */
741 int shortcut_origin = GO_TO_ROOT; 752 android_ignore_back_button(ignore);
742 753#else
743 push_current_activity(ACTIVITY_MAINMENU); 754 (void) ignore;
755#endif
756}
744 757
758static int root_menu_setup_screens(void)
759{
760 int new_screen = next_screen;
745 if (global_settings.start_in_screen == 0) 761 if (global_settings.start_in_screen == 0)
746 next_screen = (int)global_status.last_screen; 762 new_screen = (int)global_status.last_screen;
747 else next_screen = global_settings.start_in_screen - 2; 763 else new_screen = global_settings.start_in_screen - 2;
748#if CONFIG_TUNER 764#if CONFIG_TUNER
749 add_event(PLAYBACK_EVENT_START_PLAYBACK, rootmenu_start_playback_callback); 765 add_event(PLAYBACK_EVENT_START_PLAYBACK, rootmenu_start_playback_callback);
750#endif 766#endif
@@ -753,35 +769,52 @@ void root_menu(void)
753 if ( rtc_check_alarm_started(true) ) 769 if ( rtc_check_alarm_started(true) )
754 { 770 {
755 rtc_enable_alarm(false); 771 rtc_enable_alarm(false);
756 next_screen = GO_TO_WPS; 772
773 switch (global_settings.alarm_wake_up_screen)
774 {
757#if CONFIG_TUNER 775#if CONFIG_TUNER
758 if (global_settings.alarm_wake_up_screen == ALARM_START_FM) 776 case ALARM_START_FM:
759 next_screen = GO_TO_FM; 777 new_screen = GO_TO_FM;
778 break;
760#endif 779#endif
761#ifdef HAVE_RECORDING 780#ifdef HAVE_RECORDING
762 if (global_settings.alarm_wake_up_screen == ALARM_START_REC) 781 case ALARM_START_REC:
763 { 782 recording_start_automatic = true;
764 recording_start_automatic = true; 783 new_screen = GO_TO_RECSCREEN;
765 next_screen = GO_TO_RECSCREEN; 784 break;
766 }
767#endif 785#endif
786 default:
787 new_screen = GO_TO_WPS;
788 break;
789 } /* switch() */
768 } 790 }
769#endif /* HAVE_RTC_ALARM */ 791#endif /* HAVE_RTC_ALARM */
770 792
771#if defined(HAVE_HEADPHONE_DETECTION) || defined(HAVE_LINEOUT_DETECTION) 793#if defined(HAVE_HEADPHONE_DETECTION) || defined(HAVE_LINEOUT_DETECTION)
772 if (next_screen == GO_TO_WPS && global_settings.unplug_autoresume) 794 if (new_screen == GO_TO_WPS && global_settings.unplug_autoresume)
773 { 795 {
774 next_screen = GO_TO_ROOT; 796 new_screen = GO_TO_ROOT;
775#ifdef HAVE_HEADPHONE_DETECTION 797#ifdef HAVE_HEADPHONE_DETECTION
776 if (headphones_inserted()) 798 if (headphones_inserted())
777 next_screen = GO_TO_WPS; 799 new_screen = GO_TO_WPS;
778#endif 800#endif
779#ifdef HAVE_LINEOUT_DETECTION 801#ifdef HAVE_LINEOUT_DETECTION
780 if (lineout_inserted()) 802 if (lineout_inserted())
781 next_screen = GO_TO_WPS; 803 new_screen = GO_TO_WPS;
782#endif 804#endif
783 } 805 }
784#endif /*(HAVE_HEADPHONE_DETECTION) || (HAVE_LINEOUT_DETECTION)*/ 806#endif /*(HAVE_HEADPHONE_DETECTION) || (HAVE_LINEOUT_DETECTION)*/
807 return new_screen;
808}
809
810void root_menu(void)
811{
812 int previous_browser = GO_TO_FILEBROWSER;
813 int selected = 0;
814 int shortcut_origin = GO_TO_ROOT;
815
816 push_current_activity(ACTIVITY_MAINMENU);
817 next_screen = root_menu_setup_screens();
785 818
786 while (true) 819 while (true)
787 { 820 {
@@ -793,18 +826,32 @@ void root_menu(void)
793 case GO_TO_ROOT: 826 case GO_TO_ROOT:
794 if (last_screen != GO_TO_ROOT) 827 if (last_screen != GO_TO_ROOT)
795 selected = get_selection(last_screen); 828 selected = get_selection(last_screen);
796#if (CONFIG_PLATFORM&PLATFORM_ANDROID) 829
797 /* When we are in the main menu we want the hardware BACK 830 /* When we are in the main menu we want the hardware BACK
798 * button to be handled by Android instead of rockbox */ 831 * button to be handled by HOST instead of rockbox */
799 android_ignore_back_button(true); 832 ignore_back_button_stub(true);
800#endif 833
801 next_screen = do_menu(&root_menu_, &selected, NULL, false); 834 next_screen = do_menu(&root_menu_, &selected, NULL, false);
802#if (CONFIG_PLATFORM&PLATFORM_ANDROID) 835
803 android_ignore_back_button(false); 836 ignore_back_button_stub(false);
804#endif 837
805 if (next_screen != GO_TO_PREVIOUS) 838 if (next_screen != GO_TO_PREVIOUS)
806 last_screen = GO_TO_ROOT; 839 last_screen = GO_TO_ROOT;
807 break; 840 break;
841#ifdef HAVE_TAGCACHE
842 case GO_TO_FILEBROWSER:
843 case GO_TO_DBBROWSER:
844 previous_browser = next_screen;
845 goto load_next_screen;
846 break;
847#endif /* With !HAVE_TAGCACHE previous_browser is always GO_TO_FILEBROWSER */
848#if CONFIG_TUNER
849 case GO_TO_WPS:
850 case GO_TO_FM:
851 previous_music = next_screen;
852 goto load_next_screen;
853 break;
854#endif /* With !CONFIG_TUNER previous_music is always GO_TO_WPS */
808 855
809 case GO_TO_PREVIOUS: 856 case GO_TO_PREVIOUS:
810 next_screen = last_screen; 857 next_screen = last_screen;
@@ -826,7 +873,6 @@ void root_menu(void)
826 if (global_status.last_screen == GO_TO_SHORTCUTMENU) 873 if (global_status.last_screen == GO_TO_SHORTCUTMENU)
827 { 874 {
828 shortcut_origin = last_screen; 875 shortcut_origin = last_screen;
829 global_status.last_screen = last_screen;
830 key = ID2P(LANG_SHORTCUTS); 876 key = ID2P(LANG_SHORTCUTS);
831 } 877 }
832 else 878 else
@@ -848,17 +894,7 @@ void root_menu(void)
848 } 894 }
849 } 895 }
850 896
851 int opret = open_plugin_get_entry(key, &open_plugin_entry); 897 next_screen = load_plugin_screen(key);
852 bool flush = (opret == OPEN_PLUGIN_NEEDS_FLUSHED);
853 char *path = open_plugin_entry.path;
854 char *param = open_plugin_entry.param;
855 if (param[0] == '\0')
856 param = NULL;
857
858 next_screen = load_plugin_screen(path, param);
859
860 if (!flush && next_screen != GO_TO_PLUGIN)
861 open_plugin_add_path(NULL, NULL, NULL);
862 898
863 /* shortcuts may take several trips through the GO_TO_PLUGIN case 899 /* shortcuts may take several trips through the GO_TO_PLUGIN case
864 make sure we preserve and restore the origin */ 900 make sure we preserve and restore the origin */
@@ -873,18 +909,12 @@ void root_menu(void)
873 break; 909 break;
874 } 910 }
875 default: 911 default:
876#ifdef HAVE_TAGCACHE 912 goto load_next_screen;
877/* With !HAVE_TAGCACHE previous_browser is always GO_TO_FILEBROWSER */
878 if (next_screen == GO_TO_FILEBROWSER || next_screen == GO_TO_DBBROWSER)
879 previous_browser = next_screen;
880#endif
881#if CONFIG_TUNER
882/* With !CONFIG_TUNER previous_music is always GO_TO_WPS */
883 if (next_screen == GO_TO_WPS || next_screen == GO_TO_FM)
884 previous_music = next_screen;
885#endif
886 next_screen = load_screen(next_screen);
887 break; 913 break;
888 } /* switch() */ 914 } /* switch() */
915 continue;
916load_next_screen: /* load_screen is inlined */
917 next_screen = load_screen(next_screen);
889 } 918 }
919
890} 920}