* fix saving settings (don't let the window quit by itself)
* add partition creation menu items * filter filesystems by their support for "initializing" git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@22855 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -78,15 +78,23 @@ DriveSetup::_StoreSettings()
|
|||||||
fWindow->Unlock();
|
fWindow->Unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ret < B_OK)
|
if (ret < B_OK) {
|
||||||
|
fprintf(stderr, "failed to store settings: %s\n", strerror(ret));
|
||||||
return ret;
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
BFile file;
|
BFile file;
|
||||||
ret = _GetSettingsFile(file, true);
|
ret = _GetSettingsFile(file, true);
|
||||||
if (ret < B_OK)
|
if (ret < B_OK)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
return fSettings.Flatten(&file);
|
ret = fSettings.Flatten(&file);
|
||||||
|
if (ret < B_OK) {
|
||||||
|
fprintf(stderr, "failed to flatten settings: %s\n", strerror(ret));
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
return B_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -95,14 +103,23 @@ DriveSetup::_RestoreSettings()
|
|||||||
{
|
{
|
||||||
BFile file;
|
BFile file;
|
||||||
status_t ret = _GetSettingsFile(file, false);
|
status_t ret = _GetSettingsFile(file, false);
|
||||||
|
if (ret < B_OK)
|
||||||
|
return ret;
|
||||||
|
|
||||||
if (ret >= B_OK)
|
ret = fSettings.Unflatten(&file);
|
||||||
ret = fSettings.Unflatten(&file);
|
if (ret < B_OK) {
|
||||||
|
fprintf(stderr, "failed to unflatten settings: %s\n", strerror(ret));
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
fSettings.PrintToStream();
|
||||||
|
|
||||||
if (ret >= B_OK)
|
ret = fWindow->RestoreSettings(&fSettings);
|
||||||
ret = fWindow->RestoreSettings(&fSettings);
|
if (ret < B_OK) {
|
||||||
|
fprintf(stderr, "failed to restore settings: %s\n", strerror(ret));
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
return ret;
|
return B_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -2,8 +2,8 @@
|
|||||||
* Copyright 2002-2007 Haiku Inc. All rights reserved.
|
* Copyright 2002-2007 Haiku Inc. All rights reserved.
|
||||||
* Distributed under the terms of the MIT license.
|
* Distributed under the terms of the MIT license.
|
||||||
*/
|
*/
|
||||||
#ifndef MAIN_H
|
#ifndef DRIVE_SETUP_H
|
||||||
#define MAIN_H
|
#define DRIVE_SETUP_H
|
||||||
|
|
||||||
|
|
||||||
#include <Application.h>
|
#include <Application.h>
|
||||||
@@ -34,4 +34,4 @@ private:
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
#endif // MAIN_H
|
#endif // DRIVE_SETUP_H
|
||||||
|
|||||||
@@ -95,6 +95,9 @@ enum {
|
|||||||
MSG_MOUNT = 'mnts',
|
MSG_MOUNT = 'mnts',
|
||||||
MSG_UNMOUNT = 'unmt',
|
MSG_UNMOUNT = 'unmt',
|
||||||
MSG_FORMAT = 'frmt',
|
MSG_FORMAT = 'frmt',
|
||||||
|
MSG_CREATE_PRIMARY = 'crpr',
|
||||||
|
MSG_CREATE_EXTENDED = 'crex',
|
||||||
|
MSG_CREATE_LOGICAL = 'crlg',
|
||||||
MSG_INITIALIZE = 'init',
|
MSG_INITIALIZE = 'init',
|
||||||
MSG_EJECT = 'ejct',
|
MSG_EJECT = 'ejct',
|
||||||
MSG_SURFACE_TEST = 'sfct',
|
MSG_SURFACE_TEST = 'sfct',
|
||||||
@@ -120,8 +123,10 @@ MainWindow::MainWindow(BRect frame)
|
|||||||
|
|
||||||
// Parition menu
|
// Parition menu
|
||||||
menu = new BMenu("Partition");
|
menu = new BMenu("Partition");
|
||||||
BMenu* initMenu = new BMenu("Initialize");
|
BMenu* createMenu = new BMenu("Create");
|
||||||
menu->AddItem(initMenu);
|
menu->AddItem(createMenu);
|
||||||
|
fInitMenu = new BMenu("Initialize");
|
||||||
|
menu->AddItem(fInitMenu);
|
||||||
menu->AddSeparatorItem();
|
menu->AddSeparatorItem();
|
||||||
menu->AddItem(new BMenuItem("Mount", new BMessage(MSG_MOUNT), 'M'));
|
menu->AddItem(new BMenuItem("Mount", new BMessage(MSG_MOUNT), 'M'));
|
||||||
menu->AddItem(new BMenuItem("Unmount", new BMessage(MSG_UNMOUNT), 'U'));
|
menu->AddItem(new BMenuItem("Unmount", new BMessage(MSG_UNMOUNT), 'U'));
|
||||||
@@ -132,23 +137,20 @@ MainWindow::MainWindow(BRect frame)
|
|||||||
|
|
||||||
AddChild(rootMenu);
|
AddChild(rootMenu);
|
||||||
|
|
||||||
|
createMenu->AddItem(new BMenuItem("Primary",
|
||||||
|
new BMessage(MSG_CREATE_PRIMARY)));
|
||||||
|
createMenu->AddItem(new BMenuItem("Extended",
|
||||||
|
new BMessage(MSG_CREATE_EXTENDED)));
|
||||||
|
createMenu->AddItem(new BMenuItem("Logical",
|
||||||
|
new BMessage(MSG_CREATE_LOGICAL)));
|
||||||
|
|
||||||
BRect r(Bounds());
|
BRect r(Bounds());
|
||||||
r.top = rootMenu->Frame().bottom + 1;
|
r.top = rootMenu->Frame().bottom + 1;
|
||||||
fListView = new PartitionListView(r);
|
fListView = new PartitionListView(r);
|
||||||
AddChild(fListView);
|
AddChild(fListView);
|
||||||
|
|
||||||
// Populate the Initialiaze menu with the available file systems
|
// Populate the Initialiaze menu with the available file systems
|
||||||
BDiskSystem diskSystem;
|
_ScanFileSystems();
|
||||||
fDDRoster.RewindDiskSystems();
|
|
||||||
while(fDDRoster.GetNextDiskSystem(&diskSystem) == B_OK) {
|
|
||||||
if (diskSystem.IsFileSystem()) {
|
|
||||||
BMessage* message = new BMessage(MSG_INITIALIZE);
|
|
||||||
message->AddString("format", diskSystem.Name());
|
|
||||||
BString label = diskSystem.PrettyName();
|
|
||||||
label << B_UTF8_ELLIPSIS;
|
|
||||||
initMenu->AddItem(new BMenuItem(label.String(), message));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Visit all disks in the system and show their contents
|
// Visit all disks in the system and show their contents
|
||||||
_ScanDrives();
|
_ScanDrives();
|
||||||
@@ -162,31 +164,37 @@ MainWindow::MessageReceived(BMessage* message)
|
|||||||
case MSG_MOUNT_ALL:
|
case MSG_MOUNT_ALL:
|
||||||
printf("MSG_MOUNT_ALL\n");
|
printf("MSG_MOUNT_ALL\n");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case MSG_MOUNT:
|
case MSG_MOUNT:
|
||||||
printf("MSG_MOUNT\n");
|
printf("MSG_MOUNT\n");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case MSG_UNMOUNT:
|
case MSG_UNMOUNT:
|
||||||
printf("MSG_UNMOUNT\n");
|
printf("MSG_UNMOUNT\n");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case MSG_FORMAT:
|
case MSG_FORMAT:
|
||||||
printf("MSG_FORMAT\n");
|
printf("MSG_FORMAT\n");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case MSG_CREATE_PRIMARY:
|
||||||
|
printf("MSG_CREATE_PRIMARY\n");
|
||||||
|
break;
|
||||||
|
case MSG_CREATE_EXTENDED:
|
||||||
|
printf("MSG_CREATE_EXTENDED\n");
|
||||||
|
break;
|
||||||
|
case MSG_CREATE_LOGICAL:
|
||||||
|
printf("MSG_CREATE_LOGICAL\n");
|
||||||
|
break;
|
||||||
|
|
||||||
case MSG_INITIALIZE:
|
case MSG_INITIALIZE:
|
||||||
printf("MSG_INITIALIZE\n");
|
printf("MSG_INITIALIZE\n");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case MSG_EJECT:
|
case MSG_EJECT:
|
||||||
printf("MSG_EJECT\n");
|
printf("MSG_EJECT\n");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case MSG_SURFACE_TEST:
|
case MSG_SURFACE_TEST:
|
||||||
printf("MSG_SURFACE_TEST\n");
|
printf("MSG_SURFACE_TEST\n");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case MSG_RESCAN:
|
case MSG_RESCAN:
|
||||||
_ScanDrives();
|
_ScanDrives();
|
||||||
break;
|
break;
|
||||||
@@ -203,7 +211,8 @@ MainWindow::QuitRequested()
|
|||||||
{
|
{
|
||||||
// TODO: ask about any unsaved changes
|
// TODO: ask about any unsaved changes
|
||||||
be_app->PostMessage(B_QUIT_REQUESTED);
|
be_app->PostMessage(B_QUIT_REQUESTED);
|
||||||
return true;
|
Hide();
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -249,6 +258,26 @@ MainWindow::_ScanDrives()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
MainWindow::_ScanFileSystems()
|
||||||
|
{
|
||||||
|
while (BMenuItem* item = fInitMenu->RemoveItem(0L))
|
||||||
|
delete item;
|
||||||
|
|
||||||
|
BDiskSystem diskSystem;
|
||||||
|
fDDRoster.RewindDiskSystems();
|
||||||
|
while(fDDRoster.GetNextDiskSystem(&diskSystem) == B_OK) {
|
||||||
|
if (diskSystem.IsFileSystem() && diskSystem.SupportsInitializing()) {
|
||||||
|
BMessage* message = new BMessage(MSG_INITIALIZE);
|
||||||
|
message->AddString("format", diskSystem.Name());
|
||||||
|
BString label = diskSystem.PrettyName();
|
||||||
|
label << B_UTF8_ELLIPSIS;
|
||||||
|
fInitMenu->AddItem(new BMenuItem(label.String(), message));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// #pragma mark - DriveVisitor
|
// #pragma mark - DriveVisitor
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -10,9 +10,9 @@
|
|||||||
#include <Window.h>
|
#include <Window.h>
|
||||||
|
|
||||||
|
|
||||||
class PosSettings;
|
|
||||||
class BPartition;
|
|
||||||
class BDiskDevice;
|
class BDiskDevice;
|
||||||
|
class BPartition;
|
||||||
|
class BMenu;
|
||||||
class PartitionListView;
|
class PartitionListView;
|
||||||
|
|
||||||
|
|
||||||
@@ -35,10 +35,13 @@ public:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
void _ScanDrives();
|
void _ScanDrives();
|
||||||
|
void _ScanFileSystems();
|
||||||
|
|
||||||
|
|
||||||
BDiskDeviceRoster fDDRoster;
|
BDiskDeviceRoster fDDRoster;
|
||||||
PartitionListView* fListView;
|
PartitionListView* fListView;
|
||||||
|
|
||||||
|
BMenu* fInitMenu;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user