* Now listens to disk device notifications, and rescans its device list when
something comes in -- this could be greatly improved, though. * Cleanup. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@29583 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -1,10 +1,11 @@
|
||||
/*
|
||||
* Copyright 2007-2008 Haiku Inc. All rights reserved.
|
||||
* Copyright 2007-2009 Haiku Inc. All rights reserved.
|
||||
* Distributed under the terms of the MIT license.
|
||||
*
|
||||
* Authors:
|
||||
* Stephan Aßmus <[email protected]>
|
||||
*/
|
||||
|
||||
#include "DiskView.h"
|
||||
#include "MainWindow.h"
|
||||
|
||||
@@ -28,14 +29,14 @@ class PartitionView : public BView {
|
||||
public:
|
||||
PartitionView(const char* name, float weight, off_t offset,
|
||||
int32 level, partition_id id)
|
||||
: BView(name, B_WILL_DRAW | B_SUPPORTS_LAYOUT | B_FULL_UPDATE_ON_RESIZE)
|
||||
, fID(id)
|
||||
, fWeight(weight)
|
||||
, fOffset(offset)
|
||||
, fLevel(level)
|
||||
, fSelected(false)
|
||||
, fMouseOver(false)
|
||||
, fGroupLayout(new BGroupLayout(B_HORIZONTAL, kLayoutInset))
|
||||
: BView(name, B_WILL_DRAW | B_SUPPORTS_LAYOUT | B_FULL_UPDATE_ON_RESIZE),
|
||||
fID(id),
|
||||
fWeight(weight),
|
||||
fOffset(offset),
|
||||
fLevel(level),
|
||||
fSelected(false),
|
||||
fMouseOver(false),
|
||||
fGroupLayout(new BGroupLayout(B_HORIZONTAL, kLayoutInset))
|
||||
{
|
||||
SetLayout(fGroupLayout);
|
||||
|
||||
@@ -184,10 +185,11 @@ private:
|
||||
class DiskView::PartitionLayout : public BDiskDeviceVisitor {
|
||||
public:
|
||||
PartitionLayout(BView* view, SpaceIDMap& spaceIDMap)
|
||||
: fView(view)
|
||||
, fViewMap()
|
||||
, fSelectedPartition(-1)
|
||||
, fSpaceIDMap(spaceIDMap)
|
||||
:
|
||||
fView(view),
|
||||
fViewMap(),
|
||||
fSelectedPartition(-1),
|
||||
fSpaceIDMap(spaceIDMap)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -319,11 +321,11 @@ public:
|
||||
DiskView::DiskView(const BRect& frame, uint32 resizeMode,
|
||||
SpaceIDMap& spaceIDMap)
|
||||
: Inherited(frame, "diskview", resizeMode,
|
||||
B_WILL_DRAW | B_FULL_UPDATE_ON_RESIZE)
|
||||
, fDiskCount(0)
|
||||
, fDisk(NULL)
|
||||
, fSpaceIDMap(spaceIDMap)
|
||||
, fPartitionLayout(new PartitionLayout(this, fSpaceIDMap))
|
||||
B_WILL_DRAW | B_FULL_UPDATE_ON_RESIZE),
|
||||
fDiskCount(0),
|
||||
fDisk(NULL),
|
||||
fSpaceIDMap(spaceIDMap),
|
||||
fPartitionLayout(new PartitionLayout(this, fSpaceIDMap))
|
||||
{
|
||||
BGroupLayout* layout = new BGroupLayout(B_HORIZONTAL, kLayoutInset);
|
||||
SetLayout(layout);
|
||||
@@ -415,6 +417,7 @@ DiskView::SetDiskCount(int32 count)
|
||||
fDiskCount = count;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
DiskView::SetDisk(BDiskDevice* disk, partition_id selectedPartition)
|
||||
{
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2007 Haiku Inc. All rights reserved.
|
||||
* Copyright 2002-2009 Haiku Inc. All rights reserved.
|
||||
* Distributed under the terms of the MIT license.
|
||||
*
|
||||
* Authors:
|
||||
@@ -7,6 +7,7 @@
|
||||
* Ithamar R. Adema <[email protected]>
|
||||
* Stephan Aßmus <[email protected]>
|
||||
*/
|
||||
|
||||
#include "DriveSetup.h"
|
||||
#include "MainWindow.h"
|
||||
|
||||
@@ -18,22 +19,10 @@
|
||||
#include <Path.h>
|
||||
|
||||
|
||||
int
|
||||
main(int, char**)
|
||||
{
|
||||
DriveSetup app;
|
||||
app.Run();
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
// #pragma mark -
|
||||
|
||||
|
||||
DriveSetup::DriveSetup()
|
||||
: BApplication("application/x-vnd.Haiku-DriveSetup")
|
||||
, fWindow(NULL)
|
||||
, fSettings(0UL)
|
||||
: BApplication("application/x-vnd.Haiku-DriveSetup"),
|
||||
fWindow(NULL),
|
||||
fSettings(0UL)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -152,3 +141,13 @@ DriveSetup::_GetSettingsFile(BFile& file, bool forWriting) const
|
||||
}
|
||||
|
||||
|
||||
// #pragma mark -
|
||||
|
||||
|
||||
int
|
||||
main(int, char**)
|
||||
{
|
||||
DriveSetup app;
|
||||
app.Run();
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
/*
|
||||
* Copyright 2008 Haiku Inc. All rights reserved.
|
||||
* Copyright 2008-2009 Haiku Inc. All rights reserved.
|
||||
* Distributed under the terms of the MIT license.
|
||||
*
|
||||
* Authors:
|
||||
* Stephan Aßmus <[email protected]>
|
||||
*/
|
||||
|
||||
#include "InitParamsPanel.h"
|
||||
|
||||
#include <stdio.h>
|
||||
@@ -27,7 +28,7 @@ class InitParamsPanel::EscapeFilter : public BMessageFilter {
|
||||
public:
|
||||
EscapeFilter(InitParamsPanel* target)
|
||||
: BMessageFilter(B_ANY_DELIVERY, B_ANY_SOURCE),
|
||||
fPanel(target)
|
||||
fPanel(target)
|
||||
{
|
||||
}
|
||||
virtual ~EscapeFilter()
|
||||
@@ -68,15 +69,14 @@ enum {
|
||||
};
|
||||
|
||||
|
||||
|
||||
InitParamsPanel::InitParamsPanel(BWindow* window)
|
||||
: BWindow(BRect(300.0, 200.0, 600.0, 300.0), 0, B_MODAL_WINDOW_LOOK,
|
||||
B_MODAL_SUBSET_WINDOW_FEEL,
|
||||
B_ASYNCHRONOUS_CONTROLS | B_AUTO_UPDATE_SIZE_LIMITS)
|
||||
, fEscapeFilter(new EscapeFilter(this))
|
||||
, fExitSemaphore(create_sem(0, "InitParamsPanel exit"))
|
||||
, fWindow(window)
|
||||
, fReturnValue(GO_CANCELED)
|
||||
B_ASYNCHRONOUS_CONTROLS | B_AUTO_UPDATE_SIZE_LIMITS),
|
||||
fEscapeFilter(new EscapeFilter(this)),
|
||||
fExitSemaphore(create_sem(0, "InitParamsPanel exit")),
|
||||
fWindow(window),
|
||||
fReturnValue(GO_CANCELED)
|
||||
{
|
||||
AddCommonFilter(fEscapeFilter);
|
||||
|
||||
@@ -245,9 +245,3 @@ InitParamsPanel::Cancel()
|
||||
fReturnValue = GO_CANCELED;
|
||||
release_sem(fExitSemaphore);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2008 Haiku Inc. All rights reserved.
|
||||
* Copyright 2002-2009 Haiku Inc. All rights reserved.
|
||||
* Distributed under the terms of the MIT license.
|
||||
*
|
||||
* Authors:
|
||||
@@ -7,6 +7,7 @@
|
||||
* Ithamar R. Adema <[email protected]>
|
||||
* Stephan Aßmus <[email protected]>
|
||||
*/
|
||||
|
||||
#include "MainWindow.h"
|
||||
#include "DiskView.h"
|
||||
#include "InitParamsPanel.h"
|
||||
@@ -37,9 +38,10 @@ class ListPopulatorVisitor : public BDiskDeviceVisitor {
|
||||
public:
|
||||
ListPopulatorVisitor(PartitionListView* list, int32& diskCount,
|
||||
SpaceIDMap& spaceIDMap)
|
||||
: fPartitionList(list)
|
||||
, fDiskCount(diskCount)
|
||||
, fSpaceIDMap(spaceIDMap)
|
||||
:
|
||||
fPartitionList(list),
|
||||
fDiskCount(diskCount),
|
||||
fSpaceIDMap(spaceIDMap)
|
||||
{
|
||||
fDiskCount = 0;
|
||||
fSpaceIDMap.Clear();
|
||||
@@ -145,10 +147,10 @@ enum {
|
||||
|
||||
MainWindow::MainWindow(BRect frame)
|
||||
: BWindow(frame, "DriveSetup", B_DOCUMENT_WINDOW,
|
||||
B_ASYNCHRONOUS_CONTROLS | B_NOT_ZOOMABLE)
|
||||
, fCurrentDisk(NULL)
|
||||
, fCurrentPartitionID(-1)
|
||||
, fSpaceIDMap()
|
||||
B_ASYNCHRONOUS_CONTROLS | B_NOT_ZOOMABLE),
|
||||
fCurrentDisk(NULL),
|
||||
fCurrentPartitionID(-1),
|
||||
fSpaceIDMap()
|
||||
{
|
||||
BMenuBar* menuBar = new BMenuBar(Bounds(), "root menu");
|
||||
|
||||
@@ -161,7 +163,7 @@ MainWindow::MainWindow(BRect frame)
|
||||
|
||||
fDeleteMI = new BMenuItem("Delete (not implemented)",
|
||||
new BMessage(MSG_DELETE));
|
||||
fDeleteMI->SetEnabled(false);
|
||||
fDeleteMI->SetEnabled(false);
|
||||
|
||||
fMountMI = new BMenuItem("Mount", new BMessage(MSG_MOUNT), 'M');
|
||||
fUnmountMI = new BMenuItem("Unmount", new BMessage(MSG_UNMOUNT), 'U');
|
||||
@@ -170,38 +172,37 @@ fDeleteMI->SetEnabled(false);
|
||||
|
||||
// Disk menu
|
||||
fDiskMenu = new BMenu("Disk");
|
||||
fDiskMenu->AddItem(fFormatMI);
|
||||
fDiskMenu->AddItem(fEjectMI);
|
||||
fDiskMenu->AddItem(fSurfaceTestMI);
|
||||
fDiskMenu->AddItem(fFormatMI);
|
||||
fDiskMenu->AddItem(fEjectMI);
|
||||
fDiskMenu->AddItem(fSurfaceTestMI);
|
||||
|
||||
fDiskMenu->AddSeparatorItem();
|
||||
fDiskMenu->AddSeparatorItem();
|
||||
|
||||
fDiskMenu->AddItem(fRescanMI);
|
||||
fDiskMenu->AddItem(fRescanMI);
|
||||
menuBar->AddItem(fDiskMenu);
|
||||
|
||||
// Parition menu
|
||||
fPartitionMenu = new BMenu("Partition");
|
||||
fCreateMenu = new BMenu("Create (not implemented)");
|
||||
fPartitionMenu->AddItem(fCreateMenu);
|
||||
fCreateMenu = new BMenu("Create (not implemented)");
|
||||
fPartitionMenu->AddItem(fCreateMenu);
|
||||
|
||||
fInitMenu = new BMenu("Initialize");
|
||||
fPartitionMenu->AddItem(fInitMenu);
|
||||
fInitMenu = new BMenu("Initialize");
|
||||
fPartitionMenu->AddItem(fInitMenu);
|
||||
|
||||
fPartitionMenu->AddItem(fDeleteMI);
|
||||
fPartitionMenu->AddItem(fDeleteMI);
|
||||
|
||||
fPartitionMenu->AddSeparatorItem();
|
||||
fPartitionMenu->AddSeparatorItem();
|
||||
|
||||
fPartitionMenu->AddItem(fMountMI);
|
||||
fPartitionMenu->AddItem(fUnmountMI);
|
||||
fPartitionMenu->AddItem(fMountMI);
|
||||
fPartitionMenu->AddItem(fUnmountMI);
|
||||
|
||||
fPartitionMenu->AddSeparatorItem();
|
||||
fPartitionMenu->AddSeparatorItem();
|
||||
|
||||
fPartitionMenu->AddItem(fMountAllMI);
|
||||
fPartitionMenu->AddItem(fMountAllMI);
|
||||
menuBar->AddItem(fPartitionMenu);
|
||||
|
||||
AddChild(menuBar);
|
||||
|
||||
|
||||
// add DiskView
|
||||
BRect r(Bounds());
|
||||
r.top = menuBar->Frame().bottom + 1;
|
||||
@@ -221,6 +222,8 @@ fDeleteMI->SetEnabled(false);
|
||||
fListView->SetSelectionMessage(new BMessage(MSG_PARTITION_ROW_SELECTED));
|
||||
fListView->SetTarget(this);
|
||||
|
||||
BDiskDeviceRoster().StartWatching(this);
|
||||
|
||||
// populate the Initialiaze menu with the available file systems
|
||||
_ScanFileSystems();
|
||||
|
||||
@@ -231,6 +234,7 @@ fDeleteMI->SetEnabled(false);
|
||||
|
||||
MainWindow::~MainWindow()
|
||||
{
|
||||
BDiskDeviceRoster().StopWatching(this);
|
||||
delete fCurrentDisk;
|
||||
}
|
||||
|
||||
@@ -281,6 +285,9 @@ MainWindow::MessageReceived(BMessage* message)
|
||||
case MSG_SURFACE_TEST:
|
||||
printf("MSG_SURFACE_TEST\n");
|
||||
break;
|
||||
|
||||
// TODO: this could probably be done better!
|
||||
case B_DEVICE_UPDATE:
|
||||
case MSG_RESCAN:
|
||||
_ScanDrives();
|
||||
break;
|
||||
@@ -482,10 +489,10 @@ MainWindow::_EnabledDisableMenuItems(BDiskDevice* disk,
|
||||
fPartitionMenu->SetEnabled(false);
|
||||
} else {
|
||||
// fFormatMI->SetEnabled(true);
|
||||
fFormatMI->SetEnabled(false);
|
||||
fFormatMI->SetEnabled(false);
|
||||
fEjectMI->SetEnabled(disk->IsRemovableMedia());
|
||||
// fSurfaceTestMI->SetEnabled(true);
|
||||
fSurfaceTestMI->SetEnabled(false);
|
||||
fSurfaceTestMI->SetEnabled(false);
|
||||
|
||||
// Create menu and items
|
||||
fPartitionMenu->SetEnabled(true);
|
||||
@@ -524,7 +531,7 @@ fSurfaceTestMI->SetEnabled(false);
|
||||
if (partition) {
|
||||
fInitMenu->SetEnabled(!partition->IsMounted());
|
||||
// fDeleteMI->SetEnabled(!partition->IsMounted());
|
||||
fDeleteMI->SetEnabled(false);
|
||||
fDeleteMI->SetEnabled(false);
|
||||
fMountMI->SetEnabled(!partition->IsMounted());
|
||||
|
||||
bool unMountable = false;
|
||||
@@ -659,8 +666,9 @@ MainWindow::_MountAll()
|
||||
class ModificationPreparer {
|
||||
public:
|
||||
ModificationPreparer(BDiskDevice* disk)
|
||||
: fDisk(disk)
|
||||
, fModificationStatus(fDisk->PrepareModifications())
|
||||
:
|
||||
fDisk(disk),
|
||||
fModificationStatus(fDisk->PrepareModifications())
|
||||
{
|
||||
}
|
||||
~ModificationPreparer()
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2006-2008 Haiku Inc. All rights reserved.
|
||||
* Copyright 2006-2009 Haiku Inc. All rights reserved.
|
||||
* Distributed under the terms of the MIT license.
|
||||
*
|
||||
* Authors:
|
||||
@@ -18,8 +18,8 @@
|
||||
|
||||
|
||||
BBitmapStringField::BBitmapStringField(BBitmap* bitmap, const char* string)
|
||||
: Inherited(string)
|
||||
, fBitmap(bitmap)
|
||||
: Inherited(string),
|
||||
fBitmap(bitmap)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -178,11 +178,11 @@ enum {
|
||||
|
||||
|
||||
PartitionListRow::PartitionListRow(BPartition* partition)
|
||||
: Inherited()
|
||||
, fPartitionID(partition->ID())
|
||||
, fParentID(partition->Parent() ? partition->Parent()->ID() : -1)
|
||||
, fOffset(partition->Offset())
|
||||
, fSize(partition->Size())
|
||||
: Inherited(),
|
||||
fPartitionID(partition->ID()),
|
||||
fParentID(partition->Parent() ? partition->Parent()->ID() : -1),
|
||||
fOffset(partition->Offset()),
|
||||
fSize(partition->Size())
|
||||
{
|
||||
BPath path;
|
||||
partition->GetPath(&path);
|
||||
@@ -221,11 +221,11 @@ PartitionListRow::PartitionListRow(BPartition* partition)
|
||||
|
||||
PartitionListRow::PartitionListRow(partition_id parentID, partition_id id,
|
||||
off_t offset, off_t size)
|
||||
: Inherited()
|
||||
, fPartitionID(id)
|
||||
, fParentID(parentID)
|
||||
, fOffset(offset)
|
||||
, fSize(size)
|
||||
: Inherited(),
|
||||
fPartitionID(id),
|
||||
fParentID(parentID),
|
||||
fOffset(offset),
|
||||
fSize(size)
|
||||
{
|
||||
// TODO: design icon for spaces on partitions
|
||||
SetField(new BBitmapStringField(NULL, "-"), kDeviceColumn);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2007 Haiku Inc. All rights reserved.
|
||||
* Copyright 2002-2009 Haiku Inc. All rights reserved.
|
||||
* Distributed under the terms of the MIT license.
|
||||
*
|
||||
* Authors:
|
||||
@@ -7,6 +7,7 @@
|
||||
* Ithamar R. Adema <[email protected]>
|
||||
* Stephan Aßmus <[email protected]>
|
||||
*/
|
||||
|
||||
#include "Support.h"
|
||||
|
||||
#include <Partition.h>
|
||||
@@ -78,11 +79,12 @@ is_valid_partitionable_space(size_t size)
|
||||
}
|
||||
|
||||
|
||||
// #pragma mark -SpaceIDMap
|
||||
// #pragma mark - SpaceIDMap
|
||||
|
||||
|
||||
SpaceIDMap::SpaceIDMap()
|
||||
: HashMap<HashString, partition_id>()
|
||||
, fNextSpaceID(-2)
|
||||
: HashMap<HashString, partition_id>(),
|
||||
fNextSpaceID(-2)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -107,4 +109,3 @@ SpaceIDMap::SpaceIDFor(partition_id parentID, off_t spaceOffset)
|
||||
return newID;
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user