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 <stdio.h> 14 15 #include <Application.h> 16 #include <File.h> 17 #include <FindDirectory.h> 18 #include <Message.h> 19 #include <Path.h> 20 21 22 static DataTranslationsSettings sDataTranslationsSettings; 23 24 DataTranslationsSettings()25DataTranslationsSettings::DataTranslationsSettings() 26 { 27 BPath path; 28 if (find_directory(B_USER_SETTINGS_DIRECTORY, &path) != B_OK) 29 return; 30 31 fCorner = BPoint(-1, -1); 32 33 path.Append("system/DataTranslations settings"); 34 BFile file(path.Path(), B_READ_ONLY); 35 BMessage settings; 36 37 if (file.InitCheck() == B_OK 38 && settings.Unflatten(&file) == B_OK) { 39 BPoint corner; 40 if (settings.FindPoint("window corner", &corner) == B_OK) 41 fCorner = corner; 42 } 43 } 44 45 ~DataTranslationsSettings()46DataTranslationsSettings::~DataTranslationsSettings() 47 { 48 BPath path; 49 if (find_directory(B_USER_SETTINGS_DIRECTORY, &path) < B_OK) 50 return; 51 52 BMessage settings; 53 settings.AddPoint("window corner", fCorner); 54 55 path.Append("system/DataTranslations settings"); 56 BFile file(path.Path(), B_WRITE_ONLY | B_CREATE_FILE | B_ERASE_FILE); 57 if (file.InitCheck() == B_OK) 58 settings.Flatten(&file); 59 } 60 61 62 void SetWindowCorner(BPoint corner)63DataTranslationsSettings::SetWindowCorner(BPoint corner) 64 { 65 fCorner = corner; 66 } 67 68 69 DataTranslationsSettings* Instance()70DataTranslationsSettings::Instance() 71 { 72 return &sDataTranslationsSettings; 73 } 74