diff options
author | Anton Oleynikov <len0x@rockbox.org> | 2005-11-19 14:54:41 +0000 |
---|---|---|
committer | Anton Oleynikov <len0x@rockbox.org> | 2005-11-19 14:54:41 +0000 |
commit | 0afd9716a4879e66bc29826dba54c544920d1ee5 (patch) | |
tree | dd990adb04b3c650641165f60863a214386b09f8 /apps | |
parent | 8690a394b18ba969ffc2f9720b8d818bd56b42b5 (diff) |
used generic yes/no dialog for confirmation of presets clearing
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@7996 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps')
-rw-r--r-- | apps/recorder/radio.c | 102 |
1 files changed, 42 insertions, 60 deletions
diff --git a/apps/recorder/radio.c b/apps/recorder/radio.c index 60a14eff3d..3dc74cd2ce 100644 --- a/apps/recorder/radio.c +++ b/apps/recorder/radio.c @@ -55,6 +55,7 @@ #include "statusbar.h" #include "textarea.h" #include "splash.h" +#include "yesno.h" #ifdef CONFIG_TUNER @@ -1185,76 +1186,57 @@ static bool toggle_mono_mode(void) static bool scan_presets(void) { - bool exit = false; bool tuned = false; char buf[32]; int freq, i; + char *lines[]={str(LANG_FM_CLEAR_PRESETS)}; + struct text_message message={lines, 1}; - FOR_NB_SCREENS(i){ - gui_textarea_clear(&screens[i]); - screens[i].puts_scroll(0,0,str(LANG_FM_CLEAR_PRESETS)); - screens[i].puts_scroll(0,2,str(LANG_CONFIRM_WITH_PLAY_RECORDER)); - screens[i].puts_scroll(0,3,str(LANG_CANCEL_WITH_ANY_RECORDER)); - gui_textarea_update(&screens[i]); - } + if(gui_syncyesno_run(&message,NULL,NULL)==YESNO_YES){ + FOR_NB_SCREENS(i) + gui_textarea_clear(&screens[i]); + curr_freq = MIN_FREQ; + num_presets = 0; + while(curr_freq <= MAX_FREQ){ + if (num_presets >= MAX_PRESETS) + break; - while (!exit) { - int btn = button_get(true); - switch (btn) { - case SETTINGS_OK: - FOR_NB_SCREENS(i) - gui_textarea_clear(&screens[i]); - curr_freq = MIN_FREQ; - num_presets = 0; - while(curr_freq <= MAX_FREQ){ - if (num_presets >= MAX_PRESETS) - break; - - freq = curr_freq /100000; - snprintf(buf, 32, str(LANG_FM_SCANNING), freq/10, freq % 10); - gui_syncsplash(0, true, buf); - - /* Tune in and delay */ - radio_set(RADIO_FREQUENCY, curr_freq); - sleep(1); + freq = curr_freq /100000; + snprintf(buf, 32, str(LANG_FM_SCANNING), freq/10, freq % 10); + gui_syncsplash(0, true, buf); + + /* Tune in and delay */ + radio_set(RADIO_FREQUENCY, curr_freq); + sleep(1); - /* Start IF measurement */ - radio_set(RADIO_IF_MEASUREMENT, 1); - sleep(1); - - /* Now check how close to the IF frequency we are */ - tuned = radio_get(RADIO_TUNED); - - /* add preset */ - if(tuned){ - snprintf(buf, 32, str(LANG_FM_DEFAULT_PRESET_NAME),freq/10, freq % 10); - strcpy(presets[num_presets].name, buf); - presets[num_presets].frequency = curr_freq; - menu_insert(preset_menu, -1, - presets[num_presets].name, 0); - num_presets++; - } + /* Start IF measurement */ + radio_set(RADIO_IF_MEASUREMENT, 1); + sleep(1); - curr_freq += FREQ_STEP; - - } + /* Now check how close to the IF frequency we are */ + tuned = radio_get(RADIO_TUNED); - rebuild_preset_menu(); - radio_save_presets(); + /* add preset */ + if(tuned){ + snprintf(buf, 32, str(LANG_FM_DEFAULT_PRESET_NAME),freq/10, freq % 10); + strcpy(presets[num_presets].name, buf); + presets[num_presets].frequency = curr_freq; + menu_insert(preset_menu, -1, + presets[num_presets].name, 0); + num_presets++; + } - if(num_presets > 0 ){ - curr_freq = presets[0].frequency; - radio_set(RADIO_FREQUENCY, curr_freq); - remember_frequency(); - } - exit = true; - break; + curr_freq += FREQ_STEP; + + } - default: - /* ignore button releases */ - if (!(btn & BUTTON_REL)) - exit = true; - break; + rebuild_preset_menu(); + radio_save_presets(); + + if(num_presets > 0 ){ + curr_freq = presets[0].frequency; + radio_set(RADIO_FREQUENCY, curr_freq); + remember_frequency(); } } return true; |