Tracker: Style fixes

This commit is contained in:
John Scipione
2014-06-10 00:36:10 -04:00
parent 12bd3f0452
commit 9437e677ba
18 changed files with 304 additions and 194 deletions
+3 -3
View File
@@ -731,7 +731,7 @@ SelectiveAttributeTransformer::~SelectiveAttributeTransformer()
{ {
for (int32 index = fTransformedBuffers.CountItems() - 1; index >= 0; for (int32 index = fTransformedBuffers.CountItems() - 1; index >= 0;
index--) { index--) {
delete [] fTransformedBuffers.ItemAt(index); delete[] fTransformedBuffers.ItemAt(index);
} }
} }
@@ -741,7 +741,7 @@ SelectiveAttributeTransformer::Rewind()
{ {
for (int32 index = fTransformedBuffers.CountItems() - 1; index >= 0; for (int32 index = fTransformedBuffers.CountItems() - 1; index >= 0;
index--) { index--) {
delete [] fTransformedBuffers.ItemAt(index); delete[] fTransformedBuffers.ItemAt(index);
} }
fTransformedBuffers.MakeEmpty(); fTransformedBuffers.MakeEmpty();
@@ -791,7 +791,7 @@ SelectiveAttributeTransformer::CopyAndApplyTransformer(const char* name,
} }
if (!(fTransformFunc)(name, type, size, result, fTransformParams)) { if (!(fTransformFunc)(name, type, size, result, fTransformParams)) {
delete [] result; delete[] result;
return NULL; return NULL;
} }
+8 -7
View File
@@ -215,15 +215,16 @@ protected:
class AttrNode { class AttrNode {
public: public:
AttrNode(const char* name, uint32 type, off_t size, char* data) AttrNode(const char* name, uint32 type, off_t size, char* data)
: fAttr(name, type, size), :
fData(data) fAttr(name, type, size),
{ fData(data)
} {
}
~AttrNode() ~AttrNode()
{ {
delete [] fData; delete[] fData;
} }
AttributeInfo fAttr; AttributeInfo fAttr;
char* fData; char* fData;
+1 -1
View File
@@ -78,7 +78,7 @@ BackgroundImage::GetBackgroundImage(const BNode* node, bool isDesktop)
if (error == info.size) if (error == info.size)
error = container.Unflatten(buffer); error = container.Unflatten(buffer);
delete [] buffer; delete[] buffer;
if (error != B_OK) if (error != B_OK)
return NULL; return NULL;
+107 -70
View File
@@ -32,9 +32,8 @@ names are registered trademarks or trademarks of their respective holders.
All rights reserved. All rights reserved.
*/ */
#include <string.h>
#include <stdlib.h> #include "ContainerWindow.h"
#include <image.h>
#include <Alert.h> #include <Alert.h>
#include <Application.h> #include <Application.h>
@@ -59,6 +58,9 @@ All rights reserved.
#include <Roster.h> #include <Roster.h>
#include <fs_attr.h> #include <fs_attr.h>
#include <image.h>
#include <string.h>
#include <stdlib.h>
#include <memory> #include <memory>
@@ -67,7 +69,6 @@ All rights reserved.
#include "AutoLock.h" #include "AutoLock.h"
#include "BackgroundImage.h" #include "BackgroundImage.h"
#include "Commands.h" #include "Commands.h"
#include "ContainerWindow.h"
#include "CountView.h" #include "CountView.h"
#include "DeskWindow.h" #include "DeskWindow.h"
#include "FavoritesMenu.h" #include "FavoritesMenu.h"
@@ -95,6 +96,7 @@ All rights reserved.
#undef B_TRANSLATION_CONTEXT #undef B_TRANSLATION_CONTEXT
#define B_TRANSLATION_CONTEXT "ContainerWindow" #define B_TRANSLATION_CONTEXT "ContainerWindow"
const uint32 kRedo = 'REDO'; const uint32 kRedo = 'REDO';
// this is the same as B_REDO in Dano/Zeta/Haiku // this is the same as B_REDO in Dano/Zeta/Haiku
@@ -104,9 +106,11 @@ _IMPEXP_BE
#endif #endif
void do_minimize_team(BRect zoomRect, team_id team, bool zoom); void do_minimize_team(BRect zoomRect, team_id team, bool zoom);
// Amount you have to move the mouse before a drag starts // Amount you have to move the mouse before a drag starts
const float kDragSlop = 3.0f; const float kDragSlop = 3.0f;
namespace BPrivate { namespace BPrivate {
class DraggableContainerIcon : public BView { class DraggableContainerIcon : public BView {
@@ -130,6 +134,7 @@ class DraggableContainerIcon : public BView {
} // namespace BPrivate } // namespace BPrivate
struct AddOneAddonParams { struct AddOneAddonParams {
BObjectList<BMenuItem>* primaryList; BObjectList<BMenuItem>* primaryList;
BObjectList<BMenuItem>* secondaryList; BObjectList<BMenuItem>* secondaryList;
@@ -139,16 +144,19 @@ struct StaggerOneParams {
bool rectFromParent; bool rectFromParent;
}; };
const int32 kContainerWidthMinLimit = 120; const int32 kContainerWidthMinLimit = 120;
const int32 kContainerWindowHeightLimit = 85; const int32 kContainerWindowHeightLimit = 85;
const int32 kWindowStaggerBy = 17; const int32 kWindowStaggerBy = 17;
BRect BContainerWindow::sNewWindRect(85, 50, 548, 280); BRect BContainerWindow::sNewWindRect(85, 50, 548, 280);
LockingList<AddonShortcut>* BContainerWindow::fAddonsList LockingList<AddonShortcut>* BContainerWindow::fAddonsList
= new LockingList<struct AddonShortcut>(10, true); = new LockingList<struct AddonShortcut>(10, true);
namespace BPrivate { namespace BPrivate {
filter_result filter_result
@@ -276,6 +284,7 @@ OffsetFrameOne(const char* DEBUG_ONLY(name), uint32, off_t, void* castToRect,
return false; return false;
((BRect*)castToRect)->OffsetBy(kWindowStaggerBy, kWindowStaggerBy); ((BRect*)castToRect)->OffsetBy(kWindowStaggerBy, kWindowStaggerBy);
return true; return true;
} }
@@ -294,6 +303,7 @@ AddMimeTypeString(BObjectList<BString> &list, Model* model)
return; return;
} }
} }
list.AddItem(mimeType); list.AddItem(mimeType);
} }
} }
@@ -304,7 +314,8 @@ AddMimeTypeString(BObjectList<BString> &list, Model* model)
DraggableContainerIcon::DraggableContainerIcon(BRect rect, const char* name, DraggableContainerIcon::DraggableContainerIcon(BRect rect, const char* name,
uint32 resizeMask) uint32 resizeMask)
: BView(rect, name, resizeMask, B_WILL_DRAW | B_FRAME_EVENTS), :
BView(rect, name, resizeMask, B_WILL_DRAW | B_FRAME_EVENTS),
fDragButton(0), fDragButton(0),
fDragStarted(false) fDragStarted(false)
{ {
@@ -383,7 +394,7 @@ DraggableContainerIcon::MouseMoved(BPoint point, uint32 /*transit*/,
float height = ceilf(fontHeight.ascent + fontHeight.descent float height = ceilf(fontHeight.ascent + fontHeight.descent
+ fontHeight.leading + 2 + Bounds().Height() + 8); + fontHeight.leading + 2 + Bounds().Height() + 8);
BRect rect(0, 0, max_c(Bounds().Width(), BRect rect(0, 0, std::max(Bounds().Width(),
font.StringWidth(model->Name()) + 4), height); font.StringWidth(model->Name()) + 4), height);
BBitmap* dragBitmap = new BBitmap(rect, B_RGBA32, true); BBitmap* dragBitmap = new BBitmap(rect, B_RGBA32, true);
@@ -571,9 +582,9 @@ BContainerWindow::BContainerWindow(LockingList<BWindow>* list,
} }
// ToDo: remove me once we have undo/redo menu items // ToDo: remove me once we have undo/redo menu items
// (that is, move them to AddShortcuts()) // (that is, move them to AddShortcuts())
AddShortcut('Z', B_COMMAND_KEY, new BMessage(B_UNDO), this); AddShortcut('Z', B_COMMAND_KEY, new BMessage(B_UNDO), this);
AddShortcut('Z', B_COMMAND_KEY | B_SHIFT_KEY, new BMessage(kRedo), this); AddShortcut('Z', B_COMMAND_KEY | B_SHIFT_KEY, new BMessage(kRedo), this);
} }
@@ -596,7 +607,7 @@ BContainerWindow::~BContainerWindow()
delete fDragMessage; delete fDragMessage;
delete fCachedTypesList; delete fCachedTypesList;
if (fSelectionWindow && fSelectionWindow->Lock()) if (fSelectionWindow != NULL && fSelectionWindow->Lock())
fSelectionWindow->Quit(); fSelectionWindow->Quit();
} }
@@ -631,9 +642,10 @@ BContainerWindow::QuitRequested()
// means to say close all your windows. It might be better to have it // means to say close all your windows. It might be better to have it
// send a kCloseAllWindows message and have windowless apps stay running, // send a kCloseAllWindows message and have windowless apps stay running,
// which is what we will do for the Tracker // which is what we will do for the Tracker
if (CurrentMessage() if (CurrentMessage() != NULL
&& (CurrentMessage()->FindInt32("modifiers") & B_CONTROL_KEY)) && ((CurrentMessage()->FindInt32("modifiers") & B_CONTROL_KEY)) != 0) {
be_app->PostMessage(kCloseAllWindows); be_app->PostMessage(kCloseAllWindows);
}
Hide(); Hide();
// this will close the window instantly, even if // this will close the window instantly, even if
@@ -739,18 +751,17 @@ BContainerWindow::CreatePoseView(Model* model)
BRect rect(Bounds()); BRect rect(Bounds());
TrackerSettings settings; TrackerSettings settings;
if (settings.SingleWindowBrowse() if (settings.SingleWindowBrowse() && settings.ShowNavigator()
&& settings.ShowNavigator() && model->IsDirectory()) {
&& model->IsDirectory())
rect.top += BNavigator::CalcNavigatorHeight() + 1; rect.top += BNavigator::CalcNavigatorHeight() + 1;
}
rect.right -= B_V_SCROLL_BAR_WIDTH; rect.right -= B_V_SCROLL_BAR_WIDTH;
rect.bottom -= B_H_SCROLL_BAR_HEIGHT; rect.bottom -= B_H_SCROLL_BAR_HEIGHT;
fPoseView = NewPoseView(model, rect, kListMode); fPoseView = NewPoseView(model, rect, kListMode);
AddChild(fPoseView); AddChild(fPoseView);
if (settings.SingleWindowBrowse() if (settings.SingleWindowBrowse() && model->IsDirectory()
&& model->IsDirectory()
&& !fPoseView->IsFilePanel()) { && !fPoseView->IsFilePanel()) {
BRect rect(Bounds()); BRect rect(Bounds());
rect.top = 0; rect.top = 0;
@@ -760,8 +771,10 @@ BContainerWindow::CreatePoseView(Model* model)
fNavigator = new BNavigator(model, rect); fNavigator = new BNavigator(model, rect);
if (!settings.ShowNavigator()) if (!settings.ShowNavigator())
fNavigator->Hide(); fNavigator->Hide();
AddChild(fNavigator); AddChild(fNavigator);
} }
SetPathWatchingEnabled(settings.ShowNavigator() SetPathWatchingEnabled(settings.ShowNavigator()
|| settings.ShowFullPathInTitleBar()); || settings.ShowFullPathInTitleBar());
} }
@@ -996,9 +1009,10 @@ BContainerWindow::Init(const BMessage* message)
MarkAttributeMenu(fAttrMenu); MarkAttributeMenu(fAttrMenu);
CheckScreenIntersect(); CheckScreenIntersect();
if (fBackgroundImage && !dynamic_cast<BDeskWindow*>(this) if (fBackgroundImage != NULL && dynamic_cast<BDeskWindow*>(this) == NULL
&& PoseView()->ViewMode() != kListMode) && PoseView()->ViewMode() != kListMode) {
fBackgroundImage->Show(PoseView(), current_workspace()); fBackgroundImage->Show(PoseView(), current_workspace());
}
Show(); Show();
@@ -1048,8 +1062,8 @@ BContainerWindow::RestoreStateCommon()
WindowStateNodeOpener opener(this, false); WindowStateNodeOpener opener(this, false);
bool isDesktop = dynamic_cast<BDeskWindow*>(this); bool isDesktop = dynamic_cast<BDeskWindow*>(this) != NULL;
if (!TargetModel()->IsRoot() && opener.Node()) if (!TargetModel()->IsRoot() && opener.Node()) {
// don't pick up background image for root disks // don't pick up background image for root disks
// to do this, would have to have a unique attribute for the // to do this, would have to have a unique attribute for the
// disks window that doesn't collide with the desktop // disks window that doesn't collide with the desktop
@@ -1058,13 +1072,15 @@ BContainerWindow::RestoreStateCommon()
fBackgroundImage = BackgroundImage::GetBackgroundImage( fBackgroundImage = BackgroundImage::GetBackgroundImage(
opener.Node(), isDesktop); opener.Node(), isDesktop);
// look for background image info in the window's node // look for background image info in the window's node
}
BNode defaultingNode; BNode defaultingNode;
if (!fBackgroundImage && !isDesktop if (fBackgroundImage == NULL && !isDesktop
&& DefaultStateSourceNode(kDefaultFolderTemplate, &defaultingNode)) && DefaultStateSourceNode(kDefaultFolderTemplate, &defaultingNode)) {
// look for background image info in the source for defaults // look for background image info in the source for defaults
fBackgroundImage fBackgroundImage = BackgroundImage::GetBackgroundImage(&defaultingNode,
= BackgroundImage::GetBackgroundImage(&defaultingNode, isDesktop); isDesktop);
}
} }
@@ -1077,13 +1093,15 @@ BContainerWindow::UpdateTitle()
BPath path; BPath path;
TargetModel()->GetPath(&path); TargetModel()->GetPath(&path);
SetTitle(path.Path()); SetTitle(path.Path());
} else } else {
// use the default look // use the default look
SetTitle(TargetModel()->Name()); SetTitle(TargetModel()->Name());
}
if (Navigator()) if (Navigator() != NULL) {
Navigator()->UpdateLocation(PoseView()->TargetModel(), Navigator()->UpdateLocation(PoseView()->TargetModel(),
kActionUpdatePath); kActionUpdatePath);
}
} }
@@ -1096,24 +1114,26 @@ BContainerWindow::UpdateBackgroundImage()
bool isDesktop = dynamic_cast<BDeskWindow*>(this) != NULL; bool isDesktop = dynamic_cast<BDeskWindow*>(this) != NULL;
WindowStateNodeOpener opener(this, false); WindowStateNodeOpener opener(this, false);
if (!TargetModel()->IsRoot() && opener.Node()) if (!TargetModel()->IsRoot() && opener.Node()) {
fBackgroundImage = BackgroundImage::Refresh(fBackgroundImage, fBackgroundImage = BackgroundImage::Refresh(fBackgroundImage,
opener.Node(), isDesktop, PoseView()); opener.Node(), isDesktop, PoseView());
}
// look for background image info in the window's node // look for background image info in the window's node
BNode defaultingNode; BNode defaultingNode;
if (!fBackgroundImage && !isDesktop if (!fBackgroundImage && !isDesktop
&& DefaultStateSourceNode(kDefaultFolderTemplate, &defaultingNode)) && DefaultStateSourceNode(kDefaultFolderTemplate, &defaultingNode)) {
// look for background image info in the source for defaults // look for background image info in the source for defaults
fBackgroundImage = BackgroundImage::Refresh(fBackgroundImage, fBackgroundImage = BackgroundImage::Refresh(fBackgroundImage,
&defaultingNode, isDesktop, PoseView()); &defaultingNode, isDesktop, PoseView());
}
} }
void void
BContainerWindow::FrameResized(float, float) BContainerWindow::FrameResized(float, float)
{ {
if (PoseView() && dynamic_cast<BDeskWindow*>(this) == NULL) { if (PoseView() != NULL && dynamic_cast<BDeskWindow*>(this) == NULL) {
BRect extent = PoseView()->Extent(); BRect extent = PoseView()->Extent();
float offsetX = extent.left - PoseView()->Bounds().left; float offsetX = extent.left - PoseView()->Bounds().left;
float offsetY = extent.top - PoseView()->Bounds().top; float offsetY = extent.top - PoseView()->Bounds().top;
@@ -1170,7 +1190,7 @@ BContainerWindow::ViewModeChanged(uint32 oldMode, uint32 newMode)
view->FrameMoved(view->Frame().LeftTop()); view->FrameMoved(view->Frame().LeftTop());
} }
if (!fBackgroundImage) if (fBackgroundImage == NULL)
return; return;
if (newMode == kListMode) if (newMode == kListMode)
@@ -1205,8 +1225,10 @@ BContainerWindow::SaveState(bool hide)
WindowStateNodeOpener opener(this, true); WindowStateNodeOpener opener(this, true);
if (opener.StreamNode()) if (opener.StreamNode())
SaveWindowState(opener.StreamNode()); SaveWindowState(opener.StreamNode());
if (hide) if (hide)
Hide(); Hide();
if (opener.StreamNode()) if (opener.StreamNode())
fPoseView->SaveState(opener.StreamNode()); fPoseView->SaveState(opener.StreamNode());
@@ -1216,7 +1238,7 @@ BContainerWindow::SaveState(bool hide)
void void
BContainerWindow::SaveState(BMessage &message) const BContainerWindow::SaveState(BMessage& message) const
{ {
if (SaveStateIsEnabled()) { if (SaveStateIsEnabled()) {
SaveWindowState(message); SaveWindowState(message);
@@ -1235,8 +1257,7 @@ BContainerWindow::StateNeedsSaving() const
status_t status_t
BContainerWindow::GetLayoutState(BNode* node, BMessage* message) BContainerWindow::GetLayoutState(BNode* node, BMessage* message)
{ {
// ToDo: // ToDo: get rid of this, use AttrStream instead
// get rid of this, use AttrStream instead
status_t result = node->InitCheck(); status_t result = node->InitCheck();
if (result != B_OK) if (result != B_OK)
return result; return result;
@@ -1254,16 +1275,18 @@ BContainerWindow::GetLayoutState(BNode* node, BMessage* message)
&& strcmp(attrName, kAttrColumns) != 0 && strcmp(attrName, kAttrColumns) != 0
&& strcmp(attrName, kAttrViewState) != 0 && strcmp(attrName, kAttrViewState) != 0
&& strcmp(attrName, kAttrColumnsForeign) != 0 && strcmp(attrName, kAttrColumnsForeign) != 0
&& strcmp(attrName, kAttrViewStateForeign) != 0) && strcmp(attrName, kAttrViewStateForeign) != 0) {
continue; continue;
}
char* buffer = new char[info.size]; char* buffer = new char[info.size];
if (node->ReadAttr(attrName, info.type, 0, buffer, if (node->ReadAttr(attrName, info.type, 0, buffer,
(size_t)info.size) == info.size) { (size_t)info.size) == info.size) {
message->AddData(attrName, info.type, buffer, (ssize_t)info.size); message->AddData(attrName, info.type, buffer, (ssize_t)info.size);
} }
delete [] buffer; delete[] buffer;
} }
return B_OK; return B_OK;
} }
@@ -1305,6 +1328,7 @@ BContainerWindow::SetLayoutState(BNode* node, const BMessage* message)
globalIndex++; globalIndex++;
} }
} }
return B_OK; return B_OK;
} }
@@ -1350,9 +1374,8 @@ BContainerWindow::Zoom(BPoint, float, float)
fSavedZoomRect = Frame(); fSavedZoomRect = Frame();
ResizeToFit(); ResizeToFit();
if (fSavedZoomRect == Frame()) if (fSavedZoomRect == Frame() && oldZoomRect.IsValid())
if (oldZoomRect.IsValid()) ResizeTo(oldZoomRect.Width(), oldZoomRect.Height());
ResizeTo(oldZoomRect.Width(), oldZoomRect.Height());
} }
@@ -1454,9 +1477,9 @@ BContainerWindow::MessageReceived(BMessage* message)
PoseView()->DuplicateSelection(); PoseView()->DuplicateSelection();
else else
PoseView()->MoveSelectionInto(&model, this, true); PoseView()->MoveSelectionInto(&model, this, true);
break; break;
} }
case kMoveSelectionTo: case kMoveSelectionTo:
{ {
entry_ref ref; entry_ref ref;
@@ -1748,8 +1771,9 @@ BContainerWindow::SetCopyItem(BMenu* menu)
{ {
BMenuItem* item; BMenuItem* item;
if ((item = menu->FindItem(B_COPY)) == NULL if ((item = menu->FindItem(B_COPY)) == NULL
&& (item = menu->FindItem(kCopyMoreSelectionToClipboard)) == NULL) && (item = menu->FindItem(kCopyMoreSelectionToClipboard)) == NULL) {
return; return;
}
item->SetEnabled(PoseView()->SelectionList()->CountItems() > 0 item->SetEnabled(PoseView()->SelectionList()->CountItems() > 0
|| PoseView() != CurrentFocus()); || PoseView() != CurrentFocus());
@@ -1771,8 +1795,9 @@ BContainerWindow::SetPasteItem(BMenu* menu)
{ {
BMenuItem* item; BMenuItem* item;
if ((item = menu->FindItem(B_PASTE)) == NULL if ((item = menu->FindItem(B_PASTE)) == NULL
&& (item = menu->FindItem(kPasteLinksFromClipboard)) == NULL) && (item = menu->FindItem(kPasteLinksFromClipboard)) == NULL) {
return; return;
}
item->SetEnabled(FSClipboardHasRefs() || PoseView() != CurrentFocus()); item->SetEnabled(FSClipboardHasRefs() || PoseView() != CurrentFocus());
@@ -1793,8 +1818,9 @@ BContainerWindow::SetArrangeMenu(BMenu* menu)
{ {
BMenuItem* item; BMenuItem* item;
if ((item = menu->FindItem(kCleanup)) == NULL if ((item = menu->FindItem(kCleanup)) == NULL
&& (item = menu->FindItem(kCleanupAll)) == NULL) && (item = menu->FindItem(kCleanupAll)) == NULL) {
return; return;
}
item->Menu()->SetEnabled(PoseView()->CountItems() > 0 item->Menu()->SetEnabled(PoseView()->CountItems() > 0
&& (PoseView()->ViewMode() != kListMode)); && (PoseView()->ViewMode() != kListMode));
@@ -1812,6 +1838,7 @@ BContainerWindow::SetArrangeMenu(BMenu* menu)
item->SetMessage(new BMessage(kCleanup)); item->SetMessage(new BMessage(kCleanup));
arrangeMenu = item->Menu(); arrangeMenu = item->Menu();
} }
MarkArrangeByMenu(arrangeMenu); MarkArrangeByMenu(arrangeMenu);
} }
@@ -1821,8 +1848,9 @@ BContainerWindow::SetCloseItem(BMenu* menu)
{ {
BMenuItem* item; BMenuItem* item;
if ((item = menu->FindItem(B_QUIT_REQUESTED)) == NULL if ((item = menu->FindItem(B_QUIT_REQUESTED)) == NULL
&& (item = menu->FindItem(kCloseAllWindows)) == NULL) && (item = menu->FindItem(kCloseAllWindows)) == NULL) {
return; return;
}
if (modifiers() & B_SHIFT_KEY) { if (modifiers() & B_SHIFT_KEY) {
item->SetLabel(B_TRANSLATE("Close all")); item->SetLabel(B_TRANSLATE("Close all"));
@@ -1950,8 +1978,10 @@ BContainerWindow::AddFileMenu(BMenu* menu)
menu->SetTargetForItems(PoseView()); menu->SetTargetForItems(PoseView());
if (cutItem) if (cutItem)
cutItem->SetTarget(this); cutItem->SetTarget(this);
if (copyItem) if (copyItem)
copyItem->SetTarget(this); copyItem->SetTarget(this);
if (pasteItem) if (pasteItem)
pasteItem->SetTarget(this); pasteItem->SetTarget(this);
} }
@@ -2142,13 +2172,14 @@ BContainerWindow::AddShortcuts()
void void
BContainerWindow::MenusBeginning() BContainerWindow::MenusBeginning()
{ {
if (!fMenuBar) if (fMenuBar == NULL)
return; return;
if (CurrentMessage() && CurrentMessage()->what == B_MOUSE_DOWN) if (CurrentMessage() != NULL && CurrentMessage()->what == B_MOUSE_DOWN) {
// don't commit active pose if only a keyboard shortcut is // don't commit active pose if only a keyboard shortcut is
// invoked - this would prevent Cut/Copy/Paste from working // invoked - this would prevent Cut/Copy/Paste from working
fPoseView->CommitActivePose(); fPoseView->CommitActivePose();
}
// File menu // File menu
int32 selectCount = PoseView()->SelectionList()->CountItems(); int32 selectCount = PoseView()->SelectionList()->CountItems();
@@ -2185,9 +2216,9 @@ void
BContainerWindow::SetupNavigationMenu(const entry_ref* ref, BMenu* parent) BContainerWindow::SetupNavigationMenu(const entry_ref* ref, BMenu* parent)
{ {
// start by removing nav item (and separator) from old menu // start by removing nav item (and separator) from old menu
if (fNavigationItem) { if (fNavigationItem != NULL) {
BMenu* menu = fNavigationItem->Menu(); BMenu* menu = fNavigationItem->Menu();
if (menu) { if (menu != NULL) {
menu->RemoveItem(fNavigationItem); menu->RemoveItem(fNavigationItem);
BMenuItem* item = menu->RemoveItem((int32)0); BMenuItem* item = menu->RemoveItem((int32)0);
ASSERT(item != fNavigationItem); ASSERT(item != fNavigationItem);
@@ -2196,7 +2227,7 @@ BContainerWindow::SetupNavigationMenu(const entry_ref* ref, BMenu* parent)
} }
// if we weren't passed a ref then we're navigating this window // if we weren't passed a ref then we're navigating this window
if (!ref) if (ref == NULL)
ref = TargetModel()->EntryRef(); ref = TargetModel()->EntryRef();
BEntry entry; BEntry entry;
@@ -2208,8 +2239,9 @@ BContainerWindow::SetupNavigationMenu(const entry_ref* ref, BMenu* parent)
entry_ref resolvedRef; entry_ref resolvedRef;
if (model.InitCheck() != B_OK if (model.InitCheck() != B_OK
|| (!model.IsContainer() && !model.IsSymLink())) || (!model.IsContainer() && !model.IsSymLink())) {
return; return;
}
if (model.IsSymLink()) { if (model.IsSymLink()) {
if (entry.SetTo(model.EntryRef(), true) != B_OK) if (entry.SetTo(model.EntryRef(), true) != B_OK)
@@ -2223,7 +2255,7 @@ BContainerWindow::SetupNavigationMenu(const entry_ref* ref, BMenu* parent)
ref = &resolvedRef; ref = &resolvedRef;
} }
if (!fNavigationItem) { if (fNavigationItem == NULL) {
fNavigationItem = new ModelMenuItem(&model, fNavigationItem = new ModelMenuItem(&model,
new BNavMenu(model.Name(), B_REFS_RECEIVED, be_app, this)); new BNavMenu(model.Name(), B_REFS_RECEIVED, be_app, this));
} }
@@ -2278,11 +2310,9 @@ BContainerWindow::SetUpEditQueryItem(BMenu* menu)
// if the view is a query pose view, add edit query menu item // if the view is a query pose view, add edit query menu item
BMenuItem* item = menu->FindItem(kEditQuery); BMenuItem* item = menu->FindItem(kEditQuery);
if (!poseViewIsQuery && !queryInSelection && item) if (!poseViewIsQuery && !queryInSelection && item != NULL)
item->Menu()->RemoveItem(item); item->Menu()->RemoveItem(item);
else if ((poseViewIsQuery || queryInSelection) && item == NULL) {
else if ((poseViewIsQuery || queryInSelection) && !item) {
// add edit query item after Open // add edit query item after Open
item = menu->FindItem(kOpenSelection); item = menu->FindItem(kOpenSelection);
if (item) { if (item) {
@@ -2302,20 +2332,22 @@ BContainerWindow::SetupOpenWithMenu(BMenu* parent)
// start by removing nav item (and separator) from old menu // start by removing nav item (and separator) from old menu
if (fOpenWithItem) { if (fOpenWithItem) {
BMenu* menu = fOpenWithItem->Menu(); BMenu* menu = fOpenWithItem->Menu();
if (menu) if (menu != NULL)
menu->RemoveItem(fOpenWithItem); menu->RemoveItem(fOpenWithItem);
delete fOpenWithItem; delete fOpenWithItem;
fOpenWithItem = 0; fOpenWithItem = 0;
} }
if (PoseView()->SelectionList()->CountItems() == 0) if (PoseView()->SelectionList()->CountItems() == 0) {
// no selection, nothing to open // no selection, nothing to open
return; return;
}
if (TargetModel()->IsRoot()) if (TargetModel()->IsRoot()) {
// don't add ourselves if we are root // don't add ourselves if we are root
return; return;
}
// ToDo: // ToDo:
// check if only item in selection list is the root // check if only item in selection list is the root
@@ -2325,7 +2357,7 @@ BContainerWindow::SetupOpenWithMenu(BMenu* parent)
BMenuItem* item = parent->FindItem(kOpenSelection); BMenuItem* item = parent->FindItem(kOpenSelection);
int32 count = PoseView()->SelectionList()->CountItems(); int32 count = PoseView()->SelectionList()->CountItems();
if (!count) if (count == 0)
return; return;
// build a list of all refs to open // build a list of all refs to open
@@ -2443,9 +2475,10 @@ BContainerWindow::PopulateMoveCopyNavMenu(BNavMenu* navMenu, uint32 what,
// add root dir // add root dir
if (volume.GetRootDirectory(&directory) == B_OK if (volume.GetRootDirectory(&directory) == B_OK
&& directory.GetEntry(&entry) == B_OK && directory.GetEntry(&entry) == B_OK
&& model.SetTo(&entry) == B_OK) && model.SetTo(&entry) == B_OK) {
navMenu->AddNavDir(&model, what, this, true); navMenu->AddNavDir(&model, what, this, true);
// ask NavMenu to populate submenu for us // ask NavMenu to populate submenu for us
}
} }
} }
} }
@@ -2634,7 +2667,8 @@ BContainerWindow::ShowContextMenu(BPoint loc, const entry_ref* ref, BView*)
// reset in DetachedFromWindow // reset in DetachedFromWindow
// see the notes in SlowContextPopup::AttachedToWindow // see the notes in SlowContextPopup::AttachedToWindow
if (!FSIsPrintersDir(&entry) && !fDragContextMenu->IsShowing()) { if (!FSIsPrintersDir(&entry)
&& !fDragContextMenu->IsShowing()) {
//printf("ShowContextMenu - target is %s %i\n", //printf("ShowContextMenu - target is %s %i\n",
// ref->name, IsShowing(ref)); // ref->name, IsShowing(ref));
fDragContextMenu->ClearMenu(); fDragContextMenu->ClearMenu();
@@ -2653,17 +2687,18 @@ BContainerWindow::ShowContextMenu(BPoint loc, const entry_ref* ref, BView*)
fDragContextMenu->SetTypesList(fCachedTypesList); fDragContextMenu->SetTypesList(fCachedTypesList);
fDragContextMenu->SetTarget(BMessenger(this)); fDragContextMenu->SetTarget(BMessenger(this));
BPoseView* poseView = PoseView(); BPoseView* poseView = PoseView();
if (poseView) { if (poseView != NULL) {
BMessenger target(poseView); BMessenger target(poseView);
fDragContextMenu->InitTrackingHook( fDragContextMenu->InitTrackingHook(
&BPoseView::MenuTrackingHook, &target, &BPoseView::MenuTrackingHook, &target,
fDragMessage); fDragMessage);
} }
// this is now asynchronous so that we don't // this is now asynchronous so that we don't
// deadlock in Window::Quit, // deadlock in Window::Quit,
fDragContextMenu->Go(global, true, false, true); fDragContextMenu->Go(global, true, false, true);
} }
return; return;
} else if (TargetModel()->IsRoot() || model.IsVolume()) { } else if (TargetModel()->IsRoot() || model.IsVolume()) {
fContextMenu = fVolumeContextMenu; fContextMenu = fVolumeContextMenu;
@@ -2673,7 +2708,7 @@ BContainerWindow::ShowContextMenu(BPoint loc, const entry_ref* ref, BView*)
// clean up items from last context menu // clean up items from last context menu
if (fContextMenu) { if (fContextMenu != NULL) {
if (fContextMenu->Window()) if (fContextMenu->Window())
return; return;
else else
@@ -2714,7 +2749,7 @@ BContainerWindow::ShowContextMenu(BPoint loc, const entry_ref* ref, BView*)
fContextMenu->Go(global, true, true, true); fContextMenu->Go(global, true, true, true);
} }
} }
} else if (fWindowContextMenu) { } else if (fWindowContextMenu != NULL) {
if (fWindowContextMenu->Window()) if (fWindowContextMenu->Window())
return; return;
@@ -2731,6 +2766,7 @@ BContainerWindow::ShowContextMenu(BPoint loc, const entry_ref* ref, BView*)
fWindowContextMenu->Go(global, true, true, true); fWindowContextMenu->Go(global, true, true, true);
} }
fContextMenu = NULL; fContextMenu = NULL;
} }
@@ -2740,8 +2776,8 @@ BContainerWindow::AddFileContextMenus(BMenu* menu)
{ {
menu->AddItem(new BMenuItem(B_TRANSLATE("Open"), menu->AddItem(new BMenuItem(B_TRANSLATE("Open"),
new BMessage(kOpenSelection), 'O')); new BMessage(kOpenSelection), 'O'));
menu->AddItem(new BMenuItem(B_TRANSLATE("Get info"), new BMessage(kGetInfo), menu->AddItem(new BMenuItem(B_TRANSLATE("Get info"),
'I')); new BMessage(kGetInfo), 'I'));
menu->AddItem(new BMenuItem(B_TRANSLATE("Edit name"), menu->AddItem(new BMenuItem(B_TRANSLATE("Edit name"),
new BMessage(kEditItem), 'E')); new BMessage(kEditItem), 'E'));
@@ -3118,7 +3154,6 @@ BContainerWindow::UpdateMenu(BMenu* menu, UpdateMenuContext context)
SetArrangeMenu(menu); SetArrangeMenu(menu);
SetPasteItem(menu); SetPasteItem(menu);
BEntry entry(TargetModel()->EntryRef()); BEntry entry(TargetModel()->EntryRef());
BDirectory parent; BDirectory parent;
entry_ref ref; entry_ref ref;
@@ -3761,9 +3796,10 @@ BContainerWindow::SetUpDefaultState()
void void
BContainerWindow::RestoreWindowState(AttributeStreamNode* node) BContainerWindow::RestoreWindowState(AttributeStreamNode* node)
{ {
if (!node || dynamic_cast<BDeskWindow*>(this)) if (node == NULL || dynamic_cast<BDeskWindow*>(this)) {
// don't restore any window state if we are a desktop window // don't restore any window state if we are a desktop window
return; return;
}
const char* rectAttributeName; const char* rectAttributeName;
const char* workspaceAttributeName; const char* workspaceAttributeName;
@@ -3814,9 +3850,10 @@ BContainerWindow::RestoreWindowState(AttributeStreamNode* node)
void void
BContainerWindow::RestoreWindowState(const BMessage &message) BContainerWindow::RestoreWindowState(const BMessage &message)
{ {
if (dynamic_cast<BDeskWindow*>(this)) if (dynamic_cast<BDeskWindow*>(this)) {
// don't restore any window state if we are a desktop window // don't restore any window state if we are a desktop window
return; return;
}
const char* rectAttributeName; const char* rectAttributeName;
const char* workspaceAttributeName; const char* workspaceAttributeName;
+10 -4
View File
@@ -245,10 +245,12 @@ BDeskWindow::Init(const BMessage*)
BPath path; BPath path;
if (!BootedInSafeMode() && FSFindTrackerSettingsDir(&path) == B_OK) { if (!BootedInSafeMode() && FSFindTrackerSettingsDir(&path) == B_OK) {
path.Append(kShelfPath); path.Append(kShelfPath);
close(open(path.Path(), O_RDONLY | O_CREAT, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH)); close(open(path.Path(), O_RDONLY | O_CREAT, S_IRUSR | S_IWUSR
| S_IRGRP | S_IROTH));
if (get_ref_for_path(path.Path(), &ref) == B_OK) if (get_ref_for_path(path.Path(), &ref) == B_OK)
fDeskShelf = new BShelf(&ref, fPoseView); fDeskShelf = new BShelf(&ref, fPoseView);
if (fDeskShelf)
if (fDeskShelf != NULL)
fDeskShelf->SetDisplaysZombies(true); fDeskShelf->SetDisplaysZombies(true);
} }
InitKeyIndices(); InitKeyIndices();
@@ -288,7 +290,8 @@ BDeskWindow::ApplyShortcutPreferences(bool update)
if (!update) { if (!update) {
BPath path; BPath path;
if (find_directory(B_USER_SETTINGS_DIRECTORY, &path) == B_OK) { if (find_directory(B_USER_SETTINGS_DIRECTORY, &path) == B_OK) {
BPathMonitor::StartWatching(path.Path(), B_WATCH_STAT | B_WATCH_FILES_ONLY, this); BPathMonitor::StartWatching(path.Path(),
B_WATCH_STAT | B_WATCH_FILES_ONLY, this);
path.Append(kShortcutsSettings); path.Append(kShortcutsSettings);
fShortcutsSettings = new char[strlen(path.Path()) + 1]; fShortcutsSettings = new char[strlen(path.Path()) + 1];
strcpy(fShortcutsSettings, path.Path()); strcpy(fShortcutsSettings, path.Path());
@@ -316,6 +319,7 @@ BDeskWindow::ApplyShortcutPreferences(bool update)
BString command; BString command;
if (message.FindString("command", &command) != B_OK) if (message.FindString("command", &command) != B_OK)
continue; continue;
BPath path; BPath path;
bool isInAddons = false; bool isInAddons = false;
if (find_directory(B_SYSTEM_ADDONS_DIRECTORY, &path) if (find_directory(B_SYSTEM_ADDONS_DIRECTORY, &path)
@@ -353,7 +357,8 @@ BDeskWindow::ApplyShortcutPreferences(bool update)
continue; continue;
uint32 modifiers = B_COMMAND_KEY; uint32 modifiers = B_COMMAND_KEY;
// it's required by interface kit to at least have B_COMMAND_KEY // it's required by interface kit to at least
// have B_COMMAND_KEY
int32 value; int32 value;
if (message.FindInt32("mcidx", 0, &value) == B_OK) if (message.FindInt32("mcidx", 0, &value) == B_OK)
modifiers |= (value != 0 ? B_SHIFT_KEY : 0); modifiers |= (value != 0 ? B_SHIFT_KEY : 0);
@@ -370,6 +375,7 @@ BDeskWindow::ApplyShortcutPreferences(bool update)
if (item != NULL) { if (item != NULL) {
if (item->key != '\0') if (item->key != '\0')
RemoveShortcut(item->key, item->modifiers); RemoveShortcut(item->key, item->modifiers);
item->key = shortcut[0]; item->key = shortcut[0];
item->modifiers = modifiers; item->modifiers = modifiers;
AddOneShortcut(&model, item->key, item->modifiers, this); AddOneShortcut(&model, item->key, item->modifiers, this);
+2 -2
View File
@@ -269,8 +269,8 @@ BDirMenu::AddDisksIconToMenu(bool atEnd)
BMessage* message = new BMessage(fCommand); BMessage* message = new BMessage(fCommand);
message->AddRef(fEntryName.String(), model.EntryRef()); message->AddRef(fEntryName.String(), model.EntryRef());
ModelMenuItem* item = new ModelMenuItem(&model, B_TRANSLATE("Disks"), ModelMenuItem* item = new ModelMenuItem(&model,
message); B_TRANSLATE(B_DISKS_DIR_NAME), message);
if (atEnd) if (atEnd)
AddItem(item); AddItem(item);
else else
+2 -2
View File
@@ -150,10 +150,10 @@ CachedEntryIterator::CachedEntryIterator(BEntryList* iterator,
CachedEntryIterator::~CachedEntryIterator() CachedEntryIterator::~CachedEntryIterator()
{ {
delete [] fEntryRefBuffer; delete[] fEntryRefBuffer;
free(fDirentBuffer); free(fDirentBuffer);
delete fSortedList; delete fSortedList;
delete [] fEntryBuffer; delete[] fEntryBuffer;
} }
+32 -16
View File
@@ -106,6 +106,7 @@ enum ConflictCheckResult {
kNoConflicts kNoConflicts
}; };
namespace BPrivate { namespace BPrivate {
#undef B_TRANSLATION_CONTEXT #undef B_TRANSLATION_CONTEXT
@@ -195,6 +196,7 @@ static const char* kFindApplicationStr =
B_TRANSLATE_MARK("Would you like to find a suitable application " B_TRANSLATE_MARK("Would you like to find a suitable application "
"to open the file?"); "to open the file?");
// Skip these attributes when copying in Tracker // Skip these attributes when copying in Tracker
const char* kSkipAttributes[] = { const char* kSkipAttributes[] = {
kAttrPoseInfo, kAttrPoseInfo,
@@ -202,7 +204,7 @@ const char* kSkipAttributes[] = {
}; };
// #pragma mark - // #pragma mark - CopyLoopControl
CopyLoopControl::~CopyLoopControl() CopyLoopControl::~CopyLoopControl()
@@ -289,7 +291,7 @@ CopyLoopControl::PreserveAttribute(const char*)
} }
// #pragma mark - // #pragma mark - TrackerCopyLoopControl
TrackerCopyLoopControl::TrackerCopyLoopControl() TrackerCopyLoopControl::TrackerCopyLoopControl()
@@ -415,7 +417,7 @@ TrackerCopyLoopControl::SetSourceList(EntryList* list)
} }
// #pragma mark - // #pragma mark - the rest
static BNode* static BNode*
@@ -1061,7 +1063,7 @@ MoveTask(BObjectList<entry_ref>* srcList, BEntry* destEntry, BList* pointList,
delete destEntry; delete destEntry;
// delete file location list and all Points within // delete file location list and all Points within
if (pointList) { if (pointList != NULL) {
pointList->DoForEach(delete_point); pointList->DoForEach(delete_point);
delete pointList; delete pointList;
} }
@@ -1069,6 +1071,7 @@ MoveTask(BObjectList<entry_ref>* srcList, BEntry* destEntry, BList* pointList,
return B_OK; return B_OK;
} }
class FailWithAlert { class FailWithAlert {
public: public:
static void FailOnError(status_t error, const char* string, static void FailOnError(status_t error, const char* string,
@@ -1079,9 +1082,10 @@ class FailWithAlert {
} }
FailWithAlert(status_t error, const char* string, const char* name) FailWithAlert(status_t error, const char* string, const char* name)
: fString(string), :
fName(name), fString(string),
fError(error) fName(name),
fError(error)
{ {
} }
@@ -1100,7 +1104,8 @@ class MoveError {
MoveError(status_t error) MoveError(status_t error)
: fError(error) : fError(error)
{ } {
}
status_t fError; status_t fError;
}; };
@@ -1339,7 +1344,7 @@ LowLevelCopy(BEntry* srcEntry, StatStruct* srcStat, BDirectory* destDir,
CopyAttributes(loopControl, &srcFile, &destFile, buffer, bufsize); CopyAttributes(loopControl, &srcFile, &destFile, buffer, bufsize);
} catch (...) { } catch (...) {
delete [] buffer; delete[] buffer;
throw; throw;
} }
@@ -1349,7 +1354,7 @@ LowLevelCopy(BEntry* srcEntry, StatStruct* srcStat, BDirectory* destDir,
destFile.SetModificationTime(srcStat->st_mtime); destFile.SetModificationTime(srcStat->st_mtime);
destFile.SetCreationTime(srcStat->st_crtime); destFile.SetCreationTime(srcStat->st_crtime);
delete [] buffer; delete[] buffer;
if (!loopControl->ChecksumFile(&ref)) { if (!loopControl->ChecksumFile(&ref)) {
// File no good. Remove and quit. // File no good. Remove and quit.
@@ -3443,9 +3448,10 @@ _TrackerLaunchDocuments(const entry_ref* /*doNotUse*/, const BMessage* refs,
BMessage copyOfRefs(*refs); BMessage copyOfRefs(*refs);
entry_ref documentRef; entry_ref documentRef;
if (copyOfRefs.FindRef("refs", &documentRef) != B_OK) if (copyOfRefs.FindRef("refs", &documentRef) != B_OK) {
// nothing to launch, we are done // nothing to launch, we are done
return; return;
}
status_t error = B_ERROR; status_t error = B_ERROR;
entry_ref app; entry_ref app;
@@ -3732,23 +3738,25 @@ status_t
FSLaunchUsing(const entry_ref* ref, BMessage* listOfRefs) FSLaunchUsing(const entry_ref* ref, BMessage* listOfRefs)
{ {
BMessage temp(B_REFS_RECEIVED); BMessage temp(B_REFS_RECEIVED);
if (!listOfRefs) { if (listOfRefs == NULL) {
ASSERT(ref); ASSERT(ref);
temp.AddRef("refs", ref); temp.AddRef("refs", ref);
listOfRefs = &temp; listOfRefs = &temp;
} }
FSOpenWith(listOfRefs); FSOpenWith(listOfRefs);
return B_OK; return B_OK;
} }
status_t status_t
FSLaunchItem(const entry_ref* ref, BMessage* message, int32, bool async) FSLaunchItem(const entry_ref* ref, BMessage* message, int32, bool async)
{ {
if (message) if (message != NULL)
message->what = B_REFS_RECEIVED; message->what = B_REFS_RECEIVED;
status_t result = TrackerLaunch(ref, message, async, true); status_t result = TrackerLaunch(ref, message, async, true);
delete message; delete message;
return result; return result;
} }
@@ -3759,6 +3767,7 @@ FSLaunchItem(const entry_ref* ref, BMessage* message, int32 workspace)
FSLaunchItem(ref, message, workspace, true); FSLaunchItem(ref, message, workspace, true);
} }
// Get the original path of an entry in the trash // Get the original path of an entry in the trash
status_t status_t
FSGetOriginalPath(BEntry* entry, BPath* result) FSGetOriginalPath(BEntry* entry, BPath* result)
@@ -3816,42 +3825,49 @@ FSGetOriginalPath(BEntry* entry, BPath* result)
err = parent.GetPath(&pathParent); err = parent.GetPath(&pathParent);
if (err != B_OK) if (err != B_OK)
return err; return err;
err = entry->GetPath(&path); err = entry->GetPath(&path);
if (err != B_OK) if (err != B_OK)
return err; return err;
result->Append(path.Path() + strlen(pathParent.Path()) + 1); result->Append(path.Path() + strlen(pathParent.Path()) + 1);
// compute the new path by appending the offset of // compute the new path by appending the offset of
// the item we are locating, to the original path // the item we are locating, to the original path
// of the parent // of the parent
return B_OK; return B_OK;
} }
directory_which directory_which
WellKnowEntryList::Match(const node_ref* node) WellKnowEntryList::Match(const node_ref* node)
{ {
const WellKnownEntry* result = MatchEntry(node); const WellKnownEntry* result = MatchEntry(node);
if (result) if (result != NULL)
return result->which; return result->which;
return (directory_which)-1; return (directory_which)-1;
} }
const WellKnowEntryList::WellKnownEntry* const WellKnowEntryList::WellKnownEntry*
WellKnowEntryList::MatchEntry(const node_ref* node) WellKnowEntryList::MatchEntry(const node_ref* node)
{ {
if (!self) if (self == NULL)
self = new WellKnowEntryList(); self = new WellKnowEntryList();
return self->MatchEntryCommon(node); return self->MatchEntryCommon(node);
} }
const WellKnowEntryList::WellKnownEntry* const WellKnowEntryList::WellKnownEntry*
WellKnowEntryList::MatchEntryCommon(const node_ref* node) WellKnowEntryList::MatchEntryCommon(const node_ref* node)
{ {
uint32 count = entries.size(); uint32 count = entries.size();
for (uint32 index = 0; index < count; index++) for (uint32 index = 0; index < count; index++) {
if (*node == entries[index].node) if (*node == entries[index].node)
return &entries[index]; return &entries[index];
}
return NULL; return NULL;
} }
+2
View File
@@ -159,6 +159,8 @@ private:
#define B_DESKTOP_DIR_NAME "Desktop" #define B_DESKTOP_DIR_NAME "Desktop"
#define B_DISKS_DIR_NAME "Disks"
#define B_TRASH_DIR_NAME "Trash"
#ifndef _IMPEXP_TRACKER #ifndef _IMPEXP_TRACKER
#define _IMPEXP_TRACKER #define _IMPEXP_TRACKER
+1 -1
View File
@@ -2329,7 +2329,7 @@ FindPanel::RestoreWindowState(const BNode* node)
} }
} }
} }
delete [] buffer; delete[] buffer;
} }
// mark or unmark "All disks" // mark or unmark "All disks"
fVolMenu->ItemAt(0)->SetMarked(searchAllVolumes); fVolMenu->ItemAt(0)->SetMarked(searchAllVolumes);
+10 -10
View File
@@ -344,27 +344,24 @@ Model::CompareFolderNamesFirst(const Model* compareModel) const
const char* const char*
Model::Name() const Model::Name() const
{ {
static const char* kRootNodeName = B_TRANSLATE_MARK("Disks"); static const char* kRootNodeName = B_TRANSLATE_MARK(B_DISKS_DIR_NAME);
static const char* kTrashNodeName = B_TRANSLATE_MARK("Trash"); static const char* kTrashNodeName = B_TRANSLATE_MARK(B_TRASH_DIR_NAME);
static const char* kDesktopNodeName = B_TRANSLATE_MARK("Desktop"); static const char* kDesktopNodeName = B_TRANSLATE_MARK(B_DESKTOP_DIR_NAME);
switch (fBaseType) { switch (fBaseType) {
case kRootNode: case kRootNode:
return B_TRANSLATE_NOCOLLECT(kRootNodeName); return B_TRANSLATE_NOCOLLECT(kRootNodeName);
case kVolumeNode: case kVolumeNode:
if (fVolumeName) if (fVolumeName != NULL)
return fVolumeName; return fVolumeName;
break; break;
case kTrashNode: case kTrashNode:
return B_TRANSLATE_NOCOLLECT(kTrashNodeName); return B_TRANSLATE_NOCOLLECT(kTrashNodeName);
case kDesktopNode: case kDesktopNode:
return B_TRANSLATE_NOCOLLECT(kDesktopNodeName); return B_TRANSLATE_NOCOLLECT(kDesktopNodeName);
default:
break;
} }
if (fHasLocalizedName && gLocalizedNamePreferred) if (fHasLocalizedName && gLocalizedNamePreferred)
@@ -517,6 +514,7 @@ Model::CloseNode()
#ifdef CHECK_OPEN_MODEL_LEAKS #ifdef CHECK_OPEN_MODEL_LEAKS
if (writableOpenModelList) if (writableOpenModelList)
writableOpenModelList->RemoveItem(this); writableOpenModelList->RemoveItem(this);
if (readOnlyOpenModelList) if (readOnlyOpenModelList)
readOnlyOpenModelList->RemoveItem(this); readOnlyOpenModelList->RemoveItem(this);
#endif #endif
@@ -655,7 +653,8 @@ Model::FinishSettingUpType()
fBaseType = kDesktopNode; fBaseType = kDesktopNode;
} }
fMimeType = B_DIR_MIMETYPE; // should use a shared string here fMimeType = B_DIR_MIMETYPE;
// should use a shared string here
if (IsNodeOpen()) { if (IsNodeOpen()) {
BNodeInfo info(fNode); BNodeInfo info(fNode);
if (info.GetType(mimeString) == B_OK) if (info.GetType(mimeString) == B_OK)
@@ -705,7 +704,8 @@ Model::FinishSettingUpType()
} }
case kLinkNode: case kLinkNode:
fMimeType = B_LINK_MIMETYPE; // should use a shared string here fMimeType = B_LINK_MIMETYPE;
// should use a shared string here
break; break;
case kExecutableNode: case kExecutableNode:
+5 -4
View File
@@ -430,7 +430,7 @@ BPoseView::RestoreColumnState(AttributeStreamNode* node)
} }
AddColumnList(&tempSortedList); AddColumnList(&tempSortedList);
} }
delete [] buffer; delete[] buffer;
} }
} }
SetUpDefaultColumnsIfNeeded(); SetUpDefaultColumnsIfNeeded();
@@ -541,7 +541,7 @@ BPoseView::RestoreState(AttributeStreamNode* node)
fViewState = viewstate; fViewState = viewstate;
} }
} }
delete [] buffer; delete[] buffer;
} }
} }
@@ -2972,7 +2972,7 @@ BPoseView::ReadExtendedPoseInfo(Model* model)
if (result == kReadAttrFailed if (result == kReadAttrFailed
|| size > poseInfo->SizeWithHeadroom() || size > poseInfo->SizeWithHeadroom()
|| size < poseInfo->Size()) { || size < poseInfo->Size()) {
delete [] buffer; delete[] buffer;
return NULL; return NULL;
} }
@@ -8047,8 +8047,9 @@ BPoseView::OpenSelection(BPose* clickedPose, int32* index)
if (settings.SingleWindowBrowse() if (settings.SingleWindowBrowse()
&& !singleWindowBrowsePose && !singleWindowBrowsePose
&& fSelectionList->CountItems() == 1 && fSelectionList->CountItems() == 1
&& !IsFilePanel()) && !IsFilePanel()) {
singleWindowBrowsePose = fSelectionList->ItemAt(0); singleWindowBrowsePose = fSelectionList->ItemAt(0);
}
// check if we can use the single window mode // check if we can use the single window mode
if (settings.SingleWindowBrowse() if (settings.SingleWindowBrowse()
+1 -1
View File
@@ -385,7 +385,7 @@ BRecentFilesList::~BRecentFilesList()
if (fTypeCount) { if (fTypeCount) {
for (int32 index = 0; index < fTypeCount; index++) for (int32 index = 0; index < fTypeCount; index++)
free(fTypes[index]); free(fTypes[index]);
delete [] fTypes; delete[] fTypes;
} }
} }
+2 -2
View File
@@ -75,10 +75,10 @@ ArgvParser::ArgvParser(const char* name)
ArgvParser::~ArgvParser() ArgvParser::~ArgvParser()
{ {
delete [] fBuffer; delete[] fBuffer;
MakeArgvEmpty(); MakeArgvEmpty();
delete [] fCurrentArgv; delete[] fCurrentArgv;
if (fFile) if (fFile)
fclose(fFile); fclose(fFile);
+102 -58
View File
@@ -80,7 +80,6 @@ All rights reserved.
#include "PoseView.h" #include "PoseView.h"
#include "QueryContainerWindow.h" #include "QueryContainerWindow.h"
#include "StatusWindow.h" #include "StatusWindow.h"
#include "TrackerSettings.h"
#include "TrashWatcher.h" #include "TrashWatcher.h"
#include "FunctionObject.h" #include "FunctionObject.h"
#include "TrackerSettings.h" #include "TrackerSettings.h"
@@ -91,11 +90,13 @@ All rights reserved.
#include "VirtualDirectoryWindow.h" #include "VirtualDirectoryWindow.h"
#include "VolumeWindow.h" #include "VolumeWindow.h"
// prototypes for some private kernel calls that will some day be public // prototypes for some private kernel calls that will some day be public
#ifndef _IMPEXP_ROOT #ifndef _IMPEXP_ROOT
# define _IMPEXP_ROOT # define _IMPEXP_ROOT
#endif #endif
const int32 DEFAULT_MON_NUM = 4096; const int32 DEFAULT_MON_NUM = 4096;
// copied from fsil.c // copied from fsil.c
@@ -106,6 +107,8 @@ const int8 kOpenWindowHasState = 2;
const uint32 PSV_MAKE_PRINTER_ACTIVE_QUIETLY = 'pmaq'; const uint32 PSV_MAKE_PRINTER_ACTIVE_QUIETLY = 'pmaq';
// from pr_server.h // from pr_server.h
const int32 kNodeMonitorBumpValue = 512;
namespace BPrivate { namespace BPrivate {
@@ -237,8 +240,10 @@ public:
#undef B_TRANSLATION_CONTEXT #undef B_TRANSLATION_CONTEXT
#define B_TRANSLATION_CONTEXT "Tracker" #define B_TRANSLATION_CONTEXT "Tracker"
TTracker::TTracker() TTracker::TTracker()
: BApplication(kTrackerSignature), :
BApplication(kTrackerSignature),
fWatchingInterface(new WatchingInterface), fWatchingInterface(new WatchingInterface),
fSettingsWindow(NULL) fSettingsWindow(NULL)
{ {
@@ -296,7 +301,7 @@ bool
TTracker::QuitRequested() TTracker::QuitRequested()
{ {
// don't allow user quitting // don't allow user quitting
if (CurrentMessage() && CurrentMessage()->FindBool("shortcut")) { if (CurrentMessage() != NULL && CurrentMessage()->FindBool("shortcut")) {
// but allow quitting to hide fSettingsWindow // but allow quitting to hide fSettingsWindow
int32 index = 0; int32 index = 0;
BWindow* window = NULL; BWindow* window = NULL;
@@ -304,13 +309,15 @@ TTracker::QuitRequested()
if (window == fSettingsWindow) { if (window == fSettingsWindow) {
if (fSettingsWindow->Lock()) { if (fSettingsWindow->Lock()) {
if (!fSettingsWindow->IsHidden() if (!fSettingsWindow->IsHidden()
&& fSettingsWindow->IsActive()) && fSettingsWindow->IsActive()) {
fSettingsWindow->Hide(); fSettingsWindow->Hide();
}
fSettingsWindow->Unlock(); fSettingsWindow->Unlock();
} }
break; break;
} }
} }
return false; return false;
} }
@@ -387,7 +394,7 @@ TTracker::QuitRequested()
message.Flatten(buffer, (ssize_t)size); message.Flatten(buffer, (ssize_t)size);
deskDir.WriteAttr(kAttrOpenWindows, B_MESSAGE_TYPE, 0, buffer, deskDir.WriteAttr(kAttrOpenWindows, B_MESSAGE_TYPE, 0, buffer,
size); size);
delete [] buffer; delete[] buffer;
} else } else
deskDir.RemoveAttr(kAttrOpenWindows); deskDir.RemoveAttr(kAttrOpenWindows);
} }
@@ -734,6 +741,7 @@ TTracker::OpenRef(const entry_ref* ref, const node_ref* nodeToClose,
B_WARNING_ALERT); B_WARNING_ALERT);
alert->SetFlags(alert->Flags() | B_CLOSE_ON_ESCAPE); alert->SetFlags(alert->Flags() | B_CLOSE_ON_ESCAPE);
alert->Go(); alert->Go();
return result; return result;
} }
} else } else
@@ -757,8 +765,9 @@ TTracker::OpenRef(const entry_ref* ref, const node_ref* nodeToClose,
BNodeInfo nodeInfo(model->Node()); BNodeInfo nodeInfo(model->Node());
char preferredApp[B_MIME_TYPE_LENGTH]; char preferredApp[B_MIME_TYPE_LENGTH];
if (nodeInfo.GetPreferredApp(preferredApp) == B_OK if (nodeInfo.GetPreferredApp(preferredApp) == B_OK
&& strcasecmp(preferredApp, kTrackerSignature) != 0) && strcasecmp(preferredApp, kTrackerSignature) != 0) {
openAsContainer = false; openAsContainer = false;
}
model->CloseNode(); model->CloseNode();
} }
@@ -779,27 +788,28 @@ TTracker::OpenRef(const entry_ref* ref, const node_ref* nodeToClose,
delete model; delete model;
// run Launch in a separate thread // run Launch in a separate thread
// and close parent if successfull // and close parent if successfull
if (nodeToClose) if (nodeToClose) {
Thread::Launch(new EntryAndNodeDoSoonWithMessageFunctor<TTracker, Thread::Launch(new EntryAndNodeDoSoonWithMessageFunctor<TTracker,
bool (TTracker::*)(const entry_ref*, const node_ref*, bool (TTracker::*)(const entry_ref*, const node_ref*,
const BMessage*)>(&TTracker::LaunchAndCloseParentIfOK, this, const BMessage*)>(&TTracker::LaunchAndCloseParentIfOK, this,
ref, nodeToClose, messageToBundle)); ref, nodeToClose, messageToBundle));
else { } else {
BMessage refsReceived(B_REFS_RECEIVED); BMessage refsReceived(B_REFS_RECEIVED);
if (messageToBundle) { if (messageToBundle) {
refsReceived = *messageToBundle; refsReceived = *messageToBundle;
refsReceived.what = B_REFS_RECEIVED; refsReceived.what = B_REFS_RECEIVED;
} }
refsReceived.AddRef("refs", ref); refsReceived.AddRef("refs", ref);
if (brokenLinkWithSpecificHandler) if (brokenLinkWithSpecificHandler) {
// This cruft is to support a hacky workaround for // This cruft is to support a hacky workaround for
// double-clicking broken refs for cifs; should get fixed // double-clicking broken refs for cifs; should get fixed
// in R5 // in R5
LaunchBrokenLink(brokenLinkPreferredApp.String(), &refsReceived); LaunchBrokenLink(brokenLinkPreferredApp.String(), &refsReceived);
else } else
TrackerLaunch(&refsReceived, true); TrackerLaunch(&refsReceived, true);
} }
} }
if (nodeToSelect) if (nodeToSelect)
SelectChildInParentSoon(ref, nodeToSelect); SelectChildInParentSoon(ref, nodeToSelect);
@@ -875,8 +885,10 @@ TTracker::RefsReceived(BMessage* message)
&type, &count); &type, &count);
if (error != B_OK) if (error != B_OK)
break; break;
if (strncmp(name, "be:", 3) != 0) if (strncmp(name, "be:", 3) != 0)
continue; continue;
for (int32 k = 0; k < count; k++) { for (int32 k = 0; k < count; k++) {
const void* data; const void* data;
ssize_t size; ssize_t size;
@@ -928,14 +940,15 @@ TTracker::ArgvReceived(int32 argc, char** argv)
for (int32 index = 1; index < argc; index++) { for (int32 index = 1; index < argc; index++) {
BEntry entry; BEntry entry;
if (entry.SetTo(&workingDirectory, argv[index]) == B_OK if (entry.SetTo(&workingDirectory, argv[index]) == B_OK
&& entry.GetRef(&ref) == B_OK) && entry.GetRef(&ref) == B_OK) {
OpenRef(&ref); OpenRef(&ref);
else if (get_ref_for_path(argv[index], &ref) == B_OK) } else if (get_ref_for_path(argv[index], &ref) == B_OK)
OpenRef(&ref); OpenRef(&ref);
} }
} }
} }
void void
TTracker::OpenContainerWindow(Model* model, BMessage* originalRefsList, TTracker::OpenContainerWindow(Model* model, BMessage* originalRefsList,
OpenSelector openSelector, uint32 openFlags, bool checkAlreadyOpen, OpenSelector openSelector, uint32 openFlags, bool checkAlreadyOpen,
@@ -943,9 +956,10 @@ TTracker::OpenContainerWindow(Model* model, BMessage* originalRefsList,
{ {
AutoLock<WindowList> lock(&fWindowList); AutoLock<WindowList> lock(&fWindowList);
BContainerWindow* window = NULL; BContainerWindow* window = NULL;
if (checkAlreadyOpen && openSelector != kRunOpenWithWindow) if (checkAlreadyOpen && openSelector != kRunOpenWithWindow) {
// find out if window already open // find out if window already open
window = FindContainerWindow(model->NodeRef()); window = FindContainerWindow(model->NodeRef());
}
bool someWindowActivated = false; bool someWindowActivated = false;
@@ -966,12 +980,14 @@ TTracker::OpenContainerWindow(Model* model, BMessage* originalRefsList,
if (someWindowActivated) { if (someWindowActivated) {
delete model; delete model;
return; return;
} // If no window was actiated, (none in the current workspace }
// we open a new one.
// If no window was activated (none in the current workspace),
// we open a new one.
if (openSelector == kRunOpenWithWindow) { if (openSelector == kRunOpenWithWindow) {
BMessage* refList = NULL; BMessage* refList = NULL;
if (!originalRefsList) { if (originalRefsList == NULL) {
// when passing just a single model, stuff it's entry in a single // when passing just a single model, stuff it's entry in a single
// element list anyway // element list anyway
ASSERT(model); ASSERT(model);
@@ -979,9 +995,10 @@ TTracker::OpenContainerWindow(Model* model, BMessage* originalRefsList,
refList->AddRef("refs", model->EntryRef()); refList->AddRef("refs", model->EntryRef());
delete model; delete model;
model = NULL; model = NULL;
} else } else {
// clone the message, window adopts it for it's own use // clone the message, window adopts it for it's own use
refList = new BMessage(*originalRefsList); refList = new BMessage(*originalRefsList);
}
window = new OpenWithContainerWindow(refList, &fWindowList); window = new OpenWithContainerWindow(refList, &fWindowList);
} else if (model->IsRoot()) { } else if (model->IsRoot()) {
// window will adopt the model // window will adopt the model
@@ -992,16 +1009,17 @@ TTracker::OpenContainerWindow(Model* model, BMessage* originalRefsList,
} else if (model->IsVirtualDirectory()) { } else if (model->IsVirtualDirectory()) {
// window will adopt the model // window will adopt the model
window = new VirtualDirectoryWindow(&fWindowList, openFlags); window = new VirtualDirectoryWindow(&fWindowList, openFlags);
} else } else {
// window will adopt the model // window will adopt the model
window = new BContainerWindow(&fWindowList, openFlags); window = new BContainerWindow(&fWindowList, openFlags);
}
if (model) if (model != NULL)
window->CreatePoseView(model); window->CreatePoseView(model);
BMessage restoreStateMessage(kRestoreState); BMessage restoreStateMessage(kRestoreState);
if (stateMessage) if (stateMessage != NULL)
restoreStateMessage.AddMessage("state", stateMessage); restoreStateMessage.AddMessage("state", stateMessage);
window->PostMessage(&restoreStateMessage); window->PostMessage(&restoreStateMessage);
@@ -1066,13 +1084,13 @@ TTracker::GetDeskWindow() const
{ {
int32 count = fWindowList.CountItems(); int32 count = fWindowList.CountItems();
for (int32 index = 0; index < count; index++) { for (int32 index = 0; index < count; index++) {
BDeskWindow* window = dynamic_cast<BDeskWindow*> BDeskWindow* window = dynamic_cast<BDeskWindow*>(
(fWindowList.ItemAt(index)); fWindowList.ItemAt(index));
if (window != NULL)
if (window)
return window; return window;
} }
TRESPASS(); TRESPASS();
return NULL; return NULL;
} }
@@ -1083,16 +1101,17 @@ TTracker::FindContainerWindow(const node_ref* node, int32 number) const
ASSERT(fWindowList.IsLocked()); ASSERT(fWindowList.IsLocked());
int32 count = fWindowList.CountItems(); int32 count = fWindowList.CountItems();
int32 windowsFound = 0; int32 windowsFound = 0;
for (int32 index = 0; index < count; index++) { for (int32 index = 0; index < count; index++) {
BContainerWindow* window = dynamic_cast<BContainerWindow*> BContainerWindow* window = dynamic_cast<BContainerWindow*>
(fWindowList.ItemAt(index)); (fWindowList.ItemAt(index));
if (window && window->IsShowing(node) && number == windowsFound++) if (window != NULL && window->IsShowing(node)
&& number == windowsFound++) {
return window; return window;
}
} }
return NULL; return NULL;
} }
@@ -1113,6 +1132,7 @@ TTracker::FindContainerWindow(const entry_ref* entry, int32 number) const
if (window && window->IsShowing(entry) && number == windowsFound++) if (window && window->IsShowing(entry) && number == windowsFound++)
return window; return window;
} }
return NULL; return NULL;
} }
@@ -1143,9 +1163,10 @@ TTracker::FindParentContainerWindow(const entry_ref* ref) const
for (int32 index = 0; index < count; index++) { for (int32 index = 0; index < count; index++) {
BContainerWindow* window = dynamic_cast<BContainerWindow*> BContainerWindow* window = dynamic_cast<BContainerWindow*>
(fWindowList.ItemAt(index)); (fWindowList.ItemAt(index));
if (window && window->IsShowing(&parentRef)) if (window != NULL && window->IsShowing(&parentRef))
return window; return window;
} }
return NULL; return NULL;
} }
@@ -1159,9 +1180,10 @@ TTracker::FindInfoWindow(const node_ref* node) const
for (int32 index = 0; index < count; index++) { for (int32 index = 0; index < count; index++) {
BInfoWindow* window = dynamic_cast<BInfoWindow*> BInfoWindow* window = dynamic_cast<BInfoWindow*>
(fWindowList.ItemAt(index)); (fWindowList.ItemAt(index));
if (window && window->IsShowing(node)) if (window != NULL && window->IsShowing(node))
return window; return window;
} }
return NULL; return NULL;
} }
@@ -1173,13 +1195,14 @@ TTracker::QueryActiveForDevice(dev_t device)
int32 count = fWindowList.CountItems(); int32 count = fWindowList.CountItems();
for (int32 index = 0; index < count; index++) { for (int32 index = 0; index < count; index++) {
BQueryContainerWindow* window BQueryContainerWindow* window
= dynamic_cast<BQueryContainerWindow*>(fWindowList.ItemAt(index)); = dynamic_cast<BQueryContainerWindow*>(fWindowList.ItemAt(index));
if (window) { if (window != NULL) {
AutoLock<BWindow> lock(window); AutoLock<BWindow> lock(window);
if (window->ActiveOnDevice(device)) if (window->ActiveOnDevice(device))
return true; return true;
} }
} }
return false; return false;
} }
@@ -1194,7 +1217,7 @@ TTracker::CloseActiveQueryWindows(dev_t device)
for (int32 index = fWindowList.CountItems(); index >= 0; index--) { for (int32 index = fWindowList.CountItems(); index >= 0; index--) {
BQueryContainerWindow* window BQueryContainerWindow* window
= dynamic_cast<BQueryContainerWindow*>(fWindowList.ItemAt(index)); = dynamic_cast<BQueryContainerWindow*>(fWindowList.ItemAt(index));
if (window) { if (window != NULL) {
AutoLock<BWindow> lock(window); AutoLock<BWindow> lock(window);
if (window->ActiveOnDevice(device)) { if (window->ActiveOnDevice(device)) {
window->PostMessage(B_QUIT_REQUESTED); window->PostMessage(B_QUIT_REQUESTED);
@@ -1202,14 +1225,18 @@ TTracker::CloseActiveQueryWindows(dev_t device)
} }
} }
} }
lock.Unlock(); lock.Unlock();
if (closed)
if (closed) {
for (int32 timeout = 30; timeout; timeout--) { for (int32 timeout = 30; timeout; timeout--) {
// wait a bit for windows to fully close // wait a bit for windows to fully close
if (!QueryActiveForDevice(device)) if (!QueryActiveForDevice(device))
return; return;
snooze(100000); snooze(100000);
} }
}
} }
@@ -1218,15 +1245,14 @@ TTracker::SaveAllPoseLocations()
{ {
int32 numWindows = fWindowList.CountItems(); int32 numWindows = fWindowList.CountItems();
for (int32 windowIndex = 0; windowIndex < numWindows; windowIndex++) { for (int32 windowIndex = 0; windowIndex < numWindows; windowIndex++) {
BContainerWindow* window BContainerWindow* window = dynamic_cast<BContainerWindow*>(
= dynamic_cast<BContainerWindow*> fWindowList.ItemAt(windowIndex));
(fWindowList.ItemAt(windowIndex));
if (window) { if (window != NULL) {
AutoLock<BWindow> lock(window); AutoLock<BWindow> lock(window);
BDeskWindow* deskWindow = dynamic_cast<BDeskWindow*>(window); BDeskWindow* deskWindow = dynamic_cast<BDeskWindow*>(window);
if (deskWindow) if (deskWindow != NULL)
deskWindow->SaveDesktopPoseLocations(); deskWindow->SaveDesktopPoseLocations();
else else
window->PoseView()->SavePoseLocations(); window->PoseView()->SavePoseLocations();
@@ -1283,11 +1309,13 @@ TTracker::CloseAllInWorkspace()
// count from end to beginning so we can remove items safely // count from end to beginning so we can remove items safely
for (int32 index = fWindowList.CountItems() - 1; index >= 0; index--) { for (int32 index = fWindowList.CountItems() - 1; index >= 0; index--) {
BWindow* window = fWindowList.ItemAt(index); BWindow* window = fWindowList.ItemAt(index);
if (window->Workspaces() & currentWorkspace) if ((window->Workspaces() & currentWorkspace) != 0) {
// avoid the desktop // avoid the desktop
if (!dynamic_cast<BDeskWindow*>(window) if (dynamic_cast<BDeskWindow*>(window) == NULL
&& !dynamic_cast<BStatusWindow*>(window)) && dynamic_cast<BStatusWindow*>(window) == NULL) {
window->PostMessage(B_QUIT_REQUESTED); window->PostMessage(B_QUIT_REQUESTED);
}
}
} }
} }
@@ -1305,18 +1333,21 @@ TTracker::CloseAllWindows()
for (int32 index = 0; index < count; index++) { for (int32 index = 0; index < count; index++) {
BWindow* window = WindowAt(index); BWindow* window = WindowAt(index);
// avoid the desktop // avoid the desktop
if (!dynamic_cast<BDeskWindow*>(window) if (dynamic_cast<BDeskWindow*>(window) == NULL
&& !dynamic_cast<BStatusWindow*>(window)) && dynamic_cast<BStatusWindow*>(window) == NULL) {
window->PostMessage(B_QUIT_REQUESTED); window->PostMessage(B_QUIT_REQUESTED);
}
} }
// count from end to beginning so we can remove items safely // count from end to beginning so we can remove items safely
for (int32 index = fWindowList.CountItems() - 1; index >= 0; index--) { for (int32 index = fWindowList.CountItems() - 1; index >= 0; index--) {
BWindow* window = fWindowList.ItemAt(index); BWindow* window = fWindowList.ItemAt(index);
if (!dynamic_cast<BDeskWindow*>(window) if (dynamic_cast<BDeskWindow*>(window) == NULL
&& !dynamic_cast<BStatusWindow*>(window)) && dynamic_cast<BStatusWindow*>(window) == NULL) {
// ToDo: // ToDo: get rid of the Remove here, BContainerWindow::Quit()
// get rid of the Remove here, BContainerWindow::Quit does it // does it
fWindowList.RemoveItemAt(index); fWindowList.RemoveItemAt(index);
}
} }
} }
@@ -1331,13 +1362,14 @@ TTracker::_OpenPreviouslyOpenedWindows(const char* pathFilter)
BDirectory deskDir; BDirectory deskDir;
attr_info attrInfo; attr_info attrInfo;
if (FSGetDeskDir(&deskDir) != B_OK if (FSGetDeskDir(&deskDir) != B_OK
|| deskDir.GetAttrInfo(kAttrOpenWindows, &attrInfo) != B_OK) || deskDir.GetAttrInfo(kAttrOpenWindows, &attrInfo) != B_OK) {
return; return;
}
char* buffer = (char*)malloc((size_t)attrInfo.size); char* buffer = (char*)malloc((size_t)attrInfo.size);
BMessage message; BMessage message;
if (deskDir.ReadAttr(kAttrOpenWindows, B_MESSAGE_TYPE, 0, buffer, if (deskDir.ReadAttr(kAttrOpenWindows, B_MESSAGE_TYPE, 0, buffer,
(size_t)attrInfo.size) != attrInfo.size (size_t)attrInfo.size) != attrInfo.size
|| message.Unflatten(buffer) != B_OK) { || message.Unflatten(buffer) != B_OK) {
free(buffer); free(buffer);
return; return;
@@ -1351,7 +1383,7 @@ TTracker::_OpenPreviouslyOpenedWindows(const char* pathFilter)
int32 stateMessageCounter = 0; int32 stateMessageCounter = 0;
const char* path; const char* path;
for (int32 i = 0; message.FindString("paths", i, &path) == B_OK; i++) { for (int32 i = 0; message.FindString("paths", i, &path) == B_OK; i++) {
if (strncmp(path, pathFilter, filterLength)) if (strncmp(path, pathFilter, filterLength) != 0)
continue; continue;
BEntry entry(path, true); BEntry entry(path, true);
@@ -1462,12 +1494,14 @@ TTracker::ReadyToRun()
} }
} }
MimeTypeList* MimeTypeList*
TTracker::MimeTypes() const TTracker::MimeTypes() const
{ {
return fMimeTypeList; return fMimeTypeList;
} }
void void
TTracker::SelectChildInParentSoon(const entry_ref* parent, TTracker::SelectChildInParentSoon(const entry_ref* parent,
const node_ref* child) const node_ref* child)
@@ -1477,6 +1511,7 @@ TTracker::SelectChildInParentSoon(const entry_ref* parent,
100000, 200000, 5000000); 100000, 200000, 5000000);
} }
void void
TTracker::CloseParentWaitingForChildSoon(const entry_ref* child, TTracker::CloseParentWaitingForChildSoon(const entry_ref* child,
const node_ref* parent) const node_ref* parent)
@@ -1486,6 +1521,7 @@ TTracker::CloseParentWaitingForChildSoon(const entry_ref* child,
200000, 100000, 5000000); 200000, 100000, 5000000);
} }
void void
TTracker::SelectPoseAtLocationSoon(node_ref parent, BPoint pointInPose) TTracker::SelectPoseAtLocationSoon(node_ref parent, BPoint pointInPose)
{ {
@@ -1494,6 +1530,7 @@ TTracker::SelectPoseAtLocationSoon(node_ref parent, BPoint pointInPose)
100000); 100000);
} }
void void
TTracker::SelectPoseAtLocationInParent(node_ref parent, BPoint pointInPose) TTracker::SelectPoseAtLocationInParent(node_ref parent, BPoint pointInPose)
{ {
@@ -1505,6 +1542,7 @@ TTracker::SelectPoseAtLocationInParent(node_ref parent, BPoint pointInPose)
} }
} }
bool bool
TTracker::CloseParentWaitingForChild(const entry_ref* child, TTracker::CloseParentWaitingForChild(const entry_ref* child,
const node_ref* parent) const node_ref* parent)
@@ -1533,6 +1571,7 @@ TTracker::CloseParentWaitingForChild(const entry_ref* child,
return false; return false;
} }
void void
TTracker::CloseParent(node_ref parent) TTracker::CloseParent(node_ref parent)
{ {
@@ -1543,6 +1582,7 @@ TTracker::CloseParent(node_ref parent)
CloseParentWindowCommon(FindContainerWindow(&parent)); CloseParentWindowCommon(FindContainerWindow(&parent));
} }
void void
TTracker::ShowSettingsWindow() TTracker::ShowSettingsWindow()
{ {
@@ -1555,36 +1595,40 @@ TTracker::ShowSettingsWindow()
fSettingsWindow->Show(); fSettingsWindow->Show();
else else
fSettingsWindow->Activate(); fSettingsWindow->Activate();
fSettingsWindow->Unlock(); fSettingsWindow->Unlock();
} }
} }
} }
bool bool
TTracker::CloseParentWindowCommon(BContainerWindow* window) TTracker::CloseParentWindowCommon(BContainerWindow* window)
{ {
ASSERT(fWindowList.IsLocked()); ASSERT(fWindowList.IsLocked());
if (dynamic_cast<BDeskWindow*>(window)) if (dynamic_cast<BDeskWindow*>(window) == NULL) {
// don't close the destop // don't close the destop
return false; return false;
}
window->PostMessage(B_QUIT_REQUESTED); window->PostMessage(B_QUIT_REQUESTED);
return true; return true;
} }
bool bool
TTracker::SelectChildInParent(const entry_ref* parent, const node_ref* child) TTracker::SelectChildInParent(const entry_ref* parent, const node_ref* child)
{ {
AutoLock<WindowList> lock(&fWindowList); AutoLock<WindowList> lock(&fWindowList);
BContainerWindow* window = FindContainerWindow(parent); BContainerWindow* window = FindContainerWindow(parent);
if (!window) if (window == NULL) {
// parent window already closed, give up // parent window already closed, give up
return false; return false;
}
AutoLock<BWindow> windowLock(window); AutoLock<BWindow> windowLock(window);
if (windowLock.IsLocked()) { if (windowLock.IsLocked()) {
BPoseView* view = window->PoseView(); BPoseView* view = window->PoseView();
int32 index; int32 index;
@@ -1594,10 +1638,10 @@ TTracker::SelectChildInParent(const entry_ref* parent, const node_ref* child)
return true; return true;
} }
} }
return false; return false;
} }
const int32 kNodeMonitorBumpValue = 512;
status_t status_t
TTracker::NeedMoreNodeMonitors() TTracker::NeedMoreNodeMonitors()
@@ -1612,13 +1656,13 @@ TTracker::NeedMoreNodeMonitors()
fNodeMonitorCount -= kNodeMonitorBumpValue; fNodeMonitorCount -= kNodeMonitorBumpValue;
return errno; return errno;
} }
return B_OK;
return B_OK;
} }
status_t status_t
TTracker::WatchNode(const node_ref* node, uint32 flags, TTracker::WatchNode(const node_ref* node, uint32 flags, BMessenger target)
BMessenger target)
{ {
status_t result = watch_node(node, flags, target); status_t result = watch_node(node, flags, target);
if (result == B_OK || result != B_NO_MEMORY) { if (result == B_OK || result != B_NO_MEMORY) {
@@ -1631,7 +1675,7 @@ TTracker::WatchNode(const node_ref* node, uint32 flags,
"node monitors\n")); "node monitors\n"));
TTracker* tracker = dynamic_cast<TTracker*>(be_app); TTracker* tracker = dynamic_cast<TTracker*>(be_app);
if (!tracker) { if (tracker == NULL) {
// we are the file panel only, just fail // we are the file panel only, just fail
return result; return result;
} }
+13 -11
View File
@@ -111,10 +111,8 @@ rgb_color ValueToColor(int32 value)
int32 ColorToValue(rgb_color color) int32 ColorToValue(rgb_color color)
{ {
return color.alpha << 24L return color.alpha << 24L | color.red << 16L | color.green << 8L
| color.red << 16L | color.blue;
| color.green << 8L
| color.blue;
} }
@@ -122,15 +120,17 @@ int32 ColorToValue(rgb_color color)
TTrackerState::TTrackerState() TTrackerState::TTrackerState()
: Settings("TrackerSettings", "Tracker"), :
fInited(false), Settings("TrackerSettings", "Tracker"),
fSettingsLoaded(false) fInited(false),
fSettingsLoaded(false)
{ {
} }
TTrackerState::TTrackerState(const TTrackerState&) TTrackerState::TTrackerState(const TTrackerState&)
: Settings("", "") :
Settings("", "")
{ {
// Placeholder copy constructor to prevent others from accidentally using // Placeholder copy constructor to prevent others from accidentally using
// the default copy constructor. Note, the DEBUGGER call is for the off // the default copy constructor. Note, the DEBUGGER call is for the off
@@ -478,11 +478,13 @@ void
TrackerSettings::RecentCounts(int32* applications, int32* documents, TrackerSettings::RecentCounts(int32* applications, int32* documents,
int32* folders) int32* folders)
{ {
if (applications) if (applications != NULL)
*applications = gTrackerState.fRecentApplicationsCount->Value(); *applications = gTrackerState.fRecentApplicationsCount->Value();
if (documents)
if (documents != NULL)
*documents = gTrackerState.fRecentDocumentsCount->Value(); *documents = gTrackerState.fRecentDocumentsCount->Value();
if (folders)
if (folders != NULL)
*folders = gTrackerState.fRecentFoldersCount->Value(); *folders = gTrackerState.fRecentFoldersCount->Value();
} }
+2 -1
View File
@@ -298,7 +298,8 @@ TrackerSettingsWindow::_HandleChangedSettingsView()
SettingsItem::SettingsItem(const char* label, SettingsView* view) SettingsItem::SettingsItem(const char* label, SettingsView* view)
: BStringItem(label), :
BStringItem(label),
fSettingsView(view) fSettingsView(view)
{ {
} }
+1 -1
View File
@@ -1238,8 +1238,8 @@ StringToScalar(const char* text)
// no suffix, try plain byte conversion // no suffix, try plain byte conversion
val = strtoll(buffer, &end, 10); val = strtoll(buffer, &end, 10);
} }
delete[] buffer;
delete [] buffer;
return val; return val;
} }