Tracker: Style fixes

This commit is contained in:
John Scipione 2014-06-10 00:28:42 -04:00
parent 12bd3f0452
commit 9437e677ba
18 changed files with 304 additions and 194 deletions

View File

@ -731,7 +731,7 @@ SelectiveAttributeTransformer::~SelectiveAttributeTransformer()
{
for (int32 index = fTransformedBuffers.CountItems() - 1; index >= 0;
index--) {
delete [] fTransformedBuffers.ItemAt(index);
delete[] fTransformedBuffers.ItemAt(index);
}
}
@ -741,7 +741,7 @@ SelectiveAttributeTransformer::Rewind()
{
for (int32 index = fTransformedBuffers.CountItems() - 1; index >= 0;
index--) {
delete [] fTransformedBuffers.ItemAt(index);
delete[] fTransformedBuffers.ItemAt(index);
}
fTransformedBuffers.MakeEmpty();
@ -791,7 +791,7 @@ SelectiveAttributeTransformer::CopyAndApplyTransformer(const char* name,
}
if (!(fTransformFunc)(name, type, size, result, fTransformParams)) {
delete [] result;
delete[] result;
return NULL;
}

View File

@ -215,15 +215,16 @@ protected:
class AttrNode {
public:
AttrNode(const char* name, uint32 type, off_t size, char* data)
: fAttr(name, type, size),
fData(data)
{
}
:
fAttr(name, type, size),
fData(data)
{
}
~AttrNode()
{
delete [] fData;
}
{
delete[] fData;
}
AttributeInfo fAttr;
char* fData;

View File

@ -78,7 +78,7 @@ BackgroundImage::GetBackgroundImage(const BNode* node, bool isDesktop)
if (error == info.size)
error = container.Unflatten(buffer);
delete [] buffer;
delete[] buffer;
if (error != B_OK)
return NULL;

View File

@ -32,9 +32,8 @@ names are registered trademarks or trademarks of their respective holders.
All rights reserved.
*/
#include <string.h>
#include <stdlib.h>
#include <image.h>
#include "ContainerWindow.h"
#include <Alert.h>
#include <Application.h>
@ -59,6 +58,9 @@ All rights reserved.
#include <Roster.h>
#include <fs_attr.h>
#include <image.h>
#include <string.h>
#include <stdlib.h>
#include <memory>
@ -67,7 +69,6 @@ All rights reserved.
#include "AutoLock.h"
#include "BackgroundImage.h"
#include "Commands.h"
#include "ContainerWindow.h"
#include "CountView.h"
#include "DeskWindow.h"
#include "FavoritesMenu.h"
@ -95,6 +96,7 @@ All rights reserved.
#undef B_TRANSLATION_CONTEXT
#define B_TRANSLATION_CONTEXT "ContainerWindow"
const uint32 kRedo = 'REDO';
// this is the same as B_REDO in Dano/Zeta/Haiku
@ -104,9 +106,11 @@ _IMPEXP_BE
#endif
void do_minimize_team(BRect zoomRect, team_id team, bool zoom);
// Amount you have to move the mouse before a drag starts
const float kDragSlop = 3.0f;
namespace BPrivate {
class DraggableContainerIcon : public BView {
@ -130,6 +134,7 @@ class DraggableContainerIcon : public BView {
} // namespace BPrivate
struct AddOneAddonParams {
BObjectList<BMenuItem>* primaryList;
BObjectList<BMenuItem>* secondaryList;
@ -139,16 +144,19 @@ struct StaggerOneParams {
bool rectFromParent;
};
const int32 kContainerWidthMinLimit = 120;
const int32 kContainerWindowHeightLimit = 85;
const int32 kWindowStaggerBy = 17;
BRect BContainerWindow::sNewWindRect(85, 50, 548, 280);
LockingList<AddonShortcut>* BContainerWindow::fAddonsList
= new LockingList<struct AddonShortcut>(10, true);
namespace BPrivate {
filter_result
@ -276,6 +284,7 @@ OffsetFrameOne(const char* DEBUG_ONLY(name), uint32, off_t, void* castToRect,
return false;
((BRect*)castToRect)->OffsetBy(kWindowStaggerBy, kWindowStaggerBy);
return true;
}
@ -294,6 +303,7 @@ AddMimeTypeString(BObjectList<BString> &list, Model* model)
return;
}
}
list.AddItem(mimeType);
}
}
@ -304,7 +314,8 @@ AddMimeTypeString(BObjectList<BString> &list, Model* model)
DraggableContainerIcon::DraggableContainerIcon(BRect rect, const char* name,
uint32 resizeMask)
: BView(rect, name, resizeMask, B_WILL_DRAW | B_FRAME_EVENTS),
:
BView(rect, name, resizeMask, B_WILL_DRAW | B_FRAME_EVENTS),
fDragButton(0),
fDragStarted(false)
{
@ -383,7 +394,7 @@ DraggableContainerIcon::MouseMoved(BPoint point, uint32 /*transit*/,
float height = ceilf(fontHeight.ascent + fontHeight.descent
+ 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);
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
// (that is, move them to AddShortcuts())
AddShortcut('Z', B_COMMAND_KEY, new BMessage(B_UNDO), this);
AddShortcut('Z', B_COMMAND_KEY | B_SHIFT_KEY, new BMessage(kRedo), this);
// (that is, move them to AddShortcuts())
AddShortcut('Z', B_COMMAND_KEY, new BMessage(B_UNDO), this);
AddShortcut('Z', B_COMMAND_KEY | B_SHIFT_KEY, new BMessage(kRedo), this);
}
@ -596,7 +607,7 @@ BContainerWindow::~BContainerWindow()
delete fDragMessage;
delete fCachedTypesList;
if (fSelectionWindow && fSelectionWindow->Lock())
if (fSelectionWindow != NULL && fSelectionWindow->Lock())
fSelectionWindow->Quit();
}
@ -631,9 +642,10 @@ BContainerWindow::QuitRequested()
// means to say close all your windows. It might be better to have it
// send a kCloseAllWindows message and have windowless apps stay running,
// which is what we will do for the Tracker
if (CurrentMessage()
&& (CurrentMessage()->FindInt32("modifiers") & B_CONTROL_KEY))
if (CurrentMessage() != NULL
&& ((CurrentMessage()->FindInt32("modifiers") & B_CONTROL_KEY)) != 0) {
be_app->PostMessage(kCloseAllWindows);
}
Hide();
// this will close the window instantly, even if
@ -739,18 +751,17 @@ BContainerWindow::CreatePoseView(Model* model)
BRect rect(Bounds());
TrackerSettings settings;
if (settings.SingleWindowBrowse()
&& settings.ShowNavigator()
&& model->IsDirectory())
if (settings.SingleWindowBrowse() && settings.ShowNavigator()
&& model->IsDirectory()) {
rect.top += BNavigator::CalcNavigatorHeight() + 1;
}
rect.right -= B_V_SCROLL_BAR_WIDTH;
rect.bottom -= B_H_SCROLL_BAR_HEIGHT;
fPoseView = NewPoseView(model, rect, kListMode);
AddChild(fPoseView);
if (settings.SingleWindowBrowse()
&& model->IsDirectory()
if (settings.SingleWindowBrowse() && model->IsDirectory()
&& !fPoseView->IsFilePanel()) {
BRect rect(Bounds());
rect.top = 0;
@ -760,8 +771,10 @@ BContainerWindow::CreatePoseView(Model* model)
fNavigator = new BNavigator(model, rect);
if (!settings.ShowNavigator())
fNavigator->Hide();
AddChild(fNavigator);
}
SetPathWatchingEnabled(settings.ShowNavigator()
|| settings.ShowFullPathInTitleBar());
}
@ -996,9 +1009,10 @@ BContainerWindow::Init(const BMessage* message)
MarkAttributeMenu(fAttrMenu);
CheckScreenIntersect();
if (fBackgroundImage && !dynamic_cast<BDeskWindow*>(this)
&& PoseView()->ViewMode() != kListMode)
if (fBackgroundImage != NULL && dynamic_cast<BDeskWindow*>(this) == NULL
&& PoseView()->ViewMode() != kListMode) {
fBackgroundImage->Show(PoseView(), current_workspace());
}
Show();
@ -1048,8 +1062,8 @@ BContainerWindow::RestoreStateCommon()
WindowStateNodeOpener opener(this, false);
bool isDesktop = dynamic_cast<BDeskWindow*>(this);
if (!TargetModel()->IsRoot() && opener.Node())
bool isDesktop = dynamic_cast<BDeskWindow*>(this) != NULL;
if (!TargetModel()->IsRoot() && opener.Node()) {
// don't pick up background image for root disks
// to do this, would have to have a unique attribute for the
// disks window that doesn't collide with the desktop
@ -1058,13 +1072,15 @@ BContainerWindow::RestoreStateCommon()
fBackgroundImage = BackgroundImage::GetBackgroundImage(
opener.Node(), isDesktop);
// look for background image info in the window's node
}
BNode defaultingNode;
if (!fBackgroundImage && !isDesktop
&& DefaultStateSourceNode(kDefaultFolderTemplate, &defaultingNode))
if (fBackgroundImage == NULL && !isDesktop
&& DefaultStateSourceNode(kDefaultFolderTemplate, &defaultingNode)) {
// look for background image info in the source for defaults
fBackgroundImage
= BackgroundImage::GetBackgroundImage(&defaultingNode, isDesktop);
fBackgroundImage = BackgroundImage::GetBackgroundImage(&defaultingNode,
isDesktop);
}
}
@ -1077,13 +1093,15 @@ BContainerWindow::UpdateTitle()
BPath path;
TargetModel()->GetPath(&path);
SetTitle(path.Path());
} else
} else {
// use the default look
SetTitle(TargetModel()->Name());
}
if (Navigator())
if (Navigator() != NULL) {
Navigator()->UpdateLocation(PoseView()->TargetModel(),
kActionUpdatePath);
}
}
@ -1096,24 +1114,26 @@ BContainerWindow::UpdateBackgroundImage()
bool isDesktop = dynamic_cast<BDeskWindow*>(this) != NULL;
WindowStateNodeOpener opener(this, false);
if (!TargetModel()->IsRoot() && opener.Node())
if (!TargetModel()->IsRoot() && opener.Node()) {
fBackgroundImage = BackgroundImage::Refresh(fBackgroundImage,
opener.Node(), isDesktop, PoseView());
}
// look for background image info in the window's node
BNode defaultingNode;
if (!fBackgroundImage && !isDesktop
&& DefaultStateSourceNode(kDefaultFolderTemplate, &defaultingNode))
&& DefaultStateSourceNode(kDefaultFolderTemplate, &defaultingNode)) {
// look for background image info in the source for defaults
fBackgroundImage = BackgroundImage::Refresh(fBackgroundImage,
&defaultingNode, isDesktop, PoseView());
}
}
void
BContainerWindow::FrameResized(float, float)
{
if (PoseView() && dynamic_cast<BDeskWindow*>(this) == NULL) {
if (PoseView() != NULL && dynamic_cast<BDeskWindow*>(this) == NULL) {
BRect extent = PoseView()->Extent();
float offsetX = extent.left - PoseView()->Bounds().left;
float offsetY = extent.top - PoseView()->Bounds().top;
@ -1170,7 +1190,7 @@ BContainerWindow::ViewModeChanged(uint32 oldMode, uint32 newMode)
view->FrameMoved(view->Frame().LeftTop());
}
if (!fBackgroundImage)
if (fBackgroundImage == NULL)
return;
if (newMode == kListMode)
@ -1205,8 +1225,10 @@ BContainerWindow::SaveState(bool hide)
WindowStateNodeOpener opener(this, true);
if (opener.StreamNode())
SaveWindowState(opener.StreamNode());
if (hide)
Hide();
if (opener.StreamNode())
fPoseView->SaveState(opener.StreamNode());
@ -1216,7 +1238,7 @@ BContainerWindow::SaveState(bool hide)
void
BContainerWindow::SaveState(BMessage &message) const
BContainerWindow::SaveState(BMessage& message) const
{
if (SaveStateIsEnabled()) {
SaveWindowState(message);
@ -1235,8 +1257,7 @@ BContainerWindow::StateNeedsSaving() const
status_t
BContainerWindow::GetLayoutState(BNode* node, BMessage* message)
{
// ToDo:
// get rid of this, use AttrStream instead
// ToDo: get rid of this, use AttrStream instead
status_t result = node->InitCheck();
if (result != B_OK)
return result;
@ -1254,16 +1275,18 @@ BContainerWindow::GetLayoutState(BNode* node, BMessage* message)
&& strcmp(attrName, kAttrColumns) != 0
&& strcmp(attrName, kAttrViewState) != 0
&& strcmp(attrName, kAttrColumnsForeign) != 0
&& strcmp(attrName, kAttrViewStateForeign) != 0)
&& strcmp(attrName, kAttrViewStateForeign) != 0) {
continue;
}
char* buffer = new char[info.size];
if (node->ReadAttr(attrName, info.type, 0, buffer,
(size_t)info.size) == info.size) {
message->AddData(attrName, info.type, buffer, (ssize_t)info.size);
}
delete [] buffer;
delete[] buffer;
}
return B_OK;
}
@ -1305,6 +1328,7 @@ BContainerWindow::SetLayoutState(BNode* node, const BMessage* message)
globalIndex++;
}
}
return B_OK;
}
@ -1350,9 +1374,8 @@ BContainerWindow::Zoom(BPoint, float, float)
fSavedZoomRect = Frame();
ResizeToFit();
if (fSavedZoomRect == Frame())
if (oldZoomRect.IsValid())
ResizeTo(oldZoomRect.Width(), oldZoomRect.Height());
if (fSavedZoomRect == Frame() && oldZoomRect.IsValid())
ResizeTo(oldZoomRect.Width(), oldZoomRect.Height());
}
@ -1454,9 +1477,9 @@ BContainerWindow::MessageReceived(BMessage* message)
PoseView()->DuplicateSelection();
else
PoseView()->MoveSelectionInto(&model, this, true);
break;
}
case kMoveSelectionTo:
{
entry_ref ref;
@ -1748,8 +1771,9 @@ BContainerWindow::SetCopyItem(BMenu* menu)
{
BMenuItem* item;
if ((item = menu->FindItem(B_COPY)) == NULL
&& (item = menu->FindItem(kCopyMoreSelectionToClipboard)) == NULL)
&& (item = menu->FindItem(kCopyMoreSelectionToClipboard)) == NULL) {
return;
}
item->SetEnabled(PoseView()->SelectionList()->CountItems() > 0
|| PoseView() != CurrentFocus());
@ -1771,8 +1795,9 @@ BContainerWindow::SetPasteItem(BMenu* menu)
{
BMenuItem* item;
if ((item = menu->FindItem(B_PASTE)) == NULL
&& (item = menu->FindItem(kPasteLinksFromClipboard)) == NULL)
&& (item = menu->FindItem(kPasteLinksFromClipboard)) == NULL) {
return;
}
item->SetEnabled(FSClipboardHasRefs() || PoseView() != CurrentFocus());
@ -1793,8 +1818,9 @@ BContainerWindow::SetArrangeMenu(BMenu* menu)
{
BMenuItem* item;
if ((item = menu->FindItem(kCleanup)) == NULL
&& (item = menu->FindItem(kCleanupAll)) == NULL)
&& (item = menu->FindItem(kCleanupAll)) == NULL) {
return;
}
item->Menu()->SetEnabled(PoseView()->CountItems() > 0
&& (PoseView()->ViewMode() != kListMode));
@ -1812,6 +1838,7 @@ BContainerWindow::SetArrangeMenu(BMenu* menu)
item->SetMessage(new BMessage(kCleanup));
arrangeMenu = item->Menu();
}
MarkArrangeByMenu(arrangeMenu);
}
@ -1821,8 +1848,9 @@ BContainerWindow::SetCloseItem(BMenu* menu)
{
BMenuItem* item;
if ((item = menu->FindItem(B_QUIT_REQUESTED)) == NULL
&& (item = menu->FindItem(kCloseAllWindows)) == NULL)
&& (item = menu->FindItem(kCloseAllWindows)) == NULL) {
return;
}
if (modifiers() & B_SHIFT_KEY) {
item->SetLabel(B_TRANSLATE("Close all"));
@ -1950,8 +1978,10 @@ BContainerWindow::AddFileMenu(BMenu* menu)
menu->SetTargetForItems(PoseView());
if (cutItem)
cutItem->SetTarget(this);
if (copyItem)
copyItem->SetTarget(this);
if (pasteItem)
pasteItem->SetTarget(this);
}
@ -2142,13 +2172,14 @@ BContainerWindow::AddShortcuts()
void
BContainerWindow::MenusBeginning()
{
if (!fMenuBar)
if (fMenuBar == NULL)
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
// invoked - this would prevent Cut/Copy/Paste from working
fPoseView->CommitActivePose();
}
// File menu
int32 selectCount = PoseView()->SelectionList()->CountItems();
@ -2185,9 +2216,9 @@ void
BContainerWindow::SetupNavigationMenu(const entry_ref* ref, BMenu* parent)
{
// start by removing nav item (and separator) from old menu
if (fNavigationItem) {
if (fNavigationItem != NULL) {
BMenu* menu = fNavigationItem->Menu();
if (menu) {
if (menu != NULL) {
menu->RemoveItem(fNavigationItem);
BMenuItem* item = menu->RemoveItem((int32)0);
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 (!ref)
if (ref == NULL)
ref = TargetModel()->EntryRef();
BEntry entry;
@ -2208,8 +2239,9 @@ BContainerWindow::SetupNavigationMenu(const entry_ref* ref, BMenu* parent)
entry_ref resolvedRef;
if (model.InitCheck() != B_OK
|| (!model.IsContainer() && !model.IsSymLink()))
|| (!model.IsContainer() && !model.IsSymLink())) {
return;
}
if (model.IsSymLink()) {
if (entry.SetTo(model.EntryRef(), true) != B_OK)
@ -2223,7 +2255,7 @@ BContainerWindow::SetupNavigationMenu(const entry_ref* ref, BMenu* parent)
ref = &resolvedRef;
}
if (!fNavigationItem) {
if (fNavigationItem == NULL) {
fNavigationItem = new ModelMenuItem(&model,
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
BMenuItem* item = menu->FindItem(kEditQuery);
if (!poseViewIsQuery && !queryInSelection && item)
if (!poseViewIsQuery && !queryInSelection && item != NULL)
item->Menu()->RemoveItem(item);
else if ((poseViewIsQuery || queryInSelection) && !item) {
else if ((poseViewIsQuery || queryInSelection) && item == NULL) {
// add edit query item after Open
item = menu->FindItem(kOpenSelection);
if (item) {
@ -2302,20 +2332,22 @@ BContainerWindow::SetupOpenWithMenu(BMenu* parent)
// start by removing nav item (and separator) from old menu
if (fOpenWithItem) {
BMenu* menu = fOpenWithItem->Menu();
if (menu)
if (menu != NULL)
menu->RemoveItem(fOpenWithItem);
delete fOpenWithItem;
fOpenWithItem = 0;
}
if (PoseView()->SelectionList()->CountItems() == 0)
if (PoseView()->SelectionList()->CountItems() == 0) {
// no selection, nothing to open
return;
}
if (TargetModel()->IsRoot())
if (TargetModel()->IsRoot()) {
// don't add ourselves if we are root
return;
}
// ToDo:
// check if only item in selection list is the root
@ -2325,7 +2357,7 @@ BContainerWindow::SetupOpenWithMenu(BMenu* parent)
BMenuItem* item = parent->FindItem(kOpenSelection);
int32 count = PoseView()->SelectionList()->CountItems();
if (!count)
if (count == 0)
return;
// build a list of all refs to open
@ -2443,9 +2475,10 @@ BContainerWindow::PopulateMoveCopyNavMenu(BNavMenu* navMenu, uint32 what,
// add root dir
if (volume.GetRootDirectory(&directory) == B_OK
&& directory.GetEntry(&entry) == B_OK
&& model.SetTo(&entry) == B_OK)
&& model.SetTo(&entry) == B_OK) {
navMenu->AddNavDir(&model, what, this, true);
// ask NavMenu to populate submenu for us
}
}
}
}
@ -2634,7 +2667,8 @@ BContainerWindow::ShowContextMenu(BPoint loc, const entry_ref* ref, BView*)
// reset in DetachedFromWindow
// see the notes in SlowContextPopup::AttachedToWindow
if (!FSIsPrintersDir(&entry) && !fDragContextMenu->IsShowing()) {
if (!FSIsPrintersDir(&entry)
&& !fDragContextMenu->IsShowing()) {
//printf("ShowContextMenu - target is %s %i\n",
// ref->name, IsShowing(ref));
fDragContextMenu->ClearMenu();
@ -2653,17 +2687,18 @@ BContainerWindow::ShowContextMenu(BPoint loc, const entry_ref* ref, BView*)
fDragContextMenu->SetTypesList(fCachedTypesList);
fDragContextMenu->SetTarget(BMessenger(this));
BPoseView* poseView = PoseView();
if (poseView) {
if (poseView != NULL) {
BMessenger target(poseView);
fDragContextMenu->InitTrackingHook(
&BPoseView::MenuTrackingHook, &target,
fDragMessage);
fDragMessage);
}
// this is now asynchronous so that we don't
// deadlock in Window::Quit,
fDragContextMenu->Go(global, true, false, true);
}
return;
} else if (TargetModel()->IsRoot() || model.IsVolume()) {
fContextMenu = fVolumeContextMenu;
@ -2673,7 +2708,7 @@ BContainerWindow::ShowContextMenu(BPoint loc, const entry_ref* ref, BView*)
// clean up items from last context menu
if (fContextMenu) {
if (fContextMenu != NULL) {
if (fContextMenu->Window())
return;
else
@ -2714,7 +2749,7 @@ BContainerWindow::ShowContextMenu(BPoint loc, const entry_ref* ref, BView*)
fContextMenu->Go(global, true, true, true);
}
}
} else if (fWindowContextMenu) {
} else if (fWindowContextMenu != NULL) {
if (fWindowContextMenu->Window())
return;
@ -2731,6 +2766,7 @@ BContainerWindow::ShowContextMenu(BPoint loc, const entry_ref* ref, BView*)
fWindowContextMenu->Go(global, true, true, true);
}
fContextMenu = NULL;
}
@ -2740,8 +2776,8 @@ BContainerWindow::AddFileContextMenus(BMenu* menu)
{
menu->AddItem(new BMenuItem(B_TRANSLATE("Open"),
new BMessage(kOpenSelection), 'O'));
menu->AddItem(new BMenuItem(B_TRANSLATE("Get info"), new BMessage(kGetInfo),
'I'));
menu->AddItem(new BMenuItem(B_TRANSLATE("Get info"),
new BMessage(kGetInfo), 'I'));
menu->AddItem(new BMenuItem(B_TRANSLATE("Edit name"),
new BMessage(kEditItem), 'E'));
@ -3118,7 +3154,6 @@ BContainerWindow::UpdateMenu(BMenu* menu, UpdateMenuContext context)
SetArrangeMenu(menu);
SetPasteItem(menu);
BEntry entry(TargetModel()->EntryRef());
BDirectory parent;
entry_ref ref;
@ -3761,9 +3796,10 @@ BContainerWindow::SetUpDefaultState()
void
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
return;
}
const char* rectAttributeName;
const char* workspaceAttributeName;
@ -3814,9 +3850,10 @@ BContainerWindow::RestoreWindowState(AttributeStreamNode* node)
void
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
return;
}
const char* rectAttributeName;
const char* workspaceAttributeName;

View File

@ -245,10 +245,12 @@ BDeskWindow::Init(const BMessage*)
BPath path;
if (!BootedInSafeMode() && FSFindTrackerSettingsDir(&path) == B_OK) {
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)
fDeskShelf = new BShelf(&ref, fPoseView);
if (fDeskShelf)
if (fDeskShelf != NULL)
fDeskShelf->SetDisplaysZombies(true);
}
InitKeyIndices();
@ -288,7 +290,8 @@ BDeskWindow::ApplyShortcutPreferences(bool update)
if (!update) {
BPath path;
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);
fShortcutsSettings = new char[strlen(path.Path()) + 1];
strcpy(fShortcutsSettings, path.Path());
@ -316,6 +319,7 @@ BDeskWindow::ApplyShortcutPreferences(bool update)
BString command;
if (message.FindString("command", &command) != B_OK)
continue;
BPath path;
bool isInAddons = false;
if (find_directory(B_SYSTEM_ADDONS_DIRECTORY, &path)
@ -353,7 +357,8 @@ BDeskWindow::ApplyShortcutPreferences(bool update)
continue;
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;
if (message.FindInt32("mcidx", 0, &value) == B_OK)
modifiers |= (value != 0 ? B_SHIFT_KEY : 0);
@ -370,6 +375,7 @@ BDeskWindow::ApplyShortcutPreferences(bool update)
if (item != NULL) {
if (item->key != '\0')
RemoveShortcut(item->key, item->modifiers);
item->key = shortcut[0];
item->modifiers = modifiers;
AddOneShortcut(&model, item->key, item->modifiers, this);

View File

@ -269,8 +269,8 @@ BDirMenu::AddDisksIconToMenu(bool atEnd)
BMessage* message = new BMessage(fCommand);
message->AddRef(fEntryName.String(), model.EntryRef());
ModelMenuItem* item = new ModelMenuItem(&model, B_TRANSLATE("Disks"),
message);
ModelMenuItem* item = new ModelMenuItem(&model,
B_TRANSLATE(B_DISKS_DIR_NAME), message);
if (atEnd)
AddItem(item);
else

View File

@ -150,10 +150,10 @@ CachedEntryIterator::CachedEntryIterator(BEntryList* iterator,
CachedEntryIterator::~CachedEntryIterator()
{
delete [] fEntryRefBuffer;
delete[] fEntryRefBuffer;
free(fDirentBuffer);
delete fSortedList;
delete [] fEntryBuffer;
delete[] fEntryBuffer;
}

View File

@ -106,6 +106,7 @@ enum ConflictCheckResult {
kNoConflicts
};
namespace BPrivate {
#undef B_TRANSLATION_CONTEXT
@ -195,6 +196,7 @@ static const char* kFindApplicationStr =
B_TRANSLATE_MARK("Would you like to find a suitable application "
"to open the file?");
// Skip these attributes when copying in Tracker
const char* kSkipAttributes[] = {
kAttrPoseInfo,
@ -202,7 +204,7 @@ const char* kSkipAttributes[] = {
};
// #pragma mark -
// #pragma mark - CopyLoopControl
CopyLoopControl::~CopyLoopControl()
@ -289,7 +291,7 @@ CopyLoopControl::PreserveAttribute(const char*)
}
// #pragma mark -
// #pragma mark - TrackerCopyLoopControl
TrackerCopyLoopControl::TrackerCopyLoopControl()
@ -415,7 +417,7 @@ TrackerCopyLoopControl::SetSourceList(EntryList* list)
}
// #pragma mark -
// #pragma mark - the rest
static BNode*
@ -1061,7 +1063,7 @@ MoveTask(BObjectList<entry_ref>* srcList, BEntry* destEntry, BList* pointList,
delete destEntry;
// delete file location list and all Points within
if (pointList) {
if (pointList != NULL) {
pointList->DoForEach(delete_point);
delete pointList;
}
@ -1069,6 +1071,7 @@ MoveTask(BObjectList<entry_ref>* srcList, BEntry* destEntry, BList* pointList,
return B_OK;
}
class FailWithAlert {
public:
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)
: fString(string),
fName(name),
fError(error)
:
fString(string),
fName(name),
fError(error)
{
}
@ -1100,7 +1104,8 @@ class MoveError {
MoveError(status_t error)
: fError(error)
{ }
{
}
status_t fError;
};
@ -1339,7 +1344,7 @@ LowLevelCopy(BEntry* srcEntry, StatStruct* srcStat, BDirectory* destDir,
CopyAttributes(loopControl, &srcFile, &destFile, buffer, bufsize);
} catch (...) {
delete [] buffer;
delete[] buffer;
throw;
}
@ -1349,7 +1354,7 @@ LowLevelCopy(BEntry* srcEntry, StatStruct* srcStat, BDirectory* destDir,
destFile.SetModificationTime(srcStat->st_mtime);
destFile.SetCreationTime(srcStat->st_crtime);
delete [] buffer;
delete[] buffer;
if (!loopControl->ChecksumFile(&ref)) {
// File no good. Remove and quit.
@ -3443,9 +3448,10 @@ _TrackerLaunchDocuments(const entry_ref* /*doNotUse*/, const BMessage* refs,
BMessage copyOfRefs(*refs);
entry_ref documentRef;
if (copyOfRefs.FindRef("refs", &documentRef) != B_OK)
if (copyOfRefs.FindRef("refs", &documentRef) != B_OK) {
// nothing to launch, we are done
return;
}
status_t error = B_ERROR;
entry_ref app;
@ -3732,23 +3738,25 @@ status_t
FSLaunchUsing(const entry_ref* ref, BMessage* listOfRefs)
{
BMessage temp(B_REFS_RECEIVED);
if (!listOfRefs) {
if (listOfRefs == NULL) {
ASSERT(ref);
temp.AddRef("refs", ref);
listOfRefs = &temp;
}
FSOpenWith(listOfRefs);
return B_OK;
}
status_t
FSLaunchItem(const entry_ref* ref, BMessage* message, int32, bool async)
{
if (message)
if (message != NULL)
message->what = B_REFS_RECEIVED;
status_t result = TrackerLaunch(ref, message, async, true);
delete message;
return result;
}
@ -3759,6 +3767,7 @@ FSLaunchItem(const entry_ref* ref, BMessage* message, int32 workspace)
FSLaunchItem(ref, message, workspace, true);
}
// Get the original path of an entry in the trash
status_t
FSGetOriginalPath(BEntry* entry, BPath* result)
@ -3816,42 +3825,49 @@ FSGetOriginalPath(BEntry* entry, BPath* result)
err = parent.GetPath(&pathParent);
if (err != B_OK)
return err;
err = entry->GetPath(&path);
if (err != B_OK)
return err;
result->Append(path.Path() + strlen(pathParent.Path()) + 1);
// compute the new path by appending the offset of
// the item we are locating, to the original path
// of the parent
return B_OK;
}
directory_which
WellKnowEntryList::Match(const node_ref* node)
{
const WellKnownEntry* result = MatchEntry(node);
if (result)
if (result != NULL)
return result->which;
return (directory_which)-1;
}
const WellKnowEntryList::WellKnownEntry*
WellKnowEntryList::MatchEntry(const node_ref* node)
{
if (!self)
if (self == NULL)
self = new WellKnowEntryList();
return self->MatchEntryCommon(node);
}
const WellKnowEntryList::WellKnownEntry*
WellKnowEntryList::MatchEntryCommon(const node_ref* node)
{
uint32 count = entries.size();
for (uint32 index = 0; index < count; index++)
for (uint32 index = 0; index < count; index++) {
if (*node == entries[index].node)
return &entries[index];
}
return NULL;
}

View File

@ -159,6 +159,8 @@ private:
#define B_DESKTOP_DIR_NAME "Desktop"
#define B_DISKS_DIR_NAME "Disks"
#define B_TRASH_DIR_NAME "Trash"
#ifndef _IMPEXP_TRACKER
#define _IMPEXP_TRACKER

View File

@ -2329,7 +2329,7 @@ FindPanel::RestoreWindowState(const BNode* node)
}
}
}
delete [] buffer;
delete[] buffer;
}
// mark or unmark "All disks"
fVolMenu->ItemAt(0)->SetMarked(searchAllVolumes);

View File

@ -344,27 +344,24 @@ Model::CompareFolderNamesFirst(const Model* compareModel) const
const char*
Model::Name() const
{
static const char* kRootNodeName = B_TRANSLATE_MARK("Disks");
static const char* kTrashNodeName = B_TRANSLATE_MARK("Trash");
static const char* kDesktopNodeName = B_TRANSLATE_MARK("Desktop");
static const char* kRootNodeName = B_TRANSLATE_MARK(B_DISKS_DIR_NAME);
static const char* kTrashNodeName = B_TRANSLATE_MARK(B_TRASH_DIR_NAME);
static const char* kDesktopNodeName = B_TRANSLATE_MARK(B_DESKTOP_DIR_NAME);
switch (fBaseType) {
case kRootNode:
return B_TRANSLATE_NOCOLLECT(kRootNodeName);
case kVolumeNode:
if (fVolumeName)
if (fVolumeName != NULL)
return fVolumeName;
break;
case kTrashNode:
return B_TRANSLATE_NOCOLLECT(kTrashNodeName);
case kDesktopNode:
return B_TRANSLATE_NOCOLLECT(kDesktopNodeName);
default:
break;
}
if (fHasLocalizedName && gLocalizedNamePreferred)
@ -517,6 +514,7 @@ Model::CloseNode()
#ifdef CHECK_OPEN_MODEL_LEAKS
if (writableOpenModelList)
writableOpenModelList->RemoveItem(this);
if (readOnlyOpenModelList)
readOnlyOpenModelList->RemoveItem(this);
#endif
@ -655,7 +653,8 @@ Model::FinishSettingUpType()
fBaseType = kDesktopNode;
}
fMimeType = B_DIR_MIMETYPE; // should use a shared string here
fMimeType = B_DIR_MIMETYPE;
// should use a shared string here
if (IsNodeOpen()) {
BNodeInfo info(fNode);
if (info.GetType(mimeString) == B_OK)
@ -705,7 +704,8 @@ Model::FinishSettingUpType()
}
case kLinkNode:
fMimeType = B_LINK_MIMETYPE; // should use a shared string here
fMimeType = B_LINK_MIMETYPE;
// should use a shared string here
break;
case kExecutableNode:

View File

@ -430,7 +430,7 @@ BPoseView::RestoreColumnState(AttributeStreamNode* node)
}
AddColumnList(&tempSortedList);
}
delete [] buffer;
delete[] buffer;
}
}
SetUpDefaultColumnsIfNeeded();
@ -541,7 +541,7 @@ BPoseView::RestoreState(AttributeStreamNode* node)
fViewState = viewstate;
}
}
delete [] buffer;
delete[] buffer;
}
}
@ -2972,7 +2972,7 @@ BPoseView::ReadExtendedPoseInfo(Model* model)
if (result == kReadAttrFailed
|| size > poseInfo->SizeWithHeadroom()
|| size < poseInfo->Size()) {
delete [] buffer;
delete[] buffer;
return NULL;
}
@ -8047,8 +8047,9 @@ BPoseView::OpenSelection(BPose* clickedPose, int32* index)
if (settings.SingleWindowBrowse()
&& !singleWindowBrowsePose
&& fSelectionList->CountItems() == 1
&& !IsFilePanel())
&& !IsFilePanel()) {
singleWindowBrowsePose = fSelectionList->ItemAt(0);
}
// check if we can use the single window mode
if (settings.SingleWindowBrowse()

View File

@ -385,7 +385,7 @@ BRecentFilesList::~BRecentFilesList()
if (fTypeCount) {
for (int32 index = 0; index < fTypeCount; index++)
free(fTypes[index]);
delete [] fTypes;
delete[] fTypes;
}
}

