From 01f3fea56ceca42ff1f25ff75a57351fb25f823b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Axel=20D=C3=B6rfler?= Date: Fri, 27 Feb 2004 20:21:11 +0000 Subject: [PATCH] The DataEditor always starts in the device native block size or 512 for all other file types, but the block size menu didn't take that into account, it always showed "512" to be active when started. Also, if the DataEditor has a block size that is not yet part of the block size menu, it will be added and made current. git-svn-id: file:///srv/svn/repos/haiku/trunk/current@6778 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/apps/diskprobe/ProbeView.cpp | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/src/apps/diskprobe/ProbeView.cpp b/src/apps/diskprobe/ProbeView.cpp index 91f5ffed42..4f75781bc8 100644 --- a/src/apps/diskprobe/ProbeView.cpp +++ b/src/apps/diskprobe/ProbeView.cpp @@ -1156,15 +1156,26 @@ ProbeView::AttachedToWindow() // Block Size subMenu = new BMenu("BlockSize"); - subMenu->AddItem(item = new BMenuItem("512", message = new BMessage(kMsgBlockSize))); - message->AddInt32("block_size", 512); - item->SetMarked(true); - subMenu->AddItem(new BMenuItem("1024", message = new BMessage(kMsgBlockSize))); - message->AddInt32("block_size", 1024); - subMenu->AddItem(new BMenuItem("2048", message = new BMessage(kMsgBlockSize))); - message->AddInt32("block_size", 2048); - subMenu->SetTargetForItems(this); subMenu->SetRadioMode(true); + const uint32 blockSizes[] = {512, 1024, 2048}; + for (uint32 i = 0; i < sizeof(blockSizes) / sizeof(blockSizes[0]); i++) { + char buffer[32]; + snprintf(buffer, sizeof(buffer), "%ld%s", blockSizes[i], + fEditor.IsDevice() && fEditor.BlockSize() == blockSizes[i] ? " (native)" : ""); + subMenu->AddItem(item = new BMenuItem(buffer, message = new BMessage(kMsgBlockSize))); + message->AddInt32("block_size", blockSizes[i]); + if (fEditor.BlockSize() == blockSizes[i]) + item->SetMarked(true); + } + if (subMenu->FindMarked() == NULL) { + // if the device has some weird block size, we'll add it here, too + char buffer[32]; + snprintf(buffer, sizeof(buffer), "%ld (native)", fEditor.BlockSize()); + subMenu->AddItem(item = new BMenuItem(buffer, message = new BMessage(kMsgBlockSize))); + message->AddInt32("block_size", fEditor.BlockSize()); + item->SetMarked(true); + } + subMenu->SetTargetForItems(this); menu->AddItem(new BMenuItem(subMenu)); menu->AddSeparatorItem();