2 * Copyright 2006, 2011, 2013 Stephan Aßmus <superstippi@gmx.de>
3 * All rights reserved. Distributed under the terms of the MIT License.
12 #include <Application.h>
13 #include <Directory.h>
15 #include <FindDirectory.h>
18 #include <Resources.h>
25 load_settings(BMessage
* message
, const char* fileName
, const char* folder
)
27 if (message
== NULL
|| fileName
== NULL
|| fileName
[0] == '\0')
31 status_t ret
= find_directory(B_USER_SETTINGS_DIRECTORY
, &path
);
35 // passing folder is optional
37 ret
= path
.Append(folder
);
39 if (ret
== B_OK
&& (ret
= path
.Append(fileName
)) == B_OK
) {
40 BFile
file(path
.Path(), B_READ_ONLY
);
41 ret
= file
.InitCheck();
43 ret
= message
->Unflatten(&file
);
51 save_settings(const BMessage
* message
, const char* fileName
, const char* folder
)
53 if (message
== NULL
|| fileName
== NULL
|| fileName
[0] == '\0')
57 status_t ret
= find_directory(B_USER_SETTINGS_DIRECTORY
, &path
);
61 // passing folder is optional
63 ret
= path
.Append(folder
);
66 ret
= create_directory(path
.Path(), 0777);
69 ret
= path
.Append(fileName
);
72 BFile
file(path
.Path(), B_WRITE_ONLY
| B_CREATE_FILE
| B_ERASE_FILE
);
73 ret
= file
.InitCheck();
75 ret
= message
->Flatten(&file
);
83 get_app_resources(BResources
& resources
)
86 status_t status
= be_app
->GetAppInfo(&info
);
90 return resources
.SetTo(&info
.ref
);
95 set_small_font(BView
* view
)
99 font
.SetSize(ceilf(font
.Size() * 0.8));
100 view
->SetFont(&font
);