68 lines
1.6 KiB
C++
68 lines
1.6 KiB
C++
class WindowPreferences : public BArchivable
|
|
{
|
|
public:
|
|
WindowPreferences(BString path);
|
|
~WindowPreferences()
|
|
status_t Save(BString path);
|
|
|
|
BPoint fLastWindowPosition;
|
|
BRect fLastWindowRect;
|
|
// What does this do?
|
|
//bool fEnableDoubleClick;
|
|
bool fEnableTimestamp;
|
|
}
|
|
|
|
|
|
WindowPreferences::WindowPreferences(BString path) {
|
|
BPath* settings;
|
|
status_t error = find_directory(B_USER_SETTINGS_DIRECTORY, &settings)
|
|
if (error == B_OK)
|
|
error = settings->Append(path);
|
|
|
|
if (error != B_OK)
|
|
debugger("Incorrect settings file passed?");
|
|
|
|
BFile file = new BFile(settings, B_READ_ONLY);
|
|
BMessage preferences;
|
|
error = preferences.Unflatten(file);
|
|
WindowPreferences instance = Instantiate(preferences);
|
|
|
|
if (instance == NULL) {
|
|
//Make some defaults instead
|
|
fLastWindowPosition = BPoint(0,0);
|
|
fLastWindowRect = BRect(640, 480);
|
|
fEnableTimeSteamp = false;
|
|
}
|
|
}
|
|
|
|
|
|
status_t
|
|
WindowPreferences::WriteMessage(BString path) {
|
|
BPath* settings;
|
|
status_t error = find_directory(B_USER_SETTINGS_DIRECTORY, &settings)
|
|
if (error == B_OK)
|
|
error = settings->Append(path);
|
|
|
|
if (error != B_OK)
|
|
debugger("Incorrect settings file passed?");
|
|
|
|
BMessage archive = new BMessage();
|
|
WindowPreferences::Archive(archive)
|
|
|
|
BFile file = new BFile(settings, B_CREATE_FILE & B_ERASE_FILE & B_WRITE_ONLY)
|
|
// write message to disk
|
|
archive.Flatten(file);
|
|
}
|
|
|
|
|
|
status_t
|
|
WindowPreferences::Archive(BMessage* data, bool deep) {
|
|
data.AddPoint("LastWindowPosition", fLastWindowPosition);
|
|
data.AddRect("LastWindowRect", fLastWindowRect);
|
|
// What does this do?
|
|
//settings.AddBool("EnableDoubleClick", fEnableDoubleClick);
|
|
data.AddBool("EnableTimestamp", fEnableTimestamp);
|
|
|
|
return B_OK;
|
|
}
|