* Applied patch by idefix that disables the "Initialize" button if the name
field is empty. This is part of ticket #4123. * The message constants should be moved into their own shared header, though; added a TODO for this. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35524 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
a791687e90
commit
7c69435755
|
@ -24,6 +24,7 @@
|
|||
|
||||
|
||||
static uint32 MSG_BLOCK_SIZE = 'blsz';
|
||||
static uint32 MSG_NAME_CHANGED = 'nmch';
|
||||
|
||||
|
||||
InitializeBFSEditor::InitializeBFSEditor()
|
||||
|
@ -95,6 +96,7 @@ void
|
|||
InitializeBFSEditor::_CreateViewControls()
|
||||
{
|
||||
fNameTC = new BTextControl("Name:", "Haiku", NULL);
|
||||
fNameTC->SetModificationMessage(new BMessage(MSG_NAME_CHANGED));
|
||||
// TODO find out what is the max length for this specific FS partition name
|
||||
fNameTC->TextView()->SetMaxBytes(31);
|
||||
|
||||
|
|
|
@ -4,9 +4,10 @@
|
|||
*
|
||||
* Authors:
|
||||
* Stephan Aßmus <superstippi@gmx.de>
|
||||
* Karsten Heimrich. <host.haiku@gmx.de>
|
||||
* Karsten Heimrich. <host.haiku@gmx.de>
|
||||
*/
|
||||
|
||||
|
||||
#include "InitParamsPanel.h"
|
||||
|
||||
#include <driver_settings.h>
|
||||
|
@ -20,6 +21,7 @@
|
|||
#include <Message.h>
|
||||
#include <MessageFilter.h>
|
||||
#include <String.h>
|
||||
#include <TextControl.h>
|
||||
|
||||
|
||||
#define TR_CONTEXT "InitParamsPanel"
|
||||
|
@ -67,10 +69,13 @@ private:
|
|||
// #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_BLOCK_SIZE = 'blsz'
|
||||
MSG_NAME_CHANGED = 'nmch'
|
||||
};
|
||||
|
||||
|
||||
|
@ -87,7 +92,7 @@ InitParamsPanel::InitParamsPanel(BWindow* window, const BString& diskSystem,
|
|||
{
|
||||
AddCommonFilter(fEscapeFilter);
|
||||
|
||||
BButton* okButton = new BButton(TR("Initialize"), new BMessage(MSG_OK));
|
||||
fOkButton = new BButton(TR("Initialize"), new BMessage(MSG_OK));
|
||||
|
||||
partition->GetInitializationParameterEditor(diskSystem.String(),
|
||||
&fEditor);
|
||||
|
@ -99,12 +104,12 @@ InitParamsPanel::InitParamsPanel(BWindow* window, const BString& diskSystem,
|
|||
.AddGroup(B_HORIZONTAL, spacing)
|
||||
.AddGlue()
|
||||
.Add(new BButton(TR("Cancel"), new BMessage(MSG_CANCEL)))
|
||||
.Add(okButton)
|
||||
.Add(fOkButton)
|
||||
.End()
|
||||
.SetInsets(spacing, spacing, spacing, spacing)
|
||||
);
|
||||
|
||||
SetDefaultButton(okButton);
|
||||
SetDefaultButton(fOkButton);
|
||||
|
||||
// If the partition had a previous name, set to that name.
|
||||
BString name = partition->ContentName();
|
||||
|
@ -145,6 +150,19 @@ InitParamsPanel::MessageReceived(BMessage* message)
|
|||
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);
|
||||
}
|
||||
|
|
|
@ -36,6 +36,7 @@ private:
|
|||
EscapeFilter* fEscapeFilter;
|
||||
sem_id fExitSemaphore;
|
||||
BWindow* fWindow;
|
||||
BButton* fOkButton;
|
||||
int32 fReturnValue;
|
||||
|
||||
BPartitionParameterEditor* fEditor;
|
||||
|
|
Loading…
Reference in New Issue