summaryrefslogtreecommitdiff
path: root/apps/settings.c
diff options
context:
space:
mode:
Diffstat (limited to 'apps/settings.c')
-rw-r--r--apps/settings.c49
1 files changed, 45 insertions, 4 deletions
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;