Fixed design issues in BPartitionParameterEditor.
* The user of an editor needed knowledge about the editor in order to make use of it. * Furthermore, the BPartitionParameterEditor exposed type specific functionality that it shouldn't know anything about, either. * We may now define a number of known parameters per editor type; right now there is only "type" as it's needed by DriveSetup. * Adapted all disk systems, and DriveSetup to the new API. * Renamed CreateParamsPanel, and InitializeParamsPanel to *ParametersPanel in DriveSetup. * They now share a common base class AbstractParametersPanel.
This commit is contained in:
@@ -1,4 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
|
* Copyright 2013, Axel Dörfler, [email protected].
|
||||||
* Copyright 2009, Bryce Groff, [email protected].
|
* Copyright 2009, Bryce Groff, [email protected].
|
||||||
* Distributed under the terms of the MIT License.
|
* Distributed under the terms of the MIT License.
|
||||||
*/
|
*/
|
||||||
@@ -9,26 +10,32 @@
|
|||||||
#include <View.h>
|
#include <View.h>
|
||||||
|
|
||||||
|
|
||||||
// BPartitionParameterEditor
|
class BMessage;
|
||||||
|
class BPartition;
|
||||||
|
class BVariant;
|
||||||
|
|
||||||
|
|
||||||
class BPartitionParameterEditor {
|
class BPartitionParameterEditor {
|
||||||
public:
|
public:
|
||||||
BPartitionParameterEditor();
|
BPartitionParameterEditor();
|
||||||
virtual ~BPartitionParameterEditor();
|
virtual ~BPartitionParameterEditor();
|
||||||
|
|
||||||
virtual bool FinishedEditing();
|
virtual void SetTo(BPartition* partition);
|
||||||
|
|
||||||
|
void SetModificationMessage(BMessage* message);
|
||||||
|
BMessage* ModificationMessage() const;
|
||||||
|
|
||||||
virtual BView* View();
|
virtual BView* View();
|
||||||
|
|
||||||
virtual status_t GetParameters(BString* parameters);
|
virtual bool ValidateParameters() const;
|
||||||
|
virtual status_t ParameterChanged(const char* name,
|
||||||
|
const BVariant& variant);
|
||||||
|
|
||||||
// TODO: Those are child creation specific and shouldn't be in a generic
|
virtual status_t GetParameters(BString& parameters);
|
||||||
// interface. Something like a
|
|
||||||
// GenericPartitionParameterChanged(partition_parameter_type,
|
private:
|
||||||
// const BVariant&)
|
BMessage* fModificationMessage;
|
||||||
// would be better.
|
|
||||||
virtual status_t PartitionTypeChanged(const char* type);
|
|
||||||
virtual status_t PartitionNameChanged(const char* name);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
#endif //_PARTITION_PARAMETER_EDITOR_H
|
#endif // _PARTITION_PARAMETER_EDITOR_H
|
||||||
|
|||||||
@@ -1,7 +1,3 @@
|
|||||||
/*
|
|
||||||
* BFSAddOn.rdef
|
|
||||||
*/
|
|
||||||
|
|
||||||
resource app_signature "application/x-vnd.Haiku-BFSAddOn";
|
resource app_signature "application/x-vnd.Haiku-BFSAddOn";
|
||||||
|
|
||||||
resource app_version {
|
resource app_version {
|
||||||
@@ -11,5 +7,5 @@ resource app_version {
|
|||||||
variety = 0,
|
variety = 0,
|
||||||
internal = 0,
|
internal = 0,
|
||||||
short_info = "1.0.0",
|
short_info = "1.0.0",
|
||||||
long_info = "Haiku BFS disk add-on."
|
long_info = "BFS disk add-on."
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
|
* Copyright 2013, Axel Dörfler, [email protected].
|
||||||
* Copyright 2009-2010, Stephan Aßmus <[email protected]>
|
* Copyright 2009-2010, Stephan Aßmus <[email protected]>
|
||||||
* Copyright 2009, Bryce Groff, [email protected].
|
* Copyright 2009, Bryce Groff, [email protected].
|
||||||
* Distributed under the terms of the MIT License.
|
* Distributed under the terms of the MIT License.
|
||||||
@@ -16,10 +17,11 @@
|
|||||||
#include <GridLayoutBuilder.h>
|
#include <GridLayoutBuilder.h>
|
||||||
#include <MenuField.h>
|
#include <MenuField.h>
|
||||||
#include <MenuItem.h>
|
#include <MenuItem.h>
|
||||||
#include <PartitionParameterEditor.h>
|
#include <Partition.h>
|
||||||
#include <PopUpMenu.h>
|
#include <PopUpMenu.h>
|
||||||
#include <SpaceLayoutItem.h>
|
#include <SpaceLayoutItem.h>
|
||||||
#include <TextControl.h>
|
#include <TextControl.h>
|
||||||
|
#include <Variant.h>
|
||||||
#include <View.h>
|
#include <View.h>
|
||||||
#include <Window.h>
|
#include <Window.h>
|
||||||
|
|
||||||
@@ -36,10 +38,9 @@ InitializeBFSEditor::InitializeBFSEditor()
|
|||||||
:
|
:
|
||||||
BPartitionParameterEditor(),
|
BPartitionParameterEditor(),
|
||||||
fView(NULL),
|
fView(NULL),
|
||||||
fNameTC(NULL),
|
fNameControl(NULL),
|
||||||
fBlockSizeMF(NULL),
|
fBlockSizeMenuField(NULL),
|
||||||
fUseIndicesCB(NULL),
|
fUseIndicesCheckBox(NULL)
|
||||||
fParameters(NULL)
|
|
||||||
{
|
{
|
||||||
_CreateViewControls();
|
_CreateViewControls();
|
||||||
}
|
}
|
||||||
@@ -50,6 +51,15 @@ InitializeBFSEditor::~InitializeBFSEditor()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
InitializeBFSEditor::SetTo(BPartition* partition)
|
||||||
|
{
|
||||||
|
BString name = partition->ContentName();
|
||||||
|
if (!name.IsEmpty())
|
||||||
|
fNameControl->SetText(name.String());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
BView*
|
BView*
|
||||||
InitializeBFSEditor::View()
|
InitializeBFSEditor::View()
|
||||||
{
|
{
|
||||||
@@ -58,41 +68,39 @@ InitializeBFSEditor::View()
|
|||||||
|
|
||||||
|
|
||||||
bool
|
bool
|
||||||
InitializeBFSEditor::FinishedEditing()
|
InitializeBFSEditor::ValidateParameters() const
|
||||||
{
|
{
|
||||||
fParameters = "";
|
// The name must be set
|
||||||
if (BMenuItem* item = fBlockSizeMF->Menu()->FindMarked()) {
|
return fNameControl->TextView()->TextLength() > 0;
|
||||||
const char* size;
|
|
||||||
BMessage* message = item->Message();
|
|
||||||
if (!message || message->FindString("size", &size) < B_OK)
|
|
||||||
size = "2048";
|
|
||||||
// TODO: use libroot driver settings API
|
|
||||||
fParameters << "block_size " << size << ";\n";
|
|
||||||
}
|
|
||||||
if (fUseIndicesCB->Value() == B_CONTROL_OFF)
|
|
||||||
fParameters << "noindex;\n";
|
|
||||||
|
|
||||||
fParameters << "name \"" << fNameTC->Text() << "\";\n";
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
InitializeBFSEditor::GetParameters(BString* parameters)
|
InitializeBFSEditor::ParameterChanged(const char* name, const BVariant& variant)
|
||||||
{
|
{
|
||||||
if (parameters == NULL)
|
if (!strcmp(name, "name"))
|
||||||
return B_BAD_VALUE;
|
fNameControl->SetText(variant.ToString());
|
||||||
|
|
||||||
*parameters = fParameters;
|
|
||||||
return B_OK;
|
return B_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
InitializeBFSEditor::PartitionNameChanged(const char* name)
|
InitializeBFSEditor::GetParameters(BString& parameters)
|
||||||
{
|
{
|
||||||
fNameTC->SetText(name);
|
parameters = "";
|
||||||
|
|
||||||
|
if (BMenuItem* item = fBlockSizeMenuField->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";
|
||||||
|
}
|
||||||
|
if (fUseIndicesCheckBox->Value() == B_CONTROL_OFF)
|
||||||
|
parameters << "noindex;\n";
|
||||||
|
|
||||||
|
parameters << "name \"" << fNameControl->Text() << "\";\n";
|
||||||
return B_OK;
|
return B_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -100,10 +108,9 @@ InitializeBFSEditor::PartitionNameChanged(const char* name)
|
|||||||
void
|
void
|
||||||
InitializeBFSEditor::_CreateViewControls()
|
InitializeBFSEditor::_CreateViewControls()
|
||||||
{
|
{
|
||||||
fNameTC = new BTextControl(B_TRANSLATE("Name:"), "Haiku", NULL);
|
fNameControl = new BTextControl(B_TRANSLATE("Name:"), "Haiku", NULL);
|
||||||
fNameTC->SetModificationMessage(new BMessage(MSG_NAME_CHANGED));
|
fNameControl->SetModificationMessage(new BMessage(MSG_NAME_CHANGED));
|
||||||
// TODO find out what is the max length for this specific FS partition name
|
fNameControl->TextView()->SetMaxBytes(31);
|
||||||
fNameTC->TextView()->SetMaxBytes(31);
|
|
||||||
|
|
||||||
BPopUpMenu* blocksizeMenu = new BPopUpMenu("blocksize");
|
BPopUpMenu* blocksizeMenu = new BPopUpMenu("blocksize");
|
||||||
BMessage* message = new BMessage(MSG_BLOCK_SIZE);
|
BMessage* message = new BMessage(MSG_BLOCK_SIZE);
|
||||||
@@ -123,13 +130,15 @@ InitializeBFSEditor::_CreateViewControls()
|
|||||||
blocksizeMenu->AddItem(new BMenuItem(
|
blocksizeMenu->AddItem(new BMenuItem(
|
||||||
B_TRANSLATE("8192 (Mostly large files)"), message));
|
B_TRANSLATE("8192 (Mostly large files)"), message));
|
||||||
|
|
||||||
fBlockSizeMF = new BMenuField(B_TRANSLATE("Blocksize:"), blocksizeMenu);
|
fBlockSizeMenuField = new BMenuField(B_TRANSLATE("Blocksize:"),
|
||||||
|
blocksizeMenu);
|
||||||
defaultItem->SetMarked(true);
|
defaultItem->SetMarked(true);
|
||||||
|
|
||||||
fUseIndicesCB = new BCheckBox(B_TRANSLATE("Enable query support"), NULL);
|
fUseIndicesCheckBox = new BCheckBox(B_TRANSLATE("Enable query support"),
|
||||||
fUseIndicesCB->SetValue(true);
|
NULL);
|
||||||
fUseIndicesCB->SetToolTip(B_TRANSLATE("Disabling query support may speed "
|
fUseIndicesCheckBox->SetValue(true);
|
||||||
"up certain file system operations, but should only be used "
|
fUseIndicesCheckBox->SetToolTip(B_TRANSLATE("Disabling query support may "
|
||||||
|
"speed up certain file system operations, but should only be used "
|
||||||
"if one is absolutely certain that one will not need queries.\n"
|
"if one is absolutely certain that one will not need queries.\n"
|
||||||
"Any volume that is intended for booting Haiku must have query "
|
"Any volume that is intended for booting Haiku must have query "
|
||||||
"support enabled."));
|
"support enabled."));
|
||||||
@@ -138,14 +147,14 @@ InitializeBFSEditor::_CreateViewControls()
|
|||||||
|
|
||||||
fView = BGridLayoutBuilder(spacing, spacing)
|
fView = BGridLayoutBuilder(spacing, spacing)
|
||||||
// row 1
|
// row 1
|
||||||
.Add(fNameTC->CreateLabelLayoutItem(), 0, 0)
|
.Add(fNameControl->CreateLabelLayoutItem(), 0, 0)
|
||||||
.Add(fNameTC->CreateTextViewLayoutItem(), 1, 0)
|
.Add(fNameControl->CreateTextViewLayoutItem(), 1, 0)
|
||||||
|
|
||||||
// row 2
|
// row 2
|
||||||
.Add(fBlockSizeMF->CreateLabelLayoutItem(), 0, 1)
|
.Add(fBlockSizeMenuField->CreateLabelLayoutItem(), 0, 1)
|
||||||
.Add(fBlockSizeMF->CreateMenuBarLayoutItem(), 1, 1)
|
.Add(fBlockSizeMenuField->CreateMenuBarLayoutItem(), 1, 1)
|
||||||
|
|
||||||
// row 3
|
// row 3
|
||||||
.Add(fUseIndicesCB, 0, 2, 2).View()
|
.Add(fUseIndicesCheckBox, 0, 2, 2).View()
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
|
* Copyright 2013, Axel Dörfler, [email protected].
|
||||||
* Copyright 2009-2010, Stephan Aßmus <[email protected]>
|
* Copyright 2009-2010, Stephan Aßmus <[email protected]>
|
||||||
* Copyright 2009, Bryce Groff, [email protected].
|
* Copyright 2009, Bryce Groff, [email protected].
|
||||||
* Distributed under the terms of the MIT License.
|
* Distributed under the terms of the MIT License.
|
||||||
@@ -10,6 +11,7 @@
|
|||||||
#include <PartitionParameterEditor.h>
|
#include <PartitionParameterEditor.h>
|
||||||
#include <String.h>
|
#include <String.h>
|
||||||
|
|
||||||
|
|
||||||
class BCheckBox;
|
class BCheckBox;
|
||||||
class BMenuField;
|
class BMenuField;
|
||||||
class BTextControl;
|
class BTextControl;
|
||||||
@@ -21,21 +23,24 @@ public:
|
|||||||
InitializeBFSEditor();
|
InitializeBFSEditor();
|
||||||
virtual ~InitializeBFSEditor();
|
virtual ~InitializeBFSEditor();
|
||||||
|
|
||||||
virtual bool FinishedEditing();
|
virtual void SetTo(BPartition* partition);
|
||||||
virtual BView* View();
|
|
||||||
virtual status_t GetParameters(BString* parameters);
|
|
||||||
|
|
||||||
virtual status_t PartitionNameChanged(const char* name);
|
virtual bool ValidateParameters() const;
|
||||||
|
virtual status_t ParameterChanged(const char* name,
|
||||||
|
const BVariant& variant);
|
||||||
|
|
||||||
|
virtual BView* View();
|
||||||
|
|
||||||
|
virtual status_t GetParameters(BString& parameters);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void _CreateViewControls();
|
void _CreateViewControls();
|
||||||
|
|
||||||
|
private:
|
||||||
BView* fView;
|
BView* fView;
|
||||||
BTextControl* fNameTC;
|
BTextControl* fNameControl;
|
||||||
BMenuField* fBlockSizeMF;
|
BMenuField* fBlockSizeMenuField;
|
||||||
BCheckBox* fUseIndicesCB;
|
BCheckBox* fUseIndicesCheckBox;
|
||||||
|
|
||||||
BString fParameters;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
|
* Copyright 2013, Axel Dörfler, [email protected].
|
||||||
* Copyright 2009, Bryce Groff, [email protected].
|
* Copyright 2009, Bryce Groff, [email protected].
|
||||||
* Distributed under the terms of the MIT License.
|
* Distributed under the terms of the MIT License.
|
||||||
*/
|
*/
|
||||||
@@ -10,15 +11,15 @@
|
|||||||
#include <DiskDeviceTypes.h>
|
#include <DiskDeviceTypes.h>
|
||||||
#include <GroupView.h>
|
#include <GroupView.h>
|
||||||
#include <PartitionParameterEditor.h>
|
#include <PartitionParameterEditor.h>
|
||||||
|
#include <Variant.h>
|
||||||
#include <View.h>
|
#include <View.h>
|
||||||
|
|
||||||
|
|
||||||
#undef B_TRANSLATION_CONTEXT
|
#undef B_TRANSLATION_CONTEXT
|
||||||
#define B_TRANSLATION_CONTEXT "BFS_Creation_Parameter"
|
#define B_TRANSLATION_CONTEXT "PrimaryPartitionEditor"
|
||||||
|
|
||||||
|
|
||||||
PrimaryPartitionEditor::PrimaryPartitionEditor()
|
PrimaryPartitionEditor::PrimaryPartitionEditor()
|
||||||
:
|
|
||||||
fParameters(NULL)
|
|
||||||
{
|
{
|
||||||
fActiveCheckBox = new BCheckBox("active", B_TRANSLATE("Active partition"),
|
fActiveCheckBox = new BCheckBox("active", B_TRANSLATE("Active partition"),
|
||||||
NULL);
|
NULL);
|
||||||
@@ -39,35 +40,28 @@ PrimaryPartitionEditor::View()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool
|
status_t
|
||||||
PrimaryPartitionEditor::FinishedEditing()
|
PrimaryPartitionEditor::ParameterChanged(const char* name,
|
||||||
|
const BVariant& variant)
|
||||||
|
{
|
||||||
|
if (!strcmp(name, "type")) {
|
||||||
|
fActiveCheckBox->SetEnabled(strcmp(variant.ToString(),
|
||||||
|
kPartitionTypeIntelExtended) != 0);
|
||||||
|
}
|
||||||
|
return B_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
status_t
|
||||||
|
PrimaryPartitionEditor::GetParameters(BString& parameters)
|
||||||
{
|
{
|
||||||
if (fActiveCheckBox->IsEnabled()) {
|
if (fActiveCheckBox->IsEnabled()) {
|
||||||
if (fActiveCheckBox->Value() == B_CONTROL_ON)
|
if (fActiveCheckBox->Value() == B_CONTROL_ON)
|
||||||
fParameters.SetTo("active true ;");
|
parameters.SetTo("active true ;");
|
||||||
else
|
else
|
||||||
fParameters.SetTo("active false ;");
|
parameters.SetTo("active false ;");
|
||||||
} else
|
} else
|
||||||
fParameters.SetTo("");
|
parameters.SetTo("");
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
status_t
|
|
||||||
PrimaryPartitionEditor::GetParameters(BString* parameters)
|
|
||||||
{
|
|
||||||
if (fParameters == NULL)
|
|
||||||
return B_BAD_VALUE;
|
|
||||||
|
|
||||||
*parameters = fParameters;
|
|
||||||
return B_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
status_t
|
|
||||||
PrimaryPartitionEditor::PartitionTypeChanged(const char* type)
|
|
||||||
{
|
|
||||||
fActiveCheckBox->SetEnabled(strcmp(type, kPartitionTypeIntelExtended) != 0);
|
|
||||||
return B_OK;
|
return B_OK;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
|
* Copyright 2013, Axel Dörfler, [email protected].
|
||||||
* Copyright 2009, Bryce Groff, [email protected].
|
* Copyright 2009, Bryce Groff, [email protected].
|
||||||
* Distributed under the terms of the MIT License.
|
* Distributed under the terms of the MIT License.
|
||||||
*/
|
*/
|
||||||
@@ -18,17 +19,17 @@ public:
|
|||||||
PrimaryPartitionEditor();
|
PrimaryPartitionEditor();
|
||||||
virtual ~PrimaryPartitionEditor();
|
virtual ~PrimaryPartitionEditor();
|
||||||
|
|
||||||
virtual bool FinishedEditing();
|
|
||||||
virtual BView* View();
|
virtual BView* View();
|
||||||
virtual status_t GetParameters(BString* parameters);
|
|
||||||
|
|
||||||
virtual status_t PartitionTypeChanged(const char* type);
|
virtual status_t ParameterChanged(const char* name,
|
||||||
|
const BVariant& variant);
|
||||||
|
|
||||||
|
virtual status_t GetParameters(BString& parameters);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
BView* fView;
|
BView* fView;
|
||||||
BCheckBox* fActiveCheckBox;
|
BCheckBox* fActiveCheckBox;
|
||||||
BString fParameters;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
#endif //_CREATION_PARAMETER_EDITOR
|
#endif // _CREATION_PARAMETER_EDITOR
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ Addon <disk_system>intel :
|
|||||||
# kernel sources
|
# kernel sources
|
||||||
PartitionMap.cpp
|
PartitionMap.cpp
|
||||||
|
|
||||||
: be $(HAIKU_LOCALE_LIBS) $(TARGET_LIBSUPC++)
|
: be libshared.a $(HAIKU_LOCALE_LIBS) $(TARGET_LIBSUPC++)
|
||||||
;
|
;
|
||||||
|
|
||||||
DoCatalogs <disk_system>intel :
|
DoCatalogs <disk_system>intel :
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
|
* Copyright 2013, Axel Dörfler, [email protected].
|
||||||
* Copyright 2009-2010, Stephan Aßmus <[email protected]>
|
* Copyright 2009-2010, Stephan Aßmus <[email protected]>
|
||||||
* Copyright 2009, Bryce Groff, [email protected].
|
* Copyright 2009, Bryce Groff, [email protected].
|
||||||
* Distributed under the terms of the MIT License.
|
* Distributed under the terms of the MIT License.
|
||||||
@@ -11,19 +12,20 @@
|
|||||||
|
|
||||||
#include <Button.h>
|
#include <Button.h>
|
||||||
#include <Catalog.h>
|
#include <Catalog.h>
|
||||||
#include <CheckBox.h>
|
|
||||||
#include <ControlLook.h>
|
#include <ControlLook.h>
|
||||||
#include <GridLayoutBuilder.h>
|
#include <GridLayoutBuilder.h>
|
||||||
#include <MenuField.h>
|
#include <Partition.h>
|
||||||
#include <MenuItem.h>
|
|
||||||
#include <PartitionParameterEditor.h>
|
|
||||||
#include <PopUpMenu.h>
|
|
||||||
#include <SpaceLayoutItem.h>
|
#include <SpaceLayoutItem.h>
|
||||||
#include <TextControl.h>
|
#include <TextControl.h>
|
||||||
|
#include <Variant.h>
|
||||||
#include <View.h>
|
#include <View.h>
|
||||||
#include <Window.h>
|
#include <Window.h>
|
||||||
|
|
||||||
|
|
||||||
|
#undef B_TRANSLATION_CONTEXT
|
||||||
|
#define B_TRANSLATION_CONTEXT "NTFS_Initialize_Parameter"
|
||||||
|
|
||||||
|
|
||||||
static uint32 MSG_NAME_CHANGED = 'nmch';
|
static uint32 MSG_NAME_CHANGED = 'nmch';
|
||||||
|
|
||||||
|
|
||||||
@@ -31,7 +33,7 @@ InitializeNTFSEditor::InitializeNTFSEditor()
|
|||||||
:
|
:
|
||||||
BPartitionParameterEditor(),
|
BPartitionParameterEditor(),
|
||||||
fView(NULL),
|
fView(NULL),
|
||||||
fNameTC(NULL),
|
fNameControl(NULL),
|
||||||
fParameters(NULL)
|
fParameters(NULL)
|
||||||
{
|
{
|
||||||
_CreateViewControls();
|
_CreateViewControls();
|
||||||
@@ -43,6 +45,15 @@ InitializeNTFSEditor::~InitializeNTFSEditor()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
InitializeNTFSEditor::SetTo(BPartition* partition)
|
||||||
|
{
|
||||||
|
BString name = partition->ContentName();
|
||||||
|
if (!name.IsEmpty())
|
||||||
|
fNameControl->SetText(name.String());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
BView*
|
BView*
|
||||||
InitializeNTFSEditor::View()
|
InitializeNTFSEditor::View()
|
||||||
{
|
{
|
||||||
@@ -51,30 +62,28 @@ InitializeNTFSEditor::View()
|
|||||||
|
|
||||||
|
|
||||||
bool
|
bool
|
||||||
InitializeNTFSEditor::FinishedEditing()
|
InitializeNTFSEditor::ValidateParameters() const
|
||||||
{
|
{
|
||||||
fParameters = "";
|
// The name must be set
|
||||||
fParameters << "name \"" << fNameTC->Text() << "\";\n";
|
return fNameControl->TextView()->TextLength() > 0;
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
InitializeNTFSEditor::GetParameters(BString* parameters)
|
InitializeNTFSEditor::ParameterChanged(const char* name,
|
||||||
|
const BVariant& variant)
|
||||||
{
|
{
|
||||||
if (parameters == NULL)
|
if (!strcmp(name, "name"))
|
||||||
return B_BAD_VALUE;
|
fNameControl->SetText(variant.ToString());
|
||||||
|
|
||||||
*parameters = fParameters;
|
|
||||||
return B_OK;
|
return B_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
InitializeNTFSEditor::PartitionNameChanged(const char* name)
|
InitializeNTFSEditor::GetParameters(BString& parameters)
|
||||||
{
|
{
|
||||||
fNameTC->SetText(name);
|
parameters = "name \"";
|
||||||
|
parameters << fNameControl->Text() << "\";\n";
|
||||||
return B_OK;
|
return B_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -82,16 +91,15 @@ InitializeNTFSEditor::PartitionNameChanged(const char* name)
|
|||||||
void
|
void
|
||||||
InitializeNTFSEditor::_CreateViewControls()
|
InitializeNTFSEditor::_CreateViewControls()
|
||||||
{
|
{
|
||||||
fNameTC = new BTextControl("Name:", "New NTFS Volume", NULL);
|
fNameControl = new BTextControl(B_TRANSLATE("Name:"), "New NTFS Volume",
|
||||||
fNameTC->SetModificationMessage(new BMessage(MSG_NAME_CHANGED));
|
NULL);
|
||||||
// TODO find out what is the max length for this specific FS partition name
|
fNameControl->SetModificationMessage(new BMessage(MSG_NAME_CHANGED));
|
||||||
fNameTC->TextView()->SetMaxBytes(31);
|
fNameControl->TextView()->SetMaxBytes(127);
|
||||||
|
|
||||||
float spacing = be_control_look->DefaultItemSpacing();
|
float spacing = be_control_look->DefaultItemSpacing();
|
||||||
|
|
||||||
fView = BGridLayoutBuilder(spacing, spacing)
|
fView = BGridLayoutBuilder(spacing, spacing)
|
||||||
// row 1
|
.Add(fNameControl->CreateLabelLayoutItem(), 0, 0)
|
||||||
.Add(fNameTC->CreateLabelLayoutItem(), 0, 0)
|
.Add(fNameControl->CreateTextViewLayoutItem(), 1, 0).View()
|
||||||
.Add(fNameTC->CreateTextViewLayoutItem(), 1, 0).View()
|
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
|
* Copyright 2013, Axel Dörfler, [email protected].
|
||||||
* Copyright 2009-2010, Stephan Aßmus <[email protected]>
|
* Copyright 2009-2010, Stephan Aßmus <[email protected]>
|
||||||
* Copyright 2009, Bryce Groff, [email protected].
|
* Copyright 2009, Bryce Groff, [email protected].
|
||||||
* Distributed under the terms of the MIT License.
|
* Distributed under the terms of the MIT License.
|
||||||
@@ -10,6 +11,7 @@
|
|||||||
#include <PartitionParameterEditor.h>
|
#include <PartitionParameterEditor.h>
|
||||||
#include <String.h>
|
#include <String.h>
|
||||||
|
|
||||||
|
|
||||||
class BCheckBox;
|
class BCheckBox;
|
||||||
class BMenuField;
|
class BMenuField;
|
||||||
class BTextControl;
|
class BTextControl;
|
||||||
@@ -21,17 +23,22 @@ public:
|
|||||||
InitializeNTFSEditor();
|
InitializeNTFSEditor();
|
||||||
virtual ~InitializeNTFSEditor();
|
virtual ~InitializeNTFSEditor();
|
||||||
|
|
||||||
virtual bool FinishedEditing();
|
virtual void SetTo(BPartition* partition);
|
||||||
virtual BView* View();
|
|
||||||
virtual status_t GetParameters(BString* parameters);
|
|
||||||
|
|
||||||
virtual status_t PartitionNameChanged(const char* name);
|
virtual bool ValidateParameters() const;
|
||||||
|
virtual status_t ParameterChanged(const char* name,
|
||||||
|
const BVariant& variant);
|
||||||
|
|
||||||
|
virtual BView* View();
|
||||||
|
|
||||||
|
virtual status_t GetParameters(BString& parameters);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void _CreateViewControls();
|
void _CreateViewControls();
|
||||||
|
|
||||||
|
private:
|
||||||
BView* fView;
|
BView* fView;
|
||||||
BTextControl* fNameTC;
|
BTextControl* fNameControl;
|
||||||
|
|
||||||
BString fParameters;
|
BString fParameters;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -13,3 +13,9 @@ Addon <disk_system>ntfs :
|
|||||||
|
|
||||||
: be $(HAIKU_LOCALE_LIBS) $(TARGET_LIBSUPC++) libshared.a
|
: be $(HAIKU_LOCALE_LIBS) $(TARGET_LIBSUPC++) libshared.a
|
||||||
;
|
;
|
||||||
|
|
||||||
|
DoCatalogs <disk_system>ntfs :
|
||||||
|
x-vnd.Haiku-NTFSDiskAddOn
|
||||||
|
:
|
||||||
|
InitializeParameterEditor.cpp
|
||||||
|
;
|
||||||
|
|||||||
@@ -1,15 +1,11 @@
|
|||||||
/*
|
resource app_signature "application/x-vnd.Haiku-NTFSDiskAddOn";
|
||||||
* NTFSAddOn.rdef
|
|
||||||
*/
|
|
||||||
|
|
||||||
resource app_signature "application/x-vnd.Haiku-NTFSAddOn";
|
|
||||||
|
|
||||||
resource app_version {
|
resource app_version {
|
||||||
major = 0,
|
major = 1,
|
||||||
middle = 0,
|
middle = 0,
|
||||||
minor = 1,
|
minor = 0,
|
||||||
variety = 0,
|
variety = 0,
|
||||||
internal = 0,
|
internal = 0,
|
||||||
short_info = "0.0.1",
|
short_info = "1.0.0",
|
||||||
long_info = "Haiku NTFS disk add-on."
|
long_info = "NTFS disk add-on."
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -0,0 +1,248 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2008-2013 Haiku, Inc. All rights reserved.
|
||||||
|
* Distributed under the terms of the MIT license.
|
||||||
|
*
|
||||||
|
* Authors:
|
||||||
|
* Stephan Aßmus <superstippi@gmx.de>
|
||||||
|
* Axel Dörfler, axeld@pinc-software.de.
|
||||||
|
* Karsten Heimrich. <host.haiku@gmx.de>
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
#include "AbstractParametersPanel.h"
|
||||||
|
|
||||||
|
#include <driver_settings.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
#include <Button.h>
|
||||||
|
#include <Catalog.h>
|
||||||
|
#include <DiskSystemAddOn.h>
|
||||||
|
#include <DiskSystemAddOnManager.h>
|
||||||
|
#include <GroupLayout.h>
|
||||||
|
#include <MessageFilter.h>
|
||||||
|
#include <String.h>
|
||||||
|
|
||||||
|
|
||||||
|
#undef B_TRANSLATION_CONTEXT
|
||||||
|
#define B_TRANSLATION_CONTEXT "AbstractParametersPanel"
|
||||||
|
|
||||||
|
|
||||||
|
static const uint32 kMsgOk = 'okok';
|
||||||
|
static const uint32 kParameterChanged = 'pmch';
|
||||||
|
|
||||||
|
|
||||||
|
class AbstractParametersPanel::EscapeFilter : public BMessageFilter {
|
||||||
|
public:
|
||||||
|
EscapeFilter(AbstractParametersPanel* target)
|
||||||
|
:
|
||||||
|
BMessageFilter(B_ANY_DELIVERY, B_ANY_SOURCE),
|
||||||
|
fPanel(target)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual ~EscapeFilter()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual filter_result Filter(BMessage* message, BHandler** target)
|
||||||
|
{
|
||||||
|
filter_result result = B_DISPATCH_MESSAGE;
|
||||||
|
switch (message->what) {
|
||||||
|
case B_KEY_DOWN:
|
||||||
|
case B_UNMAPPED_KEY_DOWN: {
|
||||||
|
uint32 key;
|
||||||
|
if (message->FindInt32("raw_char", (int32*)&key) >= B_OK) {
|
||||||
|
if (key == B_ESCAPE) {
|
||||||
|
result = B_SKIP_MESSAGE;
|
||||||
|
fPanel->Cancel();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
AbstractParametersPanel* fPanel;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// #pragma mark -
|
||||||
|
|
||||||
|
|
||||||
|
AbstractParametersPanel::AbstractParametersPanel(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),
|
||||||
|
fOkButton(new BButton(B_TRANSLATE("OK"), new BMessage(kMsgOk))),
|
||||||
|
fReturnStatus(B_CANCELED),
|
||||||
|
fEditor(NULL),
|
||||||
|
fEscapeFilter(new EscapeFilter(this)),
|
||||||
|
fExitSemaphore(create_sem(0, "AbstractParametersPanel exit")),
|
||||||
|
fWindow(window)
|
||||||
|
{
|
||||||
|
AddCommonFilter(fEscapeFilter);
|
||||||
|
AddToSubset(fWindow);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
AbstractParametersPanel::~AbstractParametersPanel()
|
||||||
|
{
|
||||||
|
RemoveCommonFilter(fEscapeFilter);
|
||||||
|
delete fEscapeFilter;
|
||||||
|
|
||||||
|
delete_sem(fExitSemaphore);
|
||||||
|
|
||||||
|
if (fEditor == NULL)
|
||||||
|
delete fOkButton;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool
|
||||||
|
AbstractParametersPanel::QuitRequested()
|
||||||
|
{
|
||||||
|
release_sem(fExitSemaphore);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
AbstractParametersPanel::MessageReceived(BMessage* message)
|
||||||
|
{
|
||||||
|
switch (message->what) {
|
||||||
|
case B_CANCEL:
|
||||||
|
Cancel();
|
||||||
|
break;
|
||||||
|
|
||||||
|
case kMsgOk:
|
||||||
|
fReturnStatus = B_OK;
|
||||||
|
release_sem(fExitSemaphore);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case kParameterChanged:
|
||||||
|
fOkButton->SetEnabled(fEditor->ValidateParameters());
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
BWindow::MessageReceived(message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
status_t
|
||||||
|
AbstractParametersPanel::Go(BString& parameters)
|
||||||
|
{
|
||||||
|
// Without an editor, we cannot change anything, anyway
|
||||||
|
if (fEditor == NULL) {
|
||||||
|
parameters = "";
|
||||||
|
if (fReturnStatus == B_CANCELED)
|
||||||
|
fReturnStatus = B_OK;
|
||||||
|
|
||||||
|
if (!Lock())
|
||||||
|
return B_ERROR;
|
||||||
|
} else {
|
||||||
|
// run the window thread, to get an initial layout of the controls
|
||||||
|
Hide();
|
||||||
|
Show();
|
||||||
|
if (!Lock())
|
||||||
|
return B_CANCELED;
|
||||||
|
|
||||||
|
// center the panel above the parent window
|
||||||
|
CenterIn(fWindow->Frame());
|
||||||
|
|
||||||
|
Show();
|
||||||
|
Unlock();
|
||||||
|
|
||||||
|
// block this thread now, but keep the window repainting
|
||||||
|
while (true) {
|
||||||
|
status_t status = acquire_sem_etc(fExitSemaphore, 1,
|
||||||
|
B_CAN_INTERRUPT | B_RELATIVE_TIMEOUT, 50000);
|
||||||
|
if (status != B_TIMED_OUT && status != B_INTERRUPTED)
|
||||||
|
break;
|
||||||
|
fWindow->UpdateIfNeeded();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!Lock())
|
||||||
|
return B_CANCELED;
|
||||||
|
|
||||||
|
if (fReturnStatus == B_OK) {
|
||||||
|
if (fEditor->ValidateParameters()) {
|
||||||
|
status_t err = fEditor->GetParameters(parameters);
|
||||||
|
if (err != B_OK)
|
||||||
|
fReturnStatus = err;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
status_t status = fReturnStatus;
|
||||||
|
|
||||||
|
Quit();
|
||||||
|
// NOTE: this object is toast now!
|
||||||
|
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
AbstractParametersPanel::Cancel()
|
||||||
|
{
|
||||||
|
fReturnStatus = B_CANCELED;
|
||||||
|
release_sem(fExitSemaphore);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
AbstractParametersPanel::Init(B_PARAMETER_EDITOR_TYPE type,
|
||||||
|
const BString& diskSystem, BPartition* partition)
|
||||||
|
{
|
||||||
|
// Create partition parameter editor
|
||||||
|
|
||||||
|
status_t status = B_ERROR;
|
||||||
|
if (diskSystem.IsEmpty()) {
|
||||||
|
status = partition->GetParameterEditor(type, &fEditor);
|
||||||
|
} else {
|
||||||
|
DiskSystemAddOnManager* manager = DiskSystemAddOnManager::Default();
|
||||||
|
BDiskSystemAddOn* addOn = manager->GetAddOn(diskSystem);
|
||||||
|
if (addOn != NULL) {
|
||||||
|
// put the add-on
|
||||||
|
manager->PutAddOn(addOn);
|
||||||
|
|
||||||
|
status = addOn->GetParameterEditor(type, &fEditor);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (status != B_OK && status != B_NOT_SUPPORTED)
|
||||||
|
fReturnStatus = status;
|
||||||
|
|
||||||
|
if (fEditor == NULL)
|
||||||
|
return;
|
||||||
|
|
||||||
|
// Create controls
|
||||||
|
|
||||||
|
BLayoutBuilder::Group<> builder = BLayoutBuilder::Group<>(this,
|
||||||
|
B_VERTICAL);
|
||||||
|
AddControls(builder, fEditor->View());
|
||||||
|
|
||||||
|
builder.AddGroup(B_HORIZONTAL, B_USE_DEFAULT_SPACING)
|
||||||
|
.AddGlue()
|
||||||
|
.Add(new BButton(B_TRANSLATE("Cancel"), new BMessage(B_CANCEL)))
|
||||||
|
.Add(fOkButton)
|
||||||
|
.End()
|
||||||
|
.SetInsets(B_USE_DEFAULT_SPACING);
|
||||||
|
|
||||||
|
SetDefaultButton(fOkButton);
|
||||||
|
|
||||||
|
fEditor->SetTo(partition);
|
||||||
|
fEditor->SetModificationMessage(new BMessage(kParameterChanged));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
AbstractParametersPanel::AddControls(BLayoutBuilder::Group<>& builder,
|
||||||
|
BView* editorView)
|
||||||
|
{
|
||||||
|
builder.Add(editorView);
|
||||||
|
}
|
||||||
@@ -0,0 +1,58 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2008-2013 Haiku, Inc. All rights reserved.
|
||||||
|
* Distributed under the terms of the MIT license.
|
||||||
|
*
|
||||||
|
* Authors:
|
||||||
|
* Stephan Aßmus <superstippi@gmx.de>
|
||||||
|
* Axel Dörfler, axeld@pinc-software.de.
|
||||||
|
*/
|
||||||
|
#ifndef ABSTRACT_PARAMETERS_PANEL_H
|
||||||
|
#define ABSTRACT_PARAMETERS_PANEL_H
|
||||||
|
|
||||||
|
|
||||||
|
#include <LayoutBuilder.h>
|
||||||
|
#include <Partition.h>
|
||||||
|
#include <PartitionParameterEditor.h>
|
||||||
|
#include <Window.h>
|
||||||
|
|
||||||
|
#include "Support.h"
|
||||||
|
|
||||||
|
|
||||||
|
class BMenuField;
|
||||||
|
class BTextControl;
|
||||||
|
|
||||||
|
|
||||||
|
class AbstractParametersPanel : public BWindow {
|
||||||
|
public:
|
||||||
|
AbstractParametersPanel(BWindow* window);
|
||||||
|
virtual ~AbstractParametersPanel();
|
||||||
|
|
||||||
|
virtual bool QuitRequested();
|
||||||
|
virtual void MessageReceived(BMessage* message);
|
||||||
|
|
||||||
|
status_t Go(BString& parameters);
|
||||||
|
void Cancel();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void Init(B_PARAMETER_EDITOR_TYPE type,
|
||||||
|
const BString& diskSystem,
|
||||||
|
BPartition* partition);
|
||||||
|
|
||||||
|
virtual void AddControls(BLayoutBuilder::Group<>& builder,
|
||||||
|
BView* editorView);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
BButton* fOkButton;
|
||||||
|
status_t fReturnStatus;
|
||||||
|
|
||||||
|
BPartitionParameterEditor* fEditor;
|
||||||
|
|
||||||
|
private:
|
||||||
|
class EscapeFilter;
|
||||||
|
EscapeFilter* fEscapeFilter;
|
||||||
|
sem_id fExitSemaphore;
|
||||||
|
BWindow* fWindow;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
#endif // ABSTRACT_PARAMETERS_PANEL_H
|
||||||
@@ -1,9 +1,10 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2008-2012 Haiku Inc. All rights reserved.
|
* Copyright 2008-2013 Haiku Inc. All rights reserved.
|
||||||
* Distributed under the terms of the MIT license.
|
* Distributed under the terms of the MIT license.
|
||||||
*
|
*
|
||||||
* Authors:
|
* Authors:
|
||||||
* Stephan Aßmus <superstippi@gmx.de>
|
* Stephan Aßmus <superstippi@gmx.de>
|
||||||
|
* Axel Dörfler, axeld@pinc-software.de.
|
||||||
* Bryce Groff <bgroff@hawaii.edu>
|
* Bryce Groff <bgroff@hawaii.edu>
|
||||||
* Karsten Heimrich <host.haiku@gmx.de>
|
* Karsten Heimrich <host.haiku@gmx.de>
|
||||||
*/
|
*/
|
||||||
@@ -15,89 +16,34 @@
|
|||||||
#include <Catalog.h>
|
#include <Catalog.h>
|
||||||
#include <ControlLook.h>
|
#include <ControlLook.h>
|
||||||
#include <DiskDeviceTypes.h>
|
#include <DiskDeviceTypes.h>
|
||||||
#include <GridLayoutBuilder.h>
|
|
||||||
#include <GroupLayout.h>
|
|
||||||
#include <GroupLayoutBuilder.h>
|
|
||||||
#include <Locale.h>
|
|
||||||
#include <MenuField.h>
|
#include <MenuField.h>
|
||||||
#include <MenuItem.h>
|
#include <MenuItem.h>
|
||||||
#include <Message.h>
|
|
||||||
#include <MessageFilter.h>
|
#include <MessageFilter.h>
|
||||||
#include <PopUpMenu.h>
|
#include <PopUpMenu.h>
|
||||||
#include <PartitionParameterEditor.h>
|
|
||||||
#include <Partition.h>
|
|
||||||
#include <String.h>
|
#include <String.h>
|
||||||
|
#include <TextControl.h>
|
||||||
|
#include <Variant.h>
|
||||||
|
|
||||||
#include "Support.h"
|
#include "Support.h"
|
||||||
|
|
||||||
|
|
||||||
#undef B_TRANSLATION_CONTEXT
|
#undef B_TRANSLATION_CONTEXT
|
||||||
#define B_TRANSLATION_CONTEXT "CreateParamsPanel"
|
#define B_TRANSLATION_CONTEXT "CreateParametersPanel"
|
||||||
|
|
||||||
|
|
||||||
class CreateParamsPanel::EscapeFilter : public BMessageFilter {
|
|
||||||
public:
|
|
||||||
EscapeFilter(CreateParamsPanel* target)
|
|
||||||
:
|
|
||||||
BMessageFilter(B_ANY_DELIVERY, B_ANY_SOURCE),
|
|
||||||
fPanel(target)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual ~EscapeFilter()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual filter_result Filter(BMessage* message, BHandler** target)
|
|
||||||
{
|
|
||||||
filter_result result = B_DISPATCH_MESSAGE;
|
|
||||||
switch (message->what) {
|
|
||||||
case B_KEY_DOWN:
|
|
||||||
case B_UNMAPPED_KEY_DOWN: {
|
|
||||||
uint32 key;
|
|
||||||
if (message->FindInt32("raw_char", (int32*)&key) >= B_OK) {
|
|
||||||
if (key == B_ESCAPE) {
|
|
||||||
result = B_SKIP_MESSAGE;
|
|
||||||
fPanel->Cancel();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
CreateParamsPanel* fPanel;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
// #pragma mark -
|
|
||||||
|
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
MSG_OK = 'okok',
|
|
||||||
MSG_CANCEL = 'cncl',
|
|
||||||
MSG_PARTITION_TYPE = 'type',
|
MSG_PARTITION_TYPE = 'type',
|
||||||
MSG_SIZE_SLIDER = 'ssld',
|
MSG_SIZE_SLIDER = 'ssld',
|
||||||
MSG_SIZE_TEXTCONTROL = 'stct'
|
MSG_SIZE_TEXTCONTROL = 'stct'
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
CreateParamsPanel::CreateParamsPanel(BWindow* window, BPartition* partition,
|
CreateParametersPanel::CreateParametersPanel(BWindow* window,
|
||||||
off_t offset, off_t size)
|
BPartition* partition, off_t offset, off_t size)
|
||||||
:
|
:
|
||||||
BWindow(BRect(300.0, 200.0, 600.0, 300.0), 0, B_MODAL_WINDOW_LOOK,
|
AbstractParametersPanel(window)
|
||||||
B_MODAL_SUBSET_WINDOW_FEEL,
|
|
||||||
B_ASYNCHRONOUS_CONTROLS | B_AUTO_UPDATE_SIZE_LIMITS),
|
|
||||||
fEscapeFilter(new EscapeFilter(this)),
|
|
||||||
fExitSemaphore(create_sem(0, "CreateParamsPanel exit")),
|
|
||||||
fWindow(window),
|
|
||||||
fReturnValue(GO_CANCELED)
|
|
||||||
{
|
{
|
||||||
AddCommonFilter(fEscapeFilter);
|
Init(B_CREATE_PARAMETER_EDITOR, "", partition);
|
||||||
|
|
||||||
// Scale offset, and size from bytes to megabytes (2^20)
|
// Scale offset, and size from bytes to megabytes (2^20)
|
||||||
// so that we do not run over a signed int32.
|
// so that we do not run over a signed int32.
|
||||||
@@ -107,138 +53,56 @@ CreateParamsPanel::CreateParamsPanel(BWindow* window, BPartition* partition,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
CreateParamsPanel::~CreateParamsPanel()
|
CreateParametersPanel::~CreateParametersPanel()
|
||||||
{
|
{
|
||||||
RemoveCommonFilter(fEscapeFilter);
|
|
||||||
delete fEscapeFilter;
|
|
||||||
|
|
||||||
delete_sem(fExitSemaphore);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool
|
status_t
|
||||||
CreateParamsPanel::QuitRequested()
|
CreateParametersPanel::Go(off_t& offset, off_t& size, BString& name,
|
||||||
{
|
|
||||||
release_sem(fExitSemaphore);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
CreateParamsPanel::MessageReceived(BMessage* message)
|
|
||||||
{
|
|
||||||
switch (message->what) {
|
|
||||||
case MSG_CANCEL:
|
|
||||||
Cancel();
|
|
||||||
break;
|
|
||||||
|
|
||||||
case MSG_OK:
|
|
||||||
fReturnValue = GO_SUCCESS;
|
|
||||||
release_sem(fExitSemaphore);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case MSG_PARTITION_TYPE:
|
|
||||||
if (fEditor != NULL) {
|
|
||||||
const char* type;
|
|
||||||
message->FindString("type", &type);
|
|
||||||
fEditor->PartitionTypeChanged(type);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case MSG_SIZE_SLIDER:
|
|
||||||
_UpdateSizeTextControl();
|
|
||||||
break;
|
|
||||||
|
|
||||||
case MSG_SIZE_TEXTCONTROL:
|
|
||||||
{
|
|
||||||
int32 size = atoi(fSizeTextControl->Text());
|
|
||||||
if (size >= 0 && size <= fSizeSlider->MaxPartitionSize())
|
|
||||||
fSizeSlider->SetValue(size + fSizeSlider->Offset());
|
|
||||||
else
|
|
||||||
_UpdateSizeTextControl();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
default:
|
|
||||||
BWindow::MessageReceived(message);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
int32
|
|
||||||
CreateParamsPanel::Go(off_t& offset, off_t& size, BString& name,
|
|
||||||
BString& type, BString& parameters)
|
BString& type, BString& parameters)
|
||||||
{
|
{
|
||||||
// run the window thread, to get an initial layout of the controls
|
// The object will be deleted in Go(), so we need to get the values before
|
||||||
Hide();
|
|
||||||
Show();
|
|
||||||
if (!Lock())
|
|
||||||
return GO_CANCELED;
|
|
||||||
|
|
||||||
// center the panel above the parent window
|
// Return the value back as bytes.
|
||||||
CenterIn(fWindow->Frame());
|
size = (off_t)fSizeSlider->Size() * kMegaByte;
|
||||||
|
offset = (off_t)fSizeSlider->Offset() * kMegaByte;
|
||||||
|
|
||||||
Show();
|
// get name
|
||||||
Unlock();
|
name.SetTo(fNameTextControl->Text());
|
||||||
|
|
||||||
// block this thread now, but keep the window repainting
|
// get type
|
||||||
while (true) {
|
if (BMenuItem* item = fTypeMenuField->Menu()->FindMarked()) {
|
||||||
status_t err = acquire_sem_etc(fExitSemaphore, 1,
|
const char* _type;
|
||||||
B_CAN_INTERRUPT | B_RELATIVE_TIMEOUT, 50000);
|
BMessage* message = item->Message();
|
||||||
if (err != B_TIMED_OUT && err != B_INTERRUPTED)
|
if (!message || message->FindString("type", &_type) < B_OK)
|
||||||
break;
|
_type = kPartitionTypeBFS;
|
||||||
fWindow->UpdateIfNeeded();
|
type << _type;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!Lock())
|
return AbstractParametersPanel::Go(parameters);
|
||||||
return GO_CANCELED;
|
|
||||||
|
|
||||||
if (fReturnValue == GO_SUCCESS) {
|
|
||||||
// Return the value back as bytes.
|
|
||||||
size = (off_t)fSizeSlider->Size() * kMegaByte;
|
|
||||||
offset = (off_t)fSizeSlider->Offset() * kMegaByte;
|
|
||||||
|
|
||||||
// get name
|
|
||||||
name.SetTo(fNameTextControl->Text());
|
|
||||||
|
|
||||||
// get type
|
|
||||||
if (BMenuItem* item = fTypeMenuField->Menu()->FindMarked()) {
|
|
||||||
const char* _type;
|
|
||||||
BMessage* message = item->Message();
|
|
||||||
if (!message || message->FindString("type", &_type) < B_OK)
|
|
||||||
_type = kPartitionTypeBFS;
|
|
||||||
type << _type;
|
|
||||||
}
|
|
||||||
|
|
||||||
// get editors parameters
|
|
||||||
if (fEditor != NULL) {
|
|
||||||
if (fEditor->FinishedEditing()) {
|
|
||||||
status_t status = fEditor->GetParameters(¶meters);
|
|
||||||
if (status != B_OK)
|
|
||||||
fReturnValue = status;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
int32 value = fReturnValue;
|
|
||||||
|
|
||||||
Quit();
|
|
||||||
// NOTE: this object is toast now!
|
|
||||||
|
|
||||||
return value;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
CreateParamsPanel::Cancel()
|
CreateParametersPanel::AddControls(BLayoutBuilder::Group<>& builder,
|
||||||
|
BView* editorView)
|
||||||
{
|
{
|
||||||
fReturnValue = GO_CANCELED;
|
builder
|
||||||
release_sem(fExitSemaphore);
|
.Add(fSizeSlider)
|
||||||
|
.Add(fSizeTextControl)
|
||||||
|
.AddGrid(0.0, 5.0)
|
||||||
|
.Add(fNameTextControl->CreateLabelLayoutItem(), 0, 0)
|
||||||
|
.Add(fNameTextControl->CreateTextViewLayoutItem(), 1, 0)
|
||||||
|
.Add(fTypeMenuField->CreateLabelLayoutItem(), 0, 1)
|
||||||
|
.Add(fTypeMenuField->CreateMenuBarLayoutItem(), 1, 1)
|
||||||
|
.End()
|
||||||
|
.Add(editorView);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
CreateParamsPanel::_CreateViewControls(BPartition* parent, off_t offset,
|
CreateParametersPanel::_CreateViewControls(BPartition* parent, off_t offset,
|
||||||
off_t size)
|
off_t size)
|
||||||
{
|
{
|
||||||
// Setup the controls
|
// Setup the controls
|
||||||
@@ -265,8 +129,7 @@ CreateParamsPanel::_CreateViewControls(BPartition* parent, off_t offset,
|
|||||||
|
|
||||||
int32 cookie = 0;
|
int32 cookie = 0;
|
||||||
BString supportedType;
|
BString supportedType;
|
||||||
while (parent->GetNextSupportedChildType(&cookie, &supportedType)
|
while (parent->GetNextSupportedChildType(&cookie, &supportedType) == B_OK) {
|
||||||
== B_OK) {
|
|
||||||
BMessage* message = new BMessage(MSG_PARTITION_TYPE);
|
BMessage* message = new BMessage(MSG_PARTITION_TYPE);
|
||||||
message->AddString("type", supportedType);
|
message->AddString("type", supportedType);
|
||||||
BMenuItem* item = new BMenuItem(supportedType, message);
|
BMenuItem* item = new BMenuItem(supportedType, message);
|
||||||
@@ -279,46 +142,44 @@ CreateParamsPanel::_CreateViewControls(BPartition* parent, off_t offset,
|
|||||||
fTypeMenuField = new BMenuField(B_TRANSLATE("Partition type:"),
|
fTypeMenuField = new BMenuField(B_TRANSLATE("Partition type:"),
|
||||||
fTypePopUpMenu);
|
fTypePopUpMenu);
|
||||||
|
|
||||||
const float spacing = be_control_look->DefaultItemSpacing();
|
fOkButton->SetLabel(B_TRANSLATE("Create"));
|
||||||
BGroupLayout* layout = new BGroupLayout(B_VERTICAL, spacing);
|
|
||||||
layout->SetInsets(spacing, spacing, spacing, spacing);
|
|
||||||
|
|
||||||
SetLayout(layout);
|
|
||||||
|
|
||||||
AddChild(BGroupLayoutBuilder(B_VERTICAL, spacing)
|
|
||||||
.Add(fSizeSlider)
|
|
||||||
.Add(fSizeTextControl)
|
|
||||||
.Add(BGridLayoutBuilder(0.0, 5.0)
|
|
||||||
.Add(fNameTextControl->CreateLabelLayoutItem(), 0, 0)
|
|
||||||
.Add(fNameTextControl->CreateTextViewLayoutItem(), 1, 0)
|
|
||||||
.Add(fTypeMenuField->CreateLabelLayoutItem(), 0, 1)
|
|
||||||
.Add(fTypeMenuField->CreateMenuBarLayoutItem(), 1, 1)
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
status_t err = parent->GetParameterEditor(B_CREATE_PARAMETER_EDITOR,
|
|
||||||
&fEditor);
|
|
||||||
if (err == B_OK && fEditor != NULL)
|
|
||||||
AddChild(fEditor->View());
|
|
||||||
else
|
|
||||||
fEditor = NULL;
|
|
||||||
|
|
||||||
BButton* okButton = new BButton(B_TRANSLATE("Create"),
|
|
||||||
new BMessage(MSG_OK));
|
|
||||||
AddChild(BGroupLayoutBuilder(B_HORIZONTAL, spacing)
|
|
||||||
.AddGlue()
|
|
||||||
.Add(new BButton(B_TRANSLATE("Cancel"), new BMessage(MSG_CANCEL)))
|
|
||||||
.Add(okButton)
|
|
||||||
);
|
|
||||||
SetDefaultButton(okButton);
|
|
||||||
|
|
||||||
AddToSubset(fWindow);
|
|
||||||
layout->View()->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
CreateParamsPanel::_UpdateSizeTextControl()
|
CreateParametersPanel::MessageReceived(BMessage* message)
|
||||||
|
{
|
||||||
|
switch (message->what) {
|
||||||
|
case MSG_PARTITION_TYPE:
|
||||||
|
if (fEditor != NULL) {
|
||||||
|
const char* type;
|
||||||
|
if (message->FindString("type", &type) == B_OK)
|
||||||
|
fEditor->ParameterChanged("type", BVariant(type));
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case MSG_SIZE_SLIDER:
|
||||||
|
_UpdateSizeTextControl();
|
||||||
|
break;
|
||||||
|
|
||||||
|
case MSG_SIZE_TEXTCONTROL:
|
||||||
|
{
|
||||||
|
int32 size = atoi(fSizeTextControl->Text());
|
||||||
|
if (size >= 0 && size <= fSizeSlider->MaxPartitionSize())
|
||||||
|
fSizeSlider->SetValue(size + fSizeSlider->Offset());
|
||||||
|
else
|
||||||
|
_UpdateSizeTextControl();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
default:
|
||||||
|
AbstractParametersPanel::MessageReceived(message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
CreateParametersPanel::_UpdateSizeTextControl()
|
||||||
{
|
{
|
||||||
BString sizeString;
|
BString sizeString;
|
||||||
sizeString << fSizeSlider->Value() - fSizeSlider->Offset();
|
sizeString << fSizeSlider->Value() - fSizeSlider->Offset();
|
||||||
|
|||||||
@@ -1,40 +1,40 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2008-2012 Haiku Inc. All rights reserved.
|
* Copyright 2008-2013 Haiku Inc. All rights reserved.
|
||||||
* Distributed under the terms of the MIT license.
|
* Distributed under the terms of the MIT license.
|
||||||
*
|
*
|
||||||
* Authors:
|
* Authors:
|
||||||
* Stephan Aßmus <superstippi@gmx.de>
|
* Stephan Aßmus <superstippi@gmx.de>
|
||||||
|
* Axel Dörfler, axeld@pinc-software.de.
|
||||||
* Bryce Groff <bgroff@hawaii.edu>
|
* Bryce Groff <bgroff@hawaii.edu>
|
||||||
*/
|
*/
|
||||||
#ifndef CREATE_PARAMS_PANEL_H
|
#ifndef CREATE_PARAMS_PANEL_H
|
||||||
#define CREATE_PARAMS_PANEL_H
|
#define CREATE_PARAMS_PANEL_H
|
||||||
|
|
||||||
|
|
||||||
#include <Window.h>
|
#include "AbstractParametersPanel.h"
|
||||||
#include <InterfaceKit.h>
|
|
||||||
#include <PartitionParameterEditor.h>
|
|
||||||
#include <Partition.h>
|
|
||||||
|
|
||||||
|
|
||||||
class BMenuField;
|
class BMenuField;
|
||||||
|
class BPopUpMenu;
|
||||||
class BTextControl;
|
class BTextControl;
|
||||||
class SizeSlider;
|
class SizeSlider;
|
||||||
|
|
||||||
|
|
||||||
class CreateParamsPanel : public BWindow {
|
class CreateParametersPanel : public AbstractParametersPanel {
|
||||||
public:
|
public:
|
||||||
CreateParamsPanel(BWindow* window,
|
CreateParametersPanel(BWindow* window,
|
||||||
BPartition* parent, off_t offset,
|
BPartition* parent, off_t offset,
|
||||||
off_t size);
|
off_t size);
|
||||||
virtual ~CreateParamsPanel();
|
virtual ~CreateParametersPanel();
|
||||||
|
|
||||||
|
status_t Go(off_t& offset, off_t& size, BString& name,
|
||||||
|
BString& type, BString& parameters);
|
||||||
|
|
||||||
virtual bool QuitRequested();
|
|
||||||
virtual void MessageReceived(BMessage* message);
|
virtual void MessageReceived(BMessage* message);
|
||||||
|
|
||||||
int32 Go(off_t& offset, off_t& size, BString& name,
|
protected:
|
||||||
BString& type, BString& parameters);
|
virtual void AddControls(BLayoutBuilder::Group<>& builder,
|
||||||
void Cancel();
|
BView* editorView);
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void _CreateViewControls(BPartition* parent,
|
void _CreateViewControls(BPartition* parent,
|
||||||
@@ -43,15 +43,6 @@ private:
|
|||||||
void _UpdateSizeTextControl();
|
void _UpdateSizeTextControl();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
class EscapeFilter;
|
|
||||||
|
|
||||||
EscapeFilter* fEscapeFilter;
|
|
||||||
sem_id fExitSemaphore;
|
|
||||||
BWindow* fWindow;
|
|
||||||
int32 fReturnValue;
|
|
||||||
|
|
||||||
BPartitionParameterEditor* fEditor;
|
|
||||||
|
|
||||||
BPopUpMenu* fTypePopUpMenu;
|
BPopUpMenu* fTypePopUpMenu;
|
||||||
BMenuField* fTypeMenuField;
|
BMenuField* fTypeMenuField;
|
||||||
BTextControl* fNameTextControl;
|
BTextControl* fNameTextControl;
|
||||||
|
|||||||
@@ -4,6 +4,7 @@
|
|||||||
*
|
*
|
||||||
* Authors:
|
* Authors:
|
||||||
* Stephan Aßmus <superstippi@gmx.de>
|
* Stephan Aßmus <superstippi@gmx.de>
|
||||||
|
* Axel Dörfler, axeld@pinc-software.de.
|
||||||
* Karsten Heimrich. <host.haiku@gmx.de>
|
* Karsten Heimrich. <host.haiku@gmx.de>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@@ -15,240 +16,41 @@
|
|||||||
|
|
||||||
#include <Button.h>
|
#include <Button.h>
|
||||||
#include <Catalog.h>
|
#include <Catalog.h>
|
||||||
#include <ControlLook.h>
|
|
||||||
#include <DiskSystemAddOn.h>
|
|
||||||
#include <DiskSystemAddOnManager.h>
|
|
||||||
#include <GroupLayout.h>
|
|
||||||
#include <GroupLayoutBuilder.h>
|
|
||||||
#include <Locale.h>
|
|
||||||
#include <Message.h>
|
|
||||||
#include <MessageFilter.h>
|
|
||||||
#include <String.h>
|
|
||||||
#include <TextControl.h>
|
|
||||||
|
|
||||||
|
|
||||||
#undef B_TRANSLATION_CONTEXT
|
#undef B_TRANSLATION_CONTEXT
|
||||||
#define B_TRANSLATION_CONTEXT "InitParamsPanel"
|
#define B_TRANSLATION_CONTEXT "InitializeParametersPanel"
|
||||||
|
|
||||||
|
|
||||||
class InitParamsPanel::EscapeFilter : public BMessageFilter {
|
InitParametersPanel::InitParametersPanel(BWindow* window,
|
||||||
public:
|
const BString& diskSystem, BPartition* partition)
|
||||||
EscapeFilter(InitParamsPanel* target)
|
|
||||||
:
|
|
||||||
BMessageFilter(B_ANY_DELIVERY, B_ANY_SOURCE),
|
|
||||||
fPanel(target)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual ~EscapeFilter()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual filter_result Filter(BMessage* message, BHandler** target)
|
|
||||||
{
|
|
||||||
filter_result result = B_DISPATCH_MESSAGE;
|
|
||||||
switch (message->what) {
|
|
||||||
case B_KEY_DOWN:
|
|
||||||
case B_UNMAPPED_KEY_DOWN: {
|
|
||||||
uint32 key;
|
|
||||||
if (message->FindInt32("raw_char", (int32*)&key) >= B_OK) {
|
|
||||||
if (key == B_ESCAPE) {
|
|
||||||
result = B_SKIP_MESSAGE;
|
|
||||||
fPanel->Cancel();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
InitParamsPanel* fPanel;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
// #pragma mark -
|
|
||||||
|
|
||||||
|
|
||||||
// TODO: MSG_NAME_CHANGED is shared with the disk system add-ons, so it should
|
|
||||||
// be in some private shared header.
|
|
||||||
// TODO: there is already B_CANCEL, why not use that one?
|
|
||||||
enum {
|
|
||||||
MSG_OK = 'okok',
|
|
||||||
MSG_CANCEL = 'cncl',
|
|
||||||
MSG_NAME_CHANGED = 'nmch'
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
InitParamsPanel::InitParamsPanel(BWindow* window, const BString& diskSystem,
|
|
||||||
BPartition* partition)
|
|
||||||
:
|
:
|
||||||
BWindow(BRect(300.0, 200.0, 600.0, 300.0), 0, B_MODAL_WINDOW_LOOK,
|
AbstractParametersPanel(window)
|
||||||
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)
|
|
||||||
{
|
{
|
||||||
AddCommonFilter(fEscapeFilter);
|
Init(B_INITIALIZE_PARAMETER_EDITOR, diskSystem, partition);
|
||||||
|
|
||||||
fOkButton = new BButton(B_TRANSLATE("Initialize"), new BMessage(MSG_OK));
|
fOkButton->SetLabel(B_TRANSLATE("Initialize"));
|
||||||
|
|
||||||
DiskSystemAddOnManager* manager = DiskSystemAddOnManager::Default();
|
|
||||||
BDiskSystemAddOn* addOn = manager->GetAddOn(diskSystem);
|
|
||||||
if (addOn) {
|
|
||||||
// put the add-on
|
|
||||||
manager->PutAddOn(addOn);
|
|
||||||
|
|
||||||
status_t err = addOn->GetParameterEditor(B_INITIALIZE_PARAMETER_EDITOR,
|
|
||||||
&fEditor);
|
|
||||||
if (err != B_OK)
|
|
||||||
fEditor = NULL;
|
|
||||||
} else {
|
|
||||||
fEditor = NULL;
|
|
||||||
}
|
|
||||||
if (fEditor == NULL)
|
|
||||||
return;
|
|
||||||
|
|
||||||
SetLayout(new BGroupLayout(B_HORIZONTAL));
|
|
||||||
const float spacing = be_control_look->DefaultItemSpacing();
|
|
||||||
AddChild(BGroupLayoutBuilder(B_VERTICAL, spacing)
|
|
||||||
.Add(fEditor->View())
|
|
||||||
.AddGroup(B_HORIZONTAL, spacing)
|
|
||||||
.AddGlue()
|
|
||||||
.Add(new BButton(B_TRANSLATE("Cancel"), new BMessage(MSG_CANCEL)))
|
|
||||||
.Add(fOkButton)
|
|
||||||
.End()
|
|
||||||
.SetInsets(spacing, spacing, spacing, spacing)
|
|
||||||
);
|
|
||||||
|
|
||||||
SetDefaultButton(fOkButton);
|
|
||||||
|
|
||||||
// If the partition had a previous name, set to that name.
|
|
||||||
BString name = partition->ContentName();
|
|
||||||
if (name.Length() > 0)
|
|
||||||
fEditor->PartitionNameChanged(name.String());
|
|
||||||
|
|
||||||
AddToSubset(fWindow);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
InitParamsPanel::~InitParamsPanel()
|
InitParametersPanel::~InitParametersPanel()
|
||||||
{
|
{
|
||||||
RemoveCommonFilter(fEscapeFilter);
|
|
||||||
delete fEscapeFilter;
|
|
||||||
|
|
||||||
delete_sem(fExitSemaphore);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool
|
status_t
|
||||||
InitParamsPanel::QuitRequested()
|
InitParametersPanel::Go(BString& name, BString& parameters)
|
||||||
{
|
{
|
||||||
release_sem(fExitSemaphore);
|
status_t status = AbstractParametersPanel::Go(parameters);
|
||||||
return false;
|
if (status == B_OK) {
|
||||||
}
|
void* handle = parse_driver_settings_string(parameters.String());
|
||||||
|
if (handle != NULL) {
|
||||||
|
const char* string = get_driver_parameter(handle, "name",
|
||||||
void
|
NULL, NULL);
|
||||||
InitParamsPanel::MessageReceived(BMessage* message)
|
name.SetTo(string);
|
||||||
{
|
delete_driver_settings(handle);
|
||||||
switch (message->what) {
|
|
||||||
case MSG_CANCEL:
|
|
||||||
Cancel();
|
|
||||||
break;
|
|
||||||
|
|
||||||
case MSG_OK:
|
|
||||||
fReturnValue = GO_SUCCESS;
|
|
||||||
release_sem(fExitSemaphore);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case MSG_NAME_CHANGED:
|
|
||||||
// message comes from fEditor's BTextControl
|
|
||||||
BTextControl* control;
|
|
||||||
if (message->FindPointer("source", (void**)&control) != B_OK)
|
|
||||||
break;
|
|
||||||
if (control->TextView()->TextLength() == 0
|
|
||||||
&& fOkButton->IsEnabled())
|
|
||||||
fOkButton->SetEnabled(false);
|
|
||||||
else if (control->TextView()->TextLength() > 0
|
|
||||||
&& !fOkButton->IsEnabled())
|
|
||||||
fOkButton->SetEnabled(true);
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
BWindow::MessageReceived(message);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
int32
|
|
||||||
InitParamsPanel::Go(BString& name, BString& parameters)
|
|
||||||
{
|
|
||||||
// Without an editor, we cannot change anything, anyway
|
|
||||||
if (fEditor == NULL)
|
|
||||||
return GO_SUCCESS;
|
|
||||||
|
|
||||||
// run the window thread, to get an initial layout of the controls
|
|
||||||
Hide();
|
|
||||||
Show();
|
|
||||||
if (!Lock())
|
|
||||||
return GO_CANCELED;
|
|
||||||
|
|
||||||
// center the panel above the parent window
|
|
||||||
CenterIn(fWindow->Frame());
|
|
||||||
|
|
||||||
Show();
|
|
||||||
Unlock();
|
|
||||||
|
|
||||||
// block this thread now, but keep the window repainting
|
|
||||||
while (true) {
|
|
||||||
status_t err = acquire_sem_etc(fExitSemaphore, 1,
|
|
||||||
B_CAN_INTERRUPT | B_RELATIVE_TIMEOUT, 50000);
|
|
||||||
if (err != B_TIMED_OUT && err != B_INTERRUPTED)
|
|
||||||
break;
|
|
||||||
fWindow->UpdateIfNeeded();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!Lock())
|
|
||||||
return GO_CANCELED;
|
|
||||||
|
|
||||||
if (fEditor == NULL)
|
|
||||||
fReturnValue = B_BAD_VALUE;
|
|
||||||
|
|
||||||
if (fReturnValue == GO_SUCCESS) {
|
|
||||||
if (fEditor->FinishedEditing()) {
|
|
||||||
status_t err = fEditor->GetParameters(¶meters);
|
|
||||||
if (err == B_OK) {
|
|
||||||
void* handle = parse_driver_settings_string(
|
|
||||||
parameters.String());
|
|
||||||
if (handle != NULL) {
|
|
||||||
const char* string = get_driver_parameter(handle, "name",
|
|
||||||
NULL, NULL);
|
|
||||||
name.SetTo(string);
|
|
||||||
delete_driver_settings(handle);
|
|
||||||
}
|
|
||||||
} else
|
|
||||||
fReturnValue = err;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int32 value = fReturnValue;
|
return status;
|
||||||
|
|
||||||
Quit();
|
|
||||||
// NOTE: this object is toast now!
|
|
||||||
|
|
||||||
return value;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
InitParamsPanel::Cancel()
|
|
||||||
{
|
|
||||||
fReturnValue = GO_CANCELED;
|
|
||||||
release_sem(fExitSemaphore);
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,45 +1,27 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2008 Haiku Inc. All rights reserved.
|
* Copyright 2008-2013 Haiku, Inc. All rights reserved.
|
||||||
* Distributed under the terms of the MIT license.
|
* Distributed under the terms of the MIT license.
|
||||||
*
|
*
|
||||||
* Authors:
|
* Authors:
|
||||||
* Stephan Aßmus <superstippi@gmx.de>
|
* Stephan Aßmus <superstippi@gmx.de>
|
||||||
|
* Axel Dörfler, axeld@pinc-software.de.
|
||||||
*/
|
*/
|
||||||
#ifndef INIT_PARAMS_PANEL_H
|
#ifndef INIT_PARAMETERS_PANEL_H
|
||||||
#define INIT_PARAMS_PANEL_H
|
#define INIT_PARAMETERS_PANEL_H
|
||||||
|
|
||||||
#include "Support.h"
|
|
||||||
|
|
||||||
#include <Partition.h>
|
|
||||||
#include <PartitionParameterEditor.h>
|
|
||||||
#include <Window.h>
|
|
||||||
|
|
||||||
class BMenuField;
|
|
||||||
class BTextControl;
|
|
||||||
|
|
||||||
|
|
||||||
class InitParamsPanel : public BWindow {
|
#include "AbstractParametersPanel.h"
|
||||||
|
|
||||||
|
|
||||||
|
class InitParametersPanel : public AbstractParametersPanel {
|
||||||
public:
|
public:
|
||||||
InitParamsPanel(BWindow* window,
|
InitParametersPanel(BWindow* window,
|
||||||
const BString& diskSystem,
|
const BString& diskSystem,
|
||||||
BPartition* partition);
|
BPartition* partition);
|
||||||
virtual ~InitParamsPanel();
|
virtual ~InitParametersPanel();
|
||||||
|
|
||||||
virtual bool QuitRequested();
|
status_t Go(BString& name, BString& parameters);
|
||||||
virtual void MessageReceived(BMessage* message);
|
|
||||||
|
|
||||||
int32 Go(BString& name, BString& parameters);
|
|
||||||
void Cancel();
|
|
||||||
|
|
||||||
private:
|
|
||||||
class EscapeFilter;
|
|
||||||
EscapeFilter* fEscapeFilter;
|
|
||||||
sem_id fExitSemaphore;
|
|
||||||
BWindow* fWindow;
|
|
||||||
BButton* fOkButton;
|
|
||||||
int32 fReturnValue;
|
|
||||||
|
|
||||||
BPartitionParameterEditor* fEditor;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // INIT_PARAMS_PANEL_H
|
|
||||||
|
#endif // INIT_PARAMETERS_PANEL_H
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ AddSubDirSupportedPlatforms libbe_test ;
|
|||||||
UsePrivateHeaders interface shared storage tracker ;
|
UsePrivateHeaders interface shared storage tracker ;
|
||||||
|
|
||||||
Preference DriveSetup :
|
Preference DriveSetup :
|
||||||
|
AbstractParametersPanel.cpp
|
||||||
CreateParamsPanel.cpp
|
CreateParamsPanel.cpp
|
||||||
DiskView.cpp
|
DiskView.cpp
|
||||||
DriveSetup.cpp
|
DriveSetup.cpp
|
||||||
|
|||||||
@@ -882,9 +882,9 @@ MainWindow::_Initialize(BDiskDevice* disk, partition_id selectedPartition,
|
|||||||
|
|
||||||
BString name;
|
BString name;
|
||||||
BString parameters;
|
BString parameters;
|
||||||
InitParamsPanel* panel = new InitParamsPanel(this, diskSystemName,
|
InitParametersPanel* panel = new InitParametersPanel(this, diskSystemName,
|
||||||
partition);
|
partition);
|
||||||
if (panel->Go(name, parameters) == GO_CANCELED)
|
if (panel->Go(name, parameters) != B_OK)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
bool supportsName = diskSystem.SupportsContentName();
|
bool supportsName = diskSystem.SupportsContentName();
|
||||||
@@ -1037,9 +1037,9 @@ MainWindow::_Create(BDiskDevice* disk, partition_id selectedPartition)
|
|||||||
off_t offset = currentSelection->Offset();
|
off_t offset = currentSelection->Offset();
|
||||||
off_t size = currentSelection->Size();
|
off_t size = currentSelection->Size();
|
||||||
|
|
||||||
CreateParamsPanel* panel = new CreateParamsPanel(this, parent, offset,
|
CreateParametersPanel* panel = new CreateParametersPanel(this, parent,
|
||||||
size);
|
offset, size);
|
||||||
if (panel->Go(offset, size, name, type, parameters) == GO_CANCELED)
|
if (panel->Go(offset, size, name, type, parameters) != B_OK)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
ret = parent->ValidateCreateChild(&offset, &size, type.String(),
|
ret = parent->ValidateCreateChild(&offset, &size, type.String(),
|
||||||
|
|||||||
@@ -21,11 +21,6 @@ void dump_partition_info(const BPartition* partition);
|
|||||||
|
|
||||||
bool is_valid_partitionable_space(size_t size);
|
bool is_valid_partitionable_space(size_t size);
|
||||||
|
|
||||||
enum {
|
|
||||||
GO_CANCELED = 0,
|
|
||||||
GO_SUCCESS
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
static const uint32 kMegaByte = 0x100000;
|
static const uint32 kMegaByte = 0x100000;
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
|
* Copyright 2013, Axel Dörfler, axeld@pinc-software.de.
|
||||||
* Copyright 2009, Bryce Groff, brycegroff@gmail.com.
|
* Copyright 2009, Bryce Groff, brycegroff@gmail.com.
|
||||||
* Distributed under the terms of the MIT License.
|
* Distributed under the terms of the MIT License.
|
||||||
*/
|
*/
|
||||||
@@ -10,12 +11,52 @@
|
|||||||
|
|
||||||
|
|
||||||
BPartitionParameterEditor::BPartitionParameterEditor()
|
BPartitionParameterEditor::BPartitionParameterEditor()
|
||||||
|
:
|
||||||
|
fModificationMessage(NULL)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
BPartitionParameterEditor::~BPartitionParameterEditor()
|
BPartitionParameterEditor::~BPartitionParameterEditor()
|
||||||
{
|
{
|
||||||
|
delete fModificationMessage;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*! \brief Sets the controls of the editor to match the parameters
|
||||||
|
of the given \a partition.
|
||||||
|
|
||||||
|
For \c B_CREATE_PARAMETER_EDITOR editors, this will be the parent
|
||||||
|
partition.
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
BPartitionParameterEditor::SetTo(BPartition* partition)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*! \brief Sets the modification message.
|
||||||
|
|
||||||
|
This message needs to be sent whenever an internal parameter changed.
|
||||||
|
This call takes over ownership of the provided message.
|
||||||
|
|
||||||
|
The message may contain a string field "parameter" with the value set
|
||||||
|
to the name of the changed parameter.
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
BPartitionParameterEditor::SetModificationMessage(BMessage* message)
|
||||||
|
{
|
||||||
|
delete fModificationMessage;
|
||||||
|
fModificationMessage = message;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*! \brief The currently set modification message, if any.
|
||||||
|
*/
|
||||||
|
BMessage*
|
||||||
|
BPartitionParameterEditor::ModificationMessage() const
|
||||||
|
{
|
||||||
|
return fModificationMessage;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -40,7 +81,6 @@ BPartitionParameterEditor::View()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// FinishedEditing
|
|
||||||
/*! \brief Called when the user finishes editing the parameters.
|
/*! \brief Called when the user finishes editing the parameters.
|
||||||
|
|
||||||
To be overridden by derived classes.
|
To be overridden by derived classes.
|
||||||
@@ -52,9 +92,31 @@ BPartitionParameterEditor::View()
|
|||||||
\return \c true, if the current parameters are valid, \c false otherwise.
|
\return \c true, if the current parameters are valid, \c false otherwise.
|
||||||
*/
|
*/
|
||||||
bool
|
bool
|
||||||
BPartitionParameterEditor::FinishedEditing()
|
BPartitionParameterEditor::ValidateParameters() const
|
||||||
{
|
{
|
||||||
return false;
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*! \brief Called when a parameter has changed.
|
||||||
|
|
||||||
|
Each editor type comes with a number of predefined parameters that
|
||||||
|
may be changed from the outside while the editor is open. You can
|
||||||
|
either accept the changes, and update your controls correspondingly,
|
||||||
|
or else reject the change by returning an appropriate error code.
|
||||||
|
|
||||||
|
To be overridden by derived classes.
|
||||||
|
The base class version returns B_OK.
|
||||||
|
|
||||||
|
\param name The name of the changed parameter.
|
||||||
|
\param variant The new value of the parameter.
|
||||||
|
\return \c B_OK, if everything went fine, another error code otherwise.
|
||||||
|
*/
|
||||||
|
status_t
|
||||||
|
BPartitionParameterEditor::ParameterChanged(const char* name,
|
||||||
|
const BVariant& variant)
|
||||||
|
{
|
||||||
|
return B_NOT_SUPPORTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -68,43 +130,8 @@ BPartitionParameterEditor::FinishedEditing()
|
|||||||
\return \c B_OK, if everything went fine, another error code otherwise.
|
\return \c B_OK, if everything went fine, another error code otherwise.
|
||||||
*/
|
*/
|
||||||
status_t
|
status_t
|
||||||
BPartitionParameterEditor::GetParameters(BString* parameters)
|
BPartitionParameterEditor::GetParameters(BString& parameters)
|
||||||
{
|
{
|
||||||
status_t error = (parameters ? B_OK : B_BAD_VALUE);
|
parameters.SetTo("");
|
||||||
if (error == B_OK)
|
return B_OK;
|
||||||
parameters->SetTo("");
|
|
||||||
return error;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*! \brief Called when type information has changed.
|
|
||||||
|
|
||||||
To be overridden by derived classes.
|
|
||||||
The base class version returns B_OK.
|
|
||||||
|
|
||||||
\param type A string that is the new type.
|
|
||||||
|
|
||||||
\return \c B_OK, if everything went fine, another error code otherwise.
|
|
||||||
*/
|
|
||||||
status_t
|
|
||||||
BPartitionParameterEditor::PartitionTypeChanged(const char* type)
|
|
||||||
{
|
|
||||||
return B_NOT_SUPPORTED;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*! \brief Called when name information has changed.
|
|
||||||
|
|
||||||
To be overridden by derived classes.
|
|
||||||
The base class version returns B_OK.
|
|
||||||
|
|
||||||
\param name A string that is the new name.
|
|
||||||
|
|
||||||
\return \c B_OK, if everything went fine, another error code otherwise.
|
|
||||||
*/
|
|
||||||
status_t
|
|
||||||
BPartitionParameterEditor::PartitionNameChanged(const char* name)
|
|
||||||
{
|
|
||||||
return B_NOT_SUPPORTED;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user