1a10cf76eSAxel Dörfler /* 251516391SAxel Dörfler * Copyright 2002-2010, Haiku, Inc. 3797de116SAxel Dörfler * Distributed under the terms of the MIT license. 4a10cf76eSAxel Dörfler * 5797de116SAxel Dörfler * Authors: 6797de116SAxel Dörfler * Oliver Siebenmarck 7797de116SAxel Dörfler * Axel Dörfler 8a10cf76eSAxel Dörfler */ 9a10cf76eSAxel Dörfler 10797de116SAxel Dörfler 11797de116SAxel Dörfler #include "DataTranslationsSettings.h" 12797de116SAxel Dörfler 13a10cf76eSAxel Dörfler #include <stdio.h> 14a10cf76eSAxel Dörfler 15f4265833SJonas Sundström #include <Application.h> 16f4265833SJonas Sundström #include <File.h> 17f4265833SJonas Sundström #include <FindDirectory.h> 18f4265833SJonas Sundström #include <Message.h> 19f4265833SJonas Sundström #include <Path.h> 20f4265833SJonas Sundström 21a10cf76eSAxel Dörfler 22*bffb78deSJonas Sundström static DataTranslationsSettings sDataTranslationsSettings; 23*bffb78deSJonas Sundström 24*bffb78deSJonas Sundström DataTranslationsSettings()25a10cf76eSAxel DörflerDataTranslationsSettings::DataTranslationsSettings() 26a10cf76eSAxel Dörfler { 27a10cf76eSAxel Dörfler BPath path; 28797de116SAxel Dörfler if (find_directory(B_USER_SETTINGS_DIRECTORY, &path) != B_OK) 29797de116SAxel Dörfler return; 30a10cf76eSAxel Dörfler 3151516391SAxel Dörfler fCorner = BPoint(-1, -1); 32797de116SAxel Dörfler 33797de116SAxel Dörfler path.Append("system/DataTranslations settings"); 34a10cf76eSAxel Dörfler BFile file(path.Path(), B_READ_ONLY); 35797de116SAxel Dörfler BMessage settings; 36797de116SAxel Dörfler 37797de116SAxel Dörfler if (file.InitCheck() == B_OK 38797de116SAxel Dörfler && settings.Unflatten(&file) == B_OK) { 39797de116SAxel Dörfler BPoint corner; 40797de116SAxel Dörfler if (settings.FindPoint("window corner", &corner) == B_OK) 41797de116SAxel Dörfler fCorner = corner; 42a10cf76eSAxel Dörfler } 43a10cf76eSAxel Dörfler } 44797de116SAxel Dörfler 45a10cf76eSAxel Dörfler ~DataTranslationsSettings()46a10cf76eSAxel DörflerDataTranslationsSettings::~DataTranslationsSettings() 47a10cf76eSAxel Dörfler { 48a10cf76eSAxel Dörfler BPath path; 49a10cf76eSAxel Dörfler if (find_directory(B_USER_SETTINGS_DIRECTORY, &path) < B_OK) 50a10cf76eSAxel Dörfler return; 51a10cf76eSAxel Dörfler 52797de116SAxel Dörfler BMessage settings; 53797de116SAxel Dörfler settings.AddPoint("window corner", fCorner); 54a10cf76eSAxel Dörfler 55797de116SAxel Dörfler path.Append("system/DataTranslations settings"); 56797de116SAxel Dörfler BFile file(path.Path(), B_WRITE_ONLY | B_CREATE_FILE | B_ERASE_FILE); 57797de116SAxel Dörfler if (file.InitCheck() == B_OK) 58797de116SAxel Dörfler settings.Flatten(&file); 59a10cf76eSAxel Dörfler } 60797de116SAxel Dörfler 61a10cf76eSAxel Dörfler 62a10cf76eSAxel Dörfler void SetWindowCorner(BPoint corner)63a10cf76eSAxel DörflerDataTranslationsSettings::SetWindowCorner(BPoint corner) 64a10cf76eSAxel Dörfler { 65a10cf76eSAxel Dörfler fCorner = corner; 66a10cf76eSAxel Dörfler } 67*bffb78deSJonas Sundström 68*bffb78deSJonas Sundström 69*bffb78deSJonas Sundström DataTranslationsSettings* Instance()70*bffb78deSJonas SundströmDataTranslationsSettings::Instance() 71*bffb78deSJonas Sundström { 72*bffb78deSJonas Sundström return &sDataTranslationsSettings; 73*bffb78deSJonas Sundström } 74