2005-05-23 04:58:42 +04:00
|
|
|
/*
|
|
|
|
Open Tracker License
|
|
|
|
|
|
|
|
Terms and Conditions
|
|
|
|
|
|
|
|
Copyright (c) 1991-2000, Be Incorporated. All rights reserved.
|
|
|
|
|
|
|
|
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
|
|
|
this software and associated documentation files (the "Software"), to deal in
|
|
|
|
the Software without restriction, including without limitation the rights to
|
|
|
|
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
|
|
|
of the Software, and to permit persons to whom the Software is furnished to do
|
|
|
|
so, subject to the following conditions:
|
|
|
|
|
|
|
|
The above copyright notice and this permission notice applies to all licensees
|
|
|
|
and shall be included in all copies or substantial portions of the Software.
|
|
|
|
|
|
|
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF TITLE, MERCHANTABILITY,
|
|
|
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
|
|
|
BE INCORPORATED BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
|
|
|
|
AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF, OR IN CONNECTION
|
|
|
|
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
|
|
|
|
|
|
Except as contained in this notice, the name of Be Incorporated shall not be
|
|
|
|
used in advertising or otherwise to promote the sale, use or other dealings in
|
|
|
|
this Software without prior written authorization from Be Incorporated.
|
|
|
|
|
|
|
|
Tracker(TM), Be(R), BeOS(R), and BeIA(TM) are trademarks or registered trademarks
|
|
|
|
of Be Incorporated in the United States and other countries. Other brand product
|
|
|
|
names are registered trademarks or trademarks of their respective holders.
|
|
|
|
All rights reserved.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <Alert.h>
|
|
|
|
|
|
|
|
#include "Commands.h"
|
|
|
|
#include "DeskWindow.h"
|
|
|
|
#include "Model.h"
|
|
|
|
#include "SettingsViews.h"
|
|
|
|
#include "Tracker.h"
|
|
|
|
#include "WidgetAttributeText.h"
|
|
|
|
|
|
|
|
#include <Box.h>
|
|
|
|
#include <Button.h>
|
|
|
|
#include <MenuField.h>
|
|
|
|
#include <ColorControl.h>
|
|
|
|
#include <NodeMonitor.h>
|
|
|
|
#include <StringView.h>
|
|
|
|
|
2006-06-01 14:47:12 +04:00
|
|
|
|
|
|
|
static const uint32 kSpaceBarSwitchColor = 'SBsc';
|
|
|
|
static const float kItemExtraSpacing = 2.0f;
|
|
|
|
static const float kIndentSpacing = 12.0f;
|
|
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
send_bool_notices(uint32 what, const char *name, bool value)
|
|
|
|
{
|
|
|
|
TTracker *tracker = dynamic_cast<TTracker *>(be_app);
|
|
|
|
if (!tracker)
|
|
|
|
return;
|
|
|
|
|
|
|
|
BMessage message;
|
|
|
|
message.AddBool(name, value);
|
|
|
|
tracker->SendNotices(what, &message);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// #pragma mark -
|
2005-05-23 04:58:42 +04:00
|
|
|
|
|
|
|
|
|
|
|
SettingsView::SettingsView(BRect rect, const char *name)
|
2006-06-25 14:46:00 +04:00
|
|
|
: BView(rect, name, B_FOLLOW_ALL, 0)
|
2005-05-23 04:58:42 +04:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2006-06-01 14:47:12 +04:00
|
|
|
|
2005-05-23 04:58:42 +04:00
|
|
|
SettingsView::~SettingsView()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-06-01 14:47:12 +04:00
|
|
|
/*!
|
|
|
|
The inherited functions should set the default values
|
|
|
|
and update the UI gadgets. The latter can by done by
|
|
|
|
calling ShowCurrentSettings().
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
SettingsView::SetDefaults()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
The inherited functions should set the values that was
|
|
|
|
active when the settings window opened. It should also
|
|
|
|
update the UI widgets accordingly, preferrable by calling
|
|
|
|
ShowCurrentSettings().
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
SettingsView::Revert()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2005-05-23 04:58:42 +04:00
|
|
|
|
2006-06-01 14:47:12 +04:00
|
|
|
/*!
|
|
|
|
This function is called when the window is shown to let
|
|
|
|
the settings views record the state to revert to.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
SettingsView::RecordRevertSettings()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
This function is used by the window to tell the view
|
|
|
|
to display the current settings in the tracker.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
SettingsView::ShowCurrentSettings()
|
|
|
|
{
|
|
|
|
}
|
2005-05-23 04:58:42 +04:00
|
|
|
|
|
|
|
|
2006-06-01 14:47:12 +04:00
|
|
|
/*!
|
|
|
|
This function is used by the window to tell whether
|
|
|
|
it can ghost the revert button or not. It it shows the
|
|
|
|
reverted settings, this function should return true.
|
|
|
|
*/
|
|
|
|
bool
|
|
|
|
SettingsView::IsRevertable() const
|
|
|
|
{
|
|
|
|
return true;
|
2005-05-23 04:58:42 +04:00
|
|
|
}
|
|
|
|
|
2006-06-01 14:47:12 +04:00
|
|
|
|
2005-05-23 04:58:42 +04:00
|
|
|
// #pragma mark -
|
|
|
|
|
2006-06-01 14:47:12 +04:00
|
|
|
|
2005-05-23 04:58:42 +04:00
|
|
|
DesktopSettingsView::DesktopSettingsView(BRect rect)
|
2006-06-01 14:47:12 +04:00
|
|
|
: SettingsView(rect, "DesktopSettingsView")
|
2005-05-23 04:58:42 +04:00
|
|
|
{
|
2006-06-25 14:46:00 +04:00
|
|
|
rect.OffsetTo(B_ORIGIN);
|
|
|
|
fShowDisksIconRadioButton = new BRadioButton(rect, "", "Show Disks Icon",
|
2005-05-23 04:58:42 +04:00
|
|
|
new BMessage(kShowDisksIconChanged));
|
|
|
|
fShowDisksIconRadioButton->ResizeToPreferred();
|
2006-06-25 14:46:00 +04:00
|
|
|
AddChild(fShowDisksIconRadioButton);
|
2005-05-23 04:58:42 +04:00
|
|
|
|
|
|
|
const float itemSpacing = fShowDisksIconRadioButton->Bounds().Height() + kItemExtraSpacing;
|
2006-06-25 14:46:00 +04:00
|
|
|
rect.OffsetBy(0, itemSpacing);
|
2005-05-23 04:58:42 +04:00
|
|
|
|
2006-06-25 14:46:00 +04:00
|
|
|
fMountVolumesOntoDesktopRadioButton = new BRadioButton(rect, "",
|
2007-01-21 23:50:14 +03:00
|
|
|
"Show Volumes on Desktop", new BMessage(kVolumesOnDesktopChanged));
|
2005-05-23 04:58:42 +04:00
|
|
|
AddChild(fMountVolumesOntoDesktopRadioButton);
|
|
|
|
fMountVolumesOntoDesktopRadioButton->ResizeToPreferred();
|
|
|
|
|
2006-06-25 14:46:00 +04:00
|
|
|
rect.OffsetBy(20, itemSpacing);
|
2005-05-23 04:58:42 +04:00
|
|
|
|
2006-06-25 14:46:00 +04:00
|
|
|
fMountSharedVolumesOntoDesktopCheckBox = new BCheckBox(rect, "",
|
|
|
|
"Show Shared Volumes On Desktop", new BMessage(kVolumesOnDesktopChanged));
|
2005-05-23 04:58:42 +04:00
|
|
|
AddChild(fMountSharedVolumesOntoDesktopCheckBox);
|
|
|
|
fMountSharedVolumesOntoDesktopCheckBox->ResizeToPreferred();
|
|
|
|
|
2006-06-25 14:46:00 +04:00
|
|
|
rect.OffsetBy(-20, 2 * itemSpacing);
|
2005-05-23 04:58:42 +04:00
|
|
|
|
2006-06-25 14:46:00 +04:00
|
|
|
fIntegrateNonBootBeOSDesktopsCheckBox = new BCheckBox(rect, "",
|
|
|
|
"Integrate Non-Boot BeOS Desktops", new BMessage(kDesktopIntegrationChanged));
|
2005-05-23 04:58:42 +04:00
|
|
|
AddChild(fIntegrateNonBootBeOSDesktopsCheckBox);
|
|
|
|
fIntegrateNonBootBeOSDesktopsCheckBox->ResizeToPreferred();
|
|
|
|
|
2006-06-25 14:46:00 +04:00
|
|
|
rect.OffsetBy(0, itemSpacing);
|
2005-05-23 04:58:42 +04:00
|
|
|
|
2006-06-25 14:46:00 +04:00
|
|
|
fEjectWhenUnmountingCheckBox = new BCheckBox(rect, "", "Eject When Unmounting",
|
|
|
|
new BMessage(kEjectWhenUnmountingChanged));
|
2005-05-23 04:58:42 +04:00
|
|
|
AddChild(fEjectWhenUnmountingCheckBox);
|
|
|
|
fEjectWhenUnmountingCheckBox->ResizeToPreferred();
|
|
|
|
|
2006-06-25 14:46:00 +04:00
|
|
|
rect = Bounds();
|
|
|
|
rect.top = rect.bottom;
|
|
|
|
fMountButton = new BButton(rect, "", "Mount Settings" B_UTF8_ELLIPSIS,
|
|
|
|
new BMessage(kRunAutomounterSettings), B_FOLLOW_LEFT | B_FOLLOW_BOTTOM);
|
|
|
|
fMountButton->ResizeToPreferred();
|
|
|
|
fMountButton->MoveBy(0, -fMountButton->Bounds().Height());
|
|
|
|
AddChild(fMountButton);
|
2005-05-23 04:58:42 +04:00
|
|
|
|
2006-06-25 14:46:00 +04:00
|
|
|
fMountButton->SetTarget(be_app);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
DesktopSettingsView::GetPreferredSize(float *_width, float *_height)
|
|
|
|
{
|
|
|
|
if (_width != NULL) {
|
|
|
|
*_width = max_c(fIntegrateNonBootBeOSDesktopsCheckBox->Frame().right,
|
|
|
|
fMountSharedVolumesOntoDesktopCheckBox->Frame().right);
|
|
|
|
}
|
2005-05-23 04:58:42 +04:00
|
|
|
|
2006-06-25 14:46:00 +04:00
|
|
|
if (_height != NULL) {
|
|
|
|
*_height = fEjectWhenUnmountingCheckBox->Frame().bottom + 8
|
|
|
|
+ fMountButton->Bounds().Height();
|
|
|
|
}
|
2005-05-23 04:58:42 +04:00
|
|
|
}
|
|
|
|
|
2006-06-01 14:47:12 +04:00
|
|
|
|
2005-05-23 04:58:42 +04:00
|
|
|
void
|
|
|
|
DesktopSettingsView::AttachedToWindow()
|
|
|
|
{
|
|
|
|
fShowDisksIconRadioButton->SetTarget(this);
|
|
|
|
fMountVolumesOntoDesktopRadioButton->SetTarget(this);
|
|
|
|
fMountSharedVolumesOntoDesktopCheckBox->SetTarget(this);
|
|
|
|
fIntegrateNonBootBeOSDesktopsCheckBox->SetTarget(this);
|
|
|
|
fEjectWhenUnmountingCheckBox->SetTarget(this);
|
|
|
|
}
|
|
|
|
|
2006-06-01 14:47:12 +04:00
|
|
|
|
2005-05-23 04:58:42 +04:00
|
|
|
void
|
|
|
|
DesktopSettingsView::MessageReceived(BMessage *message)
|
|
|
|
{
|
|
|
|
TTracker *tracker = dynamic_cast<TTracker *>(be_app);
|
|
|
|
if (!tracker)
|
|
|
|
return;
|
|
|
|
|
|
|
|
TrackerSettings settings;
|
|
|
|
|
|
|
|
switch (message->what) {
|
|
|
|
case kShowDisksIconChanged:
|
|
|
|
{
|
|
|
|
// Turn on and off related settings:
|
|
|
|
fMountVolumesOntoDesktopRadioButton->SetValue(
|
|
|
|
!fShowDisksIconRadioButton->Value() == 1);
|
|
|
|
fMountSharedVolumesOntoDesktopCheckBox->SetEnabled(
|
|
|
|
fMountVolumesOntoDesktopRadioButton->Value() == 1);
|
|
|
|
|
|
|
|
// Set the new settings in the tracker:
|
|
|
|
settings.SetShowDisksIcon(fShowDisksIconRadioButton->Value() == 1);
|
|
|
|
settings.SetMountVolumesOntoDesktop(
|
|
|
|
fMountVolumesOntoDesktopRadioButton->Value() == 1);
|
|
|
|
settings.SetMountSharedVolumesOntoDesktop(
|
|
|
|
fMountSharedVolumesOntoDesktopCheckBox->Value() == 1);
|
|
|
|
|
|
|
|
// Construct the notification message:
|
|
|
|
BMessage notificationMessage;
|
|
|
|
notificationMessage.AddBool("ShowDisksIcon",
|
|
|
|
fShowDisksIconRadioButton->Value() == 1);
|
|
|
|
notificationMessage.AddBool("MountVolumesOntoDesktop",
|
|
|
|
fMountVolumesOntoDesktopRadioButton->Value() == 1);
|
|
|
|
notificationMessage.AddBool("MountSharedVolumesOntoDesktop",
|
|
|
|
fMountSharedVolumesOntoDesktopCheckBox->Value() == 1);
|
|
|
|
|
|
|
|
// Send the notification message:
|
|
|
|
tracker->SendNotices(kVolumesOnDesktopChanged, ¬ificationMessage);
|
|
|
|
|
|
|
|
// Tell the settings window the contents have changed:
|
|
|
|
Window()->PostMessage(kSettingsContentsModified);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case kVolumesOnDesktopChanged:
|
|
|
|
{
|
|
|
|
// Turn on and off related settings:
|
|
|
|
fShowDisksIconRadioButton->SetValue(
|
|
|
|
!fMountVolumesOntoDesktopRadioButton->Value() == 1);
|
|
|
|
fMountSharedVolumesOntoDesktopCheckBox->SetEnabled(
|
|
|
|
fMountVolumesOntoDesktopRadioButton->Value() == 1);
|
|
|
|
|
|
|
|
// Set the new settings in the tracker:
|
|
|
|
settings.SetShowDisksIcon(fShowDisksIconRadioButton->Value() == 1);
|
|
|
|
settings.SetMountVolumesOntoDesktop(
|
|
|
|
fMountVolumesOntoDesktopRadioButton->Value() == 1);
|
|
|
|
settings.SetMountSharedVolumesOntoDesktop(
|
|
|
|
fMountSharedVolumesOntoDesktopCheckBox->Value() == 1);
|
|
|
|
|
|
|
|
// Construct the notification message:
|
|
|
|
BMessage notificationMessage;
|
|
|
|
notificationMessage.AddBool("ShowDisksIcon",
|
|
|
|
fShowDisksIconRadioButton->Value() == 1);
|
|
|
|
notificationMessage.AddBool("MountVolumesOntoDesktop",
|
|
|
|
fMountVolumesOntoDesktopRadioButton->Value() == 1);
|
|
|
|
notificationMessage.AddBool("MountSharedVolumesOntoDesktop",
|
|
|
|
fMountSharedVolumesOntoDesktopCheckBox->Value() == 1);
|
|
|
|
|
|
|
|
// Send the notification message:
|
|
|
|
tracker->SendNotices(kVolumesOnDesktopChanged, ¬ificationMessage);
|
|
|
|
|
|
|
|
// Tell the settings window the contents have changed:
|
|
|
|
Window()->PostMessage(kSettingsContentsModified);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case kDesktopIntegrationChanged:
|
|
|
|
{
|
|
|
|
// Set the new settings in the tracker:
|
|
|
|
settings.SetIntegrateNonBootBeOSDesktops(
|
|
|
|
fIntegrateNonBootBeOSDesktopsCheckBox->Value() == 1);
|
|
|
|
|
|
|
|
// Construct the notification message:
|
|
|
|
BMessage notificationMessage;
|
|
|
|
notificationMessage.AddBool("MountVolumesOntoDesktop",
|
|
|
|
fMountVolumesOntoDesktopRadioButton->Value() == 1);
|
|
|
|
notificationMessage.AddBool("MountSharedVolumesOntoDesktop",
|
|
|
|
fMountSharedVolumesOntoDesktopCheckBox->Value() == 1);
|
|
|
|
notificationMessage.AddBool("IntegrateNonBootBeOSDesktops",
|
|
|
|
fIntegrateNonBootBeOSDesktopsCheckBox->Value() == 1);
|
|
|
|
|
2006-06-01 14:47:12 +04:00
|
|
|
// Send the notification message
|
2005-05-23 04:58:42 +04:00
|
|
|
tracker->SendNotices(kDesktopIntegrationChanged, ¬ificationMessage);
|
|
|
|
|
2006-06-01 14:47:12 +04:00
|
|
|
// Tell the settings window the contents have changed
|
2005-05-23 04:58:42 +04:00
|
|
|
Window()->PostMessage(kSettingsContentsModified);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case kEjectWhenUnmountingChanged:
|
|
|
|
{
|
|
|
|
settings.SetEjectWhenUnmounting(
|
|
|
|
fEjectWhenUnmountingCheckBox->Value() == 1);
|
|
|
|
|
2006-06-01 14:47:12 +04:00
|
|
|
// Send the notification message
|
|
|
|
send_bool_notices(kEjectWhenUnmountingChanged,
|
|
|
|
"EjectWhenUnmounting", fEjectWhenUnmountingCheckBox->Value() == 1);
|
|
|
|
|
|
|
|
// Tell the settings window the contents have changed
|
2005-05-23 04:58:42 +04:00
|
|
|
Window()->PostMessage(kSettingsContentsModified);
|
|
|
|
break;
|
|
|
|
}
|
2006-06-01 14:47:12 +04:00
|
|
|
|
2005-05-23 04:58:42 +04:00
|
|
|
default:
|
|
|
|
_inherited::MessageReceived(message);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-06-01 14:47:12 +04:00
|
|
|
|
2005-05-23 04:58:42 +04:00
|
|
|
void
|
|
|
|
DesktopSettingsView::SetDefaults()
|
|
|
|
{
|
|
|
|
// ToDo: Avoid the duplication of the default values.
|
|
|
|
TrackerSettings settings;
|
|
|
|
|
|
|
|
settings.SetShowDisksIcon(false);
|
|
|
|
settings.SetMountVolumesOntoDesktop(true);
|
|
|
|
settings.SetMountSharedVolumesOntoDesktop(false);
|
2006-06-01 14:47:12 +04:00
|
|
|
settings.SetIntegrateNonBootBeOSDesktops(false);
|
2005-05-23 04:58:42 +04:00
|
|
|
settings.SetEjectWhenUnmounting(true);
|
|
|
|
|
2006-06-01 14:47:12 +04:00
|
|
|
ShowCurrentSettings();
|
|
|
|
_SendNotices();
|
2005-05-23 04:58:42 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
DesktopSettingsView::Revert()
|
|
|
|
{
|
|
|
|
TrackerSettings settings;
|
|
|
|
|
|
|
|
settings.SetShowDisksIcon(fShowDisksIcon);
|
|
|
|
settings.SetMountVolumesOntoDesktop(fMountVolumesOntoDesktop);
|
|
|
|
settings.SetMountSharedVolumesOntoDesktop(fMountSharedVolumesOntoDesktop);
|
|
|
|
settings.SetIntegrateNonBootBeOSDesktops(fIntegrateNonBootBeOSDesktops);
|
|
|
|
settings.SetEjectWhenUnmounting(fEjectWhenUnmounting);
|
|
|
|
|
2006-06-01 14:47:12 +04:00
|
|
|
ShowCurrentSettings();
|
|
|
|
_SendNotices();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
DesktopSettingsView::_SendNotices()
|
|
|
|
{
|
|
|
|
TTracker *tracker = dynamic_cast<TTracker *>(be_app);
|
|
|
|
if (!tracker)
|
|
|
|
return;
|
|
|
|
|
|
|
|
// Construct the notification message:
|
|
|
|
BMessage notificationMessage;
|
|
|
|
notificationMessage.AddBool("ShowDisksIcon",
|
|
|
|
fShowDisksIconRadioButton->Value() == 1);
|
|
|
|
notificationMessage.AddBool("MountVolumesOntoDesktop",
|
|
|
|
fMountVolumesOntoDesktopRadioButton->Value() == 1);
|
|
|
|
notificationMessage.AddBool("MountSharedVolumesOntoDesktop",
|
|
|
|
fMountSharedVolumesOntoDesktopCheckBox->Value() == 1);
|
|
|
|
notificationMessage.AddBool("IntegrateNonBootBeOSDesktops",
|
|
|
|
fIntegrateNonBootBeOSDesktopsCheckBox->Value() == 1);
|
|
|
|
notificationMessage.AddBool("EjectWhenUnmounting",
|
|
|
|
fEjectWhenUnmountingCheckBox->Value() == 1);
|
|
|
|
|
|
|
|
// Send notices to the tracker about the change:
|
|
|
|
tracker->SendNotices(kVolumesOnDesktopChanged, ¬ificationMessage);
|
|
|
|
tracker->SendNotices(kDesktopIntegrationChanged, ¬ificationMessage);
|
2005-05-23 04:58:42 +04:00
|
|
|
}
|
|
|
|
|
2006-06-01 14:47:12 +04:00
|
|
|
|
2005-05-23 04:58:42 +04:00
|
|
|
void
|
2006-06-01 14:47:12 +04:00
|
|
|
DesktopSettingsView::ShowCurrentSettings()
|
2005-05-23 04:58:42 +04:00
|
|
|
{
|
|
|
|
TrackerSettings settings;
|
|
|
|
|
|
|
|
fShowDisksIconRadioButton->SetValue(settings.ShowDisksIcon());
|
|
|
|
fMountVolumesOntoDesktopRadioButton->SetValue(settings.MountVolumesOntoDesktop());
|
|
|
|
|
|
|
|
fMountSharedVolumesOntoDesktopCheckBox->SetValue(settings.MountSharedVolumesOntoDesktop());
|
|
|
|
fMountSharedVolumesOntoDesktopCheckBox->SetEnabled(settings.MountVolumesOntoDesktop());
|
|
|
|
|
|
|
|
fIntegrateNonBootBeOSDesktopsCheckBox->SetValue(settings.IntegrateNonBootBeOSDesktops());
|
|
|
|
|
|
|
|
fEjectWhenUnmountingCheckBox->SetValue(settings.EjectWhenUnmounting());
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
DesktopSettingsView::RecordRevertSettings()
|
|
|
|
{
|
|
|
|
TrackerSettings settings;
|
|
|
|
|
|
|
|
fShowDisksIcon = settings.ShowDisksIcon();
|
|
|
|
fMountVolumesOntoDesktop = settings.MountVolumesOntoDesktop();
|
|
|
|
fMountSharedVolumesOntoDesktop = settings.MountSharedVolumesOntoDesktop();
|
|
|
|
fIntegrateNonBootBeOSDesktops = settings.IntegrateNonBootBeOSDesktops();
|
|
|
|
fEjectWhenUnmounting = settings.EjectWhenUnmounting();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool
|
2006-06-01 14:47:12 +04:00
|
|
|
DesktopSettingsView::IsRevertable() const
|
2005-05-23 04:58:42 +04:00
|
|
|
{
|
2006-06-01 14:47:12 +04:00
|
|
|
return fShowDisksIcon != (fShowDisksIconRadioButton->Value() > 0)
|
|
|
|
|| fMountVolumesOntoDesktop !=
|
|
|
|
(fMountVolumesOntoDesktopRadioButton->Value() > 0)
|
|
|
|
|| fMountSharedVolumesOntoDesktop !=
|
|
|
|
(fMountSharedVolumesOntoDesktopCheckBox->Value() > 0)
|
|
|
|
|| fIntegrateNonBootBeOSDesktops !=
|
|
|
|
(fIntegrateNonBootBeOSDesktopsCheckBox->Value() > 0)
|
|
|
|
|| fEjectWhenUnmounting !=
|
|
|
|
(fEjectWhenUnmountingCheckBox->Value() > 0);
|
2005-05-23 04:58:42 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// #pragma mark -
|
|
|
|
|
|
|
|
|
|
|
|
WindowsSettingsView::WindowsSettingsView(BRect rect)
|
2006-06-01 14:47:12 +04:00
|
|
|
: SettingsView(rect, "WindowsSettingsView")
|
2005-05-23 04:58:42 +04:00
|
|
|
{
|
2006-06-25 14:46:00 +04:00
|
|
|
rect.OffsetTo(B_ORIGIN);
|
2007-01-21 23:50:14 +03:00
|
|
|
fShowFullPathInTitleBarCheckBox = new BCheckBox(rect, "", "Show Folder Location in Title Bar",
|
2005-05-23 04:58:42 +04:00
|
|
|
new BMessage(kWindowsShowFullPathChanged));
|
|
|
|
fShowFullPathInTitleBarCheckBox->ResizeToPreferred();
|
2006-06-25 14:46:00 +04:00
|
|
|
AddChild(fShowFullPathInTitleBarCheckBox);
|
2005-05-23 04:58:42 +04:00
|
|
|
|
|
|
|
const float itemSpacing = fShowFullPathInTitleBarCheckBox->Bounds().Height() + kItemExtraSpacing;
|
2006-06-25 14:46:00 +04:00
|
|
|
rect.OffsetBy(0, itemSpacing);
|
2005-05-23 04:58:42 +04:00
|
|
|
|
2007-01-21 23:50:14 +03:00
|
|
|
fSingleWindowBrowseCheckBox = new BCheckBox(rect, "", "Single Window Navigation",
|
2005-05-23 04:58:42 +04:00
|
|
|
new BMessage(kSingleWindowBrowseChanged));
|
|
|
|
fSingleWindowBrowseCheckBox->ResizeToPreferred();
|
2006-06-25 14:46:00 +04:00
|
|
|
AddChild(fSingleWindowBrowseCheckBox);
|
2005-05-23 04:58:42 +04:00
|
|
|
|
2006-06-25 14:46:00 +04:00
|
|
|
rect.OffsetBy(20, itemSpacing);
|
2005-05-23 04:58:42 +04:00
|
|
|
|
2006-06-25 14:46:00 +04:00
|
|
|
fShowNavigatorCheckBox = new BCheckBox(rect, "", "Show Navigator",
|
2005-05-23 04:58:42 +04:00
|
|
|
new BMessage(kShowNavigatorChanged));
|
|
|
|
fShowNavigatorCheckBox->ResizeToPreferred();
|
2006-06-25 14:46:00 +04:00
|
|
|
AddChild(fShowNavigatorCheckBox);
|
2005-05-23 04:58:42 +04:00
|
|
|
|
2006-06-25 14:46:00 +04:00
|
|
|
rect.OffsetBy(-20, itemSpacing);
|
2005-05-23 04:58:42 +04:00
|
|
|
|
2006-06-25 14:46:00 +04:00
|
|
|
fOutlineSelectionCheckBox = new BCheckBox(rect, "", "Outline Selection Rectangle Only",
|
2005-05-23 04:58:42 +04:00
|
|
|
new BMessage(kTransparentSelectionChanged));
|
2006-06-01 14:47:12 +04:00
|
|
|
fOutlineSelectionCheckBox->ResizeToPreferred();
|
2006-06-25 14:46:00 +04:00
|
|
|
AddChild(fOutlineSelectionCheckBox);
|
2005-05-23 04:58:42 +04:00
|
|
|
|
2006-06-25 14:46:00 +04:00
|
|
|
rect.OffsetBy(0, itemSpacing);
|
2005-05-23 04:58:42 +04:00
|
|
|
|
2007-01-21 23:50:14 +03:00
|
|
|
fSortFolderNamesFirstCheckBox = new BCheckBox(rect, "", "List Folders First",
|
2005-05-23 04:58:42 +04:00
|
|
|
new BMessage(kSortFolderNamesFirstChanged));
|
|
|
|
fSortFolderNamesFirstCheckBox->ResizeToPreferred();
|
2006-06-25 14:46:00 +04:00
|
|
|
AddChild(fSortFolderNamesFirstCheckBox);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
WindowsSettingsView::GetPreferredSize(float *_width, float *_height)
|
|
|
|
{
|
|
|
|
if (_width != NULL)
|
|
|
|
*_width = fOutlineSelectionCheckBox->Frame().right;
|
|
|
|
|
|
|
|
if (_height != NULL)
|
|
|
|
*_height = fSortFolderNamesFirstCheckBox->Frame().bottom;
|
2005-05-23 04:58:42 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
WindowsSettingsView::AttachedToWindow()
|
|
|
|
{
|
|
|
|
fSingleWindowBrowseCheckBox->SetTarget(this);
|
|
|
|
fShowNavigatorCheckBox->SetTarget(this);
|
|
|
|
fShowFullPathInTitleBarCheckBox->SetTarget(this);
|
2006-06-01 14:47:12 +04:00
|
|
|
fOutlineSelectionCheckBox->SetTarget(this);
|
2005-05-23 04:58:42 +04:00
|
|
|
fSortFolderNamesFirstCheckBox->SetTarget(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
WindowsSettingsView::MessageReceived(BMessage *message)
|
|
|
|
{
|
|
|
|
TTracker *tracker = dynamic_cast<TTracker *>(be_app);
|
|
|
|
if (!tracker)
|
|
|
|
return;
|
|
|
|
TrackerSettings settings;
|
|
|
|
|
|
|
|
switch (message->what) {
|
|
|
|
case kWindowsShowFullPathChanged:
|
|
|
|
settings.SetShowFullPathInTitleBar(fShowFullPathInTitleBarCheckBox->Value() == 1);
|
|
|
|
tracker->SendNotices(kWindowsShowFullPathChanged);
|
|
|
|
Window()->PostMessage(kSettingsContentsModified);
|
|
|
|
break;
|
2006-06-01 14:47:12 +04:00
|
|
|
|
2005-05-23 04:58:42 +04:00
|
|
|
case kSingleWindowBrowseChanged:
|
|
|
|
settings.SetSingleWindowBrowse(fSingleWindowBrowseCheckBox->Value() == 1);
|
|
|
|
if (fSingleWindowBrowseCheckBox->Value() == 0) {
|
|
|
|
fShowNavigatorCheckBox->SetEnabled(false);
|
|
|
|
settings.SetShowNavigator(0);
|
|
|
|
} else {
|
|
|
|
fShowNavigatorCheckBox->SetEnabled(true);
|
|
|
|
settings.SetShowNavigator(fShowNavigatorCheckBox->Value() != 0);
|
|
|
|
}
|
|
|
|
tracker->SendNotices(kShowNavigatorChanged);
|
|
|
|
tracker->SendNotices(kSingleWindowBrowseChanged);
|
|
|
|
Window()->PostMessage(kSettingsContentsModified);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case kShowNavigatorChanged:
|
|
|
|
settings.SetShowNavigator(fShowNavigatorCheckBox->Value() == 1);
|
|
|
|
tracker->SendNotices(kShowNavigatorChanged);
|
|
|
|
Window()->PostMessage(kSettingsContentsModified);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case kTransparentSelectionChanged:
|
|
|
|
{
|
|
|
|
settings.SetTransparentSelection(
|
2006-06-01 14:47:12 +04:00
|
|
|
fOutlineSelectionCheckBox->Value() == B_CONTROL_OFF);
|
2005-05-23 04:58:42 +04:00
|
|
|
|
|
|
|
// Make the notification message and send it to the tracker:
|
2006-06-01 14:47:12 +04:00
|
|
|
send_bool_notices(kTransparentSelectionChanged,
|
|
|
|
"TransparentSelection", settings.TransparentSelection());
|
2005-05-23 04:58:42 +04:00
|
|
|
|
|
|
|
Window()->PostMessage(kSettingsContentsModified);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case kSortFolderNamesFirstChanged:
|
|
|
|
{
|
|
|
|
settings.SetSortFolderNamesFirst(fSortFolderNamesFirstCheckBox->Value() == 1);
|
|
|
|
|
|
|
|
// Make the notification message and send it to the tracker:
|
2006-06-01 14:47:12 +04:00
|
|
|
send_bool_notices(kSortFolderNamesFirstChanged, "SortFolderNamesFirst",
|
2005-05-23 04:58:42 +04:00
|
|
|
fSortFolderNamesFirstCheckBox->Value() == 1);
|
|
|
|
|
|
|
|
Window()->PostMessage(kSettingsContentsModified);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
default:
|
|
|
|
_inherited::MessageReceived(message);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
WindowsSettingsView::SetDefaults()
|
|
|
|
{
|
2006-06-01 14:47:12 +04:00
|
|
|
TTracker *tracker = dynamic_cast<TTracker *>(be_app);
|
|
|
|
if (!tracker)
|
|
|
|
return;
|
|
|
|
|
2005-05-23 04:58:42 +04:00
|
|
|
TrackerSettings settings;
|
|
|
|
|
2006-06-01 14:47:12 +04:00
|
|
|
if (settings.ShowFullPathInTitleBar()) {
|
|
|
|
settings.SetShowFullPathInTitleBar(false);
|
|
|
|
tracker->SendNotices(kWindowsShowFullPathChanged);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (settings.SingleWindowBrowse()) {
|
|
|
|
settings.SetSingleWindowBrowse(false);
|
|
|
|
tracker->SendNotices(kSingleWindowBrowseChanged);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (settings.ShowNavigator()) {
|
|
|
|
settings.SetShowNavigator(false);
|
|
|
|
tracker->SendNotices(kShowNavigatorChanged);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!settings.TransparentSelection()) {
|
|
|
|
settings.SetTransparentSelection(true);
|
|
|
|
send_bool_notices(kTransparentSelectionChanged,
|
|
|
|
"TransparentSelection", true);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (settings.SortFolderNamesFirst()) {
|
|
|
|
settings.SetSortFolderNamesFirst(false);
|
|
|
|
send_bool_notices(kSortFolderNamesFirstChanged,
|
|
|
|
"SortFolderNamesFirst", false);
|
|
|
|
}
|
2005-05-23 04:58:42 +04:00
|
|
|
|
2006-06-01 14:47:12 +04:00
|
|
|
ShowCurrentSettings();
|
2005-05-23 04:58:42 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
WindowsSettingsView::Revert()
|
|
|
|
{
|
2006-06-01 14:47:12 +04:00
|
|
|
TTracker *tracker = dynamic_cast<TTracker *>(be_app);
|
|
|
|
if (!tracker)
|
|
|
|
return;
|
|
|
|
|
2005-05-23 04:58:42 +04:00
|
|
|
TrackerSettings settings;
|
|
|
|
|
2006-06-01 14:47:12 +04:00
|
|
|
if (settings.ShowFullPathInTitleBar() != fShowFullPathInTitleBar) {
|
|
|
|
settings.SetShowFullPathInTitleBar(fShowFullPathInTitleBar);
|
|
|
|
tracker->SendNotices(kWindowsShowFullPathChanged);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (settings.SingleWindowBrowse() != fSingleWindowBrowse) {
|
|
|
|
settings.SetSingleWindowBrowse(fSingleWindowBrowse);
|
|
|
|
tracker->SendNotices(kSingleWindowBrowseChanged);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (settings.ShowNavigator() != fShowNavigator) {
|
|
|
|
settings.SetShowNavigator(fShowNavigator);
|
|
|
|
tracker->SendNotices(kShowNavigatorChanged);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (settings.TransparentSelection() != fTransparentSelection) {
|
|
|
|
settings.SetTransparentSelection(fTransparentSelection);
|
|
|
|
send_bool_notices(kTransparentSelectionChanged,
|
|
|
|
"TransparentSelection", fTransparentSelection);
|
|
|
|
}
|
2005-05-23 04:58:42 +04:00
|
|
|
|
2006-06-01 14:47:12 +04:00
|
|
|
if (settings.SortFolderNamesFirst() != fSortFolderNamesFirst) {
|
|
|
|
settings.SetSortFolderNamesFirst(fSortFolderNamesFirst);
|
|
|
|
send_bool_notices(kSortFolderNamesFirstChanged,
|
|
|
|
"SortFolderNamesFirst", fSortFolderNamesFirst);
|
|
|
|
}
|
|
|
|
|
|
|
|
ShowCurrentSettings();
|
2005-05-23 04:58:42 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
2006-06-01 14:47:12 +04:00
|
|
|
WindowsSettingsView::ShowCurrentSettings()
|
2005-05-23 04:58:42 +04:00
|
|
|
{
|
|
|
|
TrackerSettings settings;
|
|
|
|
|
|
|
|
fShowFullPathInTitleBarCheckBox->SetValue(settings.ShowFullPathInTitleBar());
|
|
|
|
fSingleWindowBrowseCheckBox->SetValue(settings.SingleWindowBrowse());
|
|
|
|
fShowNavigatorCheckBox->SetEnabled(settings.SingleWindowBrowse());
|
|
|
|
fShowNavigatorCheckBox->SetValue(settings.ShowNavigator());
|
2006-06-01 14:47:12 +04:00
|
|
|
fOutlineSelectionCheckBox->SetValue(settings.TransparentSelection()
|
|
|
|
? B_CONTROL_OFF : B_CONTROL_ON);
|
2005-05-23 04:58:42 +04:00
|
|
|
fSortFolderNamesFirstCheckBox->SetValue(settings.SortFolderNamesFirst());
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
WindowsSettingsView::RecordRevertSettings()
|
|
|
|
{
|
|
|
|
TrackerSettings settings;
|
|
|
|
|
|
|
|
fShowFullPathInTitleBar = settings.ShowFullPathInTitleBar();
|
|
|
|
fSingleWindowBrowse = settings.SingleWindowBrowse();
|
|
|
|
fShowNavigator = settings.ShowNavigator();
|
|
|
|
fTransparentSelection = settings.TransparentSelection();
|
|
|
|
fSortFolderNamesFirst = settings.SortFolderNamesFirst();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool
|
2006-06-01 14:47:12 +04:00
|
|
|
WindowsSettingsView::IsRevertable() const
|
2005-05-23 04:58:42 +04:00
|
|
|
{
|
2006-06-01 14:47:12 +04:00
|
|
|
TrackerSettings settings;
|
|
|
|
|
|
|
|
return fShowFullPathInTitleBar != settings.ShowFullPathInTitleBar()
|
|
|
|
|| fSingleWindowBrowse != settings.SingleWindowBrowse()
|
|
|
|
|| fShowNavigator != settings.ShowNavigator()
|
|
|
|
|| fTransparentSelection != settings.TransparentSelection()
|
|
|
|
|| fSortFolderNamesFirst != settings.SortFolderNamesFirst();
|
2005-05-23 04:58:42 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// #pragma mark -
|
|
|
|
|
|
|
|
|
|
|
|
TimeFormatSettingsView::TimeFormatSettingsView(BRect rect)
|
2006-06-01 14:47:12 +04:00
|
|
|
: SettingsView(rect, "WindowsSettingsView")
|
2005-05-23 04:58:42 +04:00
|
|
|
{
|
2006-06-25 14:46:00 +04:00
|
|
|
rect.OffsetTo(B_ORIGIN);
|
2005-05-23 04:58:42 +04:00
|
|
|
|
2006-06-25 14:46:00 +04:00
|
|
|
font_height fontHeight;
|
|
|
|
be_bold_font->GetHeight(&fontHeight);
|
2006-06-01 14:47:12 +04:00
|
|
|
|
2006-06-25 14:46:00 +04:00
|
|
|
rect.bottom = ceilf(fontHeight.ascent + fontHeight.descent) + 10;
|
|
|
|
BBox *clockBox = new BBox(rect, "Clock");
|
|
|
|
clockBox->SetLabel("Clock");
|
2005-05-23 04:58:42 +04:00
|
|
|
AddChild(clockBox);
|
2006-06-01 14:47:12 +04:00
|
|
|
|
2006-06-25 14:46:00 +04:00
|
|
|
rect.left = 8;
|
|
|
|
rect.top = rect.bottom - 8;
|
|
|
|
f24HrRadioButton = new BRadioButton(rect, "", "24 Hour",
|
2005-05-23 04:58:42 +04:00
|
|
|
new BMessage(kSettingsContentsModified));
|
|
|
|
f24HrRadioButton->ResizeToPreferred();
|
2006-06-25 14:46:00 +04:00
|
|
|
clockBox->AddChild(f24HrRadioButton);
|
2005-05-23 04:58:42 +04:00
|
|
|
|
|
|
|
const float itemSpacing = f24HrRadioButton->Bounds().Height() + kItemExtraSpacing;
|
2006-06-25 14:46:00 +04:00
|
|
|
rect.OffsetBy(0, itemSpacing);
|
2005-05-23 04:58:42 +04:00
|
|
|
|
2006-06-25 14:46:00 +04:00
|
|
|
f12HrRadioButton = new BRadioButton(rect, "", "12 Hour",
|
2005-05-23 04:58:42 +04:00
|
|
|
new BMessage(kSettingsContentsModified));
|
|
|
|
f12HrRadioButton->ResizeToPreferred();
|
2006-06-25 14:46:00 +04:00
|
|
|
clockBox->AddChild(f12HrRadioButton);
|
2005-05-23 04:58:42 +04:00
|
|
|
|
2006-06-25 14:46:00 +04:00
|
|
|
float width = max_c(f12HrRadioButton->Frame().right, f24HrRadioButton->Frame().right) + 8.0f;
|
|
|
|
clockBox->ResizeTo(width, clockBox->Bounds().Height()
|
|
|
|
+ 3 * f12HrRadioButton->Frame().Height());
|
2005-05-23 04:58:42 +04:00
|
|
|
|
2006-06-25 14:46:00 +04:00
|
|
|
rect = clockBox->Frame();
|
|
|
|
rect.OffsetBy(rect.Width() + 8, 0);
|
|
|
|
BBox *dateFormatBox = new BBox(rect, "Date Order");
|
2005-05-23 04:58:42 +04:00
|
|
|
dateFormatBox->SetLabel("Date Order");
|
|
|
|
AddChild(dateFormatBox);
|
2006-06-01 14:47:12 +04:00
|
|
|
|
2006-06-25 14:46:00 +04:00
|
|
|
rect = f24HrRadioButton->Frame();
|
|
|
|
fYMDRadioButton = new BRadioButton(rect, "", "Year-Month-Day",
|
2005-05-23 04:58:42 +04:00
|
|
|
new BMessage(kSettingsContentsModified));
|
|
|
|
fYMDRadioButton->ResizeToPreferred();
|
2006-06-25 14:46:00 +04:00
|
|
|
dateFormatBox->AddChild(fYMDRadioButton);
|
2005-05-23 04:58:42 +04:00
|
|
|
|
2006-06-25 14:46:00 +04:00
|
|
|
rect.OffsetBy(0, itemSpacing);
|
2005-05-23 04:58:42 +04:00
|
|
|
|
2006-06-25 14:46:00 +04:00
|
|
|
fDMYRadioButton = new BRadioButton(rect, "", "Day-Month-Year",
|
2005-05-23 04:58:42 +04:00
|
|
|
new BMessage(kSettingsContentsModified));
|
|
|
|
fDMYRadioButton->ResizeToPreferred();
|
2006-06-25 14:46:00 +04:00
|
|
|
dateFormatBox->AddChild(fDMYRadioButton);
|
2005-05-23 04:58:42 +04:00
|
|
|
|
2006-06-25 14:46:00 +04:00
|
|
|
rect.OffsetBy(0, itemSpacing);
|
2005-05-23 04:58:42 +04:00
|
|
|
|
2006-06-25 14:46:00 +04:00
|
|
|
fMDYRadioButton = new BRadioButton(rect, "", "Month-Day-Year",
|
2005-05-23 04:58:42 +04:00
|
|
|
new BMessage(kSettingsContentsModified));
|
|
|
|
fMDYRadioButton->ResizeToPreferred();
|
2006-06-25 14:46:00 +04:00
|
|
|
dateFormatBox->AddChild(fMDYRadioButton);
|
2005-05-23 04:58:42 +04:00
|
|
|
|
2006-06-25 14:46:00 +04:00
|
|
|
dateFormatBox->ResizeTo(fYMDRadioButton->Bounds().Width() + 16,
|
|
|
|
dateFormatBox->Bounds().Height());
|
2005-05-23 04:58:42 +04:00
|
|
|
|
|
|
|
BPopUpMenu *menu = new BPopUpMenu("Separator");
|
|
|
|
menu->AddItem(new BMenuItem("None", new BMessage(kSettingsContentsModified)));
|
|
|
|
menu->AddItem(new BMenuItem("Space", new BMessage(kSettingsContentsModified)));
|
|
|
|
menu->AddItem(new BMenuItem("-", new BMessage(kSettingsContentsModified)));
|
|
|
|
menu->AddItem(new BMenuItem("/", new BMessage(kSettingsContentsModified)));
|
|
|
|
menu->AddItem(new BMenuItem("\\", new BMessage(kSettingsContentsModified)));
|
|
|
|
menu->AddItem(new BMenuItem(".", new BMessage(kSettingsContentsModified)));
|
|
|
|
|
2006-06-25 14:46:00 +04:00
|
|
|
rect.left = 0;
|
|
|
|
rect.top = clockBox->Frame().bottom + 8;
|
|
|
|
rect.right = Bounds().Width() - 8;
|
|
|
|
rect.bottom = rect.top + itemSpacing;
|
|
|
|
fSeparatorMenuField = new BMenuField(rect, "Separator", "Separator:", menu);
|
|
|
|
fSeparatorMenuField->SetDivider(fSeparatorMenuField->StringWidth(fSeparatorMenuField->Label()) + 8.0f);
|
|
|
|
fSeparatorMenuField->SetAlignment(B_ALIGN_LEFT);
|
2005-05-23 04:58:42 +04:00
|
|
|
fSeparatorMenuField->ResizeToPreferred();
|
|
|
|
AddChild(fSeparatorMenuField);
|
|
|
|
|
2006-06-25 14:46:00 +04:00
|
|
|
rect.OffsetBy(0, itemSpacing + 10);
|
2006-06-01 14:47:12 +04:00
|
|
|
|
2006-06-25 14:46:00 +04:00
|
|
|
BStringView *exampleView = new BStringView(rect, "", "Examples:");
|
2005-05-23 04:58:42 +04:00
|
|
|
exampleView->ResizeToPreferred();
|
2006-06-25 14:46:00 +04:00
|
|
|
AddChild(exampleView);
|
2006-06-01 14:47:12 +04:00
|
|
|
|
2006-06-25 14:46:00 +04:00
|
|
|
rect.OffsetBy(0, itemSpacing);
|
2005-05-23 04:58:42 +04:00
|
|
|
|
2006-06-25 14:46:00 +04:00
|
|
|
fLongDateExampleView = new BStringView(rect, "", "");
|
2005-05-23 04:58:42 +04:00
|
|
|
fLongDateExampleView->ResizeToPreferred();
|
2006-06-25 14:46:00 +04:00
|
|
|
AddChild(fLongDateExampleView);
|
2005-05-23 04:58:42 +04:00
|
|
|
|
2006-06-25 14:46:00 +04:00
|
|
|
rect.OffsetBy(0, itemSpacing);
|
2005-05-23 04:58:42 +04:00
|
|
|
|
2006-06-25 14:46:00 +04:00
|
|
|
fShortDateExampleView = new BStringView(rect, "", "");
|
2005-05-23 04:58:42 +04:00
|
|
|
fShortDateExampleView->ResizeToPreferred();
|
2006-06-25 14:46:00 +04:00
|
|
|
AddChild(fShortDateExampleView);
|
2005-05-23 04:58:42 +04:00
|
|
|
|
2006-06-01 14:47:12 +04:00
|
|
|
_UpdateExamples();
|
2005-05-23 04:58:42 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-06-25 14:46:00 +04:00
|
|
|
void
|
|
|
|
TimeFormatSettingsView::GetPreferredSize(float *_width, float *_height)
|
|
|
|
{
|
|
|
|
if (_width != NULL) {
|
|
|
|
BView* view = fMDYRadioButton->Parent();
|
|
|
|
if (view != NULL)
|
|
|
|
*_width = view->Frame().right;
|
|
|
|
else
|
|
|
|
*_width = Bounds().Width();
|
|
|
|
}
|
|
|
|
|
|
|
|
if (_height != NULL)
|
|
|
|
*_height = fShortDateExampleView->Frame().bottom;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-05-23 04:58:42 +04:00
|
|
|
void
|
|
|
|
TimeFormatSettingsView::AttachedToWindow()
|
|
|
|
{
|
|
|
|
f24HrRadioButton->SetTarget(this);
|
|
|
|
f12HrRadioButton->SetTarget(this);
|
|
|
|
fYMDRadioButton->SetTarget(this);
|
|
|
|
fDMYRadioButton->SetTarget(this);
|
|
|
|
fMDYRadioButton->SetTarget(this);
|
2006-06-01 14:47:12 +04:00
|
|
|
|
2005-05-23 04:58:42 +04:00
|
|
|
fSeparatorMenuField->Menu()->SetTargetForItems(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
TimeFormatSettingsView::MessageReceived(BMessage *message)
|
|
|
|
{
|
|
|
|
TTracker *tracker = dynamic_cast<TTracker *>(be_app);
|
|
|
|
if (!tracker)
|
|
|
|
return;
|
|
|
|
TrackerSettings settings;
|
|
|
|
|
|
|
|
switch (message->what) {
|
|
|
|
case kSettingsContentsModified:
|
|
|
|
{
|
|
|
|
int32 separator = 0;
|
|
|
|
BMenuItem *item = fSeparatorMenuField->Menu()->FindMarked();
|
|
|
|
if (item) {
|
|
|
|
separator = fSeparatorMenuField->Menu()->IndexOf(item);
|
|
|
|
if (separator >= 0)
|
|
|
|
settings.SetTimeFormatSeparator((FormatSeparator)separator);
|
|
|
|
}
|
2006-06-01 14:47:12 +04:00
|
|
|
|
2005-05-23 04:58:42 +04:00
|
|
|
DateOrder format =
|
|
|
|
fYMDRadioButton->Value() ? kYMDFormat :
|
|
|
|
fDMYRadioButton->Value() ? kDMYFormat : kMDYFormat;
|
2006-06-01 14:47:12 +04:00
|
|
|
|
2005-05-23 04:58:42 +04:00
|
|
|
settings.SetDateOrderFormat(format);
|
|
|
|
settings.SetClockTo24Hr(f24HrRadioButton->Value() == 1);
|
|
|
|
|
|
|
|
// Make the notification message and send it to the tracker:
|
|
|
|
BMessage notificationMessage;
|
|
|
|
notificationMessage.AddInt32("TimeFormatSeparator", separator);
|
|
|
|
notificationMessage.AddInt32("DateOrderFormat", format);
|
|
|
|
notificationMessage.AddBool("24HrClock", f24HrRadioButton->Value() == 1);
|
|
|
|
tracker->SendNotices(kDateFormatChanged, ¬ificationMessage);
|
|
|
|
|
2006-06-01 14:47:12 +04:00
|
|
|
_UpdateExamples();
|
2005-05-23 04:58:42 +04:00
|
|
|
|
|
|
|
Window()->PostMessage(kSettingsContentsModified);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
default:
|
|
|
|
_inherited::MessageReceived(message);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
TimeFormatSettingsView::SetDefaults()
|
|
|
|
{
|
|
|
|
TrackerSettings settings;
|
|
|
|
|
|
|
|
settings.SetTimeFormatSeparator(kSlashSeparator);
|
|
|
|
settings.SetDateOrderFormat(kMDYFormat);
|
|
|
|
settings.SetClockTo24Hr(false);
|
|
|
|
|
2006-06-01 14:47:12 +04:00
|
|
|
ShowCurrentSettings();
|
|
|
|
_SendNotices();
|
2005-05-23 04:58:42 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
TimeFormatSettingsView::Revert()
|
|
|
|
{
|
|
|
|
TrackerSettings settings;
|
|
|
|
|
|
|
|
settings.SetTimeFormatSeparator(fSeparator);
|
|
|
|
settings.SetDateOrderFormat(fFormat);
|
|
|
|
settings.SetClockTo24Hr(f24HrClock);
|
|
|
|
|
2006-06-01 14:47:12 +04:00
|
|
|
ShowCurrentSettings();
|
|
|
|
_SendNotices();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
TimeFormatSettingsView::_SendNotices()
|
|
|
|
{
|
|
|
|
TTracker *tracker = dynamic_cast<TTracker *>(be_app);
|
|
|
|
if (!tracker)
|
|
|
|
return;
|
|
|
|
|
|
|
|
TrackerSettings settings;
|
|
|
|
|
|
|
|
// Make the notification message and send it to the tracker:
|
|
|
|
BMessage notificationMessage;
|
|
|
|
notificationMessage.AddInt32("TimeFormatSeparator", (int32)settings.TimeFormatSeparator());
|
|
|
|
notificationMessage.AddInt32("DateOrderFormat", (int32)settings.DateOrderFormat());
|
|
|
|
notificationMessage.AddBool("24HrClock", settings.ClockIs24Hr());
|
|
|
|
tracker->SendNotices(kDateFormatChanged, ¬ificationMessage);
|
2005-05-23 04:58:42 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
2006-06-01 14:47:12 +04:00
|
|
|
TimeFormatSettingsView::ShowCurrentSettings()
|
2005-05-23 04:58:42 +04:00
|
|
|
{
|
|
|
|
TrackerSettings settings;
|
|
|
|
|
|
|
|
f24HrRadioButton->SetValue(settings.ClockIs24Hr());
|
|
|
|
f12HrRadioButton->SetValue(!settings.ClockIs24Hr());
|
2006-06-01 14:47:12 +04:00
|
|
|
|
2005-05-23 04:58:42 +04:00
|
|
|
switch (settings.DateOrderFormat()) {
|
|
|
|
case kYMDFormat:
|
|
|
|
fYMDRadioButton->SetValue(1);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case kMDYFormat:
|
|
|
|
fMDYRadioButton->SetValue(1);
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
case kDMYFormat:
|
|
|
|
fDMYRadioButton->SetValue(1);
|
|
|
|
break;
|
|
|
|
}
|
2006-06-01 14:47:12 +04:00
|
|
|
|
2005-05-23 04:58:42 +04:00
|
|
|
FormatSeparator separator = settings.TimeFormatSeparator();
|
2006-06-01 14:47:12 +04:00
|
|
|
|
2005-05-23 04:58:42 +04:00
|
|
|
if (separator >= kNoSeparator && separator < kSeparatorsEnd)
|
|
|
|
fSeparatorMenuField->Menu()->ItemAt((int32)separator)->SetMarked(true);
|
|
|
|
|
2006-06-01 14:47:12 +04:00
|
|
|
_UpdateExamples();
|
2005-05-23 04:58:42 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
TimeFormatSettingsView::RecordRevertSettings()
|
|
|
|
{
|
|
|
|
TrackerSettings settings;
|
|
|
|
|
|
|
|
f24HrClock = settings.ClockIs24Hr();
|
|
|
|
fSeparator = settings.TimeFormatSeparator();
|
|
|
|
fFormat = settings.DateOrderFormat();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool
|
2006-06-01 14:47:12 +04:00
|
|
|
TimeFormatSettingsView::IsRevertable() const
|
2005-05-23 04:58:42 +04:00
|
|
|
{
|
|
|
|
FormatSeparator separator;
|
|
|
|
|
|
|
|
BMenuItem *item = fSeparatorMenuField->Menu()->FindMarked();
|
|
|
|
if (item) {
|
|
|
|
int32 index = fSeparatorMenuField->Menu()->IndexOf(item);
|
|
|
|
if (index >= 0)
|
|
|
|
separator = (FormatSeparator)index;
|
|
|
|
else
|
2006-06-01 14:47:12 +04:00
|
|
|
return true;
|
2005-05-23 04:58:42 +04:00
|
|
|
} else
|
2006-06-01 14:47:12 +04:00
|
|
|
return true;
|
|
|
|
|
2005-05-23 04:58:42 +04:00
|
|
|
DateOrder format =
|
|
|
|
fYMDRadioButton->Value() ? kYMDFormat :
|
|
|
|
(fDMYRadioButton->Value() ? kDMYFormat : kMDYFormat);
|
|
|
|
|
2006-06-01 14:47:12 +04:00
|
|
|
return f24HrClock != (f24HrRadioButton->Value() > 0)
|
|
|
|
|| separator != fSeparator
|
|
|
|
|| format != fFormat;
|
2005-05-23 04:58:42 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
2006-06-01 14:47:12 +04:00
|
|
|
TimeFormatSettingsView::_UpdateExamples()
|
2005-05-23 04:58:42 +04:00
|
|
|
{
|
|
|
|
time_t timeValue = (time_t)time(NULL);
|
|
|
|
tm timeData;
|
|
|
|
localtime_r(&timeValue, &timeData);
|
|
|
|
BString timeFormat = "Internal Error!";
|
|
|
|
char buffer[256];
|
|
|
|
|
|
|
|
FormatSeparator separator;
|
|
|
|
|
|
|
|
BMenuItem *item = fSeparatorMenuField->Menu()->FindMarked();
|
|
|
|
if (item) {
|
|
|
|
int32 index = fSeparatorMenuField->Menu()->IndexOf(item);
|
|
|
|
if (index >= 0)
|
|
|
|
separator = (FormatSeparator)index;
|
|
|
|
else
|
|
|
|
separator = kSlashSeparator;
|
|
|
|
} else
|
|
|
|
separator = kSlashSeparator;
|
|
|
|
|
|
|
|
DateOrder order =
|
|
|
|
fYMDRadioButton->Value() ? kYMDFormat :
|
|
|
|
(fDMYRadioButton->Value() ? kDMYFormat : kMDYFormat);
|
|
|
|
|
|
|
|
bool clockIs24hr = (f24HrRadioButton->Value() > 0);
|
|
|
|
|
|
|
|
TimeFormat(timeFormat, 0, separator, order, clockIs24hr);
|
|
|
|
strftime(buffer, 256, timeFormat.String(), &timeData);
|
|
|
|
|
|
|
|
fLongDateExampleView->SetText(buffer);
|
|
|
|
fLongDateExampleView->ResizeToPreferred();
|
|
|
|
|
|
|
|
TimeFormat(timeFormat, 4, separator, order, clockIs24hr);
|
|
|
|
strftime(buffer, 256, timeFormat.String(), &timeData);
|
|
|
|
|
|
|
|
fShortDateExampleView->SetText(buffer);
|
|
|
|
fShortDateExampleView->ResizeToPreferred();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// #pragma mark -
|
|
|
|
|
|
|
|
|
|
|
|
SpaceBarSettingsView::SpaceBarSettingsView(BRect rect)
|
2006-06-01 14:47:12 +04:00
|
|
|
: SettingsView(rect, "SpaceBarSettingsView")
|
2005-05-23 04:58:42 +04:00
|
|
|
{
|
2006-06-25 14:46:00 +04:00
|
|
|
rect.OffsetTo(B_ORIGIN);
|
2007-01-21 23:50:14 +03:00
|
|
|
fSpaceBarShowCheckBox = new BCheckBox(rect, "", "Show Space Bars on Volumes",
|
2005-05-23 04:58:42 +04:00
|
|
|
new BMessage(kUpdateVolumeSpaceBar));
|
|
|
|
fSpaceBarShowCheckBox->ResizeToPreferred();
|
2006-06-25 14:46:00 +04:00
|
|
|
AddChild(fSpaceBarShowCheckBox);
|
|
|
|
|
|
|
|
rect = fSpaceBarShowCheckBox->Frame();
|
|
|
|
rect.OffsetBy(0, fSpaceBarShowCheckBox->Bounds().Height() + kItemExtraSpacing);
|
|
|
|
|
2005-05-23 04:58:42 +04:00
|
|
|
BPopUpMenu *menu = new BPopUpMenu(B_EMPTY_STRING);
|
|
|
|
menu->SetFont(be_plain_font);
|
|
|
|
|
|
|
|
BMenuItem *item;
|
|
|
|
menu->AddItem(item = new BMenuItem("Used Space Color", new BMessage(kSpaceBarSwitchColor)));
|
|
|
|
item->SetMarked(true);
|
|
|
|
fCurrentColor = 0;
|
|
|
|
menu->AddItem(new BMenuItem("Free Space Color", new BMessage(kSpaceBarSwitchColor)));
|
|
|
|
menu->AddItem(new BMenuItem("Warning Space Color", new BMessage(kSpaceBarSwitchColor)));
|
|
|
|
|
2006-06-25 14:46:00 +04:00
|
|
|
BBox *box = new BBox(rect);
|
|
|
|
box->SetLabel(fColorPicker = new BMenuField(rect, NULL, NULL, menu));
|
2005-05-23 04:58:42 +04:00
|
|
|
AddChild(box);
|
|
|
|
|
2006-06-01 14:47:12 +04:00
|
|
|
fColorControl = new BColorControl(BPoint(8, fColorPicker->Bounds().Height()
|
|
|
|
+ 8 + kItemExtraSpacing),
|
|
|
|
B_CELLS_16x16, 1, "SpaceColorControl", new BMessage(kSpaceBarColorChanged));
|
2005-05-23 04:58:42 +04:00
|
|
|
fColorControl->SetValue(TrackerSettings().UsedSpaceColor());
|
|
|
|
fColorControl->ResizeToPreferred();
|
|
|
|
box->AddChild(fColorControl);
|
2006-06-25 14:46:00 +04:00
|
|
|
|
2006-06-01 14:47:12 +04:00
|
|
|
box->ResizeTo(fColorControl->Bounds().Width() + 16,
|
|
|
|
fColorControl->Frame().bottom + 8);
|
2005-05-23 04:58:42 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
SpaceBarSettingsView::~SpaceBarSettingsView()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-06-25 14:46:00 +04:00
|
|
|
void
|
|
|
|
SpaceBarSettingsView::GetPreferredSize(float *_width, float *_height)
|
|
|
|
{
|
|
|
|
BView* view = fColorControl->Parent();
|
|
|
|
if (view == NULL)
|
|
|
|
BView::GetPreferredSize(_width, _height);
|
|
|
|
|
|
|
|
if (_width != NULL) {
|
|
|
|
float width = fSpaceBarShowCheckBox->Bounds().Width();
|
|
|
|
if (view->Bounds().Width() > width)
|
|
|
|
width = view->Bounds().Width();
|
|
|
|
|
|
|
|
*_width = width;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (_height != NULL)
|
|
|
|
*_height = view->Frame().bottom;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-05-23 04:58:42 +04:00
|
|
|
void
|
|
|
|
SpaceBarSettingsView::AttachedToWindow()
|
|
|
|
{
|
|
|
|
fSpaceBarShowCheckBox->SetTarget(this);
|
|
|
|
fColorControl->SetTarget(this);
|
|
|
|
fColorPicker->Menu()->SetTargetForItems(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
SpaceBarSettingsView::MessageReceived(BMessage *message)
|
|
|
|
{
|
|
|
|
TTracker *tracker = dynamic_cast<TTracker *>(be_app);
|
|
|
|
if (!tracker)
|
|
|
|
return;
|
|
|
|
TrackerSettings settings;
|
|
|
|
|
|
|
|
switch (message->what) {
|
|
|
|
case kUpdateVolumeSpaceBar:
|
|
|
|
{
|
|
|
|
settings.SetShowVolumeSpaceBar(fSpaceBarShowCheckBox->Value() == 1);
|
|
|
|
Window()->PostMessage(kSettingsContentsModified);
|
|
|
|
BMessage notificationMessage;
|
|
|
|
notificationMessage.AddBool("ShowVolumeSpaceBar", settings.ShowVolumeSpaceBar());
|
|
|
|
tracker->SendNotices(kShowVolumeSpaceBar, ¬ificationMessage);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case kSpaceBarSwitchColor:
|
|
|
|
{
|
|
|
|
fCurrentColor = message->FindInt32("index");
|
|
|
|
switch (fCurrentColor) {
|
|
|
|
case 0:
|
|
|
|
fColorControl->SetValue(settings.UsedSpaceColor());
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
fColorControl->SetValue(settings.FreeSpaceColor());
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
fColorControl->SetValue(settings.WarningSpaceColor());
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case kSpaceBarColorChanged:
|
|
|
|
{
|
|
|
|
switch (fCurrentColor) {
|
|
|
|
case 0:
|
|
|
|
settings.SetUsedSpaceColor(fColorControl->ValueAsColor());
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
settings.SetFreeSpaceColor(fColorControl->ValueAsColor());
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
settings.SetWarningSpaceColor(fColorControl->ValueAsColor());
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
Window()->PostMessage(kSettingsContentsModified);
|
|
|
|
BMessage notificationMessage;
|
|
|
|
tracker->SendNotices(kSpaceBarColorChanged, ¬ificationMessage);
|
|
|
|
break;
|
|
|
|
}
|
2006-06-01 14:47:12 +04:00
|
|
|
|
2005-05-23 04:58:42 +04:00
|
|
|
default:
|
|
|
|
_inherited::MessageReceived(message);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
SpaceBarSettingsView::SetDefaults()
|
|
|
|
{
|
2006-06-01 14:47:12 +04:00
|
|
|
TTracker *tracker = dynamic_cast<TTracker *>(be_app);
|
|
|
|
if (!tracker)
|
|
|
|
return;
|
|
|
|
|
2005-05-23 04:58:42 +04:00
|
|
|
TrackerSettings settings;
|
|
|
|
|
2006-06-01 14:47:12 +04:00
|
|
|
if (settings.ShowVolumeSpaceBar()) {
|
|
|
|
settings.SetShowVolumeSpaceBar(false);
|
|
|
|
send_bool_notices(kShowVolumeSpaceBar, "ShowVolumeSpaceBar", false);
|
|
|
|
}
|
2005-05-23 04:58:42 +04:00
|
|
|
|
2006-06-01 14:47:12 +04:00
|
|
|
if (settings.UsedSpaceColor() != Color(0, 203, 0, 192)
|
|
|
|
|| settings.FreeSpaceColor() != Color(255, 255, 255, 192)
|
|
|
|
|| settings.WarningSpaceColor() != Color(203, 0, 0, 192)) {
|
|
|
|
settings.SetUsedSpaceColor(Color(0, 203, 0, 192));
|
|
|
|
settings.SetFreeSpaceColor(Color(255, 255, 255, 192));
|
|
|
|
settings.SetWarningSpaceColor(Color(203, 0, 0, 192));
|
|
|
|
tracker->SendNotices(kSpaceBarColorChanged);
|
|
|
|
}
|
2005-05-23 04:58:42 +04:00
|
|
|
|
2006-06-01 14:47:12 +04:00
|
|
|
ShowCurrentSettings();
|
2005-05-23 04:58:42 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
SpaceBarSettingsView::Revert()
|
|
|
|
{
|
2006-06-01 14:47:12 +04:00
|
|
|
TTracker *tracker = dynamic_cast<TTracker *>(be_app);
|
|
|
|
if (!tracker)
|
|
|
|
return;
|
|
|
|
|
2005-05-23 04:58:42 +04:00
|
|
|
TrackerSettings settings;
|
|
|
|
|
2006-06-01 14:47:12 +04:00
|
|
|
if (settings.ShowVolumeSpaceBar() != fSpaceBarShow) {
|
|
|
|
settings.SetShowVolumeSpaceBar(fSpaceBarShow);
|
|
|
|
send_bool_notices(kShowVolumeSpaceBar, "ShowVolumeSpaceBar", fSpaceBarShow);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (settings.UsedSpaceColor() != fUsedSpaceColor
|
|
|
|
|| settings.FreeSpaceColor() != fFreeSpaceColor
|
|
|
|
|| settings.WarningSpaceColor() != fWarningSpaceColor) {
|
|
|
|
settings.SetUsedSpaceColor(fUsedSpaceColor);
|
|
|
|
settings.SetFreeSpaceColor(fFreeSpaceColor);
|
|
|
|
settings.SetWarningSpaceColor(fWarningSpaceColor);
|
|
|
|
tracker->SendNotices(kSpaceBarColorChanged);
|
|
|
|
}
|
|
|
|
|
|
|
|
ShowCurrentSettings();
|
2005-05-23 04:58:42 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
2006-06-01 14:47:12 +04:00
|
|
|
SpaceBarSettingsView::ShowCurrentSettings()
|
2005-05-23 04:58:42 +04:00
|
|
|
{
|
|
|
|
TrackerSettings settings;
|
|
|
|
|
|
|
|
fSpaceBarShowCheckBox->SetValue(settings.ShowVolumeSpaceBar());
|
2006-06-01 14:47:12 +04:00
|
|
|
|
2005-05-23 04:58:42 +04:00
|
|
|
switch (fCurrentColor) {
|
|
|
|
case 0:
|
|
|
|
fColorControl->SetValue(settings.UsedSpaceColor());
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
fColorControl->SetValue(settings.FreeSpaceColor());
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
fColorControl->SetValue(settings.WarningSpaceColor());
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
SpaceBarSettingsView::RecordRevertSettings()
|
|
|
|
{
|
|
|
|
TrackerSettings settings;
|
2006-06-01 14:47:12 +04:00
|
|
|
|
2005-05-23 04:58:42 +04:00
|
|
|
fSpaceBarShow = settings.ShowVolumeSpaceBar();
|
|
|
|
fUsedSpaceColor = settings.UsedSpaceColor();
|
|
|
|
fFreeSpaceColor = settings.FreeSpaceColor();
|
|
|
|
fWarningSpaceColor = settings.WarningSpaceColor();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool
|
2006-06-01 14:47:12 +04:00
|
|
|
SpaceBarSettingsView::IsRevertable() const
|
2005-05-23 04:58:42 +04:00
|
|
|
{
|
2006-06-01 14:47:12 +04:00
|
|
|
TrackerSettings settings;
|
|
|
|
|
|
|
|
return fSpaceBarShow != (fSpaceBarShowCheckBox->Value() == B_CONTROL_ON)
|
|
|
|
|| fUsedSpaceColor != settings.UsedSpaceColor()
|
|
|
|
|| fFreeSpaceColor != settings.FreeSpaceColor()
|
|
|
|
|| fWarningSpaceColor != settings.WarningSpaceColor();
|
2005-05-23 04:58:42 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// #pragma mark -
|
|
|
|
|
|
|
|
|
|
|
|
TrashSettingsView::TrashSettingsView(BRect rect)
|
2006-06-01 14:47:12 +04:00
|
|
|
: SettingsView(rect, "TrashSettingsView")
|
2005-05-23 04:58:42 +04:00
|
|
|
{
|
2006-06-25 14:46:00 +04:00
|
|
|
rect.OffsetTo(B_ORIGIN);
|
2007-01-21 23:50:14 +03:00
|
|
|
fDontMoveFilesToTrashCheckBox = new BCheckBox(rect, "", "Don't Move Files to Trash",
|
2005-05-23 04:58:42 +04:00
|
|
|
new BMessage(kDontMoveFilesToTrashChanged));
|
|
|
|
fDontMoveFilesToTrashCheckBox->ResizeToPreferred();
|
2006-06-25 14:46:00 +04:00
|
|
|
AddChild(fDontMoveFilesToTrashCheckBox);
|
2005-05-23 04:58:42 +04:00
|
|
|
|
2006-06-25 14:46:00 +04:00
|
|
|
rect = fDontMoveFilesToTrashCheckBox->Frame();
|
|
|
|
rect.OffsetBy(0, fDontMoveFilesToTrashCheckBox->Bounds().Height() + kItemExtraSpacing);
|
2005-05-23 04:58:42 +04:00
|
|
|
|
2006-06-25 14:46:00 +04:00
|
|
|
fAskBeforeDeleteFileCheckBox = new BCheckBox(rect, "", "Ask Before Delete",
|
2005-05-23 04:58:42 +04:00
|
|
|
new BMessage(kAskBeforeDeleteFileChanged));
|
|
|
|
fAskBeforeDeleteFileCheckBox->ResizeToPreferred();
|
2006-06-25 14:46:00 +04:00
|
|
|
AddChild(fAskBeforeDeleteFileCheckBox);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
TrashSettingsView::GetPreferredSize(float *_width, float *_height)
|
|
|
|
{
|
|
|
|
if (_width != NULL) {
|
|
|
|
float width = fDontMoveFilesToTrashCheckBox->Bounds().Width();
|
|
|
|
if (width < fAskBeforeDeleteFileCheckBox->Bounds().Width())
|
|
|
|
width = fAskBeforeDeleteFileCheckBox->Bounds().Width();
|
|
|
|
|
|
|
|
*_width = width;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (_height != NULL)
|
|
|
|
*_height = fAskBeforeDeleteFileCheckBox->Frame().bottom;
|
2005-05-23 04:58:42 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
TrashSettingsView::AttachedToWindow()
|
|
|
|
{
|
|
|
|
fDontMoveFilesToTrashCheckBox->SetTarget(this);
|
|
|
|
fAskBeforeDeleteFileCheckBox->SetTarget(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
TrashSettingsView::MessageReceived(BMessage *message)
|
|
|
|
{
|
|
|
|
TTracker *tracker = dynamic_cast<TTracker *>(be_app);
|
|
|
|
if (!tracker)
|
|
|
|
return;
|
|
|
|
TrackerSettings settings;
|
|
|
|
|
|
|
|
switch (message->what) {
|
|
|
|
case kDontMoveFilesToTrashChanged:
|
|
|
|
settings.SetDontMoveFilesToTrash(fDontMoveFilesToTrashCheckBox->Value() == 1);
|
|
|
|
|
|
|
|
tracker->SendNotices(kDontMoveFilesToTrashChanged);
|
|
|
|
Window()->PostMessage(kSettingsContentsModified);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case kAskBeforeDeleteFileChanged:
|
|
|
|
settings.SetAskBeforeDeleteFile(fAskBeforeDeleteFileCheckBox->Value() == 1);
|
|
|
|
|
|
|
|
tracker->SendNotices(kAskBeforeDeleteFileChanged);
|
|
|
|
Window()->PostMessage(kSettingsContentsModified);
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
_inherited::MessageReceived(message);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
TrashSettingsView::SetDefaults()
|
|
|
|
{
|
|
|
|
TrackerSettings settings;
|
|
|
|
|
|
|
|
settings.SetDontMoveFilesToTrash(false);
|
|
|
|
settings.SetAskBeforeDeleteFile(true);
|
|
|
|
|
2006-06-01 14:47:12 +04:00
|
|
|
ShowCurrentSettings();
|
|
|
|
_SendNotices();
|
2005-05-23 04:58:42 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
TrashSettingsView::Revert()
|
|
|
|
{
|
|
|
|
TrackerSettings settings;
|
|
|
|
|
|
|
|
settings.SetDontMoveFilesToTrash(fDontMoveFilesToTrash);
|
|
|
|
settings.SetAskBeforeDeleteFile(fAskBeforeDeleteFile);
|
|
|
|
|
2006-06-01 14:47:12 +04:00
|
|
|
ShowCurrentSettings();
|
|
|
|
_SendNotices();
|
2005-05-23 04:58:42 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
2006-06-01 14:47:12 +04:00
|
|
|
TrashSettingsView::_SendNotices()
|
|
|
|
{
|
|
|
|
TTracker *tracker = dynamic_cast<TTracker *>(be_app);
|
|
|
|
if (!tracker)
|
|
|
|
return;
|
|
|
|
|
|
|
|
tracker->SendNotices(kDontMoveFilesToTrashChanged);
|
|
|
|
tracker->SendNotices(kAskBeforeDeleteFileChanged);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
TrashSettingsView::ShowCurrentSettings()
|
2005-05-23 04:58:42 +04:00
|
|
|
{
|
|
|
|
TrackerSettings settings;
|
|
|
|
|
|
|
|
fDontMoveFilesToTrashCheckBox->SetValue(settings.DontMoveFilesToTrash());
|
|
|
|
fAskBeforeDeleteFileCheckBox->SetValue(settings.AskBeforeDeleteFile());
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
TrashSettingsView::RecordRevertSettings()
|
|
|
|
{
|
|
|
|
TrackerSettings settings;
|
|
|
|
|
|
|
|
fDontMoveFilesToTrash = settings.DontMoveFilesToTrash();
|
|
|
|
fAskBeforeDeleteFile = settings.AskBeforeDeleteFile();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool
|
2006-06-01 14:47:12 +04:00
|
|
|
TrashSettingsView::IsRevertable() const
|
2005-05-23 04:58:42 +04:00
|
|
|
{
|
2006-06-01 14:47:12 +04:00
|
|
|
return fDontMoveFilesToTrash != (fDontMoveFilesToTrashCheckBox->Value() > 0)
|
|
|
|
|| fAskBeforeDeleteFile != (fAskBeforeDeleteFileCheckBox->Value() > 0);
|
2005-05-23 04:58:42 +04:00
|
|
|
}
|
|
|
|
|