static int eq_do_simple_menu(void * param) { (void)param; struct simplelist_info info; struct settings_list setting; char title[MAX_PATH]; simplelist_info_init(&info, str(LANG_EQUALIZER_GAIN), EQ_NUM_BANDS, NULL); info.get_name = (list_get_name*)gainitem_get_name; info.get_talk = gainitem_speak_item; info.get_icon = gainitem_get_icon; info.action_callback = simplelist_action_callback; info.selection = -1; info.title_icon = Icon_Submenu; setting.flags = F_BANFROMQS|F_INT_SETTING|F_T_INT|F_NO_WRAP; setting.lang_id = LANG_GAIN; setting.default_val.int_ = 0; setting.int_setting = &gain_int_setting; while (true) { simplelist_show_list(&info); if (info.selection < 0) break; pcmbuf_set_low_latency(true); setting.setting = &global_settings.eq_band_settings[info.selection].gain; option_screen(&setting, NULL, false, gainitem_get_name(info.selection, NULL, title, MAX_PATH)); eq_apply(); pcmbuf_set_low_latency(false); } return 0; }
bool folder_select(char* setting, int setting_len) { struct folder *root; struct simplelist_info info; size_t buf_size; /* 32 separate folders should be Enough For Everybody(TM) */ char *vect[32]; char copy[setting_len]; int nb_items; /* copy onto stack as split_string() modifies it */ strlcpy(copy, setting, setting_len); nb_items = split_string(copy, ':', vect, ARRAYLEN(vect)); buffer_front = plugin_get_buffer(&buf_size); buffer_end = buffer_front + buf_size; root = load_root(); if (nb_items > 0) { for(int i = 0; i < nb_items; i++) select_paths(root, vect[i]); } simplelist_info_init(&info, str(LANG_SELECT_FOLDER), count_items(root), root); info.get_name = folder_get_name; info.action_callback = folder_action_callback; info.get_icon = folder_get_icon; simplelist_show_list(&info); /* done editing. check for changes */ save_folders(root, copy, setting_len); if (strcmp(copy, setting)) { /* prompt for saving changes and commit if yes */ if (yesno_pop(ID2P(LANG_SAVE_CHANGES))) { strcpy(setting, copy); settings_save(); return true; } } return false; }
static int eq_do_advanced_menu(void * param) { (void)param; struct simplelist_info info; struct settings_list setting; char title[MAX_PATH]; int band, item; intptr_t selected_band = -1; simplelist_info_init(&info, str(LANG_EQUALIZER_ADVANCED), EQ_NUM_BANDS, &selected_band); info.get_name = (list_get_name*)advancedmenu_item_get_name; info.get_talk = advancedmenu_speak_item; info.get_icon = advancedmenu_get_icon; info.action_callback = simplelist_action_callback; info.selection = -1; info.title_icon = Icon_EQ; setting.flags = F_BANFROMQS|F_INT_SETTING|F_T_INT|F_NO_WRAP; while (true) { simplelist_show_list(&info); if (info.selection < 0) break; selection_to_banditem(info.selection, selected_band, &band, &item); switch (item) { case 0: /* title, do nothing */ { int extra; if (selected_band == band) { extra = 0; selected_band = -1; } else { extra = 3; selected_band = band; } info.selection = band; info.count = EQ_NUM_BANDS + extra; continue; } case 1: /* cutoff */ if (band == 0 || band == EQ_NUM_BANDS - 1) setting.lang_id = LANG_EQUALIZER_BAND_CUTOFF; else setting.lang_id = LANG_EQUALIZER_BAND_CENTER; setting.default_val.int_ = eq_defaults[band].cutoff; setting.int_setting = &cutoff_int_setting; setting.setting = &global_settings.eq_band_settings[band].cutoff; break; case 2: /* Q */ setting.lang_id = LANG_EQUALIZER_BAND_Q; setting.default_val.int_ = eq_defaults[band].q; setting.int_setting = &q_int_setting; setting.setting = &global_settings.eq_band_settings[band].q; break; case 3: /* Gain */ setting.lang_id = LANG_GAIN; setting.default_val.int_ = eq_defaults[band].gain; setting.int_setting = &gain_int_setting; setting.setting = &global_settings.eq_band_settings[band].gain; break; } pcmbuf_set_low_latency(true); advancedmenu_item_get_name(info.selection, &selected_band, title, MAX_PATH); option_screen(&setting, NULL, false, title[0] == '\t' ? &title[1] : title); eq_apply(); pcmbuf_set_low_latency(false); } return 0; }
int do_shortcut_menu(void *ignored) { (void)ignored; struct simplelist_info list; struct shortcut *sc; int done = GO_TO_PREVIOUS; if (first_handle == 0) shortcuts_init(); simplelist_info_init(&list, P2STR(ID2P(LANG_SHORTCUTS)), shortcut_count, NULL); list.get_name = shortcut_menu_get_name; list.action_callback = shortcut_menu_get_action; if (global_settings.show_icons) list.get_icon = shortcut_menu_get_icon; list.title_icon = Icon_Bookmark; if (global_settings.talk_menu) list.get_talk = shortcut_menu_speak_item; push_current_activity(ACTIVITY_SHORTCUTSMENU); while (done == GO_TO_PREVIOUS) { if (simplelist_show_list(&list)) break; /* some error happened?! */ if (list.selection == -1) break; else { sc = get_shortcut(list.selection); if (!sc) continue; switch (sc->type) { case SHORTCUT_PLAYLISTMENU: if (!file_exists(sc->u.path)) { splash(HZ, ID2P(LANG_NO_FILES)); break; } else { onplay_show_playlist_menu(sc->u.path); } break; case SHORTCUT_FILE: if (!file_exists(sc->u.path)) { splash(HZ, ID2P(LANG_NO_FILES)); break; } /* else fall through */ case SHORTCUT_BROWSER: { struct browse_context browse; browse_context_init(&browse, global_settings.dirfilter, 0, NULL, NOICON, sc->u.path, NULL); if (sc->type == SHORTCUT_FILE) browse.flags |= BROWSE_RUNFILE; done = rockbox_browse(&browse); } break; case SHORTCUT_SETTING: do_setting_screen(sc->u.setting, sc->name[0] ? sc->name : P2STR(ID2P(sc->u.setting->lang_id)),NULL); break; case SHORTCUT_DEBUGITEM: run_debug_screen(sc->u.path); break; case SHORTCUT_SHUTDOWN: #if CONFIG_CHARGING if (charger_inserted()) charging_splash(); else #endif sys_poweroff(); break; case SHORTCUT_TIME: #if CONFIG_RTC if (sc->u.timedata.talktime) { talk_timedate(); talk_force_enqueue_next(); } 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; } } } pop_current_activity(); return done; }