From 7befa79ace38aeecb9ceb86e7244c6d6747fd888 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Axel=20D=C3=B6rfler?= Date: Thu, 1 Jun 2006 10:47:12 +0000 Subject: [PATCH] Imported SettingsViews.cpp 1.10, FilePanelPriv.cpp 1.14, TrackerSettingsWindow.cpp 1.7, SettingsViews.h 1.8, FSClipboard.cpp 1.12, PoseView.cpp 1.60, TrackerSettingsWindow.h 1.2, TrackerSettings.cpp 1.11 from the OpenTracker repository. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@17688 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/kits/tracker/FSClipboard.cpp | 103 +-- src/kits/tracker/FilePanelPriv.cpp | 280 ++++---- src/kits/tracker/PoseView.cpp | 32 +- src/kits/tracker/SettingsViews.cpp | 747 ++++++++++++--------- src/kits/tracker/SettingsViews.h | 314 ++++----- src/kits/tracker/TrackerSettings.cpp | 4 +- src/kits/tracker/TrackerSettingsWindow.cpp | 98 +-- src/kits/tracker/TrackerSettingsWindow.h | 54 +- 8 files changed, 887 insertions(+), 745 deletions(-) diff --git a/src/kits/tracker/FSClipboard.cpp b/src/kits/tracker/FSClipboard.cpp index c7b559e169..2b2ccc702d 100644 --- a/src/kits/tracker/FSClipboard.cpp +++ b/src/kits/tracker/FSClipboard.cpp @@ -61,6 +61,56 @@ FSClipboardCheckIntegrity() } */ +static void +MakeNodeFromName(node_ref *node, char *name) +{ + char *nodeString = strchr(name, '_'); + if (nodeString != NULL) { + node->node = strtoll(nodeString + 1, (char **)NULL, 10); + node->device = atoi(name + 1); + } +} + + +static inline void +MakeRefName(char *refName, const node_ref *node) +{ + sprintf(refName, "r%ld_%Ld", node->device, node->node); +} + + +static inline void +MakeModeName(char *modeName, const node_ref *node) +{ + sprintf(modeName, "m%ld_%Ld", node->device, node->node); +} + + +static inline void +MakeModeName(char *name) +{ + name[0] = 'm'; +} + + +static inline void +MakeModeNameFromRefName(char *modeName, char *refName) +{ + strcpy(modeName, refName); + modeName[0] = 'm'; +} + + +static inline bool +CompareModeAndRefName(const char *modeName, const char *refName) +{ + return !strcmp(refName + 1, modeName + 1); +} + + +// #pragma mark - + + bool FSClipboardHasRefs() { @@ -125,53 +175,6 @@ FSClipboardStopWatch(BMessenger target) } -static void -MakeNodeFromName(node_ref *node, char *name) -{ - char *nodeString = strchr(name, '_'); - if (nodeString != NULL) { - node->node = strtoll(nodeString + 1, (char **)NULL, 10); - node->device = atoi(name + 1); - } -} - - -static inline void -MakeRefName(char *refName, const node_ref *node) -{ - sprintf(refName, "r%ld_%Ld", node->device, node->node); -} - - -static inline void -MakeModeName(char *modeName, const node_ref *node) -{ - sprintf(modeName, "m%ld_%Ld", node->device, node->node); -} - - -static inline void -MakeModeName(char *name) -{ - name[0] = 'm'; -} - - -static inline void -MakeModeNameFromRefName(char *modeName, char *refName) -{ - strcpy(modeName, refName); - modeName[0] = 'm'; -} - - -static inline bool -CompareModeAndRefName(const char *modeName, const char *refName) -{ - return !strcmp(refName + 1, modeName + 1); -} - - void FSClipboardClear() { @@ -265,7 +268,7 @@ FSClipboardAddPoses(const node_ref *directory, PoseList *list, uint32 moveMode, clipNode.moveMode = moveMode; // set it back to current value } } else { - // add if it doesn't exist + // add it if it doesn't exist if (clip->AddRef(refName, model->EntryRef()) == B_OK && clip->AddInt32(modeName, (int32)moveMode) == B_OK) { pose->SetClipboardMode(moveMode); @@ -278,7 +281,8 @@ FSClipboardAddPoses(const node_ref *directory, PoseList *list, uint32 moveMode, } else { clip->RemoveName(modeName); clip->RemoveName(refName); - // here notifying delete isn't needed as node didn't exist in clipboard + // here notifying delete isn't needed as node didn't + // exist in clipboard } } } @@ -297,7 +301,6 @@ FSClipboardAddPoses(const node_ref *directory, PoseList *list, uint32 moveMode, uint32 FSClipboardRemovePoses(const node_ref *directory, PoseList *list) { - if (!be_clipboard->Lock()) return 0; diff --git a/src/kits/tracker/FilePanelPriv.cpp b/src/kits/tracker/FilePanelPriv.cpp index d713f171f2..5eaf902987 100644 --- a/src/kits/tracker/FilePanelPriv.cpp +++ b/src/kits/tracker/FilePanelPriv.cpp @@ -32,7 +32,24 @@ names are registered trademarks or trademarks of their respective holders. All rights reserved. */ -#include + +#include "Attributes.h" +#include "AttributeStream.h" +#include "AutoLock.h" +#include "Commands.h" +#include "DesktopPoseView.h" +#include "DirMenu.h" +#include "FavoritesConfig.h" +#include "FavoritesMenu.h" +#include "FilePanelPriv.h" +#include "FSUtils.h" +#include "FSClipboard.h" +#include "IconMenuItem.h" +#include "MimeTypes.h" +#include "NavMenu.h" +#include "PoseView.h" +#include "Tracker.h" +#include "tracker_private.h" #include #include @@ -57,23 +74,7 @@ All rights reserved. #include #include -#include "Attributes.h" -#include "AttributeStream.h" -#include "AutoLock.h" -#include "Commands.h" -#include "DesktopPoseView.h" -#include "DirMenu.h" -#include "FavoritesConfig.h" -#include "FavoritesMenu.h" -#include "FilePanelPriv.h" -#include "FSUtils.h" -#include "FSClipboard.h" -#include "IconMenuItem.h" -#include "MimeTypes.h" -#include "NavMenu.h" -#include "PoseView.h" -#include "Tracker.h" -#include "tracker_private.h" +#include const char *kDefaultFilePanelTemplate = "FilePanelSettings"; @@ -228,12 +229,12 @@ TFilePanel::TFilePanel(file_panel_mode mode, BMessenger *target, TFilePanel::~TFilePanel() { - // regardless of the hide/close method - // always get rid of the config window + // regardless of the hide/close method + // always get rid of the config window if (fConfigWindow) { - // moved from QuitRequested to ensure that - // if the config window is showing that - // it gets closed as well + // moved from QuitRequested to ensure that + // if the config window is showing that + // it gets closed as well fConfigWindow->Lock(); fConfigWindow->Quit(); } @@ -1028,10 +1029,8 @@ TFilePanel::MessageReceived(BMessage *message) case B_REFS_RECEIVED: // item was double clicked in file panel (PoseView) if (message->FindRef("refs", &ref) == B_OK) { - BEntry entry(&ref, true); if (entry.InitCheck() == B_OK) { - // Double-click on dir or link-to-dir ALWAYS opens the dir. // If more than one dir is selected, the // first is entered. @@ -1044,24 +1043,23 @@ TFilePanel::MessageReceived(BMessage *message) PoseView()->SwitchDir(&ref); SwitchDirMenuTo(&ref); } else { - // Otherwise, we have a file or a link to a file. // AdjustButton has already tested the flavor; // all we have to do is see if the button is enabled. BButton *button = dynamic_cast(FindView("default button")); if (!button) break; - + if (IsSavePanel()) { int32 count = 0; type_code type; message->GetInfo("refs", &type, &count); // Don't allow saves of multiple files - if (count > 1) + if (count > 1) { ShowCenteredAlert("Sorry, saving of more than one item is not allowed.", "Cancel"); - else { + } else { // if we are a savepanel, set up the filepanel correctly // then pass control so we follow the same path as if the user // clicked the save button @@ -1075,8 +1073,7 @@ TFilePanel::MessageReceived(BMessage *message) } break; } - - + // send handler a message and close BMessage openMessage(*fMessage); for (int32 index = 0; ; index++) { @@ -1089,124 +1086,125 @@ TFilePanel::MessageReceived(BMessage *message) } } break; - + case kSwitchDirectory: - { - entry_ref ref; - // this comes from dir menu or nav menu, so switch directories - if (message->FindRef("refs", &ref) == B_OK) { - BEntry entry(&ref, true); - if (entry.GetRef(&ref) == B_OK) - SetTo(&ref); - } + { + entry_ref ref; + // this comes from dir menu or nav menu, so switch directories + if (message->FindRef("refs", &ref) == B_OK) { + BEntry entry(&ref, true); + if (entry.GetRef(&ref) == B_OK) + SetTo(&ref); } break; - + } + case kSwitchToHome: - { - BPath homePath; - entry_ref ref; - if (find_directory(B_USER_DIRECTORY, &homePath) != B_OK - || get_ref_for_path(homePath.Path(), &ref) != B_OK) - break; - - SetTo(&ref); - } + { + BPath homePath; + entry_ref ref; + if (find_directory(B_USER_DIRECTORY, &homePath) != B_OK + || get_ref_for_path(homePath.Path(), &ref) != B_OK) + break; + + SetTo(&ref); break; + } case kAddCurrentDir: - { - BPath path; - if (find_directory (B_USER_SETTINGS_DIRECTORY, &path, true) != B_OK) - break; - - path.Append(kGoDirectory); - BDirectory goDirectory(path.Path()); + { + BPath path; + if (find_directory (B_USER_SETTINGS_DIRECTORY, &path, true) != B_OK) + break; - if (goDirectory.InitCheck() == B_OK) { - BEntry entry(TargetModel()->EntryRef()); - entry.GetPath(&path); - - BSymLink link; - goDirectory.CreateSymLink(TargetModel()->Name(), path.Path(), &link); - } + path.Append(kGoDirectory); + BDirectory goDirectory(path.Path()); + + if (goDirectory.InitCheck() == B_OK) { + BEntry entry(TargetModel()->EntryRef()); + entry.GetPath(&path); + + BSymLink link; + goDirectory.CreateSymLink(TargetModel()->Name(), path.Path(), &link); } break; + } case kConfigShow: - { - if (fConfigWindow) - fConfigWindow->Activate(); - else { - BPath path; - if (find_directory (B_USER_SETTINGS_DIRECTORY, &path, true) != B_OK) - break; - - path.Append(kGoDirectory); - BDirectory goDirectory(path.Path()); - - if (goDirectory.InitCheck() == B_OK) { - entry_ref startref; - BEntry entry; - goDirectory.GetEntry(&entry); - entry.GetRef(&startref); - - int32 apps, docs, folders; - TrackerSettings().RecentCounts(&apps, &docs, &folders); + { + if (fConfigWindow) { + fConfigWindow->Activate(); + break; + } - // if this is a save panel - // then don't show recent docs controls - if (fIsSavePanel) - docs = -1; - - fConfigWindow = new TFavoritesConfigWindow(BRect(0, 0, 320, 24), - "Configure Favorites", Feel() == B_MODAL_APP_WINDOW_FEEL, - fNodeFlavors, BMessenger(this), &startref, -1, docs, folders); - } - } + BPath path; + if (find_directory (B_USER_SETTINGS_DIRECTORY, &path, true) != B_OK) + break; + + path.Append(kGoDirectory); + BDirectory goDirectory(path.Path()); + + if (goDirectory.InitCheck() == B_OK) { + entry_ref startref; + BEntry entry; + goDirectory.GetEntry(&entry); + entry.GetRef(&startref); + + int32 apps, docs, folders; + TrackerSettings().RecentCounts(&apps, &docs, &folders); + + // if this is a save panel + // then don't show recent docs controls + if (fIsSavePanel) + docs = -1; + + fConfigWindow = new TFavoritesConfigWindow(BRect(0, 0, 320, 24), + "Configure Favorites", Feel() == B_MODAL_APP_WINDOW_FEEL, + fNodeFlavors, BMessenger(this), &startref, -1, docs, folders); } break; + } case kConfigClose: - { - int32 count = 0; - TrackerSettings settings; + { + int32 count = 0; + TrackerSettings settings; - // save off whatever was last in the fields - // do this just in case someone didn't tab out - if (message->FindInt32("applications", &count) == B_OK) - settings.SetRecentApplicationsCount(count); - if (message->FindInt32("folders", &count) == B_OK) - settings.SetRecentFoldersCount(count); - if (message->FindInt32("documents", &count) == B_OK) - settings.SetRecentDocumentsCount(count); - - settings.SaveSettings(false); + // save off whatever was last in the fields + // do this just in case someone didn't tab out + if (message->FindInt32("applications", &count) == B_OK) + settings.SetRecentApplicationsCount(count); + if (message->FindInt32("folders", &count) == B_OK) + settings.SetRecentFoldersCount(count); + if (message->FindInt32("documents", &count) == B_OK) + settings.SetRecentDocumentsCount(count); - fConfigWindow = NULL; - } + settings.SaveSettings(false); + + fConfigWindow = NULL; break; + } case kUpdateAppsCount: case kUpdateDocsCount: case kUpdateFolderCount: - { - // messages sent when the user changes the count - int32 count; - TrackerSettings settings; - - if (message->FindInt32("count", &count) == B_OK) { - if (message->what == kUpdateAppsCount) - settings.SetRecentApplicationsCount(count); - else if (message->what == kUpdateDocsCount) - settings.SetRecentDocumentsCount(count); - else if (message->what == kUpdateFolderCount) - settings.SetRecentFoldersCount(count); - settings.SaveSettings(false); - } + { + // messages sent when the user changes the count + int32 count; + TrackerSettings settings; + + if (message->FindInt32("count", &count) == B_OK) { + if (message->what == kUpdateAppsCount) + settings.SetRecentApplicationsCount(count); + else if (message->what == kUpdateDocsCount) + settings.SetRecentDocumentsCount(count); + else if (message->what == kUpdateFolderCount) + settings.SetRecentFoldersCount(count); + settings.SaveSettings(false); } break; - + } + case kCancelButton: PostMessage(B_QUIT_REQUESTED); break; @@ -1234,26 +1232,25 @@ TFilePanel::MessageReceived(BMessage *message) HandleSaveButton(); } else HandleOpenButton(); - break; case B_OBSERVER_NOTICE_CHANGE: - { - int32 observerWhat; - if (message->FindInt32("be:observe_change_what", &observerWhat) == B_OK) { - switch (observerWhat) { - case kDesktopFilePanelRootChanged: - { - bool desktopIsRoot = true; - message->FindBool("DesktopFilePanelRoot", &desktopIsRoot); + { + int32 observerWhat; + if (message->FindInt32("be:observe_change_what", &observerWhat) == B_OK) { + switch (observerWhat) { + case kDesktopFilePanelRootChanged: + { + bool desktopIsRoot = true; + if (message->FindBool("DesktopFilePanelRoot", &desktopIsRoot) == B_OK) TrackerSettings().SetDesktopFilePanelRoot(desktopIsRoot); - SetTo(TargetModel()->EntryRef()); - break; - } + SetTo(TargetModel()->EntryRef()); + break; } - } - } + } + } break; + } default: _inherited::MessageReceived(message); @@ -1267,7 +1264,7 @@ TFilePanel::OpenDirectory() BObjectList *list = PoseView()->SelectionList(); if (list->CountItems() != 1) return; - + Model *model = list->FirstItem()->TargetModel(); if (model->ResolveIfLink()->IsDirectory()) { BMessage message(B_REFS_RECEIVED); @@ -1558,9 +1555,12 @@ TFilePanel::WindowActivated(bool active) } +// #pragma mark - + + BFilePanelPoseView::BFilePanelPoseView(Model *model, BRect frame, uint32 resizeMask) - : BPoseView(model, frame, kListMode, resizeMask), - fIsDesktop(false) + : BPoseView(model, frame, kListMode, resizeMask), + fIsDesktop(false) { } diff --git a/src/kits/tracker/PoseView.cpp b/src/kits/tracker/PoseView.cpp index 8176725b2a..73909e59ba 100644 --- a/src/kits/tracker/PoseView.cpp +++ b/src/kits/tracker/PoseView.cpp @@ -2272,22 +2272,36 @@ BPoseView::MessageReceived(BMessage *message) break; case kShowSelectionWhenInactiveChanged: - message->FindBool("ShowSelectionWhenInactive", &fShowSelectionWhenInactive); - TrackerSettings().SetShowSelectionWhenInactive(fShowSelectionWhenInactive); + { + // Updating the settings here will propagate setting changed + // from Tracker to all open file panels as well + bool showSelection; + if (message->FindBool("ShowSelectionWhenInactive", &showSelection) == B_OK) { + fShowSelectionWhenInactive = showSelection; + TrackerSettings().SetShowSelectionWhenInactive(fShowSelectionWhenInactive); + } Invalidate(); break; + } case kTransparentSelectionChanged: - message->FindBool("TransparentSelection", &fTransparentSelection); - TrackerSettings().SetTransparentSelection(fTransparentSelection); + { + bool transparentSelection; + if (message->FindBool("TransparentSelection", &transparentSelection) == B_OK) { + fTransparentSelection = transparentSelection; + TrackerSettings().SetTransparentSelection(fTransparentSelection); + } break; + } case kSortFolderNamesFirstChanged: if (ViewMode() == kListMode) { + TrackerSettings settings; bool sortFolderNamesFirst; - message->FindBool("SortFolderNamesFirst", &sortFolderNamesFirst); - TrackerSettings().SetSortFolderNamesFirst(sortFolderNamesFirst); - NameAttributeText::SetSortFolderNamesFirst(sortFolderNamesFirst); + if (message->FindBool("SortFolderNamesFirst", &sortFolderNamesFirst) == B_OK) + settings.SetSortFolderNamesFirst(sortFolderNamesFirst); + + NameAttributeText::SetSortFolderNamesFirst(settings.SortFolderNamesFirst()); SortPoses(); Invalidate(); } @@ -2295,8 +2309,8 @@ BPoseView::MessageReceived(BMessage *message) case kShowVolumeSpaceBar: bool enabled; - message->FindBool("ShowVolumeSpaceBar", &enabled); - TrackerSettings().SetShowVolumeSpaceBar(enabled); + if (message->FindBool("ShowVolumeSpaceBar", &enabled) == B_OK) + TrackerSettings().SetShowVolumeSpaceBar(enabled); // supposed to fall through case kSpaceBarColorChanged: UpdateVolumeIcons(); diff --git a/src/kits/tracker/SettingsViews.cpp b/src/kits/tracker/SettingsViews.cpp index e4ef8ba4c1..abba8743bb 100644 --- a/src/kits/tracker/SettingsViews.cpp +++ b/src/kits/tracker/SettingsViews.cpp @@ -48,54 +48,101 @@ All rights reserved. #include #include -const uint32 kSpaceBarSwitchColor = 'SBsc'; + +static const uint32 kSpaceBarSwitchColor = 'SBsc'; +static const float kBorderSpacing = 5.0f; +static const float kItemHeight = 18.0f; +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(be_app); + if (!tracker) + return; + + BMessage message; + message.AddBool(name, value); + tracker->SendNotices(what, &message); +} + + +// #pragma mark - SettingsView::SettingsView(BRect rect, const char *name) - : BView(rect, name, B_FOLLOW_ALL_SIDES, 0) + : BView(rect, name, B_FOLLOW_ALL_SIDES, 0) { } + SettingsView::~SettingsView() { } -// 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() {} -// 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(bool) {} - -// 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::ShowsRevertSettings() const { return true; } - -namespace BPrivate { - const float kBorderSpacing = 5.0f; - const float kItemHeight = 18.0f; - const float kItemExtraSpacing = 2.0f; - const float kIndentSpacing = 12.0f; +/*! + 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() +{ +} + + +/*! + 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() +{ +} + + +/*! + 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; +} + + // #pragma mark - + DesktopSettingsView::DesktopSettingsView(BRect rect) - : SettingsView(rect, "DesktopSettingsView") + : SettingsView(rect, "DesktopSettingsView") { BRect frame = BRect(kBorderSpacing, kBorderSpacing, rect.Width() - 2 * kBorderSpacing, kBorderSpacing + kItemHeight); @@ -150,9 +197,9 @@ DesktopSettingsView::DesktopSettingsView(BRect rect) button->ResizeToPreferred(); button->MoveBy(0, rect.Height() - kBorderSpacing - button->Frame().bottom); button->SetTarget(be_app); - } + void DesktopSettingsView::AttachedToWindow() { @@ -163,6 +210,7 @@ DesktopSettingsView::AttachedToWindow() fEjectWhenUnmountingCheckBox->SetTarget(this); } + void DesktopSettingsView::MessageReceived(BMessage *message) { @@ -252,10 +300,10 @@ DesktopSettingsView::MessageReceived(BMessage *message) notificationMessage.AddBool("IntegrateNonBootBeOSDesktops", fIntegrateNonBootBeOSDesktopsCheckBox->Value() == 1); - // Send the notification message: + // Send the notification message tracker->SendNotices(kDesktopIntegrationChanged, ¬ificationMessage); - // Tell the settings window the contents have changed: + // Tell the settings window the contents have changed Window()->PostMessage(kSettingsContentsModified); break; } @@ -264,26 +312,22 @@ DesktopSettingsView::MessageReceived(BMessage *message) { settings.SetEjectWhenUnmounting( fEjectWhenUnmountingCheckBox->Value() == 1); - - // Construct the notification message: - BMessage notificationMessage; - notificationMessage.AddBool("EjectWhenUnmounting", - fEjectWhenUnmountingCheckBox->Value() == 1); - // Send the notification message: - tracker->SendNotices(kEjectWhenUnmountingChanged, ¬ificationMessage); - - // Tell the settings window the contents have changed: + // Send the notification message + send_bool_notices(kEjectWhenUnmountingChanged, + "EjectWhenUnmounting", fEjectWhenUnmountingCheckBox->Value() == 1); + + // Tell the settings window the contents have changed Window()->PostMessage(kSettingsContentsModified); break; } - + default: _inherited::MessageReceived(message); } } - + void DesktopSettingsView::SetDefaults() { @@ -293,11 +337,11 @@ DesktopSettingsView::SetDefaults() settings.SetShowDisksIcon(false); settings.SetMountVolumesOntoDesktop(true); settings.SetMountSharedVolumesOntoDesktop(false); - settings.SetIntegrateNonBootBeOSDesktops(true); + settings.SetIntegrateNonBootBeOSDesktops(false); settings.SetEjectWhenUnmounting(true); - ShowCurrentSettings(true); - // true -> send notices about the change + ShowCurrentSettings(); + _SendNotices(); } @@ -312,12 +356,39 @@ DesktopSettingsView::Revert() settings.SetIntegrateNonBootBeOSDesktops(fIntegrateNonBootBeOSDesktops); settings.SetEjectWhenUnmounting(fEjectWhenUnmounting); - ShowCurrentSettings(true); - // true -> send notices about the change + ShowCurrentSettings(); + _SendNotices(); } + void -DesktopSettingsView::ShowCurrentSettings(bool sendNotices) +DesktopSettingsView::_SendNotices() +{ + TTracker *tracker = dynamic_cast(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); +} + + +void +DesktopSettingsView::ShowCurrentSettings() { TrackerSettings settings; @@ -330,29 +401,6 @@ DesktopSettingsView::ShowCurrentSettings(bool sendNotices) fIntegrateNonBootBeOSDesktopsCheckBox->SetValue(settings.IntegrateNonBootBeOSDesktops()); fEjectWhenUnmountingCheckBox->SetValue(settings.EjectWhenUnmounting()); - - if (sendNotices) { - TTracker *tracker = dynamic_cast(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); - } } @@ -370,28 +418,25 @@ DesktopSettingsView::RecordRevertSettings() bool -DesktopSettingsView::ShowsRevertSettings() const +DesktopSettingsView::IsRevertable() const { - return - (fShowDisksIcon == - (fShowDisksIconRadioButton->Value() > 0)) - && (fMountVolumesOntoDesktop == - (fMountVolumesOntoDesktopRadioButton->Value() > 0)) - && (fMountSharedVolumesOntoDesktop == - (fMountSharedVolumesOntoDesktopCheckBox->Value() > 0)) - && (fIntegrateNonBootBeOSDesktops == - (fIntegrateNonBootBeOSDesktopsCheckBox->Value() > 0)) - && (fEjectWhenUnmounting == - (fEjectWhenUnmountingCheckBox->Value() > 0)); + return fShowDisksIcon != (fShowDisksIconRadioButton->Value() > 0) + || fMountVolumesOntoDesktop != + (fMountVolumesOntoDesktopRadioButton->Value() > 0) + || fMountSharedVolumesOntoDesktop != + (fMountSharedVolumesOntoDesktopCheckBox->Value() > 0) + || fIntegrateNonBootBeOSDesktops != + (fIntegrateNonBootBeOSDesktopsCheckBox->Value() > 0) + || fEjectWhenUnmounting != + (fEjectWhenUnmountingCheckBox->Value() > 0); } -//------------------------------------------------------------------------ // #pragma mark - WindowsSettingsView::WindowsSettingsView(BRect rect) - : SettingsView(rect, "WindowsSettingsView") + : SettingsView(rect, "WindowsSettingsView") { BRect frame = BRect(kBorderSpacing, kBorderSpacing, rect.Width() - 2 * kBorderSpacing, kBorderSpacing + kItemHeight); @@ -419,7 +464,6 @@ WindowsSettingsView::WindowsSettingsView(BRect rect) frame.OffsetBy(-20, itemSpacing); - fShowSelectionWhenInactiveCheckBox = new BCheckBox(frame, "", "Show Selection When Inactive", new BMessage(kShowSelectionWhenInactiveChanged)); AddChild(fShowSelectionWhenInactiveCheckBox); @@ -427,10 +471,10 @@ WindowsSettingsView::WindowsSettingsView(BRect rect) frame.OffsetBy(0, itemSpacing); - fTransparentSelectionCheckBox = new BCheckBox(frame, "", "Transparent Selection Box", + fOutlineSelectionCheckBox = new BCheckBox(frame, "", "Outline Selection Rectangle Only", new BMessage(kTransparentSelectionChanged)); - AddChild(fTransparentSelectionCheckBox); - fTransparentSelectionCheckBox->ResizeToPreferred(); + AddChild(fOutlineSelectionCheckBox); + fOutlineSelectionCheckBox->ResizeToPreferred(); frame.OffsetBy(0, itemSpacing); @@ -448,7 +492,7 @@ WindowsSettingsView::AttachedToWindow() fShowNavigatorCheckBox->SetTarget(this); fShowFullPathInTitleBarCheckBox->SetTarget(this); fShowSelectionWhenInactiveCheckBox->SetTarget(this); - fTransparentSelectionCheckBox->SetTarget(this); + fOutlineSelectionCheckBox->SetTarget(this); fSortFolderNamesFirstCheckBox->SetTarget(this); } @@ -467,7 +511,7 @@ WindowsSettingsView::MessageReceived(BMessage *message) tracker->SendNotices(kWindowsShowFullPathChanged); Window()->PostMessage(kSettingsContentsModified); break; - + case kSingleWindowBrowseChanged: settings.SetSingleWindowBrowse(fSingleWindowBrowseCheckBox->Value() == 1); if (fSingleWindowBrowseCheckBox->Value() == 0) { @@ -491,13 +535,11 @@ WindowsSettingsView::MessageReceived(BMessage *message) case kShowSelectionWhenInactiveChanged: { settings.SetShowSelectionWhenInactive( - fShowSelectionWhenInactiveCheckBox->Value() == 1); + fShowSelectionWhenInactiveCheckBox->Value() == 1); // Make the notification message and send it to the tracker: - BMessage notificationMessage; - notificationMessage.AddBool("ShowSelectionWhenInactive", - fShowSelectionWhenInactiveCheckBox->Value() == 1); - tracker->SendNotices(kShowSelectionWhenInactiveChanged, ¬ificationMessage); + send_bool_notices(kShowSelectionWhenInactiveChanged, + "ShowSelectionWhenInactive", fShowSelectionWhenInactiveCheckBox->Value() == 1); Window()->PostMessage(kSettingsContentsModified); break; @@ -506,13 +548,11 @@ WindowsSettingsView::MessageReceived(BMessage *message) case kTransparentSelectionChanged: { settings.SetTransparentSelection( - fTransparentSelectionCheckBox->Value() == 1); + fOutlineSelectionCheckBox->Value() == B_CONTROL_OFF); // Make the notification message and send it to the tracker: - BMessage notificationMessage; - notificationMessage.AddBool("TransparentSelection", - fTransparentSelectionCheckBox->Value() == 1); - tracker->SendNotices(kTransparentSelectionChanged, ¬ificationMessage); + send_bool_notices(kTransparentSelectionChanged, + "TransparentSelection", settings.TransparentSelection()); Window()->PostMessage(kSettingsContentsModified); break; @@ -523,10 +563,8 @@ WindowsSettingsView::MessageReceived(BMessage *message) settings.SetSortFolderNamesFirst(fSortFolderNamesFirstCheckBox->Value() == 1); // Make the notification message and send it to the tracker: - BMessage notificationMessage; - notificationMessage.AddBool("SortFolderNamesFirst", + send_bool_notices(kSortFolderNamesFirstChanged, "SortFolderNamesFirst", fSortFolderNamesFirstCheckBox->Value() == 1); - tracker->SendNotices(kSortFolderNamesFirstChanged, ¬ificationMessage); Window()->PostMessage(kSettingsContentsModified); break; @@ -542,43 +580,98 @@ WindowsSettingsView::MessageReceived(BMessage *message) void WindowsSettingsView::SetDefaults() { + TTracker *tracker = dynamic_cast(be_app); + if (!tracker) + return; + TrackerSettings settings; - settings.SetShowFullPathInTitleBar(false); - settings.SetSingleWindowBrowse(false); - settings.SetShowNavigator(false); - settings.SetShowSelectionWhenInactive(true); - settings.SetTransparentSelection(false); - settings.SetSortFolderNamesFirst(false); + if (settings.ShowFullPathInTitleBar()) { + settings.SetShowFullPathInTitleBar(false); + tracker->SendNotices(kWindowsShowFullPathChanged); + } - ShowCurrentSettings(true); - // true -> send notices about the change + if (settings.SingleWindowBrowse()) { + settings.SetSingleWindowBrowse(false); + tracker->SendNotices(kSingleWindowBrowseChanged); + } + + if (settings.ShowNavigator()) { + settings.SetShowNavigator(false); + tracker->SendNotices(kShowNavigatorChanged); + } + + if (!settings.ShowSelectionWhenInactive()) { + settings.SetShowSelectionWhenInactive(true); + send_bool_notices(kShowSelectionWhenInactiveChanged, + "ShowSelectionWhenInactive", true); + } + + if (!settings.TransparentSelection()) { + settings.SetTransparentSelection(true); + send_bool_notices(kTransparentSelectionChanged, + "TransparentSelection", true); + } + + if (settings.SortFolderNamesFirst()) { + settings.SetSortFolderNamesFirst(false); + send_bool_notices(kSortFolderNamesFirstChanged, + "SortFolderNamesFirst", false); + } + + ShowCurrentSettings(); } void WindowsSettingsView::Revert() { + TTracker *tracker = dynamic_cast(be_app); + if (!tracker) + return; + TrackerSettings settings; - settings.SetShowFullPathInTitleBar(fShowFullPathInTitleBar); - settings.SetSingleWindowBrowse(fSingleWindowBrowse); - settings.SetShowNavigator(fShowNavigator); - settings.SetShowSelectionWhenInactive(fShowSelectionWhenInactive); - settings.SetTransparentSelection(fTransparentSelection); - settings.SetSortFolderNamesFirst(fSortFolderNamesFirst); + if (settings.ShowFullPathInTitleBar() != fShowFullPathInTitleBar) { + settings.SetShowFullPathInTitleBar(fShowFullPathInTitleBar); + tracker->SendNotices(kWindowsShowFullPathChanged); + } - ShowCurrentSettings(true); - // true -> send notices about the change + if (settings.SingleWindowBrowse() != fSingleWindowBrowse) { + settings.SetSingleWindowBrowse(fSingleWindowBrowse); + tracker->SendNotices(kSingleWindowBrowseChanged); + } + + if (settings.ShowNavigator() != fShowNavigator) { + settings.SetShowNavigator(fShowNavigator); + tracker->SendNotices(kShowNavigatorChanged); + } + + if (settings.ShowSelectionWhenInactive() != fShowSelectionWhenInactive) { + settings.SetShowSelectionWhenInactive(fShowSelectionWhenInactive); + send_bool_notices(kShowSelectionWhenInactiveChanged, + "ShowSelectionWhenInactive", fShowSelectionWhenInactive); + } + + if (settings.TransparentSelection() != fTransparentSelection) { + settings.SetTransparentSelection(fTransparentSelection); + send_bool_notices(kTransparentSelectionChanged, + "TransparentSelection", fTransparentSelection); + } + + if (settings.SortFolderNamesFirst() != fSortFolderNamesFirst) { + settings.SetSortFolderNamesFirst(fSortFolderNamesFirst); + send_bool_notices(kSortFolderNamesFirstChanged, + "SortFolderNamesFirst", fSortFolderNamesFirst); + } + + ShowCurrentSettings(); } void -WindowsSettingsView::ShowCurrentSettings(bool sendNotices) +WindowsSettingsView::ShowCurrentSettings() { - TTracker *tracker = dynamic_cast(be_app); - if (!tracker) - return; TrackerSettings settings; fShowFullPathInTitleBarCheckBox->SetValue(settings.ShowFullPathInTitleBar()); @@ -586,17 +679,9 @@ WindowsSettingsView::ShowCurrentSettings(bool sendNotices) fShowNavigatorCheckBox->SetEnabled(settings.SingleWindowBrowse()); fShowNavigatorCheckBox->SetValue(settings.ShowNavigator()); fShowSelectionWhenInactiveCheckBox->SetValue(settings.ShowSelectionWhenInactive()); - fTransparentSelectionCheckBox->SetValue(settings.TransparentSelection()); + fOutlineSelectionCheckBox->SetValue(settings.TransparentSelection() + ? B_CONTROL_OFF : B_CONTROL_ON); fSortFolderNamesFirstCheckBox->SetValue(settings.SortFolderNamesFirst()); - - if (sendNotices) { - tracker->SendNotices(kSingleWindowBrowseChanged); - tracker->SendNotices(kShowNavigatorChanged); - tracker->SendNotices(kWindowsShowFullPathChanged); - tracker->SendNotices(kShowSelectionWhenInactiveChanged); - tracker->SendNotices(kTransparentSelectionChanged); - tracker->SendNotices(kSortFolderNamesFirstChanged); - } } @@ -615,30 +700,24 @@ WindowsSettingsView::RecordRevertSettings() bool -WindowsSettingsView::ShowsRevertSettings() const +WindowsSettingsView::IsRevertable() const { - return - (fShowFullPathInTitleBar == - (fShowFullPathInTitleBarCheckBox->Value() > 0)) - && (fSingleWindowBrowse == - (fSingleWindowBrowseCheckBox->Value() > 0)) - && (fShowNavigator == - (fShowNavigatorCheckBox->Value() > 0)) - && (fShowSelectionWhenInactive == - (fShowSelectionWhenInactiveCheckBox->Value() > 0)) - && (fTransparentSelection == - (fTransparentSelectionCheckBox->Value() > 0)) - && (fSortFolderNamesFirst == - (fSortFolderNamesFirstCheckBox->Value() > 0)); + TrackerSettings settings; + + return fShowFullPathInTitleBar != settings.ShowFullPathInTitleBar() + || fSingleWindowBrowse != settings.SingleWindowBrowse() + || fShowNavigator != settings.ShowNavigator() + || fShowSelectionWhenInactive != settings.ShowSelectionWhenInactive() + || fTransparentSelection != settings.TransparentSelection() + || fSortFolderNamesFirst != settings.SortFolderNamesFirst(); } -//------------------------------------------------------------------------ // #pragma mark - FilePanelSettingsView::FilePanelSettingsView(BRect rect) - : SettingsView(rect, "FilePanelSettingsView") + : SettingsView(rect, "FilePanelSettingsView") { BRect frame = BRect(kBorderSpacing, kBorderSpacing, rect.Width() - 2 * kBorderSpacing, kBorderSpacing + kItemHeight); @@ -651,14 +730,14 @@ FilePanelSettingsView::FilePanelSettingsView(BRect rect) const float itemSpacing = fDesktopFilePanelRootCheckBox->Bounds().Height() + kItemExtraSpacing; frame.OffsetBy(0, itemSpacing); - + BRect recentBoxFrame(kBorderSpacing, frame.bottom, rect.Width() - kBorderSpacing, frame.top); BBox *recentBox = new BBox(recentBoxFrame, "recentBox"); recentBox->SetLabel("Recent" B_UTF8_ELLIPSIS); AddChild(recentBox); - + frame = recentBoxFrame.OffsetToCopy(0,0); frame.OffsetTo(kBorderSpacing, 3 * kBorderSpacing); @@ -715,62 +794,57 @@ FilePanelSettingsView::MessageReceived(BMessage *message) switch (message->what) { case kDesktopFilePanelRootChanged: - { - settings.SetDesktopFilePanelRoot(fDesktopFilePanelRootCheckBox->Value() == 1); + { + settings.SetDesktopFilePanelRoot(fDesktopFilePanelRootCheckBox->Value() == 1); - // Make the notification message and send it to the tracker: - BMessage message; - message.AddBool("DesktopFilePanelRoot", fDesktopFilePanelRootCheckBox->Value() == 1); - tracker->SendNotices(kDesktopFilePanelRootChanged, &message); + // Make the notification message and send it to the tracker: + BMessage message; + message.AddBool("DesktopFilePanelRoot", fDesktopFilePanelRootCheckBox->Value() == 1); + tracker->SendNotices(kDesktopFilePanelRootChanged, &message); - Window()->PostMessage(kSettingsContentsModified); - } + Window()->PostMessage(kSettingsContentsModified); break; + } case kFavoriteCountChanged: - { - GetAndRefreshDisplayedFigures(); - settings.SetRecentDocumentsCount(fDisplayedDocCount); - settings.SetRecentFoldersCount(fDisplayedFolderCount); + { + _GetAndRefreshDisplayedFigures(); + settings.SetRecentDocumentsCount(fDisplayedDocCount); + settings.SetRecentFoldersCount(fDisplayedFolderCount); - // Make the notification message and send it to the tracker: - BMessage message; - message.AddInt32("RecentDocuments", fDisplayedDocCount); - message.AddInt32("RecentFolders", fDisplayedFolderCount); - tracker->SendNotices(kFavoriteCountChanged, &message); + // Make the notification message and send it to the tracker: + BMessage message; + message.AddInt32("RecentDocuments", fDisplayedDocCount); + message.AddInt32("RecentFolders", fDisplayedFolderCount); + tracker->SendNotices(kFavoriteCountChanged, &message); - Window()->PostMessage(kSettingsContentsModified); - } - break; + Window()->PostMessage(kSettingsContentsModified); + break; + } case B_OBSERVER_NOTICE_CHANGE: - { - int32 observerWhat; - if (message->FindInt32("be:observe_change_what", &observerWhat) == B_OK) { - switch (observerWhat) { - case kFavoriteCountChangedExternally: - { - int32 count; - if (message->FindInt32("RecentApplications", &count) == B_OK) { - settings.SetRecentApplicationsCount(count); - ShowCurrentSettings(); - } + { + int32 observerWhat; + if (message->FindInt32("be:observe_change_what", &observerWhat) == B_OK + && (uint32)observerWhat == kFavoriteCountChangedExternally) { + int32 count; + if (message->FindInt32("RecentApplications", &count) == B_OK) { + settings.SetRecentApplicationsCount(count); + ShowCurrentSettings(); + } - if (message->FindInt32("RecentDocuments", &count) == B_OK) { - settings.SetRecentDocumentsCount(count); - ShowCurrentSettings(); - } + if (message->FindInt32("RecentDocuments", &count) == B_OK) { + settings.SetRecentDocumentsCount(count); + ShowCurrentSettings(); + } - if (message->FindInt32("RecentFolders", &count) == B_OK) { - settings.SetRecentFoldersCount(count); - ShowCurrentSettings(); - } - } - break; - } + if (message->FindInt32("RecentFolders", &count) == B_OK) { + settings.SetRecentFoldersCount(count); + ShowCurrentSettings(); } } break; + } default: _inherited::MessageReceived(message); @@ -783,13 +857,13 @@ void FilePanelSettingsView::SetDefaults() { TrackerSettings settings; - + settings.SetDesktopFilePanelRoot(true); settings.SetRecentDocumentsCount(10); settings.SetRecentFoldersCount(10); - ShowCurrentSettings(true); - // true -> send notices about the change + ShowCurrentSettings(); + _SendNotices(); } @@ -802,17 +876,38 @@ FilePanelSettingsView::Revert() settings.SetRecentDocumentsCount(fRecentDocuments); settings.SetRecentFoldersCount(fRecentFolders); - ShowCurrentSettings(true); - // true -> send notices about the change + ShowCurrentSettings(); + _SendNotices(); } void -FilePanelSettingsView::ShowCurrentSettings(bool sendNotices) +FilePanelSettingsView::_SendNotices() { TTracker *tracker = dynamic_cast(be_app); if (!tracker) return; + + TrackerSettings settings; + + // Make the notification message and send it to the tracker: + + BMessage message; + message.AddBool("DesktopFilePanelRoot", fDesktopFilePanelRootCheckBox->Value() == 1); + tracker->SendNotices(kDesktopFilePanelRootChanged, &message); + + int32 recentApplications, recentDocuments, recentFolders; + settings.RecentCounts(&recentApplications, &recentDocuments, &recentFolders); + + message.AddInt32("RecentDocuments", recentDocuments); + message.AddInt32("RecentFolders", recentFolders); + tracker->SendNotices(kFavoriteCountChanged, &message); +} + + +void +FilePanelSettingsView::ShowCurrentSettings() +{ TrackerSettings settings; fDesktopFilePanelRootCheckBox->SetValue(settings.DesktopFilePanelRoot()); @@ -827,18 +922,6 @@ FilePanelSettingsView::ShowCurrentSettings(bool sendNotices) BString folderCountText; folderCountText << recentFolders; fRecentFoldersTextControl->SetText(folderCountText.String()); - - if (sendNotices) { - // Make the notification message and send it to the tracker: - - BMessage message; - message.AddBool("DesktopFilePanelRoot", fDesktopFilePanelRootCheckBox->Value() == 1); - tracker->SendNotices(kDesktopFilePanelRootChanged, &message); - - message.AddInt32("RecentDocuments", recentDocuments); - message.AddInt32("RecentFolders", recentFolders); - tracker->SendNotices(kFavoriteCountChanged, &message); - } } @@ -853,19 +936,18 @@ FilePanelSettingsView::RecordRevertSettings() bool -FilePanelSettingsView::ShowsRevertSettings() const +FilePanelSettingsView::IsRevertable() const { - GetAndRefreshDisplayedFigures(); + _GetAndRefreshDisplayedFigures(); - return - (fDesktopFilePanelRoot == (fDesktopFilePanelRootCheckBox->Value() > 0)) - && (fDisplayedDocCount == fRecentDocuments) - && (fDisplayedFolderCount == fRecentFolders); + return fDesktopFilePanelRoot != (fDesktopFilePanelRootCheckBox->Value() > 0) + || fDisplayedDocCount != fRecentDocuments + || fDisplayedFolderCount != fRecentFolders; } void -FilePanelSettingsView::GetAndRefreshDisplayedFigures() const +FilePanelSettingsView::_GetAndRefreshDisplayedFigures() const { sscanf(fRecentDocumentsTextControl->Text(), "%ld", &fDisplayedDocCount); sscanf(fRecentFoldersTextControl->Text(), "%ld", &fDisplayedFolderCount); @@ -880,21 +962,20 @@ FilePanelSettingsView::GetAndRefreshDisplayedFigures() const } -//------------------------------------------------------------------------ // #pragma mark - TimeFormatSettingsView::TimeFormatSettingsView(BRect rect) - : SettingsView(rect, "WindowsSettingsView") + : SettingsView(rect, "WindowsSettingsView") { BRect clockBoxFrame = BRect(kBorderSpacing, kBorderSpacing, rect.Width() / 2 - 4 * kBorderSpacing, kBorderSpacing + 5 * kItemHeight); BBox *clockBox = new BBox(clockBoxFrame, "Clock"); clockBox->SetLabel("Clock"); - + AddChild(clockBox); - + BRect frame = BRect(kBorderSpacing, 2.5f*kBorderSpacing, clockBoxFrame.Width() - 2 * kBorderSpacing, kBorderSpacing + kItemHeight); @@ -914,7 +995,6 @@ TimeFormatSettingsView::TimeFormatSettingsView(BRect rect) clockBox->ResizeTo(clockBox->Bounds().Width(), f12HrRadioButton->Frame().bottom + kBorderSpacing); - BRect dateFormatBoxFrame = BRect(clockBoxFrame.right + kBorderSpacing, kBorderSpacing, rect.right - kBorderSpacing, kBorderSpacing + 5 * itemSpacing); @@ -922,7 +1002,7 @@ TimeFormatSettingsView::TimeFormatSettingsView(BRect rect) dateFormatBox->SetLabel("Date Order"); AddChild(dateFormatBox); - + frame = BRect(kBorderSpacing, 2.5f*kBorderSpacing, dateFormatBoxFrame.Width() - 2 * kBorderSpacing, kBorderSpacing + kItemHeight); @@ -948,7 +1028,7 @@ TimeFormatSettingsView::TimeFormatSettingsView(BRect rect) dateFormatBox->ResizeTo(dateFormatBox->Bounds().Width(), fMDYRadioButton->Frame().bottom + kBorderSpacing); 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))); @@ -964,11 +1044,11 @@ TimeFormatSettingsView::TimeFormatSettingsView(BRect rect) AddChild(fSeparatorMenuField); frame.OffsetBy(0, 30.0f); - + BStringView *exampleView = new BStringView(frame, "", "Examples:"); AddChild(exampleView); exampleView->ResizeToPreferred(); - + frame.OffsetBy(0, itemSpacing); fLongDateExampleView = new BStringView(frame, "", ""); @@ -981,7 +1061,7 @@ TimeFormatSettingsView::TimeFormatSettingsView(BRect rect) AddChild(fShortDateExampleView); fShortDateExampleView->ResizeToPreferred(); - UpdateExamples(); + _UpdateExamples(); } @@ -993,7 +1073,7 @@ TimeFormatSettingsView::AttachedToWindow() fYMDRadioButton->SetTarget(this); fDMYRadioButton->SetTarget(this); fMDYRadioButton->SetTarget(this); - + fSeparatorMenuField->Menu()->SetTargetForItems(this); } @@ -1016,11 +1096,11 @@ TimeFormatSettingsView::MessageReceived(BMessage *message) if (separator >= 0) settings.SetTimeFormatSeparator((FormatSeparator)separator); } - + DateOrder format = fYMDRadioButton->Value() ? kYMDFormat : fDMYRadioButton->Value() ? kDMYFormat : kMDYFormat; - + settings.SetDateOrderFormat(format); settings.SetClockTo24Hr(f24HrRadioButton->Value() == 1); @@ -1031,7 +1111,7 @@ TimeFormatSettingsView::MessageReceived(BMessage *message) notificationMessage.AddBool("24HrClock", f24HrRadioButton->Value() == 1); tracker->SendNotices(kDateFormatChanged, ¬ificationMessage); - UpdateExamples(); + _UpdateExamples(); Window()->PostMessage(kSettingsContentsModified); break; @@ -1052,8 +1132,8 @@ TimeFormatSettingsView::SetDefaults() settings.SetDateOrderFormat(kMDYFormat); settings.SetClockTo24Hr(false); - ShowCurrentSettings(true); - // true -> send notices about the change + ShowCurrentSettings(); + _SendNotices(); } @@ -1066,19 +1146,37 @@ TimeFormatSettingsView::Revert() settings.SetDateOrderFormat(fFormat); settings.SetClockTo24Hr(f24HrClock); - ShowCurrentSettings(true); - // true -> send notices about the change + ShowCurrentSettings(); + _SendNotices(); } void -TimeFormatSettingsView::ShowCurrentSettings(bool sendNotices) +TimeFormatSettingsView::_SendNotices() +{ + TTracker *tracker = dynamic_cast(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); +} + + +void +TimeFormatSettingsView::ShowCurrentSettings() { TrackerSettings settings; f24HrRadioButton->SetValue(settings.ClockIs24Hr()); f12HrRadioButton->SetValue(!settings.ClockIs24Hr()); - + switch (settings.DateOrderFormat()) { case kYMDFormat: fYMDRadioButton->SetValue(1); @@ -1093,26 +1191,13 @@ TimeFormatSettingsView::ShowCurrentSettings(bool sendNotices) fDMYRadioButton->SetValue(1); break; } - + FormatSeparator separator = settings.TimeFormatSeparator(); - + if (separator >= kNoSeparator && separator < kSeparatorsEnd) fSeparatorMenuField->Menu()->ItemAt((int32)separator)->SetMarked(true); - UpdateExamples(); - - if (sendNotices) { - TTracker *tracker = dynamic_cast(be_app); - if (!tracker) - return; - - // 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); - } + _UpdateExamples(); } @@ -1128,7 +1213,7 @@ TimeFormatSettingsView::RecordRevertSettings() bool -TimeFormatSettingsView::ShowsRevertSettings() const +TimeFormatSettingsView::IsRevertable() const { FormatSeparator separator; @@ -1138,23 +1223,22 @@ TimeFormatSettingsView::ShowsRevertSettings() const if (index >= 0) separator = (FormatSeparator)index; else - return false; + return true; } else - return false; - + return true; + DateOrder format = fYMDRadioButton->Value() ? kYMDFormat : (fDMYRadioButton->Value() ? kDMYFormat : kMDYFormat); - return - f24HrClock == (f24HrRadioButton->Value() > 0) - && separator == fSeparator - && format == fFormat; + return f24HrClock != (f24HrRadioButton->Value() > 0) + || separator != fSeparator + || format != fFormat; } void -TimeFormatSettingsView::UpdateExamples() +TimeFormatSettingsView::_UpdateExamples() { time_t timeValue = (time_t)time(NULL); tm timeData; @@ -1194,12 +1278,11 @@ TimeFormatSettingsView::UpdateExamples() } -//------------------------------------------------------------------------ // #pragma mark - SpaceBarSettingsView::SpaceBarSettingsView(BRect rect) - : SettingsView(rect, "SpaceBarSettingsView") + : SettingsView(rect, "SpaceBarSettingsView") { BRect frame = BRect(kBorderSpacing, kBorderSpacing, rect.Width() - 2 * kBorderSpacing, kBorderSpacing + kItemHeight); @@ -1222,16 +1305,17 @@ SpaceBarSettingsView::SpaceBarSettingsView(BRect rect) menu->AddItem(new BMenuItem("Warning Space Color", new BMessage(kSpaceBarSwitchColor))); BBox *box = new BBox(frame); - box->SetLabel(fColorPicker = new BMenuField(frame,NULL,NULL,menu)); + box->SetLabel(fColorPicker = new BMenuField(frame, NULL, NULL, menu)); AddChild(box); - fColorControl = new BColorControl( - BPoint(8,fColorPicker->Bounds().Height() + 8 + kItemExtraSpacing), - B_CELLS_16x16,1,"SpaceColorControl",new BMessage(kSpaceBarColorChanged)); + fColorControl = new BColorControl(BPoint(8, fColorPicker->Bounds().Height() + + 8 + kItemExtraSpacing), + B_CELLS_16x16, 1, "SpaceColorControl", new BMessage(kSpaceBarColorChanged)); fColorControl->SetValue(TrackerSettings().UsedSpaceColor()); fColorControl->ResizeToPreferred(); box->AddChild(fColorControl); - box->ResizeTo(fColorControl->Bounds().Width() + 16,fColorControl->Frame().bottom + 8); + box->ResizeTo(fColorControl->Bounds().Width() + 16, + fColorControl->Frame().bottom + 8); } @@ -1303,7 +1387,7 @@ SpaceBarSettingsView::MessageReceived(BMessage *message) tracker->SendNotices(kSpaceBarColorChanged, ¬ificationMessage); break; } - + default: _inherited::MessageReceived(message); break; @@ -1314,44 +1398,64 @@ SpaceBarSettingsView::MessageReceived(BMessage *message) void SpaceBarSettingsView::SetDefaults() { + TTracker *tracker = dynamic_cast(be_app); + if (!tracker) + return; + TrackerSettings settings; - settings.SetShowVolumeSpaceBar(false); + if (settings.ShowVolumeSpaceBar()) { + settings.SetShowVolumeSpaceBar(false); + send_bool_notices(kShowVolumeSpaceBar, "ShowVolumeSpaceBar", false); + } - settings.SetUsedSpaceColor(Color(0,0xcb,0,192)); - settings.SetFreeSpaceColor(Color(0xff,0xff,0xff,192)); - settings.SetWarningSpaceColor(Color(0xcb,0,0,192)); + 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); + } - ShowCurrentSettings(true); - // true -> send notices about the change + ShowCurrentSettings(); } void SpaceBarSettingsView::Revert() { + TTracker *tracker = dynamic_cast(be_app); + if (!tracker) + return; + TrackerSettings settings; - settings.SetShowVolumeSpaceBar(fSpaceBarShow); - settings.SetUsedSpaceColor(fUsedSpaceColor); - settings.SetFreeSpaceColor(fFreeSpaceColor); - settings.SetWarningSpaceColor(fWarningSpaceColor); - - ShowCurrentSettings(true); - // true -> send notices about the change + 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(); } void -SpaceBarSettingsView::ShowCurrentSettings(bool sendNotices) +SpaceBarSettingsView::ShowCurrentSettings() { - TTracker *tracker = dynamic_cast(be_app); - if (!tracker) - return; TrackerSettings settings; fSpaceBarShowCheckBox->SetValue(settings.ShowVolumeSpaceBar()); - + switch (fCurrentColor) { case 0: fColorControl->SetValue(settings.UsedSpaceColor()); @@ -1363,16 +1467,6 @@ SpaceBarSettingsView::ShowCurrentSettings(bool sendNotices) fColorControl->SetValue(settings.WarningSpaceColor()); break; } - - if (sendNotices) { - BMessage notificationMessage; - notificationMessage.AddBool("ShowVolumeSpaceBar", settings.ShowVolumeSpaceBar()); - tracker->SendNotices(kShowVolumeSpaceBar, ¬ificationMessage); - - Window()->PostMessage(kSettingsContentsModified); - BMessage notificationMessage2; - tracker->SendNotices(kSpaceBarColorChanged, ¬ificationMessage2); - } } @@ -1380,7 +1474,7 @@ void SpaceBarSettingsView::RecordRevertSettings() { TrackerSettings settings; - + fSpaceBarShow = settings.ShowVolumeSpaceBar(); fUsedSpaceColor = settings.UsedSpaceColor(); fFreeSpaceColor = settings.FreeSpaceColor(); @@ -1389,18 +1483,22 @@ SpaceBarSettingsView::RecordRevertSettings() bool -SpaceBarSettingsView::ShowsRevertSettings() const +SpaceBarSettingsView::IsRevertable() const { - return (fSpaceBarShow == (fSpaceBarShowCheckBox->Value() == 1)); + TrackerSettings settings; + + return fSpaceBarShow != (fSpaceBarShowCheckBox->Value() == B_CONTROL_ON) + || fUsedSpaceColor != settings.UsedSpaceColor() + || fFreeSpaceColor != settings.FreeSpaceColor() + || fWarningSpaceColor != settings.WarningSpaceColor(); } -//------------------------------------------------------------------------ // #pragma mark - TrashSettingsView::TrashSettingsView(BRect rect) - : SettingsView(rect, "TrashSettingsView") + : SettingsView(rect, "TrashSettingsView") { BRect frame = BRect(kBorderSpacing, kBorderSpacing, rect.Width() - 2 * kBorderSpacing, kBorderSpacing + kItemHeight); @@ -1465,8 +1563,8 @@ TrashSettingsView::SetDefaults() settings.SetDontMoveFilesToTrash(false); settings.SetAskBeforeDeleteFile(true); - ShowCurrentSettings(true); - // true -> send notices about the change + ShowCurrentSettings(); + _SendNotices(); } @@ -1478,21 +1576,30 @@ TrashSettingsView::Revert() settings.SetDontMoveFilesToTrash(fDontMoveFilesToTrash); settings.SetAskBeforeDeleteFile(fAskBeforeDeleteFile); - ShowCurrentSettings(true); - // true -> send notices about the change + ShowCurrentSettings(); + _SendNotices(); } void -TrashSettingsView::ShowCurrentSettings(bool sendNotices) +TrashSettingsView::_SendNotices() +{ + TTracker *tracker = dynamic_cast(be_app); + if (!tracker) + return; + + tracker->SendNotices(kDontMoveFilesToTrashChanged); + tracker->SendNotices(kAskBeforeDeleteFileChanged); +} + + +void +TrashSettingsView::ShowCurrentSettings() { TrackerSettings settings; fDontMoveFilesToTrashCheckBox->SetValue(settings.DontMoveFilesToTrash()); fAskBeforeDeleteFileCheckBox->SetValue(settings.AskBeforeDeleteFile()); - - if (sendNotices) - Window()->PostMessage(kSettingsContentsModified); } @@ -1507,9 +1614,9 @@ TrashSettingsView::RecordRevertSettings() bool -TrashSettingsView::ShowsRevertSettings() const +TrashSettingsView::IsRevertable() const { - return (fDontMoveFilesToTrash == (fDontMoveFilesToTrashCheckBox->Value() > 0)) - && (fAskBeforeDeleteFile == (fAskBeforeDeleteFileCheckBox->Value() > 0)); + return fDontMoveFilesToTrash != (fDontMoveFilesToTrashCheckBox->Value() > 0) + || fAskBeforeDeleteFile != (fAskBeforeDeleteFileCheckBox->Value() > 0); } diff --git a/src/kits/tracker/SettingsViews.h b/src/kits/tracker/SettingsViews.h index e5ba6a1a45..82c950beac 100644 --- a/src/kits/tracker/SettingsViews.h +++ b/src/kits/tracker/SettingsViews.h @@ -51,203 +51,211 @@ class BStringView; namespace BPrivate { class SettingsView : public BView { -public: - SettingsView(BRect, const char *); - virtual ~SettingsView(); + public: + SettingsView(BRect frame, const char *name); + virtual ~SettingsView(); - virtual void SetDefaults(); - virtual void Revert(); - virtual void ShowCurrentSettings(bool sendNotices = false); - virtual void RecordRevertSettings(); - virtual bool ShowsRevertSettings() const; -protected: - - typedef BView _inherited; + virtual void SetDefaults(); + virtual void Revert(); + virtual void ShowCurrentSettings(); + virtual void RecordRevertSettings(); + virtual bool IsRevertable() const; + + protected: + typedef BView _inherited; }; class DesktopSettingsView : public SettingsView { -public: - DesktopSettingsView(BRect); - - void MessageReceived(BMessage *); - void AttachedToWindow(); - - void SetDefaults(); - void Revert(); - void ShowCurrentSettings(bool sendNotices = false); - void RecordRevertSettings(); - bool ShowsRevertSettings() const; -private: - BRadioButton *fShowDisksIconRadioButton; - BRadioButton *fMountVolumesOntoDesktopRadioButton; - BCheckBox *fMountSharedVolumesOntoDesktopCheckBox; - BCheckBox *fIntegrateNonBootBeOSDesktopsCheckBox; - BCheckBox *fEjectWhenUnmountingCheckBox; + public: + DesktopSettingsView(BRect frame); - bool fShowDisksIcon; - bool fMountVolumesOntoDesktop; - bool fMountSharedVolumesOntoDesktop; - bool fIntegrateNonBootBeOSDesktops; - bool fEjectWhenUnmounting; - - typedef SettingsView _inherited; + virtual void MessageReceived(BMessage *message); + virtual void AttachedToWindow(); + + virtual void SetDefaults(); + virtual void Revert(); + virtual void ShowCurrentSettings(); + virtual void RecordRevertSettings(); + virtual bool IsRevertable() const; + + private: + void _SendNotices(); + + BRadioButton *fShowDisksIconRadioButton; + BRadioButton *fMountVolumesOntoDesktopRadioButton; + BCheckBox *fMountSharedVolumesOntoDesktopCheckBox; + BCheckBox *fIntegrateNonBootBeOSDesktopsCheckBox; + BCheckBox *fEjectWhenUnmountingCheckBox; + + bool fShowDisksIcon; + bool fMountVolumesOntoDesktop; + bool fMountSharedVolumesOntoDesktop; + bool fIntegrateNonBootBeOSDesktops; + bool fEjectWhenUnmounting; + + typedef SettingsView _inherited; }; class WindowsSettingsView : public SettingsView { -public: - WindowsSettingsView(BRect); + public: + WindowsSettingsView(BRect frame); - void MessageReceived(BMessage *); - void AttachedToWindow(); - - void SetDefaults(); - void Revert(); - void ShowCurrentSettings(bool sendNotices = false); - void RecordRevertSettings(); - bool ShowsRevertSettings() const; -private: - BCheckBox *fShowFullPathInTitleBarCheckBox; - BCheckBox *fSingleWindowBrowseCheckBox; - BCheckBox *fShowNavigatorCheckBox; - BCheckBox *fShowSelectionWhenInactiveCheckBox; - BCheckBox *fTransparentSelectionCheckBox; - BCheckBox *fSortFolderNamesFirstCheckBox; + virtual void MessageReceived(BMessage *message); + virtual void AttachedToWindow(); - bool fShowFullPathInTitleBar; - bool fSingleWindowBrowse; - bool fShowNavigator; - bool fShowSelectionWhenInactive; - bool fTransparentSelection; - bool fSortFolderNamesFirst; - - typedef SettingsView _inherited; + virtual void SetDefaults(); + virtual void Revert(); + virtual void ShowCurrentSettings(); + virtual void RecordRevertSettings(); + virtual bool IsRevertable() const; + + private: + BCheckBox *fShowFullPathInTitleBarCheckBox; + BCheckBox *fSingleWindowBrowseCheckBox; + BCheckBox *fShowNavigatorCheckBox; + BCheckBox *fShowSelectionWhenInactiveCheckBox; + BCheckBox *fOutlineSelectionCheckBox; + BCheckBox *fSortFolderNamesFirstCheckBox; + + bool fShowFullPathInTitleBar; + bool fSingleWindowBrowse; + bool fShowNavigator; + bool fShowSelectionWhenInactive; + bool fTransparentSelection; + bool fSortFolderNamesFirst; + + typedef SettingsView _inherited; }; class FilePanelSettingsView : public SettingsView { -public: - FilePanelSettingsView(BRect); - ~FilePanelSettingsView(); + public: + FilePanelSettingsView(BRect frame); + virtual ~FilePanelSettingsView(); - void MessageReceived(BMessage *); - void AttachedToWindow(); - - void SetDefaults(); - void Revert(); - void ShowCurrentSettings(bool sendNotices = false); - void RecordRevertSettings(); - bool ShowsRevertSettings() const; + virtual void MessageReceived(BMessage *message); + virtual void AttachedToWindow(); - void GetAndRefreshDisplayedFigures() const; -private: - BCheckBox *fDesktopFilePanelRootCheckBox; + virtual void SetDefaults(); + virtual void Revert(); + virtual void ShowCurrentSettings(); + virtual void RecordRevertSettings(); + virtual bool IsRevertable() const; - BTextControl *fRecentApplicationsTextControl; // Not used for the moment. - BTextControl *fRecentDocumentsTextControl; - BTextControl *fRecentFoldersTextControl; - bool fDesktopFilePanelRoot; - int32 fRecentApplications; // Not used for the moment, - int32 fRecentDocuments; - int32 fRecentFolders; - - mutable int32 fDisplayedAppCount; // Not used for the moment. - mutable int32 fDisplayedDocCount; - mutable int32 fDisplayedFolderCount; + private: + void _GetAndRefreshDisplayedFigures() const; + void _SendNotices(); - typedef SettingsView _inherited; + BCheckBox *fDesktopFilePanelRootCheckBox; + + BTextControl *fRecentApplicationsTextControl; // Not used for the moment. + BTextControl *fRecentDocumentsTextControl; + BTextControl *fRecentFoldersTextControl; + + bool fDesktopFilePanelRoot; + int32 fRecentApplications; // Not used for the moment, + int32 fRecentDocuments; + int32 fRecentFolders; + + mutable int32 fDisplayedAppCount; // Not used for the moment. + mutable int32 fDisplayedDocCount; + mutable int32 fDisplayedFolderCount; + + typedef SettingsView _inherited; }; class TimeFormatSettingsView : public SettingsView { -public: - TimeFormatSettingsView(BRect); + public: + TimeFormatSettingsView(BRect frame); - void MessageReceived(BMessage *); - void AttachedToWindow(); + virtual void MessageReceived(BMessage *message); + virtual void AttachedToWindow(); - void SetDefaults(); - void Revert(); - void ShowCurrentSettings(bool sendNotices = false); - void RecordRevertSettings(); - bool ShowsRevertSettings() const; - - void UpdateExamples(); -private: - BRadioButton *f24HrRadioButton; - BRadioButton *f12HrRadioButton; + virtual void SetDefaults(); + virtual void Revert(); + virtual void ShowCurrentSettings(); + virtual void RecordRevertSettings(); + virtual bool IsRevertable() const; - BRadioButton *fYMDRadioButton; - BRadioButton *fDMYRadioButton; - BRadioButton *fMDYRadioButton; + private: + void _UpdateExamples(); + void _SendNotices(); - BMenuField *fSeparatorMenuField; - - BStringView *fLongDateExampleView; - BStringView *fShortDateExampleView; - - bool f24HrClock; + BRadioButton *f24HrRadioButton; + BRadioButton *f12HrRadioButton; - FormatSeparator fSeparator; - DateOrder fFormat; + BRadioButton *fYMDRadioButton; + BRadioButton *fDMYRadioButton; + BRadioButton *fMDYRadioButton; - typedef SettingsView _inherited; + BMenuField *fSeparatorMenuField; + + BStringView *fLongDateExampleView; + BStringView *fShortDateExampleView; + + bool f24HrClock; + + FormatSeparator fSeparator; + DateOrder fFormat; + + typedef SettingsView _inherited; }; class SpaceBarSettingsView : public SettingsView { -public: - SpaceBarSettingsView(BRect); - ~SpaceBarSettingsView(); + public: + SpaceBarSettingsView(BRect frame); + virtual ~SpaceBarSettingsView(); - void MessageReceived(BMessage *); - void AttachedToWindow(); - - void SetDefaults(); - void Revert(); - void ShowCurrentSettings(bool sendNotices = false); - void RecordRevertSettings(); - bool ShowsRevertSettings() const; + virtual void MessageReceived(BMessage *message); + virtual void AttachedToWindow(); -private: - BCheckBox *fSpaceBarShowCheckBox; - BColorControl *fColorControl; - BMenuField *fColorPicker; -// BRadioButton *fUsedRadio; -// BRadioButton *fWarningRadio; -// BRadioButton *fFreeRadio; - int32 fCurrentColor; + virtual void SetDefaults(); + virtual void Revert(); + virtual void ShowCurrentSettings(); + virtual void RecordRevertSettings(); + virtual bool IsRevertable() const; - bool fSpaceBarShow; - rgb_color fUsedSpaceColor; - rgb_color fFreeSpaceColor; - rgb_color fWarningSpaceColor; + private: + BCheckBox *fSpaceBarShowCheckBox; + BColorControl *fColorControl; + BMenuField *fColorPicker; + int32 fCurrentColor; - typedef SettingsView _inherited; + bool fSpaceBarShow; + rgb_color fUsedSpaceColor; + rgb_color fFreeSpaceColor; + rgb_color fWarningSpaceColor; + + typedef SettingsView _inherited; }; class TrashSettingsView : public SettingsView { -public: - TrashSettingsView(BRect); + public: + TrashSettingsView(BRect frame); - void MessageReceived(BMessage *); - void AttachedToWindow(); + virtual void MessageReceived(BMessage *message); + virtual void AttachedToWindow(); - void SetDefaults(); - void Revert(); - void ShowCurrentSettings(bool sendNotices = false); - void RecordRevertSettings(); - bool ShowsRevertSettings() const; + virtual void SetDefaults(); + virtual void Revert(); + virtual void ShowCurrentSettings(); + virtual void RecordRevertSettings(); + virtual bool IsRevertable() const; -private: - BCheckBox *fDontMoveFilesToTrashCheckBox; - BCheckBox *fAskBeforeDeleteFileCheckBox; + private: + void _SendNotices(); - bool fDontMoveFilesToTrash; - bool fAskBeforeDeleteFile; - - typedef SettingsView _inherited; + BCheckBox *fDontMoveFilesToTrashCheckBox; + BCheckBox *fAskBeforeDeleteFileCheckBox; + + bool fDontMoveFilesToTrash; + bool fAskBeforeDeleteFile; + + typedef SettingsView _inherited; }; } // namespace BPrivate using namespace BPrivate; -#endif +#endif // _SETTINGS_VIEWS diff --git a/src/kits/tracker/TrackerSettings.cpp b/src/kits/tracker/TrackerSettings.cpp index 0f5747f75d..ef93e3c5c2 100644 --- a/src/kits/tracker/TrackerSettings.cpp +++ b/src/kits/tracker/TrackerSettings.cpp @@ -172,7 +172,7 @@ TTrackerState::LoadSettingsIfNeeded() Add(fMountSharedVolumesOntoDesktop = new BooleanValueSetting("MountSharedVolumesOntoDesktop", false)); Add(fIntegrateNonBootBeOSDesktops = new BooleanValueSetting - ("IntegrateNonBootBeOSDesktops", true)); + ("IntegrateNonBootBeOSDesktops", false)); Add(fIntegrateAllNonBootDesktops = new BooleanValueSetting ("IntegrateAllNonBootDesktops", false)); Add(fEjectWhenUnmounting = new BooleanValueSetting("EjectWhenUnmounting", true)); @@ -180,7 +180,7 @@ TTrackerState::LoadSettingsIfNeeded() Add(fDesktopFilePanelRoot = new BooleanValueSetting("DesktopFilePanelRoot", true)); Add(fShowFullPathInTitleBar = new BooleanValueSetting("ShowFullPathInTitleBar", false)); Add(fShowSelectionWhenInactive = new BooleanValueSetting("ShowSelectionWhenInactive", true)); - Add(fTransparentSelection = new BooleanValueSetting("TransparentSelection", false)); + Add(fTransparentSelection = new BooleanValueSetting("TransparentSelection", true)); Add(fSortFolderNamesFirst = new BooleanValueSetting("SortFolderNamesFirst", false)); Add(fHideDotFiles = new BooleanValueSetting("HideDotFiles", false)); Add(fSingleWindowBrowse = new BooleanValueSetting("SingleWindowBrowse", false)); diff --git a/src/kits/tracker/TrackerSettingsWindow.cpp b/src/kits/tracker/TrackerSettingsWindow.cpp index c7e399f147..74cc2b2949 100644 --- a/src/kits/tracker/TrackerSettingsWindow.cpp +++ b/src/kits/tracker/TrackerSettingsWindow.cpp @@ -32,12 +32,14 @@ names are registered trademarks or trademarks of their respective holders. All rights reserved. */ + #include "SettingsViews.h" #include "TrackerSettings.h" #include "TrackerSettingsWindow.h" #include + const BPoint kSettingsWindowOffset(30, 30); const float kSettingsWindowsWidth = 370; const float kSettingsWindowsHeight = 270; @@ -48,27 +50,27 @@ const uint32 kRevertButtonPressed = 'Rebp'; TrackerSettingsWindow::TrackerSettingsWindow() - : BWindow(BRect(kSettingsWindowOffset.x, kSettingsWindowOffset.y, - kSettingsWindowOffset.x + kSettingsWindowsWidth, - kSettingsWindowOffset.y + kSettingsWindowsHeight), - "Tracker Settings", B_TITLED_WINDOW, B_NOT_MINIMIZABLE | B_NOT_RESIZABLE - | B_NO_WORKSPACE_ACTIVATION | B_NOT_ANCHORED_ON_ACTIVATE - | B_ASYNCHRONOUS_CONTROLS | B_NOT_ZOOMABLE) + : BWindow(BRect(kSettingsWindowOffset.x, kSettingsWindowOffset.y, + kSettingsWindowOffset.x + kSettingsWindowsWidth, + kSettingsWindowOffset.y + kSettingsWindowsHeight), + "Tracker Settings", B_TITLED_WINDOW, B_NOT_MINIMIZABLE | B_NOT_RESIZABLE + | B_NO_WORKSPACE_ACTIVATION | B_NOT_ANCHORED_ON_ACTIVATE + | B_ASYNCHRONOUS_CONTROLS | B_NOT_ZOOMABLE) { BView *backgroundView = new BView(Bounds(), "Background", B_FOLLOW_ALL_SIDES, 0); - + backgroundView->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); AddChild(backgroundView); - + const float kBorderDistance = 12; const float kListViewWidth = 90; const float kListViewHeight = kSettingsWindowsHeight - 2 * kBorderDistance; const float kBoxWidth = kSettingsWindowsWidth - kListViewWidth - 3 * (kBorderDistance - 1); const float kBoxHeight = kListViewHeight - 30; - + BRect listViewRect(kBorderDistance, kBorderDistance, kBorderDistance + kListViewWidth, kBorderDistance + kListViewHeight); - + BBox *borderBox = new BBox(listViewRect.InsetByCopy(-2, -2)); backgroundView->AddChild(borderBox); @@ -77,20 +79,20 @@ TrackerSettingsWindow::TrackerSettingsWindow() listViewRect.right -= 1; fSettingsTypeListView = new BListView(listViewRect, "List View"); - + borderBox->AddChild(fSettingsTypeListView); - + fSettingsContainerBox = new BBox(BRect(kBorderDistance + kListViewWidth + kBorderDistance, kBorderDistance, kBorderDistance + kListViewWidth + kBorderDistance + kBoxWidth, kBorderDistance + kBoxHeight)); - + backgroundView->AddChild(fSettingsContainerBox); - + const float kButtonTop = fSettingsContainerBox->Frame().bottom + kBorderDistance; const float kDefaultsButtonLeft = fSettingsContainerBox->Frame().left; const float kButtonWidth = 45; const float kButtonHeight = 20; - + fDefaultsButton = new BButton(BRect(kDefaultsButtonLeft, kButtonTop, kDefaultsButtonLeft + kButtonWidth, kButtonTop + kButtonHeight), "Defaults", "Defaults", new BMessage(kDefaultsButtonPressed)); @@ -103,15 +105,15 @@ TrackerSettingsWindow::TrackerSettingsWindow() fRevertButton = new BButton(BRect(fDefaultsButton->Frame().right + kBorderDistance, kButtonTop, fDefaultsButton->Frame().right + kBorderDistance + kButtonWidth, kButtonTop + kButtonHeight), "Revert", "Revert", new BMessage(kRevertButtonPressed)); - + fRevertButton->SetEnabled(false); fRevertButton->ResizeToPreferred(); backgroundView->AddChild(fRevertButton); BRect SettingsViewSize = fSettingsContainerBox->Bounds().InsetByCopy(5, 5); - + SettingsViewSize.top += 10; - + fSettingsTypeListView->AddItem(new SettingsItem("Desktop", new DesktopSettingsView(SettingsViewSize))); fSettingsTypeListView->AddItem(new SettingsItem("Windows", @@ -141,7 +143,7 @@ TrackerSettingsWindow::QuitRequested() Unlock(); } else return true; - + if (isHidden) return true; @@ -154,16 +156,15 @@ TrackerSettingsWindow::QuitRequested() void TrackerSettingsWindow::MessageReceived(BMessage *message) { - switch (message->what) { case kSettingsContentsModified: HandleChangedContents(); break; - + case kDefaultsButtonPressed: HandlePressedDefaultsButton(); break; - + case kRevertButtonPressed: HandlePressedRevertButton(); break; @@ -171,7 +172,7 @@ TrackerSettingsWindow::MessageReceived(BMessage *message) case kSettingsViewChanged: HandleChangedSettingsView(); break; - + default: _inherited::MessageReceived(message); } @@ -182,16 +183,15 @@ void TrackerSettingsWindow::Show() { if (Lock()) { - int32 itemCount = fSettingsTypeListView->CountItems(); - - for (int32 i = 0; iRecordRevertSettings(); ViewAt(i)->ShowCurrentSettings(); } fSettingsTypeListView->Invalidate(); - + Unlock(); } _inherited::Show(); @@ -218,10 +218,11 @@ TrackerSettingsWindow::HandleChangedContents() int32 itemCount = fSettingsTypeListView->CountItems(); bool revertable = false; - - for (int32 i = 0; i < itemCount; i++) - revertable |= ! ViewAt(i)->ShowsRevertSettings(); - + + for (int32 i = 0; i < itemCount; i++) { + revertable |= ViewAt(i)->IsRevertable(); + } + fSettingsTypeListView->Invalidate(); fRevertButton->SetEnabled(revertable); @@ -245,24 +246,25 @@ void TrackerSettingsWindow::HandlePressedRevertButton() { int32 itemCount = fSettingsTypeListView->CountItems(); - - for (int32 i = 0; i < itemCount; i++) - if (ViewAt(i)->ShowsRevertSettings() == false) + + for (int32 i = 0; i < itemCount; i++) { + if (ViewAt(i)->IsRevertable()) ViewAt(i)->Revert(); + } HandleChangedContents(); } + void TrackerSettingsWindow::HandleChangedSettingsView() { int32 currentSelection = fSettingsTypeListView->CurrentSelection(); - if (currentSelection < 0) return; - - BView *oldView = fSettingsContainerBox->ChildAt(0); - + + BView *oldView = fSettingsContainerBox->ChildAt(0); + if (oldView) oldView->RemoveSelf(); @@ -276,13 +278,18 @@ TrackerSettingsWindow::HandleChangedSettingsView() } } + +// #pragma mark - + + SettingsItem::SettingsItem(const char *label, SettingsView *view) - : BStringItem(label), - fSettingsView(view) + : BStringItem(label), + fSettingsView(view) { } -void + +void SettingsItem::DrawItem(BView *owner, BRect rect, bool drawEverything) { const rgb_color kModifiedColor = {0, 0, 255, 0}; @@ -290,7 +297,7 @@ SettingsItem::DrawItem(BView *owner, BRect rect, bool drawEverything) const rgb_color kSelectedColor = {140, 140, 140, 0}; if (fSettingsView) { - bool showsRevertSettings = fSettingsView->ShowsRevertSettings(); + bool isRevertable = fSettingsView->IsRevertable(); bool isSelected = IsSelected(); if (isSelected || drawEverything) { @@ -304,14 +311,14 @@ SettingsItem::DrawItem(BView *owner, BRect rect, bool drawEverything) owner->SetLowColor(color); owner->FillRect(rect); } - - if (!showsRevertSettings) + + if (isRevertable) owner->SetHighColor(kModifiedColor); else owner->SetHighColor(kBlack); owner->MovePenTo(rect.left + 4, rect.bottom - 2); - + owner->DrawString(Text()); owner->SetHighColor(kBlack); @@ -319,6 +326,7 @@ SettingsItem::DrawItem(BView *owner, BRect rect, bool drawEverything) } } + SettingsView * SettingsItem::View() { diff --git a/src/kits/tracker/TrackerSettingsWindow.h b/src/kits/tracker/TrackerSettingsWindow.h index 61dfe0fdc7..43a7e6e3a4 100644 --- a/src/kits/tracker/TrackerSettingsWindow.h +++ b/src/kits/tracker/TrackerSettingsWindow.h @@ -43,46 +43,48 @@ All rights reserved. #include "SettingsViews.h" + namespace BPrivate { class TrackerSettingsWindow : public BWindow { -public: - TrackerSettingsWindow(); - - bool QuitRequested(); - void MessageReceived(BMessage *); - void Show(); - - SettingsView *ViewAt(int32 i); + public: + TrackerSettingsWindow(); - void HandleChangedContents(); - void HandlePressedDefaultsButton(); - void HandlePressedRevertButton(); - void HandleChangedSettingsView(); - -private: - BListView *fSettingsTypeListView; - BBox *fSettingsContainerBox; - BButton *fDefaultsButton; - BButton *fRevertButton; + bool QuitRequested(); + void MessageReceived(BMessage *message); + void Show(); - typedef BWindow _inherited; + SettingsView *ViewAt(int32 i); + + void HandleChangedContents(); + void HandlePressedDefaultsButton(); + void HandlePressedRevertButton(); + void HandleChangedSettingsView(); + + private: + BListView *fSettingsTypeListView; + BBox *fSettingsContainerBox; + BButton *fDefaultsButton; + BButton *fRevertButton; + + typedef BWindow _inherited; }; class SettingsItem : public BStringItem { -public: - SettingsItem(const char *, SettingsView *); + public: + SettingsItem(const char *label, SettingsView *view); - void DrawItem(BView *owner, BRect rect, bool drawEverything); + void DrawItem(BView *owner, BRect rect, bool drawEverything); - SettingsView *View(); -private: - SettingsView *fSettingsView; + SettingsView *View(); + + private: + SettingsView *fSettingsView; }; } // namespace BPrivate using namespace BPrivate; -#endif +#endif // _TRACKER_SETTINGS_WINDOW