Index: apps/settings.h =================================================================== --- apps/settings.h (revision 16361) +++ apps/settings.h (working copy) @@ -725,6 +725,7 @@ int keyclick_repeats; /* keyclick on repeats */ #endif unsigned char playlist_catalog_dir[MAX_FILENAME+1]; + int sleep_timer; }; /** global variables **/ Index: apps/settings_list.c =================================================================== --- apps/settings_list.c (revision 16361) +++ apps/settings_list.c (working copy) @@ -199,7 +199,27 @@ #endif #endif /* HAVE_RECORDING */ +/* sleep Menu */ +static void sleep_timer_formatter(char* buffer, size_t buffer_size, int value, + const char* unit) +{ + int minutes, hours; + (void) unit; + + if (value > 0) { + hours = value / 60; + minutes = value - (hours * 60); + snprintf(buffer, buffer_size, "%d:%02d", hours, minutes); + } else { + snprintf(buffer, buffer_size, "%s", str(LANG_OFF)); + } +} +static void sleep_timer_cb(int minutes) +{ + set_sleep_timer(global_settings.sleep_timer * 60); +} + static void formatter_unit_0_is_off(char *buffer, size_t buffer_size, int val, const char *unit) { @@ -1189,6 +1209,9 @@ #endif /* CONFIG_CODEC == SWCODEC */ FILENAME_SETTING(0, playlist_catalog_dir, "playlist catalog directory", PLAYLIST_CATALOG_DEFAULT_DIR, NULL, NULL, MAX_FILENAME+1), + INT_SETTING(0, sleep_timer, LANG_SLEEP_TIMER, 0, "sleep timer", + UNIT_MIN, 300, 0, -5, sleep_timer_formatter, NULL, + &sleep_timer_cb), }; const int nb_settings = sizeof(settings)/sizeof(*settings); Index: apps/menus/main_menu.c =================================================================== --- apps/menus/main_menu.c (revision 16361) +++ apps/menus/main_menu.c (working copy) @@ -395,39 +395,8 @@ MENUITEM_FUNCTION(show_info_item, 0, ID2P(LANG_ROCKBOX_INFO), (menu_function)show_info, NULL, NULL, Icon_NOICON); - -/* sleep Menu */ -static void sleep_timer_formatter(char* buffer, size_t buffer_size, int value, - const char* unit) -{ - int minutes, hours; - - (void) unit; - - if (value) { - hours = value / 60; - minutes = value - (hours * 60); - snprintf(buffer, buffer_size, "%d:%02d", hours, minutes); - } else { - snprintf(buffer, buffer_size, "%s", str(LANG_OFF)); - } -} - -static void sleep_timer_set(int minutes) -{ - set_sleep_timer(minutes * 60); -} - -static int sleep_timer(void) -{ - int minutes = (get_sleep_timer() + 59) / 60; /* round up */ - return (int)set_int(str(LANG_SLEEP_TIMER), "", UNIT_MIN, &minutes, - &sleep_timer_set, -5, 300, 0, sleep_timer_formatter); -} - -MENUITEM_FUNCTION(sleep_timer_call, 0, ID2P(LANG_SLEEP_TIMER), sleep_timer, - NULL, NULL, Icon_Menu_setting); /* make it look like a - setting to the user */ +MENUITEM_SETTING(sleep_timer_call, &global_settings.sleep_timer, NULL); + MENUITEM_FUNCTION(show_credits_item, 0, ID2P(LANG_VERSION), (menu_function)show_credits, NULL, NULL, Icon_NOICON); MENUITEM_FUNCTION(show_runtime_item, 0, ID2P(LANG_RUNNING_TIME), Index: apps/gui/option_select.c =================================================================== --- apps/gui/option_select.c (revision 16361) +++ apps/gui/option_select.c (working copy) @@ -511,7 +511,7 @@ return true; gui_syncstatusbar_draw(&statusbars, false); /* callback */ - if ( function ) + if ( function && action == ACTION_STD_OK ) function(*variable); }