Changeset 19870

Show
Ignore:
Timestamp:
01/19/07 18:01:42 (22 months ago)
Author:
axeld
Message:

* To get away with that empty mount menu, it now at least shows all mounted and

mountable volumes - there are no icons yet, and it will also not work at all,
that is, you cannot mount/unmount any volumes yet.

* Got rid of _INCLUDES_CLASS_DEVICE_MAP in MountMenu.cpp.

Location:
haiku/trunk/src/kits/tracker
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • haiku/trunk/src/kits/tracker/Jamfile

    r18649 r19870  
    44AddSubDirSupportedPlatforms libbe_test ; 
    55 
    6 UsePrivateHeaders shared ; 
    7 UsePrivateHeaders tracker ; 
     6UsePrivateHeaders shared storage tracker ; 
    87 
    98UseLibraryHeaders icon ; 
  • haiku/trunk/src/kits/tracker/MountMenu.cpp

    r16909 r19870  
    4949#include "Bitmaps.h" 
    5050 
    51 #if OPEN_TRACKER 
     51#ifdef __HAIKU__ 
     52#       include <DiskDevice.h> 
     53#       include <DiskDeviceList.h> 
     54#else 
    5255#       include "DeviceMap.h" 
    53 #else 
    54 #       include <private/storage/DeviceMap.h> 
    5556#endif 
    5657 
     
    5859 
    5960 
    60 MountMenu::MountMenu(const char *name) 
    61         : BMenu(name) 
    62 { 
    63         SetFont(be_plain_font); 
    64 } 
    65  
    66  
    67 #if _INCLUDES_CLASS_DEVICE_MAP 
     61#ifdef __HAIKU__ 
     62//      #pragma mark - Haiku Disk Device API 
     63 
     64 
     65class AddMenuItemVisitor : public BDiskDeviceVisitor { 
     66        public: 
     67                AddMenuItemVisitor(BMenu* menu); 
     68                virtual ~AddMenuItemVisitor(); 
     69 
     70                virtual bool Visit(BDiskDevice *device); 
     71                virtual bool Visit(BPartition *partition, int32 level); 
     72 
     73        private: 
     74                BMenu* fMenu; 
     75}; 
     76 
     77 
     78AddMenuItemVisitor::AddMenuItemVisitor(BMenu* menu) 
     79        : 
     80        fMenu(menu) 
     81{ 
     82} 
     83 
     84 
     85AddMenuItemVisitor::~AddMenuItemVisitor() 
     86{ 
     87} 
     88 
     89 
     90bool 
     91AddMenuItemVisitor::Visit(BDiskDevice *device) 
     92{ 
     93        return Visit(device, 0); 
     94} 
     95 
     96 
     97bool 
     98AddMenuItemVisitor::Visit(BPartition *partition, int32 level) 
     99{ 
     100        if (!partition->ContainsFileSystem()) 
     101                return NULL; 
     102 
     103        // get name (and eventually the type) 
     104        BString name = partition->ContentName(); 
     105        if (name.Length() == 0) { 
     106                name = partition->Name(); 
     107                if (name.Length() == 0) { 
     108                        const char *type = partition->ContentType(); 
     109                        if (type == NULL) 
     110                                return NULL; 
     111 
     112                        name = "(unnamed "; 
     113                        name << type; 
     114                        name << ")"; 
     115                } 
     116        } 
     117 
     118        // get icon 
     119        BBitmap *icon = new BBitmap(BRect(0, 0, B_MINI_ICON - 1, B_MINI_ICON - 1), 
     120                B_CMAP8); 
     121        if (partition->GetIcon(icon, B_MINI_ICON) != B_OK) { 
     122                delete icon; 
     123                icon = NULL; 
     124        } 
     125 
     126        BMessage *message = new BMessage(partition->IsMounted() ? 
     127                kUnmountVolume : kMountVolume); 
     128        message->AddInt32("id", partition->ID()); 
     129 
     130        // TODO: for now, until we actually have disk device icons 
     131        BMenuItem *item; 
     132        if (icon != NULL) 
     133                item = new IconMenuItem(name.String(), message, icon); 
     134        else 
     135                item = new BMenuItem(name.String(), message); 
     136        if (partition->IsMounted()) { 
     137                item->SetMarked(true); 
     138 
     139                BVolume volume; 
     140                if (partition->GetVolume(&volume) == B_OK) { 
     141                        BVolume bootVolume; 
     142                        BVolumeRoster().GetBootVolume(&bootVolume); 
     143                        if (volume == bootVolume) 
     144                                item->SetEnabled(false); 
     145                } 
     146        } 
     147 
     148        fMenu->AddItem(item); 
     149        return false; 
     150} 
     151 
     152#else   // !__HAIKU__ 
     153//      #pragma mark - R5 DeviceMap API 
     154 
     155 
    68156struct AddOneAsMenuItemParams { 
    69157        BMenu *mountMenu; 
     
    128216        return NULL; 
    129217} 
    130 #endif  // _INCLUDES_CLASS_DEVICE_MAP 
     218#endif  // !__HAIKU__ 
     219 
     220 
     221//      #pragma mark - 
     222 
     223 
     224MountMenu::MountMenu(const char *name) 
     225        : BMenu(name) 
     226{ 
     227        SetFont(be_plain_font); 
     228} 
    131229 
    132230 
     
    134232MountMenu::AddDynamicItem(add_state) 
    135233{ 
    136 #if _INCLUDES_CLASS_DEVICE_MAP 
     234        // remove old items 
    137235        for (;;) { 
    138236                BMenuItem *item = RemoveItem(0L); 
     
    142240        } 
    143241 
     242#ifdef __HAIKU__ 
     243        BDiskDeviceList devices; 
     244        status_t status = devices.Fetch(); 
     245        if (status == B_OK) { 
     246                AddMenuItemVisitor visitor(this); 
     247                devices.VisitEachPartition(&visitor); 
     248        } 
     249#else 
    144250        AddOneAsMenuItemParams params; 
    145251        params.mountMenu = this; 
     
    150256        autoMounter->CheckVolumesNow(); 
    151257        autoMounter->EachPartition(&AddOnePartitionAsMenuItem, &params); 
     258#endif 
    152259 
    153260#ifdef SHOW_NETWORK_VOLUMES 
     
    186293        AddSeparatorItem(); 
    187294 
     295#ifndef __HAIKU__ 
    188296        // add an option to rescan the scsii bus, etc. 
    189297        BMenuItem *rescanItem = NULL; 
     
    192300                AddItem(rescanItem); 
    193301        } 
     302#endif 
    194303 
    195304        BMenuItem *mountAll = new BMenuItem("Mount All", new BMessage(kMountAllNow)); 
     
    201310        SetTargetForItems(be_app); 
    202311         
     312#ifndef __HAIKU__ 
    203313        if (rescanItem) 
    204314                rescanItem->SetTarget(autoMounter); 
    205 #endif  // _INCLUDES_CLASS_DEVICE_MAP 
     315#endif 
    206316 
    207317        return false;