WIP: Yet more style fixes, mostly 80 char violations.

This commit is contained in:
John Scipione
2012-07-28 14:02:34 -04:00
parent 0d47dc5dd2
commit a51764c53e
30 changed files with 1273 additions and 858 deletions
+11 -11
View File
@@ -156,8 +156,8 @@ AttributeStreamNode::Contains(const char* name, uint32 type)
off_t off_t
AttributeStreamNode::Read(const char* name, const char* foreignName, uint32 type, AttributeStreamNode::Read(const char* name, const char* foreignName,
off_t size, void* buffer, void (*swapFunc)(void*)) uint32 type, off_t size, void* buffer, void (*swapFunc)(void*))
{ {
if (!fReadFrom) if (!fReadFrom)
return 0; return 0;
@@ -288,8 +288,8 @@ AttributeStreamFileNode::Contains(const char* name, uint32 type)
off_t off_t
AttributeStreamFileNode::Read(const char* name, const char* foreignName, uint32 type, AttributeStreamFileNode::Read(const char* name, const char* foreignName,
off_t size, void* buffer, void (*swapFunc)(void*)) uint32 type, off_t size, void* buffer, void (*swapFunc)(void*))
{ {
if (name && fNode->ReadAttr(name, type, 0, buffer, (size_t)size) == size) if (name && fNode->ReadAttr(name, type, 0, buffer, (size_t)size) == size)
return size; return size;
@@ -306,8 +306,8 @@ AttributeStreamFileNode::Read(const char* name, const char* foreignName, uint32
off_t off_t
AttributeStreamFileNode::Write(const char* name, const char* foreignName, uint32 type, AttributeStreamFileNode::Write(const char* name, const char* foreignName,
off_t size, const void* buffer) uint32 type, off_t size, const void* buffer)
{ {
ASSERT(fNode); ASSERT(fNode);
ASSERT(dynamic_cast<BNode*>(fNode)); ASSERT(dynamic_cast<BNode*>(fNode));
@@ -659,8 +659,8 @@ AttributeStreamFilterNode::Contains(const char* name, uint32 type)
off_t off_t
AttributeStreamFilterNode::Read(const char* name, const char* foreignName, uint32 type, AttributeStreamFilterNode::Read(const char* name, const char* foreignName,
off_t size, void* buffer, void (*swapFunc)(void*)) uint32 type, off_t size, void* buffer, void (*swapFunc)(void*))
{ {
if (!fReadFrom) if (!fReadFrom)
return 0; return 0;
@@ -673,8 +673,8 @@ AttributeStreamFilterNode::Read(const char* name, const char* foreignName, uint3
off_t off_t
AttributeStreamFilterNode::Write(const char* name, const char* foreignName, uint32 type, AttributeStreamFilterNode::Write(const char* name, const char* foreignName,
off_t size, const void* buffer) uint32 type, off_t size, const void* buffer)
{ {
if (!fWriteTo) if (!fWriteTo)
return 0; return 0;
@@ -693,7 +693,7 @@ NamesToAcceptAttrFilter::NamesToAcceptAttrFilter(const char** nameList)
bool bool
NamesToAcceptAttrFilter::Reject(const char* name, uint32 , off_t ) NamesToAcceptAttrFilter::Reject(const char* name, uint32, off_t)
{ {
for (int32 index = 0; ;index++) { for (int32 index = 0; ;index++) {
if (!fNameList[index]) if (!fNameList[index])
+16 -12
View File
@@ -114,11 +114,11 @@ public:
virtual off_t Contains(const char*, uint32); virtual off_t Contains(const char*, uint32);
// returns size of attribute if found // returns size of attribute if found
virtual off_t Read(const char* name, const char* foreignName, uint32 type, off_t size, virtual off_t Read(const char* name, const char* foreignName,
void* buffer, void (*swapFunc)(void*) = 0); uint32 type, off_t size, void* buffer, void (*swapFunc)(void*) = 0);
// read from this node // read from this node
virtual off_t Write(const char* name, const char* foreignName, uint32 type, off_t size, virtual off_t Write(const char* name, const char* foreignName,
const void* buffer); uint32 type, off_t size, const void* buffer);
// write to this node // write to this node
// work calls // work calls
@@ -307,22 +307,25 @@ private:
class SelectiveAttributeTransformer : public AttributeStreamNode { class SelectiveAttributeTransformer : public AttributeStreamNode {
// node applies a transformation on specified attributes // node applies a transformation on specified attributes
public: public:
SelectiveAttributeTransformer(const char* attributeName, bool (*)(const char*, SelectiveAttributeTransformer(const char* attributeName,
uint32 , off_t , void*, void*), void* params); bool (*)(const char*, uint32 , off_t , void*, void*), void* params);
virtual ~SelectiveAttributeTransformer(); virtual ~SelectiveAttributeTransformer();
virtual off_t Read(const char* name, const char* foreignName, uint32 type, off_t size, virtual off_t Read(const char* name, const char* foreignName, uint32 type,
void* buffer, void (*swapFunc)(void*) = 0); off_t size, void* buffer, void (*swapFunc)(void*) = 0);
virtual void Rewind(); virtual void Rewind();
protected: protected:
virtual bool WillTransform(const char* name, uint32 type, off_t size, const char* data) const; virtual bool WillTransform(const char* name, uint32 type, off_t size,
const char* data) const;
// override to implement filtering; should only return true if transformation will // override to implement filtering; should only return true if transformation will
// occur // occur
virtual char* CopyAndApplyTransformer(const char* name, uint32 type, off_t size, const char* data); virtual char* CopyAndApplyTransformer(const char* name, uint32 type,
off_t size, const char* data);
// makes a copy of data // makes a copy of data
virtual bool ApplyTransformer(const char* name, uint32 type, off_t size, char* data); virtual bool ApplyTransformer(const char* name, uint32 type, off_t size,
char* data);
// transforms in place // transforms in place
virtual const AttributeInfo* Next(); virtual const AttributeInfo* Next();
virtual const char* Get(); virtual const char* Get();
@@ -342,7 +345,8 @@ private:
template <class Type> template <class Type>
class AttributeStreamConstValue : public AttributeStreamNode { class AttributeStreamConstValue : public AttributeStreamNode {
public: public:
AttributeStreamConstValue(const char* name, uint32 attributeType, Type value); AttributeStreamConstValue(const char* name, uint32 attributeType,
Type value);
protected: protected:
virtual bool CanFeed() const { return true; } virtual bool CanFeed() const { return true; }
+15 -9
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. names are registered trademarks or trademarks of their respective holders.
All rights reserved. All rights reserved.
*/ */
#ifndef _TRACKER_BACKGROUND_H #ifndef _TRACKER_BACKGROUND_H
#define _TRACKER_BACKGROUND_H #define _TRACKER_BACKGROUND_H
#include <SupportDefs.h> #include <SupportDefs.h>
/*----------------------------------------------------------------*/ /*----------------------------------------------------------------*/
@@ -45,12 +45,18 @@ All rights reserved.
/*----------------------------------------------------------------*/ /*----------------------------------------------------------------*/
/*----- Tracker background BMessage entries --------------------*/ /*----- Tracker background BMessage entries --------------------*/
#define B_BACKGROUND_IMAGE "be:bgndimginfopath" // string path #define B_BACKGROUND_IMAGE "be:bgndimginfopath"
#define B_BACKGROUND_MODE "be:bgndimginfomode" // int32, the enum below // string path
#define B_BACKGROUND_ORIGIN "be:bgndimginfooffset" // BPoint #define B_BACKGROUND_MODE "be:bgndimginfomode"
#define B_BACKGROUND_TEXT_OUTLINE "be:bgndimginfoerasetext" // bool // int32, the enum below
// NOTE: the actual attribute name is kept for backwards compatible settings #define B_BACKGROUND_ORIGIN "be:bgndimginfooffset"
#define B_BACKGROUND_WORKSPACES "be:bgndimginfoworkspaces" // uint32 // BPoint
#define B_BACKGROUND_TEXT_OUTLINE "be:bgndimginfoerasetext"
// bool
// NOTE: the actual attribute name is kept for backwards
// compatible settings
#define B_BACKGROUND_WORKSPACES "be:bgndimginfoworkspaces"
// uint32
/*----------------------------------------------------------------*/ /*----------------------------------------------------------------*/
/*----- Background mode values ---------------------------------*/ /*----- Background mode values ---------------------------------*/
@@ -65,7 +71,7 @@ enum {
/*----------------------------------------------------------------*/ /*----------------------------------------------------------------*/
/*----------------------------------------------------------------*/ /*----------------------------------------------------------------*/
const int32 B_RESTORE_BACKGROUND_IMAGE = 'Tbgr'; // force a Tracker window to const int32 B_RESTORE_BACKGROUND_IMAGE = 'Tbgr';
// use a new background image // force a Tracker window to use a new background image
#endif // _TRACKER_BACKGROUND_H #endif // _TRACKER_BACKGROUND_H
+7 -5
View File
@@ -71,7 +71,7 @@ BackgroundImage::GetBackgroundImage(const BNode* node, bool isDesktop)
return NULL; return NULL;
BMessage container; BMessage container;
char* buffer = new char [info.size]; char* buffer = new char[info.size];
status_t error = node->ReadAttr(kBackgroundImageInfo, info.type, 0, buffer, (size_t)info.size); status_t error = node->ReadAttr(kBackgroundImageInfo, info.type, 0, buffer, (size_t)info.size);
if (error == info.size) if (error == info.size)
@@ -104,14 +104,16 @@ BackgroundImage::GetBackgroundImage(const BNode* node, bool isDesktop)
be_control_look->SetBackgroundInfo(container); be_control_look->SetBackgroundInfo(container);
} }
container.FindInt32(kBackgroundImageInfoWorkspaces, index, (int32*)&workspaces); container.FindInt32(kBackgroundImageInfoWorkspaces, index,
(int32*)&workspaces);
container.FindInt32(kBackgroundImageInfoMode, index, (int32*)&mode); container.FindInt32(kBackgroundImageInfoMode, index, (int32*)&mode);
container.FindBool(kBackgroundImageInfoTextOutline, index, &textWidgetLabelOutline); container.FindBool(kBackgroundImageInfoTextOutline, index,
&textWidgetLabelOutline);
container.FindPoint(kBackgroundImageInfoOffset, index, &offset); container.FindPoint(kBackgroundImageInfoOffset, index, &offset);
BackgroundImage::BackgroundImageInfo* imageInfo = new BackgroundImage::BackgroundImageInfo* imageInfo = new
BackgroundImage::BackgroundImageInfo(workspaces, bitmap, mode, offset, BackgroundImage::BackgroundImageInfo(workspaces, bitmap, mode,
textWidgetLabelOutline); offset, textWidgetLabelOutline);
if (!result) if (!result)
result = new BackgroundImage(node, isDesktop); result = new BackgroundImage(node, isDesktop);
+17 -8
View File
@@ -104,7 +104,8 @@ BImageResources::FinishResources(BResources* res) const
const void* const void*
BImageResources::LoadResource(type_code type, int32 id, size_t* out_size) const BImageResources::LoadResource(type_code type, int32 id,
size_t* out_size) const
{ {
// Serialize execution. // Serialize execution.
// Looks like BResources is not really thread safe. We should // Looks like BResources is not really thread safe. We should
@@ -116,12 +117,14 @@ BImageResources::LoadResource(type_code type, int32 id, size_t* out_size) const
// Return the resource. Because we never change the BResources // Return the resource. Because we never change the BResources
// object, the returned data will not change until TTracker is // object, the returned data will not change until TTracker is
// destroyed. // destroyed.
return const_cast<BResources*>(&fResources)->LoadResource(type, id, out_size); return const_cast<BResources*>(&fResources)->LoadResource(type, id,
out_size);
} }
const void* const void*
BImageResources::LoadResource(type_code type, const char* name, size_t* out_size) const BImageResources::LoadResource(type_code type, const char* name,
size_t* out_size) const
{ {
// Serialize execution. // Serialize execution.
BAutolock lock(fLock); BAutolock lock(fLock);
@@ -131,12 +134,14 @@ BImageResources::LoadResource(type_code type, const char* name, size_t* out_size
// Return the resource. Because we never change the BResources // Return the resource. Because we never change the BResources
// object, the returned data will not change until TTracker is // object, the returned data will not change until TTracker is
// destroyed. // destroyed.
return const_cast<BResources*>(&fResources)->LoadResource(type, name, out_size); return const_cast<BResources*>(&fResources)->LoadResource(type, name,
out_size);
} }
status_t status_t
BImageResources::GetIconResource(int32 id, icon_size size, BBitmap* dest) const BImageResources::GetIconResource(int32 id, icon_size size,
BBitmap* dest) const
{ {
size_t length = 0; size_t length = 0;
const void* data; const void* data;
@@ -144,8 +149,10 @@ BImageResources::GetIconResource(int32 id, icon_size size, BBitmap* dest) const
#ifdef __HAIKU__ #ifdef __HAIKU__
// try to load vector icon // try to load vector icon
data = LoadResource(B_VECTOR_ICON_TYPE, id, &length); data = LoadResource(B_VECTOR_ICON_TYPE, id, &length);
if (data != NULL && BIconUtils::GetVectorIcon((uint8*)data, length, dest) == B_OK) if (data != NULL
&& BIconUtils::GetVectorIcon((uint8*)data, length, dest) == B_OK) {
return B_OK; return B_OK;
}
#endif #endif
// fall back to R5 icon // fall back to R5 icon
@@ -155,7 +162,8 @@ BImageResources::GetIconResource(int32 id, icon_size size, BBitmap* dest) const
length = 0; length = 0;
data = LoadResource(size == B_LARGE_ICON ? 'ICON' : 'MICN', id, &length); data = LoadResource(size == B_LARGE_ICON ? 'ICON' : 'MICN', id, &length);
if (data == NULL || length != (size_t)(size == B_LARGE_ICON ? 1024 : 256)) { if (data == NULL
|| length != (size_t)(size == B_LARGE_ICON ? 1024 : 256)) {
TRESPASS(); TRESPASS();
return B_ERROR; return B_ERROR;
} }
@@ -212,7 +220,8 @@ BImageResources::find_image(void* memAddr) const
status_t status_t
BImageResources::GetBitmapResource(type_code type, int32 id, BBitmap** out) const BImageResources::GetBitmapResource(type_code type, int32 id,
BBitmap** out) const
{ {
*out = NULL; *out = NULL;
+43 -24
View File
@@ -110,12 +110,14 @@ namespace BPrivate {
class DraggableContainerIcon : public BView { class DraggableContainerIcon : public BView {
public: public:
DraggableContainerIcon(BRect rect, const char* name, uint32 resizeMask); DraggableContainerIcon(BRect rect, const char* name,
uint32 resizeMask);
virtual void AttachedToWindow(); virtual void AttachedToWindow();
virtual void MouseDown(BPoint where); virtual void MouseDown(BPoint where);
virtual void MouseUp(BPoint where); virtual void MouseUp(BPoint where);
virtual void MouseMoved(BPoint point, uint32 /*transit*/, const BMessage* message); virtual void MouseMoved(BPoint point, uint32 /*transit*/,
const BMessage* message);
virtual void FrameMoved(BPoint newLocation); virtual void FrameMoved(BPoint newLocation);
virtual void Draw(BRect updateRect); virtual void Draw(BRect updateRect);
@@ -215,7 +217,8 @@ CompareLabels(const BMenuItem* item1, const BMenuItem* item2)
static bool static bool
AddOneAddon(const Model* model, const char* name, uint32 shortcut, bool primary, void* context) AddOneAddon(const Model* model, const char* name, uint32 shortcut,
bool primary, void* context)
{ {
AddOneAddonParams* params = (AddOneAddonParams*)context; AddOneAddonParams* params = (AddOneAddonParams*)context;
@@ -249,14 +252,16 @@ AddOnThread(BMessage* refsMessage, entry_ref addonRef, entry_ref dirRef)
image_id addonImage = load_add_on(path.Path()); image_id addonImage = load_add_on(path.Path());
if (addonImage >= 0) { if (addonImage >= 0) {
void (*processRefs)(entry_ref, BMessage*, void*); void (*processRefs)(entry_ref, BMessage*, void*);
result = get_image_symbol(addonImage, "process_refs", 2, (void**)&processRefs); result = get_image_symbol(addonImage, "process_refs", 2,
(void**)&processRefs);
#ifndef __INTEL__ #ifndef __INTEL__
if (result < 0) { if (result < 0) {
PRINT(("trying old legacy ppc signature\n")); PRINT(("trying old legacy ppc signature\n"));
// try old-style addon signature // try old-style addon signature
result = get_image_symbol(addonImage, result = get_image_symbol(addonImage,
"process_refs__F9entry_refP8BMessagePv", 2, (void**)&processRefs); "process_refs__F9entry_refP8BMessagePv", 2,
(void**)&processRefs);
} }
#endif #endif
@@ -279,8 +284,8 @@ AddOnThread(BMessage* refsMessage, entry_ref addonRef, entry_ref dirRef)
buffer.ReplaceFirst("%error", strerror(result)); buffer.ReplaceFirst("%error", strerror(result));
buffer.ReplaceFirst("%name", addonRef.name); buffer.ReplaceFirst("%name", addonRef.name);
BAlert* alert = new BAlert("", buffer.String(), B_TRANSLATE("Cancel"), 0, 0, BAlert* alert = new BAlert("", buffer.String(), B_TRANSLATE("Cancel"),
B_WIDTH_AS_USUAL, B_WARNING_ALERT); 0, 0, B_WIDTH_AS_USUAL, B_WARNING_ALERT);
alert->SetShortcut(0, B_ESCAPE); alert->SetShortcut(0, B_ESCAPE);
alert->Go(); alert->Go();
@@ -946,10 +951,12 @@ BContainerWindow::Init(const BMessage* message)
float iconSize = fMenuBar->Bounds().Height() - 2; float iconSize = fMenuBar->Bounds().Height() - 2;
if (iconSize < 16) if (iconSize < 16)
iconSize = 16; iconSize = 16;
float iconPosY = 1 + (fMenuBar->Bounds().Height() - 2 - iconSize) / 2; float iconPosY = 1 + (fMenuBar->Bounds().Height() - 2
BView* icon = new DraggableContainerIcon(BRect(Bounds().Width() - 4 - iconSize + 1, - iconSize) / 2;
iconPosY, Bounds().Width() - 4, iconPosY + iconSize - 1), BView* icon = new DraggableContainerIcon(BRect(Bounds().Width()
"ThisContainer", B_FOLLOW_RIGHT); - 4 - iconSize + 1, iconPosY, Bounds().Width() - 4,
iconPosY + iconSize - 1), "ThisContainer",
B_FOLLOW_RIGHT);
fMenuBar->AddChild(icon); fMenuBar->AddChild(icon);
} }
} else { } else {
@@ -958,11 +965,12 @@ BContainerWindow::Init(const BMessage* message)
} }
AddContextMenus(); AddContextMenus();
AddShortcut('T', B_COMMAND_KEY | B_SHIFT_KEY, new BMessage(kDelete), PoseView()); AddShortcut('T', B_COMMAND_KEY | B_SHIFT_KEY, new BMessage(kDelete),
PoseView());
AddShortcut('K', B_COMMAND_KEY | B_SHIFT_KEY, new BMessage(kCleanupAll), AddShortcut('K', B_COMMAND_KEY | B_SHIFT_KEY, new BMessage(kCleanupAll),
PoseView()); PoseView());
AddShortcut('Q', B_COMMAND_KEY | B_OPTION_KEY | B_SHIFT_KEY | B_CONTROL_KEY, AddShortcut('Q', B_COMMAND_KEY | B_OPTION_KEY | B_SHIFT_KEY
new BMessage(kQuitTracker)); | B_CONTROL_KEY, new BMessage(kQuitTracker));
AddShortcut(B_DOWN_ARROW, B_COMMAND_KEY, new BMessage(kOpenSelection), AddShortcut(B_DOWN_ARROW, B_COMMAND_KEY, new BMessage(kOpenSelection),
PoseView()); PoseView());
@@ -971,9 +979,12 @@ BContainerWindow::Init(const BMessage* message)
#if DEBUG #if DEBUG
// add some debugging shortcuts // add some debugging shortcuts
AddShortcut('D', B_COMMAND_KEY | B_CONTROL_KEY, new BMessage('dbug'), PoseView()); AddShortcut('D', B_COMMAND_KEY | B_CONTROL_KEY, new BMessage('dbug'),
AddShortcut('C', B_COMMAND_KEY | B_CONTROL_KEY, new BMessage('dpcc'), PoseView()); PoseView());
AddShortcut('F', B_COMMAND_KEY | B_CONTROL_KEY, new BMessage('dpfl'), PoseView()); AddShortcut('C', B_COMMAND_KEY | B_CONTROL_KEY, new BMessage('dpcc'),
PoseView());
AddShortcut('F', B_COMMAND_KEY | B_CONTROL_KEY, new BMessage('dpfl'),
PoseView());
AddShortcut('F', B_COMMAND_KEY | B_CONTROL_KEY | B_OPTION_KEY, AddShortcut('F', B_COMMAND_KEY | B_CONTROL_KEY | B_OPTION_KEY,
new BMessage('dpfL'), PoseView()); new BMessage('dpfL'), PoseView());
#endif #endif
@@ -1007,7 +1018,8 @@ BContainerWindow::Init(const BMessage* message)
void void
BContainerWindow::RestoreState() BContainerWindow::RestoreState()
{ {
SetSizeLimits(kContainerWidthMinLimit, 10000, kContainerWindowHeightLimit, 10000); SetSizeLimits(kContainerWidthMinLimit, 10000,
kContainerWindowHeightLimit, 10000);
UpdateTitle(); UpdateTitle();
@@ -1022,7 +1034,8 @@ BContainerWindow::RestoreState()
void void
BContainerWindow::RestoreState(const BMessage &message) BContainerWindow::RestoreState(const BMessage &message)
{ {
SetSizeLimits(kContainerWidthMinLimit, 10000, kContainerWindowHeightLimit, 10000); SetSizeLimits(kContainerWidthMinLimit, 10000,
kContainerWindowHeightLimit, 10000);
UpdateTitle(); UpdateTitle();
@@ -1057,7 +1070,8 @@ BContainerWindow::RestoreStateCommon()
if (!fBackgroundImage && !isDesktop if (!fBackgroundImage && !isDesktop
&& DefaultStateSourceNode(kDefaultFolderTemplate, &defaultingNode)) && DefaultStateSourceNode(kDefaultFolderTemplate, &defaultingNode))
// look for background image info in the source for defaults // look for background image info in the source for defaults
fBackgroundImage = BackgroundImage::GetBackgroundImage(&defaultingNode, isDesktop); fBackgroundImage
= BackgroundImage::GetBackgroundImage(&defaultingNode, isDesktop);
} }
@@ -1075,7 +1089,8 @@ BContainerWindow::UpdateTitle()
SetTitle(TargetModel()->Name()); SetTitle(TargetModel()->Name());
if (Navigator()) if (Navigator())
Navigator()->UpdateLocation(PoseView()->TargetModel(), kActionUpdatePath); Navigator()->UpdateLocation(PoseView()->TargetModel(),
kActionUpdatePath);
} }
@@ -1121,7 +1136,8 @@ BContainerWindow::FrameResized(float, float)
if (offsetY < 0 && PoseView()->Bounds().bottom > extent.bottom if (offsetY < 0 && PoseView()->Bounds().bottom > extent.bottom
&& Bounds().Height() > fPreviousBounds.Height()) && Bounds().Height() > fPreviousBounds.Height())
scroll.y scroll.y
= max_c(fPreviousBounds.Height() - Bounds().Height(), offsetY); = max_c(fPreviousBounds.Height() - Bounds().Height(),
offsetY);
if (scroll != B_ORIGIN) if (scroll != B_ORIGIN)
PoseView()->ScrollBy(scroll.x, scroll.y); PoseView()->ScrollBy(scroll.x, scroll.y);
@@ -1154,7 +1170,8 @@ BContainerWindow::ViewModeChanged(uint32 oldMode, uint32 newMode)
{ {
BView* view = FindView("MenuBar"); BView* view = FindView("MenuBar");
if (view != NULL) { if (view != NULL) {
// make sure the draggable icon hides if it doesn't have space left anymore // make sure the draggable icon hides if it doesn't
// have space left anymore
view = view->FindView("ThisContainer"); view = view->FindView("ThisContainer");
if (view != NULL) if (view != NULL)
view->FrameMoved(view->Frame().LeftTop()); view->FrameMoved(view->Frame().LeftTop());
@@ -1248,8 +1265,10 @@ BContainerWindow::GetLayoutState(BNode* node, BMessage* message)
continue; continue;
char* buffer = new char[info.size]; char* buffer = new char[info.size];
if (node->ReadAttr(attrName, info.type, 0, buffer, (size_t)info.size) == info.size) if (node->ReadAttr(attrName, info.type, 0, buffer,
(size_t)info.size) == info.size) {
message->AddData(attrName, info.type, buffer, (ssize_t)info.size); message->AddData(attrName, info.type, buffer, (ssize_t)info.size);
}
delete [] buffer; delete [] buffer;
} }
return B_OK; return B_OK;
+4 -2
View File
@@ -241,7 +241,8 @@ DesktopPoseView::AdaptToVolumeChange(BMessage* message)
entryMessage.AddInt32("opcode", B_ENTRY_REMOVED); entryMessage.AddInt32("opcode", B_ENTRY_REMOVED);
entry_ref ref; entry_ref ref;
if (entry.GetRef(&ref) == B_OK) { if (entry.GetRef(&ref) == B_OK) {
BContainerWindow* disksWindow = tracker->FindContainerWindow(&ref); BContainerWindow* disksWindow
= tracker->FindContainerWindow(&ref);
if (disksWindow) { if (disksWindow) {
disksWindow->Lock(); disksWindow->Lock();
disksWindow->Close(); disksWindow->Close();
@@ -252,7 +253,8 @@ DesktopPoseView::AdaptToVolumeChange(BMessage* message)
entryMessage.AddInt64("node", model.NodeRef()->node); entryMessage.AddInt64("node", model.NodeRef()->node);
entryMessage.AddInt64("directory", model.EntryRef()->directory); entryMessage.AddInt64("directory", model.EntryRef()->directory);
entryMessage.AddString("name", model.EntryRef()->name); entryMessage.AddString("name", model.EntryRef()->name);
BContainerWindow* deskWindow = dynamic_cast<BContainerWindow*>(Window()); BContainerWindow* deskWindow
= dynamic_cast<BContainerWindow*>(Window());
if (deskWindow) if (deskWindow)
deskWindow->PostMessage(&entryMessage, deskWindow->PoseView()); deskWindow->PostMessage(&entryMessage, deskWindow->PoseView());
} }
+20 -14
View File
@@ -195,8 +195,8 @@ FSClipboardClear()
*/ */
uint32 uint32
FSClipboardAddPoses(const node_ref* directory, PoseList* list, uint32 moveMode, FSClipboardAddPoses(const node_ref* directory, PoseList* list,
bool clearClipboard) uint32 moveMode, bool clearClipboard)
{ {
uint32 refsAdded = 0; uint32 refsAdded = 0;
int32 listCount = list->CountItems(); int32 listCount = list->CountItems();
@@ -409,13 +409,16 @@ FSClipboardPaste(Model* model, uint32 linksMode)
// we need this data later on // we need this data later on
MakeModeNameFromRefName(modeName, refName); MakeModeNameFromRefName(modeName, refName);
if (!linksMode && clip->FindInt32(modeName, (int32*)&moveMode) != B_OK) if (!linksMode && clip->FindInt32(modeName, (int32*)&moveMode)
!= B_OK) {
continue; continue;
}
BEntry entry(&ref); BEntry entry(&ref);
uint32 newMoveMode = 0; uint32 newMoveMode = 0;
bool sameDirectory = destNodeRef->device == ref.device && destNodeRef->node == ref.directory; bool sameDirectory = destNodeRef->device == ref.device
&& destNodeRef->node == ref.directory;
if (!entry.Exists()) { if (!entry.Exists()) {
// The entry doesn't exist anymore, so we'll remove // The entry doesn't exist anymore, so we'll remove
@@ -435,9 +438,10 @@ FSClipboardPaste(Model* model, uint32 linksMode)
copyList->AddItem(new entry_ref(ref)); copyList->AddItem(new entry_ref(ref));
} }
// if the entry should have been removed from its directory, // if the entry should have been removed from its
// we want to copy that entry next time, no matter if the // directory, we want to copy that entry next time, no
// items don't have to be moved at all (source == target) // matter if the items don't have to be moved at all
// (source == target)
if (moveMode == kMoveSelectionTo) if (moveMode == kMoveSelectionTo)
newMoveMode = kCopySelectionTo; newMoveMode = kCopySelectionTo;
} }
@@ -449,8 +453,8 @@ FSClipboardPaste(Model* model, uint32 linksMode)
TClipboardNodeRef clipNode; TClipboardNodeRef clipNode;
MakeNodeFromName(&clipNode.node, modeName); MakeNodeFromName(&clipNode.node, modeName);
clipNode.moveMode = kDelete; clipNode.moveMode = kDelete;
updateMessage->AddData("tcnode", T_CLIPBOARD_NODE, &clipNode, updateMessage->AddData("tcnode", T_CLIPBOARD_NODE,
sizeof(TClipboardNodeRef), true); &clipNode, sizeof(TClipboardNodeRef), true);
} }
} }
be_clipboard->Commit(); be_clipboard->Commit();
@@ -470,7 +474,7 @@ FSClipboardPaste(Model* model, uint32 linksMode)
if (model->IsRoot()) { if (model->IsRoot()) {
BAlert* alert = new BAlert("", BAlert* alert = new BAlert("",
B_TRANSLATE("You must drop items on one of the disk icons " B_TRANSLATE("You must drop items on one of the disk icons "
"in the \"Disks\" window."), B_TRANSLATE("Cancel"), NULL, NULL, "in the \"Disks\" window."), B_TRANSLATE("Cancel"), NULL, NULL,
B_WIDTH_AS_USUAL, B_WARNING_ALERT); B_WIDTH_AS_USUAL, B_WARNING_ALERT);
alert->SetShortcut(0, B_ESCAPE); alert->SetShortcut(0, B_ESCAPE);
alert->Go(); alert->Go();
@@ -499,9 +503,10 @@ FSClipboardPaste(Model* model, uint32 linksMode)
} }
// asynchronous calls take over ownership of the objects passed to it // asynchronous calls take over ownership of the objects passed to it
if (moveList->CountItems() > 0) if (moveList->CountItems() > 0) {
FSMoveToFolder(moveList, new BEntry(entry), linksMode ? linksMode : kMoveSelectionTo); FSMoveToFolder(moveList, new BEntry(entry),
else linksMode ? linksMode : kMoveSelectionTo);
} else
delete moveList; delete moveList;
if (copyList->CountItems() > 0) if (copyList->CountItems() > 0)
@@ -761,7 +766,8 @@ BClipboardRefsWatcher::Clear()
//void //void
//BClipboardRefsWatcher::UpdatePoseViews(bool clearClipboard, const node_ref* node) //BClipboardRefsWatcher::UpdatePoseViews(bool clearClipboard,
// const node_ref* node)
//{ //{
// BMessage message(kFSClipboardChanges); // BMessage message(kFSClipboardChanges);
// message.AddInt32("device", node->device); // message.AddInt32("device", node->device);
+5 -3
View File
@@ -67,7 +67,7 @@ class BClipboardRefsWatcher : public BLooper {
void UpdatePoseViews(BMessage* reportMessage); void UpdatePoseViews(BMessage* reportMessage);
protected: protected:
virtual void MessageReceived(BMessage*); virtual void MessageReceived(BMessage*);
private: private:
bool fRefsInClipboard; bool fRefsInClipboard;
@@ -87,10 +87,12 @@ void FSClipboardStartWatch(BMessenger target);
void FSClipboardStopWatch(BMessenger target); void FSClipboardStopWatch(BMessenger target);
void FSClipboardClear(); void FSClipboardClear();
uint32 FSClipboardAddPoses(const node_ref* directory, PoseList* list, uint32 moveMode, bool clearClipboard); uint32 FSClipboardAddPoses(const node_ref* directory, PoseList* list,
uint32 moveMode, bool clearClipboard);
uint32 FSClipboardRemovePoses(const node_ref* directory, PoseList* list); uint32 FSClipboardRemovePoses(const node_ref* directory, PoseList* list);
bool FSClipboardPaste(Model* model, uint32 linksMode = 0); bool FSClipboardPaste(Model* model, uint32 linksMode = 0);
void FSClipboardRemove(Model* model); void FSClipboardRemove(Model* model);
uint32 FSClipboardFindNodeMode(Model* model, bool autoLock, bool updateRefIfNeeded); uint32 FSClipboardFindNodeMode(Model* model, bool autoLock,
bool updateRefIfNeeded);
#endif // FS_CLIPBOARD_H #endif // FS_CLIPBOARD_H
+18 -14
View File
@@ -50,7 +50,8 @@ class UndoItemMove : public UndoItem {
/** source - list of file(s) that were moved. Assumes ownership. /** source - list of file(s) that were moved. Assumes ownership.
* origfolder - location it was moved from * origfolder - location it was moved from
*/ */
UndoItemMove(BObjectList<entry_ref>* sourceList, BDirectory &target, BList* pointList); UndoItemMove(BObjectList<entry_ref>* sourceList, BDirectory &target,
BList* pointList);
virtual ~UndoItemMove(); virtual ~UndoItemMove();
virtual status_t Undo(); virtual status_t Undo();
@@ -72,10 +73,12 @@ class UndoItemFolder : public UndoItem {
virtual status_t Redo(); virtual status_t Redo();
private: private:
/* this ref has two different meanings in the different states of this object: // this ref has two different meanings in the different states of
- Undo() - fRef indicates the folder that was created via FSCreateNewFolderIn(...) // this object:
- Redo() - fRef indicates the folder in which FSCreateNewFolderIn() should be performed // - Undo() - fRef indicates the folder that was created via
*/ // FSCreateNewFolderIn(...)
// - Redo() - fRef indicates the folder in which
// FSCreateNewFolderIn() should be performed
entry_ref fRef; entry_ref fRef;
}; };
@@ -169,8 +172,8 @@ Undo::Remove()
} }
MoveCopyUndo::MoveCopyUndo(BObjectList<entry_ref>* sourceList, BDirectory &dest, MoveCopyUndo::MoveCopyUndo(BObjectList<entry_ref>* sourceList,
BList* pointList, uint32 moveMode) BDirectory &dest, BList* pointList, uint32 moveMode)
{ {
if (moveMode == kMoveSelectionTo) if (moveMode == kMoveSelectionTo)
fUndo = new UndoItemMove(sourceList, dest, pointList); fUndo = new UndoItemMove(sourceList, dest, pointList);
@@ -200,8 +203,8 @@ RenameVolumeUndo::RenameVolumeUndo(BVolume &volume, const char* newName)
// #pragma mark - // #pragma mark -
UndoItemCopy::UndoItemCopy(BObjectList<entry_ref>* sourceList, BDirectory &target, UndoItemCopy::UndoItemCopy(BObjectList<entry_ref>* sourceList,
BList* /*pointList*/, uint32 moveMode) BDirectory &target, BList* /*pointList*/, uint32 moveMode)
: :
fSourceList(*sourceList), fSourceList(*sourceList),
fTargetList(*sourceList), fTargetList(*sourceList),
@@ -264,8 +267,8 @@ UndoItemCopy::UpdateEntry(BEntry* entry, const char* name)
// #pragma mark - // #pragma mark -
UndoItemMove::UndoItemMove(BObjectList<entry_ref>* sourceList, BDirectory &target, UndoItemMove::UndoItemMove(BObjectList<entry_ref>* sourceList,
BList* /*pointList*/) BDirectory &target, BList* /*pointList*/)
: :
fSourceList(*sourceList) fSourceList(*sourceList)
{ {
@@ -293,7 +296,8 @@ UndoItemMove::Undo()
ChangeListSource(*list, entry); ChangeListSource(*list, entry);
// FSMoveToFolder() owns its arguments // FSMoveToFolder() owns its arguments
FSMoveToFolder(list, new BEntry(&fSourceRef), FSUndoMoveMode(kMoveSelectionTo), NULL); FSMoveToFolder(list, new BEntry(&fSourceRef),
FSUndoMoveMode(kMoveSelectionTo), NULL);
return B_OK; return B_OK;
} }
@@ -303,8 +307,8 @@ status_t
UndoItemMove::Redo() UndoItemMove::Redo()
{ {
// FSMoveToFolder() owns its arguments // FSMoveToFolder() owns its arguments
FSMoveToFolder(new BObjectList<entry_ref>(fSourceList), new BEntry(&fTargetRef), FSMoveToFolder(new BObjectList<entry_ref>(fSourceList),
FSUndoMoveMode(kMoveSelectionTo), NULL); new BEntry(&fTargetRef), FSUndoMoveMode(kMoveSelectionTo), NULL);
return B_OK; return B_OK;
} }
+44 -35
View File
@@ -46,8 +46,8 @@ All rights reserved.
#include "ObjectList.h" #include "ObjectList.h"
// Note - APIs/code in FSUtils.h and FSUtils.cpp is slated for a major cleanup // 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 // -- in other words, you will find a lot of ugly cruft in here
class BDirectory; class BDirectory;
class BEntry; class BEntry;
@@ -165,36 +165,39 @@ private:
#endif #endif
_IMPEXP_TRACKER status_t FSCopyAttributesAndStats(BNode*, BNode*); _IMPEXP_TRACKER status_t FSCopyAttributesAndStats(BNode*, BNode*);
_IMPEXP_TRACKER void FSDuplicate(BObjectList<entry_ref>* srcList, BList* pointList); _IMPEXP_TRACKER void FSDuplicate(BObjectList<entry_ref>* srcList,
_IMPEXP_TRACKER void FSMoveToFolder(BObjectList<entry_ref>* srcList, BEntry*, uint32 moveMode, BList* pointList);
BList* pointList = NULL); _IMPEXP_TRACKER void FSMoveToFolder(BObjectList<entry_ref>* srcList, BEntry*,
_IMPEXP_TRACKER void FSMakeOriginalName(char* name, BDirectory* destDir, const char* suffix); uint32 moveMode, BList* pointList = NULL);
_IMPEXP_TRACKER void FSMakeOriginalName(char* name, BDirectory* destDir,
const char* suffix);
_IMPEXP_TRACKER bool FSIsTrashDir(const BEntry*); _IMPEXP_TRACKER bool FSIsTrashDir(const BEntry*);
_IMPEXP_TRACKER bool FSIsPrintersDir(const BEntry*); _IMPEXP_TRACKER bool FSIsPrintersDir(const BEntry*);
_IMPEXP_TRACKER bool FSIsDeskDir(const BEntry*); _IMPEXP_TRACKER bool FSIsDeskDir(const BEntry*);
_IMPEXP_TRACKER bool FSIsHomeDir(const BEntry*); _IMPEXP_TRACKER bool FSIsHomeDir(const BEntry*);
_IMPEXP_TRACKER bool FSIsRootDir(const BEntry*); _IMPEXP_TRACKER bool FSIsRootDir(const BEntry*);
_IMPEXP_TRACKER void FSMoveToTrash(BObjectList<entry_ref>* srcList, BList* pointList = NULL, _IMPEXP_TRACKER void FSMoveToTrash(BObjectList<entry_ref>* srcList,
bool async = true); BList* pointList = NULL, bool async = true);
// Deprecated // Deprecated
void FSDeleteRefList(BObjectList<entry_ref>*, bool, bool confirm = true); void FSDeleteRefList(BObjectList<entry_ref>*, bool, bool confirm = true);
void FSDelete(entry_ref*, bool, bool confirm = true); void FSDelete(entry_ref*, bool, bool confirm = true);
void FSRestoreRefList(BObjectList<entry_ref>* list, bool async); void FSRestoreRefList(BObjectList<entry_ref>* list, bool async);
_IMPEXP_TRACKER status_t FSLaunchItem(const entry_ref* application, const BMessage* refsReceived, _IMPEXP_TRACKER status_t FSLaunchItem(const entry_ref* application,
bool async, bool openWithOK); const BMessage* refsReceived, bool async, bool openWithOK);
// Preferred way of launching; only pass an actual application in <application>, not // Preferred way of launching; only pass an actual application in
// a document; to open documents with the preferred app, pase 0 in <application> and // <application>, not a document; to open documents with the preferred
// stuff all the document refs into <refsReceived> // app, pase 0 in <application> and stuff all the document refs into
// Consider having silent mode that does not show alerts, just returns error code // <refsReceived> Consider having silent mode that does not show alerts,
// just returns error code
_IMPEXP_TRACKER status_t FSOpenWith(BMessage* listOfRefs); _IMPEXP_TRACKER status_t FSOpenWith(BMessage* listOfRefs);
// runs the Open With window; pas a list of refs // runs the Open With window; pas a list of refs
_IMPEXP_TRACKER void FSEmptyTrash(); _IMPEXP_TRACKER void FSEmptyTrash();
_IMPEXP_TRACKER status_t FSCreateNewFolderIn(const node_ref* destDir, entry_ref* newRef, _IMPEXP_TRACKER status_t FSCreateNewFolderIn(const node_ref* destDir,
node_ref* new_node); entry_ref* newRef, node_ref* new_node);
_IMPEXP_TRACKER void FSCreateTrashDirs(); _IMPEXP_TRACKER void FSCreateTrashDirs();
_IMPEXP_TRACKER status_t FSGetTrashDir(BDirectory* trashDir, dev_t volume); _IMPEXP_TRACKER status_t FSGetTrashDir(BDirectory* trashDir, dev_t volume);
_IMPEXP_TRACKER status_t FSGetDeskDir(BDirectory* deskDir); _IMPEXP_TRACKER status_t FSGetDeskDir(BDirectory* deskDir);
@@ -218,23 +221,26 @@ enum ReadAttrResult {
kReadAttrForeignOK kReadAttrForeignOK
}; };
ReadAttrResult ReadAttr(const BNode*, const char* hostAttrName, const char* foreignAttrName, ReadAttrResult ReadAttr(const BNode*, const char* hostAttrName,
type_code , off_t , void*, size_t , void (*swapFunc)(void*) = 0, const char* foreignAttrName, type_code, off_t, void*, size_t,
bool isForeign = false); void (*swapFunc)(void*) = 0, bool isForeign = false);
// Endian swapping ReadAttr call; endianness is determined by trying first the // Endian swapping ReadAttr call; endianness is determined by trying
// native attribute name, then the foreign one; an endian swapping function can // first the native attribute name, then the foreign one; an endian
// be passed, if null data won't be swapped; if <isForeign> set the foreign endianness // swapping function can be passed, if null data won't be swapped;
// will be read directly without first trying the native one // if <isForeign> set the foreign endianness will be read directly
// without first trying the native one
ReadAttrResult GetAttrInfo(const BNode*, const char* hostAttrName, const char* foreignAttrName, ReadAttrResult GetAttrInfo(const BNode*, const char* hostAttrName,
type_code* = NULL, size_t* = NULL); const char* foreignAttrName, type_code* = NULL, size_t* = NULL);
status_t FSCreateNewFolder(const entry_ref*); status_t FSCreateNewFolder(const entry_ref*);
status_t FSRecursiveCreateFolder(const char* path); status_t FSRecursiveCreateFolder(const char* path);
void FSMakeOriginalName(BString &name, const BDirectory* destDir, const char* suffix = 0); void FSMakeOriginalName(BString &name, const BDirectory* destDir,
const char* suffix = 0);
status_t TrackerLaunch(const entry_ref* app, bool async); status_t TrackerLaunch(const entry_ref* app, bool async);
status_t TrackerLaunch(const BMessage* refs, bool async, bool okToRunOpenWith = true); status_t TrackerLaunch(const BMessage* refs, bool async,
bool okToRunOpenWith = true);
status_t TrackerLaunch(const entry_ref* app, const BMessage* refs, bool async, status_t TrackerLaunch(const entry_ref* app, const BMessage* refs, bool async,
bool okToRunOpenWith = true); bool okToRunOpenWith = true);
status_t LaunchBrokenLink(const char*, const BMessage*); status_t LaunchBrokenLink(const char*, const BMessage*);
@@ -243,9 +249,9 @@ status_t FSFindTrackerSettingsDir(BPath*, bool autoCreate = true);
bool FSIsDeskDir(const BEntry*); bool FSIsDeskDir(const BEntry*);
// two separate ifYouDoAction and toDoAction versions are needed for localization // two separate ifYouDoAction and toDoAction versions are needed for
// purposes. The first one is used in "If you do action ..." sentence, // localization purposes. The first one is used in "If you do action..."
// the second one in the "To do action" sentence. // sentence, the second one in the "To do action" sentence.
bool ConfirmChangeIfWellKnownDirectory(const BEntry* entry, bool ConfirmChangeIfWellKnownDirectory(const BEntry* entry,
const char* ifYouDoAction, const char* toDoAction, const char* ifYouDoAction, const char* toDoAction,
const char* toConfirmAction, bool dontAsk = false, const char* toConfirmAction, bool dontAsk = false,
@@ -254,12 +260,14 @@ bool ConfirmChangeIfWellKnownDirectory(const BEntry* entry,
bool CheckDevicesEqual(const entry_ref* entry, const Model* targetModel); bool CheckDevicesEqual(const entry_ref* entry, const Model* targetModel);
// Deprecated calls use newer calls above instead // Deprecated calls use newer calls above instead
_IMPEXP_TRACKER void FSLaunchItem(const entry_ref*, BMessage* = NULL, int32 workspace = -1); _IMPEXP_TRACKER void FSLaunchItem(const entry_ref*, BMessage* = NULL,
int32 workspace = -1);
_IMPEXP_TRACKER status_t FSLaunchItem(const entry_ref*, BMessage*, _IMPEXP_TRACKER status_t FSLaunchItem(const entry_ref*, BMessage*,
int32 workspace, bool asynch); int32 workspace, bool asynch);
_IMPEXP_TRACKER void FSOpenWithDocuments(const entry_ref* executableToLaunch, _IMPEXP_TRACKER void FSOpenWithDocuments(const entry_ref* executableToLaunch,
BMessage* documentEntryRefs); BMessage* documentEntryRefs);
_IMPEXP_TRACKER status_t FSLaunchUsing(const entry_ref* ref, BMessage* listOfRefs); _IMPEXP_TRACKER status_t FSLaunchUsing(const entry_ref* ref,
BMessage* listOfRefs);
// some extra directory_which values // some extra directory_which values
@@ -279,7 +287,8 @@ class WellKnowEntryList {
// system hierarchy // system hierarchy
public: public:
struct WellKnownEntry { struct WellKnownEntry {
WellKnownEntry(const node_ref* node, directory_which which, const char* name) WellKnownEntry(const node_ref* node, directory_which which,
const char* name)
: :
node(*node), node(*node),
which(which), which(which),
@@ -314,8 +323,8 @@ class WellKnowEntryList {
WellKnowEntryList(); WellKnowEntryList();
void AddOne(directory_which, const char* name); void AddOne(directory_which, const char* name);
void AddOne(directory_which, const char* path, const char* name); void AddOne(directory_which, const char* path, const char* name);
void AddOne(directory_which, directory_which base, const char* extension, void AddOne(directory_which, directory_which base,
const char* name); const char* extension, const char* name);
std::vector<WellKnownEntry> entries; std::vector<WellKnownEntry> entries;
static WellKnowEntryList* self; static WellKnowEntryList* self;
+11 -6
View File
@@ -124,7 +124,8 @@ FavoritesMenu::AddNextItem()
try { try {
BPath path; BPath path;
ThrowOnError( find_directory (B_USER_SETTINGS_DIRECTORY, &path, true) ); ThrowOnError(find_directory(B_USER_SETTINGS_DIRECTORY,
&path, true));
path.Append(kGoDirectory); path.Append(kGoDirectory);
mkdir(path.Path(), 0777); mkdir(path.Path(), 0777);
@@ -169,7 +170,8 @@ FavoritesMenu::AddNextItem()
if (item == NULL) if (item == NULL)
return true; return true;
item->SetLabel(ref.name); // this is the name of the link in the Go dir item->SetLabel(ref.name);
// this is the name of the link in the Go dir
if (!fAddedSeparatorForSection) { if (!fAddedSeparatorForSection) {
fAddedSeparatorForSection = true; fAddedSeparatorForSection = true;
@@ -214,7 +216,8 @@ FavoritesMenu::AddNextItem()
if (!ShouldShowModel(&model)) if (!ShouldShowModel(&model))
return true; return true;
BMenuItem* item = BNavMenu::NewModelItem(&model, fOpenFileMessage, fTarget); BMenuItem* item = BNavMenu::NewModelItem(&model,
fOpenFileMessage, fTarget);
if (item) { if (item) {
if (!fAddedSeparatorForSection) { if (!fAddedSeparatorForSection) {
fAddedSeparatorForSection = true; fAddedSeparatorForSection = true;
@@ -252,8 +255,10 @@ FavoritesMenu::AddNextItem()
// don't add folders that are already in the GoTo section // don't add folders that are already in the GoTo section
if (find_if(fUniqueRefCheck.begin(), fUniqueRefCheck.end(), if (find_if(fUniqueRefCheck.begin(), fUniqueRefCheck.end(),
bind2nd(std::equal_to<entry_ref>(), ref)) != fUniqueRefCheck.end()) bind2nd(std::equal_to<entry_ref>(), ref))
!= fUniqueRefCheck.end()) {
continue; continue;
}
Model model(&ref, true); Model model(&ref, true);
if (model.InitCheck() != B_OK) if (model.InitCheck() != B_OK)
@@ -262,8 +267,8 @@ FavoritesMenu::AddNextItem()
if (!ShouldShowModel(&model)) if (!ShouldShowModel(&model))
return true; return true;
BMenuItem* item = BNavMenu::NewModelItem(&model, fOpenFolderMessage, BMenuItem* item = BNavMenu::NewModelItem(&model,
fTarget, true); fOpenFolderMessage, fTarget, true);
if (item) { if (item) {
if (!fAddedSeparatorForSection) { if (!fAddedSeparatorForSection) {
fAddedSeparatorForSection = true; fAddedSeparatorForSection = true;
+93 -49
View File
@@ -507,7 +507,8 @@ TFilePanel::AdjustButton()
if (!button) if (!button)
return; return;
BTextControl* textControl = dynamic_cast<BTextControl*>(FindView("text view")); BTextControl* textControl
= dynamic_cast<BTextControl*>(FindView("text view"));
BObjectList<BPose>* selectionList = fPoseView->SelectionList(); BObjectList<BPose>* selectionList = fPoseView->SelectionList();
BString buttonText = fButtonText; BString buttonText = fButtonText;
bool enabled = false; bool enabled = false;
@@ -522,7 +523,8 @@ TFilePanel::AdjustButton()
enabled = true; enabled = true;
buttonText = B_TRANSLATE("Open"); buttonText = B_TRANSLATE("Open");
} else { } else {
// insert the name of the selected model into the text field // insert the name of the selected model into
// the text field
textControl->SetText(model->Name()); textControl->SetText(model->Name());
textControl->MakeFocus(true); textControl->MakeFocus(true);
} }
@@ -736,30 +738,39 @@ TFilePanel::Init(const BMessage*)
AddShortcut('W', B_COMMAND_KEY, new BMessage(kCancelButton)); AddShortcut('W', B_COMMAND_KEY, new BMessage(kCancelButton));
AddShortcut('H', B_COMMAND_KEY, new BMessage(kSwitchToHome)); AddShortcut('H', B_COMMAND_KEY, new BMessage(kSwitchToHome));
AddShortcut('A', B_COMMAND_KEY | B_SHIFT_KEY, new BMessage(kShowSelectionWindow)); AddShortcut('A', B_COMMAND_KEY | B_SHIFT_KEY,
new BMessage(kShowSelectionWindow));
AddShortcut('A', B_COMMAND_KEY, new BMessage(B_SELECT_ALL), PoseView()); AddShortcut('A', B_COMMAND_KEY, new BMessage(B_SELECT_ALL), PoseView());
AddShortcut('S', B_COMMAND_KEY, new BMessage(kInvertSelection), PoseView()); AddShortcut('S', B_COMMAND_KEY, new BMessage(kInvertSelection),
PoseView());
AddShortcut('Y', B_COMMAND_KEY, new BMessage(kResizeToFit), PoseView()); AddShortcut('Y', B_COMMAND_KEY, new BMessage(kResizeToFit), PoseView());
AddShortcut(B_DOWN_ARROW, B_COMMAND_KEY, new BMessage(kOpenDir)); AddShortcut(B_DOWN_ARROW, B_COMMAND_KEY, new BMessage(kOpenDir));
AddShortcut(B_DOWN_ARROW, B_COMMAND_KEY | B_OPTION_KEY, new BMessage(kOpenDir)); AddShortcut(B_DOWN_ARROW, B_COMMAND_KEY | B_OPTION_KEY,
new BMessage(kOpenDir));
AddShortcut(B_UP_ARROW, B_COMMAND_KEY, new BMessage(kOpenParentDir)); AddShortcut(B_UP_ARROW, B_COMMAND_KEY, new BMessage(kOpenParentDir));
AddShortcut(B_UP_ARROW, B_COMMAND_KEY | B_OPTION_KEY, new BMessage(kOpenParentDir)); AddShortcut(B_UP_ARROW, B_COMMAND_KEY | B_OPTION_KEY,
new BMessage(kOpenParentDir));
// New code to make buttons font sensitive // New code to make buttons font sensitive
rect = windRect; rect = windRect;
rect.top = rect.bottom - 35; rect.top = rect.bottom - 35;
rect.bottom -= 10; rect.bottom -= 10;
rect.right -= 25; rect.right -= 25;
float default_width = be_plain_font->StringWidth(fButtonText.String()) + 20; float default_width
rect.left = (default_width > 75) ? (rect.right - default_width) : (rect.right - 75); = be_plain_font->StringWidth(fButtonText.String()) + 20;
rect.left = default_width > 75
? rect.right - default_width : rect.right - 75;
BButton* default_button = new BButton(rect, "default button", fButtonText.String(), BButton* default_button = new BButton(rect, "default button",
new BMessage(kDefaultButton), B_FOLLOW_RIGHT + B_FOLLOW_BOTTOM); fButtonText.String(), new BMessage(kDefaultButton),
B_FOLLOW_RIGHT + B_FOLLOW_BOTTOM);
fBackView->AddChild(default_button); fBackView->AddChild(default_button);
rect.right = rect.left -= 10; rect.right = rect.left -= 10;
float cancel_width = be_plain_font->StringWidth(B_TRANSLATE("Cancel")) + 20; float cancel_width
rect.left = (cancel_width > 75) ? (rect.right - cancel_width) : (rect.right - 75); = be_plain_font->StringWidth(B_TRANSLATE("Cancel")) + 20;
rect.left = cancel_width > 75
? rect.right - cancel_width : rect.right - 75;
BButton* cancel_button = new BButton(rect, "cancel button", BButton* cancel_button = new BButton(rect, "cancel button",
B_TRANSLATE("Cancel"), new BMessage(kCancelButton), B_TRANSLATE("Cancel"), new BMessage(kCancelButton),
@@ -804,7 +815,8 @@ void
TFilePanel::RestoreState() TFilePanel::RestoreState()
{ {
BNode defaultingNode; BNode defaultingNode;
if (DefaultStateSourceNode(kDefaultFilePanelTemplate, &defaultingNode, false)) { if (DefaultStateSourceNode(kDefaultFilePanelTemplate, &defaultingNode,
false)) {
AttributeStreamFileNode streamNodeSource(&defaultingNode); AttributeStreamFileNode streamNodeSource(&defaultingNode);
RestoreWindowState(&streamNodeSource); RestoreWindowState(&streamNodeSource);
PoseView()->Init(&streamNodeSource); PoseView()->Init(&streamNodeSource);
@@ -882,7 +894,8 @@ TFilePanel::AddFileContextMenus(BMenu* menu)
new BMessage(B_CUT), 'X')); new BMessage(B_CUT), 'X'));
menu->AddItem(new BMenuItem(B_TRANSLATE("Copy"), menu->AddItem(new BMenuItem(B_TRANSLATE("Copy"),
new BMessage(B_COPY), 'C')); new BMessage(B_COPY), 'C'));
// menu->AddItem(pasteItem = new BMenuItem("Paste", new BMessage(B_PASTE), 'V')); //menu->AddItem(pasteItem = new BMenuItem("Paste", new BMessage(B_PASTE),
// 'V'));
menu->SetTargetForItems(PoseView()); menu->SetTargetForItems(PoseView());
} }
@@ -898,10 +911,12 @@ TFilePanel::AddVolumeContextMenus(BMenu* menu)
menu->AddItem(new BMenuItem(B_TRANSLATE("Edit name"), menu->AddItem(new BMenuItem(B_TRANSLATE("Edit name"),
new BMessage(kEditItem), 'E')); new BMessage(kEditItem), 'E'));
menu->AddSeparatorItem(); menu->AddSeparatorItem();
menu->AddItem(new BMenuItem(B_TRANSLATE("Cut"), new BMessage(B_CUT), 'X')); menu->AddItem(new BMenuItem(B_TRANSLATE("Cut"), new BMessage(B_CUT),
'X'));
menu->AddItem(new BMenuItem(B_TRANSLATE("Copy"), menu->AddItem(new BMenuItem(B_TRANSLATE("Copy"),
new BMessage(B_COPY), 'C')); new BMessage(B_COPY), 'C'));
// menu->AddItem(pasteItem = new BMenuItem("Paste", new BMessage(B_PASTE), 'V')); //menu->AddItem(pasteItem = new BMenuItem("Paste", new BMessage(B_PASTE),
// 'V'));
menu->SetTargetForItems(PoseView()); menu->SetTargetForItems(PoseView());
} }
@@ -955,7 +970,8 @@ TFilePanel::MenusBeginning()
int32 count = PoseView()->SelectionList()->CountItems(); int32 count = PoseView()->SelectionList()->CountItems();
EnableNamedMenuItem(fMenuBar, kNewFolder, !TargetModel()->IsRoot()); EnableNamedMenuItem(fMenuBar, kNewFolder, !TargetModel()->IsRoot());
EnableNamedMenuItem(fMenuBar, kMoveToTrash, !TargetModel()->IsRoot() && count); EnableNamedMenuItem(fMenuBar, kMoveToTrash, !TargetModel()->IsRoot()
&& count);
EnableNamedMenuItem(fMenuBar, kGetInfo, count != 0); EnableNamedMenuItem(fMenuBar, kGetInfo, count != 0);
EnableNamedMenuItem(fMenuBar, kEditItem, count == 1); EnableNamedMenuItem(fMenuBar, kEditItem, count == 1);
@@ -977,9 +993,12 @@ TFilePanel::MenusEnded()
void void
TFilePanel::ShowContextMenu(BPoint point, const entry_ref* ref, BView* view) TFilePanel::ShowContextMenu(BPoint point, const entry_ref* ref, BView* view)
{ {
EnableNamedMenuItem(fWindowContextMenu, kNewFolder, !TargetModel()->IsRoot()); EnableNamedMenuItem(fWindowContextMenu, kNewFolder,
EnableNamedMenuItem(fWindowContextMenu, kOpenParentDir, !TargetModel()->IsRoot()); !TargetModel()->IsRoot());
EnableNamedMenuItem(fWindowContextMenu, kMoveToTrash, !TargetModel()->IsRoot()); EnableNamedMenuItem(fWindowContextMenu, kOpenParentDir,
!TargetModel()->IsRoot());
EnableNamedMenuItem(fWindowContextMenu, kMoveToTrash,
!TargetModel()->IsRoot());
_inherited::ShowContextMenu(point, ref, view); _inherited::ShowContextMenu(point, ref, view);
} }
@@ -998,7 +1017,8 @@ TFilePanel::SetButtonLabel(file_panel_button selector, const char* text)
switch (selector) { switch (selector) {
case B_CANCEL_BUTTON: case B_CANCEL_BUTTON:
{ {
BButton* button = dynamic_cast<BButton*>(FindView("cancel button")); BButton* button
= dynamic_cast<BButton*>(FindView("cancel button"));
if (!button) if (!button)
break; break;
@@ -1016,7 +1036,8 @@ TFilePanel::SetButtonLabel(file_panel_button selector, const char* text)
{ {
fButtonText = text; fButtonText = text;
float delta = 0; float delta = 0;
BButton* button = dynamic_cast<BButton*>(FindView("default button")); BButton* button
= dynamic_cast<BButton*>(FindView("default button"));
if (button) { if (button) {
float old_width = button->StringWidth(button->Label()); float old_width = button->StringWidth(button->Label());
button->SetLabel(text); button->SetLabel(text);
@@ -1043,7 +1064,8 @@ TFilePanel::SetSaveText(const char* text)
if (!text) if (!text)
return; return;
BTextControl* textControl = dynamic_cast<BTextControl*>(FindView("text view")); BTextControl* textControl
= dynamic_cast<BTextControl*>(FindView("text view"));
textControl->SetText(text); textControl->SetText(text);
textControl->TextView()->SelectAll(); textControl->TextView()->SelectAll();
} }
@@ -1060,9 +1082,9 @@ TFilePanel::MessageReceived(BMessage* message)
if (message->FindRef("refs", &ref) == B_OK) { if (message->FindRef("refs", &ref) == B_OK) {
BEntry entry(&ref, true); BEntry entry(&ref, true);
if (entry.InitCheck() == B_OK) { if (entry.InitCheck() == B_OK) {
// Double-click on dir or link-to-dir ALWAYS opens the dir. // Double-click on dir or link-to-dir ALWAYS opens the
// If more than one dir is selected, the // dir. If more than one dir is selected, the first is
// first is entered. // entered.
if (entry.IsDirectory()) { if (entry.IsDirectory()) {
entry.GetRef(&ref); entry.GetRef(&ref);
bool isDesktop = SwitchDirToDesktopIfNeeded(ref); bool isDesktop = SwitchDirToDesktopIfNeeded(ref);
@@ -1075,7 +1097,8 @@ TFilePanel::MessageReceived(BMessage* message)
// Otherwise, we have a file or a link to a file. // Otherwise, we have a file or a link to a file.
// AdjustButton has already tested the flavor; // AdjustButton has already tested the flavor;
// all we have to do is see if the button is enabled. // all we have to do is see if the button is enabled.
BButton* button = dynamic_cast<BButton*>(FindView("default button")); BButton* button = dynamic_cast<BButton*>(
FindView("default button"));
if (!button) if (!button)
break; break;
@@ -1087,15 +1110,19 @@ TFilePanel::MessageReceived(BMessage* message)
// Don't allow saves of multiple files // Don't allow saves of multiple files
if (count > 1) { if (count > 1) {
ShowCenteredAlert( ShowCenteredAlert(
B_TRANSLATE("Sorry, saving more than one item is not allowed."), B_TRANSLATE(
"Sorry, saving more than one "
"item is not allowed."),
B_TRANSLATE("Cancel")); B_TRANSLATE("Cancel"));
} else { } else {
// if we are a savepanel, set up the filepanel correctly // if we are a savepanel, set up the
// then pass control so we follow the same path as if the user // filepanel correctly then pass control
// so we follow the same path as if the user
// clicked the save button // clicked the save button
// set the 'name' fld to the current ref's name // set the 'name' fld to the current ref's
// notify the panel that the default button should be enabled // name notify the panel that the default
// button should be enabled
SetSaveText(ref.name); SetSaveText(ref.name);
SelectionChanged(); SelectionChanged();
@@ -1144,8 +1171,10 @@ TFilePanel::MessageReceived(BMessage* message)
case kAddCurrentDir: case kAddCurrentDir:
{ {
BPath path; BPath path;
if (find_directory (B_USER_SETTINGS_DIRECTORY, &path, true) != B_OK) if (find_directory(B_USER_SETTINGS_DIRECTORY, &path, true)
!= B_OK) {
break; break;
}
path.Append(kGoDirectory); path.Append(kGoDirectory);
BDirectory goDirectory(path.Path()); BDirectory goDirectory(path.Path());
@@ -1155,7 +1184,8 @@ TFilePanel::MessageReceived(BMessage* message)
entry.GetPath(&path); entry.GetPath(&path);
BSymLink link; BSymLink link;
goDirectory.CreateSymLink(TargetModel()->Name(), path.Path(), &link); goDirectory.CreateSymLink(TargetModel()->Name(), path.Path(),
&link);
} }
break; break;
} }
@@ -1163,8 +1193,10 @@ TFilePanel::MessageReceived(BMessage* message)
case kEditFavorites: case kEditFavorites:
{ {
BPath path; BPath path;
if (find_directory (B_USER_SETTINGS_DIRECTORY, &path, true) != B_OK) if (find_directory (B_USER_SETTINGS_DIRECTORY, &path, true)
!= B_OK) {
break; break;
}
path.Append(kGoDirectory); path.Append(kGoDirectory);
BMessenger msgr(kTrackerSignature); BMessenger msgr(kTrackerSignature);
@@ -1199,7 +1231,8 @@ TFilePanel::MessageReceived(BMessage* message)
if (fIsSavePanel) { if (fIsSavePanel) {
if (PoseView()->IsFocus() if (PoseView()->IsFocus()
&& PoseView()->SelectionList()->CountItems() == 1) { && PoseView()->SelectionList()->CountItems() == 1) {
Model* model = (PoseView()->SelectionList()->FirstItem())->TargetModel(); Model* model = (PoseView()->SelectionList()->
FirstItem())->TargetModel();
if (model->ResolveIfLink()->IsDirectory()) { if (model->ResolveIfLink()->IsDirectory()) {
PoseView()->CommitActivePose(); PoseView()->CommitActivePose();
PoseView()->OpenSelection(); PoseView()->OpenSelection();
@@ -1215,13 +1248,17 @@ TFilePanel::MessageReceived(BMessage* message)
case B_OBSERVER_NOTICE_CHANGE: case B_OBSERVER_NOTICE_CHANGE:
{ {
int32 observerWhat; int32 observerWhat;
if (message->FindInt32("be:observe_change_what", &observerWhat) == B_OK) { if (message->FindInt32("be:observe_change_what", &observerWhat)
== B_OK) {
switch (observerWhat) { switch (observerWhat) {
case kDesktopFilePanelRootChanged: case kDesktopFilePanelRootChanged:
{ {
bool desktopIsRoot = true; bool desktopIsRoot = true;
if (message->FindBool("DesktopFilePanelRoot", &desktopIsRoot) == B_OK) if (message->FindBool("DesktopFilePanelRoot",
TrackerSettings().SetDesktopFilePanelRoot(desktopIsRoot); &desktopIsRoot) == B_OK) {
TrackerSettings().
SetDesktopFilePanelRoot(desktopIsRoot);
}
SetTo(TargetModel()->EntryRef()); SetTo(TargetModel()->EntryRef());
break; break;
} }
@@ -1416,9 +1453,10 @@ TFilePanel::HandleSaveButton()
fTextControl->TextView()->SelectAll(); fTextControl->TextView()->SelectAll();
return; return;
} else { } else {
// if this was invoked by a dbl click, it is an explicit replacement // if this was invoked by a dbl click, it is an explicit
// of the file. // replacement of the file.
BString str(B_TRANSLATE("The file \"%name\" already exists in the specified folder. Do you want to replace it?")); BString str(B_TRANSLATE("The file \"%name\" already exists in "
"the specified folder. Do you want to replace it?"));
str.ReplaceFirst("%name", fTextControl->Text()); str.ReplaceFirst("%name", fTextControl->Text());
if (ShowCenteredAlert(str.String(), B_TRANSLATE("Cancel"), if (ShowCenteredAlert(str.String(), B_TRANSLATE("Cancel"),
@@ -1512,8 +1550,10 @@ TFilePanel::HandleOpenButton()
if (((fNodeFlavors & B_DIRECTORY_NODE) != 0 if (((fNodeFlavors & B_DIRECTORY_NODE) != 0
&& model->ResolveIfLink()->IsDirectory()) && model->ResolveIfLink()->IsDirectory())
|| ((fNodeFlavors & B_SYMLINK_NODE) != 0 && model->IsSymLink()) || ((fNodeFlavors & B_SYMLINK_NODE) != 0 && model->IsSymLink())
|| ((fNodeFlavors & B_FILE_NODE) != 0 && model->ResolveIfLink()->IsFile())) || ((fNodeFlavors & B_FILE_NODE) != 0
&& model->ResolveIfLink()->IsFile())) {
message.AddRef("refs", model->EntryRef()); message.AddRef("refs", model->EntryRef());
}
} }
OpenSelectionCommon(&message); OpenSelectionCommon(&message);
@@ -1550,7 +1590,8 @@ TFilePanel::WindowActivated(bool active)
// #pragma mark - // #pragma mark -
BFilePanelPoseView::BFilePanelPoseView(Model* model, BRect frame, uint32 resizeMask) BFilePanelPoseView::BFilePanelPoseView(Model* model, BRect frame,
uint32 resizeMask)
: BPoseView(model, frame, kListMode, resizeMask), : BPoseView(model, frame, kListMode, resizeMask),
fIsDesktop(model->IsDesktop()) fIsDesktop(model->IsDesktop())
{ {
@@ -1583,8 +1624,8 @@ bool
BFilePanelPoseView::FSNotification(const BMessage* message) BFilePanelPoseView::FSNotification(const BMessage* message)
{ {
if (IsDesktopView()) { if (IsDesktopView()) {
// Pretty much copied straight from DesktopPoseView. Would be better // Pretty much copied straight from DesktopPoseView.
// if the code could be shared somehow. // Would be better if the code could be shared somehow.
switch (message->FindInt32("opcode")) { switch (message->FindInt32("opcode")) {
case B_DEVICE_MOUNTED: case B_DEVICE_MOUNTED:
{ {
@@ -1600,7 +1641,8 @@ BFilePanelPoseView::FSNotification(const BMessage* message)
break; break;
if (settings.MountVolumesOntoDesktop() if (settings.MountVolumesOntoDesktop()
&& (!volume.IsShared() || settings.MountSharedVolumesOntoDesktop())) { && (!volume.IsShared()
|| settings.MountSharedVolumesOntoDesktop())) {
// place an icon for the volume onto the desktop // place an icon for the volume onto the desktop
CreateVolumePose(&volume, true); CreateVolumePose(&volume, true);
} }
@@ -1692,7 +1734,8 @@ BFilePanelPoseView::AdaptToVolumeChange(BMessage* message)
message->FindBool("ShowDisksIcon", &showDisksIcon); message->FindBool("ShowDisksIcon", &showDisksIcon);
message->FindBool("MountVolumesOntoDesktop", &mountVolumesOnDesktop); message->FindBool("MountVolumesOntoDesktop", &mountVolumesOnDesktop);
message->FindBool("MountSharedVolumesOntoDesktop", &mountSharedVolumesOntoDesktop); message->FindBool("MountSharedVolumesOntoDesktop",
&mountSharedVolumesOntoDesktop);
BEntry entry("/"); BEntry entry("/");
Model model(&entry); Model model(&entry);
@@ -1725,7 +1768,8 @@ BFilePanelPoseView::AdaptToDesktopIntegrationChange(BMessage* message)
bool mountSharedVolumesOntoDesktop = true; bool mountSharedVolumesOntoDesktop = true;
message->FindBool("MountVolumesOntoDesktop", &mountVolumesOnDesktop); message->FindBool("MountVolumesOntoDesktop", &mountVolumesOnDesktop);
message->FindBool("MountSharedVolumesOntoDesktop", &mountSharedVolumesOntoDesktop); message->FindBool("MountSharedVolumesOntoDesktop",
&mountSharedVolumesOntoDesktop);
ShowVolumes(false, mountSharedVolumesOntoDesktop); ShowVolumes(false, mountSharedVolumesOntoDesktop);
ShowVolumes(mountVolumesOnDesktop, mountSharedVolumesOntoDesktop); ShowVolumes(mountVolumesOnDesktop, mountSharedVolumesOntoDesktop);
+2 -1
View File
@@ -122,7 +122,8 @@ protected:
virtual void WindowActivated(bool state); virtual void WindowActivated(bool state);
static filter_result FSFilter(BMessage*, BHandler**, BMessageFilter*); static filter_result FSFilter(BMessage*, BHandler**, BMessageFilter*);
static filter_result MessageDropFilter(BMessage*, BHandler**, BMessageFilter*); static filter_result MessageDropFilter(BMessage*, BHandler**,
BMessageFilter*);
int32 ShowCenteredAlert(const char* text, const char* button1, int32 ShowCenteredAlert(const char* text, const char* button1,
const char* button2 = NULL, const char* button3 = NULL); const char* button2 = NULL, const char* button3 = NULL);
+319 -257
View File
@@ -106,7 +106,8 @@ namespace BPrivate {
class MostUsedNames { class MostUsedNames {
public: public:
MostUsedNames(const char* fileName, const char* directory, int32 maxCount = 5); MostUsedNames(const char* fileName, const char* directory,
int32 maxCount = 5);
~MostUsedNames(); ~MostUsedNames();
bool ObtainList(BList* list); bool ObtainList(BList* list);
@@ -175,8 +176,8 @@ MoreOptionsStruct::QueryTemporary(const BNode* node)
FindWindow::FindWindow(const entry_ref* newRef, bool editIfTemplateOnly) FindWindow::FindWindow(const entry_ref* newRef, bool editIfTemplateOnly)
: :
BWindow(kInitialRect, B_TRANSLATE("Find"), B_TITLED_WINDOW, B_NOT_RESIZABLE BWindow(kInitialRect, B_TRANSLATE("Find"), B_TITLED_WINDOW,
| B_NOT_ZOOMABLE), B_NOT_RESIZABLE | B_NOT_ZOOMABLE),
fFile(TryOpening(newRef)), fFile(TryOpening(newRef)),
fFromTemplate(false), fFromTemplate(false),
fEditTemplateOnly(false), fEditTemplateOnly(false),
@@ -218,7 +219,8 @@ FindWindow::FindWindow(const entry_ref* newRef, bool editIfTemplateOnly)
fFromTemplate = IsQueryTemplate(fFile); fFromTemplate = IsQueryTemplate(fFile);
fBackground = new FindPanel(Bounds(), fFile, this, fFromTemplate, fEditTemplateOnly); fBackground = new FindPanel(Bounds(), fFile, this, fFromTemplate,
fEditTemplateOnly);
AddChild(fBackground); AddChild(fBackground);
} }
@@ -292,8 +294,10 @@ const char*
FindWindow::QueryName() const FindWindow::QueryName() const
{ {
if (fFromTemplate) { if (fFromTemplate) {
if (!fQueryNameFromTemplate.Length()) if (!fQueryNameFromTemplate.Length()) {
fFile->ReadAttrString(kAttrQueryTemplateName, &fQueryNameFromTemplate); fFile->ReadAttrString(kAttrQueryTemplateName,
&fQueryNameFromTemplate);
}
return fQueryNameFromTemplate.String(); return fQueryNameFromTemplate.String();
} }
@@ -375,7 +379,8 @@ FindWindow::SaveQueryAttributes(BNode* file, bool queryTemplate)
// save date/time info for recent query support and transient query killer // save date/time info for recent query support and transient query killer
int32 currentTime = (int32)time(0); int32 currentTime = (int32)time(0);
file->WriteAttr(kAttrQueryLastChange, B_INT32_TYPE, 0, &currentTime, sizeof(int32)); file->WriteAttr(kAttrQueryLastChange, B_INT32_TYPE, 0, &currentTime,
sizeof(int32));
int32 tmp = 1; int32 tmp = 1;
file->WriteAttr("_trk/recentQuery", B_INT32_TYPE, 0, &tmp, sizeof(int32)); file->WriteAttr("_trk/recentQuery", B_INT32_TYPE, 0, &tmp, sizeof(int32));
} }
@@ -393,7 +398,8 @@ FindWindow::SaveQueryAsAttributes(BNode* file, BEntry* entry, bool queryTemplate
// and the file's location // and the file's location
FSSetPoseLocation(entry, *oldLocation); FSSetPoseLocation(entry, *oldLocation);
BNodeInfo(file).SetType(queryTemplate ? B_QUERY_TEMPLATE_MIMETYPE : B_QUERY_MIMETYPE); BNodeInfo(file).SetType(queryTemplate
? B_QUERY_TEMPLATE_MIMETYPE : B_QUERY_MIMETYPE);
BString predicate; BString predicate;
bool dynamicDate; bool dynamicDate;
@@ -509,7 +515,8 @@ FindWindow::Find()
} }
int32 currentTime = (int32)time(0); int32 currentTime = (int32)time(0);
fFile->WriteAttr(kAttrQueryLastChange, B_INT32_TYPE, 0, &currentTime, sizeof(int32)); fFile->WriteAttr(kAttrQueryLastChange, B_INT32_TYPE, 0, &currentTime,
sizeof(int32));
// tell the tracker about it // tell the tracker about it
BMessage message(B_REFS_RECEIVED); BMessage message(B_REFS_RECEIVED);
@@ -683,7 +690,8 @@ FindPanel::FindPanel(BRect frame, BFile* node, FindWindow* parent,
BMessenger self(this); BMessenger self(this);
fRecentQueries = new BPopUpMenu("RecentQueries"); fRecentQueries = new BPopUpMenu("RecentQueries");
FindPanel::AddRecentQueries(fRecentQueries, true, &self, kSwitchToQueryTemplate); FindPanel::AddRecentQueries(fRecentQueries, true, &self,
kSwitchToQueryTemplate);
AddChild(new MiniMenuField(rect, "RecentQueries", fRecentQueries)); AddChild(new MiniMenuField(rect, "RecentQueries", fRecentQueries));
@@ -741,8 +749,8 @@ FindPanel::FindPanel(BRect frame, BFile* node, FindWindow* parent,
B_TRANSLATE_NOCOLLECT(kDragNDropActionSpecifiers[1])); B_TRANSLATE_NOCOLLECT(kDragNDropActionSpecifiers[1]));
BMessenger self(this); BMessenger self(this);
fDraggableIcon = new DraggableQueryIcon(DraggableIcon::PreferredRect(draggableIconOrigin, fDraggableIcon = new DraggableQueryIcon(DraggableIcon::PreferredRect(
B_LARGE_ICON), "saveHere", &dragNDropMessage, draggableIconOrigin, B_LARGE_ICON), "saveHere", &dragNDropMessage,
self, B_FOLLOW_LEFT | B_FOLLOW_BOTTOM); self, B_FOLLOW_LEFT | B_FOLLOW_BOTTOM);
AddChild(fDraggableIcon); AddChild(fDraggableIcon);
} }
@@ -769,8 +777,8 @@ FindPanel::FindPanel(BRect frame, BFile* node, FindWindow* parent,
rect = expandedBounds; rect = expandedBounds;
rect.right = rect.left + 200; rect.right = rect.left + 200;
rect.bottom = rect.top + 20;; rect.bottom = rect.top + 20;;
fQueryName = new BTextControl(rect, "queryName", B_TRANSLATE("Query name:"), fQueryName = new BTextControl(rect, "queryName",
"", 0); B_TRANSLATE("Query name:"), "", 0);
fQueryName->SetDivider(fQueryName->StringWidth(fQueryName->Label()) + 5); fQueryName->SetDivider(fQueryName->StringWidth(fQueryName->Label()) + 5);
fMoreOptionsPane->AddItem(fQueryName, 1); fMoreOptionsPane->AddItem(fQueryName, 1);
FillCurrentQueryName(fQueryName, parent); FillCurrentQueryName(fQueryName, parent);
@@ -838,9 +846,9 @@ FindPanel::AttachedToWindow()
fQueryName->SetTarget(this); fQueryName->SetTarget(this);
fLatch->SetTarget(fMoreOptionsPane); fLatch->SetTarget(fMoreOptionsPane);
RestoreMimeTypeMenuSelection(node); RestoreMimeTypeMenuSelection(node);
// preselect the mime we used the last time // preselect the mime we used the last time have to do it here
// have to do it here because AddByAttributeItems will build different // because AddByAttributeItems will build different menus based
// menus based on which mime type is preselected // on which mime type is preselected
RestoreWindowState(node); RestoreWindowState(node);
if (!Window()->CurrentFocus()) { if (!Window()->CurrentFocus()) {
@@ -971,9 +979,10 @@ FindPanel::ShowVolumeMenuLabel()
tmpItem = item; tmpItem = item;
} }
} }
if (countSelected == 0) { if (countSelected == 0) {
// no disk selected, for now revert to search all disks // no disk selected, for now revert to search all disks
// ToDo: // TODO:
// show no disks here and add a check that will not let the // show no disks here and add a check that will not let the
// query go if the user doesn't pick at least one // query go if the user doesn't pick at least one
fVolMenu->ItemAt(0)->SetMarked(true); fVolMenu->ItemAt(0)->SetMarked(true);
@@ -997,51 +1006,49 @@ FindPanel::MessageReceived(BMessage* message)
switch (message->what) { switch (message->what) {
case kVolumeItem: case kVolumeItem:
{ {
// volume changed // volume changed
BMenuItem* invokedItem; BMenuItem* invokedItem;
dev_t dev; dev_t dev;
if (message->FindPointer("source", (void**)&invokedItem) != B_OK) if (message->FindPointer("source", (void**)&invokedItem) != B_OK)
return; return;
if (message->FindInt32("device", &dev) != B_OK) if (message->FindInt32("device", &dev) != B_OK)
break; break;
BMenu* menu = invokedItem->Menu(); BMenu* menu = invokedItem->Menu();
ASSERT(menu); ASSERT(menu);
if (dev == -1) { if (dev == -1) {
// all disks selected, uncheck everything else
int32 count = menu->CountItems();
for (int32 index = 2; index < count; index++)
menu->ItemAt(index)->SetMarked(false);
// all disks selected, uncheck everything else // make all disks the title and check it
int32 count = menu->CountItems(); PopUpMenuSetTitle(menu, menu->ItemAt(0)->Label());
for (int32 index = 2; index < count; index++) menu->ItemAt(0)->SetMarked(true);
menu->ItemAt(index)->SetMarked(false); } else {
// a specific volume selected, unmark "all disks"
menu->ItemAt(0)->SetMarked(false);
// make all disks the title and check it // toggle mark on invoked item
PopUpMenuSetTitle(menu, menu->ItemAt(0)->Label()); int32 count = menu->CountItems();
menu->ItemAt(0)->SetMarked(true); for (int32 index = 2; index < count; index++) {
BMenuItem* item = menu->ItemAt(index);
} else { if (invokedItem == item) {
// a specific volume selected, unmark "all disks" // we just selected this
menu->ItemAt(0)->SetMarked(false); bool wasMarked = item->IsMarked();
item->SetMarked(!wasMarked);
// toggle mark on invoked item
int32 count = menu->CountItems();
for (int32 index = 2; index < count; index++) {
BMenuItem* item = menu->ItemAt(index);
if (invokedItem == item) {
// we just selected this
bool wasMarked = item->IsMarked();
item->SetMarked(!wasMarked);
}
} }
} }
// make sure the right label is showing
ShowVolumeMenuLabel();
break;
} }
// make sure the right label is showing
ShowVolumeMenuLabel();
break;
}
case kByAttributeItem: case kByAttributeItem:
case kByNameItem: case kByNameItem:
@@ -1058,102 +1065,110 @@ FindPanel::MessageReceived(BMessage* message)
break; break;
case kMIMETypeItem: case kMIMETypeItem:
{ {
BMenuItem* item; BMenuItem* item;
if (message->FindPointer("source", (void**)&item) == B_OK) { if (message->FindPointer("source", (void**)&item) == B_OK) {
// don't add the "All files and folders" to the list // don't add the "All files and folders" to the list
if (fMimeTypeMenu->IndexOf(item) != 0) if (fMimeTypeMenu->IndexOf(item) != 0)
gMostUsedMimeTypes.AddName(item->Label()); gMostUsedMimeTypes.AddName(item->Label());
SetCurrentMimeType(item); SetCurrentMimeType(item);
}
// mime type switched
if (fMode != kByAttributeItem)
break;
// the attributes for this type may be different, rip out the existing ones
RemoveAttrViewItems();
Window()->ResizeTo(Window()->Frame().Width(),
ViewHeightForMode(kByAttributeItem, fLatch->Value() != 0));
BBox* box = dynamic_cast<BBox*>(FindView("Box"));
ASSERT(box);
box->ResizeTo(box->Bounds().Width(),
BoxHeightForMode(kByAttributeItem, fLatch->Value() != 0));
AddAttrView();
break;
} }
// mime type switched
if (fMode != kByAttributeItem)
break;
// the attributes for this type may be different,
// rip out the existing ones
RemoveAttrViewItems();
Window()->ResizeTo(Window()->Frame().Width(),
ViewHeightForMode(kByAttributeItem, fLatch->Value() != 0));
BBox* box = dynamic_cast<BBox*>(FindView("Box"));
ASSERT(box);
box->ResizeTo(box->Bounds().Width(),
BoxHeightForMode(kByAttributeItem, fLatch->Value() != 0));
AddAttrView();
break;
}
case kNameModifiedMessage: case kNameModifiedMessage:
// the query name was edited, make the query permanent // the query name was edited, make the query permanent
fTemporaryCheck->SetValue(0); fTemporaryCheck->SetValue(0);
break; break;
case B_SAVE_REQUESTED: case B_SAVE_REQUESTED:
{ {
// finish saving query template from a SaveAs panel // finish saving query template from a SaveAs panel
entry_ref ref; entry_ref ref;
status_t error = message->FindRef("refs", &ref); status_t error = message->FindRef("refs", &ref);
if (error == B_OK) {
// direct entry selected, convert to parent dir and name
BEntry entry(&ref);
error = entry.GetParent(&entry);
if (error == B_OK) { if (error == B_OK) {
// direct entry selected, convert to parent dir and name entry.GetRef(&dir);
BEntry entry(&ref); name = ref.name;
error = entry.GetParent(&entry);
if (error == B_OK) {
entry.GetRef(&dir);
name = ref.name;
}
} else {
// parent dir and name selected
error = message->FindRef("directory", &dir);
if (error == B_OK)
error = message->FindString("name", &name);
} }
} else {
// parent dir and name selected
error = message->FindRef("directory", &dir);
if (error == B_OK) if (error == B_OK)
SaveAsQueryOrTemplate(&dir, name, true); error = message->FindString("name", &name);
} }
if (error == B_OK)
SaveAsQueryOrTemplate(&dir, name, true);
break; break;
}
case B_COPY_TARGET: case B_COPY_TARGET:
{ {
// finish drag&drop // finish drag&drop
const char* str; const char* str;
const char* mimeType = NULL; const char* mimeType = NULL;
const char* actionSpecifier = NULL; const char* actionSpecifier = NULL;
if (message->FindString("be:types", &str) == B_OK
&& strcasecmp(str, B_FILE_MIME_TYPE) == 0
&& (message->FindString("be:actionspecifier", &actionSpecifier) == B_OK
|| message->FindString("be:filetypes", &mimeType) == B_OK)
&& message->FindString("name", &name) == B_OK
&& message->FindRef("directory", &dir) == B_OK) {
bool query = false; if (message->FindString("be:types", &str) == B_OK
bool queryTemplate = false; && strcasecmp(str, B_FILE_MIME_TYPE) == 0
&& (message->FindString("be:actionspecifier",
&actionSpecifier) == B_OK
|| message->FindString("be:filetypes", &mimeType) == B_OK)
&& message->FindString("name", &name) == B_OK
&& message->FindRef("directory", &dir) == B_OK) {
if (actionSpecifier bool query = false;
&& strcasecmp(actionSpecifier, bool queryTemplate = false;
B_TRANSLATE_NOCOLLECT(
kDragNDropActionSpecifiers[0])) == 0) {
query = true;
} else if (actionSpecifier
&& strcasecmp(actionSpecifier,
B_TRANSLATE_NOCOLLECT(
kDragNDropActionSpecifiers[1])) == 0) {
queryTemplate = true;
} else if (mimeType && strcasecmp(mimeType,
kDragNDropTypes[0]) == 0) {
query = true;
} else if (mimeType && strcasecmp(mimeType, kDragNDropTypes[1]) == 0)
queryTemplate = true;
if (query || queryTemplate) if (actionSpecifier
SaveAsQueryOrTemplate(&dir, name, queryTemplate); && strcasecmp(actionSpecifier,
B_TRANSLATE_NOCOLLECT(
kDragNDropActionSpecifiers[0])) == 0) {
query = true;
} else if (actionSpecifier
&& strcasecmp(actionSpecifier,
B_TRANSLATE_NOCOLLECT(
kDragNDropActionSpecifiers[1])) == 0) {
queryTemplate = true;
} else if (mimeType && strcasecmp(mimeType,
kDragNDropTypes[0]) == 0) {
query = true;
} else if (mimeType && strcasecmp(mimeType,
kDragNDropTypes[1]) == 0) {
queryTemplate = true;
} }
if (query || queryTemplate)
SaveAsQueryOrTemplate(&dir, name, queryTemplate);
} }
break; break;
}
default: default:
_inherited::MessageReceived(message); _inherited::MessageReceived(message);
@@ -1163,11 +1178,13 @@ FindPanel::MessageReceived(BMessage* message)
void void
FindPanel::SaveAsQueryOrTemplate(const entry_ref* dir, const char* name, bool queryTemplate) FindPanel::SaveAsQueryOrTemplate(const entry_ref* dir, const char* name,
bool queryTemplate)
{ {
BDirectory directory(dir); BDirectory directory(dir);
BFile file(&directory, name, O_RDWR | O_CREAT | O_TRUNC); BFile file(&directory, name, O_RDWR | O_CREAT | O_TRUNC);
BNodeInfo(&file).SetType(queryTemplate ? B_QUERY_TEMPLATE_MIMETYPE : B_QUERY_MIMETYPE); BNodeInfo(&file).SetType(queryTemplate
? B_QUERY_TEMPLATE_MIMETYPE : B_QUERY_MIMETYPE);
BMessage attach(kAttachFile); BMessage attach(kAttachFile);
attach.AddRef("directory", dir); attach.AddRef("directory", dir);
@@ -1194,7 +1211,8 @@ FindPanel::BuildAttrQuery(BQuery* query, bool &dynamicDate) const
if (!textControl) if (!textControl)
return; return;
BMenuField* menuField = dynamic_cast<BMenuField*>(view->FindView("MenuField")); BMenuField* menuField
= dynamic_cast<BMenuField*>(view->FindView("MenuField"));
if (!menuField) if (!menuField)
return; return;
@@ -1218,78 +1236,85 @@ FindPanel::BuildAttrQuery(BQuery* query, bool &dynamicDate) const
break; break;
case B_TIME_TYPE: case B_TIME_TYPE:
{ {
int flags = 0; int flags = 0;
DEBUG_ONLY(time_t result =) DEBUG_ONLY(time_t result =)
parsedate_etc(textControl->TextView()->Text(), -1, &flags); parsedate_etc(textControl->TextView()->Text(), -1,
dynamicDate = (flags & PARSEDATE_RELATIVE_TIME) != 0; &flags);
PRINT(("parsedate_etc - date is %srelative, %" dynamicDate = (flags & PARSEDATE_RELATIVE_TIME) != 0;
B_PRIdTIME "\n", PRINT(("parsedate_etc - date is %srelative, %"
dynamicDate ? "" : "not ", result)); B_PRIdTIME "\n",
dynamicDate ? "" : "not ", result));
query->PushDate(textControl->TextView()->Text()); query->PushDate(textControl->TextView()->Text());
}
break; break;
}
case B_BOOL_TYPE: case B_BOOL_TYPE:
{ {
uint32 value; uint32 value;
if (strcasecmp(textControl->TextView()->Text(), "true") == 0) if (strcasecmp(textControl->TextView()->Text(),
value = 1; "true") == 0) {
else if (strcasecmp(textControl->TextView()->Text(), "true") == 0) value = 1;
value = 1; } else if (strcasecmp(textControl->TextView()->Text(),
else "true") == 0) {
value = (uint32)atoi(textControl->TextView()->Text()); value = 1;
} else
value = (uint32)atoi(textControl->TextView()->Text());
value %= 2; value %= 2;
query->PushUInt32(value); query->PushUInt32(value);
}
break; break;
}
case B_UINT8_TYPE: case B_UINT8_TYPE:
case B_UINT16_TYPE: case B_UINT16_TYPE:
case B_UINT32_TYPE: case B_UINT32_TYPE:
query->PushUInt32((uint32)StringToScalar(textControl->TextView()->Text())); query->PushUInt32((uint32)StringToScalar(
textControl->TextView()->Text()));
break; break;
case B_INT8_TYPE: case B_INT8_TYPE:
case B_INT16_TYPE: case B_INT16_TYPE:
case B_INT32_TYPE: case B_INT32_TYPE:
query->PushInt32((int32)StringToScalar(textControl->TextView()->Text())); query->PushInt32((int32)StringToScalar(
textControl->TextView()->Text()));
break; break;
case B_UINT64_TYPE: case B_UINT64_TYPE:
query->PushUInt64((uint64)StringToScalar(textControl->TextView()->Text())); query->PushUInt64((uint64)StringToScalar(
textControl->TextView()->Text()));
break; break;
case B_OFF_T_TYPE: case B_OFF_T_TYPE:
case B_INT64_TYPE: case B_INT64_TYPE:
query->PushInt64(StringToScalar(textControl->TextView()->Text())); query->PushInt64(StringToScalar(
textControl->TextView()->Text()));
break; break;
case B_FLOAT_TYPE: case B_FLOAT_TYPE:
{ {
float floatVal; float floatVal;
sscanf(textControl->TextView()->Text(), "%f", &floatVal); sscanf(textControl->TextView()->Text(), "%f", &floatVal);
query->PushFloat(floatVal); query->PushFloat(floatVal);
}
break; break;
}
case B_DOUBLE_TYPE: case B_DOUBLE_TYPE:
{ {
double doubleVal; double doubleVal;
sscanf(textControl->TextView()->Text(), "%lf", &doubleVal); sscanf(textControl->TextView()->Text(), "%lf", &doubleVal);
query->PushDouble(doubleVal); query->PushDouble(doubleVal);
}
break; break;
}
} }
} }
query_op theOperator; query_op theOperator;
BMenuItem* operatorItem = item->Submenu()->FindMarked(); BMenuItem* operatorItem = item->Submenu()->FindMarked();
if (operatorItem && operatorItem->Message() != NULL) { if (operatorItem && operatorItem->Message() != NULL) {
operatorItem->Message()->FindInt32("operator", (int32*)&theOperator); operatorItem->Message()->FindInt32("operator",
(int32*)&theOperator);
query->PushOp(theOperator); query->PushOp(theOperator);
} else } else
query->PushOp(B_EQ); query->PushOp(B_EQ);
@@ -1297,7 +1322,8 @@ FindPanel::BuildAttrQuery(BQuery* query, bool &dynamicDate) const
// add logic based on selection in Logic menufield // add logic based on selection in Logic menufield
if (index > 0) { if (index > 0) {
TAttrView* prevView = fAttrViewList.ItemAt(index - 1); TAttrView* prevView = fAttrViewList.ItemAt(index - 1);
menuField = dynamic_cast<BMenuField*>(prevView->FindView("Logic")); menuField
= dynamic_cast<BMenuField*>(prevView->FindView("Logic"));
if (menuField) { if (menuField) {
item = menuField->Menu()->FindMarked(); item = menuField->Menu()->FindMarked();
if (item) { if (item) {
@@ -1348,7 +1374,8 @@ FindPanel::GetByAttrPredicate(BQuery* query, bool &dynamicDate) const
void void
FindPanel::GetDefaultName(BString &result) const FindPanel::GetDefaultName(BString &result) const
{ {
BTextControl* textControl = dynamic_cast<BTextControl*>(FindView("TextControl")); BTextControl* textControl
= dynamic_cast<BTextControl*>(FindView("TextControl"));
switch (Mode()) { switch (Mode()) {
case kByNameItem: case kByNameItem:
result.SetTo(B_TRANSLATE_COMMENT("Name = %name", result.SetTo(B_TRANSLATE_COMMENT("Name = %name",
@@ -1393,16 +1420,17 @@ void
FindPanel::GetByNamePredicate(BQuery* query) const FindPanel::GetByNamePredicate(BQuery* query) const
{ {
ASSERT(Mode() == (int32)kByNameItem); ASSERT(Mode() == (int32)kByNameItem);
BTextControl* textControl = dynamic_cast<BTextControl*>(FindView("TextControl")); BTextControl* textControl
= dynamic_cast<BTextControl*>(FindView("TextControl"));
ASSERT(textControl); ASSERT(textControl);
query->PushAttr("name"); query->PushAttr("name");
query->PushString(textControl->TextView()->Text(), true); query->PushString(textControl->TextView()->Text(), true);
if (strstr(textControl->TextView()->Text(), "*")) if (strstr(textControl->TextView()->Text(), "*")) {
// assume pattern is a regular expression and try doing an exact match // assume pattern is a regular expression and try doing an exact match
query->PushOp(B_EQ); query->PushOp(B_EQ);
else } else
query->PushOp(B_CONTAINS); query->PushOp(B_CONTAINS);
PushMimeType(query); PushMimeType(query);
@@ -1446,14 +1474,16 @@ FindPanel::SwitchMode(uint32 mode)
bounds.bottom -= 10; bounds.bottom -= 10;
if (fLatch->Value()) if (fLatch->Value())
bounds.bottom -= kMoreOptionsDelta; bounds.bottom -= kMoreOptionsDelta;
box->ResizeTo(bounds.Width(), BoxHeightForMode(mode, fLatch->Value() != 0)); box->ResizeTo(bounds.Width(), BoxHeightForMode(mode,
fLatch->Value() != 0));
RemoveByAttributeItems(); RemoveByAttributeItems();
ShowOrHideMimeTypeMenu(); ShowOrHideMimeTypeMenu();
AddByNameOrFormulaItems(); AddByNameOrFormulaItems();
if (buffer.Length()) { if (buffer.Length()) {
ASSERT(mode == kByFormulaItem || oldMode == kByAttributeItem); ASSERT(mode == kByFormulaItem
|| oldMode == kByAttributeItem);
BTextControl* textControl = dynamic_cast<BTextControl*> BTextControl* textControl = dynamic_cast<BTextControl*>
(FindView("TextControl")); (FindView("TextControl"));
textControl->SetText(buffer.String()); textControl->SetText(buffer.String());
@@ -1492,9 +1522,11 @@ FindPanel::CurrentMimeType(const char** type) const
// search for marked item in the list // search for marked item in the list
BMenuItem* item = MimeTypeMenu()->FindMarked(); BMenuItem* item = MimeTypeMenu()->FindMarked();
// if it's one of the most used items, ignore it if (item != NULL && MimeTypeMenu()->IndexOf(item) != 0
if (item != NULL && MimeTypeMenu()->IndexOf(item) != 0 && item->Submenu() == NULL) && item->Submenu() == NULL) {
// if it's one of the most used items, ignore it
item = NULL; item = NULL;
}
if (item == NULL) { if (item == NULL) {
for (int32 index = MimeTypeMenu()->CountItems(); index-- > 0;) { for (int32 index = MimeTypeMenu()->CountItems(); index-- > 0;) {
@@ -1536,7 +1568,7 @@ FindPanel::SetCurrentMimeType(BMenuItem* item)
fMimeTypeField->MenuItem()->SetLabel(item->Label()); fMimeTypeField->MenuItem()->SetLabel(item->Label());
BMenuItem* search; BMenuItem* search;
for (int32 i = 2;(search = MimeTypeMenu()->ItemAt(i)) != NULL;i++) { for (int32 i = 2; (search = MimeTypeMenu()->ItemAt(i)) != NULL; i++) {
if (item == search || !search->Label()) if (item == search || !search->Label())
continue; continue;
if (!strcmp(item->Label(),search->Label())) { if (!strcmp(item->Label(),search->Label())) {
@@ -1583,12 +1615,14 @@ FindPanel::SetCurrentMimeType(const char* label)
if (submenu != NULL && !found) { if (submenu != NULL && !found) {
for (int32 subIndex = submenu->CountItems(); subIndex-- > 0;) { for (int32 subIndex = submenu->CountItems(); subIndex-- > 0;) {
BMenuItem* subItem = submenu->ItemAt(subIndex); BMenuItem* subItem = submenu->ItemAt(subIndex);
if (subItem->Label() != NULL && !strcmp(label, subItem->Label())) { if (subItem->Label() != NULL
&& !strcmp(label, subItem->Label())) {
subItem->SetMarked(true); subItem->SetMarked(true);
found = true; found = true;
} }
} }
} }
if (item->Label() != NULL && !strcmp(label, item->Label())) { if (item->Label() != NULL && !strcmp(label, item->Label())) {
item->SetMarked(true); item->SetMarked(true);
return B_OK; return B_OK;
@@ -1615,8 +1649,9 @@ FindPanel::AddOneMimeTypeToMenu(const ShortMimeInfo* info, void* castToMenu)
BMessage* msg = new BMessage(kMIMETypeItem); BMessage* msg = new BMessage(kMIMETypeItem);
msg->AddString("mimetype", info->InternalName()); msg->AddString("mimetype", info->InternalName());
superItem->Submenu()->AddItem(new IconMenuItem(info->ShortDescription(), superItem->Submenu()->AddItem(new IconMenuItem(
msg, info->InternalName(), B_MINI_ICON)); info->ShortDescription(), msg, info->InternalName(),
B_MINI_ICON));
} }
return false; return false;
@@ -1628,8 +1663,8 @@ FindPanel::AddMimeTypesToMenu()
{ {
BMessage* itemMessage = new BMessage(kMIMETypeItem); BMessage* itemMessage = new BMessage(kMIMETypeItem);
itemMessage->AddString("mimetype", kAllMimeTypes); itemMessage->AddString("mimetype", kAllMimeTypes);
MimeTypeMenu()->AddItem(new BMenuItem(B_TRANSLATE("All files and folders"), MimeTypeMenu()->AddItem(
itemMessage)); new BMenuItem(B_TRANSLATE("All files and folders"), itemMessage));
MimeTypeMenu()->AddSeparatorItem(); MimeTypeMenu()->AddSeparatorItem();
MimeTypeMenu()->ItemAt(0)->SetMarked(true); MimeTypeMenu()->ItemAt(0)->SetMarked(true);
@@ -1777,8 +1812,8 @@ AddOneRecentItem(const entry_ref* ref, void* castToParams)
void void
FindPanel::AddRecentQueries(BMenu* menu, bool addSaveAsItem, const BMessenger* target, FindPanel::AddRecentQueries(BMenu* menu, bool addSaveAsItem,
uint32 what) const BMessenger* target, uint32 what)
{ {
BObjectList<entry_ref> templates(10, true); BObjectList<entry_ref> templates(10, true);
BObjectList<EntryWithDate> recentQueries(10, true); BObjectList<EntryWithDate> recentQueries(10, true);
@@ -1788,7 +1823,8 @@ FindPanel::AddRecentQueries(BMenu* menu, bool addSaveAsItem, const BMessenger* t
BVolume volume; BVolume volume;
roster.Rewind(); roster.Rewind();
while (roster.GetNextVolume(&volume) == B_OK) { while (roster.GetNextVolume(&volume) == B_OK) {
if (volume.IsPersistent() && volume.KnowsQuery() && volume.KnowsAttr()) { if (volume.IsPersistent() && volume.KnowsQuery()
&& volume.KnowsAttr()) {
BQuery query; BQuery query;
query.SetVolume(&volume); query.SetVolume(&volume);
@@ -2046,9 +2082,11 @@ FindPanel::SaveWindowState(BNode* node, bool editTemplate)
saveMoreOptions.searchTrash = fSearchTrashCheck->Value() != 0; saveMoreOptions.searchTrash = fSearchTrashCheck->Value() != 0;
saveMoreOptions.temporary = fTemporaryCheck->Value() != 0; saveMoreOptions.temporary = fTemporaryCheck->Value() != 0;
if (node->WriteAttr(kAttrQueryMoreOptions, B_RAW_TYPE, 0, &saveMoreOptions, if (node->WriteAttr(kAttrQueryMoreOptions, B_RAW_TYPE, 0,
sizeof(saveMoreOptions)) == sizeof(saveMoreOptions)) &saveMoreOptions,
sizeof(saveMoreOptions)) == sizeof(saveMoreOptions)) {
node->RemoveAttr(kAttrQueryMoreOptionsForeign); node->RemoveAttr(kAttrQueryMoreOptionsForeign);
}
if (editTemplate) { if (editTemplate) {
if (UserSpecifiedName()) { if (UserSpecifiedName()) {
@@ -2059,36 +2097,37 @@ FindPanel::SaveWindowState(BNode* node, bool editTemplate)
switch (Mode()) { switch (Mode()) {
case kByAttributeItem: case kByAttributeItem:
{ {
BMessage message; BMessage message;
int32 count = fAttrViewList.CountItems(); int32 count = fAttrViewList.CountItems();
node->WriteAttr(kAttrQueryInitialNumAttrs, B_INT32_TYPE, 0, node->WriteAttr(kAttrQueryInitialNumAttrs, B_INT32_TYPE, 0,
&count, sizeof(int32)); &count, sizeof(int32));
for (int32 index = 0; index < count; index++) for (int32 index = 0; index < count; index++)
fAttrViewList.ItemAt(index)->SaveState(&message, index); fAttrViewList.ItemAt(index)->SaveState(&message, index);
ssize_t size = message.FlattenedSize(); ssize_t size = message.FlattenedSize();
char* buffer = new char[size]; char* buffer = new char[size];
status_t result = message.Flatten(buffer, size); status_t result = message.Flatten(buffer, size);
if (result == B_OK) { if (result == B_OK) {
node->WriteAttr(kAttrQueryInitialAttrs, B_MESSAGE_TYPE, 0, node->WriteAttr(kAttrQueryInitialAttrs, B_MESSAGE_TYPE, 0,
buffer, (size_t)size); buffer, (size_t)size);
}
delete [] buffer;
} }
delete[] buffer;
break; break;
}
case kByNameItem: case kByNameItem:
case kByFormulaItem: case kByFormulaItem:
{ {
BTextControl* textControl = dynamic_cast<BTextControl*> BTextControl* textControl = dynamic_cast<BTextControl*>
(FindView("TextControl")); (FindView("TextControl"));
ASSERT(textControl); ASSERT(textControl);
BString formula(textControl->TextView()->Text()); BString formula(textControl->TextView()->Text());
node->WriteAttrString(kAttrQueryInitialString, &formula); node->WriteAttrString(kAttrQueryInitialString, &formula);
break; break;
} }
} }
} }
@@ -2169,7 +2208,8 @@ FindPanel::RestoreWindowState(const BNode* node)
// set modification message after checking the temporary check box, // set modification message after checking the temporary check box,
// and filling out the text control so that we do not // and filling out the text control so that we do not
// always trigger clearing of the temporary check box. // always trigger clearing of the temporary check box.
fQueryName->SetModificationMessage(new BMessage(kNameModifiedMessage)); fQueryName->SetModificationMessage(
new BMessage(kNameModifiedMessage));
} }
// get volumes to perform query on // get volumes to perform query on
@@ -2178,23 +2218,25 @@ FindPanel::RestoreWindowState(const BNode* node)
attr_info info; attr_info info;
if (node->GetAttrInfo(kAttrQueryVolume, &info) == B_OK) { if (node->GetAttrInfo(kAttrQueryVolume, &info) == B_OK) {
char* buffer = new char[info.size]; char* buffer = new char[info.size];
if (node->ReadAttr(kAttrQueryVolume, B_MESSAGE_TYPE, 0, buffer, (size_t)info.size) if (node->ReadAttr(kAttrQueryVolume, B_MESSAGE_TYPE, 0, buffer,
== info.size) { (size_t)info.size) == info.size) {
BMessage message; BMessage message;
if (message.Unflatten(buffer) == B_OK) { if (message.Unflatten(buffer) == B_OK) {
for (int32 index = 0; ;index++) { for (int32 index = 0; ;index++) {
ASSERT(index < 100); ASSERT(index < 100);
BVolume volume; BVolume volume;
// match a volume with the info embedded in the message // match a volume with the info embedded in
status_t result = MatchArchivedVolume(&volume, &message, index); // the message
status_t result = MatchArchivedVolume(&volume, &message,
index);
if (result == B_OK) { if (result == B_OK) {
char name[256]; char name[256];
volume.GetName(name); volume.GetName(name);
SelectItemWithLabel(fVolMenu, name); SelectItemWithLabel(fVolMenu, name);
searchAllVolumes = false; 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 // if B_DEV_BAD_DRIVE_NUM, the volume just isn't
// time around, keep looking for more // mounted this time around, keep looking for more
// if other error, bail // if other error, bail
break; break;
} }
@@ -2208,37 +2250,40 @@ FindPanel::RestoreWindowState(const BNode* node)
switch (Mode()) { switch (Mode()) {
case kByAttributeItem: case kByAttributeItem:
{ {
int32 count = InitialAttrCount(node); int32 count = InitialAttrCount(node);
attr_info info; attr_info info;
if (node->GetAttrInfo(kAttrQueryInitialAttrs, &info) != B_OK) if (node->GetAttrInfo(kAttrQueryInitialAttrs, &info) != B_OK)
break;
char* buffer = new char[info.size];
if (node->ReadAttr(kAttrQueryInitialAttrs, B_MESSAGE_TYPE, 0, buffer, (size_t)info.size)
== info.size) {
BMessage message;
if (message.Unflatten(buffer) == B_OK)
for (int32 index = 0; index < count; index++)
fAttrViewList.ItemAt(index)->RestoreState(message, index);
}
delete [] buffer;
break; break;
char* buffer = new char[info.size];
if (node->ReadAttr(kAttrQueryInitialAttrs, B_MESSAGE_TYPE, 0,
buffer, (size_t)info.size) == info.size) {
BMessage message;
if (message.Unflatten(buffer) == B_OK)
for (int32 index = 0; index < count; index++) {
fAttrViewList.ItemAt(index)->RestoreState(message,
index);
}
} }
delete[] buffer;
break;
}
case kByNameItem: case kByNameItem:
case kByFormulaItem: case kByFormulaItem:
{ {
BString buffer; BString buffer;
if (node->ReadAttrString(kAttrQueryInitialString, &buffer) == B_OK) { if (node->ReadAttrString(kAttrQueryInitialString, &buffer)
BTextControl* textControl = dynamic_cast<BTextControl*> == B_OK) {
(FindView("TextControl")); BTextControl* textControl = dynamic_cast<BTextControl*>
ASSERT(textControl); (FindView("TextControl"));
ASSERT(textControl);
textControl->TextView()->SetText(buffer.String()); textControl->TextView()->SetText(buffer.String());
}
} }
break; break;
}
} }
// try to restore focus and possibly text selection // try to restore focus and possibly text selection
@@ -2304,7 +2349,8 @@ FindPanel::AddByNameOrFormulaItems()
BRect bounds(box->Bounds()); BRect bounds(box->Bounds());
bounds.InsetBy(10, 10); bounds.InsetBy(10, 10);
BTextControl* textControl = new BTextControl(bounds, "TextControl", "", "", NULL); BTextControl* textControl = new BTextControl(bounds, "TextControl",
"", "", NULL);
textControl->SetDivider(0.0f); textControl->SetDivider(0.0f);
box->AddChild(textControl); box->AddChild(textControl);
textControl->MakeFocus(); textControl->MakeFocus();
@@ -2353,7 +2399,8 @@ FindPanel::RemoveByAttributeItems()
void void
FindPanel::ShowOrHideMimeTypeMenu() FindPanel::ShowOrHideMimeTypeMenu()
{ {
BMenuField* menuField = dynamic_cast<BMenuField*>(FindView("MimeTypeMenu")); BMenuField* menuField
= dynamic_cast<BMenuField*>(FindView("MimeTypeMenu"));
if (Mode() == (int32)kByFormulaItem && !menuField->IsHidden()) if (Mode() == (int32)kByFormulaItem && !menuField->IsHidden())
menuField->Hide(); menuField->Hide();
else if (menuField->IsHidden()) else if (menuField->IsHidden())
@@ -2398,8 +2445,8 @@ TAttrView::TAttrView(BRect frame, int32 index)
for (int32 i = 0; i < 5; i++) { for (int32 i = 0; i < 5; i++) {
message = new BMessage(kAttributeItem); message = new BMessage(kAttributeItem);
message->AddInt32("operator", operators[i]); message->AddInt32("operator", operators[i]);
submenu->AddItem(new BMenuItem(B_TRANSLATE_NOCOLLECT(operatorLabels[i]), submenu->AddItem(new BMenuItem(B_TRANSLATE_NOCOLLECT(
message)); operatorLabels[i]), message));
} }
// mark first item // mark first item
@@ -2464,7 +2511,7 @@ TAttrView::TAttrView(BRect frame, int32 index)
AddChild(fTextControl); AddChild(fTextControl);
AddChild(fMenuField); AddChild(fMenuField);
// add attributes from currently selected mimetype // add attributes from currently selected mimetype
} }
@@ -2558,7 +2605,8 @@ TAttrView::SaveState(BMessage* message, int32)
if (field) { if (field) {
BMenuItem* item = field->Menu()->FindMarked(); BMenuItem* item = field->Menu()->FindMarked();
ASSERT(item); ASSERT(item);
message->AddInt32("logicalRelation", item ? field->Menu()->IndexOf(item) : 0); message->AddInt32("logicalRelation",
item ? field->Menu()->IndexOf(item) : 0);
} }
} }
@@ -2618,7 +2666,8 @@ TAttrView::Draw(BRect)
// draws the is/contains, etc. string // draws the is/contains, etc. string
bounds.left -= (width + 10); bounds.left -= (width + 10);
bounds.bottom -= 6; bounds.bottom -= 6;
DrawString(item->Submenu()->FindMarked()->Label(), bounds.LeftBottom()); DrawString(item->Submenu()->FindMarked()->Label(),
bounds.LeftBottom());
} }
} }
@@ -2677,15 +2726,19 @@ TAttrView::AddAttributes(BMenu* menu, const BMimeType &mimeType)
// go through each field in meta mime and add it to a menu // go through each field in meta mime and add it to a menu
for (int32 index = 0; ; index++) { for (int32 index = 0; ; index++) {
const char* publicName; const char* publicName;
if (attributeMessage.FindString("attr:public_name", index, &publicName) != B_OK) if (attributeMessage.FindString("attr:public_name", index,
&publicName) != B_OK) {
break; break;
}
if (!attributeMessage.FindBool("attr:viewable")) if (!attributeMessage.FindBool("attr:viewable"))
continue; continue;
const char* attributeName; const char* attributeName;
if (attributeMessage.FindString("attr:name", index, &attributeName) != B_OK) if (attributeMessage.FindString("attr:name", index, &attributeName)
!= B_OK) {
continue; continue;
}
int32 type; int32 type;
if (attributeMessage.FindInt32("attr:type", index, &type) != B_OK) if (attributeMessage.FindInt32("attr:type", index, &type) != B_OK)
@@ -2714,7 +2767,8 @@ TAttrView::AddAttributes(BMenu* menu, const BMimeType &mimeType)
message = new BMessage(kAttributeItem); message = new BMessage(kAttributeItem);
message->AddInt32("operator", B_NE); message->AddInt32("operator", B_NE);
submenu->AddItem(new BMenuItem(B_TRANSLATE("is not"), message)); submenu->AddItem(new BMenuItem(B_TRANSLATE("is not"),
message));
submenu->SetTargetForItems(this); submenu->SetTargetForItems(this);
message = new BMessage(kAttributeItem); message = new BMessage(kAttributeItem);
@@ -2942,12 +2996,14 @@ DeleteTransientQueriesTask::ProcessOneRef(Model* model)
ASSERT(dynamic_cast<TTracker*>(be_app)); ASSERT(dynamic_cast<TTracker*>(be_app));
// check that it is not showing // check that it is not showing
if (dynamic_cast<TTracker*>(be_app)->EntryHasWindowOpen(model->EntryRef())) { if (dynamic_cast<TTracker*>(be_app)->EntryHasWindowOpen(
model->EntryRef())) {
PRINT(("query %s, showing, can't delete\n", model->Name())); PRINT(("query %s, showing, can't delete\n", model->Name()));
return false; return false;
} }
PRINT(("query %s, old, temporary, not shownig - deleting\n", model->Name())); PRINT(("query %s, old, temporary, not shownig - deleting\n",
model->Name()));
BEntry entry(model->EntryRef()); BEntry entry(model->EntryRef());
entry.Remove(); entry.Remove();
@@ -2993,8 +3049,8 @@ DeleteTransientQueriesTask::StartUpTransientQueryCleaner()
// #pragma mark - // #pragma mark -
RecentFindItemsMenu::RecentFindItemsMenu(const char* title, const BMessenger* target, RecentFindItemsMenu::RecentFindItemsMenu(const char* title,
uint32 what) const BMessenger* target, uint32 what)
: BMenu(title, B_ITEMS_IN_COLUMN), : BMenu(title, B_ITEMS_IN_COLUMN),
fTarget(*target), fTarget(*target),
fWhat(what) fWhat(what)
@@ -3029,7 +3085,8 @@ TrackerBuildRecentFindItemsMenu(const char* title)
DraggableQueryIcon::DraggableQueryIcon(BRect frame, const char* name, DraggableQueryIcon::DraggableQueryIcon(BRect frame, const char* name,
const BMessage* message, BMessenger messenger, uint32 resizeFlags, uint32 flags) const BMessage* message, BMessenger messenger, uint32 resizeFlags,
uint32 flags)
: DraggableIcon(frame, name, B_QUERY_MIMETYPE, B_LARGE_ICON, : DraggableIcon(frame, name, B_QUERY_MIMETYPE, B_LARGE_ICON,
message, messenger, resizeFlags, flags) message, messenger, resizeFlags, flags)
{ {
@@ -3056,7 +3113,8 @@ DraggableQueryIcon::DragStarted(BMessage* dragMessage)
// #pragma mark - // #pragma mark -
MostUsedNames::MostUsedNames(const char* fileName, const char* directory, int32 maxCount) MostUsedNames::MostUsedNames(const char* fileName, const char* directory,
int32 maxCount)
: :
fFileName(fileName), fFileName(fileName),
fDirectory(directory), fDirectory(directory),
@@ -3157,7 +3215,8 @@ MostUsedNames::AddName(const char* name)
list_entry* entry = NULL; list_entry* entry = NULL;
if (fList.CountItems() > fCount * 2) { if (fList.CountItems() > fCount * 2) {
entry = static_cast<list_entry*>(fList.RemoveItem(fList.CountItems() - 1)); entry = static_cast<list_entry*>(
fList.RemoveItem(fList.CountItems() - 1));
// is this the name we want to add here? // is this the name we want to add here?
if (strcmp(name, entry->name)) { if (strcmp(name, entry->name)) {
@@ -3169,9 +3228,12 @@ MostUsedNames::AddName(const char* name)
} }
if (entry == NULL) { if (entry == NULL) {
for (int32 i = 0; (entry = static_cast<list_entry*>(fList.ItemAt(i))) != NULL; i++) for (int32 i = 0;
(entry = static_cast<list_entry*>(fList.ItemAt(i))) != NULL;
i++) {
if (!strcmp(entry->name, name)) if (!strcmp(entry->name, name))
break; break;
}
} }
if (entry == NULL) { if (entry == NULL) {
+9 -5
View File
@@ -176,8 +176,10 @@ TGroupedMenu::TGroupedMenu(const char* name)
TGroupedMenu::~TGroupedMenu() TGroupedMenu::~TGroupedMenu()
{ {
TMenuItemGroup* group; TMenuItemGroup* group;
while ((group = static_cast<TMenuItemGroup*>(fGroups.RemoveItem(0L))) != NULL) while ((group = static_cast<TMenuItemGroup*>(fGroups.RemoveItem(0L)))
!= NULL) {
delete group; delete group;
}
} }
@@ -247,7 +249,8 @@ TGroupedMenu::CountGroups()
void void
TGroupedMenu::AddGroupItem(TMenuItemGroup* group, BMenuItem* item, int32 atIndex) TGroupedMenu::AddGroupItem(TMenuItemGroup* group, BMenuItem* item,
int32 atIndex)
{ {
int32 groupIndex = fGroups.IndexOf(group); int32 groupIndex = fGroups.IndexOf(group);
bool addSeparator = false; bool addSeparator = false;
@@ -257,7 +260,8 @@ TGroupedMenu::AddGroupItem(TMenuItemGroup* group, BMenuItem* item, int32 atIndex
if (groupIndex > 0) { if (groupIndex > 0) {
// add this group after an existing one // add this group after an existing one
TMenuItemGroup* previous = GroupAt(groupIndex - 1); TMenuItemGroup* previous = GroupAt(groupIndex - 1);
group->fFirstItemIndex = previous->fFirstItemIndex + previous->fItemsTotal; group->fFirstItemIndex = previous->fFirstItemIndex
+ previous->fItemsTotal;
addSeparator = true; addSeparator = true;
} else { } else {
// this is the first group // this is the first group
@@ -283,7 +287,8 @@ TGroupedMenu::AddGroupItem(TMenuItemGroup* group, BMenuItem* item, int32 atIndex
// insert item for real // insert item for real
AddItem(item, atIndex + group->fFirstItemIndex + (group->HasSeparator() ? 1 : 0)); AddItem(item,
atIndex + group->fFirstItemIndex + (group->HasSeparator() ? 1 : 0));
// move the groups after this one // move the groups after this one
@@ -320,4 +325,3 @@ TGroupedMenu::RemoveGroupItem(TMenuItemGroup* group, BMenuItem* item)
group->fFirstItemIndex -= removedSeparator ? 2 : 1; group->fFirstItemIndex -= removedSeparator ? 2 : 1;
} }
} }
+117 -77
View File
@@ -242,13 +242,17 @@ IconCacheEntry::IconHitTest(BPoint where, IconDrawMode mode, icon_size size) con
BBitmap* BBitmap*
IconCacheEntry::ConstructBitmap(BBitmap* constructFrom, IconDrawMode requestedMode, IconCacheEntry::ConstructBitmap(BBitmap* constructFrom,
IconDrawMode constructFromMode, icon_size size, LazyBitmapAllocator* lazyBitmap) IconDrawMode requestedMode, IconDrawMode constructFromMode,
icon_size size, LazyBitmapAllocator* lazyBitmap)
{ {
ASSERT(requestedMode == kSelected && constructFromMode == kNormalIcon); ASSERT(requestedMode == kSelected && constructFromMode == kNormalIcon);
// for now // for now
if (requestedMode == kSelected && constructFromMode == kNormalIcon)
return IconCache::sIconCache->MakeSelectedIcon(constructFrom, size, lazyBitmap); if (requestedMode == kSelected && constructFromMode == kNormalIcon) {
return IconCache::sIconCache->MakeSelectedIcon(constructFrom, size,
lazyBitmap);
}
return NULL; return NULL;
} }
@@ -260,7 +264,8 @@ IconCacheEntry::ConstructBitmap(IconDrawMode requestedMode, icon_size size,
{ {
BBitmap* source = (size == B_MINI_ICON) ? fMiniIcon : fLargeIcon; BBitmap* source = (size == B_MINI_ICON) ? fMiniIcon : fLargeIcon;
ASSERT(source); ASSERT(source);
return ConstructBitmap(source, requestedMode, kNormalIcon, size, lazyBitmap); return ConstructBitmap(source, requestedMode, kNormalIcon, size,
lazyBitmap);
} }
@@ -303,14 +308,13 @@ IconCache::IconCache()
} }
// The following calls use the icon lookup sequence node-prefered app for node- // The following calls use the icon lookup sequence node-prefered app for
// metamime-preferred app for metamime to find an icon; // node-metamime-preferred app for metamime to find an icon;
// if we are trying to get a specialized icon, we will first look for a normal // if we are trying to get a specialized icon, we will first look for a normal
// icon in each of the locations, if we get a hit, we look for the specialized, // icon in each of the locations, if we get a hit, we look for the
// if we don't find one, we try to auto-construct one, if we can't we assume the // specialized, if we don't find one, we try to auto-construct one, if we
// icon is not available // can't we assume the icon is not available for now the code only looks for
// for now the code only looks for normal icons, selected icons are auto-generated // normal icons, selected icons are auto-generated
IconCacheEntry* IconCacheEntry*
IconCache::GetIconForPreferredApp(const char* fileTypeSignature, IconCache::GetIconForPreferredApp(const char* fileTypeSignature,
const char* preferredApp, IconDrawMode mode, icon_size size, const char* preferredApp, IconDrawMode mode, icon_size size,
@@ -336,20 +340,24 @@ IconCache::GetIconForPreferredApp(const char* fileTypeSignature,
if (!entry || !entry->HaveIconBitmap(NORMAL_ICON_ONLY, size)) { if (!entry || !entry->HaveIconBitmap(NORMAL_ICON_ONLY, size)) {
PRINT_DISK_HITS(("File %s; Line %d # hitting disk for preferredApp %s, type %s\n", PRINT_DISK_HITS(
("File %s; Line %d # hitting disk for preferredApp %s, type %s\n",
__FILE__, __LINE__, preferredApp, fileTypeSignature)); __FILE__, __LINE__, preferredApp, fileTypeSignature));
BMimeType preferredAppType(preferredApp); BMimeType preferredAppType(preferredApp);
BString signature(fileTypeSignature); BString signature(fileTypeSignature);
signature.ToLower(); signature.ToLower();
if (preferredAppType.GetIconForType(signature.String(), lazyBitmap->Get(), if (preferredAppType.GetIconForType(signature.String(),
size) != B_OK) lazyBitmap->Get(), size) != B_OK) {
return NULL; return NULL;
}
BBitmap* bitmap = lazyBitmap->Adopt(); BBitmap* bitmap = lazyBitmap->Adopt();
if (!entry) { if (!entry) {
PRINT_ADD_ITEM(("File %s; Line %d # adding entry for preferredApp %s, type %s\n", PRINT_ADD_ITEM(
__FILE__, __LINE__, preferredApp, fileTypeSignature)); ("File %s; Line %d # adding entry for preferredApp %s, "
"type %s\n", __FILE__, __LINE__, preferredApp,
fileTypeSignature));
entry = fSharedCache.AddItem(fileTypeSignature, preferredApp); entry = fSharedCache.AddItem(fileTypeSignature, preferredApp);
} }
entry->SetIcon(bitmap, kNormalIcon, size); entry->SetIcon(bitmap, kNormalIcon, size);
@@ -394,8 +402,10 @@ IconCache::GetIconFromMetaMime(const char* fileType, IconDrawMode mode,
return NULL; return NULL;
SharedCacheEntry* aliasTo = NULL; SharedCacheEntry* aliasTo = NULL;
if (entry) if (entry) {
aliasTo = (SharedCacheEntry*)entry->ResolveIfAlias(&fSharedCache); aliasTo
= (SharedCacheEntry*)entry->ResolveIfAlias(&fSharedCache);
}
// look for icon defined by preferred app from metamime // look for icon defined by preferred app from metamime
aliasTo = (SharedCacheEntry*)GetIconForPreferredApp(fileType, aliasTo = (SharedCacheEntry*)GetIconForPreferredApp(fileType,
@@ -407,7 +417,8 @@ IconCache::GetIconFromMetaMime(const char* fileType, IconDrawMode mode,
// make an aliased entry so that the next time we get a // make an aliased entry so that the next time we get a
// hit on the first FindItem in here // hit on the first FindItem in here
if (!entry) { if (!entry) {
PRINT_ADD_ITEM(("File %s; Line %d # adding entry as alias for type %s\n", PRINT_ADD_ITEM(
("File %s; Line %d # adding entry as alias for type %s\n",
__FILE__, __LINE__, fileType)); __FILE__, __LINE__, fileType));
entry = fSharedCache.AddItem(&aliasTo, fileType); entry = fSharedCache.AddItem(&aliasTo, fileType);
entry->SetAliasFor(&fSharedCache, aliasTo); entry->SetAliasFor(&fSharedCache, aliasTo);
@@ -489,8 +500,9 @@ IconCache::GetIconFromFileTypes(ModelNodeLazyOpener* modelOpener,
lazyBitmap, entry); lazyBitmap, entry);
#if DEBUG #if DEBUG
else else
PRINT(("File %s; Line %d # failed to get supertype for type %s\n", PRINT(
__FILE__, __LINE__, fileType)); ("File %s; Line %d # failed to get supertype for "
"type %s\n", __FILE__, __LINE__, fileType));
#endif #endif
} }
} }
@@ -503,15 +515,20 @@ IconCache::GetIconFromFileTypes(ModelNodeLazyOpener* modelOpener,
// make an aliased entry so that the next time we get a // make an aliased entry so that the next time we get a
// hit and substitute a generic icon right away // hit and substitute a generic icon right away
PRINT_ADD_ITEM(("File %s; Line %d # adding entry as alias for preferredApp %s, type %s\n", PRINT_ADD_ITEM(
("File %s; Line %d # adding entry as alias for "
"preferredApp %s, type %s\n",
__FILE__, __LINE__, nodePreferredApp, fileType)); __FILE__, __LINE__, nodePreferredApp, fileType));
IconCacheEntry* aliasedEntry = fSharedCache.AddItem((SharedCacheEntry**)&entry, IconCacheEntry* aliasedEntry
fileType, nodePreferredApp); = fSharedCache.AddItem((SharedCacheEntry**)&entry, fileType,
aliasedEntry->SetAliasFor(&fSharedCache, (SharedCacheEntry*)entry); nodePreferredApp);
aliasedEntry->SetAliasFor(&fSharedCache,
(SharedCacheEntry*)entry);
// OK to cast here, have a runtime check // OK to cast here, have a runtime check
source = kPreferredAppForNode; source = kPreferredAppForNode;
// set source as preferred for node, so that next time we get a hit in // set source as preferred for node, so that next time we
// the initial find that uses GetIconForPreferredApp // get a hit in the initial find that uses
// GetIconForPreferredApp
} else } else
source = kMetaMime; source = kMetaMime;
#if DEBUG #if DEBUG
@@ -542,8 +559,8 @@ IconCache::GetVolumeIcon(AutoLock<SimpleIconCache>*nodeCacheLocker,
if (source == kTrackerDefault) { if (source == kTrackerDefault) {
// if tracker default, resolved entry is from shared cache // if tracker default, resolved entry is from shared cache
// this could be done a little cleaner if entry had a way to reach // this could be done a little cleaner if entry had a way to
// the cache it is in // reach the cache it is in
*resultingOpenCache = sharedCacheLocker; *resultingOpenCache = sharedCacheLocker;
sharedCacheLocker->Lock(); sharedCacheLocker->Lock();
} }
@@ -563,7 +580,8 @@ IconCache::GetVolumeIcon(AutoLock<SimpleIconCache>*nodeCacheLocker,
BBitmap* bitmap = lazyBitmap->Get(); BBitmap* bitmap = lazyBitmap->Get();
GetTrackerResources()->GetIconResource(R_ShareIcon, size, bitmap); GetTrackerResources()->GetIconResource(R_ShareIcon, size, bitmap);
if (!entry) { if (!entry) {
PRINT_ADD_ITEM(("File %s; Line %d # adding entry for model %s\n", PRINT_ADD_ITEM(
("File %s; Line %d # adding entry for model %s\n",
__FILE__, __LINE__, model->Name())); __FILE__, __LINE__, model->Name()));
entry = fNodeCache.AddItem(model->NodeRef()); entry = fNodeCache.AddItem(model->NodeRef());
} }
@@ -573,7 +591,8 @@ IconCache::GetVolumeIcon(AutoLock<SimpleIconCache>*nodeCacheLocker,
BBitmap* bitmap = lazyBitmap->Adopt(); BBitmap* bitmap = lazyBitmap->Adopt();
ASSERT(bitmap); ASSERT(bitmap);
if (!entry) { if (!entry) {
PRINT_ADD_ITEM(("File %s; Line %d # adding entry for model %s\n", PRINT_ADD_ITEM(
("File %s; Line %d # adding entry for model %s\n",
__FILE__, __LINE__, model->Name())); __FILE__, __LINE__, model->Name()));
entry = fNodeCache.AddItem(model->NodeRef()); entry = fNodeCache.AddItem(model->NodeRef());
} }
@@ -584,7 +603,8 @@ IconCache::GetVolumeIcon(AutoLock<SimpleIconCache>*nodeCacheLocker,
*resultingOpenCache = sharedCacheLocker; *resultingOpenCache = sharedCacheLocker;
sharedCacheLocker->Lock(); sharedCacheLocker->Lock();
// If the volume doesnt have a device it should have the generic icon // If the volume doesnt have a device it should have
// the generic icon
entry = GetIconFromMetaMime(B_VOLUME_MIMETYPE, mode, entry = GetIconFromMetaMime(B_VOLUME_MIMETYPE, mode,
size, lazyBitmap, entry); size, lazyBitmap, entry);
} }
@@ -754,8 +774,10 @@ IconCache::GetNodeIcon(ModelNodeLazyOpener* modelOpener,
status_t result; status_t result;
if (file) if (file)
result = GetAppIconFromAttr(file, lazyBitmap->Get(), size); result = GetAppIconFromAttr(file, lazyBitmap->Get(), size);
else else {
result = GetFileIconFromAttr(model->Node(), lazyBitmap->Get(), size); result = GetFileIconFromAttr(model->Node(), lazyBitmap->Get(),
size);
}
if (result == B_OK) { if (result == B_OK) {
// node has it's own icon, use it // node has it's own icon, use it
@@ -806,7 +828,8 @@ IconCache::GetGenericIcon(AutoLock<SimpleIconCache>* sharedCacheLocker,
// make an aliased entry so that the next time we get a // make an aliased entry so that the next time we get a
// hit and substitute a generic icon right away // hit and substitute a generic icon right away
PRINT_ADD_ITEM(("File %s; Line %d # adding entry for preferredApp %s, type %s\n", PRINT_ADD_ITEM(
("File %s; Line %d # adding entry for preferredApp %s, type %s\n",
__FILE__, __LINE__, model->PreferredAppSignature(), __FILE__, __LINE__, model->PreferredAppSignature(),
model->MimeType())); model->MimeType()));
IconCacheEntry* aliasedEntry = fSharedCache.AddItem( IconCacheEntry* aliasedEntry = fSharedCache.AddItem(
@@ -913,9 +936,9 @@ IconCache::Preload(AutoLock<SimpleIconCache>* nodeCacheLocker,
model, source, mode, size, &lazyBitmap, entry); model, source, mode, size, &lazyBitmap, entry);
} }
} }
// update the icon source // update the icon source
model->SetIconFrom(source); model->SetIconFrom(source);
} else { } else {
// we already know where the icon should come from, // we already know where the icon should come from,
// use shortcuts to get it // use shortcuts to get it
@@ -1001,18 +1024,21 @@ IconCache::Preload(AutoLock<SimpleIconCache>* nodeCacheLocker,
if (!entry || !entry->HaveIconBitmap(mode, size)) { if (!entry || !entry->HaveIconBitmap(mode, size)) {
// we don't have an icon, go with the generic // we don't have an icon, go with the generic
PRINT(("icon cache complete miss, falling back on generic icon for %s\n", PRINT(
model->Name())); ("icon cache complete miss, falling back on generic icon "
"for %s\n", model->Name()));
entry = GetGenericIcon(sharedCacheLocker, &resultingOpenCache, entry = GetGenericIcon(sharedCacheLocker, &resultingOpenCache,
model, source, mode, size, &lazyBitmap, entry); model, source, mode, size, &lazyBitmap, entry);
// we don't even have generic, something is really broken, // we don't even have generic, something is really broken,
// go with hardcoded generic icon // go with hardcoded generic icon
if (!entry || !entry->HaveIconBitmap(mode, size)) { if (!entry || !entry->HaveIconBitmap(mode, size)) {
PRINT(("icon cache complete miss, falling back on generic icon for %s\n", PRINT(
model->Name())); ("icon cache complete miss, falling back on generic "
entry = GetFallbackIcon(sharedCacheLocker, &resultingOpenCache, "icon for %s\n", model->Name()));
model, mode, size, &lazyBitmap, entry); entry = GetFallbackIcon(sharedCacheLocker,
&resultingOpenCache, model, mode, size, &lazyBitmap,
entry);
} }
// force icon pick up next time around because we probably just // force icon pick up next time around because we probably just
@@ -1061,8 +1087,9 @@ IconCache::Draw(Model* model, BView* view, BPoint where, IconDrawMode mode,
void void
IconCache::SyncDraw(Model* model, BView* view, BPoint where, IconDrawMode mode, IconCache::SyncDraw(Model* model, BView* view, BPoint where,
icon_size size, void (*blitFunc)(BView*, BPoint, BBitmap*, void*), IconDrawMode mode, icon_size size,
void (*blitFunc)(BView*, BPoint, BBitmap*, void*),
void* passThruState) void* passThruState)
{ {
AutoLock<SimpleIconCache> nodeCacheLocker(&fNodeCache, false); AutoLock<SimpleIconCache> nodeCacheLocker(&fNodeCache, false);
@@ -1083,12 +1110,14 @@ IconCache::SyncDraw(Model* model, BView* view, BPoint where, IconDrawMode mode,
void void
IconCache::Preload(Model* model, IconDrawMode mode, icon_size size, bool permanent) IconCache::Preload(Model* model, IconDrawMode mode, icon_size size,
bool permanent)
{ {
AutoLock<SimpleIconCache> nodeCacheLocker(&fNodeCache, false); AutoLock<SimpleIconCache> nodeCacheLocker(&fNodeCache, false);
AutoLock<SimpleIconCache> sharedCacheLocker(&fSharedCache, false); AutoLock<SimpleIconCache> sharedCacheLocker(&fSharedCache, false);
Preload(&nodeCacheLocker, &sharedCacheLocker, 0, model, mode, size, permanent); Preload(&nodeCacheLocker, &sharedCacheLocker, 0, model, mode, size,
permanent);
} }
@@ -1358,9 +1387,8 @@ IconCacheEntry::RetireIcons(BObjectList<BBitmap>* retiredBitmapList)
// In debug mode keep the hash table sizes small so that they grow a lot and // In debug mode keep the hash table sizes small so that they grow a lot and
// execercise the resizing code a lot. In release mode allocate them large up-front // execercise the resizing code a lot. In release mode allocate them large
// for better performance // up-front for better performance
SharedIconCache::SharedIconCache() SharedIconCache::SharedIconCache()
#if DEBUG #if DEBUG
: SimpleIconCache("Shared Icon cache aka \"The Dead-Locker\""), : SimpleIconCache("Shared Icon cache aka \"The Dead-Locker\""),
@@ -1397,26 +1425,31 @@ SharedIconCache::Draw(IconCacheEntry* entry, BView* view, BPoint where,
SharedCacheEntry* SharedCacheEntry*
SharedIconCache::FindItem(const char* fileType, const char* appSignature) const SharedIconCache::FindItem(const char* fileType,
const char* appSignature) const
{ {
ASSERT(fileType); ASSERT(fileType);
if (!fileType) if (!fileType)
fileType = B_FILE_MIMETYPE; fileType = B_FILE_MIMETYPE;
SharedCacheEntry* result = fHashTable.FindFirst(SharedCacheEntry::Hash(fileType, SharedCacheEntry* result
appSignature)); = fHashTable.FindFirst(SharedCacheEntry::Hash(fileType,
appSignature));
if (!result) if (!result)
return NULL; return NULL;
for(;;) { for(;;) {
if (result->fFileType == fileType && result->fAppSignature == appSignature) if (result->fFileType == fileType
&& result->fAppSignature == appSignature) {
return result; return result;
}
if (result->fNext < 0) if (result->fNext < 0)
break; break;
result = const_cast<SharedCacheEntry*>(&fElementArray.At(result->fNext)); result
= const_cast<SharedCacheEntry*>(&fElementArray.At(result->fNext));
} }
return NULL; return NULL;
@@ -1438,8 +1471,8 @@ SharedIconCache::AddItem(const char* fileType, const char* appSignature)
SharedCacheEntry* SharedCacheEntry*
SharedIconCache::AddItem(SharedCacheEntry** outstandingEntry, const char* fileType, SharedIconCache::AddItem(SharedCacheEntry** outstandingEntry,
const char* appSignature) const char* fileType, const char* appSignature)
{ {
int32 entryToken = fHashTable.ElementIndex(*outstandingEntry); int32 entryToken = fHashTable.ElementIndex(*outstandingEntry);
ASSERT(entryToken >= 0); ASSERT(entryToken >= 0);
@@ -1481,7 +1514,8 @@ SharedIconCache::RemoveAliasesTo(int32 aliasIndex)
void void
SharedIconCache::SetAliasFor(IconCacheEntry* alias, const SharedCacheEntry* original) const SharedIconCache::SetAliasFor(IconCacheEntry* alias,
const SharedCacheEntry* original) const
{ {
alias->fAliasForIndex = fHashTable.ElementIndex(original); alias->fAliasForIndex = fHashTable.ElementIndex(original);
} }
@@ -1493,7 +1527,8 @@ SharedCacheEntry::SharedCacheEntry()
} }
SharedCacheEntry::SharedCacheEntry(const char* fileType, const char* appSignature) SharedCacheEntry::SharedCacheEntry(const char* fileType,
const char* appSignature)
: fNext(-1), : fNext(-1),
fFileType(fileType), fFileType(fileType),
fAppSignature(appSignature) fAppSignature(appSignature)
@@ -1502,8 +1537,8 @@ SharedCacheEntry::SharedCacheEntry(const char* fileType, const char* appSignatur
void void
SharedCacheEntry::Draw(BView* view, BPoint where, IconDrawMode mode, icon_size size, SharedCacheEntry::Draw(BView* view, BPoint where, IconDrawMode mode,
bool async) icon_size size, bool async)
{ {
BBitmap* bitmap = IconForMode(mode, size); BBitmap* bitmap = IconForMode(mode, size);
ASSERT(bitmap); ASSERT(bitmap);
@@ -1529,8 +1564,9 @@ SharedCacheEntry::Draw(BView* view, BPoint where, IconDrawMode mode, icon_size s
void void
SharedCacheEntry::Draw(BView* view, BPoint where, IconDrawMode mode, icon_size size, SharedCacheEntry::Draw(BView* view, BPoint where, IconDrawMode mode,
void (*blitFunc)(BView*, BPoint, BBitmap*, void*), void* passThruState) icon_size size, void (*blitFunc)(BView*, BPoint, BBitmap*, void*),
void* passThruState)
{ {
BBitmap* bitmap = IconForMode(mode, size); BBitmap* bitmap = IconForMode(mode, size);
if (!bitmap) if (!bitmap)
@@ -1542,7 +1578,7 @@ SharedCacheEntry::Draw(BView* view, BPoint where, IconDrawMode mode, icon_size s
// } else { // } else {
// view->SetDrawingMode(B_OP_OVER); // view->SetDrawingMode(B_OP_OVER);
// } // }
//
(blitFunc)(view, where, bitmap, passThruState); (blitFunc)(view, where, bitmap, passThruState);
} }
@@ -1572,7 +1608,8 @@ SharedCacheEntry::Hash() const
bool bool
SharedCacheEntry::operator==(const SharedCacheEntry &entry) const SharedCacheEntry::operator==(const SharedCacheEntry &entry) const
{ {
return fFileType == entry.FileType() && fAppSignature == entry.AppSignature(); return fFileType == entry.FileType()
&& fAppSignature == entry.AppSignature();
} }
@@ -1616,8 +1653,8 @@ NodeCacheEntry::NodeCacheEntry(const node_ref* node, bool permanent)
void void
NodeCacheEntry::Draw(BView* view, BPoint where, IconDrawMode mode, icon_size size, NodeCacheEntry::Draw(BView* view, BPoint where, IconDrawMode mode,
bool async) icon_size size, bool async)
{ {
BBitmap* bitmap = IconForMode(mode, size); BBitmap* bitmap = IconForMode(mode, size);
if (!bitmap) if (!bitmap)
@@ -1646,8 +1683,9 @@ NodeCacheEntry::Draw(BView* view, BPoint where, IconDrawMode mode, icon_size siz
void void
NodeCacheEntry::Draw(BView* view, BPoint where, IconDrawMode mode, icon_size size, NodeCacheEntry::Draw(BView* view, BPoint where, IconDrawMode mode,
void (*blitFunc)(BView*, BPoint, BBitmap*, void*), void* passThruState) icon_size size, void (*blitFunc)(BView*, BPoint, BBitmap*, void*),
void* passThruState)
{ {
BBitmap* bitmap = IconForMode(mode, size); BBitmap* bitmap = IconForMode(mode, size);
if (!bitmap) if (!bitmap)
@@ -1766,7 +1804,8 @@ NodeIconCache::FindItem(const node_ref* node) const
if (result->fNext < 0) if (result->fNext < 0)
break; break;
result = const_cast<NodeCacheEntry*>(&fElementArray.At(result->fNext)); result
= const_cast<NodeCacheEntry*>(&fElementArray.At(result->fNext));
} }
return NULL; return NULL;
@@ -1786,7 +1825,8 @@ NodeIconCache::AddItem(const node_ref* node, bool permanent)
NodeCacheEntry* NodeCacheEntry*
NodeIconCache::AddItem(NodeCacheEntry** outstandingEntry, const node_ref* node) NodeIconCache::AddItem(NodeCacheEntry** outstandingEntry,
const node_ref* node)
{ {
int32 entryToken = fHashTable.ElementIndex(*outstandingEntry); int32 entryToken = fHashTable.ElementIndex(*outstandingEntry);
@@ -1876,8 +1916,8 @@ SimpleIconCache::SimpleIconCache(const char* name)
void void
SimpleIconCache::Draw(IconCacheEntry*, BView*, BPoint, IconDrawMode , SimpleIconCache::Draw(IconCacheEntry*, BView*, BPoint, IconDrawMode,
icon_size , bool ) icon_size, bool)
{ {
TRESPASS(); TRESPASS();
// pure virtual, do nothing // pure virtual, do nothing
@@ -1885,8 +1925,8 @@ SimpleIconCache::Draw(IconCacheEntry*, BView*, BPoint, IconDrawMode ,
void void
SimpleIconCache::Draw(IconCacheEntry*, BView*, BPoint, IconDrawMode, icon_size, SimpleIconCache::Draw(IconCacheEntry*, BView*, BPoint, IconDrawMode,
void(*)(BView*, BPoint, BBitmap*, void*), void*) icon_size, void(*)(BView*, BPoint, BBitmap*, void*), void*)
{ {
TRESPASS(); TRESPASS();
// pure virtual, do nothing // pure virtual, do nothing
@@ -1917,8 +1957,8 @@ SimpleIconCache::IsLocked() const
// #pragma mark - // #pragma mark -
LazyBitmapAllocator::LazyBitmapAllocator(icon_size size, color_space colorSpace, LazyBitmapAllocator::LazyBitmapAllocator(icon_size size,
bool preallocate) color_space colorSpace, bool preallocate)
: fBitmap(NULL), : fBitmap(NULL),
fSize(size), fSize(size),
fColorSpace(colorSpace) fColorSpace(colorSpace)
+44 -36
View File
@@ -49,13 +49,13 @@ All rights reserved.
#include "Utilities.h" #include "Utilities.h"
// Icon cache splits icons into two caches - the shared cache, likely to get the // Icon cache splits icons into two caches - the shared cache, likely to
// most hits and the node cache. Every icon that is found in a mime based // get the most hits and the node cache. Every icon that is found in a
// structure goes into the shared cache, only files that have their own private // mime-based structure goes into the shared cache, only files that have
// icon use the node cache; // their own private icon use the node cache;
// Entries are only deleted from the shared cache if an icon for a mime type changes, // Entries are only deleted from the shared cache if an icon for a mime type
// this makes async icon drawing easier. Node cache deletes it's entries whenever a // changes, this makes async icon drawing easier. Node cache deletes it's
// file gets deleted. // entries whenever a file gets deleted.
// if a view ever uses the cache to draw in async mode, it needs to call // if a view ever uses the cache to draw in async mode, it needs to call
// it when it is being destroyed // it when it is being destroyed
@@ -100,13 +100,14 @@ enum IconDrawMode {
// Where did an icon come from // Where did an icon come from
enum IconSource { enum IconSource {
kUnknownSource, kUnknownSource,
kUnknownNotFromNode, // icon origin not known but determined not to be from kUnknownNotFromNode, // icon origin not known but determined not
// the node itself // to be from the node itself
kTrackerDefault, // file has no type, Tracker provides generic, folder, kTrackerDefault, // file has no type, Tracker provides generic,
// symlink or app // folder, symlink or app
kTrackerSupplied, // home directory, boot volume, trash, etc. kTrackerSupplied, // home directory, boot volume, trash, etc.
kMetaMime, // from BMimeType kMetaMime, // from BMimeType
kPreferredAppForType, // have a preferred application for a type, has an icon kPreferredAppForType, // have a preferred application for a type,
// has an icon
kPreferredAppForNode, // have a preferred application for this node, kPreferredAppForNode, // have a preferred application for this node,
// has an icon // has an icon
kVolume, kVolume,
@@ -127,7 +128,8 @@ public:
~IconCacheEntry(); ~IconCacheEntry();
void SetAliasFor(const SharedIconCache*, const SharedCacheEntry*); void SetAliasFor(const SharedIconCache*, const SharedCacheEntry*);
static IconCacheEntry* ResolveIfAlias(const SharedIconCache*, IconCacheEntry*); static IconCacheEntry* ResolveIfAlias(const SharedIconCache*,
IconCacheEntry*);
IconCacheEntry* ResolveIfAlias(const SharedIconCache*); IconCacheEntry* ResolveIfAlias(const SharedIconCache*);
void SetIcon(BBitmap* bitmap, IconDrawMode mode, icon_size size, void SetIcon(BBitmap* bitmap, IconDrawMode mode, icon_size size,
@@ -137,9 +139,9 @@ public:
bool CanConstructBitmap(IconDrawMode mode, icon_size size) const; bool CanConstructBitmap(IconDrawMode mode, icon_size size) const;
static bool AlternateModeForIconConstructing(IconDrawMode requestedMode, static bool AlternateModeForIconConstructing(IconDrawMode requestedMode,
IconDrawMode &alternate, icon_size size); IconDrawMode &alternate, icon_size size);
BBitmap* ConstructBitmap(BBitmap* constructFrom, IconDrawMode requestedMode, BBitmap* ConstructBitmap(BBitmap* constructFrom,
IconDrawMode constructFromMode, icon_size size, IconDrawMode requestedMode, IconDrawMode constructFromMode,
LazyBitmapAllocator*); icon_size size, LazyBitmapAllocator*);
BBitmap* ConstructBitmap(IconDrawMode requestedMode, icon_size size, BBitmap* ConstructBitmap(IconDrawMode requestedMode, icon_size size,
LazyBitmapAllocator*); LazyBitmapAllocator*);
// same as above, always uses normal icon as source // same as above, always uses normal icon as source
@@ -242,16 +244,18 @@ public:
virtual void Draw(IconCacheEntry*, BView*, BPoint, IconDrawMode, virtual void Draw(IconCacheEntry*, BView*, BPoint, IconDrawMode,
icon_size, void (*)(BView*, BPoint, BBitmap*, void*), void* = NULL); icon_size, void (*)(BView*, BPoint, BBitmap*, void*), void* = NULL);
SharedCacheEntry* FindItem(const char* fileType, const char* appSignature = 0) SharedCacheEntry* FindItem(const char* fileType,
const; const char* appSignature = 0) const;
SharedCacheEntry* AddItem(const char* fileType, const char* appSignature = 0); SharedCacheEntry* AddItem(const char* fileType,
SharedCacheEntry* AddItem(SharedCacheEntry** outstandingEntry, const char* fileType,
const char* appSignature = 0); const char* appSignature = 0);
// same as previous AddItem, updates the pointer to outstandingEntry, because SharedCacheEntry* AddItem(SharedCacheEntry** outstandingEntry,
// adding to the hash table makes any pending pointer invalid const char* fileType, const char* appSignature = 0);
// same as previous AddItem, updates the pointer to outstandingEntry,
// because adding to the hash table makes any pending pointer invalid
void IconChanged(SharedCacheEntry*); void IconChanged(SharedCacheEntry*);
void SetAliasFor(IconCacheEntry* alias, const SharedCacheEntry* original) const; void SetAliasFor(IconCacheEntry* alias,
const SharedCacheEntry* original) const;
IconCacheEntry* ResolveIfAlias(IconCacheEntry* entry) const; IconCacheEntry* ResolveIfAlias(IconCacheEntry* entry) const;
int32 EntryIndex(const SharedCacheEntry* entry) const; int32 EntryIndex(const SharedCacheEntry* entry) const;
@@ -261,9 +265,9 @@ private:
OpenHashTable<SharedCacheEntry, SharedCacheEntryArray> fHashTable; OpenHashTable<SharedCacheEntry, SharedCacheEntryArray> fHashTable;
SharedCacheEntryArray fElementArray; SharedCacheEntryArray fElementArray;
BObjectList<BBitmap> fRetiredBitmaps; BObjectList<BBitmap> fRetiredBitmaps;
// icons are drawn asynchronously, can't just delete them // icons are drawn asynchronously, can't just delete them right away,
// right away, instead have to place them onto the retired bitmap list // instead have to place them onto the retired bitmap list and wait
// and wait for the next sync to delete them // for the next sync to delete them
}; };
@@ -317,11 +321,13 @@ public:
NodeCacheEntry* FindItem(const node_ref*) const; NodeCacheEntry* FindItem(const node_ref*) const;
NodeCacheEntry* AddItem(const node_ref*, bool permanent = false); NodeCacheEntry* AddItem(const node_ref*, bool permanent = false);
NodeCacheEntry* AddItem(NodeCacheEntry** outstandingEntry, const node_ref*); NodeCacheEntry* AddItem(NodeCacheEntry** outstandingEntry,
// same as previous AddItem, updates the pointer to outstandingEntry, because const node_ref*);
// adding to the hash table makes any pending pointer invalid // same as previous AddItem, updates the pointer to outstandingEntry,
// because adding to the hash table makes any pending pointer invalid
void Deleting(const node_ref*); void Deleting(const node_ref*);
// model for this node is getting deleted (not necessarily the node itself) // model for this node is getting deleted
// (not necessarily the node itself)
void Removing(const node_ref*); void Removing(const node_ref*);
// used by permanent NodeIconCache entries, when an entry gets deleted // used by permanent NodeIconCache entries, when an entry gets deleted
void Deleting(const BView*); void Deleting(const BView*);
@@ -406,12 +412,12 @@ private:
IconCacheEntry* GetIconForPreferredApp(const char* mimeTypeSignature, IconCacheEntry* GetIconForPreferredApp(const char* mimeTypeSignature,
const char* preferredApp, IconDrawMode mode, icon_size size, const char* preferredApp, IconDrawMode mode, icon_size size,
LazyBitmapAllocator*, IconCacheEntry*); LazyBitmapAllocator*, IconCacheEntry*);
IconCacheEntry* GetIconFromFileTypes(ModelNodeLazyOpener*, IconSource &source, IconCacheEntry* GetIconFromFileTypes(ModelNodeLazyOpener*,
IconSource &source, IconDrawMode mode, icon_size size,
LazyBitmapAllocator*, IconCacheEntry*);
IconCacheEntry* GetIconFromMetaMime(const char* fileType,
IconDrawMode mode, icon_size size, LazyBitmapAllocator*, IconDrawMode mode, icon_size size, LazyBitmapAllocator*,
IconCacheEntry*); IconCacheEntry*);
IconCacheEntry* GetIconFromMetaMime(const char* fileType, IconDrawMode mode,
icon_size size, LazyBitmapAllocator*,
IconCacheEntry*);
IconCacheEntry* GetVolumeIcon(AutoLock<SimpleIconCache>* nodeCache, IconCacheEntry* GetVolumeIcon(AutoLock<SimpleIconCache>* nodeCache,
AutoLock<SimpleIconCache>* sharedCache, AutoLock<SimpleIconCache>* sharedCache,
AutoLock<SimpleIconCache>** resultingLockedCache, AutoLock<SimpleIconCache>** resultingLockedCache,
@@ -431,12 +437,14 @@ private:
AutoLock<SimpleIconCache>* nodeCache, AutoLock<SimpleIconCache>* nodeCache,
AutoLock<SimpleIconCache>** resultingLockedCache, AutoLock<SimpleIconCache>** resultingLockedCache,
Model*, IconSource&, IconDrawMode mode, Model*, IconSource&, IconDrawMode mode,
icon_size size, LazyBitmapAllocator*, IconCacheEntry*, bool permanent); icon_size size, LazyBitmapAllocator*, IconCacheEntry*,
bool permanent);
IconCacheEntry* GetGenericIcon(AutoLock<SimpleIconCache>* sharedCache, IconCacheEntry* GetGenericIcon(AutoLock<SimpleIconCache>* sharedCache,
AutoLock<SimpleIconCache>** resultingLockedCache, AutoLock<SimpleIconCache>** resultingLockedCache,
Model*, IconSource&, IconDrawMode mode, Model*, IconSource&, IconDrawMode mode,
icon_size size, LazyBitmapAllocator*, IconCacheEntry*); icon_size size, LazyBitmapAllocator*, IconCacheEntry*);
IconCacheEntry* GetFallbackIcon(AutoLock<SimpleIconCache>* sharedCacheLocker, IconCacheEntry* GetFallbackIcon(
AutoLock<SimpleIconCache>* sharedCacheLocker,
AutoLock<SimpleIconCache>** resultingOpenCache, AutoLock<SimpleIconCache>** resultingOpenCache,
Model* model, IconDrawMode mode, icon_size size, Model* model, IconDrawMode mode, icon_size size,
LazyBitmapAllocator* lazyBitmap, IconCacheEntry* entry); LazyBitmapAllocator* lazyBitmap, IconCacheEntry* entry);
+166 -92
View File
@@ -120,7 +120,8 @@ class AttributeView : public BView {
BTextView* TextView() const { return fTitleEditView; } BTextView* TextView() const { return fTitleEditView; }
static filter_result TextViewFilter(BMessage*, BHandler**, BMessageFilter*); static filter_result TextViewFilter(BMessage*, BHandler**,
BMessageFilter*);
off_t LastSize() const; off_t LastSize() const;
void SetLastSize(off_t); void SetLastSize(off_t);
@@ -278,7 +279,8 @@ OpenToolTipWindow(BScreen& screen, BRect rect, const char* name,
// #pragma mark - // #pragma mark -
BInfoWindow::BInfoWindow(Model* model, int32 group_index, LockingList<BWindow>* list) BInfoWindow::BInfoWindow(Model* model, int32 group_index,
LockingList<BWindow>* list)
: BWindow(BInfoWindow::InfoWindowRect(false), : BWindow(BInfoWindow::InfoWindowRect(false),
"InfoWindow", B_TITLED_WINDOW, "InfoWindow", B_TITLED_WINDOW,
B_NOT_RESIZABLE | B_NOT_ZOOMABLE, B_CURRENT_WORKSPACE), B_NOT_RESIZABLE | B_NOT_ZOOMABLE, B_CURRENT_WORKSPACE),
@@ -366,7 +368,8 @@ BInfoWindow::Show()
AddChild(fAttributeView); AddChild(fAttributeView);
// position window appropriately based on index // position window appropriately based on index
BRect windRect(InfoWindowRect(TargetModel()->IsSymLink() || TargetModel()->IsFile())); BRect windRect(InfoWindowRect(TargetModel()->IsSymLink()
|| TargetModel()->IsFile()));
if ((fIndex + 2) % 2 == 1) { if ((fIndex + 2) % 2 == 1) {
windRect.OffsetBy(320, 0); windRect.OffsetBy(320, 0);
fIndex--; fIndex--;
@@ -499,8 +502,9 @@ BInfoWindow::MessageReceived(BMessage* message)
// We now have to re-target the broken symlink. Unfortunately, // We now have to re-target the broken symlink. Unfortunately,
// there's no way to change the target of an existing symlink. // there's no way to change the target of an existing symlink.
// So we have to delete the old one and create a new one. // So we have to delete the old one and create a new one.
// First, stop watching the broken node (we don't want this window // First, stop watching the broken node
// to quit when the node is removed.) // (we don't want this window to quit when the node
// is removed.)
stop_watching(this); stop_watching(this);
// Get the parent // Get the parent
@@ -601,8 +605,10 @@ BInfoWindow::MessageReceived(BMessage* message)
case B_STAT_CHANGED: case B_STAT_CHANGED:
case B_ATTR_CHANGED: case B_ATTR_CHANGED:
fAttributeView->ModelChanged(TargetModel(), message); fAttributeView->ModelChanged(TargetModel(), message);
// must be called before the FilePermissionView::ModelChanged() // must be called before the
// call, because it changes the model... (bad style!) // FilePermissionView::ModelChanged()
// call, because it changes the model...
// (bad style!)
if (fPermissionsView != NULL) if (fPermissionsView != NULL)
fPermissionsView->ModelChanged(TargetModel()); fPermissionsView->ModelChanged(TargetModel());
@@ -610,13 +616,15 @@ BInfoWindow::MessageReceived(BMessage* message)
case B_DEVICE_UNMOUNTED: case B_DEVICE_UNMOUNTED:
{ {
// We were watching a volume that is no longer mounted, // We were watching a volume that is no longer
// we might as well quit // mounted, we might as well quit
node_ref itemNode; node_ref itemNode;
// Only the device information is available // Only the device information is available
message->FindInt32("device", &itemNode.device); message->FindInt32("device", &itemNode.device);
if (TargetModel()->NodeRef()->device == itemNode.device) if (TargetModel()->NodeRef()->device
== itemNode.device) {
Close(); Close();
}
break; break;
} }
@@ -629,8 +637,10 @@ BInfoWindow::MessageReceived(BMessage* message)
case kPermissionsSelected: case kPermissionsSelected:
if (fPermissionsView == NULL) { if (fPermissionsView == NULL) {
// Only true on first call. // Only true on first call.
fPermissionsView = new FilePermissionsView(BRect(kBorderWidth + 1, fPermissionsView
fAttributeView->Bounds().bottom, fAttributeView->Bounds().right, = new FilePermissionsView(BRect(kBorderWidth + 1,
fAttributeView->Bounds().bottom,
fAttributeView->Bounds().right,
fAttributeView->Bounds().bottom+80), fModel); fAttributeView->Bounds().bottom+80), fModel);
ResizeBy(0, fPermissionsView->Bounds().Height()); ResizeBy(0, fPermissionsView->Bounds().Height());
@@ -661,7 +671,7 @@ BInfoWindow::GetSizeString(BString &result, off_t size, int32 fileCount)
char sizeBuffer[128]; char sizeBuffer[128];
result << string_for_size((double)size, sizeBuffer, sizeof(sizeBuffer)); result << string_for_size((double)size, sizeBuffer, sizeof(sizeBuffer));
// when we show the byte size, format it with a thousands delimiter (comma) // when we show the byte size, format it with a thousands delimiter
// TODO: use BCountry::FormatNumber // TODO: use BCountry::FormatNumber
if (size >= kKBSize) { if (size >= kKBSize) {
char numStr[128]; char numStr[128];
@@ -784,7 +794,8 @@ BInfoWindow::CalcSize(void* castToWindow)
void void
BInfoWindow::SetSizeStr(const char* sizeStr) BInfoWindow::SetSizeStr(const char* sizeStr)
{ {
AttributeView* view = dynamic_cast<AttributeView *>(FindView("attr_view")); AttributeView* view
= dynamic_cast<AttributeView *>(FindView("attr_view"));
if (view) if (view)
view->SetSizeStr(sizeStr); view->SetSizeStr(sizeStr);
} }
@@ -803,7 +814,8 @@ BInfoWindow::OpenFilePanel(const entry_ref* ref)
false, &message); false, &message);
if (fFilePanel != NULL) { if (fFilePanel != NULL) {
fFilePanel->SetButtonLabel(B_DEFAULT_BUTTON, B_TRANSLATE("Select")); fFilePanel->SetButtonLabel(B_DEFAULT_BUTTON,
B_TRANSLATE("Select"));
fFilePanel->Window()->ResizeTo(500, 300); fFilePanel->Window()->ResizeTo(500, 300);
BString title(B_TRANSLATE_COMMENT("Link \"%name\" to:", BString title(B_TRANSLATE_COMMENT("Link \"%name\" to:",
"File dialog title for new sym link")); "File dialog title for new sym link"));
@@ -826,7 +838,8 @@ BInfoWindow::OpenFilePanel(const entry_ref* ref)
AttributeView::AttributeView(BRect rect, Model* model) AttributeView::AttributeView(BRect rect, Model* model)
: BView(rect, "attr_view", B_FOLLOW_ALL_SIDES, B_WILL_DRAW | B_PULSE_NEEDED), : BView(rect, "attr_view", B_FOLLOW_ALL_SIDES,
B_WILL_DRAW | B_PULSE_NEEDED),
fDivider(0), fDivider(0),
fPreferredAppMenu(NULL), fPreferredAppMenu(NULL),
fModel(model), fModel(model),
@@ -873,9 +886,12 @@ AttributeView::AttributeView(BRect rect, Model* model)
fTitleRect.left = fIconRect.right + 5; fTitleRect.left = fIconRect.right + 5;
fTitleRect.top = 0; fTitleRect.top = 0;
fTitleRect.bottom = fontMetrics.ascent + 1; fTitleRect.bottom = fontMetrics.ascent + 1;
fTitleRect.right = min_c(fTitleRect.left + currentFont.StringWidth(fModel->Name()), Bounds().Width() - 5); fTitleRect.right = min_c(
fTitleRect.left + currentFont.StringWidth(fModel->Name()),
Bounds().Width() - 5);
// Offset so that it centers with the icon // Offset so that it centers with the icon
fTitleRect.OffsetBy(0, fIconRect.top + ((fIconRect.Height() - fTitleRect.Height()) / 2)); fTitleRect.OffsetBy(0,
fIconRect.top + ((fIconRect.Height() - fTitleRect.Height()) / 2));
// Make some room for the border for when we are in edit mode // Make some room for the border for when we are in edit mode
// (Negative numbers increase the size of the rect) // (Negative numbers increase the size of the rect)
fTitleRect.InsetBy(-1, -2); fTitleRect.InsetBy(-1, -2);
@@ -904,8 +920,10 @@ AttributeView::AttributeView(BRect rect, Model* model)
BRect preferredAppRect(kBorderWidth + kBorderMargin, BRect preferredAppRect(kBorderWidth + kBorderMargin,
fTitleRect.bottom + (lineHeight * 7), fTitleRect.bottom + (lineHeight * 7),
Bounds().Width() - 5, fTitleRect.bottom + (lineHeight * 8)); Bounds().Width() - 5, fTitleRect.bottom + (lineHeight * 8));
fPreferredAppMenu = new BMenuField(preferredAppRect, "", "", new BPopUpMenu("")); fPreferredAppMenu = new BMenuField(preferredAppRect, "", "",
fDivider = currentFont.StringWidth(B_TRANSLATE("Opens with:")) + 5; new BPopUpMenu(""));
fDivider = currentFont.StringWidth(B_TRANSLATE("Opens with:"))
+ 5;
fPreferredAppMenu->SetDivider(fDivider); fPreferredAppMenu->SetDivider(fDivider);
fDivider += (preferredAppRect.left - 2); fDivider += (preferredAppRect.left - 2);
fPreferredAppMenu->SetFont(&currentFont); fPreferredAppMenu->SetFont(&currentFont);
@@ -928,8 +946,10 @@ AttributeView::AttributeView(BRect rect, Model* model)
for (int32 index = 0; ; index++) { for (int32 index = 0; ; index++) {
const char* signature; const char* signature;
if (supportingAppList.FindString("applications", index, &signature) != B_OK) if (supportingAppList.FindString("applications", index,
&signature) != B_OK) {
break; break;
}
// Only add separator item if there are more items // Only add separator item if there are more items
if (index == 0) if (index == 0)
@@ -1020,7 +1040,8 @@ AttributeView::InitStrings(const Model* model)
// If the BPath is initialized, then check the file for existence // If the BPath is initialized, then check the file for existence
if (traversedPath.InitCheck() == B_OK) { if (traversedPath.InitCheck() == B_OK) {
BEntry entry(traversedPath.Path(), false); // look at the target itself BEntry entry(traversedPath.Path(), false);
// look at the target itself
if (entry.InitCheck() == B_OK && entry.Exists()) if (entry.InitCheck() == B_OK && entry.Exists())
linked = true; linked = true;
} }
@@ -1034,8 +1055,10 @@ AttributeView::InitStrings(const Model* model)
if (!linked) if (!linked)
fLinkToStr += " (broken)"; // link points to missing object fLinkToStr += " (broken)"; // link points to missing object
} else if (model->IsExecutable()) { } else if (model->IsExecutable()) {
if (((Model*)model)->GetLongVersionString(fDescStr, B_APP_VERSION_KIND) == B_OK) { if (((Model*)model)->GetLongVersionString(fDescStr,
// we want a flat string, so we replace all newlines/tabs with spaces B_APP_VERSION_KIND) == B_OK) {
// we want a flat string, so replace all newlines and tabs
// with spaces
fDescStr.ReplaceAll('\n', ' '); fDescStr.ReplaceAll('\n', ' ');
fDescStr.ReplaceAll('\t', ' '); fDescStr.ReplaceAll('\t', ' ');
} else } else
@@ -1097,10 +1120,10 @@ AttributeView::ModelChanged(Model* model, BMessage* message)
// ensure notification is for us // ensure notification is for us
if (*model->NodeRef() == itemNode if (*model->NodeRef() == itemNode
// For volumes, the device ID is obviously not handled in a // For volumes, the device ID is obviously not handled in a
// consistent way; the node monitor sends us the ID of the parent // consistent way; the node monitor sends us the ID of the
// device, while the model is set to the device of the volume // parent device, while the model is set to the device of the
// directly - this hack works for volumes that are mounted in // volume directly - this hack works for volumes that are
// the root directory // mounted in the root directory
|| (model->IsVolume() || (model->IsVolume()
&& itemNode.device == 1 && itemNode.device == 1
&& itemNode.node == model->NodeRef()->node)) { && itemNode.node == model->NodeRef()->node)) {
@@ -1167,8 +1190,8 @@ AttributeView::ModelChanged(Model* model, BMessage* message)
fModel = model; fModel = model;
if (fModel->IsSymLink()) { if (fModel->IsSymLink()) {
// if we are looking at a symlink, deference the model and look at the // if we are looking at a symlink, deference the model and look
// target // at the target
Model* resolvedModel = new Model(model->EntryRef(), true, true); Model* resolvedModel = new Model(model->EntryRef(), true, true);
if (resolvedModel->InitCheck() == B_OK) { if (resolvedModel->InitCheck() == B_OK) {
if (fIconModel != fModel) if (fIconModel != fModel)
@@ -1245,7 +1268,8 @@ AttributeView::MouseDown(BPoint point)
} else if (fTitleEditView) { } else if (fTitleEditView) {
FinishEditingTitle(true); FinishEditingTitle(true);
} else if (fSizeRect.Contains(point)) { } else if (fSizeRect.Contains(point)) {
if (fModel->IsDirectory() && !fModel->IsVolume() && !fModel->IsRoot()) { if (fModel->IsDirectory() && !fModel->IsVolume()
&& !fModel->IsRoot()) {
InvertRect(fSizeRect); InvertRect(fSizeRect);
fTrackingState = size_track; fTrackingState = size_track;
} else } else
@@ -1253,13 +1277,16 @@ AttributeView::MouseDown(BPoint point)
} else if (fIconRect.Contains(point)) { } else if (fIconRect.Contains(point)) {
uint32 buttons; uint32 buttons;
Window()->CurrentMessage()->FindInt32("buttons", (int32*)&buttons); Window()->CurrentMessage()->FindInt32("buttons", (int32*)&buttons);
if (((modifiers() & B_CONTROL_KEY) != 0) || (buttons & B_SECONDARY_MOUSE_BUTTON) != 0) { if (((modifiers() & B_CONTROL_KEY) != 0)
|| (buttons & B_SECONDARY_MOUSE_BUTTON) != 0) {
// Show contextual menu // Show contextual menu
BPopUpMenu* contextMenu = new BPopUpMenu("FileContext", false, false); BPopUpMenu* contextMenu
= new BPopUpMenu("FileContext", false, false);
if (contextMenu) { if (contextMenu) {
BuildContextMenu(contextMenu); BuildContextMenu(contextMenu);
contextMenu->SetAsyncAutoDestruct(true); contextMenu->SetAsyncAutoDestruct(true);
contextMenu->Go(ConvertToScreen(point), true, true, ConvertToScreen(fIconRect)); contextMenu->Go(ConvertToScreen(point), true, true,
ConvertToScreen(fIconRect));
} }
} else { } else {
// Check to see if the point is actually on part of the icon, // Check to see if the point is actually on part of the icon,
@@ -1268,21 +1295,25 @@ AttributeView::MouseDown(BPoint point)
BPoint offsetPoint; BPoint offsetPoint;
offsetPoint.x = point.x - fIconRect.left; offsetPoint.x = point.x - fIconRect.left;
offsetPoint.y = point.y - fIconRect.top; offsetPoint.y = point.y - fIconRect.top;
if (IconCache::sIconCache->IconHitTest(offsetPoint, fIconModel, kNormalIcon, B_LARGE_ICON)) { if (IconCache::sIconCache->IconHitTest(offsetPoint, fIconModel,
kNormalIcon, B_LARGE_ICON)) {
// Can't drag the trash anywhere.. // Can't drag the trash anywhere..
fTrackingState = fModel->IsTrash() ? open_only_track : icon_track; fTrackingState = fModel->IsTrash()
? open_only_track : icon_track;
// Check for possible double click // Check for possible double click
if (abs((int32)(fClickPoint.x - point.x)) < kDragSlop if (abs((int32)(fClickPoint.x - point.x)) < kDragSlop
&& abs((int32)(fClickPoint.y - point.y)) < kDragSlop) { && abs((int32)(fClickPoint.y - point.y)) < kDragSlop) {
int32 clickCount; int32 clickCount;
Window()->CurrentMessage()->FindInt32("clicks", &clickCount); Window()->CurrentMessage()->FindInt32("clicks",
&clickCount);
// This checks the* previous* click point // This checks the* previous* click point
if (clickCount == 2) { if (clickCount == 2) {
offsetPoint.x = fClickPoint.x - fIconRect.left; offsetPoint.x = fClickPoint.x - fIconRect.left;
offsetPoint.y = fClickPoint.y - fIconRect.top; offsetPoint.y = fClickPoint.y - fIconRect.top;
fDoubleClick = IconCache::sIconCache->IconHitTest(offsetPoint, fDoubleClick
= IconCache::sIconCache->IconHitTest(offsetPoint,
fIconModel, kNormalIcon, B_LARGE_ICON); fIconModel, kNormalIcon, B_LARGE_ICON);
} }
} }
@@ -1301,7 +1332,8 @@ AttributeView::MouseMoved(BPoint point, uint32, const BMessage* message)
// Highlight Drag target // Highlight Drag target
if (message && message->ReturnAddress() != BMessenger(this) if (message && message->ReturnAddress() != BMessenger(this)
&& message->what == B_SIMPLE_DATA && message->what == B_SIMPLE_DATA
&& BPoseView::CanHandleDragSelection(fModel, message, (modifiers() & B_CONTROL_KEY) != 0)) { && BPoseView::CanHandleDragSelection(fModel, message,
(modifiers() & B_CONTROL_KEY) != 0)) {
bool overTarget = fIconRect.Contains(point); bool overTarget = fIconRect.Contains(point);
SetDrawingMode(B_OP_OVER); SetDrawingMode(B_OP_OVER);
if (overTarget != fIsDropTarget) { if (overTarget != fIsDropTarget) {
@@ -1334,19 +1366,23 @@ AttributeView::MouseMoved(BPoint point, uint32, const BMessage* message)
break; break;
case icon_track: case icon_track:
if (fMouseDown && !fDragging && (abs((int32)(point.x - fClickPoint.x)) > kDragSlop if (fMouseDown && !fDragging
|| abs((int32)(point.y - fClickPoint.y)) > kDragSlop)) { && (abs((int32)(point.x - fClickPoint.x)) > kDragSlop
|| abs((int32)(point.y - fClickPoint.y)) > kDragSlop)) {
// Find the required height // Find the required height
BFont font; BFont font;
GetFont(&font); GetFont(&font);
font.SetSize(kAttribFontHeight); font.SetSize(kAttribFontHeight);
float height = CurrentFontHeight(kAttribFontHeight) + fIconRect.Height() + 8; float height = CurrentFontHeight(kAttribFontHeight)
+ fIconRect.Height() + 8;
BRect rect(0, 0, min_c(fIconRect.Width() BRect rect(0, 0, min_c(fIconRect.Width()
+ font.StringWidth(fModel->Name()) + 4, fIconRect.Width() * 3), height); + font.StringWidth(fModel->Name()) + 4,
fIconRect.Width() * 3), height);
BBitmap* dragBitmap = new BBitmap(rect, B_RGBA32, true); BBitmap* dragBitmap = new BBitmap(rect, B_RGBA32, true);
dragBitmap->Lock(); dragBitmap->Lock();
BView* view = new BView(dragBitmap->Bounds(), "", B_FOLLOW_NONE, 0); BView* view = new BView(dragBitmap->Bounds(), "",
B_FOLLOW_NONE, 0);
dragBitmap->AddChild(view); dragBitmap->AddChild(view);
view->SetOrigin(0, 0); view->SetOrigin(0, 0);
BRect clipRect(view->Bounds()); BRect clipRect(view->Bounds());
@@ -1358,23 +1394,27 @@ AttributeView::MouseMoved(BPoint point, uint32, const BMessage* message)
view->SetHighColor(0, 0, 0, 0); view->SetHighColor(0, 0, 0, 0);
view->FillRect(view->Bounds()); view->FillRect(view->Bounds());
view->SetDrawingMode(B_OP_ALPHA); view->SetDrawingMode(B_OP_ALPHA);
view->SetHighColor(0, 0, 0, 128); // set the level of transparency by value view->SetHighColor(0, 0, 0, 128);
// set the level of transparency by value
view->SetBlendingMode(B_CONSTANT_ALPHA, B_ALPHA_COMPOSITE); view->SetBlendingMode(B_CONSTANT_ALPHA, B_ALPHA_COMPOSITE);
// Draw the icon // Draw the icon
float hIconOffset = (rect.Width() - fIconRect.Width()) / 2; float hIconOffset = (rect.Width() - fIconRect.Width()) / 2;
IconCache::sIconCache->Draw(fIconModel, view, BPoint(hIconOffset, 0), IconCache::sIconCache->Draw(fIconModel, view,
kNormalIcon, B_LARGE_ICON, true); BPoint(hIconOffset, 0), kNormalIcon, B_LARGE_ICON, true);
// See if we need to truncate the string // See if we need to truncate the string
BString nameString(fModel->Name()); BString nameString(fModel->Name());
if (view->StringWidth(fModel->Name()) > rect.Width()) if (view->StringWidth(fModel->Name()) > rect.Width()) {
view->TruncateString(&nameString, B_TRUNCATE_END, rect.Width() - 5); view->TruncateString(&nameString, B_TRUNCATE_END,
rect.Width() - 5);
}
// Draw the label // Draw the label
font_height fontHeight; font_height fontHeight;
font.GetHeight(&fontHeight); font.GetHeight(&fontHeight);
float leftText = (view->StringWidth(nameString.String()) - fIconRect.Width()) / 2; float leftText = (view->StringWidth(nameString.String())
- fIconRect.Width()) / 2;
view->MovePenTo(BPoint(hIconOffset - leftText + 2, view->MovePenTo(BPoint(hIconOffset - leftText + 2,
fIconRect.Height() + (fontHeight.ascent + 2))); fIconRect.Height() + (fontHeight.ascent + 2)));
view->DrawString(nameString.String()); view->DrawString(nameString.String());
@@ -1391,9 +1431,11 @@ AttributeView::MouseMoved(BPoint point, uint32, const BMessage* message)
message.AddInt32("buttons", (int32)button); message.AddInt32("buttons", (int32)button);
message.AddInt32("be:actions", message.AddInt32("be:actions",
(modifiers() & B_OPTION_KEY) != 0 ? B_COPY_TARGET : B_MOVE_TARGET); (modifiers() & B_OPTION_KEY) != 0
? B_COPY_TARGET : B_MOVE_TARGET);
message.AddRef("refs", fModel->EntryRef()); message.AddRef("refs", fModel->EntryRef());
DragMessage(&message, dragBitmap, B_OP_ALPHA, BPoint((fClickPoint.x - fIconRect.left) DragMessage(&message, dragBitmap, B_OP_ALPHA,
BPoint((fClickPoint.x - fIconRect.left)
+ hIconOffset, fClickPoint.y - fIconRect.top), this); + hIconOffset, fClickPoint.y - fIconRect.top), this);
fDragging = true; fDragging = true;
} }
@@ -1413,47 +1455,57 @@ AttributeView::MouseMoved(BPoint point, uint32, const BMessage* message)
BPoint point; BPoint point;
GetMouse(&point, &buttons); GetMouse(&point, &buttons);
if (Window()->IsActive() && !buttons) { if (Window()->IsActive() && !buttons) {
// If we are down here, then that means that we're tracking the mouse // If we are down here, then that means that we're tracking
// but not from a mouse down. In this case, we're just interested in // the mouse but not from a mouse down. In this case, we're
// knowing whether or not we need to display the "pop-up" version // just interested in knowing whether or not we need to
// of the path or link text. // display the "pop-up" version of the path or link text.
BScreen screen(Window()); BScreen screen(Window());
BFont font; BFont font;
GetFont(&font); GetFont(&font);
font.SetSize(kAttribFontHeight); font.SetSize(kAttribFontHeight);
float maxWidth = (Bounds().Width() - (fDivider + kBorderMargin)); float maxWidth = (Bounds().Width()
- (fDivider + kBorderMargin));
if (fPathRect.Contains(point) if (fPathRect.Contains(point)
&& font.StringWidth(fPathStr.String()) > maxWidth) { && font.StringWidth(fPathStr.String()) > maxWidth) {
fTrackingState = no_track; fTrackingState = no_track;
BRect rect(fPathRect); BRect rect(fPathRect);
rect.OffsetBy(Window()->Frame().left, Window()->Frame().top); rect.OffsetBy(Window()->Frame().left,
Window()->Frame().top);
if (!fPathWindow || BMessenger(fPathWindow).IsValid() == false) { if (!fPathWindow
fPathWindow = OpenToolTipWindow(screen, rect, "fPathWindow", || BMessenger(fPathWindow).IsValid() == false) {
fPathStr.String(), BMessenger(this), fPathWindow = OpenToolTipWindow(screen, rect,
"fPathWindow", fPathStr.String(),
BMessenger(this),
new BMessage(kOpenLinkSource)); new BMessage(kOpenLinkSource));
} }
} else if (fLinkRect.Contains(point) } else if (fLinkRect.Contains(point)
&& font.StringWidth(fLinkToStr.String()) > maxWidth) { && font.StringWidth(fLinkToStr.String()) > maxWidth) {
fTrackingState = no_track; fTrackingState = no_track;
BRect rect(fLinkRect); BRect rect(fLinkRect);
rect.OffsetBy(Window()->Frame().left, Window()->Frame().top); rect.OffsetBy(Window()->Frame().left,
Window()->Frame().top);
if (!fLinkWindow || BMessenger(fLinkWindow).IsValid() == false) { if (!fLinkWindow
fLinkWindow = OpenToolTipWindow(screen, rect, "fLinkWindow", || BMessenger(fLinkWindow).IsValid() == false) {
fLinkToStr.String(), BMessenger(this), fLinkWindow = OpenToolTipWindow(screen, rect,
"fLinkWindow", fLinkToStr.String(),
BMessenger(this),
new BMessage(kOpenLinkTarget)); new BMessage(kOpenLinkTarget));
} }
} else if (fDescRect.Contains(point) } else if (fDescRect.Contains(point)
&& font.StringWidth(fDescStr.String()) > maxWidth) { && font.StringWidth(fDescStr.String()) > maxWidth) {
fTrackingState = no_track; fTrackingState = no_track;
BRect rect(fDescRect); BRect rect(fDescRect);
rect.OffsetBy(Window()->Frame().left, Window()->Frame().top); rect.OffsetBy(Window()->Frame().left,
Window()->Frame().top);
if (!fDescWindow || BMessenger(fDescWindow).IsValid() == false) { if (!fDescWindow
fDescWindow = OpenToolTipWindow(screen, rect, "fDescWindow", || BMessenger(fDescWindow).IsValid() == false) {
fDescStr.String(), BMessenger(this), NULL); fDescWindow = OpenToolTipWindow(screen, rect,
"fDescWindow", fDescStr.String(),
BMessenger(this), NULL);
} }
} }
} }
@@ -1509,12 +1561,13 @@ AttributeView::MouseUp(BPoint point)
} else if (fTrackingState == path_track && fPathRect.Contains(point)) { } else if (fTrackingState == path_track && fPathRect.Contains(point)) {
InvertRect(fPathRect); InvertRect(fPathRect);
OpenLinkSource(); OpenLinkSource();
} else if ((fTrackingState == icon_track || fTrackingState == open_only_track) } else if ((fTrackingState == icon_track
|| fTrackingState == open_only_track)
&& fIconRect.Contains(point)) { && fIconRect.Contains(point)) {
// If it was a double click, then tell Tracker to open the item // If it was a double click, then tell Tracker to open the item
// The CurrentMessage() here does* not* have a "clicks" field, // The CurrentMessage() here does* not* have a "clicks" field,
// which is why we are tracking the clicks with this temp var // which is why we are tracking the clicks with this temp var
if (fDoubleClick){ if (fDoubleClick) {
// Double click, launch. // Double click, launch.
BMessage message(B_REFS_RECEIVED); BMessage message(B_REFS_RECEIVED);
message.AddRef("refs", fModel->EntryRef()); message.AddRef("refs", fModel->EntryRef());
@@ -1580,8 +1633,10 @@ AttributeView::CheckAndSetSize()
StatStruct statBuf; StatStruct statBuf;
BModelOpener opener(fModel); BModelOpener opener(fModel);
if (fModel->InitCheck() != B_OK || fModel->Node()->GetStat(&statBuf) != B_OK) if (fModel->InitCheck() != B_OK
|| fModel->Node()->GetStat(&statBuf) != B_OK) {
return; return;
}
if (fLastSize == statBuf.st_size) if (fLastSize == statBuf.st_size)
return; return;
@@ -1594,7 +1649,8 @@ AttributeView::CheckAndSetSize()
BRect bounds(Bounds()); BRect bounds(Bounds());
float lineHeight = CurrentFontHeight() + 2; float lineHeight = CurrentFontHeight() + 2;
bounds.Set(fDivider, fIconRect.bottom, bounds.right, fIconRect.bottom + lineHeight); bounds.Set(fDivider, fIconRect.bottom, bounds.right,
fIconRect.bottom + lineHeight);
Invalidate(bounds); Invalidate(bounds);
} }
@@ -1606,8 +1662,10 @@ AttributeView::MessageReceived(BMessage* message)
&& message->what == B_SIMPLE_DATA && message->what == B_SIMPLE_DATA
&& message->ReturnAddress() != BMessenger(this) && message->ReturnAddress() != BMessenger(this)
&& fIconRect.Contains(ConvertFromScreen(message->DropPoint())) && fIconRect.Contains(ConvertFromScreen(message->DropPoint()))
&& BPoseView::CanHandleDragSelection(fModel, message, (modifiers() & B_CONTROL_KEY) != 0)) { && BPoseView::CanHandleDragSelection(fModel, message,
BPoseView::HandleDropCommon(message, fModel, 0, this, message->DropPoint()); (modifiers() & B_CONTROL_KEY) != 0)) {
BPoseView::HandleDropCommon(message, fModel, 0, this,
message->DropPoint());
Invalidate(fIconRect); Invalidate(fIconRect);
return; return;
} }
@@ -1679,7 +1737,8 @@ AttributeView::Draw(BRect)
MovePenTo(BPoint(fIconRect.right + 6, lineBase)); MovePenTo(BPoint(fIconRect.right + 6, lineBase));
// Recalculate the rect width // Recalculate the rect width
fTitleRect.right = min_c(fTitleRect.left + currentFont.StringWidth(fModel->Name()), fTitleRect.right = min_c(
fTitleRect.left + currentFont.StringWidth(fModel->Name()),
Bounds().Width() - 5); Bounds().Width() - 5);
// Check for possible need of truncation // Check for possible need of truncation
if (StringWidth(fModel->Name()) > fTitleRect.Width()) { if (StringWidth(fModel->Name()) > fTitleRect.Width()) {
@@ -1718,12 +1777,14 @@ AttributeView::Draw(BRect)
MovePenTo(BPoint(fDivider + kDrawMargin, lineBase)); MovePenTo(BPoint(fDivider + kDrawMargin, lineBase));
SetHighColor(kAttrValueColor); SetHighColor(kAttrValueColor);
// Check for possible need of truncation // Check for possible need of truncation
if (StringWidth(fSizeStr.String()) > (Bounds().Width() - (fDivider + kBorderMargin))) { if (StringWidth(fSizeStr.String())
> (Bounds().Width() - (fDivider + kBorderMargin))) {
BString tmpString(fSizeStr.String()); BString tmpString(fSizeStr.String());
TruncateString(&tmpString, B_TRUNCATE_MIDDLE, TruncateString(&tmpString, B_TRUNCATE_MIDDLE,
Bounds().Width() - (fDivider + kBorderMargin)); Bounds().Width() - (fDivider + kBorderMargin));
DrawString(tmpString.String()); DrawString(tmpString.String());
fSizeRect.right = fSizeRect.left + StringWidth(tmpString.String()) + 3; fSizeRect.right = fSizeRect.left + StringWidth(tmpString.String())
+ 3;
} else { } else {
DrawString(fSizeStr.String()); DrawString(fSizeStr.String());
fSizeRect.right = fSizeRect.left + StringWidth(fSizeStr.String()) + 3; fSizeRect.right = fSizeRect.left + StringWidth(fSizeStr.String()) + 3;
@@ -1752,7 +1813,8 @@ AttributeView::Draw(BRect)
lineBase += lineHeight; lineBase += lineHeight;
// Kind // Kind
MovePenTo(BPoint(fDivider - (StringWidth(B_TRANSLATE("Kind:"))), lineBase)); MovePenTo(BPoint(fDivider - (StringWidth(B_TRANSLATE("Kind:"))),
lineBase));
SetHighColor(kAttrTitleColor); SetHighColor(kAttrTitleColor);
DrawString(B_TRANSLATE("Kind:")); DrawString(B_TRANSLATE("Kind:"));
MovePenTo(BPoint(fDivider + kDrawMargin, lineBase)); MovePenTo(BPoint(fDivider + kDrawMargin, lineBase));
@@ -1773,7 +1835,8 @@ AttributeView::Draw(BRect)
SetHighColor(kLinkColor); SetHighColor(kLinkColor);
// Check for truncation // Check for truncation
if (StringWidth(fPathStr.String()) > (Bounds().Width() - (fDivider + kBorderMargin))) { if (StringWidth(fPathStr.String()) > (Bounds().Width()
- (fDivider + kBorderMargin))) {
BString nameString(fPathStr.String()); BString nameString(fPathStr.String());
TruncateString(&nameString, B_TRUNCATE_MIDDLE, TruncateString(&nameString, B_TRUNCATE_MIDDLE,
Bounds().Width() - (fDivider + kBorderMargin)); Bounds().Width() - (fDivider + kBorderMargin));
@@ -1799,7 +1862,8 @@ AttributeView::Draw(BRect)
SetHighColor(kLinkColor); SetHighColor(kLinkColor);
// Check for truncation // Check for truncation
if (StringWidth(fLinkToStr.String()) > (Bounds().Width() - (fDivider + kBorderMargin))) { if (StringWidth(fLinkToStr.String()) > (Bounds().Width()
- (fDivider + kBorderMargin))) {
BString nameString(fLinkToStr.String()); BString nameString(fLinkToStr.String());
TruncateString(&nameString, B_TRUNCATE_MIDDLE, TruncateString(&nameString, B_TRUNCATE_MIDDLE,
Bounds().Width() - (fDivider + kBorderMargin)); Bounds().Width() - (fDivider + kBorderMargin));
@@ -1811,7 +1875,8 @@ AttributeView::Draw(BRect)
fLinkRect.top = lineBase - fontMetrics.ascent; fLinkRect.top = lineBase - fontMetrics.ascent;
fLinkRect.bottom = lineBase + fontMetrics.descent; fLinkRect.bottom = lineBase + fontMetrics.descent;
fLinkRect.left = fDivider + 2; fLinkRect.left = fDivider + 2;
fLinkRect.right = fLinkRect.left + StringWidth(fLinkToStr.String()) + 3; fLinkRect.right = fLinkRect.left + StringWidth(fLinkToStr.String())
+ 3;
// No description field // No description field
fDescRect = BRect(-1, -1, -1, -1); fDescRect = BRect(-1, -1, -1, -1);
@@ -1838,7 +1903,8 @@ AttributeView::Draw(BRect)
MovePenTo(BPoint(fDivider + kDrawMargin, lineBase)); MovePenTo(BPoint(fDivider + kDrawMargin, lineBase));
SetHighColor(kAttrValueColor); SetHighColor(kAttrValueColor);
// Check for truncation // Check for truncation
if (StringWidth(fDescStr.String()) > (Bounds().Width() - (fDivider + kBorderMargin))) { if (StringWidth(fDescStr.String()) > (Bounds().Width()
- (fDivider + kBorderMargin))) {
BString nameString(fDescStr.String()); BString nameString(fDescStr.String());
TruncateString(&nameString, B_TRUNCATE_MIDDLE, TruncateString(&nameString, B_TRUNCATE_MIDDLE,
Bounds().Width() - (fDivider + kBorderMargin)); Bounds().Width() - (fDivider + kBorderMargin));
@@ -1873,8 +1939,9 @@ AttributeView::BeginEditingTitle()
textRect.OffsetTo(0, 0); textRect.OffsetTo(0, 0);
textRect.InsetBy(1, 1); textRect.InsetBy(1, 1);
// Just make it some really large size, since we don't do any line wrapping. // Just make it some really large size, since we don't do any line
// The text filter will make sure to scroll the cursor into position // wrapping. The text filter will make sure to scroll the cursor
// into position
textRect.right = 2000; textRect.right = 2000;
fTitleEditView = new BTextView(textFrame, "text_editor", fTitleEditView = new BTextView(textFrame, "text_editor",
@@ -1911,7 +1978,8 @@ AttributeView::FinishEditingTitle(bool commit)
const char* text = fTitleEditView->Text(); const char* text = fTitleEditView->Text();
uint32 length = strlen(text); uint32 length = strlen(text);
if (commit && strcmp(text, fModel->Name()) != 0 && length < B_FILE_NAME_LENGTH) { if (commit && strcmp(text, fModel->Name()) != 0
&& length < B_FILE_NAME_LENGTH) {
BEntry entry(fModel->EntryRef()); BEntry entry(fModel->EntryRef());
BDirectory parent; BDirectory parent;
if (entry.InitCheck() == B_OK if (entry.InitCheck() == B_OK
@@ -1936,7 +2004,8 @@ AttributeView::FinishEditingTitle(bool commit)
GetFont(&currentFont); GetFont(&currentFont);
currentFont.SetSize(kTitleFontHeight); currentFont.SetSize(kTitleFontHeight);
fTitleRect.right = min_c(fTitleRect.left fTitleRect.right = min_c(fTitleRect.left
+ currentFont.StringWidth(fTitleEditView->Text()), Bounds().Width() - 5); + currentFont.StringWidth(fTitleEditView->Text()),
Bounds().Width() - 5);
} }
} }
} else if (length >= B_FILE_NAME_LENGTH) { } else if (length >= B_FILE_NAME_LENGTH) {
@@ -2081,12 +2150,14 @@ AttributeView::BuildContextMenu(BMenu* parent)
BMenuItem* sizeItem = NULL; BMenuItem* sizeItem = NULL;
if (model.IsDirectory() && !model.IsVolume() && !model.IsRoot()) { if (model.IsDirectory() && !model.IsVolume() && !model.IsRoot()) {
parent->AddItem(sizeItem = new BMenuItem(B_TRANSLATE("Recalculate folder size"), parent->AddItem(sizeItem
= new BMenuItem(B_TRANSLATE("Recalculate folder size"),
new BMessage(kRecalculateSize))); new BMessage(kRecalculateSize)));
} }
if (model.IsSymLink()) { if (model.IsSymLink()) {
parent->AddItem(sizeItem = new BMenuItem(B_TRANSLATE("Set new link target"), parent->AddItem(sizeItem
= new BMenuItem(B_TRANSLATE("Set new link target"),
new BMessage(kSetLinkTarget))); new BMessage(kSetLinkTarget)));
} }
@@ -2116,7 +2187,8 @@ AttributeView::SetPermissionsSwitchState(int32 state)
filter_result filter_result
AttributeView::TextViewFilter(BMessage* message, BHandler**, BMessageFilter* filter) AttributeView::TextViewFilter(BMessage* message, BHandler**,
BMessageFilter* filter)
{ {
uchar key; uchar key;
AttributeView* attribView = static_cast<AttributeView*>( AttributeView* attribView = static_cast<AttributeView*>(
@@ -2162,7 +2234,8 @@ AttributeView::SetSizeStr(const char* sizeStr)
BRect bounds(Bounds()); BRect bounds(Bounds());
float lineHeight = CurrentFontHeight(kAttribFontHeight) + 6; float lineHeight = CurrentFontHeight(kAttribFontHeight) + 6;
bounds.Set(fDivider, fIconRect.bottom, bounds.right, fIconRect.bottom + lineHeight); bounds.Set(fDivider, fIconRect.bottom, bounds.right,
fIconRect.bottom + lineHeight);
Invalidate(bounds); Invalidate(bounds);
} }
@@ -2171,7 +2244,8 @@ AttributeView::SetSizeStr(const char* sizeStr)
TrackingView::TrackingView(BRect frame, const char* str, BMessage* message) TrackingView::TrackingView(BRect frame, const char* str, BMessage* message)
: BControl(frame, "trackingView", str, message, B_FOLLOW_ALL, B_WILL_DRAW), : BControl(frame, "trackingView", str, message, B_FOLLOW_ALL,
B_WILL_DRAW),
fMouseDown(false), fMouseDown(false),
fMouseInView(false) fMouseInView(false)
{ {
+2 -3
View File
@@ -77,7 +77,8 @@ ShortMimeInfo::ShortDescription() const
} }
int int
ShortMimeInfo::CompareShortDescription(const ShortMimeInfo* a, const ShortMimeInfo* b) ShortMimeInfo::CompareShortDescription(const ShortMimeInfo* a,
const ShortMimeInfo* b)
{ {
return a->fShortDescription.ICompare(b->fShortDescription); return a->fShortDescription.ICompare(b->fShortDescription);
} }
@@ -160,5 +161,3 @@ MimeTypeList::Build()
fCommonMimeList.SortItems(&ShortMimeInfo::CompareShortDescription); fCommonMimeList.SortItems(&ShortMimeInfo::CompareShortDescription);
fLock.Unlock(); fLock.Unlock();
} }
+52 -36
View File
@@ -270,8 +270,8 @@ Model::SetTo(const entry_ref* newRef, bool traverse, bool open, bool writable)
status_t status_t
Model::SetTo(const node_ref* dirNode, const node_ref* nodeRef, const char* name, Model::SetTo(const node_ref* dirNode, const node_ref* nodeRef,
bool open, bool writable) const char* name, bool open, bool writable)
{ {
delete fNode; delete fNode;
fNode = NULL; fNode = NULL;
@@ -425,7 +425,8 @@ Model::OpenNodeCommon(bool writable)
case kQueryTemplateNode: case kQueryTemplateNode:
// open or reopen // open or reopen
delete fNode; delete fNode;
fNode = new BFile(&fEntryRef, (uint32)(writable ? O_RDWR : O_RDONLY)); fNode = new BFile(&fEntryRef,
(uint32)(writable ? O_RDWR : O_RDONLY));
break; break;
case kDirectoryNode: case kDirectoryNode:
@@ -455,11 +456,12 @@ Model::OpenNodeCommon(bool writable)
PrintToStream(); PrintToStream();
#endif #endif
TRESPASS(); TRESPASS();
// this can only happen if GetStat failed before, in which case // this can only happen if GetStat failed before,
// we shouldn't be here // in which case we shouldn't be here
// ToDo: Obviously, we can also be here if the type could not be determined,
// for example for block devices (so the TRESPASS() macro shouldn't be // ToDo: Obviously, we can also be here if the type could not
// used here)! // be determined, for example for block devices (so the TRESPASS()
// macro shouldn't be used here)!
return fStatus = B_ERROR; return fStatus = B_ERROR;
} }
@@ -598,11 +600,12 @@ Model::FinishSettingUpType()
&& fBaseType != kLinkNode && fBaseType != kLinkNode
&& !CheckNodeIconHintPrivate(fNode, dynamic_cast<TTracker*>(be_app) == NULL) && !CheckNodeIconHintPrivate(fNode, dynamic_cast<TTracker*>(be_app) == NULL)
&& !HasVectorIconHint(fNode)) { && !HasVectorIconHint(fNode)) {
// when checking for the node icon hint, if we are libtracker, only check // when checking for the node icon hint, if we are libtracker,
// for small icons - checking for the large icons is a little more // only check for small icons - checking for the large icons
// work for the filesystem and this will speed up the test. // is a little more work for the filesystem and this will
// This makes node icons only work if there is a small and a large node // speed up the test. This makes node icons only work if there
// icon on a file - for libtracker that is not a problem though // is a small and a large node icon on a file - for libtracker
// that is not a problem though
fIconFrom = kUnknownNotFromNode; fIconFrom = kUnknownNotFromNode;
} }
@@ -648,9 +651,11 @@ Model::FinishSettingUpType()
fMimeType = mimeString; fMimeType = mimeString;
if (fIconFrom == kUnknownNotFromNode if (fIconFrom == kUnknownNotFromNode
&& WellKnowEntryList::Match(NodeRef()) > (directory_which)-1) && WellKnowEntryList::Match(NodeRef())
> (directory_which)-1) {
// one of home, beos, system, boot, etc. // one of home, beos, system, boot, etc.
fIconFrom = kTrackerSupplied; fIconFrom = kTrackerSupplied;
}
} }
break; break;
@@ -695,9 +700,8 @@ Model::FinishSettingUpType()
case kExecutableNode: case kExecutableNode:
if (IsNodeOpen()) { if (IsNodeOpen()) {
char signature[B_MIME_TYPE_LENGTH]; char signature[B_MIME_TYPE_LENGTH];
if (GetAppSignatureFromAttr(dynamic_cast<BFile*>(fNode), signature) if (GetAppSignatureFromAttr(dynamic_cast<BFile*>(fNode),
== B_OK) { signature) == B_OK) {
if (fPreferredAppName) if (fPreferredAppName)
DeletePreferredAppVolumeNameLinkTo(); DeletePreferredAppVolumeNameLinkTo();
@@ -706,7 +710,8 @@ Model::FinishSettingUpType()
} }
} }
if (!fMimeType.Length()) if (!fMimeType.Length())
fMimeType = B_APP_MIME_TYPE; // should use a shared string here fMimeType = B_APP_MIME_TYPE;
// should use a shared string here
break; break;
default: default:
@@ -728,7 +733,8 @@ Model::ResetIconFrom()
// mirror the logic from FinishSettingUpType // mirror the logic from FinishSettingUpType
if ((fBaseType == kDirectoryNode || fBaseType == kVolumeNode if ((fBaseType == kDirectoryNode || fBaseType == kVolumeNode
|| fBaseType == kTrashNode || fBaseType == kDesktopNode) || fBaseType == kTrashNode || fBaseType == kDesktopNode)
&& !CheckNodeIconHintPrivate(fNode, dynamic_cast<TTracker*>(be_app) == NULL)) { && !CheckNodeIconHintPrivate(fNode,
dynamic_cast<TTracker*>(be_app) == NULL)) {
if (WellKnowEntryList::Match(NodeRef()) > (directory_which)-1) { if (WellKnowEntryList::Match(NodeRef()) > (directory_which)-1) {
fIconFrom = kTrackerSupplied; fIconFrom = kTrackerSupplied;
return; return;
@@ -813,7 +819,8 @@ Model::GetPreferredAppForBrokenSymLink(BString &result)
BModelOpener opener(this); BModelOpener opener(this);
BNodeInfo info(fNode); BNodeInfo info(fNode);
status_t error = info.GetPreferredApp(result.LockBuffer(B_MIME_TYPE_LENGTH)); status_t error
= info.GetPreferredApp(result.LockBuffer(B_MIME_TYPE_LENGTH));
result.UnlockBuffer(); result.UnlockBuffer();
if (error != B_OK) if (error != B_OK)
@@ -1078,9 +1085,10 @@ Model::SupportsMimeType(const char* type, const BObjectList<BString>* list,
const char* mimeSignature; const char* mimeSignature;
int32 bufferLength; int32 bufferLength;
if (message.FindData("types", 'CSTR', index, (const void**)&mimeSignature, if (message.FindData("types", 'CSTR', index,
&bufferLength)) (const void**)&mimeSignature, &bufferLength)) {
return result; return result;
}
if (IsSuperHandlerSignature(mimeSignature)) { if (IsSuperHandlerSignature(mimeSignature)) {
if (!exactReason) if (!exactReason)
@@ -1098,7 +1106,8 @@ Model::SupportsMimeType(const char* type, const BObjectList<BString>* list,
} else } else
match = WhileEachListItem(const_cast<BObjectList<BString>*>(list), match = WhileEachListItem(const_cast<BObjectList<BString>*>(list),
MatchMimeTypeString, mimeSignature); MatchMimeTypeString, mimeSignature);
// const_cast shouldnt be here, have to have it until MW cleans up // const_cast shouldnt be here, have to have it until
// MW cleans up
if (match == kMatch) if (match == kMatch)
// supports the actual type, it can't get any better // supports the actual type, it can't get any better
@@ -1150,9 +1159,10 @@ Model::IsSuperHandler() const
const char* mimeSignature; const char* mimeSignature;
int32 bufferLength; int32 bufferLength;
if (message.FindData("types", 'CSTR', index, (const void**)&mimeSignature, if (message.FindData("types", 'CSTR', index,
&bufferLength)) (const void**)&mimeSignature, &bufferLength)) {
return false; return false;
}
if (IsSuperHandlerSignature(mimeSignature)) if (IsSuperHandlerSignature(mimeSignature))
return true; return true;
@@ -1261,7 +1271,8 @@ Model::GetVersionString(BString &result, version_kind kind)
return error; return error;
char vstr[32]; char vstr[32];
sprintf(vstr, "%ld.%ld.%ld", version.major, version.middle, version.minor); sprintf(vstr, "%ld.%ld.%ld", version.major, version.middle,
version.minor);
result = vstr; result = vstr;
return B_OK; return B_OK;
} }
@@ -1271,8 +1282,8 @@ Model::GetVersionString(BString &result, version_kind kind)
void void
Model::PrintToStream(int32 level, bool deep) Model::PrintToStream(int32 level, bool deep)
{ {
PRINT(("model name %s, entry name %s, inode %" B_PRIdINO ", dev %" B_PRIdDEV PRINT(("model name %s, entry name %s, inode %" B_PRIdINO ", dev %"
", directory inode %" B_PRIdINO "\n", B_PRIdDEV ", directory inode %" B_PRIdINO "\n",
Name() ? Name() : "**empty name**", Name() ? Name() : "**empty name**",
EntryRef()->name ? EntryRef()->name : "**empty ref name**", EntryRef()->name ? EntryRef()->name : "**empty ref name**",
NodeRef()->node, NodeRef()->node,
@@ -1324,8 +1335,10 @@ Model::PrintToStream(int32 level, bool deep)
if (level < 1) if (level < 1)
return; return;
if (!IsVolume()) if (!IsVolume()) {
PRINT(("preferred app %s\n", fPreferredAppName ? fPreferredAppName : "")); PRINT(("preferred app %s\n",
fPreferredAppName ? fPreferredAppName : ""));
}
PRINT(("icon from: ")); PRINT(("icon from: "));
switch (IconFrom()) { switch (IconFrom()) {
@@ -1426,8 +1439,9 @@ Model::TrackIconSource(icon_size size)
BMimeType preferredAppType(preferredApp); BMimeType preferredAppType(preferredApp);
err = preferredAppType.GetIconForType(MimeType(), &bitmap, size); err = preferredAppType.GetIconForType(MimeType(), &bitmap, size);
if (err == B_OK) { if (err == B_OK) {
PRINT(("track icon - got icon for type %s from preferred app %s for file\n", PRINT(
MimeType(), preferredApp)); ("track icon - got icon for type %s from preferred "
"app %s for file\n", MimeType(), preferredApp));
return; return;
} }
} }
@@ -1453,12 +1467,14 @@ Model::TrackIconSource(icon_size size)
err = preferredAppType.GetIconForType(MimeType(), &bitmap, size); err = preferredAppType.GetIconForType(MimeType(), &bitmap, size);
if (err == B_OK) { if (err == B_OK) {
// the preferred app knew icon to use for the type, we are done // the preferred app knew icon to use for the type, we are done
PRINT(("track icon - signature %s, got icon from preferred app %s\n", PRINT(
MimeType(), preferredApp)); ("track icon - signature %s, got icon from preferred "
"app %s\n", MimeType(), preferredApp));
return; return;
} }
PRINT(("track icon - signature %s, preferred app %s, no icon, error %s\n", PRINT(
MimeType(), preferredApp, strerror(err))); ("track icon - signature %s, preferred app %s, no icon, "
"error %s\n", MimeType(), preferredApp, strerror(err)));
} }
} }
+22 -16
View File
@@ -88,11 +88,12 @@ class Model {
status_t InitCheck() const; status_t InitCheck() const;
status_t SetTo(const BEntry*, bool open = false, bool writable = false); status_t SetTo(const BEntry*, bool open = false,
status_t SetTo(const entry_ref*, bool traverse = false, bool open = false,
bool writable = false); bool writable = false);
status_t SetTo(const node_ref* dirNode, const node_ref* node, const char* name, status_t SetTo(const entry_ref*, bool traverse = false,
bool open = false, bool writable = false); bool open = false, bool writable = false);
status_t SetTo(const node_ref* dirNode, const node_ref* node,
const char* name, bool open = false, bool writable = false);
int CompareFolderNamesFirst(const Model* compareModel) const; int CompareFolderNamesFirst(const Model* compareModel) const;
@@ -124,9 +125,9 @@ class Model {
void SetPreferredAppSignature(const char*); void SetPreferredAppSignature(const char*);
void GetPreferredAppForBrokenSymLink(BString &result); void GetPreferredAppForBrokenSymLink(BString &result);
// special purpose call - if a symlink is unresolvable, it makes sense // special purpose call - if a symlink is unresolvable, it makes
// to be able to get at it's preferred handler which may be different // sense to be able to get at it's preferred handler which may be
// from the Tracker. Used by the network neighborhood. // different from the Tracker. Used by the network neighborhood.
// type getters // type getters
bool IsFile() const; bool IsFile() const;
@@ -159,8 +160,8 @@ class Model {
status_t GetLongVersionString(BString &, version_kind); status_t GetLongVersionString(BString &, version_kind);
status_t GetVersionString(BString &, version_kind); status_t GetVersionString(BString &, version_kind);
status_t AttrAsString(BString &, int64* value, const char* attributeName, status_t AttrAsString(BString &, int64* value,
uint32 attributeType); const char* attributeName, uint32 attributeType);
// Node monitor update call // Node monitor update call
void UpdateEntryRef(const node_ref* dirRef, const char* name); void UpdateEntryRef(const node_ref* dirRef, const char* name);
@@ -189,8 +190,8 @@ class Model {
#endif #endif
bool IsSuperHandler() const; bool IsSuperHandler() const;
int32 SupportsMimeType(const char* type, const BObjectList<BString>* list, int32 SupportsMimeType(const char* type,
bool exactReason = false) const; const BObjectList<BString>* list, bool exactReason = false) const;
// pass in one string in <type> or a bunch in <list> // pass in one string in <type> or a bunch in <list>
// if <exactReason> false, returns as soon as it figures out that // if <exactReason> false, returns as soon as it figures out that
// app supports a given type, if true, returns an exact reason // app supports a given type, if true, returns an exact reason
@@ -200,8 +201,9 @@ class Model {
const void* buffer, size_t ); const void* buffer, size_t );
// cover call, creates a writable node and writes out attributes // cover call, creates a writable node and writes out attributes
// into it; work around for file nodes not being writeable // into it; work around for file nodes not being writeable
ssize_t WriteAttrKillForeign(const char* attr, const char* foreignAttr, ssize_t WriteAttrKillForeign(const char* attr,
type_code type, off_t, const void* buffer, size_t); const char* foreignAttr, type_code type, off_t,
const void* buffer, size_t);
bool Mimeset(bool force); bool Mimeset(bool force);
// returns true if mime type changed // returns true if mime type changed
@@ -242,11 +244,13 @@ class Model {
entry_ref fEntryRef; entry_ref fEntryRef;
StatStruct fStatBuf; StatStruct fStatBuf;
BString fMimeType; // should use string that may be shared for common types BString fMimeType;
// should use string that may be shared for common types
// bit of overloading hackery here to save on footprint // bit of overloading hackery here to save on footprint
union { union {
char* fPreferredAppName; // used if we are neither a volume nor a symlink char* fPreferredAppName; // used if we are neither a volume
// nor a symlink
char* fVolumeName; // used if we are a volume char* fVolumeName; // used if we are a volume
Model* fLinkTo; // used if we are a symlink Model* fLinkTo; // used if we are a symlink
}; };
@@ -267,7 +271,8 @@ class ModelNodeLazyOpener {
public: public:
// consider failing when open does not succeed // consider failing when open does not succeed
ModelNodeLazyOpener(Model* model, bool writable = false, bool openLater = true); ModelNodeLazyOpener(Model* model, bool writable = false,
bool openLater = true);
~ModelNodeLazyOpener(); ~ModelNodeLazyOpener();
bool IsOpen() const; bool IsOpen() const;
@@ -463,7 +468,8 @@ Model::HasLocalizedName() const
inline inline
ModelNodeLazyOpener::ModelNodeLazyOpener(Model* model, bool writable, bool openLater) ModelNodeLazyOpener::ModelNodeLazyOpener(Model* model, bool writable,
bool openLater)
: fModel(model), : fModel(model),
fWasOpen(model->IsNodeOpen()), fWasOpen(model->IsNodeOpen()),
fWasOpenForWriting(model->IsNodeOpenForWriting()) fWasOpenForWriting(model->IsNodeOpenForWriting())
+38 -22
View File
@@ -58,8 +58,8 @@ static const int32 kMaxHistory = 32;
static BPicture sPicture; static BPicture sPicture;
BNavigatorButton::BNavigatorButton(BRect rect, const char* name, BMessage* message, BNavigatorButton::BNavigatorButton(BRect rect, const char* name,
int32 resIDon, int32 resIDoff, int32 resIDdisabled) BMessage* message, int32 resIDon, int32 resIDoff, int32 resIDdisabled)
: BPictureButton(rect, name, &sPicture, &sPicture, message), : BPictureButton(rect, name, &sPicture, &sPicture, message),
fResIDOn(resIDon), fResIDOn(resIDon),
fResIDOff(resIDoff), fResIDOff(resIDoff),
@@ -81,17 +81,20 @@ void
BNavigatorButton::AttachedToWindow() BNavigatorButton::AttachedToWindow()
{ {
BBitmap* bmpOn = 0; BBitmap* bmpOn = 0;
GetTrackerResources()->GetBitmapResource(B_MESSAGE_TYPE, fResIDOn, &bmpOn); GetTrackerResources()->GetBitmapResource(B_MESSAGE_TYPE, fResIDOn,
&bmpOn);
SetPicture(bmpOn, true, true); SetPicture(bmpOn, true, true);
delete bmpOn; delete bmpOn;
BBitmap* bmpOff = 0; BBitmap* bmpOff = 0;
GetTrackerResources()->GetBitmapResource(B_MESSAGE_TYPE, fResIDOff, &bmpOff); GetTrackerResources()->GetBitmapResource(B_MESSAGE_TYPE, fResIDOff,
&bmpOff);
SetPicture(bmpOff, true, false); SetPicture(bmpOff, true, false);
delete bmpOff; delete bmpOff;
BBitmap* bmpDisabled = 0; BBitmap* bmpDisabled = 0;
GetTrackerResources()->GetBitmapResource(B_MESSAGE_TYPE, fResIDDisabled, &bmpDisabled); GetTrackerResources()->GetBitmapResource(B_MESSAGE_TYPE, fResIDDisabled,
&bmpDisabled);
SetPicture(bmpDisabled, false, false); SetPicture(bmpDisabled, false, false);
SetPicture(bmpDisabled, false, true); SetPicture(bmpDisabled, false, true);
delete bmpDisabled; delete bmpDisabled;
@@ -197,8 +200,10 @@ BNavigator::Draw(BRect)
// Draws a beveled smooth border // Draws a beveled smooth border
BeginLineArray(4); BeginLineArray(4);
AddLine(Bounds().LeftTop(), Bounds().RightTop(), shineColor); AddLine(Bounds().LeftTop(), Bounds().RightTop(), shineColor);
AddLine(Bounds().LeftTop(), Bounds().LeftBottom() - BPoint(0, 1), shineColor); AddLine(Bounds().LeftTop(), Bounds().LeftBottom() - BPoint(0, 1),
AddLine(Bounds().LeftBottom() - BPoint(-1, 1), Bounds().RightBottom() - BPoint(0, 1), halfDarkColor); shineColor);
AddLine(Bounds().LeftBottom() - BPoint(-1, 1),
Bounds().RightBottom() - BPoint(0, 1), halfDarkColor);
AddLine(Bounds().LeftBottom(), Bounds().RightBottom(), darkColor); AddLine(Bounds().LeftBottom(), Bounds().RightBottom(), darkColor);
EndLineArray(); EndLineArray();
} }
@@ -275,14 +280,17 @@ BNavigator::GoUp(bool option)
BEntry entry; BEntry entry;
if (entry.SetTo(fPath.Path()) == B_OK) { if (entry.SetTo(fPath.Path()) == B_OK) {
BEntry parentEntry; BEntry parentEntry;
if (entry.GetParent(&parentEntry) == B_OK && !FSIsDeskDir(&parentEntry)) if (entry.GetParent(&parentEntry) == B_OK
&& !FSIsDeskDir(&parentEntry)) {
SendNavigationMessage(kActionUp, &parentEntry, option); SendNavigationMessage(kActionUp, &parentEntry, option);
}
} }
} }
void void
BNavigator::SendNavigationMessage(NavigationAction action, BEntry* entry, bool option) BNavigator::SendNavigationMessage(NavigationAction action, BEntry* entry,
bool option)
{ {
entry_ref ref; entry_ref ref;
@@ -298,26 +306,33 @@ BNavigator::SendNavigationMessage(NavigationAction action, BEntry* entry, bool o
else else
nodeRef = NULL; nodeRef = NULL;
// if the option key was held down, open in new window (send message to be_app) // if the option key was held down, open in new window (send message
// otherwise send message to this window. TTracker (be_app) understands nodeRefToSlection, // to be_app) otherwise send message to this window. TTracker
// BContainerWindow doesn't, so we have to select the item manually // (be_app) understands nodeRefToSlection, BContainerWindow doesn't,
// so we have to select the item manually
if (option) { if (option) {
message.what = B_REFS_RECEIVED; message.what = B_REFS_RECEIVED;
if (nodeRef) if (nodeRef) {
message.AddData("nodeRefToSelect", B_RAW_TYPE, nodeRef, sizeof(node_ref)); message.AddData("nodeRefToSelect", B_RAW_TYPE, nodeRef,
sizeof(node_ref));
}
be_app->PostMessage(&message); be_app->PostMessage(&message);
} else { } else {
message.what = kSwitchDirectory; message.what = kSwitchDirectory;
Window()->PostMessage(&message); Window()->PostMessage(&message);
UnlockLooper(); UnlockLooper();
// This is to prevent a dead-lock situation. SelectChildInParentSoon() // This is to prevent a dead-lock situation.
// eventually locks the TaskLoop::fLock. Later, when StandAloneTaskLoop::Run() // SelectChildInParentSoon() eventually locks the
// runs, it also locks TaskLoop::fLock and subsequently locks this window's looper. // TaskLoop::fLock. Later, when StandAloneTaskLoop::Run()
// Therefore we can't call SelectChildInParentSoon with our Looper locked, // runs, it also locks TaskLoop::fLock and subsequently
// because we would get different orders of locking (thus the risk of dead-locking). // locks this window's looper. Therefore we can't call
// SelectChildInParentSoon with our Looper locked,
// because we would get different orders of locking
// (thus the risk of dead-locking).
// //
// Todo: Change the locking behaviour of StandAloneTaskLoop::Run() and sub- // Todo: Change the locking behaviour of
// sequently called functions. // StandAloneTaskLoop::Run() and subsequently called
// functions.
if (nodeRef) if (nodeRef)
dynamic_cast<TTracker*>(be_app)->SelectChildInParentSoon(&ref, nodeRef); dynamic_cast<TTracker*>(be_app)->SelectChildInParentSoon(&ref, nodeRef);
LockLooper(); LockLooper();
@@ -387,7 +402,8 @@ BNavigator::UpdateLocation(const Model* newmodel, int32 action)
BEntry entry; BEntry entry;
if (entry.SetTo(fPath.Path()) == B_OK) { if (entry.SetTo(fPath.Path()) == B_OK) {
BEntry parentEntry; BEntry parentEntry;
fUp->SetEnabled(entry.GetParent(&parentEntry) == B_OK && !FSIsDeskDir(&parentEntry)); fUp->SetEnabled(entry.GetParent(&parentEntry) == B_OK
&& !FSIsDeskDir(&parentEntry));
} }
// Enable history buttons if history contains something // Enable history buttons if history contains something
+14 -9
View File
@@ -1433,8 +1433,8 @@ SearchForSignatureEntryList::Relation(const BMessage* entriesToOpen,
void void
SearchForSignatureEntryList::RelationDescription(const BMessage* entriesToOpen, SearchForSignatureEntryList::RelationDescription(const BMessage* entriesToOpen,
const Model* applicationModel, BString* description, const entry_ref* preferredApp, const Model* applicationModel, BString* description,
const entry_ref* preferredAppForFile) const entry_ref* preferredApp, const entry_ref* preferredAppForFile)
{ {
for (int32 index = 0; ;index++) { for (int32 index = 0; ;index++) {
entry_ref ref; entry_ref ref;
@@ -1482,10 +1482,11 @@ SearchForSignatureEntryList::RelationDescription(const BMessage* entriesToOpen,
{ {
mimeType.SetTo(model.MimeType()); mimeType.SetTo(model.MimeType());
if (preferredApp && *applicationModel->EntryRef() == *preferredApp) if (preferredApp
&& *applicationModel->EntryRef() == *preferredApp) {
// application matches cached preferred app, we are done // application matches cached preferred app, we are done
description->SetTo(B_TRANSLATE("Preferred for %type")); description->SetTo(B_TRANSLATE("Preferred for %type"));
else } else
description->SetTo(B_TRANSLATE("Handles %type")); description->SetTo(B_TRANSLATE("Handles %type"));
char shortDescription[256]; char shortDescription[256];
@@ -1543,7 +1544,9 @@ SearchForSignatureEntryList::CanOpenWithFilter(const Model* appModel,
BEntry entry2(&trackerInfo.ref); BEntry entry2(&trackerInfo.ref);
entry2.GetPath(&path2); entry2.GetPath(&path2);
PRINT(("filtering out %s, sig %s, active Tracker at %s, result %s, refName %s\n", PRINT(
("filtering out %s, sig %s, active Tracker at %s, "
"result %s, refName %s\n",
path.Path(), signature, path2.Path(), strerror(result), path.Path(), signature, path2.Path(), strerror(result),
trackerInfo.ref.name)); trackerInfo.ref.name));
#endif #endif
@@ -1583,7 +1586,8 @@ SearchForSignatureEntryList::CanOpenWithFilter(const Model* appModel,
return false; return false;
} }
if (relation != kNoRelation && relation != kSuperhandler && !fGenericFilesOnly) { if (relation != kNoRelation && relation != kSuperhandler
&& !fGenericFilesOnly) {
// we hit at least one app that is not a superhandler and // we hit at least one app that is not a superhandler and
// handles the document // handles the document
fFoundOneNonSuperHandler = true; fFoundOneNonSuperHandler = true;
@@ -1614,7 +1618,8 @@ ConditionalAllAppsIterator::Instantiate()
BString lookForAppsPredicate; BString lookForAppsPredicate;
lookForAppsPredicate << "(" << kAttrAppSignature << " = \"*\" ) && ( " lookForAppsPredicate << "(" << kAttrAppSignature << " = \"*\" ) && ( "
<< kAttrMIMEType << " = " << B_APP_MIME_TYPE << " ) "; << kAttrMIMEType << " = " << B_APP_MIME_TYPE << " ) ";
fWalker = new BTrackerPrivate::TQueryWalker(lookForAppsPredicate.String()); fWalker
= new BTrackerPrivate::TQueryWalker(lookForAppsPredicate.String());
} }
@@ -1647,8 +1652,8 @@ ConditionalAllAppsIterator::GetNextRef(entry_ref* ref)
int32 int32
ConditionalAllAppsIterator::GetNextDirents(struct dirent* buffer, size_t length, ConditionalAllAppsIterator::GetNextDirents(struct dirent* buffer,
int32 count) size_t length, int32 count)
{ {
if (!Iterate()) if (!Iterate())
return 0; return 0;
+37 -22
View File
@@ -91,23 +91,26 @@ class SearchForSignatureEntryList : public EntryListBase {
void TrySettingPreferredAppForFile(const entry_ref*); void TrySettingPreferredAppForFile(const entry_ref*);
int32 Relation(const BMessage* entriesToOpen, const Model*) const; int32 Relation(const BMessage* entriesToOpen, const Model*) const;
// returns the reason why an application is shown in Open With window // returns the reason why an application is shown in
// Open With window
void RelationDescription(const BMessage* entriesToOpen, const Model*, void RelationDescription(const BMessage* entriesToOpen, const Model*,
BString*) const; BString*) const;
// returns a string describing why application handles files to open // returns a string describing why application handles files
// to open
static int32 Relation(const BMessage* entriesToOpen, static int32 Relation(const BMessage* entriesToOpen,
const Model*, const entry_ref* preferredApp, const Model*, const entry_ref* preferredApp,
const entry_ref* preferredAppForFile); const entry_ref* preferredAppForFile);
// returns the reason why an application is shown in Open With window // returns the reason why an application is shown in Open With
// static version, needs the preferred app for preformance // window static version, needs the preferred app for preformance
static void RelationDescription(const BMessage* entriesToOpen, static void RelationDescription(const BMessage* entriesToOpen,
const Model*, BString*, const entry_ref* preferredApp, const Model*, BString*, const entry_ref* preferredApp,
const entry_ref* preferredAppForFile); const entry_ref* preferredAppForFile);
// returns a string describing why application handles files to open // returns a string describing why application handles files
// to open
bool CanOpenWithFilter(const Model* appModel, const BMessage* entriesToOpen, bool CanOpenWithFilter(const Model* appModel,
const entry_ref* preferredApp); const BMessage* entriesToOpen, const entry_ref* preferredApp);
void NonGenericFileFound(); void NonGenericFileFound();
bool GenericFilesOnly() const; bool GenericFilesOnly() const;
@@ -116,7 +119,8 @@ class SearchForSignatureEntryList : public EntryListBase {
private: private:
static int32 Relation(const Model* node, const Model* app); static int32 Relation(const Model* node, const Model* app);
// returns the reason why an application is shown in Open With window // returns the reason why an application is shown in
// Open With window
CachedEntryIteratorList* fIteratorList; CachedEntryIteratorList* fIteratorList;
BObjectList<BString> fSignatures; BObjectList<BString> fSignatures;
@@ -152,7 +156,8 @@ class OpenWithContainerWindow : public BContainerWindow {
OpenWithPoseView* PoseView() const; OpenWithPoseView* PoseView() const;
protected: protected:
virtual BPoseView* NewPoseView(Model* model, BRect rect, uint32 viewMode); virtual BPoseView* NewPoseView(Model* model, BRect rect,
uint32 viewMode);
virtual bool ShouldAddMenus() const; virtual bool ShouldAddMenus() const;
virtual void ShowContextMenu(BPoint, const entry_ref*, BView*); virtual void ShowContextMenu(BPoint, const entry_ref*, BView*);
@@ -176,10 +181,12 @@ class OpenWithContainerWindow : public BContainerWindow {
void OpenWithSelection(); void OpenWithSelection();
// open entries with the selected app // open entries with the selected app
void MakeDefaultAndOpen(); void MakeDefaultAndOpen();
// open entries with the selected app and make it the default handler // open entries with the selected app and make it
// the default handler
private: private:
static filter_result KeyDownFilter(BMessage*, BHandler**, BMessageFilter*); static filter_result KeyDownFilter(BMessage*, BHandler**,
BMessageFilter*);
BMessage* fEntriesToOpen; BMessage* fEntriesToOpen;
BButton* fLaunchButton; BButton* fLaunchButton;
@@ -198,16 +205,19 @@ class OpenWithPoseView : public BPoseView {
// open entries with the selected app // open entries with the selected app
int32 OpenWithRelation(const Model*) const; int32 OpenWithRelation(const Model*) const;
// returns the reason why an application is shown in Open With window // returns the reason why an application is shown in
// Open With window
void OpenWithRelationDescription(const Model*, BString*) const; void OpenWithRelationDescription(const Model*, BString*) const;
// returns a string describing why application handles files to open // returns a string describing why application handles files
// to open
OpenWithContainerWindow* ContainerWindow() const; OpenWithContainerWindow* ContainerWindow() const;
virtual bool AddPosesThreadValid(const entry_ref*) const; virtual bool AddPosesThreadValid(const entry_ref*) const;
protected: protected:
// don't do any volume watching and memtamime watching in open with panels for now // don't do any volume watching and memtamime watching in open with
// panels for now
virtual void InitialStartWatching() {} virtual void InitialStartWatching() {}
virtual void FinalStopWatching() {} virtual void FinalStopWatching() {}
@@ -225,18 +235,22 @@ class OpenWithPoseView : public BPoseView {
virtual void SavePoseLocations(BRect* = NULL); virtual void SavePoseLocations(BRect* = NULL);
virtual void MoveSelectionToTrash(bool selectNext = true); virtual void MoveSelectionToTrash(bool selectNext = true);
virtual void MoveSelectionTo(BPoint, BPoint, BContainerWindow*); virtual void MoveSelectionTo(BPoint, BPoint, BContainerWindow*);
virtual void MoveSelectionInto(Model* destFolder, BContainerWindow* srcWindow, virtual void MoveSelectionInto(Model* destFolder,
bool forceCopy, bool create_link = false); BContainerWindow* srcWindow, bool forceCopy,
bool create_link = false);
virtual bool HandleMessageDropped(BMessage*); virtual bool HandleMessageDropped(BMessage*);
virtual bool CanHandleDragSelection(const Model*, const BMessage*, bool); virtual bool CanHandleDragSelection(const Model*, const BMessage*,
bool);
virtual bool Represents(const node_ref*) const; virtual bool Represents(const node_ref*) const;
virtual bool Represents(const entry_ref*) const; virtual bool Represents(const entry_ref*) const;
virtual void CreatePoses(Model** models, PoseInfo* poseInfoArray, int32 count, virtual void CreatePoses(Model** models, PoseInfo* poseInfoArray,
BPose** resultingPoses, bool insertionSort = true, int32* lastPoseIndexPtr = NULL, int32 count, BPose** resultingPoses, bool insertionSort = true,
BRect* boundsPtr = NULL, bool forceDraw = false); int32* lastPoseIndexPtr = NULL, BRect* boundsPtr = NULL,
// override to add selecting the default handling app for selection bool forceDraw = false);
// override to add selecting the default handling app
// for selection
virtual bool ShouldShowPose(const Model*, const PoseInfo*); virtual bool ShouldShowPose(const Model*, const PoseInfo*);
@@ -260,7 +274,8 @@ class RelationCachingModelProxy {
RelationCachingModelProxy(Model* model); RelationCachingModelProxy(Model* model);
~RelationCachingModelProxy(); ~RelationCachingModelProxy();
int32 Relation(SearchForSignatureEntryList* iterator, BMessage* entries) const; int32 Relation(SearchForSignatureEntryList* iterator,
BMessage* entries) const;
Model* fModel; Model* fModel;
mutable int32 fRelation; mutable int32 fRelation;
+6 -3
View File
@@ -102,7 +102,8 @@ OverrideAlert::OverPosition(float width, float height)
// This positions the alert window like a normal alert, put // This positions the alert window like a normal alert, put
// places it on top of the calling window if possible. // places it on top of the calling window if possible.
BWindow* window = dynamic_cast<BWindow*>(BLooper::LooperForThread(find_thread(NULL))); BWindow* window
= dynamic_cast<BWindow*>(BLooper::LooperForThread(find_thread(NULL)));
BRect screenFrame; BRect screenFrame;
BRect desirableRect; BRect desirableRect;
screenFrame = BScreen(window).Frame(); screenFrame = BScreen(window).Frame();
@@ -149,7 +150,9 @@ OverrideAlert::UpdateButtons(uint32 modifiers, bool force)
fCurModifiers = modifiers; fCurModifiers = modifiers;
for (int32 i = 0; i < 3; i++) { for (int32 i = 0; i < 3; i++) {
BButton* button = ButtonAt(i); BButton* button = ButtonAt(i);
if (button) if (button) {
button->SetEnabled(((fButtonModifiers[i] & fCurModifiers) == fButtonModifiers[i])); button->SetEnabled(((fButtonModifiers[i] & fCurModifiers)
== fButtonModifiers[i]));
}
} }
} }
+57 -34
View File
@@ -56,7 +56,8 @@ CalcFreeSpace(BVolume* volume)
if (capacity == 0) if (capacity == 0)
return 100; return 100;
int32 percent = static_cast<int32>(volume->FreeBytes() / (capacity / 100)); int32 percent
= static_cast<int32>(volume->FreeBytes() / (capacity / 100));
// warn below 20 MB of free space (if this is less than 10% of free space) // warn below 20 MB of free space (if this is less than 10% of free space)
if (volume->FreeBytes() < 20 * 1024 * 1024 && percent < 10) if (volume->FreeBytes() < 20 * 1024 * 1024 && percent < 10)
@@ -69,7 +70,8 @@ CalcFreeSpace(BVolume* volume)
// symlink pose uses the resolved model to retrieve the icon, if not broken // symlink pose uses the resolved model to retrieve the icon, if not broken
// everything else, like the attributes, etc. is retrieved directly from the // everything else, like the attributes, etc. is retrieved directly from the
// symlink itself // symlink itself
BPose::BPose(Model* model, BPoseView* view, uint32 clipboardMode, bool selected) BPose::BPose(Model* model, BPoseView* view, uint32 clipboardMode,
bool selected)
: fModel(model), : fModel(model),
fWidgetList(4, true), fWidgetList(4, true),
fClipboardMode(clipboardMode), fClipboardMode(clipboardMode),
@@ -148,7 +150,8 @@ BPose::AddWidget(BPoseView* poseView, BColumn* column)
BTextWidget* BTextWidget*
BPose::AddWidget(BPoseView* poseView, BColumn* column, ModelNodeLazyOpener &opener) BPose::AddWidget(BPoseView* poseView, BColumn* column,
ModelNodeLazyOpener &opener)
{ {
opener.OpenNode(); opener.OpenNode();
if (fModel->InitCheck() != B_OK) if (fModel->InitCheck() != B_OK)
@@ -171,7 +174,8 @@ BPose::RemoveWidget(BPoseView*, BColumn* column)
void void
BPose::Commit(bool saveChanges, BPoint loc, BPoseView* poseView, int32 poseIndex) BPose::Commit(bool saveChanges, BPoint loc, BPoseView* poseView,
int32 poseIndex)
{ {
int32 count = fWidgetList.CountItems(); int32 count = fWidgetList.CountItems();
for (int32 index = 0; index < count; index++) { for (int32 index = 0; index < count; index++) {
@@ -185,8 +189,8 @@ BPose::Commit(bool saveChanges, BPoint loc, BPoseView* poseView, int32 poseIndex
inline bool inline bool
OneMouseUp(BTextWidget* widget, BPose* pose, BPoseView* poseView, BColumn* column, OneMouseUp(BTextWidget* widget, BPose* pose, BPoseView* poseView,
BPoint poseLoc, BPoint where) BColumn* column, BPoint poseLoc, BPoint where)
{ {
BRect rect; BRect rect;
if (poseView->ViewMode() == kListMode) if (poseView->ViewMode() == kListMode)
@@ -258,7 +262,8 @@ BPose::UpdateWidgetAndModel(Model* resolvedModel, const char* attrName,
BTextWidget* widget = fWidgetList.ItemAt(i); BTextWidget* widget = fWidgetList.ItemAt(i);
BColumn* column = poseView->ColumnFor(widget->AttrHash()); BColumn* column = poseView->ColumnFor(widget->AttrHash());
if (column != NULL && !strcmp(column->AttrName(), attrName)) { if (column != NULL && !strcmp(column->AttrName(), attrName)) {
widget->CheckAndUpdate(poseLoc, column, poseView, visible); widget->CheckAndUpdate(poseLoc, column, poseView,
visible);
break; break;
} }
} }
@@ -283,8 +288,10 @@ BPose::UpdateWidgetAndModel(Model* resolvedModel, const char* attrName,
if (column->StatField()) { if (column->StatField()) {
BTextWidget* widget = WidgetFor(column->AttrHash()); BTextWidget* widget = WidgetFor(column->AttrHash());
if (widget) if (widget) {
widget->CheckAndUpdate(poseLoc, column, poseView, visible); widget->CheckAndUpdate(poseLoc, column, poseView,
visible);
}
} }
} }
} }
@@ -403,7 +410,8 @@ BPose::EditPreviousNextWidgetCommon(BPoseView* poseView, bool next)
{ {
bool found = false; bool found = false;
int32 delta = next ? 1 : -1; int32 delta = next ? 1 : -1;
for (int32 index = next ? 0 : poseView->CountColumns() - 1; ; index += delta) { for (int32 index = next ? 0 : poseView->CountColumns() - 1; ;
index += delta) {
BColumn* column = poseView->ColumnAt(index); BColumn* column = poseView->ColumnAt(index);
if (!column) if (!column)
break; break;
@@ -510,7 +518,8 @@ BPose::PointInPose(BPoint loc, const BPoseView* poseView, BPoint where,
if (!column) if (!column)
break; break;
BTextWidget* widget = WidgetFor(column->AttrHash()); BTextWidget* widget = WidgetFor(column->AttrHash());
if (widget && widget->CalcClickRect(loc, column, poseView).Contains(where)) { if (widget
&& widget->CalcClickRect(loc, column, poseView).Contains(where)) {
if (hitWidget) if (hitWidget)
*hitWidget = widget; *hitWidget = widget;
return true; return true;
@@ -522,8 +531,8 @@ BPose::PointInPose(BPoint loc, const BPoseView* poseView, BPoint where,
void void
BPose::Draw(BRect rect, const BRect& updateRect, BPoseView* poseView, BView* drawView, BPose::Draw(BRect rect, const BRect& updateRect, BPoseView* poseView,
bool fullDraw, BPoint offset, bool selected) BView* drawView, bool fullDraw, BPoint offset, bool selected)
{ {
// If the background wasn't cleared and Draw() is not called after // If the background wasn't cleared and Draw() is not called after
// having edited a name or similar (with fullDraw) // having edited a name or similar (with fullDraw)
@@ -549,8 +558,8 @@ BPose::Draw(BRect rect, const BRect& updateRect, BPoseView* poseView, BView* dra
iconRect.top = iconRect.bottom - size; iconRect.top = iconRect.bottom - size;
if (updateRect.Intersects(iconRect)) { if (updateRect.Intersects(iconRect)) {
iconRect.OffsetBy(offset); iconRect.OffsetBy(offset);
DrawIcon(iconRect.LeftTop(), drawView, poseView->IconSize(), directDraw, DrawIcon(iconRect.LeftTop(), drawView, poseView->IconSize(),
!windowActive && !showSelectionWhenInactive); directDraw, !windowActive && !showSelectionWhenInactive);
} }
// draw text // draw text
@@ -571,8 +580,8 @@ BPose::Draw(BRect rect, const BRect& updateRect, BPoseView* poseView, BView* dra
poseView)); poseView));
if (updateRect.Intersects(widgetRect)) { if (updateRect.Intersects(widgetRect)) {
BRect widgetTextRect(widget->CalcRect(rect.LeftTop(), column, BRect widgetTextRect(widget->CalcRect(rect.LeftTop(),
poseView)); column, poseView));
bool selectDuringDraw = directDraw && selected bool selectDuringDraw = directDraw && selected
&& windowActive; && windowActive;
@@ -583,12 +592,15 @@ BPose::Draw(BRect rect, const BRect& updateRect, BPoseView* poseView, BView* dra
drawView->SetLowColor(0, 0, 0); drawView->SetLowColor(0, 0, 0);
} }
if (index == 0) if (index == 0) {
widget->Draw(widgetRect, widgetTextRect, column->Width(), widget->Draw(widgetRect, widgetTextRect,
poseView, drawView, selected, fClipboardMode, offset, directDraw); column->Width(), poseView, drawView, selected,
else fClipboardMode, offset, directDraw);
} else {
widget->Draw(widgetTextRect, widgetTextRect, column->Width(), widget->Draw(widgetTextRect, widgetTextRect, column->Width(),
poseView, drawView, false, fClipboardMode, offset, directDraw); poseView, drawView, false, fClipboardMode,
offset, directDraw);
}
if (index == 0 && selectDuringDraw) if (index == 0 && selectDuringDraw)
drawView->PopState(); drawView->PopState();
@@ -596,7 +608,8 @@ BPose::Draw(BRect rect, const BRect& updateRect, BPoseView* poseView, BView* dra
if (windowActive || isDrawingSelectionRect) { if (windowActive || isDrawingSelectionRect) {
widgetTextRect.OffsetBy(offset); widgetTextRect.OffsetBy(offset);
drawView->InvertRect(widgetTextRect); drawView->InvertRect(widgetTextRect);
} else if (!windowActive && showSelectionWhenInactive) { } else if (!windowActive
&& showSelectionWhenInactive) {
widgetTextRect.OffsetBy(offset); widgetTextRect.OffsetBy(offset);
drawView->PushState(); drawView->PushState();
drawView->SetDrawingMode(B_OP_BLEND); drawView->SetDrawingMode(B_OP_BLEND);
@@ -705,8 +718,10 @@ BPose::MoveTo(BPoint point, BPoseView* poseView, bool inval)
// might need to move a text view if we're active // might need to move a text view if we're active
if (poseView->ActivePose() == this) { if (poseView->ActivePose() == this) {
BView* border_view = poseView->FindView("BorderView"); BView* border_view = poseView->FindView("BorderView");
if (border_view) if (border_view) {
border_view->MoveBy(point.x - oldLocation.x, point.y - oldLocation.y); border_view->MoveBy(point.x - oldLocation.x,
point.y - oldLocation.y);
}
} }
float scale = 1.0; float scale = 1.0;
@@ -756,8 +771,8 @@ BPose::WidgetFor(uint32 attr, int32* index) const
BTextWidget* BTextWidget*
BPose::WidgetFor(BColumn* column, BPoseView* poseView, ModelNodeLazyOpener &opener, BPose::WidgetFor(BColumn* column, BPoseView* poseView,
int32* index) ModelNodeLazyOpener &opener, int32* index)
{ {
BTextWidget* widget = WidgetFor(column->AttrHash(), index); BTextWidget* widget = WidgetFor(column->AttrHash(), index);
if (!widget) if (!widget)
@@ -777,17 +792,20 @@ BPose::TestLargeIconPixel(BPoint point) const
void void
BPose::DrawIcon(BPoint where, BView* view, icon_size kind, bool direct, bool drawUnselected) BPose::DrawIcon(BPoint where, BView* view, icon_size kind, bool direct,
bool drawUnselected)
{ {
if (fClipboardMode == kMoveSelectionTo) { if (fClipboardMode == kMoveSelectionTo) {
view->SetDrawingMode(B_OP_ALPHA); view->SetDrawingMode(B_OP_ALPHA);
view->SetHighColor(0, 0, 0, 64); // set the level of transparency view->SetHighColor(0, 0, 0, 64);
// set the level of transparency
view->SetBlendingMode(B_CONSTANT_ALPHA, B_ALPHA_OVERLAY); view->SetBlendingMode(B_CONSTANT_ALPHA, B_ALPHA_OVERLAY);
} else if (direct) } else if (direct)
view->SetDrawingMode(B_OP_OVER); view->SetDrawingMode(B_OP_OVER);
IconCache::sIconCache->Draw(ResolvedModel(), view, where, IconCache::sIconCache->Draw(ResolvedModel(), view, where,
fIsSelected && !drawUnselected ? kSelectedIcon : kNormalIcon, kind, true); fIsSelected && !drawUnselected ? kSelectedIcon : kNormalIcon, kind,
true);
if (fPercent != -1) if (fPercent != -1)
DrawBar(where, view, kind); DrawBar(where, view, kind);
@@ -816,7 +834,8 @@ BPose::DrawBar(BPoint where,BView* view,icon_size kind)
view->SetHighColor(32, 32, 32, 92); view->SetHighColor(32, 32, 32, 92);
view->MovePenTo(BPoint(where.x + size, where.y + 1 + yOffset)); view->MovePenTo(BPoint(where.x + size, where.y + 1 + yOffset));
view->StrokeLine(BPoint(where.x + size, where.y + size - yOffset)); view->StrokeLine(BPoint(where.x + size, where.y + size - yOffset));
view->StrokeLine(BPoint(where.x + size - barWidth + 1, where.y + size - yOffset)); view->StrokeLine(BPoint(where.x + size - barWidth + 1,
where.y + size - yOffset));
view->SetDrawingMode(B_OP_ALPHA); view->SetDrawingMode(B_OP_ALPHA);
@@ -846,7 +865,9 @@ BPose::DrawBar(BPoint where,BView* view,icon_size kind)
// the used space bar // the used space bar
bar.top = bar.bottom + 1; bar.top = bar.bottom + 1;
bar.bottom = rect.bottom; bar.bottom = rect.bottom;
view->SetHighColor(fPercent < -1 ? TrackerSettings().WarningSpaceColor() : TrackerSettings().UsedSpaceColor()); view->SetHighColor(fPercent < -1
? TrackerSettings().WarningSpaceColor()
: TrackerSettings().UsedSpaceColor());
view->FillRect(bar); view->FillRect(bar);
view->PopState(); view->PopState();
@@ -899,8 +920,10 @@ BPose::CalcRect(BPoint loc, const BPoseView* poseView, bool minimalRect) const
if (minimalRect) { if (minimalRect) {
BTextWidget* widget = WidgetFor(poseView->FirstColumn()->AttrHash()); BTextWidget* widget = WidgetFor(poseView->FirstColumn()->AttrHash());
if (widget) if (widget) {
rect.right = widget->CalcRect(loc, poseView->FirstColumn(), poseView).right; rect.right = widget->CalcRect(loc, poseView->FirstColumn(),
poseView).right;
}
} }
return rect; return rect;
+8 -4
View File
@@ -55,11 +55,13 @@ enum {
class BPose { class BPose {
public: public:
BPose(Model* adopt, BPoseView*, uint32 clipboardMode, bool selected = false); BPose(Model* adopt, BPoseView*, uint32 clipboardMode,
bool selected = false);
virtual ~BPose(); virtual ~BPose();
BTextWidget* AddWidget(BPoseView*, BColumn*); BTextWidget* AddWidget(BPoseView*, BColumn*);
BTextWidget* AddWidget(BPoseView*, BColumn*, ModelNodeLazyOpener &opener); BTextWidget* AddWidget(BPoseView*, BColumn*,
ModelNodeLazyOpener &opener);
void RemoveWidget(BPoseView*, BColumn*); void RemoveWidget(BPoseView*, BColumn*);
void SetLocation(BPoint, const BPoseView*); void SetLocation(BPoint, const BPoseView*);
void MoveTo(BPoint, BPoseView*, bool inval = true); void MoveTo(BPoint, BPoseView*, bool inval = true);
@@ -68,13 +70,15 @@ class BPose {
bool fullDraw = true); bool fullDraw = true);
void Draw(BRect poseRect, const BRect& updateRect, BPoseView*, void Draw(BRect poseRect, const BRect& updateRect, BPoseView*,
BView* drawView, bool fullDraw, BPoint offset, bool selected); BView* drawView, bool fullDraw, BPoint offset, bool selected);
void DeselectWithoutErasingBackground(BRect rect, BPoseView* poseView); void DeselectWithoutErasingBackground(BRect rect,
BPoseView* poseView);
// special purpose draw call for deselecting over a textured // special purpose draw call for deselecting over a textured
// background // background
void DrawBar(BPoint where, BView* view, icon_size kind); void DrawBar(BPoint where, BView* view, icon_size kind);
void DrawIcon(BPoint, BView*, icon_size, bool direct, bool drawUnselected = false); void DrawIcon(BPoint, BView*, icon_size, bool direct,
bool drawUnselected = false);
void DrawToggleSwitch(BRect, BPoseView*); void DrawToggleSwitch(BRect, BPoseView*);
void MouseUp(BPoint poseLoc, BPoseView*, BPoint where, int32 index); void MouseUp(BPoint poseLoc, BPoseView*, BPoint where, int32 index);
Model* TargetModel() const; Model* TargetModel() const;
+22 -15
View File
@@ -73,7 +73,8 @@ public:
template<class EachParam1> template<class EachParam1>
void void
EachPoseAndModel(PoseList* list, void (*eachFunction)(BPose*, Model*, EachParam1), EachPoseAndModel(PoseList* list,
void (*eachFunction)(BPose*, Model*, EachParam1),
EachParam1 eachParam1) EachParam1 eachParam1)
{ {
for (int32 index = list->CountItems() - 1; index >= 0; index--) { for (int32 index = list->CountItems() - 1; index >= 0; index--) {
@@ -87,8 +88,9 @@ EachPoseAndModel(PoseList* list, void (*eachFunction)(BPose*, Model*, EachParam1
template<class EachParam1> template<class EachParam1>
void void
EachPoseAndModel(PoseList* list, void (*eachFunction)(BPose*, Model*, int32 , EachPoseAndModel(PoseList* list,
EachParam1), EachParam1 eachParam1) void (*eachFunction)(BPose*, Model*, int32, EachParam1),
EachParam1 eachParam1)
{ {
for (int32 index = list->CountItems() - 1; index >= 0; index--) { for (int32 index = list->CountItems() - 1; index >= 0; index--) {
BPose* pose = list->ItemAt(index); BPose* pose = list->ItemAt(index);
@@ -101,8 +103,9 @@ EachPoseAndModel(PoseList* list, void (*eachFunction)(BPose*, Model*, int32 ,
template<class EachParam1, class EachParam2> template<class EachParam1, class EachParam2>
void void
EachPoseAndModel(PoseList* list, void (*eachFunction)(BPose*, Model*, EachParam1, EachPoseAndModel(PoseList* list,
EachParam2), EachParam1 eachParam1, EachParam2 eachParam2) void (*eachFunction)(BPose*, Model*, EachParam1, EachParam2),
EachParam1 eachParam1, EachParam2 eachParam2)
{ {
for (int32 index = list->CountItems() - 1; index >= 0; index--) { for (int32 index = list->CountItems() - 1; index >= 0; index--) {
BPose* pose = list->ItemAt(index); BPose* pose = list->ItemAt(index);
@@ -114,8 +117,9 @@ EachPoseAndModel(PoseList* list, void (*eachFunction)(BPose*, Model*, EachParam1
template<class EachParam1, class EachParam2> template<class EachParam1, class EachParam2>
void void
EachPoseAndModel(PoseList* list, void (*eachFunction)(BPose*, Model*, int32, EachPoseAndModel(PoseList* list,
EachParam1, EachParam2), EachParam1 eachParam1, EachParam2 eachParam2) void (*eachFunction)(BPose*, Model*, int32, EachParam1, EachParam2),
EachParam1 eachParam1, EachParam2 eachParam2)
{ {
for (int32 index = list->CountItems() - 1; index >= 0; index--) { for (int32 index = list->CountItems() - 1; index >= 0; index--) {
BPose* pose = list->ItemAt(index); BPose* pose = list->ItemAt(index);
@@ -127,8 +131,8 @@ EachPoseAndModel(PoseList* list, void (*eachFunction)(BPose*, Model*, int32,
template<class EachParam1> template<class EachParam1>
void void
EachPoseAndResolvedModel(PoseList* list, void (*eachFunction)(BPose*, Model*, EachParam1), EachPoseAndResolvedModel(PoseList* list,
EachParam1 eachParam1) void (*eachFunction)(BPose*, Model*, EachParam1), EachParam1 eachParam1)
{ {
for (int32 index = list->CountItems() - 1; index >= 0; index--) { for (int32 index = list->CountItems() - 1; index >= 0; index--) {
BPose* pose = list->ItemAt(index); BPose* pose = list->ItemAt(index);
@@ -140,8 +144,9 @@ EachPoseAndResolvedModel(PoseList* list, void (*eachFunction)(BPose*, Model*, Ea
template<class EachParam1> template<class EachParam1>
void void
EachPoseAndResolvedModel(PoseList* list, void (*eachFunction)(BPose*, Model*, int32 , EachPoseAndResolvedModel(PoseList* list,
EachParam1), EachParam1 eachParam1) void (*eachFunction)(BPose*, Model*, int32 , EachParam1),
EachParam1 eachParam1)
{ {
for (int32 index = list->CountItems() - 1; index >= 0; index--) { for (int32 index = list->CountItems() - 1; index >= 0; index--) {
BPose* pose = list->ItemAt(index); BPose* pose = list->ItemAt(index);
@@ -153,8 +158,9 @@ EachPoseAndResolvedModel(PoseList* list, void (*eachFunction)(BPose*, Model*, in
template<class EachParam1, class EachParam2> template<class EachParam1, class EachParam2>
void void
EachPoseAndResolvedModel(PoseList* list, void (*eachFunction)(BPose*, Model*, EachParam1, EachPoseAndResolvedModel(PoseList* list,
EachParam2), EachParam1 eachParam1, EachParam2 eachParam2) void (*eachFunction)(BPose*, Model*, EachParam1, EachParam2),
EachParam1 eachParam1, EachParam2 eachParam2)
{ {
for (int32 index = list->CountItems() - 1; index >= 0; index--) { for (int32 index = list->CountItems() - 1; index >= 0; index--) {
BPose* pose = list->ItemAt(index); BPose* pose = list->ItemAt(index);
@@ -166,8 +172,9 @@ EachPoseAndResolvedModel(PoseList* list, void (*eachFunction)(BPose*, Model*, Ea
template<class EachParam1, class EachParam2> template<class EachParam1, class EachParam2>
void void
EachPoseAndResolvedModel(PoseList* list, void (*eachFunction)(BPose*, Model*, int32, EachPoseAndResolvedModel(PoseList* list,
EachParam1, EachParam2), EachParam1 eachParam1, EachParam2 eachParam2) void (*eachFunction)(BPose*, Model*, int32, EachParam1, EachParam2),
EachParam1 eachParam1, EachParam2 eachParam2)
{ {
for (int32 index = list->CountItems() - 1; index >= 0; index--) { for (int32 index = list->CountItems() - 1; index >= 0; index--) {
BPose* pose = list->ItemAt(index); BPose* pose = list->ItemAt(index);
+51 -31
View File
@@ -203,7 +203,8 @@ PoseCompareAddWidget(const BPose* p1, const BPose* p2, BPoseView* view);
// #pragma mark - // #pragma mark -
BPoseView::BPoseView(Model* model, BRect bounds, uint32 viewMode, uint32 resizeMask) BPoseView::BPoseView(Model* model, BRect bounds, uint32 viewMode,
uint32 resizeMask)
: BView(bounds, "PoseView", resizeMask, B_WILL_DRAW | B_PULSE_NEEDED), : BView(bounds, "PoseView", resizeMask, B_WILL_DRAW | B_PULSE_NEEDED),
fIsDrawingSelectionRect(false), fIsDrawingSelectionRect(false),
fHScrollBar(NULL), fHScrollBar(NULL),
@@ -265,7 +266,8 @@ BPoseView::BPoseView(Model* model, BRect bounds, uint32 viewMode, uint32 resizeM
fDeskbarFrame(0, 0, -1, -1) fDeskbarFrame(0, 0, -1, -1)
{ {
fViewState->SetViewMode(viewMode); fViewState->SetViewMode(viewMode);
fShowSelectionWhenInactive = TrackerSettings().ShowSelectionWhenInactive(); fShowSelectionWhenInactive
= TrackerSettings().ShowSelectionWhenInactive();
fTransparentSelection = TrackerSettings().TransparentSelection(); fTransparentSelection = TrackerSettings().TransparentSelection();
fFilterStrings.AddItem(new BString("")); fFilterStrings.AddItem(new BString(""));
} }
@@ -400,7 +402,8 @@ BPoseView::RestoreColumnState(AttributeStreamNode* node)
} }
if (size > 0 && size < 10000) { if (size > 0 && size < 10000) {
// check for invalid sizes here to protect against munged attributes // check for invalid sizes here to protect against
// munged attributes
char* buffer = new char[size]; char* buffer = new char[size];
off_t result = node->Read(name, 0, B_RAW_TYPE, size, buffer); off_t result = node->Read(name, 0, B_RAW_TYPE, size, buffer);
if (result) { if (result) {
@@ -468,7 +471,8 @@ BPoseView::AddColumnList(BObjectList<BColumn>* list)
list->SortItems(&CompareColumns); list->SortItems(&CompareColumns);
float nextLeftEdge = 0; float nextLeftEdge = 0;
for (int32 columIndex = 0; columIndex < list->CountItems(); columIndex++) { for (int32 columIndex = 0; columIndex < list->CountItems();
columIndex++) {
BColumn* column = list->ItemAt(columIndex); BColumn* column = list->ItemAt(columIndex);
// Make sure that columns don't overlap // Make sure that columns don't overlap
@@ -477,12 +481,14 @@ BPoseView::AddColumnList(BObjectList<BColumn>* list)
column->SetOffset(nextLeftEdge); column->SetOffset(nextLeftEdge);
} }
nextLeftEdge = column->Offset() + column->Width() - kRoomForLine / 2.0f nextLeftEdge = column->Offset() + column->Width()
+ kTitleColumnExtraMargin; - kRoomForLine / 2.0f + kTitleColumnExtraMargin;
fColumnList->AddItem(column); fColumnList->AddItem(column);
if (!IsWatchingDateFormatChange() && column->AttrType() == B_TIME_TYPE) if (!IsWatchingDateFormatChange()
&& column->AttrType() == B_TIME_TYPE) {
StartWatchDateFormatChange(); StartWatchDateFormatChange();
}
} }
} }
@@ -514,15 +520,17 @@ BPoseView::RestoreState(AttributeStreamNode* node)
} }
if (size > 0 && size < 10000) { if (size > 0 && size < 10000) {
// check for invalid sizes here to protect against munged attributes // check for invalid sizes here to protect against
// munged attributes
char* buffer = new char[size]; char* buffer = new char[size];
off_t result = node->Read(name, 0, B_RAW_TYPE, size, buffer); off_t result = node->Read(name, 0, B_RAW_TYPE, size, buffer);
if (result) { if (result) {
BMallocIO stream; BMallocIO stream;
stream.WriteAt(0, buffer, size); stream.WriteAt(0, buffer, size);
stream.Seek(0, SEEK_SET); stream.Seek(0, SEEK_SET);
BViewState* viewstate = BViewState::InstantiateFromStream(&stream, BViewState* viewstate
wrongEndianness); = BViewState::InstantiateFromStream(&stream,
wrongEndianness);
if (viewstate) { if (viewstate) {
delete fViewState; delete fViewState;
fViewState = viewstate; fViewState = viewstate;
@@ -805,25 +813,28 @@ BPoseView::SavePoseLocations(BRect* frameIfDesktop)
// nuke opposite endianness // nuke opposite endianness
dir.RemoveAttr(poseInfoAttrForeign); dir.RemoveAttr(poseInfoAttrForeign);
if (!isTrash && desktop && dir.WriteAttr(kAttrExtendedDisksPoseInfo, if (!isTrash && desktop
B_RAW_TYPE, 0, && dir.WriteAttr(kAttrExtendedDisksPoseInfo,
extendedPoseInfo, extendedPoseInfoSize) B_RAW_TYPE, 0, extendedPoseInfo, extendedPoseInfoSize)
== (ssize_t)extendedPoseInfoSize) == (ssize_t)extendedPoseInfoSize) {
// nuke opposite endianness // nuke opposite endianness
dir.RemoveAttr(kAttrExtendedDisksPoseInfoForegin); dir.RemoveAttr(kAttrExtendedDisksPoseInfoForegin);
}
} }
} else { } else {
model->WriteAttrKillForeign(kAttrPoseInfo, kAttrPoseInfoForeign, model->WriteAttrKillForeign(kAttrPoseInfo,
B_RAW_TYPE, 0, &poseInfo, sizeof(poseInfo)); kAttrPoseInfoForeign, B_RAW_TYPE, 0, &poseInfo,
sizeof(poseInfo));
if (desktop) { if (desktop) {
model->WriteAttrKillForeign(kAttrExtendedPoseInfo, model->WriteAttrKillForeign(kAttrExtendedPoseInfo,
kAttrExtendedPoseInfoForegin, kAttrExtendedPoseInfoForegin,
B_RAW_TYPE, 0, extendedPoseInfo, extendedPoseInfoSize); B_RAW_TYPE, 0, extendedPoseInfo,
extendedPoseInfoSize);
} }
} }
delete [] (char*)extendedPoseInfo; delete[] (char*)extendedPoseInfo;
// TODO: fix up this mess // TODO: fix up this mess
} }
} }
@@ -935,15 +946,19 @@ BPoseView::AttachedToWindow()
if (fIsDesktopWindow) if (fIsDesktopWindow)
AddFilter(new TPoseViewFilter(this)); AddFilter(new TPoseViewFilter(this));
AddFilter(new ShortcutFilter(B_RETURN, B_OPTION_KEY, kOpenSelection, this)); AddFilter(new ShortcutFilter(B_RETURN, B_OPTION_KEY, kOpenSelection,
// add Option-Return as a shortcut filter because AddShortcut doesn't allow this));
// us to have shortcuts without Command yet // add Option-Return as a shortcut filter because AddShortcut
// doesn't allow us to have shortcuts without Command yet
AddFilter(new ShortcutFilter(B_ESCAPE, 0, B_CANCEL, this)); AddFilter(new ShortcutFilter(B_ESCAPE, 0, B_CANCEL, this));
// Escape key, used to abort an on-going clipboard cut or filtering // Escape key, used to abort an on-going clipboard cut or filtering
AddFilter(new ShortcutFilter(B_ESCAPE, B_SHIFT_KEY, kCancelSelectionToClipboard, this)); AddFilter(new ShortcutFilter(B_ESCAPE, B_SHIFT_KEY,
// Escape + SHIFT will remove current selection from clipboard, or all poses from current folder if 0 selected kCancelSelectionToClipboard, this));
// Escape + SHIFT will remove current selection from clipboard,
// or all poses from current folder if 0 selected
AddFilter(new LongAndDragTrackingFilter(kMsgMouseLongDown, kMsgMouseDragged)); AddFilter(new LongAndDragTrackingFilter(kMsgMouseLongDown,
kMsgMouseDragged));
fLastLeftTop = LeftTop(); fLastLeftTop = LeftTop();
BFont font(be_plain_font); BFont font(be_plain_font);
@@ -954,7 +969,8 @@ BPoseView::AttachedToWindow()
// static - init just once // static - init just once
if (sFontHeight == -1) { if (sFontHeight == -1) {
font.GetHeight(&sFontInfo); font.GetHeight(&sFontInfo);
sFontHeight = sFontInfo.ascent + sFontInfo.descent + sFontInfo.leading; sFontHeight = sFontInfo.ascent + sFontInfo.descent
+ sFontInfo.leading;
} }
if (TTracker* app = dynamic_cast<TTracker*>(be_app)) { if (TTracker* app = dynamic_cast<TTracker*>(be_app)) {
@@ -981,7 +997,8 @@ BPoseView::SetIconPoseHeight()
case kMiniIconMode: case kMiniIconMode:
fViewState->SetIconSize(B_MINI_ICON); fViewState->SetIconSize(B_MINI_ICON);
fIconPoseHeight = ceilf(sFontHeight < IconSizeInt() ? IconSizeInt() : sFontHeight + 1); fIconPoseHeight = ceilf(sFontHeight <
IconSizeInt() ? IconSizeInt() : sFontHeight + 1);
break; break;
default: default:
@@ -1263,7 +1280,7 @@ BPoseView::AddPosesTask(void* castToParams)
{ {
// AddPosesTask reeds a bunch of models and passes them off to // AddPosesTask reeds a bunch of models and passes them off to
// the pose placing and drawing routine. // the pose placing and drawing routine.
//
AddPosesParams* params = (AddPosesParams*)castToParams; AddPosesParams* params = (AddPosesParams*)castToParams;
BMessenger target(params->target); BMessenger target(params->target);
entry_ref ref(params->ref); entry_ref ref(params->ref);
@@ -1318,8 +1335,9 @@ BPoseView::AddPosesTask(void* castToParams)
node_ref itemNode; node_ref itemNode;
posesResult->fModels[modelChunkIndex] = 0; posesResult->fModels[modelChunkIndex] = 0;
// ToDo - redo this so that modelChunkIndex increments right before // ToDo - redo this so that modelChunkIndex increments
// a new model is added to the array; start with modelChunkIndex = -1 // right before a new model is added to the array;
// start with modelChunkIndex = -1
int32 count = container->GetNextDirents(eptr, 1024, 1); int32 count = container->GetNextDirents(eptr, 1024, 1);
if (count <= 0 && !modelChunkIndex) if (count <= 0 && !modelChunkIndex)
@@ -1328,9 +1346,11 @@ BPoseView::AddPosesTask(void* castToParams)
if (count) { if (count) {
ASSERT(count == 1); ASSERT(count == 1);
if ((!hideDotFiles && (!strcmp(eptr->d_name, ".") || !strcmp(eptr->d_name, ".."))) if ((!hideDotFiles && (!strcmp(eptr->d_name, ".")
|| (hideDotFiles && eptr->d_name[0] == '.')) || !strcmp(eptr->d_name, "..")))
|| (hideDotFiles && eptr->d_name[0] == '.')) {
continue; continue;
}
dirNode.device = eptr->d_pdev; dirNode.device = eptr->d_pdev;
dirNode.node = eptr->d_pino; dirNode.node = eptr->d_pino;