Tracker: style fixes to Tracker class

This commit is contained in:
John Scipione
2014-06-20 21:29:48 -04:00
parent 6d4e243a84
commit d8edc67336
2 changed files with 160 additions and 152 deletions
+27 -22
View File
@@ -91,6 +91,10 @@ All rights reserved.
#include "VolumeWindow.h" #include "VolumeWindow.h"
#undef B_TRANSLATION_CONTEXT
#define B_TRANSLATION_CONTEXT "Tracker"
// 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
@@ -114,6 +118,7 @@ namespace BPrivate {
NodePreloader* gPreloader = NULL; NodePreloader* gPreloader = NULL;
class LaunchLooper : public BLooper { class LaunchLooper : public BLooper {
public: public:
LaunchLooper() LaunchLooper()
@@ -147,7 +152,7 @@ public:
BLooper* gLaunchLooper = NULL; BLooper* gLaunchLooper = NULL;
// #pragma mark - // #pragma mark - functions
void void
@@ -237,10 +242,6 @@ public:
// #pragma mark - TTracker // #pragma mark - TTracker
#undef B_TRANSLATION_CONTEXT
#define B_TRANSLATION_CONTEXT "Tracker"
TTracker::TTracker() TTracker::TTracker()
: :
BApplication(kTrackerSignature), BApplication(kTrackerSignature),
@@ -329,11 +330,11 @@ TTracker::QuitRequested()
// save open windows in a message inside an attribute of the desktop // save open windows in a message inside an attribute of the desktop
int32 count = fWindowList.CountItems(); int32 count = fWindowList.CountItems();
for (int32 i = 0; i < count; i++) { for (int32 i = 0; i < count; i++) {
BContainerWindow* window = dynamic_cast<BContainerWindow*> BContainerWindow* window
(fWindowList.ItemAt(i)); = dynamic_cast<BContainerWindow*>(fWindowList.ItemAt(i));
if (window && window->Lock()) { if (window != NULL && window->Lock()) {
if (window->TargetModel() if (window->TargetModel() != NULL
&& !window->PoseView()->IsDesktopWindow()) { && !window->PoseView()->IsDesktopWindow()) {
if (window->TargetModel()->IsRoot()) if (window->TargetModel()->IsRoot())
message.AddBool("open_disks_window", true); message.AddBool("open_disks_window", true);
@@ -375,6 +376,7 @@ TTracker::QuitRequested()
} }
if (!pathAlreadyExists) if (!pathAlreadyExists)
message.AddString("paths", path.Path()); message.AddString("paths", path.Path());
message.AddInt8(path.Path(), flags); message.AddInt8(path.Path(), flags);
} }
} }
@@ -488,7 +490,6 @@ TTracker::MessageReceived(BMessage* message)
break; break;
#ifdef MOUNT_MENU_IN_DESKBAR #ifdef MOUNT_MENU_IN_DESKBAR
case 'gmtv': case 'gmtv':
{ {
// Someone (probably the deskbar) has requested a list of // Someone (probably the deskbar) has requested a list of
@@ -499,7 +500,6 @@ TTracker::MessageReceived(BMessage* message)
message->SendReply(&reply); message->SendReply(&reply);
break; break;
} }
#endif #endif
case kUnmountVolume: case kUnmountVolume:
@@ -665,18 +665,20 @@ public:
EntryAndNodeDoSoonWithMessageFunctor(FT func, T* target, EntryAndNodeDoSoonWithMessageFunctor(FT func, T* target,
const entry_ref* child, const node_ref* parent, const entry_ref* child, const node_ref* parent,
const BMessage* message) const BMessage* message)
: fFunc(func), :
fFunc(func),
fTarget(target), fTarget(target),
fNode(*parent), fNode(*parent),
fEntry(*child) fEntry(*child)
{ {
fSendMessage = (message != NULL); fSendMessage = message != NULL;
if (message) if (message != NULL)
fMessage = *message; fMessage = *message;
} }
virtual ~EntryAndNodeDoSoonWithMessageFunctor() {} virtual ~EntryAndNodeDoSoonWithMessageFunctor() {}
virtual void operator()() { virtual void operator()()
{
result = (fTarget->*fFunc)(&fEntry, &fNode, result = (fTarget->*fFunc)(&fEntry, &fNode,
fSendMessage ? &fMessage : NULL); fSendMessage ? &fMessage : NULL);
} }
@@ -804,7 +806,8 @@ TTracker::OpenRef(const entry_ref* ref, const node_ref* nodeToClose,
// 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);
} }
@@ -861,7 +864,8 @@ TTracker::RefsReceived(BMessage* message)
TrackerLaunch(&handlingApp, message, true); TrackerLaunch(&handlingApp, message, true);
break; break;
} }
} // fall thru, opening refs by the Tracker as if they were }
// fall thru, opening refs by the Tracker as if they were
// double-clicked // double-clicked
case kOpen: case kOpen:
{ {
@@ -1417,7 +1421,7 @@ TTracker::_OpenPreviouslyOpenedWindows(const char* pathFilter)
} }
} }
// Open disks window if needed // open disks window if needed
if (pathFilter == NULL && TrackerSettings().ShowDisksIcon() if (pathFilter == NULL && TrackerSettings().ShowDisksIcon()
&& message.HasBool("open_disks_window")) { && message.HasBool("open_disks_window")) {
@@ -1537,7 +1541,7 @@ TTracker::SelectPoseAtLocationInParent(node_ref parent, BPoint pointInPose)
{ {
AutoLock<WindowList> lock(&fWindowList); AutoLock<WindowList> lock(&fWindowList);
BContainerWindow* parentWindow = FindContainerWindow(&parent); BContainerWindow* parentWindow = FindContainerWindow(&parent);
if (parentWindow) { if (parentWindow != NULL) {
AutoLock<BWindow> lock(parentWindow); AutoLock<BWindow> lock(parentWindow);
parentWindow->PoseView()->SelectPoseAtLocation(pointInPose); parentWindow->PoseView()->SelectPoseAtLocation(pointInPose);
} }
@@ -1551,7 +1555,7 @@ TTracker::CloseParentWaitingForChild(const entry_ref* child,
AutoLock<WindowList> lock(&fWindowList); AutoLock<WindowList> lock(&fWindowList);
BContainerWindow* parentWindow = FindContainerWindow(parent); BContainerWindow* parentWindow = FindContainerWindow(parent);
if (!parentWindow) { if (parentWindow == NULL) {
// parent window already closed, give up // parent window already closed, give up
return true; return true;
} }
@@ -1564,11 +1568,12 @@ TTracker::CloseParentWaitingForChild(const entry_ref* child,
resolvedChild = *child; resolvedChild = *child;
BContainerWindow* window = FindContainerWindow(&resolvedChild); BContainerWindow* window = FindContainerWindow(&resolvedChild);
if (window) { if (window != NULL) {
AutoLock<BWindow> lock(window); AutoLock<BWindow> lock(window);
if (!window->IsHidden()) if (!window->IsHidden())
return CloseParentWindowCommon(parentWindow); return CloseParentWindowCommon(parentWindow);
} }
return false; return false;
} }
@@ -1634,7 +1639,7 @@ TTracker::SelectChildInParent(const entry_ref* parent, const node_ref* child)
BPoseView* view = window->PoseView(); BPoseView* view = window->PoseView();
int32 index; int32 index;
BPose* pose = view->FindPose(child, &index); BPose* pose = view->FindPose(child, &index);
if (pose) { if (pose != NULL) {
view->SelectPose(pose, index); view->SelectPose(pose, index);
return true; return true;
} }
+4 -1
View File
@@ -45,6 +45,7 @@ All rights reserved.
#include "tracker_private.h" #include "tracker_private.h"
namespace BPrivate { namespace BPrivate {
class BClipboardRefsWatcher; class BClipboardRefsWatcher;
@@ -61,6 +62,7 @@ class HexScalarValueSetting;
class TaskLoop; class TaskLoop;
class TrackerSettingsWindow; class TrackerSettingsWindow;
typedef LockingList<BWindow> WindowList; typedef LockingList<BWindow> WindowList;
// this is because MW can't handle nested templates // this is because MW can't handle nested templates
@@ -69,11 +71,11 @@ const uint32 kNextSpecifier = 'snxt';
const uint32 kPreviousSpecifier = 'sprv'; const uint32 kPreviousSpecifier = 'sprv';
const uint32 B_ENTRY_SPECIFIER = 'sref'; const uint32 B_ENTRY_SPECIFIER = 'sref';
#define kPropertyEntry "Entry" #define kPropertyEntry "Entry"
#define kPropertySelection "Selection" #define kPropertySelection "Selection"
class TTracker : public BApplication { class TTracker : public BApplication {
public: public:
TTracker(); TTracker();
@@ -249,4 +251,5 @@ TTracker::ClipboardRefsWatcher() const
using namespace BPrivate; using namespace BPrivate;
#endif // _TRACKER_H #endif // _TRACKER_H