Changeset 19870
- Timestamp:
- 01/19/07 18:01:42 (22 months ago)
- Location:
- haiku/trunk/src/kits/tracker
- Files:
-
- 2 modified
-
Jamfile (modified) (1 diff)
-
MountMenu.cpp (modified) (9 diffs)
Legend:
- Unmodified
- Added
- Removed
-
haiku/trunk/src/kits/tracker/Jamfile
r18649 r19870 4 4 AddSubDirSupportedPlatforms libbe_test ; 5 5 6 UsePrivateHeaders shared ; 7 UsePrivateHeaders tracker ; 6 UsePrivateHeaders shared storage tracker ; 8 7 9 8 UseLibraryHeaders icon ; -
haiku/trunk/src/kits/tracker/MountMenu.cpp
r16909 r19870 49 49 #include "Bitmaps.h" 50 50 51 #if OPEN_TRACKER 51 #ifdef __HAIKU__ 52 # include <DiskDevice.h> 53 # include <DiskDeviceList.h> 54 #else 52 55 # include "DeviceMap.h" 53 #else54 # include <private/storage/DeviceMap.h>55 56 #endif 56 57 … … 58 59 59 60 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 65 class 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 78 AddMenuItemVisitor::AddMenuItemVisitor(BMenu* menu) 79 : 80 fMenu(menu) 81 { 82 } 83 84 85 AddMenuItemVisitor::~AddMenuItemVisitor() 86 { 87 } 88 89 90 bool 91 AddMenuItemVisitor::Visit(BDiskDevice *device) 92 { 93 return Visit(device, 0); 94 } 95 96 97 bool 98 AddMenuItemVisitor::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 68 156 struct AddOneAsMenuItemParams { 69 157 BMenu *mountMenu; … … 128 216 return NULL; 129 217 } 130 #endif // _INCLUDES_CLASS_DEVICE_MAP 218 #endif // !__HAIKU__ 219 220 221 // #pragma mark - 222 223 224 MountMenu::MountMenu(const char *name) 225 : BMenu(name) 226 { 227 SetFont(be_plain_font); 228 } 131 229 132 230 … … 134 232 MountMenu::AddDynamicItem(add_state) 135 233 { 136 #if _INCLUDES_CLASS_DEVICE_MAP 234 // remove old items 137 235 for (;;) { 138 236 BMenuItem *item = RemoveItem(0L); … … 142 240 } 143 241 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 144 250 AddOneAsMenuItemParams params; 145 251 params.mountMenu = this; … … 150 256 autoMounter->CheckVolumesNow(); 151 257 autoMounter->EachPartition(&AddOnePartitionAsMenuItem, ¶ms); 258 #endif 152 259 153 260 #ifdef SHOW_NETWORK_VOLUMES … … 186 293 AddSeparatorItem(); 187 294 295 #ifndef __HAIKU__ 188 296 // add an option to rescan the scsii bus, etc. 189 297 BMenuItem *rescanItem = NULL; … … 192 300 AddItem(rescanItem); 193 301 } 302 #endif 194 303 195 304 BMenuItem *mountAll = new BMenuItem("Mount All", new BMessage(kMountAllNow)); … … 201 310 SetTargetForItems(be_app); 202 311 312 #ifndef __HAIKU__ 203 313 if (rescanItem) 204 314 rescanItem->SetTarget(autoMounter); 205 #endif // _INCLUDES_CLASS_DEVICE_MAP315 #endif 206 316 207 317 return false;