View File

@ -75,10 +75,10 @@ ArgvParser::ArgvParser(const char* name)
ArgvParser::~ArgvParser()
{
delete [] fBuffer;
delete[] fBuffer;
MakeArgvEmpty();
delete [] fCurrentArgv;
delete[] fCurrentArgv;
if (fFile)
fclose(fFile);

View File

@ -80,7 +80,6 @@ All rights reserved.
#include "PoseView.h"
#include "QueryContainerWindow.h"
#include "StatusWindow.h"
#include "TrackerSettings.h"
#include "TrashWatcher.h"
#include "FunctionObject.h"
#include "TrackerSettings.h"
@ -91,11 +90,13 @@ All rights reserved.
#include "VirtualDirectoryWindow.h"
#include "VolumeWindow.h"
// prototypes for some private kernel calls that will some day be public
#ifndef _IMPEXP_ROOT
# define _IMPEXP_ROOT
#endif
const int32 DEFAULT_MON_NUM = 4096;
// copied from fsil.c
@ -106,6 +107,8 @@ const int8 kOpenWindowHasState = 2;
const uint32 PSV_MAKE_PRINTER_ACTIVE_QUIETLY = 'pmaq';
// from pr_server.h
const int32 kNodeMonitorBumpValue = 512;
namespace BPrivate {
@ -237,8 +240,10 @@ public:
#undef B_TRANSLATION_CONTEXT
#define B_TRANSLATION_CONTEXT "Tracker"
TTracker::TTracker()
: BApplication(kTrackerSignature),
:
BApplication(kTrackerSignature),
fWatchingInterface(new WatchingInterface),
fSettingsWindow(NULL)
{
@ -296,7 +301,7 @@ bool
TTracker::QuitRequested()
{
// don't allow user quitting
if (CurrentMessage() && CurrentMessage()->FindBool("shortcut")) {
if (CurrentMessage() != NULL && CurrentMessage()->FindBool("shortcut")) {
// but allow quitting to hide fSettingsWindow
int32 index = 0;
BWindow* window = NULL;
@ -304,13 +309,15 @@ TTracker::QuitRequested()
if (window == fSettingsWindow) {
if (fSettingsWindow->Lock()) {
if (!fSettingsWindow->IsHidden()
&& fSettingsWindow->IsActive())
&& fSettingsWindow->IsActive()) {
fSettingsWindow->Hide();
}
fSettingsWindow->Unlock();
}
break;
}
}
return false;
}
@ -387,7 +394,7 @@ TTracker::QuitRequested()
message.Flatten(buffer, (ssize_t)size);
deskDir.WriteAttr(kAttrOpenWindows, B_MESSAGE_TYPE, 0, buffer,
size);
delete [] buffer;
delete[] buffer;
} else
deskDir.RemoveAttr(kAttrOpenWindows);
}
@ -734,6 +741,7 @@ TTracker::OpenRef(const entry_ref* ref, const node_ref* nodeToClose,
B_WARNING_ALERT);
alert->SetFlags(alert->Flags() | B_CLOSE_ON_ESCAPE);
alert->Go();
return result;
}
} else
@ -757,8 +765,9 @@ TTracker::OpenRef(const entry_ref* ref, const node_ref* nodeToClose,
BNodeInfo nodeInfo(model->Node());
char preferredApp[B_MIME_TYPE_LENGTH];
if (nodeInfo.GetPreferredApp(preferredApp) == B_OK
&& strcasecmp(preferredApp, kTrackerSignature) != 0)
&& strcasecmp(preferredApp, kTrackerSignature) != 0) {
openAsContainer = false;
}
model->CloseNode();
}
@ -779,27 +788,28 @@ TTracker::OpenRef(const entry_ref* ref, const node_ref* nodeToClose,
delete model;
// run Launch in a separate thread
// and close parent if successfull
if (nodeToClose)
if (nodeToClose) {
Thread::Launch(new EntryAndNodeDoSoonWithMessageFunctor<TTracker,
bool (TTracker::*)(const entry_ref*, const node_ref*,
const BMessage*)>(&TTracker::LaunchAndCloseParentIfOK, this,
ref, nodeToClose, messageToBundle));
else {
} else {
BMessage refsReceived(B_REFS_RECEIVED);
if (messageToBundle) {
refsReceived = *messageToBundle;
refsReceived.what = B_REFS_RECEIVED;
}
refsReceived.AddRef("refs", ref);
if (brokenLinkWithSpecificHandler)
if (brokenLinkWithSpecificHandler) {
// This cruft is to support a hacky workaround for
// double-clicking broken refs for cifs; should get fixed
// in R5
LaunchBrokenLink(brokenLinkPreferredApp.String(), &refsReceived);
else
} else
TrackerLaunch(&refsReceived, true);
}
}
if (nodeToSelect)
SelectChildInParentSoon(ref, nodeToSelect);
@ -875,8 +885,10 @@ TTracker::RefsReceived(BMessage* message)
&type, &count);
if (error != B_OK)
break;
if (strncmp(name, "be:", 3) != 0)
continue;
for (int32 k = 0; k < count; k++) {
const void* data;
ssize_t size;
@ -928,14 +940,15 @@ TTracker::ArgvReceived(int32 argc, char** argv)
for (int32 index = 1; index < argc; index++) {
BEntry entry;
if (entry.SetTo(&workingDirectory, argv[index]) == B_OK
&& entry.GetRef(&ref) == B_OK)
&& entry.GetRef(&ref) == B_OK) {
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);
}
}
}
void
TTracker::OpenContainerWindow(Model* model, BMessage* originalRefsList,
OpenSelector openSelector, uint32 openFlags, bool checkAlreadyOpen,
@ -943,9 +956,10 @@ TTracker::OpenContainerWindow(Model* model, BMessage* originalRefsList,
{
AutoLock<WindowList> lock(&fWindowList);
BContainerWindow* window = NULL;
if (checkAlreadyOpen && openSelector != kRunOpenWithWindow)
if (checkAlreadyOpen && openSelector != kRunOpenWithWindow) {
// find out if window already open
window = FindContainerWindow(model->NodeRef());
}
bool someWindowActivated = false;
@ -966,12 +980,14 @@ TTracker::OpenContainerWindow(Model* model, BMessage* originalRefsList,
if (someWindowActivated) {
delete model;
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) {
BMessage* refList = NULL;
if (!originalRefsList) {
if (originalRefsList == NULL) {
// when passing just a single model, stuff it's entry in a single
// element list anyway
ASSERT(model);
@ -979,9 +995,10 @@ TTracker::OpenContainerWindow(Model* model, BMessage* originalRefsList,
refList->AddRef("refs", model->EntryRef());
delete model;
model = NULL;
} else
} else {
// clone the message, window adopts it for it's own use
refList = new BMessage(*originalRefsList);
}
window = new OpenWithContainerWindow(refList, &fWindowList);
} else if (model->IsRoot()) {
// window will adopt the model
@ -992,16 +1009,17 @@ TTracker::OpenContainerWindow(Model* model, BMessage* originalRefsList,
} else if (model->IsVirtualDirectory()) {
// window will adopt the model
window = new VirtualDirectoryWindow(&fWindowList, openFlags);
} else
} else {
// window will adopt the model
window = new BContainerWindow(&fWindowList, openFlags);
}
if (model)
if (model != NULL)
window->CreatePoseView(model);
BMessage restoreStateMessage(kRestoreState);
if (stateMessage)
if (stateMessage != NULL)
restoreStateMessage.AddMessage("state", stateMessage);
window->PostMessage(&restoreStateMessage);
@ -1066,13 +1084,13 @@ TTracker::GetDeskWindow() const
{
int32 count = fWindowList.CountItems();
for (int32 index = 0; index < count; index++) {
BDeskWindow* window = dynamic_cast<BDeskWindow*>
(fWindowList.ItemAt(index));
if (window)
BDeskWindow* window = dynamic_cast<BDeskWindow*>(
fWindowList.ItemAt(index));
if (window != NULL)
return window;
}
TRESPASS();
return NULL;
}
@ -1083,16 +1101,17 @@ TTracker::FindContainerWindow(const node_ref* node, int32 number) const
ASSERT(fWindowList.IsLocked());
int32 count = fWindowList.CountItems();
int32 windowsFound = 0;
for (int32 index = 0; index < count; index++) {
BContainerWindow* window = dynamic_cast<BContainerWindow*>
(fWindowList.ItemAt(index));
if (window && window->IsShowing(node) && number == windowsFound++)
if (window != NULL && window->IsShowing(node)
&& number == windowsFound++) {
return window;
}
}
return NULL;
}
@ -1113,6 +1132,7 @@ TTracker::FindContainerWindow(const entry_ref* entry, int32 number) const
if (window && window->IsShowing(entry) && number == windowsFound++)
return window;
}
return NULL;
}
@ -1143,9 +1163,10 @@ TTracker::FindParentContainerWindow(const entry_ref* ref) const
for (int32 index = 0; index < count; index++) {
BContainerWindow* window = dynamic_cast<BContainerWindow*>
(fWindowList.ItemAt(index));
if (window && window->IsShowing(&parentRef))
if (window != NULL && window->IsShowing(&parentRef))
return window;
}
return NULL;
}
@ -1159,9 +1180,10 @@ TTracker::FindInfoWindow(const node_ref* node) const
for (int32 index = 0; index < count; index++) {
BInfoWindow* window = dynamic_cast<BInfoWindow*>
(fWindowList.ItemAt(index));
if (window && window->IsShowing(node))
if (window != NULL && window->IsShowing(node))
return window;
}
return NULL;
}
@ -1173,13 +1195,14 @@ TTracker::QueryActiveForDevice(dev_t device)
int32 count = fWindowList.CountItems();
for (int32 index = 0; index < count; index++) {
BQueryContainerWindow* window
= dynamic_cast<BQueryContainerWindow*>(fWindowList.ItemAt(index));
if (window) {
= dynamic_cast<BQueryContainerWindow*>(fWindowList.ItemAt(index));
if (window != NULL) {
AutoLock<BWindow> lock(window);
if (window->ActiveOnDevice(device))
return true;
}
}
return false;
}
@ -1194,7 +1217,7 @@ TTracker::CloseActiveQueryWindows(dev_t device)
for (int32 index = fWindowList.CountItems(); index >= 0; index--) {
BQueryContainerWindow* window
= dynamic_cast<BQueryContainerWindow*>(fWindowList.ItemAt(index));
if (window) {
if (window != NULL) {
AutoLock<BWindow> lock(window);
if (window->ActiveOnDevice(device)) {
window->PostMessage(B_QUIT_REQUESTED);
@ -1202,14 +1225,18 @@ TTracker::CloseActiveQueryWindows(dev_t device)
}
}
}
lock.Unlock();
if (closed)
if (closed) {
for (int32 timeout = 30; timeout; timeout--) {
// wait a bit for windows to fully close
if (!QueryActiveForDevice(device))
return;
snooze(100000);
}
}
}
@ -1218,15 +1245,14 @@ TTracker::SaveAllPoseLocations()
{
int32 numWindows = fWindowList.CountItems();
for (int32 windowIndex = 0; windowIndex < numWindows; windowIndex++) {
BContainerWindow* window
= dynamic_cast<BContainerWindow*>
(fWindowList.ItemAt(windowIndex));
BContainerWindow* window = dynamic_cast<BContainerWindow*>(
fWindowList.ItemAt(windowIndex));
if (window) {
if (window != NULL) {
AutoLock<BWindow> lock(window);
BDeskWindow* deskWindow = dynamic_cast<BDeskWindow*>(window);
if (deskWindow)
if (deskWindow != NULL)
deskWindow->SaveDesktopPoseLocations();
else
window->PoseView()->SavePoseLocations();
@ -1283,11 +1309,13 @@ TTracker::CloseAllInWorkspace()
// count from end to beginning so we can remove items safely
for (int32 index = fWindowList.CountItems() - 1; index >= 0; index--) {
BWindow* window = fWindowList.ItemAt(index);
if (window->Workspaces() & currentWorkspace)
if ((window->Workspaces() & currentWorkspace) != 0) {
// avoid the desktop
if (!dynamic_cast<BDeskWindow*>(window)
&& !dynamic_cast<BStatusWindow*>(window))
if (dynamic_cast<BDeskWindow*>(window) == NULL
&& dynamic_cast<BStatusWindow*>(window) == NULL) {
window->PostMessage(B_QUIT_REQUESTED);
}
}
}
}
@ -1305,18 +1333,21 @@ TTracker::CloseAllWindows()
for (int32 index = 0; index < count; index++) {
BWindow* window = WindowAt(index);
// avoid the desktop
if (!dynamic_cast<BDeskWindow*>(window)
&& !dynamic_cast<BStatusWindow*>(window))
if (dynamic_cast<BDeskWindow*>(window) == NULL
&& dynamic_cast<BStatusWindow*>(window) == NULL) {
window->PostMessage(B_QUIT_REQUESTED);
}
}
// count from end to beginning so we can remove items safely
for (int32 index = fWindowList.CountItems() - 1; index >= 0; index--) {
BWindow* window = fWindowList.ItemAt(index);
if (!dynamic_cast<BDeskWindow*>(window)
&& !dynamic_cast<BStatusWindow*>(window))
// ToDo:
// get rid of the Remove here, BContainerWindow::Quit does it
if (dynamic_cast<BDeskWindow*>(window) == NULL
&& dynamic_cast<BStatusWindow*>(window) == NULL) {
// ToDo: get rid of the Remove here, BContainerWindow::Quit()
// does it
fWindowList.RemoveItemAt(index);
}
}
}
@ -1331,13 +1362,14 @@ TTracker::_OpenPreviouslyOpenedWindows(const char* pathFilter)
BDirectory deskDir;
attr_info attrInfo;
if (FSGetDeskDir(&deskDir) != B_OK
|| deskDir.GetAttrInfo(kAttrOpenWindows, &attrInfo) != B_OK)
|| deskDir.GetAttrInfo(kAttrOpenWindows, &attrInfo) != B_OK) {
return;
}
char* buffer = (char*)malloc((size_t)attrInfo.size);
BMessage message;
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) {
free(buffer);
return;
@ -1351,7 +1383,7 @@ TTracker::_OpenPreviouslyOpenedWindows(const char* pathFilter)
int32 stateMessageCounter = 0;
const char* path;
for (int32 i = 0; message.FindString("paths", i, &path) == B_OK; i++) {
if (strncmp(path, pathFilter, filterLength))
if (strncmp(path, pathFilter, filterLength) != 0)
continue;
BEntry entry(path, true);
@ -1462,12 +1494,14 @@ TTracker::ReadyToRun()
}
}
MimeTypeList*
TTracker::MimeTypes() const
{
return fMimeTypeList;
}
void
TTracker::SelectChildInParentSoon(const entry_ref* parent,
const node_ref* child)
@ -1477,6 +1511,7 @@ TTracker::SelectChildInParentSoon(const entry_ref* parent,
100000, 200000, 5000000);
}
void
TTracker::CloseParentWaitingForChildSoon(const entry_ref* child,
const node_ref* parent)
@ -1486,6 +1521,7 @@ TTracker::CloseParentWaitingForChildSoon(const entry_ref* child,
200000, 100000, 5000000);
}
void
TTracker::SelectPoseAtLocationSoon(node_ref parent, BPoint pointInPose)
{
@ -1494,6 +1530,7 @@ TTracker::SelectPoseAtLocationSoon(node_ref parent, BPoint pointInPose)
100000);
}
void
TTracker::SelectPoseAtLocationInParent(node_ref parent, BPoint pointInPose)
{
@ -1505,6 +1542,7 @@ TTracker::SelectPoseAtLocationInParent(node_ref parent, BPoint pointInPose)
}
}
bool
TTracker::CloseParentWaitingForChild(const entry_ref* child,
const node_ref* parent)
@ -1533,6 +1571,7 @@ TTracker::CloseParentWaitingForChild(const entry_ref* child,
return false;
}
void
TTracker::CloseParent(node_ref parent)
{
@ -1543,6 +1582,7 @@ TTracker::CloseParent(node_ref parent)
CloseParentWindowCommon(FindContainerWindow(&parent));
}
void
TTracker::ShowSettingsWindow()
{
@ -1555,36 +1595,40 @@ TTracker::ShowSettingsWindow()
fSettingsWindow->Show();
else
fSettingsWindow->Activate();
fSettingsWindow->Unlock();
}
}
}
bool
TTracker::CloseParentWindowCommon(BContainerWindow* window)
{
ASSERT(fWindowList.IsLocked());
if (dynamic_cast<BDeskWindow*>(window))
if (dynamic_cast<BDeskWindow*>(window) == NULL) {
// don't close the destop
return false;
}
window->PostMessage(B_QUIT_REQUESTED);
return true;
}
bool
TTracker::SelectChildInParent(const entry_ref* parent, const node_ref* child)
{
AutoLock<WindowList> lock(&fWindowList);
BContainerWindow* window = FindContainerWindow(parent);
if (!window)
if (window == NULL) {
// parent window already closed, give up
return false;
}
AutoLock<BWindow> windowLock(window);
if (windowLock.IsLocked()) {
BPoseView* view = window->PoseView();
int32 index;
@ -1594,10 +1638,10 @@ TTracker::SelectChildInParent(const entry_ref* parent, const node_ref* child)
return true;
}
}
return false;
}
const int32 kNodeMonitorBumpValue = 512;
status_t
TTracker::NeedMoreNodeMonitors()
@ -1612,13 +1656,13 @@ TTracker::NeedMoreNodeMonitors()
fNodeMonitorCount -= kNodeMonitorBumpValue;
return errno;
}
return B_OK;
return B_OK;
}
status_t
TTracker::WatchNode(const node_ref* node, uint32 flags,
BMessenger target)
TTracker::WatchNode(const node_ref* node, uint32 flags, BMessenger target)
{
status_t result = watch_node(node, flags, target);
if (result == B_OK || result != B_NO_MEMORY) {
@ -1631,7 +1675,7 @@ TTracker::WatchNode(const node_ref* node, uint32 flags,
"node monitors\n"));
TTracker* tracker = dynamic_cast<TTracker*>(be_app);
if (!tracker) {
if (tracker == NULL) {
// we are the file panel only, just fail
return result;
}

View File

@ -111,10 +111,8 @@ rgb_color ValueToColor(int32 value)
int32 ColorToValue(rgb_color color)
{
return color.alpha << 24L
| color.red << 16L
| color.green << 8L
| color.blue;
return color.alpha << 24L | color.red << 16L | color.green << 8L
| color.blue;
}
@ -122,15 +120,17 @@ int32 ColorToValue(rgb_color color)
TTrackerState::TTrackerState()
: Settings("TrackerSettings", "Tracker"),
fInited(false),
fSettingsLoaded(false)
:
Settings("TrackerSettings", "Tracker"),
fInited(false),
fSettingsLoaded(false)
{
}
TTrackerState::TTrackerState(const TTrackerState&)
: Settings("", "")
:
Settings("", "")
{
// Placeholder copy constructor to prevent others from accidentally using
// the default copy constructor. Note, the DEBUGGER call is for the off
@ -478,11 +478,13 @@ void
TrackerSettings::RecentCounts(int32* applications, int32* documents,
int32* folders)
{
if (applications)
if (applications != NULL)
*applications = gTrackerState.fRecentApplicationsCount->Value();
if (documents)
if (documents != NULL)
*documents = gTrackerState.fRecentDocumentsCount->Value();
if (folders)
if (folders != NULL)
*folders = gTrackerState.fRecentFoldersCount->Value();
}

View File

@ -298,7 +298,8 @@ TrackerSettingsWindow::_HandleChangedSettingsView()
SettingsItem::SettingsItem(const char* label, SettingsView* view)
: BStringItem(label),
:
BStringItem(label),
fSettingsView(view)
{
}

View File

@ -1238,8 +1238,8 @@ StringToScalar(const char* text)
// no suffix, try plain byte conversion
val = strtoll(buffer, &end, 10);
}
delete[] buffer;
delete [] buffer;
return val;
}