Ticket #3385: trackersinglewindownavpatch.diff

File trackersinglewindownavpatch.diff, 11.2 KB (added by dru_ed, 14 years ago)

This patch fixes all bugs mentioned in Ticket.

  • VolumeWindow.cpp

     
    6161    if (!fMenuBar)
    6262        return;
    6363
    64     BVolume boot;
    65     BVolumeRoster().GetBootVolume(&boot);
    66 
    67     bool ejectableVolumeSelected = false;
    68 
    69     int32 count = PoseView()->SelectionList()->CountItems();
    70     for (int32 index = 0; index < count; index++) {
    71         Model *model = PoseView()->SelectionList()->ItemAt(index)->TargetModel();
    72         if (model->IsVolume()) {
    73             BVolume volume;
    74             volume.SetTo(model->NodeRef()->device);
    75             if (volume != boot) {
    76                 ejectableVolumeSelected = true;
    77                 break;
    78             }
    79         }
    80     }
    81 
    82     BMenuItem *item = fMenuBar->FindItem("Unmount");
    83     if (item)
    84         item->SetEnabled(ejectableVolumeSelected);
    8564}
    8665
    8766
  • PoseView.cpp

     
    78977897
    78987898
    78997899void
    7900 BPoseView::OpenParent()
     7900BPoseView::OpenParent() 
    79017901{
    7902     if (!TargetModel() || TargetModel()->IsRoot() || IsDesktopWindow())
     7902    if (!TargetModel() || IsDesktopWindow() || TargetModel()->IsRoot() )
    79037903        return;
    79047904
    79057905    BEntry entry(TargetModel()->EntryRef());
     
    79117911        || entry.GetRef(&ref) != B_OK)
    79127912        return;
    79137913
    7914     BEntry root("/");
     7914// this fuctionality, if desired, is incomplete.
     7915// blocks move a 'up' to root "/" if Disks Icon not on Desktop
     7916// however, related parts of code also need updating to support this behavior.
     7917/*  BEntry root("/");
    79157918    if (!TrackerSettings().ShowDisksIcon() && entry == root
    79167919        && (modifiers() & B_CONTROL_KEY) == 0)
    79177920        return;
    7918 
     7921*/
    79197922    Model parentModel(&ref);
    79207923
    79217924    BMessage message(B_REFS_RECEIVED);
    79227925    message.AddRef("refs", &ref);
    79237926
    7924     if (dynamic_cast<TTracker *>(be_app)) {
    7925         // add information about the child, so that we can select it
    7926         // in the parent view
    7927         message.AddData("nodeRefToSelect", B_RAW_TYPE, TargetModel()->NodeRef(),
    7928             sizeof (node_ref));
    7929 
    7930         if ((modifiers() & B_OPTION_KEY) != 0 && !IsFilePanel())
    7931             // if option down, add instructions to close the parent
    7932             message.AddData("nodeRefsToClose", B_RAW_TYPE, TargetModel()->NodeRef(),
     7927    if (!ContainerWindow()->Navigator()){
     7928        if (dynamic_cast<TTracker *>(be_app)) {
     7929            // add information about the child, so that we can select it
     7930            // in the parent view
     7931            message.AddData("nodeRefToSelect", B_RAW_TYPE, TargetModel()->NodeRef(),
    79337932                sizeof (node_ref));
     7933   
     7934            if ((modifiers() & B_OPTION_KEY) != 0 && !IsFilePanel())
     7935                // if option down, add instructions to close the parent
     7936                message.AddData("nodeRefsToClose", B_RAW_TYPE, TargetModel()->NodeRef(),
     7937                    sizeof (node_ref));
     7938        }
     7939   
     7940        be_app->PostMessage(&message);
    79347941    }
    7935 
    7936     be_app->PostMessage(&message);
     7942    else {
     7943        message.what = kSwitchDirectory;
     7944        Window()->PostMessage(&message);
     7945        UnlockLooper();
     7946        if (TargetModel()->NodeRef())
     7947            dynamic_cast<TTracker *>(be_app)->SelectChildInParentSoon(&ref, TargetModel()->NodeRef());
     7948        LockLooper();
     7949    }
    79377950}
    79387951
    79397952
  • ContainerWindow.cpp

     
    353353        return;
    354354
    355355    // we don't like the Trash icon (because it cannot be moved)
    356     if (window->IsTrash() || window->IsPrintersDir())
     356    if (window->IsTrash() || window->IsPrintersDir() || window->TargetModel()->IsRoot())
    357357        return;
    358358
    359359    uint32 buttons;
     
    746746        fIsTrash = model->IsTrash();
    747747        fInTrash = FSInTrashDir(model->EntryRef());
    748748        fIsPrinters = FSIsPrintersDir(&entry);
     749
    749750    }
    750751}
    751752
     
    927928            fPoseView->VScrollBar()->ResizeBy(0, -(KeyMenuBar()->Bounds().Height()));
    928929        }
    929930
    930         // add folder icon to menu bar
    931         if (!TargetModel()->IsRoot() && !IsTrash()) {
     931        if (!TargetModel()->IsRoot() && !IsTrash()) {
    932932            float iconSize = fMenuBar->Bounds().Height() - 2;
    933933            if (iconSize < 16)
    934934                iconSize = 16;
     
    10621062
    10631063    if (Navigator())
    10641064        Navigator()->UpdateLocation(PoseView()->TargetModel(), kActionUpdatePath);
     1065       
    10651066}
    10661067
    10671068
     
    15111512
    15121513                    if (wasInTrash ^ (IsTrash() || InTrash())
    15131514                        || isRoot != PoseView()->TargetModel()->IsRoot())
    1514                         RepopulateMenus();
     1515                        RepopulateMenus(); 
    15151516
    15161517                    // Update Navigation bar
    15171518                    if (Navigator()) {
     
    15291530                        SetPathWatchingEnabled(true);
    15301531
    15311532                    // Update draggable folder icon
    1532                     BView *view = FindView("MenuBar");
    1533                     if (view != NULL) {
    1534                         view = view->FindView("ThisContainer");
    1535                         if (view != NULL) {
     1533                    BView *fMenuBar = FindView("MenuBar");
     1534
     1535                    if ((fMenuBar != NULL) && (!TargetModel()->IsRoot() && !IsTrash())) {
     1536                        BView *view = fMenuBar->FindView("ThisContainer");
     1537                                       
     1538                        if (view != NULL) {
    15361539                            IconCache::sIconCache->IconChanged(TargetModel());
    15371540                            view->Invalidate();
    15381541                        }
    1539                     }
    1540 
     1542                        else if (!TargetModel()->IsRoot() && !IsTrash()) {
     1543                            float iconSize = fMenuBar->Bounds().Height() - 2;
     1544                            if (iconSize < 16)
     1545                                iconSize = 16;
     1546                            float iconPosY = 1 + (fMenuBar->Bounds().Height() - 2 - iconSize) / 2;
     1547                            BView *icon = new DraggableContainerIcon(BRect(Bounds().Width() - 4 - iconSize + 1,
     1548                                            iconPosY, Bounds().Width() - 4, iconPosY + iconSize - 1),
     1549                                            "ThisContainer", B_FOLLOW_RIGHT);
     1550                            fMenuBar->AddChild(icon);
     1551                           
     1552                            view = fMenuBar->FindView("ThisContainer");
     1553                            if (view != NULL) {
     1554                                IconCache::sIconCache->IconChanged(TargetModel());
     1555                                view->Invalidate();
     1556                            }
     1557                        }       
     1558                    }
     1559                    else {
     1560                        BView *view = fMenuBar->FindView("ThisContainer");
     1561                        if (view != NULL) {
     1562                            view->RemoveSelf();
     1563                            fMenuBar->Invalidate();
     1564                        }
     1565                    }               
    15411566                    // Update window title
    15421567                    UpdateTitle();
    15431568                }
     
    15531578                //
    15541579                entry_ref ref;
    15551580                if (message->FindRef("refs", &ref) == B_OK) {
    1556                     //printf("BContainerWindow::MessageReceived - refs received\n");
    15571581                    fWaitingForRefs = false;
    15581582                    BEntry entry(&ref, true);
    15591583                    //
     
    18211845    if (!PoseView()->IsFilePanel())
    18221846        menu->AddItem(new BMenuItem("Find"B_UTF8_ELLIPSIS,
    18231847            new BMessage(kFindButton), 'F'));
    1824 
    1825     if (!TargetModel()->IsQuery() && !IsTrash() && !IsPrintersDir()) {
     1848           
     1849    if (!TargetModel()->IsQuery() && !IsTrash() && !IsPrintersDir() && !TargetModel()->IsRoot()) {
    18261850        if (!PoseView()->IsFilePanel()) {
    18271851            TemplatesMenu *templateMenu = new TemplatesMenu(PoseView());
    18281852            menu->AddItem(templateMenu);
     
    18491873        menu->AddItem(new BSeparatorItem(), 1);
    18501874        menu->AddItem(new BMenuItem("Make active printer",
    18511875            new BMessage(kMakeActivePrinter)));
    1852     } else {
     1876    } else if (TargetModel()->IsRoot()) {
     1877        menu->AddItem(new BMenuItem("Unmount", new BMessage(kUnmountVolume), 'U'));
     1878        menu->AddItem(new BMenuItem("Mount settings" B_UTF8_ELLIPSIS, new BMessage(kRunAutomounterSettings)));
     1879       
     1880    } else {
    18531881        menu->AddItem(new BMenuItem("Duplicate",new BMessage(kDuplicateSelection), 'D'));
    18541882
    18551883        menu->AddItem(new BMenuItem(TrackerSettings().DontMoveFilesToTrash() ?
     
    18571885                new BMessage(kMoveToTrash), 'T'));
    18581886
    18591887        menu->AddSeparatorItem();
    1860 
    1861         // The "Move To", "Copy To", "Create Link" menus are inserted
    1862         // at this place, have a look at:
    1863         // BContainerWindow::SetupMoveCopyMenus()
     1888       
    18641889    }
    1865 
    18661890    BMenuItem *cutItem = NULL, *copyItem = NULL, *pasteItem = NULL;
    1867     if (!IsPrintersDir()) {
     1891    if (!IsPrintersDir() && !TargetModel()->IsRoot()) {
    18681892        menu->AddSeparatorItem();
    18691893
    18701894        menu->AddItem(cutItem = new BMenuItem("Cut", new BMessage(B_CUT), 'X'));
    18711895        menu->AddItem(copyItem = new BMenuItem("Copy", new BMessage(B_COPY), 'C'));
    18721896        menu->AddItem(pasteItem = new BMenuItem("Paste", new BMessage(B_PASTE), 'V'));
    1873 
     1897    }
    18741898        menu->AddSeparatorItem();
    18751899
     1900    if (!IsPrintersDir() && !TargetModel()->IsRoot()) {
    18761901        menu->AddItem(new BMenuItem("Identify", new BMessage(kIdentifyEntry)));
     1902    }   
     1903   
     1904    if (!IsPrintersDir()) {
    18771905        BMenu *addOnMenuItem = new BMenu(kAddOnsMenuName);
    18781906        addOnMenuItem->SetFont(be_plain_font);
    18791907        menu->AddItem(addOnMenuItem);
     
    18861914        copyItem->SetTarget(this);
    18871915    if (pasteItem)
    18881916        pasteItem->SetTarget(this);
     1917
    18891918}
    18901919
    18911920
     
    19722001    item->SetTarget(PoseView());
    19732002    menu->AddItem(item);
    19742003
    1975     if (!IsTrash()) {
     2004//  if (!IsTrash()) {
    19762005        item = new BMenuItem("Open parent", new BMessage(kOpenParentDir),
    19772006            B_UP_ARROW);
    19782007        item->SetTarget(PoseView());
    19792008        menu->AddItem(item);
    1980     }
     2009//  }
    19812010
    19822011    item = new BMenuItem("Close", new BMessage(B_QUIT_REQUESTED), 'W');
    19832012    item->SetTarget(this);
     
    20522081
    20532082    if (IsPrintersDir())
    20542083        EnableNamedMenuItem(fFileMenu, "Make active printer", selectCount == 1);
     2084       
     2085    if (TargetModel()->IsRoot()) {
     2086       
     2087        BVolume boot;
     2088        BVolumeRoster().GetBootVolume(&boot);
     2089   
     2090        bool ejectableVolumeSelected = false;
     2091   
     2092        int32 count = PoseView()->SelectionList()->CountItems();
     2093        for (int32 index = 0; index < count; index++) {
     2094            Model *model = PoseView()->SelectionList()->ItemAt(index)->TargetModel();
     2095            if (model->IsVolume()) {
     2096                BVolume volume;
     2097                volume.SetTo(model->NodeRef()->device);
     2098                if (volume != boot) {
     2099                    ejectableVolumeSelected = true;
     2100                    break;
     2101                }
     2102            }
     2103        }
     2104   
     2105        BMenuItem *item = fMenuBar->FindItem("Unmount");
     2106        if (item)
     2107            item->SetEnabled(ejectableVolumeSelected);
     2108    }
     2109       
    20552110}
    20562111
    20572112
     
    23372392void
    23382393BContainerWindow::SetupMoveCopyMenus(const entry_ref *item_ref, BMenu *parent)
    23392394{
    2340     if (IsTrash() || InTrash() || IsPrintersDir() || !fMoveToItem || !fCopyToItem || !fCreateLinkItem)
    2341         return;
     2395    if (IsTrash() || InTrash() || IsPrintersDir() || !fMoveToItem || !fCopyToItem || !fCreateLinkItem || PoseView()->TargetModel()->IsRoot())
     2396        return; 
    23422397
    23432398    // Grab the modifiers state since we use it twice
    23442399    uint32 modifierKeys = modifiers();
     
    25132568                // see the notes in SlowContextPopup::AttachedToWindow
    25142569       
    25152570                if (!FSIsPrintersDir(&entry) && !fDragContextMenu->IsShowing()) {
    2516                     // printf("ShowContextMenu - target is %s %i\n", ref->name, IsShowing(ref));
    25172571                    fDragContextMenu->ClearMenu();
    25182572       
    25192573                    // in case the ref is a symlink, resolve it
     
    26112665    menu->AddItem(new BMenuItem("Get info", new BMessage(kGetInfo), 'I'));
    26122666    menu->AddItem(new BMenuItem("Edit name", new BMessage(kEditItem), 'E'));
    26132667
    2614     if (!IsTrash() && !InTrash() && !IsPrintersDir())
     2668    if (!IsTrash() && !InTrash() && !IsPrintersDir() && !TargetModel()->IsRoot())
    26152669        menu->AddItem(new BMenuItem("Duplicate",
    26162670            new BMessage(kDuplicateSelection), 'D'));
    26172671
    2618     if (!IsTrash() && !InTrash()) {
     2672    if (!IsTrash() && !InTrash() && !TargetModel()->IsRoot()) {
    26192673        menu->AddItem(new BMenuItem(TrackerSettings().DontMoveFilesToTrash() ?
    26202674                "Delete" : "Move to Trash",
    26212675                new BMessage(kMoveToTrash), 'T'));
  • Tracker.cpp

     
    884884            // clone the message, window adopts it for it's own use
    885885            refList = new BMessage(*originalRefsList);
    886886        window = new OpenWithContainerWindow(refList, &fWindowList);
    887     } else if (model->IsRoot()) {
    888         // window will adopt the model
    889         window = new BVolumeWindow(&fWindowList, openFlags);
    890887    } else if (model->IsQuery()) {
    891888        // window will adopt the model
    892889        window = new BQueryContainerWindow(&fWindowList, openFlags);