summaryrefslogtreecommitdiff
path: root/apps
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
parent2376c4f825400fd0f8619cd746f3093c59ca7710 (diff)
downloadrockbox-29b1ba3445a8acaffe0fb11c267869eccda80883.zip
rockbox-29b1ba3445a8acaffe0fb11c267869eccda80883.tar.gz
rockbox-29b1ba3445a8acaffe0fb11c267869eccda80883.tar.bz2
rockbox-29b1ba3445a8acaffe0fb11c267869eccda80883.tar.xz
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')
-rw-r--r--apps/menus/main_menu.c2
-rw-r--r--apps/menus/time_menu.c2
-rw-r--r--apps/shortcuts.c54
-rw-r--r--apps/shortcuts.h1
4 files changed, 50 insertions, 9 deletions
diff --git a/apps/menus/main_menu.c b/apps/menus/main_menu.c
index b6ce9e7..130d0bc 100644
--- a/apps/menus/main_menu.c
+++ b/apps/menus/main_menu.c
@@ -376,7 +376,7 @@ MENUITEM_FUNCTION(show_info_item, 0, ID2P(LANG_ROCKBOX_INFO),
/* sleep Menu */
-static const char* sleep_timer_formatter(char* buffer, size_t buffer_size,
+const char* sleep_timer_formatter(char* buffer, size_t buffer_size,
int value, const char* unit)
{
(void) unit;
diff --git a/apps/menus/time_menu.c b/apps/menus/time_menu.c
index 9be335c..a793809 100644
--- a/apps/menus/time_menu.c
+++ b/apps/menus/time_menu.c
@@ -139,7 +139,7 @@ MENUITEM_FUNCTION(alarm_wake_up_screen, 0, ID2P(LANG_ALARM_WAKEUP_SCREEN),
MENUITEM_SETTING(sleeptimer_on_startup,
&global_settings.sleeptimer_on_startup, NULL);
-static void talk_timedate(void)
+void talk_timedate(void)
{
struct tm *tm = get_time();
if (!global_settings.talk_menu)
diff --git a/apps/shortcuts.c b/apps/shortcuts.c
index 10c090f..6997491 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;
diff --git a/apps/shortcuts.h b/apps/shortcuts.h
index c18834a..e5e0562 100644
--- a/apps/shortcuts.h
+++ b/apps/shortcuts.h
@@ -33,6 +33,7 @@ enum shortcut_type {
SHORTCUT_PLAYLISTMENU,
SHORTCUT_SEPARATOR,
SHORTCUT_SHUTDOWN,
+ SHORTCUT_TIME,
SHORTCUT_TYPE_COUNT
};