2005-07-17 20:25:48 +04:00
|
|
|
/*
|
2006-02-06 16:36:46 +03:00
|
|
|
* Copyright 2005-2006, Haiku.
|
2005-07-17 20:25:48 +04:00
|
|
|
* Distributed under the terms of the MIT License.
|
|
|
|
*
|
|
|
|
* Authors:
|
|
|
|
* Stephan Aßmus <superstippi@gmx.de>
|
|
|
|
* Axel Dörfler, axeld@pinc-software.de
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
#include "DesktopSettings.h"
|
|
|
|
#include "DesktopSettingsPrivate.h"
|
|
|
|
#include "Desktop.h"
|
2005-11-03 20:03:36 +03:00
|
|
|
#include "FontManager.h"
|
|
|
|
#include "ServerConfig.h"
|
2005-07-17 20:25:48 +04:00
|
|
|
|
2006-04-26 00:12:06 +04:00
|
|
|
#include <DefaultColors.h>
|
|
|
|
#include <ServerReadOnlyMemory.h>
|
|
|
|
|
2006-02-06 16:36:46 +03:00
|
|
|
#include <Directory.h>
|
|
|
|
#include <File.h>
|
|
|
|
#include <FindDirectory.h>
|
|
|
|
#include <Path.h>
|
|
|
|
|
2005-07-17 20:25:48 +04:00
|
|
|
|
2006-08-26 19:13:08 +04:00
|
|
|
DesktopSettingsPrivate::DesktopSettingsPrivate(server_read_only_memory* shared)
|
|
|
|
:
|
2006-04-26 00:12:06 +04:00
|
|
|
fShared(*shared)
|
2005-07-17 20:25:48 +04:00
|
|
|
{
|
|
|
|
// if the on-disk settings are not complete, the defaults will be kept
|
|
|
|
_SetDefaults();
|
|
|
|
_Load();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-08-26 19:13:08 +04:00
|
|
|
DesktopSettingsPrivate::~DesktopSettingsPrivate()
|
2005-07-17 20:25:48 +04:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
2006-08-26 19:13:08 +04:00
|
|
|
DesktopSettingsPrivate::_SetDefaults()
|
2005-07-17 20:25:48 +04:00
|
|
|
{
|
2005-11-09 22:16:25 +03:00
|
|
|
fPlainFont = *gFontManager->DefaultPlainFont();
|
|
|
|
fBoldFont = *gFontManager->DefaultBoldFont();
|
|
|
|
fFixedFont = *gFontManager->DefaultFixedFont();
|
2005-11-03 20:03:36 +03:00
|
|
|
|
2005-07-17 20:25:48 +04:00
|
|
|
fMouseMode = B_NORMAL_MOUSE;
|
|
|
|
|
|
|
|
// init scrollbar info
|
|
|
|
fScrollBarInfo.proportional = true;
|
|
|
|
fScrollBarInfo.double_arrows = false;
|
|
|
|
// look of the knob (R5: (0, 1, 2), 1 = default)
|
|
|
|
fScrollBarInfo.knob = 1;
|
|
|
|
fScrollBarInfo.min_knob_size = 15;
|
|
|
|
|
|
|
|
// init menu info
|
2006-04-20 00:04:19 +04:00
|
|
|
strlcpy(fMenuInfo.f_family, fPlainFont.Family(), B_FONT_FAMILY_LENGTH);
|
|
|
|
strlcpy(fMenuInfo.f_style, fPlainFont.Style(), B_FONT_STYLE_LENGTH);
|
|
|
|
fMenuInfo.font_size = fPlainFont.Size();
|
2006-04-26 13:03:28 +04:00
|
|
|
fMenuInfo.background_color.set_to(216, 216, 216);
|
2006-04-20 00:04:19 +04:00
|
|
|
|
|
|
|
// look of the separator (R5: (0, 1, 2), default 0)
|
|
|
|
// TODO: we could just choose a nice one and remove the others
|
2005-07-17 20:25:48 +04:00
|
|
|
fMenuInfo.separator = 0;
|
2006-04-20 00:04:19 +04:00
|
|
|
fMenuInfo.click_to_open = true; // always true
|
2005-07-17 20:25:48 +04:00
|
|
|
fMenuInfo.triggers_always_shown = false;
|
|
|
|
|
2005-11-30 18:47:01 +03:00
|
|
|
fWorkspacesCount = 4;
|
2006-04-26 00:12:06 +04:00
|
|
|
|
|
|
|
memcpy(fShared.colors, BPrivate::kDefaultColors, sizeof(rgb_color) * kNumColors);
|
2005-07-17 20:25:48 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-02-06 16:36:46 +03:00
|
|
|
status_t
|
2006-08-26 19:13:08 +04:00
|
|
|
DesktopSettingsPrivate::_GetPath(BPath& path)
|
2006-02-06 16:36:46 +03:00
|
|
|
{
|
|
|
|
status_t status = find_directory(B_USER_SETTINGS_DIRECTORY, &path);
|
|
|
|
if (status < B_OK)
|
|
|
|
return status;
|
|
|
|
|
|
|
|
status = path.Append("system/app_server");
|
|
|
|
if (status < B_OK)
|
|
|
|
return status;
|
|
|
|
|
|
|
|
return create_directory(path.Path(), 0755);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-07-17 20:25:48 +04:00
|
|
|
status_t
|
2006-08-26 19:13:08 +04:00
|
|
|
DesktopSettingsPrivate::_Load()
|
2005-07-17 20:25:48 +04:00
|
|
|
{
|
|
|
|
// TODO: add support for old app_server_settings file as well
|
2006-02-06 16:36:46 +03:00
|
|
|
|
|
|
|
BPath basePath;
|
|
|
|
status_t status = _GetPath(basePath);
|
|
|
|
if (status < B_OK)
|
|
|
|
return status;
|
|
|
|
|
|
|
|
// read workspaces settings
|
|
|
|
|
|
|
|
BPath path(basePath);
|
|
|
|
path.Append("workspaces");
|
|
|
|
|
|
|
|
BFile file;
|
|
|
|
status = file.SetTo(path.Path(), B_READ_ONLY);
|
|
|
|
if (status == B_OK) {
|
|
|
|
BMessage settings;
|
|
|
|
status = settings.Unflatten(&file);
|
|
|
|
if (status == B_OK) {
|
|
|
|
int32 count;
|
|
|
|
if (settings.FindInt32("count", &count) == B_OK) {
|
|
|
|
fWorkspacesCount = count;
|
|
|
|
if (fWorkspacesCount < 1 || fWorkspacesCount > 32)
|
|
|
|
fWorkspacesCount = 4;
|
|
|
|
}
|
|
|
|
|
|
|
|
int32 i = 0;
|
2006-04-13 12:50:04 +04:00
|
|
|
while (i < kMaxWorkspaces
|
2006-02-06 16:36:46 +03:00
|
|
|
&& settings.FindMessage("workspace", i, &fWorkspaceMessages[i]) == B_OK) {
|
|
|
|
i++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-04-02 02:03:44 +04:00
|
|
|
// read font settings
|
|
|
|
|
|
|
|
path = basePath;
|
|
|
|
path.Append("fonts");
|
|
|
|
|
|
|
|
status = file.SetTo(path.Path(), B_READ_ONLY);
|
|
|
|
if (status == B_OK) {
|
|
|
|
BMessage settings;
|
|
|
|
status = settings.Unflatten(&file);
|
|
|
|
if (status == B_OK && gFontManager->Lock()) {
|
|
|
|
const char* family;
|
|
|
|
const char* style;
|
|
|
|
float size;
|
|
|
|
if (settings.FindString("plain family", &family) == B_OK
|
|
|
|
&& settings.FindString("plain style", &style) == B_OK
|
|
|
|
&& settings.FindFloat("plain size", &size) == B_OK) {
|
|
|
|
FontStyle* fontStyle = gFontManager->GetStyle(family, style);
|
|
|
|
fPlainFont.SetStyle(fontStyle);
|
|
|
|
fPlainFont.SetSize(size);
|
|
|
|
}
|
|
|
|
if (settings.FindString("bold family", &family) == B_OK
|
|
|
|
&& settings.FindString("bold style", &style) == B_OK
|
|
|
|
&& settings.FindFloat("bold size", &size) == B_OK) {
|
|
|
|
FontStyle* fontStyle = gFontManager->GetStyle(family, style);
|
|
|
|
fBoldFont.SetStyle(fontStyle);
|
|
|
|
fBoldFont.SetSize(size);
|
|
|
|
}
|
|
|
|
if (settings.FindString("fixed family", &family) == B_OK
|
|
|
|
&& settings.FindString("fixed style", &style) == B_OK
|
|
|
|
&& settings.FindFloat("fixed size", &size) == B_OK) {
|
|
|
|
FontStyle* fontStyle = gFontManager->GetStyle(family, style);
|
|
|
|
if (fontStyle->IsFixedWidth())
|
|
|
|
fFixedFont.SetStyle(fontStyle);
|
|
|
|
fFixedFont.SetSize(size);
|
|
|
|
}
|
|
|
|
gFontManager->Unlock();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-05-31 23:23:26 +04:00
|
|
|
// read mouse settings
|
|
|
|
|
|
|
|
path = basePath;
|
|
|
|
path.Append("mouse");
|
|
|
|
|
|
|
|
status = file.SetTo(path.Path(), B_READ_ONLY);
|
|
|
|
if (status == B_OK) {
|
|
|
|
BMessage settings;
|
|
|
|
status = settings.Unflatten(&file);
|
|
|
|
if (status == B_OK) {
|
|
|
|
int32 mode;
|
|
|
|
if (settings.FindInt32("mode", &mode) == B_OK) {
|
|
|
|
fMouseMode = (mode_mouse)mode;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// read appearance settings
|
|
|
|
|
|
|
|
path = basePath;
|
|
|
|
path.Append("appearance");
|
|
|
|
|
|
|
|
status = file.SetTo(path.Path(), B_READ_ONLY);
|
|
|
|
if (status == B_OK) {
|
|
|
|
BMessage settings;
|
|
|
|
status = settings.Unflatten(&file);
|
|
|
|
if (status == B_OK) {
|
|
|
|
float fontSize;
|
|
|
|
if (settings.FindFloat("font size", &fontSize) == B_OK)
|
|
|
|
fMenuInfo.font_size = fontSize;
|
|
|
|
|
|
|
|
const char* fontFamily;
|
|
|
|
if (settings.FindString("font family", &fontFamily) == B_OK)
|
|
|
|
strlcpy(fMenuInfo.f_family, fontFamily, B_FONT_FAMILY_LENGTH);
|
|
|
|
|
|
|
|
const char* fontStyle;
|
|
|
|
if (settings.FindString("font style", &fontStyle) == B_OK)
|
|
|
|
strlcpy(fMenuInfo.f_style, fontStyle, B_FONT_STYLE_LENGTH);
|
|
|
|
|
|
|
|
rgb_color bgColor;
|
|
|
|
if (settings.FindInt32("bg color", (int32*)&bgColor) == B_OK)
|
|
|
|
fMenuInfo.background_color = bgColor;
|
|
|
|
|
|
|
|
int32 separator;
|
|
|
|
if (settings.FindInt32("separator", &separator) == B_OK)
|
|
|
|
fMenuInfo.separator = separator;
|
|
|
|
|
|
|
|
bool clickToOpen;
|
|
|
|
if (settings.FindBool("click to open", &clickToOpen) == B_OK)
|
|
|
|
fMenuInfo.click_to_open = clickToOpen;
|
|
|
|
|
|
|
|
bool triggersAlwaysShown;
|
|
|
|
if (settings.FindBool("triggers always shown", &triggersAlwaysShown) == B_OK)
|
|
|
|
fMenuInfo.triggers_always_shown = triggersAlwaysShown;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-04-02 02:03:44 +04:00
|
|
|
return B_OK;
|
2005-07-17 20:25:48 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
status_t
|
2006-08-26 19:13:08 +04:00
|
|
|
DesktopSettingsPrivate::Save(uint32 mask)
|
2005-07-17 20:25:48 +04:00
|
|
|
{
|
2006-02-06 16:36:46 +03:00
|
|
|
BPath basePath;
|
|
|
|
status_t status = _GetPath(basePath);
|
|
|
|
if (status < B_OK)
|
|
|
|
return status;
|
|
|
|
|
|
|
|
if (mask & kWorkspacesSettings) {
|
|
|
|
BPath path(basePath);
|
|
|
|
if (path.Append("workspaces") == B_OK) {
|
|
|
|
BMessage settings('asws');
|
|
|
|
settings.AddInt32("count", fWorkspacesCount);
|
|
|
|
|
|
|
|
for (int32 i = 0; i < kMaxWorkspaces; i++) {
|
|
|
|
settings.AddMessage("workspace", &fWorkspaceMessages[i]);
|
|
|
|
}
|
|
|
|
|
|
|
|
BFile file;
|
|
|
|
status = file.SetTo(path.Path(), B_CREATE_FILE | B_ERASE_FILE | B_READ_WRITE);
|
|
|
|
if (status == B_OK) {
|
|
|
|
status = settings.Flatten(&file, NULL);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-04-02 02:03:44 +04:00
|
|
|
if (mask & kFontSettings) {
|
|
|
|
BPath path(basePath);
|
|
|
|
if (path.Append("fonts") == B_OK) {
|
|
|
|
BMessage settings('asfn');
|
|
|
|
|
|
|
|
settings.AddString("plain family", fPlainFont.Family());
|
|
|
|
settings.AddString("plain style", fPlainFont.Style());
|
|
|
|
settings.AddFloat("plain size", fPlainFont.Size());
|
|
|
|
|
|
|
|
settings.AddString("bold family", fBoldFont.Family());
|
|
|
|
settings.AddString("bold style", fBoldFont.Style());
|
|
|
|
settings.AddFloat("bold size", fBoldFont.Size());
|
|
|
|
|
|
|
|
settings.AddString("fixed family", fFixedFont.Family());
|
|
|
|
settings.AddString("fixed style", fFixedFont.Style());
|
|
|
|
settings.AddFloat("fixed size", fFixedFont.Size());
|
|
|
|
|
|
|
|
BFile file;
|
|
|
|
status = file.SetTo(path.Path(), B_CREATE_FILE | B_ERASE_FILE | B_READ_WRITE);
|
|
|
|
if (status == B_OK) {
|
|
|
|
status = settings.Flatten(&file, NULL);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-05-31 23:23:26 +04:00
|
|
|
if (mask & kMouseSettings) {
|
|
|
|
BPath path(basePath);
|
|
|
|
if (path.Append("mouse") == B_OK) {
|
|
|
|
BMessage settings('asms');
|
|
|
|
settings.AddInt32("mode", (int32)fMouseMode);
|
|
|
|
|
|
|
|
BFile file;
|
|
|
|
status = file.SetTo(path.Path(), B_CREATE_FILE | B_ERASE_FILE | B_READ_WRITE);
|
|
|
|
if (status == B_OK) {
|
|
|
|
status = settings.Flatten(&file, NULL);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (mask & kAppearanceSettings) {
|
|
|
|
BPath path(basePath);
|
|
|
|
if (path.Append("appearance") == B_OK) {
|
|
|
|
BMessage settings('aslk');
|
|
|
|
settings.AddFloat("font size", fMenuInfo.font_size);
|
|
|
|
settings.AddString("font family", fMenuInfo.f_family);
|
|
|
|
settings.AddString("font style", fMenuInfo.f_style);
|
|
|
|
settings.AddInt32("bg color", (const int32&)fMenuInfo.background_color);
|
|
|
|
settings.AddInt32("separator", fMenuInfo.separator);
|
|
|
|
settings.AddBool("click to open", fMenuInfo.click_to_open);
|
|
|
|
settings.AddBool("triggers always shown", fMenuInfo.triggers_always_shown);
|
|
|
|
// TODO: more appearance settings
|
|
|
|
|
|
|
|
BFile file;
|
|
|
|
status = file.SetTo(path.Path(), B_CREATE_FILE | B_ERASE_FILE | B_READ_WRITE);
|
|
|
|
if (status == B_OK) {
|
|
|
|
status = settings.Flatten(&file, NULL);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-02-06 16:36:46 +03:00
|
|
|
return status;
|
2005-07-17 20:25:48 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-11-03 20:03:36 +03:00
|
|
|
void
|
2006-08-26 19:13:08 +04:00
|
|
|
DesktopSettingsPrivate::SetDefaultPlainFont(const ServerFont &font)
|
2005-11-03 20:03:36 +03:00
|
|
|
{
|
|
|
|
fPlainFont = font;
|
2006-04-02 02:03:44 +04:00
|
|
|
Save(kFontSettings);
|
2005-11-03 20:03:36 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const ServerFont &
|
2006-08-26 19:13:08 +04:00
|
|
|
DesktopSettingsPrivate::DefaultPlainFont() const
|
2005-11-03 20:03:36 +03:00
|
|
|
{
|
|
|
|
return fPlainFont;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
2006-08-26 19:13:08 +04:00
|
|
|
DesktopSettingsPrivate::SetDefaultBoldFont(const ServerFont &font)
|
2005-11-03 20:03:36 +03:00
|
|
|
{
|
|
|
|
fBoldFont = font;
|
2006-04-02 02:03:44 +04:00
|
|
|
Save(kFontSettings);
|
2005-11-03 20:03:36 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const ServerFont &
|
2006-08-26 19:13:08 +04:00
|
|
|
DesktopSettingsPrivate::DefaultBoldFont() const
|
2005-11-03 20:03:36 +03:00
|
|
|
{
|
|
|
|
return fBoldFont;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
2006-08-26 19:13:08 +04:00
|
|
|
DesktopSettingsPrivate::SetDefaultFixedFont(const ServerFont &font)
|
2005-11-03 20:03:36 +03:00
|
|
|
{
|
|
|
|
fFixedFont = font;
|
2006-04-02 02:03:44 +04:00
|
|
|
Save(kFontSettings);
|
2005-11-03 20:03:36 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const ServerFont &
|
2006-08-26 19:13:08 +04:00
|
|
|
DesktopSettingsPrivate::DefaultFixedFont() const
|
2005-11-03 20:03:36 +03:00
|
|
|
{
|
|
|
|
return fFixedFont;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-07-17 20:25:48 +04:00
|
|
|
void
|
2006-08-26 19:13:08 +04:00
|
|
|
DesktopSettingsPrivate::SetScrollBarInfo(const scroll_bar_info& info)
|
2005-07-17 20:25:48 +04:00
|
|
|
{
|
|
|
|
fScrollBarInfo = info;
|
2006-04-02 02:03:44 +04:00
|
|
|
Save(kAppearanceSettings);
|
2005-07-17 20:25:48 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const scroll_bar_info&
|
2006-08-26 19:13:08 +04:00
|
|
|
DesktopSettingsPrivate::ScrollBarInfo() const
|
2005-07-17 20:25:48 +04:00
|
|
|
{
|
|
|
|
return fScrollBarInfo;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
2006-08-26 19:13:08 +04:00
|
|
|
DesktopSettingsPrivate::SetMenuInfo(const menu_info& info)
|
2005-07-17 20:25:48 +04:00
|
|
|
{
|
|
|
|
fMenuInfo = info;
|
2006-04-02 02:03:44 +04:00
|
|
|
Save(kAppearanceSettings);
|
2005-07-17 20:25:48 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const menu_info&
|
2006-08-26 19:13:08 +04:00
|
|
|
DesktopSettingsPrivate::MenuInfo() const
|
2005-07-17 20:25:48 +04:00
|
|
|
{
|
|
|
|
return fMenuInfo;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
2006-08-26 19:13:08 +04:00
|
|
|
DesktopSettingsPrivate::SetMouseMode(const mode_mouse mode)
|
2005-07-17 20:25:48 +04:00
|
|
|
{
|
|
|
|
fMouseMode = mode;
|
2006-05-31 23:23:26 +04:00
|
|
|
Save(kMouseSettings);
|
2005-07-17 20:25:48 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
mode_mouse
|
2006-08-26 19:13:08 +04:00
|
|
|
DesktopSettingsPrivate::MouseMode() const
|
2005-07-17 20:25:48 +04:00
|
|
|
{
|
|
|
|
return fMouseMode;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool
|
2006-08-26 19:13:08 +04:00
|
|
|
DesktopSettingsPrivate::FocusFollowsMouse() const
|
2005-07-17 20:25:48 +04:00
|
|
|
{
|
|
|
|
return MouseMode() != B_NORMAL_MOUSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
2006-08-26 19:13:08 +04:00
|
|
|
DesktopSettingsPrivate::SetWorkspacesCount(int32 number)
|
2005-07-17 20:25:48 +04:00
|
|
|
{
|
|
|
|
if (number < 1)
|
|
|
|
number = 1;
|
|
|
|
else if (number > kMaxWorkspaces)
|
|
|
|
number = kMaxWorkspaces;
|
|
|
|
|
|
|
|
fWorkspacesCount = number;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int32
|
2006-08-26 19:13:08 +04:00
|
|
|
DesktopSettingsPrivate::WorkspacesCount() const
|
2005-07-17 20:25:48 +04:00
|
|
|
{
|
|
|
|
return fWorkspacesCount;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
2006-08-26 19:13:08 +04:00
|
|
|
DesktopSettingsPrivate::SetWorkspacesMessage(int32 index, BMessage& message)
|
2005-07-17 20:25:48 +04:00
|
|
|
{
|
|
|
|
if (index < 0 || index > kMaxWorkspaces)
|
|
|
|
return;
|
|
|
|
|
|
|
|
fWorkspaceMessages[index] = message;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const BMessage*
|
2006-08-26 19:13:08 +04:00
|
|
|
DesktopSettingsPrivate::WorkspacesMessage(int32 index) const
|
2005-07-17 20:25:48 +04:00
|
|
|
{
|
|
|
|
if (index < 0 || index > kMaxWorkspaces)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
return &fWorkspaceMessages[index];
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-08-26 19:13:08 +04:00
|
|
|
// #pragma mark - read access
|
2005-07-17 20:25:48 +04:00
|
|
|
|
|
|
|
|
|
|
|
DesktopSettings::DesktopSettings(Desktop* desktop)
|
2006-08-26 19:13:08 +04:00
|
|
|
:
|
|
|
|
fSettings(desktop->fSettings)
|
2005-07-17 20:25:48 +04:00
|
|
|
{
|
2006-08-26 19:13:08 +04:00
|
|
|
if (!desktop->fWindowLock.IsReadLocked() && !desktop->fWindowLock.IsWriteLocked())
|
|
|
|
debugger("desktop not locked when trying to access settings");
|
2005-07-17 20:25:48 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-08-26 19:13:08 +04:00
|
|
|
void
|
|
|
|
DesktopSettings::GetDefaultPlainFont(ServerFont &font) const
|
2005-07-17 20:25:48 +04:00
|
|
|
{
|
2006-08-26 19:13:08 +04:00
|
|
|
font = fSettings->DefaultPlainFont();
|
2005-07-17 20:25:48 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-11-03 20:03:36 +03:00
|
|
|
void
|
2006-08-26 19:13:08 +04:00
|
|
|
DesktopSettings::GetDefaultBoldFont(ServerFont &font) const
|
2005-11-03 20:03:36 +03:00
|
|
|
{
|
2006-08-26 19:13:08 +04:00
|
|
|
font = fSettings->DefaultBoldFont();
|
2005-11-03 20:03:36 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
2006-08-26 19:13:08 +04:00
|
|
|
DesktopSettings::GetDefaultFixedFont(ServerFont &font) const
|
2005-11-03 20:03:36 +03:00
|
|
|
{
|
2006-08-26 19:13:08 +04:00
|
|
|
font = fSettings->DefaultFixedFont();
|
2005-11-03 20:03:36 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
2006-08-26 19:13:08 +04:00
|
|
|
DesktopSettings::GetScrollBarInfo(scroll_bar_info& info) const
|
2005-11-03 20:03:36 +03:00
|
|
|
{
|
2006-08-26 19:13:08 +04:00
|
|
|
info = fSettings->ScrollBarInfo();
|
2005-11-03 20:03:36 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
2006-08-26 19:13:08 +04:00
|
|
|
DesktopSettings::GetMenuInfo(menu_info& info) const
|
2005-11-03 20:03:36 +03:00
|
|
|
{
|
2006-08-26 19:13:08 +04:00
|
|
|
info = fSettings->MenuInfo();
|
2005-11-03 20:03:36 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-08-26 19:13:08 +04:00
|
|
|
mode_mouse
|
|
|
|
DesktopSettings::MouseMode() const
|
2005-11-03 20:03:36 +03:00
|
|
|
{
|
2006-08-26 19:13:08 +04:00
|
|
|
return fSettings->MouseMode();
|
2005-11-03 20:03:36 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-08-26 19:13:08 +04:00
|
|
|
bool
|
|
|
|
DesktopSettings::FocusFollowsMouse() const
|
2005-11-03 20:03:36 +03:00
|
|
|
{
|
2006-08-26 19:13:08 +04:00
|
|
|
return fSettings->FocusFollowsMouse();
|
2005-11-03 20:03:36 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-08-26 19:13:08 +04:00
|
|
|
int32
|
|
|
|
DesktopSettings::WorkspacesCount() const
|
2005-07-17 20:25:48 +04:00
|
|
|
{
|
2006-08-26 19:13:08 +04:00
|
|
|
return fSettings->WorkspacesCount();
|
2005-07-17 20:25:48 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-08-26 19:13:08 +04:00
|
|
|
const BMessage*
|
|
|
|
DesktopSettings::WorkspacesMessage(int32 index) const
|
2005-07-17 20:25:48 +04:00
|
|
|
{
|
2006-08-26 19:13:08 +04:00
|
|
|
return fSettings->WorkspacesMessage(index);
|
2005-07-17 20:25:48 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-08-26 19:13:08 +04:00
|
|
|
// #pragma mark - write access
|
2005-07-17 20:25:48 +04:00
|
|
|
|
|
|
|
|
2006-08-26 19:13:08 +04:00
|
|
|
LockedDesktopSettings::LockedDesktopSettings(Desktop* desktop)
|
|
|
|
:
|
|
|
|
fSettings(desktop->fSettings),
|
|
|
|
fDesktop(desktop)
|
2005-07-17 20:25:48 +04:00
|
|
|
{
|
2006-08-26 19:13:08 +04:00
|
|
|
// TODO: this only works in MultiLocker's DEBUG mode
|
|
|
|
#if 0
|
|
|
|
if (desktop->fWindowLock.IsReadLocked())
|
|
|
|
debugger("desktop read locked when trying to change settings");
|
|
|
|
#endif
|
|
|
|
|
|
|
|
fDesktop->LockAllWindows();
|
2005-07-17 20:25:48 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-08-26 19:13:08 +04:00
|
|
|
LockedDesktopSettings::~LockedDesktopSettings()
|
2005-07-17 20:25:48 +04:00
|
|
|
{
|
2006-08-26 19:13:08 +04:00
|
|
|
fDesktop->UnlockAllWindows();
|
2005-07-17 20:25:48 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-08-26 19:13:08 +04:00
|
|
|
void
|
|
|
|
LockedDesktopSettings::SetDefaultPlainFont(const ServerFont &font)
|
2005-07-17 20:25:48 +04:00
|
|
|
{
|
2006-08-26 19:13:08 +04:00
|
|
|
fSettings->SetDefaultPlainFont(font);
|
2005-07-17 20:25:48 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-08-26 19:13:08 +04:00
|
|
|
void
|
|
|
|
LockedDesktopSettings::SetDefaultBoldFont(const ServerFont &font)
|
2005-07-17 20:25:48 +04:00
|
|
|
{
|
2006-08-26 19:13:08 +04:00
|
|
|
fSettings->SetDefaultBoldFont(font);
|
2005-07-17 20:25:48 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
2006-08-26 19:13:08 +04:00
|
|
|
LockedDesktopSettings::SetDefaultFixedFont(const ServerFont &font)
|
2005-07-17 20:25:48 +04:00
|
|
|
{
|
2006-08-26 19:13:08 +04:00
|
|
|
fSettings->SetDefaultFixedFont(font);
|
2005-07-17 20:25:48 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-08-26 19:13:08 +04:00
|
|
|
void
|
|
|
|
LockedDesktopSettings::SetScrollBarInfo(const scroll_bar_info& info)
|
2005-07-17 20:25:48 +04:00
|
|
|
{
|
2006-08-26 19:13:08 +04:00
|
|
|
fSettings->SetScrollBarInfo(info);
|
2005-07-17 20:25:48 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
2006-08-26 19:13:08 +04:00
|
|
|
LockedDesktopSettings::SetMenuInfo(const menu_info& info)
|
2005-07-17 20:25:48 +04:00
|
|
|
{
|
2006-08-26 19:13:08 +04:00
|
|
|
fSettings->SetMenuInfo(info);
|
2005-07-17 20:25:48 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-08-26 19:13:08 +04:00
|
|
|
void
|
|
|
|
LockedDesktopSettings::SetMouseMode(const mode_mouse mode)
|
2005-07-17 20:25:48 +04:00
|
|
|
{
|
2006-08-26 19:13:08 +04:00
|
|
|
fSettings->SetMouseMode(mode);
|
2005-07-17 20:25:48 +04:00
|
|
|
}
|
|
|
|
|
2006-08-26 19:13:08 +04:00
|
|
|
|