diff options
author | Jonathan Gordon <rockbox@jdgordon.info> | 2007-02-15 04:41:37 +0000 |
---|---|---|
committer | Jonathan Gordon <rockbox@jdgordon.info> | 2007-02-15 04:41:37 +0000 |
commit | e56f8e9f6322a74a013add1709cfea787d97967c (patch) | |
tree | 46389232eac2bdf464b25638261d449d58566113 | |
parent | 5a29fe18d4ca1c96a4d962a6494a7ff4c481b5ad (diff) | |
download | rockbox-e56f8e9f6322a74a013add1709cfea787d97967c.tar.gz rockbox-e56f8e9f6322a74a013add1709cfea787d97967c.zip |
Move the info and manage settings menus to the new system
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@12311 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r-- | apps/main_menu.c | 252 | ||||
-rw-r--r-- | apps/menus/main_menu.c | 352 | ||||
-rw-r--r-- | apps/settings_menu.c | 60 |
3 files changed, 341 insertions, 323 deletions
diff --git a/apps/main_menu.c b/apps/main_menu.c index 078e7669f2..de4c9a6263 100644 --- a/apps/main_menu.c +++ b/apps/main_menu.c | |||
@@ -56,231 +56,6 @@ | |||
56 | #include "recording.h" | 56 | #include "recording.h" |
57 | #endif | 57 | #endif |
58 | 58 | ||
59 | static bool show_credits(void) | ||
60 | { | ||
61 | plugin_load("/.rockbox/rocks/credits.rock",NULL); | ||
62 | return false; | ||
63 | } | ||
64 | |||
65 | #ifdef SIMULATOR | ||
66 | extern bool simulate_usb(void); | ||
67 | #endif | ||
68 | |||
69 | #ifdef HAVE_LCD_CHARCELLS | ||
70 | #define SIZE_FMT "%s%s" | ||
71 | #else | ||
72 | #define SIZE_FMT "%s %s" | ||
73 | #endif | ||
74 | |||
75 | static bool show_info(void) | ||
76 | { | ||
77 | char s[64], s1[32]; | ||
78 | unsigned long size, free; | ||
79 | long buflen = ((audiobufend - audiobuf) * 2) / 2097; /* avoid overflow */ | ||
80 | int key; | ||
81 | int i; | ||
82 | bool done = false; | ||
83 | bool new_info = true; | ||
84 | #ifdef HAVE_MULTIVOLUME | ||
85 | char s2[32]; | ||
86 | unsigned long size2, free2; | ||
87 | #endif | ||
88 | #ifdef HAVE_LCD_CHARCELLS | ||
89 | int page = 0; | ||
90 | #endif | ||
91 | |||
92 | const unsigned char *kbyte_units[] = { | ||
93 | ID2P(LANG_KILOBYTE), | ||
94 | ID2P(LANG_MEGABYTE), | ||
95 | ID2P(LANG_GIGABYTE) | ||
96 | }; | ||
97 | |||
98 | while (!done) | ||
99 | { | ||
100 | int y=0; | ||
101 | |||
102 | if (new_info) | ||
103 | { | ||
104 | fat_size( IF_MV2(0,) &size, &free ); | ||
105 | #ifdef HAVE_MULTIVOLUME | ||
106 | if (fat_ismounted(1)) | ||
107 | fat_size( 1, &size2, &free2 ); | ||
108 | else | ||
109 | size2 = 0; | ||
110 | #endif | ||
111 | |||
112 | if (global_settings.talk_menu) | ||
113 | { /* say whatever is reasonable, no real connection to the screen */ | ||
114 | bool enqueue = false; /* enqueue all but the first */ | ||
115 | if (battery_level() >= 0) | ||
116 | { | ||
117 | talk_id(LANG_BATTERY_TIME, enqueue); | ||
118 | enqueue = true; | ||
119 | talk_value(battery_level(), UNIT_PERCENT, true); | ||
120 | #if CONFIG_CHARGING >= CHARGING_MONITOR | ||
121 | if (charge_state == CHARGING) | ||
122 | talk_id(LANG_BATTERY_CHARGE, true); | ||
123 | else if (charge_state == TOPOFF) | ||
124 | talk_id(LANG_BATTERY_TOPOFF_CHARGE, true); | ||
125 | else if (charge_state == TRICKLE) | ||
126 | talk_id(LANG_BATTERY_TRICKLE_CHARGE, true); | ||
127 | #endif | ||
128 | } | ||
129 | |||
130 | talk_id(LANG_DISK_FREE_INFO, enqueue); | ||
131 | #ifdef HAVE_MULTIVOLUME | ||
132 | talk_id(LANG_DISK_NAME_INTERNAL, true); | ||
133 | output_dyn_value(NULL, 0, free, kbyte_units, true); | ||
134 | if (size2) | ||
135 | { | ||
136 | talk_id(LANG_DISK_NAME_MMC, true); | ||
137 | output_dyn_value(NULL, 0, free2, kbyte_units, true); | ||
138 | } | ||
139 | #else | ||
140 | output_dyn_value(NULL, 0, free, kbyte_units, true); | ||
141 | #endif | ||
142 | |||
143 | #ifdef CONFIG_RTC | ||
144 | { | ||
145 | struct tm* tm = get_time(); | ||
146 | talk_id(VOICE_CURRENT_TIME, true); | ||
147 | talk_value(tm->tm_hour, UNIT_HOUR, true); | ||
148 | talk_value(tm->tm_min, UNIT_MIN, true); | ||
149 | talk_value(tm->tm_sec, UNIT_SEC, true); | ||
150 | talk_id(LANG_MONTH_JANUARY + tm->tm_mon, true); | ||
151 | talk_number(tm->tm_mday, true); | ||
152 | talk_number(1900 + tm->tm_year, true); | ||
153 | } | ||
154 | #endif | ||
155 | } | ||
156 | new_info = false; | ||
157 | } | ||
158 | |||
159 | FOR_NB_SCREENS(i) | ||
160 | { | ||
161 | screens[i].clear_display(); | ||
162 | #ifdef HAVE_LCD_BITMAP | ||
163 | screens[i].puts(0, y, str(LANG_ROCKBOX_INFO)); | ||
164 | #endif | ||
165 | } | ||
166 | #ifdef HAVE_LCD_BITMAP | ||
167 | y += 2; | ||
168 | #endif | ||
169 | |||
170 | #ifdef HAVE_LCD_CHARCELLS | ||
171 | if (page == 0) | ||
172 | #endif | ||
173 | { | ||
174 | int integer = buflen / 1000; | ||
175 | int decimal = buflen % 1000; | ||
176 | |||
177 | #ifdef HAVE_LCD_CHARCELLS | ||
178 | snprintf(s, sizeof(s), (char *)str(LANG_BUFFER_STAT_PLAYER), | ||
179 | integer, decimal); | ||
180 | #else | ||
181 | snprintf(s, sizeof(s), (char *)str(LANG_BUFFER_STAT_RECORDER), | ||
182 | integer, decimal); | ||
183 | #endif | ||
184 | FOR_NB_SCREENS(i) | ||
185 | screens[i].puts_scroll(0, y, (unsigned char *)s); | ||
186 | y++; | ||
187 | #if CONFIG_CHARGING == CHARGING_CONTROL | ||
188 | if (charge_state == CHARGING) | ||
189 | snprintf(s, sizeof(s), (char *)str(LANG_BATTERY_CHARGE)); | ||
190 | else if (charge_state == TOPOFF) | ||
191 | snprintf(s, sizeof(s), (char *)str(LANG_BATTERY_TOPOFF_CHARGE)); | ||
192 | else if (charge_state == TRICKLE) | ||
193 | snprintf(s, sizeof(s), (char *)str(LANG_BATTERY_TRICKLE_CHARGE)); | ||
194 | else | ||
195 | #endif | ||
196 | if (battery_level() >= 0) | ||
197 | snprintf(s, sizeof(s), (char *)str(LANG_BATTERY_TIME), battery_level(), | ||
198 | battery_time() / 60, battery_time() % 60); | ||
199 | else | ||
200 | strncpy(s, "(n/a)", sizeof(s)); | ||
201 | FOR_NB_SCREENS(i) | ||
202 | screens[i].puts_scroll(0, y, (unsigned char *)s); | ||
203 | y++; | ||
204 | } | ||
205 | |||
206 | #ifdef HAVE_LCD_CHARCELLS | ||
207 | if (page == 1) | ||
208 | #endif | ||
209 | { | ||
210 | #ifdef HAVE_MULTIVOLUME | ||
211 | output_dyn_value(s1, sizeof s1, free, kbyte_units, true); | ||
212 | output_dyn_value(s2, sizeof s2, size, kbyte_units, true); | ||
213 | snprintf(s, sizeof s, "%s %s/%s", str(LANG_DISK_NAME_INTERNAL), | ||
214 | s1, s2); | ||
215 | FOR_NB_SCREENS(i) | ||
216 | screens[i].puts_scroll(0, y, (unsigned char *)s); | ||
217 | y++; | ||
218 | |||
219 | if (size2) { | ||
220 | output_dyn_value(s1, sizeof s1, free2, kbyte_units, true); | ||
221 | output_dyn_value(s2, sizeof s2, size2, kbyte_units, true); | ||
222 | snprintf(s, sizeof s, "%s %s/%s", str(LANG_DISK_NAME_MMC), | ||
223 | s1, s2); | ||
224 | FOR_NB_SCREENS(i) | ||
225 | screens[i].puts_scroll(0, y, (unsigned char *)s); | ||
226 | y++; | ||
227 | } | ||
228 | #else | ||
229 | output_dyn_value(s1, sizeof s1, size, kbyte_units, true); | ||
230 | snprintf(s, sizeof s, SIZE_FMT, str(LANG_DISK_SIZE_INFO), s1); | ||
231 | FOR_NB_SCREENS(i) | ||
232 | screens[i].puts_scroll(0, y, (unsigned char *)s); | ||
233 | y++; | ||
234 | output_dyn_value(s1, sizeof s1, free, kbyte_units, true); | ||
235 | snprintf(s, sizeof s, SIZE_FMT, str(LANG_DISK_FREE_INFO), s1); | ||
236 | FOR_NB_SCREENS(i) | ||
237 | screens[i].puts_scroll(0, y, (unsigned char *)s); | ||
238 | y++; | ||
239 | #endif | ||
240 | } | ||
241 | |||
242 | #if defined(HAVE_LCD_BITMAP) || defined(SIMULATOR) | ||
243 | FOR_NB_SCREENS(i) | ||
244 | screens[i].update(); | ||
245 | #endif | ||
246 | |||
247 | /* Wait for a key to be pushed */ | ||
248 | key = get_action(CONTEXT_MAINMENU,HZ*5); | ||
249 | switch(key) { | ||
250 | |||
251 | case ACTION_STD_CANCEL: | ||
252 | done = true; | ||
253 | break; | ||
254 | |||
255 | #ifdef HAVE_LCD_CHARCELLS | ||
256 | case ACTION_STD_NEXT: | ||
257 | case ACTION_STD_PREV: | ||
258 | page = (page == 0) ? 1 : 0; | ||
259 | break; | ||
260 | #endif | ||
261 | |||
262 | #ifndef SIMULATOR | ||
263 | case ACTION_STD_OK: | ||
264 | gui_syncsplash(0, true, str(LANG_DIRCACHE_BUILDING)); | ||
265 | fat_recalc_free(IF_MV(0)); | ||
266 | #ifdef HAVE_MULTIVOLUME | ||
267 | if (fat_ismounted(1)) | ||
268 | fat_recalc_free(1); | ||
269 | #endif | ||
270 | new_info = true; | ||
271 | break; | ||
272 | #endif | ||
273 | |||
274 | default: | ||
275 | if (default_event_handler(key) == SYS_USB_CONNECTED) | ||
276 | return true; | ||
277 | break; | ||
278 | } | ||
279 | } | ||
280 | action_signalscreenchange(); | ||
281 | return false; | ||
282 | } | ||
283 | |||
284 | #ifdef HAVE_RECORDING | 59 | #ifdef HAVE_RECORDING |
285 | 60 | ||
286 | static bool rec_menu_recording_screen(void) | 61 | static bool rec_menu_recording_screen(void) |
@@ -330,33 +105,6 @@ bool rec_menu(void) | |||
330 | } | 105 | } |
331 | #endif | 106 | #endif |
332 | 107 | ||
333 | bool info_menu(void) | ||
334 | { | ||
335 | int m; | ||
336 | bool result; | ||
337 | |||
338 | /* info menu */ | ||
339 | static const struct menu_item items[] = { | ||
340 | { ID2P(LANG_INFO_MENU), show_info }, | ||
341 | { ID2P(LANG_VERSION), show_credits }, | ||
342 | { ID2P(LANG_RUNNING_TIME), view_runtime }, | ||
343 | { ID2P(LANG_DEBUG), debug_menu }, | ||
344 | #ifdef SIMULATOR | ||
345 | { ID2P(LANG_USB), simulate_usb }, | ||
346 | #ifdef ROCKBOX_HAS_LOGF | ||
347 | {"logf", logfdisplay }, | ||
348 | {"logfdump", logfdump }, | ||
349 | #endif | ||
350 | #endif | ||
351 | }; | ||
352 | |||
353 | m=menu_init( items, sizeof(items) / sizeof(*items), NULL, | ||
354 | NULL, NULL, NULL); | ||
355 | result = menu_run(m); | ||
356 | menu_exit(m); | ||
357 | |||
358 | return result; | ||
359 | } | ||
360 | 108 | ||
361 | #if 0 | 109 | #if 0 |
362 | #ifdef HAVE_LCD_CHARCELLS | 110 | #ifdef HAVE_LCD_CHARCELLS |
diff --git a/apps/menus/main_menu.c b/apps/menus/main_menu.c index 886711853b..7dba697184 100644 --- a/apps/menus/main_menu.c +++ b/apps/menus/main_menu.c | |||
@@ -22,6 +22,7 @@ | |||
22 | #include <stddef.h> | 22 | #include <stddef.h> |
23 | #include <limits.h> | 23 | #include <limits.h> |
24 | #include "config.h" | 24 | #include "config.h" |
25 | #include "string.h" | ||
25 | #include "lang.h" | 26 | #include "lang.h" |
26 | #include "action.h" | 27 | #include "action.h" |
27 | #include "settings.h" | 28 | #include "settings.h" |
@@ -37,13 +38,17 @@ | |||
37 | #include "recording.h" | 38 | #include "recording.h" |
38 | #endif | 39 | #endif |
39 | #include "bookmark.h" | 40 | #include "bookmark.h" |
41 | #include "yesno.h" | ||
42 | #include "keyboard.h" | ||
43 | #include "screens.h" | ||
44 | #include "plugin.h" | ||
45 | #include "talk.h" | ||
46 | #include "buffer.h" | ||
40 | 47 | ||
41 | /* lazy coders can use this function if the needed callback | 48 | /* lazy coders can use this function if the needed callback |
42 | is just to say if the item is shown or not */ | 49 | is just to say if the item is shown or not */ |
43 | int dynamicitem_callback(int action,const struct menu_item_ex *this_item); | 50 | int dynamicitem_callback(int action,const struct menu_item_ex *this_item); |
44 | 51 | ||
45 | /***********************************/ | ||
46 | /* MAIN MENU */ | ||
47 | 52 | ||
48 | struct browse_folder_info { | 53 | struct browse_folder_info { |
49 | const char* dir; | 54 | const char* dir; |
@@ -51,12 +56,324 @@ struct browse_folder_info { | |||
51 | }; | 56 | }; |
52 | static struct browse_folder_info theme = {THEME_DIR, SHOW_CFG}; | 57 | static struct browse_folder_info theme = {THEME_DIR, SHOW_CFG}; |
53 | static struct browse_folder_info rocks = {PLUGIN_DIR, SHOW_PLUGINS}; | 58 | static struct browse_folder_info rocks = {PLUGIN_DIR, SHOW_PLUGINS}; |
59 | static struct browse_folder_info config = {ROCKBOX_DIR, SHOW_CFG}; | ||
54 | static int browse_folder(void *param) | 60 | static int browse_folder(void *param) |
55 | { | 61 | { |
56 | const struct browse_folder_info *info = | 62 | const struct browse_folder_info *info = |
57 | (const struct browse_folder_info*)param; | 63 | (const struct browse_folder_info*)param; |
58 | return rockbox_browse(info->dir, info->show_options); | 64 | return rockbox_browse(info->dir, info->show_options); |
59 | } | 65 | } |
66 | |||
67 | /***********************************/ | ||
68 | /* MANAGE SETTINGS MENU */ | ||
69 | |||
70 | static int reset_settings(void) | ||
71 | { | ||
72 | unsigned char *lines[]={str(LANG_RESET_ASK_RECORDER)}; | ||
73 | unsigned char *yes_lines[]={ | ||
74 | str(LANG_RESET_DONE_SETTING), | ||
75 | str(LANG_RESET_DONE_CLEAR) | ||
76 | }; | ||
77 | unsigned char *no_lines[]={yes_lines[0], str(LANG_RESET_DONE_CANCEL)}; | ||
78 | struct text_message message={(char **)lines, 1}; | ||
79 | struct text_message yes_message={(char **)yes_lines, 2}; | ||
80 | struct text_message no_message={(char **)no_lines, 2}; | ||
81 | |||
82 | switch(gui_syncyesno_run(&message, &yes_message, &no_message)) | ||
83 | { | ||
84 | case YESNO_YES: | ||
85 | settings_reset(); | ||
86 | settings_apply(); | ||
87 | break; | ||
88 | case YESNO_NO: | ||
89 | break; | ||
90 | case YESNO_USB: | ||
91 | return 1; | ||
92 | } | ||
93 | return 0; | ||
94 | } | ||
95 | static int write_settings_file(void* param) | ||
96 | { | ||
97 | return settings_save_config((int)param); | ||
98 | } | ||
99 | |||
100 | MENUITEM_FUNCTION_WPARAM(browse_configs, ID2P(LANG_CUSTOM_CFG), | ||
101 | browse_folder, (void*)&config, NULL, NOICON); | ||
102 | MENUITEM_FUNCTION_WPARAM(save_settings_item, ID2P(LANG_SAVE_SETTINGS), | ||
103 | write_settings_file, (void*)SETTINGS_SAVE_ALL, NULL, NOICON); | ||
104 | MENUITEM_FUNCTION_WPARAM(save_theme_item, ID2P(LANG_SAVE_THEME), | ||
105 | write_settings_file, (void*)SETTINGS_SAVE_THEME, NULL, NOICON); | ||
106 | MENUITEM_FUNCTION(reset_settings_item,ID2P(LANG_RESET),reset_settings, NULL, NOICON); | ||
107 | |||
108 | MAKE_MENU(manage_settings, ID2P(LANG_MANAGE_MENU), NULL, bitmap_icons_6x8[Icon_Config], | ||
109 | &browse_configs, &reset_settings_item, | ||
110 | &save_settings_item, &save_theme_item); | ||
111 | /* MANAGE SETTINGS MENU */ | ||
112 | /**********************************/ | ||
113 | |||
114 | /***********************************/ | ||
115 | /* INFO MENU */ | ||
116 | |||
117 | static bool show_credits(void) | ||
118 | { | ||
119 | plugin_load(PLUGIN_DIR "/credits.rock",NULL); | ||
120 | return false; | ||
121 | } | ||
122 | |||
123 | #ifdef SIMULATOR | ||
124 | extern bool simulate_usb(void); | ||
125 | #endif | ||
126 | |||
127 | #ifdef HAVE_LCD_CHARCELLS | ||
128 | #define SIZE_FMT "%s%s" | ||
129 | #else | ||
130 | #define SIZE_FMT "%s %s" | ||
131 | #endif | ||
132 | |||
133 | static bool show_info(void) | ||
134 | { | ||
135 | char s[64], s1[32]; | ||
136 | unsigned long size, free; | ||
137 | long buflen = ((audiobufend - audiobuf) * 2) / 2097; /* avoid overflow */ | ||
138 | int key; | ||
139 | int i; | ||
140 | bool done = false; | ||
141 | bool new_info = true; | ||
142 | #ifdef HAVE_MULTIVOLUME | ||
143 | char s2[32]; | ||
144 | unsigned long size2, free2; | ||
145 | #endif | ||
146 | #ifdef HAVE_LCD_CHARCELLS | ||
147 | int page = 0; | ||
148 | #endif | ||
149 | |||
150 | const unsigned char *kbyte_units[] = { | ||
151 | ID2P(LANG_KILOBYTE), | ||
152 | ID2P(LANG_MEGABYTE), | ||
153 | ID2P(LANG_GIGABYTE) | ||
154 | }; | ||
155 | |||
156 | while (!done) | ||
157 | { | ||
158 | int y=0; | ||
159 | |||
160 | if (new_info) | ||
161 | { | ||
162 | fat_size( IF_MV2(0,) &size, &free ); | ||
163 | #ifdef HAVE_MULTIVOLUME | ||
164 | if (fat_ismounted(1)) | ||
165 | fat_size( 1, &size2, &free2 ); | ||
166 | else | ||
167 | size2 = 0; | ||
168 | #endif | ||
169 | |||
170 | if (global_settings.talk_menu) | ||
171 | { /* say whatever is reasonable, no real connection to the screen */ | ||
172 | bool enqueue = false; /* enqueue all but the first */ | ||
173 | if (battery_level() >= 0) | ||
174 | { | ||
175 | talk_id(LANG_BATTERY_TIME, enqueue); | ||
176 | enqueue = true; | ||
177 | talk_value(battery_level(), UNIT_PERCENT, true); | ||
178 | #if CONFIG_CHARGING >= CHARGING_MONITOR | ||
179 | if (charge_state == CHARGING) | ||
180 | talk_id(LANG_BATTERY_CHARGE, true); | ||
181 | else if (charge_state == TOPOFF) | ||
182 | talk_id(LANG_BATTERY_TOPOFF_CHARGE, true); | ||
183 | else if (charge_state == TRICKLE) | ||
184 | talk_id(LANG_BATTERY_TRICKLE_CHARGE, true); | ||
185 | #endif | ||
186 | } | ||
187 | |||
188 | talk_id(LANG_DISK_FREE_INFO, enqueue); | ||
189 | #ifdef HAVE_MULTIVOLUME | ||
190 | talk_id(LANG_DISK_NAME_INTERNAL, true); | ||
191 | output_dyn_value(NULL, 0, free, kbyte_units, true); | ||
192 | if (size2) | ||
193 | { | ||
194 | talk_id(LANG_DISK_NAME_MMC, true); | ||
195 | output_dyn_value(NULL, 0, free2, kbyte_units, true); | ||
196 | } | ||
197 | #else | ||
198 | output_dyn_value(NULL, 0, free, kbyte_units, true); | ||
199 | #endif | ||
200 | |||
201 | #ifdef CONFIG_RTC | ||
202 | { | ||
203 | struct tm* tm = get_time(); | ||
204 | talk_id(VOICE_CURRENT_TIME, true); | ||
205 | talk_value(tm->tm_hour, UNIT_HOUR, true); | ||
206 | talk_value(tm->tm_min, UNIT_MIN, true); | ||
207 | talk_value(tm->tm_sec, UNIT_SEC, true); | ||
208 | talk_id(LANG_MONTH_JANUARY + tm->tm_mon, true); | ||
209 | talk_number(tm->tm_mday, true); | ||
210 | talk_number(1900 + tm->tm_year, true); | ||
211 | } | ||
212 | #endif | ||
213 | } | ||
214 | new_info = false; | ||
215 | } | ||
216 | |||
217 | FOR_NB_SCREENS(i) | ||
218 | { | ||
219 | screens[i].clear_display(); | ||
220 | #ifdef HAVE_LCD_BITMAP | ||
221 | screens[i].puts(0, y, str(LANG_ROCKBOX_INFO)); | ||
222 | #endif | ||
223 | } | ||
224 | #ifdef HAVE_LCD_BITMAP | ||
225 | y += 2; | ||
226 | #endif | ||
227 | |||
228 | #ifdef HAVE_LCD_CHARCELLS | ||
229 | if (page == 0) | ||
230 | #endif | ||
231 | { | ||
232 | int integer = buflen / 1000; | ||
233 | int decimal = buflen % 1000; | ||
234 | |||
235 | #ifdef HAVE_LCD_CHARCELLS | ||
236 | snprintf(s, sizeof(s), (char *)str(LANG_BUFFER_STAT_PLAYER), | ||
237 | integer, decimal); | ||
238 | #else | ||
239 | snprintf(s, sizeof(s), (char *)str(LANG_BUFFER_STAT_RECORDER), | ||
240 | integer, decimal); | ||
241 | #endif | ||
242 | FOR_NB_SCREENS(i) | ||
243 | screens[i].puts_scroll(0, y, (unsigned char *)s); | ||
244 | y++; | ||
245 | #if CONFIG_CHARGING == CHARGING_CONTROL | ||
246 | if (charge_state == CHARGING) | ||
247 | snprintf(s, sizeof(s), (char *)str(LANG_BATTERY_CHARGE)); | ||
248 | else if (charge_state == TOPOFF) | ||
249 | snprintf(s, sizeof(s), (char *)str(LANG_BATTERY_TOPOFF_CHARGE)); | ||
250 | else if (charge_state == TRICKLE) | ||
251 | snprintf(s, sizeof(s), (char *)str(LANG_BATTERY_TRICKLE_CHARGE)); | ||
252 | else | ||
253 | #endif | ||
254 | if (battery_level() >= 0) | ||
255 | snprintf(s, sizeof(s), (char *)str(LANG_BATTERY_TIME), battery_level(), | ||
256 | battery_time() / 60, battery_time() % 60); | ||
257 | else | ||
258 | strncpy(s, "(n/a)", sizeof(s)); | ||
259 | FOR_NB_SCREENS(i) | ||
260 | screens[i].puts_scroll(0, y, (unsigned char *)s); | ||
261 | y++; | ||
262 | } | ||
263 | |||
264 | #ifdef HAVE_LCD_CHARCELLS | ||
265 | if (page == 1) | ||
266 | #endif | ||
267 | { | ||
268 | #ifdef HAVE_MULTIVOLUME | ||
269 | output_dyn_value(s1, sizeof s1, free, kbyte_units, true); | ||
270 | output_dyn_value(s2, sizeof s2, size, kbyte_units, true); | ||
271 | snprintf(s, sizeof s, "%s %s/%s", str(LANG_DISK_NAME_INTERNAL), | ||
272 | s1, s2); | ||
273 | FOR_NB_SCREENS(i) | ||
274 | screens[i].puts_scroll(0, y, (unsigned char *)s); | ||
275 | y++; | ||
276 | |||
277 | if (size2) { | ||
278 | output_dyn_value(s1, sizeof s1, free2, kbyte_units, true); | ||
279 | output_dyn_value(s2, sizeof s2, size2, kbyte_units, true); | ||
280 | snprintf(s, sizeof s, "%s %s/%s", str(LANG_DISK_NAME_MMC), | ||
281 | s1, s2); | ||
282 | FOR_NB_SCREENS(i) | ||
283 | screens[i].puts_scroll(0, y, (unsigned char *)s); | ||
284 | y++; | ||
285 | } | ||
286 | #else | ||
287 | output_dyn_value(s1, sizeof s1, size, kbyte_units, true); | ||
288 | snprintf(s, sizeof s, SIZE_FMT, str(LANG_DISK_SIZE_INFO), s1); | ||
289 | FOR_NB_SCREENS(i) | ||
290 | screens[i].puts_scroll(0, y, (unsigned char *)s); | ||
291 | y++; | ||
292 | output_dyn_value(s1, sizeof s1, free, kbyte_units, true); | ||
293 | snprintf(s, sizeof s, SIZE_FMT, str(LANG_DISK_FREE_INFO), s1); | ||
294 | FOR_NB_SCREENS(i) | ||
295 | screens[i].puts_scroll(0, y, (unsigned char *)s); | ||
296 | y++; | ||
297 | #endif | ||
298 | } | ||
299 | |||
300 | #if defined(HAVE_LCD_BITMAP) || defined(SIMULATOR) | ||
301 | FOR_NB_SCREENS(i) | ||
302 | screens[i].update(); | ||
303 | #endif | ||
304 | |||
305 | /* Wait for a key to be pushed */ | ||
306 | key = get_action(CONTEXT_MAINMENU,HZ*5); | ||
307 | switch(key) { | ||
308 | |||
309 | case ACTION_STD_CANCEL: | ||
310 | done = true; | ||
311 | break; | ||
312 | |||
313 | #ifdef HAVE_LCD_CHARCELLS | ||
314 | case ACTION_STD_NEXT: | ||
315 | case ACTION_STD_PREV: | ||
316 | page = (page == 0) ? 1 : 0; | ||
317 | break; | ||
318 | #endif | ||
319 | |||
320 | #ifndef SIMULATOR | ||
321 | case ACTION_STD_OK: | ||
322 | gui_syncsplash(0, true, str(LANG_DIRCACHE_BUILDING)); | ||
323 | fat_recalc_free(IF_MV(0)); | ||
324 | #ifdef HAVE_MULTIVOLUME | ||
325 | if (fat_ismounted(1)) | ||
326 | fat_recalc_free(1); | ||
327 | #endif | ||
328 | new_info = true; | ||
329 | break; | ||
330 | #endif | ||
331 | |||
332 | default: | ||
333 | if (default_event_handler(key) == SYS_USB_CONNECTED) | ||
334 | return true; | ||
335 | break; | ||
336 | } | ||
337 | } | ||
338 | action_signalscreenchange(); | ||
339 | return false; | ||
340 | } | ||
341 | MENUITEM_FUNCTION(show_info_item, ID2P(LANG_INFO_MENU), | ||
342 | (menu_function)show_info, NULL, NOICON); | ||
343 | MENUITEM_FUNCTION(show_credits_item, ID2P(LANG_VERSION), | ||
344 | (menu_function)show_credits, NULL, NOICON); | ||
345 | MENUITEM_FUNCTION(show_runtime_item, ID2P(LANG_RUNNING_TIME), | ||
346 | (menu_function)view_runtime, NULL, NOICON); | ||
347 | |||
348 | #ifndef SIMULATOR | ||
349 | MENUITEM_FUNCTION(debug_menu_item, ID2P(LANG_DEBUG), | ||
350 | (menu_function)debug_menu, NULL, NOICON); | ||
351 | #else | ||
352 | MENUITEM_FUNCTION(simulate_usb_item, ID2P(LANG_USB), | ||
353 | (menu_function)simulate_usb, NULL, NOICON); | ||
354 | #ifdef ROCKBOX_HAS_LOGF | ||
355 | MENUITEM_FUNCTION(logfdisplay_item, "logf",logfdisplay, NULL, NOICON); | ||
356 | MENUITEM_FUNCTION(logfdump_item, "logfdump",logfdump, NULL, NOICON); | ||
357 | #endif | ||
358 | #endif | ||
359 | |||
360 | MAKE_MENU(info_menu, ID2P(LANG_INFO), 0, bitmap_icons_6x8[Icon_Questionmark], | ||
361 | &show_info_item, &show_credits_item, &show_runtime_item, | ||
362 | #ifndef SIMULATOR | ||
363 | &debug_menu_item | ||
364 | #else | ||
365 | &simulate_usb_item | ||
366 | #ifdef ROCKBOX_HAS_LOGF | ||
367 | ,&logfdisplay_item, &logfdump_item | ||
368 | #endif | ||
369 | #endif | ||
370 | ); | ||
371 | /* INFO MENU */ | ||
372 | /***********************************/ | ||
373 | |||
374 | /***********************************/ | ||
375 | /* MAIN MENU */ | ||
376 | |||
60 | MENUITEM_FUNCTION_WPARAM(browse_themes, ID2P(LANG_CUSTOM_THEME), | 377 | MENUITEM_FUNCTION_WPARAM(browse_themes, ID2P(LANG_CUSTOM_THEME), |
61 | browse_folder, (void*)&theme, NULL, bitmap_icons_6x8[Icon_Folder]); | 378 | browse_folder, (void*)&theme, NULL, bitmap_icons_6x8[Icon_Folder]); |
62 | MENUITEM_FUNCTION_WPARAM(browse_plugins, ID2P(LANG_PLUGINS), | 379 | MENUITEM_FUNCTION_WPARAM(browse_plugins, ID2P(LANG_PLUGINS), |
@@ -68,12 +385,6 @@ MENUITEM_FUNCTION(load_radio_screen, ID2P(LANG_FM_RADIO), | |||
68 | bitmap_icons_6x8[Icon_Radio_screen]); | 385 | bitmap_icons_6x8[Icon_Radio_screen]); |
69 | #endif | 386 | #endif |
70 | 387 | ||
71 | #include "settings_menu.h" | ||
72 | MENUITEM_FUNCTION(manage_settings_menu_item, ID2P(LANG_MANAGE_MENU), | ||
73 | (menu_function)manage_settings_menu, NULL, bitmap_icons_6x8[Icon_Config]); | ||
74 | bool info_menu(void); /* from apps/main_menu.c TEMP*/ | ||
75 | MENUITEM_FUNCTION(info_menu_item, ID2P(LANG_INFO), | ||
76 | (menu_function)info_menu, NULL, bitmap_icons_6x8[Icon_Questionmark]); | ||
77 | MENUITEM_FUNCTION(mrb_bookmarks, ID2P(LANG_BOOKMARK_MENU_RECENT_BOOKMARKS), | 388 | MENUITEM_FUNCTION(mrb_bookmarks, ID2P(LANG_BOOKMARK_MENU_RECENT_BOOKMARKS), |
78 | (menu_function)bookmark_mrb_load, NULL, bitmap_icons_6x8[Icon_Bookmark]); | 389 | (menu_function)bookmark_mrb_load, NULL, bitmap_icons_6x8[Icon_Bookmark]); |
79 | 390 | ||
@@ -86,18 +397,37 @@ static int do_shutdown(void) | |||
86 | MENUITEM_FUNCTION(do_shutdown_item, ID2P(LANG_SHUTDOWN), do_shutdown, NULL, NOICON); | 397 | MENUITEM_FUNCTION(do_shutdown_item, ID2P(LANG_SHUTDOWN), do_shutdown, NULL, NOICON); |
87 | #endif | 398 | #endif |
88 | 399 | ||
400 | #ifdef HAVE_LCD_CHARCELLS | ||
401 | int mainmenu_callback(int action,const struct menu_item_ex *this_item) | ||
402 | { | ||
403 | (void)this_item; | ||
404 | switch (action) | ||
405 | { | ||
406 | case ACTION_ENTER_MENUITEM: | ||
407 | status_set_param(true); | ||
408 | break; | ||
409 | case ACTION_EXIT_MENUITEM: | ||
410 | status_set_param(false); | ||
411 | break; | ||
412 | } | ||
413 | return action; | ||
414 | } | ||
415 | #else | ||
416 | #define mainmenu_callback NULL | ||
417 | #endif | ||
89 | /* NOTE: This title will be translatable once we decide what to call this menu | 418 | /* NOTE: This title will be translatable once we decide what to call this menu |
90 | when the root menu comes in... hopefully in the next few days */ | 419 | when the root menu comes in... hopefully in the next few days */ |
91 | MAKE_MENU(main_menu_, "Rockbox Main Menu", NULL, bitmap_icons_6x8[Icon_Submenu_Entered], | 420 | MAKE_MENU(main_menu_, "Rockbox Main Menu", mainmenu_callback, |
421 | bitmap_icons_6x8[Icon_Submenu_Entered], | ||
92 | &mrb_bookmarks, &sound_settings, | 422 | &mrb_bookmarks, &sound_settings, |
93 | &settings_menu_item, &manage_settings_menu_item, &browse_themes, | 423 | &settings_menu_item, &manage_settings, &browse_themes, |
94 | #ifdef CONFIG_TUNER | 424 | #ifdef CONFIG_TUNER |
95 | &load_radio_screen, | 425 | &load_radio_screen, |
96 | #endif | 426 | #endif |
97 | #ifdef HAVE_RECORDING | 427 | #ifdef HAVE_RECORDING |
98 | &recording_settings_menu, | 428 | &recording_settings_menu, |
99 | #endif | 429 | #endif |
100 | &playlist_menu_item, &browse_plugins, &info_menu_item | 430 | &playlist_menu_item, &browse_plugins, &info_menu |
101 | #ifdef HAVE_LCD_CHARCELLS | 431 | #ifdef HAVE_LCD_CHARCELLS |
102 | ,&do_shutdown_item | 432 | ,&do_shutdown_item |
103 | #endif | 433 | #endif |
diff --git a/apps/settings_menu.c b/apps/settings_menu.c index 67a5abaa67..49788e6eed 100644 --- a/apps/settings_menu.c +++ b/apps/settings_menu.c | |||
@@ -827,11 +827,6 @@ static bool custom_remote_wps_browse(void) | |||
827 | } | 827 | } |
828 | #endif | 828 | #endif |
829 | 829 | ||
830 | static bool custom_cfg_browse(void) | ||
831 | { | ||
832 | return rockbox_browse(ROCKBOX_DIR, SHOW_CFG); | ||
833 | } | ||
834 | |||
835 | #ifdef HAVE_LCD_BITMAP | 830 | #ifdef HAVE_LCD_BITMAP |
836 | static bool font_browse(void) | 831 | static bool font_browse(void) |
837 | { | 832 | { |
@@ -878,33 +873,6 @@ static bool codepage_setting(void) | |||
878 | INT, names, 13, set_codepage ); | 873 | INT, names, 13, set_codepage ); |
879 | } | 874 | } |
880 | 875 | ||
881 | static bool reset_settings(void) | ||
882 | { | ||
883 | unsigned char *lines[]={str(LANG_RESET_ASK_RECORDER)}; | ||
884 | unsigned char *yes_lines[]={ | ||
885 | str(LANG_RESET_DONE_SETTING), | ||
886 | str(LANG_RESET_DONE_CLEAR) | ||
887 | }; | ||
888 | unsigned char *no_lines[]={yes_lines[0], str(LANG_RESET_DONE_CANCEL)}; | ||
889 | struct text_message message={(char **)lines, 1}; | ||
890 | struct text_message yes_message={(char **)yes_lines, 2}; | ||
891 | struct text_message no_message={(char **)no_lines, 2}; | ||
892 | |||
893 | switch(gui_syncyesno_run(&message, &yes_message, &no_message)) | ||
894 | { | ||
895 | case YESNO_YES: | ||
896 | settings_reset(); | ||
897 | settings_apply(); | ||
898 | settings_save(); | ||
899 | break; | ||
900 | case YESNO_NO: | ||
901 | break; | ||
902 | case YESNO_USB: | ||
903 | return true; | ||
904 | } | ||
905 | return false; | ||
906 | } | ||
907 | |||
908 | 876 | ||
909 | #ifdef HAVE_REMOTE_LCD | 877 | #ifdef HAVE_REMOTE_LCD |
910 | static bool remote_scroll_sets(void) | 878 | static bool remote_scroll_sets(void) |
@@ -1105,31 +1073,3 @@ bool display_settings_menu(void) | |||
1105 | menu_exit(m); | 1073 | menu_exit(m); |
1106 | return result; | 1074 | return result; |
1107 | } | 1075 | } |
1108 | static bool manage_settings_write_config(void) | ||
1109 | { | ||
1110 | return settings_save_config(SETTINGS_SAVE_ALL); | ||
1111 | } | ||
1112 | static bool manage_settings_write_theme(void) | ||
1113 | { | ||
1114 | return settings_save_config(SETTINGS_SAVE_THEME); | ||
1115 | } | ||
1116 | |||
1117 | bool manage_settings_menu(void) | ||
1118 | { | ||
1119 | int m; | ||
1120 | bool result; | ||
1121 | |||
1122 | static const struct menu_item items[] = { | ||
1123 | { ID2P(LANG_CUSTOM_CFG), custom_cfg_browse }, | ||
1124 | { ID2P(LANG_RESET), reset_settings }, | ||
1125 | { ID2P(LANG_SAVE_SETTINGS), manage_settings_write_config}, | ||
1126 | { ID2P(LANG_SAVE_THEME), manage_settings_write_theme}, | ||
1127 | }; | ||
1128 | |||
1129 | m=menu_init( items, sizeof(items) / sizeof(*items), NULL, | ||
1130 | NULL, NULL, NULL); | ||
1131 | result = menu_run(m); | ||
1132 | menu_exit(m); | ||
1133 | return result; | ||
1134 | } | ||
1135 | |||