diff options
Diffstat (limited to 'apps/menus/main_menu.c')
-rw-r--r-- | apps/menus/main_menu.c | 125 |
1 files changed, 125 insertions, 0 deletions
diff --git a/apps/menus/main_menu.c b/apps/menus/main_menu.c new file mode 100644 index 0000000000..e830f4bbc7 --- /dev/null +++ b/apps/menus/main_menu.c | |||
@@ -0,0 +1,125 @@ | |||
1 | |||
2 | /*************************************************************************** | ||
3 | * __________ __ ___. | ||
4 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
5 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
6 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
7 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
8 | * \/ \/ \/ \/ \/ | ||
9 | * $Id: $ | ||
10 | * | ||
11 | * Copyright (C) 2007 Jonathan Gordon | ||
12 | * | ||
13 | * All files in this archive are subject to the GNU General Public License. | ||
14 | * See the file COPYING in the source tree root for full license agreement. | ||
15 | * | ||
16 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
17 | * KIND, either express or implied. | ||
18 | * | ||
19 | ****************************************************************************/ | ||
20 | |||
21 | #include <stdbool.h> | ||
22 | #include <stddef.h> | ||
23 | #include <limits.h> | ||
24 | #include "config.h" | ||
25 | #include "lang.h" | ||
26 | #include "action.h" | ||
27 | #include "settings.h" | ||
28 | #include "powermgmt.h" | ||
29 | #include "menu.h" | ||
30 | #include "settings_menu.h" | ||
31 | #include "exported_menus.h" | ||
32 | #include "tree.h" | ||
33 | #ifdef CONFIG_TUNER | ||
34 | #include "radio.h" | ||
35 | #endif | ||
36 | #ifdef HAVE_RECORDING | ||
37 | #include "recording.h" | ||
38 | #endif | ||
39 | #include "bookmark.h" | ||
40 | |||
41 | /* lazy coders can use this function if the needed callback | ||
42 | is just to say if the item is shown or not */ | ||
43 | int dynamicitem_callback(int action,const struct menu_item_ex *this_item); | ||
44 | |||
45 | /***********************************/ | ||
46 | /* MAIN MENU */ | ||
47 | |||
48 | struct browse_folder_info { | ||
49 | const char* dir; | ||
50 | int show_options; | ||
51 | }; | ||
52 | static struct browse_folder_info theme = {THEME_DIR, SHOW_CFG}; | ||
53 | static struct browse_folder_info rocks = {PLUGIN_DIR, SHOW_PLUGINS}; | ||
54 | static int browse_folder(void *param) | ||
55 | { | ||
56 | const struct browse_folder_info *info = | ||
57 | (const struct browse_folder_info*)param; | ||
58 | return rockbox_browse(info->dir, info->show_options); | ||
59 | } | ||
60 | MENUITEM_FUNCTION_WPARAM(browse_themes, ID2P(LANG_CUSTOM_THEME), | ||
61 | browse_folder, (void*)&theme, NULL); | ||
62 | MENUITEM_FUNCTION_WPARAM(browse_plugins, ID2P(LANG_PLUGINS), | ||
63 | browse_folder, (void*)&rocks, NULL); | ||
64 | |||
65 | #ifdef CONFIG_TUNER | ||
66 | MENUITEM_FUNCTION(load_radio_screen, ID2P(LANG_FM_RADIO), | ||
67 | (menu_function)radio_screen, dynamicitem_callback); | ||
68 | #endif | ||
69 | |||
70 | #include "settings_menu.h" | ||
71 | MENUITEM_FUNCTION(manage_settings_menu_item, ID2P(LANG_MANAGE_MENU), | ||
72 | (menu_function)manage_settings_menu, NULL); | ||
73 | bool info_menu(void); /* from apps/main_menu.c TEMP*/ | ||
74 | MENUITEM_FUNCTION(info_menu_item, ID2P(LANG_INFO), | ||
75 | (menu_function)info_menu, NULL); | ||
76 | MENUITEM_FUNCTION(mrb_bookmarks, ID2P(LANG_BOOKMARK_MENU_RECENT_BOOKMARKS), | ||
77 | (menu_function)bookmark_mrb_load, NULL); | ||
78 | |||
79 | #ifdef HAVE_LCD_CHARCELLS | ||
80 | static int do_shutdown(void) | ||
81 | { | ||
82 | sys_poweroff(); | ||
83 | return 0; | ||
84 | } | ||
85 | MENUITEM_FUNCTION(do_shutdown_item, ID2P(LANG_SHUTDOWN), do_shutdown, NULL); | ||
86 | #endif | ||
87 | |||
88 | /* NOTE: This title will be translatable once we decide what to call this menu | ||
89 | when the root menu comes in... hopefully in the next few days */ | ||
90 | MAKE_MENU(main_menu_, "ROCKbox Main Menu", NULL, | ||
91 | &mrb_bookmarks, &sound_settings, | ||
92 | &settings_menu_item, &manage_settings_menu_item, &browse_themes, | ||
93 | #ifdef CONFIG_TUNER | ||
94 | &load_radio_screen, | ||
95 | #endif | ||
96 | #ifdef HAVE_RECORDING | ||
97 | &recording_settings_menu, | ||
98 | #endif | ||
99 | &playlist_menu_item, &browse_plugins, &info_menu_item | ||
100 | #ifdef HAVE_LCD_CHARCELLS | ||
101 | ,&do_shutdown_item | ||
102 | #endif | ||
103 | ); | ||
104 | /* MAIN MENU */ | ||
105 | /***********************************/ | ||
106 | |||
107 | /* lazy coders can use this function if the needed | ||
108 | callback is just to say if the item is shown or not */ | ||
109 | int dynamicitem_callback(int action,const struct menu_item_ex *this_item) | ||
110 | { | ||
111 | if (action != ACTION_ENTER_MENUITEM) | ||
112 | return action; | ||
113 | |||
114 | #ifdef CONFIG_TUNER | ||
115 | if (this_item == &load_radio_screen) | ||
116 | { | ||
117 | if (radio_hardware_present() == 0) | ||
118 | return ACTION_EXIT_MENUITEM; | ||
119 | } | ||
120 | #else | ||
121 | (void)this_item; | ||
122 | #endif | ||
123 | |||
124 | return action; | ||
125 | } | ||