Patch by Takashi Murai: Style cleanup and fix an untranslated string in the navigation context menus.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@38859 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
+131
-118
@@ -26,10 +26,10 @@ Except as contained in this notice, the name of Be Incorporated shall not be
|
|||||||
used in advertising or otherwise to promote the sale, use or other dealings in
|
used in advertising or otherwise to promote the sale, use or other dealings in
|
||||||
this Software without prior written authorization from Be Incorporated.
|
this Software without prior written authorization from Be Incorporated.
|
||||||
|
|
||||||
Tracker(TM), Be(R), BeOS(R), and BeIA(TM) are trademarks or registered trademarks
|
Tracker(TM), Be(R), BeOS(R), and BeIA(TM) are trademarks or registered
|
||||||
of Be Incorporated in the United States and other countries. Other brand product
|
trademarks of Be Incorporated in the United States and other countries.
|
||||||
names are registered trademarks or trademarks of their respective holders.
|
Other brand product names are registered trademarks or trademarks of
|
||||||
All rights reserved.
|
their respective holders. All rights reserved.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// NavMenu is a hierarchical menu of volumes, folders, files and queries
|
// NavMenu is a hierarchical menu of volumes, folders, files and queries
|
||||||
@@ -77,21 +77,23 @@ enum nav_flags {
|
|||||||
|
|
||||||
|
|
||||||
bool
|
bool
|
||||||
SpringLoadedFolderCompareMessages(const BMessage *incoming, const BMessage *dragmessage)
|
SpringLoadedFolderCompareMessages(const BMessage* incoming,
|
||||||
|
const BMessage* dragmessage)
|
||||||
{
|
{
|
||||||
if (!dragmessage || !incoming)
|
if (!dragmessage || !incoming)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
bool retvalue=false;
|
bool retvalue = false;
|
||||||
for (int32 inIndex=0; incoming->HasRef("refs", inIndex); inIndex++) {
|
for (int32 inIndex = 0; incoming->HasRef("refs", inIndex); inIndex++) {
|
||||||
entry_ref inRef;
|
entry_ref inRef;
|
||||||
if (incoming->FindRef("refs", inIndex, &inRef) != B_OK) {
|
if (incoming->FindRef("refs", inIndex, &inRef) != B_OK) {
|
||||||
retvalue = false;
|
retvalue = false;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool inRefMatch = false;
|
bool inRefMatch = false;
|
||||||
for (int32 dragIndex=0; dragmessage->HasRef("refs", dragIndex); dragIndex++) {
|
for (int32 dragIndex = 0; dragmessage->HasRef("refs", dragIndex);
|
||||||
|
dragIndex++) {
|
||||||
entry_ref dragRef;
|
entry_ref dragRef;
|
||||||
if (dragmessage->FindRef("refs", dragIndex, &dragRef) != B_OK) {
|
if (dragmessage->FindRef("refs", dragIndex, &dragRef) != B_OK) {
|
||||||
inRefMatch = false;
|
inRefMatch = false;
|
||||||
@@ -117,7 +119,7 @@ SpringLoadedFolderCompareMessages(const BMessage *incoming, const BMessage *drag
|
|||||||
BPoint inPt, dPt;
|
BPoint inPt, dPt;
|
||||||
if (incoming->FindPoint("click_pt", &inPt) == B_OK)
|
if (incoming->FindPoint("click_pt", &inPt) == B_OK)
|
||||||
if (dragmessage->FindPoint("click_pt", &dPt) == B_OK)
|
if (dragmessage->FindPoint("click_pt", &dPt) == B_OK)
|
||||||
retvalue = (inPt == dPt);
|
retvalue = (inPt == dPt);
|
||||||
}
|
}
|
||||||
|
|
||||||
return retvalue;
|
return retvalue;
|
||||||
@@ -125,25 +127,26 @@ SpringLoadedFolderCompareMessages(const BMessage *incoming, const BMessage *drag
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
SpringLoadedFolderSetMenuStates(const BMenu* menu, const BObjectList<BString> *typeslist)
|
SpringLoadedFolderSetMenuStates(const BMenu* menu,
|
||||||
|
const BObjectList<BString> *typeslist)
|
||||||
{
|
{
|
||||||
if (!menu || !typeslist)
|
if (!menu || !typeslist)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// if a types list exists
|
// if a types list exists
|
||||||
// iterate through the list and see if each item
|
// iterate through the list and see if each item
|
||||||
// can support any item in the list
|
// can support any item in the list
|
||||||
// set the enabled state of the item
|
// set the enabled state of the item
|
||||||
int32 count = menu->CountItems();
|
int32 count = menu->CountItems();
|
||||||
for (int32 index = 0 ; index < count ; index++) {
|
for (int32 index = 0 ; index < count ; index++) {
|
||||||
ModelMenuItem *item = dynamic_cast<ModelMenuItem *>(menu->ItemAt(index));
|
ModelMenuItem* item = dynamic_cast<ModelMenuItem *>(menu->ItemAt(index));
|
||||||
if (!item)
|
if (!item)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
const Model *model = item->TargetModel();
|
const Model* model = item->TargetModel();
|
||||||
if (!model)
|
if (!model)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (model->IsSymLink()) {
|
if (model->IsSymLink()) {
|
||||||
// find out what the model is, resolve if symlink
|
// find out what the model is, resolve if symlink
|
||||||
BEntry entry(model->EntryRef(), true);
|
BEntry entry(model->EntryRef(), true);
|
||||||
@@ -157,10 +160,10 @@ SpringLoadedFolderSetMenuStates(const BMenu* menu, const BObjectList<BString> *t
|
|||||||
int32 supported = resolvedModel.SupportsMimeType(NULL, typeslist);
|
int32 supported = resolvedModel.SupportsMimeType(NULL, typeslist);
|
||||||
item->SetEnabled(supported != kDoesNotSupportType);
|
item->SetEnabled(supported != kDoesNotSupportType);
|
||||||
}
|
}
|
||||||
} else
|
} else
|
||||||
// bad entry ref (bad symlink?), disable
|
// bad entry ref (bad symlink?), disable
|
||||||
item->SetEnabled(false);
|
item->SetEnabled(false);
|
||||||
} else if (model->IsDirectory() || model->IsRoot() || model->IsVolume())
|
} else if (model->IsDirectory() || model->IsRoot() || model->IsVolume())
|
||||||
// always enabled if a container
|
// always enabled if a container
|
||||||
item->SetEnabled(true);
|
item->SetEnabled(true);
|
||||||
else if (model->IsFile() || model->IsExecutable()) {
|
else if (model->IsFile() || model->IsExecutable()) {
|
||||||
@@ -168,25 +171,26 @@ SpringLoadedFolderSetMenuStates(const BMenu* menu, const BObjectList<BString> *t
|
|||||||
item->SetEnabled(supported != kDoesNotSupportType);
|
item->SetEnabled(supported != kDoesNotSupportType);
|
||||||
} else
|
} else
|
||||||
item->SetEnabled(false);
|
item->SetEnabled(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
SpringLoadedFolderAddUniqueTypeToList(entry_ref *ref, BObjectList<BString> *typeslist)
|
SpringLoadedFolderAddUniqueTypeToList(entry_ref* ref,
|
||||||
|
BObjectList<BString> *typeslist)
|
||||||
{
|
{
|
||||||
if (!ref || !typeslist)
|
if (!ref || !typeslist)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// get the mime type for the current ref
|
// get the mime type for the current ref
|
||||||
BNodeInfo nodeinfo;
|
BNodeInfo nodeinfo;
|
||||||
BNode node(ref);
|
BNode node(ref);
|
||||||
if (node.InitCheck() != B_OK)
|
if (node.InitCheck() != B_OK)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
nodeinfo.SetTo(&node);
|
nodeinfo.SetTo(&node);
|
||||||
|
|
||||||
char mimestr[B_MIME_TYPE_LENGTH];
|
char mimestr[B_MIME_TYPE_LENGTH];
|
||||||
// add it to the list
|
// add it to the list
|
||||||
if (nodeinfo.GetType(mimestr) == B_OK && strlen(mimestr) > 0) {
|
if (nodeinfo.GetType(mimestr) == B_OK && strlen(mimestr) > 0) {
|
||||||
// if this is a symlink, add symlink to the list (below)
|
// if this is a symlink, add symlink to the list (below)
|
||||||
@@ -194,12 +198,12 @@ SpringLoadedFolderAddUniqueTypeToList(entry_ref *ref, BObjectList<BString> *type
|
|||||||
// to the list
|
// to the list
|
||||||
if (strcmp(B_LINK_MIMETYPE, mimestr) == 0) {
|
if (strcmp(B_LINK_MIMETYPE, mimestr) == 0) {
|
||||||
BEntry entry(ref, true);
|
BEntry entry(ref, true);
|
||||||
if (entry.InitCheck() == B_OK) {
|
if (entry.InitCheck() == B_OK) {
|
||||||
entry_ref resolvedRef;
|
entry_ref resolvedRef;
|
||||||
if (entry.GetRef(&resolvedRef) == B_OK)
|
if (entry.GetRef(&resolvedRef) == B_OK)
|
||||||
SpringLoadedFolderAddUniqueTypeToList(&resolvedRef, typeslist);
|
SpringLoadedFolderAddUniqueTypeToList(&resolvedRef, typeslist);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// scan the current list, don't add dups
|
// scan the current list, don't add dups
|
||||||
bool unique = true;
|
bool unique = true;
|
||||||
int32 count = typeslist->CountItems();
|
int32 count = typeslist->CountItems();
|
||||||
@@ -209,33 +213,34 @@ SpringLoadedFolderAddUniqueTypeToList(entry_ref *ref, BObjectList<BString> *type
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (unique)
|
if (unique)
|
||||||
typeslist->AddItem(new BString(mimestr));
|
typeslist->AddItem(new BString(mimestr));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
SpringLoadedFolderCacheDragData(const BMessage *incoming, BMessage **message, BObjectList<BString> **typeslist)
|
SpringLoadedFolderCacheDragData(const BMessage* incoming, BMessage* *message,
|
||||||
|
BObjectList<BString> **typeslist)
|
||||||
{
|
{
|
||||||
if (!incoming)
|
if (!incoming)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
delete *message;
|
delete *message;
|
||||||
delete *typeslist;
|
delete *typeslist;
|
||||||
|
|
||||||
BMessage *localMessage = new BMessage(*incoming);
|
BMessage* localMessage = new BMessage(*incoming);
|
||||||
BObjectList<BString> *localTypesList = new BObjectList<BString>(10, true);
|
BObjectList<BString> *localTypesList = new BObjectList<BString>(10, true);
|
||||||
|
|
||||||
for (int32 index=0; incoming->HasRef("refs", index); index++) {
|
for (int32 index = 0; incoming->HasRef("refs", index); index++) {
|
||||||
entry_ref ref;
|
entry_ref ref;
|
||||||
if (incoming->FindRef("refs", index, &ref) != B_OK)
|
if (incoming->FindRef("refs", index, &ref) != B_OK)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
SpringLoadedFolderAddUniqueTypeToList(&ref, localTypesList);
|
SpringLoadedFolderAddUniqueTypeToList(&ref, localTypesList);
|
||||||
}
|
}
|
||||||
|
|
||||||
*message = localMessage;
|
*message = localMessage;
|
||||||
*typeslist = localTypesList;
|
*typeslist = localTypesList;
|
||||||
}
|
}
|
||||||
@@ -249,8 +254,8 @@ SpringLoadedFolderCacheDragData(const BMessage *incoming, BMessage **message, BO
|
|||||||
#undef B_TRANSLATE_CONTEXT
|
#undef B_TRANSLATE_CONTEXT
|
||||||
#define B_TRANSLATE_CONTEXT "NavMenu"
|
#define B_TRANSLATE_CONTEXT "NavMenu"
|
||||||
|
|
||||||
BNavMenu::BNavMenu(const char *title, uint32 message, const BHandler *target,
|
BNavMenu::BNavMenu(const char* title, uint32 message, const BHandler* target,
|
||||||
BWindow *parentWindow, const BObjectList<BString> *list)
|
BWindow* parentWindow, const BObjectList<BString> *list)
|
||||||
: BSlowMenu(title),
|
: BSlowMenu(title),
|
||||||
fMessage(message),
|
fMessage(message),
|
||||||
fMessenger(target, target->Looper()),
|
fMessenger(target, target->Looper()),
|
||||||
@@ -266,7 +271,8 @@ BNavMenu::BNavMenu(const char *title, uint32 message, const BHandler *target,
|
|||||||
|
|
||||||
// add the parent window to the invocation message so that it
|
// add the parent window to the invocation message so that it
|
||||||
// can be closed if option modifier held down during invocation
|
// can be closed if option modifier held down during invocation
|
||||||
BContainerWindow *originatingWindow = dynamic_cast<BContainerWindow *>(fParentWindow);
|
BContainerWindow* originatingWindow =
|
||||||
|
dynamic_cast<BContainerWindow *>(fParentWindow);
|
||||||
if (originatingWindow)
|
if (originatingWindow)
|
||||||
fMessage.AddData("nodeRefsToClose", B_RAW_TYPE,
|
fMessage.AddData("nodeRefsToClose", B_RAW_TYPE,
|
||||||
originatingWindow->TargetModel()->NodeRef(), sizeof (node_ref));
|
originatingWindow->TargetModel()->NodeRef(), sizeof (node_ref));
|
||||||
@@ -276,8 +282,9 @@ BNavMenu::BNavMenu(const char *title, uint32 message, const BHandler *target,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
BNavMenu::BNavMenu(const char *title, uint32 message, const BMessenger &messenger,
|
BNavMenu::BNavMenu(const char* title, uint32 message,
|
||||||
BWindow *parentWindow, const BObjectList<BString> *list)
|
const BMessenger& messenger, BWindow* parentWindow,
|
||||||
|
const BObjectList<BString> *list)
|
||||||
: BSlowMenu(title),
|
: BSlowMenu(title),
|
||||||
fMessage(message),
|
fMessage(message),
|
||||||
fMessenger(messenger),
|
fMessenger(messenger),
|
||||||
@@ -293,7 +300,8 @@ BNavMenu::BNavMenu(const char *title, uint32 message, const BMessenger &messenge
|
|||||||
|
|
||||||
// add the parent window to the invocation message so that it
|
// add the parent window to the invocation message so that it
|
||||||
// can be closed if option modifier held down during invocation
|
// can be closed if option modifier held down during invocation
|
||||||
BContainerWindow *originatingWindow = dynamic_cast<BContainerWindow *>(fParentWindow);
|
BContainerWindow* originatingWindow =
|
||||||
|
dynamic_cast<BContainerWindow *>(fParentWindow);
|
||||||
if (originatingWindow)
|
if (originatingWindow)
|
||||||
fMessage.AddData("nodeRefsToClose", B_RAW_TYPE,
|
fMessage.AddData("nodeRefsToClose", B_RAW_TYPE,
|
||||||
originatingWindow->TargetModel()->NodeRef(), sizeof (node_ref));
|
originatingWindow->TargetModel()->NodeRef(), sizeof (node_ref));
|
||||||
@@ -312,7 +320,7 @@ void
|
|||||||
BNavMenu::AttachedToWindow()
|
BNavMenu::AttachedToWindow()
|
||||||
{
|
{
|
||||||
BSlowMenu::AttachedToWindow();
|
BSlowMenu::AttachedToWindow();
|
||||||
|
|
||||||
SpringLoadedFolderSetMenuStates(this, fTypesList);
|
SpringLoadedFolderSetMenuStates(this, fTypesList);
|
||||||
// if dragging (fTypesList != NULL)
|
// if dragging (fTypesList != NULL)
|
||||||
// set the menu items enabled state
|
// set the menu items enabled state
|
||||||
@@ -343,7 +351,7 @@ BNavMenu::ResetTargets()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
BNavMenu::ForceRebuild()
|
BNavMenu::ForceRebuild()
|
||||||
{
|
{
|
||||||
ClearMenuBuildingState();
|
ClearMenuBuildingState();
|
||||||
@@ -351,7 +359,7 @@ BNavMenu::ForceRebuild()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool
|
bool
|
||||||
BNavMenu::NeedsToRebuild() const
|
BNavMenu::NeedsToRebuild() const
|
||||||
{
|
{
|
||||||
return !fMenuBuilt;
|
return !fMenuBuilt;
|
||||||
@@ -359,11 +367,11 @@ BNavMenu::NeedsToRebuild() const
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
BNavMenu::SetNavDir(const entry_ref *ref)
|
BNavMenu::SetNavDir(const entry_ref* ref)
|
||||||
{
|
{
|
||||||
ForceRebuild();
|
ForceRebuild();
|
||||||
// reset the slow menu building mechanism so we can add more stuff
|
// reset the slow menu building mechanism so we can add more stuff
|
||||||
|
|
||||||
fNavDir = *ref;
|
fNavDir = *ref;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -378,7 +386,7 @@ BNavMenu::ClearMenuBuildingState()
|
|||||||
// they didn't get added to the menu
|
// they didn't get added to the menu
|
||||||
if (fItemList) {
|
if (fItemList) {
|
||||||
int32 count = fItemList->CountItems();
|
int32 count = fItemList->CountItems();
|
||||||
for (int32 index = count - 1; index >= 0; index--)
|
for (int32 index = count - 1; index >= 0; index--)
|
||||||
delete RemoveItem(index);
|
delete RemoveItem(index);
|
||||||
delete fItemList;
|
delete fItemList;
|
||||||
fItemList = NULL;
|
fItemList = NULL;
|
||||||
@@ -392,30 +400,32 @@ BNavMenu::StartBuildingItemList()
|
|||||||
BEntry entry;
|
BEntry entry;
|
||||||
|
|
||||||
if (fNavDir.device < 0 || entry.SetTo(&fNavDir) != B_OK
|
if (fNavDir.device < 0 || entry.SetTo(&fNavDir) != B_OK
|
||||||
|| !entry.Exists())
|
|| !entry.Exists())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
fItemList = new BObjectList<BMenuItem>(50);
|
fItemList = new BObjectList<BMenuItem>(50);
|
||||||
|
|
||||||
fIteratingDesktop = false;
|
fIteratingDesktop = false;
|
||||||
|
|
||||||
BDirectory parent;
|
BDirectory parent;
|
||||||
status_t status = entry.GetParent(&parent);
|
status_t status = entry.GetParent(&parent);
|
||||||
|
|
||||||
// if ref is the root item then build list of volume root dirs
|
// if ref is the root item then build list of volume root dirs
|
||||||
fFlags = uint8((fFlags & ~kVolumesOnly) | (status == B_ENTRY_NOT_FOUND ? kVolumesOnly : 0));
|
fFlags = uint8((fFlags & ~kVolumesOnly)
|
||||||
|
| (status == B_ENTRY_NOT_FOUND ? kVolumesOnly : 0));
|
||||||
if (fFlags & kVolumesOnly)
|
if (fFlags & kVolumesOnly)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
Model startModel(&entry, true);
|
Model startModel(&entry, true);
|
||||||
if (startModel.InitCheck() != B_OK || !startModel.IsContainer())
|
if (startModel.InitCheck() != B_OK || !startModel.IsContainer())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (startModel.IsQuery())
|
if (startModel.IsQuery())
|
||||||
fContainer = new QueryEntryListCollection(&startModel);
|
fContainer = new QueryEntryListCollection(&startModel);
|
||||||
else if (startModel.IsDesktop()) {
|
else if (startModel.IsDesktop()) {
|
||||||
fIteratingDesktop = true;
|
fIteratingDesktop = true;
|
||||||
fContainer = DesktopPoseView::InitDesktopDirentIterator(0, startModel.EntryRef());
|
fContainer = DesktopPoseView::InitDesktopDirentIterator(
|
||||||
|
0, startModel.EntryRef());
|
||||||
AddRootItemsIfNeeded();
|
AddRootItemsIfNeeded();
|
||||||
AddTrashItem();
|
AddTrashItem();
|
||||||
} else if (startModel.IsTrash()) {
|
} else if (startModel.IsTrash()) {
|
||||||
@@ -425,13 +435,13 @@ BNavMenu::StartBuildingItemList()
|
|||||||
volRoster.Rewind();
|
volRoster.Rewind();
|
||||||
BVolume volume;
|
BVolume volume;
|
||||||
fContainer = new EntryIteratorList();
|
fContainer = new EntryIteratorList();
|
||||||
|
|
||||||
while (volRoster.GetNextVolume(&volume) == B_OK) {
|
while (volRoster.GetNextVolume(&volume) == B_OK) {
|
||||||
if (volume.IsReadOnly() || !volume.IsPersistent())
|
if (volume.IsReadOnly() || !volume.IsPersistent())
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
BDirectory trashDir;
|
BDirectory trashDir;
|
||||||
|
|
||||||
if (FSGetTrashDir(&trashDir, volume.Device()) == B_OK)
|
if (FSGetTrashDir(&trashDir, volume.Device()) == B_OK)
|
||||||
dynamic_cast<EntryIteratorList *>(fContainer)->
|
dynamic_cast<EntryIteratorList *>(fContainer)->
|
||||||
AddItem(new DirectoryEntryList(trashDir));
|
AddItem(new DirectoryEntryList(trashDir));
|
||||||
@@ -508,7 +518,7 @@ BNavMenu::AddNextItem()
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
QueryEntryListCollection *queryContainer
|
QueryEntryListCollection* queryContainer
|
||||||
= dynamic_cast<QueryEntryListCollection*>(fContainer);
|
= dynamic_cast<QueryEntryListCollection*>(fContainer);
|
||||||
if (queryContainer && !queryContainer->ShowResultsFromTrash()
|
if (queryContainer && !queryContainer->ShowResultsFromTrash()
|
||||||
&& FSInTrashDir(model.EntryRef())) {
|
&& FSInTrashDir(model.EntryRef())) {
|
||||||
@@ -519,12 +529,12 @@ BNavMenu::AddNextItem()
|
|||||||
ssize_t size = -1;
|
ssize_t size = -1;
|
||||||
PoseInfo poseInfo;
|
PoseInfo poseInfo;
|
||||||
|
|
||||||
if (model.Node())
|
if (model.Node())
|
||||||
size = model.Node()->ReadAttr(kAttrPoseInfo, B_RAW_TYPE, 0,
|
size = model.Node()->ReadAttr(kAttrPoseInfo, B_RAW_TYPE, 0,
|
||||||
&poseInfo, sizeof(poseInfo));
|
&poseInfo, sizeof(poseInfo));
|
||||||
|
|
||||||
model.CloseNode();
|
model.CloseNode();
|
||||||
|
|
||||||
// item might be in invisible
|
// item might be in invisible
|
||||||
if (size == sizeof(poseInfo)
|
if (size == sizeof(poseInfo)
|
||||||
&& !BPoseView::PoseVisible(&model, &poseInfo))
|
&& !BPoseView::PoseVisible(&model, &poseInfo))
|
||||||
@@ -535,10 +545,10 @@ BNavMenu::AddNextItem()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
BNavMenu::AddOneItem(Model *model)
|
BNavMenu::AddOneItem(Model* model)
|
||||||
{
|
{
|
||||||
BMenuItem *item = NewModelItem(model, &fMessage, fMessenger, false,
|
BMenuItem* item = NewModelItem(model, &fMessage, fMessenger, false,
|
||||||
dynamic_cast<BContainerWindow *>(fParentWindow),
|
dynamic_cast<BContainerWindow *>(fParentWindow),
|
||||||
fTypesList, &fTrackingHook);
|
fTypesList, &fTrackingHook);
|
||||||
|
|
||||||
@@ -547,20 +557,20 @@ BNavMenu::AddOneItem(Model *model)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
ModelMenuItem *
|
ModelMenuItem*
|
||||||
BNavMenu::NewModelItem(Model *model, const BMessage *invokeMessage,
|
BNavMenu::NewModelItem(Model* model, const BMessage* invokeMessage,
|
||||||
const BMessenger &target, bool suppressFolderHierarchy,
|
const BMessenger& target, bool suppressFolderHierarchy,
|
||||||
BContainerWindow *parentWindow, const BObjectList<BString> *typeslist,
|
BContainerWindow* parentWindow, const BObjectList<BString> *typeslist,
|
||||||
TrackingHookData *hook)
|
TrackingHookData* hook)
|
||||||
{
|
{
|
||||||
if (model->InitCheck() != B_OK)
|
if (model->InitCheck() != B_OK)
|
||||||
return 0;
|
return 0;
|
||||||
entry_ref ref;
|
entry_ref ref;
|
||||||
bool container = false;
|
bool container = false;
|
||||||
if (model->IsSymLink()) {
|
if (model->IsSymLink()) {
|
||||||
|
|
||||||
Model *newResolvedModel = 0;
|
Model* newResolvedModel = 0;
|
||||||
Model *result = model->LinkTo();
|
Model* result = model->LinkTo();
|
||||||
|
|
||||||
if (!result) {
|
if (!result) {
|
||||||
newResolvedModel = new Model(model->EntryRef(), true, true);
|
newResolvedModel = new Model(model->EntryRef(), true, true);
|
||||||
@@ -576,17 +586,17 @@ BNavMenu::NewModelItem(Model *model, const BMessage *invokeMessage,
|
|||||||
if (result) {
|
if (result) {
|
||||||
BModelOpener opener(result);
|
BModelOpener opener(result);
|
||||||
// open the model, if it ain't open already
|
// open the model, if it ain't open already
|
||||||
|
|
||||||
PoseInfo poseInfo;
|
PoseInfo poseInfo;
|
||||||
ssize_t size = -1;
|
ssize_t size = -1;
|
||||||
|
|
||||||
if (result->Node())
|
if (result->Node())
|
||||||
size = result->Node()->ReadAttr(kAttrPoseInfo, B_RAW_TYPE, 0,
|
size = result->Node()->ReadAttr(kAttrPoseInfo, B_RAW_TYPE, 0,
|
||||||
&poseInfo, sizeof(poseInfo));
|
&poseInfo, sizeof(poseInfo));
|
||||||
|
|
||||||
result->CloseNode();
|
result->CloseNode();
|
||||||
|
|
||||||
if (size == sizeof(poseInfo) && !BPoseView::PoseVisible(result,
|
if (size == sizeof(poseInfo) && !BPoseView::PoseVisible(result,
|
||||||
&poseInfo)) {
|
&poseInfo)) {
|
||||||
// link target does not want to be visible
|
// link target does not want to be visible
|
||||||
delete newResolvedModel;
|
delete newResolvedModel;
|
||||||
@@ -602,7 +612,7 @@ BNavMenu::NewModelItem(Model *model, const BMessage *invokeMessage,
|
|||||||
container = model->IsContainer();
|
container = model->IsContainer();
|
||||||
}
|
}
|
||||||
|
|
||||||
BMessage *message = new BMessage(*invokeMessage);
|
BMessage* message = new BMessage(*invokeMessage);
|
||||||
message->AddRef("refs", model->EntryRef());
|
message->AddRef("refs", model->EntryRef());
|
||||||
|
|
||||||
// Truncate the name if necessary
|
// Truncate the name if necessary
|
||||||
@@ -610,7 +620,7 @@ BNavMenu::NewModelItem(Model *model, const BMessage *invokeMessage,
|
|||||||
be_plain_font->TruncateString(&truncatedString, B_TRUNCATE_END,
|
be_plain_font->TruncateString(&truncatedString, B_TRUNCATE_END,
|
||||||
GetMaxMenuWidth());
|
GetMaxMenuWidth());
|
||||||
|
|
||||||
ModelMenuItem *item = NULL;
|
ModelMenuItem* item = NULL;
|
||||||
if (!container || suppressFolderHierarchy) {
|
if (!container || suppressFolderHierarchy) {
|
||||||
item = new ModelMenuItem(model, truncatedString.String(), message);
|
item = new ModelMenuItem(model, truncatedString.String(), message);
|
||||||
if (invokeMessage->what != B_REFS_RECEIVED)
|
if (invokeMessage->what != B_REFS_RECEIVED)
|
||||||
@@ -618,9 +628,9 @@ BNavMenu::NewModelItem(Model *model, const BMessage *invokeMessage,
|
|||||||
// the above is broken for FavoritesMenu::AddNextItem, which uses a
|
// the above is broken for FavoritesMenu::AddNextItem, which uses a
|
||||||
// workaround - should fix this
|
// workaround - should fix this
|
||||||
} else {
|
} else {
|
||||||
BNavMenu *menu = new BNavMenu(truncatedString.String(),
|
BNavMenu* menu = new BNavMenu(truncatedString.String(),
|
||||||
invokeMessage->what, target, parentWindow, typeslist);
|
invokeMessage->what, target, parentWindow, typeslist);
|
||||||
|
|
||||||
menu->SetNavDir(&ref);
|
menu->SetNavDir(&ref);
|
||||||
if (hook)
|
if (hook)
|
||||||
menu->InitTrackingHook(hook->fTrackingHook, &(hook->fTarget),
|
menu->InitTrackingHook(hook->fTrackingHook, &(hook->fTarget),
|
||||||
@@ -629,7 +639,7 @@ BNavMenu::NewModelItem(Model *model, const BMessage *invokeMessage,
|
|||||||
item = new ModelMenuItem(model, menu);
|
item = new ModelMenuItem(model, menu);
|
||||||
item->SetMessage(message);
|
item->SetMessage(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
return item;
|
return item;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -642,48 +652,48 @@ BNavMenu::BuildVolumeMenu()
|
|||||||
|
|
||||||
roster.Rewind();
|
roster.Rewind();
|
||||||
while (roster.GetNextVolume(&volume) == B_OK) {
|
while (roster.GetNextVolume(&volume) == B_OK) {
|
||||||
|
|
||||||
if (!volume.IsPersistent())
|
if (!volume.IsPersistent())
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
BDirectory startDir;
|
BDirectory startDir;
|
||||||
if (volume.GetRootDirectory(&startDir) == B_OK) {
|
if (volume.GetRootDirectory(&startDir) == B_OK) {
|
||||||
BEntry entry;
|
BEntry entry;
|
||||||
startDir.GetEntry(&entry);
|
startDir.GetEntry(&entry);
|
||||||
|
|
||||||
Model *model = new Model(&entry);
|
Model* model = new Model(&entry);
|
||||||
if (model->InitCheck() != B_OK) {
|
if (model->InitCheck() != B_OK) {
|
||||||
delete model;
|
delete model;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
BNavMenu *menu = new BNavMenu(model->Name(), fMessage.what,
|
BNavMenu* menu = new BNavMenu(model->Name(), fMessage.what,
|
||||||
fMessenger, fParentWindow, fTypesList);
|
fMessenger, fParentWindow, fTypesList);
|
||||||
|
|
||||||
menu->SetNavDir(model->EntryRef());
|
menu->SetNavDir(model->EntryRef());
|
||||||
|
|
||||||
ASSERT(menu->Name());
|
ASSERT(menu->Name());
|
||||||
|
|
||||||
ModelMenuItem *item = new ModelMenuItem(model, menu);
|
ModelMenuItem* item = new ModelMenuItem(model, menu);
|
||||||
BMessage *message = new BMessage(fMessage);
|
BMessage* message = new BMessage(fMessage);
|
||||||
|
|
||||||
message->AddRef("refs", model->EntryRef());
|
message->AddRef("refs", model->EntryRef());
|
||||||
|
|
||||||
item->SetMessage(message);
|
item->SetMessage(message);
|
||||||
fItemList->AddItem(item);
|
fItemList->AddItem(item);
|
||||||
ASSERT(item->Label());
|
ASSERT(item->Label());
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int
|
int
|
||||||
BNavMenu::CompareFolderNamesFirstOne(const BMenuItem *i1, const BMenuItem *i2)
|
BNavMenu::CompareFolderNamesFirstOne(const BMenuItem* i1, const BMenuItem* i2)
|
||||||
{
|
{
|
||||||
const ModelMenuItem *item1 = dynamic_cast<const ModelMenuItem *>(i1);
|
const ModelMenuItem* item1 = dynamic_cast<const ModelMenuItem *>(i1);
|
||||||
const ModelMenuItem *item2 = dynamic_cast<const ModelMenuItem *>(i2);
|
const ModelMenuItem* item2 = dynamic_cast<const ModelMenuItem *>(i2);
|
||||||
|
|
||||||
if (item1 != NULL && item2 != NULL)
|
if (item1 != NULL && item2 != NULL)
|
||||||
return item1->TargetModel()->CompareFolderNamesFirst(item2->TargetModel());
|
return item1->TargetModel()->CompareFolderNamesFirst(item2->TargetModel());
|
||||||
|
|
||||||
@@ -692,7 +702,7 @@ BNavMenu::CompareFolderNamesFirstOne(const BMenuItem *i1, const BMenuItem *i2)
|
|||||||
|
|
||||||
|
|
||||||
int
|
int
|
||||||
BNavMenu::CompareOne(const BMenuItem *i1, const BMenuItem *i2)
|
BNavMenu::CompareOne(const BMenuItem* i1, const BMenuItem* i2)
|
||||||
{
|
{
|
||||||
return strcasecmp(i1->Label(), i2->Label());
|
return strcasecmp(i1->Label(), i2->Label());
|
||||||
}
|
}
|
||||||
@@ -716,18 +726,19 @@ BNavMenu::DoneBuildingItemList()
|
|||||||
if (!directory.IsRootDirectory()
|
if (!directory.IsRootDirectory()
|
||||||
&& entry.GetParent(&entry) == B_OK) {
|
&& entry.GetParent(&entry) == B_OK) {
|
||||||
Model model(&entry, true);
|
Model model(&entry, true);
|
||||||
BLooper *looper;
|
BLooper* looper;
|
||||||
AddNavParentDir(&model,fMessage.what,fMessenger.Target(&looper));
|
AddNavParentDir(&model, fMessage.what,
|
||||||
|
fMessenger.Target(&looper));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int32 count = fItemList->CountItems();
|
int32 count = fItemList->CountItems();
|
||||||
for (int32 index = 0; index < count; index++)
|
for (int32 index = 0; index < count; index++)
|
||||||
AddItem(fItemList->ItemAt(index));
|
AddItem(fItemList->ItemAt(index));
|
||||||
fItemList->MakeEmpty();
|
fItemList->MakeEmpty();
|
||||||
|
|
||||||
if (!count) {
|
if (!count) {
|
||||||
BMenuItem *item = new BMenuItem(B_TRANSLATE("Empty folder"), 0);
|
BMenuItem* item = new BMenuItem(B_TRANSLATE("Empty folder"), 0);
|
||||||
item->SetEnabled(false);
|
item->SetEnabled(false);
|
||||||
AddItem(item);
|
AddItem(item);
|
||||||
}
|
}
|
||||||
@@ -744,22 +755,22 @@ BNavMenu::GetMaxMenuWidth(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
BNavMenu::AddNavDir(const Model *model, uint32 what, BHandler *target,
|
BNavMenu::AddNavDir(const Model* model, uint32 what, BHandler* target,
|
||||||
bool populateSubmenu)
|
bool populateSubmenu)
|
||||||
{
|
{
|
||||||
BMessage *message = new BMessage((uint32)what);
|
BMessage* message = new BMessage((uint32)what);
|
||||||
message->AddRef("refs", model->EntryRef());
|
message->AddRef("refs", model->EntryRef());
|
||||||
ModelMenuItem *item = NULL;
|
ModelMenuItem* item = NULL;
|
||||||
|
|
||||||
if (populateSubmenu) {
|
if (populateSubmenu) {
|
||||||
BNavMenu *navMenu = new BNavMenu(model->Name(), what, target);
|
BNavMenu* navMenu = new BNavMenu(model->Name(), what, target);
|
||||||
navMenu->SetNavDir(model->EntryRef());
|
navMenu->SetNavDir(model->EntryRef());
|
||||||
navMenu->InitTrackingHook(fTrackingHook.fTrackingHook, &(fTrackingHook.fTarget),
|
navMenu->InitTrackingHook(fTrackingHook.fTrackingHook,
|
||||||
fTrackingHook.fDragMessage);
|
&(fTrackingHook.fTarget), fTrackingHook.fDragMessage);
|
||||||
item = new ModelMenuItem(model, navMenu);
|
item = new ModelMenuItem(model, navMenu);
|
||||||
item->SetMessage(message);
|
item->SetMessage(message);
|
||||||
} else
|
} else
|
||||||
item = new ModelMenuItem(model, model->Name(), message);
|
item = new ModelMenuItem(model, model->Name(), message);
|
||||||
|
|
||||||
AddItem(item);
|
AddItem(item);
|
||||||
@@ -767,17 +778,18 @@ BNavMenu::AddNavDir(const Model *model, uint32 what, BHandler *target,
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
BNavMenu::AddNavParentDir(const char *name,const Model *model,uint32 what,BHandler *target)
|
BNavMenu::AddNavParentDir(const char* name,const Model* model,
|
||||||
|
uint32 what, BHandler* target)
|
||||||
{
|
{
|
||||||
BNavMenu *menu = new BNavMenu(name,what,target);
|
BNavMenu* menu = new BNavMenu(name, what, target);
|
||||||
menu->SetNavDir(model->EntryRef());
|
menu->SetNavDir(model->EntryRef());
|
||||||
menu->SetShowParent(true);
|
menu->SetShowParent(true);
|
||||||
menu->InitTrackingHook(fTrackingHook.fTrackingHook, &(fTrackingHook.fTarget),
|
menu->InitTrackingHook(fTrackingHook.fTrackingHook, &(fTrackingHook.fTarget),
|
||||||
fTrackingHook.fDragMessage);
|
fTrackingHook.fDragMessage);
|
||||||
|
|
||||||
BMenuItem *item = new SpecialModelMenuItem(model,menu);
|
BMenuItem* item = new SpecialModelMenuItem(model, menu);
|
||||||
|
|
||||||
BMessage *message = new BMessage(what);
|
BMessage* message = new BMessage(what);
|
||||||
message->AddRef("refs",model->EntryRef());
|
message->AddRef("refs",model->EntryRef());
|
||||||
item->SetMessage(message);
|
item->SetMessage(message);
|
||||||
|
|
||||||
@@ -786,9 +798,9 @@ BNavMenu::AddNavParentDir(const char *name,const Model *model,uint32 what,BHandl
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
BNavMenu::AddNavParentDir(const Model *model, uint32 what, BHandler *target)
|
BNavMenu::AddNavParentDir(const Model* model, uint32 what, BHandler* target)
|
||||||
{
|
{
|
||||||
AddNavParentDir("parent folder",model,what,target);
|
AddNavParentDir(B_TRANSLATE("parent folder"),model, what, target);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -814,7 +826,7 @@ BNavMenu::TypesList() const
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
BNavMenu::SetTarget(const BMessenger &msngr)
|
BNavMenu::SetTarget(const BMessenger& msngr)
|
||||||
{
|
{
|
||||||
fMessenger = msngr;
|
fMessenger = msngr;
|
||||||
}
|
}
|
||||||
@@ -827,9 +839,9 @@ BNavMenu::Target()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
TrackingHookData *
|
TrackingHookData*
|
||||||
BNavMenu::InitTrackingHook(bool (*hook)(BMenu *, void *), const BMessenger *target,
|
BNavMenu::InitTrackingHook(bool (*hook)(BMenu*, void*),
|
||||||
const BMessage *dragMessage)
|
const BMessenger* target, const BMessage* dragMessage)
|
||||||
{
|
{
|
||||||
fTrackingHook.fTrackingHook = hook;
|
fTrackingHook.fTrackingHook = hook;
|
||||||
if (target)
|
if (target)
|
||||||
@@ -840,17 +852,18 @@ BNavMenu::InitTrackingHook(bool (*hook)(BMenu *, void *), const BMessenger *targ
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
BNavMenu::SetTrackingHookDeep(BMenu *menu, bool (*func)(BMenu *, void *), void *state)
|
BNavMenu::SetTrackingHookDeep(BMenu* menu, bool (*func)(BMenu*, void*),
|
||||||
|
void* state)
|
||||||
{
|
{
|
||||||
menu->SetTrackingHook(func, state);
|
menu->SetTrackingHook(func, state);
|
||||||
int32 count = menu->CountItems();
|
int32 count = menu->CountItems();
|
||||||
for (int32 index = 0 ; index < count; index++) {
|
for (int32 index = 0 ; index < count; index++) {
|
||||||
BMenuItem *item = menu->ItemAt(index);
|
BMenuItem* item = menu->ItemAt(index);
|
||||||
if (!item)
|
if (!item)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
BMenu *submenu = item->Submenu();
|
BMenu* submenu = item->Submenu();
|
||||||
if (submenu)
|
if (submenu)
|
||||||
SetTrackingHookDeep(submenu, func, state);
|
SetTrackingHookDeep(submenu, func, state);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user