summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--apps/lang/english.lang14
-rw-r--r--apps/settings.c49
-rw-r--r--apps/settings.h6
-rw-r--r--apps/settings_list.c21
-rw-r--r--apps/settings_list.h4
-rw-r--r--apps/settings_menu.c11
6 files changed, 89 insertions, 16 deletions
diff --git a/apps/lang/english.lang b/apps/lang/english.lang
index e9c9f4c50c..83cbe0e98f 100644
--- a/apps/lang/english.lang
+++ b/apps/lang/english.lang
@@ -10473,3 +10473,17 @@
10473 *: "Play Next" 10473 *: "Play Next"
10474 </voice> 10474 </voice>
10475</phrase> 10475</phrase>
10476<phrase>
10477 id: LANG_SAVE_THEME
10478 desc: save a theme file
10479 user:
10480 <source>
10481 *: "Save Theme Settings"
10482 </source>
10483 <dest>
10484 *: "Save Theme Settings"
10485 </dest>
10486 <voice>
10487 *: "Save Theme Settings"
10488 </voice>
10489</phrase>
diff --git a/apps/settings.c b/apps/settings.c
index faf1f92773..f0833a65c2 100644
--- a/apps/settings.c
+++ b/apps/settings.c
@@ -402,8 +402,41 @@ static bool cfg_int_to_string(int setting_id, int val, char* buf)
402 } 402 }
403 return true; 403 return true;
404} 404}
405static bool is_changed(int setting_id)
406{
407 const struct settings_list *setting = &settings[setting_id];
408 switch (setting->flags&F_T_MASK)
409 {
410 case F_T_INT:
411 case F_T_UINT:
412 if (setting->flags&F_DEF_ISFUNC)
413 {
414 if (*(int*)setting->setting == setting->default_val.func())
415 return false;
416 }
417 else if (setting->flags&F_T_SOUND)
418 {
419 if (*(int*)setting->setting ==
420 sound_default(setting->sound_setting->setting))
421 return false;
422 }
423 else if (*(int*)setting->setting == setting->default_val.int_)
424 return false;
425 break;
426 case F_T_BOOL:
427 if (*(bool*)setting->setting == setting->default_val.bool_)
428 return false;
429 break;
430 case F_T_CHARPTR:
431 case F_T_UCHARPTR:
432 if (!strcmp((char*)setting->setting, setting->default_val.charptr))
433 return false;
434 break;
435 }
436 return true;
437}
405 438
406bool settings_write_config(char* filename) 439static bool settings_write_config(char* filename, int options)
407{ 440{
408 int i; 441 int i;
409 int fd; 442 int fd;
@@ -418,6 +451,14 @@ bool settings_write_config(char* filename)
418 if (settings[i].cfg_name == NULL) 451 if (settings[i].cfg_name == NULL)
419 continue; 452 continue;
420 value[0] = '\0'; 453 value[0] = '\0';
454
455 if ((options == SETTINGS_SAVE_CHANGED) &&
456 !is_changed(i))
457 continue;
458 else if ((options == SETTINGS_SAVE_THEME) &&
459 ((settings[i].flags&F_THEMESETTING) == 0))
460 continue;
461
421 switch (settings[i].flags&F_T_MASK) 462 switch (settings[i].flags&F_T_MASK)
422 { 463 {
423 case F_T_INT: 464 case F_T_INT:
@@ -477,7 +518,7 @@ static bool flush_config_block_callback(void)
477{ 518{
478 bool r1, r2; 519 bool r1, r2;
479 r1 = write_nvram_data(nvram_buffer,NVRAM_BLOCK_SIZE); 520 r1 = write_nvram_data(nvram_buffer,NVRAM_BLOCK_SIZE);
480 r2 = settings_write_config(CONFIGFILE); 521 r2 = settings_write_config(CONFIGFILE, SETTINGS_SAVE_CHANGED);
481 return r1 || r2; 522 return r1 || r2;
482} 523}
483 524
@@ -536,7 +577,7 @@ int settings_save( void )
536 } 577 }
537 return 0; 578 return 0;
538} 579}
539bool settings_save_config(void) 580bool settings_save_config(int options)
540{ 581{
541 char filename[MAX_PATH]; 582 char filename[MAX_PATH];
542 583
@@ -554,7 +595,7 @@ bool settings_save_config(void)
554 } 595 }
555 } 596 }
556 597
557 if (settings_write_config(filename)) 598 if (settings_write_config(filename, options))
558 gui_syncsplash(HZ, true, str(LANG_SETTINGS_SAVED)); 599 gui_syncsplash(HZ, true, str(LANG_SETTINGS_SAVED));
559 else gui_syncsplash(HZ, true, str(LANG_FAILED)); 600 else gui_syncsplash(HZ, true, str(LANG_FAILED));
560 return true; 601 return true;
diff --git a/apps/settings.h b/apps/settings.h
index e8db3289a1..ea3df8ef79 100644
--- a/apps/settings.h
+++ b/apps/settings.h
@@ -206,7 +206,11 @@ bool settings_load_config(const char* file, bool apply);
206 206
207void status_save( void ); 207void status_save( void );
208int settings_save(void); 208int settings_save(void);
209bool settings_save_config(void); 209/* defines for the options paramater */
210#define SETTINGS_SAVE_CHANGED 0
211#define SETTINGS_SAVE_ALL 1
212#define SETTINGS_SAVE_THEME 2
213bool settings_save_config(int options);
210 214
211void settings_reset(void); 215void settings_reset(void);
212void sound_settings_apply(void); 216void sound_settings_apply(void);
diff --git a/apps/settings_list.c b/apps/settings_list.c
index 6243607264..f9ef383f85 100644
--- a/apps/settings_list.c
+++ b/apps/settings_list.c
@@ -155,7 +155,7 @@ const struct settings_list settings[] = {
155 /* display */ 155 /* display */
156 OFFON_SETTING(0,invert_cursor, LANG_INVERT_CURSOR, 156 OFFON_SETTING(0,invert_cursor, LANG_INVERT_CURSOR,
157 true,"invert cursor", NULL), 157 true,"invert cursor", NULL),
158 OFFON_SETTING(0,statusbar, LANG_STATUS_BAR, true,"statusbar", NULL), 158 OFFON_SETTING(F_THEMESETTING,statusbar, LANG_STATUS_BAR, true,"statusbar", NULL),
159 OFFON_SETTING(0,scrollbar, LANG_SCROLL_BAR, true,"scrollbar", NULL), 159 OFFON_SETTING(0,scrollbar, LANG_SCROLL_BAR, true,"scrollbar", NULL),
160#if CONFIG_KEYPAD == RECORDER_PAD 160#if CONFIG_KEYPAD == RECORDER_PAD
161 OFFON_SETTING(0,buttonbar, LANG_BUTTON_BAR ,true,"buttonbar", NULL), 161 OFFON_SETTING(0,buttonbar, LANG_BUTTON_BAR ,true,"buttonbar", NULL),
@@ -287,9 +287,9 @@ const struct settings_list settings[] = {
287 OFFON_SETTING(0,scroll_paginated,LANG_SCROLL_PAGINATED, 287 OFFON_SETTING(0,scroll_paginated,LANG_SCROLL_PAGINATED,
288 false,"scroll paginated",NULL), 288 false,"scroll paginated",NULL),
289#ifdef HAVE_LCD_COLOR 289#ifdef HAVE_LCD_COLOR
290 {F_T_INT|F_RGB,GS(fg_color),-1,INT(LCD_DEFAULT_FG), 290 {F_T_INT|F_RGB|F_THEMESETTING ,GS(fg_color),-1,INT(LCD_DEFAULT_FG),
291 "foreground color",NULL,UNUSED}, 291 "foreground color",NULL,UNUSED},
292 {F_T_INT|F_RGB,GS(bg_color),-1,INT(LCD_DEFAULT_BG), 292 {F_T_INT|F_RGB|F_THEMESETTING ,GS(bg_color),-1,INT(LCD_DEFAULT_BG),
293 "background color",NULL,UNUSED}, 293 "background color",NULL,UNUSED},
294#endif 294#endif
295 /* more playback */ 295 /* more playback */
@@ -676,16 +676,21 @@ const struct settings_list settings[] = {
676 676
677 /** settings not in the old config blocks **/ 677 /** settings not in the old config blocks **/
678#ifdef CONFIG_TUNER 678#ifdef CONFIG_TUNER
679 FILENAME_SETTING(0,fmr_file,"fmr","",FMPRESET_PATH "/",".fmr",MAX_FILENAME+1), 679 FILENAME_SETTING(F_THEMESETTING, fmr_file, "fmr",
680 "", FMPRESET_PATH "/", ".fmr", MAX_FILENAME+1),
680#endif 681#endif
681 FILENAME_SETTING(0,font_file,"font","",FONT_DIR "/",".fnt",MAX_FILENAME+1), 682 FILENAME_SETTING(F_THEMESETTING, font_file, "font",
682 FILENAME_SETTING(0,wps_file, "wps","",WPS_DIR "/",".wps",MAX_FILENAME+1), 683 "", FONT_DIR "/", ".fnt", MAX_FILENAME+1),
684 FILENAME_SETTING(F_THEMESETTING,wps_file, "wps",
685 "", WPS_DIR "/", ".wps", MAX_FILENAME+1),
683 FILENAME_SETTING(0,lang_file,"lang","",LANG_DIR "/",".lng",MAX_FILENAME+1), 686 FILENAME_SETTING(0,lang_file,"lang","",LANG_DIR "/",".lng",MAX_FILENAME+1),
684#ifdef HAVE_REMOTE_LCD 687#ifdef HAVE_REMOTE_LCD
685 FILENAME_SETTING(0,rwps_file,"rwps","",WPS_DIR "/",".rwps",MAX_FILENAME+1), 688 FILENAME_SETTING(F_THEMESETTING,rwps_file,"rwps",
689 "", WPS_DIR "/", ".rwps", MAX_FILENAME+1),
686#endif 690#endif
687#if LCD_DEPTH > 1 691#if LCD_DEPTH > 1
688 FILENAME_SETTING(0,backdrop_file,"backdrop","",BACKDROP_DIR "/",".bmp",MAX_FILENAME+1), 692 FILENAME_SETTING(F_THEMESETTING,backdrop_file,"backdrop",
693 "", BACKDROP_DIR "/", ".bmp", MAX_FILENAME+1),
689#endif 694#endif
690#ifdef HAVE_LCD_BITMAP 695#ifdef HAVE_LCD_BITMAP
691 FILENAME_SETTING(0,kbd_file,"kbd","",ROCKBOX_DIR "/",".kbd",MAX_FILENAME+1), 696 FILENAME_SETTING(0,kbd_file,"kbd","",ROCKBOX_DIR "/",".kbd",MAX_FILENAME+1),
diff --git a/apps/settings_list.h b/apps/settings_list.h
index 9e50b85f09..195703bfe3 100644
--- a/apps/settings_list.h
+++ b/apps/settings_list.h
@@ -83,10 +83,10 @@ struct int_setting {
83- number of bytes for a NVRAM setting is changed 83- number of bytes for a NVRAM setting is changed
84- a NVRAM setting is removed 84- a NVRAM setting is removed
85*/ 85*/
86 86#define F_THEMESETTING 0x800000
87 87
88struct settings_list { 88struct settings_list {
89 uint32_t flags; /* ____ ____ _FFF ____ ____ NNN_ IFRB STTT */ 89 uint32_t flags; /* ____ ____ TFFF ____ ____ NNN_ IFRB STTT */
90 void *setting; 90 void *setting;
91 int lang_id; /* -1 for none */ 91 int lang_id; /* -1 for none */
92 union storage_type default_val; 92 union storage_type default_val;
diff --git a/apps/settings_menu.c b/apps/settings_menu.c
index b1204e2c1a..8e6fbd02d7 100644
--- a/apps/settings_menu.c
+++ b/apps/settings_menu.c
@@ -2161,6 +2161,14 @@ static bool time_settings_menu(void)
2161 return result; 2161 return result;
2162} 2162}
2163#endif 2163#endif
2164static bool manage_settings_write_config(void)
2165{
2166 return settings_save_config(SETTINGS_SAVE_ALL);
2167}
2168static bool manage_settings_write_theme(void)
2169{
2170 return settings_save_config(SETTINGS_SAVE_THEME);
2171}
2164 2172
2165bool manage_settings_menu(void) 2173bool manage_settings_menu(void)
2166{ 2174{
@@ -2170,7 +2178,8 @@ bool manage_settings_menu(void)
2170 static const struct menu_item items[] = { 2178 static const struct menu_item items[] = {
2171 { ID2P(LANG_CUSTOM_CFG), custom_cfg_browse }, 2179 { ID2P(LANG_CUSTOM_CFG), custom_cfg_browse },
2172 { ID2P(LANG_RESET), reset_settings }, 2180 { ID2P(LANG_RESET), reset_settings },
2173 { ID2P(LANG_SAVE_SETTINGS), settings_save_config }, 2181 { ID2P(LANG_SAVE_SETTINGS), manage_settings_write_config},
2182 { ID2P(LANG_SAVE_THEME), manage_settings_write_theme},
2174 }; 2183 };
2175 2184
2176 m=menu_init( items, sizeof(items) / sizeof(*items), NULL, 2185 m=menu_init( items, sizeof(items) / sizeof(*items), NULL,