1 /* 2 * Copyright 2002-2010, Haiku, Inc. 3 * Distributed under the terms of the MIT license. 4 * 5 * Authors: 6 * Oliver Siebenmarck 7 * Axel Dörfler 8 */ 9 10 11 #include "DataTranslationsSettings.h" 12 13 #include <Application.h> 14 #include <FindDirectory.h> 15 #include <File.h> 16 #include <Path.h> 17 #include <Message.h> 18 19 #include <stdio.h> 20 21 22 DataTranslationsSettings::DataTranslationsSettings() 23 { 24 BPath path; 25 if (find_directory(B_USER_SETTINGS_DIRECTORY, &path) != B_OK) 26 return; 27 28 fCorner = BPoint(-1, -1); 29 30 path.Append("system/DataTranslations settings"); 31 BFile file(path.Path(), B_READ_ONLY); 32 BMessage settings; 33 34 if (file.InitCheck() == B_OK 35 && settings.Unflatten(&file) == B_OK) { 36 BPoint corner; 37 if (settings.FindPoint("window corner", &corner) == B_OK) 38 fCorner = corner; 39 } 40 } 41 42 43 DataTranslationsSettings::~DataTranslationsSettings() 44 { 45 BPath path; 46 if (find_directory(B_USER_SETTINGS_DIRECTORY, &path) < B_OK) 47 return; 48 49 BMessage settings; 50 settings.AddPoint("window corner", fCorner); 51 52 path.Append("system/DataTranslations settings"); 53 BFile file(path.Path(), B_WRITE_ONLY | B_CREATE_FILE | B_ERASE_FILE); 54 if (file.InitCheck() == B_OK) 55 settings.Flatten(&file); 56 } 57 58 59 void 60 DataTranslationsSettings::SetWindowCorner(BPoint corner) 61 { 62 fCorner = corner; 63 } 64