From 15a27c4d5b04acd120084d0aa344344016ec9a46 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Axel=20D=C3=B6rfler?= Date: Fri, 22 Aug 2008 11:22:52 +0000 Subject: [PATCH] * Whitespace cleanup, no functional change. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@27141 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/kits/tracker/ContainerWindow.cpp | 311 +++++++++++++-------------- src/kits/tracker/ContainerWindow.h | 16 +- 2 files changed, 163 insertions(+), 164 deletions(-) diff --git a/src/kits/tracker/ContainerWindow.cpp b/src/kits/tracker/ContainerWindow.cpp index e358e3a113..ed6e04145c 100644 --- a/src/kits/tracker/ContainerWindow.cpp +++ b/src/kits/tracker/ContainerWindow.cpp @@ -154,7 +154,7 @@ ActivateWindowFilter(BMessage *, BHandler **target, BMessageFilter *) && view->Window()) view->Window()->Activate(true); - return B_DISPATCH_MESSAGE; + return B_DISPATCH_MESSAGE; } @@ -248,10 +248,10 @@ AddOnThread(BMessage *refsMessage, entry_ref addonRef, entry_ref dirRef) // call add-on code (*processRefs)(dirRef, refsMessagePtr.get(), 0); - + unload_add_on(addonImage); return B_OK; - } else + } else PRINT(("couldn't find process_refs\n")); unload_add_on(addonImage); @@ -266,7 +266,7 @@ AddOnThread(BMessage *refsMessage, entry_ref addonRef, entry_ref dirRef) B_WIDTH_AS_USUAL, B_WARNING_ALERT); alert->SetShortcut(0, B_ESCAPE); alert->Go(); - + return result; } @@ -288,10 +288,10 @@ OffsetFrameOne(const char *DEBUG_ONLY(name), uint32, off_t, void *castToRect, if (!params->rectFromParent) return false; - + if (!castToRect) return false; - + ((BRect *)castToRect)->OffsetBy(kWindowStaggerBy, kWindowStaggerBy); return true; } @@ -428,7 +428,7 @@ DraggableContainerIcon::MouseMoved(BPoint point, uint32 /*transit*/, // See if we need to truncate the string BString nameString = model->Name(); - if (view->StringWidth(model->Name()) > rect.Width()) + if (view->StringWidth(model->Name()) > rect.Width()) view->TruncateString(&nameString, B_TRUNCATE_END, rect.Width() - 5); // Draw the label @@ -608,7 +608,7 @@ BContainerWindow::~BContainerWindow() } -BRect +BRect BContainerWindow::InitialWindowRect(window_feel feel) { if (feel != kPrivateDesktopWindowFeel) @@ -660,7 +660,7 @@ BContainerWindow::Quit() delete fNavigationItem; fNavigationItem = NULL; } - + if (fOpenWithItem && !fOpenWithItem->Menu()) { delete fOpenWithItem; fOpenWithItem = NULL; @@ -685,7 +685,7 @@ BContainerWindow::Quit() delete fAttrMenu; fAttrMenu = NULL; } - + delete fFileContextMenu; fFileContextMenu = NULL; delete fWindowContextMenu; @@ -696,9 +696,9 @@ BContainerWindow::Quit() fVolumeContextMenu = NULL; delete fDragContextMenu; fDragContextMenu = NULL; - + int32 windowCount = 0; - + // This is a deadlock code sequence - need to change this // to acquire the window list while this container window is unlocked if (fWindowList) { @@ -730,7 +730,7 @@ void BContainerWindow::UpdateIfTrash(Model *model) { BEntry entry(model->EntryRef()); - + if (entry.InitCheck() == B_OK) { fIsTrash = FSIsTrashDir(&entry); fInTrash = FSInTrashDir(model->EntryRef()); @@ -744,7 +744,7 @@ BContainerWindow::CreatePoseView(Model *model) { UpdateIfTrash(model); BRect rect(Bounds()); - + TrackerSettings settings; if (settings.SingleWindowBrowse() && settings.ShowNavigator() @@ -772,14 +772,14 @@ BContainerWindow::CreatePoseView(Model *model) } -void +void BContainerWindow::AddContextMenus() { // create context sensitive menus fFileContextMenu = new BPopUpMenu("FileContext", false, false); fFileContextMenu->SetFont(be_plain_font); AddFileContextMenus(fFileContextMenu); - + fVolumeContextMenu = new BPopUpMenu("VolumeContext", false, false); fVolumeContextMenu->SetFont(be_plain_font); AddVolumeContextMenus(fVolumeContextMenu); @@ -791,7 +791,7 @@ BContainerWindow::AddContextMenus() fDropContextMenu = new BPopUpMenu("DropContext", false, false); fDropContextMenu->SetFont(be_plain_font); AddDropContextMenus(fDropContextMenu); - + fDragContextMenu = new BSlowContextMenu("DragContext"); // will get added and built dynamically in ShowContextMenu } @@ -918,7 +918,7 @@ BContainerWindow::Init(const BMessage *message) if (iconSize < 16) iconSize = 16; float iconPosY = 1 + (fMenuBar->Bounds().Height() - 2 - iconSize) / 2; - BView *icon = new DraggableContainerIcon(BRect(Bounds().Width() - 4 - iconSize + 1, + BView *icon = new DraggableContainerIcon(BRect(Bounds().Width() - 4 - iconSize + 1, iconPosY, Bounds().Width() - 4, iconPosY + iconSize - 1), "ThisContainer", B_FOLLOW_RIGHT); fMenuBar->AddChild(icon); @@ -979,7 +979,7 @@ void BContainerWindow::RestoreState() { SetSizeLimits(kContainerWidthMinLimit, 10000, kContainerWindowHeightLimit, 10000); - + UpdateTitle(); WindowStateNodeOpener opener(this, false); @@ -994,12 +994,12 @@ void BContainerWindow::RestoreState(const BMessage &message) { SetSizeLimits(kContainerWidthMinLimit, 10000, kContainerWindowHeightLimit, 10000); - + UpdateTitle(); RestoreWindowState(message); fPoseView->Init(message); - + RestoreStateCommon(); } @@ -1023,10 +1023,10 @@ BContainerWindow::RestoreStateCommon() fBackgroundImage = BackgroundImage::GetBackgroundImage( opener.Node(), isDesktop); // look for background image info in the window's node - + BNode defaultingNode; if (!fBackgroundImage && !isDesktop - && DefaultStateSourceNode(kDefaultFolderTemplate, &defaultingNode)) + && DefaultStateSourceNode(kDefaultFolderTemplate, &defaultingNode)) // look for background image info in the source for defaults fBackgroundImage = BackgroundImage::GetBackgroundImage(&defaultingNode, isDesktop); } @@ -1038,15 +1038,15 @@ BContainerWindow::UpdateTitle() // set title to full path, if necessary if (TrackerSettings().ShowFullPathInTitleBar()) { // use the Entry's full path - BPath path; - TargetModel()->GetPath(&path); + BPath path; + TargetModel()->GetPath(&path); SetTitle(path.Path()); } else // use the default look SetTitle(TargetModel()->Name()); if (Navigator()) - Navigator()->UpdateLocation(PoseView()->TargetModel(), kActionUpdatePath); + Navigator()->UpdateLocation(PoseView()->TargetModel(), kActionUpdatePath); } @@ -1062,11 +1062,11 @@ BContainerWindow::UpdateBackgroundImage() if (!TargetModel()->IsRoot() && opener.Node()) fBackgroundImage = BackgroundImage::Refresh(fBackgroundImage, opener.Node(), isDesktop, PoseView()); - + // look for background image info in the window's node BNode defaultingNode; if (!fBackgroundImage && !isDesktop - && DefaultStateSourceNode(kDefaultFolderTemplate, &defaultingNode)) + && DefaultStateSourceNode(kDefaultFolderTemplate, &defaultingNode)) // look for background image info in the source for defaults fBackgroundImage = BackgroundImage::Refresh(fBackgroundImage, &defaultingNode, isDesktop, PoseView()); @@ -1077,20 +1077,20 @@ void BContainerWindow::FrameResized(float, float) { if (PoseView() && dynamic_cast(this) == NULL) { - BRect extent = PoseView()->Extent(); + BRect extent = PoseView()->Extent(); float offsetX = extent.left - PoseView()->Bounds().left; float offsetY = extent.top - PoseView()->Bounds().top; - + // scroll when the size augmented, there is a negative offset - // and we have resized over the bottom right corner of the extent + // and we have resized over the bottom right corner of the extent if (offsetX < 0 && PoseView()->Bounds().right > extent.right - && Bounds().Width() > fPreviousBounds.Width()) - PoseView()->ScrollBy(max_c(fPreviousBounds.Width() - Bounds().Width(), offsetX), 0); - - if (offsetY < 0 && PoseView()->Bounds().bottom > extent.bottom + && Bounds().Width() > fPreviousBounds.Width()) + PoseView()->ScrollBy(max_c(fPreviousBounds.Width() - Bounds().Width(), offsetX), 0); + + if (offsetY < 0 && PoseView()->Bounds().bottom > extent.bottom && Bounds().Height() > fPreviousBounds.Height()) PoseView()->ScrollBy(0, max_c(fPreviousBounds.Height() - Bounds().Height(), offsetY)); - + PoseView()->UpdateScrollRange(); PoseView()->ResetPosePlacementHint(); } @@ -1114,7 +1114,7 @@ BContainerWindow::WorkspacesChanged(uint32, uint32) } -void +void BContainerWindow::ViewModeChanged(uint32 oldMode, uint32 newMode) { BView *view = FindView("MenuBar"); @@ -1131,7 +1131,7 @@ BContainerWindow::ViewModeChanged(uint32 oldMode, uint32 newMode) if (newMode == kListMode) fBackgroundImage->Remove(); else if (oldMode == kListMode) - fBackgroundImage->Show(PoseView(), current_workspace()); + fBackgroundImage->Show(PoseView(), current_workspace()); } @@ -1183,11 +1183,11 @@ BContainerWindow::SaveState(BMessage &message) const bool BContainerWindow::StateNeedsSaving() const { - return fStateNeedsSaving || PoseView()->StateNeedsSaving(); + return fStateNeedsSaving || PoseView()->StateNeedsSaving(); } -status_t +status_t BContainerWindow::GetLayoutState(BNode *node, BMessage *message) { // ToDo: @@ -1221,7 +1221,7 @@ BContainerWindow::GetLayoutState(BNode *node, BMessage *message) } -status_t +status_t BContainerWindow::SetLayoutState(BNode *node, const BMessage *message) { status_t result = node->InitCheck(); @@ -1343,7 +1343,7 @@ BContainerWindow::ResizeToFit() PoseView()->ScrollBy( extent.left - PoseView()->Bounds().left, extent.top - PoseView()->Bounds().top); - + PoseView()->UpdateScrollRange(); PoseView()->EnableScrollBars(); } @@ -1384,7 +1384,7 @@ BContainerWindow::MessageReceived(BMessage *message) case kRestoreState: if (message->HasMessage("state")) { - BMessage state; + BMessage state; message->FindMessage("state", &state); Init(&state); } else @@ -1506,10 +1506,10 @@ BContainerWindow::MessageReceived(BMessage *message) if (Navigator()) { int32 action = kActionSet; if (message->FindInt32("action", &action) != B_OK) - // Design problem? Why does FindInt32 touch + // Design problem? Why does FindInt32 touch // 'action' at all if he can't find it?? action = kActionSet; - + Navigator()->UpdateLocation(PoseView()->TargetModel(), action); } @@ -1559,18 +1559,18 @@ BContainerWindow::MessageReceived(BMessage *message) list->AddItem(new entry_ref(dragref)); // // compare the target and one of the drag items' parent - // + // BEntry item(&dragref, true); BEntry itemparent; item.GetParent(&itemparent); entry_ref parentref; itemparent.GetRef(&parentref); - + entry_ref targetref; entry.GetRef(&targetref); // if they don't match, move/copy - if (targetref != parentref) + if (targetref != parentref) // copy drag contents to target ref in message FSMoveToFolder(list, new BEntry(entry), kMoveSelectionTo); @@ -1623,7 +1623,7 @@ BContainerWindow::MessageReceived(BMessage *message) if (IsPathWatchingEnabled() && !(settings.ShowNavigator() || settings.ShowFullPathInTitleBar())) SetPathWatchingEnabled(false); break; - + case kDontMoveFilesToTrashChanged: { bool dontMoveToTrash = settings.DontMoveFilesToTrash(); @@ -1645,7 +1645,7 @@ BContainerWindow::MessageReceived(BMessage *message) default: _inherited::MessageReceived(message); } - } + } break; } @@ -1762,7 +1762,7 @@ BContainerWindow::SetCleanUpItem(BMenu *menu) void BContainerWindow::SetCloseItem(BMenu *menu) { - BMenuItem *item; + BMenuItem *item; if ((item = menu->FindItem(B_QUIT_REQUESTED)) == NULL && (item = menu->FindItem(kCloseAllWindows)) == NULL) return; @@ -1826,7 +1826,7 @@ BContainerWindow::AddFileMenu(BMenu *menu) menu->AddItem(new BMenuItem("New Folder", new BMessage(kNewFolder), 'N')); } menu->AddSeparatorItem(); - + menu->AddItem(new BMenuItem("Open", new BMessage(kOpenSelection), 'O')); menu->AddItem(new BMenuItem("Get Info", new BMessage(kGetInfo), 'I')); menu->AddItem(new BMenuItem("Edit Name", new BMessage(kEditItem), 'E')); @@ -1857,7 +1857,7 @@ BContainerWindow::AddFileMenu(BMenu *menu) // at this place, have a look at: // BContainerWindow::SetupMoveCopyMenus() } - + BMenuItem *cutItem = NULL, *copyItem = NULL, *pasteItem = NULL; if (!IsPrintersDir()) { menu->AddSeparatorItem(); @@ -1867,7 +1867,7 @@ BContainerWindow::AddFileMenu(BMenu *menu) menu->AddItem(pasteItem = new BMenuItem("Paste", new BMessage(B_PASTE), 'V')); menu->AddSeparatorItem(); - + menu->AddItem(new BMenuItem("Identify", new BMessage(kIdentifyEntry))); BMenu *addOnMenuItem = new BMenu(kAddOnsMenuName); addOnMenuItem->SetFont(be_plain_font); @@ -1943,11 +1943,11 @@ BContainerWindow::AddWindowMenu(BMenu *menu) item = new BMenuItem("Select All", new BMessage(B_SELECT_ALL), 'A'); item->SetTarget(PoseView()); menu->AddItem(item); - + item = new BMenuItem("Invert Selection", new BMessage(kInvertSelection), 'S'); item->SetTarget(PoseView()); menu->AddItem(item); - + if (!IsTrash()) { item = new BMenuItem("Open Parent", new BMessage(kOpenParentDir), B_UP_ARROW); @@ -2093,12 +2093,12 @@ BContainerWindow::SetupNavigationMenu(const entry_ref *ref, BMenu *parent) parent->AddItem(fNavigationItem, 0); parent->AddItem(new BSeparatorItem(), 1); - + BMessage *message = new BMessage(B_REFS_RECEIVED); message->AddRef("refs", ref); fNavigationItem->SetMessage(message); fNavigationItem->SetTarget(be_app); - + if (!Dragging()) parent->SetTrackingHook(NULL, NULL); } @@ -2136,12 +2136,12 @@ BContainerWindow::SetUpEditQueryItem(BMenu *menu) BMenuItem *item = menu->FindItem("Edit Query"); if (!poseViewIsQuery && !queryInSelection && item) item->Menu()->RemoveItem(item); - + else if ((poseViewIsQuery || queryInSelection) && menu && !item) { - // add edit query item after Open + // add edit query item after Open item = menu->FindItem(kOpenSelection); - if (item) { + if (item) { int32 itemIndex = item->Menu()->IndexOf(item); BMenuItem *query = new BMenuItem("Edit Query", new BMessage(kEditQuery), 'G'); item->Menu()->AddItem(query, itemIndex + 1); @@ -2157,7 +2157,7 @@ BContainerWindow::SetupOpenWithMenu(BMenu *parent) // start by removing nav item (and separator) from old menu if (fOpenWithItem) { BMenu *menu = fOpenWithItem->Menu(); - if (menu) + if (menu) menu->RemoveItem(fOpenWithItem); delete fOpenWithItem; @@ -2259,7 +2259,7 @@ BContainerWindow::PopulateMoveCopyNavMenu(BNavMenu *navMenu, uint32 what, && directory.GetEntry(&entry) == B_OK && model.SetTo(&entry) == B_OK) navMenu->AddNavDir(&model, what, this, true); - // ask NavMenu to populate submenu for us + // ask NavMenu to populate submenu for us // add the home dir if (find_directory(B_USER_DIRECTORY, &path) == B_OK @@ -2294,7 +2294,7 @@ BContainerWindow::PopulateMoveCopyNavMenu(BNavMenu *navMenu, uint32 what, // add root dir if (volume.GetRootDirectory(&directory) == B_OK && directory.GetEntry(&entry) == B_OK - && model.SetTo(&entry) == B_OK) + && model.SetTo(&entry) == B_OK) navMenu->AddNavDir(&model, what, this, true); // ask NavMenu to populate submenu for us } @@ -2346,7 +2346,7 @@ BContainerWindow::SetupMoveCopyMenus(const entry_ref *item_ref, BMenu *parent) fCreateLinkItem->SetLabel("Create Relative Link"); else fCreateLinkItem->SetLabel("Create Link"); - + // only enable once the menus are built fMoveToItem->SetEnabled(false); fCopyToItem->SetEnabled(false); @@ -2356,7 +2356,7 @@ BContainerWindow::SetupMoveCopyMenus(const entry_ref *item_ref, BMenu *parent) BEntry entry; if (entry.SetTo(item_ref) != B_OK) return; - + Model tempModel(&entry); if (tempModel.InitCheck() != B_OK) return; @@ -2364,11 +2364,11 @@ BContainerWindow::SetupMoveCopyMenus(const entry_ref *item_ref, BMenu *parent) if (tempModel.IsRoot() || tempModel.IsVolume()) return; - // configure "Move to" menu item + // configure "Move to" menu item PopulateMoveCopyNavMenu(dynamic_cast(fMoveToItem->Submenu()), kMoveSelectionTo, item_ref, true); - // configure "Copy to" menu item + // configure "Copy to" menu item // add all mounted volumes (except the one this item lives on) PopulateMoveCopyNavMenu(dynamic_cast(fCopyToItem->Submenu()), kCopySelectionTo, item_ref, false); @@ -2535,7 +2535,7 @@ BContainerWindow::ShowContextMenu(BPoint loc, const entry_ref *ref, BView *) if (fWindowContextMenu->Window()) return; - MenusEnded(); + MenusEnded(); // clicked on a window, show window context menu @@ -2548,14 +2548,14 @@ BContainerWindow::ShowContextMenu(BPoint loc, const entry_ref *ref, BView *) } -void +void BContainerWindow::AddFileContextMenus(BMenu *menu) { menu->AddItem(new BMenuItem("Open", new BMessage(kOpenSelection), 'O')); menu->AddItem(new BMenuItem("Get Info", new BMessage(kGetInfo), 'I')); menu->AddItem(new BMenuItem("Edit Name", new BMessage(kEditItem), 'E')); - if (!IsTrash() && !InTrash() && !IsPrintersDir()) + if (!IsTrash() && !InTrash() && !IsPrintersDir()) menu->AddItem(new BMenuItem("Duplicate", new BMessage(kDuplicateSelection), 'D')); @@ -2593,9 +2593,9 @@ BContainerWindow::AddFileContextMenus(BMenu *menu) } -void +void BContainerWindow::AddVolumeContextMenus(BMenu *menu) -{ +{ menu->AddItem(new BMenuItem("Open", new BMessage(kOpenSelection), 'O')); menu->AddItem(new BMenuItem("Get Info", new BMessage(kGetInfo), 'I')); menu->AddItem(new BMenuItem("Edit Name", new BMessage(kEditItem), 'E')); @@ -2614,7 +2614,7 @@ BContainerWindow::AddVolumeContextMenus(BMenu *menu) } -void +void BContainerWindow::AddWindowContextMenus(BMenu *menu) { // create context sensitive menu for empty area of window @@ -2622,7 +2622,7 @@ BContainerWindow::AddWindowContextMenus(BMenu *menu) // mode menu bool needSeparator = true; - if (IsTrash()) + if (IsTrash()) menu->AddItem(new BMenuItem("Empty Trash", new BMessage(kEmptyTrash))); else if (IsPrintersDir()) menu->AddItem(new BMenuItem("Add Printer"B_UTF8_ELLIPSIS, new BMessage(kAddPrinter), 'N')); @@ -2647,7 +2647,7 @@ BContainerWindow::AddWindowContextMenus(BMenu *menu) menu->AddItem(new BMenuItem("Select"B_UTF8_ELLIPSIS, new BMessage(kShowSelectionWindow), 'A', B_SHIFT_KEY)); menu->AddItem(new BMenuItem("Select All", new BMessage(B_SELECT_ALL), 'A')); - if (!IsTrash()) + if (!IsTrash()) menu->AddItem(new BMenuItem("Open Parent", new BMessage(kOpenParentDir), B_UP_ARROW)); @@ -2670,7 +2670,7 @@ BContainerWindow::AddWindowContextMenus(BMenu *menu) } -void +void BContainerWindow::AddDropContextMenus(BMenu *menu) { menu->AddItem(new BMenuItem("Create Link Here", new BMessage(kCreateLink))); @@ -2961,16 +2961,16 @@ BContainerWindow::LoadAddOn(BMessage *message) BPose *pose; while ((pose = list->ItemAt(index++)) != NULL) refs->AddRef("refs", pose->TargetModel()->EntryRef()); - + refs->AddMessenger("TrackerViewToken", BMessenger(PoseView())); - - LaunchInNewThread("Add-on", B_NORMAL_PRIORITY, &AddOnThread, refs, addonRef, + + LaunchInNewThread("Add-on", B_NORMAL_PRIORITY, &AddOnThread, refs, addonRef, *TargetModel()->EntryRef()); } BMenuItem * -BContainerWindow::NewAttributeMenuItem(const char *label, const char *name, +BContainerWindow::NewAttributeMenuItem(const char *label, const char *name, int32 type, float width, int32 align, bool editable, bool statField) { return NewAttributeMenuItem(label, name, type, NULL, width, align, @@ -2979,7 +2979,7 @@ BContainerWindow::NewAttributeMenuItem(const char *label, const char *name, BMenuItem * -BContainerWindow::NewAttributeMenuItem(const char *label, const char *name, +BContainerWindow::NewAttributeMenuItem(const char *label, const char *name, int32 type, const char* displayAs, float width, int32 align, bool editable, bool statField) { @@ -3064,7 +3064,7 @@ BContainerWindow::HideAttributeMenu() } -void +void BContainerWindow::MarkAttributeMenu() { MarkAttributeMenu(fAttrMenu); @@ -3084,7 +3084,7 @@ BContainerWindow::MarkAttributeMenu(BMenu *menu) if (item->Message()) if (item->Message()->FindInt32("attr_hash", &attrHash) == B_OK) item->SetMarked(PoseView()->ColumnFor((uint32)attrHash) != 0); - else + else item->SetMarked(false); BMenu *submenu = item->Submenu(); @@ -3093,7 +3093,7 @@ BContainerWindow::MarkAttributeMenu(BMenu *menu) for (int32 subindex = 0; subindex < count2; subindex++) { item = submenu->ItemAt(subindex); if (item->Message()) - if (item->Message()->FindInt32("attr_hash", &attrHash) == B_OK) + if (item->Message()->FindInt32("attr_hash", &attrHash) == B_OK) item->SetMarked(PoseView()->ColumnFor((uint32)attrHash) != 0); else item->SetMarked(false); @@ -3103,7 +3103,7 @@ BContainerWindow::MarkAttributeMenu(BMenu *menu) } -void +void BContainerWindow::AddMimeTypesToMenu() { AddMimeTypesToMenu(fAttrMenu); @@ -3134,11 +3134,11 @@ BContainerWindow::CreateMimeMenu(const BMimeType& mimeType, bool isSuperType, char description[B_MIME_TYPE_LENGTH]; const char *nameToAdd = mimeType.Type(); - if (!mimeType.IsInstalled()) - return NULL; + if (!mimeType.IsInstalled()) + return NULL; // only add things to menu which have "user-visible" data - if (mimeType.GetAttrInfo(&attrInfo) != B_OK) + if (mimeType.GetAttrInfo(&attrInfo) != B_OK) return NULL; if (mimeType.GetShortDescription(description) == B_OK @@ -3156,7 +3156,7 @@ BContainerWindow::CreateMimeMenu(const BMimeType& mimeType, bool isSuperType, localMenu = new BMenu(nameToAdd); BFont font; menu->GetFont(&font); - localMenu->SetFont(&font); + localMenu->SetFont(&font); } while (attrInfo.FindString("attr:public_name", ++index, &str) == B_OK) { @@ -3191,7 +3191,7 @@ BContainerWindow::CreateMimeMenu(const BMimeType& mimeType, bool isSuperType, localMenu->AddItem(NewAttributeMenuItem(str, attrName, type, displayAs.String(), width, align, editable, false)); } - + return localMenu; } @@ -3206,7 +3206,7 @@ BContainerWindow::AddMimeTypesToMenu(BMenu *menu) int32 count = menu->CountItems(); int32 start; - for (start = 0; start < count; start++) { + for (start = 0; start < count; start++) { if (menu->ItemAt(start)->Submenu()) break; } @@ -3220,7 +3220,7 @@ BContainerWindow::AddMimeTypesToMenu(BMenu *menu) // Add a separator item if there is none yet if (dynamic_cast(menu->ItemAt(removeIndex)) == NULL) - menu->AddSeparatorItem(); + menu->AddSeparatorItem(); // Add MIME type in case we're a default query type window BPath path; @@ -3254,12 +3254,11 @@ BContainerWindow::AddMimeTypesToMenu(BMenu *menu) message1->AddString("mimetype", mimeType.Type()); levelOneMenu->AddItem(new IconMenuItem(levelTwoMenu, message1, mimeType.Type(), B_MINI_ICON)); - + BMessage *message2 = new BMessage(kMIMETypeItem); message2->AddString("mimetype", superType.Type()); menu->AddItem(new IconMenuItem(levelOneMenu, message2, superType.Type(), B_MINI_ICON)); - } else { if (levelOneMenu->CountItems() == 0) { // Our supertype menu is empty, so we remove it now. @@ -3268,7 +3267,7 @@ BContainerWindow::AddMimeTypesToMenu(BMenu *menu) BMessage *message2 = new BMessage(kMIMETypeItem); message2->AddString("mimetype", superType.Type()); menu->AddItem(new IconMenuItem(levelOneMenu, message2, - superType.Type(), B_MINI_ICON)); + superType.Type(), B_MINI_ICON)); } } } @@ -3310,7 +3309,7 @@ BContainerWindow::DelayedTaskLoop() } -bool +bool BContainerWindow::NeedsDefaultStateSetup() { if (!TargetModel()) @@ -3319,12 +3318,12 @@ BContainerWindow::NeedsDefaultStateSetup() if (TargetModel()->IsRoot()) // don't try to set up anything if we are root return false; - + WindowStateNodeOpener opener(this, false); if (!opener.StreamNode()) // can't read state, give up return false; - + return !NodeHasSavedState(opener.Node()); } @@ -3345,7 +3344,7 @@ BContainerWindow::DefaultStateSourceNode(const char *name, BNode *result, if (!BEntry(path.Path()).Exists()) { if (!createNew) return false; - + BPath tmpPath(settingsPath); for (;;) { // deal with several levels of folders @@ -3382,23 +3381,23 @@ BContainerWindow::DefaultStateSourceNode(const char *name, BNode *result, } -void +void BContainerWindow::SetUpDefaultState() { BNode defaultingNode; // this is where we'll ulitimately get the state from bool gotDefaultingNode = 0; bool shouldStagger = false; - + ASSERT(TargetModel()); PRINT(("folder %s does not have any saved state\n", TargetModel()->Name())); - + WindowStateNodeOpener opener(this, true); // this is our destination node, whatever it is for this window if (!opener.StreamNode()) return; - + if (!TargetModel()->IsRoot()) { BDirectory desktop; FSGetDeskDir(&desktop, TargetModel()->EntryRef()->device); @@ -3429,7 +3428,7 @@ BContainerWindow::SetUpDefaultState() return; // copy over the attributes - + // set up a filter of the attributes we want copied const char *allowAttrs[] = { kAttrWindowFrame, @@ -3440,7 +3439,7 @@ BContainerWindow::SetUpDefaultState() kAttrColumnsForeign, 0 }; - + // copy over attributes that apply; transform them properly, stripping // parts that do not apply, adding a window stagger, etc. @@ -3449,7 +3448,7 @@ BContainerWindow::SetUpDefaultState() SelectiveAttributeTransformer frameOffsetter(kAttrWindowFrame, OffsetFrameOne, ¶ms); SelectiveAttributeTransformer scrollOriginCleaner(kAttrViewState, ClearViewOriginOne, ¶ms); - + // do it AttributeStreamMemoryNode memoryNode; NamesToAcceptAttrFilter filter(allowAttrs); @@ -3460,13 +3459,13 @@ BContainerWindow::SetUpDefaultState() } -void +void BContainerWindow::RestoreWindowState(AttributeStreamNode *node) { if (!node || dynamic_cast(this)) // don't restore any window state if we are a desktop window return; - + const char *rectAttributeName; const char *workspaceAttributeName; if (TargetModel()->IsRoot()) { @@ -3476,7 +3475,7 @@ BContainerWindow::RestoreWindowState(AttributeStreamNode *node) rectAttributeName = kAttrWindowFrame; workspaceAttributeName = kAttrWindowWorkspace; } - + BRect frame(Frame()); if (node->Read(rectAttributeName, 0, B_RECT_TYPE, sizeof(BRect), &frame) == sizeof(BRect)) { MoveTo(frame.LeftTop()); @@ -3510,13 +3509,13 @@ BContainerWindow::RestoreWindowState(AttributeStreamNode *node) } -void +void BContainerWindow::RestoreWindowState(const BMessage &message) { if (dynamic_cast(this)) // don't restore any window state if we are a desktop window return; - + const char *rectAttributeName; const char *workspaceAttributeName; if (TargetModel()->IsRoot()) { @@ -3528,7 +3527,7 @@ BContainerWindow::RestoreWindowState(const BMessage &message) } BRect frame(Frame()); - if (message.FindRect(rectAttributeName, &frame) == B_OK) { + if (message.FindRect(rectAttributeName, &frame) == B_OK) { MoveTo(frame.LeftTop()); ResizeTo(frame.Width(), frame.Height()); } else @@ -3536,7 +3535,7 @@ BContainerWindow::RestoreWindowState(const BMessage &message) uint32 workspace; if ((fContainerWindowFlags & kRestoreWorkspace) - && message.FindInt32(workspaceAttributeName, (int32 *)&workspace) == B_OK) + && message.FindInt32(workspaceAttributeName, (int32 *)&workspace) == B_OK) SetWorkspaces(workspace); if (fContainerWindowFlags & kIsHidden) @@ -3553,7 +3552,7 @@ BContainerWindow::RestoreWindowState(const BMessage &message) } -void +void BContainerWindow::SaveWindowState(AttributeStreamNode *node) { ASSERT(node); @@ -3566,7 +3565,7 @@ BContainerWindow::SaveWindowState(AttributeStreamNode *node) rectAttributeName = kAttrWindowFrame; workspaceAttributeName = kAttrWindowWorkspace; } - + // node is null if it already got deleted BRect frame(Frame()); node->Write(rectAttributeName, 0, B_RECT_TYPE, sizeof(BRect), &frame); @@ -3588,7 +3587,7 @@ BContainerWindow::SaveWindowState(AttributeStreamNode *node) } -void +void BContainerWindow::SaveWindowState(BMessage &message) const { const char *rectAttributeName; @@ -3601,7 +3600,7 @@ BContainerWindow::SaveWindowState(BMessage &message) const rectAttributeName = kAttrWindowFrame; workspaceAttributeName = kAttrWindowWorkspace; } - + // node is null if it already got deleted BRect frame(Frame()); message.AddRect(rectAttributeName, frame); @@ -3620,7 +3619,7 @@ status_t BContainerWindow::DragStart(const BMessage *incoming) { if (!incoming) - return B_ERROR; + return B_ERROR; // if already dragging, or // if all the refs match @@ -3630,9 +3629,9 @@ BContainerWindow::DragStart(const BMessage *incoming) // cache the current drag message // build a list of the mimetypes in the message SpringLoadedFolderCacheDragData(incoming, &fDragMessage, &fCachedTypesList); - + fWaitingForRefs = true; - + return B_OK; } @@ -3645,7 +3644,7 @@ BContainerWindow::DragStop() delete fCachedTypesList; fCachedTypesList = NULL; - + fWaitingForRefs = false; } @@ -3654,7 +3653,7 @@ void BContainerWindow::ShowSelectionWindow() { if (fSelectionWindow == NULL) { - fSelectionWindow = new SelectionWindow(this); + fSelectionWindow = new SelectionWindow(this); fSelectionWindow->Show(); } else if (fSelectionWindow->Lock()) { if (fSelectionWindow->IsHidden()) { @@ -3671,7 +3670,7 @@ BContainerWindow::ShowNavigator(bool show) { if (PoseView()->IsDesktopWindow()) return; - + if (show) { if (Navigator() && !Navigator()->IsHidden()) return; @@ -3683,30 +3682,30 @@ BContainerWindow::ShowNavigator(bool show) fNavigator = new BNavigator(TargetModel(), rect); AddChild(fNavigator); } - + if (Navigator()->IsHidden()) { if (Navigator()->Bounds().top == 0) Navigator()->MoveTo(0, KeyMenuBar()->Bounds().Height() + 1); // This is if the navigator was created with a .top = 0. Navigator()->Show(); } - + float displacement = Navigator()->Frame().Height() + 1; - + PoseView()->MoveBy(0, displacement); PoseView()->ResizeBy(0, -displacement); - + if (PoseView()->VScrollBar()) { PoseView()->VScrollBar()->MoveBy(0, displacement); PoseView()->VScrollBar()->ResizeBy(0, -displacement); PoseView()->UpdateScrollRange(); - } - } else { + } + } else { if (!Navigator() || Navigator()->IsHidden()) return; float displacement = Navigator()->Frame().Height() + 1; - + PoseView()->ResizeBy(0, displacement); PoseView()->MoveBy(0, -displacement); @@ -3726,14 +3725,14 @@ BContainerWindow::SetSingleWindowBrowseShortcuts(bool enabled) { if (PoseView()->IsDesktopWindow()) return; - + if (enabled) { if (!Navigator()) return; RemoveShortcut(B_DOWN_ARROW, B_OPTION_KEY | B_COMMAND_KEY); RemoveShortcut(B_UP_ARROW, B_COMMAND_KEY | B_OPTION_KEY); - RemoveShortcut(B_UP_ARROW, B_COMMAND_KEY | B_OPTION_KEY | B_CONTROL_KEY); + RemoveShortcut(B_UP_ARROW, B_COMMAND_KEY | B_OPTION_KEY | B_CONTROL_KEY); RemoveShortcut(B_UP_ARROW, B_COMMAND_KEY | B_CONTROL_KEY); AddShortcut(B_LEFT_ARROW, B_COMMAND_KEY, @@ -3742,7 +3741,7 @@ BContainerWindow::SetSingleWindowBrowseShortcuts(bool enabled) new BMessage(kNavigatorCommandForward), Navigator()); AddShortcut(B_UP_ARROW, B_COMMAND_KEY, new BMessage(kNavigatorCommandUp), Navigator()); - + AddShortcut(B_LEFT_ARROW, B_OPTION_KEY | B_COMMAND_KEY, new BMessage(kNavigatorCommandBackward), Navigator()); AddShortcut(B_RIGHT_ARROW, B_OPTION_KEY | B_COMMAND_KEY, @@ -3756,12 +3755,12 @@ BContainerWindow::SetSingleWindowBrowseShortcuts(bool enabled) RemoveShortcut(B_RIGHT_ARROW, B_COMMAND_KEY); RemoveShortcut(B_UP_ARROW, B_COMMAND_KEY); // This is added again, below, with a new meaning. - + RemoveShortcut(B_LEFT_ARROW, B_OPTION_KEY | B_COMMAND_KEY); RemoveShortcut(B_RIGHT_ARROW, B_OPTION_KEY | B_COMMAND_KEY); RemoveShortcut(B_UP_ARROW, B_OPTION_KEY | B_COMMAND_KEY); // This also changes meaning, added again below. - + AddShortcut(B_DOWN_ARROW, B_OPTION_KEY | B_COMMAND_KEY, new BMessage(kOpenSelection), PoseView()); AddShortcut(B_UP_ARROW, B_COMMAND_KEY, @@ -3769,8 +3768,8 @@ BContainerWindow::SetSingleWindowBrowseShortcuts(bool enabled) // We change the meaning from kNavigatorCommandUp to kOpenParentDir. AddShortcut(B_UP_ARROW, B_COMMAND_KEY | B_OPTION_KEY, new BMessage(kOpenParentDir), PoseView()); - AddShortcut(B_UP_ARROW, B_COMMAND_KEY | B_OPTION_KEY | B_CONTROL_KEY, - new BMessage(kOpenParentDir), PoseView()); + AddShortcut(B_UP_ARROW, B_COMMAND_KEY | B_OPTION_KEY | B_CONTROL_KEY, + new BMessage(kOpenParentDir), PoseView()); AddShortcut(B_UP_ARROW, B_COMMAND_KEY | B_CONTROL_KEY, new BMessage(kOpenParentDir), PoseView()); // the command option results in closing the parent window @@ -3790,24 +3789,24 @@ BContainerWindow::SetPathWatchingEnabled(bool enable) if (enable) { if (TargetModel() != NULL) { BEntry entry; - + TargetModel()->GetEntry(&entry); status_t err; do { err = entry.GetParent(&entry); if (err != B_OK) break; - + char name[B_FILE_NAME_LENGTH]; entry.GetName(name); if (strcmp(name, "/") == 0) break; - + node_ref ref; entry.GetNodeRef(&ref); - watch_node(&ref, B_WATCH_NAME, this); + watch_node(&ref, B_WATCH_NAME, this); } while (err == B_OK); - + fIsWatchingPath = err == B_OK; } else fIsWatchingPath = false; @@ -3815,7 +3814,7 @@ BContainerWindow::SetPathWatchingEnabled(bool enable) } -void +void BContainerWindow::PulseTaskLoop() { if (fTaskLoop) @@ -3854,39 +3853,39 @@ WindowStateNodeOpener::~WindowStateNodeOpener() } -void +void WindowStateNodeOpener::SetTo(const BDirectory *node) { delete fModelOpener; delete fNode; delete fStreamNode; - + fModelOpener = NULL; fNode = new BDirectory(*node); fStreamNode = new AttributeStreamFileNode(fNode); } -void +void WindowStateNodeOpener::SetTo(const BEntry *entry, bool forWriting) { delete fModelOpener; delete fNode; delete fStreamNode; - + fModelOpener = NULL; fNode = new BFile(entry, (uint32)(forWriting ? O_RDWR : O_RDONLY)); fStreamNode = new AttributeStreamFileNode(fNode); } -void +void WindowStateNodeOpener::SetTo(Model *model, bool forWriting) { delete fModelOpener; delete fNode; delete fStreamNode; - + fNode = NULL; fStreamNode = NULL; fModelOpener = new ModelNodeLazyOpener(model, forWriting, false); @@ -3907,7 +3906,7 @@ WindowStateNodeOpener::Node() const { if (!fStreamNode) return NULL; - + if (fNode) return fNode; @@ -3939,14 +3938,14 @@ BackgroundView::FrameResized(float, float) } -void +void BackgroundView::PoseViewFocused(bool) { Invalidate(); } -void +void BackgroundView::WindowActivated(bool) { Invalidate(); @@ -3969,7 +3968,7 @@ BackgroundView::Draw(BRect) SetHighColor(100, 100, 100); StrokeRect(frame); - // draw the pose view focus + // draw the pose view focus if (window->IsActive() && window->PoseView()->IsFocus()) { frame.InsetBy(-2, -2); SetHighColor(keyboard_navigation_color()); @@ -3978,11 +3977,11 @@ BackgroundView::Draw(BRect) } -void +void BackgroundView::Pulse() { BContainerWindow *window = dynamic_cast(Window()); - if (window) + if (window) window->PulseTaskLoop(); } diff --git a/src/kits/tracker/ContainerWindow.h b/src/kits/tracker/ContainerWindow.h index 6e6f887d05..b5330f7a9b 100644 --- a/src/kits/tracker/ContainerWindow.h +++ b/src/kits/tracker/ContainerWindow.h @@ -77,7 +77,7 @@ class BContainerWindow : public BWindow { BContainerWindow(LockingList *windowList, uint32 containerWindowFlags, window_look look = B_DOCUMENT_WINDOW_LOOK, - window_feel feel = B_NORMAL_WINDOW_FEEL, + window_feel feel = B_NORMAL_WINDOW_FEEL, uint32 flags = B_WILL_ACCEPT_FIRST_CLICK | B_NO_WORKSPACE_ACTIVATION, uint32 workspace = B_CURRENT_WORKSPACE); @@ -152,9 +152,9 @@ class BContainerWindow : public BWindow { void AddMimeTypesToMenu(); virtual void MarkAttributeMenu(BMenu *); void MarkAttributeMenu(); - BMenuItem *NewAttributeMenuItem(const char *label, const char *name, + BMenuItem *NewAttributeMenuItem(const char *label, const char *name, int32 type, float width, int32 align, bool editable, bool statField); - BMenuItem *NewAttributeMenuItem(const char *label, const char *name, + BMenuItem *NewAttributeMenuItem(const char *label, const char *name, int32 type, const char* displayAs, float width, int32 align, bool editable, bool statField); virtual void NewAttributeMenu(BMenu *); @@ -344,7 +344,7 @@ int CompareLabels(const BMenuItem *, const BMenuItem *); // inlines --------- -inline BNavigator * +inline BNavigator * BContainerWindow::Navigator() const { return fNavigator; @@ -368,13 +368,13 @@ BContainerWindow::InTrash() const return fInTrash; } -inline bool +inline bool BContainerWindow::IsPrintersDir() const { return fIsPrinters; } -inline void +inline void BContainerWindow::SetUpDiskMenu(BMenu *) { // nothing at this level @@ -386,7 +386,7 @@ BContainerWindow::ContextMenu() return fContextMenu; } -inline bool +inline bool BContainerWindow::Dragging() const { return fDragMessage && fCachedTypesList; @@ -404,7 +404,7 @@ BContainerWindow::SaveStateIsEnabled() const return fSaveStateIsEnabled; } -inline +inline void BContainerWindow::SetSaveStateEnabled(bool value) {