summaryrefslogtreecommitdiff
path: root/apps/shortcuts.c
diff options
context:
space:
mode:
authorJonathan Gordon <rockbox@jdgordon.info>2011-12-08 10:23:46 +0000
committerJonathan Gordon <rockbox@jdgordon.info>2011-12-08 10:23:46 +0000
commit29b1ba3445a8acaffe0fb11c267869eccda80883 (patch)
tree2cbf6f1e6de488d1eb753a358fd7ac05ecbf49db /apps/shortcuts.c
parent2376c4f825400fd0f8619cd746f3093c59ca7710 (diff)
shortcuts: talk the time and configure the sleep timeout
Use "type: time" and "data: talk" to have the time voiced when the shortcut is run. use "type: time" and "data: sleep X" where X is the number of minutes to run the sleep timer for (0 means disable) the name field is required git-svn-id: svn://svn.rockbox.org/rockbox/trunk@31178 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/shortcuts.c')
-rw-r--r--apps/shortcuts.c54
1 files changed, 47 insertions, 7 deletions
diff --git a/apps/shortcuts.c b/apps/shortcuts.c
index 10c090f3eb..6997491424 100644
--- a/apps/shortcuts.c
+++ b/apps/shortcuts.c
@@ -55,6 +55,7 @@ static const char * const type_strings[SHORTCUT_TYPE_COUNT] = {
[SHORTCUT_PLAYLISTMENU] = "playlist menu",
[SHORTCUT_SEPARATOR] = "separator",
[SHORTCUT_SHUTDOWN] = "shutdown",
+ [SHORTCUT_TIME] = "time",
};
struct shortcut {
@@ -64,6 +65,12 @@ struct shortcut {
union {
char path[MAX_PATH];
const struct settings_list *setting;
+ struct {
+#if CONFIG_RTC
+ bool talktime;
+#endif
+ int sleep_timeout;
+ } timedata;
} u;
};
#define SHORTCUTS_PER_HANDLE 32
@@ -135,11 +142,11 @@ static bool verify_shortcut(struct shortcut* sc)
case SHORTCUT_BROWSER:
case SHORTCUT_FILE:
case SHORTCUT_PLAYLISTMENU:
- if (sc->u.path[0] == '\0')
- return false;
- break;
+ return sc->u.path[0] != '0';
case SHORTCUT_SETTING:
return sc->u.setting != NULL;
+ case SHORTCUT_TIME:
+ return sc->name[0] != '0';
case SHORTCUT_DEBUGITEM:
case SHORTCUT_SEPARATOR:
case SHORTCUT_SHUTDOWN:
@@ -193,7 +200,7 @@ void shortcuts_ata_idle_callback(void* data)
*/
reset_shortcuts();
shortcuts_init();
- }
+ }
first_idx_to_writeback = -1;
}
@@ -212,7 +219,6 @@ void shortcuts_add(enum shortcut_type type, const char* value)
first_idx_to_writeback = shortcut_count - 1;
register_storage_idle_func(shortcuts_ata_idle_callback);
}
-
int readline_cb(int n, char *buf, void *parameters)
{
@@ -262,6 +268,20 @@ int readline_cb(int n, char *buf, void *parameters)
case SHORTCUT_SETTING:
sc->u.setting = find_setting_by_cfgname(value, NULL);
break;
+ case SHORTCUT_TIME:
+#if CONFIG_RTC
+ if (!strcasecmp(value, "talk"))
+ sc->u.timedata.talktime = true;
+ else
+#endif
+ if (!strncasecmp(value, "sleep ", strlen("sleep ")))
+ {
+ sc->u.timedata.talktime = false;
+ sc->u.timedata.sleep_timeout = atoi(&value[strlen("sleep ")]);
+ }
+ else
+ sc->type = SHORTCUT_UNDEFINED; /* error */
+ break;
case SHORTCUT_SEPARATOR:
case SHORTCUT_SHUTDOWN:
break;
@@ -314,7 +334,7 @@ static const char * shortcut_menu_get_name(int selected_item, void * data,
return "";
if (sc->type == SHORTCUT_SETTING)
return sc->name[0] ? sc->name : P2STR(ID2P(sc->u.setting->lang_id));
- else if (sc->type == SHORTCUT_SEPARATOR)
+ else if (sc->type == SHORTCUT_SEPARATOR || sc->type == SHORTCUT_TIME)
return sc->name;
else if (sc->type == SHORTCUT_SHUTDOWN && sc->name[0] == '\0')
{
@@ -354,6 +374,8 @@ static enum themable_icons shortcut_menu_get_icon(int selected_item, void * data
return Icon_Playlist;
case SHORTCUT_SHUTDOWN:
return Icon_System_menu;
+ case SHORTCUT_TIME:
+ return Icon_Menu_functioncall;
default:
break;
}
@@ -361,6 +383,10 @@ static enum themable_icons shortcut_menu_get_icon(int selected_item, void * data
return sc->icon;
}
+void talk_timedate(void);
+const char* sleep_timer_formatter(char* buffer, size_t buffer_size,
+ int value, const char* unit);
+
int do_shortcut_menu(void *ignored)
{
(void)ignored;
@@ -377,7 +403,7 @@ int do_shortcut_menu(void *ignored)
list.title_icon = Icon_Bookmark;
push_current_activity(ACTIVITY_SHORTCUTSMENU);
-
+
while (done == GO_TO_PREVIOUS)
{
if (simplelist_show_list(&list))
@@ -434,6 +460,20 @@ int do_shortcut_menu(void *ignored)
#endif
sys_poweroff();
break;
+ case SHORTCUT_TIME:
+#if CONFIG_RTC
+ if (sc->u.timedata.talktime)
+ talk_timedate();
+ else
+#endif
+ {
+ char timer_buf[10];
+ set_sleep_timer(sc->u.timedata.sleep_timeout * 60);
+ splashf(HZ, "%s (%s)", str(LANG_SLEEP_TIMER),
+ sleep_timer_formatter(timer_buf, sizeof(timer_buf),
+ sc->u.timedata.sleep_timeout, NULL));
+ }
+ break;
case SHORTCUT_UNDEFINED:
default:
break;