Fix another not nice apostrophe (FS#11296)
[kugel-rb.git] / apps / menus / settings_menu.c
blobbcd49c942c7bdac0a18ea67faf92e76bf1b8fecc
1 /***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
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 ****************************************************************************/
22 #include <stdbool.h>
23 #include <stddef.h>
24 #include <limits.h>
25 #include <string.h>
26 #include "config.h"
27 #include "lang.h"
28 #include "action.h"
29 #include "settings.h"
30 #include "menu.h"
31 #include "sound_menu.h"
32 #include "exported_menus.h"
33 #include "tree.h"
34 #include "tagtree.h"
35 #include "usb.h"
36 #include "splash.h"
37 #include "talk.h"
38 #include "powermgmt.h"
39 #if CONFIG_CODEC == SWCODEC
40 #include "playback.h"
41 #endif
42 #if CONFIG_RTC
43 #include "screens.h"
44 #endif
45 #include "quickscreen.h"
46 #ifdef HAVE_DIRCACHE
47 #include "dircache.h"
48 #endif
50 /***********************************/
51 /* TAGCACHE MENU */
52 #ifdef HAVE_TAGCACHE
54 static void tagcache_rebuild_with_splash(void)
56 tagcache_rebuild();
57 splash(HZ*2, ID2P(LANG_TAGCACHE_FORCE_UPDATE_SPLASH));
60 static void tagcache_update_with_splash(void)
62 tagcache_update();
63 splash(HZ*2, ID2P(LANG_TAGCACHE_FORCE_UPDATE_SPLASH));
66 #ifdef HAVE_TC_RAMCACHE
67 MENUITEM_SETTING(tagcache_ram, &global_settings.tagcache_ram, NULL);
68 #endif
69 MENUITEM_SETTING(tagcache_autoupdate, &global_settings.tagcache_autoupdate, NULL);
70 MENUITEM_FUNCTION(tc_init, 0, ID2P(LANG_TAGCACHE_FORCE_UPDATE),
71 (int(*)(void))tagcache_rebuild_with_splash,
72 NULL, NULL, Icon_NOICON);
73 MENUITEM_FUNCTION(tc_update, 0, ID2P(LANG_TAGCACHE_UPDATE),
74 (int(*)(void))tagcache_update_with_splash,
75 NULL, NULL, Icon_NOICON);
76 MENUITEM_SETTING(runtimedb, &global_settings.runtimedb, NULL);
77 MENUITEM_FUNCTION(tc_export, 0, ID2P(LANG_TAGCACHE_EXPORT),
78 (int(*)(void))tagtree_export, NULL,
79 NULL, Icon_NOICON);
80 MENUITEM_FUNCTION(tc_import, 0, ID2P(LANG_TAGCACHE_IMPORT),
81 (int(*)(void))tagtree_import, NULL,
82 NULL, Icon_NOICON);
83 MAKE_MENU(tagcache_menu, ID2P(LANG_TAGCACHE), 0, Icon_NOICON,
84 #ifdef HAVE_TC_RAMCACHE
85 &tagcache_ram,
86 #endif
87 &tagcache_autoupdate, &tc_init, &tc_update, &runtimedb,
88 &tc_export, &tc_import);
89 #endif /* HAVE_TAGCACHE */
90 /* TAGCACHE MENU */
91 /***********************************/
93 /***********************************/
94 /* FILE VIEW MENU */
95 static int fileview_callback(int action,const struct menu_item_ex *this_item);
96 MENUITEM_SETTING(sort_case, &global_settings.sort_case, NULL);
97 MENUITEM_SETTING(sort_dir, &global_settings.sort_dir, fileview_callback);
98 MENUITEM_SETTING(sort_file, &global_settings.sort_file, fileview_callback);
99 MENUITEM_SETTING(interpret_numbers, &global_settings.interpret_numbers, fileview_callback);
100 MENUITEM_SETTING(dirfilter, &global_settings.dirfilter, NULL);
101 MENUITEM_SETTING(show_filename_ext, &global_settings.show_filename_ext, NULL);
102 MENUITEM_SETTING(browse_current, &global_settings.browse_current, NULL);
103 #ifdef HAVE_LCD_BITMAP
104 MENUITEM_SETTING(show_path_in_browser, &global_settings.show_path_in_browser, NULL);
105 #endif
106 static int fileview_callback(int action,const struct menu_item_ex *this_item)
108 static int oldval;
109 int *variable = this_item->variable;
110 switch (action)
112 case ACTION_ENTER_MENUITEM: /* on entering an item */
113 oldval = *variable;
114 break;
115 case ACTION_EXIT_MENUITEM: /* on exit */
116 if (*variable != oldval)
117 reload_directory(); /* force reload if this has changed */
118 break;
120 return action;
123 MAKE_MENU(file_menu, ID2P(LANG_FILE), 0, Icon_file_view_menu,
124 &sort_case, &sort_dir, &sort_file, &interpret_numbers,
125 &dirfilter, &show_filename_ext, &browse_current,
126 #ifdef HAVE_LCD_BITMAP
127 &show_path_in_browser
128 #endif
130 /* FILE VIEW MENU */
131 /***********************************/
134 /***********************************/
135 /* SYSTEM MENU */
137 /* Battery */
138 #if BATTERY_CAPACITY_INC > 0
139 MENUITEM_SETTING(battery_capacity, &global_settings.battery_capacity, NULL);
140 #endif
141 #if BATTERY_TYPES_COUNT > 1
142 MENUITEM_SETTING(battery_type, &global_settings.battery_type, NULL);
143 #endif
144 #ifdef HAVE_USB_CHARGING_ENABLE
145 static int usbcharging_callback(int action,const struct menu_item_ex *this_item)
147 (void)this_item;
148 switch (action)
150 case ACTION_EXIT_MENUITEM: /* on exit */
151 usb_charging_enable(global_settings.usb_charging);
152 break;
154 return action;
156 MENUITEM_SETTING(usb_charging, &global_settings.usb_charging, usbcharging_callback);
157 #endif /* HAVE_USB_CHARGING_ENABLE */
158 MAKE_MENU(battery_menu, ID2P(LANG_BATTERY_MENU), 0, Icon_NOICON,
159 #if BATTERY_CAPACITY_INC > 0
160 &battery_capacity,
161 #endif
162 #if BATTERY_TYPES_COUNT > 1
163 &battery_type,
164 #endif
165 #ifdef HAVE_USB_CHARGING_ENABLE
166 &usb_charging,
167 #endif
169 /* Disk */
170 #ifdef HAVE_DISK_STORAGE
171 MENUITEM_SETTING(disk_spindown, &global_settings.disk_spindown, NULL);
172 #endif
173 #ifdef HAVE_DIRCACHE
174 static int dircache_callback(int action,const struct menu_item_ex *this_item)
176 (void)this_item;
177 switch (action)
179 case ACTION_EXIT_MENUITEM: /* on exit */
180 switch (global_settings.dircache)
182 case true:
183 if (!dircache_is_enabled())
184 splash(HZ*2, ID2P(LANG_PLEASE_REBOOT));
185 break;
186 case false:
187 if (dircache_is_enabled())
188 dircache_disable();
189 break;
191 break;
193 return action;
195 MENUITEM_SETTING(dircache, &global_settings.dircache, dircache_callback);
196 #endif
197 #if defined(HAVE_DIRCACHE) || defined(HAVE_DISK_STORAGE)
198 MAKE_MENU(disk_menu, ID2P(LANG_DISK_MENU), 0, Icon_NOICON,
199 #ifdef HAVE_DISK_STORAGE
200 &disk_spindown,
201 #endif
202 #ifdef HAVE_DIRCACHE
203 &dircache,
204 #endif
206 #endif
208 /* System menu */
209 MENUITEM_SETTING(poweroff, &global_settings.poweroff, NULL);
211 /* Limits menu */
212 MENUITEM_SETTING(max_files_in_dir, &global_settings.max_files_in_dir, NULL);
213 MENUITEM_SETTING(max_files_in_playlist, &global_settings.max_files_in_playlist, NULL);
214 MAKE_MENU(limits_menu, ID2P(LANG_LIMITS_MENU), 0, Icon_NOICON,
215 &max_files_in_dir, &max_files_in_playlist);
218 /* Keyclick menu */
219 #if CONFIG_CODEC == SWCODEC
220 MENUITEM_SETTING(keyclick, &global_settings.keyclick, NULL);
221 MENUITEM_SETTING(keyclick_repeats, &global_settings.keyclick_repeats, NULL);
222 MAKE_MENU(keyclick_menu, ID2P(LANG_KEYCLICK), 0, Icon_NOICON,
223 &keyclick, &keyclick_repeats);
224 #endif
227 #if CONFIG_CODEC == MAS3507D
228 void dac_line_in(bool enable);
229 static int linein_callback(int action,const struct menu_item_ex *this_item)
231 (void)this_item;
232 switch (action)
234 case ACTION_EXIT_MENUITEM: /* on exit */
235 #ifndef SIMULATOR
236 dac_line_in(global_settings.line_in);
237 #endif
238 break;
240 return action;
242 MENUITEM_SETTING(line_in, &global_settings.line_in, linein_callback);
243 #endif
244 #if CONFIG_CHARGING
245 MENUITEM_SETTING(car_adapter_mode, &global_settings.car_adapter_mode, NULL);
246 #endif
247 #ifdef IPOD_ACCESSORY_PROTOCOL
248 MENUITEM_SETTING(serial_bitrate, &global_settings.serial_bitrate, NULL);
249 #endif
250 #ifdef HAVE_ACCESSORY_SUPPLY
251 MENUITEM_SETTING(accessory_supply, &global_settings.accessory_supply, NULL);
252 #endif
253 #ifdef HAVE_LINEOUT_POWEROFF
254 MENUITEM_SETTING(lineout_onoff, &global_settings.lineout_active, NULL);
255 #endif
256 MENUITEM_SETTING(start_screen, &global_settings.start_in_screen, NULL);
257 #ifdef USB_ENABLE_HID
258 MENUITEM_SETTING(usb_hid, &global_settings.usb_hid, NULL);
259 MENUITEM_SETTING(usb_keypad_mode, &global_settings.usb_keypad_mode, NULL);
260 #endif
262 #ifdef HAVE_MORSE_INPUT
263 MENUITEM_SETTING(morse_input, &global_settings.morse_input, NULL);
264 #endif
266 #ifdef HAVE_BUTTON_LIGHT
267 MENUITEM_SETTING(buttonlight_timeout, &global_settings.buttonlight_timeout, NULL);
268 #endif
270 #ifdef HAVE_BUTTONLIGHT_BRIGHTNESS
271 MENUITEM_SETTING(buttonlight_brightness, &global_settings.buttonlight_brightness, NULL);
272 #endif
274 #ifdef HAVE_TOUCHPAD_SENSITIVITY_SETTING
275 MENUITEM_SETTING(touchpad_sensitivity, &global_settings.touchpad_sensitivity, NULL);
276 #endif
278 MAKE_MENU(system_menu, ID2P(LANG_SYSTEM),
279 0, Icon_System_menu,
280 &start_screen,
281 #if (BATTERY_CAPACITY_INC > 0) || (BATTERY_TYPES_COUNT > 1)
282 &battery_menu,
283 #endif
284 #if defined(HAVE_DIRCACHE) || defined(HAVE_DISK_STORAGE)
285 &disk_menu,
286 #endif
287 &poweroff,
288 &limits_menu,
289 #ifdef HAVE_MORSE_INPUT
290 &morse_input,
291 #endif
292 #if CONFIG_CODEC == MAS3507D
293 &line_in,
294 #endif
295 #if CONFIG_CHARGING
296 &car_adapter_mode,
297 #endif
298 #ifdef IPOD_ACCESSORY_PROTOCOL
299 &serial_bitrate,
300 #endif
301 #ifdef HAVE_ACCESSORY_SUPPLY
302 &accessory_supply,
303 #endif
304 #ifdef HAVE_LINEOUT_POWEROFF
305 &lineout_onoff,
306 #endif
307 #ifdef HAVE_BUTTON_LIGHT
308 &buttonlight_timeout,
309 #endif
310 #ifdef HAVE_BUTTONLIGHT_BRIGHTNESS
311 &buttonlight_brightness,
312 #endif
313 #if CONFIG_CODEC == SWCODEC
314 &keyclick_menu,
315 #endif
316 #ifdef HAVE_TOUCHPAD_SENSITIVITY_SETTING
317 &touchpad_sensitivity,
318 #endif
319 #ifdef USB_ENABLE_HID
320 &usb_hid,
321 &usb_keypad_mode,
322 #endif
325 /* SYSTEM MENU */
326 /***********************************/
329 /***********************************/
330 /* BOOKMARK MENU */
331 static int bmark_callback(int action,const struct menu_item_ex *this_item)
333 (void)this_item;
334 switch (action)
336 case ACTION_EXIT_MENUITEM: /* on exit */
337 if(global_settings.autocreatebookmark == BOOKMARK_RECENT_ONLY_YES ||
338 global_settings.autocreatebookmark == BOOKMARK_RECENT_ONLY_ASK)
340 if(global_settings.usemrb == BOOKMARK_NO)
341 global_settings.usemrb = BOOKMARK_YES;
344 break;
346 return action;
348 MENUITEM_SETTING(autocreatebookmark,
349 &global_settings.autocreatebookmark, bmark_callback);
350 MENUITEM_SETTING(autoloadbookmark, &global_settings.autoloadbookmark, NULL);
351 MENUITEM_SETTING(usemrb, &global_settings.usemrb, NULL);
352 MAKE_MENU(bookmark_settings_menu, ID2P(LANG_BOOKMARK_SETTINGS), 0,
353 Icon_Bookmark,
354 &autocreatebookmark, &autoloadbookmark, &usemrb);
355 /* BOOKMARK MENU */
356 /***********************************/
358 /***********************************/
359 /* VOICE MENU */
360 static int talk_callback(int action,const struct menu_item_ex *this_item);
361 MENUITEM_SETTING(talk_menu_item, &global_settings.talk_menu, NULL);
362 MENUITEM_SETTING(talk_dir_item, &global_settings.talk_dir, NULL);
363 MENUITEM_SETTING(talk_dir_clip_item, &global_settings.talk_dir_clip, talk_callback);
364 MENUITEM_SETTING(talk_file_item, &global_settings.talk_file, NULL);
365 MENUITEM_SETTING(talk_file_clip_item, &global_settings.talk_file_clip, talk_callback);
366 static int talk_callback(int action,const struct menu_item_ex *this_item)
368 static int oldval = 0;
369 switch (action)
371 case ACTION_ENTER_MENUITEM:
372 oldval = global_settings.talk_file_clip;
373 break;
374 case ACTION_EXIT_MENUITEM:
375 #ifdef HAVE_CROSSFADE
376 audio_set_crossfade(global_settings.crossfade);
377 #endif
378 if (this_item == &talk_dir_clip_item)
379 break;
380 if (!oldval && global_settings.talk_file_clip)
382 /* force reload if newly talking thumbnails,
383 because the clip presence is cached only if enabled */
384 reload_directory();
386 break;
388 return action;
390 MENUITEM_SETTING(talk_filetype_item, &global_settings.talk_filetype, NULL);
391 MENUITEM_SETTING(talk_battery_level_item,
392 &global_settings.talk_battery_level, NULL);
393 MAKE_MENU(voice_settings_menu, ID2P(LANG_VOICE), 0, Icon_Voice,
394 &talk_menu_item, &talk_dir_item, &talk_dir_clip_item,
395 &talk_file_item, &talk_file_clip_item, &talk_filetype_item,
396 &talk_battery_level_item);
397 /* VOICE MENU */
398 /***********************************/
401 /***********************************/
402 /* HOTKEY MENU */
403 #ifdef HAVE_HOTKEY
404 MENUITEM_SETTING(hotkey_wps_item, &global_settings.hotkey_wps, NULL);
405 MENUITEM_SETTING(hotkey_tree_item, &global_settings.hotkey_tree, NULL);
406 MAKE_MENU(hotkey_menu, ID2P(LANG_HOTKEY), 0, Icon_NOICON,
407 &hotkey_wps_item, &hotkey_tree_item);
408 #endif /*have_hotkey */
409 /* HOTKEY MENU */
410 /***********************************/
413 /***********************************/
414 /* SETTINGS MENU */
415 static int language_browse(void)
417 return (int)rockbox_browse(LANG_DIR, SHOW_LNG);
419 MENUITEM_FUNCTION(browse_langs, 0, ID2P(LANG_LANGUAGE), language_browse,
420 NULL, NULL, Icon_Language);
422 MAKE_MENU(settings_menu_item, ID2P(LANG_GENERAL_SETTINGS), 0,
423 Icon_General_settings_menu,
424 &playlist_settings, &file_menu,
425 #ifdef HAVE_TAGCACHE
426 &tagcache_menu,
427 #endif
428 &display_menu, &system_menu,
429 &bookmark_settings_menu, &browse_langs, &voice_settings_menu,
430 #ifdef HAVE_HOTKEY
431 &hotkey_menu,
432 #endif
434 /* SETTINGS MENU */
435 /***********************************/