No longer annoys the user if there was no settings file (it asked to configure

the settings in that case...).


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@15728 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler
2005-12-29 18:30:35 +00:00
parent 27a00cdd92
commit c016311bca
@@ -125,14 +125,15 @@ SettingsChangedAlert()
// and user wants to run settings // and user wants to run settings
if (!gAreSettingsRunning if (!gAreSettingsRunning
&& (new BAlert("Different settings file", && (new BAlert("Different settings file",
"JPEG settings were set to default because of incompatible settings file.", "JPEG settings were set to default because of incompatible settings file.",
"Configure settings", "OK", NULL, B_WIDTH_AS_USUAL, "Configure settings", "OK", NULL, B_WIDTH_AS_USUAL,
B_WARNING_ALERT))->Go() == 0) { B_WARNING_ALERT))->Go() == 0) {
// Create settings window (with no quit on close!), launch // Create settings window (with no quit on close!), launch
// it and wait until it's closed // it and wait until it's closed
status_t err;
TranslatorWindow *window = new TranslatorWindow(false); TranslatorWindow *window = new TranslatorWindow(false);
window->Show(); window->Show();
status_t err;
wait_for_thread(window->Thread(), &err); wait_for_thread(window->Thread(), &err);
return true; return true;
} }
@@ -158,8 +159,8 @@ LoadSettings(jpeg_settings *settings)
// Open settings file (create it if there's no file) and write settings // Open settings file (create it if there's no file) and write settings
FILE *file = NULL; FILE *file = NULL;
if ((file = fopen( path.Path(), "rb"))) { if ((file = fopen(path.Path(), "rb")) != NULL) {
if ( !fread(settings, sizeof(jpeg_settings), 1, file)) { if (!fread(settings, sizeof(jpeg_settings), 1, file)) {
// settings struct has changed size // settings struct has changed size
// Load default settings, and Save them // Load default settings, and Save them
fclose(file); fclose(file);
@@ -171,14 +172,10 @@ LoadSettings(jpeg_settings *settings)
LoadSettings(settings); LoadSettings(settings);
} else } else
fclose(file); fclose(file);
} else if ((file = fopen( path.Path(), "wb+"))) { } else if ((file = fopen(path.Path(), "wb+")) != NULL) {
LoadDefaultSettings(settings); LoadDefaultSettings(settings);
fwrite(settings, sizeof(jpeg_settings), 1, file); fwrite(settings, sizeof(jpeg_settings), 1, file);
fclose(file); fclose(file);
// Tell user settings were changed to default, and ask to run settings panel or not
if (SettingsChangedAlert())
// User configured settings, load them again
LoadSettings(settings);
} }
} }