1 /***************************************************************************
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
10 * Copyright (C) 2007 Jonathan Gordon
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
20 ****************************************************************************/
32 #include "sound_menu.h"
33 #include "exported_menus.h"
40 #include "powermgmt.h"
41 #if CONFIG_CODEC == SWCODEC
47 #include "quickscreen.h"
51 #include "folder_select.h"
53 /***********************************/
57 static void tagcache_rebuild_with_splash(void)
60 splash(HZ
*2, ID2P(LANG_TAGCACHE_FORCE_UPDATE_SPLASH
));
63 static void tagcache_update_with_splash(void)
66 splash(HZ
*2, ID2P(LANG_TAGCACHE_FORCE_UPDATE_SPLASH
));
69 static int dirs_to_scan(void)
71 if (folder_select(global_settings
.tagcache_scan_paths
,
72 sizeof(global_settings
.tagcache_scan_paths
)))
74 static const char *lines
[] = {ID2P(LANG_TAGCACHE_BUSY
),
75 ID2P(LANG_TAGCACHE_FORCE_UPDATE
)};
76 static const struct text_message message
= {lines
, 2};
78 if (gui_syncyesno_run(&message
, NULL
, NULL
) == YESNO_YES
)
79 tagcache_rebuild_with_splash();
84 #ifdef HAVE_TC_RAMCACHE
85 MENUITEM_SETTING(tagcache_ram
, &global_settings
.tagcache_ram
, NULL
);
87 MENUITEM_SETTING(tagcache_autoupdate
, &global_settings
.tagcache_autoupdate
, NULL
);
88 MENUITEM_FUNCTION(tc_init
, 0, ID2P(LANG_TAGCACHE_FORCE_UPDATE
),
89 (int(*)(void))tagcache_rebuild_with_splash
,
90 NULL
, NULL
, Icon_NOICON
);
91 MENUITEM_FUNCTION(tc_update
, 0, ID2P(LANG_TAGCACHE_UPDATE
),
92 (int(*)(void))tagcache_update_with_splash
,
93 NULL
, NULL
, Icon_NOICON
);
94 MENUITEM_SETTING(runtimedb
, &global_settings
.runtimedb
, NULL
);
95 MENUITEM_FUNCTION(tc_export
, 0, ID2P(LANG_TAGCACHE_EXPORT
),
96 (int(*)(void))tagtree_export
, NULL
,
98 MENUITEM_FUNCTION(tc_import
, 0, ID2P(LANG_TAGCACHE_IMPORT
),
99 (int(*)(void))tagtree_import
, NULL
,
101 MENUITEM_FUNCTION(tc_paths
, 0, ID2P(LANG_SELECT_DATABASE_DIRS
),
102 dirs_to_scan
, NULL
, NULL
, Icon_NOICON
);
104 MAKE_MENU(tagcache_menu
, ID2P(LANG_TAGCACHE
), 0, Icon_NOICON
,
105 #ifdef HAVE_TC_RAMCACHE
108 &tagcache_autoupdate
, &tc_init
, &tc_update
, &runtimedb
,
109 &tc_export
, &tc_import
, &tc_paths
111 #endif /* HAVE_TAGCACHE */
113 /***********************************/
115 /***********************************/
117 static int fileview_callback(int action
,const struct menu_item_ex
*this_item
);
118 MENUITEM_SETTING(sort_case
, &global_settings
.sort_case
, NULL
);
119 MENUITEM_SETTING(sort_dir
, &global_settings
.sort_dir
, fileview_callback
);
120 MENUITEM_SETTING(sort_file
, &global_settings
.sort_file
, fileview_callback
);
121 MENUITEM_SETTING(interpret_numbers
, &global_settings
.interpret_numbers
, fileview_callback
);
122 MENUITEM_SETTING(dirfilter
, &global_settings
.dirfilter
, NULL
);
123 MENUITEM_SETTING(show_filename_ext
, &global_settings
.show_filename_ext
, NULL
);
124 MENUITEM_SETTING(browse_current
, &global_settings
.browse_current
, NULL
);
125 #ifdef HAVE_LCD_BITMAP
126 MENUITEM_SETTING(show_path_in_browser
, &global_settings
.show_path_in_browser
, NULL
);
128 static int clear_start_directory(void)
130 strcpy(global_settings
.start_directory
, "/");
132 splash(HZ
, ID2P(LANG_RESET_DONE_CLEAR
));
135 MENUITEM_FUNCTION(clear_start_directory_item
, 0, ID2P(LANG_RESET_START_DIR
),
136 clear_start_directory
, NULL
, NULL
, Icon_file_view_menu
);
137 static int fileview_callback(int action
,const struct menu_item_ex
*this_item
)
140 int *variable
= this_item
->variable
;
143 case ACTION_ENTER_MENUITEM
: /* on entering an item */
146 case ACTION_EXIT_MENUITEM
: /* on exit */
147 if (*variable
!= oldval
)
148 reload_directory(); /* force reload if this has changed */
154 MAKE_MENU(file_menu
, ID2P(LANG_FILE
), 0, Icon_file_view_menu
,
155 &sort_case
, &sort_dir
, &sort_file
, &interpret_numbers
,
156 &dirfilter
, &show_filename_ext
, &browse_current
,
157 #ifdef HAVE_LCD_BITMAP
158 &show_path_in_browser
,
160 &clear_start_directory_item
163 /***********************************/
166 /***********************************/
170 #if BATTERY_CAPACITY_INC > 0
171 MENUITEM_SETTING(battery_capacity
, &global_settings
.battery_capacity
, NULL
);
173 #if BATTERY_TYPES_COUNT > 1
174 MENUITEM_SETTING(battery_type
, &global_settings
.battery_type
, NULL
);
176 #ifdef HAVE_USB_CHARGING_ENABLE
177 static int usbcharging_callback(int action
,const struct menu_item_ex
*this_item
)
182 case ACTION_EXIT_MENUITEM
: /* on exit */
183 usb_charging_enable(global_settings
.usb_charging
);
188 MENUITEM_SETTING(usb_charging
, &global_settings
.usb_charging
, usbcharging_callback
);
189 #endif /* HAVE_USB_CHARGING_ENABLE */
190 MAKE_MENU(battery_menu
, ID2P(LANG_BATTERY_MENU
), 0, Icon_NOICON
,
191 #if defined(BATTERY_CAPACITY_INC) && BATTERY_CAPACITY_INC > 0
194 #if BATTERY_TYPES_COUNT > 1
197 #ifdef HAVE_USB_CHARGING_ENABLE
202 #ifdef HAVE_DISK_STORAGE
203 MENUITEM_SETTING(disk_spindown
, &global_settings
.disk_spindown
, NULL
);
206 static int dircache_callback(int action
,const struct menu_item_ex
*this_item
)
211 case ACTION_EXIT_MENUITEM
: /* on exit */
212 if (global_settings
.dircache
&& !dircache_is_enabled())
214 if (dircache_build(0) < 0)
215 splash(HZ
*2, ID2P(LANG_PLEASE_REBOOT
));
217 else if (!global_settings
.dircache
&& dircache_is_enabled())
225 MENUITEM_SETTING(dircache
, &global_settings
.dircache
, dircache_callback
);
227 #if defined(HAVE_DIRCACHE) || defined(HAVE_DISK_STORAGE)
228 MAKE_MENU(disk_menu
, ID2P(LANG_DISK_MENU
), 0, Icon_NOICON
,
229 #ifdef HAVE_DISK_STORAGE
239 MENUITEM_SETTING(max_files_in_dir
, &global_settings
.max_files_in_dir
, NULL
);
240 MENUITEM_SETTING(max_files_in_playlist
, &global_settings
.max_files_in_playlist
, NULL
);
241 #ifdef HAVE_LCD_BITMAP
242 MENUITEM_SETTING(default_glyphs
, &global_settings
.glyphs_to_cache
, NULL
);
244 MAKE_MENU(limits_menu
, ID2P(LANG_LIMITS_MENU
), 0, Icon_NOICON
,
245 &max_files_in_dir
, &max_files_in_playlist
246 #ifdef HAVE_LCD_BITMAP
253 #if CONFIG_CODEC == SWCODEC
254 MENUITEM_SETTING(keyclick
, &global_settings
.keyclick
, NULL
);
255 MENUITEM_SETTING(keyclick_repeats
, &global_settings
.keyclick_repeats
, NULL
);
256 #ifdef HAVE_HARDWARE_CLICK
257 MENUITEM_SETTING(keyclick_hardware
, &global_settings
.keyclick_hardware
, NULL
);
258 MAKE_MENU(keyclick_menu
, ID2P(LANG_KEYCLICK
), 0, Icon_NOICON
,
259 &keyclick
, &keyclick_hardware
, &keyclick_repeats
);
261 MAKE_MENU(keyclick_menu
, ID2P(LANG_KEYCLICK
), 0, Icon_NOICON
,
262 &keyclick
, &keyclick_repeats
);
267 #if CONFIG_CODEC == MAS3507D
268 void dac_line_in(bool enable
);
269 static int linein_callback(int action
,const struct menu_item_ex
*this_item
)
274 case ACTION_EXIT_MENUITEM
: /* on exit */
276 dac_line_in(global_settings
.line_in
);
282 MENUITEM_SETTING(line_in
, &global_settings
.line_in
, linein_callback
);
285 MENUITEM_SETTING(car_adapter_mode
, &global_settings
.car_adapter_mode
, NULL
);
287 #ifdef IPOD_ACCESSORY_PROTOCOL
288 MENUITEM_SETTING(serial_bitrate
, &global_settings
.serial_bitrate
, NULL
);
290 #ifdef HAVE_ACCESSORY_SUPPLY
291 MENUITEM_SETTING(accessory_supply
, &global_settings
.accessory_supply
, NULL
);
293 #ifdef HAVE_LINEOUT_POWEROFF
294 MENUITEM_SETTING(lineout_onoff
, &global_settings
.lineout_active
, NULL
);
296 #ifdef USB_ENABLE_HID
297 MENUITEM_SETTING(usb_hid
, &global_settings
.usb_hid
, NULL
);
298 MENUITEM_SETTING(usb_keypad_mode
, &global_settings
.usb_keypad_mode
, NULL
);
300 #if defined(USB_ENABLE_STORAGE) && defined(HAVE_MULTIDRIVE)
301 MENUITEM_SETTING(usb_skip_first_drive
, &global_settings
.usb_skip_first_drive
, NULL
);
304 #ifdef HAVE_MORSE_INPUT
305 MENUITEM_SETTING(morse_input
, &global_settings
.morse_input
, NULL
);
308 #ifdef HAVE_BUTTON_LIGHT
309 MENUITEM_SETTING(buttonlight_timeout
, &global_settings
.buttonlight_timeout
, NULL
);
312 #ifdef HAVE_BUTTONLIGHT_BRIGHTNESS
313 MENUITEM_SETTING(buttonlight_brightness
, &global_settings
.buttonlight_brightness
, NULL
);
316 #ifdef HAVE_TOUCHPAD_SENSITIVITY_SETTING
317 MENUITEM_SETTING(touchpad_sensitivity
, &global_settings
.touchpad_sensitivity
, NULL
);
320 #ifdef HAVE_QUICKSCREEN
321 MENUITEM_SETTING(shortcuts_replaces_quickscreen
, &global_settings
.shortcuts_replaces_qs
, NULL
);
324 MAKE_MENU(system_menu
, ID2P(LANG_SYSTEM
),
326 #if (BATTERY_CAPACITY_INC > 0) || (BATTERY_TYPES_COUNT > 1)
329 #if defined(HAVE_DIRCACHE) || defined(HAVE_DISK_STORAGE)
333 #ifdef HAVE_QUICKSCREEN
334 &shortcuts_replaces_quickscreen
,
336 #ifdef HAVE_MORSE_INPUT
339 #if CONFIG_CODEC == MAS3507D
345 #ifdef IPOD_ACCESSORY_PROTOCOL
348 #ifdef HAVE_ACCESSORY_SUPPLY
351 #ifdef HAVE_LINEOUT_POWEROFF
354 #ifdef HAVE_BUTTON_LIGHT
355 &buttonlight_timeout
,
357 #ifdef HAVE_BUTTONLIGHT_BRIGHTNESS
358 &buttonlight_brightness
,
360 #if CONFIG_CODEC == SWCODEC
363 #ifdef HAVE_TOUCHPAD_SENSITIVITY_SETTING
364 &touchpad_sensitivity
,
366 #ifdef USB_ENABLE_HID
370 #if defined(USB_ENABLE_STORAGE) && defined(HAVE_MULTIDRIVE)
371 &usb_skip_first_drive
,
376 /***********************************/
378 /***********************************/
379 /* STARTUP/SHUTDOWN MENU */
381 /* sleep timer option */
382 const char* sleep_timer_formatter(char* buffer
, size_t buffer_size
,
383 int value
, const char* unit
)
390 minutes
= value
- (hours
* 60);
391 snprintf(buffer
, buffer_size
, "%d:%02d", hours
, minutes
);
394 return str(LANG_OFF
);
398 static int seconds_to_min(int secs
)
400 return (secs
+ 10) / 60; /* round up for 50+ seconds */
403 /* A string representation of either whether a sleep timer will be started or
404 canceled, and how long it will be or how long is remaining in brackets */
405 static char* sleep_timer_getname(int selected_item
, void * data
, char *buffer
)
409 int sec
= get_sleep_timer();
411 /* we have no sprintf, so MAX_PATH is a guess */
412 snprintf(buffer
, MAX_PATH
, "%s (%s)",
413 str(sec
? LANG_SLEEP_TIMER_CANCEL_CURRENT
414 : LANG_SLEEP_TIMER_START_CURRENT
),
415 sleep_timer_formatter(timer_buf
, sizeof(timer_buf
),
416 sec
? seconds_to_min(sec
)
417 : global_settings
.sleeptimer_duration
, NULL
));
421 static int sleep_timer_voice(int selected_item
, void*data
)
425 int seconds
= get_sleep_timer();
427 seconds
? LANG_SLEEP_TIMER_CANCEL_CURRENT
428 : LANG_SLEEP_TIMER_START_CURRENT
,
430 (seconds
? seconds_to_min(seconds
)
431 : global_settings
.sleeptimer_duration
) | UNIT_MIN
<< UNIT_SHIFT
,
434 talk_idarray(talk_ids
, true);
438 /* If a sleep timer is running, cancel it, otherwise start one */
439 static int toggle_sleeptimer(void)
441 set_sleeptimer_duration(get_sleep_timer() ? 0
442 : global_settings
.sleeptimer_duration
);
446 /* Handle restarting a current sleep timer to the newly set default
448 static int sleeptimer_duration_cb(int action
,
449 const struct menu_item_ex
*this_item
)
452 static int initial_duration
;
455 case ACTION_ENTER_MENUITEM
:
456 initial_duration
= global_settings
.sleeptimer_duration
;
458 case ACTION_EXIT_MENUITEM
:
459 if (initial_duration
!= global_settings
.sleeptimer_duration
460 && get_sleep_timer())
461 set_sleeptimer_duration(global_settings
.sleeptimer_duration
);
466 MENUITEM_SETTING(start_screen
, &global_settings
.start_in_screen
, NULL
);
467 MENUITEM_SETTING(poweroff
, &global_settings
.poweroff
, NULL
);
468 MENUITEM_FUNCTION_DYNTEXT(sleeptimer_toggle
, 0, toggle_sleeptimer
, NULL
,
469 sleep_timer_getname
, sleep_timer_voice
, NULL
,
471 MENUITEM_SETTING(sleeptimer_duration
,
472 &global_settings
.sleeptimer_duration
,
473 sleeptimer_duration_cb
);
474 MENUITEM_SETTING(sleeptimer_on_startup
,
475 &global_settings
.sleeptimer_on_startup
, NULL
);
476 MENUITEM_SETTING(keypress_restarts_sleeptimer
,
477 &global_settings
.keypress_restarts_sleeptimer
, NULL
);
479 MAKE_MENU(startup_shutdown_menu
, ID2P(LANG_STARTUP_SHUTDOWN
),
484 &sleeptimer_duration
,
485 &sleeptimer_on_startup
,
486 &keypress_restarts_sleeptimer
489 /* STARTUP/SHUTDOWN MENU */
490 /***********************************/
492 /***********************************/
494 static int bmark_callback(int action
,const struct menu_item_ex
*this_item
)
499 case ACTION_EXIT_MENUITEM
: /* on exit */
500 if(global_settings
.autocreatebookmark
== BOOKMARK_RECENT_ONLY_YES
||
501 global_settings
.autocreatebookmark
== BOOKMARK_RECENT_ONLY_ASK
)
503 if(global_settings
.usemrb
== BOOKMARK_NO
)
504 global_settings
.usemrb
= BOOKMARK_YES
;
511 MENUITEM_SETTING(autocreatebookmark
,
512 &global_settings
.autocreatebookmark
, bmark_callback
);
513 MENUITEM_SETTING(autoupdatebookmark
, &global_settings
.autoupdatebookmark
, NULL
);
514 MENUITEM_SETTING(autoloadbookmark
, &global_settings
.autoloadbookmark
, NULL
);
515 MENUITEM_SETTING(usemrb
, &global_settings
.usemrb
, NULL
);
516 MAKE_MENU(bookmark_settings_menu
, ID2P(LANG_BOOKMARK_SETTINGS
), 0,
518 &autocreatebookmark
, &autoupdatebookmark
, &autoloadbookmark
, &usemrb
);
520 /***********************************/
522 /***********************************/
523 /* AUTORESUME MENU */
525 #if CONFIG_CODEC == SWCODEC
527 static int autoresume_callback(int action
, const struct menu_item_ex
*this_item
)
531 if (action
== ACTION_EXIT_MENUITEM
/* on exit */
532 && global_settings
.autoresume_enable
533 && !tagcache_is_usable())
535 static const char *lines
[] = {ID2P(LANG_TAGCACHE_BUSY
),
536 ID2P(LANG_TAGCACHE_FORCE_UPDATE
)};
537 static const struct text_message message
= {lines
, 2};
539 if (gui_syncyesno_run(&message
, NULL
, NULL
) == YESNO_YES
)
540 tagcache_rebuild_with_splash();
545 static int autoresume_nexttrack_callback(int action
,
546 const struct menu_item_ex
*this_item
)
549 static int oldval
= 0;
552 case ACTION_ENTER_MENUITEM
:
553 oldval
= global_settings
.autoresume_automatic
;
555 case ACTION_EXIT_MENUITEM
:
556 if (global_settings
.autoresume_automatic
== AUTORESUME_NEXTTRACK_CUSTOM
557 && !folder_select(global_settings
.autoresume_paths
,
560 global_settings
.autoresume_automatic
= oldval
;
566 MENUITEM_SETTING(autoresume_enable
, &global_settings
.autoresume_enable
,
567 autoresume_callback
);
568 MENUITEM_SETTING(autoresume_automatic
, &global_settings
.autoresume_automatic
,
569 autoresume_nexttrack_callback
);
571 MAKE_MENU(autoresume_menu
, ID2P(LANG_AUTORESUME
),
573 &autoresume_enable
, &autoresume_automatic
);
575 #endif /* CONFIG_CODEC == SWCODEC */
576 #endif /* HAVE_TAGCACHE */
577 /* AUTORESUME MENU */
578 /***********************************/
580 /***********************************/
582 static int talk_callback(int action
,const struct menu_item_ex
*this_item
);
583 MENUITEM_SETTING(talk_menu_item
, &global_settings
.talk_menu
, NULL
);
584 MENUITEM_SETTING(talk_dir_item
, &global_settings
.talk_dir
, NULL
);
585 MENUITEM_SETTING(talk_dir_clip_item
, &global_settings
.talk_dir_clip
, talk_callback
);
586 MENUITEM_SETTING(talk_file_item
, &global_settings
.talk_file
, NULL
);
587 MENUITEM_SETTING(talk_file_clip_item
, &global_settings
.talk_file_clip
, talk_callback
);
588 static int talk_callback(int action
,const struct menu_item_ex
*this_item
)
590 static int oldval
= 0;
593 case ACTION_ENTER_MENUITEM
:
594 oldval
= global_settings
.talk_file_clip
;
596 case ACTION_EXIT_MENUITEM
:
597 #ifdef HAVE_CROSSFADE
598 audio_set_crossfade(global_settings
.crossfade
);
600 if (this_item
== &talk_dir_clip_item
)
602 if (!oldval
&& global_settings
.talk_file_clip
)
604 /* force reload if newly talking thumbnails,
605 because the clip presence is cached only if enabled */
612 MENUITEM_SETTING(talk_filetype_item
, &global_settings
.talk_filetype
, NULL
);
613 MENUITEM_SETTING(talk_battery_level_item
,
614 &global_settings
.talk_battery_level
, NULL
);
615 MAKE_MENU(voice_settings_menu
, ID2P(LANG_VOICE
), 0, Icon_Voice
,
616 &talk_menu_item
, &talk_dir_item
, &talk_dir_clip_item
,
617 &talk_file_item
, &talk_file_clip_item
, &talk_filetype_item
,
618 &talk_battery_level_item
);
620 /***********************************/
623 /***********************************/
626 MENUITEM_SETTING(hotkey_wps_item
, &global_settings
.hotkey_wps
, NULL
);
627 MENUITEM_SETTING(hotkey_tree_item
, &global_settings
.hotkey_tree
, NULL
);
628 MAKE_MENU(hotkey_menu
, ID2P(LANG_HOTKEY
), 0, Icon_NOICON
,
629 &hotkey_wps_item
, &hotkey_tree_item
);
630 #endif /*have_hotkey */
632 /***********************************/
635 /***********************************/
638 static struct browse_folder_info langs
= { LANG_DIR
, SHOW_LNG
};
640 MENUITEM_FUNCTION(browse_langs
, MENU_FUNC_USEPARAM
, ID2P(LANG_LANGUAGE
),
641 browse_folder
, (void*)&langs
, NULL
, Icon_Language
);
643 MAKE_MENU(settings_menu_item
, ID2P(LANG_GENERAL_SETTINGS
), 0,
644 Icon_General_settings_menu
,
645 &playlist_settings
, &file_menu
,
649 &display_menu
, &system_menu
,
650 &startup_shutdown_menu
,
651 &bookmark_settings_menu
,
653 #if CONFIG_CODEC == SWCODEC
657 &browse_langs
, &voice_settings_menu
,
663 /***********************************/