* finished the initialization paremeter panel and used it in
MainWindow::_Initialize()... setting the name and block size should work, though I have not tested this yet due to lack of available partitions. TODO: Use driver settings API from libroot to build the parameter string and move the GUI of the InitParamsPanel into the BFS add-on, implement BPartition::GetInitializationParameterEditor() accordingly. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@23561 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
b91634cbea
commit
2e3a7b96c0
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2007 Haiku Inc. All rights reserved.
|
||||
* Copyright 2007-2008 Haiku Inc. All rights reserved.
|
||||
* Distributed under the terms of the MIT license.
|
||||
*
|
||||
* Authors:
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2007 Haiku Inc. All rights reserved.
|
||||
* Copyright 2007-2008 Haiku Inc. All rights reserved.
|
||||
* Distributed under the terms of the MIT license.
|
||||
*/
|
||||
#ifndef DISK_VIEW_H
|
||||
|
@ -1,12 +1,26 @@
|
||||
/*
|
||||
* Copyright 2008 Haiku Inc. All rights reserved.
|
||||
* Distributed under the terms of the MIT license.
|
||||
*
|
||||
* Authors:
|
||||
* Stephan Aßmus <superstippi@gmx.de>
|
||||
*/
|
||||
#include "InitParamsPanel.h"
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include <Button.h>
|
||||
#include <GridLayoutBuilder.h>
|
||||
#include <GroupLayoutBuilder.h>
|
||||
#include <GroupView.h>
|
||||
#include <MenuField.h>
|
||||
#include <MenuItem.h>
|
||||
#include <Message.h>
|
||||
#include <MessageFilter.h>
|
||||
#include <PopUpMenu.h>
|
||||
#include <TextControl.h>
|
||||
|
||||
#include <SpaceLayoutItem.h>
|
||||
#include <String.h>
|
||||
|
||||
|
||||
class InitParamsPanel::EscapeFilter : public BMessageFilter {
|
||||
@ -49,24 +63,81 @@ private:
|
||||
|
||||
enum {
|
||||
MSG_OK = 'okok',
|
||||
MSG_CANCEL = 'cncl'
|
||||
MSG_CANCEL = 'cncl',
|
||||
MSG_BLOCK_SIZE = 'blsz'
|
||||
};
|
||||
|
||||
|
||||
|
||||
InitParamsPanel::InitParamsPanel(BWindow *window)
|
||||
: Panel(BRect(300.0, 200.0, 600.0, 400.0), 0, B_MODAL_WINDOW_LOOK,
|
||||
B_MODAL_SUBSET_WINDOW_FEEL, B_ASYNCHRONOUS_CONTROLS),
|
||||
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")
|
||||
, fExitSemaphore(create_sem(0, "InitParamsPanel exit"))
|
||||
, fWindow(window)
|
||||
, fReturnValue(GO_CANCELED)
|
||||
{
|
||||
AddCommonFilter(fEscapeFilter);
|
||||
|
||||
...
|
||||
fNameTC = new BTextControl("Name", NULL, NULL);
|
||||
|
||||
AddChild(topView);
|
||||
BPopUpMenu* blocksizeMenu = new BPopUpMenu("Blocksize");
|
||||
BMessage* message = new BMessage(MSG_BLOCK_SIZE);
|
||||
message->AddString("size", "1024");
|
||||
blocksizeMenu->AddItem(new BMenuItem("1024 (Mostly small files)", message));
|
||||
message = new BMessage(MSG_BLOCK_SIZE);
|
||||
message->AddString("size", "2048");
|
||||
blocksizeMenu->AddItem(new BMenuItem("2048 (Recommended)", message));
|
||||
message = new BMessage(MSG_BLOCK_SIZE);
|
||||
message->AddString("size", "4096");
|
||||
blocksizeMenu->AddItem(new BMenuItem("4096", message));
|
||||
message = new BMessage(MSG_BLOCK_SIZE);
|
||||
message->AddString("size", "8192");
|
||||
blocksizeMenu->AddItem(new BMenuItem("8192 (Mostly large files)", message));
|
||||
|
||||
fBlockSizeMF = new BMenuField("Blocksize", blocksizeMenu, NULL);
|
||||
|
||||
BButton* okButton = new BButton("Initialize", new BMessage(MSG_OK));
|
||||
BButton* cancelButton = new BButton("Cancel", new BMessage(MSG_CANCEL));
|
||||
|
||||
BView* rootView = BGroupLayoutBuilder(B_VERTICAL, 5)
|
||||
|
||||
.Add(BSpaceLayoutItem::CreateVerticalStrut(10))
|
||||
|
||||
// test views
|
||||
.Add(BGridLayoutBuilder(10, 10)
|
||||
// row 1
|
||||
.Add(BSpaceLayoutItem::CreateHorizontalStrut(5), 0, 0)
|
||||
|
||||
.Add(fNameTC->CreateLabelLayoutItem(), 1, 0)
|
||||
.Add(fNameTC->CreateTextViewLayoutItem(), 2, 0)
|
||||
|
||||
.Add(BSpaceLayoutItem::CreateHorizontalStrut(10), 3, 0)
|
||||
|
||||
// row 2
|
||||
.Add(BSpaceLayoutItem::CreateHorizontalStrut(10), 0, 1)
|
||||
|
||||
.Add(fBlockSizeMF->CreateLabelLayoutItem(), 1, 1)
|
||||
.Add(fBlockSizeMF->CreateMenuBarLayoutItem(), 2, 1)
|
||||
|
||||
.Add(BSpaceLayoutItem::CreateHorizontalStrut(5), 3, 1)
|
||||
)
|
||||
|
||||
// controls
|
||||
.AddGroup(B_HORIZONTAL, 10)
|
||||
.Add(BSpaceLayoutItem::CreateHorizontalStrut(5))
|
||||
.AddGlue()
|
||||
.Add(cancelButton)
|
||||
.Add(okButton)
|
||||
.Add(BSpaceLayoutItem::CreateHorizontalStrut(5))
|
||||
.End()
|
||||
|
||||
.Add(BSpaceLayoutItem::CreateVerticalStrut(5))
|
||||
;
|
||||
|
||||
SetLayout(new BGroupLayout(B_HORIZONTAL));
|
||||
AddChild(rootView);
|
||||
SetDefaultButton(okButton);
|
||||
|
||||
AddToSubset(fWindow);
|
||||
@ -93,7 +164,7 @@ InitParamsPanel::QuitRequested()
|
||||
void
|
||||
InitParamsPanel::MessageReceived(BMessage* message)
|
||||
{
|
||||
switch (msg->what) {
|
||||
switch (message->what) {
|
||||
case MSG_CANCEL:
|
||||
Cancel();
|
||||
break;
|
||||
@ -102,7 +173,7 @@ InitParamsPanel::MessageReceived(BMessage* message)
|
||||
fReturnValue = GO_SUCCESS;
|
||||
release_sem(fExitSemaphore);
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
BWindow::MessageReceived(message);
|
||||
}
|
||||
@ -110,13 +181,13 @@ InitParamsPanel::MessageReceived(BMessage* message)
|
||||
|
||||
|
||||
int32
|
||||
InitParamsPanel::Answer(BString& name, BString& parameters)
|
||||
InitParamsPanel::Go(BString& name, BString& parameters)
|
||||
{
|
||||
// run the window thread, to get an initial layout of the controls
|
||||
Hide();
|
||||
Show();
|
||||
if (!Lock())
|
||||
return false;
|
||||
return GO_CANCELED;
|
||||
|
||||
// center the panel above the parent window
|
||||
BRect frame = Frame();
|
||||
@ -133,12 +204,22 @@ InitParamsPanel::Answer(BString& name, BString& parameters)
|
||||
// block this thread now
|
||||
acquire_sem(fExitSemaphore);
|
||||
|
||||
if (fMode == GO_SUCCESS) {
|
||||
if (!Lock())
|
||||
return GO_CANCELED;
|
||||
|
||||
if (fReturnValue == GO_SUCCESS) {
|
||||
name = fNameTC->Text();
|
||||
parameters ...
|
||||
parameters = "";
|
||||
if (BMenuItem* item = fBlockSizeMF->Menu()->FindMarked()) {
|
||||
const char* size;
|
||||
BMessage* message = item->Message();
|
||||
if (!message || message->FindString("size", &size) < B_OK)
|
||||
size = "2048";
|
||||
// TODO: use libroot driver settings API
|
||||
parameters << "block_size " << size << ";\n";
|
||||
}
|
||||
}
|
||||
|
||||
Lock();
|
||||
Quit();
|
||||
return fReturnValue;
|
||||
}
|
||||
|
@ -1,3 +1,10 @@
|
||||
/*
|
||||
* Copyright 2008 Haiku Inc. All rights reserved.
|
||||
* Distributed under the terms of the MIT license.
|
||||
*
|
||||
* Authors:
|
||||
* Stephan Aßmus <superstippi@gmx.de>
|
||||
*/
|
||||
#ifndef INIT_PARAMS_PANEL_H
|
||||
#define INIT_PARAMS_PANEL_H
|
||||
|
||||
|
@ -7,6 +7,7 @@ UsePrivateHeaders interface shared storage ;
|
||||
Preference DriveSetup :
|
||||
DiskView.cpp
|
||||
DriveSetup.cpp
|
||||
InitParamsPanel.cpp
|
||||
MainWindow.cpp
|
||||
PartitionList.cpp
|
||||
Support.cpp
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2007 Haiku Inc. All rights reserved.
|
||||
* Copyright 2002-2008 Haiku Inc. All rights reserved.
|
||||
* Distributed under the terms of the MIT license.
|
||||
*
|
||||
* Authors:
|
||||
@ -9,6 +9,7 @@
|
||||
*/
|
||||
#include "MainWindow.h"
|
||||
#include "DiskView.h"
|
||||
#include "InitParamsPanel.h"
|
||||
#include "PartitionList.h"
|
||||
#include "Support.h"
|
||||
|
||||
@ -578,10 +579,13 @@ MainWindow::_Initialize(BDiskDevice* disk, partition_id selectedPartition,
|
||||
}
|
||||
|
||||
|
||||
// TODO: check and allow BFS only, since our parameter string
|
||||
// construction only handles BFS at the moment
|
||||
// if (BString("") != diskSystem) {
|
||||
// }
|
||||
// allow BFS only, since our parameter string
|
||||
// construction only handles BFS at the moment
|
||||
if (diskSystemName != "Be File System") {
|
||||
_DisplayPartitionError("Don't know how to construct parameters "
|
||||
"for this file system.");
|
||||
return;
|
||||
}
|
||||
|
||||
status_t ret = disk->PrepareModifications();
|
||||
if (ret != B_OK) {
|
||||
@ -593,9 +597,10 @@ MainWindow::_Initialize(BDiskDevice* disk, partition_id selectedPartition,
|
||||
// TODO: use partition initialization editor
|
||||
// (partition->GetInitializationParameterEditor())
|
||||
|
||||
BString name = "BFS Init Test";
|
||||
BString name = "Haiku";
|
||||
BString parameters;
|
||||
parameters << "block_size " << 2048 << "\n";
|
||||
InitParamsPanel* panel = new InitParamsPanel(this);
|
||||
panel->Go(name, parameters);
|
||||
|
||||
bool supportsName = diskSystem.SupportsContentName();
|
||||
BString validatedName(name);
|
||||
|
@ -1,6 +1,10 @@
|
||||
/*
|
||||
* Copyright 2002-2007 Haiku Inc. All rights reserved.
|
||||
* Copyright 2002-2008 Haiku Inc. All rights reserved.
|
||||
* Distributed under the terms of the MIT license.
|
||||
*
|
||||
* Authors:
|
||||
* Ithamar R. Adema <ithamar@unet.nl>
|
||||
* Stephan Aßmus <superstippi@gmx.de>
|
||||
*/
|
||||
#ifndef MAIN_WINDOW_H
|
||||
#define MAIN_WINDOW_H
|
||||
|
@ -1,9 +1,10 @@
|
||||
/*
|
||||
* Copyright 2006-2007 Haiku Inc. All rights reserved.
|
||||
* Copyright 2006-2008 Haiku Inc. All rights reserved.
|
||||
* Distributed under the terms of the MIT license.
|
||||
*
|
||||
* Authors:
|
||||
* Ithamar R. Adema <ithamar@unet.nl>
|
||||
* Stephan Aßmus <superstippi@gmx.de>
|
||||
*/
|
||||
#include "PartitionList.h"
|
||||
#include "Support.h"
|
||||
|
@ -1,6 +1,10 @@
|
||||
/*
|
||||
* Copyright 2006-2007 Haiku Inc. All rights reserved.
|
||||
* Copyright 2006-2008 Haiku Inc. All rights reserved.
|
||||
* Distributed under the terms of the MIT license.
|
||||
*
|
||||
* Authors:
|
||||
* Ithamar R. Adema <ithamar@unet.nl>
|
||||
* Stephan Aßmus <superstippi@gmx.de>
|
||||
*/
|
||||
#ifndef PARTITIONLIST_H
|
||||
#define PARTITIONLIST_H
|
||||
|
Loading…
Reference in New Issue
Block a user