Style changes in Tracker, no functional change.

Manual whitespace cleanup
Change instances of const char * to const char*
Convert /* */ C style comments to // C++ style comments
This commit is contained in:
John Scipione
2012-07-27 20:46:47 -04:00
parent 8fe9f8b2d0
commit b05aa8b5b1
135 changed files with 6806 additions and 6302 deletions
+78 -18
View File
@@ -32,11 +32,13 @@ names are registered trademarks or trademarks of their respective holders.
All rights reserved.
*/
#include "AttributeStream.h"
#include <Debug.h>
#include <Node.h>
// ToDo:
// lazy Rewind from Drive, only if data is available
// BMessage node
@@ -49,6 +51,7 @@ AttributeInfo::AttributeInfo(const AttributeInfo &cloneThis)
{
}
AttributeInfo::AttributeInfo(const char* name, attr_info info)
: fName(name),
fInfo(info)
@@ -162,6 +165,7 @@ AttributeStreamNode::Read(const char *name, const char *foreignName, uint32 type
return fReadFrom->Read(name, foreignName, type, size, buffer, swapFunc);
}
off_t
AttributeStreamNode::Write(const char* name, const char* foreignName, uint32 type,
off_t size, const void* buffer)
@@ -172,6 +176,7 @@ AttributeStreamNode::Write(const char *name, const char *foreignName, uint32 typ
return fWriteTo->Write(name, foreignName, type, size, buffer);
}
bool
AttributeStreamNode::Drive()
{
@@ -183,6 +188,7 @@ AttributeStreamNode::Drive()
return true;
}
const AttributeInfo*
AttributeStreamNode::Next()
{
@@ -192,6 +198,7 @@ AttributeStreamNode::Next()
return NULL;
}
const char*
AttributeStreamNode::Get()
{
@@ -202,6 +209,7 @@ AttributeStreamNode::Get()
return fReadFrom->Get();
}
bool
AttributeStreamNode::Fill(char* buffer) const
{
@@ -209,6 +217,7 @@ AttributeStreamNode::Fill(char *buffer) const
return fReadFrom->Fill(buffer);
}
bool
AttributeStreamNode::Start()
{
@@ -219,6 +228,7 @@ AttributeStreamNode::Start()
return fWriteTo->Start();
}
void
AttributeStreamNode::Detach()
{
@@ -246,6 +256,7 @@ AttributeStreamFileNode::AttributeStreamFileNode(BNode *node)
ASSERT(fNode);
}
void
AttributeStreamFileNode::Rewind()
{
@@ -253,6 +264,7 @@ AttributeStreamFileNode::Rewind()
fNode->RewindAttrs();
}
void
AttributeStreamFileNode::SetTo(BNode* node)
{
@@ -274,6 +286,7 @@ AttributeStreamFileNode::Contains(const char *name, uint32 type)
return info.size;
}
off_t
AttributeStreamFileNode::Read(const char* name, const char* foreignName, uint32 type,
off_t size, void* buffer, void (*swapFunc)(void*))
@@ -291,6 +304,7 @@ AttributeStreamFileNode::Read(const char *name, const char *foreignName, uint32
return 0;
}
off_t
AttributeStreamFileNode::Write(const char* name, const char* foreignName, uint32 type,
off_t size, const void* buffer)
@@ -306,6 +320,7 @@ AttributeStreamFileNode::Write(const char *name, const char *foreignName, uint32
return result;
}
bool
AttributeStreamFileNode::Drive()
{
@@ -324,6 +339,7 @@ AttributeStreamFileNode::Drive()
return true;
}
const char*
AttributeStreamFileNode::Get()
{
@@ -332,6 +348,7 @@ AttributeStreamFileNode::Get()
return NULL;
}
bool
AttributeStreamFileNode::Fill(char* buffer) const
{
@@ -340,6 +357,7 @@ AttributeStreamFileNode::Fill(char *buffer) const
(size_t)fCurrentAttr.Size()) == (ssize_t)fCurrentAttr.Size();
}
const AttributeInfo*
AttributeStreamFileNode::Next()
{
@@ -364,12 +382,14 @@ AttributeStreamMemoryNode::AttributeStreamMemoryNode()
{
}
void
AttributeStreamMemoryNode::MakeEmpty()
{
fAttributes.MakeEmpty();
}
void
AttributeStreamMemoryNode::Rewind()
{
@@ -377,6 +397,7 @@ AttributeStreamMemoryNode::Rewind()
fCurrentIndex = -1;
}
int32
AttributeStreamMemoryNode::Find(const char* name, uint32 type) const
{
@@ -389,6 +410,7 @@ AttributeStreamMemoryNode::Find(const char *name, uint32 type) const
return -1;
}
off_t
AttributeStreamMemoryNode::Contains(const char* name, uint32 type)
{
@@ -429,6 +451,7 @@ AttributeStreamMemoryNode::Read(const char *name, const char *DEBUG_ONLY(foreign
return attrNode->fAttr.Size();
}
off_t
AttributeStreamMemoryNode::Write(const char* name, const char*, uint32 type,
off_t size, const void* buffer)
@@ -441,6 +464,7 @@ AttributeStreamMemoryNode::Write(const char *name, const char *, uint32 type,
return size;
}
bool
AttributeStreamMemoryNode::Drive()
{
@@ -453,6 +477,7 @@ AttributeStreamMemoryNode::Drive()
return true;
}
AttributeStreamMemoryNode::AttrNode*
AttributeStreamMemoryNode::BufferingGet(const char* name, uint32 type, off_t size)
{
@@ -481,6 +506,7 @@ AttributeStreamMemoryNode::BufferingGet()
return BufferingGet(attr->Name(), attr->Type(), attr->Size());
}
const AttributeInfo*
AttributeStreamMemoryNode::Next()
{
@@ -495,6 +521,7 @@ AttributeStreamMemoryNode::Next()
return &fAttributes.ItemAt(++fCurrentIndex)->fAttr;
}
const char*
AttributeStreamMemoryNode::Get()
{
@@ -502,6 +529,7 @@ AttributeStreamMemoryNode::Get()
return fAttributes.ItemAt(fCurrentIndex)->fData;
}
bool
AttributeStreamMemoryNode::Fill(char* buffer) const
{
@@ -513,14 +541,15 @@ AttributeStreamMemoryNode::Fill(char *buffer) const
}
AttributeStreamTemplateNode::AttributeStreamTemplateNode(const AttributeTemplate *
attrTemplates, int32 count)
AttributeStreamTemplateNode::AttributeStreamTemplateNode(
const AttributeTemplate* attrTemplates, int32 count)
: fAttributes(attrTemplates),
fCurrentIndex(-1),
fCount(count)
{
}
off_t
AttributeStreamTemplateNode::Contains(const char* name, uint32 type)
{
@@ -531,12 +560,14 @@ AttributeStreamTemplateNode::Contains(const char *name, uint32 type)
return fAttributes[index].fSize;
}
void
AttributeStreamTemplateNode::Rewind()
{
fCurrentIndex = -1;
}
const AttributeInfo*
AttributeStreamTemplateNode::Next()
{
@@ -546,11 +577,13 @@ AttributeStreamTemplateNode::Next()
++fCurrentIndex;
fCurrentAttr.SetTo(fAttributes[fCurrentIndex].fAttributeName,
fAttributes[fCurrentIndex].fAttributeType, fAttributes[fCurrentIndex].fSize);
fAttributes[fCurrentIndex].fAttributeType,
fAttributes[fCurrentIndex].fSize);
return &fCurrentAttr;
}
const char*
AttributeStreamTemplateNode::Get()
{
@@ -558,26 +591,32 @@ AttributeStreamTemplateNode::Get()
return fAttributes[fCurrentIndex].fBits;
}
bool
AttributeStreamTemplateNode::Fill(char* buffer) const
{
ASSERT(fCurrentIndex < fCount);
memcpy(buffer, fAttributes[fCurrentIndex].fBits, (size_t)fAttributes[fCurrentIndex].fSize);
memcpy(buffer, fAttributes[fCurrentIndex].fBits,
(size_t)fAttributes[fCurrentIndex].fSize);
return true;
}
int32
AttributeStreamTemplateNode::Find(const char* name, uint32 type) const
{
for (int32 index = 0; index < fCount; index++)
for (int32 index = 0; index < fCount; index++) {
if (fAttributes[index].fAttributeType == type &&
strcmp(name, fAttributes[index].fAttributeName) == 0)
strcmp(name, fAttributes[index].fAttributeName) == 0) {
return index;
}
}
return -1;
}
bool
AttributeStreamFilterNode::Reject(const char*, uint32, off_t)
{
@@ -585,6 +624,7 @@ AttributeStreamFilterNode::Reject(const char *, uint32 , off_t )
return false;
}
const AttributeInfo*
AttributeStreamFilterNode::Next()
{
@@ -602,6 +642,7 @@ AttributeStreamFilterNode::Next()
return NULL;
}
off_t
AttributeStreamFilterNode::Contains(const char* name, uint32 type)
{
@@ -616,6 +657,7 @@ AttributeStreamFilterNode::Contains(const char *name, uint32 type)
return 0;
}
off_t
AttributeStreamFilterNode::Read(const char* name, const char* foreignName, uint32 type,
off_t size, void* buffer, void (*swapFunc)(void*))
@@ -629,6 +671,7 @@ AttributeStreamFilterNode::Read(const char *name, const char *foreignName, uint3
return 0;
}
off_t
AttributeStreamFilterNode::Write(const char* name, const char* foreignName, uint32 type,
off_t size, const void* buffer)
@@ -648,6 +691,7 @@ NamesToAcceptAttrFilter::NamesToAcceptAttrFilter(const char **nameList)
{
}
bool
NamesToAcceptAttrFilter::Reject(const char* name, uint32 , off_t )
{
@@ -660,13 +704,16 @@ NamesToAcceptAttrFilter::Reject(const char *name, uint32 , off_t )
return false;
}
}
//PRINT(("filter rejecting %s\n", name));
return true;
}
SelectiveAttributeTransformer::SelectiveAttributeTransformer(const char *attributeName,
bool (*transformFunc)(const char * , uint32 , off_t, void *, void *), void *params)
SelectiveAttributeTransformer::SelectiveAttributeTransformer(
const char* attributeName,
bool (*transformFunc)(const char* , uint32 , off_t, void*, void*),
void* params)
: fAttributeNameToTransform(attributeName),
fTransformFunc(transformFunc),
fTransformParams(params),
@@ -677,15 +724,20 @@ SelectiveAttributeTransformer::SelectiveAttributeTransformer(const char *attribu
SelectiveAttributeTransformer::~SelectiveAttributeTransformer()
{
for (int32 index = fTransformedBuffers.CountItems() - 1; index >= 0; index--)
for (int32 index = fTransformedBuffers.CountItems() - 1; index >= 0;
index--) {
delete [] fTransformedBuffers.ItemAt(index);
}
}
void
SelectiveAttributeTransformer::Rewind()
{
for (int32 index = fTransformedBuffers.CountItems() - 1; index >= 0; index--)
for (int32 index = fTransformedBuffers.CountItems() - 1; index >= 0;
index--) {
delete [] fTransformedBuffers.ItemAt(index);
}
fTransformedBuffers.MakeEmpty();
}
@@ -698,7 +750,8 @@ SelectiveAttributeTransformer::Read(const char *name, const char *foreignName,
if (!fReadFrom)
return 0;
off_t result = fReadFrom->Read(name, foreignName, type, size, buffer, swapFunc);
off_t result = fReadFrom->Read(name, foreignName, type, size, buffer,
swapFunc);
if (WillTransform(name, type, size, (const char*)buffer))
ApplyTransformer(name, type, size, (char*)buffer);
@@ -706,6 +759,7 @@ SelectiveAttributeTransformer::Read(const char *name, const char *foreignName,
return result;
}
bool
SelectiveAttributeTransformer::WillTransform(const char* name, uint32, off_t,
const char*) const
@@ -713,16 +767,17 @@ SelectiveAttributeTransformer::WillTransform(const char *name, uint32 , off_t ,
return strcmp(name, fAttributeNameToTransform) == 0;
}
bool
SelectiveAttributeTransformer::ApplyTransformer(const char *name, uint32 type, off_t size,
char *data)
SelectiveAttributeTransformer::ApplyTransformer(const char* name, uint32 type,
off_t size, char* data)
{
return (fTransformFunc)(name, type, size, data, fTransformParams);
}
char*
SelectiveAttributeTransformer::CopyAndApplyTransformer(const char *name, uint32 type,
off_t size, const char *data)
SelectiveAttributeTransformer::CopyAndApplyTransformer(const char* name,
uint32 type, off_t size, const char* data)
{
char* result = NULL;
if (data) {
@@ -734,9 +789,11 @@ SelectiveAttributeTransformer::CopyAndApplyTransformer(const char *name, uint32
delete [] result;
return NULL;
}
return result;
}
const AttributeInfo*
SelectiveAttributeTransformer::Next()
{
@@ -748,6 +805,7 @@ SelectiveAttributeTransformer::Next()
return result;
}
const char*
SelectiveAttributeTransformer::Get()
{
@@ -756,11 +814,13 @@ SelectiveAttributeTransformer::Get()
const char* result = fReadFrom->Get();
if (!WillTransform(fCurrentAttr.Name(), fCurrentAttr.Type(), fCurrentAttr.Size(), result))
if (!WillTransform(fCurrentAttr.Name(), fCurrentAttr.Type(),
fCurrentAttr.Size(), result)) {
return result;
}
char *transformedData = CopyAndApplyTransformer(fCurrentAttr.Name(), fCurrentAttr.Type(),
fCurrentAttr.Size(), result);
char* transformedData = CopyAndApplyTransformer(fCurrentAttr.Name(),
fCurrentAttr.Type(), fCurrentAttr.Size(), result);
// enlist for proper disposal when our job is done
if (transformedData) {
+26 -12
View File
@@ -46,11 +46,10 @@ All rights reserved.
//
// In addition to the whacky (but usefull) << syntax, calls like Read, Write are also
// available
#ifndef __ATTRIBUTE_STREAM__
#define __ATTRIBUTE_STREAM__
#include <Node.h>
#include <Rect.h>
#include <String.h>
@@ -60,6 +59,7 @@ All rights reserved.
#include "ObjectList.h"
namespace BPrivate {
struct AttributeTemplate {
@@ -92,6 +92,7 @@ private:
attr_info fInfo;
};
class AttributeStreamNode {
public:
AttributeStreamNode();
@@ -120,7 +121,6 @@ public:
const void* buffer);
// write to this node
// work calls
virtual bool Drive();
// node at the head of the stream makes the entire stream
@@ -152,6 +152,7 @@ protected:
AttributeStreamNode* fWriteTo;
};
class AttributeStreamFileNode : public AttributeStreamNode {
// handles reading and writing attributes to and from the
// stream
@@ -162,10 +163,10 @@ public:
virtual void MakeEmpty();
virtual void Rewind();
virtual off_t Contains(const char* name, uint32 type);
virtual off_t Read(const char *name, const char *foreignName, uint32 type, off_t size,
void *buffer, void (*swapFunc)(void *) = 0);
virtual off_t Write(const char *name, const char *foreignName, uint32 type, off_t size,
const void *buffer);
virtual off_t Read(const char* name, const char* foreignName, uint32 type,
off_t size, void* buffer, void (*swapFunc)(void*) = 0);
virtual off_t Write(const char* name, const char* foreignName, uint32 type,
off_t size, const void* buffer);
void SetTo(BNode*);
@@ -189,6 +190,7 @@ private:
typedef AttributeStreamNode _inherited;
};
class AttributeStreamMemoryNode : public AttributeStreamNode {
// in memory attribute buffer; can be both target of writing and source
// of reading at the same time
@@ -203,7 +205,6 @@ public:
const void* buffer);
protected:
virtual bool CanFeed() const { return true; }
virtual void Rewind();
virtual bool Drive();
@@ -234,13 +235,13 @@ protected:
int32 Find(const char* name, uint32 type) const;
private:
BObjectList<AttrNode> fAttributes;
int32 fCurrentIndex;
typedef AttributeStreamNode _inherited;
};
class AttributeStreamTemplateNode : public AttributeStreamNode {
// in read-only memory attribute source
// can only be used as a source for Next and Get
@@ -250,7 +251,6 @@ public:
virtual off_t Contains(const char* name, uint32 type);
protected:
virtual bool CanFeed() const { return true; }
virtual void Rewind();
virtual const AttributeInfo* Next();
@@ -268,6 +268,7 @@ private:
typedef AttributeStreamNode _inherited;
};
class AttributeStreamFilterNode : public AttributeStreamNode {
// filter node may not pass thru specified attributes
public:
@@ -288,6 +289,7 @@ private:
typedef AttributeStreamNode _inherited;
};
class NamesToAcceptAttrFilter : public AttributeStreamFilterNode {
// filter node that only passes thru attributes that match
// a list of names
@@ -301,6 +303,7 @@ private:
const char** fNameList;
};
class SelectiveAttributeTransformer : public AttributeStreamNode {
// node applies a transformation on specified attributes
public:
@@ -335,12 +338,13 @@ private:
typedef AttributeStreamNode _inherited;
};
template <class Type>
class AttributeStreamConstValue : public AttributeStreamNode {
public:
AttributeStreamConstValue(const char* name, uint32 attributeType, Type value);
protected:
protected:
virtual bool CanFeed() const { return true; }
virtual void Rewind() { fRewound = true; }
virtual const AttributeInfo* Next();
@@ -357,6 +361,7 @@ private:
typedef AttributeStreamNode _inherited;
};
template<class Type>
AttributeStreamConstValue<Type>::AttributeStreamConstValue(const char* name,
uint32 attributeType, Type value)
@@ -366,6 +371,7 @@ AttributeStreamConstValue<Type>::AttributeStreamConstValue(const char *name,
{
}
template<class Type>
const AttributeInfo*
AttributeStreamConstValue<Type>::Next()
@@ -377,6 +383,7 @@ AttributeStreamConstValue<Type>::Next()
return &fAttr;
}
template<class Type>
const char*
AttributeStreamConstValue<Type>::Get()
@@ -384,6 +391,7 @@ AttributeStreamConstValue<Type>::Get()
return (const char*)&fValue;
}
template<class Type>
bool
AttributeStreamConstValue<Type>::Fill(char* buffer) const
@@ -392,6 +400,7 @@ AttributeStreamConstValue<Type>::Fill(char *buffer) const
return true;
}
template<class Type>
int32
AttributeStreamConstValue<Type>::Find(const char* name, uint32 type) const
@@ -402,6 +411,7 @@ AttributeStreamConstValue<Type>::Find(const char *name, uint32 type) const
return -1;
}
class AttributeStreamBoolValue : public AttributeStreamConstValue<bool> {
public:
AttributeStreamBoolValue(const char* name, bool value)
@@ -409,6 +419,7 @@ public:
{}
};
class AttributeStreamInt32Value : public AttributeStreamConstValue<int32> {
public:
AttributeStreamInt32Value(const char* name, int32 value)
@@ -416,6 +427,7 @@ public:
{}
};
class AttributeStreamInt64Value : public AttributeStreamConstValue<int64> {
public:
AttributeStreamInt64Value(const char* name, int64 value)
@@ -423,6 +435,7 @@ public:
{}
};
class AttributeStreamRectValue : public AttributeStreamConstValue<BRect> {
public:
AttributeStreamRectValue(const char* name, BRect value)
@@ -430,6 +443,7 @@ public:
{}
};
class AttributeStreamFloatValue : public AttributeStreamConstValue<float> {
public:
AttributeStreamFloatValue(const char* name, float value)
@@ -437,7 +451,7 @@ public:
{}
};
}
} // namespace BPrivate
using namespace BPrivate;
+1 -1
View File
@@ -31,10 +31,10 @@ of Be Incorporated in the United States and other countries. Other brand product
names are registered trademarks or trademarks of their respective holders.
All rights reserved.
*/
#ifndef _ATTRIBUTES_H
#define _ATTRIBUTES_H
namespace BPrivate {
// viewable attributes
+1
View File
@@ -32,6 +32,7 @@ names are registered trademarks or trademarks of their respective holders.
All rights reserved.
*/
#include "AutoMounterSettings.h"
#include <Alert.h>
-1
View File
@@ -31,7 +31,6 @@ of Be Incorporated in the United States and other countries. Other brand product
names are registered trademarks or trademarks of their respective holders.
All rights reserved.
*/
#ifndef AUTOMOUNTER_SETTINGS_H
#define AUTOMOUNTER_SETTINGS_H
+1 -1
View File
@@ -68,4 +68,4 @@ enum {
const int32 B_RESTORE_BACKGROUND_IMAGE = 'Tbgr'; // force a Tracker window to
// use a new background image
#endif /* _TRACKER_BACKGROUND_H */
#endif // _TRACKER_BACKGROUND_H
+4 -2
View File
@@ -33,7 +33,7 @@ All rights reserved.
*/
// Classes used for setting up and managing background images
//
#include <Bitmap.h>
#include <ControlLook.h>
@@ -50,6 +50,7 @@ All rights reserved.
#include "Commands.h"
#include "PoseView.h"
namespace BPrivate {
const char* kBackgroundImageInfo = B_BACKGROUND_INFO;
@@ -59,7 +60,8 @@ const char *kBackgroundImageInfoMode = B_BACKGROUND_MODE;
const char* kBackgroundImageInfoWorkspaces = B_BACKGROUND_WORKSPACES;
const char* kBackgroundImageInfoPath = B_BACKGROUND_IMAGE;
}
} // namespace BPrivate
BackgroundImage*
BackgroundImage::GetBackgroundImage(const BNode* node, bool isDesktop)
+5 -5
View File
@@ -31,16 +31,17 @@ of Be Incorporated in the United States and other countries. Other brand product
names are registered trademarks or trademarks of their respective holders.
All rights reserved.
*/
// Classes used for setting up and managing background images
//
#ifndef __BACKGROUND_IMAGE__
#define __BACKGROUND_IMAGE__
// Classes used for setting up and managing background images
#include <String.h>
#include "ObjectList.h"
class BNode;
class BView;
class BBitmap;
@@ -127,7 +128,6 @@ private:
BObjectList<BackgroundImageInfo> fBitmapForWorkspaceList;
};
} // namespace BPrivate
using namespace BPrivate;
+5 -2
View File
@@ -199,10 +199,13 @@ BImageResources::find_image(void *memAddr) const
image_info info;
int32 cookie = 0;
while (get_next_image_info(0, &cookie, &info) == B_OK)
if ((info.text <= memAddr && (((uint8 *)info.text)+info.text_size) > memAddr)
||(info.data <= memAddr && (((uint8 *)info.data)+info.data_size) > memAddr))
if ((info.text <= memAddr
&& (((uint8*)info.text)+info.text_size) > memAddr)
|| (info.data <= memAddr
&& (((uint8*)info.data)+info.data_size) > memAddr)) {
// Found the image.
return info.id;
}
return -1;
}
+2 -2
View File
@@ -31,7 +31,6 @@ of Be Incorporated in the United States and other countries. Other brand product
names are registered trademarks or trademarks of their respective holders.
All rights reserved.
*/
#ifndef __BITS__
#define __BITS__
@@ -43,6 +42,7 @@ All rights reserved.
#include "TrackerIcons.h"
class BBitmap;
namespace BPrivate {
@@ -93,13 +93,13 @@ private:
};
extern
#ifdef _IMPEXP_TRACKER
_IMPEXP_TRACKER
#endif
BImageResources* GetTrackerResources();
} // namespace BPrivate
using namespace BPrivate;
+1 -1
View File
@@ -31,10 +31,10 @@ of Be Incorporated in the United States and other countries. Other brand product
names are registered trademarks or trademarks of their respective holders.
All rights reserved.
*/
#ifndef _COMMANDS_H
#define _COMMANDS_H
#include "PublicCommands.h"
#include <MountServer.h>
+14 -12
View File
@@ -493,11 +493,10 @@ DraggableContainerIcon::FrameMoved(BPoint /*newLocation*/)
bar->GetPreferredSize(&width, &height);
bar->SetResizingMode(resizingMode);
/*
BMenuItem* item = bar->ItemAt(bar->CountItems() - 1);
if (item == NULL)
return;
*/
//BMenuItem* item = bar->ItemAt(bar->CountItems() - 1);
//if (item == NULL)
// return;
// BeOS shifts the coordinates for hidden views, so we cannot
// use them to decide if we should be visible or not...
@@ -1668,7 +1667,7 @@ BContainerWindow::MessageReceived(BMessage *message)
FSUndo();
break;
//case B_REDO: /* only defined in Dano/Zeta/OpenBeOS */
//case B_REDO: // only defined in Dano/Zeta/OpenBeOS
case kRedo:
FSRedo();
break;
@@ -2372,8 +2371,10 @@ BContainerWindow::PopulateMoveCopyNavMenu(BNavMenu *navMenu, uint32 what,
void
BContainerWindow::SetupMoveCopyMenus(const entry_ref* item_ref, BMenu* parent)
{
if (IsTrash() || InTrash() || IsPrintersDir() || !fMoveToItem || !fCopyToItem || !fCreateLinkItem)
if (IsTrash() || InTrash() || IsPrintersDir() || !fMoveToItem
|| !fCopyToItem || !fCreateLinkItem) {
return;
}
// Grab the modifiers state since we use it twice
uint32 modifierKeys = modifiers();
@@ -3340,9 +3341,8 @@ BContainerWindow::AddMimeTypesToMenu()
}
/*! Adds a menu for a specific MIME type if it doesn't exist already.
Returns the menu, if it existed or not.
*/
// Adds a menu for a specific MIME type if it doesn't exist already.
// Returns the menu, if it existed or not.
BMenu*
BContainerWindow::AddMimeMenu(const BMimeType& mimeType, bool isSuperType,
BMenu* menu, int32 start)
@@ -4170,8 +4170,10 @@ WindowStateNodeOpener::SetTo(Model *model, bool forWriting)
fNode = NULL;
fStreamNode = NULL;
fModelOpener = new ModelNodeLazyOpener(model, forWriting, false);
if (fModelOpener->IsOpen(forWriting))
fStreamNode = new AttributeStreamFileNode(fModelOpener->TargetModel()->Node());
if (fModelOpener->IsOpen(forWriting)) {
fStreamNode = new AttributeStreamFileNode(
fModelOpener->TargetModel()->Node());
}
}
+1 -1
View File
@@ -31,10 +31,10 @@ of Be Incorporated in the United States and other countries. Other brand product
names are registered trademarks or trademarks of their respective holders.
All rights reserved.
*/
#ifndef _CONTAINER_WINDOW_H
#define _CONTAINER_WINDOW_H
#include <Window.h>
#include "LockingList.h"
+2 -1
View File
@@ -31,13 +31,14 @@ of Be Incorporated in the United States and other countries. Other brand product
names are registered trademarks or trademarks of their respective holders.
All rights reserved.
*/
#ifndef __COUNT_VIEW__
#define __COUNT_VIEW__
#include <String.h>
#include <View.h>
namespace BPrivate {
class BPoseView;
+1
View File
@@ -8,6 +8,7 @@
#ifndef CURSORS_H
#define CURSORS_H
// Exported with Wonderbrush from haiku/data/artwork/cursors/Overlays_Tracker
// TODO: Don't use these, there are new cursors, which you can use by ID.
// (Except for the kMoveCursor, which has different meaning here.)
+3 -1
View File
@@ -31,16 +31,17 @@ of Be Incorporated in the United States and other countries. Other brand product
names are registered trademarks or trademarks of their respective holders.
All rights reserved.
*/
#ifndef _DESK_WINDOW_H
#define _DESK_WINDOW_H
#include <Shelf.h>
#include <set>
#include "ContainerWindow.h"
#include "DesktopPoseView.h"
class BPopUpMenu;
namespace BPrivate {
@@ -95,6 +96,7 @@ private:
typedef BContainerWindow _inherited;
};
inline DesktopPoseView*
BDeskWindow::PoseView() const
{
+6 -4
View File
@@ -34,21 +34,24 @@ All rights reserved.
// DesktopPoseView adds support for displaying integrated desktops
// from multiple volumes to BPoseView
#ifndef _DESKTOP_POSE_VIEW_H
#define _DESKTOP_POSE_VIEW_H
#include "EntryIterator.h"
#include "PoseView.h"
namespace BPrivate {
class DesktopPoseView : public BPoseView {
// overrides BPoseView to add desktop-view specific code
public:
DesktopPoseView(Model *, BRect, uint32 viewMode, uint32 resizeMask = B_FOLLOW_ALL);
DesktopPoseView(Model*, BRect, uint32 viewMode,
uint32 resizeMask = B_FOLLOW_ALL);
static EntryListBase *InitDesktopDirentIterator(BPoseView *, const entry_ref *);
static EntryListBase* InitDesktopDirentIterator(BPoseView*,
const entry_ref*);
void ShowVolumes(bool visible, bool showShared);
@@ -72,7 +75,6 @@ protected:
private:
typedef BPoseView _inherited;
};
-1
View File
@@ -595,4 +595,3 @@ PaneSwitch::DrawInState(PaneSwitch::State state)
break;
}
}
+3 -1
View File
@@ -31,14 +31,15 @@ of Be Incorporated in the United States and other countries. Other brand product
names are registered trademarks or trademarks of their respective holders.
All rights reserved.
*/
#ifndef _DIALOG_PANE_
#define _DIALOG_PANE_
#include <Control.h>
#include "ObjectList.h"
namespace BPrivate {
class ViewList : public BObjectList<BView> {
@@ -51,6 +52,7 @@ public:
void AddAll(BView* toParent);
};
class DialogPane : public BView {
// dialog with collapsible panes
public:
+4 -3
View File
@@ -139,7 +139,8 @@ BDirMenu::Populate(const BEntry *startEntry, BWindow *originatingWindow,
// if we're at the root directory skip "mnt" and go straight to "/"
BDirectory dir(&entry);
if (!showDesktop && dir.InitCheck() == B_OK && dir.IsRootDirectory()) {
if (!showDesktop && dir.InitCheck() == B_OK
&& dir.IsRootDirectory()) {
hitRoot = true;
parent.SetTo("/");
}
@@ -176,7 +177,8 @@ BDirMenu::Populate(const BEntry *startEntry, BWindow *originatingWindow,
if (!select)
return;
ModelMenuItem *item = dynamic_cast<ModelMenuItem *>(ItemAt(CountItems() - 1));
ModelMenuItem* item
= dynamic_cast<ModelMenuItem*>(ItemAt(CountItems() - 1));
if (item) {
item->SetMarked(true);
if (menu) {
@@ -269,4 +271,3 @@ BDirMenu::AddDisksIconToMenu(bool atEnd)
else
AddItem(item, 0);
}
+3 -1
View File
@@ -31,13 +31,14 @@ of Be Incorporated in the United States and other countries. Other brand product
names are registered trademarks or trademarks of their respective holders.
All rights reserved.
*/
#ifndef DIR_MENU_H
#define DIR_MENU_H
#include <PopUpMenu.h>
#include <String.h>
class MenuBar;
namespace BPrivate {
@@ -64,6 +65,7 @@ private:
BString fEntryName;
};
inline void
BDirMenu::SetMenuBar(BMenuBar* bar)
{
-1
View File
@@ -550,4 +550,3 @@ CachedEntryIteratorList::AddItem(BEntryList *walker)
{
fIteratorList.AddItem(walker);
}
+13 -4
View File
@@ -31,20 +31,22 @@ of Be Incorporated in the United States and other countries. Other brand product
names are registered trademarks or trademarks of their respective holders.
All rights reserved.
*/
#ifndef __ENTRY_ITERATOR__
#define __ENTRY_ITERATOR__
// A lot of the code in here wouldn't be needed if the destructor
// for BEntryList was virtual
// ToDo:
// get rid of all BEntryList API's in here, replace them with EntryListBase ones
// TODO: get rid of all BEntryList API's in here, replace them with
// EntryListBase ones
#ifndef __ENTRY_ITERATOR__
#define __ENTRY_ITERATOR__
#include <Directory.h>
#include "ObjectList.h"
#include "NodeWalker.h"
namespace BPrivate {
class EntryListBase : public BEntryList {
@@ -69,6 +71,7 @@ protected:
status_t fStatus;
};
class TWalkerWrapper : public EntryListBase {
// this is to be able to use TWalker polymorfically as BEntryListBase
public:
@@ -88,8 +91,10 @@ protected:
status_t fStatus;
};
const int32 kDirentBufferSize = 10 * 1024;
class CachedEntryIterator : public EntryListBase {
public:
// takes any iterator and runs it through a cache of a specified size
@@ -133,6 +138,7 @@ private:
BEntry* fEntryBuffer;
};
class DirectoryEntryList : public EntryListBase {
public:
DirectoryEntryList(const BDirectory &);
@@ -149,6 +155,7 @@ private:
BDirectory fDir;
};
class CachedDirectoryEntryList : public CachedEntryIterator {
// this class is to work around not being able to delete
// BEntryList polymorfically - need to have a special
@@ -161,6 +168,7 @@ private:
BDirectory fDir;
};
class EntryIteratorList : public EntryListBase {
// This wraps up several BEntryList style iterators and
// iterates them all, going from one to the other as it finishes
@@ -185,6 +193,7 @@ protected:
int32 fCurrentIndex;
};
class CachedEntryIteratorList : public CachedEntryIterator {
public:
CachedEntryIteratorList(bool sortInodes = true);
+2
View File
@@ -32,11 +32,13 @@ names are registered trademarks or trademarks of their respective holders.
All rights reserved.
*/
#include <FilePanel.h>
#include "FilePanelPriv.h"
#include "RecentItems.h"
// FBC fluff, stick it here to not pollute real .cpp files
void BRecentItemsList::_r1() {}
+19 -21
View File
@@ -513,10 +513,8 @@ FSClipboardPaste(Model *model, uint32 linksMode)
}
/** Seek node in clipboard, if found return it's moveMode
* else return 0
*/
// Seek node in clipboard, if found return it's moveMode
// else return 0
uint32
FSClipboardFindNodeMode(Model* model, bool autoLock, bool updateRefIfNeeded)
{
@@ -761,24 +759,24 @@ BClipboardRefsWatcher::Clear()
}
}
/*
void
BClipboardRefsWatcher::UpdatePoseViews(bool clearClipboard, const node_ref *node)
{
BMessage message(kFSClipboardChanges);
message.AddInt32("device", node->device);
message.AddInt64("directory", node->node);
message.AddBool("clearClipboard", clearClipboard);
if (Lock()) {
int32 items = fNotifyList.CountItems();
for (int32 i = 0;i < items;i++) {
fNotifyList.ItemAt(i)->SendMessage(&message);
}
Unlock();
}
}
*/
//void
//BClipboardRefsWatcher::UpdatePoseViews(bool clearClipboard, const node_ref* node)
//{
// BMessage message(kFSClipboardChanges);
// message.AddInt32("device", node->device);
// message.AddInt64("directory", node->node);
// message.AddBool("clearClipboard", clearClipboard);
//
// if (Lock()) {
// int32 items = fNotifyList.CountItems();
// for (int32 i = 0;i < items;i++) {
// fNotifyList.ItemAt(i)->SendMessage(&message);
// }
// Unlock();
// }
//}
void
BClipboardRefsWatcher::UpdatePoseViews(BMessage* reportMessage)
+3 -2
View File
@@ -31,10 +31,10 @@ of Be Incorporated in the United States and other countries. Other brand product
names are registered trademarks or trademarks of their respective holders.
All rights reserved.
*/
#ifndef FS_CLIPBOARD_H
#define FS_CLIPBOARD_H
#include <Looper.h>
#include "Model.h"
#include "ObjectList.h"
@@ -50,6 +50,7 @@ typedef struct {
} TClipboardNodeRef;
const int32 T_CLIPBOARD_NODE = 'TCNR';
class BClipboardRefsWatcher : public BLooper {
public:
BClipboardRefsWatcher();
@@ -92,4 +93,4 @@ bool FSClipboardPaste(Model *model, uint32 linksMode = 0);
void FSClipboardRemove(Model* model);
uint32 FSClipboardFindNodeMode(Model* model, bool autoLock, bool updateRefIfNeeded);
#endif /* FS_CLIPBOARD_H */
#endif // FS_CLIPBOARD_H
+4
View File
@@ -44,6 +44,7 @@ class UndoItemCopy : public UndoItem {
uint32 fMoveMode;
};
class UndoItemMove : public UndoItem {
public:
/** source - list of file(s) that were moved. Assumes ownership.
@@ -60,6 +61,7 @@ class UndoItemMove : public UndoItem {
entry_ref fSourceRef, fTargetRef;
};
class UndoItemFolder : public UndoItem {
public:
UndoItemFolder(const entry_ref &ref);
@@ -77,6 +79,7 @@ class UndoItemFolder : public UndoItem {
entry_ref fRef;
};
class UndoItemRename : public UndoItem {
public:
UndoItemRename(const entry_ref &origRef, const entry_ref &ref);
@@ -90,6 +93,7 @@ class UndoItemRename : public UndoItem {
entry_ref fRef, fOrigRef;
};
class UndoItemRenameVolume : public UndoItem {
public:
UndoItemRenameVolume(BVolume &volume, const char* newName);
+11 -1
View File
@@ -1,9 +1,11 @@
#ifndef _FS_UNDO_REDO_H
#define _FS_UNDO_REDO_H
#include "ObjectList.h"
#include <Entry.h>
namespace BPrivate {
class UndoItem;
@@ -18,48 +20,56 @@ class Undo {
UndoItem* fUndo;
};
class MoveCopyUndo : public Undo {
public:
MoveCopyUndo(BObjectList<entry_ref>* sourceList, BDirectory &dest,
BList* pointList, uint32 moveMode);
};
class NewFolderUndo : public Undo {
public:
NewFolderUndo(const entry_ref &ref);
};
class RenameUndo : public Undo {
public:
RenameUndo(BEntry &entry, const char* newName);
};
class RenameVolumeUndo : public Undo {
public:
RenameVolumeUndo(BVolume &volume, const char* newName);
};
static
inline bool FSIsUndoMoveMode(uint32 moveMode)
{
return (moveMode & '\xff\0\0\0') == 'U\0\0\0';
}
static
inline uint32 FSUndoMoveMode(uint32 moveMode)
{
return (moveMode & ~'\xff\0\0\0') | 'U\0\0\0';
}
static
inline uint32 FSMoveMode(uint32 moveMode)
{
return (moveMode & ~'\xff\0\0\0') | 'T\0\0\0';
}
extern void FSUndo();
extern void FSRedo();
} // namespace BPrivate
#endif /* _FS_UNDO_REDO_H */
#endif // _FS_UNDO_REDO_H
+12 -15
View File
@@ -34,8 +34,8 @@ respective holders. All rights reserved.
// Tracker file system calls.
// Note - APIs/code in FSUtils.h and FSUtils.cpp is slated for a major cleanup
// -- in other words, you will find a lot of ugly cruft in here
// APIs/code in FSUtils.h and FSUtils.cpp is slated for a major cleanup -- in
// other words, you will find a lot of ugly cruft in here
// ToDo:
// Move most of preflight error checks to the Model level and only keep those
@@ -44,6 +44,7 @@ respective holders. All rights reserved.
// Clean up the error handling, push most of the user interaction out of the
// low level FS calls.
#include <ctype.h>
#include <errno.h>
#include <string.h>
@@ -2307,12 +2308,10 @@ FSMakeOriginalName(char *name, BDirectory *destDir, const char *suffix)
}
if (!copycopy) {
/*
The name can't be longer than B_FILE_NAME_LENGTH.
The algoritm adds " copy XX" to the name. That's 8 characters.
B_FILE_NAME_LENGTH already accounts for NULL termination so we
don't need to save an extra char at the end.
*/
// The name can't be longer than B_FILE_NAME_LENGTH.
// The algoritm adds " copy XX" to the name. That's 8 characters.
// B_FILE_NAME_LENGTH already accounts for NULL termination so we
// don't need to save an extra char at the end.
if (strlen(name) > B_FILE_NAME_LENGTH - 8) {
// name is too long - truncate it!
name[B_FILE_NAME_LENGTH - 8] = '\0';
@@ -2331,13 +2330,11 @@ FSMakeOriginalName(char *name, BDirectory *destDir, const char *suffix)
sprintf(temp_name, "%s %ld", copybase, ++fnum);
if (strlen(temp_name) > (B_FILE_NAME_LENGTH - 1)) {
/*
The name has grown too long. Maybe we just went from
"<filename> copy 9" to "<filename> copy 10" and that extra
character was too much. The solution is to further
truncate the 'root' name and continue.
??? should we reset fnum or not ???
*/
// The name has grown too long. Maybe we just went from
// "<filename> copy 9" to "<filename> copy 10" and that extra
// character was too much. The solution is to further
// truncate the 'root' name and continue.
// ??? should we reset fnum or not ???
root[strlen(root) - 1] = '\0';
sprintf(temp_name, "%s%s %ld", root, suffix, fnum);
}
+3 -2
View File
@@ -31,10 +31,10 @@ of Be Incorporated in the United States and other countries. Other brand product
names are registered trademarks or trademarks of their respective holders.
All rights reserved.
*/
#ifndef FS_UTILS_H
#define FS_UTILS_H
#include <FindDirectory.h>
#include <List.h>
#include <Point.h>
@@ -45,6 +45,7 @@ All rights reserved.
#include "Model.h"
#include "ObjectList.h"
// Note - APIs/code in FSUtils.h and FSUtils.cpp is slated for a major cleanup
// -- in other words, you will find a lot of ugly cruft in here
@@ -328,4 +329,4 @@ class WellKnowEntryList {
using namespace BPrivate;
#endif /* FS_UTILS_H */
#endif // FS_UTILS_H
+2 -2
View File
@@ -321,7 +321,8 @@ FavoritesMenu::ShouldShowModel(const Model *model)
// #pragma mark -
RecentsMenu::RecentsMenu(const char *name,int32 which,uint32 what,BHandler *target)
RecentsMenu::RecentsMenu(const char* name, int32 which, uint32 what,
BHandler* target)
: BNavMenu(name, what, target),
fWhich(which),
fRecentsCount(0),
@@ -459,4 +460,3 @@ RecentsMenu::ClearMenuBuildingState()
fMenuBuilt = false;
BNavMenu::ClearMenuBuildingState();
}
+4 -1
View File
@@ -31,15 +31,16 @@ of Be Incorporated in the United States and other countries. Other brand product
names are registered trademarks or trademarks of their respective holders.
All rights reserved.
*/
#ifndef __FAVORITES_MENU__
#define __FAVORITES_MENU__
#include <vector>
#include "NavMenu.h"
#include "ObjectList.h"
class BRefFilter;
namespace BPrivate {
@@ -48,6 +49,7 @@ class EntryListBase;
#define kGoDirectory "Tracker/Go"
class FavoritesMenu : public BSlowMenu {
// FavoritesMenu is used in the FilePanel -
// displays recent files, recent folders and favorites items
@@ -106,6 +108,7 @@ enum recent_type {
kRecentFolders = 2
};
class RecentsMenu : public BNavMenu {
public:
RecentsMenu(const char* name,int32 which,uint32 what,BHandler* target);
+26 -1
View File
@@ -34,6 +34,7 @@ All rights reserved.
// Implementation for the public FilePanel object.
#include <sys/resource.h>
#include <BeBuild.h>
@@ -64,6 +65,7 @@ run_open_panel()
(new TFilePanel())->Show();
}
void
run_save_panel()
{
@@ -97,12 +99,14 @@ BFilePanel::BFilePanel(file_panel_mode mode, BMessenger *target,
fWindow->SetIsFilePanel(true);
}
BFilePanel::~BFilePanel()
{
if (fWindow->Lock())
fWindow->Quit();
}
void
BFilePanel::Show()
{
@@ -124,6 +128,7 @@ BFilePanel::Show()
fWindow->Activate();
}
void
BFilePanel::Hide()
{
@@ -135,6 +140,7 @@ BFilePanel::Hide()
fWindow->QuitRequested();
}
bool
BFilePanel::IsShowing() const
{
@@ -152,6 +158,7 @@ BFilePanel::SendMessage(const BMessenger *messenger, BMessage *message)
messenger->SendMessage(message);
}
file_panel_mode
BFilePanel::PanelMode() const
{
@@ -165,6 +172,7 @@ BFilePanel::PanelMode() const
return B_OPEN_PANEL;
}
BMessenger
BFilePanel::Messenger() const
{
@@ -177,6 +185,7 @@ BFilePanel::Messenger() const
return *static_cast<TFilePanel*>(fWindow)->Target();
}
void
BFilePanel::SetTarget(BMessenger target)
{
@@ -187,6 +196,7 @@ BFilePanel::SetTarget(BMessenger target)
static_cast<TFilePanel*>(fWindow)->SetTarget(target);
}
void
BFilePanel::SetMessage(BMessage* message)
{
@@ -197,6 +207,7 @@ BFilePanel::SetMessage(BMessage *message)
static_cast<TFilePanel*>(fWindow)->SetMessage(message);
}
void
BFilePanel::Refresh()
{
@@ -207,6 +218,7 @@ BFilePanel::Refresh()
static_cast<TFilePanel*>(fWindow)->Refresh();
}
BRefFilter*
BFilePanel::RefFilter() const
{
@@ -217,6 +229,7 @@ BFilePanel::RefFilter() const
return static_cast<TFilePanel*>(fWindow)->Filter();
}
void
BFilePanel::SetRefFilter(BRefFilter* filter)
{
@@ -227,6 +240,7 @@ BFilePanel::SetRefFilter(BRefFilter *filter)
static_cast<TFilePanel*>(fWindow)->SetRefFilter(filter);
}
void
BFilePanel::SetButtonLabel(file_panel_button button, const char* text)
{
@@ -237,6 +251,7 @@ BFilePanel::SetButtonLabel(file_panel_button button, const char *text)
static_cast<TFilePanel*>(fWindow)->SetButtonLabel(button, text);
}
void
BFilePanel::GetPanelDirectory(entry_ref* ref) const
{
@@ -247,6 +262,7 @@ BFilePanel::GetPanelDirectory(entry_ref *ref) const
*ref = *static_cast<TFilePanel*>(fWindow)->TargetModel()->EntryRef();
}
void
BFilePanel::SetSaveText(const char* text)
{
@@ -257,6 +273,7 @@ BFilePanel::SetSaveText(const char *text)
static_cast<TFilePanel*>(fWindow)->SetSaveText(text);
}
void
BFilePanel::SetPanelDirectory(const entry_ref* ref)
{
@@ -267,6 +284,7 @@ BFilePanel::SetPanelDirectory(const entry_ref *ref)
static_cast<TFilePanel*>(fWindow)->SetTo(ref);
}
void
BFilePanel::SetPanelDirectory(const char* path)
{
@@ -282,6 +300,7 @@ BFilePanel::SetPanelDirectory(const char *path)
static_cast<TFilePanel*>(fWindow)->SetTo(&ref);
}
void
BFilePanel::SetPanelDirectory(const BEntry* entry)
{
@@ -291,6 +310,7 @@ BFilePanel::SetPanelDirectory(const BEntry *entry)
SetPanelDirectory(&ref);
}
void
BFilePanel::SetPanelDirectory(const BDirectory* dir)
{
@@ -300,12 +320,14 @@ BFilePanel::SetPanelDirectory(const BDirectory *dir)
SetPanelDirectory(&entry);
}
BWindow*
BFilePanel::Window() const
{
return fWindow;
}
void
BFilePanel::Rewind()
{
@@ -316,6 +338,7 @@ BFilePanel::Rewind()
static_cast<TFilePanel*>(fWindow)->Rewind();
}
status_t
BFilePanel::GetNextSelectedRef(entry_ref* ref)
{
@@ -338,6 +361,7 @@ BFilePanel::SetHideWhenDone(bool on)
static_cast<TFilePanel*>(fWindow)->SetHideWhenDone(on);
}
bool
BFilePanel::HidesWhenDone(void) const
{
@@ -348,15 +372,16 @@ BFilePanel::HidesWhenDone(void) const
return static_cast<TFilePanel*>(fWindow)->HidesWhenDone();
}
void
BFilePanel::WasHidden()
{
// hook function
}
void
BFilePanel::SelectionChanged()
{
// hook function
}
-1
View File
@@ -1730,4 +1730,3 @@ BFilePanelPoseView::AdaptToDesktopIntegrationChange(BMessage *message)
ShowVolumes(false, mountSharedVolumesOntoDesktop);
ShowVolumes(mountVolumesOnDesktop, mountSharedVolumesOntoDesktop);
}
+16 -8
View File
@@ -31,16 +31,17 @@ of Be Incorporated in the United States and other countries. Other brand product
names are registered trademarks or trademarks of their respective holders.
All rights reserved.
*/
#ifndef _FILE_PANEL_PRIV_H
#define _FILE_PANEL_PRIV_H
#include <FilePanel.h>
#include "ContainerWindow.h"
#include "PoseView.h"
#include "TaskLoop.h"
class BTextControl;
class BFilePanel;
class BRefFilter;
@@ -122,19 +123,19 @@ protected:
static filter_result FSFilter(BMessage*, BHandler**, BMessageFilter*);
static filter_result MessageDropFilter(BMessage*, BHandler**, BMessageFilter*);
int32 ShowCenteredAlert(const char *text, const char *button1, const char *button2 = NULL,
const char *button3 = NULL);
int32 ShowCenteredAlert(const char* text, const char* button1,
const char* button2 = NULL, const char* button3 = NULL);
private:
bool SwitchDirToDesktopIfNeeded(entry_ref &ref);
bool CanOpenParent() const;
void SwitchDirMenuTo(const entry_ref* ref);
void AdjustButton();
bool SelectChildInParent(const entry_ref *parent, const node_ref *child);
bool SelectChildInParent(const entry_ref* parent,
const node_ref* child);
void OpenSelectionCommon(BMessage*);
bool fIsSavePanel;
uint32 fNodeFlavors;
BackgroundView* fBackView;
@@ -184,13 +185,14 @@ protected:
private:
bool fIsDesktop;
// this flags makes the distinction between the Desktop as the Root of
// the world and "/boot/home/Desktop" to which we might have navigated
// from the home dir
// This flags makes the distinction between the Desktop as
// the root of the world and "/boot/home/Desktop" to which
// we might have navigated from the home dir.
typedef BPoseView _inherited;
};
// inlines follow
inline bool
@@ -199,36 +201,42 @@ BFilePanelPoseView::IsFilePanel() const
return true;
}
inline bool
TFilePanel::IsSavePanel() const
{
return fIsSavePanel;
}
inline const BMessenger*
TFilePanel::Target() const
{
return &fTarget;
}
inline void
TFilePanel::Refresh()
{
fPoseView->Refresh();
}
inline bool
TFilePanel::HidesWhenDone(void)
{
return fHideWhenDone;
}
inline void
TFilePanel::SetHideWhenDone(bool on)
{
fHideWhenDone = on;
}
inline bool
TFilePanel::TrackingMenu() const
{
+1 -1
View File
@@ -32,6 +32,7 @@ names are registered trademarks or trademarks of their respective holders.
All rights reserved.
*/
#include "FilePermissionsView.h"
#include <stdio.h>
@@ -358,4 +359,3 @@ FilePermissionsView::AttachedToWindow()
fOwnerTextControl->SetTarget(this);
fGroupTextControl->SetTarget(this);
}
+5 -2
View File
@@ -31,15 +31,16 @@ of Be Incorporated in the United States and other countries. Other brand product
names are registered trademarks or trademarks of their respective holders.
All rights reserved.
*/
#ifndef FILE_PERMISSIONS_VIEW_H
#define FILE_PERMISSIONS_VIEW_H
#include <CheckBox.h>
#include <TextControl.h>
#include "Model.h"
namespace BPrivate {
class FocusCheckBox : public BCheckBox {
@@ -61,6 +62,7 @@ class FocusCheckBox : public BCheckBox {
}
};
class FilePermissionsView : public BView {
public:
FilePermissionsView(BRect, Model*);
@@ -92,8 +94,9 @@ class FilePermissionsView : public BView {
typedef BView _inherited;
};
} // namespace BPrivate
using namespace BPrivate;
#endif /* FILE_PERMISSIONS_VIEW_H */
#endif // FILE_PERMISSIONS_VIEW_H
+1
View File
@@ -32,6 +32,7 @@ names are registered trademarks or trademarks of their respective holders.
All rights reserved.
*/
#include <Application.h>
#include <Box.h>
#include <Button.h>
+1 -2
View File
@@ -31,7 +31,6 @@ of Be Incorporated in the United States and other countries. Other brand product
names are registered trademarks or trademarks of their respective holders.
All rights reserved.
*/
#ifndef _FIND_PANEL_H
#define _FIND_PANEL_H
@@ -40,13 +39,13 @@ All rights reserved.
#include <Window.h>
#include <View.h>
#include "DialogPane.h"
#include "ObjectList.h"
#include "MimeTypeList.h"
#include "Utilities.h"
#include "NodeWalker.h"
class BFilePanel;
class BQuery;
class BBox;
+9 -15
View File
@@ -31,10 +31,10 @@ of Be Incorporated in the United States and other countries. Other brand product
names are registered trademarks or trademarks of their respective holders.
All rights reserved.
*/
#ifndef __FUNCTION_OBJECT__
#define __FUNCTION_OBJECT__
#include <Message.h>
#include <Messenger.h>
#include <MessageFilter.h>
@@ -42,6 +42,7 @@ All rights reserved.
#include <Entry.h>
#include <Node.h>
// parameter binders serve to store a copy of a struct and
// pass it in and out by pointers, allowing struct parameters to share
// the same syntax as scalar ones
@@ -164,8 +165,7 @@ public:
template<class R>
class FunctionObjectWithResult : public FunctionObject {
public:
const R &Result() const
{ return result; }
const R &Result() const { return result; }
protected:
R result;
@@ -182,9 +182,7 @@ public:
{
}
virtual void operator()()
{ (function)(p1.Pass()); }
virtual void operator()() { (function)(p1.Pass()); }
private:
void (*function)(Param1);
@@ -193,7 +191,8 @@ private:
template <class Result, class Param1>
class SingleParamFunctionObjectWithResult : public FunctionObjectWithResult<Result> {
class SingleParamFunctionObjectWithResult : public
FunctionObjectWithResult<Result> {
public:
SingleParamFunctionObjectWithResult(Result (*function)(Param1), Param1 p1)
: function(function),
@@ -201,7 +200,6 @@ public:
{
}
virtual void operator()()
{ FunctionObjectWithResult<Result>::result = (function)(p1.Pass()); }
@@ -222,8 +220,7 @@ public:
{
}
virtual void operator()()
{ (function)(p1.Pass(), p2.Pass()); }
virtual void operator()() { (function)(p1.Pass(), p2.Pass()); }
private:
void (*function)(Param1, Param2);
@@ -244,9 +241,7 @@ public:
{
}
virtual void operator()()
{ (function)(p1.Pass(), p2.Pass(), p3.Pass()); }
virtual void operator()() { (function)(p1.Pass(), p2.Pass(), p3.Pass()); }
private:
void (*function)(Param1, Param2, Param3);
@@ -562,5 +557,4 @@ NewLockingMemberFunctionObject(void (HandlerOrSubclass::*function)(),
using namespace BPrivate;
#endif
#endif // __FUNCTION_OBJECT__
+1 -1
View File
@@ -67,4 +67,4 @@ class TGroupedMenu : public BMenu {
} // namespace BPrivate
#endif /* GROUPED_MENU_H */
#endif // GROUPED_MENU_H
+25 -7
View File
@@ -31,12 +31,13 @@ of Be Incorporated in the United States and other countries. Other brand product
names are registered trademarks or trademarks of their respective holders.
All rights reserved.
*/
#ifndef __NU_ICON_CACHE__
#define __NU_ICON_CACHE__
// Icon cache is used for drawing node icons; it caches icons
// and reuses them for successive draws
#ifndef __NU_ICON_CACHE__
#define __NU_ICON_CACHE__
#include <Bitmap.h>
#include <Mime.h>
@@ -47,6 +48,7 @@ All rights reserved.
#include "OpenHashTable.h"
#include "Utilities.h"
// Icon cache splits icons into two caches - the shared cache, likely to get the
// most hits and the node cache. Every icon that is found in a mime based
// structure goes into the shared cache, only files that have their own private
@@ -89,6 +91,7 @@ enum IconDrawMode {
kDimmedIcon
};
#define NORMAL_ICON_ONLY kNormalIcon
// replace use of these defines with mode once the respective getters
// can get non-plain icons
@@ -110,6 +113,7 @@ enum IconSource {
kNode
};
class IconCacheEntry {
// aliased entries don't own their icons, just point
// to some other entry that does
@@ -170,6 +174,7 @@ protected:
friend class NodeIconCache;
};
class SimpleIconCache {
public:
SimpleIconCache(const char*);
@@ -178,7 +183,8 @@ public:
virtual void Draw(IconCacheEntry*, BView*, BPoint, IconDrawMode mode,
icon_size size, bool async = false) = 0;
virtual void Draw(IconCacheEntry*, BView*, BPoint, IconDrawMode,
icon_size , void (*)(BView *, BPoint, BBitmap *, void *), void * = NULL) = 0;
icon_size, void (*)(BView*, BPoint, BBitmap*, void*),
void* = NULL) = 0;
bool Lock();
void Unlock();
@@ -188,6 +194,7 @@ private:
Benaphore fLock;
};
class SharedCacheEntry : public IconCacheEntry {
public:
SharedCacheEntry();
@@ -216,6 +223,7 @@ private:
friend class SharedIconCache;
};
class SharedCacheEntryArray : public OpenHashElementArray<SharedCacheEntry> {
// SharedIconCache stores all it's elements in this array
public:
@@ -223,6 +231,7 @@ public:
SharedCacheEntry* Add();
};
class SharedIconCache : public SimpleIconCache {
// SharedIconCache is used for icons that come from the mime database
public:
@@ -257,6 +266,7 @@ private:
// and wait for the next sync to delete them
};
class NodeCacheEntry : public IconCacheEntry {
public:
NodeCacheEntry(bool permanent = false);
@@ -285,6 +295,7 @@ private:
friend class NodeIconCache;
};
class NodeCacheEntryArray : public OpenHashElementArray<NodeCacheEntry> {
// NodeIconCache stores all it's elements in this array
public:
@@ -292,6 +303,7 @@ public:
NodeCacheEntry* Add();
};
class NodeIconCache : public SimpleIconCache {
// NodeIconCache is used for nodes that define their own icons
public:
@@ -323,8 +335,10 @@ private:
NodeCacheEntryArray fElementArray;
};
const int32 kColorTransformTableSize = 256;
class IconCache {
public:
IconCache();
@@ -344,7 +358,8 @@ public:
// preload calls used to ensure successive cache hit for the respective
// icon, used for common tracker types, etc; Not calling these should only
// cause a slowdown
void Preload(Model *, IconDrawMode mode, icon_size size, bool permanent = false);
void Preload(Model*, IconDrawMode mode, icon_size size,
bool permanent = false);
status_t Preload(const char* mimeType, IconDrawMode mode, icon_size size);
void Deleting(const Model*);
@@ -373,13 +388,11 @@ public:
BBitmap* MakeSelectedIcon(const BBitmap* normal, icon_size,
LazyBitmapAllocator*);
static bool NeedsDeletionNotification(IconSource);
static IconCache* sIconCache;
private:
// shared calls
IconCacheEntry* Preload(AutoLock<SimpleIconCache>* nodeCache,
AutoLock<SimpleIconCache>* sharedCache,
@@ -460,7 +473,8 @@ private:
color_space fColorSpace;
};
// nothing but inlines after here
// inlines follow
inline const char*
SharedCacheEntry::FileType() const
@@ -468,18 +482,21 @@ SharedCacheEntry::FileType() const
return fFileType.String();
}
inline const char*
SharedCacheEntry::AppSignature() const
{
return fAppSignature.String();
}
inline bool
IconCache::NeedsDeletionNotification(IconSource from)
{
return from == kNode;
}
inline IconCacheEntry*
SharedIconCache::ResolveIfAlias(IconCacheEntry* entry) const
{
@@ -489,6 +506,7 @@ SharedIconCache::ResolveIfAlias(IconCacheEntry *entry) const
return fHashTable.ElementAt(entry->fAliasForIndex);
}
inline int32
SharedIconCache::EntryIndex(const SharedCacheEntry* entry) const
{
+5 -3
View File
@@ -31,18 +31,20 @@ of Be Incorporated in the United States and other countries. Other brand product
names are registered trademarks or trademarks of their respective holders.
All rights reserved.
*/
#ifndef ICON_MENU_ITEM_H
#define ICON_MENU_ITEM_H
// Menu item class with small icons.
#ifndef ICON_MENU_ITEM_H
#define ICON_MENU_ITEM_H
#include <MenuItem.h>
#include "Model.h"
#include "Utilities.h"
class BNodeInfo;
class BNodeInfo;
namespace BPrivate {
const bigtime_t kSynchMenuInvokeTimeout = 5000000;
-1
View File
@@ -2231,4 +2231,3 @@ TrackingView::Draw(BRect)
DrawString(Label(), BPoint(3, Bounds().Height() - fontHeight.descent));
}
+6 -2
View File
@@ -52,6 +52,7 @@ namespace BPrivate {
class Model;
class AttributeView;
class BInfoWindow : public BWindow {
public:
BInfoWindow(Model*, int32 groupIndex, LockingList<BWindow>* list = NULL);
@@ -76,7 +77,8 @@ class BInfoWindow : public BWindow {
Model* fModel;
volatile bool fStopCalc;
int32 fIndex; // tells where it lives with respect to other
int32 fIndex;
// tells where it lives with respect to other
thread_id fCalcThreadID;
LockingList<BWindow>* fWindowList;
FilePermissionsView* fPermissionsView;
@@ -87,12 +89,14 @@ class BInfoWindow : public BWindow {
typedef BWindow _inherited;
};
inline bool
BInfoWindow::StopCalc()
{
return fStopCalc;
}
inline Model*
BInfoWindow::TargetModel() const
{
@@ -103,4 +107,4 @@ BInfoWindow::TargetModel() const
using namespace BPrivate;
#endif
#endif // INFO_WINDOW_H
+7 -3
View File
@@ -31,13 +31,14 @@ of Be Incorporated in the United States and other countries. Other brand product
names are registered trademarks or trademarks of their respective holders.
All rights reserved.
*/
#ifndef _LOCKING_LIST_H
#define _LOCKING_LIST_H
#include <Locker.h>
#include "ObjectList.h"
namespace BPrivate {
template <class T>
@@ -57,12 +58,14 @@ private:
BLocker lock;
};
template<class T>
LockingList<T>::LockingList(int32 itemsPerBlock, bool owning)
: BObjectList<T>(itemsPerBlock, owning)
{
}
template<class T>
bool
LockingList<T>::Lock()
@@ -70,6 +73,7 @@ LockingList<T>::Lock()
return lock.Lock();
}
template<class T>
void
LockingList<T>::Unlock()
@@ -77,6 +81,7 @@ LockingList<T>::Unlock()
lock.Unlock();
}
template<class T>
bool
LockingList<T>::IsLocked() const
@@ -84,9 +89,8 @@ LockingList<T>::IsLocked() const
return lock.IsLocked();
}
} // namespace BPrivate
using namespace BPrivate;
#endif
#endif // _LOCKING_LIST_H
+4 -2
View File
@@ -31,14 +31,15 @@ of Be Incorporated in the United States and other countries. Other brand product
names are registered trademarks or trademarks of their respective holders.
All rights reserved.
*/
#ifndef __MIME_TYPE_LIST__
#define __MIME_TYPE_LIST__
#include <String.h>
#include "ObjectList.h"
#include "Utilities.h"
namespace BPrivate {
class MimeTypeList;
@@ -63,6 +64,7 @@ private:
friend class MimeTypeList;
};
class MimeTypeList {
public:
MimeTypeList();
@@ -88,4 +90,4 @@ private:
using namespace BPrivate;
#endif
#endif // __MIME_TYPE_LIST__
+2 -2
View File
@@ -31,10 +31,10 @@ of Be Incorporated in the United States and other countries. Other brand product
names are registered trademarks or trademarks of their respective holders.
All rights reserved.
*/
#ifndef _MIME_TYPES_H
#define _MIME_TYPES_H
namespace BPrivate {
#define B_FILE_MIMETYPE "application/octet-stream"
@@ -60,4 +60,4 @@ namespace BPrivate {
using namespace BPrivate;
#endif
#endif // _MIME_TYPES_H
+8 -1
View File
@@ -32,12 +32,14 @@ names are registered trademarks or trademarks of their respective holders.
All rights reserved.
*/
#include <PopUpMenu.h>
#include <Window.h>
#include "MiniMenuField.h"
#include "Utilities.h"
MiniMenuField::MiniMenuField(BRect frame, const char* name, BPopUpMenu* menu,
uint32 resizeFlags, uint32 flags)
: BView(frame, name, resizeFlags, flags),
@@ -46,11 +48,13 @@ MiniMenuField::MiniMenuField(BRect frame, const char *name, BPopUpMenu *menu,
SetFont(be_plain_font, B_FONT_FAMILY_AND_STYLE | B_FONT_SIZE);
}
MiniMenuField::~MiniMenuField()
{
delete fMenu;
}
void
MiniMenuField::AttachedToWindow()
{
@@ -61,6 +65,7 @@ MiniMenuField::AttachedToWindow()
SetHighColor(0, 0, 0);
}
void
MiniMenuField::MakeFocus(bool on)
{
@@ -68,6 +73,7 @@ MiniMenuField::MakeFocus(bool on)
BView::MakeFocus(on);
}
void
MiniMenuField::KeyDown(const char* bytes, int32 numBytes)
{
@@ -85,6 +91,7 @@ MiniMenuField::KeyDown(const char *bytes, int32 numBytes)
}
}
void
MiniMenuField::Draw(BRect)
{
@@ -151,9 +158,9 @@ MiniMenuField::Draw(BRect)
AddLine(BPoint(bounds.left, bounds.bottom),
BPoint(bounds.left, bounds.top), focused ? markColor : viewColor);
EndLineArray();
}
void
MiniMenuField::MouseDown(BPoint)
{
+3 -3
View File
@@ -31,17 +31,17 @@ of Be Incorporated in the United States and other countries. Other brand product
names are registered trademarks or trademarks of their respective holders.
All rights reserved.
*/
#ifndef __MINI_MENU_FIELD__
#define __MINI_MENU_FIELD__
#include <View.h>
class BPopUpMenu;
namespace BPrivate {
class MiniMenuField : public BView {
public:
MiniMenuField(BRect frame, const char* name, BPopUpMenu* menu,
@@ -67,4 +67,4 @@ private:
using namespace BPrivate;
#endif
#endif // __MINI_MENU_FIELD__
+4 -5
View File
@@ -31,11 +31,12 @@ of Be Incorporated in the United States and other countries. Other brand product
names are registered trademarks or trademarks of their respective holders.
All rights reserved.
*/
#ifndef _NU_MODEL_H
#define _NU_MODEL_H
// Dedicated to BModel
#ifndef _NU_MODEL_H
#define _NU_MODEL_H
#include <AppFileInfo.h>
#include <Debug.h>
@@ -524,8 +525,6 @@ ModelNodeLazyOpener::OpenNode(bool writable)
return B_OK;
}
} // namespace BPrivate
#endif
#endif // _NU_MODEL_H
+3 -2
View File
@@ -31,12 +31,13 @@ of Be Incorporated in the United States and other countries. Other brand product
names are registered trademarks or trademarks of their respective holders.
All rights reserved.
*/
#ifndef MOUNTMENU_H
#define MOUNTMENU_H
#include <Menu.h>
namespace BPrivate {
class MountMenu : public BMenu {
@@ -54,4 +55,4 @@ protected:
using namespace BPrivate;
#endif
#endif // MOUNTMENU_H
-1
View File
@@ -868,4 +868,3 @@ BNavMenu::SetTrackingHookDeep(BMenu* menu, bool (*func)(BMenu*, void*),
SetTrackingHookDeep(submenu, func, state);
}
}
+23 -9
View File
@@ -31,6 +31,8 @@ of Be Incorporated in the United States and other countries. Other brand product
names are registered trademarks or trademarks of their respective holders.
All rights reserved.
*/
#include "Bitmaps.h"
#include "Commands.h"
#include "ContainerWindow.h"
@@ -38,9 +40,11 @@ All rights reserved.
#include "Model.h"
#include "Navigator.h"
#include "Tracker.h"
#include <Window.h>
#include <Picture.h>
#include <TextControl.h>
#include <Window.h>
namespace BPrivate {
@@ -53,6 +57,7 @@ static const int32 kMaxHistory = 32;
// pictures when we can, e.g. on a AttachedToWindow.
static BPicture sPicture;
BNavigatorButton::BNavigatorButton(BRect rect, const char* name, BMessage* message,
int32 resIDon, int32 resIDoff, int32 resIDdisabled)
: BPictureButton(rect, name, &sPicture, &sPicture, message),
@@ -60,17 +65,18 @@ BNavigatorButton::BNavigatorButton(BRect rect, const char *name, BMessage *messa
fResIDOff(resIDoff),
fResIDDisabled(resIDdisabled)
{
// Clear to background color to
// avoid ugly border on click
// Clear to background color to avoid ugly border on click
SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
SetHighColor(ui_color(B_PANEL_BACKGROUND_COLOR));
SetLowColor(ui_color(B_PANEL_BACKGROUND_COLOR));
}
BNavigatorButton::~BNavigatorButton()
{
}
void
BNavigatorButton::AttachedToWindow()
{
@@ -91,6 +97,7 @@ BNavigatorButton::AttachedToWindow()
delete bmpDisabled;
}
void
BNavigatorButton::SetPicture(BBitmap* bitmap, bool enabled, bool on)
{
@@ -158,13 +165,14 @@ BNavigator::BNavigator(const Model *model, BRect rect, uint32 resizeMask)
B_FOLLOW_LEFT_RIGHT);
fLocation->SetDivider(0);
AddChild(fLocation);
}
BNavigator::~BNavigator()
{
}
void
BNavigator::AttachedToWindow()
{
@@ -178,6 +186,7 @@ BNavigator::AttachedToWindow()
fLocation->SetTarget(this);
}
void
BNavigator::Draw(BRect)
{
@@ -194,6 +203,7 @@ BNavigator::Draw(BRect)
EndLineArray();
}
void
BNavigator::MessageReceived(BMessage* message)
{
@@ -216,8 +226,7 @@ BNavigator::MessageReceived(BMessage *message)
default:
{
// Catch any dropped refs and try
// to switch to this new directory
// Catch any dropped refs and try to switch to this new directory
entry_ref ref;
if (message->FindRef("refs", &ref) == B_OK) {
BMessage message(kSwitchDirectory);
@@ -236,6 +245,7 @@ BNavigator::MessageReceived(BMessage *message)
}
}
void
BNavigator::GoBackward(bool option)
{
@@ -247,6 +257,7 @@ BNavigator::GoBackward(bool option)
}
}
void
BNavigator::GoForward(bool option)
{
@@ -257,6 +268,7 @@ BNavigator::GoForward(bool option)
}
}
void
BNavigator::GoUp(bool option)
{
@@ -268,6 +280,7 @@ BNavigator::GoUp(bool option)
}
}
void
BNavigator::SendNavigationMessage(NavigationAction action, BEntry* entry, bool option)
{
@@ -312,6 +325,7 @@ BNavigator::SendNavigationMessage(NavigationAction action, BEntry *entry, bool o
}
}
void
BNavigator::GoTo()
{
@@ -333,21 +347,20 @@ BNavigator::GoTo()
} else {
BPath path;
if (Window()
&& Window()->TargetModel()) {
if (Window() && Window()->TargetModel()) {
Window()->TargetModel()->GetPath(&path);
fLocation->SetText(path.Path());
}
}
}
void
BNavigator::UpdateLocation(const Model* newmodel, int32 action)
{
if (newmodel)
newmodel->GetPath(&fPath);
// Modify history according to commands
switch (action) {
case kActionBackward:
@@ -383,6 +396,7 @@ BNavigator::UpdateLocation(const Model *newmodel, int32 action)
fLocation->SetText(fPath.Path());
}
float
BNavigator::CalcNavigatorHeight(void)
{
+8 -3
View File
@@ -34,11 +34,13 @@ All rights reserved.
#ifndef _NAVIGATOR_H_
#define _NAVIGATOR_H_
#include "Model.h"
#include <PictureButton.h>
#include <View.h>
class BTextControl;
class BEntry;
@@ -59,6 +61,7 @@ enum NavigationAction
kNavigatorCommandLocation = 'NVLC'
};
// Custom BPictureButton which takes
// bitmap resource IDs as arguments
class BNavigatorButton : public BPictureButton {
@@ -78,9 +81,11 @@ private:
int32 fResIDDisabled;
};
class BNavigator : public BView {
public:
BNavigator(const Model *model, BRect rect, uint32 resizeMask = B_FOLLOW_LEFT_RIGHT);
BNavigator(const Model* model, BRect rect,
uint32 resizeMask = B_FOLLOW_LEFT_RIGHT);
~BNavigator();
void UpdateLocation(const Model* newmodel, int32 action);
@@ -102,7 +107,6 @@ protected:
void GoTo();
private:
BPath fPath;
BNavigatorButton* fBack;
BNavigatorButton* fForw;
@@ -115,6 +119,7 @@ private:
typedef BView _inherited;
};
inline
BContainerWindow*
BNavigator::Window() const
@@ -127,4 +132,4 @@ BNavigator::Window() const
using namespace BPrivate;
#endif
#endif // _NAVIGATOR_H_
+2 -2
View File
@@ -110,6 +110,7 @@ NodePreloader::MessageReceived(BMessage *message)
node_ref itemNode;
switch (message->what) {
case B_NODE_MONITOR:
{
switch (message->FindInt32("opcode")) {
case B_ENTRY_REMOVED:
{
@@ -144,6 +145,7 @@ NodePreloader::MessageReceived(BMessage *message)
}
}
break;
}
default:
_inherited::MessageReceived(message);
@@ -187,7 +189,6 @@ NodePreloader::PreloadOne(const char *dirPath)
} else
delete model;
}
}
@@ -218,4 +219,3 @@ NodePreloader::Preload()
fLock.Unlock();
}
+3 -3
View File
@@ -42,15 +42,16 @@ All rights reserved.
// aliasing after a deletion, etc.
//
// The node preloader knows which icons to preload
#ifndef __NODE_CACHE_PRELOADER__
#define __NODE_CACHE_PRELOADER__
#include <Handler.h>
#include "ObjectList.h"
#include "Model.h"
namespace BPrivate {
class NodePreloader : public BHandler {
@@ -70,7 +71,6 @@ private:
// for now just preload apps and prefs
Model* FindModel(node_ref) const;
BObjectList<Model> fModelList;
Benaphore fLock;
volatile bool fQuitRequested;
@@ -82,4 +82,4 @@ private:
using namespace BPrivate;
#endif
#endif // __NODE_CACHE_PRELOADER__
+4 -5
View File
@@ -32,6 +32,7 @@ names are registered trademarks or trademarks of their respective holders.
All rights reserved.
*/
#include <Debug.h>
#include <stdio.h>
#include <string.h>
@@ -40,6 +41,7 @@ All rights reserved.
#include "NodeWalker.h"
namespace BTrackerPrivate {
TWalker::~TWalker()
@@ -484,11 +486,8 @@ TVolWalker::TVolWalker(bool knowsAttributes, bool writable, bool includeTopDirec
fKnowsAttr(knowsAttributes),
fWritable(writable)
{
/*
Get things initialized. Find first volume, or find the first volume
that supports attributes.
*/
// Get things initialized. Find first volume, or find the first volume
// that supports attributes.
NextVolume();
}
+5 -2
View File
@@ -31,10 +31,10 @@ of Be Incorporated in the United States and other countries. Other brand product
names are registered trademarks or trademarks of their respective holders.
All rights reserved.
*/
#ifndef WALKER_H
#define WALKER_H
#ifndef _BE_BUILD_H
#include <BeBuild.h>
#endif
@@ -48,8 +48,8 @@ All rights reserved.
#include "ObjectList.h"
namespace BTrackerPrivate {
namespace BTrackerPrivate {
class TWalker : public BEntryList {
// adds a virtual destructor that is severely missing in BEntryList
@@ -66,6 +66,7 @@ public:
virtual int32 CountEntries() = 0;
};
class TNodeWalker : public TWalker {
// TNodeWalker supports iterating a single volume, starting from a specified
// entry; if passed a non-directory entry it returns just that one entry
@@ -111,6 +112,7 @@ private:
// keep around to support Rewind
};
class TVolWalker : public TNodeWalker {
// TNodeWalker supports iterating over all the mounted volumes;
// non-attribute and read-only volumes may optionaly be filtered out
@@ -143,6 +145,7 @@ private:
typedef TNodeWalker _inherited;
};
class TQueryWalker : public TWalker {
public:
TQueryWalker(const char* predicate);
-1
View File
@@ -1685,4 +1685,3 @@ ConditionalAllAppsIterator::Iterate() const
{
return fParent->ShowAllApplications();
}
+11 -3
View File
@@ -31,10 +31,13 @@ of Be Incorporated in the United States and other countries. Other brand product
names are registered trademarks or trademarks of their respective holders.
All rights reserved.
*/
#ifndef _OPEN_WITH_WINDOW_H
#define _OPEN_WITH_WINDOW_H
// OpenWithContainerWindow supports the Open With feature
#include <String.h>
#include "ContainerWindow.h"
@@ -45,12 +48,11 @@ All rights reserved.
#include "SlowMenu.h"
#include "Utilities.h"
namespace BPrivate {
class OpenWithPoseView;
// OpenWithContainerWindow supports the Open With feature
enum {
kUnknownRelation = -1,
kNoRelation = 0,
@@ -61,6 +63,7 @@ enum {
kPreferredForFile
};
// pass in a predicate; a query will search for matches
// matches will be returned in iteration
class SearchForSignatureEntryList : public EntryListBase {
@@ -127,6 +130,7 @@ class SearchForSignatureEntryList : public EntryListBase {
bool fFoundOneNonSuperHandler;
};
class OpenWithContainerWindow : public BContainerWindow {
public:
OpenWithContainerWindow(BMessage* entriesToOpen,
@@ -185,6 +189,7 @@ class OpenWithContainerWindow : public BContainerWindow {
typedef BContainerWindow _inherited;
};
class OpenWithPoseView : public BPoseView {
public:
OpenWithPoseView(BRect, uint32 resizeMask = B_FOLLOW_ALL);
@@ -249,6 +254,7 @@ class OpenWithPoseView : public BPoseView {
typedef BPoseView _inherited;
};
class RelationCachingModelProxy {
public:
RelationCachingModelProxy(Model* model);
@@ -260,6 +266,7 @@ class RelationCachingModelProxy {
mutable int32 fRelation;
};
class OpenWithMenu : public BSlowMenu {
public:
OpenWithMenu(const char* label, const BMessage* entriesToOpen,
@@ -290,6 +297,7 @@ class OpenWithMenu : public BSlowMenu {
typedef BSlowMenu _inherited;
};
// used for optionally showing the list of all apps. Do nothing
// until asked to iterate and only if supposed to do so
class ConditionalAllAppsIterator : public EntryListBase {
+7
View File
@@ -34,11 +34,13 @@ All rights reserved.
// defines the status area drawn in the bottom left corner of a Tracker window
#include <Button.h>
#include <Screen.h>
#include "OverrideAlert.h"
OverrideAlert::OverrideAlert(const char* title, const char* text,
const char* button1, uint32 modifiers1,
const char* button2, uint32 modifiers2,
@@ -56,6 +58,7 @@ OverrideAlert::OverrideAlert(const char *title, const char *text,
MoveTo(where.x, where.y);
}
OverrideAlert::OverrideAlert(const char* title, const char* text,
const char* button1, uint32 modifiers1,
const char* button2, uint32 modifiers2,
@@ -73,10 +76,12 @@ OverrideAlert::OverrideAlert(const char *title, const char *text,
MoveTo(where.x, where.y);
}
OverrideAlert::~OverrideAlert()
{
}
void
OverrideAlert::DispatchMessage(BMessage* message, BHandler* handler)
{
@@ -90,6 +95,7 @@ OverrideAlert::DispatchMessage(BMessage *message, BHandler *handler)
BAlert::DispatchMessage(message, handler);
}
BPoint
OverrideAlert::OverPosition(float width, float height)
{
@@ -133,6 +139,7 @@ OverrideAlert::OverPosition(float width, float height)
return desirableRect.LeftTop();
}
void
OverrideAlert::UpdateButtons(uint32 modifiers, bool force)
{
+3 -2
View File
@@ -31,7 +31,6 @@ of Be Incorporated in the United States and other countries. Other brand product
names are registered trademarks or trademarks of their respective holders.
All rights reserved.
*/
#ifndef _OVERRIDE_ALERT_H
#define _OVERRIDE_ALERT_H
@@ -45,8 +44,10 @@ All rights reserved.
// This allows it to work when confirming rename operations with
// Focus Follows Mouse turned on.
#include <Alert.h>
namespace BPrivate {
class OverrideAlert : public BAlert {
@@ -80,4 +81,4 @@ private:
using namespace BPrivate;
#endif
#endif // _OVERRIDE_ALERT_H
+12 -2
View File
@@ -32,13 +32,16 @@ names are registered trademarks or trademarks of their respective holders.
All rights reserved.
*/
#include "PendingNodeMonitorCache.h"
#include "PoseView.h"
const bigtime_t kDelayedNodeMonitorLifetime = 10000000;
// after this much the pending node monitor gets discarded as
// too old
PendingNodeMonitorEntry::PendingNodeMonitorEntry(const node_ref* node,
const BMessage* nodeMonitor)
: fExpiresAfter(system_time() + kDelayedNodeMonitorLifetime),
@@ -47,18 +50,21 @@ PendingNodeMonitorEntry::PendingNodeMonitorEntry(const node_ref *node,
{
}
const BMessage*
PendingNodeMonitorEntry::NodeMonitor() const
{
return &fNodeMonitor;
}
bool
PendingNodeMonitorEntry::Match(const node_ref* node) const
{
return fNode == *node;
}
bool
PendingNodeMonitorEntry::TooOld(bigtime_t now) const
{
@@ -76,6 +82,7 @@ PendingNodeMonitorCache::~PendingNodeMonitorCache()
{
}
void
PendingNodeMonitorCache::Add(const BMessage* message)
{
@@ -91,6 +98,7 @@ PendingNodeMonitorCache::Add(const BMessage *message)
fList.AddItem(new PendingNodeMonitorEntry(&node, message));
}
void
PendingNodeMonitorCache::RemoveEntries(const node_ref* nodeRef)
{
@@ -100,6 +108,7 @@ PendingNodeMonitorCache::RemoveEntries(const node_ref *nodeRef)
delete fList.RemoveItemAt(index);
}
void
PendingNodeMonitorCache::RemoveOldEntries()
{
@@ -112,8 +121,10 @@ PendingNodeMonitorCache::RemoveOldEntries()
}
}
void
PendingNodeMonitorCache::PoseCreatedOrMoved(BPoseView *poseView, const BPose *pose)
PendingNodeMonitorCache::PoseCreatedOrMoved(BPoseView* poseView,
const BPose* pose)
{
bigtime_t now = system_time();
for (int32 index = 0; index < fList.CountItems();) {
@@ -136,4 +147,3 @@ PendingNodeMonitorCache::PoseCreatedOrMoved(BPoseView *poseView, const BPose *po
index++;
}
}
+4 -3
View File
@@ -39,15 +39,16 @@ All rights reserved.
// The respective node montior messages are stored in a list and applied
// later, when their target shows up. They get nuked when they become too
// old.
#ifndef __PENDING_NODEMONITOR_CACHE_H__
#define __PENDING_NODEMONITOR_CACHE_H__
#include <Message.h>
#include <Node.h>
#include "ObjectList.h"
namespace BPrivate {
class BPoseView;
@@ -66,6 +67,7 @@ private:
node_ref fNode;
};
class PendingNodeMonitorCache {
public:
PendingNodeMonitorCache();
@@ -85,5 +87,4 @@ private:
using namespace BPrivate;
#endif
#endif // __PENDING_NODEMONITOR_CACHE_H__
+2 -3
View File
@@ -32,6 +32,7 @@ names are registered trademarks or trademarks of their respective holders.
All rights reserved.
*/
#include <stdlib.h>
#include <string.h>
@@ -68,7 +69,6 @@ CalcFreeSpace(BVolume *volume)
// symlink pose uses the resolved model to retrieve the icon, if not broken
// everything else, like the attributes, etc. is retrieved directly from the
// symlink itself
BPose::BPose(Model* model, BPoseView* view, uint32 clipboardMode, bool selected)
: fModel(model),
fWidgetList(4, true),
@@ -767,14 +767,13 @@ BPose::WidgetFor(BColumn *column, BPoseView *poseView, ModelNodeLazyOpener &open
}
/* deprecated */
// the following method is deprecated
bool
BPose::TestLargeIconPixel(BPoint point) const
{
return IconCache::sIconCache->IconHitTest(point, ResolvedModel(),
kNormalIcon, B_LARGE_ICON);
}
/* deprecated */
void
+5 -4
View File
@@ -31,16 +31,17 @@ of Be Incorporated in the United States and other countries. Other brand product
names are registered trademarks or trademarks of their respective holders.
All rights reserved.
*/
#ifndef _POSE_H
#define _POSE_H
#include <Region.h>
#include "TextWidget.h"
#include "Model.h"
#include "Utilities.h"
namespace BPrivate {
class BPoseView;
@@ -85,8 +86,8 @@ class BPose {
BTextWidget* ActiveWidget() const;
BTextWidget* WidgetFor(uint32 hashAttr, int32* index = 0) const;
BTextWidget *WidgetFor(BColumn *column, BPoseView *poseView, ModelNodeLazyOpener &opener,
int32 *index = NULL);
BTextWidget* WidgetFor(BColumn* column, BPoseView* poseView,
ModelNodeLazyOpener &opener, int32* index = NULL);
// adds the widget if needed
bool PointInPose(BPoint poseLoc, const BPoseView*, BPoint where,
@@ -258,4 +259,4 @@ BPose::SetClipboardMode(uint32 clipboardMode)
using namespace BPrivate;
#endif
#endif // _POSE_H
+7
View File
@@ -51,12 +51,14 @@ PoseList::FindPose(const node_ref *node, int32 *resultingIndex) const
if (*pose->TargetModel()->NodeRef() == *node) {
if (resultingIndex)
*resultingIndex = index;
return pose;
}
}
return NULL;
}
BPose*
PoseList::FindPose(const entry_ref* entry, int32* resultingIndex) const
{
@@ -67,18 +69,21 @@ PoseList::FindPose(const entry_ref *entry, int32 *resultingIndex) const
if (*pose->TargetModel()->EntryRef() == *entry) {
if (resultingIndex)
*resultingIndex = index;
return pose;
}
}
return NULL;
}
BPose*
PoseList::FindPose(const Model* model, int32* resultingIndex) const
{
return FindPose(model->NodeRef(), resultingIndex);
}
BPose*
PoseList::DeepFindPose(const node_ref* node, int32* resultingIndex) const
{
@@ -89,6 +94,7 @@ PoseList::DeepFindPose(const node_ref *node, int32 *resultingIndex) const
if (*model->NodeRef() == *node) {
if (resultingIndex)
*resultingIndex = index;
return pose;
}
// if model is a symlink, try matching node with the target
@@ -98,6 +104,7 @@ PoseList::DeepFindPose(const node_ref *node, int32 *resultingIndex) const
if (model && *model->NodeRef() == *node) {
if (resultingIndex)
*resultingIndex = index;
return pose;
}
}
+8 -3
View File
@@ -31,16 +31,18 @@ of Be Incorporated in the United States and other countries. Other brand product
names are registered trademarks or trademarks of their respective holders.
All rights reserved.
*/
#ifndef _POSE_LIST_H
#define _POSE_LIST_H
// PoseList is a commonly used instance of BObjectList<BPose>
// Defines convenience find and iteration calls
#ifndef _POSE_LIST_H
#define _POSE_LIST_H
#include "ObjectList.h"
#include "Pose.h"
struct node_ref;
struct entry_ref;
@@ -68,6 +70,7 @@ public:
// iteration glue, add permutations as needed
template<class EachParam1>
void
EachPoseAndModel(PoseList* list, void (*eachFunction)(BPose*, Model*, EachParam1),
@@ -81,6 +84,7 @@ EachPoseAndModel(PoseList *list, void (*eachFunction)(BPose *, Model *, EachPara
}
}
template<class EachParam1>
void
EachPoseAndModel(PoseList* list, void (*eachFunction)(BPose*, Model*, int32 ,
@@ -94,6 +98,7 @@ EachPoseAndModel(PoseList *list, void (*eachFunction)(BPose *, Model *, int32 ,
}
}
template<class EachParam1, class EachParam2>
void
EachPoseAndModel(PoseList* list, void (*eachFunction)(BPose*, Model*, EachParam1,
@@ -176,4 +181,4 @@ EachPoseAndResolvedModel(PoseList *list, void (*eachFunction)(BPose *, Model *,
using namespace BPrivate;
#endif
#endif // _POSE_LIST_H
+5 -6
View File
@@ -32,6 +32,7 @@ names are registered trademarks or trademarks of their respective holders.
All rights reserved.
*/
#include "PoseView.h"
#include <algorithm>
@@ -149,13 +150,11 @@ const BPoint kTransparentDragThreshold(256, 192);
// maximum size of the transparent drag bitmap, use a drag rect
// if larger in any direction
struct attr_column_relation {
uint32 attrHash;
int32 fieldMask;
};
static struct attr_column_relation sAttrColumnMap[] = {
{ AttrHashString(kAttrStatModified, B_TIME_TYPE),
B_STAT_MODIFICATION_TIME },
@@ -167,7 +166,6 @@ static struct attr_column_relation sAttrColumnMap[] = {
B_STAT_MODE }
};
struct AddPosesResult {
~AddPosesResult();
void ReleaseModels();
@@ -7307,8 +7305,9 @@ BPoseView::SelectPosesListMode(BRect selectionRect, BList **oldList)
if (selectionRect.Intersects(poseRect)) {
bool selected = pose->IsSelected();
pose->Select(!fSelectionList->HasItem(pose));
newList->AddItem((void *)index); // this sucks, need to clean up
// using a vector class instead of BList
newList->AddItem((void*)index);
// this sucks, need to clean up using a vector class instead
// of BList
if ((selected != pose->IsSelected()) && poseRect.Intersects(bounds)) {
Invalidate(poseRect);
@@ -8468,7 +8467,7 @@ rgb_color
BPoseView::DeskTextColor() const
{
rgb_color color = ViewColor();
float thresh = color.red + (color.green * 1.5f) + (color.blue * .50f);
float thresh = color.red + (color.green * 1.5f) + (color.blue * 0.50f);
if (thresh >= 300) {
color.red = 0;
+4 -4
View File
@@ -31,16 +31,16 @@ of Be Incorporated in the United States and other countries. Other brand product
names are registered trademarks or trademarks of their respective holders.
All rights reserved.
*/
#ifndef _POSE_VIEW_H
#define _POSE_VIEW_H
//
// BPoseView is a container for poses, handling all of the interaction, drawing,
// etc. The three different view modes are handled here.
//
// this is by far the fattest Tracker class and over time will undergo a lot of
// trimming
#ifndef _POSE_VIEW_H
#define _POSE_VIEW_H
#include "AttributeStream.h"
#include "ContainerWindow.h"
@@ -1185,4 +1185,4 @@ WhileEachTextWidget(BPose *pose, BPoseView *poseView,
using namespace BPrivate;
#endif /* _POSE_VIEW_H */
#endif // _POSE_VIEW_H
+18 -4
View File
@@ -203,6 +203,7 @@ const property_info kPosesPropertyList[] = {
#endif
status_t
BPoseView::GetSupportedSuites(BMessage* _SCRIPTING_ONLY(data))
{
@@ -217,6 +218,7 @@ BPoseView::GetSupportedSuites(BMessage *_SCRIPTING_ONLY(data))
#endif
}
bool
BPoseView::HandleScriptingMessage(BMessage* _SCRIPTING_ONLY(message))
{
@@ -271,15 +273,18 @@ BPoseView::HandleScriptingMessage(BMessage *_SCRIPTING_ONLY(message))
break;
}
if (handled)
if (handled) {
// done handling message, send a reply
message->SendReply(&reply);
}
return handled;
#else
return false;
#endif
}
bool
BPoseView::ExecuteProperty(BMessage* _SCRIPTING_ONLY(specifier),
int32 _SCRIPTING_ONLY(form), const char* _SCRIPTING_ONLY(property),
@@ -334,6 +339,7 @@ BPoseView::ExecuteProperty(BMessage *_SCRIPTING_ONLY(specifier),
#endif
}
bool
BPoseView::CreateProperty(BMessage* _SCRIPTING_ONLY(specifier), BMessage*,
int32 _SCRIPTING_ONLY(form), const char* _SCRIPTING_ONLY(property),
@@ -396,6 +402,7 @@ BPoseView::CreateProperty(BMessage *_SCRIPTING_ONLY(specifier), BMessage *,
#endif
}
bool
BPoseView::DeleteProperty(BMessage* _SCRIPTING_ONLY(specifier),
int32 _SCRIPTING_ONLY(form), const char* _SCRIPTING_ONLY(property),
@@ -498,6 +505,7 @@ BPoseView::DeleteProperty(BMessage *_SCRIPTING_ONLY(specifier),
#endif
}
bool
BPoseView::CountProperty(BMessage*, int32, const char* _SCRIPTING_ONLY(property),
BMessage* _SCRIPTING_ONLY(reply))
@@ -520,6 +528,7 @@ BPoseView::CountProperty(BMessage *, int32, const char *_SCRIPTING_ONLY(property
#endif
}
bool
BPoseView::GetProperty(BMessage* _SCRIPTING_ONLY(specifier),
int32 _SCRIPTING_ONLY(form), const char* _SCRIPTING_ONLY(property),
@@ -588,12 +597,15 @@ BPoseView::GetProperty(BMessage *_SCRIPTING_ONLY(specifier),
int32 count = fPoseList->CountItems();
switch (form) {
case B_DIRECT_SPECIFIER:
{
// return all entries of all poses in PoseView
for (int32 index = 0; index < count; index++)
reply->AddRef("result", PoseAtIndex(index)->TargetModel()->EntryRef());
handled = true;
break;
}
case B_INDEX_SPECIFIER:
{
// return entry at index
@@ -611,6 +623,7 @@ BPoseView::GetProperty(BMessage *_SCRIPTING_ONLY(specifier),
handled = true;
break;
}
case kPreviousSpecifier:
case kNextSpecifier:
{
@@ -646,6 +659,7 @@ BPoseView::GetProperty(BMessage *_SCRIPTING_ONLY(specifier),
#endif
}
bool
BPoseView::SetProperty(BMessage* _SCRIPTING_ONLY(message), BMessage*,
int32 _SCRIPTING_ONLY(form), const char* _SCRIPTING_ONLY(property),
@@ -677,8 +691,7 @@ BPoseView::SetProperty(BMessage *_SCRIPTING_ONLY(message), BMessage *,
handled = true;
break;
}
}
// fall thru
} // fall thru
case kPreviousSpecifier:
case kNextSpecifier:
{
@@ -721,6 +734,7 @@ BPoseView::SetProperty(BMessage *_SCRIPTING_ONLY(message), BMessage *,
#endif
}
BHandler*
BPoseView::ResolveSpecifier(BMessage* _SCRIPTING_ONLY(message),
int32 _SCRIPTING_ONLY(index), BMessage* _SCRIPTING_ONLY(specifier),
@@ -742,6 +756,7 @@ BPoseView::ResolveSpecifier(BMessage *_SCRIPTING_ONLY(message),
#endif
}
BPose*
BPoseView::FindPose(const entry_ref* _SCRIPTING_ONLY(ref),
int32 _SCRIPTING_ONLY(specifierForm), int32* _SCRIPTING_ONLY(index)) const
@@ -761,4 +776,3 @@ BPoseView::FindPose(const entry_ref *_SCRIPTING_ONLY(ref),
return NULL;
#endif
}
+3 -2
View File
@@ -31,12 +31,13 @@ of Be Incorporated in the United States and other countries. Other brand product
names are registered trademarks or trademarks of their respective holders.
All rights reserved.
*/
#ifndef __PUBLIC_COMMANDS__
#define __PUBLIC_COMMANDS__
#include <SupportDefs.h>
// commands that may be issued to the tracker by other apps using messengers
namespace BPrivate {
@@ -56,4 +57,4 @@ const uint32 kFSClipboardChanges = 'TCch';
using namespace BPrivate;
#endif /* __PUBLIC_COMMANDS__ */
#endif // __PUBLIC_COMMANDS__
+1 -1
View File
@@ -32,6 +32,7 @@ names are registered trademarks or trademarks of their respective holders.
All rights reserved.
*/
#include <Catalog.h>
#include <Locale.h>
#include <Menu.h>
@@ -192,4 +193,3 @@ BQueryContainerWindow::ActiveOnDevice(dev_t device) const
{
return PoseView()->ActiveOnDevice(device);
}
+6 -5
View File
@@ -31,18 +31,19 @@ of Be Incorporated in the United States and other countries. Other brand product
names are registered trademarks or trademarks of their respective holders.
All rights reserved.
*/
#ifndef _QUERY_CONTAINER_WINDOW_H
#define _QUERY_CONTAINER_WINDOW_H
#include "ContainerWindow.h"
namespace BPrivate {
// Container window specificaly used for displaying BQueryPoseViews
// Adds query window specific menus
#include "ContainerWindow.h"
namespace BPrivate {
#define kQueryTemplates "DefaultQueryTemplates"
class BQueryPoseView;
@@ -75,4 +76,4 @@ private:
using namespace BPrivate;
#endif
#endif // _QUERY_CONTAINER_WINDOW_H
+21 -11
View File
@@ -31,6 +31,8 @@ of Be Incorporated in the United States and other countries. Other brand product
names are registered trademarks or trademarks of their respective holders.
All rights reserved.
*/
#include "QueryPoseView.h"
#include <new>
@@ -280,7 +282,8 @@ BQueryPoseView::InitDirentIterator(const entry_ref *ref)
// calculate the time to trigger the query refresh - next midnight
time_t now = time(0);
time_t nextMidnight = now + 60 * 60 * 24; // move ahead by a day
time_t nextMidnight = now + 60 * 60 * 24;
// move ahead by a day
tm timeData;
localtime_r(&nextMidnight, &timeData);
timeData.tm_sec = 0;
@@ -288,7 +291,8 @@ BQueryPoseView::InitDirentIterator(const entry_ref *ref)
timeData.tm_hour = 0;
nextMidnight = mktime(&timeData);
time_t nextHour = now + 60 * 60; // move ahead by a hour
time_t nextHour = now + 60 * 60;
// move ahead by a hour
localtime_r(&nextHour, &timeData);
timeData.tm_sec = 0;
timeData.tm_min = 0;
@@ -297,7 +301,8 @@ BQueryPoseView::InitDirentIterator(const entry_ref *ref)
PRINT(("%ld minutes, %ld seconds till next hour\n", (nextHour - now) / 60,
(nextHour - now) % 60));
time_t nextMinute = now + 60; // move ahead by a minute
time_t nextMinute = now + 60;
// move ahead by a minute
localtime_r(&nextMinute, &timeData);
timeData.tm_sec = 0;
nextMinute = mktime(&timeData);
@@ -358,6 +363,7 @@ BQueryPoseView::SearchForType() const
BModelOpener opener(TargetModel());
BString buffer;
attr_info attrInfo;
// read the type of files we are looking for
status_t status = TargetModel()->Node()->GetAttrInfo(kAttrQueryInitialMime, &attrInfo);
if (status == B_OK)
@@ -369,9 +375,9 @@ BQueryPoseView::SearchForType() const
const ShortMimeInfo* info = tracker->MimeTypes()->FindMimeType(buffer.String());
if (info)
fSearchForMimeType = info->InternalName();
}
}
}
}
if (!fSearchForMimeType.Length())
fSearchForMimeType = B_FILE_MIMETYPE;
}
@@ -426,8 +432,9 @@ QueryEntryListCollection::QueryEntryListCollection(Model *model, BHandler *targe
MoreOptionsStruct saveMoreOptions;
if (ReadAttr(model->Node(), kAttrQueryMoreOptions, kAttrQueryMoreOptionsForeign,
B_RAW_TYPE, 0, &saveMoreOptions, sizeof(MoreOptionsStruct),
&MoreOptionsStruct::EndianSwap) != kReadAttrFailed)
&MoreOptionsStruct::EndianSwap) != kReadAttrFailed) {
fQueryListRep->fShowResultsFromTrash = saveMoreOptions.searchTrash;
}
fStatus = query.SetPredicate(buffer.String());
@@ -438,8 +445,9 @@ QueryEntryListCollection::QueryEntryListCollection(Model *model, BHandler *targe
fQueryListRep->fRefreshEveryMinute = false;
if (model->Node()->ReadAttr(kAttrDynamicDateQuery, B_BOOL_TYPE, 0,
&fQueryListRep->fDynamicDateQuery, sizeof(bool)) != sizeof(bool))
&fQueryListRep->fDynamicDateQuery, sizeof(bool)) != sizeof(bool)) {
fQueryListRep->fDynamicDateQuery = false;
}
if (fQueryListRep->fDynamicDateQuery) {
// only refresh every minute on debug builds
@@ -483,7 +491,7 @@ QueryEntryListCollection::QueryEntryListCollection(Model *model, BHandler *targe
continue;
searchAllVolumes = false;
} else if (result != B_DEV_BAD_DRIVE_NUM)
} else if (result != B_DEV_BAD_DRIVE_NUM) {
// if B_DEV_BAD_DRIVE_NUM, the volume just isn't mounted this
// time around, keep looking for more
// if other error, bail
@@ -491,6 +499,7 @@ QueryEntryListCollection::QueryEntryListCollection(Model *model, BHandler *targe
}
}
}
}
free(buffer);
}
@@ -503,7 +512,8 @@ QueryEntryListCollection::QueryEntryListCollection(Model *model, BHandler *targe
roster.Rewind();
while (roster.GetNextVolume(&volume) == B_OK)
if (volume.IsPersistent() && volume.KnowsQuery()) {
result = FetchOneQuery(&query, target, fQueryListRep->fQueryList, &volume);
result = FetchOneQuery(&query, target,
fQueryListRep->fQueryList, &volume);
if (result != B_OK)
continue;
}
@@ -521,9 +531,9 @@ QueryEntryListCollection::FetchOneQuery(const BQuery *copyThis,
BQuery* query = new (nothrow) BQuery;
if (query == NULL)
return B_NO_MEMORY;
// have to fake a copy constructor here because BQuery doesn't have
// a copy constructor
BString buffer;
const_cast<BQuery*>(copyThis)->GetPredicate(&buffer);
query->SetPredicate(buffer.String());
@@ -537,6 +547,7 @@ QueryEntryListCollection::FetchOneQuery(const BQuery *copyThis,
delete query;
return result;
}
list->AddItem(query);
return B_OK;
@@ -672,4 +683,3 @@ QueryEntryListCollection::DynamicDateRefreshEveryMinute() const
{
return fQueryListRep->fRefreshEveryMinute;
}
+4 -5
View File
@@ -31,15 +31,16 @@ of Be Incorporated in the United States and other countries. Other brand product
names are registered trademarks or trademarks of their respective holders.
All rights reserved.
*/
#ifndef _QUERY_POSE_VIEW_H
#define _QUERY_POSE_VIEW_H
class BQuery;
#include "EntryIterator.h"
#include "PoseView.h"
class BQuery;
namespace BPrivate {
class BQueryContainerWindow;
@@ -99,7 +100,6 @@ class QueryEntryListCollection : public EntryListBase {
// elements that behave as an EntryList
// For now just manage a list of BQueries
class QueryListRep {
public:
QueryListRep(BObjectList<BQuery>* queryList)
@@ -141,7 +141,6 @@ class QueryEntryListCollection : public EntryListBase {
};
public:
QueryEntryListCollection(Model*, BHandler* = NULL, PoseList* oldPoseList = NULL);
virtual ~QueryEntryListCollection();
@@ -180,4 +179,4 @@ private:
using namespace BPrivate;
#endif
#endif // _QUERY_POSE_VIEW_H
+28 -29
View File
@@ -31,19 +31,20 @@ of Be Incorporated in the United States and other countries. Other brand product
names are registered trademarks or trademarks of their respective holders.
All rights reserved.
*/
#ifndef __RECENT_ITEMS_LIST__
#define __RECENT_ITEMS_LIST__
// BRecentItemsList classes allow creating an entire menu with
// recent files, folders, apps. If the user wishes to add items to
// their own menu, they can instead use the GetNextMenuItem call to
// get one menu at a time to add it to their app.
#include <Entry.h>
#include <Message.h>
#include <String.h>
/* BRecentItemsList classes allow creating an entire menu with
* recent files, folders, apps. If the user wishes to add items to
* their own menu, they can instead use the GetNextMenuItem call to
* get one menu at a time to add it to their app.
*/
class BMenuItem;
class BMenu;
@@ -51,27 +52,25 @@ class BMenu;
class BRecentItemsList {
public:
BRecentItemsList(int32 maxItems, bool navMenuFolders);
/* if <navMenuFolders> passed, folder items get NavMenu-style
* subdirectories attached to them
*/
// if <navMenuFolders> passed, folder items get NavMenu-style
// subdirectories attached to them
virtual ~BRecentItemsList() {}
virtual void Rewind();
/* resets the iteration */
// resets the iteration
virtual BMenuItem* GetNextMenuItem(const BMessage* fileOpenMessage = NULL,
const BMessage* containerOpenMessage = NULL,
BHandler* target = NULL, entry_ref* currentItemRef = NULL);
/* if <fileOpenMessage> specified, the item for a file gets a copy with
* the item ref attached as "refs", otherwise a default B_REFS_RECEIVED
* message message gets attached
* if <containerOpenMessage> specified, the item for a folder, volume or query
* gets a copy with the item ref attached as "refs", otherwise a default
* B_REFS_RECEIVED message message gets attached
* if <currentItemRef> gets passed, the caller gets to look at the
* entry_ref corresponding to the item
*/
// if <fileOpenMessage> specified, the item for a file gets a copy with
// the item ref attached as "refs", otherwise a default B_REFS_RECEIVED
// message message gets attached
// if <containerOpenMessage> specified, the item for a folder, volume or query
// gets a copy with the item ref attached as "refs", otherwise a default
// B_REFS_RECEIVED message message gets attached
// if <currentItemRef> gets passed, the caller gets to look at the
// entry_ref corresponding to the item
virtual status_t GetNextRef(entry_ref*);
@@ -82,7 +81,6 @@ protected:
bool fNavMenuFolders;
private:
virtual void _r1();
virtual void _r2();
virtual void _r3();
@@ -97,17 +95,17 @@ private:
uint32 _reserved[20];
};
class BRecentFilesList : public BRecentItemsList {
public:
/* use one of the two constructors to set up next item iteration */
// use one of the two constructors to set up next item iteration
BRecentFilesList(int32 maxItems = 10, bool navMenuFolders = false,
const char* ofType = NULL, const char* openedByAppSig = NULL);
BRecentFilesList(int32 maxItems, bool navMenuFolders, const char* ofTypeList[],
int32 ofTypeListCount, const char* openedByAppSig = NULL);
virtual ~BRecentFilesList();
/* use one of the two NewFileListMenu calls to get an entire menu */
// use one of the two NewFileListMenu calls to get an entire menu
static BMenu* NewFileListMenu(const char* title,
BMessage* openFileMessage = NULL, BMessage* openFolderMessage = NULL,
BHandler* target = NULL,
@@ -124,7 +122,6 @@ public:
virtual status_t GetNextRef(entry_ref*);
protected:
BString fType;
char** fTypes;
int32 fTypeCount;
@@ -145,13 +142,14 @@ private:
uint32 _reserved[20];
};
class BRecentFoldersList : public BRecentItemsList {
public:
/* use the constructor to set up next item iteration */
// use the constructor to set up next item iteration
BRecentFoldersList(int32 maxItems, bool navMenuFolders = false,
const char* openedByAppSig = NULL);
/* use NewFolderListMenu to get an entire menu */
// use NewFolderListMenu to get an entire menu
static BMenu* NewFolderListMenu(const char* title,
BMessage* openMessage = NULL, BHandler* target = NULL,
int32 maxItems = 10, bool navMenuFolders = false,
@@ -177,12 +175,13 @@ private:
uint32 _reserved[20];
};
class BRecentAppsList : public BRecentItemsList {
public:
/* use the constructor to set up next item iteration */
// use the constructor to set up next item iteration
BRecentAppsList(int32 maxItems);
/* use NewFolderListMenu to get an entire menu */
// use NewFolderListMenu to get an entire menu
static BMenu* NewAppListMenu(const char* title,
BMessage* openMessage = NULL, BHandler* target = NULL,
int32 maxItems = 10);
@@ -204,4 +203,4 @@ private:
uint32 _reserved[20];
};
#endif
#endif // __RECENT_ITEMS_LIST__
+37 -7
View File
@@ -61,6 +61,7 @@ All rights reserved.
// ALTERED VERSION: Adapted to ANSI C and C++ for the OpenTracker
// project (www.opentracker.org), Jul 11, 2000.
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
@@ -69,6 +70,7 @@ All rights reserved.
#include "RegExp.h"
// The first byte of the regexp internal "program" is actually this magic
// number; the start node begins in the second byte.
@@ -200,6 +202,7 @@ RegExp::RegExp()
{
}
RegExp::RegExp(const char* pattern)
: fError(B_OK),
fRegExp(NULL)
@@ -207,6 +210,7 @@ RegExp::RegExp(const char *pattern)
fRegExp = Compile(pattern);
}
RegExp::RegExp(const BString &pattern)
: fError(B_OK),
fRegExp(NULL)
@@ -214,19 +218,20 @@ RegExp::RegExp(const BString &pattern)
fRegExp = Compile(pattern.String());
}
RegExp::~RegExp()
{
free(fRegExp);
}
status_t
RegExp::InitCheck() const
{
return fError;
}
status_t
RegExp::SetTo(const char* pattern)
{
@@ -236,6 +241,7 @@ RegExp::SetTo(const char *pattern)
return fError;
}
status_t
RegExp::SetTo(const BString &pattern)
{
@@ -245,6 +251,7 @@ RegExp::SetTo(const BString &pattern)
return fError;
}
bool
RegExp::Matches(const char* string) const
{
@@ -254,6 +261,7 @@ RegExp::Matches(const char *string) const
return RunMatcher(fRegExp, string) == 1;
}
bool
RegExp::Matches(const BString &string) const
{
@@ -278,7 +286,6 @@ RegExp::Matches(const BString &string) const
//
// Beware that the optimization-preparation code in here knows about some
// of the structure of the compiled regexp.
regexp*
RegExp::Compile(const char* exp)
{
@@ -308,8 +315,8 @@ RegExp::Compile(const char *exp)
return NULL;
}
// Allocate space.
r = (regexp*)malloc(sizeof(regexp) + fCodeSize);
// Allocate space
if (!r) {
SetError(B_NO_MEMORY);
@@ -331,8 +338,10 @@ RegExp::Compile(const char *exp)
r->reganch = 0;
r->regmust = NULL;
r->regmlen = 0;
scan = r->program + 1; // First kRegExpBranch.
if (*Next((char *)scan) == kRegExpEnd) { // Only one top-level choice.
scan = r->program + 1;
// First kRegExpBranch.
if (*Next((char*)scan) == kRegExpEnd) {
// Only one top-level choice.
scan = Operand(scan);
// Starting-point info.
@@ -341,14 +350,12 @@ RegExp::Compile(const char *exp)
else if (*scan == kRegExpBol)
r->reganch++;
//
// If there's something expensive in the r.e., find the
// longest literal string that must appear and make it the
// regmust. Resolve ties in favor of later strings, since
// the regstart check works with the beginning of the r.e.
// and avoiding duplication strengthens checking. Not a
// strong reason, but sufficient in the absence of others.
//
if (flags&kSPStart) {
longest = NULL;
len = 0;
@@ -365,12 +372,14 @@ RegExp::Compile(const char *exp)
return r;
}
regexp*
RegExp::Expression() const
{
return fRegExp;
}
const char*
RegExp::ErrorString() const
{
@@ -469,6 +478,7 @@ RegExp::Reg(int32 paren, int32 *flagp)
return ret;
}
//
// - Branch - one alternative of an | operator
//
@@ -505,6 +515,7 @@ RegExp::Branch(int32 *flagp)
return ret;
}
//
// - Piece - something followed by possible [*+?]
//
@@ -572,6 +583,7 @@ RegExp::Piece(int32 *flagp)
return ret;
}
//
// - Atom - the lowest level
//
@@ -695,6 +707,7 @@ RegExp::Atom(int32 *flagp)
return ret;
}
//
// - Node - emit a node
//
@@ -719,6 +732,7 @@ RegExp::Node(char op)
return ret;
}
//
// - Char - emit (if appropriate) a byte of code
//
@@ -731,6 +745,7 @@ RegExp::Char(char b)
fCodeSize++;
}
//
// - Insert - insert an operator in front of already-emitted operand
//
@@ -760,6 +775,7 @@ RegExp::Insert(char op, char *opnd)
*place++ = '\0';
}
//
// - Tail - set the next-pointer at the end of a node chain
//
@@ -791,6 +807,7 @@ RegExp::Tail(char *p, char *val)
scan[2] = (char)(offset & 0377);
}
//
// - OpTail - Tail on operand of first argument; nop if operandless
//
@@ -807,6 +824,7 @@ RegExp::OpTail(char *p, char *val)
// RunMatcher and friends
//
//
// - RunMatcher - match a regexp against a string
//
@@ -866,6 +884,7 @@ RegExp::RunMatcher(regexp *prog, const char *string) const
return 0;
}
//
// - Try - try match at specific point
//
@@ -894,6 +913,7 @@ RegExp::Try(regexp *prog, const char *string) const
return 0;
}
//
// - Match - main matching routine
//
@@ -1092,6 +1112,7 @@ RegExp::Match(const char *prog) const
return 0;
}
//
// - Repeat - repeatedly match something simple, report how many
//
@@ -1141,6 +1162,7 @@ RegExp::Repeat(const char *p) const
return count;
}
//
// - Next - dig the "next" pointer out of a node
//
@@ -1162,6 +1184,7 @@ RegExp::Next(char *p)
return p + offset;
}
const char*
RegExp::Next(const char* p) const
{
@@ -1180,24 +1203,28 @@ RegExp::Next(const char *p) const
return p + offset;
}
inline int32
RegExp::UCharAt(const char* p) const
{
return (int32)*(unsigned char *)p;
}
inline char*
RegExp::Operand(char* p) const
{
return p + 3;
}
inline const char*
RegExp::Operand(const char* p) const
{
return p + 3;
}
inline bool
RegExp::IsMult(char c) const
{
@@ -1207,6 +1234,7 @@ RegExp::IsMult(char c) const
#ifdef DEBUG
//
// - Dump - dump a regexp onto stdout in vaguely comprehensible form
//
@@ -1248,6 +1276,7 @@ RegExp::Dump()
printf("\n");
}
//
// - Prop - printable representation of opcode
//
@@ -1331,6 +1360,7 @@ RegExp::Prop(const char *op) const
return buf;
}
void
RegExp::RegExpError(const char*) const
{
+16 -14
View File
@@ -31,6 +31,8 @@ of Be Incorporated in the United States and other countries. Other brand product
names are registered trademarks or trademarks of their respective holders.
All rights reserved.
*/
#ifndef _REG_EXP_H
#define _REG_EXP_H
// This code is based on regexp.c, v.1.3 by Henry Spencer:
@@ -62,13 +64,13 @@ All rights reserved.
// ALTERED VERSION: Adapted to ANSI C and C++ for the OpenTracker
// project (www.opentracker.org), Jul 11, 2000.
#ifndef _REG_EXP_H
#define _REG_EXP_H
#include <String.h>
namespace BPrivate {
enum {
REGEXP_UNMATCHED_PARENTHESIS = B_ERRORS_END,
REGEXP_TOO_BIG,
@@ -92,15 +94,15 @@ const int32 kSubExpressionMax = 10;
struct regexp {
const char* startp[kSubExpressionMax];
const char* endp[kSubExpressionMax];
char regstart; /* Internal use only. See RegExp.cpp for details. */
char reganch; /* Internal use only. */
const char *regmust;/* Internal use only. */
int regmlen; /* Internal use only. */
char program[1]; /* Unwarranted chumminess with compiler. */
char regstart; // Internal use only. See RegExp.cpp for details.
char reganch; // Internal use only.
const char* regmust;// Internal use only.
int regmlen; // Internal use only.
char program[1]; // Unwarranted chumminess with compiler.
};
class RegExp {
class RegExp {
public:
RegExp();
RegExp(const char*);
@@ -125,7 +127,6 @@ public:
#endif
private:
void SetError(status_t error) const;
// Working functions for Compile():
@@ -162,23 +163,24 @@ private:
regexp* fRegExp;
// Work variables for Compile().
const char* fInputScanPointer;
int32 fParenthesisCount;
char fDummy;
char *fCodeEmitPointer; // &fDummy = don't.
char* fCodeEmitPointer;
// &fDummy = don't.
long fCodeSize;
// Work variables for RunMatcher().
mutable const char* fStringInputPointer;
mutable const char *fRegBol; // Beginning of input, for ^ check.
mutable const char* fRegBol;
// Beginning of input, for ^ check.
mutable const char** fStartPArrayPointer;
mutable const char** fEndPArrayPointer;
};
} // namespace BPrivate
using namespace BPrivate;
#endif
#endif // _REG_EXP_H
+3 -2
View File
@@ -31,10 +31,10 @@ of Be Incorporated in the United States and other countries. Other brand product
names are registered trademarks or trademarks of their respective holders.
All rights reserved.
*/
#ifndef _SELECTION_WINDOW_H
#define _SELECTION_WINDOW_H
#include <Button.h>
#include <CheckBox.h>
#include <MenuField.h>
@@ -44,6 +44,7 @@ All rights reserved.
#include "TrackerString.h"
namespace BPrivate {
class BContainerWindow;
@@ -78,4 +79,4 @@ private:
using namespace BPrivate;
#endif
#endif // _SELECTION_WINDOW_H
+38 -4
View File
@@ -32,6 +32,7 @@ names are registered trademarks or trademarks of their respective holders.
All rights reserved.
*/
#include <Debug.h>
#include <string.h>
@@ -40,6 +41,7 @@ All rights reserved.
#include "TrackerSettings.h"
Settings* settings = NULL;
// generic setting handler classes
@@ -54,28 +56,33 @@ StringValueSetting::StringValueSetting(const char *name, const char *defaultValu
{
}
StringValueSetting::~StringValueSetting()
{
}
void
StringValueSetting::ValueChanged(const char* newValue)
{
fValue = newValue;
}
const char*
StringValueSetting::Value() const
{
return fValue.String();
}
void
StringValueSetting::SaveSettingValue(Settings* settings)
{
settings->Write("\"%s\"", fValue.String());
}
bool
StringValueSetting::NeedsSaving() const
{
@@ -83,6 +90,7 @@ StringValueSetting::NeedsSaving() const
return fValue != fDefaultValue;
}
const char*
StringValueSetting::Handle(const char* const* argv)
{
@@ -93,16 +101,20 @@ StringValueSetting::Handle(const char *const *argv)
return 0;
}
// #pragma mark -
EnumeratedStringValueSetting::EnumeratedStringValueSetting(const char* name,
const char *defaultValue, const char *const *values, const char *valueExpectedErrorString,
const char *wrongValueErrorString)
: StringValueSetting(name, defaultValue, valueExpectedErrorString, wrongValueErrorString),
const char* defaultValue, const char* const* values,
const char* valueExpectedErrorString, const char* wrongValueErrorString)
: StringValueSetting(name, defaultValue, valueExpectedErrorString,
wrongValueErrorString),
fValues(values)
{
}
void
EnumeratedStringValueSetting::ValueChanged(const char* newValue)
{
@@ -112,8 +124,10 @@ EnumeratedStringValueSetting::ValueChanged(const char *newValue)
for (int32 index = 0; ; index++) {
if (!fValues[index])
break;
if (strcmp(fValues[index], newValue) != 0)
continue;
found = true;
break;
}
@@ -122,6 +136,7 @@ EnumeratedStringValueSetting::ValueChanged(const char *newValue)
StringValueSetting::ValueChanged(newValue);
}
const char*
EnumeratedStringValueSetting::Handle(const char* const* argv)
{
@@ -132,8 +147,10 @@ EnumeratedStringValueSetting::Handle(const char *const *argv)
for (int32 index = 0; ; index++) {
if (!fValues[index])
break;
if (strcmp(fValues[index], *argv) != 0)
continue;
found = true;
break;
}
@@ -145,8 +162,10 @@ EnumeratedStringValueSetting::Handle(const char *const *argv)
return 0;
}
// #pragma mark -
ScalarValueSetting::ScalarValueSetting(const char* name, int32 defaultValue,
const char* valueExpectedErrorString, const char* wrongValueErrorString,
int32 min, int32 max)
@@ -160,6 +179,7 @@ ScalarValueSetting::ScalarValueSetting(const char *name, int32 defaultValue,
{
}
void
ScalarValueSetting::ValueChanged(int32 newValue)
{
@@ -168,18 +188,21 @@ ScalarValueSetting::ValueChanged(int32 newValue)
fValue = newValue;
}
int32
ScalarValueSetting::Value() const
{
return fValue;
}
void
ScalarValueSetting::GetValueAsString(char* buffer) const
{
sprintf(buffer, "%ld", fValue);
}
const char*
ScalarValueSetting::Handle(const char* const* argv)
{
@@ -199,20 +222,24 @@ ScalarValueSetting::Handle(const char *const *argv)
return NULL;
}
void
ScalarValueSetting::SaveSettingValue(Settings* settings)
{
settings->Write("%ld", fValue);
}
bool
ScalarValueSetting::NeedsSaving() const
{
return fValue != fDefaultValue;
}
// #pragma mark -
HexScalarValueSetting::HexScalarValueSetting(const char* name, int32 defaultValue,
const char* valueExpectedErrorString, const char* wrongValueErrorString,
int32 min, int32 max)
@@ -221,37 +248,44 @@ HexScalarValueSetting::HexScalarValueSetting(const char *name, int32 defaultValu
{
}
void
HexScalarValueSetting::GetValueAsString(char* buffer) const
{
sprintf(buffer, "0x%08lx", fValue);
}
void
HexScalarValueSetting::SaveSettingValue(Settings* settings)
{
settings->Write("0x%08lx", fValue);
}
// #pragma mark -
BooleanValueSetting::BooleanValueSetting(const char* name, bool defaultValue)
: ScalarValueSetting(name, defaultValue, 0, 0)
{
}
bool
BooleanValueSetting::Value() const
{
return fValue != 0;
}
void
BooleanValueSetting::SetValue(bool value)
{
fValue = value;
}
const char*
BooleanValueSetting::Handle(const char* const* argv)
{
@@ -268,9 +302,9 @@ BooleanValueSetting::Handle(const char *const *argv)
return 0;
}
void
BooleanValueSetting::SaveSettingValue(Settings* settings)
{
settings->Write(fValue ? "on" : "off");
}
+3 -2
View File
@@ -31,13 +31,14 @@ of Be Incorporated in the United States and other countries. Other brand product
names are registered trademarks or trademarks of their respective holders.
All rights reserved.
*/
#ifndef _SETTINGS_H_
#define _SETTINGS_H_
#include <String.h>
#include "SettingsHandler.h"
namespace BPrivate {
extern Settings* settings;
@@ -135,4 +136,4 @@ protected:
using namespace BPrivate;
#endif /* _SETTINGS_H_ */
#endif // _SETTINGS_H_
+32 -3
View File
@@ -84,6 +84,7 @@ ArgvParser::~ArgvParser()
fclose(fFile);
}
void
ArgvParser::MakeArgvEmpty()
{
@@ -94,6 +95,7 @@ ArgvParser::MakeArgvEmpty()
fArgc = 0;
}
status_t
ArgvParser::SendArgv(ArgvHandler argvHandlerFunc, void* passThru)
{
@@ -111,6 +113,7 @@ ArgvParser::SendArgv(ArgvHandler argvHandlerFunc, void *passThru)
return B_OK;
}
void
ArgvParser::NextArgv()
{
@@ -128,6 +131,7 @@ ArgvParser::NextArgv()
fArgc++;
}
void
ArgvParser::NextArgvIfNotEmpty()
{
@@ -137,6 +141,7 @@ ArgvParser::NextArgvIfNotEmpty()
NextArgv();
}
char
ArgvParser::GetCh()
{
@@ -150,15 +155,19 @@ ArgvParser::GetCh()
return fBuffer[fPos++];
}
status_t
ArgvParser::EachArgv(const char *name, ArgvHandler argvHandlerFunc, void *passThru)
ArgvParser::EachArgv(const char* name, ArgvHandler argvHandlerFunc,
void* passThru)
{
ArgvParser parser(name);
return parser.EachArgvPrivate(name, argvHandlerFunc, passThru);
}
status_t
ArgvParser::EachArgvPrivate(const char *name, ArgvHandler argvHandlerFunc, void *passThru)
ArgvParser::EachArgvPrivate(const char* name, ArgvHandler argvHandlerFunc,
void* passThru)
{
status_t result;
@@ -183,11 +192,13 @@ ArgvParser::EachArgvPrivate(const char *name, ArgvHandler argvHandlerFunc, void
result = B_ERROR;
break;
}
fLineNo++;
if (fSawBackslash) {
fSawBackslash = false;
continue;
}
// end of line, flush all argv
result = SendArgv(argvHandlerFunc, passThru);
@@ -246,6 +257,7 @@ SettingsArgvDispatcher::SettingsArgvDispatcher(const char *name)
{
}
void
SettingsArgvDispatcher::SaveSettings(Settings* settings, bool onlyIfNonDefault)
{
@@ -256,6 +268,7 @@ SettingsArgvDispatcher::SaveSettings(Settings *settings, bool onlyIfNonDefault)
}
}
bool
SettingsArgvDispatcher::HandleRectValue(BRect &result, const char* const* argv,
bool printError)
@@ -266,27 +279,32 @@ SettingsArgvDispatcher::HandleRectValue(BRect &result, const char *const *argv,
return false;
}
result.left = atoi(*argv);
if (!*++argv) {
if (printError)
printf("rect top expected");
return false;
}
result.top = atoi(*argv);
if (!*++argv) {
if (printError)
printf("rect right expected");
return false;
}
result.right = atoi(*argv);
if (!*++argv) {
if (printError)
printf("rect bottom expected");
return false;
}
result.bottom = atoi(*argv);
return true;
}
void
SettingsArgvDispatcher::WriteRectValue(Settings* setting, BRect rect)
{
@@ -294,6 +312,7 @@ SettingsArgvDispatcher::WriteRectValue(Settings *setting, BRect rect)
(int32)rect.right, (int32)rect.bottom);
}
Settings::Settings(const char* filename, const char* settingsDirName)
: fFileName(filename),
fSettingsDir(settingsDirName),
@@ -302,7 +321,8 @@ Settings::Settings(const char *filename, const char *settingsDirName)
fListSize(30),
fCurrentSettings(0)
{
fList = (SettingsArgvDispatcher **)calloc((size_t)fListSize, sizeof(SettingsArgvDispatcher *));
fList = (SettingsArgvDispatcher**)calloc((size_t)fListSize,
sizeof(SettingsArgvDispatcher*));
}
@@ -324,9 +344,11 @@ Settings::ParseUserSettings(int, const char *const *argv, void *castToThis)
SettingsArgvDispatcher* handler = ((Settings*)castToThis)->Find(*argv);
if (!handler)
return "unknown command";
return handler->Handle(argv);
}
bool
Settings::Add(SettingsArgvDispatcher* setting)
{
@@ -343,6 +365,7 @@ Settings::Add(SettingsArgvDispatcher *setting)
return true;
}
SettingsArgvDispatcher*
Settings::Find(const char* name)
{
@@ -353,6 +376,7 @@ Settings::Find(const char *name)
return NULL;
}
void
Settings::TryReadingSettings()
{
@@ -366,12 +390,14 @@ Settings::TryReadingSettings()
}
}
void
Settings::SaveSettings(bool onlyIfNonDefault)
{
SaveCurrentSettings(onlyIfNonDefault);
}
void
Settings::MakeSettingsDirectory(BDirectory* resultingSettingsDir)
{
@@ -398,6 +424,7 @@ Settings::MakeSettingsDirectory(BDirectory *resultingSettingsDir)
resultingSettingsDir->SetTo(path.Path());
}
void
Settings::SaveCurrentSettings(bool onlyIfNonDefault)
{
@@ -422,6 +449,7 @@ Settings::SaveCurrentSettings(bool onlyIfNonDefault)
fCurrentSettings = NULL;
}
void
Settings::Write(const char* format, ...)
{
@@ -432,6 +460,7 @@ Settings::Write(const char *format, ...)
va_end(args);
}
void
Settings::VSWrite(const char* format, va_list arg)
{
+8 -7
View File
@@ -31,16 +31,17 @@ of Be Incorporated in the United States and other countries. Other brand product
names are registered trademarks or trademarks of their respective holders.
All rights reserved.
*/
#ifndef __SETTINGS_FILE__
#define __SETTINGS_FILE__
#include <SupportDefs.h>
#include <stdarg.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
class BFile;
class BDirectory;
class BRect;
@@ -52,7 +53,6 @@ class Settings;
typedef const char* (*ArgvHandler)(int argc, const char* const *argv, void* params);
// return 0 or error string if parsing failed
const int32 kBufferSize = 1024;
class ArgvParser {
@@ -108,8 +108,7 @@ public:
void SaveSettings(Settings* settings, bool onlyIfNonDefault);
const char *Name() const
{ return name; }
const char* Name() const { return name; }
// name as it appears in the settings file
virtual const char* Handle(const char* const *argv) = 0;
@@ -117,7 +116,6 @@ public:
// values in argv format for this setting
// return a pointer to an error message or null if parsed OK
// some handy reader/writer calls
bool HandleRectValue(BRect&, const char* const *argv, bool printError = true);
void WriteRectValue(Settings*, BRect);
@@ -131,10 +129,12 @@ protected:
{ return true; }
// override to return false if current value is equal to the default
// and does not need saving
private:
const char* name;
};
class Settings {
// this class is a list of all the settings handlers, reads and
// saves the settings file
@@ -159,7 +159,8 @@ private:
void SaveCurrentSettings(bool onlyIfNonDefault);
const char* fFileName;
const char *fSettingsDir; // currently unused
const char* fSettingsDir;
// currently unused
SettingsArgvDispatcher** fList;
int32 fCount;
int32 fListSize;
@@ -170,4 +171,4 @@ private:
using namespace BPrivate;
#endif
#endif // __SETTINGS_FILE__
+3 -1
View File
@@ -31,10 +31,10 @@ of Be Incorporated in the United States and other countries. Other brand product
names are registered trademarks or trademarks of their respective holders.
All rights reserved.
*/
#ifndef _SETTINGS_VIEWS
#define _SETTINGS_VIEWS
#include <CheckBox.h>
#include <GroupView.h>
#include <RadioButton.h>
@@ -43,6 +43,7 @@ All rights reserved.
#include "TrackerSettings.h"
const uint32 kSettingsContentsModified = 'Scmo';
class BButton;
@@ -162,6 +163,7 @@ class SpaceBarSettingsView : public SettingsView {
typedef SettingsView _inherited;
};
class TrashSettingsView : public SettingsView {
public:
TrashSettingsView();
+6 -2
View File
@@ -178,9 +178,11 @@ BSlowContextMenu::ClearMenuBuildingState()
}
}
const int32 kItemsToAddChunk = 20;
const bigtime_t kMaxTimeBuildingMenu = 200000;
bool
BSlowContextMenu::AddDynamicItem(add_state state)
{
@@ -222,8 +224,9 @@ BSlowContextMenu::StartBuildingItemList()
BEntry entry;
if (fNavDir.device < 0 || entry.SetTo(&fNavDir) != B_OK
|| !entry.Exists())
|| !entry.Exists()) {
return false;
}
fIteratingDesktop = false;
@@ -250,9 +253,10 @@ BSlowContextMenu::StartBuildingItemList()
startModel.EntryRef());
AddRootItemsIfNeeded();
AddTrashItem();
} else
} else {
fContainer = new DirectoryEntryList(*dynamic_cast<BDirectory*>
(startModel.Node()));
}
if (fContainer->InitCheck() != B_OK)
return false;
+6 -2
View File
@@ -31,13 +31,14 @@ of Be Incorporated in the United States and other countries. Other brand product
names are registered trademarks or trademarks of their respective holders.
All rights reserved.
*/
#ifndef SLOW_CONTEXT_POPUP_H
#define SLOW_CONTEXT_POPUP_H
#include <PopUpMenu.h>
#include "NavMenu.h"
namespace BPrivate {
class BSlowContextMenu : public BPopUpMenu {
@@ -112,22 +113,25 @@ private:
using namespace BPrivate;
inline const BObjectList<BString>*
BSlowContextMenu::TypesList() const
{
return fTypesList;
}
inline const BMessenger
BSlowContextMenu::Target() const
{
return fMessenger;
}
inline const bool
BSlowContextMenu::IsShowing() const
{
return fIsShowing;
}
#endif
#endif // SLOW_CONTEXT_POPUP_H
+15 -5
View File
@@ -32,17 +32,21 @@ names are registered trademarks or trademarks of their respective holders.
All rights reserved.
*/
#include "SlowMenu.h"
BSlowMenu::BSlowMenu(const char* title, menu_layout layout)
: BMenu(title, layout),
fMenuBuilt(false)
{
}
const int32 kItemsToAddChunk = 20;
const bigtime_t kMaxTimeBuildingMenu = 200000;
bool
BSlowMenu::AddDynamicItem(add_state state)
{
@@ -68,20 +72,25 @@ BSlowMenu::AddDynamicItem(add_state state)
return false;
// done with menu, don't call again
}
if (system_time() > timeToBail)
// we have been in here long enough, come back later
if (system_time() > timeToBail) {
// we've been in here long enough, come back later
break;
}
return true; // call me again, got more to show
}
return true;
// call me again, got more to show
}
bool
BSlowMenu::StartBuildingItemList()
{
return true;
}
bool
BSlowMenu::AddNextItem()
{
@@ -90,6 +99,7 @@ BSlowMenu::AddNextItem()
return true;
}
void
BSlowMenu::DoneBuildingItemList()
{
@@ -97,10 +107,10 @@ BSlowMenu::DoneBuildingItemList()
// pure virtual, shouldn't be here
}
void
BSlowMenu::ClearMenuBuildingState()
{
TRESPASS();
// pure virtual, shouldn't be here
}
+7 -5
View File
@@ -31,19 +31,21 @@ of Be Incorporated in the United States and other countries. Other brand product
names are registered trademarks or trademarks of their respective holders.
All rights reserved.
*/
#ifndef __SLOW_MENU__
#define __SLOW_MENU__
#include <Menu.h>
#include <MenuItem.h>
#include <Debug.h>
// SlowMenu is a convenience class that makes it easier to
// use the AddDynamicItem callback to implement a menu that can
// checks periodically between creating new items and quits
// early if needed
#include <Menu.h>
#include <MenuItem.h>
#include <Debug.h>
namespace BPrivate {
class BSlowMenu : public BMenu {
@@ -73,4 +75,4 @@ class BSlowMenu : public BMenu {
using namespace BPrivate;
#endif /* __SLOW_MENU__ */
#endif // __SLOW_MENU__
+1
View File
@@ -203,4 +203,5 @@ extern BStatusWindow* gStatusWindow;
using namespace BPrivate;
#endif // STATUS_WINDOW_H
+12 -10
View File
@@ -72,8 +72,9 @@ OneShotDelayedTask::RunIfNeeded(bigtime_t currentTime)
}
PeriodicDelayedTask::PeriodicDelayedTask(FunctionObjectWithResult<bool> *functor,
bigtime_t initialDelay, bigtime_t period)
PeriodicDelayedTask::PeriodicDelayedTask(
FunctionObjectWithResult<bool>* functor, bigtime_t initialDelay,
bigtime_t period)
: DelayedTask(initialDelay),
fPeriod(period),
fFunctor(functor)
@@ -124,8 +125,8 @@ PeriodicDelayedTaskWithTimeout::RunIfNeeded(bigtime_t currentTime)
}
RunWhenIdleTask::RunWhenIdleTask(FunctionObjectWithResult<bool> *functor, bigtime_t
initialDelay, bigtime_t idleFor, bigtime_t heartBeat)
RunWhenIdleTask::RunWhenIdleTask(FunctionObjectWithResult<bool>* functor,
bigtime_t initialDelay, bigtime_t idleFor, bigtime_t heartBeat)
: PeriodicDelayedTask(functor, initialDelay, heartBeat),
fIdleFor(idleFor),
fState(kInitialDelay)
@@ -276,13 +277,14 @@ void
TaskLoop::RunLater(FunctionObjectWithResult<bool>* functor, bigtime_t delay,
bigtime_t period, bigtime_t timeout)
{
RunLater(new PeriodicDelayedTaskWithTimeout(functor, delay, period, timeout));
RunLater(new PeriodicDelayedTaskWithTimeout(functor, delay, period,
timeout));
}
void
TaskLoop::RunWhenIdle(FunctionObjectWithResult<bool> *functor, bigtime_t initialDelay,
bigtime_t idleTime, bigtime_t heartBeat)
TaskLoop::RunWhenIdle(FunctionObjectWithResult<bool>* functor,
bigtime_t initialDelay, bigtime_t idleTime, bigtime_t heartBeat)
{
RunLater(new RunWhenIdleTask(functor, initialDelay, idleTime, heartBeat));
}
@@ -338,8 +340,9 @@ TaskLoop::AccumulatedRunLater(AccumulatingFunctionObject *functor, bigtime_t del
}
int32 count = fTaskList.CountItems();
for (int32 index = 0; index < count; index++) {
AccumulatedOneShotDelayedTask *task = dynamic_cast<AccumulatedOneShotDelayedTask *>
(fTaskList.ItemAt(index));
AccumulatedOneShotDelayedTask* task
= dynamic_cast<AccumulatedOneShotDelayedTask*>(
fTaskList.ItemAt(index));
if (!task)
continue;
@@ -589,4 +592,3 @@ PiggybackTaskLoop::StartPulsingIfNeeded()
{
fPulseMe = true;
}
+33 -23
View File
@@ -31,23 +31,23 @@ of Be Incorporated in the United States and other countries. Other brand product
names are registered trademarks or trademarks of their respective holders.
All rights reserved.
*/
//
// Delayed Tasks, Periodic Delayed Tasks, Periodic Delayed Tasks with timeout,
// Run when idle tasks, accumulating delayed tasks
//
#ifndef __TASK_LOOP__
#define __TASK_LOOP__
// Delayed Tasks, Periodic Delayed Tasks, Periodic Delayed Tasks with timeout,
// Run when idle tasks, accumulating delayed tasks
#include <Locker.h>
#include "FunctionObject.h"
#include "ObjectList.h"
namespace BPrivate {
// Task flavors
class DelayedTask {
@@ -64,8 +64,9 @@ protected:
bigtime_t fRunAfter;
};
class OneShotDelayedTask : public DelayedTask {
// called once after a specified delay
class OneShotDelayedTask : public DelayedTask {
public:
OneShotDelayedTask(FunctionObject* functor, bigtime_t delay);
virtual ~OneShotDelayedTask();
@@ -76,8 +77,9 @@ protected:
FunctionObject* fFunctor;
};
class PeriodicDelayedTask : public DelayedTask {
// called periodically till functor return true
class PeriodicDelayedTask : public DelayedTask {
public:
PeriodicDelayedTask(FunctionObjectWithResult<bool>* functor,
bigtime_t initialDelay, bigtime_t period);
@@ -90,8 +92,9 @@ protected:
FunctionObjectWithResult<bool>* fFunctor;
};
class PeriodicDelayedTaskWithTimeout : public PeriodicDelayedTask {
// called periodically till functor returns true or till time out
class PeriodicDelayedTaskWithTimeout : public PeriodicDelayedTask {
public:
PeriodicDelayedTaskWithTimeout(FunctionObjectWithResult<bool>* functor,
bigtime_t initialDelay, bigtime_t period, bigtime_t timeout);
@@ -102,9 +105,10 @@ protected:
bigtime_t fTimeoutAfter;
};
class RunWhenIdleTask : public PeriodicDelayedTask {
// after initial delay starts periodically calling functor if system is idle
// until functor returns true
class RunWhenIdleTask : public PeriodicDelayedTask {
public:
RunWhenIdleTask(FunctionObjectWithResult<bool>* functor, bigtime_t initialDelay,
bigtime_t idleFor, bigtime_t heartBeat);
@@ -135,12 +139,13 @@ private:
typedef PeriodicDelayedTask _inherited;
};
class AccumulatingFunctionObject : public FunctionObject {
// This class is used for clumping up function objects that
// can be done as a single object. For instance the mime
// notification mechanism sends out multiple notifications on
// a single change and we need to accumulate the resulting
// icon update into a single one
class AccumulatingFunctionObject : public FunctionObject {
public:
virtual bool CanAccumulate(const AccumulatingFunctionObject*) const = 0;
virtual void Accumulate(AccumulatingFunctionObject*) = 0;
@@ -161,25 +166,27 @@ public:
void RunLater(FunctionObjectWithResult<bool>* functor, bigtime_t delay,
bigtime_t period);
// periodically execute function object after initial delay until function
// object returns true
// periodically execute function object after initial delay until
// function object returns true
void RunLater(FunctionObjectWithResult<bool>* functor, bigtime_t delay,
bigtime_t period, bigtime_t timeout);
// periodically execute function object after initial delay until function
// object returns true or timeout is reached
// periodically execute function object after initial delay until
// function object returns true or timeout is reached
void AccumulatedRunLater(AccumulatingFunctionObject *functor, bigtime_t delay,
bigtime_t maxAccumulatingTime = 0, int32 maxAccumulateCount = 0);
void AccumulatedRunLater(AccumulatingFunctionObject* functor,
bigtime_t delay, bigtime_t maxAccumulatingTime = 0,
int32 maxAccumulateCount = 0);
// will search the delayed task loop for other accumulating functors
// and will accumulate with them, else will create a new delayed task
// the task will no longer accumulate if past the <maxAccumulatingTime> delay
// unless <maxAccumulatingTime> is zero
// the task will no longer accumulate if past the
// <maxAccumulatingTime> delay unless <maxAccumulatingTime> is zero
// no more than <maxAccumulateCount> will get accumulated, unless
// <maxAccumulateCount> is zero
void RunWhenIdle(FunctionObjectWithResult<bool> *functor, bigtime_t initialDelay,
bigtime_t idleTime, bigtime_t heartBeat = 1000000);
void RunWhenIdle(FunctionObjectWithResult<bool>* functor,
bigtime_t initialDelay, bigtime_t idleTime,
bigtime_t heartBeat = 1000000);
// after initialDelay starts looking for a slot when the system is
// idle for at least idleTime
@@ -199,6 +206,7 @@ protected:
bigtime_t fHeartBeat;
};
class StandAloneTaskLoop : public TaskLoop {
// this task loop can work on it's own, just instantiate it
// and use it; It has to start it's own thread
@@ -223,6 +231,7 @@ private:
typedef TaskLoop _inherited;
};
class PiggybackTaskLoop : public TaskLoop {
// this TaskLoop needs periodic calls from a viewable's Pulse
// or some similar pulsing mechanism
@@ -247,8 +256,9 @@ DelayedTask::RunAfterTime() const
return fRunAfter;
}
} // namespace BPrivate
using namespace BPrivate;
#endif
#endif // __TASK_LOOP__
+10 -4
View File
@@ -32,6 +32,7 @@ names are registered trademarks or trademarks of their respective holders.
All rights reserved.
*/
#include <Application.h>
#include <Catalog.h>
#include <FindDirectory.h>
@@ -61,8 +62,7 @@ namespace BPrivate {
const char* kTemplatesDirectory = "Tracker/Tracker New Templates";
}
} // namespace BPrivate
TemplatesMenu::TemplatesMenu(const BMessenger &target, const char* label)
: BMenu(label),
@@ -71,10 +71,12 @@ TemplatesMenu::TemplatesMenu(const BMessenger &target, const char *label)
{
}
TemplatesMenu::~TemplatesMenu()
{
}
void
TemplatesMenu::AttachedToWindow()
{
@@ -83,30 +85,36 @@ TemplatesMenu::AttachedToWindow()
SetTargetForItems(fTarget);
}
status_t
TemplatesMenu::SetTargetForItems(BHandler* target)
{
status_t result = BMenu::SetTargetForItems(target);
if (fOpenItem)
fOpenItem->SetTarget(be_app_messenger);
return result;
}
status_t
TemplatesMenu::SetTargetForItems(BMessenger messenger)
{
status_t result = BMenu::SetTargetForItems(messenger);
if (fOpenItem)
fOpenItem->SetTarget(be_app_messenger);
return result;
}
void
TemplatesMenu::UpdateMenuState()
{
BuildMenu(false);
}
bool
TemplatesMenu::BuildMenu(bool addItems)
{
@@ -143,7 +151,6 @@ TemplatesMenu::BuildMenu(bool addItems)
BMimeType mime(mimeType);
if (mime.IsValid()) {
if (count == 0)
AddSeparatorItem();
@@ -163,7 +170,6 @@ TemplatesMenu::BuildMenu(bool addItems)
message->AddString("name", fileName);
AddItem(new IconMenuItem(fileName, message, &nodeInfo, B_MINI_ICON));
}
}
}
+3 -5
View File
@@ -31,13 +31,13 @@ of Be Incorporated in the United States and other countries. Other brand product
names are registered trademarks or trademarks of their respective holders.
All rights reserved.
*/
#ifndef __TEMPLATES_MENU__
#define __TEMPLATES_MENU__
#include <Menu.h>
namespace BPrivate {
extern const char* kTemplatesDirectory;
@@ -45,11 +45,9 @@ extern const char* kTemplatesMenuName;
class TemplatesMenu : public BMenu {
public:
TemplatesMenu(const BMessenger &target,
const char *label);
TemplatesMenu(const BMessenger& target, const char* label);
virtual ~TemplatesMenu();
virtual void AttachedToWindow();
virtual status_t SetTargetForItems(BHandler*);
@@ -68,4 +66,4 @@ private:
using namespace BPrivate;
#endif
#endif // __TEMPLATES_MENU__
+17 -2
View File
@@ -32,6 +32,7 @@ names are registered trademarks or trademarks of their respective holders.
All rights reserved.
*/
#if DEBUG
#include "Tests.h"
@@ -51,8 +52,6 @@ All rights reserved.
#include "Thread.h"
const char* pathsToSearch[] = {
// "/boot/home/config/settings/NetPositive/Bookmarks/",
#ifdef __HAIKU__
@@ -65,6 +64,7 @@ const char *pathsToSearch[] = {
0
};
namespace BTrackerPrivate {
class IconSpewer : public SimpleThread {
@@ -98,6 +98,7 @@ private:
entry_ref ref;
};
class IconTestWindow : public BWindow {
public:
IconTestWindow();
@@ -131,6 +132,7 @@ IconSpewer::~IconSpewer()
delete cachingIterator;
}
void
IconSpewer::Run()
{
@@ -149,6 +151,7 @@ IconSpewer::Run()
}
}
void
IconSpewer::Quit()
{
@@ -156,10 +159,12 @@ IconSpewer::Quit()
fScanThread = -1;
}
const icon_size kIconSize = B_LARGE_ICON;
const int32 kRowCount = 10;
const int32 kColumnCount = 10;
void
IconSpewer::DrawSomeNew()
{
@@ -177,10 +182,12 @@ IconSpewer::DrawSomeNew()
sprintf(buffer, "last cycle time %Ld ms", cycleTime/1000);
view->DrawString(buffer, BPoint(20, bounds.bottom - 20));
}
if (numDrawn) {
sprintf(buffer, "average draw time %Ld us per icon", watch.ElapsedTime() / numDrawn);
view->DrawString(buffer, BPoint(20, bounds.bottom - 30));
}
sprintf(buffer, "directory: %s", currentPath.Path());
view->DrawString(buffer, BPoint(20, bounds.bottom - 40));
@@ -205,7 +212,10 @@ IconSpewer::DrawSomeNew()
}
}
bool oldIconCacheInited = false;
void
IconSpewer::DrawSomeOld()
{
@@ -261,6 +271,7 @@ IconSpewer::DrawSomeOld()
#endif
}
const entry_ref*
IconSpewer::NextRef()
{
@@ -295,6 +306,8 @@ IconSpewer::NextRef()
}
// #pragma mark -
IconTestWindow::IconTestWindow()
: BWindow(BRect(100, 100, 500, 600), "icon cache test", B_TITLED_WINDOW_LOOK,
@@ -307,6 +320,7 @@ IconTestWindow::IconTestWindow()
iconSpewer.Go();
}
bool
IconTestWindow::QuitRequested()
{
@@ -314,6 +328,7 @@ IconTestWindow::QuitRequested()
return true;
}
void
RunIconCacheTests()
{
+1
View File
@@ -32,6 +32,7 @@ names are registered trademarks or trademarks of their respective holders.
All rights reserved.
*/
#include <string.h>
#include <stdlib.h>
+12 -3
View File
@@ -93,10 +93,12 @@ public:
// used for sorting in PoseViews
private:
BRect CalcRectCommon(BPoint poseLoc, const BColumn *, const BPoseView *, float width);
BRect CalcRectCommon(BPoint poseLoc, const BColumn*, const BPoseView*,
float width);
WidgetAttributeText* fText;
uint32 fAttrHash; // ToDo: get rid of this
uint32 fAttrHash;
// TODO: get rid of this
alignment fAlignment;
bool fEditable : 1;
@@ -105,42 +107,49 @@ private:
bool fSymLink : 1;
};
inline uint32
BTextWidget::AttrHash() const
{
return fAttrHash;
}
inline void
BTextWidget::SetEditable(bool on)
{
fEditable = on;
}
inline bool
BTextWidget::IsEditable() const
{
return fEditable && fText->IsEditable();
}
inline bool
BTextWidget::IsVisible() const
{
return fVisible;
}
inline void
BTextWidget::SetVisible(bool on)
{
fVisible = on;
}
inline bool
BTextWidget::IsActive() const
{
return fActive;
}
inline void
BTextWidget::SetActive(bool on)
{
@@ -160,4 +169,4 @@ BTextWidget::Draw(BRect widgetRect, BRect widgetTextRect, float width,
using namespace BPrivate;
#endif
#endif // _TEXT_WIDGET_H
+15 -5
View File
@@ -32,9 +32,11 @@ names are registered trademarks or trademarks of their respective holders.
All rights reserved.
*/
#include "Thread.h"
#include "FunctionObject.h"
SimpleThread::SimpleThread(int32 priority, const char* name)
: fScanThread(-1),
fPriority(priority),
@@ -45,19 +47,22 @@ SimpleThread::SimpleThread(int32 priority, const char *name)
SimpleThread::~SimpleThread()
{
if (fScanThread > 0 && fScanThread != find_thread(NULL))
if (fScanThread > 0 && fScanThread != find_thread(NULL)) {
// kill the thread if it is not the one we are running in
kill_thread(fScanThread);
}
}
void
SimpleThread::Go()
{
fScanThread = spawn_thread(SimpleThread::RunBinder, fName ? fName : "TrackerTaskLoop",
fPriority, this);
fScanThread = spawn_thread(SimpleThread::RunBinder,
fName ? fName : "TrackerTaskLoop", fPriority, this);
resume_thread(fScanThread);
}
status_t
SimpleThread::RunBinder(void* castToThis)
{
@@ -66,6 +71,7 @@ SimpleThread::RunBinder(void *castToThis)
return B_OK;
}
void
Thread::Launch(FunctionObject* functor, int32 priority, const char* name)
{
@@ -80,6 +86,7 @@ Thread::Thread(FunctionObject *functor, int32 priority, const char *name)
Go();
}
Thread::~Thread()
{
delete fFunctor;
@@ -94,13 +101,14 @@ Thread::Run()
// commit suicide
}
void
ThreadSequence::Launch(BObjectList<FunctionObject>* list, bool async, int32 priority)
{
if (!async)
if (!async) {
// if not async, don't even create a thread, just do it right away
Run(list);
else
} else
new ThreadSequence(list, priority);
}
@@ -118,6 +126,7 @@ ThreadSequence::~ThreadSequence()
delete fFunctorList;
}
void
ThreadSequence::Run(BObjectList<FunctionObject>* list)
{
@@ -126,6 +135,7 @@ ThreadSequence::Run(BObjectList<FunctionObject> *list)
(*list->ItemAt(index))();
}
void
ThreadSequence::Run()
{
+25 -11
View File
@@ -31,10 +31,10 @@ of Be Incorporated in the United States and other countries. Other brand product
names are registered trademarks or trademarks of their respective holders.
All rights reserved.
*/
#ifndef __THREAD__
#define __THREAD__
#include <Debug.h>
#include <OS.h>
@@ -42,6 +42,7 @@ All rights reserved.
#include "FunctionObject.h"
#include "Utilities.h"
namespace BPrivate {
class SimpleThread {
@@ -122,7 +123,6 @@ public:
{
}
virtual void operator()()
{ (fOnThis->*fFunction)(); }
@@ -133,6 +133,7 @@ private:
T fOnThis;
};
template <class Param1, class Param2>
class TwoParamFunctionObjectWorkaround : public FunctionObjectWithResult<status_t> {
public:
@@ -155,6 +156,7 @@ private:
Param2 fParam2;
};
template <class Param1, class Param2, class Param3>
class ThreeParamFunctionObjectWorkaround : public FunctionObjectWithResult<status_t> {
public:
@@ -179,6 +181,7 @@ private:
Param3 fParam3;
};
template <class Param1, class Param2, class Param3, class Param4>
class FourParamFunctionObjectWorkaround : public FunctionObjectWithResult<status_t> {
public:
@@ -205,32 +208,39 @@ private:
Param4 fParam4;
};
template<class Param1>
void
LaunchInNewThread(const char *name, int32 priority, status_t (*func)(Param1), Param1 p1)
LaunchInNewThread(const char* name, int32 priority, status_t (*func)(Param1),
Param1 p1)
{
Thread::Launch(new SingleParamFunctionObjectWorkaround<Param1>(func, p1),
priority, name);
}
template<class T>
void
LaunchInNewThread(const char *name, int32 priority, status_t (T::*function)(), T *onThis)
LaunchInNewThread(const char* name, int32 priority, status_t (T::*function)(),
T* onThis)
{
Thread::Launch(new SimpleMemberFunctionObjectWorkaround<T>(function, onThis),
priority, name);
Thread::Launch(new SimpleMemberFunctionObjectWorkaround<T>(function,
onThis), priority, name);
}
template<class Param1, class Param2>
void
LaunchInNewThread(const char* name, int32 priority,
status_t (*func)(Param1, Param2),
Param1 p1, Param2 p2)
{
Thread::Launch(new TwoParamFunctionObjectWorkaround<Param1, Param2>(func, p1, p2),
Thread::Launch(new
TwoParamFunctionObjectWorkaround<Param1, Param2>(func, p1, p2),
priority, name);
}
template<class Param1, class Param2, class Param3>
void
LaunchInNewThread(const char* name, int32 priority,
@@ -241,6 +251,7 @@ LaunchInNewThread(const char *name, int32 priority,
Param3>(func, p1, p2, p3), priority, name);
}
template<class Param1, class Param2, class Param3, class Param4>
void
LaunchInNewThread(const char* name, int32 priority,
@@ -251,6 +262,7 @@ LaunchInNewThread(const char *name, int32 priority,
Param3, Param4>(func, p1, p2, p3, p4), priority, name);
}
template<class View>
class MouseDownThread {
public:
@@ -267,8 +279,8 @@ protected:
virtual void Track();
static status_t TrackBinder(void*);
private:
private:
BMessenger fOwner;
void (View::*fDonePressing)(BPoint);
void (View::*fPressing)(BPoint, uint32);
@@ -314,14 +326,15 @@ template<class View>
void
MouseDownThread<View>::Go()
{
fThreadID = spawn_thread(&MouseDownThread::TrackBinder, "MouseTrackingThread",
B_NORMAL_PRIORITY, this);
fThreadID = spawn_thread(&MouseDownThread::TrackBinder,
"MouseTrackingThread", B_NORMAL_PRIORITY, this);
if (fThreadID <= 0 || resume_thread(fThreadID) != B_OK)
// didn't start, don't leak self
delete this;
}
template<class View>
status_t
MouseDownThread<View>::TrackBinder(void* castToThis)
@@ -333,6 +346,7 @@ MouseDownThread<View>::TrackBinder(void *castToThis)
return B_OK;
}
template<class View>
void
MouseDownThread<View>::Track()
@@ -369,4 +383,4 @@ MouseDownThread<View>::Track()
using namespace BPrivate;
#endif
#endif // __THREAD__

Some files were not shown because too many files have changed in this diff Show More