From b1403ee024f81ced657261441571ee5e8bab71ce Mon Sep 17 00:00:00 2001 From: Jörg Hohensohn Date: Fri, 23 Jul 2004 23:01:20 +0000 Subject: New way of defining menus and options allows to declare them static const, which saves the code to runtime-assemble them. Rockbox just got 6 KB smaller. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@4931 a1c6a512-1295-4272-9138-f99709370657 --- apps/settings_menu.c | 240 +++++++++++++++++++++++++-------------------------- 1 file changed, 120 insertions(+), 120 deletions(-) (limited to 'apps/settings_menu.c') diff --git a/apps/settings_menu.c b/apps/settings_menu.c index 057191e603..5da733c1df 100644 --- a/apps/settings_menu.c +++ b/apps/settings_menu.c @@ -136,7 +136,7 @@ static bool flip_display(void) */ static bool battery_type(void) { - struct opt_items names[] = { + static const struct opt_items names[] = { { STR(LANG_DISPLAY_GRAPHIC) }, { STR(LANG_DISPLAY_NUMERIC) } }; @@ -149,7 +149,7 @@ static bool battery_type(void) */ static bool volume_type(void) { - struct opt_items names[] = { + static const struct opt_items names[] = { { STR(LANG_DISPLAY_GRAPHIC) }, { STR(LANG_DISPLAY_NUMERIC) } }; @@ -172,7 +172,7 @@ static bool peak_meter_fps_menu(void) { */ static bool peak_meter_hold(void) { bool retval = false; - struct opt_items names[] = { + static const struct opt_items names[] = { { STR(LANG_OFF) }, { "200 ms " , TALK_ID(200, UNIT_MS) }, { "300 ms " , TALK_ID(300, UNIT_MS) }, @@ -209,7 +209,7 @@ static bool peak_meter_hold(void) { static bool peak_meter_clip_hold(void) { bool retval = false; - struct opt_items names[] = { + static const struct opt_items names[] = { { STR(LANG_PM_ETERNAL) }, { "1s " , TALK_ID(1, UNIT_SEC) }, { "2s " , TALK_ID(2, UNIT_SEC) }, @@ -409,17 +409,17 @@ static bool peak_meter_menu(void) int m; bool result; - struct menu_item items[] = { - { STR(LANG_PM_RELEASE) , peak_meter_release }, - { STR(LANG_PM_PEAK_HOLD), peak_meter_hold }, - { STR(LANG_PM_CLIP_HOLD), peak_meter_clip_hold }, - { STR(LANG_PM_PERFORMANCE), peak_meter_performance }, + static const struct menu_item items[] = { + { ID2P(LANG_PM_RELEASE) , peak_meter_release }, + { ID2P(LANG_PM_PEAK_HOLD), peak_meter_hold }, + { ID2P(LANG_PM_CLIP_HOLD), peak_meter_clip_hold }, + { ID2P(LANG_PM_PERFORMANCE), peak_meter_performance }, #ifdef PM_DEBUG { "Refresh rate" , -1 , peak_meter_fps_menu }, #endif - { STR(LANG_PM_SCALE) , peak_meter_scale }, - { STR(LANG_PM_MIN) , peak_meter_min }, - { STR(LANG_PM_MAX) , peak_meter_max }, + { ID2P(LANG_PM_SCALE) , peak_meter_scale }, + { ID2P(LANG_PM_MIN) , peak_meter_min }, + { ID2P(LANG_PM_MAX) , peak_meter_max }, }; m=menu_init( items, sizeof(items) / sizeof(*items), NULL, @@ -438,7 +438,7 @@ static bool shuffle(void) static bool repeat_mode(void) { bool result; - struct opt_items names[] = { + static const struct opt_items names[] = { { STR(LANG_OFF) }, { STR(LANG_REPEAT_ALL) }, { STR(LANG_REPEAT_ONE) } @@ -461,7 +461,7 @@ static bool play_selected(void) static bool dir_filter(void) { - struct opt_items names[] = { + static const struct opt_items names[] = { { STR(LANG_FILTER_ALL) }, { STR(LANG_FILTER_SUPPORTED) }, { STR(LANG_FILTER_MUSIC) }, @@ -480,7 +480,7 @@ static bool sort_file(void) { int oldval = global_settings.sort_file; bool ret; - struct opt_items names[] = { + static const struct opt_items names[] = { { STR(LANG_SORT_ALPHA) }, { STR(LANG_SORT_DATE) }, { STR(LANG_SORT_DATE_REVERSE) }, @@ -497,7 +497,7 @@ static bool sort_dir(void) { int oldval = global_settings.sort_dir; bool ret; - struct opt_items names[] = { + static const struct opt_items names[] = { { STR(LANG_SORT_ALPHA) }, { STR(LANG_SORT_DATE) }, { STR(LANG_SORT_DATE_REVERSE) } @@ -511,7 +511,7 @@ static bool sort_dir(void) static bool resume(void) { - struct opt_items names[] = { + static const struct opt_items names[] = { { STR(LANG_SET_BOOL_NO) }, { STR(LANG_RESUME_SETTING_ASK) }, { STR(LANG_RESUME_SETTING_ASK_ONCE) }, @@ -524,7 +524,7 @@ static bool resume(void) static bool autocreatebookmark(void) { bool retval = false; - struct opt_items names[] = { + static const struct opt_items names[] = { { STR(LANG_SET_BOOL_NO) }, { STR(LANG_SET_BOOL_YES) }, { STR(LANG_RESUME_SETTING_ASK) }, @@ -547,7 +547,7 @@ static bool autocreatebookmark(void) static bool autoloadbookmark(void) { - struct opt_items names[] = { + static const struct opt_items names[] = { { STR(LANG_SET_BOOL_NO) }, { STR(LANG_SET_BOOL_YES) }, { STR(LANG_RESUME_SETTING_ASK) } @@ -559,7 +559,7 @@ static bool autoloadbookmark(void) static bool useMRB(void) { - struct opt_items names[] = { + static const struct opt_items names[] = { { STR(LANG_SET_BOOL_NO) }, { STR(LANG_SET_BOOL_YES) }, { STR(LANG_BOOKMARK_SETTINGS_UNIQUE_ONLY) } @@ -578,7 +578,7 @@ static bool backlight_on_when_charging(void) static bool backlight_timer(void) { - struct opt_items names[] = { + static const struct opt_items names[] = { { STR(LANG_OFF) }, { STR(LANG_ON) }, { "1s ", TALK_ID(1, UNIT_SEC) }, @@ -605,7 +605,7 @@ static bool backlight_timer(void) static bool poweroff_idle_timer(void) { - struct opt_items names[] = { + static const struct opt_items names[] = { { STR(LANG_OFF) }, { "1m ", TALK_ID(1, UNIT_MIN) }, { "2m ", TALK_ID(2, UNIT_MIN) }, @@ -663,7 +663,7 @@ static bool bidir_limit(void) #ifdef HAVE_LCD_CHARCELLS static bool jump_scroll(void) { - struct opt_items names[] = { + static const struct opt_items names[] = { { STR(LANG_OFF) }, { STR(LANG_ONE_TIME) }, { "2", TALK_ID(2, UNIT_INT) }, @@ -758,7 +758,7 @@ static bool timedate_set(void) static bool timeformat_set(void) { - struct opt_items names[] = { + static const struct opt_items names[] = { { STR(LANG_24_HOUR_CLOCK) }, { STR(LANG_12_HOUR_CLOCK) } }; @@ -815,7 +815,7 @@ static bool buffer_margin(void) static bool ff_rewind_min_step(void) { - struct opt_items names[] = { + static const struct opt_items names[] = { { "1s", TALK_ID(1, UNIT_SEC) }, { "2s", TALK_ID(2, UNIT_SEC) }, { "3s", TALK_ID(3, UNIT_SEC) }, @@ -843,7 +843,7 @@ static bool set_fade_on_stop(void) static bool ff_rewind_accel(void) { - struct opt_items names[] = { + static const struct opt_items names[] = { { STR(LANG_OFF) }, { "2x/1s", TALK_ID(1, UNIT_SEC) }, { "2x/2s", TALK_ID(2, UNIT_SEC) }, @@ -899,7 +899,7 @@ static bool voice_menus(void) static bool voice_dirs(void) { - struct opt_items names[] = { + static const struct opt_items names[] = { { STR(LANG_OFF) }, { STR(LANG_VOICE_NUMBER) }, { STR(LANG_VOICE_SPELL) }, @@ -912,7 +912,7 @@ static bool voice_dirs(void) static bool voice_files(void) { - struct opt_items names[] = { + static const struct opt_items names[] = { { STR(LANG_OFF) }, { STR(LANG_VOICE_NUMBER) }, { STR(LANG_VOICE_SPELL) } @@ -926,10 +926,10 @@ static bool voice_menu(void) int m; bool result; - struct menu_item items[] = { - { STR(LANG_VOICE_MENU), voice_menus }, - { STR(LANG_VOICE_DIR), voice_dirs }, - { STR(LANG_VOICE_FILE), voice_files } + static const struct menu_item items[] = { + { ID2P(LANG_VOICE_MENU), voice_menus }, + { ID2P(LANG_VOICE_DIR), voice_dirs }, + { ID2P(LANG_VOICE_FILE), voice_files } }; m=menu_init( items, sizeof(items) / sizeof(*items), NULL, @@ -966,9 +966,9 @@ static bool ff_rewind_settings_menu(void) int m; bool result; - struct menu_item items[] = { - { STR(LANG_FFRW_STEP), ff_rewind_min_step }, - { STR(LANG_FFRW_ACCEL), ff_rewind_accel }, + static const struct menu_item items[] = { + { ID2P(LANG_FFRW_STEP), ff_rewind_min_step }, + { ID2P(LANG_FFRW_ACCEL), ff_rewind_accel }, }; m=menu_init( items, sizeof(items) / sizeof(*items), NULL, @@ -984,14 +984,14 @@ static bool playback_settings_menu(void) int m; bool result; - struct menu_item items[] = { - { STR(LANG_SHUFFLE), shuffle }, - { STR(LANG_REPEAT), repeat_mode }, - { STR(LANG_PLAY_SELECTED), play_selected }, - { STR(LANG_RESUME), resume }, - { STR(LANG_WIND_MENU), ff_rewind_settings_menu }, - { STR(LANG_MP3BUFFER_MARGIN), buffer_margin }, - { STR(LANG_FADE_ON_STOP), set_fade_on_stop }, + static const struct menu_item items[] = { + { ID2P(LANG_SHUFFLE), shuffle }, + { ID2P(LANG_REPEAT), repeat_mode }, + { ID2P(LANG_PLAY_SELECTED), play_selected }, + { ID2P(LANG_RESUME), resume }, + { ID2P(LANG_WIND_MENU), ff_rewind_settings_menu }, + { ID2P(LANG_MP3BUFFER_MARGIN), buffer_margin }, + { ID2P(LANG_FADE_ON_STOP), set_fade_on_stop }, }; bool old_shuffle = global_settings.playlist_shuffle; @@ -1020,10 +1020,10 @@ static bool bookmark_settings_menu(void) int m; bool result; - struct menu_item items[] = { - { STR(LANG_BOOKMARK_SETTINGS_AUTOCREATE), autocreatebookmark}, - { STR(LANG_BOOKMARK_SETTINGS_AUTOLOAD), autoloadbookmark}, - { STR(LANG_BOOKMARK_SETTINGS_MAINTAIN_RECENT_BOOKMARKS), useMRB}, + static const struct menu_item items[] = { + { ID2P(LANG_BOOKMARK_SETTINGS_AUTOCREATE), autocreatebookmark}, + { ID2P(LANG_BOOKMARK_SETTINGS_AUTOLOAD), autoloadbookmark}, + { ID2P(LANG_BOOKMARK_SETTINGS_MAINTAIN_RECENT_BOOKMARKS), useMRB}, }; m=menu_init( items, sizeof(items) / sizeof(*items), NULL, @@ -1088,13 +1088,13 @@ static bool fileview_settings_menu(void) int m; bool result; - struct menu_item items[] = { - { STR(LANG_SORT_CASE), sort_case }, - { STR(LANG_SORT_DIR), sort_dir }, - { STR(LANG_SORT_FILE), sort_file }, - { STR(LANG_FILTER), dir_filter }, - { STR(LANG_FOLLOW), browse_current }, - { STR(LANG_SHOW_ICONS), show_icons }, + static const struct menu_item items[] = { + { ID2P(LANG_SORT_CASE), sort_case }, + { ID2P(LANG_SORT_DIR), sort_dir }, + { ID2P(LANG_SORT_FILE), sort_file }, + { ID2P(LANG_FILTER), dir_filter }, + { ID2P(LANG_FOLLOW), browse_current }, + { ID2P(LANG_SHOW_ICONS), show_icons }, }; m=menu_init( items, sizeof(items) / sizeof(*items), NULL, @@ -1110,16 +1110,16 @@ static bool scroll_settings_menu(void) int m; bool result; - struct menu_item items[] = { - { STR(LANG_SCROLL_SPEED), scroll_speed }, - { STR(LANG_SCROLL_DELAY), scroll_delay }, + static const struct menu_item items[] = { + { ID2P(LANG_SCROLL_SPEED), scroll_speed }, + { ID2P(LANG_SCROLL_DELAY), scroll_delay }, #ifdef HAVE_LCD_BITMAP - { STR(LANG_SCROLL_STEP), scroll_step }, + { ID2P(LANG_SCROLL_STEP), scroll_step }, #endif - { STR(LANG_BIDIR_SCROLL), bidir_limit }, + { ID2P(LANG_BIDIR_SCROLL), bidir_limit }, #ifdef HAVE_LCD_CHARCELLS - { STR(LANG_JUMP_SCROLL), jump_scroll }, - { STR(LANG_JUMP_SCROLL_DELAY), jump_scroll_delay }, + { ID2P(LANG_JUMP_SCROLL), jump_scroll }, + { ID2P(LANG_JUMP_SCROLL_DELAY), jump_scroll_delay }, #endif }; @@ -1135,15 +1135,15 @@ static bool lcd_settings_menu(void) int m; bool result; - struct menu_item items[] = { - { STR(LANG_BACKLIGHT), backlight_timer }, - { STR(LANG_BACKLIGHT_ON_WHEN_CHARGING), backlight_on_when_charging }, - { STR(LANG_CAPTION_BACKLIGHT), caption_backlight }, - { STR(LANG_CONTRAST), contrast }, + static const struct menu_item items[] = { + { ID2P(LANG_BACKLIGHT), backlight_timer }, + { ID2P(LANG_BACKLIGHT_ON_WHEN_CHARGING), backlight_on_when_charging }, + { ID2P(LANG_CAPTION_BACKLIGHT), caption_backlight }, + { ID2P(LANG_CONTRAST), contrast }, #ifdef HAVE_LCD_BITMAP - { STR(LANG_INVERT), invert }, - { STR(LANG_FLIP_DISPLAY), flip_display }, - { STR(LANG_INVERT_CURSOR), invert_cursor }, + { ID2P(LANG_INVERT), invert }, + { ID2P(LANG_FLIP_DISPLAY), flip_display }, + { ID2P(LANG_INVERT_CURSOR), invert_cursor }, #endif }; @@ -1160,12 +1160,12 @@ static bool bars_settings_menu(void) int m; bool result; - struct menu_item items[] = { - { STR(LANG_SCROLL_BAR), scroll_bar }, - { STR(LANG_STATUS_BAR), status_bar }, - { STR(LANG_BUTTON_BAR), button_bar }, - { STR(LANG_VOLUME_DISPLAY), volume_type }, - { STR(LANG_BATTERY_DISPLAY), battery_type }, + static const struct menu_item items[] = { + { ID2P(LANG_SCROLL_BAR), scroll_bar }, + { ID2P(LANG_STATUS_BAR), status_bar }, + { ID2P(LANG_BUTTON_BAR), button_bar }, + { ID2P(LANG_VOLUME_DISPLAY), volume_type }, + { ID2P(LANG_BATTERY_DISPLAY), battery_type }, }; m=menu_init( items, sizeof(items) / sizeof(*items), NULL, @@ -1182,16 +1182,16 @@ static bool display_settings_menu(void) int m; bool result; - struct menu_item items[] = { + static const struct menu_item items[] = { #ifdef HAVE_LCD_BITMAP - { STR(LANG_CUSTOM_FONT), font_browse }, + { ID2P(LANG_CUSTOM_FONT), font_browse }, #endif - { STR(LANG_WHILE_PLAYING), custom_wps_browse }, - { STR(LANG_LCD_MENU), lcd_settings_menu }, - { STR(LANG_SCROLL_MENU), scroll_settings_menu }, + { ID2P(LANG_WHILE_PLAYING), custom_wps_browse }, + { ID2P(LANG_LCD_MENU), lcd_settings_menu }, + { ID2P(LANG_SCROLL_MENU), scroll_settings_menu }, #ifdef HAVE_LCD_BITMAP - { STR(LANG_BARS_MENU), bars_settings_menu }, - { STR(LANG_PM_MENU), peak_meter_menu }, + { ID2P(LANG_BARS_MENU), bars_settings_menu }, + { ID2P(LANG_PM_MENU), peak_meter_menu }, #endif }; @@ -1213,16 +1213,16 @@ static bool battery_settings_menu(void) int m; bool result; - struct menu_item items[] = { + static const struct menu_item items[] = { #ifdef HAVE_CHARGE_CTRL - { STR(LANG_DISCHARGE), deep_discharge }, - { STR(LANG_TRICKLE_CHARGE), trickle_charge }, + { ID2P(LANG_DISCHARGE), deep_discharge }, + { ID2P(LANG_TRICKLE_CHARGE), trickle_charge }, #endif #ifndef SIMULATOR - { STR(LANG_BATTERY_CAPACITY), battery_capacity }, + { ID2P(LANG_BATTERY_CAPACITY), battery_capacity }, #else #ifndef HAVE_CHARGE_CTRL - { "Dummy", -1, NULL }, /* to have an entry at all, in the simulator */ + { "Dummy", NULL }, /* to have an entry at all, in the simulator */ #endif #endif }; @@ -1239,10 +1239,10 @@ static bool disk_settings_menu(void) int m; bool result; - struct menu_item items[] = { - { STR(LANG_SPINDOWN), spindown }, + static const struct menu_item items[] = { + { ID2P(LANG_SPINDOWN), spindown }, #ifdef HAVE_ATA_POWER_OFF - { STR(LANG_POWEROFF), poweroff }, + { ID2P(LANG_POWEROFF), poweroff }, #endif }; @@ -1259,9 +1259,9 @@ static bool time_settings_menu(void) int m; bool result; - struct menu_item items[] = { - { STR(LANG_TIME), timedate_set }, - { STR(LANG_TIMEFORMAT), timeformat_set }, + static const struct menu_item items[] = { + { ID2P(LANG_TIME), timedate_set }, + { ID2P(LANG_TIMEFORMAT), timeformat_set }, }; m=menu_init( items, sizeof(items) / sizeof(*items), NULL, @@ -1277,11 +1277,11 @@ static bool manage_settings_menu(void) int m; bool result; - struct menu_item items[] = { - { STR(LANG_CUSTOM_CFG), custom_cfg_browse }, - { STR(LANG_FIRMWARE), firmware_browse }, - { STR(LANG_RESET), reset_settings }, - { STR(LANG_SAVE_SETTINGS), settings_save_config }, + static const struct menu_item items[] = { + { ID2P(LANG_CUSTOM_CFG), custom_cfg_browse }, + { ID2P(LANG_FIRMWARE), firmware_browse }, + { ID2P(LANG_RESET), reset_settings }, + { ID2P(LANG_SAVE_SETTINGS), settings_save_config }, }; m=menu_init( items, sizeof(items) / sizeof(*items), NULL, @@ -1296,9 +1296,9 @@ static bool limits_settings_menu(void) int m; bool result; - struct menu_item items[] = { - { STR(LANG_MAX_FILES_IN_DIR), max_files_in_dir }, - { STR(LANG_MAX_FILES_IN_PLAYLIST), max_files_in_playlist }, + static const struct menu_item items[] = { + { ID2P(LANG_MAX_FILES_IN_DIR), max_files_in_dir }, + { ID2P(LANG_MAX_FILES_IN_PLAYLIST), max_files_in_playlist }, }; m=menu_init( items, sizeof(items) / sizeof(*items), NULL, @@ -1314,23 +1314,23 @@ static bool system_settings_menu(void) int m; bool result; - struct menu_item items[] = { - { STR(LANG_BATTERY_MENU), battery_settings_menu }, - { STR(LANG_DISK_MENU), disk_settings_menu }, + static const struct menu_item items[] = { + { ID2P(LANG_BATTERY_MENU), battery_settings_menu }, + { ID2P(LANG_DISK_MENU), disk_settings_menu }, #ifdef HAVE_RTC - { STR(LANG_TIME_MENU), time_settings_menu }, + { ID2P(LANG_TIME_MENU), time_settings_menu }, #endif - { STR(LANG_POWEROFF_IDLE), poweroff_idle_timer }, - { STR(LANG_SLEEP_TIMER), sleeptimer_screen }, + { ID2P(LANG_POWEROFF_IDLE), poweroff_idle_timer }, + { ID2P(LANG_SLEEP_TIMER), sleeptimer_screen }, #ifdef HAVE_ALARM_MOD - { STR(LANG_ALARM_MOD_ALARM_MENU), alarm_screen }, + { ID2P(LANG_ALARM_MOD_ALARM_MENU), alarm_screen }, #endif - { STR(LANG_LIMITS_MENU), limits_settings_menu }, + { ID2P(LANG_LIMITS_MENU), limits_settings_menu }, #ifdef HAVE_MAS3507D - { STR(LANG_LINE_IN), line_in }, + { ID2P(LANG_LINE_IN), line_in }, #endif - { STR(LANG_CAR_ADAPTER_MODE), car_adapter_mode }, - { STR(LANG_MANAGE_MENU), manage_settings_menu }, + { ID2P(LANG_CAR_ADAPTER_MODE), car_adapter_mode }, + { ID2P(LANG_MANAGE_MENU), manage_settings_menu }, }; m=menu_init( items, sizeof(items) / sizeof(*items), NULL, @@ -1345,14 +1345,14 @@ bool settings_menu(void) int m; bool result; - struct menu_item items[] = { - { STR(LANG_PLAYBACK), playback_settings_menu }, - { STR(LANG_FILE), fileview_settings_menu }, - { STR(LANG_DISPLAY), display_settings_menu }, - { STR(LANG_SYSTEM), system_settings_menu }, - { STR(LANG_BOOKMARK_SETTINGS),bookmark_settings_menu }, - { STR(LANG_LANGUAGE), language_browse }, - { STR(LANG_VOICE), voice_menu }, + static const struct menu_item items[] = { + { ID2P(LANG_PLAYBACK), playback_settings_menu }, + { ID2P(LANG_FILE), fileview_settings_menu }, + { ID2P(LANG_DISPLAY), display_settings_menu }, + { ID2P(LANG_SYSTEM), system_settings_menu }, + { ID2P(LANG_BOOKMARK_SETTINGS),bookmark_settings_menu }, + { ID2P(LANG_LANGUAGE), language_browse }, + { ID2P(LANG_VOICE), voice_menu }, }; m=menu_init( items, sizeof(items) / sizeof(*items), NULL, -- cgit v1.2.3