Tracker: Show mounted volumes on Desktop in file panels again
Add switch to Desktop and Home shortcuts. Fixes #15148 Show Volumes or Disks on Desktop in file panel. Fixes #19547 Rename Add/RemoveRootPoses() to Add/RemoveVolumePoses(). Use default Tracker values when adapting to setting changes. Bring ShowVolumes() into BPoseView and apply the same logic used by file panel to DesktopPoseView to switch between Disks and volumes on Desktop. Add Disks or volumes to file panel in BPoseView instead. When you set Show Disks or Show Volumes, set the other as well, they are opposites of each other. Remove unnecessary params related to adding/removing volumes. Rename ShowVolumes() to ToggleDisksVolumes() and move to BPoseView. Create IsVolumesRoot() to identify Desktop in a file panel. Change-Id: Id250aa6cf7386c7988017a9edbdb16ec9cea00ba Reviewed-on: https://review.haiku-os.org/c/haiku/+/9503 Tested-by: Commit checker robot <[email protected]> Reviewed-by: Adrien Destugues <[email protected]>
This commit is contained in:
@@ -114,6 +114,7 @@ const uint32 kEditFavorites = 'Tedf';
|
|||||||
const uint32 kSwitchDirectory = 'Tswd';
|
const uint32 kSwitchDirectory = 'Tswd';
|
||||||
const uint32 kQuitTracker = 'Tqit';
|
const uint32 kQuitTracker = 'Tqit';
|
||||||
|
|
||||||
|
const uint32 kSwitchToDesktop = 'TswD';
|
||||||
const uint32 kSwitchToHome = 'Tswh';
|
const uint32 kSwitchToHome = 'Tswh';
|
||||||
|
|
||||||
const uint32 kTestIconCache = 'TicC';
|
const uint32 kTestIconCache = 'TicC';
|
||||||
|
|||||||
@@ -51,6 +51,7 @@ All rights reserved.
|
|||||||
#include "FSUtils.h"
|
#include "FSUtils.h"
|
||||||
#include "PoseList.h"
|
#include "PoseList.h"
|
||||||
#include "Tracker.h"
|
#include "Tracker.h"
|
||||||
|
#include "TrackerDefaults.h"
|
||||||
#include "TrackerSettings.h"
|
#include "TrackerSettings.h"
|
||||||
#include "TrackerString.h"
|
#include "TrackerString.h"
|
||||||
|
|
||||||
@@ -95,7 +96,7 @@ DesktopPoseView::MessageReceived(BMessage* message)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
BPoseView::MessageReceived(message);
|
_inherited::MessageReceived(message);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -188,10 +189,9 @@ DesktopPoseView::FSNotification(const BMessage* message)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
if (settings.MountVolumesOntoDesktop()
|
if (settings.MountVolumesOntoDesktop()
|
||||||
&& (!volume.IsShared()
|
&& (!volume.IsShared() || settings.MountSharedVolumesOntoDesktop())) {
|
||||||
|| settings.MountSharedVolumesOntoDesktop())) {
|
|
||||||
// place an icon for the volume onto the desktop
|
// place an icon for the volume onto the desktop
|
||||||
CreateVolumePose(&volume, true);
|
CreateVolumePose(&volume);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@@ -212,7 +212,18 @@ void
|
|||||||
DesktopPoseView::AddPosesCompleted()
|
DesktopPoseView::AddPosesCompleted()
|
||||||
{
|
{
|
||||||
_inherited::AddPosesCompleted();
|
_inherited::AddPosesCompleted();
|
||||||
|
|
||||||
CreateTrashPose();
|
CreateTrashPose();
|
||||||
|
CheckAutoPlacedPoses();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
DesktopPoseView::AddPoses(Model* model)
|
||||||
|
{
|
||||||
|
AddVolumePoses();
|
||||||
|
|
||||||
|
_inherited::AddPoses(model);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -236,21 +247,6 @@ DesktopPoseView::Represents(const entry_ref* ref) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
DesktopPoseView::ShowVolumes(bool visible, bool showShared)
|
|
||||||
{
|
|
||||||
if (LockLooper()) {
|
|
||||||
SavePoseLocations();
|
|
||||||
if (!visible)
|
|
||||||
RemoveRootPoses();
|
|
||||||
else
|
|
||||||
AddRootPoses(true, showShared);
|
|
||||||
|
|
||||||
UnlockLooper();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
DesktopPoseView::StartSettingsWatch()
|
DesktopPoseView::StartSettingsWatch()
|
||||||
{
|
{
|
||||||
@@ -278,17 +274,14 @@ DesktopPoseView::StopSettingsWatch()
|
|||||||
void
|
void
|
||||||
DesktopPoseView::AdaptToVolumeChange(BMessage* message)
|
DesktopPoseView::AdaptToVolumeChange(BMessage* message)
|
||||||
{
|
{
|
||||||
|
if (Window() == NULL)
|
||||||
|
return;
|
||||||
|
|
||||||
TTracker* tracker = dynamic_cast<TTracker*>(be_app);
|
TTracker* tracker = dynamic_cast<TTracker*>(be_app);
|
||||||
ThrowOnAssert(tracker != NULL);
|
ThrowOnAssert(tracker != NULL);
|
||||||
|
|
||||||
bool showDisksIcon = false;
|
bool showDisksIcon = kDefaultShowDisksIcon;
|
||||||
bool mountVolumesOnDesktop = true;
|
|
||||||
bool mountSharedVolumesOntoDesktop = false;
|
|
||||||
|
|
||||||
message->FindBool("ShowDisksIcon", &showDisksIcon);
|
message->FindBool("ShowDisksIcon", &showDisksIcon);
|
||||||
message->FindBool("MountVolumesOntoDesktop", &mountVolumesOnDesktop);
|
|
||||||
message->FindBool("MountSharedVolumesOntoDesktop",
|
|
||||||
&mountSharedVolumesOntoDesktop);
|
|
||||||
|
|
||||||
BEntry entry("/");
|
BEntry entry("/");
|
||||||
Model model(&entry);
|
Model model(&entry);
|
||||||
@@ -302,40 +295,30 @@ DesktopPoseView::AdaptToVolumeChange(BMessage* message)
|
|||||||
entryMessage.AddInt32("opcode", B_ENTRY_REMOVED);
|
entryMessage.AddInt32("opcode", B_ENTRY_REMOVED);
|
||||||
entry_ref ref;
|
entry_ref ref;
|
||||||
if (entry.GetRef(&ref) == B_OK) {
|
if (entry.GetRef(&ref) == B_OK) {
|
||||||
BContainerWindow* disksWindow
|
BContainerWindow* disksWindow = tracker->FindContainerWindow(&ref);
|
||||||
= tracker->FindContainerWindow(&ref);
|
|
||||||
if (disksWindow != NULL) {
|
if (disksWindow != NULL) {
|
||||||
disksWindow->Lock();
|
disksWindow->Lock();
|
||||||
disksWindow->Close();
|
disksWindow->Close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
entryMessage.AddInt32("device", model.NodeRef()->device);
|
entryMessage.AddInt32("device", model.NodeRef()->device);
|
||||||
entryMessage.AddInt64("node", model.NodeRef()->node);
|
entryMessage.AddInt64("node", model.NodeRef()->node);
|
||||||
entryMessage.AddInt64("directory", model.EntryRef()->directory);
|
entryMessage.AddInt64("directory", model.EntryRef()->directory);
|
||||||
entryMessage.AddString("name", model.EntryRef()->name);
|
entryMessage.AddString("name", model.EntryRef()->name);
|
||||||
BContainerWindow* deskWindow
|
|
||||||
= dynamic_cast<BContainerWindow*>(Window());
|
Window()->PostMessage(&entryMessage, this);
|
||||||
if (deskWindow != NULL)
|
|
||||||
deskWindow->PostMessage(&entryMessage, deskWindow->PoseView());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ShowVolumes(mountVolumesOnDesktop, mountSharedVolumesOntoDesktop);
|
ToggleDisksVolumes();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
DesktopPoseView::AdaptToDesktopIntegrationChange(BMessage* message)
|
DesktopPoseView::AdaptToDesktopIntegrationChange(BMessage* message)
|
||||||
{
|
{
|
||||||
bool mountVolumesOnDesktop = true;
|
ToggleDisksVolumes();
|
||||||
bool mountSharedVolumesOntoDesktop = true;
|
|
||||||
|
|
||||||
message->FindBool("MountVolumesOntoDesktop", &mountVolumesOnDesktop);
|
|
||||||
message->FindBool("MountSharedVolumesOntoDesktop",
|
|
||||||
&mountSharedVolumesOntoDesktop);
|
|
||||||
|
|
||||||
ShowVolumes(false, mountSharedVolumesOntoDesktop);
|
|
||||||
ShowVolumes(mountVolumesOnDesktop, mountSharedVolumesOntoDesktop);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -57,18 +57,17 @@ public:
|
|||||||
|
|
||||||
static EntryListBase* InitDesktopDirentIterator(BPoseView*, const entry_ref*);
|
static EntryListBase* InitDesktopDirentIterator(BPoseView*, const entry_ref*);
|
||||||
|
|
||||||
void ShowVolumes(bool visible, bool showShared);
|
|
||||||
|
|
||||||
void StartSettingsWatch();
|
void StartSettingsWatch();
|
||||||
void StopSettingsWatch();
|
void StopSettingsWatch();
|
||||||
|
|
||||||
virtual bool AddPosesThreadValid(const entry_ref*) const;
|
|
||||||
virtual void AddPosesCompleted();
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual EntryListBase* InitDirentIterator(const entry_ref*);
|
virtual EntryListBase* InitDirentIterator(const entry_ref*);
|
||||||
virtual bool FSNotification(const BMessage*);
|
virtual bool FSNotification(const BMessage*);
|
||||||
|
|
||||||
|
virtual bool AddPosesThreadValid(const entry_ref*) const;
|
||||||
|
virtual void AddPosesCompleted();
|
||||||
|
virtual void AddPoses(Model* model = NULL);
|
||||||
|
|
||||||
virtual bool IsDesktopView() const;
|
virtual bool IsDesktopView() const;
|
||||||
|
|
||||||
virtual bool Represents(const node_ref*) const;
|
virtual bool Represents(const node_ref*) const;
|
||||||
|
|||||||
@@ -80,6 +80,7 @@ All rights reserved.
|
|||||||
#include "NavMenu.h"
|
#include "NavMenu.h"
|
||||||
#include "Shortcuts.h"
|
#include "Shortcuts.h"
|
||||||
#include "Tracker.h"
|
#include "Tracker.h"
|
||||||
|
#include "TrackerDefaults.h"
|
||||||
#include "Utilities.h"
|
#include "Utilities.h"
|
||||||
|
|
||||||
#include "tracker_private.h"
|
#include "tracker_private.h"
|
||||||
@@ -557,6 +558,10 @@ TFilePanel::SwitchDirectory(const entry_ref* ref)
|
|||||||
PoseView()->SetIsDesktop(isDesktop);
|
PoseView()->SetIsDesktop(isDesktop);
|
||||||
_inherited::SwitchDirectory(&setToRef);
|
_inherited::SwitchDirectory(&setToRef);
|
||||||
|
|
||||||
|
if (PoseView()->IsDesktop())
|
||||||
|
PoseView()->AddVolumePoses();
|
||||||
|
|
||||||
|
AddShortcut('D', B_COMMAND_KEY, new BMessage(kSwitchToDesktop));
|
||||||
AddShortcut('H', B_COMMAND_KEY, new BMessage(kSwitchToHome));
|
AddShortcut('H', B_COMMAND_KEY, new BMessage(kSwitchToHome));
|
||||||
// our shortcut got possibly removed because the home
|
// our shortcut got possibly removed because the home
|
||||||
// menu item got removed - we shouldn't really have to do
|
// menu item got removed - we shouldn't really have to do
|
||||||
@@ -804,6 +809,7 @@ TFilePanel::Init(const BMessage*)
|
|||||||
fShortcuts = new TShortcuts(this);
|
fShortcuts = new TShortcuts(this);
|
||||||
|
|
||||||
AddShortcut('W', B_COMMAND_KEY, new BMessage(kCancelButton));
|
AddShortcut('W', B_COMMAND_KEY, new BMessage(kCancelButton));
|
||||||
|
AddShortcut('D', B_COMMAND_KEY, new BMessage(kSwitchToDesktop));
|
||||||
AddShortcut('H', B_COMMAND_KEY, new BMessage(kSwitchToHome));
|
AddShortcut('H', B_COMMAND_KEY, new BMessage(kSwitchToHome));
|
||||||
AddShortcut('A', B_COMMAND_KEY | B_SHIFT_KEY, new BMessage(kShowSelectionWindow));
|
AddShortcut('A', B_COMMAND_KEY | B_SHIFT_KEY, new BMessage(kShowSelectionWindow));
|
||||||
AddShortcut('A', B_COMMAND_KEY, new BMessage(B_SELECT_ALL), this);
|
AddShortcut('A', B_COMMAND_KEY, new BMessage(B_SELECT_ALL), this);
|
||||||
@@ -823,6 +829,7 @@ TFilePanel::Init(const BMessage*)
|
|||||||
|
|
||||||
if (ShouldAddMenus())
|
if (ShouldAddMenus())
|
||||||
AddMenus();
|
AddMenus();
|
||||||
|
|
||||||
AddContextMenus();
|
AddContextMenus();
|
||||||
|
|
||||||
PoseView()->ScrollTo(B_ORIGIN);
|
PoseView()->ScrollTo(B_ORIGIN);
|
||||||
@@ -967,8 +974,7 @@ TFilePanel::RestoreWindowState(AttributeStreamNode* node)
|
|||||||
|
|
||||||
const char* rectAttributeName = kAttrWindowFrame;
|
const char* rectAttributeName = kAttrWindowFrame;
|
||||||
BRect frame(Frame());
|
BRect frame(Frame());
|
||||||
if (node->Read(rectAttributeName, 0, B_RECT_TYPE, sizeof(BRect), &frame)
|
if (node->Read(rectAttributeName, 0, B_RECT_TYPE, sizeof(BRect), &frame) == sizeof(BRect)) {
|
||||||
== sizeof(BRect)) {
|
|
||||||
MoveTo(frame.LeftTop());
|
MoveTo(frame.LeftTop());
|
||||||
ResizeTo(frame.Width(), frame.Height());
|
ResizeTo(frame.Width(), frame.Height());
|
||||||
}
|
}
|
||||||
@@ -1296,6 +1302,27 @@ TFilePanel::MessageReceived(BMessage* message)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
case kSwitchToDesktop:
|
||||||
|
{
|
||||||
|
if (PoseView() != NULL && PoseView()->IsFocus()
|
||||||
|
&& PoseView()->CanMoveToTrashOrDuplicate()) {
|
||||||
|
// duplicate selection instead
|
||||||
|
message->what = kDuplicateSelection;
|
||||||
|
PostMessage(message, PoseView());
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
BPath path;
|
||||||
|
entry_ref ref;
|
||||||
|
if (find_directory(B_DESKTOP_DIRECTORY, &path) != B_OK
|
||||||
|
|| get_ref_for_path(path.Path(), &ref) != B_OK) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
SwitchDirectory(&ref);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
case kSwitchToHome:
|
case kSwitchToHome:
|
||||||
{
|
{
|
||||||
BPath homePath;
|
BPath homePath;
|
||||||
@@ -1698,7 +1725,7 @@ TFilePanel::WindowActivated(bool active)
|
|||||||
BFilePanelPoseView::BFilePanelPoseView(Model* model)
|
BFilePanelPoseView::BFilePanelPoseView(Model* model)
|
||||||
:
|
:
|
||||||
BPoseView(model, kListMode),
|
BPoseView(model, kListMode),
|
||||||
fIsDesktop(model->IsDesktop())
|
fIsDesktop(model != NULL && model->IsDesktop())
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1731,9 +1758,9 @@ BFilePanelPoseView::FSNotification(const BMessage* message)
|
|||||||
switch (message->FindInt32("opcode")) {
|
switch (message->FindInt32("opcode")) {
|
||||||
case B_DEVICE_MOUNTED:
|
case B_DEVICE_MOUNTED:
|
||||||
{
|
{
|
||||||
if (IsDesktop()) {
|
if (!IsDesktop() && !TargetModel()->IsRoot())
|
||||||
// Pretty much copied straight from DesktopPoseView.
|
break;
|
||||||
// Would be better if the code could be shared somehow.
|
|
||||||
dev_t device;
|
dev_t device;
|
||||||
if (message->FindInt32("new device", &device) != B_OK)
|
if (message->FindInt32("new device", &device) != B_OK)
|
||||||
break;
|
break;
|
||||||
@@ -1745,12 +1772,11 @@ BFilePanelPoseView::FSNotification(const BMessage* message)
|
|||||||
if (volume.InitCheck() != B_OK)
|
if (volume.InitCheck() != B_OK)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
if (settings.MountVolumesOntoDesktop()
|
// place volume icon onto Desktop or Root
|
||||||
&& (!volume.IsShared()
|
if ((!volume.IsShared() || settings.MountSharedVolumesOntoDesktop())
|
||||||
|| settings.MountSharedVolumesOntoDesktop())) {
|
&& ((IsVolumesRoot() && settings.MountVolumesOntoDesktop())
|
||||||
// place an icon for the volume onto the desktop
|
|| TargetModel()->IsRoot())) {
|
||||||
CreateVolumePose(&volume, true);
|
CreateVolumePose(&volume);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -1759,8 +1785,7 @@ BFilePanelPoseView::FSNotification(const BMessage* message)
|
|||||||
{
|
{
|
||||||
dev_t device;
|
dev_t device;
|
||||||
if (message->FindInt32("device", &device) == B_OK) {
|
if (message->FindInt32("device", &device) == B_OK) {
|
||||||
if (TargetModel() != NULL
|
if (TargetModel() != NULL && TargetModel()->NodeRef()->device == device) {
|
||||||
&& TargetModel()->NodeRef()->device == device) {
|
|
||||||
// Volume currently shown in this file panel
|
// Volume currently shown in this file panel
|
||||||
// disappeared, reset location to home directory
|
// disappeared, reset location to home directory
|
||||||
BMessage message(kSwitchToHome);
|
BMessage message(kSwitchToHome);
|
||||||
@@ -1809,37 +1834,36 @@ void
|
|||||||
BFilePanelPoseView::AddPosesCompleted()
|
BFilePanelPoseView::AddPosesCompleted()
|
||||||
{
|
{
|
||||||
_inherited::AddPosesCompleted();
|
_inherited::AddPosesCompleted();
|
||||||
|
|
||||||
if (IsDesktop())
|
if (IsDesktop())
|
||||||
CreateTrashPose();
|
CreateTrashPose();
|
||||||
|
|
||||||
|
// the menu that adds these shortcuts may not exist initially
|
||||||
|
Window()->AddShortcut('D', B_COMMAND_KEY, new BMessage(kSwitchToDesktop));
|
||||||
|
Window()->AddShortcut('H', B_COMMAND_KEY, new BMessage(kSwitchToHome));
|
||||||
|
|
||||||
|
UpdateScrollRange();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
BFilePanelPoseView::ShowVolumes(bool visible, bool showShared)
|
BFilePanelPoseView::AddPoses(Model* model)
|
||||||
{
|
{
|
||||||
if (IsDesktop()) {
|
if (IsDesktop())
|
||||||
if (!visible)
|
AddVolumePoses();
|
||||||
RemoveRootPoses();
|
|
||||||
else
|
|
||||||
AddRootPoses(true, showShared);
|
|
||||||
}
|
|
||||||
|
|
||||||
TFilePanel* panel = dynamic_cast<TFilePanel*>(Window());
|
_inherited::AddPoses(model);
|
||||||
if (panel != NULL && TargetModel() != NULL)
|
|
||||||
panel->SwitchDirectory(TargetModel()->EntryRef());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
BFilePanelPoseView::AdaptToVolumeChange(BMessage* message)
|
BFilePanelPoseView::AdaptToVolumeChange(BMessage* message)
|
||||||
{
|
{
|
||||||
bool showDisksIcon;
|
if (Window() == NULL)
|
||||||
bool mountVolumesOnDesktop;
|
return;
|
||||||
bool mountSharedVolumesOntoDesktop;
|
|
||||||
|
|
||||||
|
bool showDisksIcon = kDefaultShowDisksIcon;
|
||||||
message->FindBool("ShowDisksIcon", &showDisksIcon);
|
message->FindBool("ShowDisksIcon", &showDisksIcon);
|
||||||
message->FindBool("MountVolumesOntoDesktop", &mountVolumesOnDesktop);
|
|
||||||
message->FindBool("MountSharedVolumesOntoDesktop", &mountSharedVolumesOntoDesktop);
|
|
||||||
|
|
||||||
BEntry entry("/");
|
BEntry entry("/");
|
||||||
Model model(&entry);
|
Model model(&entry);
|
||||||
@@ -1856,23 +1880,18 @@ BFilePanelPoseView::AdaptToVolumeChange(BMessage* message)
|
|||||||
monitorMsg.AddInt64("node", model.NodeRef()->node);
|
monitorMsg.AddInt64("node", model.NodeRef()->node);
|
||||||
monitorMsg.AddInt64("directory", model.EntryRef()->directory);
|
monitorMsg.AddInt64("directory", model.EntryRef()->directory);
|
||||||
monitorMsg.AddString("name", model.EntryRef()->name);
|
monitorMsg.AddString("name", model.EntryRef()->name);
|
||||||
|
|
||||||
TrackerSettings().SetShowDisksIcon(showDisksIcon);
|
TrackerSettings().SetShowDisksIcon(showDisksIcon);
|
||||||
|
|
||||||
Window()->PostMessage(&monitorMsg, this);
|
Window()->PostMessage(&monitorMsg, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
ShowVolumes(mountVolumesOnDesktop, mountSharedVolumesOntoDesktop);
|
ToggleDisksVolumes();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
BFilePanelPoseView::AdaptToDesktopIntegrationChange(BMessage* message)
|
BFilePanelPoseView::AdaptToDesktopIntegrationChange(BMessage* message)
|
||||||
{
|
{
|
||||||
bool mountVolumesOnDesktop = true;
|
ToggleDisksVolumes();
|
||||||
bool mountSharedVolumesOntoDesktop = true;
|
|
||||||
|
|
||||||
message->FindBool("MountVolumesOntoDesktop", &mountVolumesOnDesktop);
|
|
||||||
message->FindBool("MountSharedVolumesOntoDesktop", &mountSharedVolumesOntoDesktop);
|
|
||||||
|
|
||||||
ShowVolumes(false, mountSharedVolumesOntoDesktop);
|
|
||||||
ShowVolumes(mountVolumesOnDesktop, mountSharedVolumesOntoDesktop);
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -193,8 +193,8 @@ protected:
|
|||||||
|
|
||||||
virtual EntryListBase* InitDirentIterator(const entry_ref*);
|
virtual EntryListBase* InitDirentIterator(const entry_ref*);
|
||||||
virtual void AddPosesCompleted();
|
virtual void AddPosesCompleted();
|
||||||
|
virtual void AddPoses(Model* model = NULL);
|
||||||
void ShowVolumes(bool visible, bool showShared);
|
virtual bool IsVolumesRoot() const { return fIsDesktop; };
|
||||||
|
|
||||||
void AdaptToVolumeChange(BMessage*);
|
void AdaptToVolumeChange(BMessage*);
|
||||||
void AdaptToDesktopIntegrationChange(BMessage*);
|
void AdaptToDesktopIntegrationChange(BMessage*);
|
||||||
@@ -205,6 +205,7 @@ private:
|
|||||||
// the root of the world and "/boot/home/Desktop" to which
|
// the root of the world and "/boot/home/Desktop" to which
|
||||||
// we might have navigated from the home dir.
|
// we might have navigated from the home dir.
|
||||||
|
|
||||||
|
friend class TFilePanel;
|
||||||
typedef BPoseView _inherited;
|
typedef BPoseView _inherited;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -1280,15 +1280,13 @@ BPoseView::AddPoses(Model* model)
|
|||||||
{
|
{
|
||||||
// if model is zero, PoseView has other means of iterating through all
|
// if model is zero, PoseView has other means of iterating through all
|
||||||
// the entries that it adds
|
// the entries that it adds
|
||||||
if (model != NULL) {
|
|
||||||
TrackerSettings settings;
|
// Desktop poses are added either in FilePanelPriv or DesktopPoseView
|
||||||
if (model->IsRoot()) {
|
|
||||||
AddRootPoses(true, settings.MountSharedVolumesOntoDesktop());
|
// adding volumes is all there is to do for root directory
|
||||||
|
if (TargetModel()->IsRoot()) {
|
||||||
|
AddVolumePoses();
|
||||||
return;
|
return;
|
||||||
} else if (IsDesktopView()
|
|
||||||
&& (settings.MountVolumesOntoDesktop() || settings.ShowDisksIcon()
|
|
||||||
|| (IsFilePanel() && settings.DesktopFilePanelRoot())))
|
|
||||||
AddRootPoses(true, settings.MountSharedVolumesOntoDesktop());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ShowBarberPole();
|
ShowBarberPole();
|
||||||
@@ -1587,8 +1585,11 @@ BPoseView::AddPosesTask(void* castToParams)
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
BPoseView::AddRootPoses(bool watchIndividually, bool mountShared)
|
BPoseView::AddVolumePoses()
|
||||||
{
|
{
|
||||||
|
if (Window() == NULL)
|
||||||
|
return;
|
||||||
|
|
||||||
BVolumeRoster roster;
|
BVolumeRoster roster;
|
||||||
roster.Rewind();
|
roster.Rewind();
|
||||||
BVolume volume;
|
BVolume volume;
|
||||||
@@ -1606,7 +1607,7 @@ BPoseView::AddRootPoses(bool watchIndividually, bool mountShared)
|
|||||||
monitorMsg.AddInt64("node", model.NodeRef()->node);
|
monitorMsg.AddInt64("node", model.NodeRef()->node);
|
||||||
monitorMsg.AddInt64("directory", model.EntryRef()->directory);
|
monitorMsg.AddInt64("directory", model.EntryRef()->directory);
|
||||||
monitorMsg.AddString("name", model.EntryRef()->name);
|
monitorMsg.AddString("name", model.EntryRef()->name);
|
||||||
if (Window())
|
|
||||||
Window()->PostMessage(&monitorMsg, this);
|
Window()->PostMessage(&monitorMsg, this);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@@ -1614,10 +1615,10 @@ BPoseView::AddRootPoses(bool watchIndividually, bool mountShared)
|
|||||||
if (!volume.IsPersistent())
|
if (!volume.IsPersistent())
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (volume.IsShared() && !mountShared)
|
if (volume.IsShared() && !TrackerSettings().MountSharedVolumesOntoDesktop())
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
CreateVolumePose(&volume, watchIndividually);
|
CreateVolumePose(&volume);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1628,7 +1629,7 @@ BPoseView::AddRootPoses(bool watchIndividually, bool mountShared)
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
BPoseView::RemoveRootPoses()
|
BPoseView::RemoveVolumePoses()
|
||||||
{
|
{
|
||||||
int32 index;
|
int32 index;
|
||||||
int32 poseCount = fPoseList->CountItems();
|
int32 poseCount = fPoseList->CountItems();
|
||||||
@@ -1652,6 +1653,25 @@ BPoseView::RemoveRootPoses()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
BPoseView::ToggleDisksVolumes()
|
||||||
|
{
|
||||||
|
if (IsVolumesRoot() && LockLooper()) {
|
||||||
|
SavePoseLocations();
|
||||||
|
|
||||||
|
if (TrackerSettings().MountVolumesOntoDesktop()) {
|
||||||
|
RemoveRootPose();
|
||||||
|
AddVolumePoses();
|
||||||
|
} else {
|
||||||
|
RemoveVolumePoses();
|
||||||
|
CreateRootPose();
|
||||||
|
}
|
||||||
|
|
||||||
|
UnlockLooper();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
BPoseView::AddTrashPoses()
|
BPoseView::AddTrashPoses()
|
||||||
{
|
{
|
||||||
@@ -1703,7 +1723,7 @@ BPoseView::AddPosesCompleted()
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
BPoseView::CreateVolumePose(BVolume* volume, bool watchIndividually)
|
BPoseView::CreateVolumePose(BVolume* volume)
|
||||||
{
|
{
|
||||||
if (volume->InitCheck() != B_OK || !volume->IsPersistent()) {
|
if (volume->InitCheck() != B_OK || !volume->IsPersistent()) {
|
||||||
// We never want to create poses for those volumes; the file
|
// We never want to create poses for those volumes; the file
|
||||||
@@ -1735,15 +1755,45 @@ BPoseView::CreateVolumePose(BVolume* volume, bool watchIndividually)
|
|||||||
dirNode.node = ref.directory;
|
dirNode.node = ref.directory;
|
||||||
|
|
||||||
BPose* pose = EntryCreated(&dirNode, &itemNode, ref.name, 0);
|
BPose* pose = EntryCreated(&dirNode, &itemNode, ref.name, 0);
|
||||||
if (pose != NULL && watchIndividually) {
|
if (pose != NULL && !TargetModel()->IsRoot()) {
|
||||||
// make sure volume names still get watched, even though
|
// When placing a volume pose onto the Desktop where unlike in the
|
||||||
// they are on the desktop which is not their physical parent
|
// Root window it will not be watched by the folder.
|
||||||
pose->TargetModel()->WatchVolumeAndMountPoint(B_WATCH_NAME
|
pose->TargetModel()->WatchVolumeAndMountPoint(B_WATCH_NAME
|
||||||
| B_WATCH_STAT | B_WATCH_ATTR, this);
|
| B_WATCH_STAT | B_WATCH_ATTR, this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
BPoseView::CreateRootPose()
|
||||||
|
{
|
||||||
|
BEntry entry("/");
|
||||||
|
Model* model = new Model(&entry);
|
||||||
|
if (model == NULL || model->InitCheck() != B_OK) {
|
||||||
|
delete model;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
PoseInfo info;
|
||||||
|
ReadPoseInfo(model, &info);
|
||||||
|
CreatePose(model, &info, true, NULL, NULL, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
BPoseView::RemoveRootPose()
|
||||||
|
{
|
||||||
|
BEntry entry("/");
|
||||||
|
node_ref nref;
|
||||||
|
if (entry.GetNodeRef(&nref) != B_OK)
|
||||||
|
return;
|
||||||
|
|
||||||
|
DeletePose(&nref);
|
||||||
|
|
||||||
|
Invalidate();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
BPoseView::CreateTrashPose()
|
BPoseView::CreateTrashPose()
|
||||||
{
|
{
|
||||||
@@ -5351,9 +5401,10 @@ BPoseView::FSNotification(const BMessage* message)
|
|||||||
&& !targetModel->IsQuery()
|
&& !targetModel->IsQuery()
|
||||||
&& !targetModel->IsVirtualDirectory()
|
&& !targetModel->IsVirtualDirectory()
|
||||||
&& !targetModel->IsRoot()
|
&& !targetModel->IsRoot()
|
||||||
&& (!settings.ShowDisksIcon() || !IsDesktopView())) {
|
&& (!settings.ShowDisksIcon() || !IsVolumesRoot())) {
|
||||||
if (count == 0)
|
if (count == 0)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
createPose = false;
|
createPose = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -5386,8 +5437,8 @@ BPoseView::FSNotification(const BMessage* message)
|
|||||||
createdPath.Length()) == 0) {
|
createdPath.Length()) == 0) {
|
||||||
if (pathStr[createdPath.Length()] != '/')
|
if (pathStr[createdPath.Length()] != '/')
|
||||||
break;
|
break;
|
||||||
StopWatchingParentsOf(fBrokenLinks->ItemAt(i)
|
|
||||||
->EntryRef());
|
StopWatchingParentsOf(fBrokenLinks->ItemAt(i)->EntryRef());
|
||||||
watch_node(&itemNode, B_WATCH_DIRECTORY, this);
|
watch_node(&itemNode, B_WATCH_DIRECTORY, this);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -5463,7 +5514,7 @@ BPoseView::FSNotification(const BMessage* message)
|
|||||||
if (targetModel != NULL && targetModel->IsRoot()) {
|
if (targetModel != NULL && targetModel->IsRoot()) {
|
||||||
BVolume volume(device);
|
BVolume volume(device);
|
||||||
if (volume.InitCheck() == B_OK)
|
if (volume.InitCheck() == B_OK)
|
||||||
CreateVolumePose(&volume, false);
|
CreateVolumePose(&volume);
|
||||||
} else if (TargetModel()->IsTrash()) {
|
} else if (TargetModel()->IsTrash()) {
|
||||||
// add trash items from newly mounted volume
|
// add trash items from newly mounted volume
|
||||||
|
|
||||||
@@ -8390,6 +8441,7 @@ BPoseView::SwitchDir(const entry_ref* newDirRef, AttributeStreamNode* node)
|
|||||||
AddTrashPoses();
|
AddTrashPoses();
|
||||||
else
|
else
|
||||||
AddPoses(TargetModel());
|
AddPoses(TargetModel());
|
||||||
|
|
||||||
TargetModel()->CloseNode();
|
TargetModel()->CloseNode();
|
||||||
|
|
||||||
AdoptSystemColors();
|
AdoptSystemColors();
|
||||||
|
|||||||
@@ -488,7 +488,10 @@ protected:
|
|||||||
virtual void CreatePoses(Model**models, PoseInfo* poseInfoArray, int32 count,
|
virtual void CreatePoses(Model**models, PoseInfo* poseInfoArray, int32 count,
|
||||||
BPose** resultingPoses, bool insertionSort = true, int32* lastPoseIndexPointer = 0,
|
BPose** resultingPoses, bool insertionSort = true, int32* lastPoseIndexPointer = 0,
|
||||||
BRect* boundsPointer = 0, bool forceDraw = false);
|
BRect* boundsPointer = 0, bool forceDraw = false);
|
||||||
void CreateVolumePose(BVolume*, bool watchIndividually);
|
void CreateVolumePose(BVolume*);
|
||||||
|
|
||||||
|
virtual void CreateRootPose();
|
||||||
|
virtual void RemoveRootPose();
|
||||||
|
|
||||||
void CreateTrashPose();
|
void CreateTrashPose();
|
||||||
|
|
||||||
@@ -502,12 +505,11 @@ protected:
|
|||||||
// if <model> is zero, PoseView has other means of iterating
|
// if <model> is zero, PoseView has other means of iterating
|
||||||
// through all the entries thaat it adds
|
// through all the entries thaat it adds
|
||||||
|
|
||||||
virtual void AddRootPoses(bool watchIndividually, bool mountShared);
|
virtual void AddVolumePoses();
|
||||||
// watchIndividually is used when placing a volume pose onto
|
virtual void RemoveVolumePoses();
|
||||||
// the Desktop where unlike in the Root window it will not be
|
virtual void ToggleDisksVolumes();
|
||||||
// watched by the folder representing root. If set, each volume
|
virtual bool IsVolumesRoot() const { return IsDesktopView(); };
|
||||||
// will therefore be watched individually
|
|
||||||
virtual void RemoveRootPoses();
|
|
||||||
virtual void AddTrashPoses();
|
virtual void AddTrashPoses();
|
||||||
|
|
||||||
virtual bool DeletePose(const node_ref*, BPose* pose = NULL, int32 index = 0);
|
virtual bool DeletePose(const node_ref*, BPose* pose = NULL, int32 index = 0);
|
||||||
|
|||||||
@@ -290,6 +290,7 @@ void
|
|||||||
TrackerSettings::SetShowDisksIcon(bool enabled)
|
TrackerSettings::SetShowDisksIcon(bool enabled)
|
||||||
{
|
{
|
||||||
gTrackerState.fShowDisksIcon->SetValue(enabled);
|
gTrackerState.fShowDisksIcon->SetValue(enabled);
|
||||||
|
gTrackerState.fMountVolumesOntoDesktop->SetValue(!enabled);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -317,6 +318,7 @@ TrackerSettings::MountVolumesOntoDesktop()
|
|||||||
void
|
void
|
||||||
TrackerSettings::SetMountVolumesOntoDesktop(bool enabled)
|
TrackerSettings::SetMountVolumesOntoDesktop(bool enabled)
|
||||||
{
|
{
|
||||||
|
gTrackerState.fShowDisksIcon->SetValue(!enabled);
|
||||||
gTrackerState.fMountVolumesOntoDesktop->SetValue(enabled);
|
gTrackerState.fMountVolumesOntoDesktop->SetValue(enabled);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user