* 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:
Axel Dörfler
2010-02-19 17:22:54 +00:00
parent a791687e90
commit 7c69435755
3 changed files with 26 additions and 5 deletions
@@ -24,6 +24,7 @@
static uint32 MSG_BLOCK_SIZE = 'blsz'; static uint32 MSG_BLOCK_SIZE = 'blsz';
static uint32 MSG_NAME_CHANGED = 'nmch';
InitializeBFSEditor::InitializeBFSEditor() InitializeBFSEditor::InitializeBFSEditor()
@@ -95,6 +96,7 @@ void
InitializeBFSEditor::_CreateViewControls() InitializeBFSEditor::_CreateViewControls()
{ {
fNameTC = new BTextControl("Name:", "Haiku", NULL); 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 // TODO find out what is the max length for this specific FS partition name
fNameTC->TextView()->SetMaxBytes(31); fNameTC->TextView()->SetMaxBytes(31);
+23 -5
View File
@@ -4,9 +4,10 @@
* *
* Authors: * Authors:
* Stephan Aßmus <[email protected]> * Stephan Aßmus <[email protected]>
* Karsten Heimrich. <[email protected]> * Karsten Heimrich. <[email protected]>
*/ */
#include "InitParamsPanel.h" #include "InitParamsPanel.h"
#include <driver_settings.h> #include <driver_settings.h>
@@ -20,6 +21,7 @@
#include <Message.h> #include <Message.h>
#include <MessageFilter.h> #include <MessageFilter.h>
#include <String.h> #include <String.h>
#include <TextControl.h>
#define TR_CONTEXT "InitParamsPanel" #define TR_CONTEXT "InitParamsPanel"
@@ -67,10 +69,13 @@ private:
// #pragma mark - // #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 { enum {
MSG_OK = 'okok', MSG_OK = 'okok',
MSG_CANCEL = 'cncl', MSG_CANCEL = 'cncl',
MSG_BLOCK_SIZE = 'blsz' MSG_NAME_CHANGED = 'nmch'
}; };
@@ -87,7 +92,7 @@ InitParamsPanel::InitParamsPanel(BWindow* window, const BString& diskSystem,
{ {
AddCommonFilter(fEscapeFilter); 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(), partition->GetInitializationParameterEditor(diskSystem.String(),
&fEditor); &fEditor);
@@ -99,12 +104,12 @@ InitParamsPanel::InitParamsPanel(BWindow* window, const BString& diskSystem,
.AddGroup(B_HORIZONTAL, spacing) .AddGroup(B_HORIZONTAL, spacing)
.AddGlue() .AddGlue()
.Add(new BButton(TR("Cancel"), new BMessage(MSG_CANCEL))) .Add(new BButton(TR("Cancel"), new BMessage(MSG_CANCEL)))
.Add(okButton) .Add(fOkButton)
.End() .End()
.SetInsets(spacing, spacing, spacing, spacing) .SetInsets(spacing, spacing, spacing, spacing)
); );
SetDefaultButton(okButton); SetDefaultButton(fOkButton);
// If the partition had a previous name, set to that name. // If the partition had a previous name, set to that name.
BString name = partition->ContentName(); BString name = partition->ContentName();
@@ -145,6 +150,19 @@ InitParamsPanel::MessageReceived(BMessage* message)
release_sem(fExitSemaphore); release_sem(fExitSemaphore);
break; 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: default:
BWindow::MessageReceived(message); BWindow::MessageReceived(message);
} }
+1
View File
@@ -36,6 +36,7 @@ private:
EscapeFilter* fEscapeFilter; EscapeFilter* fEscapeFilter;
sem_id fExitSemaphore; sem_id fExitSemaphore;
BWindow* fWindow; BWindow* fWindow;
BButton* fOkButton;
int32 fReturnValue; int32 fReturnValue;
BPartitionParameterEditor* fEditor; BPartitionParameterEditor* fEditor;