diff options
Diffstat (limited to 'apps/shortcuts.c')
-rw-r--r-- | apps/shortcuts.c | 164 |
1 files changed, 77 insertions, 87 deletions
diff --git a/apps/shortcuts.c b/apps/shortcuts.c index a32c298f6d..a7fbe7ccec 100644 --- a/apps/shortcuts.c +++ b/apps/shortcuts.c | |||
@@ -421,8 +421,6 @@ void shortcuts_init(void) | |||
421 | --buflib_move_lock; | 421 | --buflib_move_lock; |
422 | } | 422 | } |
423 | 423 | ||
424 | char* sleep_timer_getname(int selected_item, void * data, | ||
425 | char *buffer, size_t buffer_len); /* settings_menu.c */ | ||
426 | static const char * shortcut_menu_get_name(int selected_item, void * data, | 424 | static const char * shortcut_menu_get_name(int selected_item, void * data, |
427 | char * buffer, size_t buffer_len) | 425 | char * buffer, size_t buffer_len) |
428 | { | 426 | { |
@@ -440,11 +438,9 @@ static const char * shortcut_menu_get_name(int selected_item, void * data, | |||
440 | #if CONFIG_RTC | 438 | #if CONFIG_RTC |
441 | && !sc->u.timedata.talktime | 439 | && !sc->u.timedata.talktime |
442 | #endif | 440 | #endif |
443 | ) /* Toggle Sleep Timer */ | 441 | ) /* String representation for toggling sleep timer */ |
444 | { | 442 | return string_sleeptimer(buffer, buffer_len); |
445 | sleep_timer_getname(selected_item, data, buffer, buffer_len); | 443 | |
446 | return buffer; | ||
447 | } | ||
448 | return sc->name; | 444 | return sc->name; |
449 | } | 445 | } |
450 | else if ((sc->type == SHORTCUT_SHUTDOWN || sc->type == SHORTCUT_REBOOT) && | 446 | else if ((sc->type == SHORTCUT_SHUTDOWN || sc->type == SHORTCUT_REBOOT) && |
@@ -466,81 +462,6 @@ static const char * shortcut_menu_get_name(int selected_item, void * data, | |||
466 | return sc->name[0] ? sc->name : sc->u.path; | 462 | return sc->name[0] ? sc->name : sc->u.path; |
467 | } | 463 | } |
468 | 464 | ||
469 | static int shortcut_menu_speak_item(int selected_item, void * data); | ||
470 | static int shortcut_menu_get_action(int action, struct gui_synclist *lists) | ||
471 | { | ||
472 | (void)lists; | ||
473 | if (action == ACTION_STD_OK || action == ACTION_STD_MENU) | ||
474 | return ACTION_STD_CANCEL; | ||
475 | else if (action == ACTION_STD_QUICKSCREEN && action != ACTION_STD_CONTEXT) | ||
476 | return ACTION_STD_CANCEL; | ||
477 | else if (action == ACTION_STD_CONTEXT) | ||
478 | { | ||
479 | int selection = gui_synclist_get_sel_pos(lists); | ||
480 | |||
481 | if (confirm_delete_yesno("") != YESNO_YES) | ||
482 | { | ||
483 | gui_synclist_set_title(lists, lists->title, lists->title_icon); | ||
484 | shortcut_menu_speak_item(selection, NULL); | ||
485 | return ACTION_REDRAW; | ||
486 | } | ||
487 | |||
488 | remove_shortcut(selection); | ||
489 | gui_synclist_set_nb_items(lists, shortcut_count); | ||
490 | gui_synclist_set_title(lists, lists->title, lists->title_icon); | ||
491 | if (selection >= shortcut_count) | ||
492 | gui_synclist_select_item(lists, shortcut_count - 1); | ||
493 | first_idx_to_writeback = 0; | ||
494 | overwrite_shortcuts = true; | ||
495 | shortcuts_ata_idle_callback(); | ||
496 | if (shortcut_count == 0) | ||
497 | return ACTION_STD_CANCEL; | ||
498 | |||
499 | shortcut_menu_speak_item(gui_synclist_get_sel_pos(lists), NULL); | ||
500 | return ACTION_REDRAW; | ||
501 | } | ||
502 | return action; | ||
503 | } | ||
504 | |||
505 | static enum themable_icons shortcut_menu_get_icon(int selected_item, void * data) | ||
506 | { | ||
507 | (void)data; | ||
508 | int icon; | ||
509 | struct shortcut *sc = get_shortcut(selected_item); | ||
510 | if (!sc) | ||
511 | return Icon_NOICON; | ||
512 | if (sc->icon == Icon_NOICON) | ||
513 | { | ||
514 | |||
515 | switch (sc->type) | ||
516 | { | ||
517 | case SHORTCUT_FILE: | ||
518 | return filetype_get_icon(filetype_get_attr(sc->u.path)); | ||
519 | case SHORTCUT_BROWSER: | ||
520 | icon = filetype_get_icon(filetype_get_attr(sc->u.path)); | ||
521 | if (icon <= 0) | ||
522 | icon = Icon_Folder; | ||
523 | return icon; | ||
524 | case SHORTCUT_SETTING: | ||
525 | return Icon_Menu_setting; | ||
526 | case SHORTCUT_DEBUGITEM: | ||
527 | return Icon_Menu_functioncall; | ||
528 | case SHORTCUT_PLAYLISTMENU: | ||
529 | return Icon_Playlist; | ||
530 | case SHORTCUT_SHUTDOWN: | ||
531 | case SHORTCUT_REBOOT: | ||
532 | return Icon_System_menu; | ||
533 | case SHORTCUT_TIME: | ||
534 | return Icon_Menu_functioncall; | ||
535 | default: | ||
536 | break; | ||
537 | } | ||
538 | } | ||
539 | return sc->icon; | ||
540 | } | ||
541 | |||
542 | void talk_timedate(void); | ||
543 | int sleep_timer_voice(int selected_item, void*data); /* settings_menu.c */ | ||
544 | static int shortcut_menu_speak_item(int selected_item, void * data) | 465 | static int shortcut_menu_speak_item(int selected_item, void * data) |
545 | { | 466 | { |
546 | (void)data; | 467 | (void)data; |
@@ -605,7 +526,7 @@ static int shortcut_menu_speak_item(int selected_item, void * data) | |||
605 | else | 526 | else |
606 | #endif | 527 | #endif |
607 | if (sc->u.timedata.sleep_timeout < 0) | 528 | if (sc->u.timedata.sleep_timeout < 0) |
608 | sleep_timer_voice(selected_item, data); | 529 | talk_sleeptimer(); |
609 | else if (sc->name[0]) | 530 | else if (sc->name[0]) |
610 | talk_spell(sc->name, false); | 531 | talk_spell(sc->name, false); |
611 | break; | 532 | break; |
@@ -626,9 +547,78 @@ static int shortcut_menu_speak_item(int selected_item, void * data) | |||
626 | return 0; | 547 | return 0; |
627 | } | 548 | } |
628 | 549 | ||
629 | const char* sleep_timer_formatter(char* buffer, size_t buffer_size, | 550 | static int shortcut_menu_get_action(int action, struct gui_synclist *lists) |
630 | int value, const char* unit); | 551 | { |
631 | int toggle_sleeptimer(void); /* settings_menu.c */ | 552 | (void)lists; |
553 | if (action == ACTION_STD_OK || action == ACTION_STD_MENU) | ||
554 | return ACTION_STD_CANCEL; | ||
555 | else if (action == ACTION_STD_QUICKSCREEN && action != ACTION_STD_CONTEXT) | ||
556 | return ACTION_STD_CANCEL; | ||
557 | else if (action == ACTION_STD_CONTEXT) | ||
558 | { | ||
559 | int selection = gui_synclist_get_sel_pos(lists); | ||
560 | |||
561 | if (confirm_delete_yesno("") != YESNO_YES) | ||
562 | { | ||
563 | gui_synclist_set_title(lists, lists->title, lists->title_icon); | ||
564 | shortcut_menu_speak_item(selection, NULL); | ||
565 | return ACTION_REDRAW; | ||
566 | } | ||
567 | |||
568 | remove_shortcut(selection); | ||
569 | gui_synclist_set_nb_items(lists, shortcut_count); | ||
570 | gui_synclist_set_title(lists, lists->title, lists->title_icon); | ||
571 | if (selection >= shortcut_count) | ||
572 | gui_synclist_select_item(lists, shortcut_count - 1); | ||
573 | first_idx_to_writeback = 0; | ||
574 | overwrite_shortcuts = true; | ||
575 | shortcuts_ata_idle_callback(); | ||
576 | if (shortcut_count == 0) | ||
577 | return ACTION_STD_CANCEL; | ||
578 | |||
579 | shortcut_menu_speak_item(gui_synclist_get_sel_pos(lists), NULL); | ||
580 | return ACTION_REDRAW; | ||
581 | } | ||
582 | return action; | ||
583 | } | ||
584 | |||
585 | static enum themable_icons shortcut_menu_get_icon(int selected_item, void * data) | ||
586 | { | ||
587 | (void)data; | ||
588 | int icon; | ||
589 | struct shortcut *sc = get_shortcut(selected_item); | ||
590 | if (!sc) | ||
591 | return Icon_NOICON; | ||
592 | if (sc->icon == Icon_NOICON) | ||
593 | { | ||
594 | |||
595 | switch (sc->type) | ||
596 | { | ||
597 | case SHORTCUT_FILE: | ||
598 | return filetype_get_icon(filetype_get_attr(sc->u.path)); | ||
599 | case SHORTCUT_BROWSER: | ||
600 | icon = filetype_get_icon(filetype_get_attr(sc->u.path)); | ||
601 | if (icon <= 0) | ||
602 | icon = Icon_Folder; | ||
603 | return icon; | ||
604 | case SHORTCUT_SETTING: | ||
605 | return Icon_Menu_setting; | ||
606 | case SHORTCUT_DEBUGITEM: | ||
607 | return Icon_Menu_functioncall; | ||
608 | case SHORTCUT_PLAYLISTMENU: | ||
609 | return Icon_Playlist; | ||
610 | case SHORTCUT_SHUTDOWN: | ||
611 | case SHORTCUT_REBOOT: | ||
612 | return Icon_System_menu; | ||
613 | case SHORTCUT_TIME: | ||
614 | return Icon_Menu_functioncall; | ||
615 | default: | ||
616 | break; | ||
617 | } | ||
618 | } | ||
619 | return sc->icon; | ||
620 | } | ||
621 | |||
632 | int do_shortcut_menu(void *ignored) | 622 | int do_shortcut_menu(void *ignored) |
633 | { | 623 | { |
634 | (void)ignored; | 624 | (void)ignored; |
@@ -761,7 +751,7 @@ int do_shortcut_menu(void *ignored) | |||
761 | { | 751 | { |
762 | set_sleeptimer_duration(sc->u.timedata.sleep_timeout); | 752 | set_sleeptimer_duration(sc->u.timedata.sleep_timeout); |
763 | splashf(HZ, "%s (%s)", str(LANG_SLEEP_TIMER), | 753 | splashf(HZ, "%s (%s)", str(LANG_SLEEP_TIMER), |
764 | sleep_timer_formatter(timer_buf, sizeof(timer_buf), | 754 | format_sleeptimer(timer_buf, sizeof(timer_buf), |
765 | sc->u.timedata.sleep_timeout, | 755 | sc->u.timedata.sleep_timeout, |
766 | NULL)); | 756 | NULL)); |
767 | } | 757 | } |