diff options
Diffstat (limited to 'apps/menus/main_menu.c')
-rw-r--r-- | apps/menus/main_menu.c | 101 |
1 files changed, 18 insertions, 83 deletions
diff --git a/apps/menus/main_menu.c b/apps/menus/main_menu.c index 77322c6ef4..41e25e30f5 100644 --- a/apps/menus/main_menu.c +++ b/apps/menus/main_menu.c | |||
@@ -147,10 +147,6 @@ enum infoscreenorder | |||
147 | INFO_ALBUMART, | 147 | INFO_ALBUMART, |
148 | #endif | 148 | #endif |
149 | INFO_VERSION, | 149 | INFO_VERSION, |
150 | #if CONFIG_RTC | ||
151 | INFO_DATE, | ||
152 | INFO_TIME, | ||
153 | #endif | ||
154 | INFO_COUNT | 150 | INFO_COUNT |
155 | }; | 151 | }; |
156 | 152 | ||
@@ -165,9 +161,6 @@ static char* info_getname(int selected_item, void *data, | |||
165 | char *buffer, size_t buffer_len) | 161 | char *buffer, size_t buffer_len) |
166 | { | 162 | { |
167 | struct info_data *info = (struct info_data*)data; | 163 | struct info_data *info = (struct info_data*)data; |
168 | #if CONFIG_RTC | ||
169 | struct tm *tm; | ||
170 | #endif | ||
171 | char s1[32]; | 164 | char s1[32]; |
172 | #ifdef HAVE_MULTIVOLUME | 165 | #ifdef HAVE_MULTIVOLUME |
173 | char s2[32]; | 166 | char s2[32]; |
@@ -189,39 +182,7 @@ static char* info_getname(int selected_item, void *data, | |||
189 | snprintf(buffer, buffer_len, "%s: %s", | 182 | snprintf(buffer, buffer_len, "%s: %s", |
190 | str(LANG_VERSION), appsversion); | 183 | str(LANG_VERSION), appsversion); |
191 | break; | 184 | break; |
192 | #if CONFIG_RTC | 185 | |
193 | case INFO_TIME: | ||
194 | tm = get_time(); | ||
195 | if (valid_time(tm)) | ||
196 | { | ||
197 | snprintf(buffer, buffer_len, "%02d:%02d:%02d %s", | ||
198 | global_settings.timeformat == 0 ? tm->tm_hour : | ||
199 | ((tm->tm_hour + 11) % 12) + 1, | ||
200 | tm->tm_min, | ||
201 | tm->tm_sec, | ||
202 | global_settings.timeformat == 0 ? "" : | ||
203 | tm->tm_hour>11 ? "P" : "A"); | ||
204 | } | ||
205 | else | ||
206 | { | ||
207 | strncpy(buffer, "--:--:--", buffer_len); | ||
208 | } | ||
209 | break; | ||
210 | case INFO_DATE: | ||
211 | tm = get_time(); | ||
212 | if (valid_time(tm)) | ||
213 | { | ||
214 | snprintf(buffer, buffer_len, "%s %d %d", | ||
215 | str(LANG_MONTH_JANUARY + tm->tm_mon), | ||
216 | tm->tm_mday, | ||
217 | tm->tm_year+1900); | ||
218 | } | ||
219 | else | ||
220 | { | ||
221 | strncpy(buffer, str(LANG_UNKNOWN), buffer_len); | ||
222 | } | ||
223 | break; | ||
224 | #endif | ||
225 | case INFO_BUFFER: /* buffer */ | 186 | case INFO_BUFFER: /* buffer */ |
226 | { | 187 | { |
227 | long kib = (audiobufend - audiobuf) / 1024; /* to KiB */ | 188 | long kib = (audiobufend - audiobuf) / 1024; /* to KiB */ |
@@ -305,41 +266,13 @@ static int info_speak_item(int selected_item, void * data) | |||
305 | { | 266 | { |
306 | struct info_data *info = (struct info_data*)data; | 267 | struct info_data *info = (struct info_data*)data; |
307 | 268 | ||
308 | #if CONFIG_RTC | ||
309 | struct tm *tm; | ||
310 | #endif | ||
311 | |||
312 | switch (selected_item) | 269 | switch (selected_item) |
313 | { | 270 | { |
314 | case INFO_VERSION: /* version */ | 271 | case INFO_VERSION: /* version */ |
315 | talk_id(LANG_VERSION, false); | 272 | talk_id(LANG_VERSION, false); |
316 | talk_spell(appsversion, true); | 273 | talk_spell(appsversion, true); |
317 | break; | 274 | break; |
318 | #if CONFIG_RTC | 275 | |
319 | case INFO_TIME: | ||
320 | tm = get_time(); | ||
321 | talk_id(VOICE_CURRENT_TIME, false); | ||
322 | if (valid_time(tm)) | ||
323 | { | ||
324 | talk_time(tm, true); | ||
325 | } | ||
326 | else | ||
327 | { | ||
328 | talk_id(LANG_UNKNOWN, true); | ||
329 | } | ||
330 | break; | ||
331 | case INFO_DATE: | ||
332 | tm = get_time(); | ||
333 | if (valid_time(tm)) | ||
334 | { | ||
335 | talk_date(get_time(), true); | ||
336 | } | ||
337 | else | ||
338 | { | ||
339 | talk_id(LANG_UNKNOWN, true); | ||
340 | } | ||
341 | break; | ||
342 | #endif | ||
343 | case INFO_BUFFER: /* buffer */ | 276 | case INFO_BUFFER: /* buffer */ |
344 | { | 277 | { |
345 | talk_id(LANG_BUFFER_STAT, false); | 278 | talk_id(LANG_BUFFER_STAT, false); |
@@ -447,18 +380,6 @@ static int info_action_callback(int action, struct gui_synclist *lists) | |||
447 | gui_synclist_speak_item(lists); | 380 | gui_synclist_speak_item(lists); |
448 | return ACTION_REDRAW; | 381 | return ACTION_REDRAW; |
449 | } | 382 | } |
450 | #if CONFIG_RTC | ||
451 | else if (action == ACTION_NONE) | ||
452 | { | ||
453 | static int last_redraw = 0; | ||
454 | if (gui_synclist_item_is_onscreen(lists, 0, INFO_TIME) | ||
455 | && TIME_AFTER(current_tick, last_redraw + HZ*5)) | ||
456 | { | ||
457 | last_redraw = current_tick; | ||
458 | return ACTION_REDRAW; | ||
459 | } | ||
460 | } | ||
461 | #endif | ||
462 | return action; | 383 | return action; |
463 | } | 384 | } |
464 | static bool show_info(void) | 385 | static bool show_info(void) |
@@ -501,16 +422,24 @@ static void sleep_timer_set(int minutes) | |||
501 | set_sleep_timer(minutes * 60); | 422 | set_sleep_timer(minutes * 60); |
502 | } | 423 | } |
503 | 424 | ||
504 | static int sleep_timer(void) | 425 | int sleep_timer(void) |
505 | { | 426 | { |
506 | int minutes = (get_sleep_timer() + 59) / 60; /* round up */ | 427 | int minutes = (get_sleep_timer() + 59) / 60; /* round up */ |
507 | return (int)set_int(str(LANG_SLEEP_TIMER), "", UNIT_MIN, &minutes, | 428 | return (int)set_int(str(LANG_SLEEP_TIMER), "", UNIT_MIN, &minutes, |
508 | &sleep_timer_set, -5, 300, 0, sleep_timer_formatter); | 429 | &sleep_timer_set, -5, 300, 0, sleep_timer_formatter); |
509 | } | 430 | } |
510 | 431 | ||
432 | |||
433 | #if CONFIG_RTC | ||
434 | int time_screen(void* ignored); | ||
435 | MENUITEM_FUNCTION(timedate_item, MENU_FUNC_CHECK_RETVAL, ID2P(LANG_TIME_MENU), time_screen, | ||
436 | NULL, NULL, Icon_Menu_setting ); | ||
437 | #endif | ||
438 | /* This item is in the time/date screen if there is a RTC */ | ||
511 | MENUITEM_FUNCTION(sleep_timer_call, 0, ID2P(LANG_SLEEP_TIMER), sleep_timer, | 439 | MENUITEM_FUNCTION(sleep_timer_call, 0, ID2P(LANG_SLEEP_TIMER), sleep_timer, |
512 | NULL, NULL, Icon_Menu_setting); /* make it look like a | 440 | NULL, NULL, Icon_Menu_setting); /* make it look like a |
513 | setting to the user */ | 441 | setting to the user */ |
442 | |||
514 | MENUITEM_FUNCTION(show_credits_item, 0, ID2P(LANG_VERSION), | 443 | MENUITEM_FUNCTION(show_credits_item, 0, ID2P(LANG_VERSION), |
515 | (menu_function)show_credits, NULL, NULL, Icon_NOICON); | 444 | (menu_function)show_credits, NULL, NULL, Icon_NOICON); |
516 | MENUITEM_FUNCTION(show_runtime_item, 0, ID2P(LANG_RUNNING_TIME), | 445 | MENUITEM_FUNCTION(show_runtime_item, 0, ID2P(LANG_RUNNING_TIME), |
@@ -519,8 +448,14 @@ MENUITEM_FUNCTION(debug_menu_item, 0, ID2P(LANG_DEBUG), | |||
519 | (menu_function)debug_menu, NULL, NULL, Icon_NOICON); | 448 | (menu_function)debug_menu, NULL, NULL, Icon_NOICON); |
520 | 449 | ||
521 | MAKE_MENU(info_menu, ID2P(LANG_SYSTEM), 0, Icon_Questionmark, | 450 | MAKE_MENU(info_menu, ID2P(LANG_SYSTEM), 0, Icon_Questionmark, |
451 | #if CONFIG_RTC | ||
452 | &timedate_item, | ||
453 | #endif | ||
522 | &show_info_item, &show_credits_item, &show_runtime_item, | 454 | &show_info_item, &show_credits_item, &show_runtime_item, |
523 | &sleep_timer_call, &debug_menu_item); | 455 | #if CONFIG_RTC == 0 |
456 | &sleep_timer_call, | ||
457 | #endif | ||
458 | &debug_menu_item); | ||
524 | /* INFO MENU */ | 459 | /* INFO MENU */ |
525 | /***********************************/ | 460 | /***********************************/ |
526 | 461 | ||